Skip to content

@codesoul-co/hypha-adapters-local / local-artifact-files ​

Using this module ​

Use the Local artifact files module for using the public contracts and operations for this capability boundary. It exports 2 classes, 13 functions, 2 interfaces.

Import from the package entrypoint ​

ts
import {
  LocalArtifactIntegrityError,
  LocalArtifactTransferAbortedError,
  ensureSafeLocalArtifactDirectory,
  ensureSafeLocalArtifactFile,
  hashLocalArtifactFile,
  isNodeError,
  listLocalArtifactFiles,
  localArtifactBlobPath,
} from '@codesoul-co/hypha-adapters-local';

import type {
  LocalArtifactStorePaths,
  LocalArtifactTempFile,
} from '@codesoul-co/hypha-adapters-local';

// The complete export list is documented below.

Usage patterns ​

  • Use the 2 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.
  • The module exposes 13 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports ​

SymbolKindSignatureDescription
LocalArtifactIntegrityErrorclassnew LocalArtifactIntegrityError(message: string): LocalArtifactIntegrityErrorLocal Artifact Integrity Error class with 8 public constructor or member entries; its exact declarations are listed below.
LocalArtifactTransferAbortedErrorclassnew LocalArtifactTransferAbortedError(): LocalArtifactTransferAbortedErrorLocal Artifact Transfer Aborted Error class with 9 public constructor or member entries; its exact declarations are listed below.
ensureSafeLocalArtifactDirectoryfunctionensureSafeLocalArtifactDirectory(root: string, directory: string): Promise<void>Ensure Safe Local Artifact Directory function with 1 public call signature; parameters and return types are listed below.
ensureSafeLocalArtifactFilefunctionensureSafeLocalArtifactFile(root: string, filename: string): Promise<void>Ensure Safe Local Artifact File function with 1 public call signature; parameters and return types are listed below.
hashLocalArtifactFilefunctionhashLocalArtifactFile(filename: string, root?: string, abortSignal?: AbortSignal): Promise<{ contentHash: string; sizeBytes: number; }>Hash Local Artifact File function with 1 public call signature; parameters and return types are listed below.
isNodeErrorfunctionisNodeError(error: unknown, code: string): booleanIs Node Error function with 1 public call signature; parameters and return types are listed below.
listLocalArtifactFilesfunctionlistLocalArtifactFiles(root: string, extension?: string): Promise<string[]>List Local Artifact Files function with 1 public call signature; parameters and return types are listed below.
localArtifactBlobPathfunctionlocalArtifactBlobPath(paths: LocalArtifactStorePaths, contentHash: string): stringLocal Artifact Blob Path function with 1 public call signature; parameters and return types are listed below.
localArtifactManifestPathfunctionlocalArtifactManifestPath(paths: LocalArtifactStorePaths, objectKey: string): stringLocal Artifact Manifest Path function with 1 public call signature; parameters and return types are listed below.
pathExistsfunctionpathExists(filename: string): Promise<boolean>Path Exists function with 1 public call signature; parameters and return types are listed below.
prepareLocalArtifactStorefunctionprepareLocalArtifactStore(rootPath: string): Promise<LocalArtifactStorePaths>Prepare Local Artifact Store function with 1 public call signature; parameters and return types are listed below.
publishLocalArtifactBlobfunctionpublishLocalArtifactBlob(root: string, temporaryPath: string, blobPath: string, expectedHash: string, expectedSizeBytes: number): Promise<void>Publish Local Artifact Blob function with 1 public call signature; parameters and return types are listed below.
streamLocalArtifactFilefunctionstreamLocalArtifactFile(filename: string, range?: ArtifactByteRange, root?: string, abortSignal?: AbortSignal): AsyncIterable<Uint8Array>Stream Local Artifact File function with 1 public call signature; parameters and return types are listed below.
writeJsonAtomicallyfunctionwriteJsonAtomically(root: string, filename: string, value: unknown, options?: { ifAbsent?: boolean; }): Promise<void>Write JSON Atomically function with 1 public call signature; parameters and return types are listed below.
writeLocalArtifactTempFilefunctionwriteLocalArtifactTempFile(source: ArtifactByteSource, paths: LocalArtifactStorePaths, maxBytes: number, abortSignal?: AbortSignal): Promise<LocalArtifactTempFile>Write Local Artifact Temp File function with 1 public call signature; parameters and return types are listed below.
LocalArtifactStorePathsinterfaceinterface LocalArtifactStorePathsLocal Artifact Store Paths interface with 4 public fields or methods.
LocalArtifactTempFileinterfaceinterface LocalArtifactTempFileLocal Artifact Temp File interface with 3 public fields or methods.

