@vulog/aima-config 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.
Files changed (2) hide show
  1. package/README.md +145 -264
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,352 +1,233 @@
1
1
  # @vulog/aima-config
2
2
 
3
- Configuration management module for the AIMA platform. This module provides functionality to retrieve fleet configuration, cities, services, payment parameters, and manage labels.
3
+ Fleet configuration cities, services, labels, and payment parameters.
4
4
 
5
5
  ## Installation
6
6
 
7
- ```bash
8
- npm install @vulog/aima-client @vulog/aima-core @vulog/aima-config
7
+ ```sh
8
+ npm install @vulog/aima-config @vulog/aima-client @vulog/aima-core
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
- ### Initialize Client
14
-
15
- ```javascript
13
+ ```ts
16
14
  import { getClient } from '@vulog/aima-client';
17
- import {
18
- getCities,
19
- getServices,
20
- getFleetConf,
21
- getPaymentParameters,
22
- createLabel,
23
- updateLabel,
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
- ### Configuration Data
26
+ ### getCities
40
27
 
41
- #### getCities
28
+ ```ts
29
+ getCities(client: Client): Promise<City[]>
30
+ ```
42
31
 
43
- Retrieve all cities available in the fleet.
32
+ Returns cities matching the client's `fleetId`.
44
33
 
45
- ```javascript
46
- const cities = await getCities(client);
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
- **Parameters:**
50
- - `client`: AIMA client instance
45
+ Returns all cities across all franchises, each annotated with its `fleetId`.
51
46
 
52
- **Returns:** Array of city objects
47
+ **Params:** `client` Authenticated AIMA client
48
+ **Returns:** `Promise<(City & { fleetId: string })[]>`
53
49
 
54
- #### getServices
50
+ ---
55
51
 
56
- Get all services available in the fleet.
52
+ ### getServices
57
53
 
58
- ```javascript
59
- const services = await getServices(client);
54
+ ```ts
55
+ getServices(client: Client): Promise<Service[]>
60
56
  ```
61
57
 
62
- **Parameters:**
63
- - `client`: AIMA client instance
58
+ Returns services matching the client's `fleetId`.
64
59
 
65
- **Returns:** Array of service objects
60
+ **Params:** `client` Authenticated AIMA client
61
+ **Returns:** `Promise<Service[]>`
66
62
 
67
- #### getFleetConf
63
+ ---
68
64
 
69
- Retrieve fleet configuration settings.
65
+ ### getServicesAllFranchises
70
66
 
71
- ```javascript
72
- const fleetConfig = await getFleetConf(client);
67
+ ```ts
68
+ getServicesAllFranchises(client: Client): Promise<(Service & { fleetId: string })[]>
73
69
  ```
74
70
 
75
- **Parameters:**
76
- - `client`: AIMA client instance
71
+ Returns all services across all franchises, each annotated with its `fleetId`.
77
72
 
78
- **Returns:** Fleet configuration object
73
+ **Params:** `client` Authenticated AIMA client
74
+ **Returns:** `Promise<(Service & { fleetId: string })[]>`
79
75
 
80
- #### getPaymentParameters
76
+ ---
81
77
 
82
- Get payment configuration parameters.
78
+ ### getFleetConf
83
79
 
84
- ```javascript
85
- const paymentParams = await getPaymentParameters(client);
80
+ ```ts
81
+ getFleetConf(client: Client): Promise<FleetConf>
86
82
  ```
87
83
 
88
- **Parameters:**
89
- - `client`: AIMA client instance
84
+ Returns fleet-level configuration.
90
85
 
91
- **Returns:** Payment parameters object
86
+ **Params:** `client` Authenticated AIMA client
87
+ **Returns:** `Promise<FleetConf>`
92
88
 
93
- ### Label Management
89
+ ---
94
90
 
95
- #### createLabel
91
+ ### getLabels
96
92
 
97
- Create a new label.
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
- **Parameters:**
108
- - `client`: AIMA client instance
109
- - `labelData`: Label creation data
110
- - `name`: Label name
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
- #### updateLabel
102
+ ---
115
103
 
116
- Update an existing label.
104
+ ### addLabel
117
105
 
118
- ```javascript
119
- const updatedLabel = await updateLabel(client, 'label-id-here', {
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
- #### deleteLabel
110
+ Creates a new label. `name` must be non-empty.
127
111
 
128
- Delete a label.
112
+ **Params:** `client` — Authenticated AIMA client; `name` — label name (non-empty)
113
+ **Returns:** `Promise<void>`
129
114
 
130
- ```javascript
131
- const result = await deleteLabel(client, 'label-id-here');
115
+ ---
116
+
117
+ ### removeLabel
118
+
119
+ ```ts
120
+ removeLabel(client: Client, labelId: number, cascade?: boolean): Promise<void>
132
121
  ```
133
122
 
134
- #### getLabels
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
- Retrieve all labels.
130
+ ### getPaymentParameters
137
131
 
138
- ```javascript
139
- const labels = await getLabels(client);
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
- ```typescript
150
+ ```ts
147
151
  interface City {
148
152
  id: string;
149
153
  name: string;
150
- country: string;
151
- countryCode: string;
152
- coordinates: {
153
- latitude: number;
154
- longitude: number;
155
- };
156
- timezone: string;
157
- isActive: boolean;
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
- ```typescript
176
+ ```ts
164
177
  interface Service {
165
178
  id: string;
166
179
  name: string;
167
- description: string;
168
- type: 'CAR_SHARING' | 'BIKE_SHARING' | 'SCOOTER_SHARING' | 'MULTIMODAL';
169
- isActive: boolean;
170
- features: string[];
171
- pricing: any;
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
- ### FleetConfiguration
199
+ ### FleetConf
176
200
 
177
- ```typescript
178
- interface FleetConfiguration {
179
- id: string;
180
- name: string;
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
- ```typescript
210
+ ```ts
200
211
  interface Label {
201
- id: string;
212
+ id: number;
202
213
  name: string;
203
- color: string;
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
- ### Service Analysis
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
- ### City Management
312
-
313
- ```javascript
314
- async function manageCities(client) {
315
- try {
316
- const cities = await getCities(client);
317
-
318
- // Group cities by country
319
- const citiesByCountry = cities.reduce((acc, city) => {
320
- if (!acc[city.country]) {
321
- acc[city.country] = [];
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.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",
@@ -32,8 +32,8 @@
32
32
  "author": "Vulog",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@vulog/aima-client": "1.2.44",
36
- "@vulog/aima-core": "1.2.44"
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"