@vulog/aima-config 1.1.89 → 1.1.91

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 +337 -7
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,22 +1,352 @@
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.
4
+
5
+ ## Installation
6
+
3
7
  ```bash
4
- npm i @vulog/aima-client @vulog/aima-core @vulog/aima-config
8
+ npm install @vulog/aima-client @vulog/aima-core @vulog/aima-config
5
9
  ```
6
10
 
11
+ ## Usage
12
+
13
+ ### Initialize Client
14
+
7
15
  ```javascript
8
16
  import { getClient } from '@vulog/aima-client';
9
- import { getCities, getServices } from '@vulog/aima-config';
17
+ import {
18
+ getCities,
19
+ getServices,
20
+ getFleetConf,
21
+ getPaymentParameters,
22
+ createLabel,
23
+ updateLabel,
24
+ deleteLabel,
25
+ getLabels
26
+ } from '@vulog/aima-config';
10
27
 
11
28
  const client = getClient({
12
- apiKey: '...',
13
- baseUrl: '...',
14
- clientId: '...',
15
- clientSecret: '...',
16
- fleetId: '...',
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',
17
34
  });
35
+ ```
36
+
37
+ ## API Reference
18
38
 
39
+ ### Configuration Data
40
+
41
+ #### getCities
42
+
43
+ Retrieve all cities available in the fleet.
44
+
45
+ ```javascript
19
46
  const cities = await getCities(client);
47
+ ```
48
+
49
+ **Parameters:**
50
+ - `client`: AIMA client instance
51
+
52
+ **Returns:** Array of city objects
53
+
54
+ #### getServices
55
+
56
+ Get all services available in the fleet.
57
+
58
+ ```javascript
20
59
  const services = await getServices(client);
60
+ ```
21
61
 
62
+ **Parameters:**
63
+ - `client`: AIMA client instance
64
+
65
+ **Returns:** Array of service objects
66
+
67
+ #### getFleetConf
68
+
69
+ Retrieve fleet configuration settings.
70
+
71
+ ```javascript
72
+ const fleetConfig = await getFleetConf(client);
73
+ ```
74
+
75
+ **Parameters:**
76
+ - `client`: AIMA client instance
77
+
78
+ **Returns:** Fleet configuration object
79
+
80
+ #### getPaymentParameters
81
+
82
+ Get payment configuration parameters.
83
+
84
+ ```javascript
85
+ const paymentParams = await getPaymentParameters(client);
86
+ ```
87
+
88
+ **Parameters:**
89
+ - `client`: AIMA client instance
90
+
91
+ **Returns:** Payment parameters object
92
+
93
+ ### Label Management
94
+
95
+ #### createLabel
96
+
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
+ });
105
+ ```
106
+
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
113
+
114
+ #### updateLabel
115
+
116
+ Update an existing label.
117
+
118
+ ```javascript
119
+ const updatedLabel = await updateLabel(client, 'label-id-here', {
120
+ name: 'Updated Label Name',
121
+ color: '#33FF57',
122
+ description: 'Updated description'
123
+ });
124
+ ```
125
+
126
+ #### deleteLabel
127
+
128
+ Delete a label.
129
+
130
+ ```javascript
131
+ const result = await deleteLabel(client, 'label-id-here');
132
+ ```
133
+
134
+ #### getLabels
135
+
136
+ Retrieve all labels.
137
+
138
+ ```javascript
139
+ const labels = await getLabels(client);
140
+ ```
141
+
142
+ ## Types
143
+
144
+ ### City
145
+
146
+ ```typescript
147
+ interface City {
148
+ id: string;
149
+ name: string;
150
+ country: string;
151
+ countryCode: string;
152
+ coordinates: {
153
+ latitude: number;
154
+ longitude: number;
155
+ };
156
+ timezone: string;
157
+ isActive: boolean;
158
+ }
159
+ ```
160
+
161
+ ### Service
162
+
163
+ ```typescript
164
+ interface Service {
165
+ id: string;
166
+ name: string;
167
+ description: string;
168
+ type: 'CAR_SHARING' | 'BIKE_SHARING' | 'SCOOTER_SHARING' | 'MULTIMODAL';
169
+ isActive: boolean;
170
+ features: string[];
171
+ pricing: any;
172
+ }
173
+ ```
174
+
175
+ ### FleetConfiguration
176
+
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;
194
+ }
195
+ ```
196
+
197
+ ### Label
198
+
199
+ ```typescript
200
+ interface Label {
201
+ id: string;
202
+ 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
+ }
275
+ }
276
+ ```
277
+
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
+ ```
310
+
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
+ }
351
+ }
22
352
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulog/aima-config",
3
- "version": "1.1.89",
3
+ "version": "1.1.91",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "author": "Vulog",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@vulog/aima-client": "1.1.89",
23
- "@vulog/aima-core": "1.1.89"
22
+ "@vulog/aima-client": "1.1.91",
23
+ "@vulog/aima-core": "1.1.91"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "zod": "^3.25.76"