{"_id":"@asiri-ng/sdk-ts","name":"@asiri-ng/sdk-ts","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@asiri-ng/sdk-ts","version":"0.1.0","description":"Asiri API TypeScript SDK","private":false,"license":"UNLICENSED","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"publishConfig":{"access":"public"},"sideEffects":false,"scripts":{"generate":"openapi-typescript ../api-client/openapi/asiri-public-api.json -o src/generated/schema.ts","build":"pnpm run generate && tsc -p tsconfig.build.json","prepack":"pnpm run build","lint":"pnpm run generate && eslint . --max-warnings=0","typecheck":"pnpm run generate && tsc --noEmit","test":"pnpm run generate && vitest run","test:unit":"pnpm run generate && vitest run"},"dependencies":{"openapi-fetch":"^0.17.0"},"devDependencies":{"@asiri/config":"workspace:*","@types/node":"^22.10.0","eslint":"^9.16.0","openapi-typescript":"^7.13.0","typescript":"^5.7.2","vitest":"^2.1.8"},"_id":"@asiri-ng/sdk-ts@0.1.0","gitHead":"1132e17810d4f0de89598e66ba22ed6a4a1be3a5","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-yfljWzKbv6HPonEavNCukHzOxDC3f1Ca1KyUudCou7z24hLHtPDfAwe1jrzgH3beUlPyyfjy0a9EvW+A0Bf8DA==","shasum":"76639e5d6d41d93db0ceb317f40ddd1e4af62fe6","tarball":"https://registry.npmjs.org/@asiri-ng/sdk-ts/-/sdk-ts-0.1.0.tgz","fileCount":10,"unpackedSize":417660,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCOZOfhtAIXGaPRj85SEhD9+iwUOorK1r7Gksitm6SVawIhALgNjCc/XJPHxmUmelL1zU21HodvYoLxm7nuvFdNHhoS"}]},"_npmUser":{"name":"mr-tanta","email":"admin@asiri.ng"},"directories":{},"maintainers":[{"name":"abrahamtanta","email":"abraham@tantainnovatives.com"},{"name":"mr-tanta","email":"admin@asiri.ng"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk-ts_0.1.0_1778869327473_0.041106959246017816"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-15T18:22:07.353Z","0.1.0":"2026-05-15T18:22:07.625Z","modified":"2026-05-15T18:22:07.893Z"},"maintainers":[{"name":"abrahamtanta","email":"abraham@tantainnovatives.com"},{"name":"mr-tanta","email":"admin@asiri.ng"}],"description":"Asiri API TypeScript SDK","license":"UNLICENSED","readme":"# @asiri-ng/sdk-ts\n\nAsiri API TypeScript SDK. A thin, fully-typed wrapper around the public Asiri HTTP API generated from `openapi-public.json`.\n\n## Status\n\nThe package builds to `dist/` and publishes to npm from the GitHub release workflow after a PR\nis merged into `develop`, as long as the package version is not already on npm. License is\n`UNLICENSED` for now; it should become **Apache-2.0** or **MIT** before the first public\nrelease on npm.\n\n## Install\n\n```bash\npnpm add @asiri-ng/sdk-ts\n# or\nnpm install @asiri-ng/sdk-ts\n```\n\nThe SDK bundles its own `openapi-fetch` runtime — there are no peer dependencies.\n\n## Quickstart\n\n```ts\nimport { createAsiriClient, AsiriError } from '@asiri-ng/sdk-ts';\n\nconst asiri = createAsiriClient({\n  baseUrl: 'https://api.asiri.ng',\n  apiKey: process.env.ASIRI_API_KEY,\n});\n\nconst { data, error } = await asiri.GET('/v1/reports/overview');\nif (error) {\n  throw AsiriError.from(error);\n}\nconsole.log(data);\n```\n\nWhen `apiKey` is set, every request carries `Authorization: Bearer <apiKey>`. Callers can override the header on a per-request basis by passing `headers` to a method call.\n\n### Idempotency\n\nMutating requests (POST/PUT/PATCH/DELETE) require an `Idempotency-Key` header. The SDK does **not** auto-generate one — pass your own deterministic key so retries after a network failure don't double-charge:\n\n```ts\nawait asiri.POST('/v1/reports/build', {\n  body: { type: 'audit_summary', format: 'json' },\n  headers: { 'Idempotency-Key': crypto.randomUUID() },\n});\n```\n\n### Custom fetch\n\nPass `fetch` to inject instrumentation, proxying, or test doubles:\n\n```ts\ncreateAsiriClient({ baseUrl, apiKey, fetch: instrumentedFetch });\n```\n\n## Scopes\n\nAPI keys carry scopes that gate which endpoints they can call. See https://docs.asiri.ng/getting-started/api-keys for the full public vocabulary (for example `reports:read`, `reports:write`, `audit:read`, and `webhooks:write`).\n\n## Errors\n\nThe Asiri API returns a uniform JSON envelope on any non-2xx response:\n\n```ts\ntype AsiriErrorResponse = {\n  error: {\n    code: string; // machine-readable, e.g. 'invalid_api_key'\n    message: string; // human-readable summary\n    details?: unknown; // optional structured context\n    requestId?: string; // correlate with server logs\n  };\n};\n```\n\n`AsiriError.from(value, status?)` parses the nested API response or the inner error object into a\ntyped `AsiriError`:\n\n```ts\nclass AsiriError extends Error {\n  readonly code: string;\n  readonly status: number | undefined;\n  readonly details: unknown;\n  readonly requestId: string | undefined;\n}\n```\n\nThe low-level `client.GET/POST/...` methods follow openapi-fetch's `{ data, error }` convention and never throw — converting to an exception is opt-in.\n\n## Code generation\n\nTypes come from the public OpenAPI document at `packages/api-client/openapi/asiri-public-api.json`. The build runs:\n\n```bash\npnpm run build\n# = generate the public OpenAPI types, then compile src/ to dist/\n```\n\n`build`, `typecheck`, `lint`, `test`, and `prepack` all invoke `generate` first, so a fresh\ncheckout (where `src/generated/` is gitignored) just works.\n\n## Type re-exports\n\n- `paths` — the canonical path-method-status map from openapi-typescript.\n- `components` — the `#/components/schemas` namespace.\n- `operations` — operation-id-keyed type map (useful for utility types).\n- `AsiriClient` — `Client<paths>` from openapi-fetch, the return type of `createAsiriClient`.\n\n## Changelog\n\n- **0.1.0** – Initial public surface: `createAsiriClient`, `AsiriError`, public `paths`/`components`/`operations` re-exports. Smoke tests cover Bearer header injection and error parsing.\n","readmeFilename":"README.md","_rev":"1-9f68e3342d1bd92fbd5f757f44290cae"}