@timothyw/pat-common 1.0.103 → 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 = {}));
@@ -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,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.103",
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';
@@ -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>;