@codesoul-co/hypha-core / modules/runtime/runtime-helper-sdk
模块用法
用于执行该边界的运行时行为。Runtime helper sdk 模块公开 5 类、2 函数、1 接口。
从包入口导入
ts
import {
DefaultRuntimeTransitionHelper,
DefaultRuntimeWaitHelper,
DeterministicRuntimeClockHelper,
DeterministicRuntimeIdHelper,
InMemoryRuntimeDeterminismStore,
createRuntimeHelperSdk,
deterministicObservationKey,
} from '@codesoul-co/hypha-core';
import type {
CreateRuntimeHelperSdkOptions,
} from '@codesoul-co/hypha-core';使用要点
- 1 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用
import type,运行时不应依赖它们。 - 5 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
- 2 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。
公共导出
| Symbol | 种类 | 签名 | 说明 |
|---|---|---|---|
DefaultRuntimeTransitionHelper | 类 | new DefaultRuntimeTransitionHelper(): DefaultRuntimeTransitionHelper | Default Runtime Transition Helper 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。 |
DefaultRuntimeWaitHelper | 类 | new DefaultRuntimeWaitHelper(): DefaultRuntimeWaitHelper | Default Runtime Wait Helper 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。 |
DeterministicRuntimeClockHelper | 类 | new DeterministicRuntimeClockHelper(scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, waits: RuntimeWaitHelper, source?: () => string): DeterministicRuntimeClockHelper | Deterministic Runtime Clock Helper 类,共公开 3 个构造函数或成员;精确签名见本条目的声明与成员表。 |
DeterministicRuntimeIdHelper | 类 | new DeterministicRuntimeIdHelper(scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, source?: (namespace: string) => string): DeterministicRuntimeIdHelper | Deterministic Runtime ID Helper 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。 |
InMemoryRuntimeDeterminismStore | 类 | new InMemoryRuntimeDeterminismStore(): InMemoryRuntimeDeterminismStore | In Memory Runtime Determinism Store 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。 |
createRuntimeHelperSdk | 函数 | createRuntimeHelperSdk(options: CreateRuntimeHelperSdkOptions): RuntimeHelperSdk | Create Runtime Helper Sdk 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
deterministicObservationKey | 函数 | deterministicObservationKey(scope: RuntimeDeterminismScope, key: string): string | Deterministic Observation Key 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
CreateRuntimeHelperSdkOptions | 接口 | interface CreateRuntimeHelperSdkOptions | Create Runtime Helper Sdk Options 接口,共包含 4 个公开字段或方法。 |
DefaultRuntimeTransitionHelper
Default Runtime Transition Helper 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。
- 种类: 类
- 导入:
import { DefaultRuntimeTransitionHelper } from '@codesoul-co/hypha-core'; - 源码模块:
modules/runtime/runtime-helper-sdk
声明
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;
}公开成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
complete | 方法 | complete(output?: RuntimeJsonValue, variablesPatch?: Record<string, RuntimeJsonValue>): RuntimeStateExecutionResult | 公开方法;参数与返回类型以签名列为准。 |
constructor | 构造函数 | (): DefaultRuntimeTransitionHelper | 创建该类的实例。 |
continue | 方法 | continue(observation?: RuntimeJsonValue): RuntimeStateExecutionResult | 公开方法;参数与返回类型以签名列为准。 |
fail | 方法 | fail(error: NormalizedRuntimeError): RuntimeStateExecutionResult | 公开方法;参数与返回类型以签名列为准。 |
propose | 方法 | propose(to: string, reason?: string, variablesPatch?: Record<string, RuntimeJsonValue>): RuntimeTransitionProposal | 公开方法;参数与返回类型以签名列为准。 |
DefaultRuntimeWaitHelper
Default Runtime Wait Helper 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。
- 种类: 类
- 导入:
import { DefaultRuntimeWaitHelper } from '@codesoul-co/hypha-core'; - 源码模块:
modules/runtime/runtime-helper-sdk
声明
text
export declare class DefaultRuntimeWaitHelper implements RuntimeWaitHelper {
human(request: HumanWaitRequest): RuntimeStateExecutionResult;
signal(request: SignalWaitRequest): RuntimeStateExecutionResult;
timer(request: TimerWaitRequest): RuntimeStateExecutionResult;
pause(request: PauseRequest): RuntimeStateExecutionResult;
}公开成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
constructor | 构造函数 | (): DefaultRuntimeWaitHelper | 创建该类的实例。 |
human | 方法 | human(request: HumanWaitRequest): RuntimeStateExecutionResult | 公开方法;参数与返回类型以签名列为准。 |
pause | 方法 | pause(request: PauseRequest): RuntimeStateExecutionResult | 公开方法;参数与返回类型以签名列为准。 |
signal | 方法 | signal(request: SignalWaitRequest): RuntimeStateExecutionResult | 公开方法;参数与返回类型以签名列为准。 |
timer | 方法 | timer(request: TimerWaitRequest): RuntimeStateExecutionResult | 公开方法;参数与返回类型以签名列为准。 |
DeterministicRuntimeClockHelper
Deterministic Runtime Clock Helper 类,共公开 3 个构造函数或成员;精确签名见本条目的声明与成员表。
- 种类: 类
- 导入:
import { DeterministicRuntimeClockHelper } from '@codesoul-co/hypha-core'; - 源码模块:
modules/runtime/runtime-helper-sdk
声明
text
export declare class DeterministicRuntimeClockHelper implements RuntimeClockHelper {
constructor(scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, waits: RuntimeWaitHelper, source?: () => string);
now(): Promise<string>;
sleepUntil(isoTime: string): Promise<RuntimeStateExecutionResult>;
}公开成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
constructor | 构造函数 | (scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, waits: RuntimeWaitHelper, source?: () => string): DeterministicRuntimeClockHelper | 创建该类的实例。 |
now | 方法 | now(): Promise<string> | 公开方法;参数与返回类型以签名列为准。 |
sleepUntil | 方法 | sleepUntil(isoTime: string): Promise<RuntimeStateExecutionResult> | 公开方法;参数与返回类型以签名列为准。 |
DeterministicRuntimeIdHelper
Deterministic Runtime ID Helper 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。
- 种类: 类
- 导入:
import { DeterministicRuntimeIdHelper } from '@codesoul-co/hypha-core'; - 源码模块:
modules/runtime/runtime-helper-sdk
声明
text
export declare class DeterministicRuntimeIdHelper implements RuntimeIdHelper {
constructor(scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, source?: (namespace: string) => string);
next(namespace: string): Promise<string>;
}公开成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
constructor | 构造函数 | (scope: RuntimeDeterminismScope, store: RuntimeDeterminismStore, source?: (namespace: string) => string): DeterministicRuntimeIdHelper | 创建该类的实例。 |
next | 方法 | next(namespace: string): Promise<string> | 公开方法;参数与返回类型以签名列为准。 |
InMemoryRuntimeDeterminismStore
In Memory Runtime Determinism Store 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。
- 种类: 类
- 导入:
import { InMemoryRuntimeDeterminismStore } from '@codesoul-co/hypha-core'; - 源码模块:
modules/runtime/runtime-helper-sdk
声明
text
export declare class InMemoryRuntimeDeterminismStore implements RuntimeDeterminismStore {
resolve<T extends RuntimeJsonValue>(request: RuntimeDeterminismResolveRequest, produce: () => T | Promise<T>): Promise<RuntimeDeterminismResolution<T>>;
}公开成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
constructor | 构造函数 | (): InMemoryRuntimeDeterminismStore | 创建该类的实例。 |
resolve | 方法 | resolve<T extends RuntimeJsonValue>(request: RuntimeDeterminismResolveRequest, produce: () => T | Promise<T>): Promise<RuntimeDeterminismResolution<T>> | 公开方法;参数与返回类型以签名列为准。 |
createRuntimeHelperSdk
Create Runtime Helper Sdk 函数,提供 1 个公开调用签名;参数与返回类型见下表。
- 种类: 函数
- 导入:
import { createRuntimeHelperSdk } from '@codesoul-co/hypha-core'; - 源码模块:
modules/runtime/runtime-helper-sdk
声明
text
export declare function createRuntimeHelperSdk(options: CreateRuntimeHelperSdkOptions): RuntimeHelperSdk;调用签名
text
createRuntimeHelperSdk(options: CreateRuntimeHelperSdkOptions): RuntimeHelperSdk参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
options | CreateRuntimeHelperSdkOptions | 是 | 必需参数;接受的值由类型列定义。 |
返回值
- 类型:
RuntimeHelperSdk - 说明: 返回值契约由上述类型定义。
deterministicObservationKey
Deterministic Observation Key 函数,提供 1 个公开调用签名;参数与返回类型见下表。
- 种类: 函数
- 导入:
import { deterministicObservationKey } from '@codesoul-co/hypha-core'; - 源码模块:
modules/runtime/runtime-helper-sdk
声明
text
export declare function deterministicObservationKey(scope: RuntimeDeterminismScope, key: string): string;调用签名
text
deterministicObservationKey(scope: RuntimeDeterminismScope, key: string): string参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
scope | RuntimeDeterminismScope | 是 | 必需参数;接受的值由类型列定义。 |
key | string | 是 | 必需参数;接受的值由类型列定义。 |
返回值
- 类型:
string - 说明: 返回值契约由上述类型定义。
CreateRuntimeHelperSdkOptions
Create Runtime Helper Sdk Options 接口,共包含 4 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CreateRuntimeHelperSdkOptions } from '@codesoul-co/hypha-core'; - 源码模块:
modules/runtime/runtime-helper-sdk
声明
text
export interface CreateRuntimeHelperSdkOptions {
scope: RuntimeDeterminismScope;
determinismStore: RuntimeDeterminismStore;
now?: () => string;
nextId?: (namespace: string) => string;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
determinismStore | 属性 | determinismStore: RuntimeDeterminismStore | 公开属性;类型、只读和可选状态以签名列为准。 |
nextId | 方法 | nextId?(namespace: string): string | 公开方法;参数与返回类型以签名列为准。 |
now | 方法 | now?(): string | 公开方法;参数与返回类型以签名列为准。 |
scope | 属性 | scope: RuntimeDeterminismScope | 公开属性;类型、只读和可选状态以签名列为准。 |