LocalArtifactIntegrityError ​

Local Artifact Integrity Error class with 8 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { LocalArtifactIntegrityError } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare class LocalArtifactIntegrityError extends Error {
    constructor(message: string);
}

Public members ​

MemberKindSignatureDescription
causepropertycause?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
constructorconstructor(message: string): LocalArtifactIntegrityErrorCreates 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.

LocalArtifactTransferAbortedError ​

Local Artifact Transfer Aborted Error class with 9 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { LocalArtifactTransferAbortedError } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare class LocalArtifactTransferAbortedError extends Error {
    readonly code = "LOCAL_ARTIFACT_TRANSFER_ABORTED";
    constructor();
}

Public members ​

MemberKindSignatureDescription
causepropertycause?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
codepropertyreadonly code: "LOCAL_ARTIFACT_TRANSFER_ABORTED"Public property; its type, readonly modifier and optionality are shown in the signature.
constructorconstructor(): LocalArtifactTransferAbortedErrorCreates 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.

ensureSafeLocalArtifactDirectory ​

Ensure Safe Local Artifact Directory function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { ensureSafeLocalArtifactDirectory } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function ensureSafeLocalArtifactDirectory(root: string, directory: string): Promise<void>;

Call signature ​

text
ensureSafeLocalArtifactDirectory(root: string, directory: string): Promise<void>

Parameters ​

ParameterTypeRequiredDescription
rootstringYesRequired parameter; accepted values are defined by the type column.
directorystringYesRequired parameter; accepted values are defined by the type column.

Returns ​

  • Type: Promise<void>
  • Description: The return contract is defined by the type shown above.

ensureSafeLocalArtifactFile ​

Ensure Safe Local Artifact File function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { ensureSafeLocalArtifactFile } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function ensureSafeLocalArtifactFile(root: string, filename: string): Promise<void>;

Call signature ​

text
ensureSafeLocalArtifactFile(root: string, filename: string): Promise<void>

Parameters ​

ParameterTypeRequiredDescription
rootstringYesRequired parameter; accepted values are defined by the type column.
filenamestringYesRequired parameter; accepted values are defined by the type column.

Returns ​

  • Type: Promise<void>
  • Description: The return contract is defined by the type shown above.

hashLocalArtifactFile ​

Hash Local Artifact File function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { hashLocalArtifactFile } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function hashLocalArtifactFile(filename: string, root?: string, abortSignal?: AbortSignal): Promise<{
    contentHash: string;
    sizeBytes: number;
}>;

Call signature ​

text
hashLocalArtifactFile(filename: string, root?: string, abortSignal?: AbortSignal): Promise<{ contentHash: string; sizeBytes: number; }>

Parameters ​

ParameterTypeRequiredDescription
filenamestringYesRequired parameter; accepted values are defined by the type column.
rootstringNoOptional parameter; accepted values are defined by the type column.
abortSignalAbortSignalNoOptional parameter; accepted values are defined by the type column.

Returns ​

  • Type: Promise<{ contentHash: string; sizeBytes: number; }>
  • Description: The return contract is defined by the type shown above.

isNodeError ​

Is Node Error function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { isNodeError } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function isNodeError(error: unknown, code: string): boolean;

