Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Jul 12, 2021
1 parent 5d04948 commit b3570f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions x-pack/plugins/alerting/server/alerts_client/alerts_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export interface GetAlertInstanceSummaryParams {
dateStart?: string;
}

// NOTE: Changing this prefix will require a migration to update the prefix in all existing `rule` saved objects
const extractedSavedObjectParamReferenceNamePrefix = 'param:';

const alertingAuthorizationFilterOpts: AlertingAuthorizationFilterOpts = {
Expand Down Expand Up @@ -1604,7 +1605,10 @@ export class AlertsClient {
};
}

private injectReferencesIntoParams<Params extends AlertTypeParams>(
private injectReferencesIntoParams<
Params extends AlertTypeParams,
ExtractedParams extends AlertTypeParams
>(
ruleId: string,
ruleType: UntypedNormalizedAlertType,
ruleParams: SavedObjectAttributes | undefined,
Expand All @@ -1621,7 +1625,7 @@ export class AlertsClient {
}));
return ruleParams && ruleType?.useSavedObjectReferences?.injectReferences
? (ruleType.useSavedObjectReferences.injectReferences(
ruleParams,
ruleParams as ExtractedParams,
paramReferences
) as Params)
: (ruleParams as Params);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export interface AlertType<
minimumLicenseRequired: LicenseType;
useSavedObjectReferences?: {
extractReferences: (params: Params) => RuleParamsAndRefs<ExtractedParams>;
injectReferences: (params: SavedObjectAttributes, references: SavedObjectReference[]) => Params;
injectReferences: (params: ExtractedParams, references: SavedObjectReference[]) => Params;
};
isExportable: boolean;
}
Expand Down

0 comments on commit b3570f5

Please sign in to comment.