clarion-shared-types 1.0.101 → 1.0.102
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/cjs/modules/alert-intake/index.js +1 -0
- package/dist/cjs/modules/alert-intake/index.js.map +1 -1
- package/dist/cjs/modules/alert-intake/interfaces/alert-intake-analytics.js +3 -0
- package/dist/cjs/modules/alert-intake/interfaces/alert-intake-analytics.js.map +1 -0
- package/dist/esm/modules/alert-intake/index.js +1 -0
- package/dist/esm/modules/alert-intake/index.js.map +1 -1
- package/dist/esm/modules/alert-intake/interfaces/alert-intake-analytics.js +2 -0
- package/dist/esm/modules/alert-intake/interfaces/alert-intake-analytics.js.map +1 -0
- package/dist/types/modules/alert-intake/index.d.ts +1 -0
- package/dist/types/modules/alert-intake/interfaces/alert-intake-analytics.d.ts +254 -0
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
__exportStar(require("./enums/alert-intake.enum"), exports);
|
|
19
19
|
// Response shapes + plain request interfaces
|
|
20
20
|
__exportStar(require("./interfaces/alert-intake"), exports);
|
|
21
|
+
__exportStar(require("./interfaces/alert-intake-analytics"), exports);
|
|
21
22
|
// Utilities
|
|
22
23
|
__exportStar(require("./utils/alert-intake.util"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/alert-intake/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,4DAA0C;AAE1C,6CAA6C;AAC7C,4DAA0C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/alert-intake/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,4DAA0C;AAE1C,6CAA6C;AAC7C,4DAA0C;AAC1C,sEAAoD;AAEpD,YAAY;AACZ,4DAA0C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-intake-analytics.js","sourceRoot":"","sources":["../../../../../src/modules/alert-intake/interfaces/alert-intake-analytics.ts"],"names":[],"mappings":""}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export * from './enums/alert-intake.enum';
|
|
3
3
|
// Response shapes + plain request interfaces
|
|
4
4
|
export * from './interfaces/alert-intake';
|
|
5
|
+
export * from './interfaces/alert-intake-analytics';
|
|
5
6
|
// Utilities
|
|
6
7
|
export * from './utils/alert-intake.util';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/alert-intake/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,cAAc,2BAA2B,CAAC;AAE1C,6CAA6C;AAC7C,cAAc,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/alert-intake/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,cAAc,2BAA2B,CAAC;AAE1C,6CAA6C;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC;AAEpD,YAAY;AACZ,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-intake-analytics.js","sourceRoot":"","sources":["../../../../../src/modules/alert-intake/interfaces/alert-intake-analytics.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { AlertIntakeChannel, AlertIntakeMessageState, AlertIntakeScreeningReason, AlertIntakeScreeningSource, AlertIntakeScreeningStatus } from '../enums/alert-intake.enum';
|
|
2
|
+
/**
|
|
3
|
+
* Alert intake analytics: what arrived on an organization's channels over a period, what
|
|
4
|
+
* became of it, what the AI made of it and what that cost. One read, computed by
|
|
5
|
+
* clarion-alerts from one consistent snapshot, so every number on a dashboard agrees with
|
|
6
|
+
* every other.
|
|
7
|
+
*
|
|
8
|
+
* Counts only: no message text, sender or credential is ever part of it.
|
|
9
|
+
*/
|
|
10
|
+
/** How the period is cut into points for the charts. Chosen by the service from the length of the period. */
|
|
11
|
+
export type AlertIntakeAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
|
|
12
|
+
/** The AI tasks whose calls are metered. */
|
|
13
|
+
export type AlertIntakeAiTask = 'triage' | 'analysis' | 'transcription';
|
|
14
|
+
export interface AlertIntakeAnalyticsRange {
|
|
15
|
+
/** Inclusive, ISO 8601. The first message received when the period asked for was "forever". */
|
|
16
|
+
from: string;
|
|
17
|
+
/** Exclusive, ISO 8601. */
|
|
18
|
+
to: string;
|
|
19
|
+
bucket: AlertIntakeAnalyticsBucket;
|
|
20
|
+
/** IANA time zone the buckets and the hour-of-week grid are cut in. */
|
|
21
|
+
timeZone: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The headline counts. Messages are counted by when they arrived.
|
|
25
|
+
*
|
|
26
|
+
* received = raised + screenedOut + duplicates + retrying + parked + queued: every message
|
|
27
|
+
* is in exactly one of those, as it stands now.
|
|
28
|
+
*/
|
|
29
|
+
export interface AlertIntakeAnalyticsTotals {
|
|
30
|
+
received: number;
|
|
31
|
+
/** Became incidents (grievances, for a grievance desk) - including screened messages a reviewer raised. */
|
|
32
|
+
raised: number;
|
|
33
|
+
/** Screened out as not a report and not raised since (waiting for review, or dismissed). */
|
|
34
|
+
screenedOut: number;
|
|
35
|
+
duplicates: number;
|
|
36
|
+
retrying: number;
|
|
37
|
+
parked: number;
|
|
38
|
+
/** Waiting for, or being worked on by, the pipeline. */
|
|
39
|
+
queued: number;
|
|
40
|
+
/** Distinct phone numbers, WhatsApp numbers and email addresses. Never the values themselves. */
|
|
41
|
+
uniqueSenders: number;
|
|
42
|
+
withAttachments: number;
|
|
43
|
+
sharedLocations: number;
|
|
44
|
+
/** Written in a language other than English, and translated. */
|
|
45
|
+
translated: number;
|
|
46
|
+
voiceNotes: number;
|
|
47
|
+
emergencies: number;
|
|
48
|
+
sensitive: number;
|
|
49
|
+
anonymous: number;
|
|
50
|
+
acknowledged: number;
|
|
51
|
+
acknowledgementFailed: number;
|
|
52
|
+
/** Median seconds from arrival to the incident being raised; null when nothing was raised. */
|
|
53
|
+
medianSecondsToIncident: number | null;
|
|
54
|
+
p90SecondsToIncident: number | null;
|
|
55
|
+
/** AI spend in the period, US dollars. */
|
|
56
|
+
aiCostUsd: number;
|
|
57
|
+
}
|
|
58
|
+
/** The previous period of the same length, for the change shown on each headline figure. Null for "forever". */
|
|
59
|
+
export interface AlertIntakeAnalyticsComparison {
|
|
60
|
+
from: string;
|
|
61
|
+
to: string;
|
|
62
|
+
received: number;
|
|
63
|
+
raised: number;
|
|
64
|
+
screenedOut: number;
|
|
65
|
+
uniqueSenders: number;
|
|
66
|
+
medianSecondsToIncident: number | null;
|
|
67
|
+
aiCostUsd: number;
|
|
68
|
+
}
|
|
69
|
+
/** One point on the message timeline. `bucket` is the start of the point, local to `timeZone`, ISO 8601 without an offset. */
|
|
70
|
+
export interface AlertIntakeAnalyticsTimelinePoint {
|
|
71
|
+
bucket: string;
|
|
72
|
+
received: number;
|
|
73
|
+
raised: number;
|
|
74
|
+
screenedOut: number;
|
|
75
|
+
duplicates: number;
|
|
76
|
+
failed: number;
|
|
77
|
+
}
|
|
78
|
+
/** Where messages stand now; the parts add up to `received`. `failed` is retrying and parked together. */
|
|
79
|
+
export interface AlertIntakeAnalyticsOutcomes {
|
|
80
|
+
received: number;
|
|
81
|
+
raised: number;
|
|
82
|
+
screenedOut: number;
|
|
83
|
+
duplicates: number;
|
|
84
|
+
failed: number;
|
|
85
|
+
queued: number;
|
|
86
|
+
}
|
|
87
|
+
export interface AlertIntakeAnalyticsChannelRow extends AlertIntakeAnalyticsOutcomes {
|
|
88
|
+
channel: AlertIntakeChannel;
|
|
89
|
+
medianSecondsToIncident: number | null;
|
|
90
|
+
}
|
|
91
|
+
export interface AlertIntakeAnalyticsConnectionRow extends AlertIntakeAnalyticsOutcomes {
|
|
92
|
+
/** Null for messages received before connections existed. */
|
|
93
|
+
connectionId: string | null;
|
|
94
|
+
name: string;
|
|
95
|
+
channel: AlertIntakeChannel | null;
|
|
96
|
+
provider: string | null;
|
|
97
|
+
enabled: boolean | null;
|
|
98
|
+
lastReceivedAt: string | null;
|
|
99
|
+
/** The connection's current error, if it is failing. */
|
|
100
|
+
lastError: string | null;
|
|
101
|
+
}
|
|
102
|
+
export interface AlertIntakeAnalyticsCount<K extends string | number | null = string> {
|
|
103
|
+
key: K;
|
|
104
|
+
count: number;
|
|
105
|
+
}
|
|
106
|
+
/** Every screening decision on messages received in the period - including those a reviewer later raised. */
|
|
107
|
+
export interface AlertIntakeAnalyticsScreening {
|
|
108
|
+
byReason: AlertIntakeAnalyticsCount<AlertIntakeScreeningReason>[];
|
|
109
|
+
byDecider: AlertIntakeAnalyticsCount<AlertIntakeScreeningSource>[];
|
|
110
|
+
byStatus: AlertIntakeAnalyticsCount<AlertIntakeScreeningStatus>[];
|
|
111
|
+
/** Mean confidence of the model's screening decisions (0-1); null without any. */
|
|
112
|
+
averageAiConfidence: number | null;
|
|
113
|
+
/** Median hours from being screened out to a person's decision; null without reviews. */
|
|
114
|
+
medianHoursToReview: number | null;
|
|
115
|
+
/** Screened messages still waiting for a person - now, whatever the period. */
|
|
116
|
+
awaitingReview: number;
|
|
117
|
+
}
|
|
118
|
+
export interface AlertIntakeAnalyticsLanguageRow {
|
|
119
|
+
/** ISO 639-1, or `und` when it could not be told. */
|
|
120
|
+
language: string;
|
|
121
|
+
count: number;
|
|
122
|
+
translated: number;
|
|
123
|
+
}
|
|
124
|
+
export interface AlertIntakeAnalyticsCategoryRow {
|
|
125
|
+
categoryId: number | null;
|
|
126
|
+
/** The organization's category name; "Uncategorised" for reports filed without one. */
|
|
127
|
+
name: string;
|
|
128
|
+
count: number;
|
|
129
|
+
}
|
|
130
|
+
export interface AlertIntakeAnalyticsLocations {
|
|
131
|
+
/** Reports placed on the map, by how: the sender's shared pin, or a place named in the message. */
|
|
132
|
+
shared: number;
|
|
133
|
+
geocoded: number;
|
|
134
|
+
unresolved: number;
|
|
135
|
+
byCountry: AlertIntakeAnalyticsCount[];
|
|
136
|
+
}
|
|
137
|
+
export interface AlertIntakeAnalyticsAttachments {
|
|
138
|
+
files: number;
|
|
139
|
+
attached: number;
|
|
140
|
+
failed: number;
|
|
141
|
+
/** `image`, `audio`, `video`, `document`. */
|
|
142
|
+
byKind: Array<{
|
|
143
|
+
kind: string;
|
|
144
|
+
files: number;
|
|
145
|
+
attached: number;
|
|
146
|
+
failed: number;
|
|
147
|
+
}>;
|
|
148
|
+
}
|
|
149
|
+
/** Arrivals by weekday (1 = Monday ... 7 = Sunday) and hour (0-23), in `timeZone`. All 168 cells, zeros included. */
|
|
150
|
+
export interface AlertIntakeAnalyticsHeatCell {
|
|
151
|
+
weekday: number;
|
|
152
|
+
hour: number;
|
|
153
|
+
count: number;
|
|
154
|
+
}
|
|
155
|
+
export interface AlertIntakeAiTaskRow {
|
|
156
|
+
task: AlertIntakeAiTask;
|
|
157
|
+
calls: number;
|
|
158
|
+
failed: number;
|
|
159
|
+
cached: number;
|
|
160
|
+
inputTokens: number;
|
|
161
|
+
cachedInputTokens: number;
|
|
162
|
+
outputTokens: number;
|
|
163
|
+
reasoningTokens: number;
|
|
164
|
+
audioSeconds: number;
|
|
165
|
+
costUsd: number;
|
|
166
|
+
averageLatencyMs: number | null;
|
|
167
|
+
p90LatencyMs: number | null;
|
|
168
|
+
}
|
|
169
|
+
export interface AlertIntakeAiModelRow {
|
|
170
|
+
model: string;
|
|
171
|
+
task: AlertIntakeAiTask;
|
|
172
|
+
calls: number;
|
|
173
|
+
inputTokens: number;
|
|
174
|
+
outputTokens: number;
|
|
175
|
+
costUsd: number;
|
|
176
|
+
/** Calls whose model had no price in the service's price table: their cost is not in `costUsd`. */
|
|
177
|
+
unpricedCalls: number;
|
|
178
|
+
}
|
|
179
|
+
export interface AlertIntakeAiTimelinePoint {
|
|
180
|
+
bucket: string;
|
|
181
|
+
calls: number;
|
|
182
|
+
inputTokens: number;
|
|
183
|
+
outputTokens: number;
|
|
184
|
+
costUsd: number;
|
|
185
|
+
}
|
|
186
|
+
export interface AlertIntakeAnalyticsAi {
|
|
187
|
+
calls: number;
|
|
188
|
+
failed: number;
|
|
189
|
+
cached: number;
|
|
190
|
+
inputTokens: number;
|
|
191
|
+
cachedInputTokens: number;
|
|
192
|
+
outputTokens: number;
|
|
193
|
+
reasoningTokens: number;
|
|
194
|
+
audioSeconds: number;
|
|
195
|
+
costUsd: number;
|
|
196
|
+
/** AI spend divided by messages received / incidents raised in the period; null when there were none. */
|
|
197
|
+
costPerMessageUsd: number | null;
|
|
198
|
+
costPerIncidentUsd: number | null;
|
|
199
|
+
byTask: AlertIntakeAiTaskRow[];
|
|
200
|
+
byModel: AlertIntakeAiModelRow[];
|
|
201
|
+
timeline: AlertIntakeAiTimelinePoint[];
|
|
202
|
+
/** When the prices used were last reviewed (the service's price table), ISO date. */
|
|
203
|
+
pricesAsOf: string;
|
|
204
|
+
}
|
|
205
|
+
/** Platform view only: one row per organization. */
|
|
206
|
+
export interface AlertIntakeAnalyticsOrganizationRow {
|
|
207
|
+
organizationId: number | null;
|
|
208
|
+
name: string;
|
|
209
|
+
received: number;
|
|
210
|
+
raised: number;
|
|
211
|
+
screenedOut: number;
|
|
212
|
+
aiCostUsd: number;
|
|
213
|
+
}
|
|
214
|
+
export interface AlertIntakeAnalytics {
|
|
215
|
+
/** Null for the platform view across every organization. */
|
|
216
|
+
organizationId: number | null;
|
|
217
|
+
range: AlertIntakeAnalyticsRange;
|
|
218
|
+
generatedAt: string;
|
|
219
|
+
totals: AlertIntakeAnalyticsTotals;
|
|
220
|
+
previous: AlertIntakeAnalyticsComparison | null;
|
|
221
|
+
timeline: AlertIntakeAnalyticsTimelinePoint[];
|
|
222
|
+
byState: AlertIntakeAnalyticsCount<AlertIntakeMessageState>[];
|
|
223
|
+
/** Every channel, zeros included. */
|
|
224
|
+
byChannel: AlertIntakeAnalyticsChannelRow[];
|
|
225
|
+
/**
|
|
226
|
+
* The organization's own connections - including those that received nothing - and any
|
|
227
|
+
* platform connection that carried its messages (without that connection's status).
|
|
228
|
+
*/
|
|
229
|
+
byConnection: AlertIntakeAnalyticsConnectionRow[];
|
|
230
|
+
screening: AlertIntakeAnalyticsScreening;
|
|
231
|
+
languages: AlertIntakeAnalyticsLanguageRow[];
|
|
232
|
+
categories: AlertIntakeAnalyticsCategoryRow[];
|
|
233
|
+
/** Low, Medium, High, Critical. */
|
|
234
|
+
priorities: AlertIntakeAnalyticsCount[];
|
|
235
|
+
locations: AlertIntakeAnalyticsLocations;
|
|
236
|
+
attachments: AlertIntakeAnalyticsAttachments;
|
|
237
|
+
heatmap: AlertIntakeAnalyticsHeatCell[];
|
|
238
|
+
ai: AlertIntakeAnalyticsAi;
|
|
239
|
+
/** Platform view only. */
|
|
240
|
+
byOrganization?: AlertIntakeAnalyticsOrganizationRow[];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* The period an analytics read covers (query string). Both ends optional: no `from` is
|
|
244
|
+
* "forever", no `to` is now. ISO 8601 instants; `timeZone` is an IANA name.
|
|
245
|
+
*/
|
|
246
|
+
export interface AlertIntakeAnalyticsQuery {
|
|
247
|
+
from?: string;
|
|
248
|
+
to?: string;
|
|
249
|
+
timeZone?: string;
|
|
250
|
+
}
|
|
251
|
+
/** Platform operators: every organization's analytics, or one organization's. */
|
|
252
|
+
export interface PlatformAlertIntakeAnalyticsQuery extends AlertIntakeAnalyticsQuery {
|
|
253
|
+
organizationId?: number;
|
|
254
|
+
}
|