@timothyw/pat-common 1.0.124 → 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.
@@ -5,7 +5,6 @@ export interface NotificationContext<T = any> {
5
5
  entityType: NotificationEntityType;
6
6
  entityData: T;
7
7
  userId: string;
8
- variables: Record<string, any>;
9
8
  }
10
9
  export declare enum NotificationParentType {
11
10
  AGENDA_PANEL = "agenda_panel"
@@ -15,72 +14,30 @@ export declare enum NotificationEntityType {
15
14
  AGENDA_PANEL = "agenda_item",
16
15
  AGENDA_ITEM = "agenda_item"
17
16
  }
18
- export declare const notificationEntityTypeSchema: z.ZodNativeEnum<typeof NotificationEntityType>;
19
- export declare enum NotificationStatus {
20
- SCHEDULED = "scheduled",
21
- SENT = "sent",
22
- FAILED = "failed",
23
- CANCELLED = "cancelled"
24
- }
25
17
  export declare enum NotificationTriggerType {
26
18
  TIME_BASED = "time_based",
27
19
  EVENT_BASED = "event_based",
28
20
  RECURRING = "recurring"
29
21
  }
30
- export declare const notificationStatusSchema: z.ZodNativeEnum<typeof NotificationStatus>;
31
22
  export declare const notificationTriggerTypeSchema: z.ZodNativeEnum<typeof NotificationTriggerType>;
32
23
  export declare const notificationTriggerSchema: z.ZodObject<{
33
24
  type: z.ZodNativeEnum<typeof NotificationTriggerType>;
34
- conditions: z.ZodRecord<z.ZodString, z.ZodAny>;
35
- timing: z.ZodRecord<z.ZodString, z.ZodAny>;
36
25
  }, "strip", z.ZodTypeAny, {
37
26
  type: NotificationTriggerType;
38
- conditions: Record<string, any>;
39
- timing: Record<string, any>;
40
27
  }, {
41
28
  type: NotificationTriggerType;
42
- conditions: Record<string, any>;
43
- timing: Record<string, any>;
44
- }>;
45
- export declare const notificationContentSchema: z.ZodObject<{
46
- title: z.ZodString;
47
- body: z.ZodString;
48
- }, "strip", z.ZodTypeAny, {
49
- title: string;
50
- body: string;
51
- }, {
52
- title: string;
53
- body: string;
54
29
  }>;
55
30
  export declare const notificationTemplateSchema: z.ZodObject<{
56
31
  _id: z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>;
57
32
  userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
58
33
  entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
59
34
  entityId: z.ZodOptional<z.ZodString>;
60
- name: z.ZodString;
61
- description: z.ZodOptional<z.ZodString>;
62
35
  trigger: z.ZodObject<{
63
36
  type: z.ZodNativeEnum<typeof NotificationTriggerType>;
64
- conditions: z.ZodRecord<z.ZodString, z.ZodAny>;
65
- timing: z.ZodRecord<z.ZodString, z.ZodAny>;
66
37
  }, "strip", z.ZodTypeAny, {
67
38
  type: NotificationTriggerType;
68
- conditions: Record<string, any>;
69
- timing: Record<string, any>;
70
39
  }, {
71
40
  type: NotificationTriggerType;
72
- conditions: Record<string, any>;
73
- timing: Record<string, any>;
74
- }>;
75
- content: z.ZodObject<{
76
- title: z.ZodString;
77
- body: z.ZodString;
78
- }, "strip", z.ZodTypeAny, {
79
- title: string;
80
- body: string;
81
- }, {
82
- title: string;
83
- body: string;
84
41
  }>;
85
42
  active: z.ZodBoolean;
86
43
  createdAt: z.ZodDate;
@@ -94,385 +51,97 @@ export declare const notificationTemplateSchema: z.ZodObject<{
94
51
  userId: string & {
95
52
  readonly __brand: "UserId";
96
53
  };
97
- name: string;
98
- content: {
99
- title: string;
100
- body: string;
101
- };
102
54
  entityType: NotificationEntityType;
103
55
  trigger: {
104
56
  type: NotificationTriggerType;
105
- conditions: Record<string, any>;
106
- timing: Record<string, any>;
107
57
  };
108
58
  active: boolean;
109
- description?: string | undefined;
110
59
  entityId?: string | undefined;
111
60
  }, {
112
61
  _id: string;
113
62
  createdAt: Date;
114
63
  updatedAt: Date;
115
64
  userId: string;
116
- name: string;
117
- content: {
118
- title: string;
119
- body: string;
120
- };
121
- entityType: NotificationEntityType;
122
- trigger: {
123
- type: NotificationTriggerType;
124
- conditions: Record<string, any>;
125
- timing: Record<string, any>;
126
- };
127
- active: boolean;
128
- description?: string | undefined;
129
- entityId?: string | undefined;
130
- }>;
131
- export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
132
- _id: z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>;
133
- userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
134
- entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
135
- entityId: z.ZodOptional<z.ZodString>;
136
- name: z.ZodString;
137
- description: z.ZodOptional<z.ZodString>;
138
- trigger: z.ZodObject<{
139
- type: z.ZodNativeEnum<typeof NotificationTriggerType>;
140
- conditions: z.ZodRecord<z.ZodString, z.ZodAny>;
141
- timing: z.ZodRecord<z.ZodString, z.ZodAny>;
142
- }, "strip", z.ZodTypeAny, {
143
- type: NotificationTriggerType;
144
- conditions: Record<string, any>;
145
- timing: Record<string, any>;
146
- }, {
147
- type: NotificationTriggerType;
148
- conditions: Record<string, any>;
149
- timing: Record<string, any>;
150
- }>;
151
- content: z.ZodObject<{
152
- title: z.ZodString;
153
- body: z.ZodString;
154
- }, "strip", z.ZodTypeAny, {
155
- title: string;
156
- body: string;
157
- }, {
158
- title: string;
159
- body: string;
160
- }>;
161
- active: z.ZodBoolean;
162
- createdAt: z.ZodDate;
163
- updatedAt: z.ZodDate;
164
- }, "_id" | "createdAt" | "updatedAt">, "strip", z.ZodTypeAny, {
165
- userId: string & {
166
- readonly __brand: "UserId";
167
- };
168
- name: string;
169
- content: {
170
- title: string;
171
- body: string;
172
- };
173
- entityType: NotificationEntityType;
174
- trigger: {
175
- type: NotificationTriggerType;
176
- conditions: Record<string, any>;
177
- timing: Record<string, any>;
178
- };
179
- active: boolean;
180
- description?: string | undefined;
181
- entityId?: string | undefined;
182
- }, {
183
- userId: string;
184
- name: string;
185
- content: {
186
- title: string;
187
- body: string;
188
- };
189
65
  entityType: NotificationEntityType;
190
66
  trigger: {
191
67
  type: NotificationTriggerType;
192
- conditions: Record<string, any>;
193
- timing: Record<string, any>;
194
68
  };
195
69
  active: boolean;
196
- description?: string | undefined;
197
70
  entityId?: string | undefined;
198
71
  }>;
199
- export declare const entitySyncStateSchema: z.ZodObject<{
200
- userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
201
- entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
202
- entityId: z.ZodString;
203
- synced: z.ZodBoolean;
204
- updatedAt: z.ZodDate;
205
- }, "strip", z.ZodTypeAny, {
206
- updatedAt: Date;
207
- userId: string & {
208
- readonly __brand: "UserId";
209
- };
210
- entityType: NotificationEntityType;
211
- entityId: string;
212
- synced: boolean;
213
- }, {
214
- updatedAt: Date;
215
- userId: string;
216
- entityType: NotificationEntityType;
217
- entityId: string;
218
- synced: boolean;
219
- }>;
220
- export declare const notificationInstanceSchema: z.ZodObject<{
221
- _id: z.ZodEffects<z.ZodString, import("./id-types").NotificationInstanceId, string>;
222
- templateId: z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>;
223
- userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
224
- entityId: z.ZodString;
225
- scheduledFor: z.ZodDate;
226
- status: z.ZodNativeEnum<typeof NotificationStatus>;
227
- sentAt: z.ZodOptional<z.ZodDate>;
228
- content: z.ZodObject<{
229
- title: z.ZodString;
230
- body: z.ZodString;
231
- data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
232
- }, "strip", z.ZodTypeAny, {
233
- title: string;
234
- body: string;
235
- data?: Record<string, any> | undefined;
236
- }, {
237
- title: string;
238
- body: string;
239
- data?: Record<string, any> | undefined;
240
- }>;
241
- redisId: z.ZodString;
242
- error: z.ZodOptional<z.ZodString>;
243
- createdAt: z.ZodDate;
244
- updatedAt: z.ZodDate;
245
- }, "strip", z.ZodTypeAny, {
246
- status: NotificationStatus;
247
- _id: string & {
248
- readonly __brand: "NotificationInstanceId";
249
- };
250
- createdAt: Date;
251
- updatedAt: Date;
252
- userId: string & {
253
- readonly __brand: "UserId";
254
- };
255
- content: {
256
- title: string;
257
- body: string;
258
- data?: Record<string, any> | undefined;
259
- };
260
- entityId: string;
261
- templateId: string & {
262
- readonly __brand: "NotificationTemplateId";
263
- };
264
- scheduledFor: Date;
265
- redisId: string;
266
- sentAt?: Date | undefined;
267
- error?: string | undefined;
268
- }, {
269
- status: NotificationStatus;
270
- _id: string;
271
- createdAt: Date;
272
- updatedAt: Date;
273
- userId: string;
274
- content: {
275
- title: string;
276
- body: string;
277
- data?: Record<string, any> | undefined;
278
- };
279
- entityId: string;
280
- templateId: string;
281
- scheduledFor: Date;
282
- redisId: string;
283
- sentAt?: Date | undefined;
284
- error?: string | undefined;
285
- }>;
286
72
  export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
287
73
  entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
288
74
  entityId: z.ZodOptional<z.ZodString>;
289
- name: z.ZodString;
290
- description: z.ZodOptional<z.ZodString>;
291
75
  trigger: z.ZodObject<{
292
76
  type: z.ZodNativeEnum<typeof NotificationTriggerType>;
293
- conditions: z.ZodRecord<z.ZodString, z.ZodAny>;
294
- timing: z.ZodRecord<z.ZodString, z.ZodAny>;
295
77
  }, "strip", z.ZodTypeAny, {
296
78
  type: NotificationTriggerType;
297
- conditions: Record<string, any>;
298
- timing: Record<string, any>;
299
79
  }, {
300
80
  type: NotificationTriggerType;
301
- conditions: Record<string, any>;
302
- timing: Record<string, any>;
303
- }>;
304
- content: z.ZodObject<{
305
- title: z.ZodString;
306
- body: z.ZodString;
307
- }, "strip", z.ZodTypeAny, {
308
- title: string;
309
- body: string;
310
- }, {
311
- title: string;
312
- body: string;
313
81
  }>;
314
82
  active: z.ZodDefault<z.ZodBoolean>;
315
83
  }, "strip", z.ZodTypeAny, {
316
- name: string;
317
- content: {
318
- title: string;
319
- body: string;
320
- };
321
84
  entityType: NotificationEntityType;
322
85
  trigger: {
323
86
  type: NotificationTriggerType;
324
- conditions: Record<string, any>;
325
- timing: Record<string, any>;
326
87
  };
327
88
  active: boolean;
328
- description?: string | undefined;
329
89
  entityId?: string | undefined;
330
90
  }, {
331
- name: string;
332
- content: {
333
- title: string;
334
- body: string;
335
- };
336
91
  entityType: NotificationEntityType;
337
92
  trigger: {
338
93
  type: NotificationTriggerType;
339
- conditions: Record<string, any>;
340
- timing: Record<string, any>;
341
94
  };
342
- description?: string | undefined;
343
95
  entityId?: string | undefined;
344
96
  active?: boolean | undefined;
345
97
  }>;