Call signature ​

text
isNodeError(error: unknown, code: string): boolean

Parameters ​

ParameterTypeRequiredDescription
errorunknownYesRequired parameter; accepted values are defined by the type column.
codestringYesRequired parameter; accepted values are defined by the type column.

Returns ​

  • Type: boolean
  • Description: The return contract is defined by the type shown above.

listLocalArtifactFiles ​

List Local Artifact Files function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { listLocalArtifactFiles } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function listLocalArtifactFiles(root: string, extension?: string): Promise<string[]>;

Call signature ​

text
listLocalArtifactFiles(root: string, extension?: string): Promise<string[]>

Parameters ​

ParameterTypeRequiredDescription
rootstringYesRequired parameter; accepted values are defined by the type column.
extensionstringNoOptional parameter; accepted values are defined by the type column.

Returns ​

  • Type: Promise<string[]>
  • Description: The return contract is defined by the type shown above.

localArtifactBlobPath ​

Local Artifact Blob Path function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { localArtifactBlobPath } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function localArtifactBlobPath(paths: LocalArtifactStorePaths, contentHash: string): string;

Call signature ​

text
localArtifactBlobPath(paths: LocalArtifactStorePaths, contentHash: string): string

Parameters ​

ParameterTypeRequiredDescription
pathsLocalArtifactStorePathsYesRequired parameter; accepted values are defined by the type column.
contentHashstringYesRequired parameter; accepted values are defined by the type column.

Returns ​

  • Type: string
  • Description: The return contract is defined by the type shown above.

localArtifactManifestPath ​

Local Artifact Manifest Path function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { localArtifactManifestPath } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function localArtifactManifestPath(paths: LocalArtifactStorePaths, objectKey: string): string;

Call signature ​

text
localArtifactManifestPath(paths: LocalArtifactStorePaths, objectKey: string): string

Parameters ​

ParameterTypeRequiredDescription
pathsLocalArtifactStorePathsYesRequired parameter; accepted values are defined by the type column.
objectKeystringYesRequired parameter; accepted values are defined by the type column.

Returns ​

  • Type: string
  • Description: The return contract is defined by the type shown above.

pathExists ​

Path Exists function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { pathExists } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function pathExists(filename: string): Promise<boolean>;

Call signature ​

text
pathExists(filename: string): Promise<boolean>

Parameters ​

ParameterTypeRequiredDescription
filenamestringYesRequired parameter; accepted values are defined by the type column.

Returns ​

  • Type: Promise<boolean>
  • Description: The return contract is defined by the type shown above.

prepareLocalArtifactStore ​

Prepare Local Artifact Store function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { prepareLocalArtifactStore } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function prepareLocalArtifactStore(rootPath: string): Promise<LocalArtifactStorePaths>;

Call signature ​

text
prepareLocalArtifactStore(rootPath: string): Promise<LocalArtifactStorePaths>

Parameters ​

ParameterTypeRequiredDescription
rootPathstringYesRequired parameter; accepted values are defined by the type column.

Returns ​

  • Type: Promise<LocalArtifactStorePaths>
  • Description: The return contract is defined by the type shown above.

publishLocalArtifactBlob ​

Publish Local Artifact Blob function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { publishLocalArtifactBlob } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function publishLocalArtifactBlob(root: string, temporaryPath: string, blobPath: string, expectedHash: string, expectedSizeBytes: number): Promise<void>;

Call signature ​

text
publishLocalArtifactBlob(root: string, temporaryPath: string, blobPath: string, expectedHash: string, expectedSizeBytes: number): Promise<void>

Parameters ​

ParameterTypeRequiredDescription
rootstringYesRequired parameter; accepted values are defined by the type column.
temporaryPathstringYesRequired parameter; accepted values are defined by the type column.
blobPathstringYesRequired parameter; accepted values are defined by the type column.
expectedHashstringYesRequired parameter; accepted values are defined by the type column.
expectedSizeBytesnumberYesRequired parameter; accepted values are defined by the type column.

