Skip to content

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

模块用法

用于声明并运行时校验契约。Runtime projection 模块公开 5 接口、1 类型。

从包入口导入

ts
import type {
  RuntimeCancellationProjection,
  RuntimeOrchestrationProjection,
  RuntimePendingTransitionProjection,
  RuntimePendingWaitProjection,
  RuntimeResumeProjection,
  RuntimeOrchestrationRunStatus,
} from '@codesoul-co/hypha-core';

使用要点

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

公共导出

Symbol种类签名说明
RuntimeCancellationProjection接口interface RuntimeCancellationProjectionRuntime Cancellation Projection 接口,共包含 4 个公开字段或方法。
RuntimeOrchestrationProjection接口interface RuntimeOrchestrationProjectionRuntime Orchestration Projection 接口,共包含 13 个公开字段或方法。
RuntimePendingTransitionProjection接口interface RuntimePendingTransitionProjectionRuntime Pending Transition Projection 接口,共包含 3 个公开字段或方法。
RuntimePendingWaitProjection接口interface RuntimePendingWaitProjectionRuntime Pending Wait Projection 接口,共包含 10 个公开字段或方法。
RuntimeResumeProjection接口interface RuntimeResumeProjectionRuntime Resume Projection 接口,共包含 7 个公开字段或方法。
RuntimeOrchestrationRunStatus类型type RuntimeOrchestrationRunStatus = 'not_created' | RuntimeRunStatusRuntime Orchestration Run Status 公共类型别名;完整类型表达式见声明。

RuntimeCancellationProjection

Runtime Cancellation Projection 接口,共包含 4 个公开字段或方法。

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

声明

text
export interface RuntimeCancellationProjection {
    commandId: string;
    principalId: string;
    reason: string;
    requestedAt: string;
}

契约成员

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

RuntimeOrchestrationProjection

Runtime Orchestration Projection 接口,共包含 13 个公开字段或方法。

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

声明

text
export interface RuntimeOrchestrationProjection {
    runId: string;
    runStatus: RuntimeOrchestrationRunStatus;
    currentState?: string;
    terminalState?: string;
    statePath: string[];
    stateVisitCounts: Record<string, number>;
    stateAttempt: number;
    pendingTransition?: RuntimePendingTransitionProjection;
    pendingHumanActionRef?: string;
    pendingWait?: RuntimePendingWaitProjection;
    lastResume?: RuntimeResumeProjection;
    cancellation?: RuntimeCancellationProjection;
    pendingActivityIds: string[];
}

契约成员

成员种类签名说明
cancellation属性cancellation?: RuntimeCancellationProjection公开属性;类型、只读和可选状态以签名列为准。
currentState属性currentState?: string公开属性;类型、只读和可选状态以签名列为准。
lastResume属性lastResume?: RuntimeResumeProjection公开属性;类型、只读和可选状态以签名列为准。
pendingActivityIds属性pendingActivityIds: string[]公开属性;类型、只读和可选状态以签名列为准。
pendingHumanActionRef属性pendingHumanActionRef?: string公开属性;类型、只读和可选状态以签名列为准。
pendingTransition属性pendingTransition?: RuntimePendingTransitionProjection公开属性;类型、只读和可选状态以签名列为准。
pendingWait属性pendingWait?: RuntimePendingWaitProjection公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
runStatus属性runStatus: RuntimeOrchestrationRunStatus公开属性;类型、只读和可选状态以签名列为准。
stateAttempt属性stateAttempt: number公开属性;类型、只读和可选状态以签名列为准。
statePath属性statePath: string[]公开属性;类型、只读和可选状态以签名列为准。
stateVisitCounts属性stateVisitCounts: Record<string, number>公开属性;类型、只读和可选状态以签名列为准。
terminalState属性terminalState?: string公开属性;类型、只读和可选状态以签名列为准。

RuntimePendingTransitionProjection

Runtime Pending Transition Projection 接口,共包含 3 个公开字段或方法。

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

声明

text
export interface RuntimePendingTransitionProjection {
    eventId: string;
    from: string;
    to: string;
}

契约成员

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

RuntimePendingWaitProjection

Runtime Pending Wait Projection 接口,共包含 10 个公开字段或方法。

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

声明

text
export interface RuntimePendingWaitProjection {
    waitId: string;
    stateId: string;
    stateAttempt: number;
    type: RuntimeWaitIntentType;
    key?: string;
    pendingActionRef?: string;
    reason?: string;
    expectedSchema?: JsonSchema;
    expiresAt?: string;
    createdAt: string;
}

契约成员

成员种类签名说明
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
expectedSchema属性expectedSchema?: JsonSchema公开属性;类型、只读和可选状态以签名列为准。
expiresAt属性expiresAt?: string公开属性;类型、只读和可选状态以签名列为准。
key属性key?: string公开属性;类型、只读和可选状态以签名列为准。
pendingActionRef属性pendingActionRef?: string公开属性;类型、只读和可选状态以签名列为准。
reason属性reason?: string公开属性;类型、只读和可选状态以签名列为准。
stateAttempt属性stateAttempt: number公开属性;类型、只读和可选状态以签名列为准。
stateId属性stateId: string公开属性;类型、只读和可选状态以签名列为准。
type属性type: "human" | "signal" | "timer" | "pause"公开属性;类型、只读和可选状态以签名列为准。
waitId属性waitId: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeResumeProjection

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

声明

text
export interface RuntimeResumeProjection {
    commandId: string;
    kind: 'manual' | 'signal' | 'timer';
    waitId: string;
    principalId: string;
    key?: string;
    payload?: RuntimeJsonValue;
    resumedAt: string;
}

契约成员

成员种类签名说明
commandId属性commandId: string公开属性;类型、只读和可选状态以签名列为准。
key属性key?: string公开属性;类型、只读和可选状态以签名列为准。
kind属性kind: "manual" | "signal" | "timer"公开属性;类型、只读和可选状态以签名列为准。
payload属性payload?: RuntimeJsonValue公开属性;类型、只读和可选状态以签名列为准。
principalId属性principalId: string公开属性;类型、只读和可选状态以签名列为准。
resumedAt属性resumedAt: string公开属性;类型、只读和可选状态以签名列为准。
waitId属性waitId: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeOrchestrationRunStatus

Runtime Orchestration Run Status 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { RuntimeOrchestrationRunStatus } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-projection

声明

text
export type RuntimeOrchestrationRunStatus = 'not_created' | RuntimeRunStatus;