Skip to content

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

模块用法

用于声明并运行时校验契约。Runtime control 模块公开 2 常量、4 接口、3 类型。

从包入口导入

ts
import {
  RUNTIME_CONTROL_DISPOSITIONS,
  RUNTIME_CONTROL_KINDS,
} from '@codesoul-co/hypha-core';

import type {
  RuntimePauseCommand,
  RuntimeResumeCommand,
  RuntimeRunControlResult,
  RuntimeSignalCommand,
  RuntimeControlDisposition,
  RuntimeControlKind,
  RuntimeRunControlCommand,
} from '@codesoul-co/hypha-core';

使用要点

  • 7 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 2 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

公共导出

Symbol种类签名说明
RUNTIME_CONTROL_DISPOSITIONS常量const RUNTIME_CONTROL_DISPOSITIONS: readonly ["applied", "reused", "lease_unavailable"]contracts/runtime-control 模块导出的 RUNTIME CONTROL DISPOSITIONS 常量。
RUNTIME_CONTROL_KINDS常量const RUNTIME_CONTROL_KINDS: readonly ["pause", "resume", "signal"]contracts/runtime-control 模块导出的 RUNTIME CONTROL KINDS 常量。
RuntimePauseCommand接口interface RuntimePauseCommand extends RuntimeRunControlCommandBaseRuntime Pause Command 接口,共包含 10 个公开字段或方法。
RuntimeResumeCommand接口interface RuntimeResumeCommand extends RuntimeRunControlCommandBaseRuntime Resume Command 接口,共包含 10 个公开字段或方法。
RuntimeRunControlResult接口interface RuntimeRunControlResultRuntime Run Control Result 接口,共包含 6 个公开字段或方法。
RuntimeSignalCommand接口interface RuntimeSignalCommand extends RuntimeRunControlCommandBaseRuntime Signal Command 接口,共包含 10 个公开字段或方法。
RuntimeControlDisposition类型type RuntimeControlDisposition = (typeof RUNTIME_CONTROL_DISPOSITIONS)[number]Runtime Control Disposition 公共类型别名;完整类型表达式见声明。
RuntimeControlKind类型type RuntimeControlKind = (typeof RUNTIME_CONTROL_KINDS)[number]Runtime Control Kind 公共类型别名;完整类型表达式见声明。
RuntimeRunControlCommand类型type RuntimeRunControlCommand = RuntimePauseCommand | RuntimeResumeCommand | RuntimeSignalCommandRuntime Run Control Command 公共类型别名;完整类型表达式见声明。

RUNTIME_CONTROL_DISPOSITIONS

contracts/runtime-control 模块导出的 RUNTIME CONTROL DISPOSITIONS 常量。

  • 种类: 常量
  • 导入: import { RUNTIME_CONTROL_DISPOSITIONS } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-control

声明

text
export declare const RUNTIME_CONTROL_DISPOSITIONS: readonly ["applied", "reused", "lease_unavailable"];

RUNTIME_CONTROL_KINDS

contracts/runtime-control 模块导出的 RUNTIME CONTROL KINDS 常量。

  • 种类: 常量
  • 导入: import { RUNTIME_CONTROL_KINDS } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-control

声明

text
export declare const RUNTIME_CONTROL_KINDS: readonly ["pause", "resume", "signal"];

RuntimePauseCommand

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

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

声明

text
export interface RuntimePauseCommand extends RuntimeRunControlCommandBase {
    kind: 'pause';
    reason: string;
    resumeKey?: string;
    requestedAt: string;
}

契约成员

成员种类签名说明
commandId属性commandId: string公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey?: string公开属性;类型、只读和可选状态以签名列为准。
kind属性kind: "pause"公开属性;类型、只读和可选状态以签名列为准。
leaseTtlMs属性leaseTtlMs: number公开属性;类型、只读和可选状态以签名列为准。
ownerId属性ownerId: string公开属性;类型、只读和可选状态以签名列为准。
principal属性principal: RuntimePrincipal公开属性;类型、只读和可选状态以签名列为准。
reason属性reason: string公开属性;类型、只读和可选状态以签名列为准。
requestedAt属性requestedAt: string公开属性;类型、只读和可选状态以签名列为准。
resumeKey属性resumeKey?: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。