346
98
  export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
347
- name: z.ZodOptional<z.ZodString>;
348
- description: z.ZodOptional<z.ZodString>;
349
99
  trigger: z.ZodOptional<z.ZodObject<{
350
100
  type: z.ZodNativeEnum<typeof NotificationTriggerType>;
351
- conditions: z.ZodRecord<z.ZodString, z.ZodAny>;
352
- timing: z.ZodRecord<z.ZodString, z.ZodAny>;
353
101
  }, "strip", z.ZodTypeAny, {
354
102
  type: NotificationTriggerType;
355
- conditions: Record<string, any>;
356
- timing: Record<string, any>;
357
103
  }, {
358
104
  type: NotificationTriggerType;
359
- conditions: Record<string, any>;
360
- timing: Record<string, any>;
361
- }>>;
362
- content: z.ZodOptional<z.ZodObject<{
363
- title: z.ZodString;
364
- body: z.ZodString;
365
- }, "strip", z.ZodTypeAny, {
366
- title: string;
367
- body: string;
368
- }, {
369
- title: string;
370
- body: string;
371
105
  }>>;
372
106
  active: z.ZodOptional<z.ZodBoolean>;
373
107
  }, "strip", z.ZodTypeAny, {
374
- name?: string | undefined;
375
- description?: string | undefined;
376
- content?: {
377
- title: string;
378
- body: string;
379
- } | undefined;
380
108
  trigger?: {
381
109
  type: NotificationTriggerType;
382
- conditions: Record<string, any>;
383
- timing: Record<string, any>;
384
110
  } | undefined;
385
111
  active?: boolean | undefined;
386
112
  }, {
387
- name?: string | undefined;
388
- description?: string | undefined;
389
- content?: {
390
- title: string;
391
- body: string;
392
- } | undefined;
393
113
  trigger?: {
394
114
  type: NotificationTriggerType;
395
- conditions: Record<string, any>;
396
- timing: Record<string, any>;
397
115
  } | undefined;
398
116
  active?: boolean | undefined;
399
117
  }>;
