# @purista/core API

This is the main package of PURISTA.

---
Canonical: /handbook/api/modules/_purista_core/
Format: Markdown for agents
---

This is the main package of PURISTA.

Package: `@purista/core`

## Signature

```typescript
@purista/core
```

## Members

### Enumerations

- `enum EBMessageType` — Type of event bridge message
- `enum PuristaSpanName` — Opentelemetry span names used by PURISTA framework
- `enum PuristaSpanTag` — Opentelemetry tags set by PURISTA framework
- `enum StatusCode` — Message and error status codes.
The codes are based on HTTP status codes
- `enum StoreType`

### Classes

- `class AgentQueueBuilder<S>` — Builds an attached PURISTA agent from normal core queue, worker, command,
stream definitions, and a provider-neutral agent manifest.
- `class ClientBuilder` — ClientBuilder to generate clients, based on service definitions.
- `class DefaultLogger`
- `class GenericEventEmitter<T>`
- `class HandledError` — A handled error is an error which is handled or thrown by business logic.
It is wanted to expose it the outside world.
Scenarios are input validation failures or "404 Not Found" errors which should be returned to the caller.
- `class HttpClient<CustomConfig>` — HTTP client with JSON helpers, timeout handling, tracing, metrics, and normalized errors.
- `class Logger`
- `class PuristaMetricsRecorder` — OpenTelemetry API backed PURISTA metrics recorder.
- `class QueueDefinitionBuilder` — Builds a durable queue contract for background work.
- `class QueueWorkerBuilder` — Builds a queue worker definition for one queue.
- `class ScheduleDefinitionBuilder` — Builds a schedule contract for an external scheduler.
- `class StreamDefinitionBuilder<S, C>` — Builds a stream definition for incremental output or aggregate stream results.
- `class SubscriptionConsumerControlError`
- `class UnhandledError` — A unhandled error will be thrown if some error response is returned during invoking a service function
or when the invocation timed out.
This error is not handled by business logic and it is maybe unwanted to expose this error outside.

### Interfaces

- `interface GlobalContext` — Context passed to all submodules
- `interface IEmitter<T>`
- `interface ILogger`
- `interface MemoryMetricRecord` — Deterministic metric record captured by the memory recorder.
- `interface PuristaMetricDefinition<AttributesSchema>` — Declares one framework or application metric.
- `interface PuristaMetricsRecorderInterface` — A provider-neutral recorder used by framework code and metric contexts.
- `interface PuristaMetricsRuntimeOptions` — Runtime metrics options consumed by PURISTA recorders.
- `interface RestClient` — REST API client abstraction for JSON-oriented HTTP calls.
- `interface StreamHandle<Chunk, Final>`
- `interface StreamWriter<Chunk, Final>`
- `interface TransformSchemaObjectOptions`

### Type Aliases

