@oneuptime/common 14.0.104 → 14.0.105
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/Models/DatabaseModels/CloudAccount.d.mts +1 -0
- package/Models/DatabaseModels/CloudAccount.d.ts +1 -0
- package/Models/DatabaseModels/CloudAccount.js +21 -0
- package/Models/DatabaseModels/CloudBudget.d.mts +1 -0
- package/Models/DatabaseModels/CloudBudget.d.ts +1 -0
- package/Models/DatabaseModels/CloudBudget.js +38 -3
- package/Models/DatabaseModels/CloudCostRecommendation.d.mts +2 -0
- package/Models/DatabaseModels/CloudCostRecommendation.d.ts +2 -0
- package/Models/DatabaseModels/CloudCostRecommendation.js +30 -2
- package/Models/DatabaseModels/DetectionRule.js +8 -7
- package/Types/AI/ResourceAiAccessApi.d.mts +1 -0
- package/Types/AI/ResourceAiAccessApi.d.ts +1 -0
- package/Types/AI/ResourceAiAccessApi.js +6 -1
- package/Types/AI/ResourceAiAccessApi.mjs +1 -0
- package/Types/AI/ResourceAiAccessPermissions.d.mts +2 -0
- package/Types/AI/ResourceAiAccessPermissions.d.ts +2 -0
- package/Types/AI/ResourceAiAccessPermissions.js +13 -0
- package/Types/AI/ResourceAiAccessPermissions.mjs +2 -0
- package/Types/Cloud/CloudCost.d.mts +8 -0
- package/Types/Cloud/CloudCost.d.ts +8 -0
- package/Types/Cloud/CloudCost.js +37 -0
- package/Types/Cloud/CloudCost.mjs +1 -0
- package/Types/Cloud/CloudCostAnomaly.d.mts +34 -0
- package/Types/Cloud/CloudCostAnomaly.d.ts +34 -0
- package/Types/Cloud/CloudCostAnomaly.js +236 -0
- package/Types/Cloud/CloudCostAnomaly.mjs +18 -0
- package/Types/Cloud/CloudLogGroups.d.mts +6 -1
- package/Types/Cloud/CloudLogGroups.d.ts +6 -1
- package/Types/Cloud/CloudLogGroups.js +59 -3
- package/Types/Cloud/CloudLogGroups.mjs +1 -0
- package/Types/Cloud/CloudPlatform.js +9 -8
- package/Types/Cloud/CloudRightSizing.d.mts +140 -0
- package/Types/Cloud/CloudRightSizing.d.ts +140 -0
- package/Types/Cloud/CloudRightSizing.js +867 -0
- package/Types/Cloud/CloudRightSizing.mjs +53 -0
- package/Types/CloudConnection/CloudAiAgentKey.d.mts +65 -0
- package/Types/CloudConnection/CloudAiAgentKey.d.ts +65 -0
- package/Types/CloudConnection/CloudAiAgentKey.js +289 -0
- package/Types/CloudConnection/CloudAiAgentKey.mjs +18 -0
- package/Types/CloudConnection/CloudAiAgentSetupCommands.d.mts +5 -2
- package/Types/CloudConnection/CloudAiAgentSetupCommands.d.ts +5 -2
- package/Types/CloudConnection/CloudAiAgentSetupCommands.js +114 -43
- package/Types/CloudConnection/CloudAiAgentSetupCommands.mjs +4 -1
- package/Types/CloudConnection/CloudStream.d.mts +4 -0
- package/Types/CloudConnection/CloudStream.d.ts +4 -0
- package/Types/CloudConnection/CloudStream.js +18 -1
- package/Types/CloudConnection/CloudStream.mjs +4 -0
- package/Types/CloudConnection/CloudStreamTemplate.d.mts +2 -0
- package/Types/CloudConnection/CloudStreamTemplate.d.ts +2 -0
- package/Types/CloudConnection/CloudStreamTemplate.js +89 -6
- package/Types/CloudConnection/CloudStreamTemplate.mjs +2 -0
- package/Types/InstallScripts/InstallScripts.js +1 -1
- package/Types/ResourceAiAgent/CloudAiAgentNames.d.mts +6 -0
- package/Types/ResourceAiAgent/CloudAiAgentNames.d.ts +6 -0
- package/Types/ResourceAiAgent/CloudAiAgentNames.js +11 -1
- package/Types/ResourceAiAgent/CloudAiAgentNames.mjs +3 -0
- package/Types/ResourceAiAgent/ResourceAiAccess.d.mts +3 -1
- package/Types/ResourceAiAgent/ResourceAiAccess.d.ts +3 -1
- package/Types/ResourceAiAgent/ResourceAiAccess.js +13 -2
- package/Types/ResourceAiAgent/ResourceAiAccess.mjs +2 -0
- package/Types/SecurityCase/SecurityCaseContext.d.mts +2 -1
- package/Types/SecurityCase/SecurityCaseContext.d.ts +2 -1
- package/Types/SecurityCase/SecurityConnection.d.mts +2 -1
- package/Types/SecurityCase/SecurityConnection.d.ts +2 -1
- package/Types/SecurityEvent/RealTimeDetection.d.mts +14 -5
- package/Types/SecurityEvent/RealTimeDetection.d.ts +14 -5
- package/Types/SecurityEvent/RealTimeDetection.js +75 -25
- package/Types/SecurityEvent/RealTimeDetection.mjs +3 -3
- package/Types/SecurityPlaybook/SecurityPlaybookAction.d.mts +4 -2
- package/Types/SecurityPlaybook/SecurityPlaybookAction.d.ts +4 -2
- package/Types/SecurityPlaybook/SecurityPlaybookAction.js +22 -3
- package/Types/SecurityPlaybook/SecurityPlaybookStep.d.mts +7 -2
- package/Types/SecurityPlaybook/SecurityPlaybookStep.d.ts +7 -2
- package/Types/SecurityPlaybook/SecurityPlaybookStep.js +96 -39
- package/Types/SecurityPlaybook/SecurityPlaybookStep.mjs +2 -0
- package/Types/SecurityPlaybook/SecurityPlaybookStepCondition.d.mts +17 -2
- package/Types/SecurityPlaybook/SecurityPlaybookStepCondition.d.ts +17 -2
- package/Types/SecurityPlaybook/SecurityPlaybookStepCondition.js +174 -33
- package/Types/SecurityPlaybook/SecurityPlaybookStepCondition.mjs +7 -0
- package/Utils/SecurityCase/SecurityCaseMarkdown.d.mts +5 -0
- package/Utils/SecurityCase/SecurityCaseMarkdown.d.ts +5 -0
- package/Utils/SecurityCase/SecurityCaseMarkdown.js +10 -0
- package/Utils/SecurityCase/SecurityCaseMarkdown.mjs +1 -0
- package/Utils/Telemetry/CloudChangeTitle.d.mts +37 -0
- package/Utils/Telemetry/CloudChangeTitle.d.ts +37 -0
- package/Utils/Telemetry/CloudChangeTitle.js +315 -3
- package/Utils/Telemetry/CloudChangeTitle.mjs +13 -0
- package/package.json +1 -1
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLOUD_CHANGE_TITLE_SENTENCES = void 0;
|
|
3
|
+
exports.AZURE_RESOURCE_HEALTH_STATES = exports.AZURE_RESOURCE_HEALTH_CHANGE_SENTENCE = exports.CLOUD_HEALTH_STATUS_SENTENCES = exports.CLOUD_HEALTH_TITLE_SENTENCES = exports.CLOUD_HEALTH_UNNAMED_EVENTS = exports.AWS_HEALTH_EVENT_KIND_WORDS = exports.CloudHealthSource = exports.CLOUD_CHANGE_TITLE_SENTENCES = void 0;
|
|
4
4
|
exports.getCloudChangeTitleSentence = getCloudChangeTitleSentence;
|
|
5
5
|
exports.getCloudChangeTitle = getCloudChangeTitle;
|
|
6
6
|
exports.readResourceFromCloudChangeTitle = readResourceFromCloudChangeTitle;
|
|
7
7
|
exports.readCloudChangeTitleFacts = readCloudChangeTitleFacts;
|
|
8
8
|
exports.readCloudChangeTitleFactsJson = readCloudChangeTitleFactsJson;
|
|
9
|
+
exports.describeAwsHealthEventType = describeAwsHealthEventType;
|
|
10
|
+
exports.parseAwsHealthEventType = parseAwsHealthEventType;
|
|
11
|
+
exports.readCloudHealthTitleFacts = readCloudHealthTitleFacts;
|
|
12
|
+
exports.getCloudHealthTitle = getCloudHealthTitle;
|
|
13
|
+
exports.readCloudHealthTitleFactsJson = readCloudHealthTitleFactsJson;
|
|
9
14
|
exports.getChangeTitleForReader = getChangeTitleForReader;
|
|
15
|
+
exports.getChangeTitleDirection = getChangeTitleDirection;
|
|
16
|
+
const ReadingDirection_1 = require("../../Types/ReadingDirection");
|
|
10
17
|
const Translator_1 = require("../../Types/Translator");
|
|
11
18
|
const ChangeEventFields_1 = require("./ChangeEventFields");
|
|
12
19
|
/*
|
|
@@ -135,14 +142,319 @@ function readCloudChangeTitleFactsJson(value) {
|
|
|
135
142
|
}
|
|
136
143
|
return { operation, resource, failed };
|
|
137
144
|
}
|
|
145
|
+
/*
|
|
146
|
+
* ---- Health events --------------------------------------------------------
|
|
147
|
+
*
|
|
148
|
+
* What a cloud published about its health - AWS Health, Azure Service and
|
|
149
|
+
* Resource Health, Google Cloud's Service Health - is stored with the
|
|
150
|
+
* English title its connector writes: "AWS Health: EC2 operational issue
|
|
151
|
+
* (open)", "Azure Resource Health: Available → Unavailable". The frame and
|
|
152
|
+
* the state the provider reports the event in are worded in the reader's
|
|
153
|
+
* language; so are OneUptime's own words in the event - AWS's event type
|
|
154
|
+
* said in words ("EC2 operational issue", from AWS_EC2_OPERATIONAL_ISSUE,
|
|
155
|
+
* kept beside the title as the operation), and what a connector writes
|
|
156
|
+
* when the provider names nothing ("an event"). The provider's own words -
|
|
157
|
+
* an Azure or Google Cloud incident's title - are drawn as written. A state
|
|
158
|
+
* or a type no rule here knows is left as written, so a title is never cut
|
|
159
|
+
* wrongly.
|
|
160
|
+
*/
|
|
161
|
+
var CloudHealthSource;
|
|
162
|
+
(function (CloudHealthSource) {
|
|
163
|
+
CloudHealthSource["Aws"] = "aws";
|
|
164
|
+
CloudHealthSource["AzureService"] = "azure-service";
|
|
165
|
+
CloudHealthSource["AzureResource"] = "azure-resource";
|
|
166
|
+
CloudHealthSource["GoogleCloud"] = "gcp";
|
|
167
|
+
})(CloudHealthSource || (exports.CloudHealthSource = CloudHealthSource = {}));
|
|
168
|
+
/*
|
|
169
|
+
* AWS Health names an event by its type code - AWS_<SERVICE>_<KIND>, as
|
|
170
|
+
* AWS_EC2_OPERATIONAL_ISSUE - and its connector (AwsChanges) titles it in
|
|
171
|
+
* words: the service as AWS writes it, then the kind in lower case ("EC2
|
|
172
|
+
* operational issue"). The code without its words falls back to itself.
|
|
173
|
+
*/
|
|
174
|
+
function describeAwsHealthEventType(code) {
|
|
175
|
+
const words = code
|
|
176
|
+
.split("_")
|
|
177
|
+
.filter((word) => {
|
|
178
|
+
return word.length > 0;
|
|
179
|
+
});
|
|
180
|
+
if (words[0] === "AWS") {
|
|
181
|
+
words.shift();
|
|
182
|
+
}
|
|
183
|
+
if (words.length === 0) {
|
|
184
|
+
return code;
|
|
185
|
+
}
|
|
186
|
+
const service = words.shift();
|
|
187
|
+
return [
|
|
188
|
+
service,
|
|
189
|
+
...words.map((word) => {
|
|
190
|
+
return word.toLowerCase();
|
|
191
|
+
}),
|
|
192
|
+
].join(" ");
|
|
193
|
+
}
|
|
194
|
+
// An AWS Health event type code's service and kind ("EC2", "OPERATIONAL_ISSUE"), or null.
|
|
195
|
+
function parseAwsHealthEventType(code) {
|
|
196
|
+
const words = code
|
|
197
|
+
.split("_")
|
|
198
|
+
.filter((word) => {
|
|
199
|
+
return word.length > 0;
|
|
200
|
+
});
|
|
201
|
+
if (words[0] === "AWS") {
|
|
202
|
+
words.shift();
|
|
203
|
+
}
|
|
204
|
+
if (words.length < 2) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
return { service: words[0], kind: words.slice(1).join("_") };
|
|
208
|
+
}
|
|
209
|
+
/*
|
|
210
|
+
* The kinds of event AWS Health names most, every service alike - the
|
|
211
|
+
* issue it posts during an outage, the scheduled changes and maintenance -
|
|
212
|
+
* and the words they are said in, around the service as AWS names it (keys
|
|
213
|
+
* of the Dashboard's locale files). In English each reads word for word as
|
|
214
|
+
* the connector titles it (describeAwsHealthEventType). Any other kind is
|
|
215
|
+
* drawn as the connector wrote it.
|
|
216
|
+
*/
|
|
217
|
+
exports.AWS_HEALTH_EVENT_KIND_WORDS = {
|
|
218
|
+
OPERATIONAL_ISSUE: (0, Translator_1.translationKey)("{{service}} operational issue"),
|
|
219
|
+
OPERATIONAL_NOTIFICATION: (0, Translator_1.translationKey)("{{service}} operational notification"),
|
|
220
|
+
PLANNED_LIFECYCLE_EVENT: (0, Translator_1.translationKey)("{{service}} planned lifecycle event"),
|
|
221
|
+
MAINTENANCE_SCHEDULED: (0, Translator_1.translationKey)("{{service}} maintenance scheduled"),
|
|
222
|
+
INSTANCE_RETIREMENT_SCHEDULED: (0, Translator_1.translationKey)("{{service}} instance retirement scheduled"),
|
|
223
|
+
INSTANCE_STOP_SCHEDULED: (0, Translator_1.translationKey)("{{service}} instance stop scheduled"),
|
|
224
|
+
INSTANCE_REBOOT_MAINTENANCE_SCHEDULED: (0, Translator_1.translationKey)("{{service}} instance reboot maintenance scheduled"),
|
|
225
|
+
SYSTEM_REBOOT_MAINTENANCE_SCHEDULED: (0, Translator_1.translationKey)("{{service}} system reboot maintenance scheduled"),
|
|
226
|
+
};
|
|
227
|
+
/*
|
|
228
|
+
* What a connector titles an event its provider names nothing for (Azure's
|
|
229
|
+
* stage without a title, a resource whose state is not said, a Google
|
|
230
|
+
* Cloud incident with no title or product): OneUptime's words, said in the
|
|
231
|
+
* reader's language.
|
|
232
|
+
*/
|
|
233
|
+
exports.CLOUD_HEALTH_UNNAMED_EVENTS = {
|
|
234
|
+
[CloudHealthSource.AzureService]: (0, Translator_1.translationKey)("an event"),
|
|
235
|
+
[CloudHealthSource.AzureResource]: (0, Translator_1.translationKey)("changed"),
|
|
236
|
+
[CloudHealthSource.GoogleCloud]: (0, Translator_1.translationKey)("an incident"),
|
|
237
|
+
};
|
|
238
|
+
/*
|
|
239
|
+
* The sentences a health title is worded in: the provider's name is its
|
|
240
|
+
* own, never translated. Keys of the Dashboard's locale files.
|
|
241
|
+
*/
|
|
242
|
+
exports.CLOUD_HEALTH_TITLE_SENTENCES = {
|
|
243
|
+
[CloudHealthSource.Aws]: (0, Translator_1.translationKey)("AWS Health: {{event}}"),
|
|
244
|
+
[CloudHealthSource.AzureService]: (0, Translator_1.translationKey)("Azure Service Health: {{event}}"),
|
|
245
|
+
[CloudHealthSource.AzureResource]: (0, Translator_1.translationKey)("Azure Resource Health: {{event}}"),
|
|
246
|
+
[CloudHealthSource.GoogleCloud]: (0, Translator_1.translationKey)("Google Cloud Service Health: {{event}}"),
|
|
247
|
+
};
|
|
248
|
+
/*
|
|
249
|
+
* The states AWS Health, Azure Service Health and Google Cloud's Service
|
|
250
|
+
* Health report an event in, as each connector writes them - AWS's
|
|
251
|
+
* statusCode, Azure's stage, Google Cloud's incident state (lower-cased by
|
|
252
|
+
* its connector) - each with the whole sentence it is said in: a state is
|
|
253
|
+
* worded where it stands, so no language says it as a word out of context
|
|
254
|
+
* (an issue that is open is not a file opened).
|
|
255
|
+
*/
|
|
256
|
+
exports.CLOUD_HEALTH_STATUS_SENTENCES = {
|
|
257
|
+
[CloudHealthSource.Aws]: {
|
|
258
|
+
open: (0, Translator_1.translationKey)("AWS Health: {{event}} (open)"),
|
|
259
|
+
closed: (0, Translator_1.translationKey)("AWS Health: {{event}} (closed)"),
|
|
260
|
+
upcoming: (0, Translator_1.translationKey)("AWS Health: {{event}} (upcoming)"),
|
|
261
|
+
},
|
|
262
|
+
[CloudHealthSource.AzureService]: {
|
|
263
|
+
Active: (0, Translator_1.translationKey)("Azure Service Health: {{event}} (Active)"),
|
|
264
|
+
Resolved: (0, Translator_1.translationKey)("Azure Service Health: {{event}} (Resolved)"),
|
|
265
|
+
},
|
|
266
|
+
[CloudHealthSource.GoogleCloud]: {
|
|
267
|
+
active: (0, Translator_1.translationKey)("Google Cloud Service Health: {{event}} (active)"),
|
|
268
|
+
closed: (0, Translator_1.translationKey)("Google Cloud Service Health: {{event}} (closed)"),
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
// A resource's state before and now, in Azure Resource Health's title.
|
|
272
|
+
exports.AZURE_RESOURCE_HEALTH_CHANGE_SENTENCE = (0, Translator_1.translationKey)("Azure Resource Health: {{status}} → {{event}}");
|
|
273
|
+
/*
|
|
274
|
+
* The availability Azure Resource Health reports a resource in, and the
|
|
275
|
+
* word it is said in, before and after the arrow (keys of the Dashboard's
|
|
276
|
+
* locale files).
|
|
277
|
+
*/
|
|
278
|
+
exports.AZURE_RESOURCE_HEALTH_STATES = {
|
|
279
|
+
Available: (0, Translator_1.translationKey)("Available"),
|
|
280
|
+
Unavailable: (0, Translator_1.translationKey)("Unavailable"),
|
|
281
|
+
Degraded: (0, Translator_1.translationKey)("Degraded"),
|
|
282
|
+
Unknown: (0, Translator_1.translationKey)("Unknown"),
|
|
283
|
+
};
|
|
284
|
+
// How each connector's title starts (AwsChanges, AzureChanges, GcpChanges).
|
|
285
|
+
const HEALTH_TITLE_PREFIXES = [
|
|
286
|
+
{ source: CloudHealthSource.Aws, prefix: "AWS Health: " },
|
|
287
|
+
{ source: CloudHealthSource.AzureService, prefix: "Azure Service Health: " },
|
|
288
|
+
{
|
|
289
|
+
source: CloudHealthSource.AzureResource,
|
|
290
|
+
prefix: "Azure Resource Health: ",
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
source: CloudHealthSource.GoogleCloud,
|
|
294
|
+
prefix: "Google Cloud Service Health: ",
|
|
295
|
+
},
|
|
296
|
+
];
|
|
297
|
+
// What sits between a resource's state before and now in Azure Resource Health's title.
|
|
298
|
+
const STATE_ARROW = " → ";
|
|
299
|
+
function hasOwn(record, key) {
|
|
300
|
+
return Object.prototype.hasOwnProperty.call(record, key);
|
|
301
|
+
}
|
|
302
|
+
// Whether a provider reports such a state: a word read off a title is a state only then.
|
|
303
|
+
function knownState(source, state) {
|
|
304
|
+
if (source === CloudHealthSource.AzureResource) {
|
|
305
|
+
return hasOwn(exports.AZURE_RESOURCE_HEALTH_STATES, state);
|
|
306
|
+
}
|
|
307
|
+
const sentences = exports.CLOUD_HEALTH_STATUS_SENTENCES[source];
|
|
308
|
+
return Boolean(sentences) && hasOwn(sentences, state);
|
|
309
|
+
}
|
|
310
|
+
/*
|
|
311
|
+
* The facts of a stored health event's title, or null for any other change
|
|
312
|
+
* or a title of another shape (drawn as written). Plain string reads: no
|
|
313
|
+
* pattern runs on text a cloud wrote.
|
|
314
|
+
*/
|
|
315
|
+
function readCloudHealthTitleFacts(change) {
|
|
316
|
+
const fields = (0, ChangeEventFields_1.readChangeEventFields)(change.attributes);
|
|
317
|
+
if (fields.source !== ChangeEventFields_1.ChangeEventSource.CloudHealth) {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
const title = (change.title || "").trim();
|
|
321
|
+
const shape = HEALTH_TITLE_PREFIXES.find((candidate) => {
|
|
322
|
+
return title.startsWith(candidate.prefix);
|
|
323
|
+
});
|
|
324
|
+
if (!shape) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
const rest = title.slice(shape.prefix.length).trim();
|
|
328
|
+
if (!rest) {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
if (shape.source === CloudHealthSource.AzureResource) {
|
|
332
|
+
const arrow = rest.indexOf(STATE_ARROW);
|
|
333
|
+
if (arrow > 0) {
|
|
334
|
+
const before = rest.slice(0, arrow).trim();
|
|
335
|
+
const now = rest.slice(arrow + STATE_ARROW.length).trim();
|
|
336
|
+
if (knownState(shape.source, before) && knownState(shape.source, now)) {
|
|
337
|
+
return { source: shape.source, event: now, status: before };
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return { source: shape.source, event: rest, status: "" };
|
|
341
|
+
}
|
|
342
|
+
let event = rest;
|
|
343
|
+
let status = "";
|
|
344
|
+
// "<event> (<state>)": the state only when the provider reports such a state.
|
|
345
|
+
if (rest.endsWith(")")) {
|
|
346
|
+
const open = rest.lastIndexOf(" (");
|
|
347
|
+
if (open > 0) {
|
|
348
|
+
const state = rest.slice(open + 2, -1);
|
|
349
|
+
if (knownState(shape.source, state)) {
|
|
350
|
+
event = rest.slice(0, open).trim();
|
|
351
|
+
status = state;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/*
|
|
356
|
+
* AWS's event in the connector's words for its type, kept beside it as
|
|
357
|
+
* the operation - a row written before this was read too - so its kind
|
|
358
|
+
* is worded. A title cut short, or a type the words do not match, is the
|
|
359
|
+
* event as written.
|
|
360
|
+
*/
|
|
361
|
+
const code = (fields.cloudOperation || "").trim();
|
|
362
|
+
if (shape.source === CloudHealthSource.Aws &&
|
|
363
|
+
code &&
|
|
364
|
+
describeAwsHealthEventType(code) === event) {
|
|
365
|
+
return { source: shape.source, event, status, awsEventTypeCode: code };
|
|
366
|
+
}
|
|
367
|
+
return { source: shape.source, event, status };
|
|
368
|
+
}
|
|
369
|
+
/*
|
|
370
|
+
* The event as a page draws it: AWS's type in words, with a kind the
|
|
371
|
+
* Dashboard words in the reader's language; a resource's state, or what a
|
|
372
|
+
* connector writes when the provider names nothing, in the reader's words;
|
|
373
|
+
* the provider's own words as written.
|
|
374
|
+
*/
|
|
375
|
+
function getCloudHealthEvent(facts, translator, options) {
|
|
376
|
+
if (facts.source === CloudHealthSource.Aws && facts.awsEventTypeCode) {
|
|
377
|
+
const type = parseAwsHealthEventType(facts.awsEventTypeCode);
|
|
378
|
+
const sentence = type && hasOwn(exports.AWS_HEALTH_EVENT_KIND_WORDS, type.kind)
|
|
379
|
+
? exports.AWS_HEALTH_EVENT_KIND_WORDS[type.kind]
|
|
380
|
+
: undefined;
|
|
381
|
+
return type && sentence
|
|
382
|
+
? translator.translateTemplate(sentence, { service: type.service }, options)
|
|
383
|
+
: facts.event;
|
|
384
|
+
}
|
|
385
|
+
if (facts.source === CloudHealthSource.AzureResource &&
|
|
386
|
+
hasOwn(exports.AZURE_RESOURCE_HEALTH_STATES, facts.event)) {
|
|
387
|
+
return translator.translateTerm(exports.AZURE_RESOURCE_HEALTH_STATES[facts.event]);
|
|
388
|
+
}
|
|
389
|
+
const unnamed = exports.CLOUD_HEALTH_UNNAMED_EVENTS[facts.source];
|
|
390
|
+
if (unnamed && facts.event === unnamed) {
|
|
391
|
+
return translator.translateText(unnamed) || unnamed;
|
|
392
|
+
}
|
|
393
|
+
return facts.event;
|
|
394
|
+
}
|
|
395
|
+
/*
|
|
396
|
+
* A health event's title in the translator's language - English without
|
|
397
|
+
* one, word for word what its connector stores. The state is worded inside
|
|
398
|
+
* its own sentence; a resource's states before and now are said in the
|
|
399
|
+
* reader's words.
|
|
400
|
+
*/
|
|
401
|
+
function getCloudHealthTitle(facts, translator = ENGLISH, options) {
|
|
402
|
+
const event = getCloudHealthEvent(facts, translator, options);
|
|
403
|
+
if (facts.status && knownState(facts.source, facts.status)) {
|
|
404
|
+
if (facts.source === CloudHealthSource.AzureResource) {
|
|
405
|
+
return translator.translateTemplate(exports.AZURE_RESOURCE_HEALTH_CHANGE_SENTENCE, {
|
|
406
|
+
status: translator.translateTerm(exports.AZURE_RESOURCE_HEALTH_STATES[facts.status]),
|
|
407
|
+
event,
|
|
408
|
+
}, options);
|
|
409
|
+
}
|
|
410
|
+
return translator.translateTemplate(exports.CLOUD_HEALTH_STATUS_SENTENCES[facts.source][facts.status], { event }, options);
|
|
411
|
+
}
|
|
412
|
+
return translator.translateTemplate(exports.CLOUD_HEALTH_TITLE_SENTENCES[facts.source], { event }, options);
|
|
413
|
+
}
|
|
414
|
+
/*
|
|
415
|
+
* Health facts as an API answer carries them (a security case's story and
|
|
416
|
+
* impact, a record's connections): the shape checked, so a value from the
|
|
417
|
+
* wire is used only when it is one. Null otherwise.
|
|
418
|
+
*/
|
|
419
|
+
function readCloudHealthTitleFactsJson(value) {
|
|
420
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
const record = value;
|
|
424
|
+
const source = record["source"];
|
|
425
|
+
const event = record["event"];
|
|
426
|
+
const status = record["status"];
|
|
427
|
+
const code = record["awsEventTypeCode"];
|
|
428
|
+
if (!Object.values(CloudHealthSource).includes(source) ||
|
|
429
|
+
typeof event !== "string" ||
|
|
430
|
+
!event.trim() ||
|
|
431
|
+
typeof status !== "string" ||
|
|
432
|
+
(code !== undefined && typeof code !== "string")) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
return Object.assign({ source: source, event,
|
|
436
|
+
status }, (typeof code === "string" && code.trim()
|
|
437
|
+
? { awsEventTypeCode: code }
|
|
438
|
+
: {}));
|
|
439
|
+
}
|
|
138
440
|
/*
|
|
139
441
|
* What a change is called on a page: a cloud change worded from its facts
|
|
140
|
-
* in the translator's language,
|
|
141
|
-
* stored with - or its kind, when it has
|
|
442
|
+
* in the translator's language, a health event from its title's facts, any
|
|
443
|
+
* other change by the title it was stored with - or its kind, when it has
|
|
444
|
+
* none.
|
|
142
445
|
*/
|
|
143
446
|
function getChangeTitleForReader(data) {
|
|
144
447
|
if (data.facts) {
|
|
145
448
|
return getCloudChangeTitle(data.facts, data.translator, data.options);
|
|
146
449
|
}
|
|
450
|
+
if (data.health) {
|
|
451
|
+
return getCloudHealthTitle(data.health, data.translator, data.options);
|
|
452
|
+
}
|
|
147
453
|
return (data.title || "").trim() || (data.eventType || "").trim();
|
|
148
454
|
}
|
|
455
|
+
function getChangeTitleDirection(data) {
|
|
456
|
+
const isWorded = data.facts
|
|
457
|
+
? getCloudChangeTitleSentence(data.facts) !== null
|
|
458
|
+
: Boolean(data.health);
|
|
459
|
+
return isWorded ? (0, ReadingDirection_1.getReadingDirection)(data.translator.language) : "auto";
|
|
460
|
+
}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import commonJsModule from "./CloudChangeTitle.js";
|
|
2
|
+
export const AWS_HEALTH_EVENT_KIND_WORDS = commonJsModule.AWS_HEALTH_EVENT_KIND_WORDS;
|
|
3
|
+
export const AZURE_RESOURCE_HEALTH_CHANGE_SENTENCE = commonJsModule.AZURE_RESOURCE_HEALTH_CHANGE_SENTENCE;
|
|
4
|
+
export const AZURE_RESOURCE_HEALTH_STATES = commonJsModule.AZURE_RESOURCE_HEALTH_STATES;
|
|
2
5
|
export const CLOUD_CHANGE_TITLE_SENTENCES = commonJsModule.CLOUD_CHANGE_TITLE_SENTENCES;
|
|
6
|
+
export const CLOUD_HEALTH_STATUS_SENTENCES = commonJsModule.CLOUD_HEALTH_STATUS_SENTENCES;
|
|
7
|
+
export const CLOUD_HEALTH_TITLE_SENTENCES = commonJsModule.CLOUD_HEALTH_TITLE_SENTENCES;
|
|
8
|
+
export const CLOUD_HEALTH_UNNAMED_EVENTS = commonJsModule.CLOUD_HEALTH_UNNAMED_EVENTS;
|
|
9
|
+
export const CloudHealthSource = commonJsModule.CloudHealthSource;
|
|
10
|
+
export const describeAwsHealthEventType = commonJsModule.describeAwsHealthEventType;
|
|
11
|
+
export const getChangeTitleDirection = commonJsModule.getChangeTitleDirection;
|
|
3
12
|
export const getChangeTitleForReader = commonJsModule.getChangeTitleForReader;
|
|
4
13
|
export const getCloudChangeTitle = commonJsModule.getCloudChangeTitle;
|
|
5
14
|
export const getCloudChangeTitleSentence = commonJsModule.getCloudChangeTitleSentence;
|
|
15
|
+
export const getCloudHealthTitle = commonJsModule.getCloudHealthTitle;
|
|
16
|
+
export const parseAwsHealthEventType = commonJsModule.parseAwsHealthEventType;
|
|
6
17
|
export const readCloudChangeTitleFacts = commonJsModule.readCloudChangeTitleFacts;
|
|
7
18
|
export const readCloudChangeTitleFactsJson = commonJsModule.readCloudChangeTitleFactsJson;
|
|
19
|
+
export const readCloudHealthTitleFacts = commonJsModule.readCloudHealthTitleFacts;
|
|
20
|
+
export const readCloudHealthTitleFactsJson = commonJsModule.readCloudHealthTitleFactsJson;
|
|
8
21
|
export const readResourceFromCloudChangeTitle = commonJsModule.readResourceFromCloudChangeTitle;
|
package/package.json
CHANGED