@timothyw/pat-common 1.0.81 → 1.0.82
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-types.d.ts +2 -2
- package/dist/types/api/habits/update-habit-types.d.ts +2 -2
- package/dist/types/api/items/create-item-types.d.ts +4 -4
- package/dist/types/api/items/update-item-types.d.ts +4 -4
- package/dist/types/api/people/create-person-types.d.ts +4 -4
- package/dist/types/api/people/update-person-types.d.ts +4 -4
- package/dist/types/models/item-data.d.ts +7 -0
- package/dist/types/models/item-data.js +58 -0
- package/dist/types/models/user-data.d.ts +2 -2
- package/package.json +1 -1
- package/src/types/models/item-data.ts +81 -0
|
@@ -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?: {
|
|
@@ -10,14 +10,14 @@ export declare const createHabitRequestSchema: z.ZodObject<{
|
|
|
10
10
|
name: string;
|
|
11
11
|
frequency: HabitFrequency;
|
|
12
12
|
rolloverTime: string;
|
|
13
|
-
description?: string | undefined;
|
|
14
13
|
notes?: string | undefined;
|
|
14
|
+
description?: string | undefined;
|
|
15
15
|
}, {
|
|
16
16
|
name: string;
|
|
17
17
|
frequency: HabitFrequency;
|
|
18
18
|
rolloverTime: string;
|
|
19
|
-
description?: string | undefined;
|
|
20
19
|
notes?: string | undefined;
|
|
20
|
+
description?: string | undefined;
|
|
21
21
|
}>;
|
|
22
22
|
export type CreateHabitRequest = z.infer<typeof createHabitRequestSchema>;
|
|
23
23
|
export interface CreateHabitResponse {
|
|
@@ -8,14 +8,14 @@ export declare const updateHabitRequestSchema: z.ZodObject<{
|
|
|
8
8
|
rolloverTime: z.ZodOptional<z.ZodString>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
10
|
name?: string | undefined;
|
|
11
|
-
description?: string | null | undefined;
|
|
12
11
|
notes?: string | null | undefined;
|
|
12
|
+
description?: string | null | undefined;
|
|
13
13
|
frequency?: HabitFrequency | undefined;
|
|
14
14
|
rolloverTime?: string | undefined;
|
|
15
15
|
}, {
|
|
16
16
|
name?: string | undefined;
|
|
17
|
-
description?: string | null | undefined;
|
|
18
17
|
notes?: string | null | undefined;
|
|
18
|
+
description?: string | null | undefined;
|
|
19
19
|
frequency?: HabitFrequency | undefined;
|
|
20
20
|
rolloverTime?: string | undefined;
|
|
21
21
|
}>;
|
|
@@ -10,17 +10,17 @@ export declare const createItemRequestSchema: z.ZodObject<{
|
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
11
|
name: string;
|
|
12
12
|
urgent: boolean;
|
|
13
|
-
type?: string | null | undefined;
|
|
14
|
-
notes?: string | undefined;
|
|
15
13
|
dueDate?: string | null | undefined;
|
|
14
|
+
notes?: string | undefined;
|
|
16
15
|
category?: string | null | undefined;
|
|
16
|
+
type?: string | null | undefined;
|
|
17
17
|
}, {
|
|
18
18
|
name: string;
|
|
19
|
-
type?: string | null | undefined;
|
|
20
|
-
notes?: string | undefined;
|
|
21
19
|
dueDate?: string | null | undefined;
|
|
20
|
+
notes?: string | undefined;
|
|
22
21
|
urgent?: boolean | undefined;
|
|
23
22
|
category?: string | null | undefined;
|
|
23
|
+
type?: string | null | undefined;
|
|
24
24
|
}>;
|
|
25
25
|
export type CreateItemRequest = z.infer<typeof createItemRequestSchema>;
|
|
26
26
|
export interface CreateItemResponse {
|
|
@@ -8,19 +8,19 @@ export declare const updateItemRequestSchema: z.ZodObject<{
|
|
|
8
8
|
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
9
|
type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
type?: string | null | undefined;
|
|
12
11
|
name?: string | undefined;
|
|
13
|
-
notes?: string | null | undefined;
|
|
14
12
|
dueDate?: Date | null | undefined;
|
|
13
|
+
notes?: string | null | undefined;
|
|
15
14
|
urgent?: boolean | undefined;
|
|
16
15
|
category?: string | null | undefined;
|
|
17
|
-
}, {
|
|
18
16
|
type?: string | null | undefined;
|
|
17
|
+
}, {
|
|
19
18
|
name?: string | undefined;
|
|
20
|
-
notes?: string | null | undefined;
|
|
21
19
|
dueDate?: string | null | undefined;
|
|
20
|
+
notes?: string | null | undefined;
|
|
22
21
|
urgent?: boolean | undefined;
|
|
23
22
|
category?: string | null | undefined;
|
|
23
|
+
type?: string | null | undefined;
|
|
24
24
|
}>;
|
|
25
25
|
export type UpdateItemRequest = z.infer<typeof updateItemRequestSchema>;
|
|
26
26
|
export interface UpdateItemResponse {
|
|
@@ -7,26 +7,26 @@ export declare const createPersonRequestSchema: z.ZodObject<{
|
|
|
7
7
|
key: z.ZodString;
|
|
8
8
|
value: z.ZodString;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
value: string;
|
|
11
10
|
key: string;
|
|
12
|
-
}, {
|
|
13
11
|
value: string;
|
|
12
|
+
}, {
|
|
14
13
|
key: string;
|
|
14
|
+
value: string;
|
|
15
15
|
}>, "many">>;
|
|
16
16
|
notes: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, PersonNoteId, string>, "many">>;
|
|
17
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
18
|
name: string;
|
|
19
19
|
notes?: PersonNoteId[] | undefined;
|
|
20
20
|
properties?: {
|
|
21
|
-
value: string;
|
|
22
21
|
key: string;
|
|
22
|
+
value: string;
|
|
23
23
|
}[] | undefined;
|
|
24
24
|
}, {
|
|
25
25
|
name: string;
|
|
26
26
|
notes?: string[] | undefined;
|
|
27
27
|
properties?: {
|
|
28
|
-
value: string;
|
|
29
28
|
key: string;
|
|
29
|
+
value: string;
|
|
30
30
|
}[] | undefined;
|
|
31
31
|
}>;
|
|
32
32
|
export type CreatePersonRequest = z.infer<typeof createPersonRequestSchema>;
|
|
@@ -7,25 +7,25 @@ export declare const updatePersonRequestSchema: z.ZodObject<{
|
|
|
7
7
|
key: z.ZodString;
|
|
8
8
|
value: z.ZodString;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
value: string;
|
|
11
10
|
key: string;
|
|
12
|
-
}, {
|
|
13
11
|
value: string;
|
|
12
|
+
}, {
|
|
14
13
|
key: string;
|
|
14
|
+
value: string;
|
|
15
15
|
}>, "many">>;
|
|
16
16
|
noteIds: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, PersonNoteId, string>, "many">>;
|
|
17
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
18
|
name?: string | undefined;
|
|
19
19
|
properties?: {
|
|
20
|
-
value: string;
|
|
21
20
|
key: string;
|
|
21
|
+
value: string;
|
|
22
22
|
}[] | undefined;
|
|
23
23
|
noteIds?: PersonNoteId[] | undefined;
|
|
24
24
|
}, {
|
|
25
25
|
name?: string | undefined;
|
|
26
26
|
properties?: {
|
|
27
|
-
value: string;
|
|
28
27
|
key: string;
|
|
28
|
+
value: string;
|
|
29
29
|
}[] | undefined;
|
|
30
30
|
noteIds?: string[] | undefined;
|
|
31
31
|
}>;
|
|
@@ -12,3 +12,10 @@ export interface ItemData {
|
|
|
12
12
|
category?: string;
|
|
13
13
|
type?: string;
|
|
14
14
|
}
|
|
15
|
+
export type Serialized<T> = T extends Date ? string : T extends Date | undefined ? string | undefined : T extends Date | null ? string | null : T extends (infer U)[] ? Serialized<U>[] : T extends object ? {
|
|
16
|
+
[K in keyof T]: Serialized<T[K]>;
|
|
17
|
+
} : T;
|
|
18
|
+
export declare function serialize<T>(obj: T): Serialized<T>;
|
|
19
|
+
export declare function deserialize<T>(obj: Serialized<T>): T;
|
|
20
|
+
export declare function serializeItemData(item: ItemData): Serialized<ItemData>;
|
|
21
|
+
export declare function deserializeItemData(apiData: Serialized<ItemData>): ItemData;
|
|
@@ -1,2 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serialize = serialize;
|
|
4
|
+
exports.deserialize = deserialize;
|
|
5
|
+
exports.serializeItemData = serializeItemData;
|
|
6
|
+
exports.deserializeItemData = deserializeItemData;
|
|
7
|
+
function serialize(obj) {
|
|
8
|
+
return serializeRecursive(obj);
|
|
9
|
+
}
|
|
10
|
+
function deserialize(obj) {
|
|
11
|
+
return deserializeRecursive(obj);
|
|
12
|
+
}
|
|
13
|
+
function serializeRecursive(obj) {
|
|
14
|
+
if (obj === null || obj === undefined) {
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
17
|
+
if (obj instanceof Date) {
|
|
18
|
+
return obj.toISOString();
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(obj)) {
|
|
21
|
+
return obj.map(item => serializeRecursive(item));
|
|
22
|
+
}
|
|
23
|
+
if (typeof obj === 'object') {
|
|
24
|
+
const result = {};
|
|
25
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
26
|
+
result[key] = serializeRecursive(value);
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
function deserializeRecursive(obj) {
|
|
33
|
+
if (obj === null || obj === undefined) {
|
|
34
|
+
return obj;
|
|
35
|
+
}
|
|
36
|
+
if (typeof obj === 'string' && isISODateString(obj)) {
|
|
37
|
+
return new Date(obj);
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(obj)) {
|
|
40
|
+
return obj.map(item => deserializeRecursive(item));
|
|
41
|
+
}
|
|
42
|
+
if (typeof obj === 'object') {
|
|
43
|
+
const result = {};
|
|
44
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
45
|
+
result[key] = deserializeRecursive(value);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
51
|
+
function isISODateString(value) {
|
|
52
|
+
const isoRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/;
|
|
53
|
+
return isoRegex.test(value) && !isNaN(Date.parse(value));
|
|
54
|
+
}
|
|
55
|
+
function serializeItemData(item) {
|
|
56
|
+
return serialize(item);
|
|
57
|
+
}
|
|
58
|
+
function deserializeItemData(apiData) {
|
|
59
|
+
return deserialize(apiData);
|
|
60
|
+
}
|
|
@@ -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
|
@@ -13,4 +13,85 @@ export interface ItemData {
|
|
|
13
13
|
urgent: boolean;
|
|
14
14
|
category?: string;
|
|
15
15
|
type?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type Serialized<T> = T extends Date
|
|
19
|
+
? string
|
|
20
|
+
: T extends Date | undefined
|
|
21
|
+
? string | undefined
|
|
22
|
+
: T extends Date | null
|
|
23
|
+
? string | null
|
|
24
|
+
: T extends (infer U)[]
|
|
25
|
+
? Serialized<U>[]
|
|
26
|
+
: T extends object
|
|
27
|
+
? { [K in keyof T]: Serialized<T[K]> }
|
|
28
|
+
: T;
|
|
29
|
+
|
|
30
|
+
export function serialize<T>(obj: T): Serialized<T> {
|
|
31
|
+
return serializeRecursive(obj) as Serialized<T>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function deserialize<T>(obj: Serialized<T>): T {
|
|
35
|
+
return deserializeRecursive(obj) as T;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function serializeRecursive(obj: any): any {
|
|
39
|
+
if (obj === null || obj === undefined) {
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (obj instanceof Date) {
|
|
44
|
+
return obj.toISOString();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (Array.isArray(obj)) {
|
|
48
|
+
return obj.map(item => serializeRecursive(item));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (typeof obj === 'object') {
|
|
52
|
+
const result: any = {};
|
|
53
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
54
|
+
result[key] = serializeRecursive(value);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return obj;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function deserializeRecursive(obj: any): any {
|
|
63
|
+
if (obj === null || obj === undefined) {
|
|
64
|
+
return obj;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (typeof obj === 'string' && isISODateString(obj)) {
|
|
68
|
+
return new Date(obj);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (Array.isArray(obj)) {
|
|
72
|
+
return obj.map(item => deserializeRecursive(item));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (typeof obj === 'object') {
|
|
76
|
+
const result: any = {};
|
|
77
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
78
|
+
result[key] = deserializeRecursive(value);
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return obj;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function isISODateString(value: string): boolean {
|
|
87
|
+
const isoRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/;
|
|
88
|
+
return isoRegex.test(value) && !isNaN(Date.parse(value));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function serializeItemData(item: ItemData): Serialized<ItemData> {
|
|
92
|
+
return serialize(item);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function deserializeItemData(apiData: Serialized<ItemData>): ItemData {
|
|
96
|
+
return deserialize(apiData) as unknown as ItemData;
|
|
16
97
|
}
|