- `type addPrefixToObject = mapped` — Helper for better typescript type.
All keys of given object must start with the given prefix. Otherwise Typescript will complain.
- `type AgentDefinition = void` — Attached agent definition before expansion into service definitions.
- `type AgentExecutionDefinition = { definition: HarnessAgentDefinition<any, any, any>; kind: "harnessAgent" } | { definition: HarnessWorkflowDefinition<any, any, any>; kind: "harnessWorkflow" } | { handler: AgentHandler<Payload, Parameter, Resources, Models, CommandTools, AgentTools, Output, Metrics>; kind: "runFunction" }` — Internal execution definition selected by exactly one agent execution setter.
- `type AgentExecutionKind = "harnessAgent" | "harnessWorkflow" | "runFunction"` — Execution implementation kind used by an attached agent definition.
- `type AgentExecutionPolicy = void` — Queue execution policy applied to the generated agent worker and queue.
- `type AgentHandler = (context: AgentHandlerContext<Payload, Parameter, Resources, Models, CommandTools, AgentTools, Metrics>) => Promise<Output>` — Run function shape accepted by `AgentQueueBuilder.setRunFunction(...)`.
- `type AgentHandlerContext = void` — Context passed to an attached agent run function.
- `type AgentHandlerModelBindings = mapped` — Typed model handles exposed to an agent run function.
- `type AgentHttpExposure = void` — HTTP projection metadata for the generated agent command or stream.
- `type AgentInvokeMap = mapped` — Typed child-agent invocation map exposed at `context.invoke.agents`.
- `type AgentManifest = void` — Provider-neutral manifest describing an attached PURISTA agent.
- `type AgentModelBinding = void` — Declares a model alias required by an attached PURISTA agent.
- `type AgentModelCapability = ModelCapability` — Model capability names supported by `@purista/harness` model bindings.
- `type AgentQueueBuilderTypes = void` — Type accumulator used by `AgentQueueBuilder` to preserve typed schemas, tools, models, and metrics.
- `type AgentQueueResultPolicy = void` — Controls how generated queues persist and/or emit agent worker completion metadata.
- `type AgentQueueResultPolicyMode = "none" | "event" | "state" | "state-and-event"` — Storage or event side effect used for queued agent run results.
- `type AgentResponseMode = "accepted" | "status" | "stream" | "event" | "callback"` — Public response contract exposed by the generated agent command or stream.
- `type AgentResponseModeOptions = void` — Options for long-running agent response contracts.
- `type AgentRunEvent = void` — Harness run event decorated with PURISTA agent identity metadata.
- `type AgentRunIdentity = void` — Stable run identity propagated through attached agent execution events and results.
- `type AgentRunResult = void` — Aggregate result returned by an attached agent runtime.
- `type AgentRuntimeInvocationInput = void` — Aggregate invocation input passed from generated PURISTA definitions into the agent runtime.
- `type AgentRuntimeModelBinding = { capabilities: typeOperator; defaults: ModelDefaults; model: string; provider: ModelProvider; providerOptions: Record<string, unknown> } & Partial<Pick<Binding, "model">>`
- `type AgentRuntimeModelBindings = mapped` — Runtime model bindings keyed by every model alias declared on an agent builder.
- `type AgentRuntimeOptions = void` — Runtime options required to initialize attached agents for a service instance.
- `type AgentRuntimeRef = void` — Mutable runtime reference bound when the owning service instance is created.
- `type AgentRuntimeStreamInvocationInput = AgentRuntimeInvocationInput & { writer: { close: void; fail: void; onCancel: void; write: void } }` — Streaming invocation input passed from generated PURISTA stream definitions into the agent runtime.
- `type AgentSandboxPolicy = void` — Optional sandbox adapter configuration passed through to the agent runtime.
- `type AgentSessionPolicy = { mode: "ephemeral" } | { mode: "conversation"; payloadPath: typeOperator }` — Session behavior used by the harness runtime for each agent run.
- `type AllowedAgentDefinition = void` — Declares one attached agent that this attached agent may call.
- `type AllowedCommandToolDefinition = void` — Declares one service command that an attached agent may call as a typed tool.
- `type AnyAgentQueueBuilderTypes = AgentQueueBuilderTypes<Schema, Schema, Schema, Record<string, unknown>, Record<string, AgentModelBinding>, Record<string, AllowedCommandToolDefinition>, Record<string, AllowedAgentDefinition>, AgentExecutionKind | undefined, PuristaMetricDefinitions>` — Broad agent builder type used where any attached agent definition is accepted.
- `type AttachedAgentDefinition = AgentDefinition<S> & { command: AttachedCoreDefinition & { commandName: string }; queue: AttachedCoreDefinition & { queueName: string }; stream: AttachedCoreDefinition & { streamName: string }; worker: AttachedCoreDefinition & { name: string; queueName: string } }` — Agent plus the generated queue, worker, command, and stream definitions added to a service.
- `type AttachedCoreDefinition = object` — Core definition metadata attached to generated queue, worker, command, and stream artifacts.
- `type AuthCredentials = void` — HTTP authentication information kept in memory by HttpClient.
- `type BrokerHeaderCommandMsg = Prettify<BrokerHeaderCustomMsg & { receiverInstanceId: InstanceId; receiverServiceName: string; receiverServiceTarget: string; receiverServiceVersion: string }>`
- `type BrokerHeaderCommandResponseMsg = Prettify<BrokerHeaderCommandMsg & { receiverInstanceId: InstanceId }>`
- `type BrokerHeaderCustomMsg = void`
- `type ClientBuilderConfig = z.infer<typeof httpClientConfigSchema>`
- `type ClientBuilderEvents = void`
- `type CloudEvent = void`
- `type Command = Prettify<{ correlationId: CorrelationId; messageType: EBMessageType.Command; payload: { parameter: ParameterType; payload: PayloadType }; receiver: EBMessageAddress } & EBMessageBase>` — Command is a event bridge message, which is emitted by sender to event bridge.
The event bridge dispatches the event to the receiver.
A command expects to get a response message from receiver back to sender.
- `type CommandContextMockResult = void`
- `type CommandContextMockServiceClass = T extends CommandDefinitionBuilder<S, any> ? S : ServiceClass`
- `type CommandDefinitionBuilderTypes = void` — Type accumulator used by `CommandDefinitionBuilder` for schemas, hooks, invocations, events, and queues.
- `type CommandDefinitionList = Promise<CommandDefinition<S, any, any, any, any, any, any, any, any, any, any, any, any, any, CommandDefinitionMetadataBase, any>>[]` — Helper type for creating list of service commands to be passed as input to service class
- `type CommandDefinitionListResolved = CommandDefinition<S, any, any, any, any, any, any, any, any, any, any, any, any, any, CommandDefinitionMetadataBase, any>[]`
- `type CommandDefinitionMetadataBase = void`
- `type CommandToolInvokeMap = mapped` — Typed command tool call map exposed at `context.invoke.tools`.
- `type Complete = mapped` — A helper which forces to provide all object keys, even if they are optional.
- `type CompressionMethod = "gzip" | "deflat" | "br" | undefined`
- `type Config = z.infer<typeof configSchema>`
- `type ConfigFull = z.infer<typeof configFullSchema>`
- `type ConfigStoreCacheMap = Map<string, { createdAt: number; value: string }>`
- `type Constructor = (...args: A) => T` — Generic constructor type that preserves argument tuple inference.
- `type ContentType = "application/json" | "application/javascript" | "text/csv" | "text/css" | "text/html" | "text/javascript" | "text/markdown" | "text/plain" | "text/xml" | string` — List of content types for message payloads.
If the content type is other than `application/json`, the message payload must be a string.
It is up to the implementation to extract the content type from the original message and to convert or transform data.
- `type ContextBase = void` — The ContextBase provides is a basic type.
Each context for command function, subscription function and all Hooks and transformers will have at least the properties of this type.
- `type CorrelationId = string` — the correlation id links the command invocation message with the command response message
- `type CreateCommandContextMockInput = void`
- `type CreateCommandTestHarnessOptions = InstanceConfigType<InferCommandHarnessServiceBuilderConfig<TServiceBuilder>> & { eventBridge: EventBridge; queueBridge: QueueBridge }`
- `type CreateStreamContextMockInput = void`
- `type CreateSubscriptionContextMockInput = void`
- `type CustomMessage = Prettify<{ eventName: string; messageType: EBMessageType.CustomMessage; payload: Payload; receiver: EBMessageAddress } & EBMessageBase>` — A custom message is a message which can be used to pass business information.
The producer emits the message without knowledge about any consumer.
The producer does not expect a response from a consumer.
- `type DefaultConfigStoreConfig = Record<string, unknown>`
- `type DefaultEventBridgeConfig = void` — The configuration for the DefaultEventBridge.
- `type DefaultSecretStoreConfig = Record<string, unknown>`
- `type DefaultStateStoreConfig = Record<string, unknown>`
- `type EBMessage = Command | CommandResponse | InfoMessage | CustomMessage | StreamMessage` — EBMessage is some message which is handled by the event bridge.
- `type EBMessageAddress = void` — A event bridge message address describes the sender or receiver of a message.
- `type EBMessageBase = void` — Default fields which are part of any purista message
- `type EBMessageId = string` — Unique id of the event bridge message
- `type EBMessageSenderAddress = Prettify<Omit<EBMessageAddress, "instanceId"> & Required<Pick<EBMessageAddress, "instanceId">>>` — A event bridge message address describes the sender or receiver of a message.
- `type EmitCustomMessageFunction = (eventName: K, payload: EmitList[K], contentType?: ContentType, contentEncoding?: string) => Promise<void>` — Emits the given payload as custom message with the given event name.
- `type EmitSchemaList = mapped`
- `type EmptyObject = object`
- `type ErrorResponsePayload = void` — Error message payload
- `type EventBridgeCapabilityOverrides = Partial<Omit<EventBridgeCapabilities, "consumerFailureHandling">> & { consumerFailureHandling: Partial<EventBridgeCapabilities["consumerFailureHandling"]> }` — Capability overrides accepted by `getEventBridgeMock` for strict reliability tests.
- `type EventBridgeConfig = Prettify<{ defaultCommandTimeout: number; instanceId: string; logger: Logger; logLevel: LogLevelName; metrics: PuristaMetricsRuntimeOptions; metricsRecorder: PuristaMetricsRecorder; ... } & CustomConfig>` — The config object for an event bridge.
Every event bridge implementation must use this type for configuration.
- `type EventKey = string & typeOperator`
- `type EventMap = Record<string, unknown>` — Event payload map where key is the event name and value is the payload type.
- `type EventReceiver = (parameter: T) => void`
- `type ExportAsyncApiOptions = void`
- `type ExportKubernetesCronJobsOptions = void`
- `type ExportRuntimeCapabilitiesOptions = void`
- `type ExportScheduleManifestOptions = void`
- `type FromCloudEventOptions = void`
- `type FromEmitToOtherType = mapped` — Changes the canEmit proxy type to given type
- `type FromInvokeToOtherType = mapped` — Changes the canInvoke proxy type to given type
- `type FullDefinition = void`
- `type FullServiceDefinition = object`
- `type GetMessageParamsType = TransformInputParamsSchema extends Schema ? InferIn<TransformInputParamsSchema> : ParamsSchema extends Schema ? InferIn<ParamsSchema> : unknown`
- `type GetMessagePayloadType = TransformInputPayloadSchema extends Schema ? InferIn<TransformInputPayloadSchema> : PayloadSchema extends Schema ? InferIn<PayloadSchema> : unknown`
- `type HttpClientConfig = Prettify<{ baseUrl: string; basicAuth: { password: string; username: string }; bearerToken: string; defaultHeaders: Record<string, string>; defaultTimeout: number; enableOpentelemetry: boolean; ... } & CustomConfig>` — Basic configuration for HttpClient.
- `type HttpClientRequestOptions = void` — Options for a single HTTP request.
- `type HttpExposedServiceMeta = Prettify<CommandDefinitionMetadataBase & { expose: { http: { method: unknown; mode: unknown; openApi: unknown; path: unknown; stream: unknown } } }>`
- `type HttpExposureOptions = void`
- `type Infer = StandardSchemaV1.InferOutput<TSchema>` — Infers output type from a schema.
- `type InferIn = StandardSchemaV1.InferInput<TSchema>` — Infers input type from a schema.
- `type InferMetricAttributes = Definition extends PuristaMetricDefinition<AttributesSchema> ? AttributesSchema extends Schema ? InferIn<AttributesSchema> : undefined : never` — Infers the attribute input type for a metric definition.
- `type InferOptionalInput = [NonNullable<T>] extends [never] ? unknown : NonNullable<T> extends Schema ? InferIn<NonNullable<T>> : unknown` — Infers an agent tool input schema when one is declared, otherwise falls back to `unknown`.
- `type InferOptionalOutput = [NonNullable<T>] extends [never] ? unknown : NonNullable<T> extends Schema ? Infer<NonNullable<T>> : unknown` — Infers an agent tool output schema when one is declared, otherwise falls back to `unknown`.
- `type InferParameter = S extends Schema ? InferIn<S> : unknown`
- `type InferPayload = S extends Schema ? InferIn<S> : unknown`
- `type InferTypeOrEmptyObject = T extends Schema ? Infer<T> extends EmptyObject ? Infer<T> : EmptyObject : EmptyObject`
- `type InFlightDiagnostics = void`
- `type InFlightExecutionCounts = Record<"command" | "subscription" | "stream" | "generic", number>`
- `type InfoInvokeTimeout = { messageType: EBMessageType.InfoInvokeTimeout } & InfoServiceBase`
- `type InfoInvokeTimeoutPayload = void`
- `type InfoMessage = InfoServiceDrain | InfoServiceFunctionAdded | InfoServiceInit | InfoServiceNotReady | InfoServiceReady | InfoServiceShutdown | InfoInvokeTimeout | InfoSubscriptionError`
- `type InfoMessageType = EBMessageType.InfoServiceDrain | EBMessageType.InfoServiceFunctionAdded | EBMessageType.InfoServiceInit | EBMessageType.InfoServiceNotReady | EBMessageType.InfoServiceReady | EBMessageType.InfoServiceShutdown | EBMessageType.InfoInvokeTimeout | EBMessageType.InfoSubscriptionError`
- `type InfoServiceBase = Prettify<{ contentEncoding: "utf-8"; contentType: "application/json"; payload: unknown } & EBMessageBase>`
- `type InfoServiceDrain = Prettify<{ messageType: EBMessageType.InfoServiceDrain } & InfoServiceBase>`
- `type InfoServiceFunctionAdded = Prettify<{ messageType: EBMessageType.InfoServiceFunctionAdded } & InfoServiceBase>`
- `type InfoServiceInit = Prettify<{ messageType: EBMessageType.InfoServiceInit } & InfoServiceBase>`
- `type InfoServiceNotReady = Prettify<{ messageType: EBMessageType.InfoServiceNotReady } & InfoServiceBase>`
- `type InfoServiceReady = Prettify<{ messageType: EBMessageType.InfoServiceReady } & InfoServiceBase>`
- `type InfoServiceShutdown = Prettify<{ messageType: EBMessageType.InfoServiceShutdown } & InfoServiceBase>`
- `type InfoSubscriptionError = Prettify<{ messageType: EBMessageType.InfoSubscriptionError } & InfoServiceBase>`
- `type InstanceConfigType = Prettify<{ ai: AgentRuntimeOptions<Record<unknown, unknown>>; configStore: ConfigStore; logger: Logger; logLevel: LogLevelName; metrics: PuristaMetricsRuntimeOptions; metricsRecorder: PuristaMetricsRecorder; ... } & typeOperator extends never ? { resources: never } : { resources: unknown[unknown] } & typeOperator extends never ? { serviceConfig: never } : { serviceConfig: unknown[unknown] }>` — Runtime configuration accepted by `ServiceBuilder.getInstance(...)`.
- `type InstanceId = string` — the instance id of the event bridge
- `type InstanceOrType = T extends Constructor ? InstanceType<T> : T`
- `type InvokeFunction = (address: EBMessageAddress, payload: PayloadType, parameter: ParameterType) => Promise<InvokeResponseType>` — Invokes a command and returns the result.
It is recommended to validate the result against a schema which only contains the data you actually need.
- `type InvokeList = Record<string, Record<string, Record<string, { outputSchema: Schema; parameterSchema: Schema; payloadSchema: Schema }>>>`
- `type InvokeValidationMap = object`
- `type IsConstructor = T extends Constructor ? true : false`
- `type JsonRecord = Record<string, unknown>` — JSON object shape used by provider export helpers for provider-native
manifest fragments.
- `type JsonSchemaOptions = void`
- `type KubernetesCronJobManifest = void`
- `type KubernetesCronJobScheduleInput = void`
- `type KubernetesCronJobTriggerTemplate = void`
- `type LogFnParamType = [unknown, optional, rest] | [string, rest]`
- `type LoggerOptions = void`
- `type LoggerStubs = void`
- `type LogLevelName = "info" | "error" | "warn" | "debug" | "trace" | "fatal"`
- `type MetricAttributeArgs = [Attributes] extends [undefined] ? [] : [attributes]` — Method argument tuple for metric attributes.
- `type NeverObject = Record<string, never>`
- `type Newable = (config: ServiceConstructorInput<S>) => T` — Constructor type accepted by `ServiceBuilder.setCustomClass(...)`.
- `type NonEmptyString = "" extends T ? never : T`
- `type ObjectWithKeysFromStringArray = mapped` — Type helper which can create a typed record, based on given string array type.
- `type OpenStreamFunction = (address: EBMessageAddress, payload: PayloadType, parameter: ParameterType) => Promise<StreamHandle<Chunk, Final>>`
- `type PausedQueueWorkerState = void`
- `type PausedSubscriptionConsumerHealthState = PausedSubscriptionConsumerState & { registrationKey: string }`
- `type PausedSubscriptionConsumersByRegistrationKey = Record<string, PausedSubscriptionConsumerState>`
- `type PausedSubscriptionConsumerState = void`
- `type PendigInvocation = void`
- `type Prettify = mapped & object`
- `type PrincipalId = string` — the principal id
- `type PuristaMetricAttributes = Record<string, PuristaMetricAttributeValue>` — Attribute map accepted by PURISTA metrics after low-cardinality policy checks.
- `type PuristaMetricAttributeValue = string | number | boolean` — Scalar metric attribute value accepted by PURISTA.
- `type PuristaMetricContext = mapped` — Typed metric context exposed to handlers.
- `type PuristaMetricContextProperty = void` — Adds the typed PURISTA metric context to a handler context type.
- `type PuristaMetricDefinitions = Record<string, PuristaMetricDefinition<any>>` — Named metric definitions keyed by their metric name.
- `type PuristaMetricHandle = Definition extends { kind: "histogram" } ? { record: void } : { add: void }` — Handler-facing metric handle. Counters use `add`; histograms use `record`.
- `type PuristaMetricKind = "counter" | "upDownCounter" | "histogram"` — Supported PURISTA metric instrument kinds.
- `type PuristaMetricRecord = MemoryMetricRecord`
- `type QueryParameter = void`
- `type QueueContext = void`
- `type QueueDefinitionList = Promise<QueueDefinition>[]`
- `type QueueDefinitionListResolved = QueueDefinition[]`
- `type QueueHealthState = void`
- `type QueueHealthStatus = "ok" | "warn" | "error"`
- `type QueueInvokeClientMap = mapped`
- `type QueueInvokeFunction = (queueName: string, payload: Payload, parameter?: Params, options?: Omit<QueueEnqueueOptions<Payload, Params>, "queueName" | "payload" | "parameter">) => Promise<QueueEnqueueResult>`
- `type QueueInvokeList = Record<string, { parameterSchema: Schema; payloadSchema: Schema }>`
- `type QueueJobStatusRecord = void`
- `type QueueJobStore = void`
- `type QueueLease = void`
- `type QueueResultPolicyDelivery = "required" | "best-effort"` — Delivery requirement for queue result publication.
- `type QueueResultStatus = "success" | "failed" | "cancelled" | "dead-lettered" | "progress"` — Canonical queue result status values.
- `type QueueScheduleFunction = (queueName: string, runAt: Date | number, payload: Payload, parameter?: Params, options?: Omit<QueueEnqueueOptions<Payload, Params>, "queueName" | "payload" | "parameter" | "delayMs">) => Promise<QueueEnqueueResult>`
- `type QueueScheduleProxy = mapped`
- `type QueueWorkerAfterGuardHook = (this: S, context: QueueJobContext<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes>, result: Readonly<QueueHandlerResult | undefined>, message: Readonly<QueueMessage<MessagePayloadType, MessageParamsType>>) => Promise<void>`
- `type QueueWorkerBeforeGuardHook = (this: S, context: QueueJobContext<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes>, message: Readonly<QueueMessage<MessagePayloadType, MessageParamsType>>) => Promise<void>`
- `type QueueWorkerDefinitionList = Promise<QueueWorkerDefinition>[]`
- `type QueueWorkerDefinitionListResolved = QueueWorkerDefinition[]`
- `type QueueWorkerPauseHealthState = PausedQueueWorkerState & { queueName: string }`
- `type QueueWorkerPauseStateByQueue = Record<string, PausedQueueWorkerState>`
- `type RuntimeBridgeCapabilities = void`
- `type RuntimeCapabilityReportMode = "definition-only" | "runtime-inspect"`
- `type ScheduleConcurrencyPolicy = "allow" | "forbid" | "replace"`
- `type ScheduleDefinition = void` — Provider-neutral schedule metadata exported from PURISTA definitions.
- `type ScheduleExpression = { kind: "cron"; timezone: string; value: string } | { everyMs: number; kind: "interval" } | { kind: "oneShot"; runAt: string | number | Date }`
- `type ScheduleManifest = void`
- `type ScheduleMissedRunPolicy = "skip" | "runOnce" | "backfill"`
- `type ScheduleOptions = void`
- `type ScheduleTargetKind = "event" | "queue" | "command"`
- `type Schema = StandardSchemaV1` — Common Standard Schema abstraction used across PURISTA boundaries.
- `type SecretStoreCacheMap = Map<string, { createdAt: number; value: string }>`
- `type ServiceBuilderTypes = void`
- `type ServiceClassMetrics = S extends { __serviceClassTypes: Types } ? Types extends ServiceClassTypes<any, any, Metrics> ? Metrics extends PuristaMetricDefinitions ? Metrics : EmptyObject : EmptyObject : EmptyObject`
- `type ServiceClassTypes = void`
- `type ServiceContractInput = FullDefinition | FullServiceDefinition`
- `type ServiceDefinitions = void`
- `type ServiceHealthState = void`
- `type ServiceHealthStatus = "ok" | "warn" | "error"`
- `type ServiceInfoType = void` — General service information
- `type SetNewTypeValue = mapped`
- `type SetNewTypeValues = mapped`
- `type ShutdownEntry = void` — Entry of thing you like to shutdown gracefully
- `type StoreBaseConfig = Prettify<{ cacheTtl: number; enableCache: boolean; enableGet: boolean; enableRemove: boolean; enableSet: boolean; logger: Logger; ... } & Config>` — Basic configuration object which is used by any store
- `type StreamContextMockResult = void`
- `type StreamContextMockServiceClass = T extends StreamDefinitionBuilder<S, any> ? S : ServiceClass`
- `type StreamControl = Prettify<{ correlationId: CorrelationId; messageType: EBMessageType.Stream; payload: StreamControlPayload; receiver: EBMessageAddress & Required<unknown> } & EBMessageBase>`
- `type StreamControlPayload = void`
- `type StreamDefinition = void`
- `type StreamDefinitionBuilderTypes = void` — Type accumulator used by `StreamDefinitionBuilder` for schemas, invocations, events, and queue access.
- `type StreamDefinitionList = Promise<StreamDefinition<S, any, any, any, any, any, any, any, any, any, any, StreamDefinitionMetadataBase, any>>[]`
- `type StreamDefinitionListResolved = StreamDefinition<S, any, any, any, any, any, any, any, any, any, any, StreamDefinitionMetadataBase, any>[]`
- `type StreamDefinitionMetadataBase = void`
- `type StreamErrorPayload = void`
- `type StreamFrame = Prettify<{ correlationId: CorrelationId; messageType: EBMessageType.Stream; payload: StreamFramePayload<Chunk, Final>; receiver: EBMessageSenderAddress } & EBMessageBase>`
- `type StreamFramePayload = void`
- `type StreamFrameType = "open" | "start" | "chunk" | "complete" | "error" | "cancel" | "heartbeat"`
- `type StreamFunction = (this: S, context: StreamFunctionContext<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes, EmitList, QueueInvokes, ServiceClassMetrics<S>>, payload: Readonly<FunctionPayloadType>, parameter: Readonly<FunctionParamsType>, writer: StreamWriter<ChunkType, FinalType>) => Promise<void>`
- `type StreamFunctionContext = Prettify<ContextBase<Metrics> & PuristaMetricContextProperty<Metrics> & StreamFunctionContextEnhancements<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes, EmitList, QueueInvokes>>`
- `type StreamFunctionContextEnhancements = void`
- `type StreamInvokeList = Record<string, Record<string, Record<string, { chunkSchema: Schema; finalSchema: Schema; parameterSchema: Schema; payloadSchema: Schema; validateChunk: boolean; validateFinal: boolean }>>>`
- `type StreamMessage = StreamOpenRequest | StreamControl | StreamFrame<Chunk, Final>`
- `type StreamOpenRequest = Prettify<{ correlationId: CorrelationId; messageType: EBMessageType.Stream; payload: StreamOpenRequestPayload<PayloadType, ParameterType>; receiver: EBMessageAddress } & EBMessageBase>`
- `type StreamOpenRequestPayload = void`
- `type SubscriptionContextMockResult = void`
- `type SubscriptionContextMockServiceClass = T extends SubscriptionDefinitionBuilder<S, any> ? S : ServiceClass`
- `type SubscriptionDefinitionBuilderTypes = void` — Type accumulator used by `SubscriptionDefinitionBuilder` for schemas, hooks, invocations, events, and queues.
- `type SubscriptionDefinitionList = Promise<SubscriptionDefinition<ServiceClassType, any, any, any, any, any, any, any, any, any, any, any, SubscriptionDefinitionMetadataBase, any>>[]` — Helper type for creating list of service commands to be passed as input to service class
- `type SubscriptionDefinitionListResolved = SubscriptionDefinition<ServiceClassType, any, any, any, any, any, any, any, any, any, any, any, SubscriptionDefinitionMetadataBase, any>[]`
- `type SubscriptionDefinitionMetadataBase = void`
- `type SubscriptionHandlerControlResult = Exclude<SubscriptionHandlerResult, { status: "ack" }>`
- `type SubscriptionHandlerResult = { status: "ack" } | { delayMs: number; reason: string; status: "retry" } | { reason: string; status: "deadLetter" } | { reason: string; status: "drop" } | { reason: string; status: "stop-consumer" }`
- `type SubscriptionStorageEntry = void`
- `type SupportedHttpMethod = "GET" | "POST" | "PATCH" | "PUT" | "DELETE"` — Supported HTTP-Methods for defining endpoints
- `type TenantId = string` — the tenant id
- `type TraceId = string` — The trace id which will be passed through all commands, invocations and subscriptions
- `type ValidationResult = { data: TOutput; success: true } | { issues: ReadonlyArray<StandardSchemaV1.Issue>; success: false }` — Unified validation result shape for all supported schema vendors.

