linxio-js
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.

Check whether a result failed

Check whether a result failed

isLinxioFailure(result)

Narrows a LinxioResult<T> or LinxioPageResult<T> to its failure branch.

Input

result
LinxioResult<unknown> | LinxioPageResult<unknown>
required
SDK result object returned by a domain service.

Returns

data
boolean
optional
True when result.error is not null.

Unwrap a result

Unwrap a result

unwrapLinxioResult(result)

Returns data from a successful result or throws the contained SDK error. Use this when your script prefers normal throwing control flow.

Input

result
LinxioResult<TData>
required
Non-paginated SDK result object.

Returns

data
TData
optional
Successful result data.
throws
LinxioError
optional
The contained SDK error when result.error is present.

Unwrap a page result

Unwrap a page result

unwrapLinxioPageResult(result)

Returns a successful page result or throws the contained SDK error.

Input

result
LinxioPageResult<TData>
required
Paginated SDK result object.

Returns

data
LinxioPageSuccess<TData>
optional
Successful page result with data, meta, page, limit, and total.
throws
LinxioError
optional
The contained SDK error when result.error is present.

Convert unknown errors

Convert unknown errors

toLinxioError(error)

Converts arbitrary thrown values into the SDK base error type.

Input

error
unknown
required
Unknown thrown value from user code or a custom integration.

Returns

data
LinxioError
optional
Existing LinxioError values are returned as-is; other values are wrapped.

Create result objects

Create result objects

ok(data); fail(error); pageOk(page); pageFail(error)

Builds SDK-shaped result objects for custom services or tests.

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.

Collect pages

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.
params
TParams
optional
Initial list parameters. limit controls page size.

Returns

data
LinxioResult<TData[]>
optional
All records from all pages, or a typed SDK error.

Stream pages

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.
params
TParams
optional
Initial list parameters. limit controls page size.

Returns

yield
TData
optional
One item at a time across all pages.
throws
LinxioError
optional
Thrown when any page fails.

Use the endpoint catalogue

Use the endpoint catalogue

linxioEndpoints

Runtime catalogue of public and dashboard-derived endpoints represented by the SDK.

Endpoint definition

method
GET | POST | PATCH | PUT | DELETE
optional
HTTP method.
path
string
optional
Endpoint path. Dynamic segments use {name} placeholders.
source
public-docs | dashboard
optional
Whether the endpoint is from Linxio's public API docs or inferred from dashboard JavaScript.

Flatten endpoint definitions

Flatten endpoint definitions

flattenEndpointDefinitions(catalogue)

Converts the nested endpoint catalogue into a sorted array of endpoint definitions.

Input

catalogue
unknown
required
Nested endpoint catalogue, usually linxioEndpoints.

Returns

data
LinxioEndpointDefinition[]
optional
Sorted endpoint definitions.

Extract dashboard endpoints

Extract dashboard endpoints

extractDashboardEndpoints(sources)

Extracts endpoint evidence from captured Linxio dashboard JavaScript bundles.

Input

sources
DashboardSourceFile[]
required
Source filename and JavaScript content pairs.

Returns

data
DashboardEndpointEvidence[]
optional
Endpoint candidates with methods, files, occurrence counts, and normalized paths.

Compare endpoint coverage

Compare endpoint coverage

compareDashboardEndpointCoverage(input)

Compares dashboard-extracted endpoint evidence with SDK endpoint definitions.

Input

dashboardEndpoints
DashboardEndpointEvidence[]
required
Endpoint evidence from extractDashboardEndpoints().
sdkEndpoints
LinxioEndpointDefinition[]
required
Flattened SDK endpoint definitions.

Returns

dashboardCovered
DashboardEndpointEvidence[]
optional
Dashboard-observed endpoints represented in the SDK catalogue.
dashboardOnly
DashboardEndpointEvidence[]
optional
Dashboard-observed endpoints not represented in the SDK catalogue.
sdkOnly
LinxioEndpointDefinition[]
optional
SDK catalogue endpoints not observed in the analysed dashboard bundle set.

On this page