@dimescheduler/sdk
v0.8.0
Published
The Dime.Scheduler SDK
Maintainers
Readme
Supercharge your business by powering up Microsoft Dynamics 365 Business Central with a centralized resource and project planning solution 📅. Dime.Scheduler, with its powerful features and flexible design, has a proven track record in constious industries and is trusted by dozens of resellers and thousands of people all over the world 🚀.
Check out the 📚 docs » for more info.
Installation
Use whichever package manager you prefer:
Using npm:
npm install @dimescheduler/sdkUsing yarn:
yarn add @dimescheduler/sdkUsing bun:
bun i @dimescheduler/sdkUsing pnpm:
pnpm add @dimescheduler/sdkPrereleases
Alpha / beta / release-candidate builds (e.g. 0.7.1-beta.0) ship to the next dist-tag. To opt into them:
npm install @dimescheduler/sdk@nextExample
import DimeSchedulerClient from "@dimescheduler/sdk";
import type { Category } from "@dimescheduler/sdk/models";
const client = new DimeSchedulerClient({ apiKey: "MY_API_KEY" });
const category: Category = {
name: "My category",
color: "#" + ((Math.random() * 0xffffff) << 0).toString(16),
};
const { data, error, response } = await client.categories.create(category);Every entity hangs off a typed domain accessor on the client — client.categories, client.appointments, client.resources, etc. CRUD-shaped entities expose create, update, delete, and getAll; specialized endpoints (geocoding, optimization, recommendation, …) get their own purpose-built methods. Everything is typed against the Dime.Scheduler OpenAPI specification, so request bodies, query parameters, and response shapes autocomplete in your editor.
Usage
API key
Create an API key and pass it to the constructor:
import DimeSchedulerClient from "@dimescheduler/sdk";
const client = new DimeSchedulerClient({ apiKey: "MY_API_KEY" });Environment
The default environment is production. Use the Environment enum to point at the sandbox or test environments:
import DimeSchedulerClient, { Environment } from "@dimescheduler/sdk";
const client = new DimeSchedulerClient({ apiKey, environment: Environment.Sandbox });Models
Import body and response types from the @dimescheduler/sdk/models submodule. Write entities (e.g. Category, Resource, Appointment) match POST/PUT bodies; read DTOs (e.g. CategoryDto, ResourceDto) match GET responses.
import type { Category, CategoryDto } from "@dimescheduler/sdk/models";For the full type surface, every schema is also reachable via the generated components["schemas"] map exported from the package root:
import type { components } from "@dimescheduler/sdk";
type StoredProcedureData = components["schemas"]["Models.StoredProcedureData"];Calling the API
CRUD entities accept either a single object or an array — both shapes are typed:
await client.categories.create(category);
await client.categories.create([category, anotherCategory]);
await client.categories.update(category);
await client.categories.delete(category);
const { data } = await client.categories.getAll();Endpoints with required parameters expose them directly:
await client.appointments.get(startDate, endDate, ["RES1", "RES2"]);
await client.notifications.get(1, 50, { sort: "createdAt:desc" });
await client.geocoding.geocodeText("221B Baker Street", "GB");
await client.optimization.fieldService(request);Every method returns { data, error, response }. Inspect response.ok for the HTTP status, data for the typed body on success, and error for the typed error body on failure.
Middleware
DimeSchedulerClient is built on openapi-fetch, so any extra option (custom fetch, querySerializer, middleware) can be passed through:
const client = new DimeSchedulerClient({
apiKey,
fetch: customFetch,
});
client.use({
onRequest: ({ request }) => {
console.log(request.method, request.url);
},
});Regenerating types
The OpenAPI spec lives at openapi.json in this repo. After updating it, run:
yarn codegenThis rewrites src/generated/api.d.ts. The build runs codegen automatically via prebuild.
