@lastshotlabs/slingshot-assets
npm install @lastshotlabs/slingshot-assets
Functions
Section titled “Functions”Assets
Section titled “Assets”Public contract for slingshot-assets.
Cross-package consumers resolve capabilities through ctx.capabilities.require(...):
AssetsRuntimeCap— bundled assets adapter, storage adapter, and config.AssetsHealthCap— aggregated health snapshot getter.AssetsOrphanedKeysCap— recovery-API snapshot of orphaned storage keys.
Source: packages/slingshot-assets/src/public.ts
AssetsHealthCap
Section titled “AssetsHealthCap”Public contract for slingshot-assets.
Cross-package consumers resolve capabilities through ctx.capabilities.require(...):
AssetsRuntimeCap— bundled assets adapter, storage adapter, and config.AssetsHealthCap— aggregated health snapshot getter.AssetsOrphanedKeysCap— recovery-API snapshot of orphaned storage keys.
Source: packages/slingshot-assets/src/public.ts
AssetsOrphanedKeysCap
Section titled “AssetsOrphanedKeysCap”Public contract for slingshot-assets.
Cross-package consumers resolve capabilities through ctx.capabilities.require(...):
AssetsRuntimeCap— bundled assets adapter, storage adapter, and config.AssetsHealthCap— aggregated health snapshot getter.AssetsOrphanedKeysCap— recovery-API snapshot of orphaned storage keys.
Source: packages/slingshot-assets/src/public.ts
AssetsRuntimeCap
Section titled “AssetsRuntimeCap”Public contract for slingshot-assets.
Cross-package consumers resolve capabilities through ctx.capabilities.require(...):
AssetsRuntimeCap— bundled assets adapter, storage adapter, and config.AssetsHealthCap— aggregated health snapshot getter.AssetsOrphanedKeysCap— recovery-API snapshot of orphaned storage keys.
Source: packages/slingshot-assets/src/public.ts
createAssetsPackage
Section titled “createAssetsPackage”Assets package factory.
Creates a SlingshotPackageDefinition that mounts the Asset entity through
the definePackage authoring path, wires storage / image cache / S3 circuit
breaker, registers the storage-delete middleware that cascades to the object
store on entity delete, and publishes capabilities for the runtime, health
snapshot, and orphaned-key recovery API.
Every adapter ref, middleware closure, and registry instance is owned by the factory’s closure (Rule 3) — multiple package instances in the same process do not share state.
function createAssetsPackage(rawConfig: AssetsPluginConfig, deps: AssetsPackageDeps = {},): SlingshotPackageDefinitionSource: packages/slingshot-assets/src/plugin.ts
createOrphanedKeyRegistry
Section titled “createOrphanedKeyRegistry”Recovery API for orphaned-key reconciliation. Apps can fetch the in-memory orphan list to re-attempt manual cleanup or to expose a dashboard view.
The list is bounded — the oldest entries are evicted once maxRecords is
exceeded — so this is not durable storage. Apps that need persistence
MUST wire onOrphanedKey to push records onto an external queue.
function createOrphanedKeyRegistry(maxRecords = 1000): OrphanedKeyRegistrySource: packages/slingshot-assets/src/middleware/deleteStorageFile.ts
localStorage
Section titled “localStorage”Default RuntimeFs implementation using Bun’s file APIs.
function localStorage(config: LocalStorageConfig): LocalStorageAdapterSource: packages/slingshot-assets/src/adapters/local.ts
memoryStorage
Section titled “memoryStorage”Structured error thrown when the memory storage circuit breaker is open.
Callers can pattern-match on code === 'MEMORY_CIRCUIT_OPEN' to fail fast.
function memoryStorage(options: { /** * Circuit breaker — number of consecutive operation failures before the * breaker opens and short-circuits subsequent calls. Default: 5. */ readonly circuitBreakerThreshold?: number; /** * Circuit breaker — cooldown duration in ms before allowing a half-open * probe after the breaker opens. Default: 30 000 ms. */ readonly circuitBreakerCooldownMs?: number; /** * Circuit breaker — clock used for cooldown comparisons. Override in tests * for deterministic state machines. Default: `Date.now`. */ readonly now?: () => number; } = {},): MemoryStorageAdapterSource: packages/slingshot-assets/src/adapters/memory.ts
resolveStorageAdapter
Section titled “resolveStorageAdapter”Optional override options for built-in adapter resolution.
function resolveStorageAdapter(ref: StorageAdapter | StorageAdapterRef, options?: ResolveStorageAdapterOptions,): StorageAdapterSource: packages/slingshot-assets/src/adapters/index.ts
s3Storage
Section titled “s3Storage”Static AWS credentials object. Use this only when credentials never change
during the process lifetime. For long-running services prefer a
AwsCredentialProvider so STS/EC2/ECS rotation is honored.
function s3Storage(config: S3StorageConfig): S3StorageAdapterSource: packages/slingshot-assets/src/adapters/s3.ts
Classes
Section titled “Classes”ImageTransformError
Section titled “ImageTransformError”Supported output image formats for the asset image handler.
Source: packages/slingshot-assets/src/image/types.ts
ImageTransformTimeoutError
Section titled “ImageTransformTimeoutError”Supported output image formats for the asset image handler.
Source: packages/slingshot-assets/src/image/types.ts
LocalCircuitOpenError
Section titled “LocalCircuitOpenError”Default RuntimeFs implementation using Bun’s file APIs.
Source: packages/slingshot-assets/src/adapters/local.ts
MemoryCircuitOpenError
Section titled “MemoryCircuitOpenError”Structured error thrown when the memory storage circuit breaker is open.
Callers can pattern-match on code === 'MEMORY_CIRCUIT_OPEN' to fail fast.
Source: packages/slingshot-assets/src/adapters/memory.ts
S3CircuitOpenError
Section titled “S3CircuitOpenError”Static AWS credentials object. Use this only when credentials never change
during the process lifetime. For long-running services prefer a
AwsCredentialProvider so STS/EC2/ECS rotation is honored.
Source: packages/slingshot-assets/src/adapters/s3.ts
Interfaces
Section titled “Interfaces”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
AssetAdapter
Section titled “AssetAdapter”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
AssetBeforeUploadInput
Section titled “AssetBeforeUploadInput”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
AssetsHealth
Section titled “AssetsHealth”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
AssetsHealthDetails
Section titled “AssetsHealthDetails”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
AssetsPackageDeps
Section titled “AssetsPackageDeps”Assets package factory.
Creates a SlingshotPackageDefinition that mounts the Asset entity through
the definePackage authoring path, wires storage / image cache / S3 circuit
breaker, registers the storage-delete middleware that cascades to the object
store on entity delete, and publishes capabilities for the runtime, health
snapshot, and orphaned-key recovery API.
Every adapter ref, middleware closure, and registry instance is owned by the factory’s closure (Rule 3) — multiple package instances in the same process do not share state.
Source: packages/slingshot-assets/src/plugin.ts
AssetsPluginConfig
Section titled “AssetsPluginConfig”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
AssetsPluginState
Section titled “AssetsPluginState”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
AwsStaticCredentials
Section titled “AwsStaticCredentials”Static AWS credentials object. Use this only when credentials never change
during the process lifetime. For long-running services prefer a
AwsCredentialProvider so STS/EC2/ECS rotation is honored.
Source: packages/slingshot-assets/src/adapters/s3.ts
CreateAssetInput
Section titled “CreateAssetInput”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
ImageConfig
Section titled “ImageConfig”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
LocalCircuitBreakerHealth
Section titled “LocalCircuitBreakerHealth”Default RuntimeFs implementation using Bun’s file APIs.
Source: packages/slingshot-assets/src/adapters/local.ts
LocalStorageAdapter
Section titled “LocalStorageAdapter”Default RuntimeFs implementation using Bun’s file APIs.
Source: packages/slingshot-assets/src/adapters/local.ts
LocalStorageConfig
Section titled “LocalStorageConfig”Default RuntimeFs implementation using Bun’s file APIs.
Source: packages/slingshot-assets/src/adapters/local.ts
MemoryCircuitBreakerHealth
Section titled “MemoryCircuitBreakerHealth”Structured error thrown when the memory storage circuit breaker is open.
Callers can pattern-match on code === 'MEMORY_CIRCUIT_OPEN' to fail fast.
Source: packages/slingshot-assets/src/adapters/memory.ts
MemoryStorageAdapter
Section titled “MemoryStorageAdapter”Structured error thrown when the memory storage circuit breaker is open.
Callers can pattern-match on code === 'MEMORY_CIRCUIT_OPEN' to fail fast.
Source: packages/slingshot-assets/src/adapters/memory.ts
OrphanedKeyRecord
Section titled “OrphanedKeyRecord”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
OrphanedKeyRegistry
Section titled “OrphanedKeyRegistry”Recovery API for orphaned-key reconciliation. Apps can fetch the in-memory orphan list to re-attempt manual cleanup or to expose a dashboard view.
The list is bounded — the oldest entries are evicted once maxRecords is
exceeded — so this is not durable storage. Apps that need persistence
MUST wire onOrphanedKey to push records onto an external queue.
Source: packages/slingshot-assets/src/middleware/deleteStorageFile.ts
PresignedUrlConfig
Section titled “PresignedUrlConfig”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
S3CircuitBreakerHealth
Section titled “S3CircuitBreakerHealth”Static AWS credentials object. Use this only when credentials never change
during the process lifetime. For long-running services prefer a
AwsCredentialProvider so STS/EC2/ECS rotation is honored.
Source: packages/slingshot-assets/src/adapters/s3.ts
S3StorageAdapter
Section titled “S3StorageAdapter”Static AWS credentials object. Use this only when credentials never change
during the process lifetime. For long-running services prefer a
AwsCredentialProvider so STS/EC2/ECS rotation is honored.
Source: packages/slingshot-assets/src/adapters/s3.ts
S3StorageConfig
Section titled “S3StorageConfig”Static AWS credentials object. Use this only when credentials never change
during the process lifetime. For long-running services prefer a
AwsCredentialProvider so STS/EC2/ECS rotation is honored.
Source: packages/slingshot-assets/src/adapters/s3.ts
StorageAdapterRef
Section titled “StorageAdapterRef”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
UpdateAssetInput
Section titled “UpdateAssetInput”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
AssetBeforeUploadHook
Section titled “AssetBeforeUploadHook”Reference to a built-in storage adapter resolved by name.
Use this shape in config-driven mode to resolve a built-in storage adapter without passing a runtime object instance.
Source: packages/slingshot-assets/src/types.ts
AwsCredentialProvider
Section titled “AwsCredentialProvider”Static AWS credentials object. Use this only when credentials never change
during the process lifetime. For long-running services prefer a
AwsCredentialProvider so STS/EC2/ECS rotation is honored.
Source: packages/slingshot-assets/src/adapters/s3.ts