@vulog/aima-booking 1.2.38 → 1.2.40

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 CHANGED
@@ -1,30 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
- //#endregion
24
2
  let _vulog_aima_core = require("@vulog/aima-core");
25
3
  let es_toolkit_compat = require("es-toolkit/compat");
26
4
  let zod = require("zod");
27
- zod = __toESM(zod);
28
5
  //#region src/getBookingRequests.ts
29
6
  const BookingRequestStatusSchema = zod.z.enum([
30
7
  "ALERT",
@@ -71,7 +48,7 @@ const getBookingRequests = async (client, status, options) => {
71
48
  precision: 0
72
49
  }).default(endDate),
73
50
  includeProducts: zod.z.enum(["true", "false"]).optional()
74
- }).default({})).default({}).safeParse(preparedOptions);
51
+ }).default({})).safeParse(preparedOptions ?? {});
75
52
  if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
76
53
  const finalOptions = resultOptions.data;
77
54
  const searchParams = new URLSearchParams();
@@ -134,7 +111,7 @@ const SATBookingRequestStatusSchema = zod.z.enum([
134
111
  const getSATBookingRequests = async (client, status, options) => {
135
112
  const resultStatus = SATBookingRequestStatusSchema.safeParse(status);
136
113
  if (!resultStatus.success) throw new TypeError("Invalid status", { cause: resultStatus.error.issues });
137
- const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().default({}).safeParse(options);
114
+ const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().safeParse(options ?? {});
138
115
  if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
139
116
  const finalOptions = resultOptions.data;
140
117
  const searchParams = new URLSearchParams();
@@ -327,10 +304,10 @@ const getStationById = async (client, id, includes = []) => {
327
304
  };
328
305
  //#endregion
329
306
  //#region src/allocateVehicle.ts
330
- const allocateVehicleSchema = zod.default.object({
331
- bookingRequestId: zod.default.string().uuid(),
332
- vehicleId: zod.default.string().uuid(),
333
- serviceId: zod.default.string().uuid()
307
+ const allocateVehicleSchema = zod.z.object({
308
+ bookingRequestId: zod.z.string().uuid(),
309
+ vehicleId: zod.z.string().uuid(),
310
+ serviceId: zod.z.string().uuid()
334
311
  });
335
312
  const allocateVehicle = async (client, bookingRequestId, vehicleId, serviceId) => {
336
313
  const resultPayload = allocateVehicleSchema.safeParse({
@@ -343,9 +320,9 @@ const allocateVehicle = async (client, bookingRequestId, vehicleId, serviceId) =
343
320
  };
344
321
  //#endregion
345
322
  //#region src/deallocateVehicle.ts
346
- const deallocateVehicleSchema = zod.default.object({
347
- bookingRequestId: zod.default.string().uuid(),
348
- vehicleId: zod.default.string().uuid()
323
+ const deallocateVehicleSchema = zod.z.object({
324
+ bookingRequestId: zod.z.string().uuid(),
325
+ vehicleId: zod.z.string().uuid()
349
326
  });
350
327
  const deallocateVehicle = async (client, bookingRequestId, vehicleId) => {
351
328
  const resultPayload = deallocateVehicleSchema.safeParse({
@@ -357,26 +334,26 @@ const deallocateVehicle = async (client, bookingRequestId, vehicleId) => {
357
334
  };
358
335
  //#endregion
359
336
  //#region src/updateScheduleBooking.ts
360
- const schema$7 = zod.default.object({
361
- id: zod.default.string(),
362
- startDate: zod.default.string().refine((date) => !Number.isNaN(Date.parse(date)), { message: "Invalid date" }).optional(),
363
- latitude: zod.default.number().min(-90).max(90).optional(),
364
- longitude: zod.default.number().min(-180).max(180).optional(),
365
- radius: zod.default.number().min(0).optional(),
366
- userId: zod.default.string().optional(),
367
- status: zod.default.enum([
337
+ const schema$7 = zod.z.object({
338
+ id: zod.z.string(),
339
+ startDate: zod.z.string().refine((date) => !Number.isNaN(Date.parse(date)), { message: "Invalid date" }).optional(),
340
+ latitude: zod.z.number().min(-90).max(90).optional(),
341
+ longitude: zod.z.number().min(-180).max(180).optional(),
342
+ radius: zod.z.number().min(0).optional(),
343
+ userId: zod.z.string().optional(),
344
+ status: zod.z.enum([
368
345
  "CONFIRMED",
369
346
  "CANCELLED",
370
347
  "PENDING"
371
348
  ]).optional(),
372
- cityId: zod.default.string().optional(),
373
- profileId: zod.default.string().optional(),
374
- serviceId: zod.default.string().optional(),
375
- warning: zod.default.string().optional(),
376
- modelId: zod.default.number().optional(),
377
- notes: zod.default.string().optional(),
378
- bookingReferenceId: zod.default.string().optional(),
379
- plannedReturnDate: zod.default.string().refine((date) => !Number.isNaN(Date.parse(date)), { message: "Invalid date" }).optional()
349
+ cityId: zod.z.string().optional(),
350
+ profileId: zod.z.string().optional(),
351
+ serviceId: zod.z.string().optional(),
352
+ warning: zod.z.string().optional(),
353
+ modelId: zod.z.number().optional(),
354
+ notes: zod.z.string().optional(),
355
+ bookingReferenceId: zod.z.string().optional(),
356
+ plannedReturnDate: zod.z.string().refine((date) => !Number.isNaN(Date.parse(date)), { message: "Invalid date" }).optional()
380
357
  });
381
358
  const updateScheduleBooking = async (client, bookingRequestId, updateData) => {
382
359
  const result = schema$7.safeParse({
@@ -388,19 +365,19 @@ const updateScheduleBooking = async (client, bookingRequestId, updateData) => {
388
365
  };
389
366
  //#endregion
390
367
  //#region src/triggerBRPayment.ts
391
- const triggerBRPaymentSchema = zod.default.object({
392
- bookingRequestId: zod.default.string().uuid(),
393
- body: zod.default.object({
394
- scope: zod.default.enum(["RENTAL", "DEPOSIT"]),
395
- requiresActionReturnURL: zod.default.string().url().optional(),
396
- online: zod.default.boolean(),
397
- amountType: zod.default.enum(["FIXED", "PERCENTAGE"]),
398
- amountValue: zod.default.number().nonnegative(),
399
- preferredPaymentMethods: zod.default.array(zod.default.object({
400
- pspReference: zod.default.string(),
401
- amount: zod.default.number().default(0)
368
+ const triggerBRPaymentSchema = zod.z.object({
369
+ bookingRequestId: zod.z.string().uuid(),
370
+ body: zod.z.object({
371
+ scope: zod.z.enum(["RENTAL", "DEPOSIT"]),
372
+ requiresActionReturnURL: zod.z.string().url().optional(),
373
+ online: zod.z.boolean(),
374
+ amountType: zod.z.enum(["FIXED", "PERCENTAGE"]),
375
+ amountValue: zod.z.number().nonnegative(),
376
+ preferredPaymentMethods: zod.z.array(zod.z.object({
377
+ pspReference: zod.z.string(),
378
+ amount: zod.z.number().default(0)
402
379
  })).optional(),
403
- profileId: zod.default.string().uuid()
380
+ profileId: zod.z.string().uuid()
404
381
  })
405
382
  });
406
383
  const triggerBRPayment = async (client, bookingRequestId, body) => {
@@ -426,9 +403,9 @@ const getBookingRequestsByUserId = async (client, userId) => {
426
403
  };
427
404
  //#endregion
428
405
  //#region src/releaseBRPayment.ts
429
- const releaseBRPaymentSchema = zod.default.object({
430
- bookingRequestId: zod.default.string().uuid(),
431
- pspReference: zod.default.string().uuid()
406
+ const releaseBRPaymentSchema = zod.z.object({
407
+ bookingRequestId: zod.z.string().uuid(),
408
+ pspReference: zod.z.string().uuid()
432
409
  });
433
410
  const releaseBRPayment = async (client, bookingRequestId, pspReference) => {
434
411
  const resultPayload = releaseBRPaymentSchema.safeParse({
@@ -442,7 +419,7 @@ const releaseBRPayment = async (client, bookingRequestId, pspReference) => {
442
419
  };
443
420
  //#endregion
444
421
  //#region src/cancelBookingRequest.ts
445
- const schema$5 = zod.default.object({ id: zod.default.string().uuid() });
422
+ const schema$5 = zod.z.object({ id: zod.z.string().uuid() });
446
423
  const cancelBookingRequest = async (client, id) => {
447
424
  const result = schema$5.safeParse({ id });
448
425
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Client } from "@vulog/aima-client";
2
2
  import { PaginableOptions, PaginableResponse } from "@vulog/aima-core";
3
- import z$1, { z } from "zod";
3
+ import { z } from "zod";
4
4
  import { UUID } from "crypto";
5
5
 
6
6
  //#region src/types.d.ts
@@ -319,9 +319,23 @@ type BookingRequestSlave = {
319
319
  };
320
320
  //#endregion
321
321
  //#region src/getBookingRequests.d.ts
322
- declare const BookingRequestStatusSchema: z.ZodEnum<["ALERT", "UPCOMING", "ONGOING", "COMPLETED", "CANCELLED", "PENDING_APPROVAL", "CONFIRMED", "PENDING", "LATE"]>;
322
+ declare const BookingRequestStatusSchema: z.ZodEnum<{
323
+ ALERT: "ALERT";
324
+ UPCOMING: "UPCOMING";
325
+ ONGOING: "ONGOING";
326
+ COMPLETED: "COMPLETED";
327
+ CANCELLED: "CANCELLED";
328
+ PENDING_APPROVAL: "PENDING_APPROVAL";
329
+ CONFIRMED: "CONFIRMED";
330
+ PENDING: "PENDING";
331
+ LATE: "LATE";
332
+ }>;
323
333
  type BookingRequestStatus = z.infer<typeof BookingRequestStatusSchema>;
324
- declare const ServiceTypeSchema: z.ZodEnum<["SUBSCRIPTION", "ROUND_TRIP_BOOKING", "SCHEDULED_BOOKING_STATION"]>;
334
+ declare const ServiceTypeSchema: z.ZodEnum<{
335
+ SUBSCRIPTION: "SUBSCRIPTION";
336
+ ROUND_TRIP_BOOKING: "ROUND_TRIP_BOOKING";
337
+ SCHEDULED_BOOKING_STATION: "SCHEDULED_BOOKING_STATION";
338
+ }>;
325
339
  type ServiceType = z.infer<typeof ServiceTypeSchema>;
326
340
  type SpecificBookingRequestFilters = {
327
341
  serviceIds?: string[];
@@ -353,7 +367,18 @@ declare const getScheduleBookingRequests: (client: Client, status: BookingReques
353
367
  declare const getSubscriptionBookingRequests: (client: Client, status: BookingRequestStatus, options?: PaginableOptions<SpecificBookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>;
354
368
  //#endregion
355
369
  //#region src/getSATBookingRequests.d.ts
356
- declare const SATBookingRequestStatusSchema: z.ZodEnum<["ALERT", "CANCELLED", "COMPLETED", "CONFIRMED", "LATE_RETURN", "ONGOING", "PENDING_PAYMENT", "PENDING", "UPCOMING_ALLOCATED", "UPCOMING_NOT_ALLOCATED"]>;
370
+ declare const SATBookingRequestStatusSchema: z.ZodEnum<{
371
+ ALERT: "ALERT";
372
+ ONGOING: "ONGOING";
373
+ COMPLETED: "COMPLETED";
374
+ CANCELLED: "CANCELLED";
375
+ CONFIRMED: "CONFIRMED";
376
+ PENDING: "PENDING";
377
+ LATE_RETURN: "LATE_RETURN";
378
+ PENDING_PAYMENT: "PENDING_PAYMENT";
379
+ UPCOMING_ALLOCATED: "UPCOMING_ALLOCATED";
380
+ UPCOMING_NOT_ALLOCATED: "UPCOMING_NOT_ALLOCATED";
381
+ }>;
357
382
  type SATBookingRequestStatus = z.infer<typeof SATBookingRequestStatusSchema>;
358
383
  declare const getSATBookingRequests: (client: Client, status: SATBookingRequestStatus, options?: PaginableOptions<void, keyof SATBookingRequest>) => Promise<PaginableResponse<SATBookingRequest>>;
359
384
  //#endregion
@@ -367,12 +392,19 @@ declare const getScheduledBookingById: (client: Client, bookingId: string) => Pr
367
392
  declare const getAvailableVehicles: (client: Client, stationId: string, startDate: string) => Promise<AvailableVehiclesResponse>;
368
393
  //#endregion
369
394
  //#region src/getStations.d.ts
370
- declare const IncludeSchema$1: z.ZodEnum<["INFO", "OPEN_HOUR", "SERVICES"]>;
395
+ declare const IncludeSchema$1: z.ZodEnum<{
396
+ INFO: "INFO";
397
+ OPEN_HOUR: "OPEN_HOUR";
398
+ SERVICES: "SERVICES";
399
+ }>;
371
400
  type Include = z.infer<typeof IncludeSchema$1>;
372
401
  declare const getStations: (client: Client, includes?: Include[]) => Promise<Station[]>;
373
402
  //#endregion
374
403
  //#region src/getStation.d.ts
375
- declare const IncludeSchema: z.ZodEnum<["INFO", "SERVICES"]>;
404
+ declare const IncludeSchema: z.ZodEnum<{
405
+ INFO: "INFO";
406
+ SERVICES: "SERVICES";
407
+ }>;
376
408
  type IncludeStation = z.infer<typeof IncludeSchema>;
377
409
  declare const getStationById: (client: Client, id: string, includes?: IncludeStation[]) => Promise<Station | null>;
378
410
  //#endregion
@@ -386,78 +418,28 @@ declare const deallocateVehicle: (client: Client, bookingRequestId: UUID, vehicl
386
418
  declare const updateScheduleBooking: (client: Client, bookingRequestId: string, updateData: Record<string, unknown>) => Promise<SATBookingRequest>;
387
419
  //#endregion
388
420
  //#region src/triggerBRPayment.d.ts
389
- declare const triggerBRPaymentSchema: z$1.ZodObject<{
390
- bookingRequestId: z$1.ZodString;
391
- body: z$1.ZodObject<{
392
- scope: z$1.ZodEnum<["RENTAL", "DEPOSIT"]>;
393
- requiresActionReturnURL: z$1.ZodOptional<z$1.ZodString>;
394
- online: z$1.ZodBoolean;
395
- amountType: z$1.ZodEnum<["FIXED", "PERCENTAGE"]>;
396
- amountValue: z$1.ZodNumber;
397
- preferredPaymentMethods: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
398
- pspReference: z$1.ZodString;
399
- amount: z$1.ZodDefault<z$1.ZodNumber>;
400
- }, "strip", z$1.ZodTypeAny, {
401
- pspReference: string;
402
- amount: number;
403
- }, {
404
- pspReference: string;
405
- amount?: number | undefined;
406
- }>, "many">>;
407
- profileId: z$1.ZodString;
408
- }, "strip", z$1.ZodTypeAny, {
409
- profileId: string;
410
- scope: "RENTAL" | "DEPOSIT";
411
- online: boolean;
412
- amountType: "FIXED" | "PERCENTAGE";
413
- amountValue: number;
414
- requiresActionReturnURL?: string | undefined;
415
- preferredPaymentMethods?: {
416
- pspReference: string;
417
- amount: number;
418
- }[] | undefined;
419
- }, {
420
- profileId: string;
421
- scope: "RENTAL" | "DEPOSIT";
422
- online: boolean;
423
- amountType: "FIXED" | "PERCENTAGE";
424
- amountValue: number;
425
- requiresActionReturnURL?: string | undefined;
426
- preferredPaymentMethods?: {
427
- pspReference: string;
428
- amount?: number | undefined;
429
- }[] | undefined;
430
- }>;
431
- }, "strip", z$1.ZodTypeAny, {
432
- bookingRequestId: string;
433
- body: {
434
- profileId: string;
435
- scope: "RENTAL" | "DEPOSIT";
436
- online: boolean;
437
- amountType: "FIXED" | "PERCENTAGE";
438
- amountValue: number;
439
- requiresActionReturnURL?: string | undefined;
440
- preferredPaymentMethods?: {
441
- pspReference: string;
442
- amount: number;
443
- }[] | undefined;
444
- };
445
- }, {
446
- bookingRequestId: string;
447
- body: {
448
- profileId: string;
449
- scope: "RENTAL" | "DEPOSIT";
450
- online: boolean;
451
- amountType: "FIXED" | "PERCENTAGE";
452
- amountValue: number;
453
- requiresActionReturnURL?: string | undefined;
454
- preferredPaymentMethods?: {
455
- pspReference: string;
456
- amount?: number | undefined;
457
- }[] | undefined;
458
- };
459
- }>;
460
- declare const triggerBRPayment: (client: Client, bookingRequestId: UUID, body: z$1.infer<typeof triggerBRPaymentSchema>["body"]) => Promise<TriggerBRPaymentResponse>;
421
+ declare const triggerBRPaymentSchema: z.ZodObject<{
422
+ bookingRequestId: z.ZodString;
423
+ body: z.ZodObject<{
424
+ scope: z.ZodEnum<{
425
+ RENTAL: "RENTAL";
426
+ DEPOSIT: "DEPOSIT";
427
+ }>;
428
+ requiresActionReturnURL: z.ZodOptional<z.ZodString>;
429
+ online: z.ZodBoolean;
430
+ amountType: z.ZodEnum<{
431
+ FIXED: "FIXED";
432
+ PERCENTAGE: "PERCENTAGE";
433
+ }>;
434
+ amountValue: z.ZodNumber;
435
+ preferredPaymentMethods: z.ZodOptional<z.ZodArray<z.ZodObject<{
436
+ pspReference: z.ZodString;
437
+ amount: z.ZodDefault<z.ZodNumber>;
438
+ }, z.core.$strip>>>;
439
+ profileId: z.ZodString;
440
+ }, z.core.$strip>;
441
+ }, z.core.$strip>;
442
+ declare const triggerBRPayment: (client: Client, bookingRequestId: UUID, body: z.infer<typeof triggerBRPaymentSchema>["body"]) => Promise<TriggerBRPaymentResponse>;
461
443
  //#endregion
462
444
  //#region src/getBookingRequestsByUserId.d.ts
463
445
  declare const getBookingRequestsByUserId: (client: Client, userId: string) => Promise<BookingRequest[]>;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PaginableOptions, PaginableResponse } from "@vulog/aima-core";
2
- import z$1, { z } from "zod";
2
+ import { z } from "zod";
3
3
  import { Client } from "@vulog/aima-client";
4
4
  import { UUID } from "crypto";
5
5
 
@@ -319,9 +319,23 @@ type BookingRequestSlave = {
319
319
  };
320
320
  //#endregion
321
321
  //#region src/getBookingRequests.d.ts
322
- declare const BookingRequestStatusSchema: z.ZodEnum<["ALERT", "UPCOMING", "ONGOING", "COMPLETED", "CANCELLED", "PENDING_APPROVAL", "CONFIRMED", "PENDING", "LATE"]>;
322
+ declare const BookingRequestStatusSchema: z.ZodEnum<{
323
+ ALERT: "ALERT";
324
+ UPCOMING: "UPCOMING";
325
+ ONGOING: "ONGOING";
326
+ COMPLETED: "COMPLETED";
327
+ CANCELLED: "CANCELLED";
328
+ PENDING_APPROVAL: "PENDING_APPROVAL";
329
+ CONFIRMED: "CONFIRMED";
330
+ PENDING: "PENDING";
331
+ LATE: "LATE";
332
+ }>;
323
333
  type BookingRequestStatus = z.infer<typeof BookingRequestStatusSchema>;
324
- declare const ServiceTypeSchema: z.ZodEnum<["SUBSCRIPTION", "ROUND_TRIP_BOOKING", "SCHEDULED_BOOKING_STATION"]>;
334
+ declare const ServiceTypeSchema: z.ZodEnum<{
335
+ SUBSCRIPTION: "SUBSCRIPTION";
336
+ ROUND_TRIP_BOOKING: "ROUND_TRIP_BOOKING";
337
+ SCHEDULED_BOOKING_STATION: "SCHEDULED_BOOKING_STATION";
338
+ }>;
325
339
  type ServiceType = z.infer<typeof ServiceTypeSchema>;
326
340
  type SpecificBookingRequestFilters = {
327
341
  serviceIds?: string[];
@@ -353,7 +367,18 @@ declare const getScheduleBookingRequests: (client: Client, status: BookingReques
353
367
  declare const getSubscriptionBookingRequests: (client: Client, status: BookingRequestStatus, options?: PaginableOptions<SpecificBookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>;
354
368
  //#endregion
355
369
  //#region src/getSATBookingRequests.d.ts
356
- declare const SATBookingRequestStatusSchema: z.ZodEnum<["ALERT", "CANCELLED", "COMPLETED", "CONFIRMED", "LATE_RETURN", "ONGOING", "PENDING_PAYMENT", "PENDING", "UPCOMING_ALLOCATED", "UPCOMING_NOT_ALLOCATED"]>;
370
+ declare const SATBookingRequestStatusSchema: z.ZodEnum<{
371
+ ALERT: "ALERT";
372
+ ONGOING: "ONGOING";
373
+ COMPLETED: "COMPLETED";
374
+ CANCELLED: "CANCELLED";
375
+ CONFIRMED: "CONFIRMED";
376
+ PENDING: "PENDING";
377
+ LATE_RETURN: "LATE_RETURN";
378
+ PENDING_PAYMENT: "PENDING_PAYMENT";
379
+ UPCOMING_ALLOCATED: "UPCOMING_ALLOCATED";
380
+ UPCOMING_NOT_ALLOCATED: "UPCOMING_NOT_ALLOCATED";
381
+ }>;
357
382
  type SATBookingRequestStatus = z.infer<typeof SATBookingRequestStatusSchema>;
358
383
  declare const getSATBookingRequests: (client: Client, status: SATBookingRequestStatus, options?: PaginableOptions<void, keyof SATBookingRequest>) => Promise<PaginableResponse<SATBookingRequest>>;
359
384
  //#endregion
@@ -367,12 +392,19 @@ declare const getScheduledBookingById: (client: Client, bookingId: string) => Pr
367
392
  declare const getAvailableVehicles: (client: Client, stationId: string, startDate: string) => Promise<AvailableVehiclesResponse>;
368
393
  //#endregion
369
394
  //#region src/getStations.d.ts
370
- declare const IncludeSchema$1: z.ZodEnum<["INFO", "OPEN_HOUR", "SERVICES"]>;
395
+ declare const IncludeSchema$1: z.ZodEnum<{
396
+ INFO: "INFO";
397
+ OPEN_HOUR: "OPEN_HOUR";
398
+ SERVICES: "SERVICES";
399
+ }>;
371
400
  type Include = z.infer<typeof IncludeSchema$1>;
372
401
  declare const getStations: (client: Client, includes?: Include[]) => Promise<Station[]>;
373
402
  //#endregion
374
403
  //#region src/getStation.d.ts
375
- declare const IncludeSchema: z.ZodEnum<["INFO", "SERVICES"]>;
404
+ declare const IncludeSchema: z.ZodEnum<{
405
+ INFO: "INFO";
406
+ SERVICES: "SERVICES";
407
+ }>;
376
408
  type IncludeStation = z.infer<typeof IncludeSchema>;
377
409
  declare const getStationById: (client: Client, id: string, includes?: IncludeStation[]) => Promise<Station | null>;
378
410
  //#endregion
@@ -386,78 +418,28 @@ declare const deallocateVehicle: (client: Client, bookingRequestId: UUID, vehicl
386
418
  declare const updateScheduleBooking: (client: Client, bookingRequestId: string, updateData: Record<string, unknown>) => Promise<SATBookingRequest>;
387
419
  //#endregion
388
420
  //#region src/triggerBRPayment.d.ts
389
- declare const triggerBRPaymentSchema: z$1.ZodObject<{
390
- bookingRequestId: z$1.ZodString;
391
- body: z$1.ZodObject<{
392
- scope: z$1.ZodEnum<["RENTAL", "DEPOSIT"]>;
393
- requiresActionReturnURL: z$1.ZodOptional<z$1.ZodString>;
394
- online: z$1.ZodBoolean;
395
- amountType: z$1.ZodEnum<["FIXED", "PERCENTAGE"]>;
396
- amountValue: z$1.ZodNumber;
397
- preferredPaymentMethods: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
398
- pspReference: z$1.ZodString;
399
- amount: z$1.ZodDefault<z$1.ZodNumber>;
400
- }, "strip", z$1.ZodTypeAny, {
401
- pspReference: string;
402
- amount: number;
403
- }, {
404
- pspReference: string;
405
- amount?: number | undefined;
406
- }>, "many">>;
407
- profileId: z$1.ZodString;
408
- }, "strip", z$1.ZodTypeAny, {
409
- profileId: string;
410
- scope: "RENTAL" | "DEPOSIT";
411
- online: boolean;
412
- amountType: "FIXED" | "PERCENTAGE";
413
- amountValue: number;
414
- requiresActionReturnURL?: string | undefined;
415
- preferredPaymentMethods?: {
416
- pspReference: string;
417
- amount: number;
418
- }[] | undefined;
419
- }, {
420
- profileId: string;
421
- scope: "RENTAL" | "DEPOSIT";
422
- online: boolean;
423
- amountType: "FIXED" | "PERCENTAGE";
424
- amountValue: number;
425
- requiresActionReturnURL?: string | undefined;
426
- preferredPaymentMethods?: {
427
- pspReference: string;
428
- amount?: number | undefined;
429
- }[] | undefined;
430
- }>;
431
- }, "strip", z$1.ZodTypeAny, {
432
- bookingRequestId: string;
433
- body: {
434
- profileId: string;
435
- scope: "RENTAL" | "DEPOSIT";
436
- online: boolean;
437
- amountType: "FIXED" | "PERCENTAGE";
438
- amountValue: number;
439
- requiresActionReturnURL?: string | undefined;
440
- preferredPaymentMethods?: {
441
- pspReference: string;
442
- amount: number;
443
- }[] | undefined;
444
- };
445
- }, {
446
- bookingRequestId: string;
447
- body: {
448
- profileId: string;
449
- scope: "RENTAL" | "DEPOSIT";
450
- online: boolean;
451
- amountType: "FIXED" | "PERCENTAGE";
452
- amountValue: number;
453
- requiresActionReturnURL?: string | undefined;
454
- preferredPaymentMethods?: {
455
- pspReference: string;
456
- amount?: number | undefined;
457
- }[] | undefined;
458
- };
459
- }>;
460
- declare const triggerBRPayment: (client: Client, bookingRequestId: UUID, body: z$1.infer<typeof triggerBRPaymentSchema>["body"]) => Promise<TriggerBRPaymentResponse>;
421
+ declare const triggerBRPaymentSchema: z.ZodObject<{
422
+ bookingRequestId: z.ZodString;
423
+ body: z.ZodObject<{
424
+ scope: z.ZodEnum<{
425
+ RENTAL: "RENTAL";
426
+ DEPOSIT: "DEPOSIT";
427
+ }>;
428
+ requiresActionReturnURL: z.ZodOptional<z.ZodString>;
429
+ online: z.ZodBoolean;
430
+ amountType: z.ZodEnum<{
431
+ FIXED: "FIXED";
432
+ PERCENTAGE: "PERCENTAGE";
433
+ }>;
434
+ amountValue: z.ZodNumber;
435
+ preferredPaymentMethods: z.ZodOptional<z.ZodArray<z.ZodObject<{
436
+ pspReference: z.ZodString;
437
+ amount: z.ZodDefault<z.ZodNumber>;
438
+ }, z.core.$strip>>>;
439
+ profileId: z.ZodString;
440
+ }, z.core.$strip>;
441
+ }, z.core.$strip>;
442
+ declare const triggerBRPayment: (client: Client, bookingRequestId: UUID, body: z.infer<typeof triggerBRPaymentSchema>["body"]) => Promise<TriggerBRPaymentResponse>;
461
443
  //#endregion
462
444
  //#region src/getBookingRequestsByUserId.d.ts
463
445
  declare const getBookingRequestsByUserId: (client: Client, userId: string) => Promise<BookingRequest[]>;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createPaginableOptionsSchema } from "@vulog/aima-core";
2
2
  import { isNumber } from "es-toolkit/compat";
3
- import z$1, { z } from "zod";
3
+ import { z } from "zod";
4
4
  //#region src/getBookingRequests.ts
5
5
  const BookingRequestStatusSchema = z.enum([
6
6
  "ALERT",
@@ -47,7 +47,7 @@ const getBookingRequests = async (client, status, options) => {
47
47
  precision: 0
48
48
  }).default(endDate),
49
49
  includeProducts: z.enum(["true", "false"]).optional()
50
- }).default({})).default({}).safeParse(preparedOptions);
50
+ }).default({})).safeParse(preparedOptions ?? {});
51
51
  if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
52
52
  const finalOptions = resultOptions.data;
53
53
  const searchParams = new URLSearchParams();
@@ -110,7 +110,7 @@ const SATBookingRequestStatusSchema = z.enum([
110
110
  const getSATBookingRequests = async (client, status, options) => {
111
111
  const resultStatus = SATBookingRequestStatusSchema.safeParse(status);
112
112
  if (!resultStatus.success) throw new TypeError("Invalid status", { cause: resultStatus.error.issues });
113
- const resultOptions = createPaginableOptionsSchema().default({}).safeParse(options);
113
+ const resultOptions = createPaginableOptionsSchema().safeParse(options ?? {});
114
114
  if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
115
115
  const finalOptions = resultOptions.data;
116
116
  const searchParams = new URLSearchParams();
@@ -303,10 +303,10 @@ const getStationById = async (client, id, includes = []) => {
303
303
  };
304
304
  //#endregion
305
305
  //#region src/allocateVehicle.ts
306
- const allocateVehicleSchema = z$1.object({
307
- bookingRequestId: z$1.string().uuid(),
308
- vehicleId: z$1.string().uuid(),
309
- serviceId: z$1.string().uuid()
306
+ const allocateVehicleSchema = z.object({
307
+ bookingRequestId: z.string().uuid(),
308
+ vehicleId: z.string().uuid(),
309
+ serviceId: z.string().uuid()
310
310
  });
311
311
  const allocateVehicle = async (client, bookingRequestId, vehicleId, serviceId) => {
312
312
  const resultPayload = allocateVehicleSchema.safeParse({
@@ -319,9 +319,9 @@ const allocateVehicle = async (client, bookingRequestId, vehicleId, serviceId) =
319
319
  };
320
320
  //#endregion
321
321
  //#region src/deallocateVehicle.ts
322
- const deallocateVehicleSchema = z$1.object({
323
- bookingRequestId: z$1.string().uuid(),
324
- vehicleId: z$1.string().uuid()
322
+ const deallocateVehicleSchema = z.object({
323
+ bookingRequestId: z.string().uuid(),
324
+ vehicleId: z.string().uuid()
325
325
  });
326
326
  const deallocateVehicle = async (client, bookingRequestId, vehicleId) => {
327
327
  const resultPayload = deallocateVehicleSchema.safeParse({
@@ -333,26 +333,26 @@ const deallocateVehicle = async (client, bookingRequestId, vehicleId) => {
333
333
  };
334
334
  //#endregion
335
335
  //#region src/updateScheduleBooking.ts
336
- const schema$7 = z$1.object({
337
- id: z$1.string(),
338
- startDate: z$1.string().refine((date) => !Number.isNaN(Date.parse(date)), { message: "Invalid date" }).optional(),
339
- latitude: z$1.number().min(-90).max(90).optional(),
340
- longitude: z$1.number().min(-180).max(180).optional(),
341
- radius: z$1.number().min(0).optional(),
342
- userId: z$1.string().optional(),
343
- status: z$1.enum([
336
+ const schema$7 = z.object({
337
+ id: z.string(),
338
+ startDate: z.string().refine((date) => !Number.isNaN(Date.parse(date)), { message: "Invalid date" }).optional(),
339
+ latitude: z.number().min(-90).max(90).optional(),
340
+ longitude: z.number().min(-180).max(180).optional(),
341
+ radius: z.number().min(0).optional(),
342
+ userId: z.string().optional(),
343
+ status: z.enum([
344
344
  "CONFIRMED",
345
345
  "CANCELLED",
346
346
  "PENDING"
347
347
  ]).optional(),
348
- cityId: z$1.string().optional(),
349
- profileId: z$1.string().optional(),
350
- serviceId: z$1.string().optional(),
351
- warning: z$1.string().optional(),
352
- modelId: z$1.number().optional(),
353
- notes: z$1.string().optional(),
354
- bookingReferenceId: z$1.string().optional(),
355
- plannedReturnDate: z$1.string().refine((date) => !Number.isNaN(Date.parse(date)), { message: "Invalid date" }).optional()
348
+ cityId: z.string().optional(),
349
+ profileId: z.string().optional(),
350
+ serviceId: z.string().optional(),
351
+ warning: z.string().optional(),
352
+ modelId: z.number().optional(),
353
+ notes: z.string().optional(),
354
+ bookingReferenceId: z.string().optional(),
355
+ plannedReturnDate: z.string().refine((date) => !Number.isNaN(Date.parse(date)), { message: "Invalid date" }).optional()
356
356
  });
357
357
  const updateScheduleBooking = async (client, bookingRequestId, updateData) => {
358
358
  const result = schema$7.safeParse({
@@ -364,19 +364,19 @@ const updateScheduleBooking = async (client, bookingRequestId, updateData) => {
364
364
  };
365
365
  //#endregion
366
366
  //#region src/triggerBRPayment.ts
367
- const triggerBRPaymentSchema = z$1.object({
368
- bookingRequestId: z$1.string().uuid(),
369
- body: z$1.object({
370
- scope: z$1.enum(["RENTAL", "DEPOSIT"]),
371
- requiresActionReturnURL: z$1.string().url().optional(),
372
- online: z$1.boolean(),
373
- amountType: z$1.enum(["FIXED", "PERCENTAGE"]),
374
- amountValue: z$1.number().nonnegative(),
375
- preferredPaymentMethods: z$1.array(z$1.object({
376
- pspReference: z$1.string(),
377
- amount: z$1.number().default(0)
367
+ const triggerBRPaymentSchema = z.object({
368
+ bookingRequestId: z.string().uuid(),
369
+ body: z.object({
370
+ scope: z.enum(["RENTAL", "DEPOSIT"]),
371
+ requiresActionReturnURL: z.string().url().optional(),
372
+ online: z.boolean(),
373
+ amountType: z.enum(["FIXED", "PERCENTAGE"]),
374
+ amountValue: z.number().nonnegative(),
375
+ preferredPaymentMethods: z.array(z.object({
376
+ pspReference: z.string(),
377
+ amount: z.number().default(0)
378
378
  })).optional(),
379
- profileId: z$1.string().uuid()
379
+ profileId: z.string().uuid()
380
380
  })
381
381
  });
382
382
  const triggerBRPayment = async (client, bookingRequestId, body) => {
@@ -402,9 +402,9 @@ const getBookingRequestsByUserId = async (client, userId) => {
402
402
  };
403
403
  //#endregion
404
404
  //#region src/releaseBRPayment.ts
405
- const releaseBRPaymentSchema = z$1.object({
406
- bookingRequestId: z$1.string().uuid(),
407
- pspReference: z$1.string().uuid()
405
+ const releaseBRPaymentSchema = z.object({
406
+ bookingRequestId: z.string().uuid(),
407
+ pspReference: z.string().uuid()
408
408
  });
409
409
  const releaseBRPayment = async (client, bookingRequestId, pspReference) => {
410
410
  const resultPayload = releaseBRPaymentSchema.safeParse({
@@ -418,7 +418,7 @@ const releaseBRPayment = async (client, bookingRequestId, pspReference) => {
418
418
  };
419
419
  //#endregion
420
420
  //#region src/cancelBookingRequest.ts
421
- const schema$5 = z$1.object({ id: z$1.string().uuid() });
421
+ const schema$5 = z.object({ id: z.string().uuid() });
422
422
  const cancelBookingRequest = async (client, id) => {
423
423
  const result = schema$5.safeParse({ id });
424
424
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vulog/aima-booking",
3
3
  "type": "module",
4
- "version": "1.2.38",
4
+ "version": "1.2.40",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.cts",
@@ -32,12 +32,12 @@
32
32
  "author": "Vulog",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@vulog/aima-client": "1.2.38",
36
- "@vulog/aima-core": "1.2.38"
35
+ "@vulog/aima-client": "1.2.40",
36
+ "@vulog/aima-core": "1.2.40"
37
37
  },
38
38
  "peerDependencies": {
39
- "es-toolkit": "^1.39.9",
40
- "zod": "^3.25.76"
39
+ "es-toolkit": "^1.45.1",
40
+ "zod": "^4.3.6"
41
41
  },
42
42
  "description": ""
43
- }
43
+ }
@@ -2,7 +2,7 @@ import { UUID } from 'crypto';
2
2
 
3
3
  import { Client } from '@vulog/aima-client';
4
4
 
5
- import z from 'zod';
5
+ import { z } from 'zod';
6
6
 
7
7
  import { SATBookingRequest } from './types';
8
8
 
@@ -1,5 +1,5 @@
1
1
  import { Client } from '@vulog/aima-client';
2
- import z from 'zod';
2
+ import { z } from 'zod';
3
3
 
4
4
  import { SATBookingRequest } from './types';
5
5
 
@@ -4,7 +4,7 @@ import { UUID } from 'crypto';
4
4
 
5
5
  import { Client } from '@vulog/aima-client';
6
6
 
7
- import z from 'zod';
7
+ import { z } from 'zod';
8
8
 
9
9
  import { SATBookingRequest } from './types';
10
10
 
@@ -26,10 +26,8 @@ describe('getBookingRequests', () => {
26
26
  await rejects.toSatisfy((error: any) => {
27
27
  expect(error).toHaveProperty('cause');
28
28
  expect(error.cause).toHaveLength(1);
29
- expect(error.cause[0]).toHaveProperty('received');
30
29
  expect(error.cause[0]).toHaveProperty('code');
31
- expect(error.cause[0].received).toBe('FAKE');
32
- expect(error.cause[0].code).toBe('invalid_enum_value');
30
+ expect(error.cause[0].code).toBe('invalid_value');
33
31
  return true;
34
32
  });
35
33
  });
@@ -80,9 +80,9 @@ export const getBookingRequests = async (
80
80
  })
81
81
  .default({});
82
82
 
83
- const PaginableOptionsSchema = createPaginableOptionsSchema(BookingRequestFiltersSchema).default({});
83
+ const PaginableOptionsSchema = createPaginableOptionsSchema(BookingRequestFiltersSchema);
84
84
 
85
- const resultOptions = PaginableOptionsSchema.safeParse(preparedOptions);
85
+ const resultOptions = PaginableOptionsSchema.safeParse(preparedOptions ?? {});
86
86
  if (!resultOptions.success) {
87
87
  throw new TypeError('Invalid options', {
88
88
  cause: resultOptions.error.issues,
@@ -33,7 +33,7 @@ describe('getBookingRequestsByUserId', () => {
33
33
  await rejects.toSatisfy((error: Error & { cause?: unknown }) => {
34
34
  expect(error).toHaveProperty('cause');
35
35
  const issues = error.cause as Array<{ code?: string }>;
36
- expect(issues?.some((e) => e.code === 'invalid_string')).toBe(true);
36
+ expect(issues?.some((e) => e.code === 'invalid_format')).toBe(true);
37
37
  return true;
38
38
  });
39
39
  });
@@ -26,10 +26,8 @@ describe('getSATBookingRequests', () => {
26
26
  await rejects.toSatisfy((error: any) => {
27
27
  expect(error).toHaveProperty('cause');
28
28
  expect(error.cause).toHaveLength(1);
29
- expect(error.cause[0]).toHaveProperty('received');
30
29
  expect(error.cause[0]).toHaveProperty('code');
31
- expect(error.cause[0].received).toBe('FAKE');
32
- expect(error.cause[0].code).toBe('invalid_enum_value');
30
+ expect(error.cause[0].code).toBe('invalid_value');
33
31
  return true;
34
32
  });
35
33
  });
@@ -31,9 +31,9 @@ export const getSATBookingRequests = async (
31
31
  });
32
32
  }
33
33
 
34
- const PaginableOptionsSchema = createPaginableOptionsSchema().default({});
34
+ const PaginableOptionsSchema = createPaginableOptionsSchema();
35
35
 
36
- const resultOptions = PaginableOptionsSchema.safeParse(options);
36
+ const resultOptions = PaginableOptionsSchema.safeParse(options ?? {});
37
37
  if (!resultOptions.success) {
38
38
  throw new TypeError('Invalid options', {
39
39
  cause: resultOptions.error.issues,
@@ -344,7 +344,7 @@ describe('getStationById', () => {
344
344
  expect(error).toHaveProperty('cause');
345
345
  expect(error.cause).toHaveLength(1);
346
346
  expect(error.cause[0]).toHaveProperty('code');
347
- expect(error.cause[0].code).toBe('invalid_enum_value');
347
+ expect(error.cause[0].code).toBe('invalid_value');
348
348
  return true;
349
349
  });
350
350
  });
@@ -39,10 +39,8 @@ describe('getStations', () => {
39
39
  await rejects.toSatisfy((error: any) => {
40
40
  expect(error).toHaveProperty('cause');
41
41
  expect(error.cause).toHaveLength(1);
42
- expect(error.cause[0]).toHaveProperty('received');
43
42
  expect(error.cause[0]).toHaveProperty('code');
44
- expect(error.cause[0].received).toBe('FAKE');
45
- expect(error.cause[0].code).toBe('invalid_enum_value');
43
+ expect(error.cause[0].code).toBe('invalid_value');
46
44
  return true;
47
45
  });
48
46
  });
@@ -4,7 +4,7 @@ import { UUID } from 'crypto';
4
4
 
5
5
  import { Client } from '@vulog/aima-client';
6
6
 
7
- import z from 'zod';
7
+ import { z } from 'zod';
8
8
 
9
9
  import { SATBookingRequest } from './types';
10
10
 
@@ -2,7 +2,7 @@ import { UUID } from 'crypto';
2
2
 
3
3
  import { Client } from '@vulog/aima-client';
4
4
 
5
- import z from 'zod';
5
+ import { z } from 'zod';
6
6
 
7
7
  import { TriggerBRPaymentResponse } from './types';
8
8
 
@@ -1,7 +1,7 @@
1
1
  // https://java-sta.vulog.com/boapi/proxy/user/scheduleATrip/fleets/LEO-CAMTR/bookingrequests/a8068642-d164-4a7f-b73b-a1019e919db3
2
2
 
3
3
  import { Client } from '@vulog/aima-client';
4
- import z from 'zod';
4
+ import { z } from 'zod';
5
5
 
6
6
  import { SATBookingRequest } from './types';
7
7
 
package/tsconfig.json CHANGED
@@ -1,15 +1,8 @@
1
1
  {
2
+ "extends": "../../tsconfig.base.json",
2
3
  "include": ["src"],
3
4
  "exclude": ["**/*.test.ts"],
4
5
  "compilerOptions": {
5
- "module": "esnext",
6
- "target": "esnext",
7
- "lib": ["esnext"],
8
- "declaration": true,
9
- "strict": true,
10
- "moduleResolution": "node",
11
- "skipLibCheck": true,
12
- "esModuleInterop": true,
13
6
  "outDir": "dist",
14
7
  "rootDir": "src"
15
8
  }
package/vitest.config.ts CHANGED
@@ -1,8 +1 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- globals: true,
6
- environment: 'node',
7
- },
8
- });
1
+ export { default } from '../../vitest.config.base.ts';