### Variables

- `const CONFIG_FILE_NAME: "purista.client.json"`
- `const configFullSchema: ZodObject<{ buildAs: ZodDefault<ZodLiteral<"esm">>; definitionPath: ZodString; eventBridgeClient: ZodObject<{ clientName: ZodDefault<unknown> }, $strip>; httpClient: ZodObject<{ clientName: ZodDefault<unknown> }, $strip>; outputPath: ZodString; package: ZodOptional<ZodObject<{ description: unknown; name: unknown; private: unknown }, $strip>>; ... }, $strip>`
- `const configSchema: ZodObject<{ buildAs: ZodDefault<ZodLiteral<"esm">>; definitionPath: ZodString; eventBridgeClient: ZodOptional<ZodObject<{ clientName: unknown }, $strip>>; httpClient: ZodOptional<ZodObject<{ clientName: unknown }, $strip>>; outputPath: ZodString; package: ZodOptional<ZodObject<{ description: unknown; name: unknown; private: unknown }, $strip>>; ... }, $strip>`
- `const defaultQueueLifecycleConfig: QueueLifecycleConfig` — Opinionated defaults for queues so builders can omit lifecycle overrides
yet still get resilient behaviour.
- `const eventBridgeClientConfigSchema: ZodObject<{ clientName: ZodDefault<ZodString> }, $strip>`
- `const frameworkMetricDefinitions: { http.client.request.duration: PuristaMetricDefinition<undefined>; http.server.active_requests: PuristaMetricDefinition<undefined>; http.server.request.duration: PuristaMetricDefinition<undefined>; messaging.client.consumed.messages: PuristaMetricDefinition<undefined>; messaging.client.operation.duration: PuristaMetricDefinition<undefined>; messaging.client.sent.messages: PuristaMetricDefinition<undefined>; ... }` — PURISTA framework metric catalog.
- `const httpClientConfigSchema: ZodObject<{ clientName: ZodDefault<ZodString> }, $strip>`
- `const infoMessageTypes: EBMessageType[]`
- `const MIN_CONTENT_SIZE_FOR_COMPRESSION: 1024`
- `const puristaVersion: "3.0.1"` — The PURISTA package version embedded in the published runtime build.
- `const ServiceInfoValidator: { set: void }`

