SDK Reference
Utilities Result helpers, pagination helpers, endpoint catalogue exports, and dashboard endpoint analysis helpers.
Most projects can stay inside the domain services. These helpers are exported
for scripts, tests, custom endpoint wrappers, and endpoint-discovery tooling.
Input resultLinxioResult<unknown> | LinxioPageResult<unknown>
required SDK result object returned by a domain service.
Returns True when result.error is not null.
import { isLinxioFailure } from "linxio-js" ;
const result = await linxio.vehicles. list ({ limit: 100 });
if ( isLinxioFailure (result)) {
console. error (result.error.name, result.error.message);
process.exitCode = 1 ;
}
Input resultLinxioResult<TData>
required Non-paginated SDK result object.
Returns throwsLinxioError
optional The contained SDK error when result.error is present.
import { unwrapLinxioResult } from "linxio-js" ;
const vehicle = unwrapLinxioResult ( await linxio.vehicles. get (vehicleId));
console. log (vehicle.regNo);
Unwrap a page result unwrapLinxioPageResult(result)
Returns a successful page result or throws the contained SDK error.
Input resultLinxioPageResult<TData>
required Paginated SDK result object.
Returns dataLinxioPageSuccess<TData>
optional Successful page result with data, meta, page, limit, and total.
throwsLinxioError
optional The contained SDK error when result.error is present.
import { unwrapLinxioPageResult } from "linxio-js" ;
const page = unwrapLinxioPageResult (
await linxio.vehicles. list ({ limit: 100 }),
);
console. log (page.meta.total);
Input Unknown thrown value from user code or a custom integration.
Returns Existing LinxioError values are returned as-is; other values are wrapped.
import { toLinxioError } from "linxio-js" ;
try {
await runCustomEndpoint ();
} catch (error) {
const linxioError = toLinxioError (error);
console. error (linxioError.message);
}
Helpers ok(data)LinxioSuccess<TData>
optional Creates a successful non-paginated result.
fail(error)LinxioFailure<LinxioError>
optional Creates a failed non-paginated result from an unknown error.
pageOk(page)LinxioPageSuccess<TData>
optional Creates a successful paginated result from a normalized page.
pageFail(error)LinxioPageFailure<LinxioError>
optional Creates a failed paginated result from an unknown error.
import { fail, ok } from "linxio-js" ;
async function readCustomThing () {
try {
return ok ( await linxio. request ( "GET" , "/custom-thing" ));
} catch (error) {
return fail (error);
}
}
Collect pages collectPages(loadPage, params)
Loads every page from a paginated endpoint into a single result object.
Domain services already wrap this for common list methods.
Input loadPage(params: TParams) => Promise<LinxioPageResult<TData>>
required Function that loads one page.
Initial list parameters. limit controls page size.
Returns dataLinxioResult<TData[]>
optional All records from all pages, or a typed SDK error.
Collect custom endpoint pages import { collectPages } from "linxio-js" ;
const result = await collectPages (
( params ) => linxio.devices. installations (params),
{ limit: 100 },
);
if (result.error) {
throw result.error;
}
Stream pages streamPages(loadPage, params)
Streams a paginated endpoint one item at a time. This helper throws if a
page fails.
Input loadPage(params: TParams) => Promise<LinxioPageResult<TData>>
required Function that loads one page.
Initial list parameters. limit controls page size.
Returns One item at a time across all pages.
throwsLinxioError
optional Thrown when any page fails.
Stream custom endpoint pages import { streamPages } from "linxio-js" ;
for await ( const installation of streamPages (
( params ) => linxio.devices. installations (params),
{ limit: 100 },
)) {
console. log (installation.deviceId, installation.vehicleId);
}
Endpoint definition methodGET | POST | PATCH | PUT | DELETE
optional Endpoint path. Dynamic segments use {name} placeholders.
sourcepublic-docs | dashboard
optional Whether the endpoint is from Linxio's public API docs or inferred from dashboard JavaScript.
import { linxioEndpoints } from "linxio-js" ;
console. log (linxioEndpoints.vehicles.list);
// { method: "GET", path: "/vehicles/fields/json", source: "public-docs" }
Input Nested endpoint catalogue, usually linxioEndpoints.
Returns dataLinxioEndpointDefinition[]
optional Sorted endpoint definitions.
import { flattenEndpointDefinitions, linxioEndpoints } from "linxio-js" ;
const endpoints = flattenEndpointDefinitions (linxioEndpoints);
console. table (endpoints. slice ( 0 , 5 ));
Input sourcesDashboardSourceFile[]
required Source filename and JavaScript content pairs.
Returns dataDashboardEndpointEvidence[]
optional Endpoint candidates with methods, files, occurrence counts, and normalized paths.
Extract dashboard endpoint evidence import { extractDashboardEndpoints } from "linxio-js" ;
const endpoints = extractDashboardEndpoints ([
{
filename: "main.js" ,
content: dashboardBundle,
},
]);
Input dashboardEndpointsDashboardEndpointEvidence[]
required Endpoint evidence from extractDashboardEndpoints().
sdkEndpointsLinxioEndpointDefinition[]
required Flattened SDK endpoint definitions.
Returns dashboardCoveredDashboardEndpointEvidence[]
optional Dashboard-observed endpoints represented in the SDK catalogue.
dashboardOnlyDashboardEndpointEvidence[]
optional Dashboard-observed endpoints not represented in the SDK catalogue.
sdkOnlyLinxioEndpointDefinition[]
optional SDK catalogue endpoints not observed in the analysed dashboard bundle set.
import {
compareDashboardEndpointCoverage,
extractDashboardEndpoints,
flattenEndpointDefinitions,
linxioEndpoints,
} from "linxio-js" ;
const coverage = compareDashboardEndpointCoverage ({
dashboardEndpoints: extractDashboardEndpoints (sources),
sdkEndpoints: flattenEndpointDefinitions (linxioEndpoints),
});
console. log (coverage.dashboardOnly);