@webitel/api-services 26.8.21 → 26.8.23

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.21",
3
+ "version": "26.8.23",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -118,6 +118,21 @@ describe('queueSchema', () => {
118
118
  }
119
119
  });
120
120
 
121
+ /** A message here would reach the ui untranslated. WTEL-10294 */
122
+ it('reports a below-minimum number as too_small, without a message', () => {
123
+ const queue = validQueueFor(QueueType.INBOUND_QUEUE);
124
+ queue.priority = -1;
125
+
126
+ const issue = queueSchema
127
+ .safeParse(queue)
128
+ .error?.issues.find((i) => i.path.join('.') === 'priority');
129
+
130
+ expect(issue).toMatchObject({
131
+ code: 'too_small',
132
+ minimum: 0,
133
+ });
134
+ });
135
+
121
136
  /** Vuelidate's `required` treats 0 and false as filled; ours must too. */
122
137
  it('treats a zero priority as filled rather than missing', () => {
123
138
  const queue = validQueueFor(QueueType.INBOUND_QUEUE);
@@ -174,10 +189,20 @@ describe('queueSchema', () => {
174
189
  });
175
190
  });
176
191
 
177
- /** Legacy required `maxAttempts` on six types; the backend never did. WTEL-10326 */
178
- it.each(allQueueTypes)('lets type %i save without maxAttempts', (type) => {
192
+ /**
193
+ * Dialing numbers the legacy switch required and the backend does not.
194
+ * WTEL-10292, WTEL-10326
195
+ */
196
+ const legacyRequiredNumbers = [
197
+ 'payload.maxAttempts',
198
+ 'payload.originateTimeout',
199
+ 'payload.waitBetweenRetries',
200
+ 'payload.maxWaitTime',
201
+ ];
202
+
203
+ it.each(allQueueTypes)('lets type %i save with those cleared', (type) => {
179
204
  const queue = validQueueFor(type);
180
- set(queue, 'payload.maxAttempts', null);
205
+ for (const path of legacyRequiredNumbers) set(queue, path, null);
181
206
 
182
207
  expect(issuePaths(queueSchema.safeParse(queue))).toEqual([]);
183
208
  });
@@ -19,10 +19,10 @@ export interface QueueTypeRule {
19
19
  * queues that save fine today.
20
20
  * - `priority` and `payload.minOnlineAgents` carry `minValue(0)` for *all* ten
21
21
  * types, including the ones whose form never shows `minOnlineAgents`.
22
- * - `payload.originateTimeout`, `payload.waitBetweenRetries` (WTEL-10292) and
23
- * `payload.maxAttempts` (WTEL-10326) drop the legacy `required`: the backend
24
- * takes a queue without them, so it only blocked saving a cleared field.
25
- * Their `minValue` stays — it skips an empty value.
22
+ * - `payload.originateTimeout`, `payload.waitBetweenRetries`, `payload.maxWaitTime`
23
+ * (WTEL-10292) and `payload.maxAttempts` (WTEL-10326) drop the legacy
24
+ * `required`: the backend takes a queue without them, so it only blocked
25
+ * saving a cleared field. Their `minValue` stays — it skips an empty value.
26
26
  */
27
27
  export const sharedQueueRules: QueueTypeRule = {
28
28
  required: [
@@ -47,7 +47,6 @@ export const queueTypeRules: Record<number, QueueTypeRule> = {
47
47
  [QueueType.INBOUND_QUEUE]: {
48
48
  required: [
49
49
  'payload.timeBaseScore',
50
- 'payload.maxWaitTime',
51
50
  ],
52
51
  minValue: {
53
52
  'payload.maxWaitTime': 0,
@@ -109,7 +108,6 @@ export const queueTypeRules: Record<number, QueueTypeRule> = {
109
108
  required: [
110
109
  'strategy',
111
110
  'payload.timeBaseScore',
112
- 'payload.maxWaitTime',
113
111
  ],
114
112
  minValue: {
115
113
  'payload.maxWaitTime': 0,
@@ -121,7 +119,6 @@ export const queueTypeRules: Record<number, QueueTypeRule> = {
121
119
  required: [
122
120
  'strategy',
123
121
  'payload.timeBaseScore',
124
- 'payload.maxWaitTime',
125
122
  ],
126
123
  minValue: {
127
124
  'payload.maxWaitTime': 0,
@@ -132,7 +129,6 @@ export const queueTypeRules: Record<number, QueueTypeRule> = {
132
129
  required: [
133
130
  'strategy',
134
131
  'calendar',
135
- 'payload.waitBetweenRetries',
136
132
  ],
137
133
  minValue: {
138
134
  'payload.waitBetweenRetries': 0,
@@ -88,10 +88,17 @@ export const queueSchema = queueSchemaBase.superRefine((queue, ctx) => {
88
88
  // an absent optional field is the `required` rules' business, not this one
89
89
  if (value === undefined || value === null || value === '') continue;
90
90
  if (Number(value) < min) {
91
+ /**
92
+ * `too_small`, not a message: a message wins over the app's error
93
+ * map, the only thing that translates. WTEL-10294
94
+ */
91
95
  ctx.addIssue({
92
- code: 'custom',
96
+ code: 'too_small',
97
+ origin: 'number',
98
+ minimum: min,
99
+ inclusive: true,
100
+ input: value,
93
101
  path: path.split('.'),
94
- message: `Value must be ${min} or greater`,
95
102
  });
96
103
  }
97
104
  }