@timothyw/pat-common 1.0.39 → 1.0.41

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.
@@ -6,13 +6,13 @@ export declare const updateTaskRequestSchema: z.ZodObject<{
6
6
  completed: z.ZodOptional<z.ZodBoolean>;
7
7
  taskListId: z.ZodOptional<z.ZodEffects<z.ZodString, TaskListId, string>>;
8
8
  }, "strip", z.ZodTypeAny, {
9
- name?: string | undefined;
10
9
  completed?: boolean | undefined;
10
+ name?: string | undefined;
11
11
  notes?: string | undefined;
12
12
  taskListId?: TaskListId | undefined;
13
13
  }, {
14
- name?: string | undefined;
15
14
  completed?: boolean | undefined;
15
+ name?: string | undefined;
16
16
  notes?: string | undefined;
17
17
  taskListId?: string | undefined;
18
18
  }>;
@@ -2,4 +2,5 @@ export * from './api';
2
2
  export * from './models';
3
3
  export * from './auth-tokens';
4
4
  export * from './id-types';
5
+ export * from './misc-types';
5
6
  export * from './socket-message-types';
@@ -18,4 +18,5 @@ __exportStar(require("./api"), exports);
18
18
  __exportStar(require("./models"), exports);
19
19
  __exportStar(require("./auth-tokens"), exports);
20
20
  __exportStar(require("./id-types"), exports);
21
+ __exportStar(require("./misc-types"), exports);
21
22
  __exportStar(require("./socket-message-types"), exports);
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ export type DateString = string & {
3
+ readonly __brand: "DateString";
4
+ };
5
+ export declare const dateSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dateSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.dateSchema = zod_1.z.string()
6
+ .refine(val => !isNaN(Date.parse(val)), {
7
+ message: "Invalid date string",
8
+ })
9
+ .transform(val => new Date(val));
@@ -1,8 +1,19 @@
1
+ export declare enum HabitFrequency {
2
+ DAILY = "daily",
3
+ WEEKLY = "weekly",
4
+ EVERY_N_DAYS = "every_n_days",
5
+ WEEKDAYS_ONLY = "weekdays_only",
6
+ CUSTOM = "custom"
7
+ }
8
+ export declare enum HabitEntryStatus {
9
+ COMPLETED = "completed",
10
+ EXCUSED = "excused"
11
+ }
1
12
  export interface HabitEntryData {
2
13
  _id: string;
3
14
  habitId: string;
4
15
  date: Date;
5
- status: 'completed' | 'excused';
16
+ status: HabitEntryStatus;
6
17
  createdAt: Date;
7
18
  updatedAt: Date;
8
19
  }
@@ -11,7 +22,7 @@ export interface HabitData {
11
22
  userId: string;
12
23
  name: string;
13
24
  description?: string;
14
- frequency: 'daily';
25
+ frequency: HabitFrequency;
15
26
  rolloverTime: string;
16
27
  createdAt: Date;
17
28
  updatedAt: Date;
@@ -23,14 +34,7 @@ export interface HabitStats {
23
34
  missedDays: number;
24
35
  completionRate: number;
25
36
  }
26
- export interface HabitWithEntries {
27
- id: string;
28
- name: string;
29
- description?: string;
30
- frequency: 'daily';
31
- rolloverTime: string;
32
- createdAt: Date;
33
- updatedAt: Date;
37
+ export interface HabitWithEntries extends HabitData {
34
38
  entries: HabitEntryData[];
35
39
  stats: HabitStats;
36
40
  }
@@ -1,2 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HabitEntryStatus = exports.HabitFrequency = void 0;
4
+ var HabitFrequency;
5
+ (function (HabitFrequency) {
6
+ HabitFrequency["DAILY"] = "daily";
7
+ HabitFrequency["WEEKLY"] = "weekly";
8
+ HabitFrequency["EVERY_N_DAYS"] = "every_n_days";
9
+ HabitFrequency["WEEKDAYS_ONLY"] = "weekdays_only";
10
+ HabitFrequency["CUSTOM"] = "custom";
11
+ })(HabitFrequency || (exports.HabitFrequency = HabitFrequency = {}));
12
+ var HabitEntryStatus;
13
+ (function (HabitEntryStatus) {
14
+ HabitEntryStatus["COMPLETED"] = "completed";
15
+ HabitEntryStatus["EXCUSED"] = "excused";
16
+ })(HabitEntryStatus || (exports.HabitEntryStatus = HabitEntryStatus = {}));
@@ -1,4 +1,5 @@
1
1
  export * from './auth-data';
2
+ export * from './habit-data';
2
3
  export * from './item-data';
3
4
  export * from './person-data';
4
5
  export * from './program-config';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth-data"), exports);
18
+ __exportStar(require("./habit-data"), exports);
18
19
  __exportStar(require("./item-data"), exports);
19
20
  __exportStar(require("./person-data"), exports);
20
21
  __exportStar(require("./program-config"), exports);
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.39",
5
+ "version": "1.0.41",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
@@ -2,4 +2,5 @@ export * from './api'
2
2
  export * from './models'
3
3
  export * from './auth-tokens'
4
4
  export * from './id-types'
5
+ export * from './misc-types'
5
6
  export * from './socket-message-types'
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+
3
+ export type DateString = string & { readonly __brand: "DateString" };
4
+ export const dateSchema = z.string()
5
+ .refine(val => !isNaN(Date.parse(val)), {
6
+ message: "Invalid date string",
7
+ })
8
+ .transform(val => new Date(val));
@@ -1,8 +1,21 @@
1
+ export enum HabitFrequency {
2
+ DAILY = 'daily',
3
+ WEEKLY = 'weekly',
4
+ EVERY_N_DAYS = 'every_n_days',
5
+ WEEKDAYS_ONLY = 'weekdays_only',
6
+ CUSTOM = 'custom'
7
+ }
8
+
9
+ export enum HabitEntryStatus {
10
+ COMPLETED = 'completed',
11
+ EXCUSED = 'excused'
12
+ }
13
+
1
14
  export interface HabitEntryData {
2
15
  _id: string;
3
16
  habitId: string;
4
17
  date: Date;
5
- status: 'completed' | 'excused';
18
+ status: HabitEntryStatus;
6
19
  createdAt: Date;
7
20
  updatedAt: Date;
8
21
  }
@@ -12,7 +25,7 @@ export interface HabitData {
12
25
  userId: string;
13
26
  name: string;
14
27
  description?: string;
15
- frequency: 'daily';
28
+ frequency: HabitFrequency;
16
29
  rolloverTime: string;
17
30
  createdAt: Date;
18
31
  updatedAt: Date;
@@ -26,14 +39,7 @@ export interface HabitStats {
26
39
  completionRate: number;
27
40
  }
28
41
 
29
- export interface HabitWithEntries {
30
- id: string;
31
- name: string;
32
- description?: string;
33
- frequency: 'daily';
34
- rolloverTime: string;
35
- createdAt: Date;
36
- updatedAt: Date;
42
+ export interface HabitWithEntries extends HabitData {
37
43
  entries: HabitEntryData[];
38
44
  stats: HabitStats;
39
45
  }
@@ -1,4 +1,5 @@
1
1
  export * from './auth-data';
2
+ export * from './habit-data';
2
3
  export * from './item-data';
3
4
  export * from './person-data';
4
5
  export * from './program-config';