@vulog/aima-user 1.1.87 → 1.1.89

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.js CHANGED
@@ -508,12 +508,8 @@ var getEntity = async (client, entityId) => {
508
508
 
509
509
  // src/getFleetBillingGroups.ts
510
510
  var import_aima_core = require("@vulog/aima-core");
511
- var import_zod18 = require("zod");
512
511
  var getFleetBillingGroups = async (client, options) => {
513
- const argsSchema5 = import_zod18.z.object({
514
- ids: import_zod18.z.array(import_zod18.z.string().trim().min(1).uuid()).min(1)
515
- });
516
- const PaginableOptionsSchema = (0, import_aima_core.createPaginableOptionsSchema)(argsSchema5).default({});
512
+ const PaginableOptionsSchema = (0, import_aima_core.createPaginableOptionsSchema)().default({});
517
513
  const resultOptions = PaginableOptionsSchema.safeParse(options);
518
514
  if (!resultOptions.success) {
519
515
  throw new TypeError("Invalid options", {
@@ -524,7 +520,9 @@ var getFleetBillingGroups = async (client, options) => {
524
520
  const searchParams = new URLSearchParams();
525
521
  searchParams.append("page", finalOptions.page.toString());
526
522
  searchParams.append("pageSize", finalOptions.pageSize.toString());
527
- return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup?${searchParams.toString()}`).then(({ data, headers }) => {
523
+ return client.get(
524
+ `/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup?${searchParams.toString()}`
525
+ ).then(({ data, headers }) => {
528
526
  return {
529
527
  data,
530
528
  page: headers.number,
@@ -532,13 +530,15 @@ var getFleetBillingGroups = async (client, options) => {
532
530
  total: headers.totalelements,
533
531
  totalPages: headers.totalpages
534
532
  };
533
+ }).catch((error) => {
534
+ throw new Error(`Failed to get fleet billing groups: ${error.message}`);
535
535
  });
536
536
  };
537
537
 
538
538
  // src/getUsersByIds.ts
539
- var import_zod19 = require("zod");
540
- var argsSchema4 = import_zod19.z.object({
541
- ids: import_zod19.z.array(import_zod19.z.string().trim().min(1).uuid()).min(1)
539
+ var import_zod18 = require("zod");
540
+ var argsSchema4 = import_zod18.z.object({
541
+ ids: import_zod18.z.array(import_zod18.z.string().trim().min(1).uuid()).min(1)
542
542
  });
543
543
  var getUsersByIds = async (client, ids) => {
544
544
  const result = argsSchema4.safeParse({ ids });
package/dist/index.mjs CHANGED
@@ -457,12 +457,8 @@ var getEntity = async (client, entityId) => {
457
457
 
458
458
  // src/getFleetBillingGroups.ts
459
459
  import { createPaginableOptionsSchema } from "@vulog/aima-core";
460
- import { z as z18 } from "zod";
461
460
  var getFleetBillingGroups = async (client, options) => {
462
- const argsSchema5 = z18.object({
463
- ids: z18.array(z18.string().trim().min(1).uuid()).min(1)
464
- });
465
- const PaginableOptionsSchema = createPaginableOptionsSchema(argsSchema5).default({});
461
+ const PaginableOptionsSchema = createPaginableOptionsSchema().default({});
466
462
  const resultOptions = PaginableOptionsSchema.safeParse(options);
467
463
  if (!resultOptions.success) {
468
464
  throw new TypeError("Invalid options", {
@@ -473,7 +469,9 @@ var getFleetBillingGroups = async (client, options) => {
473
469
  const searchParams = new URLSearchParams();
474
470
  searchParams.append("page", finalOptions.page.toString());
475
471
  searchParams.append("pageSize", finalOptions.pageSize.toString());
476
- return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup?${searchParams.toString()}`).then(({ data, headers }) => {
472
+ return client.get(
473
+ `/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup?${searchParams.toString()}`
474
+ ).then(({ data, headers }) => {
477
475
  return {
478
476
  data,
479
477
  page: headers.number,
@@ -481,13 +479,15 @@ var getFleetBillingGroups = async (client, options) => {
481
479
  total: headers.totalelements,
482
480
  totalPages: headers.totalpages
483
481
  };
482
+ }).catch((error) => {
483
+ throw new Error(`Failed to get fleet billing groups: ${error.message}`);
484
484
  });
485
485
  };
486
486
 
487
487
  // src/getUsersByIds.ts
488
- import { z as z19 } from "zod";
489
- var argsSchema4 = z19.object({
490
- ids: z19.array(z19.string().trim().min(1).uuid()).min(1)
488
+ import { z as z18 } from "zod";
489
+ var argsSchema4 = z18.object({
490
+ ids: z18.array(z18.string().trim().min(1).uuid()).min(1)
491
491
  });
492
492
  var getUsersByIds = async (client, ids) => {
493
493
  const result = argsSchema4.safeParse({ ids });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulog/aima-user",
3
- "version": "1.1.87",
3
+ "version": "1.1.89",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -19,9 +19,9 @@
19
19
  "author": "Vulog",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@vulog/aima-client": "1.1.87",
23
- "@vulog/aima-config": "1.1.87",
24
- "@vulog/aima-core": "1.1.87"
22
+ "@vulog/aima-client": "1.1.89",
23
+ "@vulog/aima-config": "1.1.89",
24
+ "@vulog/aima-core": "1.1.89"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "zod": "^3.25.76"
@@ -0,0 +1,47 @@
1
+ import { describe, test, expect, vi, beforeEach, afterEach } from 'vitest';
2
+ import { Client } from '@vulog/aima-client';
3
+ import { getFleetBillingGroups } from './getFleetBillingGroups';
4
+
5
+ describe('getFleetBillingGroups', () => {
6
+ const FLEET_ID = 'FLEET_ID';
7
+ const getMock = vi.fn();
8
+ const client = {
9
+ get: getMock,
10
+ clientOptions: {
11
+ fleetId: FLEET_ID,
12
+ },
13
+ } as unknown as Client;
14
+
15
+ beforeEach(() => {
16
+ getMock.mockReset();
17
+ });
18
+
19
+ afterEach(() => {
20
+ vi.restoreAllMocks();
21
+ });
22
+
23
+ test('should return billing groups', async () => {
24
+ const data = [
25
+ {
26
+ id: '1234',
27
+ fleetId: 'FLEET_ID',
28
+ name: 'Transit royal',
29
+ discount: 10,
30
+ overMileageCap: null,
31
+ overMileageRate: null,
32
+ },
33
+ ];
34
+ getMock.mockResolvedValueOnce({
35
+ data,
36
+ headers: {
37
+ number: 0,
38
+ size: 100,
39
+ totalelements: 0,
40
+ totalpages: 0,
41
+ },
42
+ });
43
+ const result = await getFleetBillingGroups(client);
44
+ expect(result).toBeDefined();
45
+ expect(result.data).toEqual(data);
46
+ });
47
+ });
@@ -1,6 +1,6 @@
1
1
  import { Client } from '@vulog/aima-client';
2
2
  import { createPaginableOptionsSchema, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
3
- import { z } from 'zod';
3
+ // import { z } from 'zod';
4
4
 
5
5
  import { BillingGroup } from './types';
6
6
 
@@ -8,11 +8,7 @@ export const getFleetBillingGroups = async (
8
8
  client: Client,
9
9
  options?: PaginableOptions
10
10
  ): Promise<PaginableResponse<BillingGroup>> => {
11
- const argsSchema = z.object({
12
- ids: z.array(z.string().trim().min(1).uuid()).min(1),
13
- });
14
-
15
- const PaginableOptionsSchema = createPaginableOptionsSchema(argsSchema).default({});
11
+ const PaginableOptionsSchema = createPaginableOptionsSchema().default({});
16
12
 
17
13
  const resultOptions = PaginableOptionsSchema.safeParse(options);
18
14
  if (!resultOptions.success) {
@@ -28,9 +24,9 @@ export const getFleetBillingGroups = async (
28
24
  searchParams.append('pageSize', finalOptions.pageSize!.toString());
29
25
 
30
26
  return client
31
- .get<
32
- BillingGroup[]
33
- >(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup?${searchParams.toString()}`)
27
+ .get<BillingGroup[]>(
28
+ `/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/billingGroup?${searchParams.toString()}`
29
+ )
34
30
  .then(({ data, headers }) => {
35
31
  return {
36
32
  data,
@@ -39,5 +35,8 @@ export const getFleetBillingGroups = async (
39
35
  total: headers.totalelements,
40
36
  totalPages: headers.totalpages,
41
37
  };
38
+ })
39
+ .catch((error) => {
40
+ throw new Error(`Failed to get fleet billing groups: ${error.message}`);
42
41
  });
43
42
  };