@vulog/aima-booking 1.2.28 → 1.2.30
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.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +77 -56
- package/dist/index.mjs +76 -56
- package/package.json +3 -3
- package/src/getAvailableVehicles.ts +30 -0
- package/src/index.ts +1 -0
- package/src/types.ts +12 -0
package/dist/index.d.mts
CHANGED
|
@@ -198,6 +198,16 @@ type Station = Partial<GeoInfo> & Partial<ServiceInfo> & {
|
|
|
198
198
|
openingHours?: OpeningHours;
|
|
199
199
|
[key: string]: any;
|
|
200
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
|
+
};
|
|
201
211
|
|
|
202
212
|
declare const BookingRequestStatusSchema: z.ZodEnum<["ALERT", "UPCOMING", "ONGOING", "COMPLETED", "CANCELLED", "PENDING_APPROVAL", "CONFIRMED", "PENDING", "LATE"]>;
|
|
203
213
|
type BookingRequestStatus = z.infer<typeof BookingRequestStatusSchema>;
|
|
@@ -240,6 +250,8 @@ declare const getBookingRequestById: (client: Client, id: string) => Promise<Boo
|
|
|
240
250
|
declare const getBookingRequestByTrip: (client: Client, tripId: string) => Promise<BookingRequest>;
|
|
241
251
|
declare const getSubscriptionBookingRequestById: (client: Client, id: string) => Promise<BookingRequest>;
|
|
242
252
|
|
|
253
|
+
declare const getAvailableVehicles: (client: Client, stationId: string, startDate: string) => Promise<AvailableVehiclesResponse>;
|
|
254
|
+
|
|
243
255
|
declare const IncludeSchema$1: z.ZodEnum<["INFO", "OPEN_HOUR", "SERVICES"]>;
|
|
244
256
|
type Include = z.infer<typeof IncludeSchema$1>;
|
|
245
257
|
declare const getStations: (client: Client, includes?: Include[]) => Promise<Station[]>;
|
|
@@ -333,4 +345,4 @@ declare const releaseBRPayment: (client: Client, bookingRequestId: UUID, pspRefe
|
|
|
333
345
|
|
|
334
346
|
declare const cancelBookingRequest: (client: Client, id: string) => Promise<SATBookingRequest>;
|
|
335
347
|
|
|
336
|
-
export { 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, allocateVehicle, cancelBookingRequest, deallocateVehicle, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getBookingRequestsByUserId, getSATBookingRequests, getScheduleBookingRequests, getStationById, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests, releaseBRPayment, triggerBRPayment, updateScheduleBooking };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -198,6 +198,16 @@ type Station = Partial<GeoInfo> & Partial<ServiceInfo> & {
|
|
|
198
198
|
openingHours?: OpeningHours;
|
|
199
199
|
[key: string]: any;
|
|
200
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
|
+
};
|
|
201
211
|
|
|
202
212
|
declare const BookingRequestStatusSchema: z.ZodEnum<["ALERT", "UPCOMING", "ONGOING", "COMPLETED", "CANCELLED", "PENDING_APPROVAL", "CONFIRMED", "PENDING", "LATE"]>;
|
|
203
213
|
type BookingRequestStatus = z.infer<typeof BookingRequestStatusSchema>;
|
|
@@ -240,6 +250,8 @@ declare const getBookingRequestById: (client: Client, id: string) => Promise<Boo
|
|
|
240
250
|
declare const getBookingRequestByTrip: (client: Client, tripId: string) => Promise<BookingRequest>;
|
|
241
251
|
declare const getSubscriptionBookingRequestById: (client: Client, id: string) => Promise<BookingRequest>;
|
|
242
252
|
|
|
253
|
+
declare const getAvailableVehicles: (client: Client, stationId: string, startDate: string) => Promise<AvailableVehiclesResponse>;
|
|
254
|
+
|
|
243
255
|
declare const IncludeSchema$1: z.ZodEnum<["INFO", "OPEN_HOUR", "SERVICES"]>;
|
|
244
256
|
type Include = z.infer<typeof IncludeSchema$1>;
|
|
245
257
|
declare const getStations: (client: Client, includes?: Include[]) => Promise<Station[]>;
|
|
@@ -333,4 +345,4 @@ declare const releaseBRPayment: (client: Client, bookingRequestId: UUID, pspRefe
|
|
|
333
345
|
|
|
334
346
|
declare const cancelBookingRequest: (client: Client, id: string) => Promise<SATBookingRequest>;
|
|
335
347
|
|
|
336
|
-
export { 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, allocateVehicle, cancelBookingRequest, deallocateVehicle, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getBookingRequestsByUserId, getSATBookingRequests, getScheduleBookingRequests, getStationById, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests, releaseBRPayment, triggerBRPayment, updateScheduleBooking };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
allocateVehicle: () => allocateVehicle,
|
|
34
34
|
cancelBookingRequest: () => cancelBookingRequest,
|
|
35
35
|
deallocateVehicle: () => deallocateVehicle,
|
|
36
|
+
getAvailableVehicles: () => getAvailableVehicles,
|
|
36
37
|
getBookingRequestById: () => getBookingRequestById,
|
|
37
38
|
getBookingRequestByTrip: () => getBookingRequestByTrip,
|
|
38
39
|
getBookingRequests: () => getBookingRequests,
|
|
@@ -234,10 +235,29 @@ var getSubscriptionBookingRequestById = async (client, id) => {
|
|
|
234
235
|
).then(({ data: { stationId, ...data } }) => ({ station: stationId, ...data }));
|
|
235
236
|
};
|
|
236
237
|
|
|
237
|
-
// src/
|
|
238
|
+
// src/getAvailableVehicles.ts
|
|
238
239
|
var import_zod4 = require("zod");
|
|
239
|
-
var
|
|
240
|
-
var
|
|
240
|
+
var isoDateTimeNoMs = import_zod4.z.string().trim().datetime({ precision: 0 });
|
|
241
|
+
var getAvailableVehiclesSchema = import_zod4.z.object({
|
|
242
|
+
stationId: import_zod4.z.string().trim().min(1),
|
|
243
|
+
startDate: isoDateTimeNoMs
|
|
244
|
+
});
|
|
245
|
+
var getAvailableVehicles = async (client, stationId, startDate) => {
|
|
246
|
+
const result = getAvailableVehiclesSchema.safeParse({ stationId, startDate });
|
|
247
|
+
if (!result.success) {
|
|
248
|
+
throw new TypeError("Invalid args", {
|
|
249
|
+
cause: result.error.issues
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
return client.get(
|
|
253
|
+
`/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/subscription/stations/${stationId}/vehicles/available?startDate=${startDate}`
|
|
254
|
+
).then(({ data }) => data);
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// src/getStations.ts
|
|
258
|
+
var import_zod5 = require("zod");
|
|
259
|
+
var IncludeSchema = import_zod5.z.enum(["INFO", "OPEN_HOUR", "SERVICES"]);
|
|
260
|
+
var IncludesSchema = import_zod5.z.array(IncludeSchema);
|
|
241
261
|
var getStations = async (client, includes = []) => {
|
|
242
262
|
const resultIncludes = IncludesSchema.safeParse(includes);
|
|
243
263
|
if (!resultIncludes.success) {
|
|
@@ -327,9 +347,9 @@ var getStations = async (client, includes = []) => {
|
|
|
327
347
|
};
|
|
328
348
|
|
|
329
349
|
// src/getStation.ts
|
|
330
|
-
var
|
|
331
|
-
var IncludeSchema2 =
|
|
332
|
-
var IncludesSchema2 =
|
|
350
|
+
var import_zod6 = require("zod");
|
|
351
|
+
var IncludeSchema2 = import_zod6.z.enum(["INFO", "SERVICES"]);
|
|
352
|
+
var IncludesSchema2 = import_zod6.z.array(IncludeSchema2);
|
|
333
353
|
var getStationById = async (client, id, includes = []) => {
|
|
334
354
|
const resultIncludes = IncludesSchema2.safeParse(includes);
|
|
335
355
|
if (!resultIncludes.success) {
|
|
@@ -431,11 +451,11 @@ var getStationById = async (client, id, includes = []) => {
|
|
|
431
451
|
};
|
|
432
452
|
|
|
433
453
|
// src/allocateVehicle.ts
|
|
434
|
-
var
|
|
435
|
-
var allocateVehicleSchema =
|
|
436
|
-
bookingRequestId:
|
|
437
|
-
vehicleId:
|
|
438
|
-
serviceId:
|
|
454
|
+
var import_zod7 = __toESM(require("zod"));
|
|
455
|
+
var allocateVehicleSchema = import_zod7.default.object({
|
|
456
|
+
bookingRequestId: import_zod7.default.string().uuid(),
|
|
457
|
+
vehicleId: import_zod7.default.string().uuid(),
|
|
458
|
+
serviceId: import_zod7.default.string().uuid()
|
|
439
459
|
});
|
|
440
460
|
var allocateVehicle = async (client, bookingRequestId, vehicleId, serviceId) => {
|
|
441
461
|
const resultPayload = allocateVehicleSchema.safeParse({ bookingRequestId, vehicleId, serviceId });
|
|
@@ -450,10 +470,10 @@ var allocateVehicle = async (client, bookingRequestId, vehicleId, serviceId) =>
|
|
|
450
470
|
};
|
|
451
471
|
|
|
452
472
|
// src/deallocateVehicle.ts
|
|
453
|
-
var
|
|
454
|
-
var deallocateVehicleSchema =
|
|
455
|
-
bookingRequestId:
|
|
456
|
-
vehicleId:
|
|
473
|
+
var import_zod8 = __toESM(require("zod"));
|
|
474
|
+
var deallocateVehicleSchema = import_zod8.default.object({
|
|
475
|
+
bookingRequestId: import_zod8.default.string().uuid(),
|
|
476
|
+
vehicleId: import_zod8.default.string().uuid()
|
|
457
477
|
});
|
|
458
478
|
var deallocateVehicle = async (client, bookingRequestId, vehicleId) => {
|
|
459
479
|
const resultPayload = deallocateVehicleSchema.safeParse({ bookingRequestId, vehicleId });
|
|
@@ -468,25 +488,25 @@ var deallocateVehicle = async (client, bookingRequestId, vehicleId) => {
|
|
|
468
488
|
};
|
|
469
489
|
|
|
470
490
|
// src/updateScheduleBooking.ts
|
|
471
|
-
var
|
|
472
|
-
var schema =
|
|
473
|
-
id:
|
|
474
|
-
startDate:
|
|
491
|
+
var import_zod9 = __toESM(require("zod"));
|
|
492
|
+
var schema = import_zod9.default.object({
|
|
493
|
+
id: import_zod9.default.string(),
|
|
494
|
+
startDate: import_zod9.default.string().refine((date) => !Number.isNaN(Date.parse(date)), {
|
|
475
495
|
message: "Invalid date"
|
|
476
496
|
}).optional(),
|
|
477
|
-
latitude:
|
|
478
|
-
longitude:
|
|
479
|
-
radius:
|
|
480
|
-
userId:
|
|
481
|
-
status:
|
|
482
|
-
cityId:
|
|
483
|
-
profileId:
|
|
484
|
-
serviceId:
|
|
485
|
-
warning:
|
|
486
|
-
modelId:
|
|
487
|
-
notes:
|
|
488
|
-
bookingReferenceId:
|
|
489
|
-
plannedReturnDate:
|
|
497
|
+
latitude: import_zod9.default.number().min(-90).max(90).optional(),
|
|
498
|
+
longitude: import_zod9.default.number().min(-180).max(180).optional(),
|
|
499
|
+
radius: import_zod9.default.number().min(0).optional(),
|
|
500
|
+
userId: import_zod9.default.string().optional(),
|
|
501
|
+
status: import_zod9.default.enum(["CONFIRMED", "CANCELLED", "PENDING"]).optional(),
|
|
502
|
+
cityId: import_zod9.default.string().optional(),
|
|
503
|
+
profileId: import_zod9.default.string().optional(),
|
|
504
|
+
serviceId: import_zod9.default.string().optional(),
|
|
505
|
+
warning: import_zod9.default.string().optional(),
|
|
506
|
+
modelId: import_zod9.default.number().optional(),
|
|
507
|
+
notes: import_zod9.default.string().optional(),
|
|
508
|
+
bookingReferenceId: import_zod9.default.string().optional(),
|
|
509
|
+
plannedReturnDate: import_zod9.default.string().refine((date) => !Number.isNaN(Date.parse(date)), {
|
|
490
510
|
message: "Invalid date"
|
|
491
511
|
}).optional()
|
|
492
512
|
});
|
|
@@ -504,22 +524,22 @@ var updateScheduleBooking = async (client, bookingRequestId, updateData) => {
|
|
|
504
524
|
};
|
|
505
525
|
|
|
506
526
|
// src/triggerBRPayment.ts
|
|
507
|
-
var
|
|
508
|
-
var triggerBRPaymentSchema =
|
|
509
|
-
bookingRequestId:
|
|
510
|
-
body:
|
|
511
|
-
scope:
|
|
512
|
-
requiresActionReturnURL:
|
|
513
|
-
online:
|
|
514
|
-
amountType:
|
|
515
|
-
amountValue:
|
|
516
|
-
preferredPaymentMethods:
|
|
517
|
-
|
|
518
|
-
pspReference:
|
|
519
|
-
amount:
|
|
527
|
+
var import_zod10 = __toESM(require("zod"));
|
|
528
|
+
var triggerBRPaymentSchema = import_zod10.default.object({
|
|
529
|
+
bookingRequestId: import_zod10.default.string().uuid(),
|
|
530
|
+
body: import_zod10.default.object({
|
|
531
|
+
scope: import_zod10.default.enum(["RENTAL", "DEPOSIT"]),
|
|
532
|
+
requiresActionReturnURL: import_zod10.default.string().url().optional(),
|
|
533
|
+
online: import_zod10.default.boolean(),
|
|
534
|
+
amountType: import_zod10.default.enum(["FIXED", "PERCENTAGE"]),
|
|
535
|
+
amountValue: import_zod10.default.number().nonnegative(),
|
|
536
|
+
preferredPaymentMethods: import_zod10.default.array(
|
|
537
|
+
import_zod10.default.object({
|
|
538
|
+
pspReference: import_zod10.default.string(),
|
|
539
|
+
amount: import_zod10.default.number().default(0)
|
|
520
540
|
})
|
|
521
541
|
).optional(),
|
|
522
|
-
profileId:
|
|
542
|
+
profileId: import_zod10.default.string().uuid()
|
|
523
543
|
})
|
|
524
544
|
});
|
|
525
545
|
var triggerBRPayment = async (client, bookingRequestId, body) => {
|
|
@@ -540,9 +560,9 @@ var triggerBRPayment = async (client, bookingRequestId, body) => {
|
|
|
540
560
|
};
|
|
541
561
|
|
|
542
562
|
// src/getBookingRequestsByUserId.ts
|
|
543
|
-
var
|
|
544
|
-
var schema2 =
|
|
545
|
-
userId:
|
|
563
|
+
var import_zod11 = require("zod");
|
|
564
|
+
var schema2 = import_zod11.z.object({
|
|
565
|
+
userId: import_zod11.z.string().trim().min(1).uuid()
|
|
546
566
|
});
|
|
547
567
|
var getBookingRequestsByUserId = async (client, userId) => {
|
|
548
568
|
const result = schema2.safeParse({ userId });
|
|
@@ -562,10 +582,10 @@ var getBookingRequestsByUserId = async (client, userId) => {
|
|
|
562
582
|
};
|
|
563
583
|
|
|
564
584
|
// src/releaseBRPayment.ts
|
|
565
|
-
var
|
|
566
|
-
var releaseBRPaymentSchema =
|
|
567
|
-
bookingRequestId:
|
|
568
|
-
pspReference:
|
|
585
|
+
var import_zod12 = __toESM(require("zod"));
|
|
586
|
+
var releaseBRPaymentSchema = import_zod12.default.object({
|
|
587
|
+
bookingRequestId: import_zod12.default.string().uuid(),
|
|
588
|
+
pspReference: import_zod12.default.string().uuid()
|
|
569
589
|
});
|
|
570
590
|
var releaseBRPayment = async (client, bookingRequestId, pspReference) => {
|
|
571
591
|
const resultPayload = releaseBRPaymentSchema.safeParse({ bookingRequestId, pspReference });
|
|
@@ -585,9 +605,9 @@ var releaseBRPayment = async (client, bookingRequestId, pspReference) => {
|
|
|
585
605
|
};
|
|
586
606
|
|
|
587
607
|
// src/cancelBookingRequest.ts
|
|
588
|
-
var
|
|
589
|
-
var schema3 =
|
|
590
|
-
id:
|
|
608
|
+
var import_zod13 = __toESM(require("zod"));
|
|
609
|
+
var schema3 = import_zod13.default.object({
|
|
610
|
+
id: import_zod13.default.string().uuid()
|
|
591
611
|
});
|
|
592
612
|
var cancelBookingRequest = async (client, id) => {
|
|
593
613
|
const result = schema3.safeParse({ id });
|
|
@@ -610,6 +630,7 @@ var cancelBookingRequest = async (client, id) => {
|
|
|
610
630
|
allocateVehicle,
|
|
611
631
|
cancelBookingRequest,
|
|
612
632
|
deallocateVehicle,
|
|
633
|
+
getAvailableVehicles,
|
|
613
634
|
getBookingRequestById,
|
|
614
635
|
getBookingRequestByTrip,
|
|
615
636
|
getBookingRequests,
|
package/dist/index.mjs
CHANGED
|
@@ -183,10 +183,29 @@ var getSubscriptionBookingRequestById = async (client, id) => {
|
|
|
183
183
|
).then(({ data: { stationId, ...data } }) => ({ station: stationId, ...data }));
|
|
184
184
|
};
|
|
185
185
|
|
|
186
|
-
// src/
|
|
186
|
+
// src/getAvailableVehicles.ts
|
|
187
187
|
import { z as z4 } from "zod";
|
|
188
|
-
var
|
|
189
|
-
var
|
|
188
|
+
var isoDateTimeNoMs = z4.string().trim().datetime({ precision: 0 });
|
|
189
|
+
var getAvailableVehiclesSchema = z4.object({
|
|
190
|
+
stationId: z4.string().trim().min(1),
|
|
191
|
+
startDate: isoDateTimeNoMs
|
|
192
|
+
});
|
|
193
|
+
var getAvailableVehicles = async (client, stationId, startDate) => {
|
|
194
|
+
const result = getAvailableVehiclesSchema.safeParse({ stationId, startDate });
|
|
195
|
+
if (!result.success) {
|
|
196
|
+
throw new TypeError("Invalid args", {
|
|
197
|
+
cause: result.error.issues
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return client.get(
|
|
201
|
+
`/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/subscription/stations/${stationId}/vehicles/available?startDate=${startDate}`
|
|
202
|
+
).then(({ data }) => data);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// src/getStations.ts
|
|
206
|
+
import { z as z5 } from "zod";
|
|
207
|
+
var IncludeSchema = z5.enum(["INFO", "OPEN_HOUR", "SERVICES"]);
|
|
208
|
+
var IncludesSchema = z5.array(IncludeSchema);
|
|
190
209
|
var getStations = async (client, includes = []) => {
|
|
191
210
|
const resultIncludes = IncludesSchema.safeParse(includes);
|
|
192
211
|
if (!resultIncludes.success) {
|
|
@@ -276,9 +295,9 @@ var getStations = async (client, includes = []) => {
|
|
|
276
295
|
};
|
|
277
296
|
|
|
278
297
|
// src/getStation.ts
|
|
279
|
-
import { z as
|
|
280
|
-
var IncludeSchema2 =
|
|
281
|
-
var IncludesSchema2 =
|
|
298
|
+
import { z as z6 } from "zod";
|
|
299
|
+
var IncludeSchema2 = z6.enum(["INFO", "SERVICES"]);
|
|
300
|
+
var IncludesSchema2 = z6.array(IncludeSchema2);
|
|
282
301
|
var getStationById = async (client, id, includes = []) => {
|
|
283
302
|
const resultIncludes = IncludesSchema2.safeParse(includes);
|
|
284
303
|
if (!resultIncludes.success) {
|
|
@@ -380,11 +399,11 @@ var getStationById = async (client, id, includes = []) => {
|
|
|
380
399
|
};
|
|
381
400
|
|
|
382
401
|
// src/allocateVehicle.ts
|
|
383
|
-
import
|
|
384
|
-
var allocateVehicleSchema =
|
|
385
|
-
bookingRequestId:
|
|
386
|
-
vehicleId:
|
|
387
|
-
serviceId:
|
|
402
|
+
import z7 from "zod";
|
|
403
|
+
var allocateVehicleSchema = z7.object({
|
|
404
|
+
bookingRequestId: z7.string().uuid(),
|
|
405
|
+
vehicleId: z7.string().uuid(),
|
|
406
|
+
serviceId: z7.string().uuid()
|
|
388
407
|
});
|
|
389
408
|
var allocateVehicle = async (client, bookingRequestId, vehicleId, serviceId) => {
|
|
390
409
|
const resultPayload = allocateVehicleSchema.safeParse({ bookingRequestId, vehicleId, serviceId });
|
|
@@ -399,10 +418,10 @@ var allocateVehicle = async (client, bookingRequestId, vehicleId, serviceId) =>
|
|
|
399
418
|
};
|
|
400
419
|
|
|
401
420
|
// src/deallocateVehicle.ts
|
|
402
|
-
import
|
|
403
|
-
var deallocateVehicleSchema =
|
|
404
|
-
bookingRequestId:
|
|
405
|
-
vehicleId:
|
|
421
|
+
import z8 from "zod";
|
|
422
|
+
var deallocateVehicleSchema = z8.object({
|
|
423
|
+
bookingRequestId: z8.string().uuid(),
|
|
424
|
+
vehicleId: z8.string().uuid()
|
|
406
425
|
});
|
|
407
426
|
var deallocateVehicle = async (client, bookingRequestId, vehicleId) => {
|
|
408
427
|
const resultPayload = deallocateVehicleSchema.safeParse({ bookingRequestId, vehicleId });
|
|
@@ -417,25 +436,25 @@ var deallocateVehicle = async (client, bookingRequestId, vehicleId) => {
|
|
|
417
436
|
};
|
|
418
437
|
|
|
419
438
|
// src/updateScheduleBooking.ts
|
|
420
|
-
import
|
|
421
|
-
var schema =
|
|
422
|
-
id:
|
|
423
|
-
startDate:
|
|
439
|
+
import z9 from "zod";
|
|
440
|
+
var schema = z9.object({
|
|
441
|
+
id: z9.string(),
|
|
442
|
+
startDate: z9.string().refine((date) => !Number.isNaN(Date.parse(date)), {
|
|
424
443
|
message: "Invalid date"
|
|
425
444
|
}).optional(),
|
|
426
|
-
latitude:
|
|
427
|
-
longitude:
|
|
428
|
-
radius:
|
|
429
|
-
userId:
|
|
430
|
-
status:
|
|
431
|
-
cityId:
|
|
432
|
-
profileId:
|
|
433
|
-
serviceId:
|
|
434
|
-
warning:
|
|
435
|
-
modelId:
|
|
436
|
-
notes:
|
|
437
|
-
bookingReferenceId:
|
|
438
|
-
plannedReturnDate:
|
|
445
|
+
latitude: z9.number().min(-90).max(90).optional(),
|
|
446
|
+
longitude: z9.number().min(-180).max(180).optional(),
|
|
447
|
+
radius: z9.number().min(0).optional(),
|
|
448
|
+
userId: z9.string().optional(),
|
|
449
|
+
status: z9.enum(["CONFIRMED", "CANCELLED", "PENDING"]).optional(),
|
|
450
|
+
cityId: z9.string().optional(),
|
|
451
|
+
profileId: z9.string().optional(),
|
|
452
|
+
serviceId: z9.string().optional(),
|
|
453
|
+
warning: z9.string().optional(),
|
|
454
|
+
modelId: z9.number().optional(),
|
|
455
|
+
notes: z9.string().optional(),
|
|
456
|
+
bookingReferenceId: z9.string().optional(),
|
|
457
|
+
plannedReturnDate: z9.string().refine((date) => !Number.isNaN(Date.parse(date)), {
|
|
439
458
|
message: "Invalid date"
|
|
440
459
|
}).optional()
|
|
441
460
|
});
|
|
@@ -453,22 +472,22 @@ var updateScheduleBooking = async (client, bookingRequestId, updateData) => {
|
|
|
453
472
|
};
|
|
454
473
|
|
|
455
474
|
// src/triggerBRPayment.ts
|
|
456
|
-
import
|
|
457
|
-
var triggerBRPaymentSchema =
|
|
458
|
-
bookingRequestId:
|
|
459
|
-
body:
|
|
460
|
-
scope:
|
|
461
|
-
requiresActionReturnURL:
|
|
462
|
-
online:
|
|
463
|
-
amountType:
|
|
464
|
-
amountValue:
|
|
465
|
-
preferredPaymentMethods:
|
|
466
|
-
|
|
467
|
-
pspReference:
|
|
468
|
-
amount:
|
|
475
|
+
import z10 from "zod";
|
|
476
|
+
var triggerBRPaymentSchema = z10.object({
|
|
477
|
+
bookingRequestId: z10.string().uuid(),
|
|
478
|
+
body: z10.object({
|
|
479
|
+
scope: z10.enum(["RENTAL", "DEPOSIT"]),
|
|
480
|
+
requiresActionReturnURL: z10.string().url().optional(),
|
|
481
|
+
online: z10.boolean(),
|
|
482
|
+
amountType: z10.enum(["FIXED", "PERCENTAGE"]),
|
|
483
|
+
amountValue: z10.number().nonnegative(),
|
|
484
|
+
preferredPaymentMethods: z10.array(
|
|
485
|
+
z10.object({
|
|
486
|
+
pspReference: z10.string(),
|
|
487
|
+
amount: z10.number().default(0)
|
|
469
488
|
})
|
|
470
489
|
).optional(),
|
|
471
|
-
profileId:
|
|
490
|
+
profileId: z10.string().uuid()
|
|
472
491
|
})
|
|
473
492
|
});
|
|
474
493
|
var triggerBRPayment = async (client, bookingRequestId, body) => {
|
|
@@ -489,9 +508,9 @@ var triggerBRPayment = async (client, bookingRequestId, body) => {
|
|
|
489
508
|
};
|
|
490
509
|
|
|
491
510
|
// src/getBookingRequestsByUserId.ts
|
|
492
|
-
import { z as
|
|
493
|
-
var schema2 =
|
|
494
|
-
userId:
|
|
511
|
+
import { z as z11 } from "zod";
|
|
512
|
+
var schema2 = z11.object({
|
|
513
|
+
userId: z11.string().trim().min(1).uuid()
|
|
495
514
|
});
|
|
496
515
|
var getBookingRequestsByUserId = async (client, userId) => {
|
|
497
516
|
const result = schema2.safeParse({ userId });
|
|
@@ -511,10 +530,10 @@ var getBookingRequestsByUserId = async (client, userId) => {
|
|
|
511
530
|
};
|
|
512
531
|
|
|
513
532
|
// src/releaseBRPayment.ts
|
|
514
|
-
import
|
|
515
|
-
var releaseBRPaymentSchema =
|
|
516
|
-
bookingRequestId:
|
|
517
|
-
pspReference:
|
|
533
|
+
import z12 from "zod";
|
|
534
|
+
var releaseBRPaymentSchema = z12.object({
|
|
535
|
+
bookingRequestId: z12.string().uuid(),
|
|
536
|
+
pspReference: z12.string().uuid()
|
|
518
537
|
});
|
|
519
538
|
var releaseBRPayment = async (client, bookingRequestId, pspReference) => {
|
|
520
539
|
const resultPayload = releaseBRPaymentSchema.safeParse({ bookingRequestId, pspReference });
|
|
@@ -534,9 +553,9 @@ var releaseBRPayment = async (client, bookingRequestId, pspReference) => {
|
|
|
534
553
|
};
|
|
535
554
|
|
|
536
555
|
// src/cancelBookingRequest.ts
|
|
537
|
-
import
|
|
538
|
-
var schema3 =
|
|
539
|
-
id:
|
|
556
|
+
import z13 from "zod";
|
|
557
|
+
var schema3 = z13.object({
|
|
558
|
+
id: z13.string().uuid()
|
|
540
559
|
});
|
|
541
560
|
var cancelBookingRequest = async (client, id) => {
|
|
542
561
|
const result = schema3.safeParse({ id });
|
|
@@ -558,6 +577,7 @@ export {
|
|
|
558
577
|
allocateVehicle,
|
|
559
578
|
cancelBookingRequest,
|
|
560
579
|
deallocateVehicle,
|
|
580
|
+
getAvailableVehicles,
|
|
561
581
|
getBookingRequestById,
|
|
562
582
|
getBookingRequestByTrip,
|
|
563
583
|
getBookingRequests,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-booking",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.30",
|
|
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.2.
|
|
23
|
-
"@vulog/aima-core": "1.2.
|
|
22
|
+
"@vulog/aima-client": "1.2.30",
|
|
23
|
+
"@vulog/aima-core": "1.2.30"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"es-toolkit": "^1.39.9",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Client } from '@vulog/aima-client';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { AvailableVehiclesResponse } from './types';
|
|
5
|
+
|
|
6
|
+
/** ISO date-time without milliseconds (e.g. 2025-02-10T12:00:00Z or 2025-02-10T12:00:00+01:00). */
|
|
7
|
+
const isoDateTimeNoMs = z.string().trim().datetime({ precision: 0 });
|
|
8
|
+
|
|
9
|
+
const getAvailableVehiclesSchema = z.object({
|
|
10
|
+
stationId: z.string().trim().min(1),
|
|
11
|
+
startDate: isoDateTimeNoMs,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const getAvailableVehicles = async (
|
|
15
|
+
client: Client,
|
|
16
|
+
stationId: string,
|
|
17
|
+
startDate: string
|
|
18
|
+
): Promise<AvailableVehiclesResponse> => {
|
|
19
|
+
const result = getAvailableVehiclesSchema.safeParse({ stationId, startDate });
|
|
20
|
+
if (!result.success) {
|
|
21
|
+
throw new TypeError('Invalid args', {
|
|
22
|
+
cause: result.error.issues,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return client
|
|
26
|
+
.get<AvailableVehiclesResponse>(
|
|
27
|
+
`/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/subscription/stations/${stationId}/vehicles/available?startDate=${startDate}`
|
|
28
|
+
)
|
|
29
|
+
.then(({ data }) => data);
|
|
30
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { getBookingRequestById, getBookingRequestByTrip, getSubscriptionBookingR
|
|
|
4
4
|
export * from './types';
|
|
5
5
|
export type { BookingRequestStatus, ServiceType, BookingRequestFilters } from './getBookingRequests';
|
|
6
6
|
export type { SATBookingRequestStatus } from './getSATBookingRequests';
|
|
7
|
+
export { getAvailableVehicles } from './getAvailableVehicles';
|
|
7
8
|
export { getStations } from './getStations';
|
|
8
9
|
export type { Include } from './getStations';
|
|
9
10
|
export { getStationById } from './getStation';
|
package/src/types.ts
CHANGED
|
@@ -213,3 +213,15 @@ export type Station = Partial<GeoInfo> &
|
|
|
213
213
|
// };
|
|
214
214
|
[key: string]: any;
|
|
215
215
|
};
|
|
216
|
+
|
|
217
|
+
/** Vehicle as returned by the available vehicles endpoint. */
|
|
218
|
+
export type Vehicle = {
|
|
219
|
+
vehicleId: string;
|
|
220
|
+
[key: string]: unknown;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/** Response of the subscription stations vehicles/available endpoint. */
|
|
224
|
+
export type AvailableVehiclesResponse = {
|
|
225
|
+
stationId: string;
|
|
226
|
+
vehicles: Vehicle[];
|
|
227
|
+
};
|