@timothyw/pat-common 1.0.149 → 1.0.151

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.
@@ -0,0 +1,12 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Read(//Users/timothy/Documents/_development/webstorm-projects/pat-app/src/**)",
5
+ "Read(//Users/timothy/Documents/_development/webstorm-projects/pat-app/**)",
6
+ "Read(//Users/timothy/Documents/_development/webstorm-projects/pat-api/server/src/notifications/**)",
7
+ "Read(//Users/timothy/Documents/_development/webstorm-projects/pat-api/server/src/**)"
8
+ ],
9
+ "deny": [],
10
+ "ask": []
11
+ }
12
+ }
@@ -19,15 +19,17 @@ export declare enum NotificationEntityType {
19
19
  AGENDA_ITEM = "agenda_item",
20
20
  HABIT = "habit",
21
21
  AGENDA_PANEL = "agenda_panel",
22
- INBOX_PANEL = "inbox_panel"
22
+ INBOX_PANEL = "inbox_panel",
23
+ HABIT_PANEL = "habit_panel"
23
24
  }
24
25
  export declare enum NotificationSchedulerType {
25
26
  DAY_TIME = "day_time",
26
27
  RELATIVE_DATE = "relative_date"
27
28
  }
28
29
  export declare enum NotificationVariantType {
29
- AGENDA_ITEM_UPCOMING_DEADLINE = "agenda_item_upcoming_deadline",
30
- HABIT_INCOMPLETE = "habit_incomplete"
30
+ AGENDA_ITEM_DUE = "agenda_item_due",
31
+ HABIT_TIMED_REMINDER = "habit_timed_reminder",
32
+ HABIT_DUE = "habit_due"
31
33
  }
32
34
  export declare const ENTITY_TYPE_VARIANT_MAP: Record<NotificationEntityType, NotificationVariantType[]>;
33
35
  export declare const notificationSchedulerDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
@@ -52,6 +54,25 @@ export declare const notificationSchedulerDataSchema: z.ZodDiscriminatedUnion<"t
52
54
  type: NotificationSchedulerType.RELATIVE_DATE;
53
55
  offsetMinutes: number;
54
56
  }>]>;
57
+ export declare const notificationVariantDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
58
+ type: z.ZodLiteral<NotificationVariantType.AGENDA_ITEM_DUE>;
59
+ }, "strip", z.ZodTypeAny, {
60
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
61
+ }, {
62
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
63
+ }>, z.ZodObject<{
64
+ type: z.ZodLiteral<NotificationVariantType.HABIT_TIMED_REMINDER>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
67
+ }, {
68
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
69
+ }>, z.ZodObject<{
70
+ type: z.ZodLiteral<NotificationVariantType.HABIT_DUE>;
71
+ }, "strip", z.ZodTypeAny, {
72
+ type: NotificationVariantType.HABIT_DUE;
73
+ }, {
74
+ type: NotificationVariantType.HABIT_DUE;
75
+ }>]>;
55
76
  export declare const notificationTemplateSchema: z.ZodObject<{
56
77
  _id: z.ZodEffects<z.ZodString, import("./id-types").NotificationTemplateId, string>;
57
78
  userId: z.ZodEffects<z.ZodString, import("./id-types").UserId, string>;
@@ -80,7 +101,25 @@ export declare const notificationTemplateSchema: z.ZodObject<{
80
101
  type: NotificationSchedulerType.RELATIVE_DATE;
81
102
  offsetMinutes: number;
82
103
  }>]>;
83
- variantData: z.ZodAny;
104
+ variantData: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
105
+ type: z.ZodLiteral<NotificationVariantType.AGENDA_ITEM_DUE>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
108
+ }, {
109
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
110
+ }>, z.ZodObject<{
111
+ type: z.ZodLiteral<NotificationVariantType.HABIT_TIMED_REMINDER>;
112
+ }, "strip", z.ZodTypeAny, {
113
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
114
+ }, {
115
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
116
+ }>, z.ZodObject<{
117
+ type: z.ZodLiteral<NotificationVariantType.HABIT_DUE>;
118
+ }, "strip", z.ZodTypeAny, {
119
+ type: NotificationVariantType.HABIT_DUE;
120
+ }, {
121
+ type: NotificationVariantType.HABIT_DUE;
122
+ }>]>;
84
123
  active: z.ZodBoolean;
