@timothyw/pat-common 1.0.115 → 1.0.117
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.
|
@@ -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
|
-
|
|
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:
|
|
432
|
+
entityType: string;
|
|
356
433
|
entityId: string;
|
|
434
|
+
templateTitle: string;
|
|
435
|
+
templateBody: string;
|
|
436
|
+
variables?: Record<string, any> | undefined;
|
|
357
437
|
}, {
|
|
358
|
-
entityType:
|
|
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
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
451
|
+
status?: string | undefined;
|
|
452
|
+
entityId?: string | undefined;
|
|
453
|
+
templateId?: string | undefined;
|
|
454
|
+
limit?: number | undefined;
|
|
455
|
+
offset?: number | undefined;
|
|
369
456
|
}, {
|
|
370
|
-
|
|
371
|
-
|
|
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
|
}
|
|
@@ -403,5 +496,13 @@ export interface PreviewNotificationTemplateResponse {
|
|
|
403
496
|
preview: {
|
|
404
497
|
title: string;
|
|
405
498
|
body: string;
|
|
499
|
+
variables: Record<string, any>;
|
|
406
500
|
};
|
|
501
|
+
missingVariables: string[];
|
|
502
|
+
}
|
|
503
|
+
export interface GetNotificationInstancesResponse {
|
|
504
|
+
success: boolean;
|
|
505
|
+
instances?: Serialized<NotificationInstanceData>[];
|
|
506
|
+
total?: number;
|
|
507
|
+
error?: string;
|
|
407
508
|
}
|
|
@@ -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
|
-
|
|
86
|
-
entityId: zod_1.z.string()
|
|
104
|
+
sync: zod_1.z.boolean()
|
|
87
105
|
});
|
|
88
106
|
exports.previewNotificationTemplateRequestSchema = zod_1.z.object({
|
|
89
|
-
|
|
90
|
-
|
|
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
|
});
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
94
|
-
entityId: z.string()
|
|
114
|
+
sync: z.boolean()
|
|
95
115
|
});
|
|
96
116
|
|
|
97
117
|
export const previewNotificationTemplateRequestSchema = z.object({
|
|
98
|
-
|
|
99
|
-
|
|
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>;
|
|
@@ -140,5 +174,14 @@ export interface PreviewNotificationTemplateResponse {
|
|
|
140
174
|
preview: {
|
|
141
175
|
title: string;
|
|
142
176
|
body: string;
|
|
177
|
+
variables: Record<string, any>;
|
|
143
178
|
};
|
|
179
|
+
missingVariables: string[];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface GetNotificationInstancesResponse {
|
|
183
|
+
success: boolean;
|
|
184
|
+
instances?: Serialized<NotificationInstanceData>[];
|
|
185
|
+
total?: number;
|
|
186
|
+
error?: string;
|
|
144
187
|
}
|