@webitel/api-services 1.0.10 → 1.0.12
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 +1 -1
- package/src/api/clients/__tests__/wireParamsCoverage.spec.ts +286 -0
- package/src/api/clients/activeCalls/activeCalls.ts +72 -0
- package/src/api/clients/agentPauseCauses/agentPauseCauses.ts +182 -0
- package/src/api/clients/agentSkills/agentSkills.ts +193 -0
- package/src/api/clients/agents/__tests__/agents.wireParams.spec.ts +51 -0
- package/src/api/clients/agents/agents.ts +203 -18
- package/src/api/clients/auditForms/auditForms.ts +6 -2
- package/src/api/clients/auditForms/auditRates.ts +91 -0
- package/src/api/clients/backendProfiles/backendProfiles.ts +194 -0
- package/src/api/clients/buckets/buckets.ts +21 -25
- package/src/api/clients/callHistory/callAnnotations.ts +91 -0
- package/src/api/clients/callHistory/callHistory.ts +76 -7
- package/src/api/clients/casePriorities/__tests__/casePriorities.spec.ts +50 -0
- package/src/api/clients/casePriorities/casePriorities.ts +25 -41
- package/src/api/clients/caseStatusConditions/caseStatusConditions.ts +19 -29
- package/src/api/clients/caseStatuses/caseStatuses.ts +10 -21
- package/src/api/clients/catalog/catalog.ts +2 -8
- package/src/api/clients/changelogs/changelogs.ts +8 -0
- package/src/api/clients/chatplans/chatplans.ts +173 -0
- package/src/api/clients/cognitiveProfiles/cognitiveProfiles.ts +209 -0
- package/src/api/clients/communications/communications.ts +38 -42
- package/src/api/clients/dialplans/dialplans.ts +197 -0
- package/src/api/clients/emailProfiles/emailProfiles.ts +222 -0
- package/src/api/clients/fileServices/fileServices.ts +7 -2
- package/src/api/clients/flows/flow.ts +54 -43
- package/src/api/clients/fts/fts.ts +61 -0
- package/src/api/clients/history/transcript/callTranscript.ts +10 -20
- package/src/api/clients/importTemplates/importTemplates.ts +180 -0
- package/src/api/clients/index.ts +30 -0
- package/src/api/clients/lists/blacklistNumbers.ts +155 -0
- package/src/api/clients/lists/blacklists.ts +20 -25
- package/src/api/clients/logs/logs.ts +157 -0
- package/src/api/clients/media/media.ts +19 -15
- package/src/api/clients/object/object.ts +3 -14
- package/src/api/clients/outboundResourceGroups/outboundResourceGroups.ts +187 -0
- package/src/api/clients/outboundResourceGroups/resourcesInGroup.ts +169 -0
- package/src/api/clients/outboundResources/outboundResources.ts +225 -0
- package/src/api/clients/outboundResources/resourceDisplays.ts +165 -0
- package/src/api/clients/pauseTemplates/pauseTemplates.ts +203 -0
- package/src/api/clients/queues/__tests__/queueLogs.spec.ts +3 -3
- package/src/api/clients/queues/__tests__/queueMembers.spec.ts +4 -4
- package/src/api/clients/queues/queueLogs.ts +8 -3
- package/src/api/clients/queues/queueMembers.ts +3 -3
- package/src/api/clients/queues/queues.ts +52 -0
- package/src/api/clients/regions/regions.ts +21 -25
- package/src/api/clients/schemaVariables/schemaVariables.ts +167 -0
- package/src/api/clients/shiftTemplates/shiftTemplates.ts +176 -0
- package/src/api/clients/skills/skillAgents.ts +190 -0
- package/src/api/clients/skills/skills.ts +21 -25
- package/src/api/clients/storagePolicies/storagePolicies.ts +270 -0
- package/src/api/clients/teamHooks/teamHooks.ts +195 -0
- package/src/api/clients/teamTriggers/agentTriggers.ts +77 -0
- package/src/api/clients/teamTriggers/teamFlows.ts +194 -0
- package/src/api/clients/teams/teams.ts +31 -31
- package/src/api/clients/triggers/triggerJobs.ts +63 -0
- package/src/api/clients/triggers/triggers.ts +266 -0
- package/src/api/clients/userSettings/userSettings.ts +8 -9
- package/src/api/clients/users/users.ts +2 -0
- package/src/api/clients/workingConditions/workingConditions.ts +184 -0
- package/src/api/clients/workspaceWidgets/workspaceWidgets.ts +73 -0
- package/src/api/clients//321/201ontacts/contactChatMessagesHistory.ts +15 -26
- package/src/validations/calendar/__tests__/calendar.validations.spec.ts +85 -0
- package/src/validations/calendar/calendar.validations.ts +1 -1
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/activeCalls/activeCalls.d.ts +7 -0
- package/types/api/clients/agentPauseCauses/agentPauseCauses.d.ts +21 -0
- package/types/api/clients/agentSkills/agentSkills.d.ts +12 -0
- package/types/api/clients/agents/agents.d.ts +23 -2
- package/types/api/clients/auditForms/auditForms.d.ts +7 -0
- package/types/api/clients/auditForms/auditRates.d.ts +10 -0
- package/types/api/clients/backendProfiles/backendProfiles.d.ts +21 -0
- package/types/api/clients/callHistory/callAnnotations.d.ts +12 -0
- package/types/api/clients/callHistory/callHistory.d.ts +24 -3
- package/types/api/clients/chatplans/chatplans.d.ts +21 -0
- package/types/api/clients/cognitiveProfiles/cognitiveProfiles.d.ts +21 -0
- package/types/api/clients/dialplans/dialplans.d.ts +16 -0
- package/types/api/clients/emailProfiles/emailProfiles.d.ts +27 -0
- package/types/api/clients/fileServices/fileServices.d.ts +1 -1
- package/types/api/clients/fts/fts.d.ts +7 -0
- package/types/api/clients/importTemplates/importTemplates.d.ts +21 -0
- package/types/api/clients/index.d.ts +30 -0
- package/types/api/clients/lists/blacklistNumbers.d.ts +11 -0
- package/types/api/clients/logs/logs.d.ts +15 -0
- package/types/api/clients/outboundResourceGroups/outboundResourceGroups.d.ts +20 -0
- package/types/api/clients/outboundResourceGroups/resourcesInGroup.d.ts +11 -0
- package/types/api/clients/outboundResources/outboundResources.d.ts +21 -0
- package/types/api/clients/outboundResources/resourceDisplays.d.ts +11 -0
- package/types/api/clients/pauseTemplates/pauseTemplates.d.ts +20 -0
- package/types/api/clients/queues/queues.d.ts +5 -0
- package/types/api/clients/schemaVariables/schemaVariables.d.ts +21 -0
- package/types/api/clients/shiftTemplates/shiftTemplates.d.ts +20 -0
- package/types/api/clients/skills/skillAgents.d.ts +13 -0
- package/types/api/clients/storagePolicies/storagePolicies.d.ts +26 -0
- package/types/api/clients/teamHooks/teamHooks.d.ts +12 -0
- package/types/api/clients/teamTriggers/agentTriggers.d.ts +23 -0
- package/types/api/clients/teamTriggers/teamFlows.d.ts +12 -0
- package/types/api/clients/triggers/triggerJobs.d.ts +7 -0
- package/types/api/clients/triggers/triggers.d.ts +22 -0
- package/types/api/clients/userSettings/userSettings.d.ts +2 -2
- package/types/api/clients/workingConditions/workingConditions.d.ts +20 -0
- package/types/api/clients/workspaceWidgets/workspaceWidgets.d.ts +3 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { getWorkingConditionService } from '../../../gen-wire';
|
|
2
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
3
|
+
import {
|
|
4
|
+
applyTransform,
|
|
5
|
+
camelToSnake,
|
|
6
|
+
merge,
|
|
7
|
+
notify,
|
|
8
|
+
sanitize,
|
|
9
|
+
snakeToCamel,
|
|
10
|
+
} from '../../transformers';
|
|
11
|
+
import type {
|
|
12
|
+
AddItemParams,
|
|
13
|
+
ApiParams,
|
|
14
|
+
DeleteItemParams,
|
|
15
|
+
GetItemParams,
|
|
16
|
+
UpdateItemParams,
|
|
17
|
+
} from '../_shared/types';
|
|
18
|
+
|
|
19
|
+
const fieldsToSend = [
|
|
20
|
+
'name',
|
|
21
|
+
'description',
|
|
22
|
+
'workdayHours',
|
|
23
|
+
'workdayPerMonth',
|
|
24
|
+
'pauseDuration',
|
|
25
|
+
'vacation',
|
|
26
|
+
'pauseTemplate',
|
|
27
|
+
'sickLeaves',
|
|
28
|
+
'shiftTemplate',
|
|
29
|
+
'daysOff',
|
|
30
|
+
'createdAt',
|
|
31
|
+
'createdBy',
|
|
32
|
+
'domainId',
|
|
33
|
+
'id',
|
|
34
|
+
'updatedAt',
|
|
35
|
+
'updatedBy',
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* WFM services wrap both request and response payloads in an `item` envelope.
|
|
40
|
+
*/
|
|
41
|
+
const itemResponseHandler = (response: ApiParams) => ({
|
|
42
|
+
...response.item,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const getWorkingConditionsList = async (params: ApiParams) => {
|
|
46
|
+
const {
|
|
47
|
+
search: q,
|
|
48
|
+
page,
|
|
49
|
+
size,
|
|
50
|
+
sort,
|
|
51
|
+
fields,
|
|
52
|
+
} = applyTransform(params, [
|
|
53
|
+
merge(getDefaultGetParams()),
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
const response =
|
|
58
|
+
await getWorkingConditionService().workingConditionServiceSearchWorkingCondition(
|
|
59
|
+
{
|
|
60
|
+
page,
|
|
61
|
+
size,
|
|
62
|
+
q,
|
|
63
|
+
sort,
|
|
64
|
+
fields,
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
const { items, next } = applyTransform(response.data, [
|
|
68
|
+
snakeToCamel(),
|
|
69
|
+
merge(getDefaultGetListResponse()),
|
|
70
|
+
]);
|
|
71
|
+
return {
|
|
72
|
+
items,
|
|
73
|
+
next,
|
|
74
|
+
};
|
|
75
|
+
} catch (err) {
|
|
76
|
+
throw applyTransform(err, [
|
|
77
|
+
notify,
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const getWorkingCondition = async ({ itemId: id }: GetItemParams) => {
|
|
83
|
+
try {
|
|
84
|
+
const response =
|
|
85
|
+
await getWorkingConditionService().workingConditionServiceReadWorkingCondition(
|
|
86
|
+
String(id),
|
|
87
|
+
);
|
|
88
|
+
return applyTransform(response.data, [
|
|
89
|
+
snakeToCamel(),
|
|
90
|
+
itemResponseHandler,
|
|
91
|
+
]);
|
|
92
|
+
} catch (err) {
|
|
93
|
+
throw applyTransform(err, [
|
|
94
|
+
notify,
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const addWorkingCondition = async ({ itemInstance }: AddItemParams) => {
|
|
100
|
+
const item = applyTransform(itemInstance, [
|
|
101
|
+
sanitize(fieldsToSend),
|
|
102
|
+
camelToSnake(),
|
|
103
|
+
]);
|
|
104
|
+
try {
|
|
105
|
+
const response =
|
|
106
|
+
await getWorkingConditionService().workingConditionServiceCreateWorkingCondition(
|
|
107
|
+
{
|
|
108
|
+
item: {
|
|
109
|
+
...item,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
return applyTransform(response.data, [
|
|
114
|
+
snakeToCamel(),
|
|
115
|
+
itemResponseHandler,
|
|
116
|
+
]);
|
|
117
|
+
} catch (err) {
|
|
118
|
+
throw applyTransform(err, [
|
|
119
|
+
notify,
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const updateWorkingCondition = async ({
|
|
125
|
+
itemInstance,
|
|
126
|
+
itemId: id,
|
|
127
|
+
}: UpdateItemParams) => {
|
|
128
|
+
const item = applyTransform(itemInstance, [
|
|
129
|
+
sanitize(fieldsToSend),
|
|
130
|
+
camelToSnake(),
|
|
131
|
+
]);
|
|
132
|
+
try {
|
|
133
|
+
const response =
|
|
134
|
+
await getWorkingConditionService().workingConditionServiceUpdateWorkingCondition(
|
|
135
|
+
String(id),
|
|
136
|
+
{
|
|
137
|
+
item: {
|
|
138
|
+
...item,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
);
|
|
142
|
+
return applyTransform(response.data, [
|
|
143
|
+
snakeToCamel(),
|
|
144
|
+
]);
|
|
145
|
+
} catch (err) {
|
|
146
|
+
throw applyTransform(err, [
|
|
147
|
+
notify,
|
|
148
|
+
]);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const deleteWorkingCondition = async ({ id }: DeleteItemParams) => {
|
|
153
|
+
try {
|
|
154
|
+
const response =
|
|
155
|
+
await getWorkingConditionService().workingConditionServiceDeleteWorkingCondition(
|
|
156
|
+
String(id),
|
|
157
|
+
);
|
|
158
|
+
return applyTransform(response.data, []);
|
|
159
|
+
} catch (err) {
|
|
160
|
+
throw applyTransform(err, [
|
|
161
|
+
notify,
|
|
162
|
+
]);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const getWorkingConditionsLookup = (
|
|
167
|
+
params: Parameters<typeof getWorkingConditionsList>[0],
|
|
168
|
+
) =>
|
|
169
|
+
getWorkingConditionsList({
|
|
170
|
+
...params,
|
|
171
|
+
fields: params.fields || [
|
|
172
|
+
'id',
|
|
173
|
+
'name',
|
|
174
|
+
],
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export const WorkingConditionsAPI = {
|
|
178
|
+
getList: getWorkingConditionsList,
|
|
179
|
+
get: getWorkingCondition,
|
|
180
|
+
add: addWorkingCondition,
|
|
181
|
+
update: updateWorkingCondition,
|
|
182
|
+
delete: deleteWorkingCondition,
|
|
183
|
+
getLookup: getWorkingConditionsLookup,
|
|
184
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { getUserHelperService } from '../../../gen-wire';
|
|
2
|
+
import { convertDuration } from '../../../scripts';
|
|
3
|
+
import {
|
|
4
|
+
applyTransform,
|
|
5
|
+
merge,
|
|
6
|
+
notify,
|
|
7
|
+
snakeToCamel,
|
|
8
|
+
} from '../../transformers';
|
|
9
|
+
import type { ApiParams } from '../_shared/types';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The agent workspace's activity widget bar: one flat stats object, with the
|
|
13
|
+
* duration fields pre-formatted for display.
|
|
14
|
+
*/
|
|
15
|
+
const getWorkspaceWidgets = async () => {
|
|
16
|
+
const defaultObject = {
|
|
17
|
+
callInbound: 0,
|
|
18
|
+
callHandled: 0,
|
|
19
|
+
callMissed: 0,
|
|
20
|
+
callManual: 0,
|
|
21
|
+
callQueueMissed: 0,
|
|
22
|
+
callInboundQueue: 0,
|
|
23
|
+
callDialerQueue: 0,
|
|
24
|
+
avgHoldSec: 0,
|
|
25
|
+
avgTalkSec: 0,
|
|
26
|
+
occupancy: 0,
|
|
27
|
+
utilization: 0,
|
|
28
|
+
chatAccepts: 0,
|
|
29
|
+
chatAht: 0,
|
|
30
|
+
scoreCount: 0,
|
|
31
|
+
scoreRequiredAvg: 0,
|
|
32
|
+
sumTalkSec: 0,
|
|
33
|
+
processing: 0,
|
|
34
|
+
available: 0,
|
|
35
|
+
voiceMail: 0,
|
|
36
|
+
queueTalkSec: 0,
|
|
37
|
+
taskAccepts: 0,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const responseHandler = (stats: ApiParams) => ({
|
|
41
|
+
...stats,
|
|
42
|
+
avgHoldSec: convertDuration(stats.avgHoldSec),
|
|
43
|
+
avgTalkSec: convertDuration(stats.avgTalkSec),
|
|
44
|
+
occupancy: `${stats.occupancy.toFixed(2)}%`,
|
|
45
|
+
utilization: `${stats.utilization.toFixed(2)}%`,
|
|
46
|
+
chatAht: convertDuration(stats.chatAht),
|
|
47
|
+
sumTalkSec: convertDuration(stats.sumTalkSec),
|
|
48
|
+
processing: convertDuration(stats.processing),
|
|
49
|
+
voiceMail: convertDuration(stats.voiceMail),
|
|
50
|
+
queueTalkSec: convertDuration(stats.queueTalkSec),
|
|
51
|
+
available: convertDuration(stats.available),
|
|
52
|
+
|
|
53
|
+
// left unformatted on purpose: https://webitel.atlassian.net/browse/DEV-4691?focusedCommentId=637940
|
|
54
|
+
scoreRequiredAvg: stats.scoreRequiredAvg,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const response = await getUserHelperService().activityWorkspaceWidget();
|
|
59
|
+
return applyTransform(response.data, [
|
|
60
|
+
snakeToCamel(),
|
|
61
|
+
merge(defaultObject),
|
|
62
|
+
responseHandler,
|
|
63
|
+
]);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
throw applyTransform(err, [
|
|
66
|
+
notify,
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const WorkspaceWidgetsAPI = {
|
|
72
|
+
getWidgets: getWorkspaceWidgets,
|
|
73
|
+
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
getDefaultGetListResponse,
|
|
4
|
-
getDefaultInstance,
|
|
5
|
-
getDefaultOpenAPIConfig,
|
|
6
|
-
} from '../../defaults';
|
|
1
|
+
import { getContactsChatCatalog } from '../../../gen-wire';
|
|
2
|
+
import { getDefaultGetListResponse } from '../../defaults';
|
|
7
3
|
import {
|
|
8
4
|
applyTransform,
|
|
9
5
|
merge,
|
|
@@ -12,15 +8,6 @@ import {
|
|
|
12
8
|
} from '../../transformers';
|
|
13
9
|
import type { ApiId, ApiParams } from '../_shared/types';
|
|
14
10
|
|
|
15
|
-
const instance = getDefaultInstance();
|
|
16
|
-
const configuration = getDefaultOpenAPIConfig();
|
|
17
|
-
|
|
18
|
-
const contactChatService = ContactsChatCatalogApiFactory(
|
|
19
|
-
configuration,
|
|
20
|
-
'',
|
|
21
|
-
instance,
|
|
22
|
-
);
|
|
23
|
-
|
|
24
11
|
const getChat = async ({
|
|
25
12
|
contactId,
|
|
26
13
|
chatId,
|
|
@@ -45,10 +32,11 @@ const getChat = async ({
|
|
|
45
32
|
};
|
|
46
33
|
|
|
47
34
|
try {
|
|
48
|
-
const response =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
const response =
|
|
36
|
+
await getContactsChatCatalog().contactsChatCatalogGetContactChatHistory(
|
|
37
|
+
String(contactId),
|
|
38
|
+
String(chatId),
|
|
39
|
+
);
|
|
52
40
|
const { messages, peers } = applyTransform(response.data, [
|
|
53
41
|
snakeToCamel(),
|
|
54
42
|
]);
|
|
@@ -95,13 +83,14 @@ const getAllMessages = async (params: ApiParams) => {
|
|
|
95
83
|
const { contactId, page, size } = params;
|
|
96
84
|
|
|
97
85
|
try {
|
|
98
|
-
const response =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
86
|
+
const response =
|
|
87
|
+
await getContactsChatCatalog().contactsChatCatalogGetContactChatHistory2(
|
|
88
|
+
contactId,
|
|
89
|
+
{
|
|
90
|
+
size,
|
|
91
|
+
page: page || 1,
|
|
92
|
+
},
|
|
93
|
+
);
|
|
105
94
|
const { messages, peers, chats, next } = applyTransform(response.data, [
|
|
106
95
|
snakeToCamel(),
|
|
107
96
|
merge(getDefaultGetListResponse()),
|
|
@@ -453,6 +453,91 @@ describe('calendarSchema', () => {
|
|
|
453
453
|
).toBe(true);
|
|
454
454
|
}
|
|
455
455
|
});
|
|
456
|
+
|
|
457
|
+
it('rejects overlapping special intervals on the same day', () => {
|
|
458
|
+
const result = calendarSchema.safeParse({
|
|
459
|
+
...minimalValidInput,
|
|
460
|
+
specials: [
|
|
461
|
+
{
|
|
462
|
+
day: 1,
|
|
463
|
+
disabled: false,
|
|
464
|
+
start: 540,
|
|
465
|
+
end: 720,
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
day: 1,
|
|
469
|
+
disabled: false,
|
|
470
|
+
start: 600,
|
|
471
|
+
end: 780,
|
|
472
|
+
},
|
|
473
|
+
],
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
expect(result.success).toBe(false);
|
|
477
|
+
if (!result.success) {
|
|
478
|
+
const intersectIssues = result.error.issues.filter(
|
|
479
|
+
(issue) => issueKey(issue) === 'timerangeNotIntersect',
|
|
480
|
+
);
|
|
481
|
+
expect(intersectIssues.length).toBeGreaterThan(0);
|
|
482
|
+
expect(
|
|
483
|
+
intersectIssues.some(
|
|
484
|
+
(issue) => issue.path.join('.') === 'specials.0.start',
|
|
485
|
+
),
|
|
486
|
+
).toBe(true);
|
|
487
|
+
expect(
|
|
488
|
+
intersectIssues.some(
|
|
489
|
+
(issue) => issue.path.join('.') === 'specials.1.end',
|
|
490
|
+
),
|
|
491
|
+
).toBe(true);
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
it('accepts non-overlapping special intervals on the same day', () => {
|
|
496
|
+
const result = calendarSchema.safeParse({
|
|
497
|
+
...minimalValidInput,
|
|
498
|
+
specials: [
|
|
499
|
+
{
|
|
500
|
+
day: 1,
|
|
501
|
+
disabled: false,
|
|
502
|
+
start: 540,
|
|
503
|
+
end: 600,
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
day: 1,
|
|
507
|
+
disabled: false,
|
|
508
|
+
start: 660,
|
|
509
|
+
end: 720,
|
|
510
|
+
},
|
|
511
|
+
],
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
expect(result.success).toBe(true);
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
it('rejects a special entry with start greater than end', () => {
|
|
518
|
+
const result = calendarSchema.safeParse({
|
|
519
|
+
...minimalValidInput,
|
|
520
|
+
specials: [
|
|
521
|
+
{
|
|
522
|
+
day: 0,
|
|
523
|
+
disabled: false,
|
|
524
|
+
start: 720,
|
|
525
|
+
end: 600,
|
|
526
|
+
},
|
|
527
|
+
],
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
expect(result.success).toBe(false);
|
|
531
|
+
if (!result.success) {
|
|
532
|
+
expect(
|
|
533
|
+
result.error.issues.some(
|
|
534
|
+
(issue) =>
|
|
535
|
+
issueKey(issue) === 'timerangeStartLessThanEnd' &&
|
|
536
|
+
issue.path.join('.') === 'specials.0.start',
|
|
537
|
+
),
|
|
538
|
+
).toBe(true);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
456
541
|
});
|
|
457
542
|
|
|
458
543
|
describe('excepts', () => {
|
|
@@ -209,6 +209,6 @@ export const calendarSchema = z.object<
|
|
|
209
209
|
endAt: z.any().optional(),
|
|
210
210
|
expires: z.boolean().optional().default(false),
|
|
211
211
|
accepts: acceptsOfDayUiArraySchema.default(defaultAccepts),
|
|
212
|
-
specials:
|
|
212
|
+
specials: acceptsOfDayUiArraySchema.default(defaultSpecials),
|
|
213
213
|
excepts: z.array(calendarExceptSchema).optional().default([]),
|
|
214
214
|
});
|