85
124
  createdAt: z.ZodDate;
86
125
  updatedAt: z.ZodDate;
@@ -104,8 +143,14 @@ export declare const notificationTemplateSchema: z.ZodObject<{
104
143
  type: NotificationSchedulerType.RELATIVE_DATE;
105
144
  offsetMinutes: number;
106
145
  };
146
+ variantData: {
147
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
148
+ } | {
149
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
150
+ } | {
151
+ type: NotificationVariantType.HABIT_DUE;
152
+ };
107
153
  active: boolean;
108
- variantData?: any;
109
154
  }, {
110
155
  _id: string;
111
156
  createdAt: Date;
@@ -122,8 +167,14 @@ export declare const notificationTemplateSchema: z.ZodObject<{
122
167
  type: NotificationSchedulerType.RELATIVE_DATE;
123
168
  offsetMinutes: number;
124
169
  };
170
+ variantData: {
171
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
172
+ } | {
173
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
174
+ } | {
175
+ type: NotificationVariantType.HABIT_DUE;
176
+ };
125
177
  active: boolean;
126
- variantData?: any;
127
178
  }>;
128
179
  export declare const notificationDesyncSchema: z.ZodObject<{
129
180
  _id: z.ZodEffects<z.ZodString, import("./id-types").NotificationSyncId, string>;
@@ -174,7 +225,25 @@ export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
174
225
  type: NotificationSchedulerType.RELATIVE_DATE;
175
226
  offsetMinutes: number;
176
227
  }>]>;
177
- variantData: z.ZodAny;
228
+ variantData: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
229
+ type: z.ZodLiteral<NotificationVariantType.AGENDA_ITEM_DUE>;
230
+ }, "strip", z.ZodTypeAny, {
231
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
232
+ }, {
233
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
234
+ }>, z.ZodObject<{
235
+ type: z.ZodLiteral<NotificationVariantType.HABIT_TIMED_REMINDER>;
236
+ }, "strip", z.ZodTypeAny, {
237
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
238
+ }, {
239
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
240
+ }>, z.ZodObject<{
241
+ type: z.ZodLiteral<NotificationVariantType.HABIT_DUE>;
242
+ }, "strip", z.ZodTypeAny, {
243
+ type: NotificationVariantType.HABIT_DUE;
244
+ }, {
245
+ type: NotificationVariantType.HABIT_DUE;
246
+ }>]>;
178
247
  active: z.ZodDefault<z.ZodBoolean>;
179
248
  }, "strip", z.ZodTypeAny, {
180
249
  targetLevel: NotificationTemplateLevel;
@@ -187,9 +256,15 @@ export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
187
256
  type: NotificationSchedulerType.RELATIVE_DATE;
188
257
  offsetMinutes: number;
189
258
  };
259
+ variantData: {
260
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
261
+ } | {
262
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
263
+ } | {
264
+ type: NotificationVariantType.HABIT_DUE;
265
+ };
190
266
  active: boolean;
191
267
  targetId?: string | undefined;
192
- variantData?: any;
193
268
  }, {
194
269
  targetLevel: NotificationTemplateLevel;
195
270
  targetEntityType: NotificationEntityType;
@@ -201,8 +276,14 @@ export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
201
276
  type: NotificationSchedulerType.RELATIVE_DATE;
202
277
  offsetMinutes: number;
203
278
  };
279
+ variantData: {
280
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
281
+ } | {
282
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
283
+ } | {
284
+ type: NotificationVariantType.HABIT_DUE;
285
+ };
204
286
  targetId?: string | undefined;
205
- variantData?: any;
206
287
  active?: boolean | undefined;
207
288
  }>;
208
289
  export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
@@ -228,7 +309,25 @@ export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
228
309
  type: NotificationSchedulerType.RELATIVE_DATE;
229
310
  offsetMinutes: number;
230
311
  }>]>>;
