@codesoul-co/hypha-core / modules/runtime/event-schema-registry
- Package index:
@codesoul-co/hypha-core - Source:
packages/core/src/modules/runtime/event-schema-registry.ts - Exports: 6
Using this module
Use the Event schema registry module for declaring and runtime-validating contracts. It exports 1 class, 5 interfaces.
Import from the package entrypoint
ts
import {
InMemoryEventSchemaRegistry,
} from '@codesoul-co/hypha-core';
import type {
EventSchemaDefinition,
EventSchemaRegistry,
EventUpcaster,
EventValidationIssue,
EventValidationResult,
} from '@codesoul-co/hypha-core';Usage patterns
- Use the 5 type/interface exports as static contracts in application code, adapters, or tests. Import them with
import type; they do not exist at runtime. - The module exposes 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
Public exports
| Symbol | Kind | Signature | Description |
|---|---|---|---|
InMemoryEventSchemaRegistry | class | new InMemoryEventSchemaRegistry(): InMemoryEventSchemaRegistry | In Memory Event Schema Registry class with 5 public constructor or member entries; its exact declarations are listed below. |
EventSchemaDefinition | interface | interface EventSchemaDefinition | Event Schema Definition interface with 6 public fields or methods. |
EventSchemaRegistry | interface | interface EventSchemaRegistry | Event Schema Registry interface with 4 public fields or methods. |
EventUpcaster | interface | interface EventUpcaster | Event Upcaster interface with 5 public fields or methods. |
EventValidationIssue | interface | interface EventValidationIssue | Event Validation Issue interface with 3 public fields or methods. |
EventValidationResult | interface | interface EventValidationResult | Event Validation Result interface with 5 public fields or methods. |
InMemoryEventSchemaRegistry
In Memory Event Schema Registry class with 5 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { InMemoryEventSchemaRegistry } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-schema-registry
Declaration
text
export declare class InMemoryEventSchemaRegistry implements EventSchemaRegistry {
constructor();
register(definition: EventSchemaDefinition): Promise<void>;
registerUpcaster(upcaster: EventUpcaster): Promise<void>;
validate(event: EventCreateInput): Promise<EventValidationResult>;
upcast(event: PersistedFrameworkEvent, targetVersion?: string): Promise<PersistedFrameworkEvent>;
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
constructor | constructor | (): InMemoryEventSchemaRegistry | Creates an instance of this class. |
register | method | register(definition: EventSchemaDefinition): Promise<void> | Public method; parameters and return type are shown in the signature. |
registerUpcaster | method | registerUpcaster(upcaster: EventUpcaster): Promise<void> | Public method; parameters and return type are shown in the signature. |
upcast | method | upcast(event: PersistedFrameworkEvent, targetVersion?: string): Promise<PersistedFrameworkEvent> | Public method; parameters and return type are shown in the signature. |
validate | method | validate(event: EventCreateInput): Promise<EventValidationResult> | Public method; parameters and return type are shown in the signature. |
EventSchemaDefinition
Event Schema Definition interface with 6 public fields or methods.
- Kind: interface
- Import:
import type { EventSchemaDefinition } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-schema-registry
Declaration
text
export interface EventSchemaDefinition {
eventType: string;
version: string;
schema: JsonSchema;
schemaHash: string;
sensitivePaths?: string[];
upcasterRefs?: string[];
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
eventType | property | eventType: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
schema | property | schema: JsonSchema | Public property; its type, readonly modifier and optionality are shown in the signature. |
schemaHash | property | schemaHash: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
sensitivePaths | property | sensitivePaths?: string[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
upcasterRefs | property | upcasterRefs?: string[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
version | property | version: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
EventSchemaRegistry
Event Schema Registry interface with 4 public fields or methods.
- Kind: interface
- Import:
import type { EventSchemaRegistry } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-schema-registry
Declaration
text
export interface EventSchemaRegistry {
register(definition: EventSchemaDefinition): Promise<void>;
registerUpcaster(upcaster: EventUpcaster): Promise<void>;
validate(event: EventCreateInput): Promise<EventValidationResult>;
upcast(event: PersistedFrameworkEvent, targetVersion?: string): Promise<PersistedFrameworkEvent>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
register | method | register(definition: EventSchemaDefinition): Promise<void> | Public method; parameters and return type are shown in the signature. |
registerUpcaster | method | registerUpcaster(upcaster: EventUpcaster): Promise<void> | Public method; parameters and return type are shown in the signature. |
upcast | method | upcast(event: PersistedFrameworkEvent, targetVersion?: string): Promise<PersistedFrameworkEvent> | Public method; parameters and return type are shown in the signature. |
validate | method | validate(event: EventCreateInput): Promise<EventValidationResult> | Public method; parameters and return type are shown in the signature. |
EventUpcaster
Event Upcaster interface with 5 public fields or methods.
- Kind: interface
- Import:
import type { EventUpcaster } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-schema-registry
Declaration
text
export interface EventUpcaster {
ref: string;
eventType: string;
fromVersion: string;
toVersion: string;
upcast(payload: unknown): unknown;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
eventType | property | eventType: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
fromVersion | property | fromVersion: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
ref | property | ref: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
toVersion | property | toVersion: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
upcast | method | upcast(payload: unknown): unknown | Public method; parameters and return type are shown in the signature. |
EventValidationIssue
Event Validation Issue interface with 3 public fields or methods.
- Kind: interface
- Import:
import type { EventValidationIssue } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-schema-registry
Declaration
text
export interface EventValidationIssue {
path: string;
code: string;
message: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
code | property | code: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
message | property | message: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
path | property | path: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
EventValidationResult
Event Validation Result interface with 5 public fields or methods.
- Kind: interface
- Import:
import type { EventValidationResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-schema-registry
Declaration
text
export interface EventValidationResult {
valid: boolean;
eventType: string;
version: string;
schemaHash?: string;
issues: EventValidationIssue[];
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
eventType | property | eventType: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
issues | property | issues: EventValidationIssue[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
schemaHash | property | schemaHash?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
valid | property | valid: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
version | property | version: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
