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