231
- variantData: z.ZodOptional<z.ZodAny>;
312
+ variantData: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
313
+ type: z.ZodLiteral<NotificationVariantType.AGENDA_ITEM_DUE>;
314
+ }, "strip", z.ZodTypeAny, {
315
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
316
+ }, {
317
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
318
+ }>, z.ZodObject<{
319
+ type: z.ZodLiteral<NotificationVariantType.HABIT_TIMED_REMINDER>;
320
+ }, "strip", z.ZodTypeAny, {
321
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
322
+ }, {
323
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
324
+ }>, z.ZodObject<{
325
+ type: z.ZodLiteral<NotificationVariantType.HABIT_DUE>;
326
+ }, "strip", z.ZodTypeAny, {
327
+ type: NotificationVariantType.HABIT_DUE;
328
+ }, {
329
+ type: NotificationVariantType.HABIT_DUE;
330
+ }>]>>;
232
331
  active: z.ZodOptional<z.ZodBoolean>;
233
332
  }, "strip", z.ZodTypeAny, {
234
333
  schedulerData?: {
@@ -239,7 +338,13 @@ export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
239
338
  type: NotificationSchedulerType.RELATIVE_DATE;
240
339
  offsetMinutes: number;
241
340
  } | undefined;
242
- variantData?: any;
341
+ variantData?: {
342
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
343
+ } | {
344
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
345
+ } | {
346
+ type: NotificationVariantType.HABIT_DUE;
347
+ } | undefined;
243
348
  active?: boolean | undefined;
244
349
  }, {
245
350
  schedulerData?: {
@@ -250,7 +355,13 @@ export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
250
355
  type: NotificationSchedulerType.RELATIVE_DATE;
251
356
  offsetMinutes: number;
252
357
  } | undefined;
253
- variantData?: any;
358
+ variantData?: {
359
+ type: NotificationVariantType.AGENDA_ITEM_DUE;
360
+ } | {
361
+ type: NotificationVariantType.HABIT_TIMED_REMINDER;
362
+ } | {
363
+ type: NotificationVariantType.HABIT_DUE;
364
+ } | undefined;
254
365
  active?: boolean | undefined;
255
366
  }>;
256
367
  export declare const getEntitySyncRequestSchema: z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setEntitySyncRequestSchema = exports.getEntitySyncRequestSchema = exports.updateNotificationTemplateRequestSchema = exports.createNotificationTemplateRequestSchema = exports.notificationDesyncSchema = exports.notificationTemplateSchema = exports.notificationSchedulerDataSchema = exports.ENTITY_TYPE_VARIANT_MAP = exports.NotificationVariantType = exports.NotificationSchedulerType = exports.NotificationEntityType = exports.NotificationTemplateLevel = exports.NotificationTemplateSyncState = void 0;
3
+ exports.setEntitySyncRequestSchema = exports.getEntitySyncRequestSchema = exports.updateNotificationTemplateRequestSchema = exports.createNotificationTemplateRequestSchema = exports.notificationDesyncSchema = exports.notificationTemplateSchema = exports.notificationVariantDataSchema = exports.notificationSchedulerDataSchema = exports.ENTITY_TYPE_VARIANT_MAP = exports.NotificationVariantType = exports.NotificationSchedulerType = exports.NotificationEntityType = exports.NotificationTemplateLevel = exports.NotificationTemplateSyncState = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const id_types_1 = require("./id-types");
6
6
  var NotificationTemplateSyncState;
@@ -20,6 +20,7 @@ var NotificationEntityType;
20
20
  NotificationEntityType["HABIT"] = "habit";
21
21
  NotificationEntityType["AGENDA_PANEL"] = "agenda_panel";
22
22
  NotificationEntityType["INBOX_PANEL"] = "inbox_panel";
23
+ NotificationEntityType["HABIT_PANEL"] = "habit_panel";
23
24
  })(NotificationEntityType || (exports.NotificationEntityType = NotificationEntityType = {}));
24
25
  var NotificationSchedulerType;
25
26
  (function (NotificationSchedulerType) {
@@ -28,18 +29,21 @@ var NotificationSchedulerType;
28
29
  })(NotificationSchedulerType || (exports.NotificationSchedulerType = NotificationSchedulerType = {}));
29
30
  var NotificationVariantType;
