@scoutflo/alert-correlation 0.2.1 → 0.3.0
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/dist/src/contracts/alertEvidence.d.ts +161 -0
- package/dist/src/contracts/alertEvidence.js +44 -0
- package/dist/src/contracts/alertEvidence.js.map +1 -0
- package/dist/src/contracts/alertRef.d.ts +1 -7
- package/dist/src/contracts/alertRef.js +1 -3
- package/dist/src/contracts/alertRef.js.map +1 -1
- package/dist/src/contracts/context.d.ts +7 -11
- package/dist/src/contracts/decision.d.ts +1 -1
- package/dist/src/contracts/facts.d.ts +5 -2
- package/dist/src/contracts/index.d.ts +1 -0
- package/dist/src/contracts/index.js +1 -0
- package/dist/src/contracts/index.js.map +1 -1
- package/dist/src/decision/reasonCodes.d.ts +6 -0
- package/dist/src/decision/reasonCodes.js +6 -0
- package/dist/src/decision/reasonCodes.js.map +1 -1
- package/dist/src/extractors/genericExtractor.js +30 -12
- package/dist/src/extractors/genericExtractor.js.map +1 -1
- package/dist/src/extractors/prometheusExtractor.js +14 -7
- package/dist/src/extractors/prometheusExtractor.js.map +1 -1
- package/dist/src/extractors/registry.js +1 -1
- package/dist/src/extractors/registry.js.map +1 -1
- package/dist/src/extractors/sentryExtractor.js +42 -34
- package/dist/src/extractors/sentryExtractor.js.map +1 -1
- package/dist/src/extractors/types.d.ts +3 -4
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/resolveAlertCorrelation.d.ts +3 -4
- package/dist/src/resolveAlertCorrelation.js +2 -3
- package/dist/src/resolveAlertCorrelation.js.map +1 -1
- package/dist/src/time/normalizeAlertTime.d.ts +2 -2
- package/dist/src/time/normalizeAlertTime.js +8 -7
- package/dist/src/time/normalizeAlertTime.js.map +1 -1
- package/dist/test/contracts.test.js +67 -8
- package/dist/test/contracts.test.js.map +1 -1
- package/dist/test/fixtures.d.ts +48 -0
- package/dist/test/fixtures.js +51 -0
- package/dist/test/fixtures.js.map +1 -0
- package/dist/test/generic-extractor.test.js +28 -8
- package/dist/test/generic-extractor.test.js.map +1 -1
- package/dist/test/prometheus-extractor.test.js +34 -8
- package/dist/test/prometheus-extractor.test.js.map +1 -1
- package/dist/test/provider-hardening.test.js +99 -82
- package/dist/test/provider-hardening.test.js.map +1 -1
- package/dist/test/resolve-alert-correlation.test.js +9 -4
- package/dist/test/resolve-alert-correlation.test.js.map +1 -1
- package/dist/test/sentry-extractor.test.js +10 -10
- package/dist/test/sentry-extractor.test.js.map +1 -1
- package/dist/test/time.test.js +20 -14
- package/dist/test/time.test.js.map +1 -1
- package/dist/test/victoriametrics-extractor.test.js +8 -8
- package/dist/test/victoriametrics-extractor.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,26 +11,30 @@ exports.sentryExtractor = {
|
|
|
11
11
|
name: 'sentry-extractor',
|
|
12
12
|
version: genericExtractor_1.EXTRACTOR_VERSION,
|
|
13
13
|
extract: (input) => {
|
|
14
|
+
const raw = input.evidence.rawPreview ?? {};
|
|
15
|
+
const alertRef = input.alertOccurrenceRef.alertRef;
|
|
14
16
|
const labels = [
|
|
15
|
-
...(0, genericExtractor_1.factsFromTagCollection)(
|
|
17
|
+
...(0, genericExtractor_1.factsFromTagCollection)(input.evidence.tags, 'evidence.tags'),
|
|
18
|
+
...(0, genericExtractor_1.factsFromRecord)(input.evidence.labels, 'evidence.labels', 'label', 0.86),
|
|
19
|
+
...(0, genericExtractor_1.factsFromTagCollection)((0, genericExtractor_1.getPath)(raw, ['tags']), 'raw.tags'),
|
|
16
20
|
...compactFacts([
|
|
17
21
|
(0, genericExtractor_1.makeFact)({
|
|
18
22
|
key: 'level',
|
|
19
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
23
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['level']]),
|
|
20
24
|
sourcePath: 'raw.level',
|
|
21
25
|
kind: 'label',
|
|
22
26
|
confidence: 0.72,
|
|
23
27
|
}),
|
|
24
28
|
(0, genericExtractor_1.makeFact)({
|
|
25
29
|
key: 'status',
|
|
26
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
30
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['status']]) ?? input.evidence.state ?? input.evidence.presentation.status,
|
|
27
31
|
sourcePath: 'raw.status',
|
|
28
32
|
kind: 'label',
|
|
29
33
|
confidence: 0.74,
|
|
30
34
|
}),
|
|
31
35
|
(0, genericExtractor_1.makeFact)({
|
|
32
36
|
key: 'platform',
|
|
33
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
37
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['platform']]),
|
|
34
38
|
sourcePath: 'raw.platform',
|
|
35
39
|
kind: 'label',
|
|
36
40
|
confidence: 0.72,
|
|
@@ -40,42 +44,42 @@ exports.sentryExtractor = {
|
|
|
40
44
|
const identifiers = compactFacts([
|
|
41
45
|
(0, genericExtractor_1.makeFact)({
|
|
42
46
|
key: 'issueId',
|
|
43
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
47
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['id'], ['issueId']]) ?? input.evidence.providerIds?.issueId,
|
|
44
48
|
sourcePath: 'raw.id',
|
|
45
49
|
kind: 'provider_identity',
|
|
46
50
|
confidence: 0.92,
|
|
47
51
|
}),
|
|
48
52
|
(0, genericExtractor_1.makeFact)({
|
|
49
53
|
key: 'shortId',
|
|
50
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
54
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['shortId'], ['short_id']]) ?? input.evidence.providerIds?.shortId,
|
|
51
55
|
sourcePath: 'raw.shortId',
|
|
52
56
|
kind: 'provider_identity',
|
|
53
57
|
confidence: 0.9,
|
|
54
58
|
}),
|
|
55
59
|
(0, genericExtractor_1.makeFact)({
|
|
56
60
|
key: 'shortIdPrefix',
|
|
57
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
61
|
+
value: ((0, genericExtractor_1.firstPrimitive)(raw, [['shortId'], ['short_id']]) ?? input.evidence.providerIds?.shortId)?.split('-')[0],
|
|
58
62
|
sourcePath: 'raw.shortId',
|
|
59
63
|
kind: 'provider_identity',
|
|
60
64
|
confidence: 0.76,
|
|
61
65
|
}),
|
|
62
66
|
(0, genericExtractor_1.makeFact)({
|
|
63
67
|
key: 'permalink',
|
|
64
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
68
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['permalink']]) ?? input.evidence.sourceUrls?.permalink,
|
|
65
69
|
sourcePath: 'raw.permalink',
|
|
66
70
|
kind: 'provider_identity',
|
|
67
71
|
confidence: 0.86,
|
|
68
72
|
}),
|
|
69
73
|
(0, genericExtractor_1.makeFact)({
|
|
70
74
|
key: 'projectSlug',
|
|
71
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
75
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['project', 'slug'], ['projectSlug']]) ?? input.evidence.providerIds?.projectSlug,
|
|
72
76
|
sourcePath: 'raw.project.slug',
|
|
73
77
|
kind: 'provider_identity',
|
|
74
78
|
confidence: 0.9,
|
|
75
79
|
}),
|
|
76
80
|
(0, genericExtractor_1.makeFact)({
|
|
77
81
|
key: 'orgSlug',
|
|
78
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
82
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [
|
|
79
83
|
['organization', 'slug'],
|
|
80
84
|
['org', 'slug'],
|
|
81
85
|
['organizationSlug'],
|
|
@@ -87,7 +91,7 @@ exports.sentryExtractor = {
|
|
|
87
91
|
}),
|
|
88
92
|
(0, genericExtractor_1.makeFact)({
|
|
89
93
|
key: 'releasePackage',
|
|
90
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
94
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [
|
|
91
95
|
['firstRelease', 'versionInfo', 'package'],
|
|
92
96
|
['release', 'versionInfo', 'package'],
|
|
93
97
|
['latestEvent', 'release', 'package'],
|
|
@@ -98,21 +102,21 @@ exports.sentryExtractor = {
|
|
|
98
102
|
}),
|
|
99
103
|
(0, genericExtractor_1.makeFact)({
|
|
100
104
|
key: 'serverName',
|
|
101
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
105
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['server_name'], ['serverName']]),
|
|
102
106
|
sourcePath: 'raw.server_name',
|
|
103
107
|
kind: 'provider_identity',
|
|
104
108
|
confidence: 0.75,
|
|
105
109
|
}),
|
|
106
110
|
(0, genericExtractor_1.makeFact)({
|
|
107
111
|
key: 'latestEvent.eventID',
|
|
108
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
112
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['latestEvent', 'eventID'], ['latestEvent', 'eventId']]),
|
|
109
113
|
sourcePath: 'raw.latestEvent.eventID',
|
|
110
114
|
kind: 'provider_identity',
|
|
111
115
|
confidence: 0.9,
|
|
112
116
|
}),
|
|
113
117
|
(0, genericExtractor_1.makeFact)({
|
|
114
118
|
key: 'trace_id',
|
|
115
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
119
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [
|
|
116
120
|
['latestEvent', 'contexts', 'trace', 'trace_id'],
|
|
117
121
|
['contexts', 'trace', 'trace_id'],
|
|
118
122
|
['trace_id'],
|
|
@@ -123,7 +127,7 @@ exports.sentryExtractor = {
|
|
|
123
127
|
}),
|
|
124
128
|
(0, genericExtractor_1.makeFact)({
|
|
125
129
|
key: 'span_id',
|
|
126
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
130
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [
|
|
127
131
|
['latestEvent', 'contexts', 'trace', 'span_id'],
|
|
128
132
|
['contexts', 'trace', 'span_id'],
|
|
129
133
|
['span_id'],
|
|
@@ -134,7 +138,7 @@ exports.sentryExtractor = {
|
|
|
134
138
|
}),
|
|
135
139
|
(0, genericExtractor_1.makeFact)({
|
|
136
140
|
key: 'releaseVersion',
|
|
137
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
141
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [
|
|
138
142
|
['firstRelease', 'version'],
|
|
139
143
|
['release', 'version'],
|
|
140
144
|
['latestEvent', 'release', 'version'],
|
|
@@ -145,66 +149,67 @@ exports.sentryExtractor = {
|
|
|
145
149
|
}),
|
|
146
150
|
]);
|
|
147
151
|
const textHints = compactFacts([
|
|
152
|
+
...(0, genericExtractor_1.factsFromRecord)(input.evidence.annotations, 'evidence.annotations', 'annotation', 0.78),
|
|
148
153
|
(0, genericExtractor_1.makeFact)({
|
|
149
154
|
key: 'metadata.type',
|
|
150
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
155
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['metadata', 'type']]),
|
|
151
156
|
sourcePath: 'raw.metadata.type',
|
|
152
157
|
kind: 'text_derived',
|
|
153
158
|
confidence: 0.74,
|
|
154
159
|
}),
|
|
155
160
|
(0, genericExtractor_1.makeFact)({
|
|
156
161
|
key: 'metadata.value',
|
|
157
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
162
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['metadata', 'value']]),
|
|
158
163
|
sourcePath: 'raw.metadata.value',
|
|
159
164
|
kind: 'text_derived',
|
|
160
165
|
confidence: 0.74,
|
|
161
166
|
}),
|
|
162
167
|
(0, genericExtractor_1.makeFact)({
|
|
163
168
|
key: 'metadata.function',
|
|
164
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
169
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['metadata', 'function']]),
|
|
165
170
|
sourcePath: 'raw.metadata.function',
|
|
166
171
|
kind: 'text_derived',
|
|
167
172
|
confidence: 0.72,
|
|
168
173
|
}),
|
|
169
174
|
(0, genericExtractor_1.makeFact)({
|
|
170
175
|
key: 'sdk.name',
|
|
171
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
176
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['sdk', 'name'], ['latestEvent', 'sdk', 'name']]),
|
|
172
177
|
sourcePath: 'raw.sdk.name',
|
|
173
178
|
kind: 'text_derived',
|
|
174
179
|
confidence: 0.7,
|
|
175
180
|
}),
|
|
176
181
|
(0, genericExtractor_1.makeFact)({
|
|
177
182
|
key: 'sdk.version',
|
|
178
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
183
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['sdk', 'version'], ['latestEvent', 'sdk', 'version']]),
|
|
179
184
|
sourcePath: 'raw.sdk.version',
|
|
180
185
|
kind: 'text_derived',
|
|
181
186
|
confidence: 0.7,
|
|
182
187
|
}),
|
|
183
188
|
(0, genericExtractor_1.makeFact)({
|
|
184
189
|
key: 'logger',
|
|
185
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
190
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['logger']]),
|
|
186
191
|
sourcePath: 'raw.logger',
|
|
187
192
|
kind: 'text_derived',
|
|
188
193
|
confidence: 0.58,
|
|
189
194
|
}),
|
|
190
195
|
(0, genericExtractor_1.makeFact)({
|
|
191
196
|
key: 'culprit',
|
|
192
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
197
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['culprit']]),
|
|
193
198
|
sourcePath: 'raw.culprit',
|
|
194
199
|
kind: 'text_derived',
|
|
195
200
|
confidence: 0.62,
|
|
196
201
|
}),
|
|
197
202
|
(0, genericExtractor_1.makeFact)({
|
|
198
203
|
key: 'filename',
|
|
199
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
204
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['metadata', 'filename']]),
|
|
200
205
|
sourcePath: 'raw.metadata.filename',
|
|
201
206
|
kind: 'resource_hint',
|
|
202
207
|
confidence: 0.6,
|
|
203
208
|
}),
|
|
204
209
|
(0, genericExtractor_1.makeFact)({
|
|
205
210
|
key: 'transaction',
|
|
206
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
207
|
-
sourcePath: (0, genericExtractor_1.firstPrimitive)(
|
|
211
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['transaction'], ['latestEvent', 'transaction']]),
|
|
212
|
+
sourcePath: (0, genericExtractor_1.firstPrimitive)(raw, [['transaction']])
|
|
208
213
|
? 'raw.transaction'
|
|
209
214
|
: 'raw.latestEvent.transaction',
|
|
210
215
|
kind: 'resource_hint',
|
|
@@ -213,27 +218,30 @@ exports.sentryExtractor = {
|
|
|
213
218
|
]);
|
|
214
219
|
const title = (0, genericExtractor_1.makeFact)({
|
|
215
220
|
key: 'title',
|
|
216
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
217
|
-
sourcePath: (0, genericExtractor_1.firstPrimitive)(
|
|
221
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['title'], ['metadata', 'title']]) ?? input.evidence.presentation.title,
|
|
222
|
+
sourcePath: (0, genericExtractor_1.firstPrimitive)(raw, [['title']]) ? 'raw.title' : 'evidence.presentation.title',
|
|
218
223
|
kind: 'text_derived',
|
|
219
224
|
confidence: 0.82,
|
|
220
225
|
});
|
|
221
226
|
const severity = (0, genericExtractor_1.makeFact)({
|
|
222
227
|
key: 'severity',
|
|
223
|
-
value: (0, genericExtractor_1.firstPrimitive)(
|
|
224
|
-
sourcePath: (0, genericExtractor_1.firstPrimitive)(
|
|
228
|
+
value: (0, genericExtractor_1.firstPrimitive)(raw, [['level']]) ?? input.evidence.presentation.severity,
|
|
229
|
+
sourcePath: (0, genericExtractor_1.firstPrimitive)(raw, [['level']]) ? 'raw.level' : 'evidence.presentation.severity',
|
|
225
230
|
kind: 'label',
|
|
226
231
|
confidence: 0.72,
|
|
227
232
|
});
|
|
228
233
|
return {
|
|
229
|
-
provider:
|
|
230
|
-
integrationId:
|
|
231
|
-
alertKey:
|
|
234
|
+
provider: alertRef.provider,
|
|
235
|
+
integrationId: alertRef.integrationId,
|
|
236
|
+
alertKey: alertRef.alertKey,
|
|
237
|
+
occurrenceId: input.alertOccurrenceRef.occurrenceId,
|
|
238
|
+
evidenceRef: input.alertOccurrenceRef.evidenceRef,
|
|
239
|
+
evidenceSource: input.evidence.evidenceSource,
|
|
232
240
|
extractor: {
|
|
233
241
|
name: 'sentry-extractor',
|
|
234
242
|
version: genericExtractor_1.EXTRACTOR_VERSION,
|
|
235
243
|
},
|
|
236
|
-
time: (0, normalizeAlertTime_1.normalizeAlertTime)(input.
|
|
244
|
+
time: (0, normalizeAlertTime_1.normalizeAlertTime)(input.evidence, (0, genericExtractor_1.extractProviderTimeHints)(raw)),
|
|
237
245
|
labels,
|
|
238
246
|
identifiers,
|
|
239
247
|
resourceHints: textHints.filter((fact) => fact.kind === 'resource_hint'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentryExtractor.js","sourceRoot":"","sources":["../../../src/extractors/sentryExtractor.ts"],"names":[],"mappings":";;;AACA,mEAAgE;AAChE,
|
|
1
|
+
{"version":3,"file":"sentryExtractor.js","sourceRoot":"","sources":["../../../src/extractors/sentryExtractor.ts"],"names":[],"mappings":";;;AACA,mEAAgE;AAChE,yDAQ4B;AAG5B,SAAS,YAAY,CAAC,KAA8B;IAClD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAgB,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7D,CAAC;AAEY,QAAA,eAAe,GAAsB;IAChD,QAAQ,EAAE,QAAQ;IAClB,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,oCAAiB;IAC1B,OAAO,EAAE,CAAC,KAAK,EAAyB,EAAE;QACxC,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,I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AAK,CAAC,kBAAkB,CAAC,WAAW;YACjD,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,cAAc;YAC7C,SAAS,EAAE;gBACT,IAAI,EAAE,kBAAkB;gBACxB,OAAO,EAAE,oCAAiB;aAC3B;YACD,IAAI,EAAE,IAAA,uCAAkB,EAAC,KAAK,CAAC,QAAQ,EAAE,IAAA,2CAAwB,EAAC,GAAG,CAAC,CAAC;YACvE,MAAM;YACN,WAAW;YACX,aAAa,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC;YACxE,SAAS;YACT,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5B,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AlertCorrelationFacts, AlertEvidenceSnapshot, AlertOccurrenceRef } from '../contracts';
|
|
2
2
|
export interface ProviderExtractorInput {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
summary?: AlertSummarySnapshot;
|
|
3
|
+
alertOccurrenceRef: AlertOccurrenceRef;
|
|
4
|
+
evidence: AlertEvidenceSnapshot;
|
|
6
5
|
}
|
|
7
6
|
export interface ProviderExtractor {
|
|
8
7
|
provider: string;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const ALERT_CORRELATION_PACKAGE = "@scoutflo/alert-correlation";
|
|
2
2
|
export * as correlationCore from '@scoutflo/correlation-core';
|
|
3
3
|
export * from './contracts/alertRef';
|
|
4
|
+
export * from './contracts/alertEvidence';
|
|
4
5
|
export * from './contracts/facts';
|
|
5
6
|
export * from './contracts/topology';
|
|
6
7
|
export * from './contracts/decision';
|
package/dist/src/index.js
CHANGED
|
@@ -40,6 +40,7 @@ exports.correlationCore = exports.ALERT_CORRELATION_PACKAGE = void 0;
|
|
|
40
40
|
exports.ALERT_CORRELATION_PACKAGE = '@scoutflo/alert-correlation';
|
|
41
41
|
exports.correlationCore = __importStar(require("@scoutflo/correlation-core"));
|
|
42
42
|
__exportStar(require("./contracts/alertRef"), exports);
|
|
43
|
+
__exportStar(require("./contracts/alertEvidence"), exports);
|
|
43
44
|
__exportStar(require("./contracts/facts"), exports);
|
|
44
45
|
__exportStar(require("./contracts/topology"), exports);
|
|
45
46
|
__exportStar(require("./contracts/decision"), exports);
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAa,QAAA,yBAAyB,GAAG,6BAA6B,CAAC;AAEvE,8EAA8D;AAE9D,uDAAqC;AACrC,oDAAkC;AAClC,uDAAqC;AACrC,uDAAqC;AACrC,sDAAoC;AACpC,4DAA0C;AAC1C,qDAAmC;AACnC,gEAA8C;AAC9C,mEAAiD;AACjD,+DAA6C;AAC7C,wEAAsD;AACtD,wDAAsC;AACtC,yDAAuC;AACvC,0DAAwC;AACxC,mDAAiC;AACjC,yEAAuD;AACvD,4DAA0C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAa,QAAA,yBAAyB,GAAG,6BAA6B,CAAC;AAEvE,8EAA8D;AAE9D,uDAAqC;AACrC,4DAA0C;AAC1C,oDAAkC;AAClC,uDAAqC;AACrC,uDAAqC;AACrC,sDAAoC;AACpC,4DAA0C;AAC1C,qDAAmC;AACnC,gEAA8C;AAC9C,mEAAiD;AACjD,+DAA6C;AAC7C,wEAAsD;AACtD,wDAAsC;AACtC,yDAAuC;AACvC,0DAAwC;AACxC,mDAAiC;AACjC,yEAAuD;AACvD,4DAA0C"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { AlertCorrelationDecision, AlertCorrelationFacts,
|
|
1
|
+
import type { AlertCorrelationDecision, AlertCorrelationFacts, AlertEvidenceSnapshot, AlertOccurrenceRef, CorrelationCandidate, TopologyCandidateInput } from './contracts';
|
|
2
2
|
export interface ResolveAlertCorrelationInput {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
summary?: AlertSummarySnapshot;
|
|
3
|
+
alertOccurrenceRef: AlertOccurrenceRef;
|
|
4
|
+
evidence: AlertEvidenceSnapshot;
|
|
6
5
|
topology: TopologyCandidateInput;
|
|
7
6
|
}
|
|
8
7
|
export interface ResolveAlertCorrelationResult {
|
|
@@ -6,9 +6,8 @@ const registry_1 = require("./extractors/registry");
|
|
|
6
6
|
const providerRelationshipMatcher_1 = require("./matchers/providerRelationshipMatcher");
|
|
7
7
|
function resolveAlertCorrelation(input) {
|
|
8
8
|
const facts = (0, registry_1.extractAlertFacts)({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
summary: input.summary,
|
|
9
|
+
alertOccurrenceRef: input.alertOccurrenceRef,
|
|
10
|
+
evidence: input.evidence,
|
|
12
11
|
});
|
|
13
12
|
const candidates = (0, providerRelationshipMatcher_1.matchTopologyCandidates)(facts, input.topology);
|
|
14
13
|
const decision = (0, decideTarget_1.decideTarget)(candidates);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAlertCorrelation.js","sourceRoot":"","sources":["../../src/resolveAlertCorrelation.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"resolveAlertCorrelation.js","sourceRoot":"","sources":["../../src/resolveAlertCorrelation.ts"],"names":[],"mappings":";;AAwBA,0DAWC;AA3BD,0DAAuD;AACvD,oDAA0D;AAC1D,wFAAiF;AAcjF,SAAgB,uBAAuB,CACrC,KAAmC;IAEnC,MAAM,KAAK,GAAG,IAAA,4BAAiB,EAAC;QAC9B,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;QAC5C,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAA,qDAAuB,EAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,IAAA,2BAAY,EAAC,UAAU,CAAC,CAAC;IAE1C,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AlertEvidenceSnapshot, AlertTimeWindow } from '../contracts';
|
|
2
2
|
export interface ProviderTimeHints {
|
|
3
3
|
startsAt?: string;
|
|
4
4
|
firstSeen?: string;
|
|
@@ -6,4 +6,4 @@ export interface ProviderTimeHints {
|
|
|
6
6
|
endsAt?: string;
|
|
7
7
|
lastSeen?: string;
|
|
8
8
|
}
|
|
9
|
-
export declare function normalizeAlertTime(
|
|
9
|
+
export declare function normalizeAlertTime(evidence: AlertEvidenceSnapshot, hints: ProviderTimeHints): AlertTimeWindow;
|
|
@@ -9,16 +9,17 @@ function firstValidIso(...values) {
|
|
|
9
9
|
return !Number.isNaN(date.getTime());
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
function normalizeAlertTime(
|
|
13
|
-
const startsAt = firstValidIso(hints.startsAt, hints.firstSeen, hints.eventTimestamp,
|
|
14
|
-
|
|
15
|
-
const endsAt = firstValidIso(hints.endsAt, hints.lastSeen);
|
|
12
|
+
function normalizeAlertTime(evidence, hints) {
|
|
13
|
+
const startsAt = firstValidIso(evidence.startsAt, evidence.observedAt, hints.startsAt, hints.firstSeen, hints.eventTimestamp, evidence.capturedAt) ?? evidence.capturedAt;
|
|
14
|
+
const observedAt = firstValidIso(evidence.observedAt, hints.eventTimestamp, startsAt);
|
|
15
|
+
const endsAt = firstValidIso(evidence.endsAt, hints.endsAt, hints.lastSeen);
|
|
16
|
+
const lastSeen = firstValidIso(hints.lastSeen, evidence.endsAt);
|
|
16
17
|
return {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
capturedAt: evidence.capturedAt,
|
|
19
|
+
...(observedAt ? { observedAt } : {}),
|
|
19
20
|
startsAt,
|
|
20
21
|
...(endsAt ? { endsAt } : {}),
|
|
21
|
-
...(
|
|
22
|
+
...(lastSeen ? { lastSeen } : {}),
|
|
22
23
|
isOpenEnded: !endsAt,
|
|
23
24
|
};
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeAlertTime.js","sourceRoot":"","sources":["../../../src/time/normalizeAlertTime.ts"],"names":[],"mappings":";;AAkBA,
|
|
1
|
+
{"version":3,"file":"normalizeAlertTime.js","sourceRoot":"","sources":["../../../src/time/normalizeAlertTime.ts"],"names":[],"mappings":";;AAkBA,gDA0BC;AAlCD,SAAS,aAAa,CAAC,GAAG,MAAiC;IACzD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,kBAAkB,CAChC,QAA+B,EAC/B,KAAwB;IAExB,MAAM,QAAQ,GACZ,aAAa,CACX,QAAQ,CAAC,QAAQ,EACjB,QAAQ,CAAC,UAAU,EACnB,KAAK,CAAC,QAAQ,EACd,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,cAAc,EACpB,QAAQ,CAAC,UAAU,CACpB,IAAI,QAAQ,CAAC,UAAU,CAAC;IAE3B,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IACtF,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC5E,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEhE,OAAO;QACL,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,QAAQ;QACR,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,WAAW,EAAE,CAAC,MAAM;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -6,34 +6,93 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
7
7
|
const node_test_1 = __importDefault(require("node:test"));
|
|
8
8
|
const src_1 = require("../src");
|
|
9
|
-
(0, node_test_1.default)('alertRefSchema
|
|
9
|
+
(0, node_test_1.default)('alertRefSchema accepts logical provider alert identity only', () => {
|
|
10
10
|
const parsed = src_1.alertRefSchema.safeParse({
|
|
11
11
|
integrationId: 'int-prom',
|
|
12
12
|
provider: 'prometheus',
|
|
13
13
|
alertKey: 'prometheus:abc',
|
|
14
|
+
});
|
|
15
|
+
strict_1.default.equal(parsed.success, true);
|
|
16
|
+
strict_1.default.deepEqual(parsed.data, {
|
|
17
|
+
integrationId: 'int-prom',
|
|
18
|
+
provider: 'prometheus',
|
|
19
|
+
alertKey: 'prometheus:abc',
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.default)('alertRefSchema rejects observation metadata as identity fields', () => {
|
|
23
|
+
const parsed = src_1.alertRefSchema.safeParse({
|
|
24
|
+
integrationId: 'int-prom',
|
|
25
|
+
provider: 'prometheus',
|
|
26
|
+
alertKey: 'prometheus:abc',
|
|
27
|
+
timestamp: '2026-06-14T09:55:00.000Z',
|
|
14
28
|
selectedAt: '2026-06-14T10:00:00.000Z',
|
|
15
29
|
});
|
|
16
30
|
strict_1.default.equal(parsed.success, false);
|
|
17
31
|
});
|
|
32
|
+
(0, node_test_1.default)('alertOccurrenceRefSchema links an occurrence to its evidence snapshot', () => {
|
|
33
|
+
const parsed = src_1.alertOccurrenceRefSchema.safeParse({
|
|
34
|
+
occurrenceId: 'occ-prom-1',
|
|
35
|
+
alertRef: {
|
|
36
|
+
integrationId: 'int-prom',
|
|
37
|
+
provider: 'prometheus',
|
|
38
|
+
alertKey: 'prometheus:abc',
|
|
39
|
+
},
|
|
40
|
+
evidenceRef: 'ev-prom-1',
|
|
41
|
+
});
|
|
42
|
+
strict_1.default.equal(parsed.success, true);
|
|
43
|
+
});
|
|
44
|
+
(0, node_test_1.default)('alertEvidenceSnapshotSchema captures bounded normalized evidence', () => {
|
|
45
|
+
const parsed = src_1.alertEvidenceSnapshotSchema.safeParse({
|
|
46
|
+
evidenceRef: 'ev-prom-1',
|
|
47
|
+
occurrenceId: 'occ-prom-1',
|
|
48
|
+
alertRef: {
|
|
49
|
+
integrationId: 'int-prom',
|
|
50
|
+
provider: 'prometheus',
|
|
51
|
+
alertKey: 'prometheus:abc',
|
|
52
|
+
},
|
|
53
|
+
evidenceSource: 'slack_notification',
|
|
54
|
+
capturedAt: '2026-06-14T10:00:00.000Z',
|
|
55
|
+
observedAt: '2026-06-14T09:55:00.000Z',
|
|
56
|
+
startsAt: '2026-06-14T09:50:00.000Z',
|
|
57
|
+
labels: {
|
|
58
|
+
service: 'checkout',
|
|
59
|
+
namespace: 'prod',
|
|
60
|
+
pod: 'checkout-abc',
|
|
61
|
+
},
|
|
62
|
+
annotations: {
|
|
63
|
+
summary: 'Checkout latency is high',
|
|
64
|
+
},
|
|
65
|
+
presentation: {
|
|
66
|
+
title: 'HighLatency',
|
|
67
|
+
severity: 'critical',
|
|
68
|
+
status: 'firing',
|
|
69
|
+
},
|
|
70
|
+
rawPreview: {
|
|
71
|
+
commonLabels: { alertname: 'HighLatency' },
|
|
72
|
+
},
|
|
73
|
+
rawHash: 'sha256:abc',
|
|
74
|
+
schemaVersion: 'alert-evidence/v1',
|
|
75
|
+
redactionVersion: 'redaction/v1',
|
|
76
|
+
});
|
|
77
|
+
strict_1.default.equal(parsed.success, true);
|
|
78
|
+
});
|
|
18
79
|
(0, node_test_1.default)('AlertCorrelationDecision supports degraded context', () => {
|
|
19
80
|
const decision = {
|
|
20
|
-
status: '
|
|
81
|
+
status: 'evidence_available_topology_missing',
|
|
21
82
|
target: null,
|
|
22
83
|
candidates: [],
|
|
23
84
|
evidence: [],
|
|
24
85
|
confidence: 0,
|
|
25
|
-
reasonCodes: ['source_resource_missing'],
|
|
86
|
+
reasonCodes: ['source_resource_missing', 'topology_relationships_missing'],
|
|
26
87
|
};
|
|
27
|
-
strict_1.default.equal(decision.status, '
|
|
88
|
+
strict_1.default.equal(decision.status, 'evidence_available_topology_missing');
|
|
28
89
|
});
|
|
29
|
-
(0, node_test_1.default)('AlertRef type
|
|
90
|
+
(0, node_test_1.default)('AlertRef type is stable across observations', () => {
|
|
30
91
|
const ref = {
|
|
31
92
|
integrationId: 'int-sentry',
|
|
32
93
|
provider: 'sentry',
|
|
33
94
|
alertKey: 'sentry:issue-1',
|
|
34
|
-
timestamp: '2026-06-14T09:55:00.000Z',
|
|
35
|
-
selectedAt: '2026-06-14T10:00:00.000Z',
|
|
36
95
|
};
|
|
37
|
-
strict_1.default.
|
|
96
|
+
strict_1.default.deepEqual(Object.keys(ref).sort(), ['alertKey', 'integrationId', 'provider']);
|
|
38
97
|
});
|
|
39
98
|
//# sourceMappingURL=contracts.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.test.js","sourceRoot":"","sources":["../../test/contracts.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AACxC,0DAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"contracts.test.js","sourceRoot":"","sources":["../../test/contracts.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AACxC,0DAA6B;AAC7B,gCAMgB;AAEhB,IAAA,mBAAI,EAAC,6DAA6D,EAAE,GAAG,EAAE;IACvE,MAAM,MAAM,GAAG,oBAAc,CAAC,SAAS,CAAC;QACtC,aAAa,EAAE,UAAU;QACzB,QAAQ,EAAE,YAAY;QACtB,QAAQ,EAAE,gBAAgB;KAC3B,CAAC,CAAC;IAEH,gBAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,gBAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE;QAC5B,aAAa,EAAE,UAAU;QACzB,QAAQ,EAAE,YAAY;QACtB,QAAQ,EAAE,gBAAgB;KAC3B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAA,mBAAI,EAAC,gEAAgE,EAAE,GAAG,EAAE;IAC1E,MAAM,MAAM,GAAG,oBAAc,CAAC,SAAS,CAAC;QACtC,aAAa,EAAE,UAAU;QACzB,QAAQ,EAAE,YAAY;QACtB,QAAQ,EAAE,gBAAgB;QAC1B,SAAS,EAAE,0BAA0B;QACrC,UAAU,EAAE,0BAA0B;KACvC,CAAC,CAAC;IAEH,gBAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC;AAEH,IAAA,mBAAI,EAAC,uEAAuE,EAAE,GAAG,EAAE;IACjF,MAAM,MAAM,GAAG,8BAAwB,CAAC,SAAS,CAAC;QAChD,YAAY,EAAE,YAAY;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AAI;QACZ,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC,yBAAyB,EAAE,gCAAgC,CAAC;KAC3E,CAAC;IAEF,gBAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,qCAAqC,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC;AAEH,IAAA,mBAAI,EAAC,6CAA6C,EAAE,GAAG,EAAE;IACvD,MAAM,GAAG,GAAa;QACpB,aAAa,EAAE,YAAY;QAC3B,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,gBAAgB;KAC3B,CAAC;IAEF,gBAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC;AACvF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AlertEvidenceSnapshot, AlertOccurrenceRef, AlertRef } from '../src';
|
|
2
|
+
export declare function makeAlertRef(overrides?: Partial<AlertRef>): AlertRef;
|
|
3
|
+
export declare function makeAlertEvidenceSnapshot(overrides?: Partial<AlertEvidenceSnapshot>): AlertEvidenceSnapshot;
|
|
4
|
+
export declare function makeAlertOccurrenceRef(overrides?: Partial<AlertOccurrenceRef>): AlertOccurrenceRef;
|
|
5
|
+
export declare function makeExtractorInput(overrides?: {
|
|
6
|
+
alertRef?: Partial<AlertRef>;
|
|
7
|
+
evidence?: Partial<AlertEvidenceSnapshot>;
|
|
8
|
+
}): {
|
|
9
|
+
alertOccurrenceRef: {
|
|
10
|
+
occurrenceId: string;
|
|
11
|
+
alertRef: {
|
|
12
|
+
integrationId: string;
|
|
13
|
+
provider: string;
|
|
14
|
+
alertKey: string;
|
|
15
|
+
};
|
|
16
|
+
evidenceRef: string;
|
|
17
|
+
};
|
|
18
|
+
evidence: {
|
|
19
|
+
occurrenceId: string;
|
|
20
|
+
alertRef: {
|
|
21
|
+
integrationId: string;
|
|
22
|
+
provider: string;
|
|
23
|
+
alertKey: string;
|
|
24
|
+
};
|
|
25
|
+
evidenceRef: string;
|
|
26
|
+
evidenceSource: "provider_list" | "provider_detail" | "provider_webhook" | "slack_notification";
|
|
27
|
+
capturedAt: string;
|
|
28
|
+
presentation: {
|
|
29
|
+
status?: string | undefined;
|
|
30
|
+
title?: string | undefined;
|
|
31
|
+
severity?: string | undefined;
|
|
32
|
+
description?: string | undefined;
|
|
33
|
+
};
|
|
34
|
+
schemaVersion: string;
|
|
35
|
+
redactionVersion: string;
|
|
36
|
+
observedAt?: string | undefined;
|
|
37
|
+
startsAt?: string | undefined;
|
|
38
|
+
endsAt?: string | undefined;
|
|
39
|
+
state?: string | undefined;
|
|
40
|
+
labels?: Record<string, string> | undefined;
|
|
41
|
+
annotations?: Record<string, string> | undefined;
|
|
42
|
+
tags?: Record<string, string> | undefined;
|
|
43
|
+
providerIds?: Record<string, string> | undefined;
|
|
44
|
+
sourceUrls?: Record<string, string> | undefined;
|
|
45
|
+
rawPreview?: Record<string, unknown> | undefined;
|
|
46
|
+
rawHash?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeAlertRef = makeAlertRef;
|
|
4
|
+
exports.makeAlertEvidenceSnapshot = makeAlertEvidenceSnapshot;
|
|
5
|
+
exports.makeAlertOccurrenceRef = makeAlertOccurrenceRef;
|
|
6
|
+
exports.makeExtractorInput = makeExtractorInput;
|
|
7
|
+
function makeAlertRef(overrides = {}) {
|
|
8
|
+
return {
|
|
9
|
+
integrationId: 'int-test',
|
|
10
|
+
provider: 'prometheus',
|
|
11
|
+
alertKey: 'provider:alert-1',
|
|
12
|
+
...overrides,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function makeAlertEvidenceSnapshot(overrides = {}) {
|
|
16
|
+
const alertRef = overrides.alertRef ?? makeAlertRef();
|
|
17
|
+
return {
|
|
18
|
+
evidenceRef: 'ev-test-1',
|
|
19
|
+
occurrenceId: 'occ-test-1',
|
|
20
|
+
alertRef,
|
|
21
|
+
evidenceSource: 'provider_detail',
|
|
22
|
+
capturedAt: '2026-06-14T10:00:00.000Z',
|
|
23
|
+
presentation: {},
|
|
24
|
+
schemaVersion: 'alert-evidence/v1',
|
|
25
|
+
redactionVersion: 'redaction/v1',
|
|
26
|
+
...overrides,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function makeAlertOccurrenceRef(overrides = {}) {
|
|
30
|
+
const alertRef = overrides.alertRef ?? makeAlertRef();
|
|
31
|
+
return {
|
|
32
|
+
occurrenceId: 'occ-test-1',
|
|
33
|
+
alertRef,
|
|
34
|
+
evidenceRef: 'ev-test-1',
|
|
35
|
+
...overrides,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function makeExtractorInput(overrides = {}) {
|
|
39
|
+
const alertRef = makeAlertRef(overrides.alertRef);
|
|
40
|
+
const evidence = makeAlertEvidenceSnapshot({
|
|
41
|
+
...overrides.evidence,
|
|
42
|
+
alertRef,
|
|
43
|
+
});
|
|
44
|
+
const alertOccurrenceRef = makeAlertOccurrenceRef({
|
|
45
|
+
occurrenceId: evidence.occurrenceId,
|
|
46
|
+
evidenceRef: evidence.evidenceRef,
|
|
47
|
+
alertRef,
|
|
48
|
+
});
|
|
49
|
+
return { alertOccurrenceRef, evidence };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../test/fixtures.ts"],"names":[],"mappings":";;AAMA,oCAOC;AAED,8DAgBC;AAED,wDAWC;AAED,gDAkBC;AA1DD,SAAgB,YAAY,CAAC,YAA+B,EAAE;IAC5D,OAAO;QACL,aAA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