@timothyw/pat-common 1.0.131 → 1.0.133

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.
@@ -15,32 +15,67 @@ export declare enum NotificationEntityType {
15
15
  AGENDA_PANEL = "agenda_item",
16
16
  INBOX_PANEL = "inbox_panel"
17
17
  }
18
- export declare enum NotificationTriggerType {
19
- TIME_BASED = "time_based",
20
- EVENT_BASED = "event_based",
21
- RECURRING = "recurring"
18
+ export declare enum NotificationSchedulerType {
19
+ DAY_TIME = "day_time",
20
+ RELATIVE_DATE = "relative_date"
22
21
  }
23
- export declare const notificationTriggerTypeSchema: z.ZodNativeEnum<typeof NotificationTriggerType>;
24
- export declare const notificationTriggerSchema: z.ZodObject<{
25
- type: z.ZodNativeEnum<typeof NotificationTriggerType>;
22
+ export declare const notificationSchedulerDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
23
+ type: z.ZodLiteral<NotificationSchedulerType.DAY_TIME>;
24
+ days: z.ZodArray<z.ZodNumber, "many">;
25
+ time: z.ZodString;
26
26
  }, "strip", z.ZodTypeAny, {
27
- type: NotificationTriggerType;
27
+ type: NotificationSchedulerType.DAY_TIME;
28
+ days: number[];
29
+ time: string;
28
30
  }, {
29
- type: NotificationTriggerType;
30
- }>;
31
+ type: NotificationSchedulerType.DAY_TIME;
32
+ days: number[];
33
+ time: string;
34
+ }>, z.ZodObject<{
35
+ type: z.ZodLiteral<NotificationSchedulerType.RELATIVE_DATE>;
36
+ date: z.ZodString;
37
+ offsetMinutes: z.ZodNumber;
38
+ }, "strip", z.ZodTypeAny, {
39
+ type: NotificationSchedulerType.RELATIVE_DATE;
40
+ date: string;
41
+ offsetMinutes: number;
42
+ }, {
43
+ type: NotificationSchedulerType.RELATIVE_DATE;
44
+ date: string;
45
+ offsetMinutes: number;
46
+ }>]>;
31
47
  export declare const notificationTemplateSchema: z.ZodObject<{
32
48
  _id: z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>;
33
49
  userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
34
50
  targetLevel: z.ZodNativeEnum<typeof NotificationTemplateLevel>;
35
51
  targetEntityType: z.ZodNativeEnum<typeof NotificationEntityType>;
36
52
  targetId: z.ZodString;
37
- trigger: z.ZodObject<{
38
- type: z.ZodNativeEnum<typeof NotificationTriggerType>;
53
+ schedulerData: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
54
+ type: z.ZodLiteral<NotificationSchedulerType.DAY_TIME>;
55
+ days: z.ZodArray<z.ZodNumber, "many">;
56
+ time: z.ZodString;
57
+ }, "strip", z.ZodTypeAny, {
58
+ type: NotificationSchedulerType.DAY_TIME;
59
+ days: number[];
60
+ time: string;
61
+ }, {
62
+ type: NotificationSchedulerType.DAY_TIME;
63
+ days: number[];
64
+ time: string;
65
+ }>, z.ZodObject<{
66
+ type: z.ZodLiteral<NotificationSchedulerType.RELATIVE_DATE>;
67
+ date: z.ZodString;
68
+ offsetMinutes: z.ZodNumber;
39
69
  }, "strip", z.ZodTypeAny, {
40
- type: NotificationTriggerType;
70
+ type: NotificationSchedulerType.RELATIVE_DATE;
71
+ date: string;
72
+ offsetMinutes: number;
41
73
  }, {
42
- type: NotificationTriggerType;
43
- }>;
74
+ type: NotificationSchedulerType.RELATIVE_DATE;
75
+ date: string;
76
+ offsetMinutes: number;
77
+ }>]>;
78
+ variantData: z.ZodAny;
44
79
  active: z.ZodBoolean;
45
80
  createdAt: z.ZodDate;
46
81
  updatedAt: z.ZodDate;
