@webitel/api-services 26.8.64 → 26.8.66

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.
Files changed (106) hide show
  1. package/package.json +1 -1
  2. package/src/api/clients/agents/agents.ts +28 -56
  3. package/src/enums/AgentStatus/AgentStatus.ts +8 -0
  4. package/src/enums/ChannelState/ChannelState.ts +16 -0
  5. package/src/enums/ChannelType/ChannelType.ts +10 -0
  6. package/src/enums/index.ts +6 -0
  7. package/src/gen/_models/engineListOfMemberCommunication.ts +12 -0
  8. package/src/gen/_models/googleProtobufNullValue.ts +8 -3
  9. package/src/gen/_models/index.ts +10 -1
  10. package/src/gen/_models/messageRead2Params.ts +14 -0
  11. package/src/gen/_models/searchMemberCommunicationParams.ts +13 -0
  12. package/src/gen/_models/{messageReadParams.ts → webitelImApiGatewayV1HandBackToBotResponse.ts} +3 -3
  13. package/src/gen/_models/webitelImApiGatewayV1MessageFailure.ts +17 -0
  14. package/src/gen/_models/webitelImApiGatewayV1MessageFailureError.ts +11 -0
  15. package/src/gen/_models/webitelImApiGatewayV1MessageReadBody.ts +13 -0
  16. package/src/gen/_models/webitelImApiGatewayV1SearchMessageHistoryResponse.ts +1 -1
  17. package/src/gen/_models/webitelImApiGatewayV1SearchThreadResponse.ts +1 -1
  18. package/{types/gen/_models/messageReadParams.d.ts → src/gen/_models/webitelImApiGatewayV1TakeOverFromBotResponse.ts} +4 -3
  19. package/src/gen/_models/webitelImApiGatewayV1Thread.ts +1 -1
  20. package/src/gen/_models/webitelImApiGatewayV1ThreadManagementHandBackToBotBody.ts +10 -0
  21. package/src/gen/_models/webitelImApiGatewayV1ThreadManagementTakeOverFromBotBody.ts +10 -0
  22. package/src/gen/_models/webitelImApiGatewayV1ThreadUpdates.ts +8 -2
  23. package/src/gen-wire/_models/engineListOfMemberCommunication.ts +12 -0
  24. package/src/gen-wire/_models/googleProtobufNullValue.ts +8 -3
  25. package/src/gen-wire/_models/index.ts +10 -1
  26. package/src/gen-wire/_models/messageRead2Params.ts +14 -0
  27. package/src/gen-wire/_models/searchMemberCommunicationParams.ts +13 -0
  28. package/src/gen-wire/_models/{messageReadParams.ts → webitelImApiGatewayV1HandBackToBotResponse.ts} +3 -3
  29. package/src/gen-wire/_models/webitelImApiGatewayV1MessageFailure.ts +17 -0
  30. package/src/gen-wire/_models/webitelImApiGatewayV1MessageFailureError.ts +11 -0
  31. package/src/gen-wire/_models/webitelImApiGatewayV1MessageReadBody.ts +13 -0
  32. package/src/gen-wire/_models/webitelImApiGatewayV1SearchMessageHistoryResponse.ts +1 -1
  33. package/src/gen-wire/_models/webitelImApiGatewayV1SearchThreadResponse.ts +1 -1
  34. package/{types/gen-wire/_models/messageReadParams.d.ts → src/gen-wire/_models/webitelImApiGatewayV1TakeOverFromBotResponse.ts} +4 -3
  35. package/src/gen-wire/_models/webitelImApiGatewayV1Thread.ts +1 -1
  36. package/src/gen-wire/_models/webitelImApiGatewayV1ThreadManagementHandBackToBotBody.ts +10 -0
  37. package/src/gen-wire/_models/webitelImApiGatewayV1ThreadManagementTakeOverFromBotBody.ts +10 -0
  38. package/src/gen-wire/_models/webitelImApiGatewayV1ThreadUpdates.ts +8 -2
  39. package/src/gen-wire/index.ts +13 -1
  40. package/src/gen-wire/member-service/member-service.ts +25 -0
  41. package/src/gen-wire/member-service/member-service.zod.ts +48 -0
  42. package/src/gen-wire/webitel-im-api-gateway-v1-message/webitel-im-api-gateway-v1-message.ts +28 -7
  43. package/src/gen-wire/webitel-im-api-gateway-v1-message/webitel-im-api-gateway-v1-message.zod.ts +39 -6
  44. package/src/gen-wire/webitel-im-api-gateway-v1-messagehistory/webitel-im-api-gateway-v1-messagehistory.zod.ts +3 -3
  45. package/src/gen-wire/webitel-im-api-gateway-v1-threadmanagement/webitel-im-api-gateway-v1-threadmanagement.ts +40 -0
  46. package/src/gen-wire/webitel-im-api-gateway-v1-threadmanagement/webitel-im-api-gateway-v1-threadmanagement.zod.ts +27 -5
  47. package/src/gen-wire/webitel-im-api-gateway-v1-updates/webitel-im-api-gateway-v1-updates.zod.ts +135 -3
  48. package/src/scripts/convertDuration/convertDuration.ts +0 -6
  49. package/src/validations/agent/__tests__/agent.validations.spec.ts +96 -0
  50. package/src/validations/agent/agent.validations.ts +25 -0
  51. package/src/validations/agentSubordinate/__tests__/agentSubordinate.validations.spec.ts +24 -0
  52. package/src/validations/agentSubordinate/agentSubordinate.validations.ts +7 -0
  53. package/src/validations/index.ts +2 -0
  54. package/types/.tsbuildinfo +1 -1
  55. package/types/enums/AgentStatus/AgentStatus.d.ts +7 -0
  56. package/types/enums/ChannelState/ChannelState.d.ts +15 -0
  57. package/types/enums/ChannelType/ChannelType.d.ts +9 -0
  58. package/types/enums/index.d.ts +4 -1
  59. package/types/gen/_models/engineListOfMemberCommunication.d.ts +11 -0
  60. package/types/gen/_models/googleProtobufNullValue.d.ts +8 -3
  61. package/types/gen/_models/index.d.ts +10 -1
  62. package/types/gen/_models/messageRead2Params.d.ts +13 -0
  63. package/types/gen/_models/searchMemberCommunicationParams.d.ts +12 -0
  64. package/types/gen/_models/webitelImApiGatewayV1HandBackToBotResponse.d.ts +9 -0
  65. package/types/gen/_models/webitelImApiGatewayV1MessageFailure.d.ts +16 -0
  66. package/types/gen/_models/webitelImApiGatewayV1MessageFailureError.d.ts +10 -0
  67. package/types/gen/_models/webitelImApiGatewayV1MessageReadBody.d.ts +12 -0
  68. package/types/gen/_models/webitelImApiGatewayV1SearchMessageHistoryResponse.d.ts +1 -1
  69. package/types/gen/_models/webitelImApiGatewayV1SearchThreadResponse.d.ts +1 -1
  70. package/types/gen/_models/webitelImApiGatewayV1TakeOverFromBotResponse.d.ts +9 -0
  71. package/types/gen/_models/webitelImApiGatewayV1Thread.d.ts +1 -1
  72. package/types/gen/_models/webitelImApiGatewayV1ThreadManagementHandBackToBotBody.d.ts +9 -0
  73. package/types/gen/_models/webitelImApiGatewayV1ThreadManagementTakeOverFromBotBody.d.ts +9 -0
  74. package/types/gen/_models/webitelImApiGatewayV1ThreadUpdates.d.ts +8 -2
  75. package/types/gen-wire/_models/engineListOfMemberCommunication.d.ts +11 -0
  76. package/types/gen-wire/_models/googleProtobufNullValue.d.ts +8 -3
  77. package/types/gen-wire/_models/index.d.ts +10 -1
  78. package/types/gen-wire/_models/messageRead2Params.d.ts +13 -0
  79. package/types/gen-wire/_models/searchMemberCommunicationParams.d.ts +12 -0
  80. package/types/gen-wire/_models/webitelImApiGatewayV1HandBackToBotResponse.d.ts +9 -0
  81. package/types/gen-wire/_models/webitelImApiGatewayV1MessageFailure.d.ts +16 -0
  82. package/types/gen-wire/_models/webitelImApiGatewayV1MessageFailureError.d.ts +10 -0
  83. package/types/gen-wire/_models/webitelImApiGatewayV1MessageReadBody.d.ts +12 -0
  84. package/types/gen-wire/_models/webitelImApiGatewayV1SearchMessageHistoryResponse.d.ts +1 -1
  85. package/types/gen-wire/_models/webitelImApiGatewayV1SearchThreadResponse.d.ts +1 -1
  86. package/types/gen-wire/_models/webitelImApiGatewayV1TakeOverFromBotResponse.d.ts +9 -0
  87. package/types/gen-wire/_models/webitelImApiGatewayV1Thread.d.ts +1 -1
  88. package/types/gen-wire/_models/webitelImApiGatewayV1ThreadManagementHandBackToBotBody.d.ts +9 -0
  89. package/types/gen-wire/_models/webitelImApiGatewayV1ThreadManagementTakeOverFromBotBody.d.ts +9 -0
  90. package/types/gen-wire/_models/webitelImApiGatewayV1ThreadUpdates.d.ts +8 -2
  91. package/types/gen-wire/call-service/call-service.zod.d.ts +3 -3
  92. package/types/gen-wire/case-timeline/case-timeline.zod.d.ts +3 -3
  93. package/types/gen-wire/index.d.ts +3 -3
  94. package/types/gen-wire/member-service/member-service.d.ts +3 -1
  95. package/types/gen-wire/member-service/member-service.zod.d.ts +37 -0
  96. package/types/gen-wire/routing-schema-service/routing-schema-service.zod.d.ts +11 -11
  97. package/types/gen-wire/timeline/timeline.zod.d.ts +3 -3
  98. package/types/gen-wire/trigger-service/trigger-service.zod.d.ts +12 -12
  99. package/types/gen-wire/webitel-im-api-gateway-v1-message/webitel-im-api-gateway-v1-message.d.ts +5 -3
  100. package/types/gen-wire/webitel-im-api-gateway-v1-message/webitel-im-api-gateway-v1-message.zod.d.ts +20 -5
  101. package/types/gen-wire/webitel-im-api-gateway-v1-threadmanagement/webitel-im-api-gateway-v1-threadmanagement.d.ts +5 -1
  102. package/types/gen-wire/webitel-im-api-gateway-v1-threadmanagement/webitel-im-api-gateway-v1-threadmanagement.zod.d.ts +16 -0
  103. package/types/gen-wire/webitel-im-api-gateway-v1-updates/webitel-im-api-gateway-v1-updates.zod.d.ts +51 -0
  104. package/types/validations/agent/agent.validations.d.ts +28 -0
  105. package/types/validations/agentSubordinate/agentSubordinate.validations.d.ts +7 -0
  106. package/types/validations/index.d.ts +2 -0
