@vulog/aima-booking 1.1.74 → 1.1.75
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 +71 -35
- package/dist/index.d.ts +71 -35
- package/dist/index.js +65 -8
- package/dist/index.mjs +64 -8
- package/package.json +3 -3
- package/src/getBookingRequests.test.ts +15 -15
- package/src/getBookingRequests.ts +2 -1
- package/src/getSATBookingRequests.test.ts +174 -0
- package/src/getSATBookingRequests.ts +72 -0
- package/src/index.ts +2 -0
- package/src/types.ts +69 -37
package/dist/index.d.mts
CHANGED
|
@@ -25,52 +25,84 @@ type CustomPrice = {
|
|
|
25
25
|
reason: string;
|
|
26
26
|
pricingReferenceId: string | null;
|
|
27
27
|
};
|
|
28
|
-
type
|
|
29
|
-
|
|
30
|
-
startDate: string;
|
|
31
|
-
endDate: string;
|
|
32
|
-
returnedDate?: string;
|
|
33
|
-
profileId: string;
|
|
34
|
-
vehicleId?: string;
|
|
35
|
-
modelId: number;
|
|
36
|
-
journeyId?: string;
|
|
37
|
-
station: string;
|
|
38
|
-
profileType?: 'Single' | 'Business';
|
|
39
|
-
entityName?: string;
|
|
40
|
-
status: string;
|
|
41
|
-
creationDate: string;
|
|
42
|
-
realStartDate?: string;
|
|
43
|
-
cancellationDate?: string;
|
|
44
|
-
cancelledBy?: string;
|
|
45
|
-
fleetId: string;
|
|
46
|
-
userId: string;
|
|
47
|
-
serviceId: string;
|
|
48
|
-
warning?: string;
|
|
49
|
-
paymentReceipts?: PaymentReceipts[];
|
|
50
|
-
credit?: string;
|
|
28
|
+
type BaseBookingRequest = {
|
|
29
|
+
bookingReferenceId?: string;
|
|
51
30
|
cityId: string;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
completed: boolean;
|
|
32
|
+
contractType?: string;
|
|
33
|
+
creationDate: string;
|
|
34
|
+
customPrice: CustomPrice | null;
|
|
55
35
|
deliveryAddress?: string;
|
|
56
36
|
deliveryAddressAdditionalInfo?: string;
|
|
57
37
|
deliveryCity?: string;
|
|
58
38
|
deliveryPostalCode?: string;
|
|
59
39
|
dropOffStation?: string;
|
|
60
|
-
|
|
40
|
+
fleetId: string;
|
|
41
|
+
id: string;
|
|
42
|
+
notes?: string;
|
|
61
43
|
planDurationInMonths?: number;
|
|
62
|
-
|
|
63
|
-
customPrice: CustomPrice | null;
|
|
64
|
-
productIds: string[];
|
|
65
|
-
bookingReferenceId?: string;
|
|
44
|
+
plannedReturnDate?: string;
|
|
66
45
|
pricingDetails: {
|
|
67
46
|
pricingId: string;
|
|
68
47
|
providerType: string;
|
|
69
48
|
}[];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
productIds: string[];
|
|
50
|
+
profileId: string;
|
|
51
|
+
rollingContract: boolean;
|
|
52
|
+
serviceId: string;
|
|
53
|
+
startDate: string;
|
|
54
|
+
status: string;
|
|
55
|
+
userId: string;
|
|
56
|
+
};
|
|
57
|
+
type BookingRequest = BaseBookingRequest & {
|
|
73
58
|
[key: string]: any;
|
|
59
|
+
cancellationDate?: string;
|
|
60
|
+
cancelledBy?: string;
|
|
61
|
+
credit?: string;
|
|
62
|
+
endDate: string;
|
|
63
|
+
entityName?: string;
|
|
64
|
+
journeyId?: string;
|
|
65
|
+
modelId: number;
|
|
66
|
+
modelName?: string;
|
|
67
|
+
paymentReceipts?: PaymentReceipts[];
|
|
68
|
+
pricePerUnit?: string;
|
|
69
|
+
profileType?: 'Single' | 'Business';
|
|
70
|
+
realStartDate?: string;
|
|
71
|
+
returnedDate?: string;
|
|
72
|
+
station: string;
|
|
73
|
+
vehicleId?: string;
|
|
74
|
+
vehicleResidualValue?: number;
|
|
75
|
+
warning?: string;
|
|
76
|
+
};
|
|
77
|
+
type SATBookingRequest = BaseBookingRequest & {
|
|
78
|
+
cancellationDate: string | null;
|
|
79
|
+
cancelledBy: string | null;
|
|
80
|
+
endDate: string | null;
|
|
81
|
+
entityName: string | null;
|
|
82
|
+
journeyId: string | null;
|
|
83
|
+
modelId: number | null;
|
|
84
|
+
profileType: string | null;
|
|
85
|
+
realStartDate: string | null;
|
|
86
|
+
returnedDate: string | null;
|
|
87
|
+
station: string | null;
|
|
88
|
+
vehicleId: string | null;
|
|
89
|
+
cancellationFeeAmount: number | null;
|
|
90
|
+
credits: string | null;
|
|
91
|
+
earlyCancelledByUser: boolean;
|
|
92
|
+
email: string | null;
|
|
93
|
+
failureReason: string | null;
|
|
94
|
+
latitude: number;
|
|
95
|
+
longitude: number;
|
|
96
|
+
parentId: string | null;
|
|
97
|
+
planName: string | null;
|
|
98
|
+
preallocatedVehicleId: string | null;
|
|
99
|
+
previous: any | null;
|
|
100
|
+
price: any | null;
|
|
101
|
+
radius: number;
|
|
102
|
+
requiresActionReturnURL: string | null;
|
|
103
|
+
thresholdDateLimit: string | null;
|
|
104
|
+
trip: any | null;
|
|
105
|
+
warning: string | null;
|
|
74
106
|
};
|
|
75
107
|
|
|
76
108
|
declare const BookingRequestStatusSchema: z.ZodEnum<["ALERT", "UPCOMING", "ONGOING", "COMPLETED", "CANCELLED", "PENDING_APPROVAL"]>;
|
|
@@ -106,6 +138,10 @@ declare const getBookingRequests: (client: Client, status: BookingRequestStatus,
|
|
|
106
138
|
declare const getScheduleBookingRequests: (client: Client, status: BookingRequestStatus, options?: PaginableOptions<SpecificBookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>;
|
|
107
139
|
declare const getSubscriptionBookingRequests: (client: Client, status: BookingRequestStatus, options?: PaginableOptions<SpecificBookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>;
|
|
108
140
|
|
|
141
|
+
declare const SATBookingRequestStatusSchema: z.ZodEnum<["ALERT", "CANCELLED", "COMPLETED", "CONFIRMED", "LATE_RETURN", "ONGOING", "PENDING_PAYMENT", "PENDING", "UPCOMING_ALLOCATED", "UPCOMING_NOT_ALLOCATED"]>;
|
|
142
|
+
type SATBookingRequestStatus = z.infer<typeof SATBookingRequestStatusSchema>;
|
|
143
|
+
declare const getSATBookingRequests: (client: Client, status: SATBookingRequestStatus, options?: PaginableOptions<void, keyof SATBookingRequest>) => Promise<PaginableResponse<SATBookingRequest>>;
|
|
144
|
+
|
|
109
145
|
declare const getBookingRequestById: (client: Client, id: string) => Promise<BookingRequest>;
|
|
110
146
|
declare const getBookingRequestByTrip: (client: Client, tripId: string) => Promise<BookingRequest>;
|
|
111
147
|
declare const getSubscriptionBookingRequestById: (client: Client, id: string) => Promise<BookingRequest>;
|
|
@@ -155,4 +191,4 @@ type Station = Partial<GeoInfo> & Partial<ServiceInfo> & {
|
|
|
155
191
|
};
|
|
156
192
|
declare const getStations: (client: Client, includes?: Include[]) => Promise<Station[]>;
|
|
157
193
|
|
|
158
|
-
export { type BookingRequest, type BookingRequestFilters, type BookingRequestStatus, type DayOpeningHours, type Days, type Include, type OpeningHours, type ServiceType, type Station, type Timetable, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getScheduleBookingRequests, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests };
|
|
194
|
+
export { type BookingRequest, type BookingRequestFilters, type BookingRequestStatus, type DayOpeningHours, type Days, type Include, type OpeningHours, type SATBookingRequestStatus, type ServiceType, type Station, type Timetable, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getSATBookingRequests, getScheduleBookingRequests, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,52 +25,84 @@ type CustomPrice = {
|
|
|
25
25
|
reason: string;
|
|
26
26
|
pricingReferenceId: string | null;
|
|
27
27
|
};
|
|
28
|
-
type
|
|
29
|
-
|
|
30
|
-
startDate: string;
|
|
31
|
-
endDate: string;
|
|
32
|
-
returnedDate?: string;
|
|
33
|
-
profileId: string;
|
|
34
|
-
vehicleId?: string;
|
|
35
|
-
modelId: number;
|
|
36
|
-
journeyId?: string;
|
|
37
|
-
station: string;
|
|
38
|
-
profileType?: 'Single' | 'Business';
|
|
39
|
-
entityName?: string;
|
|
40
|
-
status: string;
|
|
41
|
-
creationDate: string;
|
|
42
|
-
realStartDate?: string;
|
|
43
|
-
cancellationDate?: string;
|
|
44
|
-
cancelledBy?: string;
|
|
45
|
-
fleetId: string;
|
|
46
|
-
userId: string;
|
|
47
|
-
serviceId: string;
|
|
48
|
-
warning?: string;
|
|
49
|
-
paymentReceipts?: PaymentReceipts[];
|
|
50
|
-
credit?: string;
|
|
28
|
+
type BaseBookingRequest = {
|
|
29
|
+
bookingReferenceId?: string;
|
|
51
30
|
cityId: string;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
completed: boolean;
|
|
32
|
+
contractType?: string;
|
|
33
|
+
creationDate: string;
|
|
34
|
+
customPrice: CustomPrice | null;
|
|
55
35
|
deliveryAddress?: string;
|
|
56
36
|
deliveryAddressAdditionalInfo?: string;
|
|
57
37
|
deliveryCity?: string;
|
|
58
38
|
deliveryPostalCode?: string;
|
|
59
39
|
dropOffStation?: string;
|
|
60
|
-
|
|
40
|
+
fleetId: string;
|
|
41
|
+
id: string;
|
|
42
|
+
notes?: string;
|
|
61
43
|
planDurationInMonths?: number;
|
|
62
|
-
|
|
63
|
-
customPrice: CustomPrice | null;
|
|
64
|
-
productIds: string[];
|
|
65
|
-
bookingReferenceId?: string;
|
|
44
|
+
plannedReturnDate?: string;
|
|
66
45
|
pricingDetails: {
|
|
67
46
|
pricingId: string;
|
|
68
47
|
providerType: string;
|
|
69
48
|
}[];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
productIds: string[];
|
|
50
|
+
profileId: string;
|
|
51
|
+
rollingContract: boolean;
|
|
52
|
+
serviceId: string;
|
|
53
|
+
startDate: string;
|
|
54
|
+
status: string;
|
|
55
|
+
userId: string;
|
|
56
|
+
};
|
|
57
|
+
type BookingRequest = BaseBookingRequest & {
|
|
73
58
|
[key: string]: any;
|
|
59
|
+
cancellationDate?: string;
|
|
60
|
+
cancelledBy?: string;
|
|
61
|
+
credit?: string;
|
|
62
|
+
endDate: string;
|
|
63
|
+
entityName?: string;
|
|
64
|
+
journeyId?: string;
|
|
65
|
+
modelId: number;
|
|
66
|
+
modelName?: string;
|
|
67
|
+
paymentReceipts?: PaymentReceipts[];
|
|
68
|
+
pricePerUnit?: string;
|
|
69
|
+
profileType?: 'Single' | 'Business';
|
|
70
|
+
realStartDate?: string;
|
|
71
|
+
returnedDate?: string;
|
|
72
|
+
station: string;
|
|
73
|
+
vehicleId?: string;
|
|
74
|
+
vehicleResidualValue?: number;
|
|
75
|
+
warning?: string;
|
|
76
|
+
};
|
|
77
|
+
type SATBookingRequest = BaseBookingRequest & {
|
|
78
|
+
cancellationDate: string | null;
|
|
79
|
+
cancelledBy: string | null;
|
|
80
|
+
endDate: string | null;
|
|
81
|
+
entityName: string | null;
|
|
82
|
+
journeyId: string | null;
|
|
83
|
+
modelId: number | null;
|
|
84
|
+
profileType: string | null;
|
|
85
|
+
realStartDate: string | null;
|
|
86
|
+
returnedDate: string | null;
|
|
87
|
+
station: string | null;
|
|
88
|
+
vehicleId: string | null;
|
|
89
|
+
cancellationFeeAmount: number | null;
|
|
90
|
+
credits: string | null;
|
|
91
|
+
earlyCancelledByUser: boolean;
|
|
92
|
+
email: string | null;
|
|
93
|
+
failureReason: string | null;
|
|
94
|
+
latitude: number;
|
|
95
|
+
longitude: number;
|
|
96
|
+
parentId: string | null;
|
|
97
|
+
planName: string | null;
|
|
98
|
+
preallocatedVehicleId: string | null;
|
|
99
|
+
previous: any | null;
|
|
100
|
+
price: any | null;
|
|
101
|
+
radius: number;
|
|
102
|
+
requiresActionReturnURL: string | null;
|
|
103
|
+
thresholdDateLimit: string | null;
|
|
104
|
+
trip: any | null;
|
|
105
|
+
warning: string | null;
|
|
74
106
|
};
|
|
75
107
|
|
|
76
108
|
declare const BookingRequestStatusSchema: z.ZodEnum<["ALERT", "UPCOMING", "ONGOING", "COMPLETED", "CANCELLED", "PENDING_APPROVAL"]>;
|
|
@@ -106,6 +138,10 @@ declare const getBookingRequests: (client: Client, status: BookingRequestStatus,
|
|
|
106
138
|
declare const getScheduleBookingRequests: (client: Client, status: BookingRequestStatus, options?: PaginableOptions<SpecificBookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>;
|
|
107
139
|
declare const getSubscriptionBookingRequests: (client: Client, status: BookingRequestStatus, options?: PaginableOptions<SpecificBookingRequestFilters>) => Promise<PaginableResponse<BookingRequest>>;
|
|
108
140
|
|
|
141
|
+
declare const SATBookingRequestStatusSchema: z.ZodEnum<["ALERT", "CANCELLED", "COMPLETED", "CONFIRMED", "LATE_RETURN", "ONGOING", "PENDING_PAYMENT", "PENDING", "UPCOMING_ALLOCATED", "UPCOMING_NOT_ALLOCATED"]>;
|
|
142
|
+
type SATBookingRequestStatus = z.infer<typeof SATBookingRequestStatusSchema>;
|
|
143
|
+
declare const getSATBookingRequests: (client: Client, status: SATBookingRequestStatus, options?: PaginableOptions<void, keyof SATBookingRequest>) => Promise<PaginableResponse<SATBookingRequest>>;
|
|
144
|
+
|
|
109
145
|
declare const getBookingRequestById: (client: Client, id: string) => Promise<BookingRequest>;
|
|
110
146
|
declare const getBookingRequestByTrip: (client: Client, tripId: string) => Promise<BookingRequest>;
|
|
111
147
|
declare const getSubscriptionBookingRequestById: (client: Client, id: string) => Promise<BookingRequest>;
|
|
@@ -155,4 +191,4 @@ type Station = Partial<GeoInfo> & Partial<ServiceInfo> & {
|
|
|
155
191
|
};
|
|
156
192
|
declare const getStations: (client: Client, includes?: Include[]) => Promise<Station[]>;
|
|
157
193
|
|
|
158
|
-
export { type BookingRequest, type BookingRequestFilters, type BookingRequestStatus, type DayOpeningHours, type Days, type Include, type OpeningHours, type ServiceType, type Station, type Timetable, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getScheduleBookingRequests, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests };
|
|
194
|
+
export { type BookingRequest, type BookingRequestFilters, type BookingRequestStatus, type DayOpeningHours, type Days, type Include, type OpeningHours, type SATBookingRequestStatus, type ServiceType, type Station, type Timetable, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getSATBookingRequests, getScheduleBookingRequests, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests };
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(index_exports, {
|
|
|
23
23
|
getBookingRequestById: () => getBookingRequestById,
|
|
24
24
|
getBookingRequestByTrip: () => getBookingRequestByTrip,
|
|
25
25
|
getBookingRequests: () => getBookingRequests,
|
|
26
|
+
getSATBookingRequests: () => getSATBookingRequests,
|
|
26
27
|
getScheduleBookingRequests: () => getScheduleBookingRequests,
|
|
27
28
|
getStations: () => getStations,
|
|
28
29
|
getSubscriptionBookingRequestById: () => getSubscriptionBookingRequestById,
|
|
@@ -44,6 +45,7 @@ var BookingRequestStatusSchema = import_zod.z.enum([
|
|
|
44
45
|
]);
|
|
45
46
|
var ServiceTypeSchema = import_zod.z.enum(["SUBSCRIPTION", "ROUND_TRIP_BOOKING", "SCHEDULED_BOOKING_STATION"]);
|
|
46
47
|
var getBookingRequests = async (client, status, options) => {
|
|
48
|
+
const preparedOptions = options ? { ...options, filters: options.filters || {} } : { filters: {} };
|
|
47
49
|
const resultStatus = BookingRequestStatusSchema.safeParse(status);
|
|
48
50
|
if (!resultStatus.success) {
|
|
49
51
|
throw new TypeError("Invalid status", {
|
|
@@ -68,7 +70,7 @@ var getBookingRequests = async (client, status, options) => {
|
|
|
68
70
|
includeProducts: import_zod.z.enum(["true", "false"]).optional()
|
|
69
71
|
});
|
|
70
72
|
const PaginableOptionsSchema = (0, import_aima_core.createPaginableOptionsSchema)(BookingRequestFiltersSchema).default({});
|
|
71
|
-
const resultOptions = PaginableOptionsSchema.safeParse(
|
|
73
|
+
const resultOptions = PaginableOptionsSchema.safeParse(preparedOptions);
|
|
72
74
|
if (!resultOptions.success) {
|
|
73
75
|
throw new TypeError("Invalid options", {
|
|
74
76
|
cause: resultOptions.error.issues
|
|
@@ -121,10 +123,64 @@ var getSubscriptionBookingRequests = async (client, status, options) => {
|
|
|
121
123
|
});
|
|
122
124
|
};
|
|
123
125
|
|
|
124
|
-
// src/
|
|
126
|
+
// src/getSATBookingRequests.ts
|
|
127
|
+
var import_aima_core2 = require("@vulog/aima-core");
|
|
125
128
|
var import_zod2 = require("zod");
|
|
129
|
+
var SATBookingRequestStatusSchema = import_zod2.z.enum([
|
|
130
|
+
"ALERT",
|
|
131
|
+
"CANCELLED",
|
|
132
|
+
"COMPLETED",
|
|
133
|
+
"CONFIRMED",
|
|
134
|
+
"LATE_RETURN",
|
|
135
|
+
"ONGOING",
|
|
136
|
+
"PENDING_PAYMENT",
|
|
137
|
+
"PENDING",
|
|
138
|
+
"UPCOMING_ALLOCATED",
|
|
139
|
+
"UPCOMING_NOT_ALLOCATED"
|
|
140
|
+
]);
|
|
141
|
+
var getSATBookingRequests = async (client, status, options) => {
|
|
142
|
+
const resultStatus = SATBookingRequestStatusSchema.safeParse(status);
|
|
143
|
+
if (!resultStatus.success) {
|
|
144
|
+
throw new TypeError("Invalid status", {
|
|
145
|
+
cause: resultStatus.error.issues
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const PaginableOptionsSchema = (0, import_aima_core2.createPaginableOptionsSchema)().default({});
|
|
149
|
+
const resultOptions = PaginableOptionsSchema.safeParse(options);
|
|
150
|
+
if (!resultOptions.success) {
|
|
151
|
+
throw new TypeError("Invalid options", {
|
|
152
|
+
cause: resultOptions.error.issues
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const finalOptions = resultOptions.data;
|
|
156
|
+
const searchParams = new URLSearchParams();
|
|
157
|
+
if (finalOptions.page) {
|
|
158
|
+
searchParams.append("page", finalOptions.page.toString());
|
|
159
|
+
}
|
|
160
|
+
if (finalOptions.pageSize) {
|
|
161
|
+
searchParams.append("size", finalOptions.pageSize.toString());
|
|
162
|
+
}
|
|
163
|
+
if (finalOptions.sortDirection && finalOptions.sort) {
|
|
164
|
+
searchParams.append("sort", `${finalOptions.sort},${finalOptions.sortDirection}`);
|
|
165
|
+
}
|
|
166
|
+
if (finalOptions.sort && !finalOptions.sortDirection) {
|
|
167
|
+
searchParams.append("sort", finalOptions.sort);
|
|
168
|
+
}
|
|
169
|
+
return client.get(`/boapi/proxy/user/scheduleATrip/fleets/${client.clientOptions.fleetId}/bookingrequests/status/${status}?${searchParams.toString()}`).then(({ data, headers }) => {
|
|
170
|
+
return {
|
|
171
|
+
data,
|
|
172
|
+
page: headers.number,
|
|
173
|
+
pageSize: headers.size,
|
|
174
|
+
total: headers.totalelements,
|
|
175
|
+
totalPages: headers.totalpages
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// src/getBookingRequest.ts
|
|
181
|
+
var import_zod3 = require("zod");
|
|
126
182
|
var getBookingRequestById = async (client, id) => {
|
|
127
|
-
const result =
|
|
183
|
+
const result = import_zod3.z.string().trim().min(1).uuid().safeParse(id);
|
|
128
184
|
if (!result.success) {
|
|
129
185
|
throw new TypeError("Invalid id", {
|
|
130
186
|
cause: result.error.issues
|
|
@@ -135,7 +191,7 @@ var getBookingRequestById = async (client, id) => {
|
|
|
135
191
|
).then(({ data }) => data);
|
|
136
192
|
};
|
|
137
193
|
var getBookingRequestByTrip = async (client, tripId) => {
|
|
138
|
-
const result =
|
|
194
|
+
const result = import_zod3.z.string().trim().min(1).safeParse(tripId);
|
|
139
195
|
if (!result.success) {
|
|
140
196
|
throw new TypeError("Invalid tripId", {
|
|
141
197
|
cause: result.error.issues
|
|
@@ -146,7 +202,7 @@ var getBookingRequestByTrip = async (client, tripId) => {
|
|
|
146
202
|
).then(({ data }) => data);
|
|
147
203
|
};
|
|
148
204
|
var getSubscriptionBookingRequestById = async (client, id) => {
|
|
149
|
-
const result =
|
|
205
|
+
const result = import_zod3.z.string().trim().min(1).uuid().safeParse(id);
|
|
150
206
|
if (!result.success) {
|
|
151
207
|
throw new TypeError("Invalid id", {
|
|
152
208
|
cause: result.error.issues
|
|
@@ -158,9 +214,9 @@ var getSubscriptionBookingRequestById = async (client, id) => {
|
|
|
158
214
|
};
|
|
159
215
|
|
|
160
216
|
// src/getStations.ts
|
|
161
|
-
var
|
|
162
|
-
var IncludeSchema =
|
|
163
|
-
var IncludesSchema =
|
|
217
|
+
var import_zod4 = require("zod");
|
|
218
|
+
var IncludeSchema = import_zod4.z.enum(["INFO", "OPEN_HOUR", "SERVICES"]);
|
|
219
|
+
var IncludesSchema = import_zod4.z.array(IncludeSchema);
|
|
164
220
|
var getStations = async (client, includes = []) => {
|
|
165
221
|
const resultIncludes = IncludesSchema.safeParse(includes);
|
|
166
222
|
if (!resultIncludes.success) {
|
|
@@ -253,6 +309,7 @@ var getStations = async (client, includes = []) => {
|
|
|
253
309
|
getBookingRequestById,
|
|
254
310
|
getBookingRequestByTrip,
|
|
255
311
|
getBookingRequests,
|
|
312
|
+
getSATBookingRequests,
|
|
256
313
|
getScheduleBookingRequests,
|
|
257
314
|
getStations,
|
|
258
315
|
getSubscriptionBookingRequestById,
|
package/dist/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ var BookingRequestStatusSchema = z.enum([
|
|
|
12
12
|
]);
|
|
13
13
|
var ServiceTypeSchema = z.enum(["SUBSCRIPTION", "ROUND_TRIP_BOOKING", "SCHEDULED_BOOKING_STATION"]);
|
|
14
14
|
var getBookingRequests = async (client, status, options) => {
|
|
15
|
+
const preparedOptions = options ? { ...options, filters: options.filters || {} } : { filters: {} };
|
|
15
16
|
const resultStatus = BookingRequestStatusSchema.safeParse(status);
|
|
16
17
|
if (!resultStatus.success) {
|
|
17
18
|
throw new TypeError("Invalid status", {
|
|
@@ -36,7 +37,7 @@ var getBookingRequests = async (client, status, options) => {
|
|
|
36
37
|
includeProducts: z.enum(["true", "false"]).optional()
|
|
37
38
|
});
|
|
38
39
|
const PaginableOptionsSchema = createPaginableOptionsSchema(BookingRequestFiltersSchema).default({});
|
|
39
|
-
const resultOptions = PaginableOptionsSchema.safeParse(
|
|
40
|
+
const resultOptions = PaginableOptionsSchema.safeParse(preparedOptions);
|
|
40
41
|
if (!resultOptions.success) {
|
|
41
42
|
throw new TypeError("Invalid options", {
|
|
42
43
|
cause: resultOptions.error.issues
|
|
@@ -89,10 +90,64 @@ var getSubscriptionBookingRequests = async (client, status, options) => {
|
|
|
89
90
|
});
|
|
90
91
|
};
|
|
91
92
|
|
|
92
|
-
// src/
|
|
93
|
+
// src/getSATBookingRequests.ts
|
|
94
|
+
import { createPaginableOptionsSchema as createPaginableOptionsSchema2 } from "@vulog/aima-core";
|
|
93
95
|
import { z as z2 } from "zod";
|
|
96
|
+
var SATBookingRequestStatusSchema = z2.enum([
|
|
97
|
+
"ALERT",
|
|
98
|
+
"CANCELLED",
|
|
99
|
+
"COMPLETED",
|
|
100
|
+
"CONFIRMED",
|
|
101
|
+
"LATE_RETURN",
|
|
102
|
+
"ONGOING",
|
|
103
|
+
"PENDING_PAYMENT",
|
|
104
|
+
"PENDING",
|
|
105
|
+
"UPCOMING_ALLOCATED",
|
|
106
|
+
"UPCOMING_NOT_ALLOCATED"
|
|
107
|
+
]);
|
|
108
|
+
var getSATBookingRequests = async (client, status, options) => {
|
|
109
|
+
const resultStatus = SATBookingRequestStatusSchema.safeParse(status);
|
|
110
|
+
if (!resultStatus.success) {
|
|
111
|
+
throw new TypeError("Invalid status", {
|
|
112
|
+
cause: resultStatus.error.issues
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const PaginableOptionsSchema = createPaginableOptionsSchema2().default({});
|
|
116
|
+
const resultOptions = PaginableOptionsSchema.safeParse(options);
|
|
117
|
+
if (!resultOptions.success) {
|
|
118
|
+
throw new TypeError("Invalid options", {
|
|
119
|
+
cause: resultOptions.error.issues
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const finalOptions = resultOptions.data;
|
|
123
|
+
const searchParams = new URLSearchParams();
|
|
124
|
+
if (finalOptions.page) {
|
|
125
|
+
searchParams.append("page", finalOptions.page.toString());
|
|
126
|
+
}
|
|
127
|
+
if (finalOptions.pageSize) {
|
|
128
|
+
searchParams.append("size", finalOptions.pageSize.toString());
|
|
129
|
+
}
|
|
130
|
+
if (finalOptions.sortDirection && finalOptions.sort) {
|
|
131
|
+
searchParams.append("sort", `${finalOptions.sort},${finalOptions.sortDirection}`);
|
|
132
|
+
}
|
|
133
|
+
if (finalOptions.sort && !finalOptions.sortDirection) {
|
|
134
|
+
searchParams.append("sort", finalOptions.sort);
|
|
135
|
+
}
|
|
136
|
+
return client.get(`/boapi/proxy/user/scheduleATrip/fleets/${client.clientOptions.fleetId}/bookingrequests/status/${status}?${searchParams.toString()}`).then(({ data, headers }) => {
|
|
137
|
+
return {
|
|
138
|
+
data,
|
|
139
|
+
page: headers.number,
|
|
140
|
+
pageSize: headers.size,
|
|
141
|
+
total: headers.totalelements,
|
|
142
|
+
totalPages: headers.totalpages
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// src/getBookingRequest.ts
|
|
148
|
+
import { z as z3 } from "zod";
|
|
94
149
|
var getBookingRequestById = async (client, id) => {
|
|
95
|
-
const result =
|
|
150
|
+
const result = z3.string().trim().min(1).uuid().safeParse(id);
|
|
96
151
|
if (!result.success) {
|
|
97
152
|
throw new TypeError("Invalid id", {
|
|
98
153
|
cause: result.error.issues
|
|
@@ -103,7 +158,7 @@ var getBookingRequestById = async (client, id) => {
|
|
|
103
158
|
).then(({ data }) => data);
|
|
104
159
|
};
|
|
105
160
|
var getBookingRequestByTrip = async (client, tripId) => {
|
|
106
|
-
const result =
|
|
161
|
+
const result = z3.string().trim().min(1).safeParse(tripId);
|
|
107
162
|
if (!result.success) {
|
|
108
163
|
throw new TypeError("Invalid tripId", {
|
|
109
164
|
cause: result.error.issues
|
|
@@ -114,7 +169,7 @@ var getBookingRequestByTrip = async (client, tripId) => {
|
|
|
114
169
|
).then(({ data }) => data);
|
|
115
170
|
};
|
|
116
171
|
var getSubscriptionBookingRequestById = async (client, id) => {
|
|
117
|
-
const result =
|
|
172
|
+
const result = z3.string().trim().min(1).uuid().safeParse(id);
|
|
118
173
|
if (!result.success) {
|
|
119
174
|
throw new TypeError("Invalid id", {
|
|
120
175
|
cause: result.error.issues
|
|
@@ -126,9 +181,9 @@ var getSubscriptionBookingRequestById = async (client, id) => {
|
|
|
126
181
|
};
|
|
127
182
|
|
|
128
183
|
// src/getStations.ts
|
|
129
|
-
import { z as
|
|
130
|
-
var IncludeSchema =
|
|
131
|
-
var IncludesSchema =
|
|
184
|
+
import { z as z4 } from "zod";
|
|
185
|
+
var IncludeSchema = z4.enum(["INFO", "OPEN_HOUR", "SERVICES"]);
|
|
186
|
+
var IncludesSchema = z4.array(IncludeSchema);
|
|
132
187
|
var getStations = async (client, includes = []) => {
|
|
133
188
|
const resultIncludes = IncludesSchema.safeParse(includes);
|
|
134
189
|
if (!resultIncludes.success) {
|
|
@@ -220,6 +275,7 @@ export {
|
|
|
220
275
|
getBookingRequestById,
|
|
221
276
|
getBookingRequestByTrip,
|
|
222
277
|
getBookingRequests,
|
|
278
|
+
getSATBookingRequests,
|
|
223
279
|
getScheduleBookingRequests,
|
|
224
280
|
getStations,
|
|
225
281
|
getSubscriptionBookingRequestById,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-booking",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.75",
|
|
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": "ISC",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@vulog/aima-client": "1.1.
|
|
23
|
-
"@vulog/aima-core": "1.1.
|
|
22
|
+
"@vulog/aima-client": "1.1.75",
|
|
23
|
+
"@vulog/aima-core": "1.1.75"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"es-toolkit": "^1.33.0",
|
|
@@ -43,11 +43,11 @@ describe('getBookingRequests', () => {
|
|
|
43
43
|
await rejects.toThrowError('Invalid options');
|
|
44
44
|
await rejects.toSatisfy((error: any) => {
|
|
45
45
|
expect(error).toHaveProperty('cause');
|
|
46
|
-
expect(error.cause).
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
expect(
|
|
46
|
+
expect(error.cause.length).toBeGreaterThanOrEqual(1);
|
|
47
|
+
const pageError = error.cause.find(
|
|
48
|
+
(e: any) => e.path && e.path[0] === 'page' && e.code === 'too_small'
|
|
49
|
+
);
|
|
50
|
+
expect(pageError).toBeDefined();
|
|
51
51
|
return true;
|
|
52
52
|
});
|
|
53
53
|
});
|
|
@@ -62,11 +62,11 @@ describe('getBookingRequests', () => {
|
|
|
62
62
|
await rejects.toThrowError('Invalid options');
|
|
63
63
|
await rejects.toSatisfy((error: any) => {
|
|
64
64
|
expect(error).toHaveProperty('cause');
|
|
65
|
-
expect(error.cause).
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
expect(
|
|
65
|
+
expect(error.cause.length).toBeGreaterThanOrEqual(1);
|
|
66
|
+
const pageSizeError = error.cause.find(
|
|
67
|
+
(e: any) => e.path && e.path[0] === 'pageSize' && e.code === 'too_small'
|
|
68
|
+
);
|
|
69
|
+
expect(pageSizeError).toBeDefined();
|
|
70
70
|
return true;
|
|
71
71
|
});
|
|
72
72
|
});
|
|
@@ -80,11 +80,11 @@ describe('getBookingRequests', () => {
|
|
|
80
80
|
await rejects.toThrowError('Invalid options');
|
|
81
81
|
await rejects.toSatisfy((error: any) => {
|
|
82
82
|
expect(error).toHaveProperty('cause');
|
|
83
|
-
expect(error.cause).
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
expect(
|
|
83
|
+
expect(error.cause.length).toBeGreaterThanOrEqual(1);
|
|
84
|
+
const pageSizeError = error.cause.find(
|
|
85
|
+
(e: any) => e.path && e.path[0] === 'pageSize' && e.code === 'too_big'
|
|
86
|
+
);
|
|
87
|
+
expect(pageSizeError).toBeDefined();
|
|
88
88
|
return true;
|
|
89
89
|
});
|
|
90
90
|
});
|
|
@@ -49,6 +49,7 @@ export const getBookingRequests = async (
|
|
|
49
49
|
status: BookingRequestStatus,
|
|
50
50
|
options?: PaginableOptions<BookingRequestFilters>
|
|
51
51
|
): Promise<PaginableResponse<BookingRequest>> => {
|
|
52
|
+
const preparedOptions = options ? { ...options, filters: options.filters || {} } : { filters: {} };
|
|
52
53
|
const resultStatus = BookingRequestStatusSchema.safeParse(status);
|
|
53
54
|
if (!resultStatus.success) {
|
|
54
55
|
throw new TypeError('Invalid status', {
|
|
@@ -76,7 +77,7 @@ export const getBookingRequests = async (
|
|
|
76
77
|
|
|
77
78
|
const PaginableOptionsSchema = createPaginableOptionsSchema(BookingRequestFiltersSchema).default({});
|
|
78
79
|
|
|
79
|
-
const resultOptions = PaginableOptionsSchema.safeParse(
|
|
80
|
+
const resultOptions = PaginableOptionsSchema.safeParse(preparedOptions);
|
|
80
81
|
if (!resultOptions.success) {
|
|
81
82
|
throw new TypeError('Invalid options', {
|
|
82
83
|
cause: resultOptions.error.issues,
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { describe, test, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { getSATBookingRequests, SATBookingRequestStatus } from './getSATBookingRequests';
|
|
3
|
+
import { Client } from '@vulog/aima-client';
|
|
4
|
+
|
|
5
|
+
describe('getSATBookingRequests', () => {
|
|
6
|
+
const getMock = vi.fn();
|
|
7
|
+
const client = {
|
|
8
|
+
get: getMock,
|
|
9
|
+
clientOptions: {
|
|
10
|
+
fleetId: 'FLEET_ID',
|
|
11
|
+
},
|
|
12
|
+
} as unknown as Client;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
getMock.mockReset();
|
|
16
|
+
vi.useFakeTimers({ now: new Date('2025-01-12T13:35:50.123Z') });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
vi.useRealTimers();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('Fake status', async () => {
|
|
24
|
+
const rejects = expect(() => getSATBookingRequests({} as Client, 'FAKE' as any)).rejects;
|
|
25
|
+
await rejects.toThrowError('Invalid status');
|
|
26
|
+
await rejects.toSatisfy((error: any) => {
|
|
27
|
+
expect(error).toHaveProperty('cause');
|
|
28
|
+
expect(error.cause).toHaveLength(1);
|
|
29
|
+
expect(error.cause[0]).toHaveProperty('received');
|
|
30
|
+
expect(error.cause[0]).toHaveProperty('code');
|
|
31
|
+
expect(error.cause[0].received).toBe('FAKE');
|
|
32
|
+
expect(error.cause[0].code).toBe('invalid_enum_value');
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('negative page', async () => {
|
|
38
|
+
const rejects = expect(() =>
|
|
39
|
+
getSATBookingRequests({} as Client, 'PENDING', {
|
|
40
|
+
page: -1,
|
|
41
|
+
})
|
|
42
|
+
).rejects;
|
|
43
|
+
await rejects.toThrowError('Invalid options');
|
|
44
|
+
await rejects.toSatisfy((error: any) => {
|
|
45
|
+
expect(error).toHaveProperty('cause');
|
|
46
|
+
expect(error.cause).toHaveLength(1);
|
|
47
|
+
expect(error.cause[0]).toHaveProperty('path');
|
|
48
|
+
expect(error.cause[0]).toHaveProperty('code');
|
|
49
|
+
expect(error.cause[0].path[0]).toBe('page');
|
|
50
|
+
expect(error.cause[0].code).toBe('too_small');
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('negative pageSize', async () => {
|
|
56
|
+
const rejects = expect(() =>
|
|
57
|
+
getSATBookingRequests({} as Client, 'PENDING', {
|
|
58
|
+
page: 0,
|
|
59
|
+
pageSize: -1,
|
|
60
|
+
})
|
|
61
|
+
).rejects;
|
|
62
|
+
await rejects.toThrowError('Invalid options');
|
|
63
|
+
await rejects.toSatisfy((error: any) => {
|
|
64
|
+
expect(error).toHaveProperty('cause');
|
|
65
|
+
expect(error.cause).toHaveLength(1);
|
|
66
|
+
expect(error.cause[0]).toHaveProperty('path');
|
|
67
|
+
expect(error.cause[0]).toHaveProperty('code');
|
|
68
|
+
expect(error.cause[0].path[0]).toBe('pageSize');
|
|
69
|
+
expect(error.cause[0].code).toBe('too_small');
|
|
70
|
+
return true;
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('too big pageSize', async () => {
|
|
75
|
+
const rejects = expect(() =>
|
|
76
|
+
getSATBookingRequests({} as Client, 'PENDING', {
|
|
77
|
+
pageSize: 1001,
|
|
78
|
+
})
|
|
79
|
+
).rejects;
|
|
80
|
+
await rejects.toThrowError('Invalid options');
|
|
81
|
+
await rejects.toSatisfy((error: any) => {
|
|
82
|
+
expect(error).toHaveProperty('cause');
|
|
83
|
+
expect(error.cause).toHaveLength(1);
|
|
84
|
+
expect(error.cause[0]).toHaveProperty('path');
|
|
85
|
+
expect(error.cause[0]).toHaveProperty('code');
|
|
86
|
+
expect(error.cause[0].path[0]).toBe('pageSize');
|
|
87
|
+
expect(error.cause[0].code).toBe('too_big');
|
|
88
|
+
return true;
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('call Base', async () => {
|
|
93
|
+
getMock.mockResolvedValueOnce({
|
|
94
|
+
data: [],
|
|
95
|
+
headers: {
|
|
96
|
+
number: 0,
|
|
97
|
+
size: 100,
|
|
98
|
+
totalelements: 0,
|
|
99
|
+
totalpages: 0,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const result = await getSATBookingRequests(client, 'PENDING');
|
|
104
|
+
expect(getMock).toBeCalled();
|
|
105
|
+
expect(getMock).toBeCalledWith(
|
|
106
|
+
'/boapi/proxy/user/scheduleATrip/fleets/FLEET_ID/bookingrequests/status/PENDING?size=100'
|
|
107
|
+
);
|
|
108
|
+
expect(result).toEqual({
|
|
109
|
+
data: [],
|
|
110
|
+
page: 0,
|
|
111
|
+
pageSize: 100,
|
|
112
|
+
total: 0,
|
|
113
|
+
totalPages: 0,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('call with sort and sortDirection', async () => {
|
|
118
|
+
getMock.mockResolvedValueOnce({
|
|
119
|
+
data: [],
|
|
120
|
+
headers: {
|
|
121
|
+
number: 0,
|
|
122
|
+
size: 10,
|
|
123
|
+
totalelements: 0,
|
|
124
|
+
totalpages: 0,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const result = await getSATBookingRequests(client, 'PENDING', {
|
|
129
|
+
pageSize: 10,
|
|
130
|
+
sort: 'id',
|
|
131
|
+
sortDirection: 'DESC'
|
|
132
|
+
});
|
|
133
|
+
expect(getMock).toBeCalled();
|
|
134
|
+
expect(getMock).toBeCalledWith(
|
|
135
|
+
'/boapi/proxy/user/scheduleATrip/fleets/FLEET_ID/bookingrequests/status/PENDING?size=10&sort=id%2CDESC'
|
|
136
|
+
);
|
|
137
|
+
expect(result).toEqual({
|
|
138
|
+
data: [],
|
|
139
|
+
page: 0,
|
|
140
|
+
pageSize: 10,
|
|
141
|
+
total: 0,
|
|
142
|
+
totalPages: 0,
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test('call with page and different sort', async () => {
|
|
147
|
+
getMock.mockResolvedValueOnce({
|
|
148
|
+
data: [],
|
|
149
|
+
headers: {
|
|
150
|
+
number: 0,
|
|
151
|
+
size: 50,
|
|
152
|
+
totalelements: 0,
|
|
153
|
+
totalpages: 0,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const result = await getSATBookingRequests(client, 'COMPLETED', {
|
|
158
|
+
page: 1,
|
|
159
|
+
pageSize: 50,
|
|
160
|
+
sort: 'creationDate'
|
|
161
|
+
});
|
|
162
|
+
expect(getMock).toBeCalled();
|
|
163
|
+
expect(getMock).toBeCalledWith(
|
|
164
|
+
`/boapi/proxy/user/scheduleATrip/fleets/FLEET_ID/bookingrequests/status/COMPLETED?page=1&size=50&sort=creationDate`
|
|
165
|
+
);
|
|
166
|
+
expect(result).toEqual({
|
|
167
|
+
data: [],
|
|
168
|
+
page: 0,
|
|
169
|
+
pageSize: 50,
|
|
170
|
+
total: 0,
|
|
171
|
+
totalPages: 0,
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Client } from '@vulog/aima-client';
|
|
2
|
+
import { createPaginableOptionsSchema, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import { SATBookingRequest } from './types';
|
|
6
|
+
|
|
7
|
+
const SATBookingRequestStatusSchema = z.enum([
|
|
8
|
+
'ALERT',
|
|
9
|
+
'CANCELLED',
|
|
10
|
+
'COMPLETED',
|
|
11
|
+
'CONFIRMED',
|
|
12
|
+
'LATE_RETURN',
|
|
13
|
+
'ONGOING',
|
|
14
|
+
'PENDING_PAYMENT',
|
|
15
|
+
'PENDING',
|
|
16
|
+
'UPCOMING_ALLOCATED',
|
|
17
|
+
'UPCOMING_NOT_ALLOCATED',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export type SATBookingRequestStatus = z.infer<typeof SATBookingRequestStatusSchema>;
|
|
21
|
+
|
|
22
|
+
export const getSATBookingRequests = async (
|
|
23
|
+
client: Client,
|
|
24
|
+
status: SATBookingRequestStatus,
|
|
25
|
+
options?: PaginableOptions<void, keyof SATBookingRequest>
|
|
26
|
+
): Promise<PaginableResponse<SATBookingRequest>> => {
|
|
27
|
+
const resultStatus = SATBookingRequestStatusSchema.safeParse(status);
|
|
28
|
+
if (!resultStatus.success) {
|
|
29
|
+
throw new TypeError('Invalid status', {
|
|
30
|
+
cause: resultStatus.error.issues,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const PaginableOptionsSchema = createPaginableOptionsSchema().default({});
|
|
35
|
+
|
|
36
|
+
const resultOptions = PaginableOptionsSchema.safeParse(options);
|
|
37
|
+
if (!resultOptions.success) {
|
|
38
|
+
throw new TypeError('Invalid options', {
|
|
39
|
+
cause: resultOptions.error.issues,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const finalOptions = resultOptions.data;
|
|
44
|
+
|
|
45
|
+
const searchParams = new URLSearchParams();
|
|
46
|
+
if (finalOptions!.page) {
|
|
47
|
+
searchParams.append('page', finalOptions!.page.toString());
|
|
48
|
+
}
|
|
49
|
+
if (finalOptions!.pageSize) {
|
|
50
|
+
searchParams.append('size', finalOptions!.pageSize.toString());
|
|
51
|
+
}
|
|
52
|
+
if (finalOptions.sortDirection && finalOptions.sort) {
|
|
53
|
+
searchParams.append('sort', `${finalOptions.sort},${finalOptions.sortDirection}`);
|
|
54
|
+
}
|
|
55
|
+
if (finalOptions.sort && !finalOptions.sortDirection) {
|
|
56
|
+
searchParams.append('sort', finalOptions.sort);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return client
|
|
60
|
+
.get<
|
|
61
|
+
SATBookingRequest[]
|
|
62
|
+
>(`/boapi/proxy/user/scheduleATrip/fleets/${client.clientOptions.fleetId}/bookingrequests/status/${status}?${searchParams.toString()}`)
|
|
63
|
+
.then(({ data, headers }) => {
|
|
64
|
+
return {
|
|
65
|
+
data,
|
|
66
|
+
page: headers.number,
|
|
67
|
+
pageSize: headers.size,
|
|
68
|
+
total: headers.totalelements,
|
|
69
|
+
totalPages: headers.totalpages,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { getBookingRequests, getScheduleBookingRequests, getSubscriptionBookingRequests } from './getBookingRequests';
|
|
2
|
+
export { getSATBookingRequests } from './getSATBookingRequests';
|
|
2
3
|
export { getBookingRequestById, getBookingRequestByTrip, getSubscriptionBookingRequestById } from './getBookingRequest';
|
|
3
4
|
export type { BookingRequest } from './types';
|
|
4
5
|
export type { BookingRequestStatus, ServiceType, BookingRequestFilters } from './getBookingRequests';
|
|
6
|
+
export type { SATBookingRequestStatus } from './getSATBookingRequests';
|
|
5
7
|
export { getStations } from './getStations';
|
|
6
8
|
export type { Station, Include, Days, DayOpeningHours, Timetable, OpeningHours } from './getStations';
|
package/src/types.ts
CHANGED
|
@@ -24,50 +24,82 @@ export type CustomPrice = {
|
|
|
24
24
|
pricingReferenceId: string | null;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export type
|
|
28
|
-
|
|
29
|
-
startDate: string;
|
|
30
|
-
endDate: string;
|
|
31
|
-
returnedDate?: string;
|
|
32
|
-
profileId: string;
|
|
33
|
-
vehicleId?: string;
|
|
34
|
-
modelId: number;
|
|
35
|
-
journeyId?: string;
|
|
36
|
-
station: string;
|
|
37
|
-
profileType?: 'Single' | 'Business';
|
|
38
|
-
entityName?: string;
|
|
39
|
-
status: string;
|
|
40
|
-
creationDate: string;
|
|
41
|
-
realStartDate?: string;
|
|
42
|
-
cancellationDate?: string;
|
|
43
|
-
cancelledBy?: string;
|
|
44
|
-
fleetId: string;
|
|
45
|
-
userId: string;
|
|
46
|
-
serviceId: string;
|
|
47
|
-
warning?: string;
|
|
48
|
-
paymentReceipts?: PaymentReceipts[];
|
|
49
|
-
credit?: string;
|
|
27
|
+
export type BaseBookingRequest = {
|
|
28
|
+
bookingReferenceId?: string;
|
|
50
29
|
cityId: string;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
30
|
+
completed: boolean;
|
|
31
|
+
contractType?: string;
|
|
32
|
+
creationDate: string;
|
|
33
|
+
customPrice: CustomPrice | null;
|
|
54
34
|
deliveryAddress?: string;
|
|
55
35
|
deliveryAddressAdditionalInfo?: string;
|
|
56
36
|
deliveryCity?: string;
|
|
57
37
|
deliveryPostalCode?: string;
|
|
58
38
|
dropOffStation?: string;
|
|
59
|
-
|
|
39
|
+
fleetId: string;
|
|
40
|
+
id: string;
|
|
41
|
+
notes?: string;
|
|
60
42
|
planDurationInMonths?: number;
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
plannedReturnDate?: string;
|
|
44
|
+
pricingDetails: { pricingId: string; providerType: string }[];
|
|
63
45
|
productIds: string[];
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
46
|
+
profileId: string;
|
|
47
|
+
rollingContract: boolean;
|
|
48
|
+
serviceId: string;
|
|
49
|
+
startDate: string;
|
|
50
|
+
status: string;
|
|
51
|
+
userId: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type BookingRequest = BaseBookingRequest & {
|
|
72
55
|
[key: string]: any;
|
|
56
|
+
cancellationDate?: string;
|
|
57
|
+
cancelledBy?: string;
|
|
58
|
+
credit?: string;
|
|
59
|
+
endDate: string;
|
|
60
|
+
entityName?: string;
|
|
61
|
+
journeyId?: string;
|
|
62
|
+
modelId: number;
|
|
63
|
+
modelName?: string;
|
|
64
|
+
paymentReceipts?: PaymentReceipts[];
|
|
65
|
+
pricePerUnit?: string;
|
|
66
|
+
profileType?: 'Single' | 'Business';
|
|
67
|
+
realStartDate?: string;
|
|
68
|
+
returnedDate?: string;
|
|
69
|
+
station: string;
|
|
70
|
+
vehicleId?: string;
|
|
71
|
+
vehicleResidualValue?: number;
|
|
72
|
+
warning?: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type SATBookingRequest = BaseBookingRequest & {
|
|
76
|
+
cancellationDate: string | null;
|
|
77
|
+
cancelledBy: string | null;
|
|
78
|
+
endDate: string | null;
|
|
79
|
+
entityName: string | null;
|
|
80
|
+
journeyId: string | null;
|
|
81
|
+
modelId: number | null;
|
|
82
|
+
profileType: string | null;
|
|
83
|
+
realStartDate: string | null;
|
|
84
|
+
returnedDate: string | null;
|
|
85
|
+
station: string | null;
|
|
86
|
+
vehicleId: string | null;
|
|
87
|
+
// Additional properties specific to SAT booking request
|
|
88
|
+
cancellationFeeAmount: number | null;
|
|
89
|
+
credits: string | null;
|
|
90
|
+
earlyCancelledByUser: boolean;
|
|
91
|
+
email: string | null;
|
|
92
|
+
failureReason: string | null;
|
|
93
|
+
latitude: number;
|
|
94
|
+
longitude: number;
|
|
95
|
+
parentId: string | null;
|
|
96
|
+
planName: string | null;
|
|
97
|
+
preallocatedVehicleId: string | null;
|
|
98
|
+
previous: any | null;
|
|
99
|
+
price: any | null;
|
|
100
|
+
radius: number;
|
|
101
|
+
requiresActionReturnURL: string | null;
|
|
102
|
+
thresholdDateLimit: string | null;
|
|
103
|
+
trip: any | null;
|
|
104
|
+
warning: string | null;
|
|
73
105
|
};
|