@camstack/addon-advanced-notifier 0.1.7 → 0.1.9

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.
@@ -0,0 +1,23 @@
1
+ import { ICamstackAddon, AddonManifest, AddonContext, CapabilityProviderMap } from '@camstack/types';
2
+
3
+ declare class AdvancedNotifierAddon implements ICamstackAddon {
4
+ readonly manifest: AddonManifest;
5
+ private context;
6
+ private ruleStore;
7
+ private ruleEngine;
8
+ private cooldown;
9
+ private cachedRules;
10
+ private consoleOutput;
11
+ private outputs;
12
+ private auditLog;
13
+ private unsubscribers;
14
+ private readonly notifier;
15
+ initialize(context: AddonContext): Promise<void>;
16
+ shutdown(): Promise<void>;
17
+ getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
18
+ private handleEvent;
19
+ private buildTemplateVariables;
20
+ private priorityToSeverity;
21
+ }
22
+
23
+ export { AdvancedNotifierAddon, AdvancedNotifierAddon as default };
@@ -0,0 +1,23 @@
1
+ import { ICamstackAddon, AddonManifest, AddonContext, CapabilityProviderMap } from '@camstack/types';
2
+
3
+ declare class AdvancedNotifierAddon implements ICamstackAddon {
4
+ readonly manifest: AddonManifest;
5
+ private context;
6
+ private ruleStore;
7
+ private ruleEngine;
8
+ private cooldown;
9
+ private cachedRules;
10
+ private consoleOutput;
11
+ private outputs;
12
+ private auditLog;
13
+ private unsubscribers;
14
+ private readonly notifier;
15
+ initialize(context: AddonContext): Promise<void>;
16
+ shutdown(): Promise<void>;
17
+ getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
18
+ private handleEvent;
19
+ private buildTemplateVariables;
20
+ private priorityToSeverity;
21
+ }
22
+
23
+ export { AdvancedNotifierAddon, AdvancedNotifierAddon as default };
@@ -0,0 +1,97 @@
1
+ export { AdvancedNotifierAddon } from './addon.mjs';
2
+ import { NotificationRule, ISettingsBackend, INotificationOutput, Notification, IScopedLogger, NotificationHistoryEntry, NotificationHistoryFilter } from '@camstack/types';
3
+
4
+ declare function renderTemplate(template: string, variables: Record<string, string>): string;
5
+
6
+ declare class CooldownTracker {
7
+ private readonly lastFired;
8
+ canFire(ruleId: string, cooldownSeconds: number): boolean;
9
+ recordFire(ruleId: string): void;
10
+ reset(): void;
11
+ }
12
+
13
+ interface EventData {
14
+ readonly id: string;
15
+ readonly timestamp: Date;
16
+ readonly source: {
17
+ readonly type: string;
18
+ readonly id: string;
19
+ };
20
+ readonly category: string;
21
+ readonly data: Record<string, unknown>;
22
+ }
23
+ declare class RuleEngine {
24
+ evaluate(event: EventData, rules: readonly NotificationRule[]): NotificationRule[];
25
+ private matchesRule;
26
+ private evaluateConditions;
27
+ }
28
+
29
+ declare class RuleStore {
30
+ private readonly backend;
31
+ constructor(backend: ISettingsBackend);
32
+ getRules(): Promise<NotificationRule[]>;
33
+ saveRules(rules: readonly NotificationRule[]): Promise<void>;
34
+ upsertRule(rule: NotificationRule): Promise<void>;
35
+ deleteRule(ruleId: string): Promise<void>;
36
+ }
37
+
38
+ declare class WebhookOutput implements INotificationOutput {
39
+ readonly id = "webhook";
40
+ readonly name = "Webhook";
41
+ readonly icon = "webhook";
42
+ private readonly url;
43
+ constructor(url: string);
44
+ send(notification: Notification): Promise<void>;
45
+ sendTest(): Promise<{
46
+ success: boolean;
47
+ error?: string;
48
+ }>;
49
+ }
50
+
51
+ declare class HomeAssistantOutput implements INotificationOutput {
52
+ readonly id = "home-assistant";
53
+ readonly name = "Home Assistant";
54
+ readonly icon = "home";
55
+ private readonly url;
56
+ private readonly token;
57
+ constructor(url: string, token: string);
58
+ send(notification: Notification): Promise<void>;
59
+ sendTest(): Promise<{
60
+ success: boolean;
61
+ error?: string;
62
+ }>;
63
+ }
64
+
65
+ declare class ConsoleOutput implements INotificationOutput {
66
+ readonly id = "console";
67
+ readonly name = "Console Log";
68
+ readonly icon = "terminal";
69
+ private readonly logger;
70
+ constructor(logger: IScopedLogger);
71
+ send(notification: Notification): Promise<void>;
72
+ sendTest(): Promise<{
73
+ success: boolean;
74
+ error?: string;
75
+ }>;
76
+ }
77
+
78
+ declare class NotificationBatcher {
79
+ private readonly windowMs;
80
+ private readonly handler;
81
+ private readonly batches;
82
+ constructor(windowMs: number, handler: (frameKey: string, events: unknown[]) => void);
83
+ add(frameKey: string, event: unknown): void;
84
+ private flush;
85
+ shutdown(): void;
86
+ }
87
+
88
+ declare class AuditLog {
89
+ private readonly backend;
90
+ private readonly maxEntries;
91
+ constructor(backend: ISettingsBackend, maxEntries?: number);
92
+ record(entry: NotificationHistoryEntry): Promise<void>;
93
+ getHistory(filter?: NotificationHistoryFilter): Promise<NotificationHistoryEntry[]>;
94
+ private getAll;
95
+ }
96
+
97
+ export { AuditLog, ConsoleOutput, CooldownTracker, HomeAssistantOutput, NotificationBatcher, RuleEngine, RuleStore, WebhookOutput, renderTemplate };
@@ -0,0 +1,97 @@
1
+ export { AdvancedNotifierAddon } from './addon.js';
2
+ import { NotificationRule, ISettingsBackend, INotificationOutput, Notification, IScopedLogger, NotificationHistoryEntry, NotificationHistoryFilter } from '@camstack/types';
3
+
4
+ declare function renderTemplate(template: string, variables: Record<string, string>): string;
5
+
6
+ declare class CooldownTracker {
7
+ private readonly lastFired;
8
+ canFire(ruleId: string, cooldownSeconds: number): boolean;
9
+ recordFire(ruleId: string): void;
10
+ reset(): void;
11
+ }
12
+
13
+ interface EventData {
14
+ readonly id: string;
15
+ readonly timestamp: Date;
16
+ readonly source: {
17
+ readonly type: string;
18
+ readonly id: string;
19
+ };
20
+ readonly category: string;
21
+ readonly data: Record<string, unknown>;
22
+ }
23
+ declare class RuleEngine {
24
+ evaluate(event: EventData, rules: readonly NotificationRule[]): NotificationRule[];
25
+ private matchesRule;
26
+ private evaluateConditions;
27
+ }
28
+
29
+ declare class RuleStore {
30
+ private readonly backend;
31
+ constructor(backend: ISettingsBackend);
32
+ getRules(): Promise<NotificationRule[]>;
33
+ saveRules(rules: readonly NotificationRule[]): Promise<void>;
34
+ upsertRule(rule: NotificationRule): Promise<void>;
35
+ deleteRule(ruleId: string): Promise<void>;
36
+ }
37
+
38
+ declare class WebhookOutput implements INotificationOutput {
39
+ readonly id = "webhook";
40
+ readonly name = "Webhook";
41
+ readonly icon = "webhook";
42
+ private readonly url;
43
+ constructor(url: string);
44
+ send(notification: Notification): Promise<void>;
45
+ sendTest(): Promise<{
46
+ success: boolean;
47
+ error?: string;
48
+ }>;
49
+ }
50
+
51
+ declare class HomeAssistantOutput implements INotificationOutput {
52
+ readonly id = "home-assistant";
53
+ readonly name = "Home Assistant";
54
+ readonly icon = "home";
55
+ private readonly url;
56
+ private readonly token;
57
+ constructor(url: string, token: string);
58
+ send(notification: Notification): Promise<void>;
59
+ sendTest(): Promise<{
60
+ success: boolean;
61
+ error?: string;
62
+ }>;
63
+ }
64
+
65
+ declare class ConsoleOutput implements INotificationOutput {
66
+ readonly id = "console";
67
+ readonly name = "Console Log";
68
+ readonly icon = "terminal";
69
+ private readonly logger;
70
+ constructor(logger: IScopedLogger);
71
+ send(notification: Notification): Promise<void>;
72
+ sendTest(): Promise<{
73
+ success: boolean;
74
+ error?: string;
75
+ }>;
76
+ }
77
+
78
+ declare class NotificationBatcher {
79
+ private readonly windowMs;
80
+ private readonly handler;
81
+ private readonly batches;
82
+ constructor(windowMs: number, handler: (frameKey: string, events: unknown[]) => void);
83
+ add(frameKey: string, event: unknown): void;
84
+ private flush;
85
+ shutdown(): void;
86
+ }
87
+
88
+ declare class AuditLog {
89
+ private readonly backend;
90
+ private readonly maxEntries;
91
+ constructor(backend: ISettingsBackend, maxEntries?: number);
92
+ record(entry: NotificationHistoryEntry): Promise<void>;
93
+ getHistory(filter?: NotificationHistoryFilter): Promise<NotificationHistoryEntry[]>;
94
+ private getAll;
95
+ }
96
+
97
+ export { AuditLog, ConsoleOutput, CooldownTracker, HomeAssistantOutput, NotificationBatcher, RuleEngine, RuleStore, WebhookOutput, renderTemplate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-advanced-notifier",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Rules-based notification engine for CamStack",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -8,9 +8,9 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./dist/index.d.ts",
11
12
  "import": "./dist/index.mjs",
12
- "require": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
13
+ "require": "./dist/index.js"
14
14
  },
15
15
  "./package.json": "./package.json"
16
16
  },