Skip to content

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

模块用法

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

从包入口导入

ts
import {
  RUNTIME_CANCELLATION_DISPOSITIONS,
  RUNTIME_CANCELLATION_PROPAGATIONS,
  RUNTIME_CANCELLATION_TARGET_STATUSES,
  RUNTIME_CANCELLATION_TARGET_TYPES,
} from '@codesoul-co/hypha-core';

import type {
  RuntimeActivityCancellationPort,
  RuntimeActivityCancellationRequest,
  RuntimeCancelCommand,
  RuntimeCancellationPolicy,
  RuntimeCancellationTargetResult,
  RuntimeCancelResult,
  RuntimeChildRunCancellationPort,
  RuntimeChildRunCancellationRequest,
} from '@codesoul-co/hypha-core';

// 完整导出列表见下方。

使用要点

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

公共导出

Symbol种类签名说明
RUNTIME_CANCELLATION_DISPOSITIONS常量const RUNTIME_CANCELLATION_DISPOSITIONS: readonly ["applied", "reused"]contracts/runtime-cancellation 模块导出的 RUNTIME CANCELLATION DISPOSITIONS 常量。
RUNTIME_CANCELLATION_PROPAGATIONS常量const RUNTIME_CANCELLATION_PROPAGATIONS: readonly ["none", "children", "all_descendants"]contracts/runtime-cancellation 模块导出的 RUNTIME CANCELLATION PROPAGATIONS 常量。
RUNTIME_CANCELLATION_TARGET_STATUSES常量const RUNTIME_CANCELLATION_TARGET_STATUSES: readonly ["cancelled", "already_terminal", "not_found", "failed"]contracts/runtime-cancellation 模块导出的 RUNTIME CANCELLATION TARGET STATUSES 常量。
RUNTIME_CANCELLATION_TARGET_TYPES常量const RUNTIME_CANCELLATION_TARGET_TYPES: readonly ["activity", "child_run", "session_command"]contracts/runtime-cancellation 模块导出的 RUNTIME CANCELLATION TARGET TYPES 常量。
RuntimeActivityCancellationPort接口interface RuntimeActivityCancellationPortRuntime Activity Cancellation Port 接口,共包含 1 个公开字段或方法。
RuntimeActivityCancellationRequest接口interface RuntimeActivityCancellationRequestRuntime Activity Cancellation Request 接口,共包含 7 个公开字段或方法。
RuntimeCancelCommand接口interface RuntimeCancelCommandRuntime Cancel Command 接口,共包含 9 个公开字段或方法。
RuntimeCancellationPolicy接口interface RuntimeCancellationPolicyRuntime Cancellation Policy 接口,共包含 3 个公开字段或方法。
RuntimeCancellationTargetResult接口interface RuntimeCancellationTargetResultRuntime Cancellation Target Result 接口,共包含 4 个公开字段或方法。
RuntimeCancelResult接口interface RuntimeCancelResultRuntime Cancel Result 接口,共包含 6 个公开字段或方法。
RuntimeChildRunCancellationPort接口interface RuntimeChildRunCancellationPortRuntime Child Run Cancellation Port 接口,共包含 2 个公开字段或方法。
RuntimeChildRunCancellationRequest接口interface RuntimeChildRunCancellationRequestRuntime Child Run Cancellation Request 接口,共包含 8 个公开字段或方法。
RuntimeChildRunListRequest接口interface RuntimeChildRunListRequestRuntime Child Run List Request 接口,共包含 2 个公开字段或方法。
RuntimeChildRunReference接口interface RuntimeChildRunReferenceRuntime Child Run Reference 接口,共包含 1 个公开字段或方法。
RuntimeCancellationDisposition类型type RuntimeCancellationDisposition = (typeof RUNTIME_CANCELLATION_DISPOSITIONS)[number]Runtime Cancellation Disposition 公共类型别名;完整类型表达式见声明。
RuntimeCancellationPropagation类型type RuntimeCancellationPropagation = (typeof RUNTIME_CANCELLATION_PROPAGATIONS)[number]Runtime Cancellation Propagation 公共类型别名;完整类型表达式见声明。
RuntimeCancellationTargetStatus类型type RuntimeCancellationTargetStatus = (typeof RUNTIME_CANCELLATION_TARGET_STATUSES)[number]Runtime Cancellation Target Status 公共类型别名;完整类型表达式见声明。
RuntimeCancellationTargetType类型type RuntimeCancellationTargetType = (typeof RUNTIME_CANCELLATION_TARGET_TYPES)[number]Runtime Cancellation Target Type 公共类型别名;完整类型表达式见声明。