@@ -56,10 +91,17 @@ export declare const notificationTemplateSchema: z.ZodObject<{
56
91
  targetLevel: NotificationTemplateLevel;
57
92
  targetEntityType: NotificationEntityType;
58
93
  targetId: string;
59
- trigger: {
60
- type: NotificationTriggerType;
94
+ schedulerData: {
95
+ type: NotificationSchedulerType.DAY_TIME;
96
+ days: number[];
97
+ time: string;
98
+ } | {
99
+ type: NotificationSchedulerType.RELATIVE_DATE;
100
+ date: string;
101
+ offsetMinutes: number;
61
102
  };
62
103
  active: boolean;
104
+ variantData?: any;
63
105
  }, {
64
106
  _id: string;
65
107
  createdAt: Date;
@@ -68,58 +110,131 @@ export declare const notificationTemplateSchema: z.ZodObject<{
68
110
  targetLevel: NotificationTemplateLevel;
69
111
  targetEntityType: NotificationEntityType;
70
112
  targetId: string;
71
- trigger: {
72
- type: NotificationTriggerType;
113
+ schedulerData: {
114
+ type: NotificationSchedulerType.DAY_TIME;
115
+ days: number[];
116
+ time: string;
117
+ } | {
118
+ type: NotificationSchedulerType.RELATIVE_DATE;
119
+ date: string;
120
+ offsetMinutes: number;
73
121
  };
74
122
  active: boolean;
123
+ variantData?: any;
75
124
  }>;
76
125
  export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
77
126
  targetLevel: z.ZodNativeEnum<typeof NotificationTemplateLevel>;
78
127
  targetEntityType: z.ZodNativeEnum<typeof NotificationEntityType>;
79
128
  targetId: z.ZodOptional<z.ZodString>;
80
- trigger: z.ZodObject<{
81
- type: z.ZodNativeEnum<typeof NotificationTriggerType>;
129
+ schedulerData: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
130
+ type: z.ZodLiteral<NotificationSchedulerType.DAY_TIME>;
131
+ days: z.ZodArray<z.ZodNumber, "many">;
132
+ time: z.ZodString;
82
133
  }, "strip", z.ZodTypeAny, {
83
- type: NotificationTriggerType;
134
+ type: NotificationSchedulerType.DAY_TIME;
135
+ days: number[];
136
+ time: string;
84
137
  }, {
85
- type: NotificationTriggerType;
86
- }>;
138
+ type: NotificationSchedulerType.DAY_TIME;
139
+ days: number[];
140
+ time: string;
141
+ }>, z.ZodObject<{
142
+ type: z.ZodLiteral<NotificationSchedulerType.RELATIVE_DATE>;
143
+ date: z.ZodString;
144
+ offsetMinutes: z.ZodNumber;
145
+ }, "strip", z.ZodTypeAny, {
146
+ type: NotificationSchedulerType.RELATIVE_DATE;
147
+ date: string;
148
+ offsetMinutes: number;
149
+ }, {
150
+ type: NotificationSchedulerType.RELATIVE_DATE;
151
+ date: string;
152
+ offsetMinutes: number;
153
+ }>]>;
154
+ variantData: z.ZodAny;
87
155
  active: z.ZodDefault<z.ZodBoolean>;
88
156
  }, "strip", z.ZodTypeAny, {
89
157
  targetLevel: NotificationTemplateLevel;
90
158
  targetEntityType: NotificationEntityType;
91
- trigger: {
92
- type: NotificationTriggerType;
159
+ schedulerData: {
160
+ type: NotificationSchedulerType.DAY_TIME;
161
+ days: number[];
162
+ time: string;
163
+ } | {
164
+ type: NotificationSchedulerType.RELATIVE_DATE;
165
+ date: string;
166
+ offsetMinutes: number;
93
167
  };
94
168
  active: boolean;
95
169
  targetId?: string | undefined;
170
+ variantData?: any;
96
171
  }, {
97
172
  targetLevel: NotificationTemplateLevel;
98
173
  targetEntityType: NotificationEntityType;
99
- trigger: {
100
- type: NotificationTriggerType;
174
+ schedulerData: {
175
+ type: NotificationSchedulerType.DAY_TIME;
176
+ days: number[];
177
+ time: string;
178
+ } | {
179
+ type: NotificationSchedulerType.RELATIVE_DATE;
180
+ date: string;
181
+ offsetMinutes: number;
101
182
  };
102
183
  targetId?: string | undefined;
184
+ variantData?: any;
103
185
  active?: boolean | undefined;
104
186
  }>;
105
187
  export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
106
- trigger: z.ZodOptional<z.ZodObject<{
107
- type: z.ZodNativeEnum<typeof NotificationTriggerType>;
188
+ schedulerData: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
189
+ type: z.ZodLiteral<NotificationSchedulerType.DAY_TIME>;
190
+ days: z.ZodArray<z.ZodNumber, "many">;
191
+ time: z.ZodString;
192
+ }, "strip", z.ZodTypeAny, {
193
+ type: NotificationSchedulerType.DAY_TIME;
194
+ days: number[];
195
+ time: string;
196
+ }, {
197
+ type: NotificationSchedulerType.DAY_TIME;
198
+ days: number[];
199
+ time: string;
200
+ }>, z.ZodObject<{
201
+ type: z.ZodLiteral<NotificationSchedulerType.RELATIVE_DATE>;
202
+ date: z.ZodString;
203
+ offsetMinutes: z.ZodNumber;
108
204
  }, "strip", z.ZodTypeAny, {
109
- type: NotificationTriggerType;
205
+ type: NotificationSchedulerType.RELATIVE_DATE;
206
+ date: string;
207
+ offsetMinutes: number;
110
208
  }, {
111
- type: NotificationTriggerType;
112
- }>>;
209
+ type: NotificationSchedulerType.RELATIVE_DATE;
210
+ date: string;
211
+ offsetMinutes: number;
212
+ }>]>>;
213
+ variantData: z.ZodOptional<z.ZodAny>;
113
214
  active: z.ZodOptional<z.ZodBoolean>;
