@vulog/aima-booking 1.2.45 → 1.2.47
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 +103 -386
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,411 +1,128 @@
|
|
|
1
1
|
# @vulog/aima-booking
|
|
2
2
|
|
|
3
|
-
Booking
|
|
3
|
+
Booking requests, stations, subscriptions, and vehicle allocation for the AIMA platform.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
```
|
|
8
|
-
npm install @vulog/aima-
|
|
7
|
+
```sh
|
|
8
|
+
npm install @vulog/aima-booking @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
|
-
getSubscriptionBookingRequests,
|
|
21
|
-
getSATBookingRequests,
|
|
22
|
-
getBookingRequestById,
|
|
23
|
-
getBookingRequestByTrip,
|
|
24
|
-
getSubscriptionBookingRequestById,
|
|
25
|
-
getStations,
|
|
26
|
-
getStationById
|
|
27
|
-
} from '@vulog/aima-booking';
|
|
15
|
+
import { getBookingRequestById, getStations } from '@vulog/aima-booking';
|
|
16
|
+
|
|
17
|
+
const client = getClient({ /* ClientOptions */ });
|
|
28
18
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
baseUrl: 'https://your-api-base-url',
|
|
32
|
-
clientId: 'your-client-id',
|
|
33
|
-
clientSecret: 'your-client-secret',
|
|
34
|
-
fleetId: 'your-fleet-id',
|
|
35
|
-
});
|
|
19
|
+
const booking = await getBookingRequestById(client, 'booking-uuid');
|
|
20
|
+
const stations = await getStations(client, ['INFO', 'SERVICES']);
|
|
36
21
|
```
|
|
37
22
|
|
|
38
23
|
## API Reference
|
|
39
24
|
|
|
40
25
|
### Booking Requests
|
|
41
26
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Retrieve booking requests
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
```javascript
|
|
91
|
-
const satRequests = await getSATBookingRequests(client, 'PENDING');
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Individual Booking Requests
|
|
95
|
-
|
|
96
|
-
#### getBookingRequestById
|
|
97
|
-
|
|
98
|
-
Retrieve a specific booking request by ID.
|
|
99
|
-
|
|
100
|
-
```javascript
|
|
101
|
-
const bookingRequest = await getBookingRequestById(client, 'bb493049-5b4f-43ea-8a65-964a13aec549');
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
#### getBookingRequestByTrip
|
|
105
|
-
|
|
106
|
-
Get booking request associated with a trip.
|
|
107
|
-
|
|
108
|
-
```javascript
|
|
109
|
-
const bookingRequest = await getBookingRequestByTrip(client, '33E8E42710144E15A5CC447E4D3524F4');
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
#### getSubscriptionBookingRequestById
|
|
113
|
-
|
|
114
|
-
Get subscription booking request by ID.
|
|
115
|
-
|
|
116
|
-
```javascript
|
|
117
|
-
const subscriptionRequest = await getSubscriptionBookingRequestById(client, 'b7faa2a2-e8fc-4a29-8de7-09ce783b9797');
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### Stations
|
|
121
|
-
|
|
122
|
-
#### getStations
|
|
123
|
-
|
|
124
|
-
Retrieve stations with optional includes.
|
|
125
|
-
|
|
126
|
-
```javascript
|
|
127
|
-
const stations = await getStations(client, ['OPEN_HOUR', 'INFO']);
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**Parameters:**
|
|
131
|
-
- `client`: AIMA client instance
|
|
132
|
-
- `includes`: Array of data to include ('OPEN_HOUR', 'INFO', 'VEHICLES', 'ZONES')
|
|
133
|
-
|
|
134
|
-
#### getStationById
|
|
135
|
-
|
|
136
|
-
Get a specific station by ID.
|
|
137
|
-
|
|
138
|
-
```javascript
|
|
139
|
-
const station = await getStationById(client, 'station-id-here', ['OPEN_HOUR', 'INFO']);
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Vehicle Allocation
|
|
143
|
-
|
|
144
|
-
#### allocateVehicle
|
|
145
|
-
|
|
146
|
-
Allocate a vehicle to a booking request.
|
|
147
|
-
|
|
148
|
-
```javascript
|
|
149
|
-
import { allocateVehicle } from '@vulog/aima-booking';
|
|
150
|
-
|
|
151
|
-
const result = await allocateVehicle(client, 'booking-request-uuid', 'vehicle-uuid', 'service-uuid');
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
#### deallocateVehicle
|
|
155
|
-
|
|
156
|
-
Deallocate a vehicle from a booking request.
|
|
157
|
-
|
|
158
|
-
```javascript
|
|
159
|
-
import { deallocateVehicle } from '@vulog/aima-booking';
|
|
160
|
-
|
|
161
|
-
await deallocateVehicle(client, 'booking-request-uuid');
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Booking Actions
|
|
165
|
-
|
|
166
|
-
#### updateScheduleBooking
|
|
167
|
-
|
|
168
|
-
Update a scheduled booking.
|
|
169
|
-
|
|
170
|
-
```javascript
|
|
171
|
-
import { updateScheduleBooking } from '@vulog/aima-booking';
|
|
172
|
-
|
|
173
|
-
await updateScheduleBooking(client, 'booking-request-uuid', { endDate: '2024-02-15T00:00:00Z' });
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
#### cancelBookingRequest
|
|
177
|
-
|
|
178
|
-
Cancel a booking request.
|
|
179
|
-
|
|
180
|
-
```javascript
|
|
181
|
-
import { cancelBookingRequest } from '@vulog/aima-booking';
|
|
182
|
-
|
|
183
|
-
await cancelBookingRequest(client, 'booking-request-uuid');
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
#### triggerBRPayment / releaseBRPayment
|
|
187
|
-
|
|
188
|
-
Trigger or release payment for a booking request.
|
|
189
|
-
|
|
190
|
-
```javascript
|
|
191
|
-
import { triggerBRPayment, releaseBRPayment } from '@vulog/aima-booking';
|
|
192
|
-
|
|
193
|
-
await triggerBRPayment(client, 'booking-request-uuid');
|
|
194
|
-
await releaseBRPayment(client, 'booking-request-uuid');
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
#### getBookingRequestsByUserId
|
|
198
|
-
|
|
199
|
-
Get booking requests for a specific user.
|
|
200
|
-
|
|
201
|
-
```javascript
|
|
202
|
-
import { getBookingRequestsByUserId } from '@vulog/aima-booking';
|
|
203
|
-
|
|
204
|
-
const requests = await getBookingRequestsByUserId(client, 'user-uuid');
|
|
205
|
-
```
|
|
27
|
+
| Function | Signature | Description |
|
|
28
|
+
|----------|-----------|-------------|
|
|
29
|
+
| `getBookingRequests` | `(client, status: BookingRequestStatus, options?: PaginableOptions<BookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>` | Retrieve a paginated list of booking requests by status |
|
|
30
|
+
| `getScheduleBookingRequests` | `(client, status: BookingRequestStatus, options?: PaginableOptions<SpecificBookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>` | Booking requests filtered to service types `ROUND_TRIP_BOOKING` and `SCHEDULED_BOOKING_STATION` (auto-added) |
|
|
31
|
+
| `getSubscriptionBookingRequests` | `(client, status: BookingRequestStatus, options?: PaginableOptions<SpecificBookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>` | Booking requests filtered to service type `SUBSCRIPTION` (auto-added) |
|
|
32
|
+
| `getSATBookingRequests` | `(client, status: SATBookingRequestStatus, options?: PaginableOptions<void, keyof SATBookingRequest>) => Promise<PaginableResponse<SATBookingRequest>>` | Retrieve SAT booking requests by status |
|
|
33
|
+
| `getBookingRequestById` | `(client, id: string) => Promise<BookingRequest>` | Retrieve a single booking request by UUID |
|
|
34
|
+
| `getBookingRequestByTrip` | `(client, tripId: string) => Promise<BookingRequest>` | Retrieve a booking request by associated trip ID |
|
|
35
|
+
| `getSubscriptionBookingRequestById` | `(client, id: string) => Promise<BookingRequest>` | Retrieve a subscription booking request by ID — normalises `stationId` to `station` |
|
|
36
|
+
| `getScheduledBookingById` | `(client, bookingId: string) => Promise<SATBookingRequest>` | Retrieve a scheduled booking by UUID |
|
|
37
|
+
| `getBookingRequestsByUserId` | `(client, userId: string) => Promise<BookingRequest[]>` | Retrieve all booking requests for a user — returns `[]` on 404 |
|
|
38
|
+
|
|
39
|
+
### Actions
|
|
40
|
+
|
|
41
|
+
| Function | Signature | Description |
|
|
42
|
+
|----------|-----------|-------------|
|
|
43
|
+
| `cancelBookingRequest` | `(client, id: string) => Promise<SATBookingRequest>` | Cancel a booking request |
|
|
44
|
+
| `triggerBRPayment` | `(client, bookingRequestId: string, body: TriggerBRPaymentBody) => Promise<TriggerBRPaymentResponse>` | Trigger a payment on a booking request |
|
|
45
|
+
| `releaseBRPayment` | `(client, bookingRequestId: string, pspReference: string) => Promise<SATBookingRequest>` | Release a held payment on a booking request |
|
|
46
|
+
| `updateScheduleBooking` | `(client, bookingRequestId: string, updateData: Record<string, unknown>) => Promise<SATBookingRequest>` | Update fields on a scheduled booking |
|
|
47
|
+
| `submitCancellationRequest` | `(client, bookingRequestId: string, userId: string) => Promise<SATBookingRequest>` | Submit a cancellation request for a booking |
|
|
48
|
+
| `createBookingRequest` | `(client, body: CreateBookingRequestBody, options?: CreateBookingRequestOptions) => Promise<BookingRequest>` | Create a new booking request |
|
|
49
|
+
|
|
50
|
+
#### triggerBRPayment — body fields
|
|
51
|
+
|
|
52
|
+
| Field | Type | Required |
|
|
53
|
+
|-------|------|----------|
|
|
54
|
+
| `scope` | `'RENTAL' \| 'DEPOSIT'` | Yes |
|
|
55
|
+
| `online` | `boolean` | Yes |
|
|
56
|
+
| `amountType` | `'FIXED' \| 'PERCENTAGE'` | Yes |
|
|
57
|
+
| `amountValue` | `number` | Yes |
|
|
58
|
+
| `profileId` | `string` | Yes |
|
|
59
|
+
| `requiresActionReturnURL` | `string` | No |
|
|
60
|
+
| `preferredPaymentMethods` | `{ pspReference: string; amount: number }[]` | No |
|
|
61
|
+
|
|
62
|
+
#### createBookingRequest — required body fields
|
|
63
|
+
|
|
64
|
+
| Field | Type |
|
|
65
|
+
|-------|------|
|
|
66
|
+
| `startDate` | `string` |
|
|
67
|
+
| `endDate` | `string` |
|
|
68
|
+
| `modelId` | `number` (int) |
|
|
69
|
+
| `profileId` | `string` (UUID) |
|
|
70
|
+
| `serviceId` | `string` (UUID) |
|
|
71
|
+
|
|
72
|
+
#### updateScheduleBooking — available fields
|
|
73
|
+
|
|
74
|
+
`startDate`, `latitude`, `longitude`, `radius`, `userId`, `status`, `cityId`, `profileId`, `serviceId`, `warning`, `modelId`, `notes`, `bookingReferenceId`, `plannedReturnDate`
|
|
206
75
|
|
|
207
76
|
### Subscriptions
|
|
208
77
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
Create a new subscription booking
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
78
|
+
| Function | Signature | Description |
|
|
79
|
+
|----------|-----------|-------------|
|
|
80
|
+
| `createSubscription` | `(client, body: CreateSubscriptionBody) => Promise<BookingRequest>` | Create a new subscription booking |
|
|
81
|
+
| `getSubscriptionsByUserId` | `(client, userId: string, active?: boolean) => Promise<Master[]>` | Retrieve subscriptions for a user — `active` defaults to `true` |
|
|
82
|
+
| `getSlaves` | `(client, parentId: string, status: 'ONGOING' \| 'COMPLETED' \| 'UPCOMING') => Promise<BookingRequestSlave[]>` | Retrieve slave bookings for a parent subscription |
|
|
83
|
+
| `getAdditionalDrivers` | `(client, parentId: string) => Promise<AdditionalDriver[]>` | Retrieve additional drivers for a subscription |
|
|
84
|
+
| `getDigitalContracts` | `(client, bookingId: string, status?: string) => Promise<Contract[]>` | Retrieve digital contracts for a booking — `status` defaults to `'SIGNED'` |
|
|
85
|
+
|
|
86
|
+
#### createSubscription — required body fields
|
|
87
|
+
|
|
88
|
+
| Field | Type |
|
|
89
|
+
|-------|------|
|
|
90
|
+
| `userId` | `string` |
|
|
91
|
+
| `profileId` | `string` |
|
|
92
|
+
| `startDate` | `string` |
|
|
93
|
+
| `endDate` | `string` |
|
|
94
|
+
| `vehicleId` | `string` |
|
|
95
|
+
| `modelId` | `number` (int) |
|
|
96
|
+
| `station` | `string` |
|
|
97
|
+
| `serviceId` | `string` |
|
|
215
98
|
|
|
216
|
-
|
|
217
|
-
userId: 'user-uuid',
|
|
218
|
-
profileId: 'profile-uuid',
|
|
219
|
-
startDate: '2024-01-15T00:00:00Z',
|
|
220
|
-
endDate: '2024-07-15T00:00:00Z',
|
|
221
|
-
vehicleId: 'vehicle-uuid',
|
|
222
|
-
modelId: 372,
|
|
223
|
-
station: 'station-uuid',
|
|
224
|
-
serviceId: 'service-uuid',
|
|
225
|
-
// optional fields
|
|
226
|
-
pricingId: 'pricing-uuid',
|
|
227
|
-
notes: 'VIP client',
|
|
228
|
-
isRollingContract: false,
|
|
229
|
-
additionalDriverInvitations: ['driver@example.com'],
|
|
230
|
-
});
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
### Available Vehicles
|
|
234
|
-
|
|
235
|
-
#### getAvailableVehicles
|
|
236
|
-
|
|
237
|
-
Get available vehicles for booking.
|
|
238
|
-
|
|
239
|
-
```javascript
|
|
240
|
-
import { getAvailableVehicles } from '@vulog/aima-booking';
|
|
99
|
+
### Stations
|
|
241
100
|
|
|
242
|
-
|
|
243
|
-
|
|
101
|
+
| Function | Signature | Description |
|
|
102
|
+
|----------|-----------|-------------|
|
|
103
|
+
| `getStations` | `(client, includes?: Include[]) => Promise<Station[]>` | Retrieve all stations, optionally including extra data |
|
|
104
|
+
| `getStationById` | `(client, id: string, includes?: IncludeStation[]) => Promise<Station \| null>` | Retrieve a station by ID — returns `null` on 400 |
|
|
105
|
+
| `getAvailableVehicles` | `(client, stationId: string, startDate: string) => Promise<AvailableVehiclesResponse>` | Retrieve available vehicles at a station — `startDate` must be ISO without milliseconds |
|
|
106
|
+
| `getAvailableModels` | `(client, params: GetAvailableModelsParams) => Promise<StationWithAvailableModels[]>` | Retrieve available models across stations |
|
|
107
|
+
| `getStationUnavailability` | `(client, params: { stationId: string; from: string; to: string; serviceId: string }) => Promise<StationVehicleCalendar>` | Retrieve vehicle unavailability calendar for a station |
|
|
108
|
+
|
|
109
|
+
#### getAvailableModels — params
|
|
110
|
+
|
|
111
|
+
| Field | Type | Required |
|
|
112
|
+
|-------|------|----------|
|
|
113
|
+
| `startDate` | `string` | Yes |
|
|
114
|
+
| `endDate` | `string` | Yes |
|
|
115
|
+
| `cityId` | `string` | No |
|
|
116
|
+
| `userId` | `string` | No |
|
|
117
|
+
| `profileId` | `string` | No |
|
|
118
|
+
| `oneWayTrip` | `boolean` | No |
|
|
119
|
+
| `showUnavailableModels` | `boolean` | No |
|
|
244
120
|
|
|
245
121
|
## Types
|
|
246
122
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
vehicleId: string;
|
|
254
|
-
stationId: string;
|
|
255
|
-
status: 'PENDING' | 'ONGOING' | 'COMPLETED' | 'CANCELLED' | 'EXPIRED';
|
|
256
|
-
startTime: string;
|
|
257
|
-
endTime: string;
|
|
258
|
-
createdAt: string;
|
|
259
|
-
updatedAt: string;
|
|
260
|
-
}
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
### Station
|
|
264
|
-
|
|
265
|
-
```typescript
|
|
266
|
-
interface Station {
|
|
267
|
-
id: string;
|
|
268
|
-
name: string;
|
|
269
|
-
address: string;
|
|
270
|
-
coordinates: {
|
|
271
|
-
latitude: number;
|
|
272
|
-
longitude: number;
|
|
273
|
-
};
|
|
274
|
-
isActive: boolean;
|
|
275
|
-
openHours: OpenHours[];
|
|
276
|
-
info: StationInfo;
|
|
277
|
-
vehicles: Vehicle[];
|
|
278
|
-
zones: Zone[];
|
|
279
|
-
}
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### BookingRequestStatus
|
|
283
|
-
|
|
284
|
-
```typescript
|
|
285
|
-
type BookingRequestStatus = 'PENDING' | 'ONGOING' | 'COMPLETED' | 'CANCELLED' | 'EXPIRED';
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
### ServiceType
|
|
289
|
-
|
|
290
|
-
```typescript
|
|
291
|
-
type ServiceType = 'CAR_SHARING' | 'BIKE_SHARING' | 'SCOOTER_SHARING' | 'MULTIMODAL';
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
## Error Handling
|
|
295
|
-
|
|
296
|
-
All functions include validation and will throw appropriate errors if:
|
|
297
|
-
- Required parameters are missing
|
|
298
|
-
- Invalid booking request or station IDs are provided
|
|
299
|
-
- Invalid status values are used
|
|
300
|
-
- Network errors occur
|
|
301
|
-
|
|
302
|
-
## Examples
|
|
303
|
-
|
|
304
|
-
### Complete Booking Management Workflow
|
|
305
|
-
|
|
306
|
-
```javascript
|
|
307
|
-
import { getClient } from '@vulog/aima-client';
|
|
308
|
-
import {
|
|
309
|
-
getBookingRequests,
|
|
310
|
-
getStations,
|
|
311
|
-
getBookingRequestById
|
|
312
|
-
} from '@vulog/aima-booking';
|
|
313
|
-
|
|
314
|
-
const client = getClient({
|
|
315
|
-
apiKey: 'your-api-key',
|
|
316
|
-
baseUrl: 'https://your-api-base-url',
|
|
317
|
-
clientId: 'your-client-id',
|
|
318
|
-
clientSecret: 'your-client-secret',
|
|
319
|
-
fleetId: 'your-fleet-id',
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
async function bookingWorkflow() {
|
|
323
|
-
try {
|
|
324
|
-
// Get all ongoing booking requests
|
|
325
|
-
const ongoingRequests = await getBookingRequests(client, 'ONGOING');
|
|
326
|
-
console.log(`Found ${ongoingRequests.length} ongoing booking requests`);
|
|
327
|
-
|
|
328
|
-
// Get stations with full information
|
|
329
|
-
const stations = await getStations(client, ['OPEN_HOUR', 'INFO', 'VEHICLES']);
|
|
330
|
-
console.log(`Found ${stations.length} stations`);
|
|
331
|
-
|
|
332
|
-
// Get specific booking request
|
|
333
|
-
const bookingRequest = await getBookingRequestById(client, 'bb493049-5b4f-43ea-8a65-964a13aec549');
|
|
334
|
-
console.log('Booking request details:', bookingRequest);
|
|
335
|
-
|
|
336
|
-
return { ongoingRequests, stations, bookingRequest };
|
|
337
|
-
} catch (error) {
|
|
338
|
-
console.error('Booking workflow error:', error);
|
|
339
|
-
throw error;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
### Station Analysis
|
|
345
|
-
|
|
346
|
-
```javascript
|
|
347
|
-
async function analyzeStations(client) {
|
|
348
|
-
try {
|
|
349
|
-
const stations = await getStations(client, ['OPEN_HOUR', 'INFO', 'VEHICLES']);
|
|
350
|
-
|
|
351
|
-
const analysis = {
|
|
352
|
-
totalStations: stations.length,
|
|
353
|
-
activeStations: stations.filter(s => s.isActive).length,
|
|
354
|
-
stationsWithVehicles: stations.filter(s => s.vehicles && s.vehicles.length > 0).length,
|
|
355
|
-
averageVehiclesPerStation: stations.reduce((sum, s) => sum + (s.vehicles?.length || 0), 0) / stations.length,
|
|
356
|
-
stationsByZone: stations.reduce((acc, station) => {
|
|
357
|
-
station.zones?.forEach(zone => {
|
|
358
|
-
acc[zone.name] = (acc[zone.name] || 0) + 1;
|
|
359
|
-
});
|
|
360
|
-
return acc;
|
|
361
|
-
}, {})
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
console.log('Station Analysis:');
|
|
365
|
-
console.log(`Total Stations: ${analysis.totalStations}`);
|
|
366
|
-
console.log(`Active Stations: ${analysis.activeStations}`);
|
|
367
|
-
console.log(`Stations with Vehicles: ${analysis.stationsWithVehicles}`);
|
|
368
|
-
console.log(`Average Vehicles per Station: ${analysis.averageVehiclesPerStation.toFixed(2)}`);
|
|
369
|
-
console.log('Stations by Zone:', analysis.stationsByZone);
|
|
370
|
-
|
|
371
|
-
return analysis;
|
|
372
|
-
} catch (error) {
|
|
373
|
-
console.error('Station analysis error:', error);
|
|
374
|
-
throw error;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
### Booking Request Monitoring
|
|
380
|
-
|
|
381
|
-
```javascript
|
|
382
|
-
async function monitorBookingRequests(client) {
|
|
383
|
-
try {
|
|
384
|
-
const [ongoing, completed, cancelled] = await Promise.all([
|
|
385
|
-
getBookingRequests(client, 'ONGOING'),
|
|
386
|
-
getBookingRequests(client, 'COMPLETED'),
|
|
387
|
-
getBookingRequests(client, 'CANCELLED')
|
|
388
|
-
]);
|
|
389
|
-
|
|
390
|
-
const monitoring = {
|
|
391
|
-
ongoing: ongoing.length,
|
|
392
|
-
completed: completed.length,
|
|
393
|
-
cancelled: cancelled.length,
|
|
394
|
-
total: ongoing.length + completed.length + cancelled.length,
|
|
395
|
-
completionRate: completed.length / (completed.length + cancelled.length) * 100
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
console.log('Booking Request Monitoring:');
|
|
399
|
-
console.log(`Ongoing: ${monitoring.ongoing}`);
|
|
400
|
-
console.log(`Completed: ${monitoring.completed}`);
|
|
401
|
-
console.log(`Cancelled: ${monitoring.cancelled}`);
|
|
402
|
-
console.log(`Total: ${monitoring.total}`);
|
|
403
|
-
console.log(`Completion Rate: ${monitoring.completionRate.toFixed(2)}%`);
|
|
404
|
-
|
|
405
|
-
return monitoring;
|
|
406
|
-
} catch (error) {
|
|
407
|
-
console.error('Booking monitoring error:', error);
|
|
408
|
-
throw error;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
```
|
|
123
|
+
| Type | Values / Shape |
|
|
124
|
+
|------|---------------|
|
|
125
|
+
| `BookingRequestStatus` | `'ALERT' \| 'UPCOMING' \| 'ONGOING' \| 'COMPLETED' \| 'CANCELLED' \| 'PENDING_APPROVAL' \| 'CONFIRMED' \| 'PENDING' \| 'LATE'` |
|
|
126
|
+
| `SATBookingRequestStatus` | `'ALERT' \| 'CANCELLED' \| 'COMPLETED' \| 'CONFIRMED' \| 'LATE_RETURN' \| 'ONGOING' \| 'PENDING_PAYMENT' \| 'PENDING' \| 'UPCOMING_ALLOCATED' \| 'UPCOMING_NOT_ALLOCATED'` |
|
|
127
|
+
| `Include` | `'INFO' \| 'OPEN_HOUR' \| 'SERVICES'` |
|
|
128
|
+
| `IncludeStation` | `'INFO' \| 'SERVICES'` |
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-booking",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.47",
|
|
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.47",
|
|
36
|
+
"@vulog/aima-core": "1.2.47"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"es-toolkit": "^1.45.1",
|