30
31
  (function (NotificationVariantType) {
31
- NotificationVariantType["AGENDA_ITEM_UPCOMING_DEADLINE"] = "agenda_item_upcoming_deadline";
32
- NotificationVariantType["HABIT_INCOMPLETE"] = "habit_incomplete";
32
+ NotificationVariantType["AGENDA_ITEM_DUE"] = "agenda_item_due";
33
+ NotificationVariantType["HABIT_TIMED_REMINDER"] = "habit_timed_reminder";
34
+ NotificationVariantType["HABIT_DUE"] = "habit_due";
33
35
  })(NotificationVariantType || (exports.NotificationVariantType = NotificationVariantType = {}));
34
36
  exports.ENTITY_TYPE_VARIANT_MAP = {
35
37
  [NotificationEntityType.AGENDA_ITEM]: [
36
- NotificationVariantType.AGENDA_ITEM_UPCOMING_DEADLINE,
38
+ NotificationVariantType.AGENDA_ITEM_DUE,
37
39
  ],
38
40
  [NotificationEntityType.HABIT]: [
39
- NotificationVariantType.HABIT_INCOMPLETE,
41
+ NotificationVariantType.HABIT_TIMED_REMINDER,
42
+ NotificationVariantType.HABIT_DUE,
40
43
  ],
41
44
  [NotificationEntityType.AGENDA_PANEL]: [],
42
45
  [NotificationEntityType.INBOX_PANEL]: [],
46
+ [NotificationEntityType.HABIT_PANEL]: [],
43
47
  };
