@vulog/aima-client 1.2.44 → 1.2.46

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/README.md CHANGED
@@ -1,19 +1,91 @@
1
1
  # @vulog/aima-client
2
2
 
3
- ```bash
4
- npm i @vulog/aima-client
3
+ Core HTTP client with OAuth2 authentication, token caching, and request interceptors.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install @vulog/aima-client
5
9
  ```
6
10
 
7
- ```javascript
11
+ ## Usage
12
+
13
+ ```ts
8
14
  import { getClient } from '@vulog/aima-client';
9
15
 
10
16
  const client = getClient({
11
- apiKey: '...',
12
- baseUrl: '...',
13
- clientId: '...',
14
- clientSecret: '...',
15
- fleetId: '...',
17
+ fleetId: 'my-fleet',
18
+ baseUrl: 'https://api.example.com',
19
+ clientId: 'my-client-id',
20
+ clientSecret: 'my-client-secret',
21
+ apiKey: 'my-api-key',
16
22
  });
23
+ ```
24
+
25
+ ## API Reference
26
+
27
+ ### getClient
17
28
 
18
- const { data: serviceResponse } = await client.get(`/boapi/proxy/user/fleets/.../master/services`);
29
+ ```ts
30
+ getClient(options: ClientOptions): Client
19
31
  ```
32
+
33
+ Factory that returns a cached Axios-based `Client`. Uses an LRU cache keyed by `options.name ?? options.fleetId`. Attaches OAuth2 token interceptors (client_credentials flow), auto-refreshes on 401 (up to 5 retries), and supports optional cURL logging.
34
+
35
+ | Parameter | Type | Description |
36
+ |-----------|------|-------------|
37
+ | `options` | `ClientOptions` | Configuration for the client instance |
38
+
39
+ Returns a `Client` (authenticated Axios instance).
40
+
41
+ ## Types
42
+
43
+ ### ClientOptions
44
+
45
+ | Field | Type | Required | Description |
46
+ |-------|------|----------|-------------|
47
+ | `fleetId` | `string` | Yes | Fleet identifier |
48
+ | `baseUrl` | `string` | Yes | Base URL for API requests |
49
+ | `clientId` | `string` | Yes | OAuth2 client ID |
50
+ | `clientSecret` | `string` | Yes | OAuth2 client secret |
51
+ | `apiKey` | `string` | Yes | API key |
52
+ | `name` | `string` | No | Cache key override (defaults to `fleetId`) |
53
+ | `fleetMaster` | `string` | No | Realm override for token URL |
54
+ | `secure` | `boolean` | No | Enables password grant and refresh_token flow |
55
+ | `logCurl` | `boolean` | No | Logs a cURL command for each request |
56
+ | `logResponse` | `boolean` | No | Logs the full response |
57
+ | `store` | `Store` | No | Custom token storage (defaults to in-memory LRU) |
58
+ | `onLog` | `(...args: any[]) => void` | No | Custom logger function |
59
+ | `userAgent` | `string` | No | Overrides default `aima-node/{version} {fleetId}` |
60
+
61
+ ### Client
62
+
63
+ Axios instance extended with:
64
+
65
+ | Member | Type | Description |
66
+ |--------|------|-------------|
67
+ | `signInWithPassword` | `(username: string, password: string) => Promise<Token>` | Password grant — only available when `secure: true` |
68
+ | `clientOptions` | `ClientOptions` | The options used to create this client |
69
+
70
+ ### Token
71
+
72
+ | Field | Type |
73
+ |-------|------|
74
+ | `accessToken` | `string` |
75
+ | `refreshToken` | `string` |
76
+
77
+ ### Store
78
+
79
+ Custom token storage interface.
80
+
81
+ | Method | Signature |
82
+ |--------|-----------|
83
+ | `getToken` | `() => Promise<Token \| undefined>` |
84
+ | `setToken` | `(token: Token) => Promise<void>` |
85
+
86
+ ### ClientError
87
+
88
+ | Field | Type |
89
+ |-------|------|
90
+ | `formattedError` | `{ status?: any; data?: any; message?: any }` |
91
+ | `originalError` | `any` |
package/dist/index.cjs CHANGED
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  }) : target, mod));
23
23
  //#endregion
24
24
  let axios = require("axios");
25
- axios = __toESM(axios);
25
+ axios = __toESM(axios, 1);
26
26
  let es_toolkit = require("es-toolkit");
27
27
  let lru_cache = require("lru-cache");
28
28
  //#region src/CurlHelper.ts
@@ -133,7 +133,7 @@ const getClient = (options) => {
133
133
  "Cache-Control": "no-cache",
134
134
  "Content-Type": "application/json",
135
135
  "X-Api-Key": options.apiKey,
136
- "User-Agent": options.userAgent ?? `aima-node/1.2.44 ${options.fleetId}`
136
+ "User-Agent": options.userAgent ?? `aima-node/1.2.46 ${options.fleetId}`
137
137
  },
138
138
  withCredentials: false
139
139
  });
package/dist/index.mjs CHANGED
@@ -109,7 +109,7 @@ const getClient = (options) => {
109
109
  "Cache-Control": "no-cache",
110
110
  "Content-Type": "application/json",
111
111
  "X-Api-Key": options.apiKey,
112
- "User-Agent": options.userAgent ?? `aima-node/1.2.44 ${options.fleetId}`
112
+ "User-Agent": options.userAgent ?? `aima-node/1.2.46 ${options.fleetId}`
113
113
  },
114
114
  withCredentials: false
115
115
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vulog/aima-client",
3
3
  "type": "module",
4
- "version": "1.2.44",
4
+ "version": "1.2.46",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.cts",
@@ -33,9 +33,9 @@
33
33
  "author": "Vulog",
34
34
  "license": "MIT",
35
35
  "peerDependencies": {
36
- "axios": "^1.13.6",
36
+ "axios": "^1.15.0",
37
37
  "es-toolkit": "^1.45.1",
38
- "lru-cache": "^11.2.7"
38
+ "lru-cache": "^11.3.5"
39
39
  },
40
40
  "description": ""
41
- }
41
+ }