@scalepad/sdk-core
v0.1.3
Published
Thin typed ScalePad Core API helper package used by the ScalePad CLI.
Keywords
Readme
@scalepad/sdk-core
Thin typed client for selected ScalePad Core API routes used by the ScalePad CLI.
@scalepad/cli is the primary supported developer interface right now. Use this package when you need a lightweight programmatic helper for a subset of Core API workflows.
Install
npm install @scalepad/sdk-coreUsage
import { createCoreClient } from "@scalepad/sdk-core";
const client = createCoreClient({
apiKey: process.env.SCALEPAD_API_KEY!,
validateResponses: true
});
const clients = await client.listClients({ pageSize: 10 });
console.log(clients.data);API
The package exports a generated client plus a small convenience wrapper.
Wrapper helpers:
createCoreClient(config)ScalepadCoreClientlistClients(query)getClient(id)listIntegrationConfigurations()listHardwareAssets(query)listTickets(query)paginateClientPages(query)paginateClients(query)collectAllClients(query)paginateHardwareAssetPages(query)paginateHardwareAssets(query)collectAllHardwareAssets(query)paginateTicketPages(query)paginateTickets(query)collectAllTickets(query)
Generated and schema exports:
GeneratedCoreClientcoreOperationsScalepadApiErrorpaths
Client configuration
type CoreClientConfig = {
apiKey: string;
baseUrl?: string;
fetchImpl?: typeof fetch;
userAgent?: string;
timeoutMs?: number;
maxRetries?: number;
retry?: Partial<RetryConfig>;
validateResponses?: boolean;
};apiKeyis required and is sent asx-api-keybaseUrldefaults tohttps://api.scalepad.comfetchImpllets you inject a custom fetch implementationuserAgentdefaults to@scalepad/clitimeoutMsdefaults to30000maxRetriesis kept for backward compatibility and overridesretry.maxRetrieswhen setretry.retryOn429andretry.retryOn5xxcontrol safe-method retriesretry.retryUnsafeMethodsdefaults tofalsevalidateResponsesenables basic runtime envelope validation for wrapper methods
List queries
List endpoints accept this shared shape:
type ListQuery = {
cursor?: string;
pageSize?: number;
filters?: Record<string, string>;
sort?: string;
};Filters are translated to filter[field]=expression query parameters, and pageSize is translated to page_size.
Pagination helpers
Wrapper list methods still support manual cursor pagination through ListQuery, and the package now also exports helper iterators:
for await (const clientRecord of client.paginateClients({ pageSize: 100 })) {
console.log(clientRecord.id);
}
const allTickets = await client.collectAllTickets({ pageSize: 200 });Error handling
Failed requests throw richer typed errors:
ScalepadApiErrorfor general API failuresAuthenticationErrorAuthorizationErrorRateLimitErrorServerErrorTimeoutErrorNetworkErrorResponseValidationError
Development
This package is generated from the checked-in OpenAPI spec in the monorepo root. To refresh or rebuild it:
pnpm fetch:specs
pnpm generate:sdk
pnpm --filter @scalepad/sdk-core build