Skip to content

@codesoul-co/hypha-core / modules/runtime/runtime-helper-sdk

Using this module

Use the Runtime helper sdk module for executing runtime behavior at this boundary. It exports 5 classes, 2 functions, 1 interface.

Import from the package entrypoint

ts
import {
  DefaultRuntimeTransitionHelper,
  DefaultRuntimeWaitHelper,
  DeterministicRuntimeClockHelper,
  DeterministicRuntimeIdHelper,
  InMemoryRuntimeDeterminismStore,
  createRuntimeHelperSdk,
  deterministicObservationKey,
} from '@codesoul-co/hypha-core';

import type {
  CreateRuntimeHelperSdkOptions,
} from '@codesoul-co/hypha-core';

Usage patterns

  • Use the 1 type/interface export as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 5 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
  • The module exposes 2 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
DefaultRuntimeTransitionHelperclassnew DefaultRuntimeTransitionHelper(): DefaultRuntimeTransitionHelperDefault Runtime Transition Helper class with 5 public constructor or member entries; its exact declarations are listed below.
DefaultRuntimeWaitHelperclassnew DefaultRuntimeWaitHelper(): DefaultRuntimeWaitHelperDefault Runtime Wait Helper class with 5 public constructor or member entries; its exact declarations are listed below.
DeterministicRuntimeClockHelperclassnew DeterministicRuntimeClockHelper(scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, waits: RuntimeWaitHelper, source?: () => string): DeterministicRuntimeClockHelperDeterministic Runtime Clock Helper class with 3 public constructor or member entries; its exact declarations are listed below.
DeterministicRuntimeIdHelperclassnew DeterministicRuntimeIdHelper(scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, source?: (namespace: string) => string): DeterministicRuntimeIdHelperDeterministic Runtime ID Helper class with 2 public constructor or member entries; its exact declarations are listed below.
InMemoryRuntimeDeterminismStoreclassnew InMemoryRuntimeDeterminismStore(): InMemoryRuntimeDeterminismStoreIn Memory Runtime Determinism Store class with 2 public constructor or member entries; its exact declarations are listed below.
createRuntimeHelperSdkfunctioncreateRuntimeHelperSdk(options: CreateRuntimeHelperSdkOptions): RuntimeHelperSdkCreate Runtime Helper Sdk function with 1 public call signature; parameters and return types are listed below.
deterministicObservationKeyfunctiondeterministicObservationKey(scope: RuntimeDeterminismScope, key: string): stringDeterministic Observation Key function with 1 public call signature; parameters and return types are listed below.
CreateRuntimeHelperSdkOptionsinterfaceinterface CreateRuntimeHelperSdkOptionsCreate Runtime Helper Sdk Options interface with 4 public fields or methods.

DefaultRuntimeTransitionHelper

Default Runtime Transition Helper class with 5 public constructor or member entries; its exact declarations are listed below.

Declaration

text
export declare class DefaultRuntimeTransitionHelper implements RuntimeTransitionHelper {
    propose(to: string, reason?: string, variablesPatch?: Record<string, RuntimeJsonValue>): RuntimeTransitionProposal;
    complete(output?: RuntimeJsonValue, variablesPatch?: Record<string, RuntimeJsonValue>): RuntimeStateExecutionResult;
    continue(observation?: RuntimeJsonValue): RuntimeStateExecutionResult;
    fail(error: NormalizedRuntimeError): RuntimeStateExecutionResult;
}

Public members

MemberKindSignatureDescription
completemethodcomplete(output?: RuntimeJsonValue, variablesPatch?: Record<string, RuntimeJsonValue>): RuntimeStateExecutionResultPublic method; parameters and return type are shown in the signature.
constructorconstructor(): DefaultRuntimeTransitionHelperCreates an instance of this class.
continuemethodcontinue(observation?: RuntimeJsonValue): RuntimeStateExecutionResultPublic method; parameters and return type are shown in the signature.
failmethodfail(error: NormalizedRuntimeError): RuntimeStateExecutionResultPublic method; parameters and return type are shown in the signature.
proposemethodpropose(to: string, reason?: string, variablesPatch?: Record<string, RuntimeJsonValue>): RuntimeTransitionProposalPublic method; parameters and return type are shown in the signature.

DefaultRuntimeWaitHelper

Default Runtime Wait Helper class with 5 public constructor or member entries; its exact declarations are listed below.

Declaration

text
export declare class DefaultRuntimeWaitHelper implements RuntimeWaitHelper {
    human(request: HumanWaitRequest): RuntimeStateExecutionResult;
    signal(request: SignalWaitRequest): RuntimeStateExecutionResult;
    timer(request: TimerWaitRequest): RuntimeStateExecutionResult;
    pause(request: PauseRequest): RuntimeStateExecutionResult;
}

