@timothyw/pat-common 1.0.9 → 1.0.10
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-config-types.d.ts +43 -44
- package/dist/types/api/account/update-user-config-types.js +7 -32
- package/dist/types/api/items/update-item-types.d.ts +2 -2
- package/dist/types/id-types.d.ts +11 -5
- package/dist/types/id-types.js +7 -0
- package/dist/types/models/user-config.d.ts +92 -10
- package/dist/types/models/user-config.js +57 -0
- package/package.json +1 -1
- package/src/types/api/account/update-user-config-types.ts +10 -33
- package/src/types/id-types.ts +15 -5
- package/src/types/models/user-config.ts +60 -24
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { UserConfig } from "../../models";
|
|
2
3
|
export declare const updateUserConfigRequestSchema: z.ZodObject<{
|
|
3
|
-
name: z.ZodOptional<z.
|
|
4
|
-
timezone: z.ZodOptional<z.
|
|
5
|
-
discordID: z.ZodOptional<z.
|
|
6
|
-
itemListTracking: z.ZodOptional<z.
|
|
4
|
+
name: z.ZodOptional<z.ZodString>;
|
|
5
|
+
timezone: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
6
|
+
discordID: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
7
|
+
itemListTracking: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
7
8
|
channelId: z.ZodString;
|
|
8
9
|
messageId: z.ZodString;
|
|
9
10
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -13,8 +14,8 @@ export declare const updateUserConfigRequestSchema: z.ZodObject<{
|
|
|
13
14
|
channelId: string;
|
|
14
15
|
messageId: string;
|
|
15
16
|
}>>>;
|
|
16
|
-
iosApp: z.ZodOptional<z.
|
|
17
|
-
panels: z.
|
|
17
|
+
iosApp: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
panels: z.ZodArray<z.ZodObject<{
|
|
18
19
|
type: z.ZodEnum<["agenda", "tasks", "inbox", "people", "settings"]>;
|
|
19
20
|
visible: z.ZodBoolean;
|
|
20
21
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -23,65 +24,63 @@ export declare const updateUserConfigRequestSchema: z.ZodObject<{
|
|
|
23
24
|
}, {
|
|
24
25
|
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
25
26
|
visible: boolean;
|
|
26
|
-
}>, "many"
|
|
27
|
-
itemCategories: z.
|
|
28
|
-
itemTypes: z.
|
|
29
|
-
propertyKeys: z.
|
|
27
|
+
}>, "many">;
|
|
28
|
+
itemCategories: z.ZodArray<z.ZodString, "many">;
|
|
29
|
+
itemTypes: z.ZodArray<z.ZodString, "many">;
|
|
30
|
+
propertyKeys: z.ZodArray<z.ZodString, "many">;
|
|
30
31
|
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
panels
|
|
32
|
+
panels: {
|
|
32
33
|
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
33
34
|
visible: boolean;
|
|
34
|
-
}[]
|
|
35
|
-
itemCategories
|
|
36
|
-
itemTypes
|
|
37
|
-
propertyKeys
|
|
35
|
+
}[];
|
|
36
|
+
itemCategories: string[];
|
|
37
|
+
itemTypes: string[];
|
|
38
|
+
propertyKeys: string[];
|
|
38
39
|
}, {
|
|
39
|
-
panels
|
|
40
|
+
panels: {
|
|
40
41
|
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
41
42
|
visible: boolean;
|
|
42
|
-
}[]
|
|
43
|
-
itemCategories
|
|
44
|
-
itemTypes
|
|
45
|
-
propertyKeys
|
|
46
|
-
}
|
|
43
|
+
}[];
|
|
44
|
+
itemCategories: string[];
|
|
45
|
+
itemTypes: string[];
|
|
46
|
+
propertyKeys: string[];
|
|
47
|
+
}>>;
|
|
47
48
|
}, "strict", z.ZodTypeAny, {
|
|
48
|
-
name?: string |
|
|
49
|
-
timezone?: string |
|
|
50
|
-
discordID?: string |
|
|
49
|
+
name?: string | undefined;
|
|
50
|
+
timezone?: string | undefined;
|
|
51
|
+
discordID?: string | undefined;
|
|
51
52
|
itemListTracking?: {
|
|
52
53
|
channelId: string;
|
|
53
54
|
messageId: string;
|
|
54
|
-
} |
|
|
55
|
+
} | undefined;
|
|
55
56
|
iosApp?: {
|
|
56
|
-
panels
|
|
57
|
+
panels: {
|
|
57
58
|
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
58
59
|
visible: boolean;
|
|
59
|
-
}[]
|
|
60
|
-
itemCategories
|
|
61
|
-
itemTypes
|
|
62
|
-
propertyKeys
|
|
63
|
-
} |
|
|
60
|
+
}[];
|
|
61
|
+
itemCategories: string[];
|
|
62
|
+
itemTypes: string[];
|
|
63
|
+
propertyKeys: string[];
|
|
64
|
+
} | undefined;
|
|
64
65
|
}, {
|
|
65
|
-
name?: string |
|
|
66
|
-
timezone?: string |
|
|
67
|
-
discordID?: string |
|
|
66
|
+
name?: string | undefined;
|
|
67
|
+
timezone?: string | undefined;
|
|
68
|
+
discordID?: string | undefined;
|
|
68
69
|
itemListTracking?: {
|
|
69
70
|
channelId: string;
|
|
70
71
|
messageId: string;
|
|
71
|
-
} |
|
|
72
|
+
} | undefined;
|
|
72
73
|
iosApp?: {
|
|
73
|
-
panels
|
|
74
|
+
panels: {
|
|
74
75
|
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
75
76
|
visible: boolean;
|
|
76
|
-
}[]
|
|
77
|
-
itemCategories
|
|
78
|
-
itemTypes
|
|
79
|
-
propertyKeys
|
|
80
|
-
} |
|
|
77
|
+
}[];
|
|
78
|
+
itemCategories: string[];
|
|
79
|
+
itemTypes: string[];
|
|
80
|
+
propertyKeys: string[];
|
|
81
|
+
} | undefined;
|
|
81
82
|
}>;
|
|
82
83
|
export type UpdateUserConfigRequest = z.infer<typeof updateUserConfigRequestSchema>;
|
|
83
84
|
export interface UpdateUserConfigResponse {
|
|
84
|
-
user:
|
|
85
|
-
id: string;
|
|
86
|
-
};
|
|
85
|
+
user: UserConfig;
|
|
87
86
|
}
|
|
@@ -1,35 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateUserConfigRequestSchema = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Intl.DateTimeFormat(undefined, { timeZone: tz });
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
catch (e) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}, {
|
|
18
|
-
message: "Invalid timezone"
|
|
19
|
-
})
|
|
20
|
-
.nullish(),
|
|
21
|
-
discordID: zod_1.z.string().nullish(),
|
|
22
|
-
itemListTracking: zod_1.z.object({
|
|
23
|
-
channelId: zod_1.z.string(),
|
|
24
|
-
messageId: zod_1.z.string()
|
|
25
|
-
}).nullish(),
|
|
26
|
-
iosApp: zod_1.z.object({
|
|
27
|
-
panels: zod_1.z.array(zod_1.z.object({
|
|
28
|
-
type: zod_1.z.enum(panels_1.PANEL_TYPES),
|
|
29
|
-
visible: zod_1.z.boolean()
|
|
30
|
-
})).optional(),
|
|
31
|
-
itemCategories: zod_1.z.array(zod_1.z.string()).optional(),
|
|
32
|
-
itemTypes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
33
|
-
propertyKeys: zod_1.z.array(zod_1.z.string()).optional()
|
|
34
|
-
}).nullish()
|
|
35
|
-
}).strict();
|
|
4
|
+
const models_1 = require("../../models");
|
|
5
|
+
exports.updateUserConfigRequestSchema = models_1.userConfigSchema
|
|
6
|
+
.omit({ _id: true, createdAt: true, updatedAt: true })
|
|
7
|
+
.partial()
|
|
8
|
+
.strict();
|
|
9
|
+
const test = null;
|
|
10
|
+
test.iosApp;
|
|
@@ -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
|
-
name?: string | undefined;
|
|
11
10
|
type?: string | null | undefined;
|
|
11
|
+
name?: string | 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
|
-
name?: string | undefined;
|
|
18
17
|
type?: string | null | undefined;
|
|
18
|
+
name?: string | undefined;
|
|
19
19
|
dueDate?: string | null | undefined;
|
|
20
20
|
notes?: string | undefined;
|
|
21
21
|
urgent?: boolean | undefined;
|
package/dist/types/id-types.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const userIdSchema: z.ZodEffects<z.ZodString, UserId, string>;
|
|
1
3
|
export type UserId = string & {
|
|
2
|
-
readonly __brand:
|
|
4
|
+
readonly __brand: "UserId";
|
|
3
5
|
};
|
|
6
|
+
export declare const authIdSchema: z.ZodEffects<z.ZodString, AuthId, string>;
|
|
4
7
|
export type AuthId = string & {
|
|
5
|
-
readonly __brand:
|
|
8
|
+
readonly __brand: "AuthId";
|
|
6
9
|
};
|
|
10
|
+
export declare const itemIdSchema: z.ZodEffects<z.ZodString, ItemId, string>;
|
|
7
11
|
export type ItemId = string & {
|
|
8
|
-
readonly __brand:
|
|
12
|
+
readonly __brand: "ItemId";
|
|
9
13
|
};
|
|
14
|
+
export declare const personIdSchema: z.ZodEffects<z.ZodString, PersonId, string>;
|
|
10
15
|
export type PersonId = string & {
|
|
11
|
-
readonly __brand:
|
|
16
|
+
readonly __brand: "PersonId";
|
|
12
17
|
};
|
|
18
|
+
export declare const thoughtIdSchema: z.ZodEffects<z.ZodString, ThoughtId, string>;
|
|
13
19
|
export type ThoughtId = string & {
|
|
14
|
-
readonly __brand:
|
|
20
|
+
readonly __brand: "ThoughtId";
|
|
15
21
|
};
|
package/dist/types/id-types.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.thoughtIdSchema = exports.personIdSchema = exports.itemIdSchema = exports.authIdSchema = exports.userIdSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.userIdSchema = zod_1.z.string().transform((val) => val);
|
|
6
|
+
exports.authIdSchema = zod_1.z.string().transform((val) => val);
|
|
7
|
+
exports.itemIdSchema = zod_1.z.string().transform((val) => val);
|
|
8
|
+
exports.personIdSchema = zod_1.z.string().transform((val) => val);
|
|
9
|
+
exports.thoughtIdSchema = zod_1.z.string().transform((val) => val);
|
|
@@ -1,24 +1,106 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
import { UserId } from "../id-types";
|
|
3
|
-
|
|
4
|
-
type:
|
|
3
|
+
declare const panelSchema: z.ZodObject<{
|
|
4
|
+
type: z.ZodEnum<["agenda", "tasks", "inbox", "people", "settings"]>;
|
|
5
|
+
visible: z.ZodBoolean;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
5
8
|
visible: boolean;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
}, {
|
|
10
|
+
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
11
|
+
visible: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
export type Panel = z.infer<typeof panelSchema>;
|
|
14
|
+
export declare const userConfigSchema: z.ZodObject<{
|
|
15
|
+
_id: z.ZodEffects<z.ZodString, UserId, string>;
|
|
16
|
+
createdAt: z.ZodDate;
|
|
17
|
+
updatedAt: z.ZodDate;
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
timezone: z.ZodEffects<z.ZodString, string, string>;
|
|
20
|
+
discordID: z.ZodOptional<z.ZodString>;
|
|
21
|
+
itemListTracking: z.ZodOptional<z.ZodObject<{
|
|
22
|
+
channelId: z.ZodString;
|
|
23
|
+
messageId: z.ZodString;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
channelId: string;
|
|
26
|
+
messageId: string;
|
|
27
|
+
}, {
|
|
28
|
+
channelId: string;
|
|
29
|
+
messageId: string;
|
|
30
|
+
}>>;
|
|
31
|
+
iosApp: z.ZodObject<{
|
|
32
|
+
panels: z.ZodArray<z.ZodObject<{
|
|
33
|
+
type: z.ZodEnum<["agenda", "tasks", "inbox", "people", "settings"]>;
|
|
34
|
+
visible: z.ZodBoolean;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
37
|
+
visible: boolean;
|
|
38
|
+
}, {
|
|
39
|
+
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
40
|
+
visible: boolean;
|
|
41
|
+
}>, "many">;
|
|
42
|
+
itemCategories: z.ZodArray<z.ZodString, "many">;
|
|
43
|
+
itemTypes: z.ZodArray<z.ZodString, "many">;
|
|
44
|
+
propertyKeys: z.ZodArray<z.ZodString, "many">;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
panels: {
|
|
47
|
+
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
48
|
+
visible: boolean;
|
|
49
|
+
}[];
|
|
50
|
+
itemCategories: string[];
|
|
51
|
+
itemTypes: string[];
|
|
52
|
+
propertyKeys: string[];
|
|
53
|
+
}, {
|
|
54
|
+
panels: {
|
|
55
|
+
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
56
|
+
visible: boolean;
|
|
57
|
+
}[];
|
|
58
|
+
itemCategories: string[];
|
|
59
|
+
itemTypes: string[];
|
|
60
|
+
propertyKeys: string[];
|
|
61
|
+
}>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
_id: string & {
|
|
64
|
+
readonly __brand: "UserId";
|
|
65
|
+
};
|
|
9
66
|
createdAt: Date;
|
|
10
67
|
updatedAt: Date;
|
|
11
68
|
name: string;
|
|
12
69
|
timezone: string;
|
|
13
|
-
|
|
70
|
+
iosApp: {
|
|
71
|
+
panels: {
|
|
72
|
+
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
73
|
+
visible: boolean;
|
|
74
|
+
}[];
|
|
75
|
+
itemCategories: string[];
|
|
76
|
+
itemTypes: string[];
|
|
77
|
+
propertyKeys: string[];
|
|
78
|
+
};
|
|
79
|
+
discordID?: string | undefined;
|
|
14
80
|
itemListTracking?: {
|
|
15
81
|
channelId: string;
|
|
16
82
|
messageId: string;
|
|
17
|
-
};
|
|
83
|
+
} | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
_id: string;
|
|
86
|
+
createdAt: Date;
|
|
87
|
+
updatedAt: Date;
|
|
88
|
+
name: string;
|
|
89
|
+
timezone: string;
|
|
18
90
|
iosApp: {
|
|
19
|
-
panels:
|
|
91
|
+
panels: {
|
|
92
|
+
type: "agenda" | "tasks" | "inbox" | "people" | "settings";
|
|
93
|
+
visible: boolean;
|
|
94
|
+
}[];
|
|
20
95
|
itemCategories: string[];
|
|
21
96
|
itemTypes: string[];
|
|
22
97
|
propertyKeys: string[];
|
|
23
98
|
};
|
|
24
|
-
|
|
99
|
+
discordID?: string | undefined;
|
|
100
|
+
itemListTracking?: {
|
|
101
|
+
channelId: string;
|
|
102
|
+
messageId: string;
|
|
103
|
+
} | undefined;
|
|
104
|
+
}>;
|
|
105
|
+
export type UserConfig = z.infer<typeof userConfigSchema>;
|
|
106
|
+
export {};
|
|
@@ -1,2 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.userConfigSchema = void 0;
|
|
4
|
+
const panels_1 = require("../panels");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const id_types_1 = require("../id-types");
|
|
7
|
+
const panelSchema = zod_1.z.object({
|
|
8
|
+
type: zod_1.z.enum(panels_1.PANEL_TYPES),
|
|
9
|
+
visible: zod_1.z.boolean()
|
|
10
|
+
});
|
|
11
|
+
// export interface Panel {
|
|
12
|
+
// type: PanelType;
|
|
13
|
+
// visible: boolean;
|
|
14
|
+
// }
|
|
15
|
+
exports.userConfigSchema = zod_1.z.object({
|
|
16
|
+
_id: id_types_1.userIdSchema,
|
|
17
|
+
createdAt: zod_1.z.date(),
|
|
18
|
+
updatedAt: zod_1.z.date(),
|
|
19
|
+
name: zod_1.z.string().min(1),
|
|
20
|
+
timezone: zod_1.z.string().refine((tz) => {
|
|
21
|
+
try {
|
|
22
|
+
Intl.DateTimeFormat(undefined, { timeZone: tz });
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}, { message: "Invalid timezone" }),
|
|
29
|
+
discordID: zod_1.z.string().optional(),
|
|
30
|
+
itemListTracking: zod_1.z.object({
|
|
31
|
+
channelId: zod_1.z.string(),
|
|
32
|
+
messageId: zod_1.z.string()
|
|
33
|
+
}).optional(),
|
|
34
|
+
iosApp: zod_1.z.object({
|
|
35
|
+
panels: zod_1.z.array(panelSchema),
|
|
36
|
+
itemCategories: zod_1.z.array(zod_1.z.string()),
|
|
37
|
+
itemTypes: zod_1.z.array(zod_1.z.string()),
|
|
38
|
+
propertyKeys: zod_1.z.array(zod_1.z.string())
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
// export interface UserConfig {
|
|
42
|
+
// _id: UserId;
|
|
43
|
+
// createdAt: Date;
|
|
44
|
+
// updatedAt: Date;
|
|
45
|
+
//
|
|
46
|
+
// name: string;
|
|
47
|
+
// timezone: string;
|
|
48
|
+
// discordID?: string;
|
|
49
|
+
// itemListTracking?: {
|
|
50
|
+
// channelId: string;
|
|
51
|
+
// messageId: string;
|
|
52
|
+
// };
|
|
53
|
+
// iosApp: {
|
|
54
|
+
// panels: Panel[];
|
|
55
|
+
// itemCategories: string[];
|
|
56
|
+
// itemTypes: string[];
|
|
57
|
+
// propertyKeys: string[];
|
|
58
|
+
// };
|
|
59
|
+
// }
|
package/package.json
CHANGED
|
@@ -1,40 +1,17 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { UserId } from "../../id-types";
|
|
3
|
+
import { UserConfig, userConfigSchema } from "../../models";
|
|
3
4
|
|
|
4
|
-
export const updateUserConfigRequestSchema =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
Intl.DateTimeFormat(undefined, { timeZone: tz });
|
|
10
|
-
return true;
|
|
11
|
-
} catch (e) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}, {
|
|
15
|
-
message: "Invalid timezone"
|
|
16
|
-
})
|
|
17
|
-
.nullish(),
|
|
18
|
-
discordID: z.string().nullish(),
|
|
19
|
-
itemListTracking: z.object({
|
|
20
|
-
channelId: z.string(),
|
|
21
|
-
messageId: z.string()
|
|
22
|
-
}).nullish(),
|
|
23
|
-
iosApp: z.object({
|
|
24
|
-
panels: z.array(z.object({
|
|
25
|
-
type: z.enum(PANEL_TYPES),
|
|
26
|
-
visible: z.boolean()
|
|
27
|
-
})).optional(),
|
|
28
|
-
itemCategories: z.array(z.string()).optional(),
|
|
29
|
-
itemTypes: z.array(z.string()).optional(),
|
|
30
|
-
propertyKeys: z.array(z.string()).optional()
|
|
31
|
-
}).nullish()
|
|
32
|
-
}).strict();
|
|
5
|
+
export const updateUserConfigRequestSchema = userConfigSchema
|
|
6
|
+
.omit({ _id: true, createdAt: true, updatedAt: true })
|
|
7
|
+
.partial()
|
|
8
|
+
.strict();
|
|
33
9
|
|
|
34
10
|
export type UpdateUserConfigRequest = z.infer<typeof updateUserConfigRequestSchema>;
|
|
35
11
|
|
|
12
|
+
const test: UpdateUserConfigRequest | null = null;
|
|
13
|
+
test!.iosApp
|
|
14
|
+
|
|
36
15
|
export interface UpdateUserConfigResponse {
|
|
37
|
-
user:
|
|
38
|
-
id: string;
|
|
39
|
-
};
|
|
16
|
+
user: UserConfig
|
|
40
17
|
}
|
package/src/types/id-types.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export type AuthId = string & { readonly __brand: unique symbol };
|
|
1
|
+
import { z } from "zod";
|
|
3
2
|
|
|
4
|
-
export
|
|
5
|
-
export type
|
|
6
|
-
|
|
3
|
+
export const userIdSchema = z.string().transform((val): UserId => val as UserId);
|
|
4
|
+
export type UserId = string & { readonly __brand: "UserId" };
|
|
5
|
+
|
|
6
|
+
export const authIdSchema = z.string().transform((val): AuthId => val as AuthId);
|
|
7
|
+
export type AuthId = string & { readonly __brand: "AuthId" };
|
|
8
|
+
|
|
9
|
+
export const itemIdSchema = z.string().transform((val): ItemId => val as ItemId);
|
|
10
|
+
export type ItemId = string & { readonly __brand: "ItemId" };
|
|
11
|
+
|
|
12
|
+
export const personIdSchema = z.string().transform((val): PersonId => val as PersonId);
|
|
13
|
+
export type PersonId = string & { readonly __brand: "PersonId" };
|
|
14
|
+
|
|
15
|
+
export const thoughtIdSchema = z.string().transform((val): ThoughtId => val as ThoughtId);
|
|
16
|
+
export type ThoughtId = string & { readonly __brand: "ThoughtId" };
|
|
@@ -1,27 +1,63 @@
|
|
|
1
|
-
import { PanelType } from "../panels";
|
|
2
|
-
import {
|
|
1
|
+
import { PANEL_TYPES, PanelType } from "../panels";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { AuthId, UserId, userIdSchema } from "../id-types";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
type:
|
|
6
|
-
visible: boolean
|
|
7
|
-
}
|
|
5
|
+
const panelSchema = z.object({
|
|
6
|
+
type: z.enum(PANEL_TYPES),
|
|
7
|
+
visible: z.boolean()
|
|
8
|
+
});
|
|
8
9
|
|
|
9
|
-
export
|
|
10
|
-
_id: UserId;
|
|
11
|
-
createdAt: Date;
|
|
12
|
-
updatedAt: Date;
|
|
10
|
+
export type Panel = z.infer<typeof panelSchema>;
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
// export interface Panel {
|
|
13
|
+
// type: PanelType;
|
|
14
|
+
// visible: boolean;
|
|
15
|
+
// }
|
|
16
|
+
|
|
17
|
+
export const userConfigSchema = z.object({
|
|
18
|
+
_id: userIdSchema,
|
|
19
|
+
createdAt: z.date(),
|
|
20
|
+
updatedAt: z.date(),
|
|
21
|
+
name: z.string().min(1),
|
|
22
|
+
timezone: z.string().refine((tz: string) => {
|
|
23
|
+
try {
|
|
24
|
+
Intl.DateTimeFormat(undefined, { timeZone: tz });
|
|
25
|
+
return true;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}, { message: "Invalid timezone" }),
|
|
30
|
+
discordID: z.string().optional(),
|
|
31
|
+
itemListTracking: z.object({
|
|
32
|
+
channelId: z.string(),
|
|
33
|
+
messageId: z.string()
|
|
34
|
+
}).optional(),
|
|
35
|
+
iosApp: z.object({
|
|
36
|
+
panels: z.array(panelSchema),
|
|
37
|
+
itemCategories: z.array(z.string()),
|
|
38
|
+
itemTypes: z.array(z.string()),
|
|
39
|
+
propertyKeys: z.array(z.string())
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export type UserConfig = z.infer<typeof userConfigSchema>;
|
|
44
|
+
|
|
45
|
+
// export interface UserConfig {
|
|
46
|
+
// _id: UserId;
|
|
47
|
+
// createdAt: Date;
|
|
48
|
+
// updatedAt: Date;
|
|
49
|
+
//
|
|
50
|
+
// name: string;
|
|
51
|
+
// timezone: string;
|
|
52
|
+
// discordID?: string;
|
|
53
|
+
// itemListTracking?: {
|
|
54
|
+
// channelId: string;
|
|
55
|
+
// messageId: string;
|
|
56
|
+
// };
|
|
57
|
+
// iosApp: {
|
|
58
|
+
// panels: Panel[];
|
|
59
|
+
// itemCategories: string[];
|
|
60
|
+
// itemTypes: string[];
|
|
61
|
+
// propertyKeys: string[];
|
|
62
|
+
// };
|
|
63
|
+
// }
|