### Functions

- `assertNonArrowFunction(fn: (...args: never[]) => unknown, label: string): void`
- `convertEmitValidationsToSchema<T>(emits: T): Promise<FromEmitToOtherType<T, SchemaObject>>`
- `convertInvokeValidationsToSchema<T>(invokes: T): Promise<FromInvokeToOtherType<T, { outputSchema: SchemaObject; parameterSchema: SchemaObject; payloadSchema: SchemaObject }>>`
- `createInvokeFunctionProxy<TFaux>(invokeOg: InvokeFunction, address?: EBMessageAddress, lvl: number): TFaux`
- `createMemoryMetricsRecorder(options: PuristaMetricsRuntimeOptions): PuristaMetricsRecorder & { records: MemoryMetricRecord[]; clear: void }`
- `createMetricContext<Definitions>(definitions: Definitions, recorder: PuristaMetricsRecorder): PuristaMetricContext<Definitions>`
- `createNoopMetricsRecorder(): PuristaMetricsRecorder`
- `createOpenStreamFunctionProxy<TFaux>(openStreamOg: OpenStreamFunction, address?: EBMessageAddress, lvl: number): TFaux`
- `createQueueEnqueueProxy<TQueues>(enqueueFn: QueueInvokeFunction, queues?: TQueues): QueueInvokeFunction & QueueInvokeClientMap<TQueues>`
- `createQueueScheduleProxy<TQueues>(scheduleFn: QueueScheduleFunction, queues?: TQueues): QueueScheduleFunction & QueueScheduleProxy<QueueInvokeClientMap<TQueues>>`
- `createStateStoreQueueJobStore(stateStore: StateStore, prefix: string): QueueJobStore`
- `exportAsyncApi(options: ExportAsyncApiOptions): Promise<{ asyncapi: string; channels: JsonRecord; components: { messages: JsonRecord; schemas: { PuristaHeaders: { properties: unknown; type: unknown } } }; defaultContentType: string; info: { title: string; version: string }; operations: JsonRecord; ... }>`
- `exportCloudEventsSchema(): { $schema: string; properties: { contentencoding: { type: string }; correlationid: { type: string }; data: boolean; datacontenttype: { type: string }; id: { type: string }; instanceId: { type: string }; ... }; required: string[]; title: string; type: string }`
- `exportKubernetesCronJobs(options: ExportKubernetesCronJobsOptions): Promise<KubernetesCronJobManifest[]>`
- `exportRuntimeCapabilities(options: ExportRuntimeCapabilitiesOptions): { eventBridge: { capabilities: EventBridgeCapabilities | undefined; name: string } | undefined; mode: RuntimeCapabilityReportMode; queueBridge: { capabilities: QueueBridgeCapabilities | undefined; idempotency: { enforced: unknown; exactlyOnce: unknown } | undefined; longRunning: { leaseExtension: unknown; leaseInspection: unknown; strictStartupValidation: unknown } | undefined; name: string; resultPolicies: { event: unknown; state: unknown; stateAndEvent: unknown } | undefined } | undefined; version: string }`
- `exportScheduleManifest(options: ExportScheduleManifestOptions): Promise<ScheduleManifest>`
- `exportServiceDefinitions(serviceBuilders: ServiceBuilder<ServiceBuilderTypes>[]): Promise<FullDefinition>`
- `fromCloudEvent<Payload>(cloudEvent: JsonRecord | CloudEvent, options: FromCloudEventOptions): { contentEncoding: string; contentType: string; correlationId: string; eventName: string; id: string; messageType: CustomMessage; ... }`
- `getCommandFunctionWithValidation<S>(fn: CommandFunction<S, unknown, unknown, unknown, unknown, unknown, any, any, any, any, any>, inputPayloadSchema: Schema | undefined, inputParameterSchema: Schema | undefined, outputPayloadSchema: Schema | undefined, beforeGuards: Record<string, CommandBeforeGuardHook<S, unknown, unknown, unknown, unknown, any, any, any, any, any>>): (this: S, context: { configs: { getConfig: ConfigGetterFunction; removeConfig: ConfigDeleteFunction; setConfig: ConfigSetterFunction }; emit: EmitCustomMessageFunction<any>; logger: Logger; message: Readonly<Command<MessagePayloadType, MessageParamsType>>; metrics: PuristaMetricContext<Metrics>; queue: QueueContext & QueueContext<any>; ... }, payload: unknown, parameter: unknown) => Promise<unknown>`
- `getDefaultEventBridgeConfig(): Complete<DefaultEventBridgeConfig>`
- `getDefaultLogLevel(): LogLevelName`
- `getFrameworkMetricDefinition(name: string): PuristaMetricDefinition<undefined> | undefined`
- `getNewSubscriptionStorageEntry(subscription: Subscription, cb: (message: EBMessage) => Promise<Omit<{ contentEncoding: unknown; contentType: unknown; correlationId: unknown; eventName: unknown; id: unknown; messageType: unknown; ... }, unknown | unknown> | undefined>): SubscriptionStorageEntry`
- `getSubscriptionFunctionWithValidation<S>(fn: SubscriptionFunction<S, unknown, unknown, unknown, any, any, any, any, any>, inputPayloadSchema: Schema | undefined, inputParameterSchema: Schema | undefined, outputPayloadSchema: Schema | undefined, beforeGuards: Record<string, SubscriptionBeforeGuardHook<S, unknown, unknown, any, any, any, any, any>>): (this: S, context: { configs: { getConfig: ConfigGetterFunction; removeConfig: ConfigDeleteFunction; setConfig: ConfigSetterFunction }; emit: EmitCustomMessageFunction<any>; logger: Logger; message: Readonly<EBMessage>; metrics: PuristaMetricContext<Metrics>; queue: QueueContext & QueueContext<any>; ... }, payload: unknown, parameter: unknown) => Promise<unknown>`
- `getTimeoutPromise<T>(fn: Promise<T>, ttl: number): Promise<T>`
- `initDefaultConfigStore(options: { logger: Logger }): DefaultConfigStore`
- `initDefaultSecretStore(options: { logger: Logger }): DefaultSecretStore`
- `initDefaultStateStore(options: { logger: Logger }): DefaultStateStore`
- `initLogger(level: LogLevelName, opt?: LoggerOptions<never, boolean>): Logger`
- `isAllowedMetricAttributeKey(key: string): boolean`
- `isCustomMessage(message: EBMessage): message`
- `isHttpExposedServiceMeta(input?: unknown): input`
- `isInfoMessage(message: EBMessage): message`
- `isInfoServiceFunctionAdded(message: EBMessage): message`
- `isMessageMatchingSubscription(_log: Logger, message: EBMessage, subscription: SubscriptionStorageEntry): boolean`
- `isStreamControl(message: StreamMessage): message`
- `isStreamFrame<Chunk, Final>(message: StreamMessage<Chunk, Final>): message`
- `isStreamMessage(message: EBMessage): message`
- `isStreamOpenRequest(message: StreamMessage): message`
- `isSubscriptionConsumerControlError(value: unknown): value`
- `isSubscriptionHandlerControlResult(value: unknown): value`
- `isSubscriptionHandlerResult(value: unknown): value`
- `mergeMetricAttributes(defaultAttributes?: PuristaMetricAttributes, attributes?: PuristaMetricAttributes): { attributes: PuristaMetricAttributes; droppedAttributeKeys: string[] }`
- `mergeServiceDefinition<T>(existing: FullServiceDefinition, definitionToAdd: ServiceDefinitions): T`
- `safeBind<ThisType, Args, ReturnType>(fn: (this: ThisType, ...args: Args) => ReturnType, thisArg: ThisType): (...args: Args) => ReturnType`
- `schemaObjectToTsType(schemaObject: SchemaObject | ReferenceObject, options?: Partial<GlobalContext>): string`
- `throwIfNotValidMessage(input: unknown): void`
- `toCloudEvent<Payload>(message: { contentEncoding: string; contentType: string; correlationId: string; eventName: string; id: string; messageType: CustomMessage; ... }): CloudEvent`
- `toJSONSchema(schema: Schema, options?: JsonSchemaOptions): Promise<SchemaObject>`
- `transformSchemaObject(schemaObject: SchemaObject | ReferenceObject, ctx: GlobalContext, path: string): string`
- `validate<TSchema>(schema: TSchema, value: unknown): Promise<ValidationResult<Infer<TSchema>>>`
- `validateMetricAttributes(attributes?: Record<string, unknown>): { attributes: PuristaMetricAttributes; droppedAttributeKeys: string[] }`
- `validateMetricDefinition(name: string, definition: PuristaMetricDefinition<any>, knownMetricNames: Iterable<string>): Promise<void>`
- `validateMetricDefinitions(definitions: Record<string, PuristaMetricDefinition<any>>): Promise<void>`

