@luxexchange/notifications 1.0.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.
Files changed (45) hide show
  1. package/.depcheckrc +14 -0
  2. package/.eslintrc.js +20 -0
  3. package/README.md +548 -0
  4. package/package.json +42 -0
  5. package/project.json +30 -0
  6. package/src/getIsNotificationServiceLocalOverrideEnabled.ts +7 -0
  7. package/src/global.d.ts +2 -0
  8. package/src/index.ts +41 -0
  9. package/src/notification-data-source/NotificationDataSource.ts +8 -0
  10. package/src/notification-data-source/getNotificationQueryOptions.ts +85 -0
  11. package/src/notification-data-source/implementations/createIntervalNotificationDataSource.ts +73 -0
  12. package/src/notification-data-source/implementations/createLocalTriggerDataSource.test.ts +492 -0
  13. package/src/notification-data-source/implementations/createLocalTriggerDataSource.ts +177 -0
  14. package/src/notification-data-source/implementations/createNotificationDataSource.ts +19 -0
  15. package/src/notification-data-source/implementations/createPollingNotificationDataSource.test.ts +398 -0
  16. package/src/notification-data-source/implementations/createPollingNotificationDataSource.ts +74 -0
  17. package/src/notification-data-source/implementations/createReactiveDataSource.ts +113 -0
  18. package/src/notification-data-source/types/ReactiveCondition.ts +60 -0
  19. package/src/notification-processor/NotificationProcessor.ts +26 -0
  20. package/src/notification-processor/implementations/createBaseNotificationProcessor.test.ts +854 -0
  21. package/src/notification-processor/implementations/createBaseNotificationProcessor.ts +239 -0
  22. package/src/notification-processor/implementations/createNotificationProcessor.test.ts +130 -0
  23. package/src/notification-processor/implementations/createNotificationProcessor.ts +15 -0
  24. package/src/notification-renderer/NotificationRenderer.ts +8 -0
  25. package/src/notification-renderer/components/BannerTemplate.tsx +188 -0
  26. package/src/notification-renderer/components/InlineBannerNotification.tsx +123 -0
  27. package/src/notification-renderer/implementations/createNotificationRenderer.ts +16 -0
  28. package/src/notification-renderer/utils/iconUtils.ts +103 -0
  29. package/src/notification-service/NotificationService.ts +47 -0
  30. package/src/notification-service/implementations/createNotificationService.test.ts +1092 -0
  31. package/src/notification-service/implementations/createNotificationService.ts +364 -0
  32. package/src/notification-telemetry/NotificationTelemetry.ts +44 -0
  33. package/src/notification-telemetry/implementations/createNotificationTelemetry.test.ts +99 -0
  34. package/src/notification-telemetry/implementations/createNotificationTelemetry.ts +33 -0
  35. package/src/notification-tracker/NotificationTracker.ts +14 -0
  36. package/src/notification-tracker/implementations/createApiNotificationTracker.test.ts +465 -0
  37. package/src/notification-tracker/implementations/createApiNotificationTracker.ts +154 -0
  38. package/src/notification-tracker/implementations/createNoopNotificationTracker.ts +44 -0
  39. package/src/notification-tracker/implementations/createNotificationTracker.ts +31 -0
  40. package/src/utils/formatNotificationType.test.ts +25 -0
  41. package/src/utils/formatNotificationType.ts +25 -0
  42. package/tsconfig.json +24 -0
  43. package/tsconfig.lint.json +8 -0
  44. package/vitest-setup.ts +1 -0
  45. package/vitest.config.ts +14 -0
@@ -0,0 +1,25 @@
1
+ import { ContentStyle } from '@luxfi/api'
2
+ import { formatNotificationType } from '@luxfi/notifications/src/utils/formatNotificationType'
3
+ import { describe, expect, it } from 'vitest'
4
+
5
+ describe('formatNotificationType', () => {
6
+ it('should format ContentStyle.MODAL', () => {
7
+ expect(formatNotificationType(ContentStyle.MODAL)).toBe('modal')
8
+ })
9
+
10
+ it('should format ContentStyle.LOWER_LEFT_BANNER', () => {
11
+ expect(formatNotificationType(ContentStyle.LOWER_LEFT_BANNER)).toBe('lower_left_banner')
12
+ })
13
+
14
+ it('should format ContentStyle.UNSPECIFIED', () => {
15
+ expect(formatNotificationType(ContentStyle.UNSPECIFIED)).toBe('unspecified')
16
+ })
17
+
18
+ it('should return "unknown" for undefined', () => {
19
+ expect(formatNotificationType(undefined)).toBe('unknown')
20
+ })
21
+
22
+ it('should return "unknown_N" for unrecognized numeric values', () => {
23
+ expect(formatNotificationType(999 as ContentStyle)).toBe('unknown_999')
24
+ })
25
+ })
@@ -0,0 +1,25 @@
1
+ import { ContentStyle } from '@luxfi/api'
2
+
3
+ /**
4
+ * Converts a ContentStyle enum value to a human-readable string for logging/telemetry
5
+ * @param style - The ContentStyle enum value (numeric)
6
+ * @returns A human-readable string representation of the notification type
7
+ */
8
+ export function formatNotificationType(style: number | undefined): string {
9
+ if (style === undefined) {
10
+ return 'unknown'
11
+ }
12
+
13
+ switch (style) {
14
+ case ContentStyle.MODAL:
15
+ return 'modal'
16
+ case ContentStyle.LOWER_LEFT_BANNER:
17
+ return 'lower_left_banner'
18
+ case ContentStyle.UNSPECIFIED:
19
+ return 'unspecified'
20
+ case ContentStyle.SYSTEM_BANNER:
21
+ return 'system_banner'
22
+ default:
23
+ return `unknown_${style}`
24
+ }
25
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "extends": "../../config/tsconfig/app.json",
3
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.json", "../../index.d.ts"],
4
+ "exclude": ["src/**/*.spec.ts", "src/**/*.spec.tsx", "src/**/*.test.ts", "src/**/*.test.tsx"],
5
+ "compilerOptions": {
6
+ "emitDeclarationOnly": true,
7
+ "noEmit": false,
8
+ "paths": {
9
+ "@universe/notifications/*": ["./*"]
10
+ },
11
+ "types": ["node", "vitest/globals"]
12
+ },
13
+ "references": [
14
+ {
15
+ "path": "../utilities"
16
+ },
17
+ {
18
+ "path": "../api"
19
+ },
20
+ {
21
+ "path": "../ui"
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "preserveSymlinks": true
5
+ },
6
+ "include": ["**/*.ts", "**/*.tsx", "**/*.json"],
7
+ "exclude": ["node_modules"]
8
+ }
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: 'node',
6
+ setupFiles: ['./vitest-setup.ts'],
7
+ coverage: {
8
+ exclude: ['**/__generated__/**', '**/node_modules/**', '**/dist/**', '**/*.config.*', '**/scripts/**'],
9
+ },
10
+ },
11
+ resolve: {
12
+ extensions: ['.web.ts', '.web.tsx', '.ts', '.tsx', '.js', '.jsx', '.json'],
13
+ },
14
+ })