@timothyw/pat-common 1.0.113 → 1.0.116
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/id-types.d.ts +2 -2
- package/dist/types/index.d.ts +1 -3
- package/dist/types/index.js +4 -3
- package/dist/types/new/agenda-types.d.ts +116 -0
- package/dist/types/new/agenda-types.js +37 -0
- package/dist/types/new/auth-types.d.ts +153 -0
- package/dist/types/new/auth-types.js +48 -0
- package/dist/types/new/habits-types.d.ts +317 -0
- package/dist/types/new/habits-types.js +70 -0
- package/dist/types/new/index.d.ts +10 -0
- package/dist/types/new/index.js +26 -0
- package/dist/types/new/lists-types.d.ts +164 -0
- package/dist/types/new/lists-types.js +50 -0
- package/dist/types/new/misc/index.d.ts +1 -0
- package/dist/types/new/misc/index.js +17 -0
- package/dist/types/new/misc/version-types.d.ts +26 -0
- package/dist/types/new/misc/version-types.js +13 -0
- package/dist/types/new/notifications-types.d.ts +407 -0
- package/dist/types/new/notifications-types.js +91 -0
- package/dist/types/new/people-types.d.ts +285 -0
- package/dist/types/new/people-types.js +58 -0
- package/dist/types/new/program-config-types.d.ts +105 -0
- package/dist/types/new/program-config-types.js +29 -0
- package/dist/types/new/thoughts-types.d.ts +57 -0
- package/dist/types/new/thoughts-types.js +18 -0
- package/dist/types/new/user-types.d.ts +283 -0
- package/dist/types/new/user-types.js +46 -0
- package/dist/types/old/api/account/get-user-types.d.ts +5 -0
- package/dist/types/old/api/account/get-user-types.js +2 -0
- package/dist/types/old/api/account/index.d.ts +2 -0
- package/dist/types/old/api/account/index.js +18 -0
- package/dist/types/old/api/account/update-user-types.d.ts +128 -0
- package/dist/types/old/api/account/update-user-types.js +8 -0
- package/dist/types/old/api/auth/create-account-types.d.ts +24 -0
- package/dist/types/old/api/auth/create-account-types.js +10 -0
- package/dist/types/old/api/auth/index.d.ts +5 -0
- package/dist/types/old/api/auth/index.js +21 -0
- package/dist/types/old/api/auth/refresh-auth-types.d.ts +15 -0
- package/dist/types/old/api/auth/refresh-auth-types.js +7 -0
- package/dist/types/old/api/auth/resend-verification-types.d.ts +3 -0
- package/dist/types/old/api/auth/resend-verification-types.js +2 -0
- package/dist/types/old/api/auth/sign-in-types.d.ts +19 -0
- package/dist/types/old/api/auth/sign-in-types.js +8 -0
- package/dist/types/old/api/auth/verify-email-types.d.ts +3 -0
- package/dist/types/old/api/auth/verify-email-types.js +2 -0
- package/dist/types/old/api/habits/create-habit-entry-types.d.ts +19 -0
- package/dist/types/old/api/habits/create-habit-entry-types.js +10 -0
- package/dist/types/old/api/habits/create-habit-types.d.ts +26 -0
- package/dist/types/old/api/habits/create-habit-types.js +12 -0
- package/dist/types/old/api/habits/delete-habit-entry-types.d.ts +5 -0
- package/dist/types/old/api/habits/delete-habit-entry-types.js +2 -0
- package/dist/types/old/api/habits/delete-habit-types.d.ts +3 -0
- package/dist/types/old/api/habits/delete-habit-types.js +2 -0
- package/dist/types/old/api/habits/get-habits-types.d.ts +5 -0
- package/dist/types/old/api/habits/get-habits-types.js +2 -0
- package/dist/types/old/api/habits/index.d.ts +6 -0
- package/dist/types/old/api/habits/index.js +22 -0
- package/dist/types/old/api/habits/update-habit-types.d.ts +26 -0
- package/dist/types/old/api/habits/update-habit-types.js +12 -0
- package/dist/types/old/api/index.d.ts +9 -0
- package/dist/types/old/api/index.js +25 -0
- package/dist/types/old/api/items/complete-item-types.d.ts +14 -0
- package/dist/types/old/api/items/complete-item-types.js +7 -0
- package/dist/types/old/api/items/create-item-types.d.ts +29 -0
- package/dist/types/old/api/items/create-item-types.js +12 -0
- package/dist/types/old/api/items/delete-item-types.d.ts +3 -0
- package/dist/types/old/api/items/delete-item-types.js +2 -0
- package/dist/types/old/api/items/get-items-types.d.ts +5 -0
- package/dist/types/old/api/items/get-items-types.js +2 -0
- package/dist/types/old/api/items/index.d.ts +5 -0
- package/dist/types/old/api/items/index.js +21 -0
- package/dist/types/old/api/items/update-item-types.d.ts +29 -0
- package/dist/types/old/api/items/update-item-types.js +12 -0
- package/dist/types/old/api/lists/complete-list-item-types.d.ts +14 -0
- package/dist/types/old/api/lists/complete-list-item-types.js +7 -0
- package/dist/types/old/api/lists/create-list-item-types.d.ts +22 -0
- package/dist/types/old/api/lists/create-list-item-types.js +10 -0
- package/dist/types/old/api/lists/create-list-types.d.ts +17 -0
- package/dist/types/old/api/lists/create-list-types.js +9 -0
- package/dist/types/old/api/lists/get-list-item-types.d.ts +5 -0
- package/dist/types/old/api/lists/get-list-item-types.js +2 -0
- package/dist/types/old/api/lists/get-lists-types.d.ts +5 -0
- package/dist/types/old/api/lists/get-lists-types.js +2 -0
- package/dist/types/old/api/lists/index.d.ts +7 -0
- package/dist/types/old/api/lists/index.js +23 -0
- package/dist/types/old/api/lists/update-list-item-types.d.ts +23 -0
- package/dist/types/old/api/lists/update-list-item-types.js +11 -0
- package/dist/types/old/api/lists/update-list-types.d.ts +17 -0
- package/dist/types/old/api/lists/update-list-types.js +9 -0
- package/dist/types/old/api/misc/index.d.ts +1 -0
- package/dist/types/old/api/misc/index.js +17 -0
- package/dist/types/old/api/misc/version-types.d.ts +9 -0
- package/dist/types/old/api/misc/version-types.js +2 -0
- package/dist/types/old/api/notifications/create-notification-template-types.d.ts +78 -0
- package/dist/types/old/api/notifications/create-notification-template-types.js +25 -0
- package/dist/types/old/api/notifications/delete-notification-template-types.d.ts +5 -0
- package/dist/types/old/api/notifications/delete-notification-template-types.js +6 -0
- package/dist/types/old/api/notifications/get-notification-templates-types.d.ts +8 -0
- package/dist/types/old/api/notifications/get-notification-templates-types.js +6 -0
- package/dist/types/old/api/notifications/index.d.ts +6 -0
- package/dist/types/old/api/notifications/index.js +22 -0
- package/dist/types/old/api/notifications/preview-notification-template-types.d.ts +29 -0
- package/dist/types/old/api/notifications/preview-notification-template-types.js +12 -0
- package/dist/types/old/api/notifications/sync-notification-template-types.d.ts +14 -0
- package/dist/types/old/api/notifications/sync-notification-template-types.js +8 -0
- package/dist/types/old/api/notifications/update-notification-template-types.d.ts +69 -0
- package/dist/types/old/api/notifications/update-notification-template-types.js +22 -0
- package/dist/types/old/api/people/create-person-note-types.d.ts +19 -0
- package/dist/types/old/api/people/create-person-note-types.js +9 -0
- package/dist/types/old/api/people/create-person-types.d.ts +35 -0
- package/dist/types/old/api/people/create-person-types.js +13 -0
- package/dist/types/old/api/people/delete-person-notes-types.d.ts +3 -0
- package/dist/types/old/api/people/delete-person-notes-types.js +2 -0
- package/dist/types/old/api/people/delete-person-types.d.ts +3 -0
- package/dist/types/old/api/people/delete-person-types.js +2 -0
- package/dist/types/old/api/people/get-people-types.d.ts +5 -0
- package/dist/types/old/api/people/get-people-types.js +2 -0
- package/dist/types/old/api/people/get-person-notes-types.d.ts +5 -0
- package/dist/types/old/api/people/get-person-notes-types.js +2 -0
- package/dist/types/old/api/people/index.d.ts +8 -0
- package/dist/types/old/api/people/index.js +24 -0
- package/dist/types/old/api/people/update-person-note-types.d.ts +14 -0
- package/dist/types/old/api/people/update-person-note-types.js +7 -0
- package/dist/types/old/api/people/update-person-types.d.ts +35 -0
- package/dist/types/old/api/people/update-person-types.js +13 -0
- package/dist/types/old/api/thoughts/create-thought-types.d.ts +14 -0
- package/dist/types/old/api/thoughts/create-thought-types.js +7 -0
- package/dist/types/old/api/thoughts/delete-thought-types.d.ts +3 -0
- package/dist/types/old/api/thoughts/delete-thought-types.js +2 -0
- package/dist/types/old/api/thoughts/get-thoughts-types.d.ts +5 -0
- package/dist/types/old/api/thoughts/get-thoughts-types.js +2 -0
- package/dist/types/old/api/thoughts/index.d.ts +4 -0
- package/dist/types/old/api/thoughts/index.js +20 -0
- package/dist/types/old/api/thoughts/update-thought-types.d.ts +14 -0
- package/dist/types/old/api/thoughts/update-thought-types.js +7 -0
- package/dist/types/old/auth-tokens.d.ts +11 -0
- package/dist/types/old/auth-tokens.js +2 -0
- package/dist/types/old/models/auth-data.d.ts +14 -0
- package/dist/types/old/models/auth-data.js +9 -0
- package/dist/types/old/models/habit-data.d.ts +48 -0
- package/dist/types/old/models/habit-data.js +25 -0
- package/dist/types/old/models/index.d.ts +10 -0
- package/dist/types/old/models/index.js +26 -0
- package/dist/types/old/models/item-data.d.ts +14 -0
- package/dist/types/old/models/item-data.js +2 -0
- package/dist/types/old/models/list-data.d.ts +23 -0
- package/dist/types/old/models/list-data.js +8 -0
- package/dist/types/old/models/notifiable.d.ts +42 -0
- package/dist/types/old/models/notifiable.js +2 -0
- package/dist/types/old/models/notification-template-data.d.ts +224 -0
- package/dist/types/old/models/notification-template-data.js +52 -0
- package/dist/types/old/models/person-data.d.ts +31 -0
- package/dist/types/old/models/person-data.js +2 -0
- package/dist/types/old/models/program-config.d.ts +25 -0
- package/dist/types/old/models/program-config.js +2 -0
- package/dist/types/old/models/thought-data.d.ts +8 -0
- package/dist/types/old/models/thought-data.js +2 -0
- package/dist/types/old/models/user-data.d.ts +147 -0
- package/dist/types/old/models/user-data.js +42 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/type-helpers.d.ts +4 -0
- package/dist/utils/type-helpers.js +19 -0
- package/package.json +1 -1
- package/src/types/id-types.ts +2 -2
- package/src/types/index.ts +4 -3
- package/src/types/new/agenda-types.ts +69 -0
- package/src/types/new/auth-types.ts +92 -0
- package/src/types/new/habits-types.ts +112 -0
- package/src/types/new/index.ts +10 -0
- package/src/types/new/lists-types.ts +108 -0
- package/src/types/new/misc/index.ts +1 -0
- package/src/types/new/misc/version-types.ts +15 -0
- package/src/types/new/notifications-types.ts +144 -0
- package/src/types/new/people-types.ts +110 -0
- package/src/types/new/program-config-types.ts +29 -0
- package/src/types/new/thoughts-types.ts +44 -0
- package/src/types/new/user-types.ts +61 -0
- package/src/types/{api → old/api}/account/get-user-types.ts +1 -1
- package/src/types/{api → old/api}/account/update-user-types.ts +1 -1
- package/src/types/{api → old/api}/auth/create-account-types.ts +1 -1
- package/src/types/{api → old/api}/habits/create-habit-entry-types.ts +2 -2
- package/src/types/{api → old/api}/habits/create-habit-types.ts +1 -1
- package/src/types/{api → old/api}/habits/delete-habit-entry-types.ts +1 -1
- package/src/types/{api → old/api}/habits/get-habits-types.ts +1 -1
- package/src/types/{api → old/api}/habits/update-habit-types.ts +1 -1
- package/src/types/{api → old/api}/items/complete-item-types.ts +1 -1
- package/src/types/{api → old/api}/items/create-item-types.ts +1 -1
- package/src/types/{api → old/api}/items/get-items-types.ts +1 -1
- package/src/types/{api → old/api}/items/update-item-types.ts +1 -1
- package/src/types/{api → old/api}/lists/complete-list-item-types.ts +1 -1
- package/src/types/{api → old/api}/lists/create-list-item-types.ts +2 -2
- package/src/types/{api → old/api}/lists/create-list-types.ts +1 -1
- package/src/types/{api → old/api}/lists/get-list-item-types.ts +1 -1
- package/src/types/{api → old/api}/lists/get-lists-types.ts +1 -1
- package/src/types/{api → old/api}/lists/update-list-item-types.ts +2 -2
- package/src/types/{api → old/api}/lists/update-list-types.ts +1 -1
- package/src/types/{api → old/api}/notifications/create-notification-template-types.ts +1 -1
- package/src/types/{api → old/api}/notifications/get-notification-templates-types.ts +1 -1
- package/src/types/{api → old/api}/notifications/sync-notification-template-types.ts +1 -1
- package/src/types/{api → old/api}/notifications/update-notification-template-types.ts +1 -1
- package/src/types/{api → old/api}/people/create-person-note-types.ts +2 -2
- package/src/types/{api → old/api}/people/create-person-types.ts +2 -2
- package/src/types/{api → old/api}/people/get-people-types.ts +1 -1
- package/src/types/{api → old/api}/people/get-person-notes-types.ts +1 -1
- package/src/types/{api → old/api}/people/update-person-note-types.ts +1 -1
- package/src/types/{api → old/api}/people/update-person-types.ts +2 -2
- package/src/types/{api → old/api}/thoughts/create-thought-types.ts +1 -1
- package/src/types/{api → old/api}/thoughts/get-thoughts-types.ts +1 -1
- package/src/types/{api → old/api}/thoughts/update-thought-types.ts +1 -1
- package/src/types/{models → old/models}/auth-data.ts +1 -1
- package/src/types/{models → old/models}/habit-data.ts +2 -2
- package/src/types/{models → old/models}/item-data.ts +1 -1
- package/src/types/{models → old/models}/list-data.ts +1 -1
- package/src/types/{models → old/models}/notification-template-data.ts +1 -1
- package/src/types/{models → old/models}/person-data.ts +1 -1
- package/src/types/{models → old/models}/thought-data.ts +1 -1
- package/src/types/{models → old/models}/user-data.ts +2 -2
- package/src/utils/index.ts +2 -1
- package/src/utils/type-helpers.ts +19 -0
- /package/src/types/{api → old/api}/account/index.ts +0 -0
- /package/src/types/{api → old/api}/auth/index.ts +0 -0
- /package/src/types/{api → old/api}/auth/refresh-auth-types.ts +0 -0
- /package/src/types/{api → old/api}/auth/resend-verification-types.ts +0 -0
- /package/src/types/{api → old/api}/auth/sign-in-types.ts +0 -0
- /package/src/types/{api → old/api}/auth/verify-email-types.ts +0 -0
- /package/src/types/{api → old/api}/habits/delete-habit-types.ts +0 -0
- /package/src/types/{api → old/api}/habits/index.ts +0 -0
- /package/src/types/{api → old/api}/index.ts +0 -0
- /package/src/types/{api → old/api}/items/delete-item-types.ts +0 -0
- /package/src/types/{api → old/api}/items/index.ts +0 -0
- /package/src/types/{api → old/api}/lists/index.ts +0 -0
- /package/src/types/{api → old/api}/misc/index.ts +0 -0
- /package/src/types/{api → old/api}/misc/version-types.ts +0 -0
- /package/src/types/{api → old/api}/notifications/delete-notification-template-types.ts +0 -0
- /package/src/types/{api → old/api}/notifications/index.ts +0 -0
- /package/src/types/{api → old/api}/notifications/preview-notification-template-types.ts +0 -0
- /package/src/types/{api → old/api}/people/delete-person-notes-types.ts +0 -0
- /package/src/types/{api → old/api}/people/delete-person-types.ts +0 -0
- /package/src/types/{api → old/api}/people/index.ts +0 -0
- /package/src/types/{api → old/api}/thoughts/delete-thought-types.ts +0 -0
- /package/src/types/{api → old/api}/thoughts/index.ts +0 -0
- /package/src/types/{auth-tokens.ts → old/auth-tokens.ts} +0 -0
- /package/src/types/{models → old/models}/index.ts +0 -0
- /package/src/types/{models → old/models}/notifiable.ts +0 -0
- /package/src/types/{models → old/models}/program-config.ts +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { notificationTemplateIdSchema, userIdSchema } from '../id-types';
|
|
3
|
+
import { Serialized } from '../../utils';
|
|
4
|
+
|
|
5
|
+
export const notificationEntityTypeSchema = z.enum([
|
|
6
|
+
'agenda', 'tasks', 'habits', 'inbox',
|
|
7
|
+
'agenda_item', 'habit',
|
|
8
|
+
'agenda_defaults', 'habits_defaults'
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
export const notificationTriggerTypeSchema = z.enum(['time_based', 'event_based', 'recurring']);
|
|
12
|
+
|
|
13
|
+
export const notificationTriggerSchema = z.object({
|
|
14
|
+
type: notificationTriggerTypeSchema,
|
|
15
|
+
conditions: z.record(z.any()),
|
|
16
|
+
timing: z.record(z.any())
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const notificationContentSchema = z.object({
|
|
20
|
+
title: z.string(),
|
|
21
|
+
body: z.string(),
|
|
22
|
+
variables: z.record(z.string()).optional()
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const notificationTemplateSchema = z.object({
|
|
26
|
+
_id: notificationTemplateIdSchema,
|
|
27
|
+
userId: userIdSchema,
|
|
28
|
+
entityType: notificationEntityTypeSchema,
|
|
29
|
+
entityId: z.string().optional(),
|
|
30
|
+
name: z.string(),
|
|
31
|
+
description: z.string().optional(),
|
|
32
|
+
trigger: notificationTriggerSchema,
|
|
33
|
+
content: notificationContentSchema,
|
|
34
|
+
active: z.boolean(),
|
|
35
|
+
inheritedFrom: notificationTemplateIdSchema.optional(),
|
|
36
|
+
customized: z.boolean(),
|
|
37
|
+
createdAt: z.date(),
|
|
38
|
+
updatedAt: z.date()
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const createNotificationTemplateSchema = notificationTemplateSchema.omit({
|
|
42
|
+
_id: true,
|
|
43
|
+
createdAt: true,
|
|
44
|
+
updatedAt: true
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const entitySyncStateSchema = z.object({
|
|
48
|
+
userId: userIdSchema,
|
|
49
|
+
entityType: notificationEntityTypeSchema,
|
|
50
|
+
entityId: z.string(),
|
|
51
|
+
synced: z.boolean(),
|
|
52
|
+
updatedAt: z.date()
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const createNotificationTemplateRequestSchema = z.object({
|
|
56
|
+
entityType: notificationEntityTypeSchema,
|
|
57
|
+
entityId: z.string().optional(),
|
|
58
|
+
name: z.string().min(1).max(100),
|
|
59
|
+
description: z.string().max(500).optional(),
|
|
60
|
+
trigger: z.object({
|
|
61
|
+
type: notificationTriggerTypeSchema,
|
|
62
|
+
conditions: z.record(z.any()),
|
|
63
|
+
timing: z.record(z.any())
|
|
64
|
+
}),
|
|
65
|
+
content: z.object({
|
|
66
|
+
title: z.string().min(1).max(200),
|
|
67
|
+
body: z.string().min(1).max(1000),
|
|
68
|
+
variables: z.record(z.string()).optional()
|
|
69
|
+
}),
|
|
70
|
+
active: z.boolean().default(true),
|
|
71
|
+
inheritedFrom: z.string().optional(),
|
|
72
|
+
customized: z.boolean().default(false)
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const updateNotificationTemplateRequestSchema = z.object({
|
|
76
|
+
name: z.string().optional(),
|
|
77
|
+
description: z.string().optional(),
|
|
78
|
+
trigger: z.object({
|
|
79
|
+
type: notificationTriggerTypeSchema,
|
|
80
|
+
conditions: z.record(z.any()),
|
|
81
|
+
timing: z.record(z.any())
|
|
82
|
+
}).optional(),
|
|
83
|
+
content: z.object({
|
|
84
|
+
title: z.string(),
|
|
85
|
+
body: z.string(),
|
|
86
|
+
variables: z.record(z.string()).optional()
|
|
87
|
+
}).optional(),
|
|
88
|
+
active: z.boolean().optional(),
|
|
89
|
+
customized: z.boolean().optional()
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export const syncNotificationTemplateRequestSchema = z.object({
|
|
93
|
+
entityType: notificationEntityTypeSchema,
|
|
94
|
+
entityId: z.string()
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export const previewNotificationTemplateRequestSchema = z.object({
|
|
98
|
+
templateId: notificationTemplateIdSchema,
|
|
99
|
+
entityData: z.record(z.any()).optional()
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export type NotificationEntityType = z.infer<typeof notificationEntityTypeSchema>;
|
|
103
|
+
export type NotificationTriggerType = z.infer<typeof notificationTriggerTypeSchema>;
|
|
104
|
+
export type NotificationTrigger = z.infer<typeof notificationTriggerSchema>;
|
|
105
|
+
export type NotificationContent = z.infer<typeof notificationContentSchema>;
|
|
106
|
+
export type NotificationTemplateData = z.infer<typeof notificationTemplateSchema>;
|
|
107
|
+
export type CreateNotificationTemplateData = z.infer<typeof createNotificationTemplateSchema>;
|
|
108
|
+
export type EntitySyncState = z.infer<typeof entitySyncStateSchema>;
|
|
109
|
+
|
|
110
|
+
export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;
|
|
111
|
+
export type UpdateNotificationTemplateRequest = z.infer<typeof updateNotificationTemplateRequestSchema>;
|
|
112
|
+
export type SyncNotificationTemplateRequest = z.infer<typeof syncNotificationTemplateRequestSchema>;
|
|
113
|
+
export type PreviewNotificationTemplateRequest = z.infer<typeof previewNotificationTemplateRequestSchema>;
|
|
114
|
+
|
|
115
|
+
export interface CreateNotificationTemplateResponse {
|
|
116
|
+
template: Serialized<NotificationTemplateData>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface GetNotificationTemplatesResponse {
|
|
120
|
+
templates: Serialized<NotificationTemplateData>[];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface GetNotificationTemplateResponse {
|
|
124
|
+
template: Serialized<NotificationTemplateData>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface UpdateNotificationTemplateResponse {
|
|
128
|
+
template: Serialized<NotificationTemplateData>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface DeleteNotificationTemplateResponse {
|
|
132
|
+
deleted: boolean;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface SyncNotificationTemplateResponse {
|
|
136
|
+
synced: boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface PreviewNotificationTemplateResponse {
|
|
140
|
+
preview: {
|
|
141
|
+
title: string;
|
|
142
|
+
body: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { personIdSchema, personNoteIdSchema, userIdSchema } from '../id-types';
|
|
3
|
+
import { Serialized } from '../../utils';
|
|
4
|
+
|
|
5
|
+
export const personPropertySchema = z.object({
|
|
6
|
+
key: z.string(),
|
|
7
|
+
value: z.string()
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const personNoteSchema = z.object({
|
|
11
|
+
_id: personNoteIdSchema,
|
|
12
|
+
personId: personIdSchema,
|
|
13
|
+
userId: userIdSchema,
|
|
14
|
+
content: z.string(),
|
|
15
|
+
createdAt: z.date(),
|
|
16
|
+
updatedAt: z.date()
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const personDataSchema = z.object({
|
|
20
|
+
_id: personIdSchema,
|
|
21
|
+
userId: userIdSchema,
|
|
22
|
+
createdAt: z.date(),
|
|
23
|
+
updatedAt: z.date(),
|
|
24
|
+
name: z.string(),
|
|
25
|
+
properties: z.array(personPropertySchema),
|
|
26
|
+
noteIds: z.array(personNoteIdSchema)
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const personSchema = z.object({
|
|
30
|
+
_id: personIdSchema,
|
|
31
|
+
userId: userIdSchema,
|
|
32
|
+
createdAt: z.date(),
|
|
33
|
+
updatedAt: z.date(),
|
|
34
|
+
name: z.string(),
|
|
35
|
+
properties: z.array(personPropertySchema),
|
|
36
|
+
notes: z.array(personNoteSchema)
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const createPersonRequestSchema = z.object({
|
|
40
|
+
name: z.string().min(1),
|
|
41
|
+
properties: z.array(z.object({
|
|
42
|
+
key: z.string().min(1),
|
|
43
|
+
value: z.string().min(1)
|
|
44
|
+
})).optional(),
|
|
45
|
+
notes: z.array(personNoteIdSchema).optional()
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const updatePersonRequestSchema = z.object({
|
|
49
|
+
name: z.string().min(1).optional(),
|
|
50
|
+
properties: z.array(z.object({
|
|
51
|
+
key: z.string().min(1),
|
|
52
|
+
value: z.string().min(1)
|
|
53
|
+
})).optional(),
|
|
54
|
+
noteIds: z.array(personNoteIdSchema).optional()
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const createPersonNoteRequestSchema = z.object({
|
|
58
|
+
personId: personIdSchema,
|
|
59
|
+
content: z.string().min(1)
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const updatePersonNoteRequestSchema = z.object({
|
|
63
|
+
content: z.string().min(1)
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export type PersonPropertyData = z.infer<typeof personPropertySchema>;
|
|
67
|
+
export type PersonNoteData = z.infer<typeof personNoteSchema>;
|
|
68
|
+
export type PersonData = z.infer<typeof personDataSchema>;
|
|
69
|
+
export type Person = z.infer<typeof personSchema>;
|
|
70
|
+
|
|
71
|
+
export type CreatePersonRequest = z.infer<typeof createPersonRequestSchema>;
|
|
72
|
+
export type UpdatePersonRequest = z.infer<typeof updatePersonRequestSchema>;
|
|
73
|
+
export type CreatePersonNoteRequest = z.infer<typeof createPersonNoteRequestSchema>;
|
|
74
|
+
export type UpdatePersonNoteRequest = z.infer<typeof updatePersonNoteRequestSchema>;
|
|
75
|
+
|
|
76
|
+
export interface CreatePersonResponse {
|
|
77
|
+
person: Serialized<Person>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface GetPeopleResponse {
|
|
81
|
+
people: Serialized<Person>[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface GetPersonResponse {
|
|
85
|
+
person: Serialized<Person>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface UpdatePersonResponse {
|
|
89
|
+
person: Serialized<Person>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface DeletePersonResponse {
|
|
93
|
+
deleted: boolean;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface CreatePersonNoteResponse {
|
|
97
|
+
personNote: Serialized<PersonNoteData>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface GetPersonNotesResponse {
|
|
101
|
+
personNotes: Serialized<PersonNoteData>[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface UpdatePersonNoteResponse {
|
|
105
|
+
personNote: Serialized<PersonNoteData>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface DeletePersonNoteResponse {
|
|
109
|
+
deleted: boolean;
|
|
110
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const programConfigSchema = z.object({
|
|
4
|
+
_requiredBuildVersions: z.object({
|
|
5
|
+
iOS: z.number(),
|
|
6
|
+
android: z.number()
|
|
7
|
+
}),
|
|
8
|
+
dev: z.object({
|
|
9
|
+
authorizedEmails: z.array(z.string())
|
|
10
|
+
}),
|
|
11
|
+
discord: z.object({
|
|
12
|
+
token: z.string(),
|
|
13
|
+
clientId: z.string(),
|
|
14
|
+
guildId: z.string(),
|
|
15
|
+
logChannelId: z.string().optional()
|
|
16
|
+
}),
|
|
17
|
+
mailjet: z.object({
|
|
18
|
+
apiKey: z.string(),
|
|
19
|
+
secretKey: z.string()
|
|
20
|
+
}),
|
|
21
|
+
expo: z.object({
|
|
22
|
+
token: z.string()
|
|
23
|
+
}),
|
|
24
|
+
redisUrl: z.string(),
|
|
25
|
+
updatedAt: z.date(),
|
|
26
|
+
createdAt: z.date()
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type ProgramConfigData = z.infer<typeof programConfigSchema>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { thoughtIdSchema, userIdSchema } from '../id-types';
|
|
3
|
+
import { Serialized } from '../../utils';
|
|
4
|
+
|
|
5
|
+
export const thoughtSchema = z.object({
|
|
6
|
+
_id: thoughtIdSchema,
|
|
7
|
+
userId: userIdSchema,
|
|
8
|
+
createdAt: z.date(),
|
|
9
|
+
updatedAt: z.date(),
|
|
10
|
+
content: z.string()
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const createThoughtRequestSchema = z.object({
|
|
14
|
+
content: z.string().min(1)
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const updateThoughtRequestSchema = z.object({
|
|
18
|
+
content: z.string().min(1)
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type ThoughtData = z.infer<typeof thoughtSchema>;
|
|
22
|
+
|
|
23
|
+
export type CreateThoughtRequest = z.infer<typeof createThoughtRequestSchema>;
|
|
24
|
+
export type UpdateThoughtRequest = z.infer<typeof updateThoughtRequestSchema>;
|
|
25
|
+
|
|
26
|
+
export interface CreateThoughtResponse {
|
|
27
|
+
thought: Serialized<ThoughtData>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface GetThoughtsResponse {
|
|
31
|
+
thoughts: Serialized<ThoughtData>[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface GetThoughtResponse {
|
|
35
|
+
thought: Serialized<ThoughtData>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface UpdateThoughtResponse {
|
|
39
|
+
thought: Serialized<ThoughtData>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface DeleteThoughtResponse {
|
|
43
|
+
deleted: boolean;
|
|
44
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { userIdSchema } from '../id-types';
|
|
3
|
+
import { Serialized } from '../../utils';
|
|
4
|
+
import { ModuleType } from '../../enums';
|
|
5
|
+
|
|
6
|
+
export const moduleSchema = z.object({
|
|
7
|
+
type: z.nativeEnum(ModuleType),
|
|
8
|
+
visible: z.boolean()
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const deviceSchema = z.object({
|
|
12
|
+
pushToken: z.string()
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const userSchema = z.object({
|
|
16
|
+
_id: userIdSchema,
|
|
17
|
+
createdAt: z.date(),
|
|
18
|
+
updatedAt: z.date(),
|
|
19
|
+
sandbox: z.object({
|
|
20
|
+
discordId: z.string().optional(),
|
|
21
|
+
devices: z.array(deviceSchema)
|
|
22
|
+
}),
|
|
23
|
+
name: z.string().min(1),
|
|
24
|
+
timezone: z.string().refine((tz: string) => {
|
|
25
|
+
try {
|
|
26
|
+
Intl.DateTimeFormat(undefined, { timeZone: tz });
|
|
27
|
+
return true;
|
|
28
|
+
} catch (e) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
config: z.object({
|
|
33
|
+
modules: z.array(moduleSchema),
|
|
34
|
+
agenda: z.object({
|
|
35
|
+
itemCategories: z.array(z.string()),
|
|
36
|
+
itemTypes: z.array(z.string())
|
|
37
|
+
}),
|
|
38
|
+
people: z.object({
|
|
39
|
+
propertyKeys: z.array(z.string())
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const updateUserRequestSchema = userSchema
|
|
45
|
+
.omit({ _id: true, createdAt: true, updatedAt: true })
|
|
46
|
+
.deepPartial()
|
|
47
|
+
.strict();
|
|
48
|
+
|
|
49
|
+
export type UserModuleData = z.infer<typeof moduleSchema>;
|
|
50
|
+
export type UserDeviceData = z.infer<typeof deviceSchema>;
|
|
51
|
+
export type UserData = z.infer<typeof userSchema>;
|
|
52
|
+
|
|
53
|
+
export type UpdateUserRequest = z.infer<typeof updateUserRequestSchema>;
|
|
54
|
+
|
|
55
|
+
export interface GetUserResponse {
|
|
56
|
+
user: Serialized<UserData>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface UpdateUserResponse {
|
|
60
|
+
user: Serialized<UserData>;
|
|
61
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { UserData, userDataSchema } from "../../models";
|
|
3
|
-
import { Serialized } from "
|
|
3
|
+
import { Serialized } from "../../../../utils";
|
|
4
4
|
|
|
5
5
|
export const updateUserRequestSchema = userDataSchema
|
|
6
6
|
.omit({ _id: true, createdAt: true, updatedAt: true })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Habit, HabitEntryStatus } from "../../models";
|
|
3
|
-
import { dateOnlyStringSchema } from "
|
|
4
|
-
import { Serialized } from "
|
|
3
|
+
import { dateOnlyStringSchema } from "../../../misc-types";
|
|
4
|
+
import { Serialized } from "../../../../utils";
|
|
5
5
|
|
|
6
6
|
export const createHabitEntryRequestSchema = z.object({
|
|
7
7
|
date: dateOnlyStringSchema,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Habit, HabitFrequency } from "../../models";
|
|
3
|
-
import { Serialized } from "
|
|
3
|
+
import { Serialized } from "../../../../utils";
|
|
4
4
|
|
|
5
5
|
export const createHabitRequestSchema = z.object({
|
|
6
6
|
name: z.string().min(1, 'Name is required').trim(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Habit, HabitFrequency } from "../../models";
|
|
3
|
-
import { Serialized } from "
|
|
3
|
+
import { Serialized } from "../../../../utils";
|
|
4
4
|
|
|
5
5
|
export const updateHabitRequestSchema = z.object({
|
|
6
6
|
name: z.string().min(1, 'Name is required').trim().optional(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { listIdSchema } from '
|
|
3
|
-
import { Serialized } from "
|
|
2
|
+
import { listIdSchema } from '../../../id-types';
|
|
3
|
+
import { Serialized } from "../../../../utils";
|
|
4
4
|
import { ListItemData } from "../../models";
|
|
5
5
|
|
|
6
6
|
export const createListItemRequestSchema = z.object({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { listIdSchema } from '
|
|
3
|
-
import { Serialized } from "
|
|
2
|
+
import { listIdSchema } from '../../../id-types';
|
|
3
|
+
import { Serialized } from "../../../../utils";
|
|
4
4
|
import { ListItemData } from "../../models";
|
|
5
5
|
|
|
6
6
|
export const updateListItemRequestSchema = z.object({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { Serialized } from "
|
|
2
|
+
import { Serialized } from "../../../../utils";
|
|
3
3
|
import { NotificationTemplateData, CreateNotificationTemplateData, notificationEntityTypeSchema, notificationTriggerTypeSchema } from "../../models/notification-template-data";
|
|
4
4
|
|
|
5
5
|
// Request schema
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { personIdSchema } from "
|
|
2
|
+
import { personIdSchema } from "../../../id-types";
|
|
3
3
|
import { PersonNoteData } from "../../models";
|
|
4
|
-
import { Serialized } from "
|
|
4
|
+
import { Serialized } from "../../../../utils";
|
|
5
5
|
|
|
6
6
|
export const createPersonNoteRequestSchema = z.object({
|
|
7
7
|
personId: personIdSchema,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { personNoteIdSchema } from "
|
|
2
|
+
import { personNoteIdSchema } from "../../../id-types";
|
|
3
3
|
import { Person } from "../../models";
|
|
4
|
-
import { Serialized } from "
|
|
4
|
+
import { Serialized } from "../../../../utils";
|
|
5
5
|
|
|
6
6
|
export const createPersonRequestSchema = z.object({
|
|
7
7
|
name: z.string().min(1),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { personNoteIdSchema } from "
|
|
2
|
+
import { personNoteIdSchema } from "../../../id-types";
|
|
3
3
|
import { Person } from "../../models";
|
|
4
|
-
import { Serialized } from "
|
|
4
|
+
import { Serialized } from "../../../../utils";
|
|
5
5
|
|
|
6
6
|
export const updatePersonRequestSchema = z.object({
|
|
7
7
|
name: z.string().min(1).optional(),
|