Skip to content

@codesoul-co/hypha-core / contracts/artifact-record-repository

模块用法

用于声明并运行时校验契约。Artifact record repository 模块公开 2 类、5 接口。

从包入口导入

ts
import {
  ArtifactRecordRepositoryConflictError,
  ArtifactRecordRepositoryError,
} from '@codesoul-co/hypha-core';

import type {
  ArtifactIdempotencyRecord,
  ArtifactRecordCommitRequest,
  ArtifactRecordRepository,
  ArtifactRevisionFence,
  StoredArtifactRecord,
} from '@codesoul-co/hypha-core';

使用要点

  • 5 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 2 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。

公共导出

Symbol种类签名说明
ArtifactRecordRepositoryConflictErrornew ArtifactRecordRepositoryConflictError(message: string, details?: Record<string, unknown> | undefined): ArtifactRecordRepositoryConflictErrorArtifact Record Repository Conflict Error 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。
ArtifactRecordRepositoryErrornew ArtifactRecordRepositoryError(code: "ARTIFACT_RECORD_REPOSITORY_UNAVAILABLE" | "ARTIFACT_RECORD_REPOSITORY_CORRUPT", message: string, cause?: unknown | undefined): ArtifactRecordRepositoryErrorArtifact Record Repository Error 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。
ArtifactIdempotencyRecord接口interface ArtifactIdempotencyRecordArtifact Idempotency Record 接口,共包含 4 个公开字段或方法。
ArtifactRecordCommitRequest接口interface ArtifactRecordCommitRequestArtifact Record Commit Request 接口,共包含 3 个公开字段或方法。
ArtifactRecordRepository接口interface ArtifactRecordRepositoryMetadata persistence port for ArtifactManager. Implementations persist records, version/lineage links, and idempotency results, but never Artifact content bytes.
ArtifactRevisionFence接口interface ArtifactRevisionFenceArtifact Revision Fence 接口,共包含 3 个公开字段或方法。
StoredArtifactRecord接口interface StoredArtifactRecordStored Artifact Record 接口,共包含 2 个公开字段或方法。

ArtifactRecordRepositoryConflictError

Artifact Record Repository Conflict Error 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。

声明

text
export declare class ArtifactRecordRepositoryConflictError extends Error {
    readonly details?: Record<string, unknown> | undefined;
    constructor(message: string, details?: Record<string, unknown> | undefined);
}

公开成员

成员种类签名说明
cause属性cause?: unknown公开属性;类型、只读和可选状态以签名列为准。
constructor构造函数(message: string, details?: Record<string, unknown> | undefined): ArtifactRecordRepositoryConflictError创建该类的实例。
details属性readonly details?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
message属性message: string公开属性;类型、只读和可选状态以签名列为准。
name属性name: string公开属性;类型、只读和可选状态以签名列为准。
stack属性stack?: string公开属性;类型、只读和可选状态以签名列为准。
static captureStackTrace方法static captureStackTrace(targetObject: object, constructorOpt?: Function): voidCreates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. js const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to `new Error().stack` The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}. The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance: js function a() { b(); } function b() { c(); } function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error; } a();
static prepareStackTrace方法static prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any公开方法;参数与返回类型以签名列为准。
static stackTraceLimit属性static stackTraceLimit: numberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

ArtifactRecordRepositoryError

Artifact Record Repository Error 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。

声明

text
export declare class ArtifactRecordRepositoryError extends Error {
    readonly code: 'ARTIFACT_RECORD_REPOSITORY_UNAVAILABLE' | 'ARTIFACT_RECORD_REPOSITORY_CORRUPT';
    readonly cause?: unknown | undefined;
    constructor(code: 'ARTIFACT_RECORD_REPOSITORY_UNAVAILABLE' | 'ARTIFACT_RECORD_REPOSITORY_CORRUPT', message: string, cause?: unknown | undefined);
}

公开成员

成员种类签名说明
cause属性readonly cause?: unknown公开属性;类型、只读和可选状态以签名列为准。
code属性readonly code: "ARTIFACT_RECORD_REPOSITORY_UNAVAILABLE" | "ARTIFACT_RECORD_REPOSITORY_CORRUPT"公开属性;类型、只读和可选状态以签名列为准。
constructor构造函数(code: "ARTIFACT_RECORD_REPOSITORY_UNAVAILABLE" | "ARTIFACT_RECORD_REPOSITORY_CORRUPT", message: string, cause?: unknown | undefined): ArtifactRecordRepositoryError创建该类的实例。
message属性message: string公开属性;类型、只读和可选状态以签名列为准。
name属性name: string公开属性;类型、只读和可选状态以签名列为准。
stack属性stack?: string公开属性;类型、只读和可选状态以签名列为准。
static captureStackTrace方法static captureStackTrace(targetObject: object, constructorOpt?: Function): voidCreates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. js const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to `new Error().stack` The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}. The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance: js function a() { b(); } function b() { c(); } function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error; } a();
static prepareStackTrace方法static prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any公开方法;参数与返回类型以签名列为准。
static stackTraceLimit属性static stackTraceLimit: numberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