44
48
  exports.notificationSchedulerDataSchema = zod_1.z.discriminatedUnion('type', [
45
49
  zod_1.z.object({
@@ -52,6 +56,17 @@ exports.notificationSchedulerDataSchema = zod_1.z.discriminatedUnion('type', [
52
56
  offsetMinutes: zod_1.z.number().int()
53
57
  })
54
58
  ]);
59
+ exports.notificationVariantDataSchema = zod_1.z.discriminatedUnion('type', [
60
+ zod_1.z.object({
61
+ type: zod_1.z.literal(NotificationVariantType.AGENDA_ITEM_DUE),
62
+ }),
63
+ zod_1.z.object({
64
+ type: zod_1.z.literal(NotificationVariantType.HABIT_TIMED_REMINDER),
65
+ }),
66
+ zod_1.z.object({
67
+ type: zod_1.z.literal(NotificationVariantType.HABIT_DUE),
68
+ })
69
+ ]);
55
70
  exports.notificationTemplateSchema = zod_1.z.object({
56
71
  _id: id_types_1.notificationTemplateIdSchema,
57
72
  userId: id_types_1.userIdSchema,
@@ -59,7 +74,7 @@ exports.notificationTemplateSchema = zod_1.z.object({
59
74
  targetEntityType: zod_1.z.nativeEnum(NotificationEntityType),
60
75
  targetId: zod_1.z.string(),
61
76
  schedulerData: exports.notificationSchedulerDataSchema,
62
- variantData: zod_1.z.any(),
77
+ variantData: exports.notificationVariantDataSchema,
63
78
  active: zod_1.z.boolean(),
64
79
  createdAt: zod_1.z.date(),
65
80
  updatedAt: zod_1.z.date()
@@ -76,12 +91,12 @@ exports.createNotificationTemplateRequestSchema = zod_1.z.object({
76
91
  targetEntityType: zod_1.z.nativeEnum(NotificationEntityType),
77
92
  targetId: zod_1.z.string().optional(),
78
93
  schedulerData: exports.notificationSchedulerDataSchema,
79
- variantData: zod_1.z.any(),
94
+ variantData: exports.notificationVariantDataSchema,
80
95
  active: zod_1.z.boolean().default(true)
81
96
  });
82
97
  exports.updateNotificationTemplateRequestSchema = zod_1.z.object({
83
98
  schedulerData: exports.notificationSchedulerDataSchema.optional(),
84
- variantData: zod_1.z.any().optional(),
99
+ variantData: exports.notificationVariantDataSchema.optional(),
85
100
  active: zod_1.z.boolean().optional()
86
101
  });
87
102
  exports.getEntitySyncRequestSchema = 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.149",
5
+ "version": "1.0.151",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
@@ -26,6 +26,7 @@ export enum NotificationEntityType {
26
26
 
27
27
  AGENDA_PANEL = 'agenda_panel',
28
28
  INBOX_PANEL = 'inbox_panel',
29
+ HABIT_PANEL = 'habit_panel',
29
30
  }
30
31
 
31
32
  export enum NotificationSchedulerType {
@@ -34,19 +35,22 @@ export enum NotificationSchedulerType {
34
35
  }
35
36
 
36
37
  export enum NotificationVariantType {
37
- AGENDA_ITEM_UPCOMING_DEADLINE = 'agenda_item_upcoming_deadline',
38
- HABIT_INCOMPLETE = 'habit_incomplete',
38
+ AGENDA_ITEM_DUE = 'agenda_item_due',
39
+ HABIT_TIMED_REMINDER = 'habit_timed_reminder',
40
+ HABIT_DUE = 'habit_due',
39
41
  }
40
42
 
41
43
  export const ENTITY_TYPE_VARIANT_MAP: Record<NotificationEntityType, NotificationVariantType[]> = {
42
44
  [NotificationEntityType.AGENDA_ITEM]: [
43
- NotificationVariantType.AGENDA_ITEM_UPCOMING_DEADLINE,
45
+ NotificationVariantType.AGENDA_ITEM_DUE,
44
46
  ],
45
47
  [NotificationEntityType.HABIT]: [
46
- NotificationVariantType.HABIT_INCOMPLETE,
48
+ NotificationVariantType.HABIT_TIMED_REMINDER,
49
+ NotificationVariantType.HABIT_DUE,
47
50
  ],
48
51
  [NotificationEntityType.AGENDA_PANEL]: [],
49
52
  [NotificationEntityType.INBOX_PANEL]: [],
53
+ [NotificationEntityType.HABIT_PANEL]: [],
50
54
  } as const;
51
55
 
52
56
  export const notificationSchedulerDataSchema = z.discriminatedUnion('type', [
@@ -59,7 +63,19 @@ export const notificationSchedulerDataSchema = z.discriminatedUnion('type', [
59
63
  type: z.literal(NotificationSchedulerType.RELATIVE_DATE),
60
64
  offsetMinutes: z.number().int()
61
65
  })
62
- ])
66
+ ]);
67
+
68
+ export const notificationVariantDataSchema = z.discriminatedUnion('type', [
69
+ z.object({
70
+ type: z.literal(NotificationVariantType.AGENDA_ITEM_DUE),
71
+ }),
72
+ z.object({
73
+ type: z.literal(NotificationVariantType.HABIT_TIMED_REMINDER),
74
+ }),
75
+ z.object({
76
+ type: z.literal(NotificationVariantType.HABIT_DUE),
77
+ })
78
+ ]);
63
79
 
64
80
  export const notificationTemplateSchema = z.object({
65
81
  _id: notificationTemplateIdSchema,
@@ -68,7 +84,7 @@ export const notificationTemplateSchema = z.object({
68
84
  targetEntityType: z.nativeEnum(NotificationEntityType),
69
85
  targetId: z.string(),
70
86
  schedulerData: notificationSchedulerDataSchema,
71
- variantData: z.any(),
87
+ variantData: notificationVariantDataSchema,
72
88
  active: z.boolean(),
73
89
  createdAt: z.date(),
74
90
  updatedAt: z.date()
@@ -87,13 +103,13 @@ export const createNotificationTemplateRequestSchema = z.object({
87
103
  targetEntityType: z.nativeEnum(NotificationEntityType),
88
104
  targetId: z.string().optional(),
89
105
  schedulerData: notificationSchedulerDataSchema,
90
- variantData: z.any(),
106
+ variantData: notificationVariantDataSchema,
91
107
  active: z.boolean().default(true)
92
108
  });
93
109
 
94
110
  export const updateNotificationTemplateRequestSchema = z.object({
95
111
  schedulerData: notificationSchedulerDataSchema.optional(),
96
- variantData: z.any().optional(),
112
+ variantData: notificationVariantDataSchema.optional(),
97
113
  active: z.boolean().optional()
98
114
  });
99
115