RUNTIME_CANCELLATION_DISPOSITIONS

contracts/runtime-cancellation 模块导出的 RUNTIME CANCELLATION DISPOSITIONS 常量。

声明

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

RUNTIME_CANCELLATION_PROPAGATIONS

contracts/runtime-cancellation 模块导出的 RUNTIME CANCELLATION PROPAGATIONS 常量。

声明

text
export declare const RUNTIME_CANCELLATION_PROPAGATIONS: readonly ["none", "children", "all_descendants"];

RUNTIME_CANCELLATION_TARGET_STATUSES

contracts/runtime-cancellation 模块导出的 RUNTIME CANCELLATION TARGET STATUSES 常量。

声明

text
export declare const RUNTIME_CANCELLATION_TARGET_STATUSES: readonly ["cancelled", "already_terminal", "not_found", "failed"];

RUNTIME_CANCELLATION_TARGET_TYPES

contracts/runtime-cancellation 模块导出的 RUNTIME CANCELLATION TARGET TYPES 常量。

声明

text
export declare const RUNTIME_CANCELLATION_TARGET_TYPES: readonly ["activity", "child_run", "session_command"];

RuntimeActivityCancellationPort

Runtime Activity Cancellation Port 接口,共包含 1 个公开字段或方法。

声明

text
export interface RuntimeActivityCancellationPort {
    cancel(request: RuntimeActivityCancellationRequest): Promise<RuntimeCancellationTargetResult>;
}

契约成员

成员种类签名说明
cancel方法cancel(request: RuntimeActivityCancellationRequest): Promise<RuntimeCancellationTargetResult>公开方法;参数与返回类型以签名列为准。

RuntimeActivityCancellationRequest

Runtime Activity Cancellation Request 接口,共包含 7 个公开字段或方法。

声明

text
export interface RuntimeActivityCancellationRequest {
    scope: RuntimeScope;
    activityId: string;
    reason: string;
    requestedAt: string;
    deadlineAt?: string;
    fencingToken: number;
    idempotencyKey: string;
}

契约成员

成员种类签名说明
activityId属性activityId: string公开属性;类型、只读和可选状态以签名列为准。
deadlineAt属性deadlineAt?: string公开属性;类型、只读和可选状态以签名列为准。
fencingToken属性fencingToken: number公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey: string公开属性;类型、只读和可选状态以签名列为准。
reason属性reason: string公开属性;类型、只读和可选状态以签名列为准。
requestedAt属性requestedAt: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。

RuntimeCancelCommand

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

声明

text
export interface RuntimeCancelCommand {
    commandId: string;
    scope: RuntimeScope;
    principal: RuntimePrincipal;
    ownerId: string;
    leaseTtlMs: number;
    reason: string;
    policy: RuntimeCancellationPolicy;
    requestedAt: string;
    idempotencyKey?: string;
}

契约成员

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

RuntimeCancellationPolicy

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

声明

text
export interface RuntimeCancellationPolicy {
    propagation: RuntimeCancellationPropagation;
    cancelRunningActivities: boolean;
    waitGraceMs?: number;
}

契约成员

成员种类签名说明
cancelRunningActivities属性cancelRunningActivities: boolean公开属性;类型、只读和可选状态以签名列为准。
propagation属性propagation: "none" | "children" | "all_descendants"公开属性;类型、只读和可选状态以签名列为准。
waitGraceMs属性waitGraceMs?: number公开属性;类型、只读和可选状态以签名列为准。

RuntimeCancellationTargetResult

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

声明

