Skip to content

Commit

Permalink
fixed types
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Apr 2, 2021
1 parent 3266b39 commit 3c2b78d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions x-pack/plugins/alerting/server/routes/create_rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const rewriteBodyReq: RewriteRequestCase<CreateOptions<AlertTypeParams>['data']>
...rest,
alertTypeId,
notifyWhen,
actions,
actions: actions.map((action) => rewriteBodyReqActions(action)),
});
const rewriteBodyRes: RewriteResponseCase<SanitizedAlert<AlertTypeParams>> = ({
actions,
Expand Down Expand Up @@ -130,11 +130,12 @@ export const createRuleRoute = (
try {
const createdRule: SanitizedAlert<AlertTypeParams> = await alertsClient.create<AlertTypeParams>(
{
data: rewriteBodyReq({
...rule,
notify_when: rule.notify_when as AlertNotifyWhenType,
actions: rule.actions.map((action) => rewriteBodyReqActions(action)),
}),
data: {
...rewriteBodyReq({
...rule,
notify_when: rule.notify_when as AlertNotifyWhenType,
}),
},
options: { id: params?.id },
}
);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting/server/routes/legacy/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const bodySchema = schema.object({
schema.object({
group: schema.string(),
id: schema.string(),
actionTypeId: schema.maybe(schema.string()),
actionTypeId: schema.string(),
params: schema.recordOf(schema.string(), schema.any(), { defaultValue: {} }),
}),
{ defaultValue: [] }
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting/server/routes/legacy/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const bodySchema = schema.object({
group: schema.string(),
id: schema.string(),
params: schema.recordOf(schema.string(), schema.any(), { defaultValue: {} }),
actionTypeId: schema.maybe(schema.string()),
actionTypeId: schema.string(),
}),
{ defaultValue: [] }
),
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/alerting/server/routes/update_rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ const rewriteBodyReqActions: RewriteRequestCase<AlertAction> = ({
});

const rewriteBodyReq: RewriteRequestCase<UpdateOptions<AlertTypeParams>> = (result) => {
const { notify_when: notifyWhen, ...rest } = result.data;
const { notify_when: notifyWhen, actions, ...rest } = result.data;
return {
...result,
data: {
...rest,
notifyWhen,
actions: actions.map((action) => rewriteBodyReqActions(action)),
},
};
};
Expand Down Expand Up @@ -137,7 +138,6 @@ export const updateRuleRoute = (
data: {
...rule,
notify_when: rule.notify_when as AlertNotifyWhenType,
actions: rule.actions.map((action) => rewriteBodyReqActions(action)),
},
})
);
Expand Down

0 comments on commit 3c2b78d

Please sign in to comment.