114
215
  }, "strip", z.ZodTypeAny, {
115
- trigger?: {
116
- type: NotificationTriggerType;
216
+ schedulerData?: {
217
+ type: NotificationSchedulerType.DAY_TIME;
218
+ days: number[];
219
+ time: string;
220
+ } | {
221
+ type: NotificationSchedulerType.RELATIVE_DATE;
222
+ date: string;
223
+ offsetMinutes: number;
117
224
  } | undefined;
225
+ variantData?: any;
118
226
  active?: boolean | undefined;
119
227
  }, {
120
- trigger?: {
121
- type: NotificationTriggerType;
228
+ schedulerData?: {
229
+ type: NotificationSchedulerType.DAY_TIME;
230
+ days: number[];
231
+ time: string;
232
+ } | {
233
+ type: NotificationSchedulerType.RELATIVE_DATE;
234
+ date: string;
235
+ offsetMinutes: number;
122
236
  } | undefined;
237
+ variantData?: any;
123
238
  active?: boolean | undefined;
124
239
  }>;
125
240
  export declare const entitySyncRequestSchema: z.ZodObject<{
@@ -145,7 +260,7 @@ export declare const getEntitySyncRequestSchema: z.ZodObject<{
145
260
  targetEntityType: NotificationEntityType;
146
261
  targetId: string;
147
262
  }>;
148
- export type NotificationTrigger = z.infer<typeof notificationTriggerSchema>;
263
+ export type NotificationTrigger = z.infer<typeof notificationSchedulerDataSchema>;
149
264
  export type NotificationTemplateData = z.infer<typeof notificationTemplateSchema>;
150
265
  export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;
151
266
  export type UpdateNotificationTemplateRequest = z.infer<typeof updateNotificationTemplateRequestSchema>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEntitySyncRequestSchema = exports.entitySyncRequestSchema = exports.updateNotificationTemplateRequestSchema = exports.createNotificationTemplateRequestSchema = exports.notificationTemplateSchema = exports.notificationTriggerSchema = exports.notificationTriggerTypeSchema = exports.NotificationTriggerType = exports.NotificationEntityType = exports.NotificationTemplateLevel = void 0;
3
+ exports.getEntitySyncRequestSchema = exports.entitySyncRequestSchema = exports.updateNotificationTemplateRequestSchema = exports.createNotificationTemplateRequestSchema = exports.notificationTemplateSchema = exports.notificationSchedulerDataSchema = exports.NotificationSchedulerType = exports.NotificationEntityType = exports.NotificationTemplateLevel = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const id_types_1 = require("./id-types");
6
6
  var NotificationTemplateLevel;
@@ -14,25 +14,31 @@ var NotificationEntityType;
14
14
  NotificationEntityType["AGENDA_PANEL"] = "agenda_item";
15
15
  NotificationEntityType["INBOX_PANEL"] = "inbox_panel";
16
16
  })(NotificationEntityType || (exports.NotificationEntityType = NotificationEntityType = {}));
17
- var NotificationTriggerType;
18
- (function (NotificationTriggerType) {
19
- NotificationTriggerType["TIME_BASED"] = "time_based";
20
- NotificationTriggerType["EVENT_BASED"] = "event_based";
21
- NotificationTriggerType["RECURRING"] = "recurring";
22
- })(NotificationTriggerType || (exports.NotificationTriggerType = NotificationTriggerType = {}));
23
- exports.notificationTriggerTypeSchema = zod_1.z.nativeEnum(NotificationTriggerType);
24
- exports.notificationTriggerSchema = zod_1.z.object({
25
- type: exports.notificationTriggerTypeSchema,
26
- });
17
+ var NotificationSchedulerType;
18
+ (function (NotificationSchedulerType) {
19
+ NotificationSchedulerType["DAY_TIME"] = "day_time";
20
+ NotificationSchedulerType["RELATIVE_DATE"] = "relative_date";
21
+ })(NotificationSchedulerType || (exports.NotificationSchedulerType = NotificationSchedulerType = {}));
22
+ exports.notificationSchedulerDataSchema = zod_1.z.discriminatedUnion('type', [
23
+ zod_1.z.object({
24
+ type: zod_1.z.literal(NotificationSchedulerType.DAY_TIME),
25
+ days: zod_1.z.array(zod_1.z.number().min(0).max(6)),
26
+ time: zod_1.z.string().regex(/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/), // HH:mm format
27
+ }),
28
+ zod_1.z.object({
29
+ type: zod_1.z.literal(NotificationSchedulerType.RELATIVE_DATE),
30
+ date: zod_1.z.string(),
31
+ offsetMinutes: zod_1.z.number().int()
32
+ })
33
+ ]);
27
34
  exports.notificationTemplateSchema = zod_1.z.object({
28
35
  _id: id_types_1.notificationTemplateIdSchema,
29
36
  userId: id_types_1.userIdSchema,
30
37
  targetLevel: zod_1.z.nativeEnum(NotificationTemplateLevel),
31
38
  targetEntityType: zod_1.z.nativeEnum(NotificationEntityType),
32
39
  targetId: zod_1.z.string(),
33
- // entityType: z.nativeEnum(NotificationEntityType),
34
- // entityId: z.string().optional(),
35
- trigger: exports.notificationTriggerSchema,
40
+ schedulerData: exports.notificationSchedulerDataSchema,
41
+ variantData: zod_1.z.any(),
36
42
  active: zod_1.z.boolean(),
37
43
  createdAt: zod_1.z.date(),
38
44
  updatedAt: zod_1.z.date()
@@ -41,13 +47,13 @@ exports.createNotificationTemplateRequestSchema = zod_1.z.object({
41
47
  targetLevel: zod_1.z.nativeEnum(NotificationTemplateLevel),
42
48
  targetEntityType: zod_1.z.nativeEnum(NotificationEntityType),
43
49
  targetId: zod_1.z.string().optional(),
44
- trigger: exports.notificationTriggerSchema,
50
+ schedulerData: exports.notificationSchedulerDataSchema,
51
+ variantData: zod_1.z.any(),
45
52
  active: zod_1.z.boolean().default(true)
46
53
  });
47
54
  exports.updateNotificationTemplateRequestSchema = zod_1.z.object({
48
- trigger: zod_1.z.object({
49
- type: exports.notificationTriggerTypeSchema,
50
- }).optional(),
55
+ schedulerData: exports.notificationSchedulerDataSchema.optional(),
56
+ variantData: zod_1.z.any().optional(),
51
57
  active: zod_1.z.boolean().optional()
52
58
  });
53
59
  exports.entitySyncRequestSchema = zod_1.z.object({
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.131",
5
+ "version": "1.0.133",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
@@ -21,17 +21,23 @@ export enum NotificationEntityType {
21
21
  INBOX_PANEL = 'inbox_panel',
22
22
  }
23
23
 
24
- export enum NotificationTriggerType {
25
- TIME_BASED = 'time_based',
26
- EVENT_BASED = 'event_based',
27
- RECURRING = 'recurring'
24
+ export enum NotificationSchedulerType {
25
+ DAY_TIME = 'day_time',
26
+ RELATIVE_DATE = 'relative_date',
28
27
  }
29
28
 
30
- export const notificationTriggerTypeSchema = z.nativeEnum(NotificationTriggerType);
31
-
32
- export const notificationTriggerSchema = z.object({
33
- type: notificationTriggerTypeSchema,
34
- });
29
+ export const notificationSchedulerDataSchema = z.discriminatedUnion('type', [
30
+ z.object({
31
+ type: z.literal(NotificationSchedulerType.DAY_TIME),
32
+ days: z.array(z.number().min(0).max(6)),
33
+ time: z.string().regex(/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/), // HH:mm format
34
+ }),
35
+ z.object({
36
+ type: z.literal(NotificationSchedulerType.RELATIVE_DATE),
37
+ date: z.string(),
38
+ offsetMinutes: z.number().int()
39
+ })
40
+ ])
35
41
 
36
42
  export const notificationTemplateSchema = z.object({
37
43
  _id: notificationTemplateIdSchema,
@@ -39,9 +45,8 @@ export const notificationTemplateSchema = z.object({
39
45
  targetLevel: z.nativeEnum(NotificationTemplateLevel),
40
46
  targetEntityType: z.nativeEnum(NotificationEntityType),
41
47
  targetId: z.string(),
42
- // entityType: z.nativeEnum(NotificationEntityType),
43
- // entityId: z.string().optional(),
44
- trigger: notificationTriggerSchema,
48
+ schedulerData: notificationSchedulerDataSchema,
49
+ variantData: z.any(),
45
50
  active: z.boolean(),
46
51
  createdAt: z.date(),
47
52
  updatedAt: z.date()
@@ -51,14 +56,14 @@ export const createNotificationTemplateRequestSchema = z.object({
51
56
  targetLevel: z.nativeEnum(NotificationTemplateLevel),
52
57
  targetEntityType: z.nativeEnum(NotificationEntityType),
53
58
  targetId: z.string().optional(),
54
- trigger: notificationTriggerSchema,
59
+ schedulerData: notificationSchedulerDataSchema,
60
+ variantData: z.any(),
55
61
  active: z.boolean().default(true)
56
62
  });
57
63
 
58
64
  export const updateNotificationTemplateRequestSchema = z.object({
59
- trigger: z.object({
60
- type: notificationTriggerTypeSchema,
61
- }).optional(),
65
+ schedulerData: notificationSchedulerDataSchema.optional(),
66
+ variantData: z.any().optional(),
62
67
  active: z.boolean().optional()
63
68
  });
64
69
 
@@ -73,7 +78,7 @@ export const getEntitySyncRequestSchema = z.object({
73
78
  targetId: z.string()
74
79
  });
75
80
 
76
- export type NotificationTrigger = z.infer<typeof notificationTriggerSchema>;
81
+ export type NotificationTrigger = z.infer<typeof notificationSchedulerDataSchema>;
77
82
  export type NotificationTemplateData = z.infer<typeof notificationTemplateSchema>;
78
83
 
79
84
  export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;