Skip to content

@codesoul-co/hypha-core / contracts/runtime-query

模块用法

用于声明并运行时校验契约。Runtime query 模块公开 6 接口。

从包入口导入

ts
import type {
  RuntimeQueryRequest,
  RuntimeQueryServiceContract,
  RuntimeRunView,
  RuntimeStateExplanation,
  RuntimeTimelineRequest,
  RuntimeTimelineResult,
} from '@codesoul-co/hypha-core';

使用要点

  • 6 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。

公共导出

Symbol种类签名说明
RuntimeQueryRequest接口interface RuntimeQueryRequestRuntime Query Request 接口,共包含 1 个公开字段或方法。
RuntimeQueryServiceContract接口interface RuntimeQueryServiceContractRuntime Query Service Contract 接口,共包含 5 个公开字段或方法。
RuntimeRunView接口interface RuntimeRunViewRuntime Run View 接口,共包含 7 个公开字段或方法。
RuntimeStateExplanation接口interface RuntimeStateExplanationRuntime State Explanation 接口,共包含 10 个公开字段或方法。
RuntimeTimelineRequest接口interface RuntimeTimelineRequest extends RuntimeQueryRequestRuntime Timeline Request 接口,共包含 5 个公开字段或方法。
RuntimeTimelineResult接口interface RuntimeTimelineResultRuntime Timeline Result 接口,共包含 5 个公开字段或方法。

RuntimeQueryRequest

Runtime Query Request 接口,共包含 1 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeQueryRequest } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-query

声明

text
export interface RuntimeQueryRequest {
    scope: RuntimeScope;
}

契约成员

成员种类签名说明
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。

RuntimeQueryServiceContract

Runtime Query Service Contract 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeQueryServiceContract } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-query

声明

text
export interface RuntimeQueryServiceContract {
    getRun(request: RuntimeQueryRequest): Promise<RuntimeRunView | null>;
    getFSM(request: RuntimeQueryRequest): Promise<RuntimeOrchestrationProjection | null>;
    getTimeline(request: RuntimeTimelineRequest): Promise<RuntimeTimelineResult>;
    getPendingWaits(request: RuntimeQueryRequest): Promise<RuntimePendingWaitProjection[]>;
    explainState(request: RuntimeQueryRequest): Promise<RuntimeStateExplanation | null>;
}

契约成员

成员种类签名说明
explainState方法explainState(request: RuntimeQueryRequest): Promise<RuntimeStateExplanation | null>公开方法;参数与返回类型以签名列为准。
getFSM方法getFSM(request: RuntimeQueryRequest): Promise<RuntimeOrchestrationProjection | null>公开方法;参数与返回类型以签名列为准。
getPendingWaits方法getPendingWaits(request: RuntimeQueryRequest): Promise<RuntimePendingWaitProjection[]>公开方法;参数与返回类型以签名列为准。
getRun方法getRun(request: RuntimeQueryRequest): Promise<RuntimeRunView | null>公开方法;参数与返回类型以签名列为准。
getTimeline方法getTimeline(request: RuntimeTimelineRequest): Promise<RuntimeTimelineResult>公开方法;参数与返回类型以签名列为准。

RuntimeRunView

Runtime Run View 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeRunView } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-query

声明

text
export interface RuntimeRunView {
    scope: RuntimeScope;
    projectionVersion: string;
    projection: RuntimeOrchestrationProjection;
    projectionLastSequence: number;
    eventHeadSequence: number;
    projectionLag: number;
    refreshedAt: string;
}

契约成员

成员种类签名说明
eventHeadSequence属性eventHeadSequence: number公开属性;类型、只读和可选状态以签名列为准。
projection属性projection: RuntimeOrchestrationProjection公开属性;类型、只读和可选状态以签名列为准。
projectionLag属性projectionLag: number公开属性;类型、只读和可选状态以签名列为准。
projectionLastSequence属性projectionLastSequence: number公开属性;类型、只读和可选状态以签名列为准。
projectionVersion属性projectionVersion: string公开属性;类型、只读和可选状态以签名列为准。
refreshedAt属性refreshedAt: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。

RuntimeStateExplanation

Runtime State Explanation 接口,共包含 10 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeStateExplanation } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-query

声明

text
export interface RuntimeStateExplanation {
    scope: RuntimeScope;
    runStatus: RuntimeOrchestrationProjection['runStatus'];
    currentState?: string;
    stateAttempt: number;
    statePath: string[];
    pendingWaitId?: string;
    pendingTransitionEventId?: string;
    pendingActivityIds: string[];
    lastEventSequence: number;
    source: 'runtime.orchestration.projection';
}

契约成员

成员种类签名说明
currentState属性currentState?: string公开属性;类型、只读和可选状态以签名列为准。
lastEventSequence属性lastEventSequence: number公开属性;类型、只读和可选状态以签名列为准。
pendingActivityIds属性pendingActivityIds: string[]公开属性;类型、只读和可选状态以签名列为准。
pendingTransitionEventId属性pendingTransitionEventId?: string公开属性;类型、只读和可选状态以签名列为准。
pendingWaitId属性pendingWaitId?: string公开属性;类型、只读和可选状态以签名列为准。
runStatus属性runStatus: import("/Users/erwin/Downloads/codespace/Hypha/packages/core/dist/contracts/runtime-projection").RuntimeOrchestrationRunStatus公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。
source属性source: "runtime.orchestration.projection"公开属性;类型、只读和可选状态以签名列为准。
stateAttempt属性stateAttempt: number公开属性;类型、只读和可选状态以签名列为准。
statePath属性statePath: string[]公开属性;类型、只读和可选状态以签名列为准。

RuntimeTimelineRequest

Runtime Timeline Request 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeTimelineRequest } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-query

声明

text
export interface RuntimeTimelineRequest extends RuntimeQueryRequest {
    fromSequence?: number;
    toSequence?: number;
    types?: FrameworkEventType[];
    limit?: number;
}

契约成员

成员种类签名说明
fromSequence属性fromSequence?: number公开属性;类型、只读和可选状态以签名列为准。
limit属性limit?: number公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。
toSequence属性toSequence?: number公开属性;类型、只读和可选状态以签名列为准。
types属性types?: FrameworkEventType[]公开属性;类型、只读和可选状态以签名列为准。

RuntimeTimelineResult

Runtime Timeline Result 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeTimelineResult } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-query

声明

text
export interface RuntimeTimelineResult {
    scope: RuntimeScope;
    events: PersistedFrameworkEvent[];
    eventCount: number;
    eventHeadSequence: number;
    refreshedAt: string;
}

契约成员

成员种类签名说明
eventCount属性eventCount: number公开属性;类型、只读和可选状态以签名列为准。
eventHeadSequence属性eventHeadSequence: number公开属性;类型、只读和可选状态以签名列为准。
events属性events: PersistedFrameworkEvent<unknown>[]公开属性;类型、只读和可选状态以签名列为准。
refreshedAt属性refreshedAt: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。