sobj

The sobj function creates a typed storage client from an adapter.

📥 Import

ts
import { sobj } from 'sobj'

📝 Signature

ts
function sobj<C extends SobjCapabilities>(
  adapter: SobjAdapter<C>
): Sobj<C>

⚙️ Usage

Create a client by passing your preferred adapter (such as @sobj/memory for tests, or @sobj/s3, @sobj/r2 for production):

ts
import { sobj } from 'sobj'
import { memory } from '@sobj/memory'

const storage = sobj(memory())

The returned storage object exposes only the operations that the adapter declares it supports. TypeScript enforces this at compile time.

⚡ Operations

The following operations are available on a Sobj client when the adapter supports them:

OperationAlways availableDescription
putUpload an object
getDownload an object
headGet object metadata
deleteRemove an object
listList objects
copyadapter-dependentCopy an object
presignadapter-dependentGenerate pre-signed URLs
multipartadapter-dependentMultipart uploads
versioningadapter-dependentObject versioning

🏷️ Type

The return type mirrors the adapter's capabilities:

ts
type Sobj<C extends SobjCapabilities> = SobjAdapter<C>

For example, if the adapter supports presign, the returned client will have a presign property. If the adapter does not support presign, TypeScript will not expose it.