### Command

- `class CommandDefinitionBuilder<S, C>` — Command definition builder is a helper to create and define a command for a service.
It helps to set all needed information like schemas and hooks.
With these information, the types are automatically set and extended.
- `type CommandAfterGuardHook = (this: S, context: CommandFunctionContext<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes, EmitList, QueueInvokes>, result: Readonly<FunctionOutputType>, originalPayload: Readonly<FunctionPayloadType>, originalParameter: Readonly<FunctionParamsType>) => Promise<void>` — Definition of after guard hook functions.
This guard is called after function successfully returns and after output validation.
- `type CommandBeforeGuardHook = (this: S, context: CommandFunctionContext<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes, EmitList, QueueInvokes>, payload: Readonly<FunctionPayloadType>, parameter: Readonly<FunctionParamsType>) => Promise<void>` — Guard is called after command function input validation and before executing the command function.
The guard is usefull to separate for example auth checks from business logic.
It should throw HandledError or return void.
- `type CommandDefinition = void` — The definition for a command provided by some service.
- `type CommandErrorResponse = Prettify<{ contentEncoding: "utf-8"; contentType: "application/json"; correlationId: CorrelationId; isHandledError: boolean; messageType: EBMessageType.CommandErrorResponse; payload: { data: unknown; message: string; status: StatusCode }; ... } & EBMessageBase>` — CommandErrorResponse is a response to a specific previously received command which indicates some failure.
- `type CommandFunction = (this: S, context: CommandFunctionContext<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes, EmitList, QueueInvokes, ServiceClassMetrics<S>>, payload: Readonly<FunctionPayloadType>, parameter: Readonly<FunctionParamsType>) => Promise<FunctionOutputType>` — CommandFunction is a function which will be triggered when a matching event bridge message is received by the service
- `type CommandFunctionContext = Prettify<ContextBase<Metrics> & PuristaMetricContextProperty<Metrics> & CommandFunctionContextEnhancements<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes, EmitList, QueueInvokes>>` — The command function context which will be passed into command function.
- `type CommandFunctionContextEnhancements = void` — It provides the original command message with types for payload and parameter.
Also, the methods:
- `type CommandResponse = CommandSuccessResponse<T> | CommandErrorResponse` — CommandResponse is a response to a specific previously received command which can be either a success or failure
- `type CommandSuccessResponse = Prettify<{ correlationId: CorrelationId; messageType: EBMessageType.CommandSuccessResponse; payload: PayloadType; receiver: EBMessageSenderAddress } & EBMessageBase>` — CommandSuccessResponse is a response to a specific previously received command.
It indicates that the command was executed successfully and contains the result payload
- `type CommandTransformFunctionContext = Prettify<ContextBase & { message: Readonly<Command<unknown, unknown>>; resources: Resources }>`
- `type CommandTransformInputHook = (this: S, context: CommandTransformFunctionContext<MessagePayloadType, MessageParamsType, Resources>, payload: Readonly<TransformInputPayload>, parameter: Readonly<TransformInputParams>) => Promise<{ parameter: FunctionParamsType; payload: FunctionPayloadType }>` — The command transform gets the raw message payload and parameter input, which is validated against the transform input schemas.
The command transform function is called before guard hooks and before the actual command function.
- `type CommandTransformOutputHook = (this: S, context: CommandTransformFunctionContext<MessagePayloadType, MessageParamsType, Resources>, input: Readonly<FinalFunctionOutputType>, params: Readonly<FunctionParamsType>) => Promise<TransformOutputHookOutput>` — This transform hook is executed after function output validation and AfterGuardHooks.
- `isCommand(message: EBMessage): message`
- `isCommandErrorResponse(message: unknown): message`
- `isCommandResponse(message: EBMessage): message`
- `isCommandSuccessResponse(message: EBMessage): message`

