@timothyw/pat-common 1.0.103 → 1.0.106

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 = {}));
@@ -12,14 +12,14 @@ export declare const createItemRequestSchema: z.ZodObject<{
12
12
  name: string;
13
13
  urgent: boolean;
14
14
  type?: string | undefined;
15
- dueDate?: string | undefined;
16
15
  notes?: string | undefined;
16
+ dueDate?: string | undefined;
17
17
  category?: string | undefined;
18
18
  }, {
19
19
  name: string;
20
20
  type?: string | undefined;
21
- dueDate?: string | undefined;
22
21
  notes?: string | undefined;
22
+ dueDate?: string | undefined;
23
23
  urgent?: boolean | undefined;
24
24
  category?: string | undefined;
25
25
  }>;
@@ -11,15 +11,15 @@ export declare const updateItemRequestSchema: z.ZodObject<{
11
11
  }, "strip", z.ZodTypeAny, {
12
12
  type?: string | null | undefined;
13
13
  name?: string | undefined;
14
- dueDate?: string | null | undefined;
15
14
  notes?: string | null | undefined;
15
+ dueDate?: string | null | undefined;
16
16
  urgent?: boolean | undefined;
17
17
  category?: string | null | undefined;
18
18
  }, {
19
19
  type?: string | null | undefined;
20
20
  name?: string | undefined;
21
- dueDate?: string | null | undefined;
22
21
  notes?: string | null | undefined;
22
+ dueDate?: string | null | undefined;
23
23
  urgent?: boolean | undefined;
24
24
  category?: string | null | undefined;
25
25
  }>;
@@ -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);
@@ -1,11 +1,14 @@
1
1
  import { z } from 'zod';
2
2
  import { Serialized } from "../../../utils";
3
- import { TaskListData } from "../../models";
3
+ import { TaskListData, TaskListType } from "../../models";
4
4
  export declare const createTaskListRequestSchema: z.ZodObject<{
5
5
  name: z.ZodString;
6
+ type: z.ZodNativeEnum<typeof TaskListType>;
6
7
  }, "strip", z.ZodTypeAny, {
8
+ type: TaskListType;
7
9
  name: string;
8
10
  }, {
11
+ type: TaskListType;
9
12
  name: string;
10
13
  }>;
11
14
  export type CreateTaskListRequest = z.infer<typeof createTaskListRequestSchema>;
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTaskListRequestSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
5
6
  exports.createTaskListRequestSchema = zod_1.z.object({
6
- name: zod_1.z.string().min(1)
7
+ name: zod_1.z.string().min(1),
8
+ type: zod_1.z.nativeEnum(models_1.TaskListType)
7
9
  });
@@ -1,11 +1,14 @@
1
1
  import { z } from 'zod';
2
2
  import { Serialized } from "../../../utils";
3
- import { TaskListData } from "../../models";
3
+ import { TaskListData, TaskListType } from "../../models";
4
4
  export declare const updateTaskListRequestSchema: z.ZodObject<{
5
5
  name: z.ZodOptional<z.ZodString>;
6
+ type: z.ZodOptional<z.ZodNativeEnum<typeof TaskListType>>;
6
7
  }, "strip", z.ZodTypeAny, {
8
+ type?: TaskListType | undefined;
7
9
  name?: string | undefined;
8
10
  }, {
11
+ type?: TaskListType | undefined;
9
12
  name?: string | undefined;
10
13
  }>;
11
14
  export type UpdateTaskListRequest = z.infer<typeof updateTaskListRequestSchema>;
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateTaskListRequestSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
5
6
  exports.updateTaskListRequestSchema = zod_1.z.object({
6
- name: zod_1.z.string().min(1).optional()
7
+ name: zod_1.z.string().min(1).optional(),
8
+ type: zod_1.z.nativeEnum(models_1.TaskListType).optional()
7
9
  });
@@ -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,8 @@
1
1
  import { TaskId, TaskListId, UserId } from "../id-types";
2
+ export declare enum TaskListType {
3
+ TASKS = "tasks",
4
+ NOTES = "notes"
5
+ }
2
6
  export interface TaskData {
3
7
  _id: TaskId;
4
8
  userId: UserId;
@@ -15,4 +19,5 @@ export interface TaskListData {
15
19
  createdAt: Date;
16
20
  updatedAt: Date;
17
21
  name: string;
22
+ type: TaskListType;
18
23
  }
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaskListType = void 0;
4
+ var TaskListType;
5
+ (function (TaskListType) {
6
+ TaskListType["TASKS"] = "tasks";
7
+ TaskListType["NOTES"] = "notes";
8
+ })(TaskListType || (exports.TaskListType = TaskListType = {}));
@@ -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,7 +2,7 @@
2
2
  "name": "@timothyw/pat-common",
3
3
  "description": "",
4
4
  "author": "Timothy Washburn",
5
- "version": "1.0.103",
5
+ "version": "1.0.106",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
@@ -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';
@@ -1,9 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  import { Serialized } from "../../../utils";
3
- import { TaskListData } from "../../models";
3
+ import { TaskListData, TaskListType } from "../../models";
4
4
 
5
5
  export const createTaskListRequestSchema = z.object({
6
- name: z.string().min(1)
6
+ name: z.string().min(1),
7
+ type: z.nativeEnum(TaskListType)
7
8
  });
8
9
 
9
10
  export type CreateTaskListRequest = z.infer<typeof createTaskListRequestSchema>;
@@ -1,9 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  import { Serialized } from "../../../utils";
3
- import { TaskListData } from "../../models";
3
+ import { TaskListData, TaskListType } from "../../models";
4
4
 
5
5
  export const updateTaskListRequestSchema = z.object({
6
- name: z.string().min(1).optional()
6
+ name: z.string().min(1).optional(),
7
+ type: z.nativeEnum(TaskListType).optional()
7
8
  });
8
9
 
9
10
  export type UpdateTaskListRequest = z.infer<typeof updateTaskListRequestSchema>;
@@ -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,5 +1,10 @@
1
1
  import { TaskId, TaskListId, UserId } from "../id-types";
2
2
 
3
+ export enum TaskListType {
4
+ TASKS = 'tasks',
5
+ NOTES = 'notes'
6
+ }
7
+
3
8
  export interface TaskData {
4
9
  _id: TaskId;
5
10
  userId: UserId;
@@ -17,4 +22,5 @@ export interface TaskListData {
17
22
  createdAt: Date;
18
23
  updatedAt: Date;
19
24
  name: string;
25
+ type: TaskListType;
20
26
  }
@@ -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>;