npm.io
1.0.28-alpha.1 • Published 9 months ago

@med.me/adt-sdk

Licence
MIT
Version
1.0.28-alpha.1
Deps
0
Size
363 kB
Vulns
0
Weekly
0

@med.me/adt-sdk

Medme ADT SDK - TypeScript client library for ADT API

Installation

npm install @med.me/adt-sdk
# or
yarn add @med.me/adt-sdk

Usage

import { OpenAPI, PatientService, ActivityService } from '@med.me/adt-sdk';

// Configure the API client
OpenAPI.BASE = 'http://localhost:5000';
OpenAPI.TOKEN = 'your-auth-token';

// Use the services
const patients = await PatientService.getPatients();
const activities = await ActivityService.getActivities();

Development

Prerequisites
  1. Make sure the ADT backend (adt-core) is running on http://localhost:5000
  2. Ensure you have the required dependencies installed
SDK Update Process
1. Update Backend API Schema

In the adt-core project:

yarn gen:openapi  # Generate updated openapi.json
yarn start:dev    # Start server to serve OpenAPI schema
2. Regenerate SDK Code

In the adt-sdk project:

# Install dependencies (first time only)
yarn install

# Generate new SDK code from current backend
API_URL=http://localhost:5000/openapi-json yarn codegen-local

# Build the SDK
yarn build
3. Update Frontend Project

In the adt-front project:

# Update SDK dependency
yarn install
Version Management

When updating the SDK with new changes:

  1. Update version in package.json:

    npm version patch  # for bug fixes
    npm version minor  # for new features
    npm version major  # for breaking changes
  2. Build and test:

    yarn build
  3. Publish (if using npm registry):

    npm publish
Scripts
  • yarn codegen-local - Generate SDK code from local backend API
  • yarn build - Build the SDK for distribution

Project Structure

src/
├── core/          # Core API utilities
├── models/        # TypeScript type definitions
├── services/      # API service classes
└── index.ts       # Main export file

Notes

  • The SDK is automatically generated from OpenAPI specification
  • Do not manually edit generated files in src/ - they will be overwritten
  • Always use the codegen-local script to update the SDK
  • The SDK uses fetch API client for HTTP requests

Troubleshooting

Common Issues
  1. "openapi command not found"

    yarn add -D openapi-typescript-codegen
  2. Backend not responding

    • Ensure adt-core is running on port 5000
    • Check that /openapi-json endpoint is accessible
  3. Build errors after regeneration

    • Check for naming conflicts in generated types
    • Verify OpenAPI schema is valid
Getting Help

If you encounter issues during SDK update:

  1. Check that backend API is running and accessible
  2. Verify the OpenAPI schema is valid
  3. Review generated code for any obvious issues
  4. Check console for specific error messages