@junando/core 0.9.0 → 0.10.1
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 +28 -1
- package/dist/index.js +64 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -685,6 +685,33 @@ declare class MockTraceRepository implements ITraceRepository {
|
|
|
685
685
|
addFixture(traceId: string, spans: Record<string, unknown>[]): void;
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
+
declare class FactoryRegistry<T> {
|
|
689
|
+
private readonly _factories;
|
|
690
|
+
private _default;
|
|
691
|
+
/**
|
|
692
|
+
* Register a factory for a given key.
|
|
693
|
+
* Overwrites any existing registration for that key.
|
|
694
|
+
*/
|
|
695
|
+
register(key: string, factory: () => T): void;
|
|
696
|
+
/**
|
|
697
|
+
* Set the default factory to use when no key matches.
|
|
698
|
+
*/
|
|
699
|
+
registerDefault(factory: () => T): void;
|
|
700
|
+
/**
|
|
701
|
+
* Resolve the factory for a given key.
|
|
702
|
+
* Returns the default if no specific factory is registered for that key.
|
|
703
|
+
*/
|
|
704
|
+
resolve(key: string): T;
|
|
705
|
+
/**
|
|
706
|
+
* Check if a factory is registered for a given key.
|
|
707
|
+
*/
|
|
708
|
+
has(key: string): boolean;
|
|
709
|
+
/**
|
|
710
|
+
* Return all registered keys.
|
|
711
|
+
*/
|
|
712
|
+
keys(): string[];
|
|
713
|
+
}
|
|
714
|
+
|
|
688
715
|
/**
|
|
689
716
|
* Flush all buffered log entries to Loki in a single HTTP request.
|
|
690
717
|
* Call this at the END of the Lambda handler, after all business logic completes.
|
|
@@ -731,4 +758,4 @@ declare namespace index {
|
|
|
731
758
|
export { index_alertClusters as alertClusters, index_alertsProcessed as alertsProcessed, index_alertsReceived as alertsReceived, index_dedupDuplicate as dedupDuplicate, index_dedupNew as dedupNew, index_dedupRedisFailoverTotal as dedupRedisFailoverTotal, index_latency as latency, index_llmInferenceDuration as llmInferenceDuration, index_llmInferenceTotal as llmInferenceTotal, index_notificationsTotal as notificationsTotal, index_pipelineInlineFailuresTotal as pipelineInlineFailuresTotal, index_registry as registry, index_sqsQueueLag as sqsQueueLag, index_webhookRequestsTotal as webhookRequestsTotal };
|
|
732
759
|
}
|
|
733
760
|
|
|
734
|
-
export { ALERT_TYPE_LABELS, type AlertCluster, AlertClusterSchema, type AlertErrorType, type AlertStatus, AlertStatusSchema, AlertType, type AlertmanagerPayload, AlertmanagerPayloadSchema, CIRCUIT_BREAKER, ClaudeProvider, ClusteringService, type Config, ConsoleNotifier, DEDUP_TTL_MS_MULTIPLIER, DEV_SERVER_PORT, Fingerprint, GeminiProvider, HOUR_MS, HTTP_TIMEOUT_MS, type IAlertQueue, type IDeduplicationStore, type IIndexer, type ILLMProvider, type INotifier, type ITraceRepository, InMemoryAlertQueue, InMemoryDeduplicationStore, InMemoryIndexer, type Incident, IncidentSchema, type LLMAnalysis, LLMAnalysisSchema, LLMProviderType, LLM_FALLBACK_DEFAULTS, LLM_MAX_TOKENS, LLM_MODELS, type Logger, type LoggerOptions, LokiTraceRepository, MockLLMProvider, MockTraceRepository, type NormalizedAlert, NormalizedAlertSchema, type OpenSearchHttpFetcher, type OpenSearchHttpResponse, OpenSearchIndexer, type OpenSearchIndexerDeps, PAYLOAD_DEFAULTS, ProcessIncidentUseCase, RATE_LIMITER, REDIS_KEY_PREFIX, RedisDeduplicationStore, SLACK_API_URL, SQSAlertQueue, type SignedHttpRequest, SlackNotifier, TEAMS_WEBHOOK_TIMEOUT_MS, TeamsNotifier, TeamsNotifierError, type TraceabilityDocument, URGENCY_EMOJI, type UrgencyLevel, UrgencyLevelSchema, WEBHOOK_DEFAULTS, createLLMProvider, createLogger, createNotifier, flushLoki, loadConfig, index as metrics, normalizePayload, reinitLogger, startSqsLagPoller };
|
|
761
|
+
export { ALERT_TYPE_LABELS, type AlertCluster, AlertClusterSchema, type AlertErrorType, type AlertStatus, AlertStatusSchema, AlertType, type AlertmanagerPayload, AlertmanagerPayloadSchema, CIRCUIT_BREAKER, ClaudeProvider, ClusteringService, type Config, ConsoleNotifier, DEDUP_TTL_MS_MULTIPLIER, DEV_SERVER_PORT, FactoryRegistry, Fingerprint, GeminiProvider, HOUR_MS, HTTP_TIMEOUT_MS, type IAlertQueue, type IDeduplicationStore, type IIndexer, type ILLMProvider, type INotifier, type ITraceRepository, InMemoryAlertQueue, InMemoryDeduplicationStore, InMemoryIndexer, type Incident, IncidentSchema, type LLMAnalysis, LLMAnalysisSchema, LLMProviderType, LLM_FALLBACK_DEFAULTS, LLM_MAX_TOKENS, LLM_MODELS, type Logger, type LoggerOptions, LokiTraceRepository, MockLLMProvider, MockTraceRepository, type NormalizedAlert, NormalizedAlertSchema, type OpenSearchHttpFetcher, type OpenSearchHttpResponse, OpenSearchIndexer, type OpenSearchIndexerDeps, PAYLOAD_DEFAULTS, ProcessIncidentUseCase, RATE_LIMITER, REDIS_KEY_PREFIX, RedisDeduplicationStore, SLACK_API_URL, SQSAlertQueue, type SignedHttpRequest, SlackNotifier, TEAMS_WEBHOOK_TIMEOUT_MS, TeamsNotifier, TeamsNotifierError, type TraceabilityDocument, URGENCY_EMOJI, type UrgencyLevel, UrgencyLevelSchema, WEBHOOK_DEFAULTS, createLLMProvider, createLogger, createNotifier, flushLoki, loadConfig, index as metrics, normalizePayload, reinitLogger, startSqsLagPoller };
|
package/dist/index.js
CHANGED
|
@@ -1005,6 +1005,50 @@ function createLLMProvider(provider, apiKey, model, options) {
|
|
|
1005
1005
|
return factory(apiKey, model, options);
|
|
1006
1006
|
}
|
|
1007
1007
|
|
|
1008
|
+
// src/shared/factory-registry.ts
|
|
1009
|
+
var FactoryRegistry = class {
|
|
1010
|
+
_factories = /* @__PURE__ */ new Map();
|
|
1011
|
+
_default = () => {
|
|
1012
|
+
throw new Error(`No factory registered and no default available`);
|
|
1013
|
+
};
|
|
1014
|
+
/**
|
|
1015
|
+
* Register a factory for a given key.
|
|
1016
|
+
* Overwrites any existing registration for that key.
|
|
1017
|
+
*/
|
|
1018
|
+
register(key, factory) {
|
|
1019
|
+
this._factories.set(key, factory);
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Set the default factory to use when no key matches.
|
|
1023
|
+
*/
|
|
1024
|
+
registerDefault(factory) {
|
|
1025
|
+
this._default = factory;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Resolve the factory for a given key.
|
|
1029
|
+
* Returns the default if no specific factory is registered for that key.
|
|
1030
|
+
*/
|
|
1031
|
+
resolve(key) {
|
|
1032
|
+
const factory = this._factories.get(key);
|
|
1033
|
+
if (factory) {
|
|
1034
|
+
return factory();
|
|
1035
|
+
}
|
|
1036
|
+
return this._default();
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Check if a factory is registered for a given key.
|
|
1040
|
+
*/
|
|
1041
|
+
has(key) {
|
|
1042
|
+
return this._factories.has(key);
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Return all registered keys.
|
|
1046
|
+
*/
|
|
1047
|
+
keys() {
|
|
1048
|
+
return Array.from(this._factories.keys());
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1008
1052
|
// src/infrastructure/notifier/slack.adapter.ts
|
|
1009
1053
|
var logger3 = createLogger();
|
|
1010
1054
|
function sanitizeEndpointPath(endpointPath) {
|
|
@@ -1336,14 +1380,26 @@ var TeamsNotifier = class {
|
|
|
1336
1380
|
};
|
|
1337
1381
|
|
|
1338
1382
|
// src/infrastructure/notifier/factory.ts
|
|
1383
|
+
function buildNotifierRegistry(config) {
|
|
1384
|
+
const registry2 = new FactoryRegistry();
|
|
1385
|
+
registry2.register("teams", () => {
|
|
1386
|
+
if (!config.teamsWebhookUrl) {
|
|
1387
|
+
throw new Error("NOTIFIER_TYPE=teams requires TEAMS_WEBHOOK_URL to be set");
|
|
1388
|
+
}
|
|
1389
|
+
return new TeamsNotifier(config.teamsWebhookUrl);
|
|
1390
|
+
});
|
|
1391
|
+
registry2.register("slack", () => {
|
|
1392
|
+
if (!config.slackBotToken || !config.slackChannel) {
|
|
1393
|
+
throw new Error("NOTIFIER_TYPE=slack requires SLACK_BOT_TOKEN and SLACK_CHANNEL to be set");
|
|
1394
|
+
}
|
|
1395
|
+
return new SlackNotifier(config.slackBotToken, config.slackChannel);
|
|
1396
|
+
});
|
|
1397
|
+
registry2.registerDefault(() => new SlackNotifier("dummy-token", "#alerts"));
|
|
1398
|
+
return registry2;
|
|
1399
|
+
}
|
|
1339
1400
|
function createNotifier(config) {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
return new TeamsNotifier(config.teamsWebhookUrl);
|
|
1343
|
-
case "slack":
|
|
1344
|
-
default:
|
|
1345
|
-
return new SlackNotifier(config.slackBotToken, config.slackChannel);
|
|
1346
|
-
}
|
|
1401
|
+
const registry2 = buildNotifierRegistry(config);
|
|
1402
|
+
return registry2.resolve(config.notifierType);
|
|
1347
1403
|
}
|
|
1348
1404
|
|
|
1349
1405
|
// ../../node_modules/.pnpm/@smithy+smithy-client@4.12.13/node_modules/@smithy/smithy-client/dist-es/NoOpLogger.js
|
|
@@ -9899,6 +9955,7 @@ export {
|
|
|
9899
9955
|
ConsoleNotifier,
|
|
9900
9956
|
DEDUP_TTL_MS_MULTIPLIER,
|
|
9901
9957
|
DEV_SERVER_PORT,
|
|
9958
|
+
FactoryRegistry,
|
|
9902
9959
|
Fingerprint,
|
|
9903
9960
|
GeminiProvider,
|
|
9904
9961
|
HOUR_MS,
|