@timothyw/pat-common 1.0.40 → 1.0.42

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.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './enums';
2
2
  export * from './types';
3
+ export * from './utils';
package/dist/index.js CHANGED
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./enums"), exports);
18
18
  __exportStar(require("./types"), exports);
19
+ __exportStar(require("./utils"), exports);
@@ -1,18 +1,19 @@
1
1
  import { z } from "zod";
2
- import { HabitWithEntries } from "../../models/habit-data";
2
+ import { DateString } from "../../misc-types";
3
+ import { HabitWithEntries } from "../../models";
3
4
  export declare const createHabitEntryRequestSchema: z.ZodObject<{
4
- date: z.ZodDate;
5
- status: z.ZodEnum<["completed", "excused", "missed"]>;
5
+ date: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>;
6
+ status: z.ZodEnum<["completed", "excused"]>;
6
7
  }, "strip", z.ZodTypeAny, {
7
- status: "completed" | "excused" | "missed";
8
+ status: "completed" | "excused";
8
9
  date: Date;
9
10
  }, {
10
- status: "completed" | "excused" | "missed";
11
- date: Date;
11
+ status: "completed" | "excused";
12
+ date: string;
12
13
  }>;
13
14
  export interface CreateHabitEntryRequest {
14
- date: Date;
15
- status: 'completed' | 'excused' | 'missed';
15
+ date: DateString;
16
+ status: 'completed' | 'excused';
16
17
  }
17
18
  export interface CreateHabitEntryResponse {
18
19
  habit: HabitWithEntries;
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createHabitEntryRequestSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const misc_types_1 = require("../../misc-types");
5
6
  exports.createHabitEntryRequestSchema = zod_1.z.object({
6
- date: zod_1.z.date(),
7
- status: zod_1.z.enum(['completed', 'excused', 'missed'])
7
+ date: misc_types_1.dateSchema,
8
+ status: zod_1.z.enum(['completed', 'excused'])
8
9
  });
@@ -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,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);
@@ -0,0 +1,2 @@
1
+ import { DateString } from "../types";
2
+ export declare const toDateString: (date: Date) => DateString;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toDateString = void 0;
4
+ const toDateString = (date) => {
5
+ return date.toISOString();
6
+ };
7
+ exports.toDateString = toDateString;
@@ -0,0 +1 @@
1
+ export * from './date-utils';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./date-utils"), 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.40",
5
+ "version": "1.0.42",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './enums'
2
- export * from './types'
2
+ export * from './types'
3
+ export * from './utils'
@@ -1,14 +1,15 @@
1
1
  import { z } from "zod";
2
- import { HabitWithEntries } from "../../models/habit-data";
2
+ import { dateSchema, DateString } from "../../misc-types";
3
+ import { HabitWithEntries } from "../../models";
3
4
 
4
5
  export const createHabitEntryRequestSchema = z.object({
5
- date: z.date(),
6
- status: z.enum(['completed', 'excused', 'missed'])
6
+ date: dateSchema,
7
+ status: z.enum(['completed', 'excused'])
7
8
  });
8
9
 
9
10
  export interface CreateHabitEntryRequest {
10
- date: Date;
11
- status: 'completed' | 'excused' | 'missed';
11
+ date: DateString;
12
+ status: 'completed' | 'excused';
12
13
  }
13
14
 
14
15
  export interface CreateHabitEntryResponse {
@@ -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,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';
@@ -0,0 +1,5 @@
1
+ import { DateString } from "../types";
2
+
3
+ export const toDateString = (date: Date): DateString => {
4
+ return date.toISOString() as DateString;
5
+ }
@@ -0,0 +1 @@
1
+ export * from './date-utils'