400
- export declare const syncNotificationTemplateRequestSchema: z.ZodObject<{
401
- sync: z.ZodBoolean;
402
- }, "strip", z.ZodTypeAny, {
403
- sync: boolean;
404
- }, {
405
- sync: boolean;
406
- }>;
407
- export declare const previewNotificationTemplateRequestSchema: z.ZodObject<{
408
- templateTitle: z.ZodString;
409
- templateBody: z.ZodString;
410
- entityType: z.ZodString;
411
- entityId: z.ZodString;
412
- }, "strip", z.ZodTypeAny, {
413
- entityType: string;
414
- entityId: string;
415
- templateTitle: string;
416
- templateBody: string;
417
- }, {
418
- entityType: string;
419
- entityId: string;
420
- templateTitle: string;
421
- templateBody: string;
422
- }>;
423
- export declare const getNotificationInstancesRequestSchema: z.ZodObject<{
424
- status: z.ZodOptional<z.ZodString>;
425
- templateId: z.ZodOptional<z.ZodString>;
426
- entityId: z.ZodOptional<z.ZodString>;
427
- limit: z.ZodOptional<z.ZodNumber>;
428
- offset: z.ZodOptional<z.ZodNumber>;
429
- }, "strip", z.ZodTypeAny, {
430
- status?: string | undefined;
431
- entityId?: string | undefined;
432
- templateId?: string | undefined;
433
- limit?: number | undefined;
434
- offset?: number | undefined;
435
- }, {
436
- status?: string | undefined;
437
- entityId?: string | undefined;
438
- templateId?: string | undefined;
439
- limit?: number | undefined;
440
- offset?: number | undefined;
441
- }>;
442
118
  export declare const entitySyncRequestSchema: z.ZodObject<{
443
- entityType: z.ZodString;
119
+ entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
444
120
  entityId: z.ZodString;
445
121
  synced: z.ZodBoolean;
446
122
  }, "strip", z.ZodTypeAny, {
447
- entityType: string;
123
+ entityType: NotificationEntityType;
448
124
  entityId: string;
449
125
  synced: boolean;
450
126
  }, {
451
- entityType: string;
127
+ entityType: NotificationEntityType;
452
128
  entityId: string;
453
129
  synced: boolean;
454
130
  }>;
