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:
| Operation | Always available | Description |
|---|---|---|
put | ✓ | Upload an object |
get | ✓ | Download an object |
head | ✓ | Get object metadata |
delete | ✓ | Remove an object |
list | ✓ | List objects |
copy | adapter-dependent | Copy an object |
presign | adapter-dependent | Generate pre-signed URLs |
multipart | adapter-dependent | Multipart uploads |
versioning | adapter-dependent | Object 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.
🔗 Related
- Adapter — the adapter contract
- Operations — all operation signatures
- Quick start — practical usage example