@timothyw/pat-common 1.0.102 → 1.0.105

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.
@@ -5,6 +5,5 @@ export declare enum ModuleType {
5
5
  HABITS = "habits",
6
6
  PEOPLE = "people",
7
7
  SETTINGS = "settings",
8
- NOTIFICATIONS = "notifications",
9
8
  DEV = "dev"
10
9
  }
@@ -9,6 +9,5 @@ var ModuleType;
9
9
  ModuleType["HABITS"] = "habits";
10
10
  ModuleType["PEOPLE"] = "people";
11
11
  ModuleType["SETTINGS"] = "settings";
12
- ModuleType["NOTIFICATIONS"] = "notifications";
13
12
  ModuleType["DEV"] = "dev";
14
13
  })(ModuleType || (exports.ModuleType = ModuleType = {}));
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { Serialized } from "../../../utils";
3
3
  import { NotificationTemplateData } from "../../models/notification-template-data";
4
4
  export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
5
- entityType: z.ZodEnum<["agenda", "tasks", "habits", "agenda_item", "task_list", "task", "habit"]>;
5
+ entityType: z.ZodEnum<["agenda", "tasks", "habits", "inbox", "agenda_item", "task_list", "task", "habit", "agenda_defaults", "tasks_defaults", "habits_defaults"]>;
6
6
  entityId: z.ZodOptional<z.ZodString>;
7
7
  name: z.ZodString;
8
8
  description: z.ZodOptional<z.ZodString>;
@@ -36,7 +36,7 @@ export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
36
36
  inheritedFrom: z.ZodOptional<z.ZodString>;
37
37
  customized: z.ZodDefault<z.ZodBoolean>;
