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 SDK result object returned by a domain service.
Show child parameters Returned data on success, or null on failure.
Typed SDK error when the operation fails.
Returns True when result.error is not null.
import { isLinxioFailure } from "@ambulancewa/linxio-js" ;
const result = await linxio.vehicles. list ({ limit: 100 });
if ( isLinxioFailure (result)) {
console. error (result.error.name, result.error.message);
process.exitCode = 1 ;
} {
"data" : true
}
Input Non-paginated SDK result object.
Show child parameters Returned data on success, or null on failure.
Typed SDK error when the operation fails.
Returns The contained SDK error when result.error is present.
Show child fields Original cause when available.
HTTP method when the error came from a request.
API path when the error came from a request.
Request identifier from X-Request-Id when supplied.
import { unwrapLinxioResult } from "@ambulancewa/linxio-js" ;
const vehicle = unwrapLinxioResult ( await linxio.vehicles. get (vehicleId));
console. log (vehicle.regNo); {
"data" : "string"
}
Unwrap a page result unwrapLinxioPageResult(result)
Returns a successful page result or throws the contained SDK error.
Input Paginated SDK result object.
Show child parameters dataTData[] | null
optional Records for the current page on success, or null on failure.
Typed SDK error when the operation fails.
Normalized pagination metadata on success.
pagenumber | null
optional Current page number on success.
limitnumber | null
optional totalnumber | null
optional Total matching record count on success.
aggregationsunknown
optional Aggregation payload when Linxio returns one.
additionalFieldsRecord<string, unknown>
optional Additional page envelope fields retained by the SDK.
Returns dataLinxioPageSuccess<TData>
optional Successful page result with data, meta, page, limit, and total.
The contained SDK error when result.error is present.
Show child fields Original cause when available.
HTTP method when the error came from a request.
API path when the error came from a request.
Request identifier from X-Request-Id when supplied.
import { unwrapLinxioPageResult } from "@ambulancewa/linxio-js" ;
const page = unwrapLinxioPageResult (
await linxio.vehicles. list ({ limit: 100 }),
);
console. log (page.meta.total); {
"data" : "string"
}
Input Unknown thrown value from user code or a custom integration.
Returns Existing LinxioError values are returned as-is; other values are wrapped.
Show child fields Original cause when available.
HTTP method when the error came from a request.
API path when the error came from a request.
Request identifier from X-Request-Id when supplied.
import { toLinxioError } from "@ambulancewa/linxio-js" ;
try {
await runCustomEndpoint ();
} catch (error) {
const linxioError = toLinxioError (error);
console. error (linxioError.message);
} {
"data" : {
"message" : "string" ,
"name" : "Example" ,
"cause" : { } ,
"method" : "string" ,
"path" : "string" ,
"requestId" : "string"
}
}
Helpers ok(data)LinxioSuccess<TData>
optional Creates a successful non-paginated result.
Creates a failed non-paginated result from an unknown error.
Show child fields Original cause when available.
HTTP method when the error came from a request.
API path when the error came from a request.
Request identifier from X-Request-Id when supplied.
pageOk(page)LinxioPageSuccess<TData>
optional Creates a successful paginated result from a normalized page.
Creates a failed paginated result from an unknown error.
Show child fields Original cause when available.
HTTP method when the error came from a request.
API path when the error came from a request.
Request identifier from X-Request-Id when supplied.
import { fail, ok } from "@ambulancewa/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 Function that loads one page.
Show child parameters dataTData[] | null
optional Records for the current page on success, or null on failure.
Typed SDK error when the operation fails.
Normalized pagination metadata on success.
pagenumber | null
optional Current page number on success.
limitnumber | null
optional totalnumber | null
optional Total matching record count on success.
aggregationsunknown
optional Aggregation payload when Linxio returns one.
additionalFieldsRecord<string, unknown>
optional Additional page envelope fields retained by the SDK.
Initial list parameters. limit controls page size.
Returns All records from all pages, or a typed SDK error.
Show child fields Returned data on success, or null on failure.
Typed SDK error when the operation fails.
Stream pages streamPages(loadPage, params)
Streams a paginated endpoint one item at a time. This helper throws if a
page fails.
Input Function that loads one page.
Show child parameters dataTData[] | null
optional Records for the current page on success, or null on failure.
Typed SDK error when the operation fails.
Normalized pagination metadata on success.
pagenumber | null
optional Current page number on success.
limitnumber | null
optional totalnumber | null
optional Total matching record count on success.
aggregationsunknown
optional Aggregation payload when Linxio returns one.
additionalFieldsRecord<string, unknown>
optional Additional page envelope fields retained by the SDK.
Initial list parameters. limit controls page size.
Returns One item at a time across all pages.
Thrown when any page fails.
Show child fields Original cause when available.
HTTP method when the error came from a request.
API path when the error came from a request.
Request identifier from X-Request-Id when supplied.
Stream custom endpoint pages import { streamPages } from "@ambulancewa/linxio-js" ;
for await ( const sensor of streamPages (
( params ) => linxio.sensors. list (params),
{ limit: 100 },
)) {
console. log (sensor.id, sensor.label);
} {
"yield" : "string"
}
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 "@ambulancewa/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 "@ambulancewa/linxio-js" ;
const endpoints = flattenEndpointDefinitions (linxioEndpoints);
console. table (endpoints. slice ( 0 , 5 )); {
"data" : [
"string"
]
}
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 "@ambulancewa/linxio-js" ;
const endpoints = extractDashboardEndpoints ([
{
filename: "main.js" ,
content: dashboardBundle,
},
]); {
"data" : [
"string"
]
}
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.