455
131
  export declare const getEntitySyncRequestSchema: z.ZodObject<{
456
- entityType: z.ZodString;
132
+ entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
457
133
  entityId: z.ZodString;
458
134
  }, "strip", z.ZodTypeAny, {
459
- entityType: string;
135
+ entityType: NotificationEntityType;
460
136
  entityId: string;
461
137
  }, {
462
- entityType: string;
138
+ entityType: NotificationEntityType;
463
139
  entityId: string;
464
140
  }>;
465
141
  export type NotificationTrigger = z.infer<typeof notificationTriggerSchema>;
466
- export type NotificationContent = z.infer<typeof notificationContentSchema>;
467
142
  export type NotificationTemplateData = z.infer<typeof notificationTemplateSchema>;
468
- export type CreateNotificationTemplateData = z.infer<typeof createNotificationTemplateSchema>;
469
- export type EntitySyncState = z.infer<typeof entitySyncStateSchema>;
470
- export type NotificationInstanceData = z.infer<typeof notificationInstanceSchema>;
471
143
  export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;
472
144
  export type UpdateNotificationTemplateRequest = z.infer<typeof updateNotificationTemplateRequestSchema>;
473
- export type SyncNotificationTemplateRequest = z.infer<typeof syncNotificationTemplateRequestSchema>;
474
- export type PreviewNotificationTemplateRequest = z.infer<typeof previewNotificationTemplateRequestSchema>;
475
- export type GetNotificationInstancesRequest = z.infer<typeof getNotificationInstancesRequestSchema>;
476
145
  export type EntitySyncRequest = z.infer<typeof entitySyncRequestSchema>;