### Event bridge

- `enum EventBridgeCommandTransport` — Command request/response transport strategy used by an event bridge.
- `enum EventBridgeLateResponseHandling` — Policy for command responses that arrive after invocation timeout.
- `enum EventBridgeResponseConfirmationLevel` — Confirmation level available for command responses.
- `enum EventBridgeStreamLateFrameHandling` — Policy for stream frames that arrive after stream timeout.
- `class DefaultEventBridge` — Process-local in-memory event bridge for development and tests.
- `class EventBridgeBaseClass<ConfigType>` — The base class to be extended by event bridge implementations
- `class InFlightExecutionTracker` — Tracks active event bridge handler promises for drain and health reporting.
- `class PendingInvocationRegistry<T>` — Registry for command invocations awaiting correlated responses.
- `class PendingStreamRegistry<Chunk, Final>` — Registry for stream invocations awaiting correlated frames.
- `interface EventBridge` — Event transport adapter contract used by PURISTA services.
- `type DefinitionEventBridgeConfig = void` — Event bridge delivery requirements requested by command, stream, or subscription definitions.
- `type DefinitionEventBridgeConsumerFailureHandling = void` — Advisory failure handling for broker-backed consumers such as subscriptions.
- `type DefinitionEventBridgeConsumerFailureMode = "strict" | "best-effort"` — Startup behavior when requested consumer failure semantics are unsupported.
- `type EventBridgeCapabilities = void` — Capability matrix reported by an EventBridge.
- `type EventBridgeCommandCapabilities = void` — Command reliability capabilities for an event bridge.
- `type EventBridgeConsumerFailureCapabilities = void` — Subscription consumer failure capabilities for an event bridge.
- `type EventBridgeInFlightExecutionCounts = Record<InFlightExecutionKind, number>` — In-flight execution counts grouped by work kind.
- `type EventBridgeStreamCapabilities = void` — Stream transport capabilities for an event bridge.
- `type InFlightExecutionKind = "command" | "subscription" | "stream" | "generic"` — Work kind tracked during event bridge drain and diagnostics.
- `type PendingInvocation = void` — Internal pending command invocation callbacks and timeout handle.
- `type PendingStreamSession = void` — Mutable stream session stored for one pending stream invocation.
- `type PushResult = "accepted" | "late" | "missing"` — Result of routing a stream frame or error to a pending stream session.
- `getCommandQueueName(address: EBMessageAddress): string`

### Helper

- `convertToCamelCase(str: string): string`
- `convertToKebabCase(str: string): string`
- `convertToPascalCase(str: string): string`
- `convertToSnakeCase(str: string): string`
- `createErrorResponse(instanceId: string, originalEBMessage: Readonly<Command>, statusCode: StatusCode, error?: unknown): Readonly<Omit<CommandErrorResponse, "instanceId">>`
- `createInfoMessage(messageType: InfoMessageType, sender: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string }, additional?: Partial<InfoMessage>): InfoMessage`
- `createSuccessResponse<T>(instanceId: string, originalEBMessage: Readonly<Command>, payload: T, eventName?: string, contentType: string, contentEncoding: string): Readonly<CommandSuccessResponse<T>>`
- `deserializeOtp(logger: Logger, otp?: string): Context | undefined`
- `getCleanedMessage(message: Readonly<EBMessage>, stripeOutContent: boolean): Record<string, unknown>`
- `getErrorMessageForCode(code: StatusCode): string`
- `getNewCorrelationId(): string`
- `getNewEBMessageId(): string`
- `getNewInstanceId(): string`
- `getNewTraceId(): string`
- `getSubscriptionQueueName(address: EBMessageAddress): string`
- `getUniqueId(): string`
- `gracefulShutdown(logger: Logger, list: ShutdownEntry[], timeoutMs: number): void`
- `isDevelop(): boolean`
- `serializeOtp(): string`

### Queue

- `type DefinitionQueueBridgeConfig = void` — Queue bridge delivery requirements requested by the service definition.
- `type EventToQueueBindingDefinition = void` — Binds an emitted event to a queue enqueue operation.
- `type EventToQueueIdempotencyMode = "advisory" | "strict"` — Idempotency requirement for event-to-queue bindings.
- `type EventToQueueIdempotencyStrategy = "messageId" | "correlationId" | "eventField" | "none" | (event: any) => string | undefined` — Strategy used to derive an idempotency key from the source event.
- `type QueueDefinition = void` — Public definition of a queue contract attached to a PURISTA service.
- `type QueueEnqueueOptions = void` — Options passed to a queue bridge when enqueueing work.
- `type QueueExecutionProfileName = "longRunning"` — Named execution profile for queue workers.
- `type QueueHandlerResult = { headers: Record<string, string>; output: unknown; status: "success" } | { delayMs: number; reason: string; status: "retry" } | { delayMs: number; fatal: boolean; reason: string; status: "fail" }` — Result returned by a queue worker handler.
- `type QueueJobContext = ContextBase<Metrics> & PuristaMetricContextProperty<Metrics> & { emit: EmitCustomMessageFunction<EmitList>; job: QueueJobControls; message: Readonly<QueueMessage<MessagePayloadType, MessageParamsType>>; queue: QueueContext<QueueInvokes>; resources: Resources; service: Invokes; ... }` — Context object passed to queue worker handlers.
- `type QueueJobControls = void` — Runtime controls available to a queue worker for the currently leased job.
- `type QueueLifecycleConfig = void` — Queue retry, leasing, heartbeat, and poison-message policy.
- `type QueueLongRunningExecutionProfile = void` — Runtime policy for work that may exceed a normal lease interval.
- `type QueueMessage = void` — Provider-neutral queue message shape used by bridges and workers.
- `type QueueMetrics = void` — Queue operational metrics returned by a bridge.
- `type QueueOrderingGuarantee = "none" | "fifo" | "partition"` — Ordering guarantee requested by a queue definition.
- `type QueueResultEventIdStrategy = "jobIdAndStatus" | (input: { attempt: number; jobId: string; queueName: string; status: QueueResultStatus }) => string` — Strategy used to generate result event ids.
- `type QueueResultEventPayload = void` — Payload emitted for queue result events.
- `type QueueResultPolicy = void` — Controls how queue worker outcomes are persisted or emitted.
- `type QueueResultPolicyMode = "none" | "event" | "state" | "state-and-event"` — Queue result publication mode.
- `type QueueRetryStrategy = void` — Exponential backoff settings for queue retries.
- `type QueueTransformContext = ContextBase & { resources: Resources }` — Context passed to queue transform hooks.
- `type QueueTransformHook = (this: S, context: QueueTransformContext<Resources>, payload: Readonly<Payload>, parameter: Readonly<Params | undefined>) => Promise<{ parameter: Params; payload: Payload }>` — Hook that can normalize queue payload and parameters before enqueue or execute.
- `type QueueWorkerDefinition = void` — Public definition of a worker attached to a queue.
- `type QueueWorkerHandler = (context: QueueJobContext<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes, EmitList, QueueInvokes, Metrics>, message: QueueMessage<MessagePayloadType, MessageParamsType>) => Promise<QueueHandlerResult | undefined>` — Function that processes one leased queue message.
- `type QueueWorkerMode = "continuous" | "interval" | "sequential"` — Queue worker polling mode.

