JavaScript client

JavaScript client

@devium/rms is the official TypeScript client. It ships one client per API domain — each wraps a backend service, with typed methods, request/response models, and automatic case conversion.

Install

npm install @devium/rms

The clients

Every client is exported from the package root and defaults to its own versioned base path.

ClientDefault base pathCovers
AuthApiClient/api/v1/authLogin, token refresh, validation
UserApiClient/api/v1/usersUsers and user data
OrganizationApiClient/api/v1/organizationsOrganizations, locations, members
ResourceApiClient/api/v1/resourcesPools, resources, bookings, queues
AnalyticsApiClient/api/v1/analyticsState and utilization analytics
LCMApiClient/api/v1/lcmLifecycle state transitions
KeepAliveApiClient/api/v1/keep-aliveResource heartbeats
HostAgentApiClient/api/v1/host-agent-serviceHost agent operations
CentralAgentApiClient/api/v1/central-agentCentral agent coordination

BaseApiClient (the shared base) and ApiError are exported too, along with every request/response type.

Set up a client

Each client takes a base URL. In a browser app served from the same origin, the default relative path works as-is; from Node or another origin, pass the full URL. Authenticate by setting the access token (see Authentication).

import { AuthApiClient, ResourceApiClient } from '@devium/rms';

const host = 'https://app.devium.io';

const auth = new AuthApiClient(`${host}/api/v1/auth`);
const { accessToken } = await auth.login({ username: 'you@example.com', password: '••••••••' });

const resources = new ResourceApiClient(`${host}/api/v1/resources`);
resources.setAccessToken(accessToken);

setAccessToken(token) and clearAccessToken() are available on every client (inherited from BaseApiClient).

Conventions

A few behaviours are shared across all clients:

  • camelCase everywhere. You pass and receive camelCase; the client converts to the API's snake_case on the way out and back on the way in. Write availableFrom, not available_from.

  • Pagination. List endpoints accept page, limit, sortBy, and sortOrder, and return a PaginatedResponse<T>:

    interface PaginatedResponse<T> {
      items: T[];
      totalCount: number;
      page: number;
      limit: number;
      totalPages: number;
    }
    
  • Field selection. Pass a fields string (comma-separated, camelCase) to trim the response to the fields you need.

const page = await resources.getAllResources(poolId, {
  bookable: true,
  fields: 'id,name,state',
  page: 1,
  limit: 20,
  sortBy: 'name',
  sortOrder: 'asc',
});
console.log(page.items, `of ${page.totalCount}`);

Next steps