@vulog/aima-event 1.1.57 → 1.1.58

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 CHANGED
@@ -37,5 +37,6 @@ type EventFilters = {
37
37
  };
38
38
  declare const getEventsByType: (client: Client, type: EventType, options?: PaginableOptions<EventFilters>) => Promise<PaginableResponse<Event>>;
39
39
  declare const getEvents: (client: Client, options?: PaginableOptions<EventFilters>) => Promise<PaginableResponse<Event>>;
40
+ declare const getEventsByTripId: (client: Client, tripId: string, options?: PaginableOptions<EventFilters>) => Promise<PaginableResponse<Event>>;
40
41
 
41
- export { type Event, type EventFilters, type EventType, getEvents, getEventsByType };
42
+ export { type Event, type EventFilters, type EventType, type ExtraInfo, getEvents, getEventsByTripId, getEventsByType };
package/dist/index.d.ts CHANGED
@@ -37,5 +37,6 @@ type EventFilters = {
37
37
  };
38
38
  declare const getEventsByType: (client: Client, type: EventType, options?: PaginableOptions<EventFilters>) => Promise<PaginableResponse<Event>>;
39
39
  declare const getEvents: (client: Client, options?: PaginableOptions<EventFilters>) => Promise<PaginableResponse<Event>>;
40
+ declare const getEventsByTripId: (client: Client, tripId: string, options?: PaginableOptions<EventFilters>) => Promise<PaginableResponse<Event>>;
40
41
 
41
- export { type Event, type EventFilters, type EventType, getEvents, getEventsByType };
42
+ export { type Event, type EventFilters, type EventType, type ExtraInfo, getEvents, getEventsByTripId, getEventsByType };
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  getEvents: () => getEvents,
24
+ getEventsByTripId: () => getEventsByTripId,
24
25
  getEventsByType: () => getEventsByType
25
26
  });
26
27
  module.exports = __toCommonJS(index_exports);
@@ -297,8 +298,41 @@ var getEvents = async (client, options) => {
297
298
  };
298
299
  });
299
300
  };
301
+ var getEventsByTripId = async (client, tripId, options) => {
302
+ const EventFiltersSchema = import_zod.z.object({
303
+ startDate: import_zod.z.string().datetime({ offset: false, precision: 0 }).optional(),
304
+ endDate: import_zod.z.string().datetime({ offset: false, precision: 0 }).optional()
305
+ });
306
+ const PaginableOptionsSchema = (0, import_aima_core.createPaginableOptionsSchema)(EventFiltersSchema).default({});
307
+ const resultOptions = PaginableOptionsSchema.safeParse(options);
308
+ if (!resultOptions.success) {
309
+ throw new TypeError("Invalid options", {
310
+ cause: resultOptions.error.issues
311
+ });
312
+ }
313
+ const finalOptions = resultOptions.data;
314
+ const searchParams = new URLSearchParams();
315
+ searchParams.append("page", finalOptions.page.toString());
316
+ searchParams.append("pageSize", finalOptions.pageSize.toString());
317
+ Object.entries(finalOptions.filters).forEach(([key, value]) => {
318
+ if (value === void 0) {
319
+ return;
320
+ }
321
+ searchParams.append(key, value);
322
+ });
323
+ return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/events/trips/${tripId}?${searchParams.toString()}`).then(({ data, headers }) => {
324
+ return {
325
+ data,
326
+ page: headers.number,
327
+ pageSize: headers.size,
328
+ total: headers.totalelements,
329
+ totalPages: headers.totalpages
330
+ };
331
+ });
332
+ };
300
333
  // Annotate the CommonJS export names for ESM import in node:
301
334
  0 && (module.exports = {
302
335
  getEvents,
336
+ getEventsByTripId,
303
337
  getEventsByType
304
338
  });
package/dist/index.mjs CHANGED
@@ -270,7 +270,40 @@ var getEvents = async (client, options) => {
270
270
  };
271
271
  });
272
272
  };
273
+ var getEventsByTripId = async (client, tripId, options) => {
274
+ const EventFiltersSchema = z.object({
275
+ startDate: z.string().datetime({ offset: false, precision: 0 }).optional(),
276
+ endDate: z.string().datetime({ offset: false, precision: 0 }).optional()
277
+ });
278
+ const PaginableOptionsSchema = createPaginableOptionsSchema(EventFiltersSchema).default({});
279
+ const resultOptions = PaginableOptionsSchema.safeParse(options);
280
+ if (!resultOptions.success) {
281
+ throw new TypeError("Invalid options", {
282
+ cause: resultOptions.error.issues
283
+ });
284
+ }
285
+ const finalOptions = resultOptions.data;
286
+ const searchParams = new URLSearchParams();
287
+ searchParams.append("page", finalOptions.page.toString());
288
+ searchParams.append("pageSize", finalOptions.pageSize.toString());
289
+ Object.entries(finalOptions.filters).forEach(([key, value]) => {
290
+ if (value === void 0) {
291
+ return;
292
+ }
293
+ searchParams.append(key, value);
294
+ });
295
+ return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/events/trips/${tripId}?${searchParams.toString()}`).then(({ data, headers }) => {
296
+ return {
297
+ data,
298
+ page: headers.number,
299
+ pageSize: headers.size,
300
+ total: headers.totalelements,
301
+ totalPages: headers.totalpages
302
+ };
303
+ });
304
+ };
273
305
  export {
274
306
  getEvents,
307
+ getEventsByTripId,
275
308
  getEventsByType
276
309
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulog/aima-event",
3
- "version": "1.1.57",
3
+ "version": "1.1.58",
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.57",
23
- "@vulog/aima-core": "1.1.57"
22
+ "@vulog/aima-client": "1.1.58",
23
+ "@vulog/aima-core": "1.1.58"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "zod": "^3.24.2"
package/src/index.ts CHANGED
@@ -1,3 +1,2 @@
1
- export { getEventsByType, getEvents } from './getEvents';
2
- export type { Event } from './types';
3
- export type { EventFilters, EventType } from './getEvents';
1
+ export * from './types';
2
+ export * from './getEvents';