### Queue bridge

- `class DefaultQueueBridge` — In-memory queue bridge for development and unit tests.
- `interface QueueBridge` — Queue transport adapter contract used by PURISTA services and queue workers.
- `type DefaultQueueBridgeOptions = void` — Configuration for the process-local DefaultQueueBridge.
- `type QueueBridgeCapabilities = void` — Capability matrix reported by a QueueBridge.
- `type QueueDeadLetterListOptions = void` — Pagination options for dead-letter and lease inspection APIs.
- `type QueueDeadLetterRedriveOptions = void` — Options for moving dead-letter messages back to the live queue.
- `type QueueEnqueueResult = void` — Metadata returned after a message has been accepted for queue delivery.
- `type QueueLeaseInspectionRecord = void` — Diagnostic view of an active queue lease.
- `type QueueLeaseOptions = void` — Options used when leasing work from a queue.
- `type QueueRetryRequest = void` — Retry request returned to a queue bridge when work should run again.

### Schema

- `type OpenApiZodAny = ZodType & { metaOpenApi: SchemaObject | SchemaObject[] }` — Zod schema augmented with PURISTA OpenAPI metadata.
- `extendApi<TSchema>(schema: TSchema, meta: SchemaObject | SchemaObject[]): TSchema`
- `validationToSchema<T>(schema?: T): Promise<SchemaObject | undefined>`

### Service

- `class Service<S>` — Base class for all services.
This class provides base functions to work with the event bridge, logging and so on
- `class ServiceBuilder<S>` — This class is used to build a service.
- `interface ServiceClass<S>` — The ServiceClass interface
- `type ServiceConstructorInput = void`

### Store

- `class ConfigStoreBaseClass<ConfigStoreConfigType>` — Base class for config store adapters.
- `class DefaultConfigStore` — Process-local in-memory config store for development and tests.
- `class DefaultSecretStore` — Process-local in-memory secret store for development and tests.
- `class DefaultStateStore` — Process-local in-memory state store for development and tests.
- `class SecretStoreBaseClass<SecretStoreConfigType>` — Base class for secret store adapters.
- `class StateStoreBaseClass<StateStoreConfigType>` — Base class for state store implementations.
- `interface ConfigStore` — Interface definition for config store adapters
- `interface SecretStore` — Interface definition for a secret store implementation
- `interface StateStore` — Interface definition for state store implementations
- `type ConfigDeleteFunction = (configName: string) => Promise<void>` — delete a config value from the config store
- `type ConfigGetterFunction = (...configNames: ConfigNames) => Promise<ObjectWithKeysFromStringArray<ConfigNames>>` — get a config value from the config store
- `type ConfigSetterFunction = (configName: string, configValue: unknown) => Promise<void>` — set a config value in the config store
- `type SecretDeleteFunction = (secretName: string) => Promise<void>` — delete a secret from the secret store
- `type SecretGetterFunction = (...secretNames: SecretNames) => Promise<ObjectWithKeysFromStringArray<SecretNames, string | undefined>>` — get a secret from the secret store
- `type SecretSetterFunction = (secretName: string, secretValue: string) => Promise<void>` — set a secret in the secret store
- `type StateDeleteFunction = (stateName: string) => Promise<void>` — delete a state value from the state store
- `type StateGetterFunction = (...stateNames: StateNames) => Promise<ObjectWithKeysFromStringArray<StateNames>>` — get a state value from the state store
- `type StateSetterFunction = (stateName: string, stateValue: unknown) => Promise<void>` — set a state value in the state store

### Stream

- `type StreamAfterGuardHook = (this: S, context: StreamFunctionContext<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes, EmitList, QueueInvokes>, result: Readonly<FunctionFinalType>, originalPayload: Readonly<FunctionPayloadType>, originalParameter: Readonly<FunctionParamsType>) => Promise<void>` — Guard called after a stream completes successfully and the final payload has
been validated.
- `type StreamBeforeGuardHook = (this: S, context: StreamFunctionContext<MessagePayloadType, MessageParamsType, Resources, Invokes, StreamInvokes, EmitList, QueueInvokes>, payload: Readonly<FunctionPayloadType>, parameter: Readonly<FunctionParamsType>) => Promise<void>` — Guard called after stream input validation and before the stream handler runs.

### Subscription

- `class SubscriptionDefinitionBuilder<S, C>` — Subscription definition builder is a helper to create and define a subscriptions for a service.
It helps to set all needed filters.
- `type Subscription = void` — A subscription managed by the event bridge
- `type SubscriptionAfterGuardHook = (this: ServiceClassType, context: SubscriptionFunctionContext<Resources, Invokes, StreamInvokes, EmitList, QueueInvokes>, result: Readonly<FunctionResultType>, payload: Readonly<FunctionPayloadOutputType>, parameter: Readonly<FunctionParameterType>) => Promise<void>` — Definition of after guard hook functions.
This guard is called after function successfully returns and after output validation.
- `type SubscriptionBeforeGuardHook = (this: S, context: SubscriptionFunctionContext<Resources, Invokes, StreamInvokes, EmitList, QueueInvokes>, payload: Readonly<FunctionPayloadType>, parameter: Readonly<FunctionParamsType>) => Promise<void>` — Guard is called after command function input validation and before executing the command function.
The guard is usefull to separate for example auth checks from business logic.
It should throw HandledError or return void.
- `type SubscriptionDefinition = void` — The definition for a subscription provided by some service.
- `type SubscriptionFunction = (this: ServiceClassType, context: SubscriptionFunctionContext<Resources, Invokes, StreamInvokes, EmitList, QueueInvokes, ServiceClassMetrics<ServiceClassType>>, payload: Readonly<FunctionPayloadType>, parameter: Readonly<FunctionParamsType>) => Promise<FunctionOutputType | SubscriptionHandlerResult>` — CommandFunction is a function which will be triggered when a matching event bridge message is received by the service
- `type SubscriptionFunctionContext = Prettify<ContextBase<Metrics> & PuristaMetricContextProperty<Metrics> & SubscriptionFunctionContextEnhancements<Resources, Invokes, StreamInvokes, EmitList, QueueInvokes>>` — The subscription function context which will be passed into subscription function.
- `type SubscriptionFunctionContextEnhancements = void` — It provides the original command message.
Also, the methods:
- `type SubscriptionTransformFunctionContext = Prettify<ContextBase & { message: Readonly<EBMessage>; resources: Resources }>`
- `type SubscriptionTransformInputHook = (this: S, context: SubscriptionTransformFunctionContext, payload: Readonly<TransformInputPayload>, parameter: Readonly<TransformInputParams>) => Promise<{ parameter: Readonly<FunctionParamsType>; payload: Readonly<FunctionPayloadType> }>`
- `type SubscriptionTransformOutputHook = (this: S, context: SubscriptionTransformFunctionContext, payload: Readonly<FinalFunctionOutputType>, parameter: Readonly<FunctionParamsType>) => Promise<TransformOutputHookOutput>` — This transform hook is executed after function output validation and AfterGuardHooks.

### Unit test helper

