/** * Storage submodule — zero-native-dependency entry point. * * Exports the `Storage` interface, `KEYS` key-encoding helpers, * and `MemoryStorage`. These have no native dependencies and are * safe to import in any environment including browsers. * * For backends or wrappers that have runtime dependencies, use the * per-backend subpaths: * * ```ts * import { CompressedStorage } from '@lostgradient/weft/storage/compressed'; // requires node:zlib / Bun * import { SQLiteStorage } from '@lostgradient/weft/storage/sqlite'; // Bun or Node SQLite * import { LMDBStorage } from '@lostgradient/weft/storage/lmdb'; // peer: lmdb * import { TursoStorage } from '@lostgradient/weft/storage/turso'; // peer: @libsql/client * import { NeonStorage } from '@lostgradient/weft/storage/neon'; // peer: @neondatabase/serverless * import { CloudflareDurableObjectSQLiteStorage } from '@lostgradient/weft/storage/cloudflare'; // caller-injected `sql` binding, zero runtime deps * import { IndexedDBStorage } from '@lostgradient/weft/storage/indexeddb'; // browser-only * import { WebExtensionStorage } from '@lostgradient/weft/storage/web-extension'; // extension-only * import { HTTPStorage } from '@lostgradient/weft/storage/http'; // remote storage * ``` * * @module @lostgradient/weft/storage */ import { storageDeleteRange } from './delete-range'; import { assertDurableStorageForRecovery, assertStorageBatchOperationCount, requireStorageCapability, storageBatch, StorageBatchOperationLimitExceededError, storageConditionalBatch, storageValuesEqual } from './interface'; import { MemoryStorage } from './memory'; import { resolveStorage } from './resolve'; import { ScopedStorage, scopedStorage } from './scoped-storage'; import { copyTextKeyValueRowsToStorage } from './text-value-import'; import { textValueStore } from './text-value-store'; import { jsonCodec, msgpackCodec, withCodec } from './typed-storage'; /** * Re-exported {@link jsonCodec}. See the original declaration for full docs. * * @example * ```ts * import { jsonCodec } from '@lostgradient/weft/storage'; * const codec = jsonCodec(); * void codec; * ``` */ declare const exportedJsonCodec: typeof jsonCodec; /** * Re-exported {@link assertDurableStorageForRecovery}. See the original declaration for full docs. * * @example * ```ts * import { assertDurableStorageForRecovery } from '@lostgradient/weft/storage'; * import { SQLiteStorage } from '@lostgradient/weft/storage/sqlite'; * * await using storage = new SQLiteStorage('./weft.db'); * assertDurableStorageForRecovery(storage); * ``` */ declare const exportedAssertDurableStorageForRecovery: typeof assertDurableStorageForRecovery; /** * Re-exported {@link copyTextKeyValueRowsToStorage}. See the original declaration for full docs. * * @example * ```ts * import { MemoryStorage, copyTextKeyValueRowsToStorage } from '@lostgradient/weft/storage'; * * await using storage = new MemoryStorage(); * const result = await copyTextKeyValueRowsToStorage({ * storage, * rows: [{ key: 'session:1', value: 'active' }], * targetPrefix: 'app:my-service', * }); * void result; * ``` */ declare const exportedCopyTextKeyValueRowsToStorage: typeof copyTextKeyValueRowsToStorage; /** * Re-exported {@link KEYS}. See the original declaration for full docs. * * @example * ```ts * import { KEYS } from '@lostgradient/weft/storage'; * const key = KEYS.workflow('wf-1'); * void key; * ``` */ declare const exportedKeys: { readonly workflow: (id: string) => string; readonly checkpoint: (id: string) => string; readonly checkpointHistory: (id: string, step: number) => string; readonly timelinePrefix: (id: string) => string; readonly timeline: (id: string, step: number) => string; readonly schedule: (id: string) => string; readonly scheduleTick: (fireAt: number, id: string) => string; readonly scheduleRun: (workflowId: string) => string; readonly scheduleRunLink: (workflowId: string) => string; readonly scheduleRunBySchedulePrefix: (scheduleId: string) => string; readonly scheduleRunBySchedule: (scheduleId: string, workflowId: string) => string; readonly operation: (queue: string, scheduledAt: number, id: string) => string; readonly operationInflight: (id: string) => string; readonly operationQueued: (id: string) => string; readonly operationResolved: (id: string) => string; readonly bulkOperationAuditPrefix: () => string; readonly bulkOperationAudit: (timestamp: number, requestId: string, confirmationToken: string) => string; readonly operationResolvedByTimePrefix: () => string; readonly operationResolvedByTime: (resolvedAt: number, id: string) => string; readonly asyncActivity: (workflowId: string, token: string) => string; readonly asyncActivityResolution: (workflowId: string, token: string) => string; readonly activityReconciliationPrefix: (workflowId: string) => string; readonly activityReconciliation: (workflowId: string, activityName: string, idempotencyKeyDigest: string) => string; readonly eventPrefix: (workflowId: string) => string; readonly event: (workflowId: string, sequence: number) => string; readonly eventHead: (workflowId: string) => string; readonly eventWatermark: (workflowId: string) => string; readonly fleetEventPrefix: () => string; readonly fleetEvent: (sequence: number) => string; readonly fleetEventTail: () => string; readonly fleetEventWatermark: () => string; readonly fleetEventByWorkflowPrefix: (workflowId: string) => string; readonly fleetEventByWorkflow: (workflowId: string, sequence: number) => string; } & { readonly signal: (workflowId: string, name: string, id: string) => string; readonly startSignal: (workflowId: string, name: string, id: string) => string; readonly signalSequence: (workflowId: string) => string; readonly signalAcceptedResponsePrefix: (workflowId: string) => string; readonly signalAcceptedResponse: (workflowId: string, name: string, signalId: string) => string; } & { readonly deadline: (deadline: number, workflowId: string) => string; readonly terminalCleanup: (fireAt: number, timerId: string) => string; readonly teardownTimer: (fireAt: number, timerId: string) => string; readonly delayedStart: (startAt: number, workflowId: string) => string; readonly terminalWorkflowPrefix: () => string; readonly terminalWorkflow: (updatedAt: number, workflowId: string) => string; } & { readonly attribute: (workflowId: string) => string; readonly attributeIndex: (attributeName: string, encodedValue: string, workflowId: string) => string; readonly tagIndex: (tag: string, workflowId: string) => string; readonly updatePrefix: (workflowId: string) => string; readonly update: (workflowId: string, updateId: string) => string; readonly updateResponse: (updateId: string) => string; readonly updateIdempotency: (workflowId: string, key: string) => string; readonly startIdempotency: (key: string) => string; readonly startIdempotencySignalId: (key: string) => string; } & { readonly livenessPrefix: () => string; readonly liveness: (instanceId: string) => string; readonly leasePrefix: () => string; readonly leaseEpoch: () => string; readonly leaseHolder: () => string; } & { readonly applicationMailbox: (namespace: string, resourceId: string) => string; readonly applicationMailboxSinkProbe: (namespace: string, resourceId: string, nonce: string) => string; readonly applicationCommandPrefix: (namespace: string, resourceId: string) => string; readonly applicationCommand: (namespace: string, resourceId: string, commandId: string) => string; readonly applicationCommandReadyPrefix: (namespace: string, resourceId: string) => string; readonly applicationCommandReady: (namespace: string, resourceId: string, sequence: number) => string; readonly applicationCommandIdempotency: (namespace: string, resourceId: string, key: string) => string; readonly applicationCommandBySequencePrefix: (namespace: string, resourceId: string) => string; readonly applicationCommandBySequence: (namespace: string, resourceId: string, sequence: number) => string; readonly applicationCommandTerminalPrefix: (namespace: string, resourceId: string) => string; readonly applicationCommandTerminal: (namespace: string, resourceId: string, terminalAt: number, commandId: string) => string; } & { readonly applicationOutbox: (namespace: string, ownerId: string) => string; readonly applicationOutboxSinkProbe: (namespace: string, ownerId: string, nonce: string) => string; readonly applicationDeliveryPrefix: (namespace: string, ownerId: string) => string; readonly applicationDelivery: (namespace: string, ownerId: string, deliveryId: string) => string; readonly applicationDeliveryDuePrefix: (namespace: string, ownerId: string) => string; readonly applicationDeliveryDue: (namespace: string, ownerId: string, availableAt: number, deliveryId: string) => string; readonly applicationDeliveryIdempotency: (namespace: string, ownerId: string, key: string) => string; readonly applicationDeliveryBySequencePrefix: (namespace: string, ownerId: string) => string; readonly applicationDeliveryBySequence: (namespace: string, ownerId: string, sequence: number) => string; readonly applicationDeliveryTerminalPrefix: (namespace: string, ownerId: string) => string; readonly applicationDeliveryTerminal: (namespace: string, ownerId: string, terminalAt: number, deliveryId: string) => string; } & { readonly workflowOwnerEpoch: (workflowId: string) => string; readonly workflowOwnerHolder: (workflowId: string) => string; readonly ownershipModeMarker: () => string; } & { readonly catalogEntry: (name: string, revision: string) => string; readonly catalogEntryPrefix: (name: string) => string; readonly catalogActive: (name: string) => string; readonly catalogTombstone: (name: string, revision: string) => string; readonly catalogTombstonePrefix: () => string; readonly catalogRemovalGeneration: (name: string, revision: string) => string; } & { readonly workflowGeneration: (workflowId: string) => string; } & { readonly budget: (namespace: string, period: string, date: string) => string; readonly review: (workflowId: string, reviewId: string) => string; readonly workflowHeaders: (workflowId: string) => string; readonly childCancellationPrefix: (workflowId: string) => string; readonly childCancellation: (workflowId: string, childWorkflowId: string) => string; readonly childWorkflowByParentPrefix: (parentWorkflowId: string, parentWorkflowExecutionToken?: string) => string; readonly childWorkflowByParent: (parentWorkflowId: string, parentWorkflowExecutionToken: string | undefined, childWorkflowId: string) => string; readonly terminalCleanupNeeded: (workflowId: string) => string; readonly workflowConcurrency: (workflowType: string, partitionKey: string) => string; readonly workflowConcurrencyHolder: (workflowId: string) => string; readonly workflowHasServices: (workflowId: string) => string; readonly finalizerState: (workflowId: string) => string; readonly teardownOwed: (workflowId: string) => string; readonly teardownSucceeded: (workflowId: string) => string; readonly teardownDeadLetter: (workflowId: string) => string; readonly teardownDeadLetterPrefix: () => string; readonly teardownDeadLetterHistory: (workflowId: string, workflowExecutionToken: string) => string; readonly teardownDeadLetterHistoryPrefix: () => string; readonly offload: (workflowId: string, key: string) => string; readonly archive: (workflowId: string, key: string) => string; readonly stateExecution: (ownerWorkflowId: string, key: string) => string; readonly stateWorkflow: (workflowType: string, key: string) => string; readonly streamChunkPrefix: (workflowId: string, key: string) => string; readonly streamChunk: (workflowId: string, key: string, chunkIndex: number) => string; readonly streamTail: (workflowId: string, key: string) => string; readonly streamMetadata: (workflowId: string, key: string) => string; readonly budgetCharged: (operationId: string) => string; readonly toolEffect: (workflowId: string, agentId: string, semanticHash: string) => string; readonly workflowVisibilityStatus: (status: string, workflowId: string) => string; readonly workflowVisibilityType: (type: string, workflowId: string) => string; readonly workflowVisibilityCreated: (createdAt: number, workflowId: string) => string; readonly workflowVisibilityUpdated: (updatedAt: number, workflowId: string) => string; readonly workflowVisibilityDeadline: (deadline: number, workflowId: string) => string; readonly workflowVisibilityManifest: (workflowId: string) => string; readonly workflowVisibilityMetaVersion: () => string; readonly workflowVisibilityMetaBuiltAt: () => string; readonly workflowVisibilityMetaCursor: () => string; }; /** * Re-exported {@link MAX_BATCH_OPERATIONS}. See the original declaration for full docs. * * @example * ```ts * import { MAX_BATCH_OPERATIONS } from '@lostgradient/weft/storage'; * console.log(MAX_BATCH_OPERATIONS); * ``` */ declare const exportedMaxBatchOperations = 10000; /** * Re-exported {@link MAX_SCAN_LIMIT}. See the original declaration for full docs. * * @example * ```ts * import { MAX_SCAN_LIMIT } from '@lostgradient/weft/storage'; * console.log(MAX_SCAN_LIMIT); * ``` */ declare const exportedMaxScanLimit = 10000; /** * Re-exported {@link MemoryStorage}. See the original declaration for full docs. * * @example * ```ts * import { MemoryStorage } from '@lostgradient/weft/storage'; * await using storage = new MemoryStorage(); * void storage; * ``` */ declare const exportedMemoryStorage: typeof MemoryStorage; /** * Re-exported {@link msgpackCodec}. See the original declaration for full docs. * * @example * ```ts * import { msgpackCodec } from '@lostgradient/weft/storage'; * const codec = msgpackCodec(); * void codec; * ``` */ declare const exportedMsgpackCodec: typeof msgpackCodec; /** * Re-exported {@link resolveStorage}. See the original declaration for full docs. * * @example * ```ts * import { resolveStorage } from '@lostgradient/weft/storage'; * const storage = await resolveStorage({ type: 'memory' }); * void storage; * ``` */ declare const exportedResolveStorage: typeof resolveStorage; /** * Re-exported {@link ScopedStorage}. See the original declaration for full docs. * * @example * ```ts * import { MemoryStorage, ScopedStorage } from '@lostgradient/weft/storage'; * await using base = new MemoryStorage(); * const scoped = new ScopedStorage(base, 'scope:'); * void scoped; * ``` */ declare const exportedScopedStorage: typeof ScopedStorage; /** * Re-exported {@link scopedStorage}. See the original declaration for full docs. * * @example * ```ts * import { MemoryStorage, scopedStorage } from '@lostgradient/weft/storage'; * await using base = new MemoryStorage(); * const scoped = scopedStorage(base, 'scope:'); * void scoped; * ``` */ declare const exportedScopedStorageFactory: typeof scopedStorage; /** * Re-exported {@link assertStorageBatchOperationCount}. See the original declaration for full docs. * * @example * ```ts * import { assertStorageBatchOperationCount } from '@lostgradient/weft/storage'; * assertStorageBatchOperationCount('batch operations', 1); * ``` */ declare const exportedAssertStorageBatchOperationCount: typeof assertStorageBatchOperationCount; /** * Re-exported {@link storageBatch}. See the original declaration for full docs. * * @example * ```ts * import { MemoryStorage, storageBatch } from '@lostgradient/weft/storage'; * await using storage = new MemoryStorage(); * await storageBatch(storage, []); * ``` */ declare const exportedStorageBatch: typeof storageBatch; /** * Re-exported {@link storageConditionalBatch}. See the original declaration for full docs. * * @example * ```ts * import { MemoryStorage, storageConditionalBatch } from '@lostgradient/weft/storage'; * await using storage = new MemoryStorage(); * await storageConditionalBatch(storage, [], []); * ``` */ declare const exportedStorageConditionalBatch: typeof storageConditionalBatch; /** * Re-exported {@link storageDeleteRange}. See the original declaration for full docs. * * @example * ```ts * import { MemoryStorage, storageDeleteRange } from '@lostgradient/weft/storage'; * await using storage = new MemoryStorage(); * await storage.put('ev:wf:0000000001', new Uint8Array([1])); * const deleted = await storageDeleteRange(storage, 'ev:wf:', { lte: 'ev:wf:0000000001' }); * void deleted; * ``` */ declare const exportedStorageDeleteRange: typeof storageDeleteRange; /** * Re-exported {@link requireStorageCapability}. See the original declaration for full docs. * * @example * ```ts * import { MemoryStorage, requireStorageCapability } from '@lostgradient/weft/storage'; * await using storage = new MemoryStorage(); * requireStorageCapability(storage, 'conditionalBatch', 'compare-and-swap'); * ``` */ declare const exportedRequireStorageCapability: typeof requireStorageCapability; /** * Re-exported {@link storageValuesEqual}. See the original declaration for full docs. * * @example * ```ts * import { storageValuesEqual } from '@lostgradient/weft/storage'; * const equal = storageValuesEqual(new Uint8Array([1]), new Uint8Array([1])); * void equal; * ``` */ declare const exportedStorageValuesEqual: typeof storageValuesEqual; /** * Re-exported {@link StorageBatchOperationLimitExceededError}. See the original declaration for full docs. * * @example * ```ts * import { StorageBatchOperationLimitExceededError } from '@lostgradient/weft/storage'; * const error = new StorageBatchOperationLimitExceededError('batch operations', 10001); * console.log(error.count); * ``` */ declare const exportedStorageBatchOperationLimitExceededError: typeof StorageBatchOperationLimitExceededError; /** * Re-exported {@link textValueStore}. See the original declaration for full docs. * * @example * ```ts * import { MemoryStorage, textValueStore } from '@lostgradient/weft/storage'; * await using base = new MemoryStorage(); * const store = textValueStore(base); * void store; * ``` */ declare const exportedTextValueStore: typeof textValueStore; /** * Re-exported {@link WEFT_RESERVED_KEY_PREFIXES}. See the original declaration for full docs. * * @example * ```ts * import { WEFT_RESERVED_KEY_PREFIXES } from '@lostgradient/weft/storage'; * * const key = 'wf:order-123'; * const isWeftKey = WEFT_RESERVED_KEY_PREFIXES.some((prefix) => key.startsWith(prefix)); * void isWeftKey; * ``` */ declare const exportedWeftReservedKeyPrefixes: readonly ["actrec:", "appcmd:", "appdidem:", "appdlv:", "appdseq:", "appdterm:", "appdue:", "appidem:", "appmbx:", "appobx:", "appprobe:", "appready:", "appseq:", "appterm:", "archive:", "async-act:", "attr:", "audit:bulk:", "blob:", "budget:", "budget-charged:", "catalog-active:", "catalog-entry:", "catalog-removal-generation:", "catalog-tombstone:", "child-by-parent:", "ev:", "fleet-event-by-workflow:", "fleet-event:", "fleet-event-tail", "fleet-event-watermark", "idx:", "lease:", "liveness:", "offload:", "ownership-mode-marker", "op:", "review:", "schedule:", "schedule-due:", "schedule-run-by-schedule:", "schedule-run-link:", "schedule-run:", "sig:", "sigres:", "sigseq:", "start-idem:", "state:", "tag:", "tool-effect:", "upd:", "upk:", "upr:", "wf:", "wf-cleanup:", "wf-cleanup-needed:", "wf-concurrency:", "wf-concurrency-holder:", "wf-deadline:", "wf-delayed:", "wf-finalizer-state:", "wf-gen:", "wf-has-services:", "wf-headers:", "wf-idx-", "wf-owner-epoch:", "wf-owner-holder:", "wf-teardown:", "wf-teardown-deadletter:", "wf-teardown-deadletter-history:", "wf-teardown-needed:", "wf-teardown-succeeded:", "wf-terminal:"]; /** * Re-exported {@link withCodec}. See the original declaration for full docs. * * @example * ```ts * import { jsonCodec, MemoryStorage, withCodec } from '@lostgradient/weft/storage'; * await using base = new MemoryStorage(); * const typed = withCodec(base, jsonCodec()); * void typed; * ``` */ declare const exportedWithCodec: typeof withCodec; export type { JSONValue } from '../core/json.ts'; export type { DeleteRangeOptions } from './delete-range'; export type { BatchOperation, ConditionalBatchCondition, GatedStorageCapabilityKey, ScanOptions, Storage, StorageBatchOperationLimitTarget, StorageCapabilities, } from './interface'; export type { StorageConfiguration } from './resolve'; export type { CopyTextKeyValueRowsToStorageOptions, CopyTextKeyValueRowsToStorageResult, TextKeyValueRow, } from './text-value-import'; export type { TextValueStore, TextValueStoreBatchOperation, TextValueStoreCondition, TextValueStoreOptions, } from './text-value-store'; export type { CodecStorageOptions, MessagePackValue, StorageCodec, StorageValueParser, TypedBatchOperation, TypedConditionalBatchCondition, TypedStorage, } from './typed-storage'; export { exportedAssertDurableStorageForRecovery as assertDurableStorageForRecovery, exportedAssertStorageBatchOperationCount as assertStorageBatchOperationCount, exportedCopyTextKeyValueRowsToStorage as copyTextKeyValueRowsToStorage, exportedJsonCodec as jsonCodec, exportedKeys as KEYS, exportedMaxBatchOperations as MAX_BATCH_OPERATIONS, exportedMaxScanLimit as MAX_SCAN_LIMIT, exportedMemoryStorage as MemoryStorage, exportedMsgpackCodec as msgpackCodec, exportedRequireStorageCapability as requireStorageCapability, exportedResolveStorage as resolveStorage, exportedScopedStorage as ScopedStorage, exportedScopedStorageFactory as scopedStorage, exportedStorageBatch as storageBatch, exportedStorageBatchOperationLimitExceededError as StorageBatchOperationLimitExceededError, exportedStorageConditionalBatch as storageConditionalBatch, exportedStorageDeleteRange as storageDeleteRange, exportedStorageValuesEqual as storageValuesEqual, exportedTextValueStore as textValueStore, exportedWeftReservedKeyPrefixes as WEFT_RESERVED_KEY_PREFIXES, exportedWithCodec as withCodec, };