@vulog/aima-booking 1.2.30 → 1.2.32
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/dist/index.cjs +465 -0
- package/dist/index.d.cts +362 -0
- package/dist/index.d.mts +281 -267
- package/dist/index.mjs +398 -567
- package/package.json +20 -7
- package/src/cancelBookingRequest.test.ts +1 -3
- package/src/getBookingRequest.test.ts +27 -35
- package/src/getBookingRequests.test.ts +3 -5
- package/src/getBookingRequestsByUserId.test.ts +2 -6
- package/src/getSATBookingRequests.test.ts +3 -3
- package/src/getStation.test.ts +93 -88
- package/src/releaseBRPayment.test.ts +9 -15
- package/src/triggerBRPayment.test.ts +4 -6
- package/{tsup.config.ts → tsdown.config.ts} +1 -1
- package/dist/index.d.ts +0 -348
- package/dist/index.js +0 -647
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { Client } from "@vulog/aima-client";
|
|
2
|
+
import { PaginableOptions, PaginableResponse } from "@vulog/aima-core";
|
|
3
|
+
import z$1, { z } from "zod";
|
|
4
|
+
import { UUID } from "crypto";
|
|
5
|
+
|
|
6
|
+
//#region src/types.d.ts
|
|
7
|
+
type PaymentReceipts = {
|
|
8
|
+
id: string;
|
|
9
|
+
pspName: string;
|
|
10
|
+
pspReference: string;
|
|
11
|
+
amount: number;
|
|
12
|
+
currency: string;
|
|
13
|
+
date: string;
|
|
14
|
+
status: string;
|
|
15
|
+
paymentMethodType: string;
|
|
16
|
+
paymentIntentPspReference?: string;
|
|
17
|
+
number: number;
|
|
18
|
+
metadatas: {
|
|
19
|
+
scope: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/** Payment intent or receipt item as returned by trigger BR payment (and similar payment endpoints). */
|
|
23
|
+
type BRPaymentItem = {
|
|
24
|
+
id: string;
|
|
25
|
+
pspName: string;
|
|
26
|
+
pspReference: string;
|
|
27
|
+
pspPublishableKey: string;
|
|
28
|
+
amount: number;
|
|
29
|
+
currency: string;
|
|
30
|
+
date: string;
|
|
31
|
+
captureBefore: string;
|
|
32
|
+
status: string;
|
|
33
|
+
paymentMethodType: string;
|
|
34
|
+
paymentMethodPspReference: string;
|
|
35
|
+
paymentIntentPspReference: string;
|
|
36
|
+
number: number;
|
|
37
|
+
code?: string;
|
|
38
|
+
declineCode?: string;
|
|
39
|
+
pspClientSecret?: string;
|
|
40
|
+
reason?: string;
|
|
41
|
+
note?: string;
|
|
42
|
+
nextAction?: {
|
|
43
|
+
nextActionRedirectUrl: {
|
|
44
|
+
url: string;
|
|
45
|
+
method: string;
|
|
46
|
+
data: Record<string, string>;
|
|
47
|
+
};
|
|
48
|
+
type: string;
|
|
49
|
+
};
|
|
50
|
+
metadatas: Record<string, string>;
|
|
51
|
+
};
|
|
52
|
+
/** Credit entry in a booking request (e.g. trigger BR payment response). */
|
|
53
|
+
type BookingCredit = {
|
|
54
|
+
id: string;
|
|
55
|
+
fleetId: string;
|
|
56
|
+
amount: number;
|
|
57
|
+
availableAmount: number;
|
|
58
|
+
status: string;
|
|
59
|
+
walletId: string;
|
|
60
|
+
date: string;
|
|
61
|
+
};
|
|
62
|
+
/** Preferred payment method entry in request/response. */
|
|
63
|
+
type PreferredPaymentMethod = {
|
|
64
|
+
pspReference: string;
|
|
65
|
+
amount: number;
|
|
66
|
+
};
|
|
67
|
+
type CustomPrice = {
|
|
68
|
+
id: string;
|
|
69
|
+
fleetId: string;
|
|
70
|
+
type: 'CUSTOM_FIXED_PRICE' | 'EXTENDED_FIXED_PRICE';
|
|
71
|
+
amount: number;
|
|
72
|
+
reason: string;
|
|
73
|
+
pricingReferenceId: string | null;
|
|
74
|
+
};
|
|
75
|
+
type BaseBookingRequest = {
|
|
76
|
+
bookingReferenceId?: string;
|
|
77
|
+
cityId: string;
|
|
78
|
+
completed: boolean;
|
|
79
|
+
contractType?: string;
|
|
80
|
+
creationDate: string;
|
|
81
|
+
customPrice: CustomPrice | null;
|
|
82
|
+
deliveryAddress?: string;
|
|
83
|
+
deliveryAddressAdditionalInfo?: string;
|
|
84
|
+
deliveryCity?: string;
|
|
85
|
+
deliveryPostalCode?: string;
|
|
86
|
+
dropOffStation?: string;
|
|
87
|
+
fleetId: string;
|
|
88
|
+
id: string;
|
|
89
|
+
notes?: string;
|
|
90
|
+
planDurationInMonths?: number;
|
|
91
|
+
plannedReturnDate?: string;
|
|
92
|
+
pricingDetails: {
|
|
93
|
+
pricingId: string;
|
|
94
|
+
providerType: string;
|
|
95
|
+
}[];
|
|
96
|
+
productIds: string[];
|
|
97
|
+
profileId: string;
|
|
98
|
+
rollingContract: boolean;
|
|
99
|
+
serviceId: string;
|
|
100
|
+
startDate: string;
|
|
101
|
+
status: string;
|
|
102
|
+
userId: string;
|
|
103
|
+
};
|
|
104
|
+
type BookingRequest = BaseBookingRequest & {
|
|
105
|
+
[key: string]: any;
|
|
106
|
+
cancellationDate?: string;
|
|
107
|
+
cancelledBy?: string;
|
|
108
|
+
credit?: string;
|
|
109
|
+
endDate: string;
|
|
110
|
+
entityName?: string;
|
|
111
|
+
journeyId?: string;
|
|
112
|
+
modelId: number;
|
|
113
|
+
modelName?: string;
|
|
114
|
+
paymentReceipts?: PaymentReceipts[];
|
|
115
|
+
pricePerUnit?: string;
|
|
116
|
+
profileType?: 'Single' | 'Business';
|
|
117
|
+
realStartDate?: string;
|
|
118
|
+
returnedDate?: string;
|
|
119
|
+
station: string;
|
|
120
|
+
vehicleId?: string;
|
|
121
|
+
vehicleResidualValue?: number;
|
|
122
|
+
warning?: string;
|
|
123
|
+
};
|
|
124
|
+
type SATBookingRequest = BaseBookingRequest & {
|
|
125
|
+
cancellationDate: string | null;
|
|
126
|
+
cancelledBy: string | null;
|
|
127
|
+
endDate: string | null;
|
|
128
|
+
entityName: string | null;
|
|
129
|
+
journeyId: string | null;
|
|
130
|
+
modelId: number | null;
|
|
131
|
+
profileType: string | null;
|
|
132
|
+
realStartDate: string | null;
|
|
133
|
+
returnedDate: string | null;
|
|
134
|
+
station: string | null;
|
|
135
|
+
vehicleId: string | null;
|
|
136
|
+
cancellationFeeAmount: number | null;
|
|
137
|
+
credits: string | null;
|
|
138
|
+
earlyCancelledByUser: boolean;
|
|
139
|
+
email: string | null;
|
|
140
|
+
failureReason: string | null;
|
|
141
|
+
latitude: number;
|
|
142
|
+
longitude: number;
|
|
143
|
+
parentId: string | null;
|
|
144
|
+
planName: string | null;
|
|
145
|
+
preallocatedVehicleId: string | null;
|
|
146
|
+
previous: any | null;
|
|
147
|
+
price: any | null;
|
|
148
|
+
radius: number;
|
|
149
|
+
requiresActionReturnURL: string | null;
|
|
150
|
+
thresholdDateLimit: string | null;
|
|
151
|
+
trip: any | null;
|
|
152
|
+
warning: string | null;
|
|
153
|
+
};
|
|
154
|
+
/** Response of the trigger BR payment endpoint (booking request + payment intents/receipts). */
|
|
155
|
+
type TriggerBRPaymentResponse = Omit<SATBookingRequest, 'credits'> & {
|
|
156
|
+
paymentIntents: BRPaymentItem[];
|
|
157
|
+
paymentReceipts: BRPaymentItem[];
|
|
158
|
+
credits: BookingCredit[];
|
|
159
|
+
preferredPaymentMethods?: PreferredPaymentMethod[];
|
|
160
|
+
};
|
|
161
|
+
type GeoInfo = {
|
|
162
|
+
name: string;
|
|
163
|
+
coordinates: {
|
|
164
|
+
latitude: number;
|
|
165
|
+
longitude: number;
|
|
166
|
+
};
|
|
167
|
+
geoProperties: {
|
|
168
|
+
[key: string]: any;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
type Service = {
|
|
172
|
+
id: string;
|
|
173
|
+
models: {
|
|
174
|
+
id: number;
|
|
175
|
+
vehicles: string[];
|
|
176
|
+
}[];
|
|
177
|
+
};
|
|
178
|
+
type ServiceInfo = {
|
|
179
|
+
services: Service[];
|
|
180
|
+
};
|
|
181
|
+
type Days = 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY';
|
|
182
|
+
type DayOpeningHours = {
|
|
183
|
+
id: number;
|
|
184
|
+
closed: boolean;
|
|
185
|
+
openAt: string;
|
|
186
|
+
closeAt: string;
|
|
187
|
+
};
|
|
188
|
+
type Timetable = Record<Days, DayOpeningHours[]>;
|
|
189
|
+
type OpeningHours = {
|
|
190
|
+
alwaysOpen: boolean;
|
|
191
|
+
timetable: Timetable;
|
|
192
|
+
};
|
|
193
|
+
type Station = Partial<GeoInfo> & Partial<ServiceInfo> & {
|
|
194
|
+
id: string;
|
|
195
|
+
zoneId: string;
|
|
196
|
+
poiId: string;
|
|
197
|
+
modificationDate: string;
|
|
198
|
+
fleetId: string;
|
|
199
|
+
openingHours?: OpeningHours;
|
|
200
|
+
[key: string]: any;
|
|
201
|
+
};
|
|
202
|
+
/** Vehicle as returned by the available vehicles endpoint. */
|
|
203
|
+
type Vehicle = {
|
|
204
|
+
vehicleId: string;
|
|
205
|
+
[key: string]: unknown;
|
|
206
|
+
};
|
|
207
|
+
/** Response of the subscription stations vehicles/available endpoint. */
|
|
208
|
+
type AvailableVehiclesResponse = {
|
|
209
|
+
stationId: string;
|
|
210
|
+
vehicles: Vehicle[];
|
|
211
|
+
};
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/getBookingRequests.d.ts
|
|
214
|
+
declare const BookingRequestStatusSchema: z.ZodEnum<["ALERT", "UPCOMING", "ONGOING", "COMPLETED", "CANCELLED", "PENDING_APPROVAL", "CONFIRMED", "PENDING", "LATE"]>;
|
|
215
|
+
type BookingRequestStatus = z.infer<typeof BookingRequestStatusSchema>;
|
|
216
|
+
declare const ServiceTypeSchema: z.ZodEnum<["SUBSCRIPTION", "ROUND_TRIP_BOOKING", "SCHEDULED_BOOKING_STATION"]>;
|
|
217
|
+
type ServiceType = z.infer<typeof ServiceTypeSchema>;
|
|
218
|
+
type SpecificBookingRequestFilters = {
|
|
219
|
+
serviceIds?: string[];
|
|
220
|
+
userId?: string;
|
|
221
|
+
modelId?: number;
|
|
222
|
+
vehicleId?: string;
|
|
223
|
+
stationId?: string;
|
|
224
|
+
/**
|
|
225
|
+
* Format: yyyy-MM-dd
|
|
226
|
+
*/
|
|
227
|
+
creationDate?: string;
|
|
228
|
+
/**
|
|
229
|
+
* Format: yyyy-MM-dd'T'HH:mm:ssZ
|
|
230
|
+
* default now
|
|
231
|
+
*/
|
|
232
|
+
startDate?: string;
|
|
233
|
+
/**
|
|
234
|
+
* Format: yyyy-MM-dd'T'HH:mm:ssZ
|
|
235
|
+
* default now plus 2 months
|
|
236
|
+
*/
|
|
237
|
+
endDate?: string;
|
|
238
|
+
includeProducts?: 'true' | 'false';
|
|
239
|
+
};
|
|
240
|
+
type BookingRequestFilters = SpecificBookingRequestFilters & {
|
|
241
|
+
serviceTypes?: ServiceType[];
|
|
242
|
+
};
|
|
243
|
+
declare const getBookingRequests: (client: Client, status: BookingRequestStatus, options?: PaginableOptions<BookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>;
|
|
244
|
+
declare const getScheduleBookingRequests: (client: Client, status: BookingRequestStatus, options?: PaginableOptions<SpecificBookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>;
|
|
245
|
+
declare const getSubscriptionBookingRequests: (client: Client, status: BookingRequestStatus, options?: PaginableOptions<SpecificBookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>;
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/getSATBookingRequests.d.ts
|
|
248
|
+
declare const SATBookingRequestStatusSchema: z.ZodEnum<["ALERT", "CANCELLED", "COMPLETED", "CONFIRMED", "LATE_RETURN", "ONGOING", "PENDING_PAYMENT", "PENDING", "UPCOMING_ALLOCATED", "UPCOMING_NOT_ALLOCATED"]>;
|
|
249
|
+
type SATBookingRequestStatus = z.infer<typeof SATBookingRequestStatusSchema>;
|
|
250
|
+
declare const getSATBookingRequests: (client: Client, status: SATBookingRequestStatus, options?: PaginableOptions<void, keyof SATBookingRequest>) => Promise<PaginableResponse<SATBookingRequest>>;
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/getBookingRequest.d.ts
|
|
253
|
+
declare const getBookingRequestById: (client: Client, id: string) => Promise<BookingRequest>;
|
|
254
|
+
declare const getBookingRequestByTrip: (client: Client, tripId: string) => Promise<BookingRequest>;
|
|
255
|
+
declare const getSubscriptionBookingRequestById: (client: Client, id: string) => Promise<BookingRequest>;
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/getAvailableVehicles.d.ts
|
|
258
|
+
declare const getAvailableVehicles: (client: Client, stationId: string, startDate: string) => Promise<AvailableVehiclesResponse>;
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/getStations.d.ts
|
|
261
|
+
declare const IncludeSchema$1: z.ZodEnum<["INFO", "OPEN_HOUR", "SERVICES"]>;
|
|
262
|
+
type Include = z.infer<typeof IncludeSchema$1>;
|
|
263
|
+
declare const getStations: (client: Client, includes?: Include[]) => Promise<Station[]>;
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/getStation.d.ts
|
|
266
|
+
declare const IncludeSchema: z.ZodEnum<["INFO", "SERVICES"]>;
|
|
267
|
+
type IncludeStation = z.infer<typeof IncludeSchema>;
|
|
268
|
+
declare const getStationById: (client: Client, id: string, includes?: IncludeStation[]) => Promise<Station | null>;
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/allocateVehicle.d.ts
|
|
271
|
+
declare const allocateVehicle: (client: Client, bookingRequestId: UUID, vehicleId: UUID, serviceId: UUID) => Promise<SATBookingRequest>;
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/deallocateVehicle.d.ts
|
|
274
|
+
declare const deallocateVehicle: (client: Client, bookingRequestId: UUID, vehicleId: UUID) => Promise<SATBookingRequest>;
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/updateScheduleBooking.d.ts
|
|
277
|
+
declare const updateScheduleBooking: (client: Client, bookingRequestId: string, updateData: Record<string, unknown>) => Promise<SATBookingRequest>;
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/triggerBRPayment.d.ts
|
|
280
|
+
declare const triggerBRPaymentSchema: z$1.ZodObject<{
|
|
281
|
+
bookingRequestId: z$1.ZodString;
|
|
282
|
+
body: z$1.ZodObject<{
|
|
283
|
+
scope: z$1.ZodEnum<["RENTAL", "DEPOSIT"]>;
|
|
284
|
+
requiresActionReturnURL: z$1.ZodOptional<z$1.ZodString>;
|
|
285
|
+
online: z$1.ZodBoolean;
|
|
286
|
+
amountType: z$1.ZodEnum<["FIXED", "PERCENTAGE"]>;
|
|
287
|
+
amountValue: z$1.ZodNumber;
|
|
288
|
+
preferredPaymentMethods: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
|
|
289
|
+
pspReference: z$1.ZodString;
|
|
290
|
+
amount: z$1.ZodDefault<z$1.ZodNumber>;
|
|
291
|
+
}, "strip", z$1.ZodTypeAny, {
|
|
292
|
+
pspReference: string;
|
|
293
|
+
amount: number;
|
|
294
|
+
}, {
|
|
295
|
+
pspReference: string;
|
|
296
|
+
amount?: number | undefined;
|
|
297
|
+
}>, "many">>;
|
|
298
|
+
profileId: z$1.ZodString;
|
|
299
|
+
}, "strip", z$1.ZodTypeAny, {
|
|
300
|
+
profileId: string;
|
|
301
|
+
scope: "RENTAL" | "DEPOSIT";
|
|
302
|
+
online: boolean;
|
|
303
|
+
amountType: "FIXED" | "PERCENTAGE";
|
|
304
|
+
amountValue: number;
|
|
305
|
+
requiresActionReturnURL?: string | undefined;
|
|
306
|
+
preferredPaymentMethods?: {
|
|
307
|
+
pspReference: string;
|
|
308
|
+
amount: number;
|
|
309
|
+
}[] | undefined;
|
|
310
|
+
}, {
|
|
311
|
+
profileId: string;
|
|
312
|
+
scope: "RENTAL" | "DEPOSIT";
|
|
313
|
+
online: boolean;
|
|
314
|
+
amountType: "FIXED" | "PERCENTAGE";
|
|
315
|
+
amountValue: number;
|
|
316
|
+
requiresActionReturnURL?: string | undefined;
|
|
317
|
+
preferredPaymentMethods?: {
|
|
318
|
+
pspReference: string;
|
|
319
|
+
amount?: number | undefined;
|
|
320
|
+
}[] | undefined;
|
|
321
|
+
}>;
|
|
322
|
+
}, "strip", z$1.ZodTypeAny, {
|
|
323
|
+
bookingRequestId: string;
|
|
324
|
+
body: {
|
|
325
|
+
profileId: string;
|
|
326
|
+
scope: "RENTAL" | "DEPOSIT";
|
|
327
|
+
online: boolean;
|
|
328
|
+
amountType: "FIXED" | "PERCENTAGE";
|
|
329
|
+
amountValue: number;
|
|
330
|
+
requiresActionReturnURL?: string | undefined;
|
|
331
|
+
preferredPaymentMethods?: {
|
|
332
|
+
pspReference: string;
|
|
333
|
+
amount: number;
|
|
334
|
+
}[] | undefined;
|
|
335
|
+
};
|
|
336
|
+
}, {
|
|
337
|
+
bookingRequestId: string;
|
|
338
|
+
body: {
|
|
339
|
+
profileId: string;
|
|
340
|
+
scope: "RENTAL" | "DEPOSIT";
|
|
341
|
+
online: boolean;
|
|
342
|
+
amountType: "FIXED" | "PERCENTAGE";
|
|
343
|
+
amountValue: number;
|
|
344
|
+
requiresActionReturnURL?: string | undefined;
|
|
345
|
+
preferredPaymentMethods?: {
|
|
346
|
+
pspReference: string;
|
|
347
|
+
amount?: number | undefined;
|
|
348
|
+
}[] | undefined;
|
|
349
|
+
};
|
|
350
|
+
}>;
|
|
351
|
+
declare const triggerBRPayment: (client: Client, bookingRequestId: UUID, body: z$1.infer<typeof triggerBRPaymentSchema>["body"]) => Promise<TriggerBRPaymentResponse>;
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/getBookingRequestsByUserId.d.ts
|
|
354
|
+
declare const getBookingRequestsByUserId: (client: Client, userId: string) => Promise<BookingRequest[]>;
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/releaseBRPayment.d.ts
|
|
357
|
+
declare const releaseBRPayment: (client: Client, bookingRequestId: UUID, pspReference: string) => Promise<SATBookingRequest>;
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/cancelBookingRequest.d.ts
|
|
360
|
+
declare const cancelBookingRequest: (client: Client, id: string) => Promise<SATBookingRequest>;
|
|
361
|
+
//#endregion
|
|
362
|
+
export { AvailableVehiclesResponse, BRPaymentItem, BaseBookingRequest, BookingCredit, BookingRequest, type BookingRequestFilters, type BookingRequestStatus, CustomPrice, DayOpeningHours, Days, GeoInfo, type Include, type IncludeStation, OpeningHours, PaymentReceipts, PreferredPaymentMethod, SATBookingRequest, type SATBookingRequestStatus, Service, ServiceInfo, type ServiceType, Station, Timetable, TriggerBRPaymentResponse, Vehicle, allocateVehicle, cancelBookingRequest, deallocateVehicle, getAvailableVehicles, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getBookingRequestsByUserId, getSATBookingRequests, getScheduleBookingRequests, getStationById, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests, releaseBRPayment, triggerBRPayment, updateScheduleBooking };
|