- `type CommandContextMockBuilderTypes = T extends CommandDefinitionBuilder<any, C> ? C : never` — Infer the internal builder type configuration from a command builder.
- `type CreateQueueWorkerContextMockInput = void` — Input for createQueueWorkerContextMock.
- `type InferCommandBuilderConfig = T extends CommandDefinitionBuilder<any, C> ? C : never` — Infer the definition config type from a command builder.
- `type InferCommandHarnessServiceBuilderConfig = T extends ServiceBuilder<S> ? S : never` — Infer the instance config type from a service builder.
- `type InferQueueWorkerHarnessServiceBuilderConfig = T extends ServiceBuilder<S> ? S : never` — Infer the instance config type from a service builder.
- `type InferStreamBuilderConfig = T extends StreamDefinitionBuilder<any, C> ? C : never` — Infer the definition config type from a stream builder.
- `type InferStreamHarnessServiceBuilderConfig = T extends ServiceBuilder<S> ? S : never` — Infer the instance config type from a service builder.
- `type QueueWorkerContextMockResult = void` — Result returned by createQueueWorkerContextMock.
- `type StreamContextMockBuilderTypes = T extends StreamDefinitionBuilder<any, C> ? C : never` — Infer the internal builder type configuration from a stream builder.
- `type SubscriptionContextMockBuilderTypes = T extends SubscriptionDefinitionBuilder<any, C> ? C : never` — Infer the internal builder type configuration from a subscription builder.
- `createCommandContextMock<TBuilder>(builder: TBuilder, input: CreateCommandContextMockInput<TBuilder>): CommandContextMockResult<TBuilder>`
- `createCommandTestHarness<TServiceBuilder, TCommandBuilder>(serviceBuilder: TServiceBuilder, commandBuilder: TCommandBuilder, options: CreateCommandTestHarnessOptions<TServiceBuilder>): Promise<{ destroy: () => Promise<void>; eventBridge: EventBridge; run: (input: { parameter: InferIn<InferCommandBuilderConfig<TCommandBuilder>["ParamsSchema"]>; payload: InferIn<InferCommandBuilderConfig<TCommandBuilder>["PayloadSchema"]> }) => Promise<{ message: unknown; result: unknown }>; service: Service<ServiceClassTypes<EmptyObject, EmptyObject>>; stubs: { eventBridge: Record<unknown, unknown> | undefined } }>`
- `createQueueWorkerContextMock<Payload, Parameter, Resources>(_builder: QueueWorkerBuilder, input: CreateQueueWorkerContextMockInput<Payload, Parameter, Resources>): QueueWorkerContextMockResult<Payload, Parameter, Resources>`
- `createQueueWorkerTestHarness<TServiceBuilder>(serviceBuilder: TServiceBuilder, workerBuilder: QueueWorkerBuilder, options: mapped & { eventBridge: EventBridge; queueBridge: QueueBridge }): Promise<{ destroy: () => Promise<void>; eventBridge: EventBridge; queueBridge: QueueBridge; run: (message: QueueMessage<Payload, Parameter>) => Promise<{ ackCalls: unknown; deadLetterCalls: unknown; extendLeaseCalls: unknown; nackCalls: unknown }>; service: Service<ServiceClassTypes<EmptyObject, EmptyObject>>; stubs: { eventBridge: Record<unknown, unknown> | undefined; queueBridge: Record<unknown, unknown> | undefined } }>`
- `createStreamContextMock<TBuilder>(builder: TBuilder, input: CreateStreamContextMockInput<TBuilder>): StreamContextMockResult<TBuilder>`
- `createStreamTestHarness<TServiceBuilder, TStreamBuilder>(serviceBuilder: TServiceBuilder, streamBuilder: TStreamBuilder, options: mapped & { eventBridge: EventBridge }): Promise<{ destroy: () => Promise<void>; eventBridge: EventBridge; run: (input: { parameter: InferIn<InferStreamBuilderConfig<TStreamBuilder>["ParamsSchema"]>; payload: InferIn<InferStreamBuilderConfig<TStreamBuilder>["PayloadSchema"]> }) => Promise<{ chunks: unknown; final: unknown; frames: unknown }>; service: Service<ServiceClassTypes<EmptyObject, EmptyObject>>; stubs: { eventBridge: Record<unknown, unknown> | undefined } }>`
- `createSubscriptionContextMock<TBuilder>(builder: TBuilder, input: CreateSubscriptionContextMockInput<TBuilder>): SubscriptionContextMockResult<TBuilder>`
- `getCommandErrorMessageMock(error?: HandledError | UnhandledError, input?: Partial<{ contentEncoding: "utf-8"; contentType: "application/json"; correlationId: string; eventName: string; id: string; isHandledError: boolean; ... }>, commandMessage?: { contentEncoding: string; contentType: string; correlationId: string; eventName: string; id: string; messageType: Command; ... }): Readonly<CommandErrorResponse>`
- `getCommandMessageMock<Payload, Parameter>(input?: Partial<{ contentEncoding: string; contentType: string; correlationId: string; eventName: string; id: string; messageType: Command; ... }> & { payload: { parameter: Parameter; payload: Payload } }): Readonly<Command<Payload, Parameter>>`
- `getCommandSuccessMessageMock<PayloadType>(payload: PayloadType, input?: Partial<{ contentEncoding: string; contentType: string; correlationId: string; eventName: string; id: string; messageType: CommandSuccessResponse; ... }>, commandMessage?: { contentEncoding: string; contentType: string; correlationId: string; eventName: string; id: string; messageType: Command; ... }): Readonly<CommandSuccessResponse<PayloadType>>`
- `getCommandTransformContextMock<MessagePayloadType, MessageParamsType, Resources>(input: { parameter: MessageParamsType; payload: MessagePayloadType; resources: Partial<Resources>; sandbox: SinonSandbox }): { mock: { configs: { getConfig: ConfigGetterFunction; removeConfig: ConfigDeleteFunction; setConfig: ConfigSetterFunction }; logger: Logger; message: Readonly<Command<PayloadType, ParameterType>>; metrics: PuristaMetricContext<Metrics>; queue: QueueContext; resources: Resources; ... }; stubs: { enqueue: SinonStub<any[], any>; getConfig: SinonStub<any[], any>; getSecret: SinonStub<any[], any>; getState: SinonStub<any[], any>; logger: { debug: SinonStub<unknown[], any>; error: SinonStub<unknown[], any>; fatal: SinonStub<unknown[], any>; info: SinonStub<unknown[], any>; trace: SinonStub<unknown[], any>; warn: SinonStub<unknown[], any> }; removeConfig: SinonStub<any[], any>; ... } }`
- `getCustomMessageMessageMock<PayloadType>(eventName: string, payload: PayloadType, input?: Partial<{ contentEncoding: string; contentType: string; correlationId: string; eventName: string; id: string; messageType: CustomMessage; ... }>): Readonly<CustomMessage<PayloadType>>`
- `getEventBridgeMock(sandboxOrOptions?: SinonSandbox | { capabilities: EventBridgeCapabilityOverrides; sandbox: SinonSandbox }): { mock: EventBridge; stubs: Record<string, SinonStub> }`
- `getLoggerMock(sandbox?: SinonSandbox): { mock: Logger; stubs: { debug: SinonStub<any[], any>; error: SinonStub<any[], any>; fatal: SinonStub<any[], any>; info: SinonStub<any[], any>; trace: SinonStub<any[], any>; warn: SinonStub<any[], any> } }`
- `getQueueBridgeMock(sandboxOrOptions?: SinonSandbox | { capabilities: Partial<QueueBridgeCapabilities>; sandbox: SinonSandbox }): { mock: QueueBridge; stubs: Record<string, SinonStub> }`
- `getSubscriptionTransformContextMock<Resources>(input: { message: EBMessage; resources: Partial<Resources>; sandbox: SinonSandbox }): { mock: { configs: { getConfig: ConfigGetterFunction; removeConfig: ConfigDeleteFunction; setConfig: ConfigSetterFunction }; logger: Logger; message: Readonly<EBMessage>; metrics: PuristaMetricContext<Metrics>; queue: QueueContext; resources: EmptyObject; ... }; stubs: { enqueue: SinonStub<any[], any>; getConfig: SinonStub<any[], any>; getSecret: SinonStub<any[], any>; getState: SinonStub<any[], any>; logger: { debug: SinonStub<unknown[], any>; error: SinonStub<unknown[], any>; fatal: SinonStub<unknown[], any>; info: SinonStub<unknown[], any>; trace: SinonStub<unknown[], any>; warn: SinonStub<unknown[], any> }; removeConfig: SinonStub<any[], any>; ... } }`
