@timothyw/pat-common 1.0.116 → 1.0.118

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.
@@ -112,5 +112,4 @@ export interface CompleteAgendaItemResponse {
112
112
  agendaItem: Serialized<AgendaItemData>;
113
113
  }
114
114
  export interface DeleteAgendaItemResponse {
115
- deleted: boolean;
116
115
  }
@@ -307,11 +307,9 @@ export interface UpdateHabitResponse {
307
307
  habit: Serialized<Habit>;
308
308
  }
309
309
  export interface DeleteHabitResponse {
310
- deleted: boolean;
311
310
  }
312
311
  export interface CreateHabitEntryResponse {
313
312
  habit: Serialized<Habit>;
314
313
  }
315
314
  export interface DeleteHabitEntryResponse {
316
- habit: Serialized<Habit>;
317
315
  }
@@ -142,7 +142,6 @@ export interface UpdateListResponse {
142
142
  list: Serialized<ListData>;
143
143
  }
144
144
  export interface DeleteListResponse {
145
- deleted: boolean;
146
145
  }
147
146
  export interface CreateListItemResponse {
148
147
  listItem: Serialized<ListItemData>;
@@ -160,5 +159,4 @@ export interface CompleteListItemResponse {
160
159
  listItem: Serialized<ListItemData>;
161
160
  }
162
161
  export interface DeleteListItemResponse {
163
- deleted: boolean;
164
162
  }
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { Serialized } from '../../utils';
3
3
  export declare const notificationEntityTypeSchema: z.ZodEnum<["agenda", "tasks", "habits", "inbox", "agenda_item", "habit", "agenda_defaults", "habits_defaults"]>;
4
+ export declare const notificationStatusSchema: z.ZodEnum<["scheduled", "sent", "failed", "cancelled"]>;
4
5
  export declare const notificationTriggerTypeSchema: z.ZodEnum<["time_based", "event_based", "recurring"]>;
5
6
  export declare const notificationTriggerSchema: z.ZodObject<{
6
7
  type: z.ZodEnum<["time_based", "event_based", "recurring"]>;
@@ -215,6 +216,72 @@ export declare const entitySyncStateSchema: z.ZodObject<{
215
216
  entityId: string;
216
217
  synced: boolean;
217
218
  }>;
219
+ export declare const notificationInstanceSchema: z.ZodObject<{
220
+ _id: z.ZodEffects<z.ZodString, import("../id-types").NotificationInstanceId, string>;
221
+ templateId: z.ZodEffects<z.ZodString, import("../id-types").NotificationTemplateId, string>;
222
+ userId: z.ZodEffects<z.ZodString, import("../id-types").UserId, string>;
223
+ entityId: z.ZodString;
224
+ scheduledFor: z.ZodDate;
225
+ status: z.ZodEnum<["scheduled", "sent", "failed", "cancelled"]>;
226
+ sentAt: z.ZodOptional<z.ZodDate>;
227
+ content: z.ZodObject<{
228
+ title: z.ZodString;
229
+ body: z.ZodString;
230
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
231
+ }, "strip", z.ZodTypeAny, {
232
+ title: string;
233
+ body: string;
234
+ data?: Record<string, any> | undefined;
235
+ }, {
236
+ title: string;
237
+ body: string;
238
+ data?: Record<string, any> | undefined;
239
+ }>;
240
+ redisId: z.ZodString;
241
+ error: z.ZodOptional<z.ZodString>;
242
+ createdAt: z.ZodDate;
243
+ updatedAt: z.ZodDate;
244
+ }, "strip", z.ZodTypeAny, {
245
+ _id: string & {
246
+ readonly __brand: "NotificationInstanceId";
247
+ };
248
+ createdAt: Date;
249
+ updatedAt: Date;
250
+ userId: string & {
251
+ readonly __brand: "UserId";
252
+ };
253
+ status: "scheduled" | "sent" | "failed" | "cancelled";
254
+ content: {
255
+ title: string;
256
+ body: string;
257
+ data?: Record<string, any> | undefined;
258
+ };
259
+ entityId: string;
260
+ templateId: string & {
261
+ readonly __brand: "NotificationTemplateId";
262
+ };
263
+ scheduledFor: Date;
264
+ redisId: string;
265
+ sentAt?: Date | undefined;
266
+ error?: string | undefined;
267
+ }, {
268
+ _id: string;
269
+ createdAt: Date;
270
+ updatedAt: Date;
271
+ userId: string;
272
+ status: "scheduled" | "sent" | "failed" | "cancelled";
273
+ content: {
274
+ title: string;
275
+ body: string;
276
+ data?: Record<string, any> | undefined;
277
+ };
278
+ entityId: string;
279
+ templateId: string;
280
+ scheduledFor: Date;
281
+ redisId: string;
282
+ sentAt?: Date | undefined;
283
+ error?: string | undefined;
284
+ }>;
218
285
  export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
219
286
  entityType: z.ZodEnum<["agenda", "tasks", "habits", "inbox", "agenda_item", "habit", "agenda_defaults", "habits_defaults"]>;
220
287
  entityId: z.ZodOptional<z.ZodString>;
@@ -349,38 +416,64 @@ export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
349
416
  customized?: boolean | undefined;
350
417
  }>;
351
418
  export declare const syncNotificationTemplateRequestSchema: z.ZodObject<{
352
- entityType: z.ZodEnum<["agenda", "tasks", "habits", "inbox", "agenda_item", "habit", "agenda_defaults", "habits_defaults"]>;
419
+ sync: z.ZodBoolean;
420
+ }, "strip", z.ZodTypeAny, {
421
+ sync: boolean;
422
+ }, {
423
+ sync: boolean;
424
+ }>;
425
+ export declare const previewNotificationTemplateRequestSchema: z.ZodObject<{
426
+ templateTitle: z.ZodString;
427
+ templateBody: z.ZodString;
428
+ entityType: z.ZodString;
353
429
  entityId: z.ZodString;
430
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
354
431
  }, "strip", z.ZodTypeAny, {
355
- entityType: "agenda" | "inbox" | "habits" | "tasks" | "agenda_item" | "habit" | "agenda_defaults" | "habits_defaults";
432
+ entityType: string;
356
433
  entityId: string;
434
+ templateTitle: string;
435
+ templateBody: string;
436
+ variables?: Record<string, any> | undefined;
357
437
  }, {
358
- entityType: "agenda" | "inbox" | "habits" | "tasks" | "agenda_item" | "habit" | "agenda_defaults" | "habits_defaults";
438
+ entityType: string;
359
439
  entityId: string;
440
+ templateTitle: string;
441
+ templateBody: string;
442
+ variables?: Record<string, any> | undefined;
360
443
  }>;
361
- export declare const previewNotificationTemplateRequestSchema: z.ZodObject<{
362
- templateId: z.ZodEffects<z.ZodString, import("../id-types").NotificationTemplateId, string>;
363
- entityData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
444
+ export declare const getNotificationInstancesRequestSchema: z.ZodObject<{
445
+ status: z.ZodOptional<z.ZodString>;
446
+ templateId: z.ZodOptional<z.ZodString>;
447
+ entityId: z.ZodOptional<z.ZodString>;
448
+ limit: z.ZodOptional<z.ZodNumber>;
449
+ offset: z.ZodOptional<z.ZodNumber>;
364
450
  }, "strip", z.ZodTypeAny, {
365
- templateId: string & {
366
- readonly __brand: "NotificationTemplateId";
367
- };
368
- entityData?: Record<string, any> | undefined;
451
+ status?: string | undefined;
452
+ entityId?: string | undefined;
453
+ templateId?: string | undefined;
454
+ limit?: number | undefined;
455
+ offset?: number | undefined;
369
456
  }, {
370
- templateId: string;
371
- entityData?: Record<string, any> | undefined;
457
+ status?: string | undefined;
458
+ entityId?: string | undefined;
459
+ templateId?: string | undefined;
460
+ limit?: number | undefined;
461
+ offset?: number | undefined;
372
462
  }>;
373
463
  export type NotificationEntityType = z.infer<typeof notificationEntityTypeSchema>;
374
464
  export type NotificationTriggerType = z.infer<typeof notificationTriggerTypeSchema>;
465
+ export type NotificationStatus = z.infer<typeof notificationStatusSchema>;
375
466
  export type NotificationTrigger = z.infer<typeof notificationTriggerSchema>;
376
467
  export type NotificationContent = z.infer<typeof notificationContentSchema>;
377
468
  export type NotificationTemplateData = z.infer<typeof notificationTemplateSchema>;
378
469
  export type CreateNotificationTemplateData = z.infer<typeof createNotificationTemplateSchema>;
379
470
  export type EntitySyncState = z.infer<typeof entitySyncStateSchema>;
471
+ export type NotificationInstanceData = z.infer<typeof notificationInstanceSchema>;
380
472
  export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;
381
473
  export type UpdateNotificationTemplateRequest = z.infer<typeof updateNotificationTemplateRequestSchema>;
382
474
  export type SyncNotificationTemplateRequest = z.infer<typeof syncNotificationTemplateRequestSchema>;
383
475
  export type PreviewNotificationTemplateRequest = z.infer<typeof previewNotificationTemplateRequestSchema>;
476
+ export type GetNotificationInstancesRequest = z.infer<typeof getNotificationInstancesRequestSchema>;
384
477
  export interface CreateNotificationTemplateResponse {
385
478
  template: Serialized<NotificationTemplateData>;
386
479
  }
@@ -394,7 +487,6 @@ export interface UpdateNotificationTemplateResponse {
394
487
  template: Serialized<NotificationTemplateData>;
395
488
  }
396
489
  export interface DeleteNotificationTemplateResponse {
397
- deleted: boolean;
398
490
  }
399
491
  export interface SyncNotificationTemplateResponse {
400
492
  synced: boolean;
@@ -403,5 +495,13 @@ export interface PreviewNotificationTemplateResponse {
403
495
  preview: {
404
496
  title: string;
405
497
  body: string;
498
+ variables: Record<string, any>;
406
499
  };
500
+ missingVariables: string[];
501
+ }
502
+ export interface GetNotificationInstancesResponse {
503
+ success: boolean;
504
+ instances?: Serialized<NotificationInstanceData>[];
505
+ total?: number;
506
+ error?: string;
407
507
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.previewNotificationTemplateRequestSchema = exports.syncNotificationTemplateRequestSchema = exports.updateNotificationTemplateRequestSchema = exports.createNotificationTemplateRequestSchema = exports.entitySyncStateSchema = exports.createNotificationTemplateSchema = exports.notificationTemplateSchema = exports.notificationContentSchema = exports.notificationTriggerSchema = exports.notificationTriggerTypeSchema = exports.notificationEntityTypeSchema = void 0;
3
+ 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.notificationEntityTypeSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const id_types_1 = require("../id-types");
6
6
  exports.notificationEntityTypeSchema = zod_1.z.enum([
@@ -8,6 +8,7 @@ exports.notificationEntityTypeSchema = zod_1.z.enum([
8
8
  'agenda_item', 'habit',
9
9
  'agenda_defaults', 'habits_defaults'
10
10
  ]);
11
+ exports.notificationStatusSchema = zod_1.z.enum(['scheduled', 'sent', 'failed', 'cancelled']);
11
12
  exports.notificationTriggerTypeSchema = zod_1.z.enum(['time_based', 'event_based', 'recurring']);
12
13
  exports.notificationTriggerSchema = zod_1.z.object({
13
14
  type: exports.notificationTriggerTypeSchema,
@@ -46,6 +47,24 @@ exports.entitySyncStateSchema = zod_1.z.object({
46
47
  synced: zod_1.z.boolean(),
47
48
  updatedAt: zod_1.z.date()
48
49
  });
50
+ exports.notificationInstanceSchema = zod_1.z.object({
51
+ _id: id_types_1.notificationInstanceIdSchema,
52
+ templateId: id_types_1.notificationTemplateIdSchema,
53
+ userId: id_types_1.userIdSchema,
54
+ entityId: zod_1.z.string(),
55
+ scheduledFor: zod_1.z.date(),
56
+ status: exports.notificationStatusSchema,
57
+ sentAt: zod_1.z.date().optional(),
58
+ content: zod_1.z.object({
59
+ title: zod_1.z.string(),
60
+ body: zod_1.z.string(),
61
+ data: zod_1.z.record(zod_1.z.any()).optional()
62
+ }),
63
+ redisId: zod_1.z.string(),
64
+ error: zod_1.z.string().optional(),
65
+ createdAt: zod_1.z.date(),
66
+ updatedAt: zod_1.z.date()
67
+ });
49
68
  exports.createNotificationTemplateRequestSchema = zod_1.z.object({
50
69
  entityType: exports.notificationEntityTypeSchema,
51
70
  entityId: zod_1.z.string().optional(),
@@ -82,10 +101,19 @@ exports.updateNotificationTemplateRequestSchema = zod_1.z.object({
82
101
  customized: zod_1.z.boolean().optional()
83
102
  });
84
103
  exports.syncNotificationTemplateRequestSchema = zod_1.z.object({
85
- entityType: exports.notificationEntityTypeSchema,
86
- entityId: zod_1.z.string()
104
+ sync: zod_1.z.boolean()
87
105
  });
88
106
  exports.previewNotificationTemplateRequestSchema = zod_1.z.object({
89
- templateId: id_types_1.notificationTemplateIdSchema,
90
- entityData: zod_1.z.record(zod_1.z.any()).optional()
107
+ templateTitle: zod_1.z.string(),
108
+ templateBody: zod_1.z.string(),
109
+ entityType: zod_1.z.string(),
110
+ entityId: zod_1.z.string(),
111
+ variables: zod_1.z.record(zod_1.z.any()).optional()
112
+ });
113
+ exports.getNotificationInstancesRequestSchema = zod_1.z.object({
114
+ status: zod_1.z.string().optional(),
115
+ templateId: zod_1.z.string().optional(),
116
+ entityId: zod_1.z.string().optional(),
117
+ limit: zod_1.z.number().optional(),
118
+ offset: zod_1.z.number().optional()
91
119
  });
@@ -269,7 +269,6 @@ export interface UpdatePersonResponse {
269
269
  person: Serialized<Person>;
270
270
  }
271
271
  export interface DeletePersonResponse {
272
- deleted: boolean;
273
272
  }
274
273
  export interface CreatePersonNoteResponse {
275
274
  personNote: Serialized<PersonNoteData>;
@@ -281,5 +280,4 @@ export interface UpdatePersonNoteResponse {
281
280
  personNote: Serialized<PersonNoteData>;
282
281
  }
283
282
  export interface DeletePersonNoteResponse {
284
- deleted: boolean;
285
283
  }
@@ -53,5 +53,4 @@ export interface UpdateThoughtResponse {
53
53
  thought: Serialized<ThoughtData>;
54
54
  }
55
55
  export interface DeleteThoughtResponse {
56
- deleted: boolean;
57
56
  }
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.116",
5
+ "version": "1.0.118",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
@@ -64,6 +64,4 @@ export interface CompleteAgendaItemResponse {
64
64
  agendaItem: Serialized<AgendaItemData>;
65
65
  }
66
66
 
67
- export interface DeleteAgendaItemResponse {
68
- deleted: boolean;
69
- }
67
+ export interface DeleteAgendaItemResponse {}
@@ -99,14 +99,10 @@ export interface UpdateHabitResponse {
99
99
  habit: Serialized<Habit>;
100
100
  }
101
101
 
102
- export interface DeleteHabitResponse {
103
- deleted: boolean;
104
- }
102
+ export interface DeleteHabitResponse {}
105
103
 
106
104
  export interface CreateHabitEntryResponse {
107
105
  habit: Serialized<Habit>;
108
106
  }
109
107
 
110
- export interface DeleteHabitEntryResponse {
111
- habit: Serialized<Habit>;
112
- }
108
+ export interface DeleteHabitEntryResponse {}
@@ -79,9 +79,7 @@ export interface UpdateListResponse {
79
79
  list: Serialized<ListData>;
80
80
  }
81
81
 
82
- export interface DeleteListResponse {
83
- deleted: boolean;
84
- }
82
+ export interface DeleteListResponse {}
85
83
 
86
84
  export interface CreateListItemResponse {
87
85
  listItem: Serialized<ListItemData>;
@@ -103,6 +101,4 @@ export interface CompleteListItemResponse {
103
101
  listItem: Serialized<ListItemData>;
104
102
  }
105
103
 
106
- export interface DeleteListItemResponse {
107
- deleted: boolean;
108
- }
104
+ export interface DeleteListItemResponse {}
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { notificationTemplateIdSchema, userIdSchema } from '../id-types';
2
+ import { notificationTemplateIdSchema, notificationInstanceIdSchema, userIdSchema } from '../id-types';
3
3
  import { Serialized } from '../../utils';
4
4
 
5
5
  export const notificationEntityTypeSchema = z.enum([
@@ -8,6 +8,8 @@ export const notificationEntityTypeSchema = z.enum([
8
8
  'agenda_defaults', 'habits_defaults'
9
9
  ]);
10
10
 
11
+ export const notificationStatusSchema = z.enum(['scheduled', 'sent', 'failed', 'cancelled']);
12
+
11
13
  export const notificationTriggerTypeSchema = z.enum(['time_based', 'event_based', 'recurring']);
12
14
 
13
15
  export const notificationTriggerSchema = z.object({
@@ -52,6 +54,25 @@ export const entitySyncStateSchema = z.object({
52
54
  updatedAt: z.date()
53
55
  });
54
56
 
57
+ export const notificationInstanceSchema = z.object({
58
+ _id: notificationInstanceIdSchema,
59
+ templateId: notificationTemplateIdSchema,
60
+ userId: userIdSchema,
61
+ entityId: z.string(),
62
+ scheduledFor: z.date(),
63
+ status: notificationStatusSchema,
64
+ sentAt: z.date().optional(),
65
+ content: z.object({
66
+ title: z.string(),
67
+ body: z.string(),
68
+ data: z.record(z.any()).optional()
69
+ }),
70
+ redisId: z.string(),
71
+ error: z.string().optional(),
72
+ createdAt: z.date(),
73
+ updatedAt: z.date()
74
+ });
75
+
55
76
  export const createNotificationTemplateRequestSchema = z.object({
56
77
  entityType: notificationEntityTypeSchema,
57
78
  entityId: z.string().optional(),
@@ -90,27 +111,40 @@ export const updateNotificationTemplateRequestSchema = z.object({
90
111
  });
91
112
 
92
113
  export const syncNotificationTemplateRequestSchema = z.object({
93
- entityType: notificationEntityTypeSchema,
94
- entityId: z.string()
114
+ sync: z.boolean()
95
115
  });
96
116
 
97
117
  export const previewNotificationTemplateRequestSchema = z.object({
98
- templateId: notificationTemplateIdSchema,
99
- entityData: z.record(z.any()).optional()
118
+ templateTitle: z.string(),
119
+ templateBody: z.string(),
120
+ entityType: z.string(),
121
+ entityId: z.string(),
122
+ variables: z.record(z.any()).optional()
123
+ });
124
+
125
+ export const getNotificationInstancesRequestSchema = z.object({
126
+ status: z.string().optional(),
127
+ templateId: z.string().optional(),
128
+ entityId: z.string().optional(),
129
+ limit: z.number().optional(),
130
+ offset: z.number().optional()
100
131
  });
101
132
 
102
133
  export type NotificationEntityType = z.infer<typeof notificationEntityTypeSchema>;
103
134
  export type NotificationTriggerType = z.infer<typeof notificationTriggerTypeSchema>;
135
+ export type NotificationStatus = z.infer<typeof notificationStatusSchema>;
104
136
  export type NotificationTrigger = z.infer<typeof notificationTriggerSchema>;
105
137
  export type NotificationContent = z.infer<typeof notificationContentSchema>;
106
138
  export type NotificationTemplateData = z.infer<typeof notificationTemplateSchema>;
107
139
  export type CreateNotificationTemplateData = z.infer<typeof createNotificationTemplateSchema>;
108
140
  export type EntitySyncState = z.infer<typeof entitySyncStateSchema>;
141
+ export type NotificationInstanceData = z.infer<typeof notificationInstanceSchema>;
109
142
 
110
143
  export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;
111
144
  export type UpdateNotificationTemplateRequest = z.infer<typeof updateNotificationTemplateRequestSchema>;
112
145
  export type SyncNotificationTemplateRequest = z.infer<typeof syncNotificationTemplateRequestSchema>;
113
146
  export type PreviewNotificationTemplateRequest = z.infer<typeof previewNotificationTemplateRequestSchema>;
147
+ export type GetNotificationInstancesRequest = z.infer<typeof getNotificationInstancesRequestSchema>;
114
148
 
115
149
  export interface CreateNotificationTemplateResponse {
116
150
  template: Serialized<NotificationTemplateData>;
@@ -128,9 +162,7 @@ export interface UpdateNotificationTemplateResponse {
128
162
  template: Serialized<NotificationTemplateData>;
129
163
  }
130
164
 
131
- export interface DeleteNotificationTemplateResponse {
132
- deleted: boolean;
133
- }
165
+ export interface DeleteNotificationTemplateResponse {}
134
166
 
135
167
  export interface SyncNotificationTemplateResponse {
136
168
  synced: boolean;
@@ -140,5 +172,14 @@ export interface PreviewNotificationTemplateResponse {
140
172
  preview: {
141
173
  title: string;
142
174
  body: string;
175
+ variables: Record<string, any>;
143
176
  };
177
+ missingVariables: string[];
178
+ }
179
+
180
+ export interface GetNotificationInstancesResponse {
181
+ success: boolean;
182
+ instances?: Serialized<NotificationInstanceData>[];
183
+ total?: number;
184
+ error?: string;
144
185
  }
@@ -89,9 +89,7 @@ export interface UpdatePersonResponse {
89
89
  person: Serialized<Person>;
90
90
  }
91
91
 
92
- export interface DeletePersonResponse {
93
- deleted: boolean;
94
- }
92
+ export interface DeletePersonResponse {}
95
93
 
96
94
  export interface CreatePersonNoteResponse {
97
95
  personNote: Serialized<PersonNoteData>;
@@ -105,6 +103,4 @@ export interface UpdatePersonNoteResponse {
105
103
  personNote: Serialized<PersonNoteData>;
106
104
  }
107
105
 
108
- export interface DeletePersonNoteResponse {
109
- deleted: boolean;
110
- }
106
+ export interface DeletePersonNoteResponse {}
@@ -39,6 +39,4 @@ export interface UpdateThoughtResponse {
39
39
  thought: Serialized<ThoughtData>;
40
40
  }
41
41
 
42
- export interface DeleteThoughtResponse {
43
- deleted: boolean;
44
- }
42
+ export interface DeleteThoughtResponse {}