{"_id":"@battletexas/sdk","_rev":"2-0b9d29b321143c4bc9e046fe30a0e776","name":"@battletexas/sdk","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.0":{"name":"@battletexas/sdk","version":"0.0.0","author":{"name":"Josh Briggs"},"license":"MIT","_id":"@battletexas/sdk@0.0.0","maintainers":[{"name":"intrinzik","email":"npm@battletexas.com"}],"dist":{"shasum":"7a958a7e2d0f9e502ccccaf67c3e52d4d312e14c","tarball":"https://registry.npmjs.org/@battletexas/sdk/-/sdk-0.0.0.tgz","fileCount":38,"integrity":"sha512-RYEqhzQffcQBAQLkjz9kaq7VdHgUHVg1EmmWJJPyT6BNyiVVlUt1kZPWJzzXKTw5EBwH6+yI0pwGXeQIYuNXtA==","signatures":[{"sig":"MEUCIAq6KOHJDvXAKor7diAnEG4tWibFhKCkqG1B2EQJvX27AiEAuIwXsQ5DcBznlFaPyI1usT3GpE18j5HqNDq6BK1l6Hs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":80403},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./http":{"types":"./dist/http.d.ts","import":"./dist/http.js"},"./generated/map":{"types":"./dist/generated/map.d.ts","import":"./dist/generated/map.js"}},"gitHead":"32a6d8daa7e9efa9a544dc5003adef3b5bae96be","scripts":{"test":"vitest","build":"tsc -p tsconfig.json","check":"tsc -p tsconfig.json --noEmit","test:watch":"vitest --watch","build:watch":"tsc -p tsconfig.json --watch","generate:all":"npm run generate:types && npm run generate:models","generate:types":"openapi-typescript openapi-spec.json -o src/generated/openapi-spec.ts","generate:models":"node scripts/generate-map.mjs"},"_npmUser":{"name":"intrinzik","email":"npm@battletexas.com"},"_npmVersion":"11.4.2","description":"TypeScript SDK for the Battle Texas API","directories":{},"_nodeVersion":"24.4.1","_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.0.0","typescript":"^5.9.3","openapi-typescript":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.0.0_1764735075798_0.37202111236376","host":"s3://npm-registry-packages-npm-production"}},"0.0.1":{"name":"@battletexas/sdk","version":"0.0.1","description":"TypeScript SDK for the Battle Texas API","author":{"name":"Josh Briggs"},"license":"MIT","type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"},"./http":{"import":"./dist/http.js","types":"./dist/http.d.ts"},"./generated/map":{"import":"./dist/generated/map.js","types":"./dist/generated/map.d.ts"}},"scripts":{"build":"tsc -p tsconfig.json","build:watch":"tsc -p tsconfig.json --watch","check":"tsc -p tsconfig.json --noEmit","generate:types":"openapi-typescript openapi-spec.json -o src/generated/openapi-spec.ts","generate:models":"node scripts/generate-map.mjs","generate:all":"npm run generate:types && npm run generate:models","test":"vitest","test:watch":"vitest --watch"},"devDependencies":{"openapi-typescript":"^7.10.1","typescript":"^5.9.3","vitest":"^2.0.0"},"_id":"@battletexas/sdk@0.0.1","gitHead":"dbad075ccd7245348598155f71ac06f08a776b57","_nodeVersion":"24.4.1","_npmVersion":"11.4.2","dist":{"integrity":"sha512-AaidSZdiOz6WT5FPvRot+kzJ2M1LI7ek5cLBkkPEfRwUUTaEehSGnR6kTJVTa3sw+WC4V8pIKEQUIJrdGNc5MA==","shasum":"13daa5e76b474433590f41c4f26e920e8945204d","tarball":"https://registry.npmjs.org/@battletexas/sdk/-/sdk-0.0.1.tgz","fileCount":38,"unpackedSize":80403,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAN/y7Qj0MPfS04YTiICIcxpIkMjFbq1mr8YT/2H4+zcAiEAhgqXf//XPbVkYLgF9PxZa+fxNA2KV9W9bHGpJcRb6Rw="}]},"_npmUser":{"name":"intrinzik","email":"npm@battletexas.com"},"directories":{},"maintainers":[{"name":"intrinzik","email":"npm@battletexas.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.0.1_1764735295645_0.17821252780775798"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-03T04:11:15.665Z","modified":"2025-12-03T04:14:56.028Z","0.0.0":"2025-12-03T04:11:15.996Z","0.0.1":"2025-12-03T04:14:55.832Z"},"author":{"name":"Josh Briggs"},"license":"MIT","description":"TypeScript SDK for the Battle Texas API","maintainers":[{"name":"intrinzik","email":"npm@battletexas.com"}],"readme":"# Battle Texas TypeScript SDK\n\nA small, opinionated TypeScript SDK for talking to the **battle-texas-server** API.\n\n- **Framework-agnostic**: written in plain TS, works with SvelteKit, React, Node, etc.\n- **Strongly typed**: types generated from the OpenAPI spec.\n- **Opinionated errors**: success returns typed models, failures throw a single `ApiError` type.\n\nThis repo is intended primarily for internal use by Battle Texas apps.\n\n---\n\n## Table of contents\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Initialization](#initialization)\n  - [Imports](#imports)\n  - [Setup](#setup)\n- [Clients](#clients)\n- [Sessions](#sessions)\n- [Locations](#locations)\n- [Email & SMS Verifications](#email--sms-verifications)\n- [Error Handling](#error-handling)\n\n---\n\n## Requirements\n- TypeScript ES2020\n- Supports runtimes with `fetch`\n\t- Browser\n\t- Node 18+\n\t- Node with fetch polyfill\n\n## Installation\n\nWhile this is an internal package, it is public for review and comment.\n\n### With published package\n```bash\nnpm install @battle-texas/sdk\n```\n\n### Via private local path\nClone package to local drive, then install with:\n```bash\nnpm install ../path_to/battle-texas-sdk\n```\n\n## Initialization\n\n### Imports\n```ts\nimport {\n  HttpCore,\n  type ClientOptions,\n  LocationsClient,\n  SessionsClient,\n  VerificationsClient,\n  ApiError\n} from \"@battle-texas/sdk\";\n```\n\n### Setup\n```ts\nconst opts: ClientOptions = {\n\tbaseUrl: \"https://api.your-domain.com\",\n\ttimeoutMs: 2000,\n\tgetAccessToken: () => sessionStorage.getItem(\"access_token\") ?? undefined\n};\n\nconst core = new HttpCore(opts);\n```\n\n# Clients\nEach client scope exposes the available endpoints for a resource type\nRoad map:\n- [x] sessions\n- [x] locations (in progress)\n- [x] verifications (in progress)\n- [ ] business accounts\n- [ ] bookings\n- [ ] quotes\n\n\n```ts\nconst locations = new LocationsClient(core);\nconst sessions = new SessionsClient(core);\nconst verifications = new VerificationsClient(core);\n```\n\n## Sessions\nRoad map:\n- [x] create session `login`\n- [x] delete session `logout`\n\n### Begin Session\n\n#### Imports\n```ts\nimport type { CreateSessionBody } from \"@battle-texas/sdk/generated/map\";\n```\n\n#### Body\n```ts\nconst body: CreateSessionBody = {\n\tusername: \"name@example.com\",\n\tpassword: \"correct-horse-battery-staple\"\n};\n```\n\n#### Usage\n```ts\nawait sessions.create(body); // AccessToken | throws ApiError\n```\n\n### End session\n#### Usage\n```ts\nawait sessions.delete(); // void | throws ApiError\n```\n\n## Locations\nRoad map:\n- [x] List nearest locations by zipcode\n- [x] Public location by id\n- [x] Private location by id\n- [ ] List private locations by business id (coming soon)\n- [ ] Create new location\n- [ ] Update location\n- [ ] Delete location\n\n### List nearest locations by zipcode\n```ts\nconst params = { nearestZipcode: \"valid zipcode\" };\nawait locations.listNearestByZipcode(params); // PublicLocation[] | throws ApiError\n```\n\n### Get public location by id\n```ts\nconst id: number = 0;\nawait locations.publicById(id); // PublicLocation | throws ApiError\n```\n\n### Get private location by id\n```ts\nconst id: number = 0;\nawait locations.privateById(id); // PrivateLocation | throws ApiError\n```\n\n## Email & SMS Verifications\nRoad map:\n- [x] Email\n- [ ] SMS\n\n### Request a verification email\n\n#### Imports\n```ts\nimport type { EmailVerificationPost } from \"@battle-texas/sdk/generated/map\";\n```\n\n#### Body\n```ts\nconst body: EmailVerificationPost = { email: \"name@example.com\" };\n```\n\n#### Usage\n```ts\nawait verifications.createEmailVerification(body); // void | throws ApiError\n```\n\n### Verify email\nRequired params: uuid:string,id:number\n\n#### Usage\n```ts\nawait verifications.patchEmailVerification(uuid, id); // void | throws ApiError\n```\n\n## Error Handling\n\n### Imports\n\n```ts\nimport { ApiError } from \"@battle-texas/sdk/error\";\n```\n\n### Pattern\n```ts\ntry {\n\tconst response = await object.method(dataBody);\n} catch (err) {\n  \tif (err instanceof ApiError) {\n  \t\tconsole.error(\"HTTP:\", err.httpStatus);\n  \t\tconsole.error(\"API code:\", err.apiCode);\n  \t\tconsole.error(\"API reason:\", err.apiReason);\n  \t\tconsole.error(\"Message:\", err.message);\n\t\tconsole.error(\"Error Kind:\", err.errorKind);\n  \t} else {\n  \t\tconsole.error(\"Unexpected error:\", err);\n  \t}\n}\n```","readmeFilename":"README.md"}