Skip to content

@codesoul-co/hypha-adapters-local / legacy-tool-artifact-importer

模块用法

用于定义或实现 Provider-neutral Port。Legacy tool artifact importer 模块公开 2 类、1 函数、3 接口、1 类型。

从包入口导入

ts
import {
  LegacyToolArtifactImporter,
  LegacyToolArtifactImportError,
  legacyArtifactReference,
} from '@codesoul-co/hypha-adapters-local';

import type {
  LegacyToolArtifactImporterOptions,
  LegacyToolArtifactImportRequest,
  LegacyToolArtifactImportResult,
  LegacyToolArtifactImportErrorCode,
} from '@codesoul-co/hypha-adapters-local';

使用要点

  • 4 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 2 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
  • 1 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。

公共导出

Symbol种类签名说明
LegacyToolArtifactImporternew LegacyToolArtifactImporter(options: LegacyToolArtifactImporterOptions): LegacyToolArtifactImporterImports one explicitly identified legacy Tool file into Core ArtifactManager.
LegacyToolArtifactImportErrornew LegacyToolArtifactImportError(code: LegacyToolArtifactImportErrorCode, message: string, details?: Record<string, unknown> | undefined): LegacyToolArtifactImportErrorLegacy Tool Artifact Import Error 类,共公开 10 个构造函数或成员;精确签名见本条目的声明与成员表。
legacyArtifactReference函数legacyArtifactReference(relativePath: string, sizeBytes: number): stringLegacy Artifact Reference 函数,提供 1 个公开调用签名;参数与返回类型见下表。
LegacyToolArtifactImporterOptions接口interface LegacyToolArtifactImporterOptionsLegacy Tool Artifact Importer Options 接口,共包含 3 个公开字段或方法。
LegacyToolArtifactImportRequest接口interface LegacyToolArtifactImportRequestLegacy Tool Artifact Import Request 接口,共包含 9 个公开字段或方法。
LegacyToolArtifactImportResult接口interface LegacyToolArtifactImportResultLegacy Tool Artifact Import Result 接口,共包含 6 个公开字段或方法。
LegacyToolArtifactImportErrorCode类型type LegacyToolArtifactImportErrorCode = 'LEGACY_ARTIFACT_INVALID_PATH' | 'LEGACY_ARTIFACT_NOT_FOUND' | 'LEGACY_ARTIFACT_TOO_LARGE' | 'LEGACY_ARTIFACT_ID_MISMATCH' | 'LEGACY_ARTIFACT_SIZE_MISMATCH' | 'LEGACY_ARTIFACT_CONTENT_MISMATCH'Legacy Tool Artifact Import Error Code 公共类型别名;完整类型表达式见声明。

LegacyToolArtifactImporter

Imports one explicitly identified legacy Tool file into Core ArtifactManager.

声明

text
export declare class LegacyToolArtifactImporter {
    constructor(options: LegacyToolArtifactImporterOptions);
    import(request: LegacyToolArtifactImportRequest): Promise<LegacyToolArtifactImportResult>;
}

公开成员

成员种类签名说明
constructor构造函数(options: LegacyToolArtifactImporterOptions): LegacyToolArtifactImporter创建该类的实例。
import方法import(request: LegacyToolArtifactImportRequest): Promise<LegacyToolArtifactImportResult>公开方法;参数与返回类型以签名列为准。

LegacyToolArtifactImportError

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

声明

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

公开成员

成员种类签名说明
cause属性cause?: unknown公开属性;类型、只读和可选状态以签名列为准。
code属性readonly code: LegacyToolArtifactImportErrorCode公开属性;类型、只读和可选状态以签名列为准。
constructor构造函数(code: LegacyToolArtifactImportErrorCode, message: string, details?: Record<string, unknown> | undefined): LegacyToolArtifactImportError创建该类的实例。
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.

legacyArtifactReference

Legacy Artifact Reference 函数,提供 1 个公开调用签名;参数与返回类型见下表。

声明

text
export declare function legacyArtifactReference(relativePath: string, sizeBytes: number): string;

调用签名

text
legacyArtifactReference(relativePath: string, sizeBytes: number): string

参数

参数类型必需说明
relativePathstring必需参数;接受的值由类型列定义。
sizeBytesnumber必需参数;接受的值由类型列定义。

返回值

  • 类型: string
  • 说明: 返回值契约由上述类型定义。

LegacyToolArtifactImporterOptions

Legacy Tool Artifact Importer Options 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { LegacyToolArtifactImporterOptions } from '@codesoul-co/hypha-adapters-local';
  • 源码模块: legacy-tool-artifact-importer

声明

text
export interface LegacyToolArtifactImporterOptions {
    legacyRootPath: string;
    manager: Pick<ArtifactManager, 'create'>;
    maxArtifactBytes?: number;
}

契约成员

成员种类签名说明
legacyRootPath属性legacyRootPath: string公开属性;类型、只读和可选状态以签名列为准。
manager属性manager: Pick<ArtifactManager, "create">公开属性;类型、只读和可选状态以签名列为准。
maxArtifactBytes属性maxArtifactBytes?: number公开属性;类型、只读和可选状态以签名列为准。

LegacyToolArtifactImportRequest

Legacy Tool Artifact Import Request 接口,共包含 9 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { LegacyToolArtifactImportRequest } from '@codesoul-co/hypha-adapters-local';
  • 源码模块: legacy-tool-artifact-importer

声明

text
export interface LegacyToolArtifactImportRequest {
    relativePath: string;
    expectedLegacyArtifactId?: string;
    expectedContentHash?: string;
    expectedSizeBytes?: number;
    context: ToolArtifactManagerContext;
    toolId: string;
    invocationId: string;
    mimeType?: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
context属性context: ToolArtifactManagerContext公开属性;类型、只读和可选状态以签名列为准。
expectedContentHash属性expectedContentHash?: string公开属性;类型、只读和可选状态以签名列为准。
expectedLegacyArtifactId属性expectedLegacyArtifactId?: string公开属性;类型、只读和可选状态以签名列为准。
expectedSizeBytes属性expectedSizeBytes?: number公开属性;类型、只读和可选状态以签名列为准。
invocationId属性invocationId: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
mimeType属性mimeType?: string公开属性;类型、只读和可选状态以签名列为准。
relativePath属性relativePath: string公开属性;类型、只读和可选状态以签名列为准。
toolId属性toolId: string公开属性;类型、只读和可选状态以签名列为准。

LegacyToolArtifactImportResult

Legacy Tool Artifact Import Result 接口,共包含 6 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { LegacyToolArtifactImportResult } from '@codesoul-co/hypha-adapters-local';
  • 源码模块: legacy-tool-artifact-importer

声明

text
export interface LegacyToolArtifactImportResult {
    legacyArtifactId: string;
    artifactId: string;
    versionId: string;
    revision: number;
    contentHash: string;
    sizeBytes: number;
}

契约成员

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

LegacyToolArtifactImportErrorCode

Legacy Tool Artifact Import Error Code 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { LegacyToolArtifactImportErrorCode } from '@codesoul-co/hypha-adapters-local';
  • 源码模块: legacy-tool-artifact-importer

声明

text
export type LegacyToolArtifactImportErrorCode = 'LEGACY_ARTIFACT_INVALID_PATH' | 'LEGACY_ARTIFACT_NOT_FOUND' | 'LEGACY_ARTIFACT_TOO_LARGE' | 'LEGACY_ARTIFACT_ID_MISMATCH' | 'LEGACY_ARTIFACT_SIZE_MISMATCH' | 'LEGACY_ARTIFACT_CONTENT_MISMATCH';