38
38
  }, "strip", z.ZodTypeAny, {
39
- entityType: "agenda" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit";
39
+ entityType: "agenda" | "inbox" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit" | "agenda_defaults" | "tasks_defaults" | "habits_defaults";
40
40
  name: string;
41
41
  trigger: {
42
42
  type: "time_based" | "event_based" | "recurring";
@@ -54,7 +54,7 @@ export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
54
54
  description?: string | undefined;
55
55
  inheritedFrom?: string | undefined;
56
56
  }, {
57
- entityType: "agenda" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit";
57
+ entityType: "agenda" | "inbox" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit" | "agenda_defaults" | "tasks_defaults" | "habits_defaults";
58
58
  name: string;
59
59
  trigger: {
60
60
  type: "time_based" | "event_based" | "recurring";
@@ -9,12 +9,12 @@ export declare const getNotificationTemplatesResponseSchema: z.ZodObject<{
9
9
  error: z.ZodOptional<z.ZodString>;
10
10
  }, "strip", z.ZodTypeAny, {
11
11
  success: boolean;
12
- error?: string | undefined;
13
12
  templates?: any[] | undefined;
13
+ error?: string | undefined;
14
14
  }, {
15
15
  success: boolean;
16
- error?: string | undefined;
17
16
  templates?: any[] | undefined;
17
+ error?: string | undefined;
18
18
  }>;
19
19
  export type GetNotificationTemplatesResponse = {
20
20
  success: boolean;
@@ -2,6 +2,5 @@ export * from './get-notification-templates-types';
2
2
  export * from './create-notification-template-types';
3
3
  export * from './update-notification-template-types';
4
4
  export * from './delete-notification-template-types';
5
- export * from './get-notification-instances-types';
6
5
  export * from './preview-notification-template-types';
7
6
  export * from './sync-notification-template-types';
@@ -18,6 +18,5 @@ __exportStar(require("./get-notification-templates-types"), exports);
18
18
  __exportStar(require("./create-notification-template-types"), exports);
19
19
  __exportStar(require("./update-notification-template-types"), exports);
20
20
  __exportStar(require("./delete-notification-template-types"), exports);
21
- __exportStar(require("./get-notification-instances-types"), exports);
22
21
  __exportStar(require("./preview-notification-template-types"), exports);
23
22
  __exportStar(require("./sync-notification-template-types"), exports);
@@ -2,7 +2,6 @@ export * from './auth-data';
2
2
  export * from './habit-data';
3
3
  export * from './item-data';
4
4
  export * from './notification-template-data';
5
- export * from './notification-instance-data';
6
5
  export * from './notifiable';
7
6
  export * from './person-data';
8
7
  export * from './program-config';
@@ -18,7 +18,6 @@ __exportStar(require("./auth-data"), exports);
18
18
  __exportStar(require("./habit-data"), exports);
19
19
  __exportStar(require("./item-data"), exports);
20
20
  __exportStar(require("./notification-template-data"), exports);
21
- __exportStar(require("./notification-instance-data"), exports);
22
21
  __exportStar(require("./notifiable"), exports);
23
22
  __exportStar(require("./person-data"), exports);
24
23
  __exportStar(require("./program-config"), exports);
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { NotificationTemplateId, UserId } from "../id-types";
3
- export declare const notificationEntityTypeSchema: z.ZodEnum<["agenda", "tasks", "habits", "agenda_item", "task_list", "task", "habit"]>;
3
+ export declare const notificationEntityTypeSchema: z.ZodEnum<["agenda", "tasks", "habits", "inbox", "agenda_item", "task_list", "task", "habit", "agenda_defaults", "tasks_defaults", "habits_defaults"]>;
4
4
  export type NotificationEntityType = z.infer<typeof notificationEntityTypeSchema>;
5
5
  export declare const notificationTriggerTypeSchema: z.ZodEnum<["time_based", "event_based", "recurring"]>;
6
6
  export type NotificationTriggerType = z.infer<typeof notificationTriggerTypeSchema>;
@@ -35,7 +35,7 @@ export type NotificationContent = z.infer<typeof notificationContentSchema>;
35
35
  export declare const notificationTemplateDataSchema: z.ZodObject<{
36
36
  _id: z.ZodEffects<z.ZodString, NotificationTemplateId, string>;
37
37
  userId: z.ZodEffects<z.ZodString, UserId, string>;
38
- entityType: z.ZodEnum<["agenda", "tasks", "habits", "agenda_item", "task_list", "task", "habit"]>;
38
+ entityType: z.ZodEnum<["agenda", "tasks", "habits", "inbox", "agenda_item", "task_list", "task", "habit", "agenda_defaults", "tasks_defaults", "habits_defaults"]>;
39
39
  entityId: z.ZodOptional<z.ZodString>;
40
40
  name: z.ZodString;
41
41
  description: z.ZodOptional<z.ZodString>;
@@ -79,7 +79,7 @@ export declare const notificationTemplateDataSchema: z.ZodObject<{
79
79
  userId: string & {
80
80
  readonly __brand: "UserId";
81
81
  };
82
- entityType: "agenda" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit";
82
+ entityType: "agenda" | "inbox" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit" | "agenda_defaults" | "tasks_defaults" | "habits_defaults";
83
83
  name: string;
84
84
  trigger: {
85
85
  type: "time_based" | "event_based" | "recurring";
@@ -101,7 +101,7 @@ export declare const notificationTemplateDataSchema: z.ZodObject<{
101
101
  createdAt: Date;
102
102
  updatedAt: Date;
103
103
  userId: string;
104
- entityType: "agenda" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit";
104
+ entityType: "agenda" | "inbox" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit" | "agenda_defaults" | "tasks_defaults" | "habits_defaults";
105
105
  name: string;
106
106
  trigger: {
107
107
  type: "time_based" | "event_based" | "recurring";
@@ -123,7 +123,7 @@ export type NotificationTemplateData = z.infer<typeof notificationTemplateDataSc
123
123
  export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
124
124
  _id: z.ZodEffects<z.ZodString, NotificationTemplateId, string>;
125
125
  userId: z.ZodEffects<z.ZodString, UserId, string>;
126
- entityType: z.ZodEnum<["agenda", "tasks", "habits", "agenda_item", "task_list", "task", "habit"]>;
126
+ entityType: z.ZodEnum<["agenda", "tasks", "habits", "inbox", "agenda_item", "task_list", "task", "habit", "agenda_defaults", "tasks_defaults", "habits_defaults"]>;
127
127
  entityId: z.ZodOptional<z.ZodString>;
128
128
  name: z.ZodString;
129
129
  description: z.ZodOptional<z.ZodString>;
@@ -162,7 +162,7 @@ export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
162
162
  userId: string & {
163
163
  readonly __brand: "UserId";
164
164
  };
165
- entityType: "agenda" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit";
165
+ entityType: "agenda" | "inbox" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit" | "agenda_defaults" | "tasks_defaults" | "habits_defaults";
166
166
  name: string;
167
167
  trigger: {
168
168
  type: "time_based" | "event_based" | "recurring";
@@ -181,7 +181,7 @@ export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
181
181
  inheritedFrom?: NotificationTemplateId | undefined;
182
182
  }, {
183
183
  userId: string;
184
- entityType: "agenda" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit";
184
+ entityType: "agenda" | "inbox" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit" | "agenda_defaults" | "tasks_defaults" | "habits_defaults";
185
185
  name: string;
186
186
  trigger: {
187
187
  type: "time_based" | "event_based" | "recurring";
@@ -200,3 +200,25 @@ export declare const createNotificationTemplateSchema: z.ZodObject<Omit<{
200
200
  customized?: boolean | undefined;
201
201
  }>;
202
202
  export type CreateNotificationTemplateData = z.infer<typeof createNotificationTemplateSchema>;
203
+ export declare const entitySyncStateSchema: z.ZodObject<{
204
+ userId: z.ZodEffects<z.ZodString, UserId, string>;
205
+ entityType: z.ZodEnum<["agenda", "tasks", "habits", "inbox", "agenda_item", "task_list", "task", "habit", "agenda_defaults", "tasks_defaults", "habits_defaults"]>;
206
+ entityId: z.ZodString;
207
+ synced: z.ZodDefault<z.ZodBoolean>;
208
+ updatedAt: z.ZodDate;
209
+ }, "strip", z.ZodTypeAny, {
210
+ updatedAt: Date;
211
+ userId: string & {
212
+ readonly __brand: "UserId";
213
+ };
214
+ entityType: "agenda" | "inbox" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit" | "agenda_defaults" | "tasks_defaults" | "habits_defaults";
215
+ entityId: string;
216
+ synced: boolean;
217
+ }, {
218
+ updatedAt: Date;
219
+ userId: string;
220
+ entityType: "agenda" | "inbox" | "tasks" | "habits" | "agenda_item" | "task_list" | "task" | "habit" | "agenda_defaults" | "tasks_defaults" | "habits_defaults";
221
+ entityId: string;
222
+ synced?: boolean | undefined;
223
+ }>;
224
+ export type EntitySyncState = z.infer<typeof entitySyncStateSchema>;
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNotificationTemplateSchema = exports.notificationTemplateDataSchema = exports.notificationContentSchema = exports.notificationTriggerSchema = exports.notificationTriggerTypeSchema = exports.notificationEntityTypeSchema = void 0;
3
+ exports.entitySyncStateSchema = exports.createNotificationTemplateSchema = exports.notificationTemplateDataSchema = exports.notificationContentSchema = exports.notificationTriggerSchema = exports.notificationTriggerTypeSchema = exports.notificationEntityTypeSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- exports.notificationEntityTypeSchema = zod_1.z.enum(['agenda', 'tasks', 'habits', 'agenda_item', 'task_list', 'task', 'habit']);
5
+ exports.notificationEntityTypeSchema = zod_1.z.enum([
6
+ // Individual entity types (notifications FOR the entity itself)
7
+ 'agenda', 'tasks', 'habits', 'inbox',
8
+ 'agenda_item', 'task_list', 'task', 'habit',
9
+ // Parent template types (default templates for children)
10
+ 'agenda_defaults', 'tasks_defaults', 'habits_defaults'
11
+ ]);
6
12
  exports.notificationTriggerTypeSchema = zod_1.z.enum(['time_based', 'event_based', 'recurring']);
7
13
  exports.notificationTriggerSchema = zod_1.z.object({
8
14
  type: exports.notificationTriggerTypeSchema,
@@ -36,3 +42,11 @@ exports.createNotificationTemplateSchema = exports.notificationTemplateDataSchem
36
42
  createdAt: true,
37
43
  updatedAt: true
38
44
  });
45
+ // Entity sync state for inheritance
46
+ exports.entitySyncStateSchema = zod_1.z.object({
47
+ userId: zod_1.z.string().transform((val) => val),
48
+ entityType: exports.notificationEntityTypeSchema,
49
+ entityId: zod_1.z.string(),
50
+ synced: zod_1.z.boolean().default(true), // true = inheriting from parent, false = has custom templates
51
+ updatedAt: zod_1.z.date()
52
+ });
@@ -1,4 +1,4 @@
1
- import { Habit, HabitData, HabitEntry, HabitEntryData, ItemData, Person, PersonData, PersonNoteData, NotificationTemplateData, NotificationInstanceData, TaskData, TaskListData, ThoughtData, UserData } from "../types";
1
+ import { Habit, HabitData, HabitEntry, HabitEntryData, ItemData, Person, PersonData, PersonNoteData, NotificationTemplateData, TaskData, TaskListData, ThoughtData, UserData } from "../types";
2
2
  export type Serialized<T> = T extends Date ? string : T extends Date | undefined ? string | undefined : T extends Date | null ? string | null : T extends (infer U)[] ? Serialized<U>[] : T extends object ? {
3
3
  [K in keyof T]: Serialized<T[K]>;
4
4
  } : T;
@@ -31,6 +31,4 @@ export declare class Serializer {
31
31
  static deserializeUserData(data: Serialized<UserData>): UserData;
32
32
  static serializeNotificationTemplateData(data: NotificationTemplateData): Serialized<NotificationTemplateData>;
33
33
  static deserializeNotificationTemplateData(data: Serialized<NotificationTemplateData>): NotificationTemplateData;
34
- static serializeNotificationInstanceData(data: NotificationInstanceData): Serialized<NotificationInstanceData>;
35
- static deserializeNotificationInstanceData(data: Serialized<NotificationInstanceData>): NotificationInstanceData;
36
34
  }
@@ -86,12 +86,6 @@ class Serializer {
86
86
  static deserializeNotificationTemplateData(data) {
87
87
  return this.deserialize(data);
88
88
  }
89
- static serializeNotificationInstanceData(data) {
90
- return this.serialize(data);
91
- }
92
- static deserializeNotificationInstanceData(data) {
93
- return this.deserialize(data);
94
- }
95
89
  }
96
90
  exports.Serializer = Serializer;
97
91
  function serializeRecursive(obj) {
package/package.json CHANGED
@@ -2,14 +2,14 @@
2
2
  "name": "@timothyw/pat-common",
3
3
  "description": "",
4
4
  "author": "Timothy Washburn",
5
- "version": "1.0.102",
5
+ "version": "1.0.105",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
9
9
  "build": "tsc",
10
10
  "prepublishOnly": "npm run build",
11
- "publish:patch": "npm version patch && npm publish",
12
- "publish:minor": "npm version minor && npm publish"
11
+ "publish:patch": "npm version patch --no-git-tag-version && npm publish",
12
+ "publish:minor": "npm version minor --no-git-tag-version && npm publish"
13
13
  },
14
14
  "publishConfig": {
15
15
  "access": "public"
@@ -5,6 +5,5 @@ export enum ModuleType {
5
5
  HABITS = 'habits',
6
6
  PEOPLE = 'people',
7
7
  SETTINGS = 'settings',
8
- NOTIFICATIONS = 'notifications',
9
8
  DEV = 'dev'
10
9
  }
@@ -2,6 +2,5 @@ export * from './get-notification-templates-types';
2
2
  export * from './create-notification-template-types';
3
3
  export * from './update-notification-template-types';
4
4
  export * from './delete-notification-template-types';
5
- export * from './get-notification-instances-types';
6
5
  export * from './preview-notification-template-types';
7
6
  export * from './sync-notification-template-types';
@@ -2,7 +2,6 @@ export * from './auth-data';
2
2
  export * from './habit-data';
3
3
  export * from './item-data';
4
4
  export * from './notification-template-data';
5
- export * from './notification-instance-data';
6
5
  export * from './notifiable';
7
6
  export * from './person-data';
8
7
  export * from './program-config';
@@ -1,7 +1,14 @@
1
1
  import { z } from "zod";
2
2
  import { NotificationTemplateId, UserId } from "../id-types";
3
3
 
4
- export const notificationEntityTypeSchema = z.enum(['agenda', 'tasks', 'habits', 'agenda_item', 'task_list', 'task', 'habit']);
4
+ export const notificationEntityTypeSchema = z.enum([
5
+ // Individual entity types (notifications FOR the entity itself)
6
+ 'agenda', 'tasks', 'habits', 'inbox',
7
+ 'agenda_item', 'task_list', 'task', 'habit',
8
+
9
+ // Parent template types (default templates for children)
10
+ 'agenda_defaults', 'tasks_defaults', 'habits_defaults'
11
+ ]);
5
12
  export type NotificationEntityType = z.infer<typeof notificationEntityTypeSchema>;
6
13
 
7
14
  export const notificationTriggerTypeSchema = z.enum(['time_based', 'event_based', 'recurring']);
@@ -47,4 +54,14 @@ export const createNotificationTemplateSchema = notificationTemplateDataSchema.o
47
54
  updatedAt: true
48
55
  });
49
56
 
50
- export type CreateNotificationTemplateData = z.infer<typeof createNotificationTemplateSchema>;
57
+ export type CreateNotificationTemplateData = z.infer<typeof createNotificationTemplateSchema>;
58
+
59
+ // Entity sync state for inheritance
60
+ export const entitySyncStateSchema = z.object({
61
+ userId: z.string().transform((val): UserId => val as UserId),
62
+ entityType: notificationEntityTypeSchema,
63
+ entityId: z.string(),
64
+ synced: z.boolean().default(true), // true = inheriting from parent, false = has custom templates
65
+ updatedAt: z.date()
66
+ });
67
+ export type EntitySyncState = z.infer<typeof entitySyncStateSchema>;
@@ -6,7 +6,6 @@ import {
6
6
  PersonData,
7
7
  PersonNoteData,
8
8
  NotificationTemplateData,
9
- NotificationInstanceData,
10
9
  TaskData, TaskListData,
11
10
  ThoughtData,
12
11
  UserData
@@ -136,14 +135,6 @@ export class Serializer {
136
135
  static deserializeNotificationTemplateData(data: Serialized<NotificationTemplateData>): NotificationTemplateData {
137
136
  return this.deserialize(data) as unknown as NotificationTemplateData;
138
137
  }
139
-
140
- static serializeNotificationInstanceData(data: NotificationInstanceData): Serialized<NotificationInstanceData> {
141
- return this.serialize(data);
142
- }
143
-
144
- static deserializeNotificationInstanceData(data: Serialized<NotificationInstanceData>): NotificationInstanceData {
145
- return this.deserialize(data) as unknown as NotificationInstanceData;
146
- }
147
138
  }
148
139
 
149
140
  function serializeRecursive(obj: any): any {
@@ -1,29 +0,0 @@
1
- import { z } from "zod";
2
- import { Serialized } from "../../../utils";
3
- import { NotificationInstanceData } from "../../models/notification-instance-data";
4
-
5
- // Request schema - query parameters
6
- export const getNotificationInstancesRequestSchema = z.object({
7
- status: z.string().optional(), // filter by status
8
- templateId: z.string().optional(), // filter by template
9
- entityId: z.string().optional(), // filter by entity
10
- limit: z.number().optional(), // pagination
11
- offset: z.number().optional() // pagination
12
- });
13
-
14
- export type GetNotificationInstancesRequest = z.infer<typeof getNotificationInstancesRequestSchema>;
15
-
16
- // Response schema
17
- export const getNotificationInstancesResponseSchema = z.object({
18
- success: z.boolean(),
19
- instances: z.array(z.any()).optional(), // Will be Serialized<NotificationInstanceData>[]
20
- total: z.number().optional(),
21
- error: z.string().optional()
22
- });
23
-
24
- export type GetNotificationInstancesResponse = {
25
- success: boolean;
26
- instances?: Serialized<NotificationInstanceData>[];
27
- total?: number;
28
- error?: string;
29
- };
@@ -1,40 +0,0 @@
1
- import { z } from "zod";
2
- import { NotificationInstanceId, NotificationTemplateId, UserId } from "../id-types";
3
-
4
- export const notificationStatusSchema = z.enum(['scheduled', 'sent', 'failed', 'cancelled']);
5
- export type NotificationStatus = z.infer<typeof notificationStatusSchema>;
6
-
7
- export const notificationInstanceDataSchema = z.object({
8
- _id: z.string().transform((val): NotificationInstanceId => val as NotificationInstanceId),
9
- templateId: z.string().transform((val): NotificationTemplateId => val as NotificationTemplateId),
10
- userId: z.string().transform((val): UserId => val as UserId),
11
- entityId: z.string(), // ID of the specific entity this notification is for
12
- scheduledFor: z.date(),
13
- status: notificationStatusSchema,
14
- sentAt: z.date().optional(),
15
- content: z.object({
16
- title: z.string(),
17
- body: z.string(),
18
- data: z.record(z.any()).optional() // additional data for the notification
19
- }),
20
- redisId: z.string(), // link to Redis scheduled notification for coordination
21
- error: z.string().optional(), // error message if status is 'failed'
22
- createdAt: z.date(),
23
- updatedAt: z.date()
24
- });
25
-
26
- export type NotificationInstanceData = z.infer<typeof notificationInstanceDataSchema>;
27
-
28
- // Helper type for creating new instances (without _id, dates, status)
29
- export const createNotificationInstanceSchema = notificationInstanceDataSchema.omit({
30
- _id: true,
31
- status: true,
32
- sentAt: true,
33
- error: true,
34
- createdAt: true,
35
- updatedAt: true
36
- }).extend({
37
- status: notificationStatusSchema.default('scheduled')
38
- });
39
-
40
- export type CreateNotificationInstanceData = z.infer<typeof createNotificationInstanceSchema>;