@timothyw/pat-common 1.0.56 → 1.0.57

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,18 +1,18 @@
1
1
  import { z } from "zod";
2
2
  import { Habit, HabitEntryStatus } from "../../models";
3
- import { DateString } from "../../misc-types";
3
+ import { DateOnlyString } from "../../misc-types";
4
4
  export declare const createHabitEntryRequestSchema: z.ZodObject<{
5
- date: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>;
5
+ date: z.ZodEffects<z.ZodString, string, string>;
6
6
  status: z.ZodNativeEnum<typeof HabitEntryStatus>;
7
7
  }, "strip", z.ZodTypeAny, {
8
- date: Date;
8
+ date: string;
9
9
  status: HabitEntryStatus;
10
10
  }, {
11
11
  date: string;
12
12
  status: HabitEntryStatus;
13
13
  }>;
14
14
  export interface CreateHabitEntryRequest {
15
- date: DateString;
15
+ date: DateOnlyString;
16
16
  status: HabitEntryStatus;
17
17
  }
18
18
  export interface CreateHabitEntryResponse {
@@ -5,6 +5,6 @@ const zod_1 = require("zod");
5
5
  const models_1 = require("../../models");
6
6
  const misc_types_1 = require("../../misc-types");
7
7
  exports.createHabitEntryRequestSchema = zod_1.z.object({
8
- date: misc_types_1.dateStringSchema,
8
+ date: misc_types_1.dateOnlyStringSchema,
9
9
  status: zod_1.z.nativeEnum(models_1.HabitEntryStatus)
10
10
  });
@@ -3,6 +3,7 @@ import { Habit } from "../../models/habit-data";
3
3
  export declare const createHabitRequestSchema: z.ZodObject<{
4
4
  name: z.ZodString;
5
5
  description: z.ZodOptional<z.ZodString>;
6
+ notes: z.ZodOptional<z.ZodString>;
6
7
  frequency: z.ZodLiteral<"daily">;
7
8
  rolloverTime: z.ZodString;
8
9
  }, "strip", z.ZodTypeAny, {
@@ -10,15 +11,18 @@ export declare const createHabitRequestSchema: z.ZodObject<{
10
11
  frequency: "daily";
11
12
  rolloverTime: string;
12
13
  description?: string | undefined;
14
+ notes?: string | undefined;
13
15
  }, {
14
16
  name: string;
15
17
  frequency: "daily";
16
18
  rolloverTime: string;
17
19
  description?: string | undefined;
20
+ notes?: string | undefined;
18
21
  }>;
19
22
  export interface CreateHabitRequest {
20
23
  name: string;
21
24
  description?: string;
25
+ notes?: string;
22
26
  frequency: 'daily';
23
27
  rolloverTime: string;
24
28
  }
@@ -5,6 +5,7 @@ const zod_1 = require("zod");
5
5
  exports.createHabitRequestSchema = zod_1.z.object({
6
6
  name: zod_1.z.string().min(1, 'Name is required').trim(),
7
7
  description: zod_1.z.string().trim().optional(),
8
+ notes: zod_1.z.string().trim().optional(),
8
9
  frequency: zod_1.z.literal('daily'),
9
10
  rolloverTime: zod_1.z.string().regex(/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/, 'rolloverTime must be in HH:MM format')
10
11
  });
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  export type DateOnlyString = string & {
3
3
  readonly __brand: "DateOnlyString";
4
4
  };
5
+ export declare const dateOnlyStringSchema: z.ZodEffects<z.ZodString, string, string>;
5
6
  export type DateString = string & {
6
7
  readonly __brand: "DateString";
7
8
  };
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dateStringSchema = void 0;
3
+ exports.dateStringSchema = exports.dateOnlyStringSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ exports.dateOnlyStringSchema = zod_1.z.string()
6
+ .refine(val => /^\d{4}-\d{2}-\d{2}$/.test(val), {
7
+ message: "Invalid date-only string format, expected YYYY-MM-DD",
8
+ });
5
9
  exports.dateStringSchema = zod_1.z.string()
6
10
  .refine(val => !isNaN(Date.parse(val)), {
7
11
  message: "Invalid date string",
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.56",
5
+ "version": "1.0.57",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
@@ -1,14 +1,14 @@
1
1
  import { z } from "zod";
2
2
  import { Habit, HabitEntryStatus } from "../../models";
3
- import { DateString, dateStringSchema } from "../../misc-types";
3
+ import { DateOnlyString, dateOnlyStringSchema } from "../../misc-types";
4
4
 
5
5
  export const createHabitEntryRequestSchema = z.object({
6
- date: dateStringSchema,
6
+ date: dateOnlyStringSchema,
7
7
  status: z.nativeEnum(HabitEntryStatus)
8
8
  });
9
9
 
10
10
  export interface CreateHabitEntryRequest {
11
- date: DateString;
11
+ date: DateOnlyString;
12
12
  status: HabitEntryStatus;
13
13
  }
14
14
 
@@ -4,6 +4,7 @@ import { Habit } from "../../models/habit-data";
4
4
  export const createHabitRequestSchema = z.object({
5
5
  name: z.string().min(1, 'Name is required').trim(),
6
6
  description: z.string().trim().optional(),
7
+ notes: z.string().trim().optional(),
7
8
  frequency: z.literal('daily'),
8
9
  rolloverTime: z.string().regex(/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/, 'rolloverTime must be in HH:MM format')
9
10
  });
@@ -11,6 +12,7 @@ export const createHabitRequestSchema = z.object({
11
12
  export interface CreateHabitRequest {
12
13
  name: string;
13
14
  description?: string;
15
+ notes?: string;
14
16
  frequency: 'daily';
15
17
  rolloverTime: string;
16
18
  }
@@ -2,6 +2,11 @@ import { z } from "zod";
2
2
 
3
3
  export type DateOnlyString = string & { readonly __brand: "DateOnlyString" };
4
4
 
5
+ export const dateOnlyStringSchema = z.string()
6
+ .refine(val => /^\d{4}-\d{2}-\d{2}$/.test(val), {
7
+ message: "Invalid date-only string format, expected YYYY-MM-DD",
8
+ });
9
+
5
10
  export type DateString = string & { readonly __brand: "DateString" };
6
11
 
7
12
  export const dateStringSchema = z.string()