Returns ​

  • Type: Promise<void>
  • Description: The return contract is defined by the type shown above.

streamLocalArtifactFile ​

Stream Local Artifact File function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { streamLocalArtifactFile } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function streamLocalArtifactFile(filename: string, range?: ArtifactByteRange, root?: string, abortSignal?: AbortSignal): AsyncIterable<Uint8Array>;

Call signature ​

text
streamLocalArtifactFile(filename: string, range?: ArtifactByteRange, root?: string, abortSignal?: AbortSignal): AsyncIterable<Uint8Array>

Parameters ​

ParameterTypeRequiredDescription
filenamestringYesRequired parameter; accepted values are defined by the type column.
rangeArtifactByteRangeNoOptional parameter; accepted values are defined by the type column.
rootstringNoOptional parameter; accepted values are defined by the type column.
abortSignalAbortSignalNoOptional parameter; accepted values are defined by the type column.

Returns ​

  • Type: AsyncIterable<Uint8Array<ArrayBufferLike>>
  • Description: The return contract is defined by the type shown above.

writeJsonAtomically ​

Write JSON Atomically function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { writeJsonAtomically } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function writeJsonAtomically(root: string, filename: string, value: unknown, options?: {
    ifAbsent?: boolean;
}): Promise<void>;

Call signature ​

text
writeJsonAtomically(root: string, filename: string, value: unknown, options?: { ifAbsent?: boolean; }): Promise<void>

Parameters ​

ParameterTypeRequiredDescription
rootstringYesRequired parameter; accepted values are defined by the type column.
filenamestringYesRequired parameter; accepted values are defined by the type column.
valueunknownYesRequired parameter; accepted values are defined by the type column.
options{ ifAbsent?: boolean; }NoOptional parameter; accepted values are defined by the type column.

Returns ​

  • Type: Promise<void>
  • Description: The return contract is defined by the type shown above.

writeLocalArtifactTempFile ​

Write Local Artifact Temp File function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { writeLocalArtifactTempFile } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export declare function writeLocalArtifactTempFile(source: ArtifactByteSource, paths: LocalArtifactStorePaths, maxBytes: number, abortSignal?: AbortSignal): Promise<LocalArtifactTempFile>;

Call signature ​

text
writeLocalArtifactTempFile(source: ArtifactByteSource, paths: LocalArtifactStorePaths, maxBytes: number, abortSignal?: AbortSignal): Promise<LocalArtifactTempFile>

Parameters ​

ParameterTypeRequiredDescription
sourceArtifactByteSourceYesRequired parameter; accepted values are defined by the type column.
pathsLocalArtifactStorePathsYesRequired parameter; accepted values are defined by the type column.
maxBytesnumberYesRequired parameter; accepted values are defined by the type column.
abortSignalAbortSignalNoOptional parameter; accepted values are defined by the type column.

Returns ​

  • Type: Promise<LocalArtifactTempFile>
  • Description: The return contract is defined by the type shown above.

LocalArtifactStorePaths ​

Local Artifact Store Paths interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { LocalArtifactStorePaths } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export interface LocalArtifactStorePaths {
    root: string;
    blobs: string;
    objects: string;
    temporary: string;
}

Contract members ​

MemberKindSignatureDescription
blobspropertyblobs: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
objectspropertyobjects: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
rootpropertyroot: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
temporarypropertytemporary: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

LocalArtifactTempFile ​

Local Artifact Temp File interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { LocalArtifactTempFile } from '@codesoul-co/hypha-adapters-local';
  • Source module: local-artifact-files

Declaration ​

text
export interface LocalArtifactTempFile {
    path: string;
    contentHash: string;
    sizeBytes: number;
}

Contract members ​

MemberKindSignatureDescription
contentHashpropertycontentHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
pathpropertypath: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sizeBytespropertysizeBytes: numberPublic property; its type, readonly modifier and optionality are shown in the signature.