@timothyw/pat-common 1.0.123 → 1.0.125

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 CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './enums';
2
2
  export * from './types';
3
3
  export * from './utils';
4
- export * from './notification-entity-registry';
package/dist/index.js CHANGED
@@ -17,4 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./enums"), exports);
18
18
  __exportStar(require("./types"), exports);
19
19
  __exportStar(require("./utils"), exports);
20
- __exportStar(require("./notification-entity-registry"), exports);
@@ -1,77 +0,0 @@
1
- import { NotificationEntityConfig, ParentResolutionResult } from './types/notification-entity-config';
2
- /**
3
- * Registry for managing notification entity configurations and parent resolution
4
- */
5
- export declare class NotificationEntityRegistry {
6
- private static instance;
7
- private entityConfigs;
8
- private constructor();
9
- /**
10
- * Get the singleton instance
11
- */
12
- static getInstance(): NotificationEntityRegistry;
13
- /**
14
- * Register a new entity configuration
15
- */
16
- registerEntity(config: NotificationEntityConfig): void;
17
- /**
18
- * Get configuration for an entity type
19
- */
20
- getEntityConfig(entityType: string): NotificationEntityConfig | null;
21
- /**
22
- * Get all registered entity types
23
- */
24
- getEntityTypes(): string[];
25
- /**
26
- * Get all entity configurations
27
- */
28
- getAllConfigs(): NotificationEntityConfig[];
29
- /**
30
- * Resolve the parent type for a specific entity instance
31
- */
32
- resolveParent(entityType: string, entityData: any): ParentResolutionResult | null;
33
- /**
34
- * Check if an entity type supports dynamic parent resolution
35
- */
36
- isDynamicParentType(entityType: string): boolean;
37
- /**
38
- * Get the parent property name for dynamic resolution
39
- */
40
- getParentProperty(entityType: string): string | null;
41
- /**
42
- * Get display name for an entity type
43
- */
44
- getDisplayName(entityType: string): string;
45
- /**
46
- * Get icon for an entity type
47
- */
48
- getIcon(entityType: string): string | null;
49
- /**
50
- * Check if entity type exists
51
- */
52
- hasEntityType(entityType: string): boolean;
53
- /**
54
- * Remove an entity configuration
55
- */
56
- unregisterEntity(entityType: string): boolean;
57
- /**
58
- * Clear all configurations
59
- */
60
- clear(): void;
61
- /**
62
- * Resolve static parent type
63
- */
64
- private resolveStaticParent;
65
- /**
66
- * Resolve dynamic parent type based on entity data
67
- */
68
- private resolveDynamicParent;
69
- /**
70
- * Register default entity configurations
71
- */
72
- private registerDefaultEntities;
73
- }
74
- /**
75
- * Convenience function to get the singleton instance
76
- */
77
- export declare function getNotificationEntityRegistry(): NotificationEntityRegistry;
@@ -1,212 +1 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotificationEntityRegistry = void 0;
4
- exports.getNotificationEntityRegistry = getNotificationEntityRegistry;
5
- /**
6
- * Registry for managing notification entity configurations and parent resolution
7
- */
8
- class NotificationEntityRegistry {
9
- constructor() {
10
- this.entityConfigs = new Map();
11
- // Initialize with default configurations
12
- this.registerDefaultEntities();
13
- }
14
- /**
15
- * Get the singleton instance
16
- */
17
- static getInstance() {
18
- if (!NotificationEntityRegistry.instance) {
19
- NotificationEntityRegistry.instance = new NotificationEntityRegistry();
20
- }
21
- return NotificationEntityRegistry.instance;
22
- }
23
- /**
24
- * Register a new entity configuration
25
- */
26
- registerEntity(config) {
27
- this.entityConfigs.set(config.entityType, config);
28
- }
29
- /**
30
- * Get configuration for an entity type
31
- */
32
- getEntityConfig(entityType) {
33
- return this.entityConfigs.get(entityType) || null;
34
- }
35
- /**
36
- * Get all registered entity types
37
- */
38
- getEntityTypes() {
39
- return Array.from(this.entityConfigs.keys());
40
- }
41
- /**
42
- * Get all entity configurations
43
- */
44
- getAllConfigs() {
45
- return Array.from(this.entityConfigs.values());
46
- }
47
- /**
48
- * Resolve the parent type for a specific entity instance
49
- */
50
- resolveParent(entityType, entityData) {
51
- const config = this.entityConfigs.get(entityType);
52
- if (!config) {
53
- return null;
54
- }
55
- const resolver = config.parentResolver;
56
- if (resolver.type === 'static') {
57
- return this.resolveStaticParent(resolver);
58
- }
59
- else {
60
- return this.resolveDynamicParent(resolver, entityData);
61
- }
62
- }
63
- /**
64
- * Check if an entity type supports dynamic parent resolution
65
- */
66
- isDynamicParentType(entityType) {
67
- const config = this.entityConfigs.get(entityType);
68
- return config?.parentResolver.type === 'dynamic' || false;
69
- }
70
- /**
71
- * Get the parent property name for dynamic resolution
72
- */
73
- getParentProperty(entityType) {
74
- const config = this.entityConfigs.get(entityType);
75
- if (config?.parentResolver.type === 'dynamic') {
76
- return config.parentResolver.parentProperty;
77
- }
78
- return null;
79
- }
80
- /**
81
- * Get display name for an entity type
82
- */
83
- getDisplayName(entityType) {
84
- const config = this.entityConfigs.get(entityType);
85
- return config?.displayName || entityType;
86
- }
87
- /**
88
- * Get icon for an entity type
89
- */
90
- getIcon(entityType) {
91
- const config = this.entityConfigs.get(entityType);
92
- return config?.icon || null;
93
- }
94
- /**
95
- * Check if entity type exists
96
- */
97
- hasEntityType(entityType) {
98
- return this.entityConfigs.has(entityType);
99
- }
100
- /**
101
- * Remove an entity configuration
102
- */
103
- unregisterEntity(entityType) {
104
- return this.entityConfigs.delete(entityType);
105
- }
106
- /**
107
- * Clear all configurations
108
- */
109
- clear() {
110
- this.entityConfigs.clear();
111
- }
112
- /**
113
- * Resolve static parent type
114
- */
115
- resolveStaticParent(resolver) {
116
- return {
117
- parentType: resolver.parentType,
118
- isDynamic: false
119
- };
120
- }
121
- /**
122
- * Resolve dynamic parent type based on entity data
123
- */
124
- resolveDynamicParent(resolver, entityData) {
125
- const propertyValue = entityData?.[resolver.parentProperty];
126
- if (propertyValue && typeof propertyValue === 'string' && propertyValue.trim()) {
127
- // Use the property value to construct the parent type
128
- const parentType = resolver.parentTypePrefix + propertyValue.trim();
129
- return {
130
- parentType,
131
- isDynamic: true,
132
- resolvedProperty: propertyValue.trim(),
133
- usedFallback: false
134
- };
135
- }
136
- // Fall back to default parent
137
- return {
138
- parentType: resolver.fallbackParent,
139
- isDynamic: true,
140
- usedFallback: true
141
- };
142
- }
143
- /**
144
- * Register default entity configurations
145
- */
146
- registerDefaultEntities() {
147
- // Agenda Panel (dynamic parent for agenda items based on category)
148
- this.registerEntity({
149
- entityType: 'agenda_panel',
150
- parentResolver: {
151
- type: 'static',
152
- parentType: 'agenda_panel' // Panel level templates
153
- },
154
- displayName: 'Agenda Panel',
155
- icon: 'calendar',
156
- description: 'Default agenda panel templates'
157
- });
158
- // Agenda Item (dynamic parent based on category)
159
- this.registerEntity({
160
- entityType: 'agenda_item',
161
- parentResolver: {
162
- type: 'dynamic',
163
- parentProperty: 'category',
164
- parentTypePrefix: 'agenda_category_',
165
- fallbackParent: 'agenda_panel'
166
- },
167
- displayName: 'Agenda Item',
168
- icon: 'calendar',
169
- description: 'Individual agenda item notifications'
170
- });
171
- // Habits Panel (static parent for habits)
172
- this.registerEntity({
173
- entityType: 'habits_panel',
174
- parentResolver: {
175
- type: 'static',
176
- parentType: 'habits_panel'
177
- },
178
- displayName: 'Habits Panel',
179
- icon: 'fitness',
180
- description: 'Default habits panel templates'
181
- });
182
- // Habit (static parent - all habits inherit from habits panel)
183
- this.registerEntity({
184
- entityType: 'habit',
185
- parentResolver: {
186
- type: 'static',
187
- parentType: 'habits_panel'
188
- },
189
- displayName: 'Habit',
190
- icon: 'fitness',
191
- description: 'Individual habit notifications'
192
- });
193
- // Inbox Panel (no parent - top level)
194
- this.registerEntity({
195
- entityType: 'inbox_panel',
196
- parentResolver: {
197
- type: 'static',
198
- parentType: '' // No parent - this is a top-level entity
199
- },
200
- displayName: 'Inbox Panel',
201
- icon: 'mail',
202
- description: 'Inbox notifications'
203
- });
204
- }
205
- }
206
- exports.NotificationEntityRegistry = NotificationEntityRegistry;
207
- /**
208
- * Convenience function to get the singleton instance
209
- */
210
- function getNotificationEntityRegistry() {
211
- return NotificationEntityRegistry.getInstance();
212
- }
@@ -6,7 +6,7 @@ export * from './id-types';
6
6
  export * from './people-types';
7
7
  export * from './lists-types';
8
8
  export * from './notifications-types';
9
- export * from './notification-entity-config';
10
9
  export * from './auth-types';
11
10
  export * from './user-types';
12
11
  export * from './program-config-types';
12
+ export * from './misc';
@@ -22,7 +22,7 @@ __exportStar(require("./id-types"), exports);
22
22
  __exportStar(require("./people-types"), exports);
23
23
  __exportStar(require("./lists-types"), exports);
24
24
  __exportStar(require("./notifications-types"), exports);
25
- __exportStar(require("./notification-entity-config"), exports);
26
25
  __exportStar(require("./auth-types"), exports);
27
26
  __exportStar(require("./user-types"), exports);
28
27
  __exportStar(require("./program-config-types"), exports);
28
+ __exportStar(require("./misc"), exports);