@vulog/aima-config 1.2.45 → 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 +145 -264
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,352 +1,233 @@
|
|
|
1
1
|
# @vulog/aima-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Fleet configuration — cities, services, labels, and payment parameters.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
```
|
|
8
|
-
npm install @vulog/aima-
|
|
7
|
+
```sh
|
|
8
|
+
npm install @vulog/aima-config @vulog/aima-client @vulog/aima-core
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```javascript
|
|
13
|
+
```ts
|
|
16
14
|
import { getClient } from '@vulog/aima-client';
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
deleteLabel,
|
|
25
|
-
getLabels
|
|
26
|
-
} from '@vulog/aima-config';
|
|
27
|
-
|
|
28
|
-
const client = getClient({
|
|
29
|
-
apiKey: 'your-api-key',
|
|
30
|
-
baseUrl: 'https://your-api-base-url',
|
|
31
|
-
clientId: 'your-client-id',
|
|
32
|
-
clientSecret: 'your-client-secret',
|
|
33
|
-
fleetId: 'your-fleet-id',
|
|
34
|
-
});
|
|
15
|
+
import { getCities, getServices, getFleetConf } from '@vulog/aima-config';
|
|
16
|
+
|
|
17
|
+
const client = getClient({ /* client options */ });
|
|
18
|
+
|
|
19
|
+
const cities = await getCities(client);
|
|
20
|
+
const services = await getServices(client);
|
|
21
|
+
const conf = await getFleetConf(client);
|
|
35
22
|
```
|
|
36
23
|
|
|
37
24
|
## API Reference
|
|
38
25
|
|
|
39
|
-
###
|
|
26
|
+
### getCities
|
|
40
27
|
|
|
41
|
-
|
|
28
|
+
```ts
|
|
29
|
+
getCities(client: Client): Promise<City[]>
|
|
30
|
+
```
|
|
42
31
|
|
|
43
|
-
|
|
32
|
+
Returns cities matching the client's `fleetId`.
|
|
44
33
|
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
**Params:** `client` — Authenticated AIMA client
|
|
35
|
+
**Returns:** `Promise<City[]>`
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### getCitiesAllFranchises
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
getCitiesAllFranchises(client: Client): Promise<(City & { fleetId: string })[]>
|
|
47
43
|
```
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
- `client`: AIMA client instance
|
|
45
|
+
Returns all cities across all franchises, each annotated with its `fleetId`.
|
|
51
46
|
|
|
52
|
-
**
|
|
47
|
+
**Params:** `client` — Authenticated AIMA client
|
|
48
|
+
**Returns:** `Promise<(City & { fleetId: string })[]>`
|
|
53
49
|
|
|
54
|
-
|
|
50
|
+
---
|
|
55
51
|
|
|
56
|
-
|
|
52
|
+
### getServices
|
|
57
53
|
|
|
58
|
-
```
|
|
59
|
-
|
|
54
|
+
```ts
|
|
55
|
+
getServices(client: Client): Promise<Service[]>
|
|
60
56
|
```
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
- `client`: AIMA client instance
|
|
58
|
+
Returns services matching the client's `fleetId`.
|
|
64
59
|
|
|
65
|
-
**
|
|
60
|
+
**Params:** `client` — Authenticated AIMA client
|
|
61
|
+
**Returns:** `Promise<Service[]>`
|
|
66
62
|
|
|
67
|
-
|
|
63
|
+
---
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
### getServicesAllFranchises
|
|
70
66
|
|
|
71
|
-
```
|
|
72
|
-
|
|
67
|
+
```ts
|
|
68
|
+
getServicesAllFranchises(client: Client): Promise<(Service & { fleetId: string })[]>
|
|
73
69
|
```
|
|
74
70
|
|
|
75
|
-
|
|
76
|
-
- `client`: AIMA client instance
|
|
71
|
+
Returns all services across all franchises, each annotated with its `fleetId`.
|
|
77
72
|
|
|
78
|
-
**
|
|
73
|
+
**Params:** `client` — Authenticated AIMA client
|
|
74
|
+
**Returns:** `Promise<(Service & { fleetId: string })[]>`
|
|
79
75
|
|
|
80
|
-
|
|
76
|
+
---
|
|
81
77
|
|
|
82
|
-
|
|
78
|
+
### getFleetConf
|
|
83
79
|
|
|
84
|
-
```
|
|
85
|
-
|
|
80
|
+
```ts
|
|
81
|
+
getFleetConf(client: Client): Promise<FleetConf>
|
|
86
82
|
```
|
|
87
83
|
|
|
88
|
-
|
|
89
|
-
- `client`: AIMA client instance
|
|
84
|
+
Returns fleet-level configuration.
|
|
90
85
|
|
|
91
|
-
**
|
|
86
|
+
**Params:** `client` — Authenticated AIMA client
|
|
87
|
+
**Returns:** `Promise<FleetConf>`
|
|
92
88
|
|
|
93
|
-
|
|
89
|
+
---
|
|
94
90
|
|
|
95
|
-
|
|
91
|
+
### getLabels
|
|
96
92
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```javascript
|
|
100
|
-
const label = await createLabel(client, {
|
|
101
|
-
name: 'Premium User',
|
|
102
|
-
color: '#FF5733',
|
|
103
|
-
description: 'High-value customers'
|
|
104
|
-
});
|
|
93
|
+
```ts
|
|
94
|
+
getLabels(client: Client): Promise<Label[]>
|
|
105
95
|
```
|
|
106
96
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
- `color`: Label color (hex code)
|
|
112
|
-
- `description`: Label description
|
|
97
|
+
Returns all labels for the fleet.
|
|
98
|
+
|
|
99
|
+
**Params:** `client` — Authenticated AIMA client
|
|
100
|
+
**Returns:** `Promise<Label[]>`
|
|
113
101
|
|
|
114
|
-
|
|
102
|
+
---
|
|
115
103
|
|
|
116
|
-
|
|
104
|
+
### addLabel
|
|
117
105
|
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
name: 'Updated Label Name',
|
|
121
|
-
color: '#33FF57',
|
|
122
|
-
description: 'Updated description'
|
|
123
|
-
});
|
|
106
|
+
```ts
|
|
107
|
+
addLabel(client: Client, name: string): Promise<void>
|
|
124
108
|
```
|
|
125
109
|
|
|
126
|
-
|
|
110
|
+
Creates a new label. `name` must be non-empty.
|
|
127
111
|
|
|
128
|
-
|
|
112
|
+
**Params:** `client` — Authenticated AIMA client; `name` — label name (non-empty)
|
|
113
|
+
**Returns:** `Promise<void>`
|
|
129
114
|
|
|
130
|
-
|
|
131
|
-
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
### removeLabel
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
removeLabel(client: Client, labelId: number, cascade?: boolean): Promise<void>
|
|
132
121
|
```
|
|
133
122
|
|
|
134
|
-
|
|
123
|
+
Deletes a label by ID. `labelId` must be a positive integer. `cascade` defaults to `false`; when `true`, also removes the label from all associated resources.
|
|
124
|
+
|
|
125
|
+
**Params:** `client` — Authenticated AIMA client; `labelId` — positive integer; `cascade` — optional, default `false`
|
|
126
|
+
**Returns:** `Promise<void>`
|
|
127
|
+
|
|
128
|
+
---
|
|
135
129
|
|
|
136
|
-
|
|
130
|
+
### getPaymentParameters
|
|
137
131
|
|
|
138
|
-
```
|
|
139
|
-
|
|
132
|
+
```ts
|
|
133
|
+
getPaymentParameters(
|
|
134
|
+
client: Client,
|
|
135
|
+
serviceId?: string,
|
|
136
|
+
modelId?: string,
|
|
137
|
+
strict?: string
|
|
138
|
+
): Promise<PaymentParameters[] | null>
|
|
140
139
|
```
|
|
141
140
|
|
|
141
|
+
Returns payment parameters, optionally filtered by service and model.
|
|
142
|
+
|
|
143
|
+
**Params:** `client` — Authenticated AIMA client; `serviceId` — optional; `modelId` — optional; `strict` — optional
|
|
144
|
+
**Returns:** `Promise<PaymentParameters[] | null>`
|
|
145
|
+
|
|
142
146
|
## Types
|
|
143
147
|
|
|
144
148
|
### City
|
|
145
149
|
|
|
146
|
-
```
|
|
150
|
+
```ts
|
|
147
151
|
interface City {
|
|
148
152
|
id: string;
|
|
149
153
|
name: string;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
locale: string;
|
|
155
|
+
imagesUrl: string;
|
|
156
|
+
tokenIconsUrl?: string;
|
|
157
|
+
lat: number;
|
|
158
|
+
lon: number;
|
|
159
|
+
zoomLevel: number;
|
|
160
|
+
radius: number;
|
|
161
|
+
termsOfUseUrl: string;
|
|
162
|
+
termsOfUseUpdateDatetime: string;
|
|
163
|
+
faqUrl: string;
|
|
164
|
+
contactPhoneNumber: string;
|
|
165
|
+
agreementsDate: string;
|
|
166
|
+
timeZone: string;
|
|
167
|
+
distanceUnit: string;
|
|
168
|
+
contactUrl: string;
|
|
169
|
+
services: string[];
|
|
170
|
+
zoneId: string;
|
|
158
171
|
}
|
|
159
172
|
```
|
|
160
173
|
|
|
161
174
|
### Service
|
|
162
175
|
|
|
163
|
-
```
|
|
176
|
+
```ts
|
|
164
177
|
interface Service {
|
|
165
178
|
id: string;
|
|
166
179
|
name: string;
|
|
167
|
-
|
|
168
|
-
type:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
180
|
+
status: 'ACTIVE' | 'DISABLED';
|
|
181
|
+
type:
|
|
182
|
+
| 'FREE_FLOATING'
|
|
183
|
+
| 'FREE_FLOATING_STRICT'
|
|
184
|
+
| 'SERVICE_TRIP'
|
|
185
|
+
| 'BOOKING'
|
|
186
|
+
| 'ROUND_TRIP_BOOKING'
|
|
187
|
+
| 'BY_PASS_FREE_FLOATING'
|
|
188
|
+
| 'BY_PASS_ROUND_TRIP_BOOKING'
|
|
189
|
+
| 'SUBSCRIPTION'
|
|
190
|
+
| 'SCHEDULED_BOOKING_STATION';
|
|
191
|
+
cityId: string;
|
|
192
|
+
zones: string[];
|
|
193
|
+
vehicles: string[];
|
|
194
|
+
stations: string[];
|
|
195
|
+
pois: string[];
|
|
172
196
|
}
|
|
173
197
|
```
|
|
174
198
|
|
|
175
|
-
###
|
|
199
|
+
### FleetConf
|
|
176
200
|
|
|
177
|
-
```
|
|
178
|
-
interface
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
settings: {
|
|
182
|
-
timezone: string;
|
|
183
|
-
currency: string;
|
|
184
|
-
language: string;
|
|
185
|
-
features: string[];
|
|
186
|
-
limits: {
|
|
187
|
-
maxVehicles: number;
|
|
188
|
-
maxUsers: number;
|
|
189
|
-
maxStations: number;
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
createdAt: string;
|
|
193
|
-
updatedAt: string;
|
|
201
|
+
```ts
|
|
202
|
+
interface FleetConf {
|
|
203
|
+
triggerSubscriptionPaymentInHours: number;
|
|
204
|
+
timeZone: string;
|
|
194
205
|
}
|
|
195
206
|
```
|
|
196
207
|
|
|
197
208
|
### Label
|
|
198
209
|
|
|
199
|
-
```
|
|
210
|
+
```ts
|
|
200
211
|
interface Label {
|
|
201
|
-
id:
|
|
212
|
+
id: number;
|
|
202
213
|
name: string;
|
|
203
|
-
|
|
204
|
-
description: string;
|
|
205
|
-
createdAt: string;
|
|
206
|
-
updatedAt: string;
|
|
207
|
-
}
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
## Error Handling
|
|
211
|
-
|
|
212
|
-
All functions include validation and will throw appropriate errors if:
|
|
213
|
-
- Required parameters are missing
|
|
214
|
-
- Invalid label IDs are provided
|
|
215
|
-
- Network errors occur
|
|
216
|
-
|
|
217
|
-
## Examples
|
|
218
|
-
|
|
219
|
-
### Complete Configuration Management
|
|
220
|
-
|
|
221
|
-
```javascript
|
|
222
|
-
import { getClient } from '@vulog/aima-client';
|
|
223
|
-
import {
|
|
224
|
-
getCities,
|
|
225
|
-
getServices,
|
|
226
|
-
getFleetConf,
|
|
227
|
-
getPaymentParameters,
|
|
228
|
-
createLabel,
|
|
229
|
-
getLabels
|
|
230
|
-
} from '@vulog/aima-config';
|
|
231
|
-
|
|
232
|
-
const client = getClient({
|
|
233
|
-
apiKey: 'your-api-key',
|
|
234
|
-
baseUrl: 'https://your-api-base-url',
|
|
235
|
-
clientId: 'your-client-id',
|
|
236
|
-
clientSecret: 'your-client-secret',
|
|
237
|
-
fleetId: 'your-fleet-id',
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
async function configurationWorkflow() {
|
|
241
|
-
try {
|
|
242
|
-
// Get fleet configuration
|
|
243
|
-
const fleetConfig = await getFleetConf(client);
|
|
244
|
-
console.log('Fleet configuration:', fleetConfig);
|
|
245
|
-
|
|
246
|
-
// Get available cities
|
|
247
|
-
const cities = await getCities(client);
|
|
248
|
-
console.log(`Found ${cities.length} cities`);
|
|
249
|
-
|
|
250
|
-
// Get available services
|
|
251
|
-
const services = await getServices(client);
|
|
252
|
-
console.log(`Found ${services.length} services`);
|
|
253
|
-
|
|
254
|
-
// Get payment parameters
|
|
255
|
-
const paymentParams = await getPaymentParameters(client);
|
|
256
|
-
console.log('Payment parameters:', paymentParams);
|
|
257
|
-
|
|
258
|
-
// Create a new label
|
|
259
|
-
const label = await createLabel(client, {
|
|
260
|
-
name: 'VIP Customer',
|
|
261
|
-
color: '#FFD700',
|
|
262
|
-
description: 'Very Important Customer'
|
|
263
|
-
});
|
|
264
|
-
console.log('Created label:', label);
|
|
265
|
-
|
|
266
|
-
// Get all labels
|
|
267
|
-
const labels = await getLabels(client);
|
|
268
|
-
console.log(`Found ${labels.length} labels`);
|
|
269
|
-
|
|
270
|
-
return { fleetConfig, cities, services, paymentParams, labels };
|
|
271
|
-
} catch (error) {
|
|
272
|
-
console.error('Configuration workflow error:', error);
|
|
273
|
-
throw error;
|
|
274
|
-
}
|
|
214
|
+
createDate: string;
|
|
275
215
|
}
|
|
276
216
|
```
|
|
277
217
|
|
|
278
|
-
###
|
|
279
|
-
|
|
280
|
-
```javascript
|
|
281
|
-
async function analyzeServices(client) {
|
|
282
|
-
try {
|
|
283
|
-
const services = await getServices(client);
|
|
284
|
-
|
|
285
|
-
const analysis = {
|
|
286
|
-
totalServices: services.length,
|
|
287
|
-
activeServices: services.filter(s => s.isActive).length,
|
|
288
|
-
servicesByType: services.reduce((acc, service) => {
|
|
289
|
-
acc[service.type] = (acc[service.type] || 0) + 1;
|
|
290
|
-
return acc;
|
|
291
|
-
}, {}),
|
|
292
|
-
servicesWithFeatures: services.filter(s => s.features && s.features.length > 0).length,
|
|
293
|
-
averageFeaturesPerService: services.reduce((sum, s) => sum + (s.features?.length || 0), 0) / services.length
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
console.log('Service Analysis:');
|
|
297
|
-
console.log(`Total Services: ${analysis.totalServices}`);
|
|
298
|
-
console.log(`Active Services: ${analysis.activeServices}`);
|
|
299
|
-
console.log('Services by Type:', analysis.servicesByType);
|
|
300
|
-
console.log(`Services with Features: ${analysis.servicesWithFeatures}`);
|
|
301
|
-
console.log(`Average Features per Service: ${analysis.averageFeaturesPerService.toFixed(2)}`);
|
|
302
|
-
|
|
303
|
-
return analysis;
|
|
304
|
-
} catch (error) {
|
|
305
|
-
console.error('Service analysis error:', error);
|
|
306
|
-
throw error;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
```
|
|
218
|
+
### PaymentParameters
|
|
310
219
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
acc[city.country].push(city);
|
|
324
|
-
return acc;
|
|
325
|
-
}, {});
|
|
326
|
-
|
|
327
|
-
// Find cities in specific timezone
|
|
328
|
-
const timezoneGroups = cities.reduce((acc, city) => {
|
|
329
|
-
if (!acc[city.timezone]) {
|
|
330
|
-
acc[city.timezone] = [];
|
|
331
|
-
}
|
|
332
|
-
acc[city.timezone].push(city);
|
|
333
|
-
return acc;
|
|
334
|
-
}, {});
|
|
335
|
-
|
|
336
|
-
console.log('City Management:');
|
|
337
|
-
console.log(`Total Cities: ${cities.length}`);
|
|
338
|
-
console.log(`Active Cities: ${cities.filter(c => c.isActive).length}`);
|
|
339
|
-
console.log('Cities by Country:', Object.keys(citiesByCountry).map(country =>
|
|
340
|
-
`${country}: ${citiesByCountry[country].length}`
|
|
341
|
-
));
|
|
342
|
-
console.log('Cities by Timezone:', Object.keys(timezoneGroups).map(tz =>
|
|
343
|
-
`${tz}: ${timezoneGroups[tz].length}`
|
|
344
|
-
));
|
|
345
|
-
|
|
346
|
-
return { cities, citiesByCountry, timezoneGroups };
|
|
347
|
-
} catch (error) {
|
|
348
|
-
console.error('City management error:', error);
|
|
349
|
-
throw error;
|
|
350
|
-
}
|
|
220
|
+
```ts
|
|
221
|
+
interface PaymentParameters {
|
|
222
|
+
id: string;
|
|
223
|
+
referenceId: string;
|
|
224
|
+
scope: 'RENTAL';
|
|
225
|
+
flow: 'MANDATORY';
|
|
226
|
+
amountType: 'FIXED' | 'PERCENTAGE';
|
|
227
|
+
amountValue: null | number;
|
|
228
|
+
fleetId: string;
|
|
229
|
+
providePreferredPaymentMethodPspReferences: boolean;
|
|
230
|
+
serviceId?: string;
|
|
231
|
+
modelIds?: string[];
|
|
351
232
|
}
|
|
352
233
|
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.46",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.cts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"author": "Vulog",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@vulog/aima-client": "1.2.
|
|
36
|
-
"@vulog/aima-core": "1.2.
|
|
35
|
+
"@vulog/aima-client": "1.2.46",
|
|
36
|
+
"@vulog/aima-core": "1.2.46"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"zod": "^4.3.6"
|