@terminal49/sdk
v0.2.0
Published
Terminal49 TypeScript SDK (JSON:API, openapi-fetch)
Readme
Terminal49 TypeScript SDK
Typed, server-side client for the Terminal49 JSON:API, built with openapi-fetch, generated OpenAPI types, and JSONA deserialization. Can be used standalone or inside the MCP server.
Installation
# install from npm (recommended)
npm install @terminal49/sdk
# or inside this repo
cd sdks/typescript-sdk
npm installUsage
import { Terminal49Client } from '@terminal49/sdk';
const client = new Terminal49Client({ apiToken: process.env.T49_API_TOKEN! });
const container = await client.getContainer('container-uuid', ['shipment']);
console.log(container); // raw JSON:API document
// Optional: deserialize JSON:API to plain objects
const simplified = client.deserialize<any>(container);Guide
For a full walkthrough (track a container, list shipments, pull events, and routing),
see the SDK quickstart in the docs site: docs/api-docs/getting-started/sdk-quickstart.mdx.
Methods
search(query)getContainer(id, include?)trackContainer({ containerNumber?, bookingNumber?, scac?, refNumbers? })createTrackingRequest({ requestType, requestNumber, scac?, refNumbers?, shipmentTags? })inferTrackingNumber(number)createTrackingRequestFromInfer(number, { scac?, numberType?, refNumbers?, shipmentTags? })getShipment(id, includeContainers?)listShipments(filters?, options?)listContainers(filters?, options?)listTrackingRequests(filters?, options?)/listTrackRequests(filters?, options?)getContainerTransportEvents(id)getContainerRoute(id)listShippingLines(search?)getDemurrage(containerId)(helper)getRailMilestones(containerId)(helper)deserialize<T>(document)→ JSONA-based plain objects
Examples
After building, run:
cd sdks/typescript-sdk
export T49_API_TOKEN=your_token
export T49_CONTAINER_ID=valid_container_uuid
npm run build
npm run exampleexample.ts prints the raw JSON:API response and a simplified view using deserialize.
Development
# Generate types from OpenAPI
npm run generate:types
# Generate Mintlify-compatible TypeDoc pages
npm run docs
# Type-check
npm run type-check
# Tests
npm test
# Lint (Biome)
npm run lint
# Build
npm run buildTesting
Unit tests:
cd sdks/typescript-sdk
npm testType checks and lint:
cd sdks/typescript-sdk
npm run type-check
npm run lintSmoke tests (optional, require a token):
cd sdks/typescript-sdk
export T49_API_TOKEN=your_token
export T49_API_BASE_URL=https://api.terminal49.com/v2
export T49_INFER_NUMBER=your_tracking_number
export T49_RUN_SMOKE=1
npm run smokeFixtures
Generate sanitized, production-based fixtures for tests:
cd sdks/typescript-sdk
export T49_API_TOKEN=your_token
export T49_API_BASE_URL=https://api.terminal49.com/v2
npm run fixtures:generateThis writes JSON:API fixtures to src/fixtures/ with redacted IDs and numbers.
Numeric identifiers keep their original prefix while the last few characters are
obfuscated to preserve shape without exposing real values.
List endpoints are captured without include for performance guidance. Single-resource
fixtures include both base and include variants where supported.
Documentation generation
The SDK uses TypeDoc with typedoc-plugin-markdown to generate Mintlify-compatible MDX pages.
cd sdks/typescript-sdk
npm run docsGenerated files are written to ../../docs/sdk/reference/ and are included in the Mintlify navigation in docs/docs.json.
From the repo root, you can also run:
npm run sdk:docsReleasing a new version
Releases are automated via release-please.
Automated flow (default)
- Merge PRs to
mainwith conventional commit prefixes (feat:,fix:,docs:,chore:, etc.) that touchsdks/typescript-sdk/. - Release-please automatically opens a release PR that bumps
package.json, updatesCHANGELOG.md, and updates the manifest. - Merge the release PR.
- Release-please creates a GitHub release with the
sdk-v-v<version>tag. - The publish workflow builds, tests, and publishes to npm automatically via npm Trusted Publishing.
Manual release (fallback)
If you need to release without release-please:
- Update
CHANGELOG.mdand bump version:cd sdks/typescript-sdk npm version patch # or minor / major - Commit and push:
git add package.json package-lock.json CHANGELOG.md git commit -m "chore: release @terminal49/sdk v$(node -p "require('./package.json').version")" git push - Create a GitHub release with tag
sdk-v<version>(e.g.sdk-v0.2.0). The publish workflow will build, test, and publish to npm via npm Trusted Publishing.
Post-release
Regenerate docs if the public API changed:
npm run sdk:docsNotes
- Server-only: uses Node fetch (undici types) and targets Node 18+.
- Returns raw JSON:API documents by default; use
deserializefor flattened objects or add your own mappers.