text
export interface RuntimeCancellationTargetResult {
    targetType: RuntimeCancellationTargetType;
    targetId: string;
    status: RuntimeCancellationTargetStatus;
    error?: NormalizedRuntimeError;
}

契约成员

成员种类签名说明
error属性error?: NormalizedRuntimeError公开属性;类型、只读和可选状态以签名列为准。
status属性status: "cancelled" | "failed" | "not_found" | "already_terminal"公开属性;类型、只读和可选状态以签名列为准。
targetId属性targetId: string公开属性;类型、只读和可选状态以签名列为准。
targetType属性targetType: "activity" | "child_run" | "session_command"公开属性;类型、只读和可选状态以签名列为准。

RuntimeCancelResult

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

声明

text
export interface RuntimeCancelResult {
    commandId: string;
    disposition: RuntimeCancellationDisposition;
    eventIds: string[];
    targetResults: RuntimeCancellationTargetResult[];
    unresolvedActivityIds: string[];
    projection: RuntimeOrchestrationProjection;
}

契约成员

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

RuntimeChildRunCancellationPort

Runtime Child Run Cancellation Port 接口,共包含 2 个公开字段或方法。

声明

text
export interface RuntimeChildRunCancellationPort {
    listChildren(request: RuntimeChildRunListRequest): Promise<RuntimeChildRunReference[]>;
    cancel(request: RuntimeChildRunCancellationRequest): Promise<RuntimeCancellationTargetResult>;
}

契约成员

成员种类签名说明
cancel方法cancel(request: RuntimeChildRunCancellationRequest): Promise<RuntimeCancellationTargetResult>公开方法;参数与返回类型以签名列为准。
listChildren方法listChildren(request: RuntimeChildRunListRequest): Promise<RuntimeChildRunReference[]>公开方法;参数与返回类型以签名列为准。

RuntimeChildRunCancellationRequest

Runtime Child Run Cancellation Request 接口,共包含 8 个公开字段或方法。

声明

text
export interface RuntimeChildRunCancellationRequest {
    parentScope: RuntimeScope;
    childRunId: string;
    reason: string;
    propagation: Exclude<RuntimeCancellationPropagation, 'none'>;
    requestedAt: string;
    deadlineAt?: string;
    fencingToken: number;
    idempotencyKey: string;
}

契约成员

成员种类签名说明
childRunId属性childRunId: string公开属性;类型、只读和可选状态以签名列为准。
deadlineAt属性deadlineAt?: string公开属性;类型、只读和可选状态以签名列为准。
fencingToken属性fencingToken: number公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey: string公开属性;类型、只读和可选状态以签名列为准。
parentScope属性parentScope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。
propagation属性propagation: "children" | "all_descendants"公开属性;类型、只读和可选状态以签名列为准。
reason属性reason: string公开属性;类型、只读和可选状态以签名列为准。
requestedAt属性requestedAt: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeChildRunListRequest

Runtime Child Run List Request 接口,共包含 2 个公开字段或方法。

声明

text
export interface RuntimeChildRunListRequest {
    scope: RuntimeScope;
    requestedAt: string;
}

契约成员

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

RuntimeChildRunReference

Runtime Child Run Reference 接口,共包含 1 个公开字段或方法。

声明

text
export interface RuntimeChildRunReference {
    runId: string;
}

契约成员

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

RuntimeCancellationDisposition

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

声明

text
export type RuntimeCancellationDisposition = (typeof RUNTIME_CANCELLATION_DISPOSITIONS)[number];

RuntimeCancellationPropagation

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

声明

text
export type RuntimeCancellationPropagation = (typeof RUNTIME_CANCELLATION_PROPAGATIONS)[number];

RuntimeCancellationTargetStatus

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

声明

text
export type RuntimeCancellationTargetStatus = (typeof RUNTIME_CANCELLATION_TARGET_STATUSES)[number];

RuntimeCancellationTargetType

Runtime Cancellation Target Type 公共类型别名;完整类型表达式见声明。

声明

text
export type RuntimeCancellationTargetType = (typeof RUNTIME_CANCELLATION_TARGET_TYPES)[number];