@@ -27,6 +27,7 @@ export const updatesGetUpdatesResponseThreadsItemDialogLastMsgSenderRoleDefault
27
27
  export const updatesGetUpdatesResponseThreadsItemDialogMembersItemRoleDefault = `ROLE_UNSPECIFIED`;
28
28
  export const updatesGetUpdatesResponseThreadsItemDialogReadStatesItemMemberRoleDefault = `ROLE_UNSPECIFIED`;
29
29
  export const updatesGetUpdatesResponseThreadsItemDialogTypeDefault = `UNKNOWN`;
30
+ export const updatesGetUpdatesResponseThreadsItemFailuresItemMemberRoleDefault = `ROLE_UNSPECIFIED`;
30
31
  export const updatesGetUpdatesResponseThreadsItemMemberChangesItemActionDefault = `THREAD_MEMBER_CHANGE_ACTION_UNSPECIFIED`;
31
32
  export const updatesGetUpdatesResponseThreadsItemMemberChangesItemByRoleDefault = `ROLE_UNSPECIFIED`;
32
33
  export const updatesGetUpdatesResponseThreadsItemMemberChangesItemMemberRoleDefault = `ROLE_UNSPECIFIED`;
@@ -1386,7 +1387,7 @@ export const UpdatesGetUpdatesResponse = zod.object({
1386
1387
  .string()
1387
1388
  .optional()
1388
1389
  .describe(
1389
- 'GetUpdates cursor read before this thread (set by Get; Search carries it on the response).',
1390
+ "The caller's GetUpdates cursor as of this read (set by Get; Search carries it on the response).",
1390
1391
  ),
1391
1392
  variables: zod
1392
1393
  .object({
@@ -1500,8 +1501,137 @@ export const UpdatesGetUpdatesResponse = zod.object({
1500
1501
  })
1501
1502
  .optional()
1502
1503
  .describe(
1503
- 'The thread itself, set when it is new to the caller (created or joined since cursor).',
1504
+ 'The thread itself, set when it is new to the caller (created or joined since cursor).\nSame model as the thread list, except last_msg and updates_cursor are never set here.',
1504
1505
  ),
1506
+ failures: zod
1507
+ .array(
1508
+ zod
1509
+ .object({
1510
+ error: zod
1511
+ .object({
1512
+ code: zod.string().optional(),
1513
+ message: zod.string().optional(),
1514
+ })
1515
+ .optional(),
1516
+ member: zod
1517
+ .object({
1518
+ contact: zod
1519
+ .object({
1520
+ app_id: zod
1521
+ .string()
1522
+ .optional()
1523
+ .describe(
1524
+ 'Identifier of the specific integration app or bot.',
1525
+ ),
1526
+ created_at: zod
1527
+ .string()
1528
+ .optional()
1529
+ .describe(
1530
+ 'Record creation timestamp (Unix Epoch in milliseconds).',
1531
+ ),
1532
+ is_bot: zod
1533
+ .boolean()
1534
+ .optional()
1535
+ .describe(
1536
+ 'Represents if usere is real person or automatic script.',
1537
+ ),
1538
+ iss: zod
1539
+ .string()
1540
+ .optional()
1541
+ .describe(
1542
+ 'Provider-specific unique identifier (Issuer ID).',
1543
+ ),
1544
+ metadata: zod
1545
+ .record(zod.string(), zod.string())
1546
+ .optional()
1547
+ .describe(
1548
+ 'Additional dynamic attributes provided by the messenger.',
1549
+ ),
1550
+ name: zod
1551
+ .string()
1552
+ .optional()
1553
+ .describe('Display name of the contact.'),
1554
+ sub: zod
1555
+ .string()
1556
+ .optional()
1557
+ .describe(
1558
+ 'Associated internal system subject/identifier.',
1559
+ ),
1560
+ type: zod
1561
+ .string()
1562
+ .optional()
1563
+ .describe(
1564
+ "Channel type (e.g., 'webchat', 'telegram').",
1565
+ ),
1566
+ updated_at: zod
1567
+ .string()
1568
+ .optional()
1569
+ .describe(
1570
+ 'Last record update timestamp (Unix Epoch in milliseconds).',
1571
+ ),
1572
+ username: zod
1573
+ .string()
1574
+ .optional()
1575
+ .describe('Technical username or handle.'),
1576
+ vias: zod
1577
+ .array(
1578
+ zod.object({
1579
+ contact_id: zod.string().optional(),
1580
+ created_at: zod.string().optional(),
1581
+ disable: zod.boolean().optional(),
1582
+ disable_reason: zod.string().optional(),
1583
+ metadata: zod.looseObject({}).optional(),
1584
+ updated_at: zod.string().optional(),
1585
+ via: zod.string().optional(),
1586
+ }),
1587
+ )
1588
+ .optional(),
1589
+ })
1590
+ .optional()
1591
+ .describe(
1592
+ 'Contact represents an external messaging identity.',
1593
+ ),
1594
+ id: zod.string().optional(),
1595
+ permissions: zod
1596
+ .object({
1597
+ can_add_members: zod.boolean().optional(),
1598
+ can_change_members_permissions: zod
1599
+ .boolean()
1600
+ .optional(),
1601
+ can_change_thread_info: zod.boolean().optional(),
1602
+ can_delete_messages: zod.boolean().optional(),
1603
+ can_remove_members: zod.boolean().optional(),
1604
+ can_send_messages: zod.boolean().optional(),
1605
+ created_at: zod.string().optional(),
1606
+ id: zod.string().optional(),
1607
+ member_id: zod.string().optional(),
1608
+ updated_at: zod.string().optional(),
1609
+ })
1610
+ .optional(),
1611
+ role: zod
1612
+ .enum([
1613
+ 'ROLE_UNSPECIFIED',
1614
+ 'ROLE_MEMBER',
1615
+ 'ROLE_ADMIN',
1616
+ 'ROLE_OWNER',
1617
+ 'ROLE_SUPERVISOR',
1618
+ ])
1619
+ .default(
1620
+ updatesGetUpdatesResponseThreadsItemFailuresItemMemberRoleDefault,
1621
+ ),
1622
+ })
1623
+ .optional()
1624
+ .describe(
1625
+ 'ThreadMember represents a thread participant\nwith optional type-specific settings.',
1626
+ ),
1627
+ message_id: zod.string().optional(),
1628
+ })
1629
+ .describe(
1630
+ 'MessageFailure is a message that could not be delivered to a member.',
1631
+ ),
1632
+ )
1633
+ .optional()
1634
+ .describe('Messages that failed to reach a member since the cursor.'),
1505
1635
  left: zod
1506
1636
  .boolean()
1507
1637
  .optional()
@@ -3341,7 +3471,9 @@ export const UpdatesGetUpdatesResponse = zod.object({
3341
3471
  type: zod.int().optional(),
3342
3472
  })
3343
3473
  .optional()
3344
- .describe('Newest message for the list preview; set with dialog.'),
3474
+ .describe(
3475
+ 'Newest message for the list preview, in place of dialog.last_msg; set with dialog.',
3476
+ ),
3345
3477
  unread_count: zod.string().optional(),
3346
3478
  }),
3347
3479
  )
@@ -1,9 +1,3 @@
1
- /*
2
- * @author @Lera
3
- * fixme: change on library
4
- * https://webitel.atlassian.net/browse/WTEL-7842?focusedCommentId=702198
5
- * */
6
-
7
1
  export interface ConvertDurationOptions {
8
2
  /**
9
3
  * Keep the hours segment when the duration is under an hour.
@@ -0,0 +1,96 @@
1
+ import { getDefaultsFromZodSchema } from '@webitel/api-services/gen/utils';
2
+ import { describe, expect, it } from 'vitest';
3
+
4
+ import { agentSchema } from '../agent.validations';
5
+
6
+ const filledAgent = {
7
+ user: {
8
+ id: '1',
9
+ name: 'John',
10
+ },
11
+ team: {
12
+ id: 2,
13
+ name: 'Support',
14
+ },
15
+ chatCount: 1,
16
+ taskCount: 1,
17
+ };
18
+
19
+ const issuePaths = (value: Record<string, unknown>) =>
20
+ agentSchema
21
+ .safeParse(value)
22
+ .error?.issues.map((issue) => issue.path.join('.')) ?? [];
23
+
24
+ describe('agentSchema', () => {
25
+ it('seeds a new agent with the defaults the form expects', () => {
26
+ expect(getDefaultsFromZodSchema(agentSchema, {})).toMatchObject({
27
+ supervisor: [],
28
+ auditor: [],
29
+ region: {},
30
+ greetingMedia: {},
31
+ progressiveCount: null,
32
+ chatCount: 1,
33
+ taskCount: 1,
34
+ extraChatCount: 0,
35
+ isSupervisor: false,
36
+ screenControl: false,
37
+ });
38
+ });
39
+
40
+ it('requires a user and a team', () => {
41
+ const paths = issuePaths({
42
+ user: {},
43
+ team: {},
44
+ chatCount: 1,
45
+ taskCount: 1,
46
+ });
47
+
48
+ expect(paths).toContain('user');
49
+ expect(paths).toContain('team');
50
+ });
51
+
52
+ it('requires chat and task counts of at least 1', () => {
53
+ const paths = issuePaths({
54
+ ...filledAgent,
55
+ chatCount: 0,
56
+ taskCount: null,
57
+ });
58
+
59
+ expect(paths).toContain('chatCount');
60
+ expect(paths).toContain('taskCount');
61
+ });
62
+
63
+ it('accepts an emptied progressive count, rejects one below 1', () => {
64
+ expect(
65
+ issuePaths({
66
+ ...filledAgent,
67
+ progressiveCount: null,
68
+ }),
69
+ ).not.toContain('progressiveCount');
70
+ expect(
71
+ issuePaths({
72
+ ...filledAgent,
73
+ progressiveCount: 0,
74
+ }),
75
+ ).toContain('progressiveCount');
76
+ });
77
+
78
+ it('accepts an emptied extra chat count, rejects a negative one', () => {
79
+ expect(
80
+ issuePaths({
81
+ ...filledAgent,
82
+ extraChatCount: null,
83
+ }),
84
+ ).not.toContain('extraChatCount');
85
+ expect(
86
+ issuePaths({
87
+ ...filledAgent,
88
+ extraChatCount: -1,
89
+ }),
90
+ ).toContain('extraChatCount');
91
+ });
92
+
93
+ it('accepts a valid agent', () => {
94
+ expect(agentSchema.safeParse(filledAgent).success).toBe(true);
95
+ });
96
+ });
@@ -0,0 +1,25 @@
1
+ import type { EngineAgent } from '@webitel/api-services/gen/models';
2
+ import { z } from 'zod';
3
+
4
+ import {
5
+ filledLookupSchema,
6
+ flexibleLookupSchema,
7
+ } from '../_shared/lookup.validations';
8
+ import type { ZodShape } from '../types';
9
+
10
+ export const agentSchema = z.object<ZodShape<EngineAgent>>({
11
+ id: z.string().optional(),
12
+ user: filledLookupSchema,
13
+ team: filledLookupSchema,
14
+ supervisor: z.array(flexibleLookupSchema).optional().default([]),
15
+ auditor: z.array(flexibleLookupSchema).optional().default([]),
16
+ region: flexibleLookupSchema.optional().default({}),
17
+ greetingMedia: flexibleLookupSchema.optional().default({}),
18
+ progressiveCount: z.number().min(1).nullable().optional().default(null),
19
+ chatCount: z.number().min(1).default(1),
20
+ taskCount: z.number().min(1).default(1),
21
+ extraChatCount: z.number().min(0).nullable().optional().default(0),
22
+ isSupervisor: z.boolean().optional().default(false),
23
+ screenControl: z.boolean().optional().default(false),
24
+ allowSetScreenControl: z.boolean().optional(),
25
+ });
@@ -0,0 +1,24 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { agentSubordinateSchema } from '../agentSubordinate.validations';
4
+
5
+ describe('agentSubordinateSchema', () => {
6
+ it('requires an agent', () => {
7
+ expect(
8
+ agentSubordinateSchema.safeParse({
9
+ agent: {},
10
+ }).success,
11
+ ).toBe(false);
12
+ });
13
+
14
+ it('accepts a picked agent', () => {
15
+ expect(
16
+ agentSubordinateSchema.safeParse({
17
+ agent: {
18
+ id: '1',
19
+ name: 'John',
20
+ },
21
+ }).success,
22
+ ).toBe(true);
23
+ });
24
+ });
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+
3
+ import { filledLookupSchema } from '../_shared/lookup.validations';
4
+
5
+ export const agentSubordinateSchema = z.object({
6
+ agent: filledLookupSchema,
7
+ });
@@ -5,8 +5,10 @@ export * from './_shared/lookup.validations';
5
5
  export * from './_shared/phoneNumber.validations';
6
6
  export * from './_shared/variablePair.validations';
7
7
  export * from './adjunctType/adjunctType.validations';
8
+ export * from './agent/agent.validations';
8
9
  export * from './agentPauseCause/agentPauseCause.validations';
9
10
  export * from './agentSkill/agentSkill.validations';
11
+ export * from './agentSubordinate/agentSubordinate.validations';
10
12
  export * from './auditForm/auditForm.validations';
11
13
  export * from './bucket/bucket.validations';
12
14
  export * from './calendar/calendar.validations';