@timothyw/pat-common 1.0.57 → 1.0.59
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/types/api/account/update-user-types.d.ts +3 -3
- package/dist/types/api/habits/create-habit-entry-types.d.ts +5 -3
- package/dist/types/api/items/create-item-types.d.ts +2 -2
- package/dist/types/api/items/update-item-types.d.ts +2 -2
- package/dist/types/misc-types.d.ts +1 -1
- package/dist/types/misc-types.js +2 -1
- package/dist/types/models/habit-data.d.ts +3 -3
- package/dist/types/models/habit-data.js +1 -8
- package/dist/types/models/user-data.d.ts +2 -2
- package/package.json +1 -1
- package/src/types/misc-types.ts +2 -1
- package/src/types/models/habit-data.ts +3 -9
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { UserData } from "../../models";
|
|
3
3
|
export declare const updateUserRequestSchema: z.ZodObject<{
|
|
4
|
-
name: z.ZodOptional<z.ZodString>;
|
|
5
4
|
sandbox: z.ZodOptional<z.ZodObject<{
|
|
6
5
|
discordId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
7
6
|
devices: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -22,6 +21,7 @@ export declare const updateUserRequestSchema: z.ZodObject<{
|
|
|
22
21
|
pushToken?: string | undefined;
|
|
23
22
|
}[] | undefined;
|
|
24
23
|
}>>;
|
|
24
|
+
name: z.ZodOptional<z.ZodString>;
|
|
25
25
|
timezone: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
26
26
|
config: z.ZodOptional<z.ZodObject<{
|
|
27
27
|
modules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -77,13 +77,13 @@ export declare const updateUserRequestSchema: z.ZodObject<{
|
|
|
77
77
|
}[] | undefined;
|
|
78
78
|
}>>;
|
|
79
79
|
}, "strict", z.ZodTypeAny, {
|
|
80
|
-
name?: string | undefined;
|
|
81
80
|
sandbox?: {
|
|
82
81
|
discordId?: string | undefined;
|
|
83
82
|
devices?: {
|
|
84
83
|
pushToken?: string | undefined;
|
|
85
84
|
}[] | undefined;
|
|
86
85
|
} | undefined;
|
|
86
|
+
name?: string | undefined;
|
|
87
87
|
timezone?: string | undefined;
|
|
88
88
|
config?: {
|
|
89
89
|
agenda?: {
|
|
@@ -99,13 +99,13 @@ export declare const updateUserRequestSchema: z.ZodObject<{
|
|
|
99
99
|
}[] | undefined;
|
|
100
100
|
} | undefined;
|
|
101
101
|
}, {
|
|
102
|
-
name?: string | undefined;
|
|
103
102
|
sandbox?: {
|
|
104
103
|
discordId?: string | undefined;
|
|
105
104
|
devices?: {
|
|
106
105
|
pushToken?: string | undefined;
|
|
107
106
|
}[] | undefined;
|
|
108
107
|
} | undefined;
|
|
108
|
+
name?: string | undefined;
|
|
109
109
|
timezone?: string | undefined;
|
|
110
110
|
config?: {
|
|
111
111
|
agenda?: {
|
|
@@ -2,14 +2,16 @@ import { z } from "zod";
|
|
|
2
2
|
import { Habit, HabitEntryStatus } from "../../models";
|
|
3
3
|
import { DateOnlyString } from "../../misc-types";
|
|
4
4
|
export declare const createHabitEntryRequestSchema: z.ZodObject<{
|
|
5
|
-
date: z.ZodEffects<z.ZodString, string, string>;
|
|
5
|
+
date: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, DateOnlyString, string>;
|
|
6
6
|
status: z.ZodNativeEnum<typeof HabitEntryStatus>;
|
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
date: string;
|
|
9
8
|
status: HabitEntryStatus;
|
|
9
|
+
date: string & {
|
|
10
|
+
readonly __brand: "DateOnlyString";
|
|
11
|
+
};
|
|
10
12
|
}, {
|
|
11
|
-
date: string;
|
|
12
13
|
status: HabitEntryStatus;
|
|
14
|
+
date: string;
|
|
13
15
|
}>;
|
|
14
16
|
export interface CreateHabitEntryRequest {
|
|
15
17
|
date: DateOnlyString;
|
|
@@ -9,14 +9,14 @@ export declare const createItemRequestSchema: z.ZodObject<{
|
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
10
|
name: string;
|
|
11
11
|
urgent: boolean;
|
|
12
|
-
notes?: string | undefined;
|
|
13
12
|
type?: string | null | undefined;
|
|
13
|
+
notes?: string | undefined;
|
|
14
14
|
dueDate?: string | null | undefined;
|
|
15
15
|
category?: string | null | undefined;
|
|
16
16
|
}, {
|
|
17
17
|
name: string;
|
|
18
|
-
notes?: string | undefined;
|
|
19
18
|
type?: string | null | undefined;
|
|
19
|
+
notes?: string | undefined;
|
|
20
20
|
dueDate?: string | null | undefined;
|
|
21
21
|
urgent?: boolean | undefined;
|
|
22
22
|
category?: string | null | undefined;
|
|
@@ -7,16 +7,16 @@ export declare const updateItemRequestSchema: z.ZodObject<{
|
|
|
7
7
|
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
8
|
type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
type?: string | null | undefined;
|
|
10
11
|
name?: string | undefined;
|
|
11
12
|
notes?: string | undefined;
|
|
12
|
-
type?: string | null | undefined;
|
|
13
13
|
dueDate?: string | null | undefined;
|
|
14
14
|
urgent?: boolean | undefined;
|
|
15
15
|
category?: string | null | undefined;
|
|
16
16
|
}, {
|
|
17
|
+
type?: string | null | undefined;
|
|
17
18
|
name?: string | undefined;
|
|
18
19
|
notes?: string | undefined;
|
|
19
|
-
type?: string | null | undefined;
|
|
20
20
|
dueDate?: string | null | undefined;
|
|
21
21
|
urgent?: boolean | undefined;
|
|
22
22
|
category?: string | null | undefined;
|
|
@@ -2,7 +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
|
+
export declare const dateOnlyStringSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, DateOnlyString, string>;
|
|
6
6
|
export type DateString = string & {
|
|
7
7
|
readonly __brand: "DateString";
|
|
8
8
|
};
|
package/dist/types/misc-types.js
CHANGED
|
@@ -5,7 +5,8 @@ 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
|
+
.transform(val => val);
|
|
9
10
|
exports.dateStringSchema = zod_1.z.string()
|
|
10
11
|
.refine(val => !isNaN(Date.parse(val)), {
|
|
11
12
|
message: "Invalid date string",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateOnlyString
|
|
1
|
+
import { DateOnlyString } from "../misc-types";
|
|
2
2
|
export declare enum HabitFrequency {
|
|
3
3
|
DAILY = "daily",
|
|
4
4
|
WEEKLY = "weekly",
|
|
@@ -37,8 +37,8 @@ export interface HabitStats {
|
|
|
37
37
|
missedDays: number;
|
|
38
38
|
completionRate: number;
|
|
39
39
|
}
|
|
40
|
-
export type HabitEntry =
|
|
41
|
-
export type Habit =
|
|
40
|
+
export type HabitEntry = HabitEntryData;
|
|
41
|
+
export type Habit = HabitData & {
|
|
42
42
|
entries: HabitEntry[];
|
|
43
43
|
stats: HabitStats;
|
|
44
44
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toHabit = exports.HabitEntryStatus = exports.HabitFrequency = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
4
|
var HabitFrequency;
|
|
6
5
|
(function (HabitFrequency) {
|
|
7
6
|
HabitFrequency["DAILY"] = "daily";
|
|
@@ -18,13 +17,7 @@ var HabitEntryStatus;
|
|
|
18
17
|
const toHabit = (data, entries, stats) => {
|
|
19
18
|
return {
|
|
20
19
|
...data,
|
|
21
|
-
|
|
22
|
-
updatedAt: (0, utils_1.toDateString)(data.updatedAt),
|
|
23
|
-
entries: entries.map(entry => ({
|
|
24
|
-
...entry,
|
|
25
|
-
createdAt: (0, utils_1.toDateString)(entry.createdAt),
|
|
26
|
-
updatedAt: (0, utils_1.toDateString)(entry.updatedAt)
|
|
27
|
-
})),
|
|
20
|
+
entries,
|
|
28
21
|
stats
|
|
29
22
|
};
|
|
30
23
|
};
|
|
@@ -95,13 +95,13 @@ export declare const userDataSchema: z.ZodObject<{
|
|
|
95
95
|
};
|
|
96
96
|
createdAt: Date;
|
|
97
97
|
updatedAt: Date;
|
|
98
|
-
name: string;
|
|
99
98
|
sandbox: {
|
|
100
99
|
devices: {
|
|
101
100
|
pushToken: string;
|
|
102
101
|
}[];
|
|
103
102
|
discordId?: string | undefined;
|
|
104
103
|
};
|
|
104
|
+
name: string;
|
|
105
105
|
timezone: string;
|
|
106
106
|
config: {
|
|
107
107
|
agenda: {
|
|
@@ -120,13 +120,13 @@ export declare const userDataSchema: z.ZodObject<{
|
|
|
120
120
|
_id: string;
|
|
121
121
|
createdAt: Date;
|
|
122
122
|
updatedAt: Date;
|
|
123
|
-
name: string;
|
|
124
123
|
sandbox: {
|
|
125
124
|
devices: {
|
|
126
125
|
pushToken: string;
|
|
127
126
|
}[];
|
|
128
127
|
discordId?: string | undefined;
|
|
129
128
|
};
|
|
129
|
+
name: string;
|
|
130
130
|
timezone: string;
|
|
131
131
|
config: {
|
|
132
132
|
agenda: {
|
package/package.json
CHANGED
package/src/types/misc-types.ts
CHANGED
|
@@ -5,7 +5,8 @@ export type DateOnlyString = string & { readonly __brand: "DateOnlyString" };
|
|
|
5
5
|
export const dateOnlyStringSchema = 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
|
+
.transform(val => val as DateOnlyString);
|
|
9
10
|
|
|
10
11
|
export type DateString = string & { readonly __brand: "DateString" };
|
|
11
12
|
|
|
@@ -44,9 +44,9 @@ export interface HabitStats {
|
|
|
44
44
|
completionRate: number;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export type HabitEntry =
|
|
47
|
+
export type HabitEntry = HabitEntryData;
|
|
48
48
|
|
|
49
|
-
export type Habit =
|
|
49
|
+
export type Habit = HabitData & {
|
|
50
50
|
entries: HabitEntry[];
|
|
51
51
|
stats: HabitStats;
|
|
52
52
|
}
|
|
@@ -54,13 +54,7 @@ export type Habit = ToDateString<HabitData> & {
|
|
|
54
54
|
export const toHabit = (data: HabitData, entries: HabitEntryData[], stats: HabitStats): Habit => {
|
|
55
55
|
return {
|
|
56
56
|
...data,
|
|
57
|
-
|
|
58
|
-
updatedAt: toDateString(data.updatedAt),
|
|
59
|
-
entries: entries.map(entry => ({
|
|
60
|
-
...entry,
|
|
61
|
-
createdAt: toDateString(entry.createdAt),
|
|
62
|
-
updatedAt: toDateString(entry.updatedAt)
|
|
63
|
-
})),
|
|
57
|
+
entries,
|
|
64
58
|
stats
|
|
65
59
|
};
|
|
66
60
|
}
|