@timothyw/pat-common 1.0.148 → 1.0.150

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