@timothyw/pat-common 1.0.42 → 1.0.45
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 +4 -4
- package/dist/types/api/habits/create-habit-types.d.ts +2 -2
- package/dist/types/api/habits/delete-habit-entry-types.d.ts +2 -2
- package/dist/types/api/habits/get-habits-types.d.ts +2 -2
- package/dist/types/api/habits/update-habit-types.d.ts +2 -2
- package/dist/types/api/items/update-item-types.d.ts +2 -2
- package/dist/types/misc-types.d.ts +3 -0
- package/dist/types/models/habit-data.d.ts +6 -3
- package/dist/types/models/habit-data.js +16 -1
- package/dist/types/models/user-data.d.ts +2 -2
- package/package.json +1 -1
- package/src/types/api/habits/create-habit-entry-types.ts +2 -2
- package/src/types/api/habits/create-habit-types.ts +2 -2
- package/src/types/api/habits/delete-habit-entry-types.ts +2 -2
- package/src/types/api/habits/get-habits-types.ts +2 -2
- package/src/types/api/habits/update-habit-types.ts +2 -2
- package/src/types/misc-types.ts +11 -1
- package/src/types/models/habit-data.ts +21 -2
|
@@ -1,6 +1,7 @@
|
|
|
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>;
|
|
4
5
|
sandbox: z.ZodOptional<z.ZodObject<{
|
|
5
6
|
discordId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
6
7
|
devices: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -21,7 +22,6 @@ export declare const updateUserRequestSchema: z.ZodObject<{
|
|
|
21
22
|
pushToken?: string | undefined;
|
|
22
23
|
}[] | undefined;
|
|
23
24
|
}>>;
|
|
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;
|
|
80
81
|
sandbox?: {
|
|
81
82
|
discordId?: string | undefined;
|
|
82
83
|
devices?: {
|
|
83
84
|
pushToken?: string | undefined;
|
|
84
85
|
}[] | undefined;
|
|
85
86
|
} | 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;
|
|
102
103
|
sandbox?: {
|
|
103
104
|
discordId?: string | undefined;
|
|
104
105
|
devices?: {
|
|
105
106
|
pushToken?: string | undefined;
|
|
106
107
|
}[] | undefined;
|
|
107
108
|
} | undefined;
|
|
108
|
-
name?: string | undefined;
|
|
109
109
|
timezone?: string | undefined;
|
|
110
110
|
config?: {
|
|
111
111
|
agenda?: {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { DateString } from "../../misc-types";
|
|
3
|
-
import {
|
|
3
|
+
import { Habit } from "../../models";
|
|
4
4
|
export declare const createHabitEntryRequestSchema: z.ZodObject<{
|
|
5
5
|
date: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>;
|
|
6
6
|
status: z.ZodEnum<["completed", "excused"]>;
|
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
status: "completed" | "excused";
|
|
9
8
|
date: Date;
|
|
10
|
-
}, {
|
|
11
9
|
status: "completed" | "excused";
|
|
10
|
+
}, {
|
|
12
11
|
date: string;
|
|
12
|
+
status: "completed" | "excused";
|
|
13
13
|
}>;
|
|
14
14
|
export interface CreateHabitEntryRequest {
|
|
15
15
|
date: DateString;
|
|
16
16
|
status: 'completed' | 'excused';
|
|
17
17
|
}
|
|
18
18
|
export interface CreateHabitEntryResponse {
|
|
19
|
-
habit:
|
|
19
|
+
habit: Habit;
|
|
20
20
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
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>;
|
|
@@ -23,5 +23,5 @@ export interface CreateHabitRequest {
|
|
|
23
23
|
rolloverTime: string;
|
|
24
24
|
}
|
|
25
25
|
export interface CreateHabitResponse {
|
|
26
|
-
habit:
|
|
26
|
+
habit: Habit;
|
|
27
27
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { Habit } from "../../models";
|
|
3
3
|
export declare const updateHabitRequestSchema: z.ZodObject<{
|
|
4
4
|
name: z.ZodOptional<z.ZodString>;
|
|
5
5
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -23,5 +23,5 @@ export interface UpdateHabitRequest {
|
|
|
23
23
|
rolloverTime?: string;
|
|
24
24
|
}
|
|
25
25
|
export interface UpdateHabitResponse {
|
|
26
|
-
habit:
|
|
26
|
+
habit: Habit;
|
|
27
27
|
}
|
|
@@ -7,15 +7,15 @@ 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;
|
|
11
10
|
name?: string | undefined;
|
|
11
|
+
type?: string | null | undefined;
|
|
12
12
|
dueDate?: string | null | undefined;
|
|
13
13
|
notes?: string | undefined;
|
|
14
14
|
urgent?: boolean | undefined;
|
|
15
15
|
category?: string | null | undefined;
|
|
16
16
|
}, {
|
|
17
|
-
type?: string | null | undefined;
|
|
18
17
|
name?: string | undefined;
|
|
18
|
+
type?: string | null | undefined;
|
|
19
19
|
dueDate?: string | null | undefined;
|
|
20
20
|
notes?: string | undefined;
|
|
21
21
|
urgent?: boolean | undefined;
|
|
@@ -3,3 +3,6 @@ export type DateString = string & {
|
|
|
3
3
|
readonly __brand: "DateString";
|
|
4
4
|
};
|
|
5
5
|
export declare const dateSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>;
|
|
6
|
+
export type ToDateString<T> = {
|
|
7
|
+
[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];
|
|
8
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ToDateString } from "../misc-types";
|
|
1
2
|
export declare enum HabitFrequency {
|
|
2
3
|
DAILY = "daily",
|
|
3
4
|
WEEKLY = "weekly",
|
|
@@ -34,7 +35,9 @@ export interface HabitStats {
|
|
|
34
35
|
missedDays: number;
|
|
35
36
|
completionRate: number;
|
|
36
37
|
}
|
|
37
|
-
export
|
|
38
|
-
|
|
38
|
+
export type HabitEntry = ToDateString<HabitEntryData>;
|
|
39
|
+
export type Habit = ToDateString<HabitData> & {
|
|
40
|
+
entries: HabitEntry[];
|
|
39
41
|
stats: HabitStats;
|
|
40
|
-
}
|
|
42
|
+
};
|
|
43
|
+
export declare const toHabit: (data: HabitData, entries: HabitEntryData[], stats: HabitStats) => Habit;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HabitEntryStatus = exports.HabitFrequency = void 0;
|
|
3
|
+
exports.toHabit = exports.HabitEntryStatus = exports.HabitFrequency = void 0;
|
|
4
4
|
var HabitFrequency;
|
|
5
5
|
(function (HabitFrequency) {
|
|
6
6
|
HabitFrequency["DAILY"] = "daily";
|
|
@@ -14,3 +14,18 @@ var HabitEntryStatus;
|
|
|
14
14
|
HabitEntryStatus["COMPLETED"] = "completed";
|
|
15
15
|
HabitEntryStatus["EXCUSED"] = "excused";
|
|
16
16
|
})(HabitEntryStatus || (exports.HabitEntryStatus = HabitEntryStatus = {}));
|
|
17
|
+
const toHabit = (data, entries, stats) => {
|
|
18
|
+
return {
|
|
19
|
+
...data,
|
|
20
|
+
createdAt: data.createdAt.toISOString(),
|
|
21
|
+
updatedAt: data.updatedAt.toISOString(),
|
|
22
|
+
entries: entries.map(entry => ({
|
|
23
|
+
...entry,
|
|
24
|
+
date: entry.date.toISOString(),
|
|
25
|
+
createdAt: entry.createdAt.toISOString(),
|
|
26
|
+
updatedAt: entry.updatedAt.toISOString()
|
|
27
|
+
})),
|
|
28
|
+
stats
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.toHabit = toHabit;
|
|
@@ -95,13 +95,13 @@ export declare const userDataSchema: z.ZodObject<{
|
|
|
95
95
|
};
|
|
96
96
|
createdAt: Date;
|
|
97
97
|
updatedAt: Date;
|
|
98
|
+
name: string;
|
|
98
99
|
sandbox: {
|
|
99
100
|
devices: {
|
|
100
101
|
pushToken: string;
|
|
101
102
|
}[];
|
|
102
103
|
discordId?: string | undefined;
|
|
103
104
|
};
|
|
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;
|
|
123
124
|
sandbox: {
|
|
124
125
|
devices: {
|
|
125
126
|
pushToken: string;
|
|
126
127
|
}[];
|
|
127
128
|
discordId?: string | undefined;
|
|
128
129
|
};
|
|
129
|
-
name: string;
|
|
130
130
|
timezone: string;
|
|
131
131
|
config: {
|
|
132
132
|
agenda: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { dateSchema, DateString } from "../../misc-types";
|
|
3
|
-
import {
|
|
3
|
+
import { Habit } from "../../models";
|
|
4
4
|
|
|
5
5
|
export const createHabitEntryRequestSchema = z.object({
|
|
6
6
|
date: dateSchema,
|
|
@@ -13,5 +13,5 @@ export interface CreateHabitEntryRequest {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface CreateHabitEntryResponse {
|
|
16
|
-
habit:
|
|
16
|
+
habit: Habit;
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { Habit } from "../../models/habit-data";
|
|
3
3
|
|
|
4
4
|
export const createHabitRequestSchema = z.object({
|
|
5
5
|
name: z.string().min(1, 'Name is required').trim(),
|
|
@@ -16,5 +16,5 @@ export interface CreateHabitRequest {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface CreateHabitResponse {
|
|
19
|
-
habit:
|
|
19
|
+
habit: Habit;
|
|
20
20
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { Habit } from "../../models";
|
|
3
3
|
|
|
4
4
|
export const updateHabitRequestSchema = z.object({
|
|
5
5
|
name: z.string().min(1, 'Name is required').trim().optional(),
|
|
@@ -16,5 +16,5 @@ export interface UpdateHabitRequest {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface UpdateHabitResponse {
|
|
19
|
-
habit:
|
|
19
|
+
habit: Habit;
|
|
20
20
|
}
|
package/src/types/misc-types.ts
CHANGED
|
@@ -5,4 +5,14 @@ export const dateSchema = z.string()
|
|
|
5
5
|
.refine(val => !isNaN(Date.parse(val)), {
|
|
6
6
|
message: "Invalid date string",
|
|
7
7
|
})
|
|
8
|
-
.transform(val => new Date(val));
|
|
8
|
+
.transform(val => new Date(val));
|
|
9
|
+
|
|
10
|
+
export type ToDateString<T> = {
|
|
11
|
+
[K in keyof T]: T[K] extends Date
|
|
12
|
+
? DateString
|
|
13
|
+
: T[K] extends Array<infer U>
|
|
14
|
+
? Array<ToDateString<U>>
|
|
15
|
+
: T[K] extends object
|
|
16
|
+
? ToDateString<T[K]>
|
|
17
|
+
: T[K];
|
|
18
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DateString, ToDateString } from "../misc-types";
|
|
2
|
+
|
|
1
3
|
export enum HabitFrequency {
|
|
2
4
|
DAILY = 'daily',
|
|
3
5
|
WEEKLY = 'weekly',
|
|
@@ -39,7 +41,24 @@ export interface HabitStats {
|
|
|
39
41
|
completionRate: number;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
+
export type HabitEntry = ToDateString<HabitEntryData>;
|
|
45
|
+
|
|
46
|
+
export type Habit = ToDateString<HabitData> & {
|
|
47
|
+
entries: HabitEntry[];
|
|
44
48
|
stats: HabitStats;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const toHabit = (data: HabitData, entries: HabitEntryData[], stats: HabitStats): Habit => {
|
|
52
|
+
return {
|
|
53
|
+
...data,
|
|
54
|
+
createdAt: data.createdAt.toISOString() as DateString,
|
|
55
|
+
updatedAt: data.updatedAt.toISOString() as DateString,
|
|
56
|
+
entries: entries.map(entry => ({
|
|
57
|
+
...entry,
|
|
58
|
+
date: entry.date.toISOString() as DateString,
|
|
59
|
+
createdAt: entry.createdAt.toISOString() as DateString,
|
|
60
|
+
updatedAt: entry.updatedAt.toISOString() as DateString
|
|
61
|
+
})),
|
|
62
|
+
stats
|
|
63
|
+
};
|
|
45
64
|
}
|