{"_id":"@allsourcedev/client","_rev":"2-a530457adcaed5f2878e13ff3df1e00b","name":"@allsourcedev/client","dist-tags":{"latest":"0.23.1"},"versions":{"0.23.0":{"name":"@allsourcedev/client","version":"0.23.0","keywords":["allsource","event-store","event-sourcing","typescript","api-client"],"license":"MIT","_id":"@allsourcedev/client@0.23.0","maintainers":[{"name":"decebal","email":"decebal1988@gmail.com"}],"homepage":"https://github.com/all-source-os/all-source#readme","bugs":{"url":"https://github.com/all-source-os/all-source/issues"},"dist":{"shasum":"af8fc0e5bb7dae3f457dc97bc4008022bb7f50d6","tarball":"https://registry.npmjs.org/@allsourcedev/client/-/client-0.23.0.tgz","fileCount":14,"integrity":"sha512-ISHjGsBJXSjsr1osg9wSSTqQbzohYVdywQFnWE2K1QMGQTfFV/9qT2OWaSUECxoR3yFHjfD/yVaeBsloHcuXCA==","signatures":[{"sig":"MEUCIFtCYq2I7tMTFP/sHIOR6FwVnCUgdFVBQ/j3ICPxWc1oAiEA8t/p4dFjbAL67CoDH7PZ6ZADWKjLiSUTMxzCFBntjZM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39184},"main":"./dist/index.cjs","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"gitHead":"327e07cac3a7f00a8ca20b1ac41e1e52b9b8a01b","scripts":{"test":"bun test","build":"bun build src/index.ts --outfile dist/index.mjs --target node --format esm && bun build src/index.ts --outfile dist/index.cjs --target node --format cjs && bun run build:types","clean":"rm -rf dist .turbo","smoke":"bun run scripts/smoke.ts","type-check":"tsc --noEmit","build:types":"tsc --emitDeclarationOnly --declaration --outDir dist","prepublishOnly":"bun run build"},"_npmUser":{"name":"decebal","email":"decebal1988@gmail.com"},"repository":{"url":"git+https://github.com/all-source-os/all-source.git","type":"git","directory":"sdks/typescript"},"_npmVersion":"11.12.1","description":"JavaScript/TypeScript client for the AllSource event store API","directories":{},"_nodeVersion":"26.0.0","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"^1.1.13","typescript":"^6.0.2"},"_npmOperationalInternal":{"tmp":"tmp/client_0.23.0_1781482999256_0.766589018383875","host":"s3://npm-registry-packages-npm-production"}},"0.23.1":{"name":"@allsourcedev/client","version":"0.23.1","description":"JavaScript/TypeScript client for the AllSource event store API","license":"MIT","main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"build":"bun build src/index.ts --outfile dist/index.mjs --target node --format esm && bun build src/index.ts --outfile dist/index.cjs --target node --format cjs && bun run build:types","build:types":"tsc --emitDeclarationOnly --declaration --outDir dist","type-check":"tsc --noEmit","test":"bun test","smoke":"bun run scripts/smoke.ts","clean":"rm -rf dist .turbo","prepublishOnly":"bun run build"},"devDependencies":{"@types/bun":"^1.1.13","typescript":"^6.0.2"},"keywords":["allsource","event-store","event-sourcing","typescript","api-client"],"repository":{"type":"git","url":"git+https://github.com/all-source-os/all-source.git","directory":"sdks/typescript"},"gitHead":"39387d8b73a88d11ab1601a9f387c1dc85c4bd36","_id":"@allsourcedev/client@0.23.1","bugs":{"url":"https://github.com/all-source-os/all-source/issues"},"homepage":"https://github.com/all-source-os/all-source#readme","_nodeVersion":"26.0.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-GRvr+f+Vn9YUU1SoCaFzfx/HJ678mg1XE6WmTJaUyXuGhvgLQFwr6XWNTyYUYDbaYEWr62DVIZQqVAfpZjQENA==","shasum":"9440a9503c6ad3cfc735603183ffea5068c76d13","tarball":"https://registry.npmjs.org/@allsourcedev/client/-/client-0.23.1.tgz","fileCount":14,"unpackedSize":39224,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCfG0ky7oCShvpytnHo6haYPDNGJR/L8Nb+Y3Ow1qhIuQIhAMZZe5RrJ84mPxKTiWM1eLnB4qZo3sLlE+rBRluBtm8r"}]},"_npmUser":{"name":"decebal","email":"decebal1988@gmail.com"},"directories":{},"maintainers":[{"name":"decebal","email":"decebal1988@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/client_0.23.1_1781483786309_0.6898698929041349"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-15T00:23:19.071Z","modified":"2026-06-15T00:36:26.595Z","0.23.0":"2026-06-15T00:23:19.395Z","0.23.1":"2026-06-15T00:36:26.456Z"},"bugs":{"url":"https://github.com/all-source-os/all-source/issues"},"license":"MIT","homepage":"https://github.com/all-source-os/all-source#readme","keywords":["allsource","event-store","event-sourcing","typescript","api-client"],"repository":{"type":"git","url":"git+https://github.com/all-source-os/all-source.git","directory":"sdks/typescript"},"description":"JavaScript/TypeScript client for the AllSource event store API","maintainers":[{"name":"decebal","email":"decebal1988@gmail.com"}],"readme":"# @allsourcedev/client\n\nTypeScript/JavaScript client for the [AllSource](https://all-source.xyz) event store API.\n\nTalks to the AllSource **Query Service** (the public gateway), not Core directly.\nShips compiled ESM + CJS with `.d.ts` types. Runs on Node 18+ and Bun. Zero\nruntime dependencies (uses the global `fetch`).\n\n## Installation\n\n```bash\nnpm install @allsourcedev/client\n# or\nbun add @allsourcedev/client\n# or\npnpm add @allsourcedev/client\n```\n\n> **Why not a git install?** `@allsourcedev/client` lives in the `all-source`\n> monorepo under `sdks/typescript`. Git installers can't pull a sub-directory of\n> a monorepo — that's why `bun add github:…#workspace=@allsourcedev/client` and\n> `#path:sdks/typescript` return 404. Install from the npm registry (above).\n\n## Authentication\n\nAllSource uses API keys (signed JWTs). Get one from your dashboard at\n[all-source.xyz](https://all-source.xyz) → **Settings → API Keys**. The key is\nsent in the `X-API-Key` header; the SDK does this for you when you pass `apiKey`\nto the constructor.\n\nStore the key in an env var rather than hard-coding it:\n\n```typescript\nimport { AllSourceClient } from \"@allsourcedev/client\";\n\nconst client = new AllSourceClient({\n  baseUrl: \"https://allsource-query.fly.dev\", // your Query Service URL\n  apiKey: process.env.ALLSOURCE_API_KEY!,\n});\n```\n\nThe tenant is taken from the key — there is no separate tenant argument.\n\n## Quick Start\n\n```typescript\nimport { AllSourceClient } from \"@allsourcedev/client\";\n\nconst client = new AllSourceClient({\n  baseUrl: \"https://allsource-query.fly.dev\",\n  apiKey: process.env.ALLSOURCE_API_KEY!,\n});\n\n// Ingest an event — returns the stored event\nconst event = await client.ingestEvent({\n  event_type: \"user.signup\",\n  entity_id: \"user-abc-123\",\n  payload: { email: \"jane@example.com\", plan: \"pro\" },\n  metadata: { source: \"web\", ip: \"1.2.3.4\" },\n});\nconsole.log(\"Ingested:\", event.id);\n\n// Query events back\nconst { events, count } = await client.queryEvents({\n  entity_id: \"user-abc-123\",\n  limit: 50,\n});\nconsole.log(`Found ${count} events`);\n\n// Health check (unauthenticated)\nconst health = await client.getHealth();\nconsole.log(\"Status:\", health.status);\n```\n\n## API\n\n### `new AllSourceClient(config)`\n\n| Option           | Type       | Required | Default | Description                          |\n|------------------|------------|----------|---------|--------------------------------------|\n| `baseUrl`        | `string`   | Yes      | —       | AllSource Query Service URL          |\n| `apiKey`         | `string`   | Yes      | —       | API key (sent as `X-API-Key`)        |\n| `timeout`        | `number`   | No       | `30000` | Request timeout in milliseconds      |\n| `retry`          | `object`   | No       | —       | Retry/backoff overrides              |\n| `circuitBreaker` | `object`   | No       | —       | Circuit-breaker overrides            |\n| `fetch`          | `function` | No       | global  | Custom `fetch` implementation        |\n\n### `client.ingestEvent(event)` → `Event`\n\nIngest a single event and return the stored event (`id`, `timestamp`, …).\n\n```typescript\nconst stored = await client.ingestEvent({\n  event_type: \"order.placed\",\n  entity_id: \"order-456\",\n  payload: { total: 99.99, currency: \"USD\" },\n  metadata: { source: \"checkout\" }, // optional, preserved\n});\n```\n\n### `client.ingestBatch(events)` → `{ count, events }`\n\nIngest many events in one request.\n\n### `client.queryEvents(params?)` → `{ events, count }`\n\nQuery events with optional filters.\n\n| Param        | Type     | Description                       |\n|--------------|----------|-----------------------------------|\n| `entity_id`  | `string` | Filter by entity ID               |\n| `event_type` | `string` | Filter by event type              |\n| `limit`      | `number` | Max events to return              |\n| `offset`     | `number` | Number of events to skip          |\n| `since`      | `string` | Start time, inclusive (ISO 8601)  |\n| `until`      | `string` | End time, inclusive (ISO 8601)    |\n\n### `client.queryAndFold(params, folder)` → `S | undefined`\n\nQuery events and fold them into a derived state with an `EventFolder<S>`.\n\n### `client.listProjections()` → `{ projections, total }`\n\nList projections from Core.\n\n### Prime projections\n\n`definePrimeProjection(entityType, fieldPolicies)`,\n`projectNode(nodeId)`, `listPrimeProjections()`,\n`nodeFieldProvenance(nodeId, field)` — declarative projections with per-field\nmerge policies and provenance.\n\n### `client.getHealth()` → `HealthResponse`\n\nService health. Unauthenticated.\n\n### Reliability\n\nEvery request goes through exponential-backoff retries (on 408/429/5xx and\nnetwork errors) and a circuit breaker. Both are configurable via the constructor.\n\n### Error handling\n\nAPI errors throw `AllSourceError` with `status` and `body`:\n\n```typescript\nimport { AllSourceClient, AllSourceError } from \"@allsourcedev/client\";\n\ntry {\n  await client.ingestEvent({ /* … */ });\n} catch (err) {\n  if (err instanceof AllSourceError) {\n    console.error(`API error ${err.status}:`, err.body);\n    if (err.isUnauthorized()) console.error(\"Check your API key.\");\n  }\n}\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}