@ambulancewa/linxio-js 2.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ambulance Western Australia Limited. linxio-js is built on
4
+ the Linxio platform and is not officially connected with or endorsed by Linxio
5
+ and/or its affiliates. Any proprietary or copyrighted content remains the
6
+ property of Linxio, its affiliates, and/or the respective owner of the
7
+ copyrighted material.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ ![@ambulancewa/linxio-js](https://raw.githubusercontent.com/ambulancewa/linxio-js/refs/heads/main/repo-header.png)
2
+
3
+ linxio-js is a secure, lightweight, high-performance Node.js SDK for interacting with the [`Linxio`](https://linxio.com/) API. The client is fully-typed for use in Typescript projects, and is available as ECMAScript and CommonJS modules for use pretty much anywhere you can run Javascript. Query vehicles, drivers, and devices, stream live GPS positions, subscribe to real-time notifications, auto-paginate large fleets, export reports, manage geofences and routes, and more!
4
+
5
+ ```ts
6
+ import { createClient } from "@ambulancewa/linxio-js";
7
+
8
+ const linxio = createClient();
9
+
10
+ await linxio.auth.login({
11
+ email: process.env.LINXIO_EMAIL!,
12
+ password: process.env.LINXIO_PASSWORD!,
13
+ });
14
+
15
+ const { data, error } = await linxio.vehicles.iterate({
16
+ fields: ["id", "regNo", "lastLoggedAt"],
17
+ limit: 100,
18
+ });
19
+ ```
20
+
21
+ ## 👏 Key Features
22
+
23
+ - Fully typed TypeScript API.
24
+ - Available as both ESM and CommonJS packages.
25
+ - Fetch-native HTTP client with timeouts, typed errors, and safe JSON handling.
26
+ - Service methods return `{ data, error }` results for straightforward script ergonomics.
27
+ - Automatic JWT refresh with concurrent refresh coalescing.
28
+ - Exponential backoff retries for idempotent requests.
29
+ - Domain services for vehicles, routes, geofences, devices, drivers, sensors, fuel, users, clients, reports, digital forms, cameras, and realtime.
30
+ - Auto-pagination helpers and streaming iterators for paginated endpoints.
31
+ - Low-level `client.request()` escape hatch for tenant-specific endpoints.
32
+ - Socket.IO realtime helpers for live coordinates and notifications.
33
+
34
+ ## 📦 Installation
35
+
36
+ Prerequisites for installation:
37
+ - [Node.js](https://nodejs.org/en/download/) (v14 or higher)
38
+ - [pnpm](https://pnpm.io/installation) or your preferred compatible package manager
39
+
40
+ Installation is super straightforward. Simply install the package from npmjs:
41
+
42
+ ```bash
43
+ pnpm add @ambulancewa/linxio-js
44
+ ```
45
+
46
+ Full documentation is available at our Open Source Software Projects (OSSP) site: https://linxio-js.ambulancewa.dev
47
+
48
+ ## ⚡ Usage
49
+
50
+ ```ts
51
+ const login = await linxio.auth.login({
52
+ email,
53
+ password,
54
+ domain: "optional-domain",
55
+ });
56
+
57
+ if (login.error) {
58
+ throw login.error;
59
+ }
60
+
61
+ console.log(login.data.expireAt);
62
+ ```
63
+
64
+ Once initialised, you can use the client to query the Linxio API:
65
+
66
+ ```ts
67
+ const { data: vehicles, error, meta } = await linxio.vehicles.list({
68
+ fields: ["id", "regNo"],
69
+ limit: 50,
70
+ sort: "regNo",
71
+ });
72
+
73
+ if (error) {
74
+ throw error;
75
+ }
76
+
77
+ console.log(meta.total, vehicles);
78
+
79
+ const routes = await linxio.routes.getVehicleRoutes(vehicles[0].id, {
80
+ dateFrom: "2026-06-01T00:00:00+08:00",
81
+ dateTo: "2026-06-08T00:00:00+08:00",
82
+ });
83
+ ```
84
+
85
+ ## ⚙️ Advanced requests
86
+
87
+ Use domain services for normal workflows. For tenant-specific or newly
88
+ discovered endpoints, `client.request()` keeps the same auth, retry, timeout,
89
+ and token-refresh behavior.
90
+
91
+ ```ts
92
+ const response = await linxio.request("GET", "/vehicles/count");
93
+ ```
94
+
95
+ ## 🔴 Realtime
96
+
97
+ ```ts
98
+ const unsubscribe = linxio.realtime.onPosition([304], (position) => {
99
+ console.log(position.vehicleId, position.lat, position.lng);
100
+ });
101
+
102
+ unsubscribe();
103
+ ```
104
+
105
+ ## ❌ Errors
106
+
107
+ ```ts
108
+ import { LinxioApiError } from "linxio-js";
109
+
110
+ const { error } = await linxio.vehicles.create({});
111
+
112
+ if (error instanceof LinxioApiError) {
113
+ console.error(error.status, error.path, error.body);
114
+ }
115
+ ```
116
+
117
+ Low-level `client.request()` calls throw typed SDK errors directly.