477
146
  export type GetEntitySyncRequest = z.infer<typeof getEntitySyncRequestSchema>;
478
147
  export interface CreateNotificationTemplateResponse {
@@ -489,21 +158,6 @@ export interface UpdateNotificationTemplateResponse {
489
158
  }
490
159
  export interface DeleteNotificationTemplateResponse {
491
160
  }
492
- export interface SyncNotificationTemplateResponse {
493
- synced: boolean;
494
- }
495
- export interface PreviewNotificationTemplateResponse {
496
- preview: {
497
- title: string;
498
- body: string;
499
- };
500
- }
501
- export interface GetNotificationInstancesResponse {
502
- success: boolean;
503
- instances?: Serialized<NotificationInstanceData>[];
504
- total?: number;
505
- error?: string;
506
- }
507
161
  export interface EntitySyncResponse {
508
162
  success: boolean;
509
163
  synced: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.getEntitySyncRequestSchema = exports.entitySyncRequestSchema = exports.updateNotificationTemplateRequestSchema = exports.createNotificationTemplateRequestSchema = exports.notificationTemplateSchema = exports.notificationTriggerSchema = exports.notificationTriggerTypeSchema = exports.NotificationTriggerType = exports.NotificationEntityType = exports.NotificationParentType = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const id_types_1 = require("./id-types");
6
6
  var NotificationParentType;
@@ -13,126 +13,46 @@ var NotificationEntityType;
13
13
  NotificationEntityType["AGENDA_PANEL"] = "agenda_item";
14
14
  NotificationEntityType["AGENDA_ITEM"] = "agenda_item";
15
15
  })(NotificationEntityType || (exports.NotificationEntityType = NotificationEntityType = {}));
16
- exports.notificationEntityTypeSchema = zod_1.z.nativeEnum(NotificationEntityType);
17
- var NotificationStatus;
18
- (function (NotificationStatus) {
19
- NotificationStatus["SCHEDULED"] = "scheduled";
20
- NotificationStatus["SENT"] = "sent";
21
- NotificationStatus["FAILED"] = "failed";
22
- NotificationStatus["CANCELLED"] = "cancelled";
23
- })(NotificationStatus || (exports.NotificationStatus = NotificationStatus = {}));
24
16
  var NotificationTriggerType;
25
17
  (function (NotificationTriggerType) {
26
18
  NotificationTriggerType["TIME_BASED"] = "time_based";
27
19
  NotificationTriggerType["EVENT_BASED"] = "event_based";
28
20
  NotificationTriggerType["RECURRING"] = "recurring";
29
21
  })(NotificationTriggerType || (exports.NotificationTriggerType = NotificationTriggerType = {}));
30
- exports.notificationStatusSchema = zod_1.z.nativeEnum(NotificationStatus);
31
22
  exports.notificationTriggerTypeSchema = zod_1.z.nativeEnum(NotificationTriggerType);
32
23
  exports.notificationTriggerSchema = zod_1.z.object({
33
24
  type: exports.notificationTriggerTypeSchema,
34
- conditions: zod_1.z.record(zod_1.z.any()),
35
- timing: zod_1.z.record(zod_1.z.any())
36
- });
37
- exports.notificationContentSchema = zod_1.z.object({
38
- title: zod_1.z.string(),
39
- body: zod_1.z.string()
40
25
  });
