Skip to content

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

Using this module

Use the Artifact record repository module for declaring and runtime-validating contracts. It exports 2 classes, 5 interfaces.

Import from the package entrypoint

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

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

Usage patterns

  • Use the 5 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 2 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports

SymbolKindSignatureDescription
ArtifactRecordRepositoryConflictErrorclassnew ArtifactRecordRepositoryConflictError(message: string, details?: Record<string, unknown> | undefined): ArtifactRecordRepositoryConflictErrorArtifact Record Repository Conflict Error class with 9 public constructor or member entries; its exact declarations are listed below.
ArtifactRecordRepositoryErrorclassnew ArtifactRecordRepositoryError(code: "ARTIFACT_RECORD_REPOSITORY_UNAVAILABLE" | "ARTIFACT_RECORD_REPOSITORY_CORRUPT", message: string, cause?: unknown | undefined): ArtifactRecordRepositoryErrorArtifact Record Repository Error class with 9 public constructor or member entries; its exact declarations are listed below.
ArtifactIdempotencyRecordinterfaceinterface ArtifactIdempotencyRecordArtifact Idempotency Record interface with 4 public fields or methods.
ArtifactRecordCommitRequestinterfaceinterface ArtifactRecordCommitRequestArtifact Record Commit Request interface with 3 public fields or methods.
ArtifactRecordRepositoryinterfaceinterface ArtifactRecordRepositoryMetadata persistence port for ArtifactManager. Implementations persist records, version/lineage links, and idempotency results, but never Artifact content bytes.
ArtifactRevisionFenceinterfaceinterface ArtifactRevisionFenceArtifact Revision Fence interface with 3 public fields or methods.
StoredArtifactRecordinterfaceinterface StoredArtifactRecordStored Artifact Record interface with 2 public fields or methods.

ArtifactRecordRepositoryConflictError

Artifact Record Repository Conflict Error class with 9 public constructor or member entries; its exact declarations are listed below.

Declaration

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

Public members

MemberKindSignatureDescription
causepropertycause?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
constructorconstructor(message: string, details?: Record<string, unknown> | undefined): ArtifactRecordRepositoryConflictErrorCreates an instance of this class.
detailspropertyreadonly details?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
messagepropertymessage: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
namepropertyname: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stackpropertystack?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
static captureStackTracemethodstatic 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 prepareStackTracemethodstatic prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): anyPublic method; parameters and return type are shown in the signature.
static stackTraceLimitpropertystatic 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 class with 9 public constructor or member entries; its exact declarations are listed below.

Declaration

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);
}

Public members

MemberKindSignatureDescription
causepropertyreadonly cause?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
codepropertyreadonly code: "ARTIFACT_RECORD_REPOSITORY_UNAVAILABLE" | "ARTIFACT_RECORD_REPOSITORY_CORRUPT"Public property; its type, readonly modifier and optionality are shown in the signature.
constructorconstructor(code: "ARTIFACT_RECORD_REPOSITORY_UNAVAILABLE" | "ARTIFACT_RECORD_REPOSITORY_CORRUPT", message: string, cause?: unknown | undefined): ArtifactRecordRepositoryErrorCreates an instance of this class.
messagepropertymessage: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
namepropertyname: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stackpropertystack?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
static captureStackTracemethodstatic 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 prepareStackTracemethodstatic prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): anyPublic method; parameters and return type are shown in the signature.
static stackTraceLimitpropertystatic 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 interface with 4 public fields or methods.

Declaration

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

Contract members

MemberKindSignatureDescription
artifactIdpropertyartifactId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idempotencyKeypropertyidempotencyKey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
operationIdpropertyoperationId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
versionIdpropertyversionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ArtifactRecordCommitRequest

Artifact Record Commit Request interface with 3 public fields or methods.

Declaration

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

Contract members

MemberKindSignatureDescription
expectedLatestpropertyexpectedLatest?: ArtifactRevisionFencePublic property; its type, readonly modifier and optionality are shown in the signature.
idempotencypropertyidempotency?: ArtifactIdempotencyRecordPublic property; its type, readonly modifier and optionality are shown in the signature.
recordspropertyrecords: StoredArtifactRecord[]Public property; its type, readonly modifier and optionality are shown in the signature.

ArtifactRecordRepository

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

Declaration

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>;
}

Contract members

MemberKindSignatureDescription
claimGarbageCollectionmethodclaimGarbageCollection(request: ArtifactGarbageCollectionClaimRequest): Promise<boolean>Public method; parameters and return type are shown in the signature.
closemethodclose?(): Promise<void>Public method; parameters and return type are shown in the signature.
commitmethodcommit(request: ArtifactRecordCommitRequest): Promise<void>Public method; parameters and return type are shown in the signature.
completeGarbageCollectionmethodcompleteGarbageCollection(claimId: string, completedAt: string): Promise<void>Public method; parameters and return type are shown in the signature.
findIdempotencymethodfindIdempotency(operationId: string, idempotencyKey: string): Promise<StoredArtifactRecord | null>Public method; parameters and return type are shown in the signature.
getmethodget(artifactId: string, versionId?: string): Promise<StoredArtifactRecord | null>Public method; parameters and return type are shown in the signature.
getByVersionIdmethodgetByVersionId(versionId: string): Promise<StoredArtifactRecord | null>Public method; parameters and return type are shown in the signature.
healthmethodhealth(): Promise<ProviderHealth>Public method; parameters and return type are shown in the signature.
listmethodlist(): Promise<StoredArtifactRecord[]>Public method; parameters and return type are shown in the signature.
listGarbageCollectionCandidatesmethodlistGarbageCollectionCandidates(request: ArtifactGarbageCollectionScanRequest): Promise<ArtifactGarbageCollectionCandidate[]>Public method; parameters and return type are shown in the signature.
releaseGarbageCollectionmethodreleaseGarbageCollection(claimId: string): Promise<void>Public method; parameters and return type are shown in the signature.

ArtifactRevisionFence

Artifact Revision Fence interface with 3 public fields or methods.

Declaration

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

Contract members

MemberKindSignatureDescription
artifactIdpropertyartifactId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
revisionpropertyrevision: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
versionIdpropertyversionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

StoredArtifactRecord

Stored Artifact Record interface with 2 public fields or methods.

Declaration

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

Contract members

MemberKindSignatureDescription
profileRefpropertyprofileRef: SpecRefPublic property; its type, readonly modifier and optionality are shown in the signature.
recordpropertyrecord: ArtifactRecordPublic property; its type, readonly modifier and optionality are shown in the signature.