@webitel/api-services 26.12.24 → 26.12.26
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/triggers/triggers.ts +19 -11
- package/src/validations/changelog/changelog.validations.ts +1 -2
- package/src/validations/emailProfile/emailProfile.validations.ts +1 -2
- package/src/validations/importTemplate/importTemplate.validations.ts +1 -1
- package/src/validations/trigger/__tests__/trigger.validations.spec.ts +7 -0
- package/src/validations/trigger/trigger.validations.ts +1 -2
- package/types/.tsbuildinfo +1 -1
- package/types/validations/importTemplate/importTemplate.validations.d.ts +1 -1
- package/types/validations/trigger/trigger.validations.d.ts +1 -1
package/package.json
CHANGED
|
@@ -47,6 +47,21 @@ const preRequestHandler = (item: ApiParams) => {
|
|
|
47
47
|
return copy;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* [Claude] The API returns `variables` as a map, the form binds a `{ key, value }[]`.
|
|
52
|
+
* Applied to every item response: the card store keeps the add/update response
|
|
53
|
+
* as the item, without a refetch.
|
|
54
|
+
*/
|
|
55
|
+
const itemResponseHandler = (response: ApiParams) => {
|
|
56
|
+
const copy = deepCopy(response);
|
|
57
|
+
// [Claude] a trigger without variables gets `{}` (or nothing), which the form needs as `[]` too
|
|
58
|
+
copy.variables = Object.keys(copy.variables ?? {}).map((key) => ({
|
|
59
|
+
key,
|
|
60
|
+
value: copy.variables[key],
|
|
61
|
+
}));
|
|
62
|
+
return copy;
|
|
63
|
+
};
|
|
64
|
+
|
|
50
65
|
const getTriggersList = async (params: ApiParams) => {
|
|
51
66
|
const listFieldsToSend = [
|
|
52
67
|
'page',
|
|
@@ -104,22 +119,12 @@ const getTrigger = async ({ itemId: id }: GetItemParams) => {
|
|
|
104
119
|
variables: {},
|
|
105
120
|
};
|
|
106
121
|
|
|
107
|
-
const responseHandler = (response: ApiParams) => {
|
|
108
|
-
const copy = deepCopy(response);
|
|
109
|
-
// [Claude] a trigger without variables gets the default `{}`, which the form needs as `[]` too
|
|
110
|
-
copy.variables = Object.keys(copy.variables ?? {}).map((key) => ({
|
|
111
|
-
key,
|
|
112
|
-
value: copy.variables[key],
|
|
113
|
-
}));
|
|
114
|
-
return copy;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
122
|
try {
|
|
118
123
|
const response = await getTriggerService().readTrigger(Number(id));
|
|
119
124
|
return applyTransform(response.data, [
|
|
120
125
|
snakeToCamel(doNotConvertKeys),
|
|
121
126
|
merge(defaultObject),
|
|
122
|
-
|
|
127
|
+
itemResponseHandler,
|
|
123
128
|
]);
|
|
124
129
|
} catch (err) {
|
|
125
130
|
throw applyTransform(err, [
|
|
@@ -138,6 +143,7 @@ const addTrigger = async ({ itemInstance }: AddItemParams) => {
|
|
|
138
143
|
const response = await getTriggerService().createTrigger(item);
|
|
139
144
|
return applyTransform(response.data, [
|
|
140
145
|
snakeToCamel(doNotConvertKeys),
|
|
146
|
+
itemResponseHandler,
|
|
141
147
|
]);
|
|
142
148
|
} catch (err) {
|
|
143
149
|
throw applyTransform(err, [
|
|
@@ -155,6 +161,7 @@ const patchTrigger = async ({ changes, id }: PatchItemParams) => {
|
|
|
155
161
|
const response = await getTriggerService().patchTrigger(Number(id), body);
|
|
156
162
|
return applyTransform(response.data, [
|
|
157
163
|
snakeToCamel(doNotConvertKeys),
|
|
164
|
+
itemResponseHandler,
|
|
158
165
|
]);
|
|
159
166
|
} catch (err) {
|
|
160
167
|
throw applyTransform(err, [
|
|
@@ -176,6 +183,7 @@ const updateTrigger = async ({
|
|
|
176
183
|
const response = await getTriggerService().updateTrigger(Number(id), item);
|
|
177
184
|
return applyTransform(response.data, [
|
|
178
185
|
snakeToCamel(doNotConvertKeys),
|
|
186
|
+
itemResponseHandler,
|
|
179
187
|
]);
|
|
180
188
|
} catch (err) {
|
|
181
189
|
throw applyTransform(err, [
|
|
@@ -12,8 +12,7 @@ export type ChangelogCard = LoggerConfig;
|
|
|
12
12
|
/** [Claude] Changelog card schema: which object is logged, where the logs go and for how long. */
|
|
13
13
|
export const changelogSchema = z.object<ZodShape<LoggerConfig>>({
|
|
14
14
|
id: z.number().optional(),
|
|
15
|
-
|
|
16
|
-
object: filledLookupSchema.prefault({}),
|
|
15
|
+
object: filledLookupSchema.default({}),
|
|
17
16
|
storage: flexibleLookupSchema.optional().default({}),
|
|
18
17
|
daysToStore: z.number().min(1).default(7),
|
|
19
18
|
period: z.number().default(7),
|
|
@@ -46,8 +46,7 @@ export const emailProfileSchema = z
|
|
|
46
46
|
imapPort: clearableNumberSchema.default(993),
|
|
47
47
|
smtpHost: z.string().min(1).default(''),
|
|
48
48
|
smtpPort: clearableNumberSchema.default(587),
|
|
49
|
-
|
|
50
|
-
schema: filledLookupSchema.prefault({}),
|
|
49
|
+
schema: filledLookupSchema.default({}),
|
|
51
50
|
fetchInterval: clearableNumberSchema.default(60),
|
|
52
51
|
listen: z.boolean().default(false),
|
|
53
52
|
logged: z.boolean().default(false),
|
|
@@ -50,7 +50,7 @@ export const importTemplateSchema = z.object({
|
|
|
50
50
|
id: z.number().optional(),
|
|
51
51
|
name: z.string().min(1).default(''),
|
|
52
52
|
description: z.string().optional().default(''),
|
|
53
|
-
source: filledLookupSchema.
|
|
53
|
+
source: filledLookupSchema.default({}),
|
|
54
54
|
sourceType: z.string().default(StorageImportSourceType.Dialer),
|
|
55
55
|
parameters: importTemplateParametersSchema.prefault({}),
|
|
56
56
|
});
|
|
@@ -34,6 +34,13 @@ describe('triggerSchema', () => {
|
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
// [Claude] an empty lookup, not `undefined`: regle only shows the required `schema.id` error on an object
|
|
38
|
+
it('seeds the flow as an empty lookup', () => {
|
|
39
|
+
expect(defaults()).toMatchObject({
|
|
40
|
+
schema: {},
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
37
44
|
it('requires name, flow and the timezone of a cron trigger', () => {
|
|
38
45
|
expect(issuePaths(triggerSchema.safeParse(defaults()))).toEqual(
|
|
39
46
|
expect.arrayContaining([
|
|
@@ -41,8 +41,7 @@ export const triggerSchema = z
|
|
|
41
41
|
description: z.string().optional().default(''),
|
|
42
42
|
enabled: z.boolean().default(true),
|
|
43
43
|
type: z.string().min(1).default(EngineTriggerType.Cron),
|
|
44
|
-
|
|
45
|
-
schema: filledLookupSchema.prefault({}),
|
|
44
|
+
schema: filledLookupSchema.default({}),
|
|
46
45
|
// [Claude] an emptied number input gives `null`, which is allowed here
|
|
47
46
|
timeout: z.number().min(0).nullable().optional().default(60),
|
|
48
47
|
variables: z.array(variablePairSchema).default([]),
|