41
26
  exports.notificationTemplateSchema = zod_1.z.object({
42
27
  _id: id_types_1.notificationTemplateIdSchema,
43
28
  userId: id_types_1.userIdSchema,
44
- entityType: exports.notificationEntityTypeSchema,
29
+ entityType: zod_1.z.nativeEnum(NotificationEntityType),
45
30
  entityId: zod_1.z.string().optional(),
46
- name: zod_1.z.string(),
47
- description: zod_1.z.string().optional(),
48
31
  trigger: exports.notificationTriggerSchema,
49
- content: exports.notificationContentSchema,
50
32
  active: zod_1.z.boolean(),
51
33
  createdAt: zod_1.z.date(),
52
34
  updatedAt: zod_1.z.date()
53
35
  });
54
- exports.createNotificationTemplateSchema = exports.notificationTemplateSchema.omit({
55
- _id: true,
56
- createdAt: true,
57
- updatedAt: true
58
- });
59
- exports.entitySyncStateSchema = zod_1.z.object({
60
- userId: id_types_1.userIdSchema,
61
- entityType: exports.notificationEntityTypeSchema,
62
- entityId: zod_1.z.string(),
63
- synced: zod_1.z.boolean(),
64
- updatedAt: zod_1.z.date()
65
- });
66
- exports.notificationInstanceSchema = zod_1.z.object({
67
- _id: id_types_1.notificationInstanceIdSchema,
68
- templateId: id_types_1.notificationTemplateIdSchema,
69
- userId: id_types_1.userIdSchema,
70
- entityId: zod_1.z.string(),
71
- scheduledFor: zod_1.z.date(),
72
- status: exports.notificationStatusSchema,
73
- sentAt: zod_1.z.date().optional(),
74
- content: zod_1.z.object({
75
- title: zod_1.z.string(),
76
- body: zod_1.z.string(),
77
- data: zod_1.z.record(zod_1.z.any()).optional()
78
- }),
79
- redisId: zod_1.z.string(),
80
- error: zod_1.z.string().optional(),
81
- createdAt: zod_1.z.date(),
82
- updatedAt: zod_1.z.date()
83
- });
84
36
  exports.createNotificationTemplateRequestSchema = zod_1.z.object({
85
- entityType: exports.notificationEntityTypeSchema,
37
+ entityType: zod_1.z.nativeEnum(NotificationEntityType),
86
38
  entityId: zod_1.z.string().optional(),
87
- name: zod_1.z.string().min(1).max(100),
88
- description: zod_1.z.string().max(500).optional(),
89
39
  trigger: zod_1.z.object({
90
40
  type: exports.notificationTriggerTypeSchema,
91
- conditions: zod_1.z.record(zod_1.z.any()),
92
- timing: zod_1.z.record(zod_1.z.any())
93
- }),
94
- content: zod_1.z.object({
95
- title: zod_1.z.string().min(1).max(200),
96
- body: zod_1.z.string().min(1).max(1000)
97
41
  }),
98
42
  active: zod_1.z.boolean().default(true)
99
43
  });
100
44
  exports.updateNotificationTemplateRequestSchema = zod_1.z.object({
101
- name: zod_1.z.string().optional(),
102
- description: zod_1.z.string().optional(),
103
45
  trigger: zod_1.z.object({
104
46
  type: exports.notificationTriggerTypeSchema,
105
- conditions: zod_1.z.record(zod_1.z.any()),
106
- timing: zod_1.z.record(zod_1.z.any())
107
- }).optional(),
108
- content: zod_1.z.object({
109
- title: zod_1.z.string(),
110
- body: zod_1.z.string()
111
47
  }).optional(),
112
48
  active: zod_1.z.boolean().optional()
113
49
  });
114
- exports.syncNotificationTemplateRequestSchema = zod_1.z.object({
115
- sync: zod_1.z.boolean()
116
- });
117
- exports.previewNotificationTemplateRequestSchema = zod_1.z.object({
118
- templateTitle: zod_1.z.string(),
119
- templateBody: zod_1.z.string(),
120
- entityType: zod_1.z.string(),
121
- entityId: zod_1.z.string()
122
- });
123
- exports.getNotificationInstancesRequestSchema = zod_1.z.object({
124
- status: zod_1.z.string().optional(),
125
- templateId: zod_1.z.string().optional(),
126
- entityId: zod_1.z.string().optional(),
127
- limit: zod_1.z.number().optional(),
128
- offset: zod_1.z.number().optional()
129
- });
130
50
  exports.entitySyncRequestSchema = zod_1.z.object({
131
- entityType: zod_1.z.string(),
51
+ entityType: zod_1.z.nativeEnum(NotificationEntityType),
132
52
  entityId: zod_1.z.string(),
133
53
  synced: zod_1.z.boolean()
134
54
  });
