@hamak/notification-api 0.4.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.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * API interfaces for notification service
3
+ */
4
+ export type { INotificationService, NotificationListener, } from './notification-service.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * API interfaces for notification service
3
+ */
4
+ export {};
@@ -0,0 +1,150 @@
1
+ import type { INotification, NotificationOptions } from '../types/notification.js';
2
+ /**
3
+ * Listener function for notification changes
4
+ */
5
+ export type NotificationListener = (notifications: INotification[]) => void;
6
+ /**
7
+ * Service interface for managing notifications
8
+ *
9
+ * This service provides methods to create, dismiss, and observe notifications.
10
+ * All notifications are pure data structures (fully serializable).
11
+ */
12
+ export interface INotificationService {
13
+ /**
14
+ * Create a notification with full control over all properties
15
+ *
16
+ * @param notification - Notification data (id and timestamp will be auto-generated)
17
+ * @returns The generated notification ID
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const id = notificationService.notify({
22
+ * type: 'success',
23
+ * title: 'Upload Complete',
24
+ * message: 'File uploaded successfully',
25
+ * duration: 5000,
26
+ * source: 'file-upload',
27
+ * metadata: { filePath: '/uploads/document.pdf' }
28
+ * });
29
+ * ```
30
+ */
31
+ notify(notification: Omit<INotification, 'id' | 'timestamp'>): string;
32
+ /**
33
+ * Create an informational notification
34
+ *
35
+ * @param message - The notification message
36
+ * @param title - Optional title (defaults to 'Info')
37
+ * @param options - Optional notification options
38
+ * @returns The generated notification ID
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * notificationService.info('Processing started', 'Background Task', {
43
+ * duration: 3000,
44
+ * source: 'task-processor'
45
+ * });
46
+ * ```
47
+ */
48
+ info(message: string, title?: string, options?: NotificationOptions): string;
49
+ /**
50
+ * Create a success notification
51
+ *
52
+ * @param message - The notification message
53
+ * @param title - Optional title (defaults to 'Success')
54
+ * @param options - Optional notification options
55
+ * @returns The generated notification ID
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * notificationService.success('Data saved successfully');
60
+ * ```
61
+ */
62
+ success(message: string, title?: string, options?: NotificationOptions): string;
63
+ /**
64
+ * Create a warning notification
65
+ *
66
+ * @param message - The notification message
67
+ * @param title - Optional title (defaults to 'Warning')
68
+ * @param options - Optional notification options
69
+ * @returns The generated notification ID
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * notificationService.warning('Disk space is running low', 'System Warning', {
74
+ * source: 'system-monitor',
75
+ * metadata: { diskSpace: 512000 }
76
+ * });
77
+ * ```
78
+ */
79
+ warning(message: string, title?: string, options?: NotificationOptions): string;
80
+ /**
81
+ * Create an error notification
82
+ *
83
+ * @param message - The notification message
84
+ * @param title - Optional title (defaults to 'Error')
85
+ * @param options - Optional notification options
86
+ * @returns The generated notification ID
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * notificationService.error('Failed to save data', 'Save Error', {
91
+ * duration: 0, // No auto-dismiss for errors
92
+ * source: 'data-service',
93
+ * metadata: { errorCode: 'ERR_NETWORK' }
94
+ * });
95
+ * ```
96
+ */
97
+ error(message: string, title?: string, options?: NotificationOptions): string;
98
+ /**
99
+ * Dismiss a specific notification by ID
100
+ *
101
+ * @param id - The notification ID to dismiss
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const id = notificationService.info('Processing...');
106
+ * // Later...
107
+ * notificationService.dismiss(id);
108
+ * ```
109
+ */
110
+ dismiss(id: string): void;
111
+ /**
112
+ * Dismiss all notifications
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * notificationService.dismissAll();
117
+ * ```
118
+ */
119
+ dismissAll(): void;
120
+ /**
121
+ * Get all current notifications
122
+ *
123
+ * @returns Array of all active notifications
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const notifications = notificationService.getAll();
128
+ * console.log(`You have ${notifications.length} notifications`);
129
+ * ```
130
+ */
131
+ getAll(): INotification[];
132
+ /**
133
+ * Subscribe to notification changes
134
+ *
135
+ * @param listener - Callback function that receives updated notification list
136
+ * @returns Unsubscribe function
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const unsubscribe = notificationService.subscribe((notifications) => {
141
+ * console.log('Notifications updated:', notifications);
142
+ * });
143
+ *
144
+ * // Later...
145
+ * unsubscribe();
146
+ * ```
147
+ */
148
+ subscribe(listener: NotificationListener): () => void;
149
+ }
150
+ //# sourceMappingURL=notification-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-service.d.ts","sourceRoot":"","sources":["../../src/api/notification-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,MAAM,CAAC;IAEtE;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;IAE7E;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;IAEhF;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;IAEhF;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;IAE9E;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;;;;;;OAOG;IACH,UAAU,IAAI,IAAI,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,MAAM,IAAI,aAAa,EAAE,CAAC;IAE1B;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,IAAI,CAAC;CACvD"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * API interfaces for notification service
3
+ */
4
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @hamak/notification-api
3
+ *
4
+ * Public API for the pluggable notification system.
5
+ * Provides pure interfaces, types, and service tokens for notifications.
6
+ * All data structures are fully serializable for Redux/storage/network.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ // Export all API interfaces
11
+ export * from './api/index.js';
12
+ // Export all types
13
+ export * from './types/index.js';
14
+ // Export service tokens
15
+ export * from './tokens/index.js';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Service tokens for notification system
3
+ */
4
+ export { NOTIFICATION_SERVICE_TOKEN, } from './service-tokens.js';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Dependency Injection tokens for notification services
3
+ */
4
+ /**
5
+ * Token for injecting the NotificationService
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * export const myPlugin: PluginModule = {
10
+ * initialize(ctx) {
11
+ * const notificationService = ctx.resolve(NOTIFICATION_SERVICE_TOKEN);
12
+ * notificationService.success('Plugin initialized');
13
+ * }
14
+ * };
15
+ * ```
16
+ */
17
+ export const NOTIFICATION_SERVICE_TOKEN = Symbol.for('@hamak/notification:NotificationService');
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Type definitions for notifications
3
+ */
4
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @hamak/notification-api
3
+ *
4
+ * Public API for the pluggable notification system.
5
+ * Provides pure interfaces, types, and service tokens for notifications.
6
+ * All data structures are fully serializable for Redux/storage/network.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export * from './api/index.js';
11
+ export * from './types/index.js';
12
+ export * from './tokens/index.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,cAAc,gBAAgB,CAAC;AAG/B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @hamak/notification-api
3
+ *
4
+ * Public API for the pluggable notification system.
5
+ * Provides pure interfaces, types, and service tokens for notifications.
6
+ * All data structures are fully serializable for Redux/storage/network.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ // Export all API interfaces
11
+ export * from './api/index.js';
12
+ // Export all types
13
+ export * from './types/index.js';
14
+ // Export service tokens
15
+ export * from './tokens/index.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Service tokens for notification system
3
+ */
4
+ export { NOTIFICATION_SERVICE_TOKEN, type NotificationServiceToken, } from './service-tokens.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,0BAA0B,EAC1B,KAAK,wBAAwB,GAC9B,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Service tokens for notification system
3
+ */
4
+ export { NOTIFICATION_SERVICE_TOKEN, } from './service-tokens.js';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Dependency Injection tokens for notification services
3
+ */
4
+ /**
5
+ * Token for injecting the NotificationService
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * export const myPlugin: PluginModule = {
10
+ * initialize(ctx) {
11
+ * const notificationService = ctx.resolve(NOTIFICATION_SERVICE_TOKEN);
12
+ * notificationService.success('Plugin initialized');
13
+ * }
14
+ * };
15
+ * ```
16
+ */
17
+ export declare const NOTIFICATION_SERVICE_TOKEN: unique symbol;
18
+ /**
19
+ * Type helper for NOTIFICATION_SERVICE_TOKEN
20
+ */
21
+ export type NotificationServiceToken = typeof NOTIFICATION_SERVICE_TOKEN;
22
+ //# sourceMappingURL=service-tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-tokens.d.ts","sourceRoot":"","sources":["../../src/tokens/service-tokens.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,0BAA0B,eAAwD,CAAC;AAEhG;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,0BAA0B,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Dependency Injection tokens for notification services
3
+ */
4
+ /**
5
+ * Token for injecting the NotificationService
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * export const myPlugin: PluginModule = {
10
+ * initialize(ctx) {
11
+ * const notificationService = ctx.resolve(NOTIFICATION_SERVICE_TOKEN);
12
+ * notificationService.success('Plugin initialized');
13
+ * }
14
+ * };
15
+ * ```
16
+ */
17
+ export const NOTIFICATION_SERVICE_TOKEN = Symbol.for('@hamak/notification:NotificationService');
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Type definitions for notifications
3
+ */
4
+ export type { INotification, NotificationType, NotificationOptions, } from './notification.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Type definitions for notifications
3
+ */
4
+ export {};
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Pure data structure representing a notification message.
3
+ * This interface is fully serializable and can be stored in Redux,
4
+ * persisted to storage, or transmitted over the network.
5
+ */
6
+ export interface INotification {
7
+ /**
8
+ * Unique identifier for the notification
9
+ */
10
+ id: string;
11
+ /**
12
+ * Type/severity of the notification
13
+ */
14
+ type: 'info' | 'success' | 'warning' | 'error';
15
+ /**
16
+ * Title/heading of the notification
17
+ */
18
+ title: string;
19
+ /**
20
+ * Main notification message
21
+ */
22
+ message: string;
23
+ /**
24
+ * Unix timestamp (milliseconds) when notification was created
25
+ */
26
+ timestamp: number;
27
+ /**
28
+ * Optional auto-dismiss duration in milliseconds
29
+ * If not set, notification will persist until manually dismissed
30
+ */
31
+ duration?: number;
32
+ /**
33
+ * Optional source identifier (e.g., 'file-upload', 'auth-session')
34
+ * Used by UI layer to determine appropriate actions
35
+ */
36
+ source?: string;
37
+ /**
38
+ * Optional serializable metadata for additional context
39
+ * Must be JSON-serializable (no functions, Dates should be timestamps, etc.)
40
+ */
41
+ metadata?: Record<string, unknown>;
42
+ }
43
+ /**
44
+ * Type for notification severity levels
45
+ */
46
+ export type NotificationType = INotification['type'];
47
+ /**
48
+ * Options for creating a notification (excludes id and timestamp)
49
+ */
50
+ export interface NotificationOptions {
51
+ /**
52
+ * Auto-dismiss duration in milliseconds
53
+ */
54
+ duration?: number;
55
+ /**
56
+ * Source identifier
57
+ */
58
+ source?: string;
59
+ /**
60
+ * Additional serializable metadata
61
+ */
62
+ metadata?: Record<string, unknown>;
63
+ }
64
+ //# sourceMappingURL=notification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../src/types/notification.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IAE/C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@hamak/notification-api",
3
+ "version": "0.4.0",
4
+ "description": "Notification API - Pure interfaces and types for pluggable notification system",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js",
13
+ "legacy": "./dist/es2015/index.js"
14
+ },
15
+ "./es2015": {
16
+ "import": "./dist/es2015/index.js",
17
+ "default": "./dist/es2015/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/amah/app-framework.git",
26
+ "directory": "packages/notification/notification-api"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc -p tsconfig.lib.json && tsc -p tsconfig.es2015.json",
33
+ "clean": "rm -rf dist"
34
+ },
35
+ "keywords": [
36
+ "notification",
37
+ "api",
38
+ "interfaces",
39
+ "microkernel"
40
+ ],
41
+ "author": "",
42
+ "license": "MIT",
43
+ "devDependencies": {
44
+ "typescript": "^5.9.3",
45
+ "vitest": "^3.2.4"
46
+ }
47
+ }