{"_id":"@caleblawson/clickhouse","name":"@caleblawson/clickhouse","dist-tags":{"latest":"0.11.1-alpha.0"},"versions":{"0.11.1-alpha.0":{"name":"@caleblawson/clickhouse","version":"0.11.1-alpha.0","description":"Clickhouse provider for Mastra - includes db storage capabilities","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"license":"MIT","dependencies":{"@clickhouse/client":"^1.11.2"},"devDependencies":{"@microsoft/api-extractor":"^7.52.8","@types/node":"^20.19.0","eslint":"^9.28.0","tsup":"^8.5.0","typescript":"^5.8.3","vitest":"^3.2.3","@mastra/core":"npm:@caleblawson/core@0.10.7-alpha.0","@internal/lint":"0.0.13","@internal/storage-test-utils":"0.0.9"},"peerDependencies":{"@mastra/core":">=0.10.4-0 <0.11.0"},"scripts":{"build":"tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting","build:watch":"pnpm build --watch","pretest":"docker compose up -d && (for i in $(seq 1 30); do docker compose exec -T db clickhouse-client --query 'SELECT 1'  && break || (sleep 1; [ $i -eq 30 ] && exit 1); done)","test":"vitest run","posttest":"docker compose down -v","pretest:watch":"docker compose up -d","test:watch":"vitest watch","posttest:watch":"docker compose down -v","lint":"eslint ."},"gitHead":"c31e90130a5c9765c23f688ecea70adc6164543d","_id":"@caleblawson/clickhouse@0.11.1-alpha.0","_integrity":"sha512-vwz98xtZTAs1wFxWuEcN3NYysnXbTZKaKMcNbsIZ/xwSWxzVFoo26q+lFGGfOJZgu+YOcNgaZijVJkYVGvuUYw==","_resolved":"C:\\Users\\caleb\\AppData\\Local\\Temp\\6a191e688bc0eb3d14621b4216e85a99\\caleblawson-clickhouse-0.11.1-alpha.0.tgz","_from":"file:caleblawson-clickhouse-0.11.1-alpha.0.tgz","_nodeVersion":"21.2.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-vwz98xtZTAs1wFxWuEcN3NYysnXbTZKaKMcNbsIZ/xwSWxzVFoo26q+lFGGfOJZgu+YOcNgaZijVJkYVGvuUYw==","shasum":"4dcc433d5fb6c5abe5a1ca5a573ce5186e9e4871","tarball":"https://registry.npmjs.org/@caleblawson/clickhouse/-/clickhouse-0.11.1-alpha.0.tgz","fileCount":18,"unpackedSize":182645,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDfIL7uXxktQuryMHJ+3m/PxL9VyvblRXyEGQEB+uZkVwIhAIxLH3VO5/+zXhtiTCP1AylpE2zseW/Y+2bYJkrRpWhB"}]},"_npmUser":{"name":"caleblawson","email":"caleb.lawson@dynapt.com","actor":{"name":"caleblawson","email":"caleb.lawson@dynapt.com","type":"user"}},"directories":{},"maintainers":[{"name":"caleblawson","email":"caleb.lawson@dynapt.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/clickhouse_0.11.1-alpha.0_1750619790806_0.5993426713302825"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-22T19:16:30.712Z","0.11.1-alpha.0":"2025-06-22T19:16:31.023Z","modified":"2025-06-22T19:16:31.289Z"},"maintainers":[{"name":"caleblawson","email":"caleb.lawson@dynapt.com"}],"description":"Clickhouse provider for Mastra - includes db storage capabilities","license":"MIT","readme":"# @mastra/clickhouse\r\n\r\nClickhouse implementation for Mastra, providing efficient storage capabilities with support for threads, messages, and workflow snapshots.\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @mastra/clickhouse\r\n```\r\n\r\n## Prerequisites\r\n\r\n- Clickhouse server (version 21.8 or higher recommended)\r\n- Node.js 16 or higher\r\n\r\n## Usage\r\n\r\n```typescript\r\nimport { ClickhouseStore } from '@mastra/clickhouse';\r\n\r\nconst store = new ClickhouseStore({\r\n  url: 'http://localhost:8123',\r\n  username: 'default',\r\n  password: 'password',\r\n});\r\n\r\n// Create a thread\r\nawait store.saveThread({\r\n  id: 'thread-123',\r\n  resourceId: 'resource-456',\r\n  title: 'My Thread',\r\n  metadata: { key: 'value' },\r\n  createdAt: new Date(),\r\n  updatedAt: new Date(),\r\n});\r\n\r\n// Add messages to thread\r\nawait store.saveMessages([\r\n  {\r\n    id: 'msg-789',\r\n    threadId: 'thread-123',\r\n    role: 'user',\r\n    type: 'text',\r\n    content: [{ type: 'text', text: 'Hello' }],\r\n    createdAt: new Date(),\r\n  },\r\n]);\r\n\r\n// Query threads and messages\r\nconst savedThread = await store.getThreadById({ threadId: 'thread-123' });\r\nconst messages = await store.getMessages({ threadId: 'thread-123' });\r\n\r\n// Clean up\r\nawait store.close();\r\n```\r\n\r\n## Configuration\r\n\r\nThe Clickhouse store can be initialized with the following configuration:\r\n\r\n```typescript\r\ntype ClickhouseConfig = {\r\n  url: string; // Clickhouse HTTP interface URL\r\n  username: string; // Database username\r\n  password: string; // Database password\r\n};\r\n```\r\n\r\n## Features\r\n\r\n### Storage Features\r\n\r\n- Thread and message storage with JSON support\r\n- Efficient batch operations\r\n- Rich metadata support\r\n- Timestamp tracking\r\n- Workflow snapshot persistence\r\n- Optimized for high-volume data ingestion\r\n- Uses Clickhouse's MergeTree and ReplacingMergeTree engines for optimal performance\r\n\r\n### Table Engines\r\n\r\nThe store uses different table engines for different types of data:\r\n\r\n- `MergeTree()`: Used for messages, traces, and evals\r\n- `ReplacingMergeTree()`: Used for threads and workflow snapshots\r\n\r\n## Storage Methods\r\n\r\n### Thread Operations\r\n\r\n- `saveThread(thread)`: Create or update a thread\r\n- `getThreadById({ threadId })`: Get a thread by ID\r\n- `updateThread({ id, title, metadata })`: Update thread title and metadata\r\n- `deleteThread({ threadId })`: Delete a thread and its messages\r\n\r\n### Message Operations\r\n\r\n- `saveMessages(messages)`: Save multiple messages\r\n- `getMessages({ threadId, selectBy? })`: Get messages for a thread with optional filtering\r\n- `deleteMessages(messageIds)`: Delete specific messages\r\n\r\n### Workflow Operations\r\n\r\n- `persistWorkflowSnapshot({ workflowName, runId, snapshot })`: Save workflow state\r\n- `loadWorkflowSnapshot({ workflowName, runId })`: Load workflow state\r\n\r\n## Data Types\r\n\r\nThe store supports the following data types:\r\n\r\n- `text`: String\r\n- `timestamp`: DateTime64(3)\r\n- `uuid`: String\r\n- `jsonb`: String (JSON serialized)\r\n- `integer`: Int64\r\n- `bigint`: Int64\r\n\r\n## Related Links\r\n\r\n- [Clickhouse Documentation](https://clickhouse.com/docs)\r\n- [Clickhouse Node.js Client](https://github.com/clickhouse/clickhouse-js)\r\n","readmeFilename":"README.md","_rev":"1-df5563ef26f8a6b2496cc12f55cedd85"}