135
55
  exports.getEntitySyncRequestSchema = zod_1.z.object({
136
- entityType: zod_1.z.string(),
56
+ entityType: zod_1.z.nativeEnum(NotificationEntityType),
137
57
  entityId: zod_1.z.string()
138
58
  });
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.124",
5
+ "version": "1.0.125",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
@@ -7,7 +7,6 @@ export interface NotificationContext<T = any> {
7
7
  entityType: NotificationEntityType;
8
8
  entityData: T;
9
9
  userId: string;
10
- variables: Record<string, any>;
11
10
  }
12
11
 
13
12
  export enum NotificationParentType {
@@ -20,156 +19,61 @@ export enum NotificationEntityType {
20
19
  AGENDA_ITEM = 'agenda_item',
21
20
  }
22
21
 
23
- export const notificationEntityTypeSchema = z.nativeEnum(NotificationEntityType);
24
-
25
- export enum NotificationStatus {
26
- SCHEDULED = 'scheduled',
27
- SENT = 'sent',
28
- FAILED = 'failed',
29
- CANCELLED = 'cancelled'
30
- }
31
-
32
22
  export enum NotificationTriggerType {
33
23
  TIME_BASED = 'time_based',
34
24
  EVENT_BASED = 'event_based',
35
25
  RECURRING = 'recurring'
36
26
  }
37
27
 
38
- export const notificationStatusSchema = z.nativeEnum(NotificationStatus);
39
28
  export const notificationTriggerTypeSchema = z.nativeEnum(NotificationTriggerType);
40
29
 
41
30
  export const notificationTriggerSchema = z.object({
42
31
  type: notificationTriggerTypeSchema,
43
- conditions: z.record(z.any()),
44
- timing: z.record(z.any())
45
- });
46
-
47
- export const notificationContentSchema = z.object({
48
- title: z.string(),
49
- body: z.string()
50
32
  });
51
33
 
52
34
  export const notificationTemplateSchema = z.object({
53
35
  _id: notificationTemplateIdSchema,
54
36
  userId: userIdSchema,
55
- entityType: notificationEntityTypeSchema,
37
+ entityType: z.nativeEnum(NotificationEntityType),
56
38
  entityId: z.string().optional(),
57
- name: z.string(),
58
- description: z.string().optional(),
59
39
  trigger: notificationTriggerSchema,
60
- content: notificationContentSchema,
61
40
  active: z.boolean(),
62
41
  createdAt: z.date(),
63
42
  updatedAt: z.date()
64
43
  });
65
44
 
66
- export const createNotificationTemplateSchema = notificationTemplateSchema.omit({
67
- _id: true,
68
- createdAt: true,
69
- updatedAt: true
70
- });
71
-
72
- export const entitySyncStateSchema = z.object({
73
- userId: userIdSchema,
74
- entityType: notificationEntityTypeSchema,
75
- entityId: z.string(),
76
- synced: z.boolean(),
77
- updatedAt: z.date()
78
- });
79
-
80
- export const notificationInstanceSchema = z.object({
81
- _id: notificationInstanceIdSchema,
82
- templateId: notificationTemplateIdSchema,
83
- userId: userIdSchema,
84
- entityId: z.string(),
85
- scheduledFor: z.date(),
86
- status: notificationStatusSchema,
87
- sentAt: z.date().optional(),
88
- content: z.object({
89
- title: z.string(),
90
- body: z.string(),
91
- data: z.record(z.any()).optional()
92
- }),
93
- redisId: z.string(),
94
- error: z.string().optional(),
95
- createdAt: z.date(),
96
- updatedAt: z.date()
97
- });
98
-
99
45
  export const createNotificationTemplateRequestSchema = z.object({
100
- entityType: notificationEntityTypeSchema,
46
+ entityType: z.nativeEnum(NotificationEntityType),
101
47
  entityId: z.string().optional(),
102
- name: z.string().min(1).max(100),
103
- description: z.string().max(500).optional(),
104
48
  trigger: z.object({
105
49
  type: notificationTriggerTypeSchema,
106
- conditions: z.record(z.any()),
107
- timing: z.record(z.any())
108
- }),
109
- content: z.object({
110
- title: z.string().min(1).max(200),
111
- body: z.string().min(1).max(1000)
112
50
  }),
113
51
  active: z.boolean().default(true)
114
52
  });
115
53
 
116
54
  export const updateNotificationTemplateRequestSchema = z.object({
117
- name: z.string().optional(),
118
- description: z.string().optional(),
119
55
  trigger: z.object({
120
56
  type: notificationTriggerTypeSchema,
121
- conditions: z.record(z.any()),
122
- timing: z.record(z.any())
123
- }).optional(),
124
- content: z.object({
125
- title: z.string(),
126
- body: z.string()
127
57
  }).optional(),
128
58
  active: z.boolean().optional()
129
59
  });
130
60
 
131
- export const syncNotificationTemplateRequestSchema = z.object({
132
- sync: z.boolean()
133
- });
134
-
135
- export const previewNotificationTemplateRequestSchema = z.object({
136
- templateTitle: z.string(),
137
- templateBody: z.string(),
138
- entityType: z.string(),
139
- entityId: z.string()
140
- });
141
-
142
- export const getNotificationInstancesRequestSchema = z.object({
143
- status: z.string().optional(),
144
- templateId: z.string().optional(),
145
- entityId: z.string().optional(),
146
- limit: z.number().optional(),
147
- offset: z.number().optional()
148
- });
149
-
150
61
  export const entitySyncRequestSchema = z.object({
151
- entityType: z.string(),
62
+ entityType: z.nativeEnum(NotificationEntityType),
152
63
  entityId: z.string(),
153
64
  synced: z.boolean()
154
65
  });
155
66
 
156
67
  export const getEntitySyncRequestSchema = z.object({
157
- entityType: z.string(),
68
+ entityType: z.nativeEnum(NotificationEntityType),
158
69
  entityId: z.string()
159
70
  });
160
71
 
161
72
  export type NotificationTrigger = z.infer<typeof notificationTriggerSchema>;
162
- export type NotificationContent = z.infer<typeof notificationContentSchema>;
163
73
  export type NotificationTemplateData = z.infer<typeof notificationTemplateSchema>;
164
- export type CreateNotificationTemplateData = z.infer<typeof createNotificationTemplateSchema>;
165
- export type EntitySyncState = z.infer<typeof entitySyncStateSchema>;
166
- export type NotificationInstanceData = z.infer<typeof notificationInstanceSchema>;
167
74
 
168
75
  export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;
169
76
  export type UpdateNotificationTemplateRequest = z.infer<typeof updateNotificationTemplateRequestSchema>;
170
- export type SyncNotificationTemplateRequest = z.infer<typeof syncNotificationTemplateRequestSchema>;
171
- export type PreviewNotificationTemplateRequest = z.infer<typeof previewNotificationTemplateRequestSchema>;
172
- export type GetNotificationInstancesRequest = z.infer<typeof getNotificationInstancesRequestSchema>;
173
77
  export type EntitySyncRequest = z.infer<typeof entitySyncRequestSchema>;
174
78
  export type GetEntitySyncRequest = z.infer<typeof getEntitySyncRequestSchema>;
175
79
 
@@ -191,24 +95,6 @@ export interface UpdateNotificationTemplateResponse {
191
95
 
192
96
  export interface DeleteNotificationTemplateResponse {}
193
97
 
194
- export interface SyncNotificationTemplateResponse {
195
- synced: boolean;
196
- }
197
-
198
- export interface PreviewNotificationTemplateResponse {
199
- preview: {
200
- title: string;
201
- body: string;
202
- };
203
- }
204
-
205
- export interface GetNotificationInstancesResponse {
206
- success: boolean;
207
- instances?: Serialized<NotificationInstanceData>[];
208
- total?: number;
209
- error?: string;
210
- }
211
-
212
98
  export interface EntitySyncResponse {
213
99
  success: boolean;
214
100
  synced: boolean;
File without changes