@timothyw/pat-common 1.0.123 → 1.0.124

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);
@@ -2,28 +2,20 @@ import { z } from 'zod';
2
2
  import { Serialized } from '../utils';
3
3
  export interface NotificationContext<T = any> {
4
4
  entityId: string;
5
- entityType: string;
5
+ entityType: NotificationEntityType;
6
6
  entityData: T;
7
7
  userId: string;
8
8
  variables: Record<string, any>;
9
9
  }
10
- /**
11
- * @deprecated Use string types with NotificationEntityRegistry instead
12
- * These enums are kept for backward compatibility during migration
13
- */
14
10
  export declare enum NotificationParentType {
15
11
  AGENDA_PANEL = "agenda_panel"
16
12
  }
17
- /**
18
- * @deprecated Use string types with NotificationEntityRegistry instead
19
- * These enums are kept for backward compatibility during migration
20
- */
21
13
  export declare enum NotificationEntityType {
22
14
  INBOX_PANEL = "inbox_panel",
23
- AGENDA_PANEL = "agenda_panel",
15
+ AGENDA_PANEL = "agenda_item",
24
16
  AGENDA_ITEM = "agenda_item"
25
17
  }
26
- export declare const notificationEntityTypeSchema: z.ZodString;
18
+ export declare const notificationEntityTypeSchema: z.ZodNativeEnum<typeof NotificationEntityType>;
27
19
  export declare enum NotificationStatus {
28
20
  SCHEDULED = "scheduled",
29
21
  SENT = "sent",
@@ -63,7 +55,7 @@ export declare const notificationContentSchema: z.ZodObject<{
63
55
  export declare const notificationTemplateSchema: z.ZodObject<{
64
56
  _id: z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>;
65
57
  userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
66
- entityType: z.ZodString;
58
+ entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
67
59
  entityId: z.ZodOptional<z.ZodString>;
68
60
  name: z.ZodString;
69
61
  description: z.ZodOptional<z.ZodString>;
@@ -107,7 +99,7 @@ export declare const notificationTemplateSchema: z.ZodObject<{
107
99
  title: string;
108
100
  body: string;
109
101
  };
110
- entityType: string;
102
+ entityType: NotificationEntityType;
111
103
  trigger: {
112
104
  type: NotificationTriggerType;
113
105
  conditions: Record<string, any>;
@@ -126,7 +118,7 @@ export declare const notificationTemplateSchema: z.ZodObject<{
126
118
  title: string;
127
119
  body: string;
128
120
  };
129
- entityType: string;
121
+ entityType: NotificationEntityType;
130
122
  trigger: {
131
123
  type: NotificationTriggerType;
132
124
  conditions: Record<string, any>;
@@ -139,7 +131,7 @@ export declare const notificationTemplateSchema: z.ZodObject<{
139
131
  export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
140
132
  _id: z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>;
141
133
  userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
142
- entityType: z.ZodString;
134
+ entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
143
135
  entityId: z.ZodOptional<z.ZodString>;
144
136
  name: z.ZodString;
145
137
  description: z.ZodOptional<z.ZodString>;
@@ -178,7 +170,7 @@ export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
178
170
  title: string;
179
171
  body: string;
180
172
  };
181
- entityType: string;
173
+ entityType: NotificationEntityType;
182
174
  trigger: {
183
175
  type: NotificationTriggerType;
184
176
  conditions: Record<string, any>;
@@ -194,7 +186,7 @@ export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
194
186
  title: string;
195
187
  body: string;
196
188
  };
197
- entityType: string;
189
+ entityType: NotificationEntityType;
198
190
  trigger: {
199
191
  type: NotificationTriggerType;
200
192
  conditions: Record<string, any>;
@@ -206,7 +198,7 @@ export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
206
198
  }>;
207
199
  export declare const entitySyncStateSchema: z.ZodObject<{
208
200
  userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
209
- entityType: z.ZodString;
201
+ entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
210
202
  entityId: z.ZodString;
211
203
  synced: z.ZodBoolean;
212
204
  updatedAt: z.ZodDate;
@@ -215,13 +207,13 @@ export declare const entitySyncStateSchema: z.ZodObject<{
215
207
  userId: string & {
216
208
  readonly __brand: "UserId";
217
209
  };
218
- entityType: string;
210
+ entityType: NotificationEntityType;
219
211
  entityId: string;
220
212
  synced: boolean;
221
213
  }, {
222
214
  updatedAt: Date;
223
215
  userId: string;
224
- entityType: string;
216
+ entityType: NotificationEntityType;
225
217
  entityId: string;
226
218
  synced: boolean;
227
219
  }>;
@@ -292,7 +284,7 @@ export declare const notificationInstanceSchema: z.ZodObject<{
292
284
  error?: string | undefined;
293
285
  }>;
294
286
  export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
295
- entityType: z.ZodString;
287
+ entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
296
288
  entityId: z.ZodOptional<z.ZodString>;
297
289
  name: z.ZodString;
298
290
  description: z.ZodOptional<z.ZodString>;
@@ -326,7 +318,7 @@ export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
326
318
  title: string;
327
319
  body: string;
328
320
  };
329
- entityType: string;
321
+ entityType: NotificationEntityType;
330
322
  trigger: {
331
323
  type: NotificationTriggerType;
332
324
  conditions: Record<string, any>;
@@ -341,7 +333,7 @@ export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
341
333
  title: string;
342
334
  body: string;
343
335
  };
344
- entityType: string;
336
+ entityType: NotificationEntityType;
345
337
  trigger: {
346
338
  type: NotificationTriggerType;
347
339
  conditions: Record<string, any>;
@@ -3,26 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEntitySyncRequestSchema = exports.entitySyncRequestSchema = exports.getNotificationInstancesRequestSchema = exports.previewNotificationTemplateRequestSchema = exports.syncNotificationTemplateRequestSchema = exports.updateNotificationTemplateRequestSchema = exports.createNotificationTemplateRequestSchema = exports.notificationInstanceSchema = exports.entitySyncStateSchema = exports.createNotificationTemplateSchema = exports.notificationTemplateSchema = exports.notificationContentSchema = exports.notificationTriggerSchema = exports.notificationTriggerTypeSchema = exports.notificationStatusSchema = exports.NotificationTriggerType = exports.NotificationStatus = exports.notificationEntityTypeSchema = exports.NotificationEntityType = exports.NotificationParentType = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const id_types_1 = require("./id-types");
6
- /**
7
- * @deprecated Use string types with NotificationEntityRegistry instead
8
- * These enums are kept for backward compatibility during migration
9
- */
10
6
  var NotificationParentType;
11
7
  (function (NotificationParentType) {
12
8
  NotificationParentType["AGENDA_PANEL"] = "agenda_panel";
13
9
  })(NotificationParentType || (exports.NotificationParentType = NotificationParentType = {}));
14
- /**
15
- * @deprecated Use string types with NotificationEntityRegistry instead
16
- * These enums are kept for backward compatibility during migration
17
- */
18
10
  var NotificationEntityType;
19
11
  (function (NotificationEntityType) {
20
12
  NotificationEntityType["INBOX_PANEL"] = "inbox_panel";
21
- NotificationEntityType["AGENDA_PANEL"] = "agenda_panel";
13
+ NotificationEntityType["AGENDA_PANEL"] = "agenda_item";
22
14
  NotificationEntityType["AGENDA_ITEM"] = "agenda_item";
23
15
  })(NotificationEntityType || (exports.NotificationEntityType = NotificationEntityType = {}));
24
- // Updated to use string instead of enum
25
- exports.notificationEntityTypeSchema = zod_1.z.string();
16
+ exports.notificationEntityTypeSchema = zod_1.z.nativeEnum(NotificationEntityType);
26
17
  var NotificationStatus;
27
18
  (function (NotificationStatus) {
28
19
  NotificationStatus["SCHEDULED"] = "scheduled";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@timothyw/pat-common",
3
3
  "description": "",
4
4
  "author": "Timothy Washburn",
5
- "version": "1.0.123",
5
+ "version": "1.0.124",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './enums'
2
2
  export * from './types'
3
- export * from './utils'
4
- export * from './notification-entity-registry'
3
+ export * from './utils'
@@ -1,241 +0,0 @@
1
- import {
2
- NotificationEntityConfig,
3
- ParentResolver,
4
- ParentResolutionResult,
5
- StaticParentResolver,
6
- DynamicParentResolver
7
- } from './types/notification-entity-config';
8
-
9
- /**
10
- * Registry for managing notification entity configurations and parent resolution
11
- */
12
- export class NotificationEntityRegistry {
13
- private static instance: NotificationEntityRegistry;
14
- private entityConfigs: Map<string, NotificationEntityConfig> = new Map();
15
-
16
- private constructor() {
17
- // Initialize with default configurations
18
- this.registerDefaultEntities();
19
- }
20
-
21
- /**
22
- * Get the singleton instance
23
- */
24
- static getInstance(): NotificationEntityRegistry {
25
- if (!NotificationEntityRegistry.instance) {
26
- NotificationEntityRegistry.instance = new NotificationEntityRegistry();
27
- }
28
- return NotificationEntityRegistry.instance;
29
- }
30
-
31
- /**
32
- * Register a new entity configuration
33
- */
34
- registerEntity(config: NotificationEntityConfig): void {
35
- this.entityConfigs.set(config.entityType, config);
36
- }
37
-
38
- /**
39
- * Get configuration for an entity type
40
- */
41
- getEntityConfig(entityType: string): NotificationEntityConfig | null {
42
- return this.entityConfigs.get(entityType) || null;
43
- }
44
-
45
- /**
46
- * Get all registered entity types
47
- */
48
- getEntityTypes(): string[] {
49
- return Array.from(this.entityConfigs.keys());
50
- }
51
-
52
- /**
53
- * Get all entity configurations
54
- */
55
- getAllConfigs(): NotificationEntityConfig[] {
56
- return Array.from(this.entityConfigs.values());
57
- }
58
-
59
- /**
60
- * Resolve the parent type for a specific entity instance
61
- */
62
- resolveParent(entityType: string, entityData: any): ParentResolutionResult | null {
63
- const config = this.entityConfigs.get(entityType);
64
- if (!config) {
65
- return null;
66
- }
67
-
68
- const resolver = config.parentResolver;
69
-
70
- if (resolver.type === 'static') {
71
- return this.resolveStaticParent(resolver);
72
- } else {
73
- return this.resolveDynamicParent(resolver, entityData);
74
- }
75
- }
76
-
77
- /**
78
- * Check if an entity type supports dynamic parent resolution
79
- */
80
- isDynamicParentType(entityType: string): boolean {
81
- const config = this.entityConfigs.get(entityType);
82
- return config?.parentResolver.type === 'dynamic' || false;
83
- }
84
-
85
- /**
86
- * Get the parent property name for dynamic resolution
87
- */
88
- getParentProperty(entityType: string): string | null {
89
- const config = this.entityConfigs.get(entityType);
90
- if (config?.parentResolver.type === 'dynamic') {
91
- return config.parentResolver.parentProperty;
92
- }
93
- return null;
94
- }
95
-
96
- /**
97
- * Get display name for an entity type
98
- */
99
- getDisplayName(entityType: string): string {
100
- const config = this.entityConfigs.get(entityType);
101
- return config?.displayName || entityType;
102
- }
103
-
104
- /**
105
- * Get icon for an entity type
106
- */
107
- getIcon(entityType: string): string | null {
108
- const config = this.entityConfigs.get(entityType);
109
- return config?.icon || null;
110
- }
111
-
112
- /**
113
- * Check if entity type exists
114
- */
115
- hasEntityType(entityType: string): boolean {
116
- return this.entityConfigs.has(entityType);
117
- }
118
-
119
- /**
120
- * Remove an entity configuration
121
- */
122
- unregisterEntity(entityType: string): boolean {
123
- return this.entityConfigs.delete(entityType);
124
- }
125
-
126
- /**
127
- * Clear all configurations
128
- */
129
- clear(): void {
130
- this.entityConfigs.clear();
131
- }
132
-
133
- /**
134
- * Resolve static parent type
135
- */
136
- private resolveStaticParent(resolver: StaticParentResolver): ParentResolutionResult {
137
- return {
138
- parentType: resolver.parentType,
139
- isDynamic: false
140
- };
141
- }
142
-
143
- /**
144
- * Resolve dynamic parent type based on entity data
145
- */
146
- private resolveDynamicParent(resolver: DynamicParentResolver, entityData: any): ParentResolutionResult {
147
- const propertyValue = entityData?.[resolver.parentProperty];
148
-
149
- if (propertyValue && typeof propertyValue === 'string' && propertyValue.trim()) {
150
- // Use the property value to construct the parent type
151
- const parentType = resolver.parentTypePrefix + propertyValue.trim();
152
- return {
153
- parentType,
154
- isDynamic: true,
155
- resolvedProperty: propertyValue.trim(),
156
- usedFallback: false
157
- };
158
- }
159
-
160
- // Fall back to default parent
161
- return {
162
- parentType: resolver.fallbackParent,
163
- isDynamic: true,
164
- usedFallback: true
165
- };
166
- }
167
-
168
- /**
169
- * Register default entity configurations
170
- */
171
- private registerDefaultEntities(): void {
172
- // Agenda Panel (dynamic parent for agenda items based on category)
173
- this.registerEntity({
174
- entityType: 'agenda_panel',
175
- parentResolver: {
176
- type: 'static',
177
- parentType: 'agenda_panel' // Panel level templates
178
- },
179
- displayName: 'Agenda Panel',
180
- icon: 'calendar',
181
- description: 'Default agenda panel templates'
182
- });
183
-
184
- // Agenda Item (dynamic parent based on category)
185
- this.registerEntity({
186
- entityType: 'agenda_item',
187
- parentResolver: {
188
- type: 'dynamic',
189
- parentProperty: 'category',
190
- parentTypePrefix: 'agenda_category_',
191
- fallbackParent: 'agenda_panel'
192
- },
193
- displayName: 'Agenda Item',
194
- icon: 'calendar',
195
- description: 'Individual agenda item notifications'
196
- });
197
-
198
- // Habits Panel (static parent for habits)
199
- this.registerEntity({
200
- entityType: 'habits_panel',
201
- parentResolver: {
202
- type: 'static',
203
- parentType: 'habits_panel'
204
- },
205
- displayName: 'Habits Panel',
206
- icon: 'fitness',
207
- description: 'Default habits panel templates'
208
- });
209
-
210
- // Habit (static parent - all habits inherit from habits panel)
211
- this.registerEntity({
212
- entityType: 'habit',
213
- parentResolver: {
214
- type: 'static',
215
- parentType: 'habits_panel'
216
- },
217
- displayName: 'Habit',
218
- icon: 'fitness',
219
- description: 'Individual habit notifications'
220
- });
221
-
222
- // Inbox Panel (no parent - top level)
223
- this.registerEntity({
224
- entityType: 'inbox_panel',
225
- parentResolver: {
226
- type: 'static',
227
- parentType: '' // No parent - this is a top-level entity
228
- },
229
- displayName: 'Inbox Panel',
230
- icon: 'mail',
231
- description: 'Inbox notifications'
232
- });
233
- }
234
- }
235
-
236
- /**
237
- * Convenience function to get the singleton instance
238
- */
239
- export function getNotificationEntityRegistry(): NotificationEntityRegistry {
240
- return NotificationEntityRegistry.getInstance();
241
- }
@@ -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
- export * from './program-config-types';
11
+ export * from './program-config-types';
12
+ export * from './misc';
@@ -4,32 +4,23 @@ import { Serialized } from '../utils';
4
4
 
5
5
  export interface NotificationContext<T = any> {
6
6
  entityId: string;
7
- entityType: string;
7
+ entityType: NotificationEntityType;
8
8
  entityData: T;
9
9
  userId: string;
10
10
  variables: Record<string, any>;
11
11
  }
12
12
 
13
- /**
14
- * @deprecated Use string types with NotificationEntityRegistry instead
15
- * These enums are kept for backward compatibility during migration
16
- */
17
13
  export enum NotificationParentType {
18
14
  AGENDA_PANEL = 'agenda_panel',
19
15
  }
20
16
 
21
- /**
22
- * @deprecated Use string types with NotificationEntityRegistry instead
23
- * These enums are kept for backward compatibility during migration
24
- */
25
17
  export enum NotificationEntityType {
26
18
  INBOX_PANEL = 'inbox_panel',
27
- AGENDA_PANEL = 'agenda_panel',
19
+ AGENDA_PANEL = 'agenda_item',
28
20
  AGENDA_ITEM = 'agenda_item',
29
21
  }
30
22
 
31
- // Updated to use string instead of enum
32
- export const notificationEntityTypeSchema = z.string();
23
+ export const notificationEntityTypeSchema = z.nativeEnum(NotificationEntityType);
33
24
 
34
25
  export enum NotificationStatus {
35
26
  SCHEDULED = 'scheduled',
@@ -1,78 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- /**
4
- * Static parent resolver - entity always inherits from the same parent type
5
- */
6
- export interface StaticParentResolver {
7
- type: 'static';
8
- parentType: string;
9
- }
10
-
11
- /**
12
- * Dynamic parent resolver - parent determined by entity properties
13
- */
14
- export interface DynamicParentResolver {
15
- type: 'dynamic';
16
- parentProperty: string; // Property name on entity (e.g., 'category')
17
- parentTypePrefix: string; // Prefix for parent type (e.g., 'agenda_category_')
18
- fallbackParent: string; // Default parent if property is missing/empty
19
- }
20
-
21
- export type ParentResolver = StaticParentResolver | DynamicParentResolver;
22
-
23
- /**
24
- * Configuration for a notification entity type
25
- */
26
- export interface NotificationEntityConfig {
27
- entityType: string;
28
- parentResolver: ParentResolver;
29
- displayName: string;
30
- icon?: string;
31
- description?: string;
32
- }
33
-
34
- /**
35
- * Result of parent resolution for a specific entity instance
36
- */
37
- export interface ParentResolutionResult {
38
- parentType: string;
39
- isDynamic: boolean;
40
- resolvedProperty?: string;
41
- usedFallback?: boolean;
42
- }
43
-
44
- /**
45
- * Zod schemas for validation
46
- */
47
- export const staticParentResolverSchema = z.object({
48
- type: z.literal('static'),
49
- parentType: z.string()
50
- });
51
-
52
- export const dynamicParentResolverSchema = z.object({
53
- type: z.literal('dynamic'),
54
- parentProperty: z.string(),
55
- parentTypePrefix: z.string(),
56
- fallbackParent: z.string()
57
- });
58
-
59
- export const parentResolverSchema = z.union([
60
- staticParentResolverSchema,
61
- dynamicParentResolverSchema
62
- ]);
63
-
64
- export const notificationEntityConfigSchema = z.object({
65
- entityType: z.string(),
66
- parentResolver: parentResolverSchema,
67
- displayName: z.string(),
68
- icon: z.string().optional(),
69
- description: z.string().optional()
70
- });
71
-
72
- /**
73
- * Type exports
74
- */
75
- export type StaticParentResolverData = z.infer<typeof staticParentResolverSchema>;
76
- export type DynamicParentResolverData = z.infer<typeof dynamicParentResolverSchema>;
77
- export type ParentResolverData = z.infer<typeof parentResolverSchema>;
78
- export type NotificationEntityConfigData = z.infer<typeof notificationEntityConfigSchema>;