@junando/core 0.15.0 → 0.16.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/index.d.ts +44 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -213,6 +213,11 @@ export declare enum RuleEvaluationPhase {
|
|
|
213
213
|
PreLlm = "pre-llm",
|
|
214
214
|
PostLlm = "post-llm"
|
|
215
215
|
}
|
|
216
|
+
/** Notifier backend a logical channel resolves to */
|
|
217
|
+
export declare enum ChannelType {
|
|
218
|
+
Slack = "slack",
|
|
219
|
+
Teams = "teams"
|
|
220
|
+
}
|
|
216
221
|
export interface RuleCondition {
|
|
217
222
|
serviceName?: string;
|
|
218
223
|
alertType?: AlertType;
|
|
@@ -389,9 +394,26 @@ export declare const RuleSectionSchema: z.ZodObject<{
|
|
|
389
394
|
requiresRollback: z.ZodOptional<z.ZodBoolean>;
|
|
390
395
|
}, z.core.$strip>>>;
|
|
391
396
|
}, z.core.$strip>;
|
|
397
|
+
export interface SlackChannelConfig {
|
|
398
|
+
type: ChannelType.Slack;
|
|
399
|
+
channel: string;
|
|
400
|
+
}
|
|
401
|
+
export interface TeamsChannelConfig {
|
|
402
|
+
type: ChannelType.Teams;
|
|
403
|
+
webhookUrlEnv: string;
|
|
404
|
+
}
|
|
405
|
+
export type ChannelConfig = SlackChannelConfig | TeamsChannelConfig;
|
|
406
|
+
export declare const ChannelConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
407
|
+
type: z.ZodLiteral<ChannelType.Slack>;
|
|
408
|
+
channel: z.ZodString;
|
|
409
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
410
|
+
type: z.ZodLiteral<ChannelType.Teams>;
|
|
411
|
+
webhookUrlEnv: z.ZodString;
|
|
412
|
+
}, z.core.$strip>], "type">;
|
|
392
413
|
export interface RuleConfiguration {
|
|
393
414
|
[RuleEvaluationPhase.PreLlm]: RuleSection;
|
|
394
415
|
[RuleEvaluationPhase.PostLlm]: RuleSection;
|
|
416
|
+
channels: Record<string, ChannelConfig>;
|
|
395
417
|
}
|
|
396
418
|
export declare const RuleConfigurationSchema: z.ZodObject<{
|
|
397
419
|
"pre-llm": z.ZodObject<{
|
|
@@ -492,11 +514,19 @@ export declare const RuleConfigurationSchema: z.ZodObject<{
|
|
|
492
514
|
requiresRollback: z.ZodOptional<z.ZodBoolean>;
|
|
493
515
|
}, z.core.$strip>>>;
|
|
494
516
|
}, z.core.$strip>;
|
|
517
|
+
channels: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
518
|
+
type: z.ZodLiteral<ChannelType.Slack>;
|
|
519
|
+
channel: z.ZodString;
|
|
520
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
521
|
+
type: z.ZodLiteral<ChannelType.Teams>;
|
|
522
|
+
webhookUrlEnv: z.ZodString;
|
|
523
|
+
}, z.core.$strip>], "type">>>;
|
|
495
524
|
}, z.core.$strip>;
|
|
496
525
|
export type ValidatedRuleCondition = z.infer<typeof RuleConditionSchema>;
|
|
497
526
|
export type ValidatedRuleAction = z.infer<typeof RuleActionSchema>;
|
|
498
527
|
export type ValidatedRule = z.infer<typeof RuleSchema>;
|
|
499
528
|
export type ValidatedRuleSection = z.infer<typeof RuleSectionSchema>;
|
|
529
|
+
export type ValidatedChannelConfig = z.infer<typeof ChannelConfigSchema>;
|
|
500
530
|
export type ValidatedRuleConfiguration = z.infer<typeof RuleConfigurationSchema>;
|
|
501
531
|
//#endregion
|
|
502
532
|
//#region src/domain/entities/traceability.d.ts
|
|
@@ -1121,13 +1151,26 @@ export declare class ChannelRegistry {
|
|
|
1121
1151
|
*
|
|
1122
1152
|
* When `config.rulesConfigPath` is set:
|
|
1123
1153
|
* - Reads and validates the rules YAML config
|
|
1124
|
-
* -
|
|
1154
|
+
* - Builds a ChannelRegistry from its `channels:` section, with the default
|
|
1155
|
+
* notifier as fallback
|
|
1125
1156
|
* - Wraps the default notifier with a RoutingNotifier for multi-channel dispatch
|
|
1126
1157
|
*
|
|
1127
1158
|
* When `config.rulesConfigPath` is NOT set:
|
|
1128
1159
|
* - Returns the default notifier directly (backward-compatible)
|
|
1160
|
+
*
|
|
1161
|
+
* @throws {Error} at startup if a rule's route/escalate action references a
|
|
1162
|
+
* channel with no matching entry under `channels:` — an operator must fix
|
|
1163
|
+
* the rules config rather than have the alert silently fall back to the
|
|
1164
|
+
* default channel mid-incident.
|
|
1129
1165
|
*/
|
|
1130
1166
|
export declare function createNotifier(config: Config): INotifier;
|
|
1167
|
+
/**
|
|
1168
|
+
* Creates the RuleEngine from a YAML rules config file.
|
|
1169
|
+
*
|
|
1170
|
+
* Returns undefined when `config.rulesConfigPath` is not set,
|
|
1171
|
+
* meaning rule evaluation is disabled (pass-through behavior).
|
|
1172
|
+
*/
|
|
1173
|
+
export declare function createRuleEngine(config: Config): IRuleEngine | undefined;
|
|
1131
1174
|
//#endregion
|
|
1132
1175
|
//#region src/infrastructure/rollback/factory.d.ts
|
|
1133
1176
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/shared/constants.ts","../src/domain/entities/alert.ts","../src/domain/entities/cluster.ts","../src/domain/entities/incident.ts","../src/domain/entities/rule.ts","../src/domain/entities/traceability.ts","../src/domain/value-objects/fingerprint.ts","../src/domain/ports/index.ts","../src/domain/services/clustering.service.ts","../src/application/dtos/normalize-payload.ts","../src/shared/logger/enums.ts","../src/shared/logger/wide-event-builder.ts","../src/shared/logger/index.ts","../src/application/use-cases/process-incident.use-case.ts","../src/infrastructure/dedup/redis-dedup.adapter.ts","../src/infrastructure/dedup/dynamodb-dedup.adapter.ts","../src/infrastructure/indexer/opensearch.adapter.ts","../src/infrastructure/llm/bedrock.provider.ts","../src/infrastructure/llm/claude.provider.ts","../src/infrastructure/llm/openrouter.provider.ts","../src/infrastructure/llm/factory.ts","../src/infrastructure/llm/gemini.provider.ts","../src/infrastructure/llm/mock.provider.ts","../src/shared/config/index.ts","../src/infrastructure/rules/channel-registry.ts","../src/infrastructure/notifier/factory.ts","../src/infrastructure/rollback/factory.ts","../src/infrastructure/rollback/noop-rollback-action.handler.ts","../src/infrastructure/notifier/slack.adapter.ts","../src/infrastructure/notifier/teams.adapter.ts","../src/infrastructure/notifier/routing-notifier.ts","../src/infrastructure/queue/sqs.adapter.ts","../src/infrastructure/queue/sqs-lag-poller.ts","../src/infrastructure/traces/loki-trace.adapter.ts","../src/infrastructure/rules/yaml-rule-loader.ts","../src/infrastructure/rules/condition-evaluator.ts","../src/infrastructure/rules/action-dispatcher.ts","../src/infrastructure/rules/rule-engine.ts","../src/shared/factory-registry.ts","../src/shared/logger/loki-transport.ts"],"mappings":";;;;;;oBAMY;EACV;EACA;EACA;;UAGQ;WACC;WACA;WACA,UAAU,iBAAiB,WAAW;;cAG3C,mBAAmB,OAAO,WAAW;qBAmB9B,mBAAmB,gBAAgB;oBAIpC;EACV;EACA;EACA;EACA;EACA;;qBAIW,iBAAe;;;;;;qBAOf,iBAAe;;;;;qBAMf;qBAGA,cAAY;;;;qBAMZ;qBAGA;qBAGA;qBAGA,uBAAqB;;EAM3B;;qBAIM,YAAU;;;;;;qBAQV;qBACA;qBAGA;cAEP,eAAe;qBAMR,eAAe,gBAAgB;qBAG/B;qBAGA,kBAAgB;;;;qBAKhB,kBAAgB;;;;;;;qBCjHhB,mBAAiB,EAAA;;;;qBAEjB,uBAAqB,EAAA;;;;;;;;;;;;;;;GAYhC,EAAA,KAAA;qBAIW,2BAAyB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;GAsBpC,EAAA,KAAA;YAEU,cAAc,EAAE,aAAa;YAC7B,kBAAkB,EAAE,aAAa;YACjC,sBAAsB,EAAE,aAAa;YAGrC,iBAAiB;;;qBC9ChB,oBAAkB,EAAA;;;;;;;;;;;;;;;;GAa7B,EAAA,KAAA;YAEU,eAAe,EAAE,aAAa;;;qBCtB7B,oBAAkB,EAAA;;;;;;qBAGlB,mBAAiB,EAAA;;;;;;;;;;;GAM5B,EAAA,KAAA;qBAEW,gBAAc,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKzB,EAAA,KAAA;YAEU,eAAe,EAAE,aAAa;YAC9B,cAAc,EAAE,aAAa;YAC7B,WAAW,EAAE,aAAa;;;oBCf1B;EACV;EACA;EACA;EACA;;oBAGU;EACV;EACA;EACA;EACA;;;oBAIU;EACV;EACA;;iBAOe;EACf;EACA,YAAY;EACZ,WAAW;EACX,SAAS;EACT;EACA;IAAe;IAAc;;EAC7B;IAAiB;IAAc;;;EAE/B,eAAe,EAAE,aAAa;EAC9B;EACA;;qBAaW,qBAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;GAW9B,EAAA,KAAA;YAMU;EACN,MAAM,eAAe;;EACrB,MAAM,eAAe;EAAO;;EAC5B,MAAM,eAAe;EAAU;;EAC/B,MAAM,eAAe;EAAK;EAAa;;qBAOhC,kBAAgB,EAAA,uBAAA,EAAA;;;;;;;;;;;;GAK3B,EAAA,KAAA;iBAMe;EACf;EACA;EACA,WAAW;EACX,SAAS;;EAET,eAAe,EAAE,aAAa;EAC9B;;qBAGW,YAAU,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAOrB,EAAA,KAAA;iBAMe;EACf,OAAO;;qBAGI,mBAAiB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAE5B,EAAA,KAAA;iBAMe;GACd,oBAAoB,SAAS;GAC7B,oBAAoB,UAAU;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/shared/constants.ts","../src/domain/entities/alert.ts","../src/domain/entities/cluster.ts","../src/domain/entities/incident.ts","../src/domain/entities/rule.ts","../src/domain/entities/traceability.ts","../src/domain/value-objects/fingerprint.ts","../src/domain/ports/index.ts","../src/domain/services/clustering.service.ts","../src/application/dtos/normalize-payload.ts","../src/shared/logger/enums.ts","../src/shared/logger/wide-event-builder.ts","../src/shared/logger/index.ts","../src/application/use-cases/process-incident.use-case.ts","../src/infrastructure/dedup/redis-dedup.adapter.ts","../src/infrastructure/dedup/dynamodb-dedup.adapter.ts","../src/infrastructure/indexer/opensearch.adapter.ts","../src/infrastructure/llm/bedrock.provider.ts","../src/infrastructure/llm/claude.provider.ts","../src/infrastructure/llm/openrouter.provider.ts","../src/infrastructure/llm/factory.ts","../src/infrastructure/llm/gemini.provider.ts","../src/infrastructure/llm/mock.provider.ts","../src/shared/config/index.ts","../src/infrastructure/rules/channel-registry.ts","../src/infrastructure/notifier/factory.ts","../src/infrastructure/rollback/factory.ts","../src/infrastructure/rollback/noop-rollback-action.handler.ts","../src/infrastructure/notifier/slack.adapter.ts","../src/infrastructure/notifier/teams.adapter.ts","../src/infrastructure/notifier/routing-notifier.ts","../src/infrastructure/queue/sqs.adapter.ts","../src/infrastructure/queue/sqs-lag-poller.ts","../src/infrastructure/traces/loki-trace.adapter.ts","../src/infrastructure/rules/yaml-rule-loader.ts","../src/infrastructure/rules/condition-evaluator.ts","../src/infrastructure/rules/action-dispatcher.ts","../src/infrastructure/rules/rule-engine.ts","../src/shared/factory-registry.ts","../src/shared/logger/loki-transport.ts"],"mappings":";;;;;;oBAMY;EACV;EACA;EACA;;UAGQ;WACC;WACA;WACA,UAAU,iBAAiB,WAAW;;cAG3C,mBAAmB,OAAO,WAAW;qBAmB9B,mBAAmB,gBAAgB;oBAIpC;EACV;EACA;EACA;EACA;EACA;;qBAIW,iBAAe;;;;;;qBAOf,iBAAe;;;;;qBAMf;qBAGA,cAAY;;;;qBAMZ;qBAGA;qBAGA;qBAGA,uBAAqB;;EAM3B;;qBAIM,YAAU;;;;;;qBAQV;qBACA;qBAGA;cAEP,eAAe;qBAMR,eAAe,gBAAgB;qBAG/B;qBAGA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|
RuleEvaluationPhase["PostLlm"] = "post-llm";
|
|
195
195
|
return RuleEvaluationPhase;
|
|
196
196
|
}({});
|
|
197
|
+
/** Notifier backend a logical channel resolves to */
|
|
198
|
+
let ChannelType = /* @__PURE__ */ function(ChannelType) {
|
|
199
|
+
ChannelType["Slack"] = "slack";
|
|
200
|
+
ChannelType["Teams"] = "teams";
|
|
201
|
+
return ChannelType;
|
|
202
|
+
}({});
|
|
197
203
|
const AlertCountSchema = z.object({
|
|
198
204
|
min: z.number().optional(),
|
|
199
205
|
max: z.number().optional()
|
|
@@ -243,9 +249,19 @@ const RuleSchema = z.object({
|
|
|
243
249
|
requiresRollback: z.boolean().optional()
|
|
244
250
|
});
|
|
245
251
|
const RuleSectionSchema = z.object({ rules: z.array(RuleSchema).default([]) });
|
|
252
|
+
const SLACK_CHANNEL_SCHEMA = z.object({
|
|
253
|
+
type: z.literal("slack"),
|
|
254
|
+
channel: z.string().startsWith("#")
|
|
255
|
+
});
|
|
256
|
+
const TEAMS_CHANNEL_SCHEMA = z.object({
|
|
257
|
+
type: z.literal("teams"),
|
|
258
|
+
webhookUrlEnv: z.string().min(1)
|
|
259
|
+
});
|
|
260
|
+
const ChannelConfigSchema = z.discriminatedUnion("type", [SLACK_CHANNEL_SCHEMA, TEAMS_CHANNEL_SCHEMA]);
|
|
246
261
|
const RuleConfigurationSchema = z.object({
|
|
247
262
|
["pre-llm"]: RuleSectionSchema,
|
|
248
|
-
["post-llm"]: RuleSectionSchema
|
|
263
|
+
["post-llm"]: RuleSectionSchema,
|
|
264
|
+
channels: z.record(z.string(), ChannelConfigSchema).default({})
|
|
249
265
|
});
|
|
250
266
|
//#endregion
|
|
251
267
|
//#region src/domain/value-objects/fingerprint.ts
|
|
@@ -2263,15 +2279,46 @@ function buildNotifierRegistry(config) {
|
|
|
2263
2279
|
return registry;
|
|
2264
2280
|
}
|
|
2265
2281
|
/**
|
|
2282
|
+
* Builds the notifier for a single named channel entry from the rules YAML's
|
|
2283
|
+
* `channels:` section.
|
|
2284
|
+
*
|
|
2285
|
+
* @throws {Error} if the channel's backend cannot actually be reached (e.g.
|
|
2286
|
+
* `type: slack` with no SLACK_BOT_TOKEN configured, or `type: teams` whose
|
|
2287
|
+
* `webhookUrlEnv` is unset) — fails fast at startup rather than at delivery
|
|
2288
|
+
* time, mid-incident.
|
|
2289
|
+
*/
|
|
2290
|
+
function buildChannelNotifier(name, channelConfig, config) {
|
|
2291
|
+
if (channelConfig.type === "slack") {
|
|
2292
|
+
if (!config.slackBotToken) throw new Error(`Channel "${name}" (type: slack) requires SLACK_BOT_TOKEN to be set`);
|
|
2293
|
+
return new SlackNotifier(config.slackBotToken, channelConfig.channel);
|
|
2294
|
+
}
|
|
2295
|
+
const webhookUrl = process.env[channelConfig.webhookUrlEnv];
|
|
2296
|
+
if (!webhookUrl) throw new Error(`Channel "${name}" (type: teams) references env var "${channelConfig.webhookUrlEnv}", which is not set`);
|
|
2297
|
+
let parsedUrl;
|
|
2298
|
+
try {
|
|
2299
|
+
parsedUrl = new URL(webhookUrl);
|
|
2300
|
+
} catch {
|
|
2301
|
+
throw new Error(`Channel "${name}": ${channelConfig.webhookUrlEnv} is not a valid URL`);
|
|
2302
|
+
}
|
|
2303
|
+
if (!parsedUrl.searchParams.has("api-version")) throw new Error(`Channel "${name}": ${channelConfig.webhookUrlEnv} must include api-version= as a query parameter`);
|
|
2304
|
+
return new TeamsNotifier(webhookUrl);
|
|
2305
|
+
}
|
|
2306
|
+
/**
|
|
2266
2307
|
* Creates the notifier for the application.
|
|
2267
2308
|
*
|
|
2268
2309
|
* When `config.rulesConfigPath` is set:
|
|
2269
2310
|
* - Reads and validates the rules YAML config
|
|
2270
|
-
* -
|
|
2311
|
+
* - Builds a ChannelRegistry from its `channels:` section, with the default
|
|
2312
|
+
* notifier as fallback
|
|
2271
2313
|
* - Wraps the default notifier with a RoutingNotifier for multi-channel dispatch
|
|
2272
2314
|
*
|
|
2273
2315
|
* When `config.rulesConfigPath` is NOT set:
|
|
2274
2316
|
* - Returns the default notifier directly (backward-compatible)
|
|
2317
|
+
*
|
|
2318
|
+
* @throws {Error} at startup if a rule's route/escalate action references a
|
|
2319
|
+
* channel with no matching entry under `channels:` — an operator must fix
|
|
2320
|
+
* the rules config rather than have the alert silently fall back to the
|
|
2321
|
+
* default channel mid-incident.
|
|
2275
2322
|
*/
|
|
2276
2323
|
function createNotifier(config) {
|
|
2277
2324
|
const defaultNotifier = buildNotifierRegistry(config).resolve(config.notifierType);
|
|
@@ -2279,19 +2326,19 @@ function createNotifier(config) {
|
|
|
2279
2326
|
logger$2.debug("RULES_CONFIG_PATH not set — rule engine disabled, using default notifier");
|
|
2280
2327
|
return defaultNotifier;
|
|
2281
2328
|
}
|
|
2329
|
+
const ruleConfig = parseRuleConfig(readFileSync(config.rulesConfigPath, "utf-8"));
|
|
2282
2330
|
const channelRegistry = new ChannelRegistry();
|
|
2283
2331
|
channelRegistry.setDefault(defaultNotifier);
|
|
2332
|
+
for (const [name, channelConfig] of Object.entries(ruleConfig.channels)) channelRegistry.register(name, buildChannelNotifier(name, channelConfig, config));
|
|
2284
2333
|
const unresolved = collectUnresolvedChannels(config, channelRegistry);
|
|
2285
|
-
if (unresolved.length > 0)
|
|
2286
|
-
channels: unresolved,
|
|
2287
|
-
rulesConfigPath: config.rulesConfigPath
|
|
2288
|
-
}, "Rules reference channels with no registered notifier — these will be delivered to the default channel");
|
|
2334
|
+
if (unresolved.length > 0) throw new Error(`Rules reference undefined channels: ${unresolved.join(", ")}. Define them under "channels:" in ${config.rulesConfigPath}, or remove the reference.`);
|
|
2289
2335
|
return new RoutingNotifier(channelRegistry, defaultNotifier);
|
|
2290
2336
|
}
|
|
2291
2337
|
/**
|
|
2292
2338
|
* Collect the channel names referenced by Route/Escalate actions in the rules
|
|
2293
|
-
* config that have no notifier registered
|
|
2294
|
-
*
|
|
2339
|
+
* config that have no notifier registered against `registry` — i.e. no
|
|
2340
|
+
* matching entry under the rules YAML's `channels:` section. `createNotifier`
|
|
2341
|
+
* treats a non-empty result as a fail-fast startup error.
|
|
2295
2342
|
*
|
|
2296
2343
|
* Returns an empty list when no rules config is set.
|
|
2297
2344
|
*/
|
|
@@ -2299,9 +2346,19 @@ function collectUnresolvedChannels(config, registry) {
|
|
|
2299
2346
|
if (!config.rulesConfigPath) return [];
|
|
2300
2347
|
const ruleConfig = parseRuleConfig(readFileSync(config.rulesConfigPath, "utf-8"));
|
|
2301
2348
|
const referenced = /* @__PURE__ */ new Set();
|
|
2302
|
-
for (const section of
|
|
2349
|
+
for (const section of [ruleConfig["pre-llm"], ruleConfig["post-llm"]]) for (const rule of section.rules) for (const action of rule.actions) if ("channel" in action) referenced.add(action.channel);
|
|
2303
2350
|
return [...referenced].filter((channel) => !registry?.has(channel));
|
|
2304
2351
|
}
|
|
2352
|
+
/**
|
|
2353
|
+
* Creates the RuleEngine from a YAML rules config file.
|
|
2354
|
+
*
|
|
2355
|
+
* Returns undefined when `config.rulesConfigPath` is not set,
|
|
2356
|
+
* meaning rule evaluation is disabled (pass-through behavior).
|
|
2357
|
+
*/
|
|
2358
|
+
function createRuleEngine(config) {
|
|
2359
|
+
if (!config.rulesConfigPath) return;
|
|
2360
|
+
return new RuleEngine(parseRuleConfig(readFileSync(config.rulesConfigPath, "utf-8")));
|
|
2361
|
+
}
|
|
2305
2362
|
//#endregion
|
|
2306
2363
|
//#region src/infrastructure/rollback/noop-rollback-action.handler.ts
|
|
2307
2364
|
const logger$1 = createLogger();
|
|
@@ -36003,6 +36060,6 @@ async function loadConfig() {
|
|
|
36003
36060
|
return result.data;
|
|
36004
36061
|
}
|
|
36005
36062
|
//#endregion
|
|
36006
|
-
export { ALERT_TYPE_LABELS, AlertClusterSchema, AlertStatusSchema, AlertType, AlertmanagerPayloadSchema, BedrockProvider, CIRCUIT_BREAKER, ChannelRegistry, ClaudeProvider, ClusteringService, Component, ConsoleNotifier, DEDUP_TTL_MS_MULTIPLIER, DEV_SERVER_PORT, DynamoDBDeduplicationStore, FactoryRegistry, Fingerprint, GeminiProvider, HOUR_MS, HTTP_TIMEOUT_MS, InMemoryAlertQueue, InMemoryDeduplicationStore, InMemoryIndexer, IncidentSchema, LLMAnalysisSchema, LLMProviderType, LLM_FALLBACK_DEFAULTS, LLM_MAX_TOKENS, LLM_MODELS, LokiTraceRepository, MockLLMProvider, MockTraceRepository, NoopRollbackActionHandler, NormalizedAlertSchema, NotifyOutcome, OpenRouterProvider, OpenSearchIndexer, Outcome, PAYLOAD_DEFAULTS, ProcessIncidentUseCase, RATE_LIMITER, REDIS_KEY_PREFIX, ROLLBACK_ACTION_ID, RedisDeduplicationStore, RoutingNotifier, RuleActionSchema, RuleActionType, RuleConditionSchema, RuleConfigurationSchema, RuleEngine, RuleEvaluationPhase, RuleSchema, RuleSectionSchema, SLACK_API_URL, SQSAlertQueue, SamplingDecision, SeverityLevel, SlackNotifier, Stage, TEAMS_WEBHOOK_TIMEOUT_MS, TeamsNotifier, TeamsNotifierError, URGENCY_EMOJI, UrgencyLevelSchema, WEBHOOK_DEFAULTS, WideEventBuilder, compileCondition, createLLMProvider, createLogger, createNotifier, createRollbackActionHandler, dispatchActions, flushLoki, loadConfig, metrics_exports as metrics, normalizePayload, parseRuleConfig, reinitLogger, startSqsLagPoller };
|
|
36063
|
+
export { ALERT_TYPE_LABELS, AlertClusterSchema, AlertStatusSchema, AlertType, AlertmanagerPayloadSchema, BedrockProvider, CIRCUIT_BREAKER, ChannelConfigSchema, ChannelRegistry, ChannelType, ClaudeProvider, ClusteringService, Component, ConsoleNotifier, DEDUP_TTL_MS_MULTIPLIER, DEV_SERVER_PORT, DynamoDBDeduplicationStore, FactoryRegistry, Fingerprint, GeminiProvider, HOUR_MS, HTTP_TIMEOUT_MS, InMemoryAlertQueue, InMemoryDeduplicationStore, InMemoryIndexer, IncidentSchema, LLMAnalysisSchema, LLMProviderType, LLM_FALLBACK_DEFAULTS, LLM_MAX_TOKENS, LLM_MODELS, LokiTraceRepository, MockLLMProvider, MockTraceRepository, NoopRollbackActionHandler, NormalizedAlertSchema, NotifyOutcome, OpenRouterProvider, OpenSearchIndexer, Outcome, PAYLOAD_DEFAULTS, ProcessIncidentUseCase, RATE_LIMITER, REDIS_KEY_PREFIX, ROLLBACK_ACTION_ID, RedisDeduplicationStore, RoutingNotifier, RuleActionSchema, RuleActionType, RuleConditionSchema, RuleConfigurationSchema, RuleEngine, RuleEvaluationPhase, RuleSchema, RuleSectionSchema, SLACK_API_URL, SQSAlertQueue, SamplingDecision, SeverityLevel, SlackNotifier, Stage, TEAMS_WEBHOOK_TIMEOUT_MS, TeamsNotifier, TeamsNotifierError, URGENCY_EMOJI, UrgencyLevelSchema, WEBHOOK_DEFAULTS, WideEventBuilder, compileCondition, createLLMProvider, createLogger, createNotifier, createRollbackActionHandler, createRuleEngine, dispatchActions, flushLoki, loadConfig, metrics_exports as metrics, normalizePayload, parseRuleConfig, reinitLogger, startSqsLagPoller };
|
|
36007
36064
|
|
|
36008
36065
|
//# sourceMappingURL=index.js.map
|