@timothyw/pat-common 1.0.122 → 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,190 +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 (static parent of agenda items)
148
- this.registerEntity({
149
- entityType: 'agenda_panel',
150
- parentResolver: {
151
- type: 'static',
152
- parentType: 'agenda_panel' // Self-referencing for panel level
153
- },
154
- displayName: 'Agenda Panel',
155
- icon: 'calendar',
156
- description: 'Default notification templates for all agenda items'
157
- });
158
- // Agenda Item (can have 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
- // Inbox Panel
172
- this.registerEntity({
173
- entityType: 'inbox_panel',
174
- parentResolver: {
175
- type: 'static',
176
- parentType: 'inbox_panel' // Self-referencing for panel level
177
- },
178
- displayName: 'Inbox Panel',
179
- icon: 'mail',
180
- description: 'Inbox notification templates'
181
- });
182
- }
183
- }
184
- exports.NotificationEntityRegistry = NotificationEntityRegistry;
185
- /**
186
- * Convenience function to get the singleton instance
187
- */
188
- function getNotificationEntityRegistry() {
189
- return NotificationEntityRegistry.getInstance();
190
- }
@@ -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",
@@ -53,20 +45,17 @@ export declare const notificationTriggerSchema: z.ZodObject<{
53
45
  export declare const notificationContentSchema: z.ZodObject<{
54
46
  title: z.ZodString;
55
47
  body: z.ZodString;
56
- variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
57
48
  }, "strip", z.ZodTypeAny, {
58
49
  title: string;
59
50
  body: string;
60
- variables?: Record<string, string> | undefined;
61
51
  }, {
62
52
  title: string;
63
53
  body: string;
64
- variables?: Record<string, string> | undefined;
65
54
  }>;
66
55
  export declare const notificationTemplateSchema: z.ZodObject<{
67
56
  _id: z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>;
68
57
  userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
69
- entityType: z.ZodString;
58
+ entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
70
59
  entityId: z.ZodOptional<z.ZodString>;
71
60
  name: z.ZodString;
72
61
  description: z.ZodOptional<z.ZodString>;
@@ -86,19 +75,14 @@ export declare const notificationTemplateSchema: z.ZodObject<{
86
75
  content: z.ZodObject<{
87
76
  title: z.ZodString;
88
77
  body: z.ZodString;
89
- variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
90
78
  }, "strip", z.ZodTypeAny, {
91
79
  title: string;
92
80
  body: string;
93
- variables?: Record<string, string> | undefined;
94
81
  }, {
95
82
  title: string;
96
83
  body: string;
97
- variables?: Record<string, string> | undefined;
98
84
  }>;
99
85
  active: z.ZodBoolean;
100
- inheritedFrom: z.ZodOptional<z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>>;
101
- customized: z.ZodBoolean;
102
86
  createdAt: z.ZodDate;
103
87
  updatedAt: z.ZodDate;
104
88
  }, "strip", z.ZodTypeAny, {
@@ -114,19 +98,16 @@ export declare const notificationTemplateSchema: z.ZodObject<{
114
98
  content: {
115
99
  title: string;
116
100
  body: string;
117
- variables?: Record<string, string> | undefined;
118
101
  };
119
- entityType: string;
102
+ entityType: NotificationEntityType;
120
103
  trigger: {
121
104
  type: NotificationTriggerType;
122
105
  conditions: Record<string, any>;
123
106
  timing: Record<string, any>;
124
107
  };
125
108
  active: boolean;
126
- customized: boolean;
127
109
  description?: string | undefined;
128
110
  entityId?: string | undefined;
129
- inheritedFrom?: import("./id-types").NotificationTemplateId | undefined;
130
111
  }, {
131
112
  _id: string;
132
113
  createdAt: Date;
@@ -136,24 +117,21 @@ export declare const notificationTemplateSchema: z.ZodObject<{
136
117
  content: {
137
118
  title: string;
138
119
  body: string;
139
- variables?: Record<string, string> | undefined;
140
120
  };
141
- entityType: string;
121
+ entityType: NotificationEntityType;
142
122
  trigger: {
143
123
  type: NotificationTriggerType;
144
124
  conditions: Record<string, any>;
145
125
  timing: Record<string, any>;
146
126
  };
147
127
  active: boolean;
148
- customized: boolean;
149
128
  description?: string | undefined;
150
129
  entityId?: string | undefined;
151
- inheritedFrom?: string | undefined;
152
130
  }>;
153
131
  export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
154
132
  _id: z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>;
155
133
  userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
156
- entityType: z.ZodString;
134
+ entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
157
135
  entityId: z.ZodOptional<z.ZodString>;
158
136
  name: z.ZodString;
159
137
  description: z.ZodOptional<z.ZodString>;
@@ -173,19 +151,14 @@ export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
173
151
  content: z.ZodObject<{
174
152
  title: z.ZodString;
175
153
  body: z.ZodString;
176
- variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
177
154
  }, "strip", z.ZodTypeAny, {
178
155
  title: string;
179
156
  body: string;
180
- variables?: Record<string, string> | undefined;
181
157
  }, {
182
158
  title: string;
183
159
  body: string;
184
- variables?: Record<string, string> | undefined;
185
160
  }>;
186
161
  active: z.ZodBoolean;
187
- inheritedFrom: z.ZodOptional<z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>>;
188
- customized: z.ZodBoolean;
189
162
  createdAt: z.ZodDate;
190
163
  updatedAt: z.ZodDate;
191
164
  }, "_id" | "createdAt" | "updatedAt">, "strip", z.ZodTypeAny, {
@@ -196,42 +169,36 @@ export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
196
169
  content: {
197
170
  title: string;
198
171
  body: string;
199
- variables?: Record<string, string> | undefined;
200
172
  };
201
- entityType: string;
173
+ entityType: NotificationEntityType;
202
174
  trigger: {
203
175
  type: NotificationTriggerType;
204
176
  conditions: Record<string, any>;
205
177
  timing: Record<string, any>;
206
178
  };
207
179
  active: boolean;
208
- customized: boolean;
209
180
  description?: string | undefined;
210
181
  entityId?: string | undefined;
211
- inheritedFrom?: import("./id-types").NotificationTemplateId | undefined;
212
182
  }, {
213
183
  userId: string;
214
184
  name: string;
215
185
  content: {
216
186
  title: string;
217
187
  body: string;
218
- variables?: Record<string, string> | undefined;
219
188
  };
220
- entityType: string;
189
+ entityType: NotificationEntityType;
221
190
  trigger: {
222
191
  type: NotificationTriggerType;
223
192
  conditions: Record<string, any>;
224
193
  timing: Record<string, any>;
225
194
  };
226
195
  active: boolean;
227
- customized: boolean;
228
196
  description?: string | undefined;
229
197
  entityId?: string | undefined;
230
- inheritedFrom?: string | undefined;
231
198
  }>;
232
199
  export declare const entitySyncStateSchema: z.ZodObject<{
233
200
  userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
234
- entityType: z.ZodString;
201
+ entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
235
202
  entityId: z.ZodString;
236
203
  synced: z.ZodBoolean;
237
204
  updatedAt: z.ZodDate;
@@ -240,13 +207,13 @@ export declare const entitySyncStateSchema: z.ZodObject<{
240
207
  userId: string & {
241
208
  readonly __brand: "UserId";
242
209
  };
243
- entityType: string;
210
+ entityType: NotificationEntityType;
244
211
  entityId: string;
245
212
  synced: boolean;
246
213
  }, {
247
214
  updatedAt: Date;
248
215
  userId: string;
249
- entityType: string;
216
+ entityType: NotificationEntityType;
250
217
  entityId: string;
251
218
  synced: boolean;
252
219
  }>;
@@ -317,7 +284,7 @@ export declare const notificationInstanceSchema: z.ZodObject<{
317
284
  error?: string | undefined;
318
285
  }>;
319
286
  export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
320
- entityType: z.ZodString;
287
+ entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
321
288
  entityId: z.ZodOptional<z.ZodString>;
322
289
  name: z.ZodString;
323
290
  description: z.ZodOptional<z.ZodString>;
@@ -337,45 +304,36 @@ export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
337
304
  content: z.ZodObject<{
338
305
  title: z.ZodString;
339
306
  body: z.ZodString;
340
- variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
341
307
  }, "strip", z.ZodTypeAny, {
342
308
  title: string;
343
309
  body: string;
344
- variables?: Record<string, string> | undefined;
345
310
  }, {
346
311
  title: string;
347
312
  body: string;
348
- variables?: Record<string, string> | undefined;
349
313
  }>;
350
314
  active: z.ZodDefault<z.ZodBoolean>;
351
- inheritedFrom: z.ZodOptional<z.ZodString>;
352
- customized: z.ZodDefault<z.ZodBoolean>;
353
315
  }, "strip", z.ZodTypeAny, {
354
316
  name: string;
355
317
  content: {
356
318
  title: string;
357
319
  body: string;
358
- variables?: Record<string, string> | undefined;
359
320
  };
360
- entityType: string;
321
+ entityType: NotificationEntityType;
361
322
  trigger: {
362
323
  type: NotificationTriggerType;
363
324
  conditions: Record<string, any>;
364
325
  timing: Record<string, any>;
365
326
  };
366
327
  active: boolean;
367
- customized: boolean;
368
328
  description?: string | undefined;
369
329
  entityId?: string | undefined;
370
- inheritedFrom?: string | undefined;
371
330
  }, {
372
331
  name: string;
373
332
  content: {
374
333
  title: string;
375
334
  body: string;
376
- variables?: Record<string, string> | undefined;
377
335
  };
378
- entityType: string;
336
+ entityType: NotificationEntityType;
379
337
  trigger: {
380
338
  type: NotificationTriggerType;
381
339
  conditions: Record<string, any>;
@@ -384,8 +342,6 @@ export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
384
342
  description?: string | undefined;
385
343
  entityId?: string | undefined;
386
344
  active?: boolean | undefined;
387
- inheritedFrom?: string | undefined;
388
- customized?: boolean | undefined;
389
345
  }>;
390
346
  export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
391
347
  name: z.ZodOptional<z.ZodString>;
@@ -406,25 +362,20 @@ export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
406
362
  content: z.ZodOptional<z.ZodObject<{
407
363
  title: z.ZodString;
408
364
  body: z.ZodString;
409
- variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
410
365
  }, "strip", z.ZodTypeAny, {
411
366
  title: string;
412
367
  body: string;
413
- variables?: Record<string, string> | undefined;
414
368
  }, {
415
369
  title: string;
416
370
  body: string;
417
- variables?: Record<string, string> | undefined;
418
371
  }>>;
419
372
  active: z.ZodOptional<z.ZodBoolean>;
420
- customized: z.ZodOptional<z.ZodBoolean>;
421
373
  }, "strip", z.ZodTypeAny, {
422
374
  name?: string | undefined;
423
375
  description?: string | undefined;
424
376
  content?: {
425
377
  title: string;
426
378
  body: string;
427
- variables?: Record<string, string> | undefined;
428
379
  } | undefined;
429
380
  trigger?: {
430
381
  type: NotificationTriggerType;
@@ -432,14 +383,12 @@ export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
432
383
  timing: Record<string, any>;
433
384
  } | undefined;
434
385
  active?: boolean | undefined;
435
- customized?: boolean | undefined;
436
386
  }, {
437
387
  name?: string | undefined;
438
388
  description?: string | undefined;
439
389
  content?: {
440
390
  title: string;
441
391
  body: string;
442
- variables?: Record<string, string> | undefined;
443
392
  } | undefined;
444
393
  trigger?: {
445
394
  type: NotificationTriggerType;
@@ -447,7 +396,6 @@ export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
447
396
  timing: Record<string, any>;
448
397
  } | undefined;
449
398
  active?: boolean | undefined;
450
- customized?: boolean | undefined;
451
399
  }>;
452
400
  export declare const syncNotificationTemplateRequestSchema: z.ZodObject<{
453
401
  sync: z.ZodBoolean;
@@ -461,19 +409,16 @@ export declare const previewNotificationTemplateRequestSchema: z.ZodObject<{
461
409
  templateBody: z.ZodString;
462
410
  entityType: z.ZodString;
463
411
  entityId: z.ZodString;
464
- variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
465
412
  }, "strip", z.ZodTypeAny, {
466
413
  entityType: string;
467
414
  entityId: string;
468
415
  templateTitle: string;
469
416
  templateBody: string;
470
- variables?: Record<string, any> | undefined;
471
417
  }, {
472
418
  entityType: string;
473
419
  entityId: string;
474
420
  templateTitle: string;
475
421
  templateBody: string;
476
- variables?: Record<string, any> | undefined;
477
422
  }>;
478
423
  export declare const getNotificationInstancesRequestSchema: z.ZodObject<{
479
424
  status: z.ZodOptional<z.ZodString>;
@@ -551,9 +496,7 @@ export interface PreviewNotificationTemplateResponse {
551
496
  preview: {
552
497
  title: string;
553
498
  body: string;
554
- variables: Record<string, any>;
555
499
  };
556
- missingVariables: string[];
557
500
  }
558
501
  export interface GetNotificationInstancesResponse {
559
502
  success: boolean;
@@ -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";
@@ -45,8 +36,7 @@ exports.notificationTriggerSchema = zod_1.z.object({
45
36
  });
46
37
  exports.notificationContentSchema = zod_1.z.object({
47
38
  title: zod_1.z.string(),
48
- body: zod_1.z.string(),
49
- variables: zod_1.z.record(zod_1.z.string()).optional()
39
+ body: zod_1.z.string()
50
40
  });
51
41
  exports.notificationTemplateSchema = zod_1.z.object({
52
42
  _id: id_types_1.notificationTemplateIdSchema,
@@ -58,8 +48,6 @@ exports.notificationTemplateSchema = zod_1.z.object({
58
48
  trigger: exports.notificationTriggerSchema,
59
49
  content: exports.notificationContentSchema,
60
50
  active: zod_1.z.boolean(),
61
- inheritedFrom: id_types_1.notificationTemplateIdSchema.optional(),
62
- customized: zod_1.z.boolean(),
63
51
  createdAt: zod_1.z.date(),
64
52
  updatedAt: zod_1.z.date()
65
53
  });
@@ -105,12 +93,9 @@ exports.createNotificationTemplateRequestSchema = zod_1.z.object({
105
93
  }),
106
94
  content: zod_1.z.object({
107
95
  title: zod_1.z.string().min(1).max(200),
108
- body: zod_1.z.string().min(1).max(1000),
109
- variables: zod_1.z.record(zod_1.z.string()).optional()
96
+ body: zod_1.z.string().min(1).max(1000)
110
97
  }),
111
- active: zod_1.z.boolean().default(true),
112
- inheritedFrom: zod_1.z.string().optional(),
113
- customized: zod_1.z.boolean().default(false)
98
+ active: zod_1.z.boolean().default(true)
114
99
  });
115
100
  exports.updateNotificationTemplateRequestSchema = zod_1.z.object({
116
101
  name: zod_1.z.string().optional(),
@@ -122,11 +107,9 @@ exports.updateNotificationTemplateRequestSchema = zod_1.z.object({
122
107
  }).optional(),
123
108
  content: zod_1.z.object({
124
109
  title: zod_1.z.string(),
125
- body: zod_1.z.string(),
126
- variables: zod_1.z.record(zod_1.z.string()).optional()
110
+ body: zod_1.z.string()
127
111
  }).optional(),
128
- active: zod_1.z.boolean().optional(),
129
- customized: zod_1.z.boolean().optional()
112
+ active: zod_1.z.boolean().optional()
130
113
  });
131
114
  exports.syncNotificationTemplateRequestSchema = zod_1.z.object({
132
115
  sync: zod_1.z.boolean()
@@ -135,8 +118,7 @@ exports.previewNotificationTemplateRequestSchema = zod_1.z.object({
135
118
  templateTitle: zod_1.z.string(),
136
119
  templateBody: zod_1.z.string(),
137
120
  entityType: zod_1.z.string(),
138
- entityId: zod_1.z.string(),
139
- variables: zod_1.z.record(zod_1.z.any()).optional()
121
+ entityId: zod_1.z.string()
140
122
  });
141
123
  exports.getNotificationInstancesRequestSchema = zod_1.z.object({
142
124
  status: zod_1.z.string().optional(),
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.122",
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,217 +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 (static parent of agenda items)
173
- this.registerEntity({
174
- entityType: 'agenda_panel',
175
- parentResolver: {
176
- type: 'static',
177
- parentType: 'agenda_panel' // Self-referencing for panel level
178
- },
179
- displayName: 'Agenda Panel',
180
- icon: 'calendar',
181
- description: 'Default notification templates for all agenda items'
182
- });
183
-
184
- // Agenda Item (can have 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
- // Inbox Panel
199
- this.registerEntity({
200
- entityType: 'inbox_panel',
201
- parentResolver: {
202
- type: 'static',
203
- parentType: 'inbox_panel' // Self-referencing for panel level
204
- },
205
- displayName: 'Inbox Panel',
206
- icon: 'mail',
207
- description: 'Inbox notification templates'
208
- });
209
- }
210
- }
211
-
212
- /**
213
- * Convenience function to get the singleton instance
214
- */
215
- export function getNotificationEntityRegistry(): NotificationEntityRegistry {
216
- return NotificationEntityRegistry.getInstance();
217
- }
@@ -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',
@@ -55,8 +46,7 @@ export const notificationTriggerSchema = z.object({
55
46
 
56
47
  export const notificationContentSchema = z.object({
57
48
  title: z.string(),
58
- body: z.string(),
59
- variables: z.record(z.string()).optional()
49
+ body: z.string()
60
50
  });
61
51
 
62
52
  export const notificationTemplateSchema = z.object({
@@ -69,8 +59,6 @@ export const notificationTemplateSchema = z.object({
69
59
  trigger: notificationTriggerSchema,
70
60
  content: notificationContentSchema,
71
61
  active: z.boolean(),
72
- inheritedFrom: notificationTemplateIdSchema.optional(),
73
- customized: z.boolean(),
74
62
  createdAt: z.date(),
75
63
  updatedAt: z.date()
76
64
  });
@@ -120,12 +108,9 @@ export const createNotificationTemplateRequestSchema = z.object({
120
108
  }),
121
109
  content: z.object({
122
110
  title: z.string().min(1).max(200),
123
- body: z.string().min(1).max(1000),
124
- variables: z.record(z.string()).optional()
111
+ body: z.string().min(1).max(1000)
125
112
  }),
126
- active: z.boolean().default(true),
127
- inheritedFrom: z.string().optional(),
128
- customized: z.boolean().default(false)
113
+ active: z.boolean().default(true)
129
114
  });
130
115
 
131
116
  export const updateNotificationTemplateRequestSchema = z.object({
@@ -138,11 +123,9 @@ export const updateNotificationTemplateRequestSchema = z.object({
138
123
  }).optional(),
139
124
  content: z.object({
140
125
  title: z.string(),
141
- body: z.string(),
142
- variables: z.record(z.string()).optional()
126
+ body: z.string()
143
127
  }).optional(),
144
- active: z.boolean().optional(),
145
- customized: z.boolean().optional()
128
+ active: z.boolean().optional()
146
129
  });
147
130
 
148
131
  export const syncNotificationTemplateRequestSchema = z.object({
@@ -153,8 +136,7 @@ export const previewNotificationTemplateRequestSchema = z.object({
153
136
  templateTitle: z.string(),
154
137
  templateBody: z.string(),
155
138
  entityType: z.string(),
156
- entityId: z.string(),
157
- variables: z.record(z.any()).optional()
139
+ entityId: z.string()
158
140
  });
159
141
 
160
142
  export const getNotificationInstancesRequestSchema = z.object({
@@ -217,9 +199,7 @@ export interface PreviewNotificationTemplateResponse {
217
199
  preview: {
218
200
  title: string;
219
201
  body: string;
220
- variables: Record<string, any>;
221
202
  };
222
- missingVariables: string[];
223
203
  }
224
204
 
225
205
  export interface GetNotificationInstancesResponse {
@@ -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>;