@webitel/api-services 26.8.34 → 26.8.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/api-services",
3
- "version": "26.8.34",
3
+ "version": "26.8.36",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -93,6 +93,10 @@
93
93
  "types": "./src/gen/_models/index.ts",
94
94
  "import": "./src/gen/_models/index.ts"
95
95
  },
96
+ "./gen/models/*": {
97
+ "types": "./src/gen/_models/*.ts",
98
+ "import": "./src/gen/_models/*.ts"
99
+ },
96
100
  "./gen-wire": {
97
101
  "types": "./src/gen-wire/index.ts",
98
102
  "import": "./src/gen-wire/index.ts"
@@ -3,18 +3,34 @@
3
3
  * fixme: change on library
4
4
  * https://webitel.atlassian.net/browse/WTEL-7842?focusedCommentId=702198
5
5
  * */
6
- const convertDuration = (duration: number) => {
7
- if (!duration) return '00:00:00';
8
6
 
9
- let hour = `${Math.floor(duration / 3600)}`;
10
- let min = `${Math.floor((duration % 3600) / 60)}`;
11
- let sec = `${Math.floor((duration % 3600) % 60)}`;
7
+ export interface ConvertDurationOptions {
8
+ /**
9
+ * Keep the hours segment when the duration is under an hour.
10
+ *
11
+ * `true` (the default) preserves the long-standing `HH:MM:SS` output, which
12
+ * live timers rely on to stay a fixed width as they tick past an hour.
13
+ * `false` yields `MM:SS` below an hour and `HH:MM:SS` above it — for compact
14
+ * places where a leading `00:` is noise.
15
+ */
16
+ alwaysShowHours?: boolean;
17
+ }
12
18
 
13
- if (hour.length === 1) hour = `0${hour}`;
14
- if (min.length === 1) min = `0${min}`;
15
- if (sec.length === 1) sec = `0${sec}`;
19
+ const pad = (value: number) => `${value}`.padStart(2, '0');
16
20
 
17
- return `${hour}:${min}:${sec}`;
21
+ const convertDuration = (
22
+ duration: number,
23
+ { alwaysShowHours = true }: ConvertDurationOptions = {},
24
+ ) => {
25
+ if (!duration) return alwaysShowHours ? '00:00:00' : '00:00';
26
+
27
+ const hours = Math.floor(duration / 3600);
28
+ const minutes = Math.floor((duration % 3600) / 60);
29
+ const seconds = Math.floor((duration % 3600) % 60);
30
+
31
+ const time = `${pad(minutes)}:${pad(seconds)}`;
32
+
33
+ return alwaysShowHours || hours > 0 ? `${pad(hours)}:${time}` : time;
18
34
  };
19
35
 
20
36
  export default convertDuration;
@@ -1,6 +1,7 @@
1
1
  import { getDefaultsFromZodSchema } from '@webitel/api-services/gen/utils';
2
2
  import { describe, expect, it } from 'vitest';
3
3
  import type { z } from 'zod';
4
+ import * as validationsIndex from '../../index';
4
5
  import {
5
6
  calendarSchema,
6
7
  getCalendarDayRangeIssues,
@@ -659,11 +660,11 @@ describe('calendarSchema', () => {
659
660
  });
660
661
 
661
662
  describe('validations barrel export', () => {
662
- it('re-exports calendarSchema from the validations index', async () => {
663
- const index = await import('../../index');
664
-
665
- expect(index.calendarSchema).toBe(calendarSchema);
666
- expect(typeof index.calendarSchema.parse).toBe('function');
663
+ // Imported statically: resolving the barrel lazily made the transform cost
664
+ // land inside the test's own timeout.
665
+ it('re-exports calendarSchema from the validations index', () => {
666
+ expect(validationsIndex.calendarSchema).toBe(calendarSchema);
667
+ expect(typeof validationsIndex.calendarSchema.parse).toBe('function');
667
668
  });
668
669
  });
669
670