@rallycry/conveyor-incidents 0.3.6 → 0.3.7
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/index.d.ts +48 -1
- package/dist/index.js +49 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source-event identity and outcome hints for incident reports: what lets a
|
|
3
|
+
* retried delivery dedupe, a recurrence open a new occurrence, and detection
|
|
4
|
+
* time come from the source rather than from Conveyor's clock.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Identity of the source event behind a report. Send a stable `id` so a
|
|
8
|
+
* retried delivery is a no-op, and `observedAt` so detection time is the
|
|
9
|
+
* source's, not the time Conveyor received the request.
|
|
10
|
+
*/
|
|
11
|
+
interface ReportEventInput {
|
|
12
|
+
id?: string;
|
|
13
|
+
/** ISO timestamp or Date of the source observation. */
|
|
14
|
+
observedAt?: string | Date;
|
|
15
|
+
}
|
|
16
|
+
/** Outcome hints applied only when the report opens a new incident occurrence. */
|
|
17
|
+
interface ReportOutcomeInput {
|
|
18
|
+
detectedBy?: "partner" | "player" | "internal" | "monitor" | "agent" | "unknown";
|
|
19
|
+
impact?: string;
|
|
20
|
+
environment?: string;
|
|
21
|
+
failureStartedAt?: string | Date;
|
|
22
|
+
/** Probe/acceptance incidents: excluded from delivery metrics. */
|
|
23
|
+
synthetic?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface ReportResolvedInput {
|
|
26
|
+
title: string;
|
|
27
|
+
source?: string;
|
|
28
|
+
fingerprintKey?: string;
|
|
29
|
+
severity?: "critical" | "high" | "medium" | "low";
|
|
30
|
+
event?: ReportEventInput;
|
|
31
|
+
}
|
|
32
|
+
interface ReportResolvedResult {
|
|
33
|
+
/** The incident the evidence was recorded on; null when nothing was open. */
|
|
34
|
+
incidentId: string | null;
|
|
35
|
+
ignored: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
1
38
|
declare class ConveyorIncidentsError extends Error {
|
|
2
39
|
readonly status: number;
|
|
3
40
|
readonly body: unknown;
|
|
@@ -99,6 +136,10 @@ interface ReportIncidentInput {
|
|
|
99
136
|
* account still gets a reply.
|
|
100
137
|
*/
|
|
101
138
|
reporter?: ReportReporter;
|
|
139
|
+
/** Incident reports only: source-event identity (retries, recurrence). */
|
|
140
|
+
event?: ReportEventInput;
|
|
141
|
+
/** Incident reports only: outcome hints for a new occurrence. */
|
|
142
|
+
outcome?: ReportOutcomeInput;
|
|
102
143
|
}
|
|
103
144
|
interface AttachmentResult {
|
|
104
145
|
fileName: string;
|
|
@@ -124,7 +165,13 @@ declare class ConveyorIncidents {
|
|
|
124
165
|
private readonly fetchImpl;
|
|
125
166
|
constructor(opts: ConveyorIncidentsOptions);
|
|
126
167
|
report(input: ReportIncidentInput): Promise<ReportIncidentResult>;
|
|
168
|
+
/**
|
|
169
|
+
* Tell Conveyor the source saw the failure clear. This is recovery
|
|
170
|
+
* EVIDENCE on the open incident — a person still confirms the service was
|
|
171
|
+
* restored. Nothing open to match → `{ ignored: true, incidentId: null }`.
|
|
172
|
+
*/
|
|
173
|
+
reportResolved(input: ReportResolvedInput): Promise<ReportResolvedResult>;
|
|
127
174
|
private uploadAttachment;
|
|
128
175
|
}
|
|
129
176
|
|
|
130
|
-
export { type AttachmentResult, type ConveyorCardType, ConveyorIncidents, ConveyorIncidentsError, type ConveyorIncidentsOptions, type IncidentAttachment, type IncidentSeverity, MAX_ATTACHMENT_BYTES, type NetworkCaptureOptions, type NetworkLogEntry, type ReportIncidentInput, type ReportIncidentResult, type ReportReporter, buildNetworkLogAttachment, clearNetworkLogEntries, getNetworkLogEntries, installNetworkCapture, uninstallNetworkCapture };
|
|
177
|
+
export { type AttachmentResult, type ConveyorCardType, ConveyorIncidents, ConveyorIncidentsError, type ConveyorIncidentsOptions, type IncidentAttachment, type IncidentSeverity, MAX_ATTACHMENT_BYTES, type NetworkCaptureOptions, type NetworkLogEntry, type ReportEventInput, type ReportIncidentInput, type ReportIncidentResult, type ReportOutcomeInput, type ReportReporter, type ReportResolvedInput, type ReportResolvedResult, buildNetworkLogAttachment, clearNetworkLogEntries, getNetworkLogEntries, installNetworkCapture, uninstallNetworkCapture };
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,18 @@ var ConveyorIncidentsError = class extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
// src/report-event.ts
|
|
14
|
+
function isoOf(value) {
|
|
15
|
+
if (value === void 0) return void 0;
|
|
16
|
+
return value instanceof Date ? value.toISOString() : value;
|
|
17
|
+
}
|
|
18
|
+
function serializeEvent(event) {
|
|
19
|
+
return { id: event.id, observedAt: isoOf(event.observedAt) };
|
|
20
|
+
}
|
|
21
|
+
function serializeOutcome(outcome) {
|
|
22
|
+
return { ...outcome, failureStartedAt: isoOf(outcome.failureStartedAt) };
|
|
23
|
+
}
|
|
24
|
+
|
|
13
25
|
// src/index.ts
|
|
14
26
|
var DEFAULT_BASE_URL = "https://api.conveyor.rallycryapp.com";
|
|
15
27
|
var DEFAULT_SOURCE = "client";
|
|
@@ -128,7 +140,9 @@ var ConveyorIncidents = class {
|
|
|
128
140
|
assigned: input.assigned,
|
|
129
141
|
review: input.review,
|
|
130
142
|
createdBy: input.createdBy,
|
|
131
|
-
reporter: normalizeReporter(input.reporter)
|
|
143
|
+
reporter: normalizeReporter(input.reporter),
|
|
144
|
+
event: input.event ? { ...serializeEvent(input.event), kind: "firing" } : void 0,
|
|
145
|
+
outcome: input.outcome ? serializeOutcome(input.outcome) : void 0
|
|
132
146
|
};
|
|
133
147
|
const res = await this.fetchImpl(`${this.baseUrl}/api/incidents/report`, {
|
|
134
148
|
method: "POST",
|
|
@@ -162,6 +176,40 @@ var ConveyorIncidents = class {
|
|
|
162
176
|
}
|
|
163
177
|
return { incidentId, cardId: incidentId, attachmentResults };
|
|
164
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Tell Conveyor the source saw the failure clear. This is recovery
|
|
181
|
+
* EVIDENCE on the open incident — a person still confirms the service was
|
|
182
|
+
* restored. Nothing open to match → `{ ignored: true, incidentId: null }`.
|
|
183
|
+
*/
|
|
184
|
+
async reportResolved(input) {
|
|
185
|
+
const body = {
|
|
186
|
+
projectId: this.projectId,
|
|
187
|
+
source: input.source ?? DEFAULT_SOURCE,
|
|
188
|
+
severity: input.severity ?? DEFAULT_SEVERITY,
|
|
189
|
+
title: input.title,
|
|
190
|
+
fingerprintKey: input.fingerprintKey,
|
|
191
|
+
type: "incident",
|
|
192
|
+
event: { ...serializeEvent(input.event ?? {}), kind: "resolved" }
|
|
193
|
+
};
|
|
194
|
+
const res = await this.fetchImpl(`${this.baseUrl}/api/incidents/report`, {
|
|
195
|
+
method: "POST",
|
|
196
|
+
headers: {
|
|
197
|
+
"Content-Type": "application/json",
|
|
198
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
199
|
+
},
|
|
200
|
+
body: JSON.stringify(body)
|
|
201
|
+
});
|
|
202
|
+
const payload = await readJson(res);
|
|
203
|
+
if (!res.ok) {
|
|
204
|
+
throw new ConveyorIncidentsError(
|
|
205
|
+
`Failed to report resolution: ${res.status} ${res.statusText}`,
|
|
206
|
+
res.status,
|
|
207
|
+
payload
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
const incidentId = extractId(payload, "incidentId") ?? null;
|
|
211
|
+
return { incidentId, ignored: incidentId === null };
|
|
212
|
+
}
|
|
165
213
|
async uploadAttachment(incidentId, attachment) {
|
|
166
214
|
try {
|
|
167
215
|
const bytes = typeof attachment.content === "string" ? new TextEncoder().encode(attachment.content) : attachment.content;
|