ArtifactIdempotencyRecord

Artifact Idempotency Record 接口,共包含 4 个公开字段或方法。

声明

text
export interface ArtifactIdempotencyRecord {
    operationId: string;
    idempotencyKey: string;
    artifactId: string;
    versionId: string;
}

契约成员

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

ArtifactRecordCommitRequest

Artifact Record Commit Request 接口,共包含 3 个公开字段或方法。

声明

text
export interface ArtifactRecordCommitRequest {
    records: StoredArtifactRecord[];
    expectedLatest?: ArtifactRevisionFence;
    idempotency?: ArtifactIdempotencyRecord;
}

契约成员

成员种类签名说明
expectedLatest属性expectedLatest?: ArtifactRevisionFence公开属性;类型、只读和可选状态以签名列为准。
idempotency属性idempotency?: ArtifactIdempotencyRecord公开属性;类型、只读和可选状态以签名列为准。
records属性records: StoredArtifactRecord[]公开属性;类型、只读和可选状态以签名列为准。

ArtifactRecordRepository

Metadata persistence port for ArtifactManager. Implementations persist records, version/lineage links, and idempotency results, but never Artifact content bytes.

声明

text
export interface ArtifactRecordRepository {
    get(artifactId: string, versionId?: string): Promise<StoredArtifactRecord | null>;
    getByVersionId(versionId: string): Promise<StoredArtifactRecord | null>;
    list(): Promise<StoredArtifactRecord[]>;
    findIdempotency(operationId: string, idempotencyKey: string): Promise<StoredArtifactRecord | null>;
    commit(request: ArtifactRecordCommitRequest): Promise<void>;
    listGarbageCollectionCandidates(request: ArtifactGarbageCollectionScanRequest): Promise<ArtifactGarbageCollectionCandidate[]>;
    claimGarbageCollection(request: ArtifactGarbageCollectionClaimRequest): Promise<boolean>;
    completeGarbageCollection(claimId: string, completedAt: string): Promise<void>;
    releaseGarbageCollection(claimId: string): Promise<void>;
    health(): Promise<ProviderHealth>;
    close?(): Promise<void>;
}

契约成员

成员种类签名说明
claimGarbageCollection方法claimGarbageCollection(request: ArtifactGarbageCollectionClaimRequest): Promise<boolean>公开方法;参数与返回类型以签名列为准。
close方法close?(): Promise<void>公开方法;参数与返回类型以签名列为准。
commit方法commit(request: ArtifactRecordCommitRequest): Promise<void>公开方法;参数与返回类型以签名列为准。
completeGarbageCollection方法completeGarbageCollection(claimId: string, completedAt: string): Promise<void>公开方法;参数与返回类型以签名列为准。
findIdempotency方法findIdempotency(operationId: string, idempotencyKey: string): Promise<StoredArtifactRecord | null>公开方法;参数与返回类型以签名列为准。
get方法get(artifactId: string, versionId?: string): Promise<StoredArtifactRecord | null>公开方法;参数与返回类型以签名列为准。
getByVersionId方法getByVersionId(versionId: string): Promise<StoredArtifactRecord | null>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
list方法list(): Promise<StoredArtifactRecord[]>公开方法;参数与返回类型以签名列为准。
listGarbageCollectionCandidates方法listGarbageCollectionCandidates(request: ArtifactGarbageCollectionScanRequest): Promise<ArtifactGarbageCollectionCandidate[]>公开方法;参数与返回类型以签名列为准。
releaseGarbageCollection方法releaseGarbageCollection(claimId: string): Promise<void>公开方法;参数与返回类型以签名列为准。

ArtifactRevisionFence

Artifact Revision Fence 接口,共包含 3 个公开字段或方法。

声明

text
export interface ArtifactRevisionFence {
    artifactId: string;
    versionId: string;
    revision: number;
}

契约成员

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

StoredArtifactRecord

Stored Artifact Record 接口,共包含 2 个公开字段或方法。

声明

text
export interface StoredArtifactRecord {
    record: ArtifactRecord;
    profileRef: SpecRef;
}

契约成员

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