# @ductape/sdk

SDK for building Ductape-powered products. Use a single access key to work with databases, message brokers, storage, sessions, workflows, and more.

## Install

```sh
npm install @ductape/sdk
```

## Quick start

Initialize the client with your **access key** (and optional `env_type`). Then use the namespaced APIs: `messaging`, `storage`, `sessions`, `databases`, etc.

```ts
import Ductape from '@ductape/sdk';

const ductape = new Ductape({
  accessKey: 'your-access-key',
});

// Message brokers: produce and consume
await ductape.messaging.produce({
  product: 'my-product',
  env: 'prd',
  event: 'order-events:order-created',
  message: { orderId: '123', amount: 99.99 },
});

await ductape.messaging.consume({
  product: 'my-product',
  env: 'prd',
  event: 'order-events:order-created',
  callback: async (msg) => console.log(msg),
});

// Storage: upload, download, list files
const uploadResult = await ductape.storage.upload({
  product: 'my-product',
  env: 'prd',
  storage: 'main-storage',
  fileName: 'reports/file.pdf',
  buffer: fileBuffer,
  mimeType: 'application/pdf',
});

// Sessions: start, verify, refresh
const session = await ductape.sessions.start({
  product: 'my-product',
  env: 'prd',
  tag: 'user-session',
  data: { userId: 'u1', email: 'user@example.com' },
});
// session.token, session.refreshToken, session.sessionId
```

## What you can do

- **Messaging** - `ductape.messaging.produce()`, `consume()`, `list()`, `fetch()`, `topics.create()`, etc. (Kafka, RabbitMQ, Redis, SQS, Pub/Sub, NATS)
- **Storage** - `ductape.storage.upload()`, `download()`, `remove()`, `listFiles()`, `getSignedUrl()`, `stats()` (AWS S3, GCP, Azure)
- **Sessions** - `ductape.sessions.start()`, `verify()`, `refresh()`, `revoke()`, `listActive()` (JWT-based)
- **Databases** - relational, graph, vector (via `ductape.databases`, `ductape.graph`, `ductape.vector`)
- **Warehouse** - unified query across relational, graph, and vector (via `ductape.warehouse`)
- **Caching** - multi-tier cache with product-scoped tags (`ductape.cache`)
- **Agents** - LLM agents with tools, memory, and multi-agent flows (`ductape.agents`)
- **Resilience** - quotas, fallbacks, health checks (`ductape.quota`, `ductape.fallback`, `ductape.healthcheck`)
- **Workflows** - define and run workflows with steps that call actions, storage, messaging, etc.
- **Jobs** - schedule and run background jobs
- **Notifications** - email, SMS, push (multiple providers), callbacks
- **Secrets** - store and resolve secrets per environment

## Environment

The SDK is intended for **Node.js** (server). Browser use is not supported for broker, storage, and similar operations.

## Documentation

Full docs: [docs.ductape.app](https://docs.ductape.app)

- [Message Brokers](https://docs.ductape.app/message-brokers/overview)
- [Storage](https://docs.ductape.app/storage/overview)
- [Sessions](https://docs.ductape.app/sessions/overview)
- [Databases](https://docs.ductape.app/databases/relational/getting-started)
- [Warehouse](https://docs.ductape.app/databases/warehouse/getting-started)
- [Caching](https://docs.ductape.app/caching/overview)
- [Agents](https://docs.ductape.app/agents/overview)
- [Resilience](https://docs.ductape.app/resilience/overview)
- [Workflows](https://docs.ductape.app/workflows/overview)

## License

MIT © Ductape Technologies