RuntimeResumeCommand

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

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

声明

text
export interface RuntimeResumeCommand extends RuntimeRunControlCommandBase {
    kind: 'resume';
    key?: string;
    payload?: RuntimeJsonValue;
    requestedAt: string;
}

契约成员

成员种类签名说明
commandId属性commandId: string公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey?: string公开属性;类型、只读和可选状态以签名列为准。
key属性key?: string公开属性;类型、只读和可选状态以签名列为准。
kind属性kind: "resume"公开属性;类型、只读和可选状态以签名列为准。
leaseTtlMs属性leaseTtlMs: number公开属性;类型、只读和可选状态以签名列为准。
ownerId属性ownerId: string公开属性;类型、只读和可选状态以签名列为准。
payload属性payload?: RuntimeJsonValue公开属性;类型、只读和可选状态以签名列为准。
principal属性principal: RuntimePrincipal公开属性;类型、只读和可选状态以签名列为准。
requestedAt属性requestedAt: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。

RuntimeRunControlResult

Runtime Run Control Result 接口,共包含 6 个公开字段或方法。

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

声明

text
export interface RuntimeRunControlResult {
    commandId: string;
    kind: RuntimeControlKind;
    disposition: RuntimeControlDisposition;
    eventIds: string[];
    runRevision: number;
    projection: RuntimeOrchestrationProjection;
}

契约成员

成员种类签名说明
commandId属性commandId: string公开属性;类型、只读和可选状态以签名列为准。
disposition属性disposition: "applied" | "reused" | "lease_unavailable"公开属性;类型、只读和可选状态以签名列为准。
eventIds属性eventIds: string[]公开属性;类型、只读和可选状态以签名列为准。
kind属性kind: "signal" | "resume" | "pause"公开属性;类型、只读和可选状态以签名列为准。
projection属性projection: RuntimeOrchestrationProjection公开属性;类型、只读和可选状态以签名列为准。
runRevision属性runRevision: number公开属性;类型、只读和可选状态以签名列为准。

RuntimeSignalCommand

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

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

声明

text
export interface RuntimeSignalCommand extends RuntimeRunControlCommandBase {
    kind: 'signal';
    key: string;
    payload: RuntimeJsonValue;
    sentAt: string;
}

契约成员

成员种类签名说明
commandId属性commandId: string公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey?: string公开属性;类型、只读和可选状态以签名列为准。
key属性key: string公开属性;类型、只读和可选状态以签名列为准。
kind属性kind: "signal"公开属性;类型、只读和可选状态以签名列为准。
leaseTtlMs属性leaseTtlMs: number公开属性;类型、只读和可选状态以签名列为准。
ownerId属性ownerId: string公开属性;类型、只读和可选状态以签名列为准。
payload属性payload: RuntimeJsonValue公开属性;类型、只读和可选状态以签名列为准。
principal属性principal: RuntimePrincipal公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。
sentAt属性sentAt: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeControlDisposition

Runtime Control Disposition 公共类型别名;完整类型表达式见声明。

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

声明

text
export type RuntimeControlDisposition = (typeof RUNTIME_CONTROL_DISPOSITIONS)[number];

RuntimeControlKind

Runtime Control Kind 公共类型别名;完整类型表达式见声明。

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

声明

text
export type RuntimeControlKind = (typeof RUNTIME_CONTROL_KINDS)[number];

RuntimeRunControlCommand

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

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

声明

text
export type RuntimeRunControlCommand = RuntimePauseCommand | RuntimeResumeCommand | RuntimeSignalCommand;