@timothyw/pat-common 1.0.124 → 1.0.126
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,10 @@ export interface NotificationContext<T = any> {
|
|
|
5
5
|
entityType: NotificationEntityType;
|
|
6
6
|
entityData: T;
|
|
7
7
|
userId: string;
|
|
8
|
-
|
|
8
|
+
}
|
|
9
|
+
export declare enum TargetType {
|
|
10
|
+
PARENT = "parent",
|
|
11
|
+
ENTITY = "entity"
|
|
9
12
|
}
|
|
10
13
|
export declare enum NotificationParentType {
|
|
11
14
|
AGENDA_PANEL = "agenda_panel"
|
|
@@ -15,72 +18,30 @@ export declare enum NotificationEntityType {
|
|
|
15
18
|
AGENDA_PANEL = "agenda_item",
|
|
16
19
|
AGENDA_ITEM = "agenda_item"
|
|
17
20
|
}
|
|
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
21
|
export declare enum NotificationTriggerType {
|
|
26
22
|
TIME_BASED = "time_based",
|
|
27
23
|
EVENT_BASED = "event_based",
|
|
28
24
|
RECURRING = "recurring"
|
|
29
25
|
}
|
|
30
|
-
export declare const notificationStatusSchema: z.ZodNativeEnum<typeof NotificationStatus>;
|
|
31
26
|
export declare const notificationTriggerTypeSchema: z.ZodNativeEnum<typeof NotificationTriggerType>;
|
|
32
27
|
export declare const notificationTriggerSchema: z.ZodObject<{
|
|
33
28
|
type: z.ZodNativeEnum<typeof NotificationTriggerType>;
|
|
34
|
-
conditions: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
35
|
-
timing: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
36
29
|
}, "strip", z.ZodTypeAny, {
|
|
37
30
|
type: NotificationTriggerType;
|
|
38
|
-
conditions: Record<string, any>;
|
|
39
|
-
timing: Record<string, any>;
|
|
40
31
|
}, {
|
|
41
32
|
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
33
|
}>;
|
|
55
34
|
export declare const notificationTemplateSchema: z.ZodObject<{
|
|
56
35
|
_id: z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>;
|
|
57
36
|
userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
name: z.ZodString;
|
|
61
|
-
description: z.ZodOptional<z.ZodString>;
|
|
37
|
+
targetType: z.ZodNativeEnum<typeof TargetType>;
|
|
38
|
+
targetId: z.ZodString;
|
|
62
39
|
trigger: z.ZodObject<{
|
|
63
40
|
type: z.ZodNativeEnum<typeof NotificationTriggerType>;
|
|
64
|
-
conditions: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
65
|
-
timing: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
66
41
|
}, "strip", z.ZodTypeAny, {
|
|
67
42
|
type: NotificationTriggerType;
|
|
68
|
-
conditions: Record<string, any>;
|
|
69
|
-
timing: Record<string, any>;
|
|
70
43
|
}, {
|
|
71
44
|
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
45
|
}>;
|
|
85
46
|
active: z.ZodBoolean;
|
|
86
47
|
createdAt: z.ZodDate;
|
|
@@ -94,385 +55,97 @@ export declare const notificationTemplateSchema: z.ZodObject<{
|
|
|
94
55
|
userId: string & {
|
|
95
56
|
readonly __brand: "UserId";
|
|
96
57
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
title: string;
|
|
100
|
-
body: string;
|
|
101
|
-
};
|
|
102
|
-
entityType: NotificationEntityType;
|
|
58
|
+
targetType: TargetType;
|
|
59
|
+
targetId: string;
|
|
103
60
|
trigger: {
|
|
104
61
|
type: NotificationTriggerType;
|
|
105
|
-
conditions: Record<string, any>;
|
|
106
|
-
timing: Record<string, any>;
|
|
107
62
|
};
|
|
108
63
|
active: boolean;
|
|
109
|
-
description?: string | undefined;
|
|
110
|
-
entityId?: string | undefined;
|
|
111
64
|
}, {
|
|
112
65
|
_id: string;
|
|
113
66
|
createdAt: Date;
|
|
114
67
|
updatedAt: Date;
|
|
115
68
|
userId: string;
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
entityType: NotificationEntityType;
|
|
69
|
+
targetType: TargetType;
|
|
70
|
+
targetId: string;
|
|
190
71
|
trigger: {
|
|
191
72
|
type: NotificationTriggerType;
|
|
192
|
-
conditions: Record<string, any>;
|
|
193
|
-
timing: Record<string, any>;
|
|
194
73
|
};
|
|
195
74
|
active: boolean;
|
|
196
|
-
description?: string | undefined;
|
|
197
|
-
entityId?: string | undefined;
|
|
198
|
-
}>;
|
|
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
75
|
}>;
|
|
286
76
|
export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
|
|
287
77
|
entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
|
|
288
78
|
entityId: z.ZodOptional<z.ZodString>;
|
|
289
|
-
name: z.ZodString;
|
|
290
|
-
description: z.ZodOptional<z.ZodString>;
|
|
291
79
|
trigger: z.ZodObject<{
|
|
292
80
|
type: z.ZodNativeEnum<typeof NotificationTriggerType>;
|
|
293
|
-
conditions: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
294
|
-
timing: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
295
81
|
}, "strip", z.ZodTypeAny, {
|
|
296
82
|
type: NotificationTriggerType;
|
|
297
|
-
conditions: Record<string, any>;
|
|
298
|
-
timing: Record<string, any>;
|
|
299
83
|
}, {
|
|
300
84
|
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
85
|
}>;
|
|
314
86
|
active: z.ZodDefault<z.ZodBoolean>;
|
|
315
87
|
}, "strip", z.ZodTypeAny, {
|
|
316
|
-
name: string;
|
|
317
|
-
content: {
|
|
318
|
-
title: string;
|
|
319
|
-
body: string;
|
|
320
|
-
};
|
|
321
|
-
entityType: NotificationEntityType;
|
|
322
88
|
trigger: {
|
|
323
89
|
type: NotificationTriggerType;
|
|
324
|
-
conditions: Record<string, any>;
|
|
325
|
-
timing: Record<string, any>;
|
|
326
90
|
};
|
|
327
91
|
active: boolean;
|
|
328
|
-
|
|
92
|
+
entityType: NotificationEntityType;
|
|
329
93
|
entityId?: string | undefined;
|
|
330
94
|
}, {
|
|
331
|
-
name: string;
|
|
332
|
-
content: {
|
|
333
|
-
title: string;
|
|
334
|
-
body: string;
|
|
335
|
-
};
|
|
336
|
-
entityType: NotificationEntityType;
|
|
337
95
|
trigger: {
|
|
338
96
|
type: NotificationTriggerType;
|
|
339
|
-
conditions: Record<string, any>;
|
|
340
|
-
timing: Record<string, any>;
|
|
341
97
|
};
|
|
342
|
-
|
|
343
|
-
entityId?: string | undefined;
|
|
98
|
+
entityType: NotificationEntityType;
|
|
344
99
|
active?: boolean | undefined;
|
|
100
|
+
entityId?: string | undefined;
|
|
345
101
|
}>;
|
|
346
102
|
export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
|
|
347
|
-
name: z.ZodOptional<z.ZodString>;
|
|
348
|
-
description: z.ZodOptional<z.ZodString>;
|
|
349
103
|
trigger: z.ZodOptional<z.ZodObject<{
|
|
350
104
|
type: z.ZodNativeEnum<typeof NotificationTriggerType>;
|
|
351
|
-
conditions: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
352
|
-
timing: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
353
105
|
}, "strip", z.ZodTypeAny, {
|
|
354
106
|
type: NotificationTriggerType;
|
|
355
|
-
conditions: Record<string, any>;
|
|
356
|
-
timing: Record<string, any>;
|
|
357
107
|
}, {
|
|
358
108
|
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
109
|
}>>;
|
|
372
110
|
active: z.ZodOptional<z.ZodBoolean>;
|
|
373
111
|
}, "strip", z.ZodTypeAny, {
|
|
374
|
-
name?: string | undefined;
|
|
375
|
-
description?: string | undefined;
|
|
376
|
-
content?: {
|
|
377
|
-
title: string;
|
|
378
|
-
body: string;
|
|
379
|
-
} | undefined;
|
|
380
112
|
trigger?: {
|
|
381
113
|
type: NotificationTriggerType;
|
|
382
|
-
conditions: Record<string, any>;
|
|
383
|
-
timing: Record<string, any>;
|
|
384
114
|
} | undefined;
|
|
385
115
|
active?: boolean | undefined;
|
|
386
116
|
}, {
|
|
387
|
-
name?: string | undefined;
|
|
388
|
-
description?: string | undefined;
|
|
389
|
-
content?: {
|
|
390
|
-
title: string;
|
|
391
|
-
body: string;
|
|
392
|
-
} | undefined;
|
|
393
117
|
trigger?: {
|
|
394
118
|
type: NotificationTriggerType;
|
|
395
|
-
conditions: Record<string, any>;
|
|
396
|
-
timing: Record<string, any>;
|
|
397
119
|
} | undefined;
|
|
398
120
|
active?: boolean | undefined;
|
|
399
121
|
}>;
|
|
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
122
|
export declare const entitySyncRequestSchema: z.ZodObject<{
|
|
443
|
-
entityType: z.
|
|
123
|
+
entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
|
|
444
124
|
entityId: z.ZodString;
|
|
445
125
|
synced: z.ZodBoolean;
|
|
446
126
|
}, "strip", z.ZodTypeAny, {
|
|
447
|
-
entityType:
|
|
127
|
+
entityType: NotificationEntityType;
|
|
448
128
|
entityId: string;
|
|
449
129
|
synced: boolean;
|
|
450
130
|
}, {
|
|
451
|
-
entityType:
|
|
131
|
+
entityType: NotificationEntityType;
|
|
452
132
|
entityId: string;
|
|
453
133
|
synced: boolean;
|
|
454
134
|
}>;
|
|
455
135
|
export declare const getEntitySyncRequestSchema: z.ZodObject<{
|
|
456
|
-
entityType: z.
|
|
136
|
+
entityType: z.ZodNativeEnum<typeof NotificationEntityType>;
|
|
457
137
|
entityId: z.ZodString;
|
|
458
138
|
}, "strip", z.ZodTypeAny, {
|
|
459
|
-
entityType:
|
|
139
|
+
entityType: NotificationEntityType;
|
|
460
140
|
entityId: string;
|
|
461
141
|
}, {
|
|
462
|
-
entityType:
|
|
142
|
+
entityType: NotificationEntityType;
|
|
463
143
|
entityId: string;
|
|
464
144
|
}>;
|
|
465
145
|
export type NotificationTrigger = z.infer<typeof notificationTriggerSchema>;
|
|
466
|
-
export type NotificationContent = z.infer<typeof notificationContentSchema>;
|
|
467
146
|
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
147
|
export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;
|
|
472
148
|
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
149
|
export type EntitySyncRequest = z.infer<typeof entitySyncRequestSchema>;
|
|
477
150
|
export type GetEntitySyncRequest = z.infer<typeof getEntitySyncRequestSchema>;
|
|
478
151
|
export interface CreateNotificationTemplateResponse {
|
|
@@ -489,21 +162,6 @@ export interface UpdateNotificationTemplateResponse {
|
|
|
489
162
|
}
|
|
490
163
|
export interface DeleteNotificationTemplateResponse {
|
|
491
164
|
}
|
|
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
165
|
export interface EntitySyncResponse {
|
|
508
166
|
success: boolean;
|
|
509
167
|
synced: boolean;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEntitySyncRequestSchema = exports.entitySyncRequestSchema = exports.
|
|
3
|
+
exports.getEntitySyncRequestSchema = exports.entitySyncRequestSchema = exports.updateNotificationTemplateRequestSchema = exports.createNotificationTemplateRequestSchema = exports.notificationTemplateSchema = exports.notificationTriggerSchema = exports.notificationTriggerTypeSchema = exports.NotificationTriggerType = exports.NotificationEntityType = exports.NotificationParentType = exports.TargetType = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const id_types_1 = require("./id-types");
|
|
6
|
+
var TargetType;
|
|
7
|
+
(function (TargetType) {
|
|
8
|
+
TargetType["PARENT"] = "parent";
|
|
9
|
+
TargetType["ENTITY"] = "entity";
|
|
10
|
+
})(TargetType || (exports.TargetType = TargetType = {}));
|
|
6
11
|
var NotificationParentType;
|
|
7
12
|
(function (NotificationParentType) {
|
|
8
13
|
NotificationParentType["AGENDA_PANEL"] = "agenda_panel";
|
|
@@ -13,126 +18,48 @@ var NotificationEntityType;
|
|
|
13
18
|
NotificationEntityType["AGENDA_PANEL"] = "agenda_item";
|
|
14
19
|
NotificationEntityType["AGENDA_ITEM"] = "agenda_item";
|
|
15
20
|
})(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
21
|
var NotificationTriggerType;
|
|
25
22
|
(function (NotificationTriggerType) {
|
|
26
23
|
NotificationTriggerType["TIME_BASED"] = "time_based";
|
|
27
24
|
NotificationTriggerType["EVENT_BASED"] = "event_based";
|
|
28
25
|
NotificationTriggerType["RECURRING"] = "recurring";
|
|
29
26
|
})(NotificationTriggerType || (exports.NotificationTriggerType = NotificationTriggerType = {}));
|
|
30
|
-
exports.notificationStatusSchema = zod_1.z.nativeEnum(NotificationStatus);
|
|
31
27
|
exports.notificationTriggerTypeSchema = zod_1.z.nativeEnum(NotificationTriggerType);
|
|
32
28
|
exports.notificationTriggerSchema = zod_1.z.object({
|
|
33
29
|
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
30
|
});
|
|
41
31
|
exports.notificationTemplateSchema = zod_1.z.object({
|
|
42
32
|
_id: id_types_1.notificationTemplateIdSchema,
|
|
43
33
|
userId: id_types_1.userIdSchema,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
targetType: zod_1.z.nativeEnum(TargetType),
|
|
35
|
+
targetId: zod_1.z.string(),
|
|
36
|
+
// entityType: z.nativeEnum(NotificationEntityType),
|
|
37
|
+
// entityId: z.string().optional(),
|
|
48
38
|
trigger: exports.notificationTriggerSchema,
|
|
49
|
-
content: exports.notificationContentSchema,
|
|
50
39
|
active: zod_1.z.boolean(),
|
|
51
40
|
createdAt: zod_1.z.date(),
|
|
52
41
|
updatedAt: zod_1.z.date()
|
|
53
42
|
});
|
|
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
43
|
exports.createNotificationTemplateRequestSchema = zod_1.z.object({
|
|
85
|
-
entityType:
|
|
44
|
+
entityType: zod_1.z.nativeEnum(NotificationEntityType),
|
|
86
45
|
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
46
|
trigger: zod_1.z.object({
|
|
90
47
|
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
48
|
}),
|
|
98
49
|
active: zod_1.z.boolean().default(true)
|
|
99
50
|
});
|
|
100
51
|
exports.updateNotificationTemplateRequestSchema = zod_1.z.object({
|
|
101
|
-
name: zod_1.z.string().optional(),
|
|
102
|
-
description: zod_1.z.string().optional(),
|
|
103
52
|
trigger: zod_1.z.object({
|
|
104
53
|
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
54
|
}).optional(),
|
|
112
55
|
active: zod_1.z.boolean().optional()
|
|
113
56
|
});
|
|
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
57
|
exports.entitySyncRequestSchema = zod_1.z.object({
|
|
131
|
-
entityType: zod_1.z.
|
|
58
|
+
entityType: zod_1.z.nativeEnum(NotificationEntityType),
|
|
132
59
|
entityId: zod_1.z.string(),
|
|
133
60
|
synced: zod_1.z.boolean()
|
|
134
61
|
});
|
|
135
62
|
exports.getEntitySyncRequestSchema = zod_1.z.object({
|
|
136
|
-
entityType: zod_1.z.
|
|
63
|
+
entityType: zod_1.z.nativeEnum(NotificationEntityType),
|
|
137
64
|
entityId: zod_1.z.string()
|
|
138
65
|
});
|
package/package.json
CHANGED
|
@@ -7,7 +7,11 @@ export interface NotificationContext<T = any> {
|
|
|
7
7
|
entityType: NotificationEntityType;
|
|
8
8
|
entityData: T;
|
|
9
9
|
userId: string;
|
|
10
|
-
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export enum TargetType {
|
|
13
|
+
PARENT = 'parent',
|
|
14
|
+
ENTITY = 'entity'
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
export enum NotificationParentType {
|
|
@@ -20,156 +24,63 @@ export enum NotificationEntityType {
|
|
|
20
24
|
AGENDA_ITEM = 'agenda_item',
|
|
21
25
|
}
|
|
22
26
|
|
|
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
27
|
export enum NotificationTriggerType {
|
|
33
28
|
TIME_BASED = 'time_based',
|
|
34
29
|
EVENT_BASED = 'event_based',
|
|
35
30
|
RECURRING = 'recurring'
|
|
36
31
|
}
|
|
37
32
|
|
|
38
|
-
export const notificationStatusSchema = z.nativeEnum(NotificationStatus);
|
|
39
33
|
export const notificationTriggerTypeSchema = z.nativeEnum(NotificationTriggerType);
|
|
40
34
|
|
|
41
35
|
export const notificationTriggerSchema = z.object({
|
|
42
36
|
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
37
|
});
|
|
51
38
|
|
|
52
39
|
export const notificationTemplateSchema = z.object({
|
|
53
40
|
_id: notificationTemplateIdSchema,
|
|
54
41
|
userId: userIdSchema,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
targetType: z.nativeEnum(TargetType),
|
|
43
|
+
targetId: z.string(),
|
|
44
|
+
// entityType: z.nativeEnum(NotificationEntityType),
|
|
45
|
+
// entityId: z.string().optional(),
|
|
59
46
|
trigger: notificationTriggerSchema,
|
|
60
|
-
content: notificationContentSchema,
|
|
61
47
|
active: z.boolean(),
|
|
62
48
|
createdAt: z.date(),
|
|
63
49
|
updatedAt: z.date()
|
|
64
50
|
});
|
|
65
51
|
|
|
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
52
|
export const createNotificationTemplateRequestSchema = z.object({
|
|
100
|
-
entityType:
|
|
53
|
+
entityType: z.nativeEnum(NotificationEntityType),
|
|
101
54
|
entityId: z.string().optional(),
|
|
102
|
-
name: z.string().min(1).max(100),
|
|
103
|
-
description: z.string().max(500).optional(),
|
|
104
55
|
trigger: z.object({
|
|
105
56
|
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
57
|
}),
|
|
113
58
|
active: z.boolean().default(true)
|
|
114
59
|
});
|
|
115
60
|
|
|
116
61
|
export const updateNotificationTemplateRequestSchema = z.object({
|
|
117
|
-
name: z.string().optional(),
|
|
118
|
-
description: z.string().optional(),
|
|
119
62
|
trigger: z.object({
|
|
120
63
|
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
64
|
}).optional(),
|
|
128
65
|
active: z.boolean().optional()
|
|
129
66
|
});
|
|
130
67
|
|
|
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
68
|
export const entitySyncRequestSchema = z.object({
|
|
151
|
-
entityType: z.
|
|
69
|
+
entityType: z.nativeEnum(NotificationEntityType),
|
|
152
70
|
entityId: z.string(),
|
|
153
71
|
synced: z.boolean()
|
|
154
72
|
});
|
|
155
73
|
|
|
156
74
|
export const getEntitySyncRequestSchema = z.object({
|
|
157
|
-
entityType: z.
|
|
75
|
+
entityType: z.nativeEnum(NotificationEntityType),
|
|
158
76
|
entityId: z.string()
|
|
159
77
|
});
|
|
160
78
|
|
|
161
79
|
export type NotificationTrigger = z.infer<typeof notificationTriggerSchema>;
|
|
162
|
-
export type NotificationContent = z.infer<typeof notificationContentSchema>;
|
|
163
80
|
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
81
|
|
|
168
82
|
export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;
|
|
169
83
|
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
84
|
export type EntitySyncRequest = z.infer<typeof entitySyncRequestSchema>;
|
|
174
85
|
export type GetEntitySyncRequest = z.infer<typeof getEntitySyncRequestSchema>;
|
|
175
86
|
|
|
@@ -191,24 +102,6 @@ export interface UpdateNotificationTemplateResponse {
|
|
|
191
102
|
|
|
192
103
|
export interface DeleteNotificationTemplateResponse {}
|
|
193
104
|
|
|
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
105
|
export interface EntitySyncResponse {
|
|
213
106
|
success: boolean;
|
|
214
107
|
synced: boolean;
|
|
File without changes
|