@codesoul-co/hypha-core / contracts/artifact-store
模块用法
用于声明并运行时校验契约。Artifact store 模块公开 12 接口、1 类型。
从包入口导入
ts
import type {
ArtifactByteRange,
ArtifactContent,
ArtifactCopyRequest,
ArtifactDownloadAccess,
ArtifactDownloadAccessRequest,
ArtifactGetRequest,
ArtifactObjectMetadata,
ArtifactOperationOptions,
} from '@codesoul-co/hypha-core';
// 完整导出列表见下方。使用要点
- 13 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用
import type,运行时不应依赖它们。
公共导出
| Symbol | 种类 | 签名 | 说明 |
|---|---|---|---|
ArtifactByteRange | 接口 | interface ArtifactByteRange | Artifact Byte Range 接口,共包含 2 个公开字段或方法。 |
ArtifactContent | 接口 | interface ArtifactContent | Artifact Content 接口,共包含 6 个公开字段或方法。 |
ArtifactCopyRequest | 接口 | interface ArtifactCopyRequest | Artifact Copy Request 接口,共包含 4 个公开字段或方法。 |
ArtifactDownloadAccess | 接口 | interface ArtifactDownloadAccess | Artifact Download Access 接口,共包含 4 个公开字段或方法。 |
ArtifactDownloadAccessRequest | 接口 | interface ArtifactDownloadAccessRequest | Artifact Download Access Request 接口,共包含 4 个公开字段或方法。 |
ArtifactGetRequest | 接口 | interface ArtifactGetRequest | Artifact Get Request 接口,共包含 3 个公开字段或方法。 |
ArtifactObjectMetadata | 接口 | interface ArtifactObjectMetadata | Artifact Object Metadata 接口,共包含 6 个公开字段或方法。 |
ArtifactOperationOptions | 接口 | interface ArtifactOperationOptions | Artifact Operation Options 接口,共包含 1 个公开字段或方法。 |
ArtifactPutRequest | 接口 | interface ArtifactPutRequest | Artifact Put Request 接口,共包含 8 个公开字段或方法。 |
ArtifactStoreCapabilities | 接口 | interface ArtifactStoreCapabilities | Artifact Store Capabilities 接口,共包含 7 个公开字段或方法。 |
ArtifactStoreProvider | 接口 | interface ArtifactStoreProvider | Artifact Store Provider 接口,共包含 11 个公开字段或方法。 |
ArtifactStoreProviderFactory | 接口 | interface ArtifactStoreProviderFactory | Artifact Store Provider Factory 接口,共包含 2 个公开字段或方法。 |
ArtifactByteSource | 类型 | type ArtifactByteSource = Uint8Array | AsyncIterable<Uint8Array> | Artifact Byte Source 公共类型别名;完整类型表达式见声明。 |
ArtifactByteRange
Artifact Byte Range 接口,共包含 2 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactByteRange } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactByteRange {
start: number;
endInclusive?: number;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
endInclusive | 属性 | endInclusive?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
start | 属性 | start: number | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactContent
Artifact Content 接口,共包含 6 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactContent } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactContent {
stream: AsyncIterable<Uint8Array>;
contentHash: string;
sizeBytes: number;
mimeType?: string;
etag?: string;
range?: ArtifactByteRange;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
contentHash | 属性 | contentHash: string | 公开属性;类型、只读和可选状态以签名列为准。 |
etag | 属性 | etag?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
mimeType | 属性 | mimeType?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
range | 属性 | range?: ArtifactByteRange | 公开属性;类型、只读和可选状态以签名列为准。 |
sizeBytes | 属性 | sizeBytes: number | 公开属性;类型、只读和可选状态以签名列为准。 |
stream | 属性 | stream: AsyncIterable<Uint8Array<ArrayBufferLike>> | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactCopyRequest
Artifact Copy Request 接口,共包含 4 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactCopyRequest } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactCopyRequest {
operationId: string;
source: ArtifactStorageRef;
targetObjectKey: string;
ifAbsent?: boolean;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
ifAbsent | 属性 | ifAbsent?: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
operationId | 属性 | operationId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
source | 属性 | source: ArtifactStorageRef | 公开属性;类型、只读和可选状态以签名列为准。 |
targetObjectKey | 属性 | targetObjectKey: string | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactDownloadAccess
Artifact Download Access 接口,共包含 4 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactDownloadAccess } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactDownloadAccess {
method: 'GET';
url: string;
expiresAt: string;
headers?: Record<string, string>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
expiresAt | 属性 | expiresAt: string | 公开属性;类型、只读和可选状态以签名列为准。 |
headers | 属性 | headers?: Record<string, string> | 公开属性;类型、只读和可选状态以签名列为准。 |
method | 属性 | method: "GET" | 公开属性;类型、只读和可选状态以签名列为准。 |
url | 属性 | url: string | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactDownloadAccessRequest
Artifact Download Access Request 接口,共包含 4 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactDownloadAccessRequest } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactDownloadAccessRequest {
ref: ArtifactStorageRef;
expiresInSeconds: number;
responseMimeType?: string;
responseFilename?: string;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
expiresInSeconds | 属性 | expiresInSeconds: number | 公开属性;类型、只读和可选状态以签名列为准。 |
ref | 属性 | ref: ArtifactStorageRef | 公开属性;类型、只读和可选状态以签名列为准。 |
responseFilename | 属性 | responseFilename?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
responseMimeType | 属性 | responseMimeType?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactGetRequest
Artifact Get Request 接口,共包含 3 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactGetRequest } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactGetRequest {
ref: ArtifactStorageRef;
range?: ArtifactByteRange;
expectedContentHash?: string;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
expectedContentHash | 属性 | expectedContentHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
range | 属性 | range?: ArtifactByteRange | 公开属性;类型、只读和可选状态以签名列为准。 |
ref | 属性 | ref: ArtifactStorageRef | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactObjectMetadata
Artifact Object Metadata 接口,共包含 6 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactObjectMetadata } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactObjectMetadata {
contentHash: string;
sizeBytes: number;
mimeType?: string;
etag?: string;
lastModifiedAt?: string;
metadata?: Record<string, string>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
contentHash | 属性 | contentHash: string | 公开属性;类型、只读和可选状态以签名列为准。 |
etag | 属性 | etag?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
lastModifiedAt | 属性 | lastModifiedAt?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
metadata | 属性 | metadata?: Record<string, string> | 公开属性;类型、只读和可选状态以签名列为准。 |
mimeType | 属性 | mimeType?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
sizeBytes | 属性 | sizeBytes: number | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactOperationOptions
Artifact Operation Options 接口,共包含 1 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactOperationOptions } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactOperationOptions {
abortSignal?: AbortSignal;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
abortSignal | 属性 | abortSignal?: AbortSignal | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactPutRequest
Artifact Put Request 接口,共包含 8 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactPutRequest } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactPutRequest {
operationId: string;
objectKey: string;
content: ArtifactByteSource;
expectedContentHash?: string;
sizeBytes?: number;
mimeType?: string;
metadata?: Record<string, string>;
ifAbsent?: boolean;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
content | 属性 | content: ArtifactByteSource | 公开属性;类型、只读和可选状态以签名列为准。 |
expectedContentHash | 属性 | expectedContentHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
ifAbsent | 属性 | ifAbsent?: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
metadata | 属性 | metadata?: Record<string, string> | 公开属性;类型、只读和可选状态以签名列为准。 |
mimeType | 属性 | mimeType?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
objectKey | 属性 | objectKey: string | 公开属性;类型、只读和可选状态以签名列为准。 |
operationId | 属性 | operationId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
sizeBytes | 属性 | sizeBytes?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactStoreCapabilities
Artifact Store Capabilities 接口,共包含 7 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactStoreCapabilities } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactStoreCapabilities {
versioning: boolean;
rangeRead: boolean;
signedAccess: boolean;
serverSideCopy: boolean;
encryption: boolean;
multipartUpload: boolean;
contentAddressing: boolean;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
contentAddressing | 属性 | contentAddressing: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
encryption | 属性 | encryption: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
multipartUpload | 属性 | multipartUpload: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
rangeRead | 属性 | rangeRead: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
serverSideCopy | 属性 | serverSideCopy: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
signedAccess | 属性 | signedAccess: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
versioning | 属性 | versioning: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactStoreProvider
Artifact Store Provider 接口,共包含 11 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactStoreProvider } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactStoreProvider {
readonly id: string;
capabilities(): Promise<ArtifactStoreCapabilities>;
put(request: ArtifactPutRequest, options?: ArtifactOperationOptions): Promise<ArtifactStorageRef>;
get(request: ArtifactGetRequest, options?: ArtifactOperationOptions): Promise<ArtifactContent>;
head(ref: ArtifactStorageRef): Promise<ArtifactObjectMetadata | null>;
exists(ref: ArtifactStorageRef): Promise<boolean>;
delete(ref: ArtifactStorageRef): Promise<void>;
copy(request: ArtifactCopyRequest): Promise<ArtifactStorageRef>;
createDownloadAccess?(request: ArtifactDownloadAccessRequest): Promise<ArtifactDownloadAccess>;
health(): Promise<ProviderHealth>;
close?(): Promise<void>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
capabilities | 方法 | capabilities(): Promise<ArtifactStoreCapabilities> | 公开方法;参数与返回类型以签名列为准。 |
close | 方法 | close?(): Promise<void> | 公开方法;参数与返回类型以签名列为准。 |
copy | 方法 | copy(request: ArtifactCopyRequest): Promise<ArtifactStorageRef> | 公开方法;参数与返回类型以签名列为准。 |
createDownloadAccess | 方法 | createDownloadAccess?(request: ArtifactDownloadAccessRequest): Promise<ArtifactDownloadAccess> | 公开方法;参数与返回类型以签名列为准。 |
delete | 方法 | delete(ref: ArtifactStorageRef): Promise<void> | 公开方法;参数与返回类型以签名列为准。 |
exists | 方法 | exists(ref: ArtifactStorageRef): Promise<boolean> | 公开方法;参数与返回类型以签名列为准。 |
get | 方法 | get(request: ArtifactGetRequest, options?: ArtifactOperationOptions): Promise<ArtifactContent> | 公开方法;参数与返回类型以签名列为准。 |
head | 方法 | head(ref: ArtifactStorageRef): Promise<ArtifactObjectMetadata | null> | 公开方法;参数与返回类型以签名列为准。 |
health | 方法 | health(): Promise<ProviderHealth> | 公开方法;参数与返回类型以签名列为准。 |
id | 属性 | readonly id: string | 公开属性;类型、只读和可选状态以签名列为准。 |
put | 方法 | put(request: ArtifactPutRequest, options?: ArtifactOperationOptions): Promise<ArtifactStorageRef> | 公开方法;参数与返回类型以签名列为准。 |
ArtifactStoreProviderFactory
Artifact Store Provider Factory 接口,共包含 2 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ArtifactStoreProviderFactory } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export interface ArtifactStoreProviderFactory {
readonly providerId: string;
create(): ArtifactStoreProvider | Promise<ArtifactStoreProvider>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
create | 方法 | create(): ArtifactStoreProvider | Promise<ArtifactStoreProvider> | 公开方法;参数与返回类型以签名列为准。 |
providerId | 属性 | readonly providerId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
ArtifactByteSource
Artifact Byte Source 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { ArtifactByteSource } from '@codesoul-co/hypha-core'; - 源码模块:
contracts/artifact-store
声明
text
export type ArtifactByteSource = Uint8Array | AsyncIterable<Uint8Array>;