Public members

MemberKindSignatureDescription
constructorconstructor(): DefaultRuntimeWaitHelperCreates an instance of this class.
humanmethodhuman(request: HumanWaitRequest): RuntimeStateExecutionResultPublic method; parameters and return type are shown in the signature.
pausemethodpause(request: PauseRequest): RuntimeStateExecutionResultPublic method; parameters and return type are shown in the signature.
signalmethodsignal(request: SignalWaitRequest): RuntimeStateExecutionResultPublic method; parameters and return type are shown in the signature.
timermethodtimer(request: TimerWaitRequest): RuntimeStateExecutionResultPublic method; parameters and return type are shown in the signature.

DeterministicRuntimeClockHelper

Deterministic Runtime Clock Helper class with 3 public constructor or member entries; its exact declarations are listed below.

Declaration

text
export declare class DeterministicRuntimeClockHelper implements RuntimeClockHelper {
    constructor(scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, waits: RuntimeWaitHelper, source?: () => string);
    now(): Promise<string>;
    sleepUntil(isoTime: string): Promise<RuntimeStateExecutionResult>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, waits: RuntimeWaitHelper, source?: () => string): DeterministicRuntimeClockHelperCreates an instance of this class.
nowmethodnow(): Promise<string>Public method; parameters and return type are shown in the signature.
sleepUntilmethodsleepUntil(isoTime: string): Promise<RuntimeStateExecutionResult>Public method; parameters and return type are shown in the signature.

DeterministicRuntimeIdHelper

Deterministic Runtime ID Helper class with 2 public constructor or member entries; its exact declarations are listed below.

Declaration

text
export declare class DeterministicRuntimeIdHelper implements RuntimeIdHelper {
    constructor(scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, source?: (namespace: string) => string);
    next(namespace: string): Promise<string>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, source?: (namespace: string) => string): DeterministicRuntimeIdHelperCreates an instance of this class.
nextmethodnext(namespace: string): Promise<string>Public method; parameters and return type are shown in the signature.

InMemoryRuntimeDeterminismStore

In Memory Runtime Determinism Store class with 2 public constructor or member entries; its exact declarations are listed below.

Declaration

text
export declare class InMemoryRuntimeDeterminismStore implements RuntimeDeterminismStore {
    resolve<T extends RuntimeJsonValue>(request: RuntimeDeterminismResolveRequest, produce: () => T | Promise<T>): Promise<RuntimeDeterminismResolution<T>>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(): InMemoryRuntimeDeterminismStoreCreates an instance of this class.
resolvemethodresolve<T extends RuntimeJsonValue>(request: RuntimeDeterminismResolveRequest, produce: () => T | Promise<T>): Promise<RuntimeDeterminismResolution<T>>Public method; parameters and return type are shown in the signature.

createRuntimeHelperSdk

Create Runtime Helper Sdk function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function createRuntimeHelperSdk(options: CreateRuntimeHelperSdkOptions): RuntimeHelperSdk;

Call signature

text
createRuntimeHelperSdk(options: CreateRuntimeHelperSdkOptions): RuntimeHelperSdk

Parameters

ParameterTypeRequiredDescription
optionsCreateRuntimeHelperSdkOptionsYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: RuntimeHelperSdk
  • Description: The return contract is defined by the type shown above.

deterministicObservationKey

Deterministic Observation Key function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function deterministicObservationKey(scope: RuntimeDeterminismScope, key: string): string;

Call signature

text
deterministicObservationKey(scope: RuntimeDeterminismScope, key: string): string

Parameters

ParameterTypeRequiredDescription
scopeRuntimeDeterminismScopeYesRequired parameter; accepted values are defined by the type column.
keystringYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: string
  • Description: The return contract is defined by the type shown above.

CreateRuntimeHelperSdkOptions

Create Runtime Helper Sdk Options interface with 4 public fields or methods.

Declaration

text
export interface CreateRuntimeHelperSdkOptions {
    scope: RuntimeDeterminismScope;
    determinismStore: RuntimeDeterminismStore;
    now?: () => string;
    nextId?: (namespace: string) => string;
}

Contract members

MemberKindSignatureDescription
determinismStorepropertydeterminismStore: RuntimeDeterminismStorePublic property; its type, readonly modifier and optionality are shown in the signature.
nextIdmethodnextId?(namespace: string): stringPublic method; parameters and return type are shown in the signature.
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.
scopepropertyscope: RuntimeDeterminismScopePublic property; its type, readonly modifier and optionality are shown in the signature.