@timothyw/pat-common 1.0.68 → 1.0.71

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,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { PersonNoteId } from "../../id-types";
3
+ import { Person } from "../../models";
3
4
  export declare const createPersonRequestSchema: z.ZodObject<{
4
5
  name: z.ZodString;
5
6
  properties: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -30,13 +31,5 @@ export declare const createPersonRequestSchema: z.ZodObject<{
30
31
  }>;
31
32
  export type CreatePersonRequest = z.infer<typeof createPersonRequestSchema>;
32
33
  export interface CreatePersonResponse {
33
- person: {
34
- id: string;
35
- name: string;
36
- properties: Array<{
37
- key: string;
38
- value: string;
39
- }>;
40
- notes: Array<PersonNoteId>;
41
- };
34
+ person: Person;
42
35
  }
@@ -1,12 +1,4 @@
1
- import { PersonNoteId } from "../../id-types";
1
+ import { Person } from "../../models";
2
2
  export interface GetPeopleResponse {
3
- people: Array<{
4
- id: string;
5
- name: string;
6
- properties: Array<{
7
- key: string;
8
- value: string;
9
- }>;
10
- notes: Array<PersonNoteId>;
11
- }>;
3
+ people: Array<Person>;
12
4
  }
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { PersonNoteId } from "../../id-types";
3
+ import { Person } from "../../models";
3
4
  export declare const updatePersonRequestSchema: z.ZodObject<{
4
5
  name: z.ZodOptional<z.ZodString>;
5
6
  properties: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -30,13 +31,5 @@ export declare const updatePersonRequestSchema: z.ZodObject<{
30
31
  }>;
31
32
  export type UpdatePersonRequest = z.infer<typeof updatePersonRequestSchema>;
32
33
  export interface UpdatePersonResponse {
33
- person: {
34
- id: string;
35
- name: string;
36
- properties: Array<{
37
- key: string;
38
- value: string;
39
- }>;
40
- notes: Array<PersonNoteId>;
41
- };
34
+ person: Person;
42
35
  }
@@ -6,7 +6,3 @@ export declare const dateOnlyStringSchema: z.ZodEffects<z.ZodEffects<z.ZodString
6
6
  export type DateString = string & {
7
7
  readonly __brand: "DateString";
8
8
  };
9
- export declare const dateStringSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>;
10
- export type ToDateString<T> = {
11
- [K in keyof T]: T[K] extends Date ? DateString : T[K] extends Array<infer U> ? Array<ToDateString<U>> : T[K] extends object ? ToDateString<T[K]> : T[K];
12
- };
@@ -1,14 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dateStringSchema = exports.dateOnlyStringSchema = void 0;
3
+ exports.dateOnlyStringSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.dateOnlyStringSchema = zod_1.z.string()
6
6
  .refine(val => /^\d{4}-\d{2}-\d{2}$/.test(val), {
7
7
  message: "Invalid date-only string format, expected YYYY-MM-DD",
8
8
  })
9
9
  .transform(val => val);
10
- exports.dateStringSchema = zod_1.z.string()
11
- .refine(val => !isNaN(Date.parse(val)), {
12
- message: "Invalid date string",
13
- })
14
- .transform(val => new Date(val));
@@ -9,6 +9,15 @@ export interface PersonNoteData {
9
9
  updatedAt: Date;
10
10
  }
11
11
  export interface PersonData {
12
+ _id: PersonId;
13
+ userId: UserId;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ name: string;
17
+ properties: PersonProperty[];
18
+ noteIds: PersonNoteId[];
19
+ }
20
+ export interface Person {
12
21
  _id: PersonId;
13
22
  userId: UserId;
14
23
  createdAt: Date;
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.68",
5
+ "version": "1.0.71",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { PersonNoteId, personNoteIdSchema } from "../../id-types";
3
+ import { Person, PersonNoteData } from "../../models";
3
4
 
4
5
  export const createPersonRequestSchema = z.object({
5
6
  name: z.string().min(1),
@@ -13,13 +14,5 @@ export const createPersonRequestSchema = z.object({
13
14
  export type CreatePersonRequest = z.infer<typeof createPersonRequestSchema>;
14
15
 
15
16
  export interface CreatePersonResponse {
16
- person: {
17
- id: string;
18
- name: string;
19
- properties: Array<{
20
- key: string;
21
- value: string;
22
- }>;
23
- notes: Array<PersonNoteId>;
24
- };
17
+ person: Person;
25
18
  }
@@ -1,13 +1,6 @@
1
1
  import { PersonNoteId } from "../../id-types";
2
+ import { Person, PersonData, PersonNoteData } from "../../models";
2
3
 
3
4
  export interface GetPeopleResponse {
4
- people: Array<{
5
- id: string;
6
- name: string;
7
- properties: Array<{
8
- key: string;
9
- value: string;
10
- }>;
11
- notes: Array<PersonNoteId>;
12
- }>;
5
+ people: Array<Person>;
13
6
  }
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { personIdSchema, PersonNoteId, personNoteIdSchema } from "../../id-types";
3
+ import { Person, PersonNoteData } from "../../models";
3
4
 
4
5
  export const updatePersonRequestSchema = z.object({
5
6
  name: z.string().min(1).optional(),
@@ -13,13 +14,5 @@ export const updatePersonRequestSchema = z.object({
13
14
  export type UpdatePersonRequest = z.infer<typeof updatePersonRequestSchema>;
14
15
 
15
16
  export interface UpdatePersonResponse {
16
- person: {
17
- id: string;
18
- name: string;
19
- properties: Array<{
20
- key: string;
21
- value: string;
22
- }>;
23
- notes: Array<PersonNoteId>;
24
- };
17
+ person: Person;
25
18
  }
@@ -8,20 +8,4 @@ export const dateOnlyStringSchema = z.string()
8
8
  })
9
9
  .transform(val => val as DateOnlyString);
10
10
 
11
- export type DateString = string & { readonly __brand: "DateString" };
12
-
13
- export const dateStringSchema = z.string()
14
- .refine(val => !isNaN(Date.parse(val)), {
15
- message: "Invalid date string",
16
- })
17
- .transform(val => new Date(val));
18
-
19
- export type ToDateString<T> = {
20
- [K in keyof T]: T[K] extends Date
21
- ? DateString
22
- : T[K] extends Array<infer U>
23
- ? Array<ToDateString<U>>
24
- : T[K] extends object
25
- ? ToDateString<T[K]>
26
- : T[K];
27
- };
11
+ export type DateString = string & { readonly __brand: "DateString" };
@@ -1,5 +1,4 @@
1
- import { DateOnlyString, ToDateString } from "../misc-types";
2
- import { toDateString } from "../../utils";
1
+ import { DateOnlyString } from "../misc-types";
3
2
  import { HabitEntryId, HabitId, UserId } from "../id-types";
4
3
 
5
4
  export enum HabitFrequency {
@@ -12,6 +12,16 @@ export interface PersonNoteData {
12
12
  }
13
13
 
14
14
  export interface PersonData {
15
+ _id: PersonId;
16
+ userId: UserId;
17
+ createdAt: Date;
18
+ updatedAt: Date;
19
+ name: string;
20
+ properties: PersonProperty[];
21
+ noteIds: PersonNoteId[];
22
+ }
23
+
24
+ export interface Person {
15
25
  _id: PersonId;
16
26
  userId: UserId;
17
27
  createdAt: Date;