@vulog/aima-trip 1.2.30 → 1.2.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +142 -0
- package/dist/index.d.cts +248 -0
- package/dist/index.d.mts +215 -208
- package/dist/index.mjs +99 -171
- package/package.json +20 -7
- package/{tsup.config.ts → tsdown.config.ts} +1 -1
- package/dist/index.d.ts +0 -241
- package/dist/index.js +0 -227
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/dist/index.js
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
addTripRelatedProduct: () => addTripRelatedProduct,
|
|
34
|
-
endTrip: () => endTrip,
|
|
35
|
-
getOngoingTripPaymentsByTripIds: () => getOngoingTripPaymentsByTripIds,
|
|
36
|
-
getTripById: () => getTripById,
|
|
37
|
-
getTripsByUserId: () => getTripsByUserId,
|
|
38
|
-
getVehicleBookedByTripId: () => getVehicleBookedByTripId,
|
|
39
|
-
getVehiclesBooked: () => getVehiclesBooked,
|
|
40
|
-
getVehiclesBookedByUserId: () => getVehiclesBookedByUserId,
|
|
41
|
-
removeTripRelatedProduct: () => removeTripRelatedProduct
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(index_exports);
|
|
44
|
-
|
|
45
|
-
// src/addRemoveTripRelatedProduct.ts
|
|
46
|
-
var import_zod = __toESM(require("zod"));
|
|
47
|
-
var schema = import_zod.default.object({
|
|
48
|
-
vehicleId: import_zod.default.string().trim().min(1).uuid(),
|
|
49
|
-
productId: import_zod.default.string().trim().min(1).uuid()
|
|
50
|
-
});
|
|
51
|
-
var addRemoveTripRelatedProduct = async (client, action, vehicleId, productId) => {
|
|
52
|
-
const result = schema.safeParse({ vehicleId, productId });
|
|
53
|
-
if (!result.success) {
|
|
54
|
-
throw new TypeError("Invalid args", {
|
|
55
|
-
cause: result.error.issues
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
await client[action === "ADD" ? "put" : "delete"](
|
|
59
|
-
`/boapi/proxy/fleetmanager/public/fleets/${client.clientOptions.fleetId}/vehicles/${result.data.vehicleId}/products/${result.data.productId}`
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
var addTripRelatedProduct = async (client, vehicleId, productId) => addRemoveTripRelatedProduct(client, "ADD", vehicleId, productId);
|
|
63
|
-
var removeTripRelatedProduct = async (client, vehicleId, productId) => addRemoveTripRelatedProduct(client, "REMOVE", vehicleId, productId);
|
|
64
|
-
|
|
65
|
-
// src/endTrip.ts
|
|
66
|
-
var import_zod2 = __toESM(require("zod"));
|
|
67
|
-
var schema2 = import_zod2.default.object({
|
|
68
|
-
vehicleId: import_zod2.default.string().trim().min(1).uuid(),
|
|
69
|
-
userId: import_zod2.default.string().trim().min(1).uuid(),
|
|
70
|
-
orderId: import_zod2.default.string().trim().min(1)
|
|
71
|
-
});
|
|
72
|
-
var endTrip = async (client, info) => {
|
|
73
|
-
const result = schema2.safeParse(info);
|
|
74
|
-
if (!result.success) {
|
|
75
|
-
throw new TypeError("Invalid args", {
|
|
76
|
-
cause: result.error.issues
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
await client.post(
|
|
80
|
-
`/boapi/proxy/fleetmanager/public/fleets/${client.clientOptions.fleetId}/vehicles/${result.data.vehicleId}/trip/end`,
|
|
81
|
-
{
|
|
82
|
-
userId: result.data.userId,
|
|
83
|
-
orderId: result.data.orderId
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// src/getVehiclesBooked.ts
|
|
89
|
-
var import_zod3 = __toESM(require("zod"));
|
|
90
|
-
var optionsSchema = import_zod3.default.object({
|
|
91
|
-
minDuration: import_zod3.default.number().positive().optional(),
|
|
92
|
-
boxStatus: import_zod3.default.array(import_zod3.default.number()).optional()
|
|
93
|
-
});
|
|
94
|
-
var getVehiclesBooked = async (client, options = {}) => {
|
|
95
|
-
const result = optionsSchema.safeParse(options);
|
|
96
|
-
if (!result.success) {
|
|
97
|
-
throw new TypeError("Invalid options", {
|
|
98
|
-
cause: result.error.issues
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return client.get(`/boapi/proxy/fleetmanager/public/fleets/${client.clientOptions.fleetId}/book`).then(({ data }) => {
|
|
102
|
-
let filterData = data;
|
|
103
|
-
if (result.data.minDuration) {
|
|
104
|
-
filterData = filterData.filter((book) => {
|
|
105
|
-
if (!book.start_date) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
const startDate = new Date(book.start_date);
|
|
109
|
-
const now = /* @__PURE__ */ new Date();
|
|
110
|
-
const duration = (now.getTime() - startDate.getTime()) / 1e3;
|
|
111
|
-
return duration >= result.data.minDuration * 60;
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
if (result.data.boxStatus && result.data.boxStatus.length > 0) {
|
|
115
|
-
filterData = filterData.filter((book) => {
|
|
116
|
-
return result.data.boxStatus?.includes(book.box_status);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return filterData;
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
var schemaByUserId = import_zod3.default.object({
|
|
123
|
-
userId: import_zod3.default.string().trim().min(1).uuid()
|
|
124
|
-
});
|
|
125
|
-
var getVehiclesBookedByUserId = async (client, userId) => {
|
|
126
|
-
const result = schemaByUserId.safeParse({ userId });
|
|
127
|
-
if (!result.success) {
|
|
128
|
-
throw new TypeError("Invalid args", {
|
|
129
|
-
cause: result.error.issues
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
return client.get(
|
|
133
|
-
`/boapi/proxy/fleetmanager/public/fleets/${client.clientOptions.fleetId}/users/${result.data.userId}/vehicles`
|
|
134
|
-
).then(({ data }) => data).catch((error) => {
|
|
135
|
-
if (error.formattedError?.status === 404) {
|
|
136
|
-
return [];
|
|
137
|
-
}
|
|
138
|
-
throw error;
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
var getVehicleBookedByTripId = async (client, tripId) => {
|
|
142
|
-
return client.get(
|
|
143
|
-
`/boapi/proxy/fleetmanager/public/fleets/${client.clientOptions.fleetId}/trips/${tripId}/vehicle`
|
|
144
|
-
).then(({ data }) => data).catch((error) => {
|
|
145
|
-
if (error.formattedError?.status === 404) {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
throw error;
|
|
149
|
-
});
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
// src/getTripById.ts
|
|
153
|
-
var getTripById = async (client, tripId) => {
|
|
154
|
-
const { fleetId } = client.clientOptions;
|
|
155
|
-
return client.get(`/boapi/proxy/trip/fleets/${fleetId}/trips/${tripId}`).then(({ data }) => data).catch((error) => {
|
|
156
|
-
if (error.formattedError?.status === 404) {
|
|
157
|
-
return {};
|
|
158
|
-
}
|
|
159
|
-
throw error;
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
// src/getOngoingTripPaymentsByTripIds.ts
|
|
164
|
-
var import_zod4 = require("zod");
|
|
165
|
-
var getOngoingTripPaymentsByTripIds = async (client, tripIds) => {
|
|
166
|
-
const schema3 = import_zod4.z.object({
|
|
167
|
-
tripIds: import_zod4.z.array(import_zod4.z.string()).nonempty()
|
|
168
|
-
});
|
|
169
|
-
const result = schema3.safeParse({ tripIds });
|
|
170
|
-
if (!result.success) {
|
|
171
|
-
throw new TypeError("Invalid parameters", {
|
|
172
|
-
cause: result.error.issues
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
return client.post(`/boapi/proxy/trip/fleets/${client.clientOptions.fleetId}/trips/ongoing`, { ids: tripIds }).then(({ data }) => data);
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
// src/getTrips.ts
|
|
179
|
-
var import_aima_core = require("@vulog/aima-core");
|
|
180
|
-
var import_zod5 = __toESM(require("zod"));
|
|
181
|
-
var schemaByUserId2 = import_zod5.default.object({
|
|
182
|
-
userId: import_zod5.default.string().trim().min(1).uuid()
|
|
183
|
-
});
|
|
184
|
-
var getTripsByUserId = async (client, userId, options) => {
|
|
185
|
-
const result = schemaByUserId2.safeParse({ userId });
|
|
186
|
-
if (!result.success) {
|
|
187
|
-
throw new TypeError("Invalid userId", {
|
|
188
|
-
cause: result.error.issues
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
const PaginableOptionsSchema = (0, import_aima_core.createPaginableOptionsSchema)(
|
|
192
|
-
void 0,
|
|
193
|
-
import_zod5.default.enum(["date"]).optional().default("date")
|
|
194
|
-
).default({});
|
|
195
|
-
const resultOptions = PaginableOptionsSchema.safeParse(options);
|
|
196
|
-
if (!resultOptions.success) {
|
|
197
|
-
throw new TypeError("Invalid options", {
|
|
198
|
-
cause: resultOptions.error.issues
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
const finalOptions = resultOptions.data;
|
|
202
|
-
const searchParams = new URLSearchParams();
|
|
203
|
-
searchParams.append("page", finalOptions.page.toString());
|
|
204
|
-
searchParams.append("size", finalOptions.pageSize.toString());
|
|
205
|
-
searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
|
|
206
|
-
return client.get(`/boapi/proxy/trip/fleets/${client.clientOptions.fleetId}/trips/users/${userId}?${searchParams.toString()}`).then(({ data, headers }) => {
|
|
207
|
-
return {
|
|
208
|
-
data,
|
|
209
|
-
page: headers.number,
|
|
210
|
-
pageSize: headers.size,
|
|
211
|
-
total: headers.totalelements,
|
|
212
|
-
totalPages: headers.totalpages
|
|
213
|
-
};
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
217
|
-
0 && (module.exports = {
|
|
218
|
-
addTripRelatedProduct,
|
|
219
|
-
endTrip,
|
|
220
|
-
getOngoingTripPaymentsByTripIds,
|
|
221
|
-
getTripById,
|
|
222
|
-
getTripsByUserId,
|
|
223
|
-
getVehicleBookedByTripId,
|
|
224
|
-
getVehiclesBooked,
|
|
225
|
-
getVehiclesBookedByUserId,
|
|
226
|
-
removeTripRelatedProduct
|
|
227
|
-
});
|
|
File without changes
|