@timothyw/pat-common 1.0.111 → 1.0.113
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/notifications/create-notification-template-types.d.ts +3 -18
- package/dist/types/api/notifications/create-notification-template-types.js +1 -7
- package/dist/types/api/notifications/delete-notification-template-types.d.ts +2 -11
- package/dist/types/api/notifications/delete-notification-template-types.js +1 -6
- package/dist/types/api/notifications/get-notification-templates-types.d.ts +3 -18
- package/dist/types/api/notifications/get-notification-templates-types.js +1 -7
- package/dist/types/api/notifications/preview-notification-template-types.d.ts +5 -34
- package/dist/types/api/notifications/preview-notification-template-types.js +1 -12
- package/dist/types/api/notifications/sync-notification-template-types.d.ts +3 -18
- package/dist/types/api/notifications/sync-notification-template-types.js +1 -7
- package/dist/types/api/notifications/update-notification-template-types.d.ts +4 -19
- package/dist/types/api/notifications/update-notification-template-types.js +7 -13
- package/dist/utils/serializing-utils.d.ts +1 -28
- package/dist/utils/serializing-utils.js +8 -94
- package/package.json +1 -1
- package/src/types/api/notifications/create-notification-template-types.ts +3 -12
- package/src/types/api/notifications/delete-notification-template-types.ts +1 -7
- package/src/types/api/notifications/get-notification-templates-types.ts +3 -12
- package/src/types/api/notifications/preview-notification-template-types.ts +8 -13
- package/src/types/api/notifications/sync-notification-template-types.ts +3 -12
- package/src/types/api/notifications/update-notification-template-types.ts +11 -17
- package/src/utils/serializing-utils.ts +13 -152
|
@@ -73,21 +73,6 @@ export declare const createNotificationTemplateRequestSchema: z.ZodObject<{
|
|
|
73
73
|
customized?: boolean | undefined;
|
|
74
74
|
}>;
|
|
75
75
|
export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
error: z.ZodOptional<z.ZodString>;
|
|
80
|
-
}, "strip", z.ZodTypeAny, {
|
|
81
|
-
success: boolean;
|
|
82
|
-
error?: string | undefined;
|
|
83
|
-
template?: any;
|
|
84
|
-
}, {
|
|
85
|
-
success: boolean;
|
|
86
|
-
error?: string | undefined;
|
|
87
|
-
template?: any;
|
|
88
|
-
}>;
|
|
89
|
-
export type CreateNotificationTemplateResponse = {
|
|
90
|
-
success: boolean;
|
|
91
|
-
template?: Serialized<NotificationTemplateData>;
|
|
92
|
-
error?: string;
|
|
93
|
-
};
|
|
76
|
+
export interface CreateNotificationTemplateResponse {
|
|
77
|
+
template: Serialized<NotificationTemplateData>;
|
|
78
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createNotificationTemplateRequestSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const notification_template_data_1 = require("../../models/notification-template-data");
|
|
6
6
|
// Request schema
|
|
@@ -23,9 +23,3 @@ exports.createNotificationTemplateRequestSchema = zod_1.z.object({
|
|
|
23
23
|
inheritedFrom: zod_1.z.string().optional(),
|
|
24
24
|
customized: zod_1.z.boolean().default(false)
|
|
25
25
|
});
|
|
26
|
-
// Response schema
|
|
27
|
-
exports.createNotificationTemplateResponseSchema = zod_1.z.object({
|
|
28
|
-
success: zod_1.z.boolean(),
|
|
29
|
-
template: zod_1.z.any().optional(), // Will be Serialized<NotificationTemplateData>
|
|
30
|
-
error: zod_1.z.string().optional()
|
|
31
|
-
});
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const deleteNotificationTemplateRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
3
3
|
export type DeleteNotificationTemplateRequest = z.infer<typeof deleteNotificationTemplateRequestSchema>;
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
error: z.ZodOptional<z.ZodString>;
|
|
7
|
-
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
success: boolean;
|
|
9
|
-
error?: string | undefined;
|
|
10
|
-
}, {
|
|
11
|
-
success: boolean;
|
|
12
|
-
error?: string | undefined;
|
|
13
|
-
}>;
|
|
14
|
-
export type DeleteNotificationTemplateResponse = z.infer<typeof deleteNotificationTemplateResponseSchema>;
|
|
4
|
+
export interface DeleteNotificationTemplateResponse {
|
|
5
|
+
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.deleteNotificationTemplateRequestSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
// Request schema - no body needed for DELETE
|
|
6
6
|
exports.deleteNotificationTemplateRequestSchema = zod_1.z.object({});
|
|
7
|
-
// Response schema
|
|
8
|
-
exports.deleteNotificationTemplateResponseSchema = zod_1.z.object({
|
|
9
|
-
success: zod_1.z.boolean(),
|
|
10
|
-
error: zod_1.z.string().optional()
|
|
11
|
-
});
|
|
@@ -3,21 +3,6 @@ import { Serialized } from "../../../utils";
|
|
|
3
3
|
import { NotificationTemplateData } from "../../models/notification-template-data";
|
|
4
4
|
export declare const getNotificationTemplatesRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
5
5
|
export type GetNotificationTemplatesRequest = z.infer<typeof getNotificationTemplatesRequestSchema>;
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
error: z.ZodOptional<z.ZodString>;
|
|
10
|
-
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
success: boolean;
|
|
12
|
-
templates?: any[] | undefined;
|
|
13
|
-
error?: string | undefined;
|
|
14
|
-
}, {
|
|
15
|
-
success: boolean;
|
|
16
|
-
templates?: any[] | undefined;
|
|
17
|
-
error?: string | undefined;
|
|
18
|
-
}>;
|
|
19
|
-
export type GetNotificationTemplatesResponse = {
|
|
20
|
-
success: boolean;
|
|
21
|
-
templates?: Serialized<NotificationTemplateData>[];
|
|
22
|
-
error?: string;
|
|
23
|
-
};
|
|
6
|
+
export interface GetNotificationTemplatesResponse {
|
|
7
|
+
templates: Serialized<NotificationTemplateData>[];
|
|
8
|
+
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getNotificationTemplatesRequestSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
// Request schema - no body needed for GET
|
|
6
6
|
exports.getNotificationTemplatesRequestSchema = zod_1.z.object({});
|
|
7
|
-
// Response schema
|
|
8
|
-
exports.getNotificationTemplatesResponseSchema = zod_1.z.object({
|
|
9
|
-
success: zod_1.z.boolean(),
|
|
10
|
-
templates: zod_1.z.array(zod_1.z.any()).optional(), // Will be Serialized<NotificationTemplateData>[]
|
|
11
|
-
error: zod_1.z.string().optional()
|
|
12
|
-
});
|
|
@@ -19,40 +19,11 @@ export declare const previewNotificationTemplateRequestSchema: z.ZodObject<{
|
|
|
19
19
|
variables?: Record<string, any> | undefined;
|
|
20
20
|
}>;
|
|
21
21
|
export type PreviewNotificationTemplateRequest = z.infer<typeof previewNotificationTemplateRequestSchema>;
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
preview: z.ZodOptional<z.ZodObject<{
|
|
25
|
-
title: z.ZodString;
|
|
26
|
-
body: z.ZodString;
|
|
27
|
-
variables: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
28
|
-
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
export interface PreviewNotificationTemplateResponse {
|
|
23
|
+
preview: {
|
|
29
24
|
title: string;
|
|
30
25
|
body: string;
|
|
31
26
|
variables: Record<string, any>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
variables: Record<string, any>;
|
|
36
|
-
}>>;
|
|
37
|
-
missingVariables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
38
|
-
error: z.ZodOptional<z.ZodString>;
|
|
39
|
-
}, "strip", z.ZodTypeAny, {
|
|
40
|
-
success: boolean;
|
|
41
|
-
error?: string | undefined;
|
|
42
|
-
preview?: {
|
|
43
|
-
title: string;
|
|
44
|
-
body: string;
|
|
45
|
-
variables: Record<string, any>;
|
|
46
|
-
} | undefined;
|
|
47
|
-
missingVariables?: string[] | undefined;
|
|
48
|
-
}, {
|
|
49
|
-
success: boolean;
|
|
50
|
-
error?: string | undefined;
|
|
51
|
-
preview?: {
|
|
52
|
-
title: string;
|
|
53
|
-
body: string;
|
|
54
|
-
variables: Record<string, any>;
|
|
55
|
-
} | undefined;
|
|
56
|
-
missingVariables?: string[] | undefined;
|
|
57
|
-
}>;
|
|
58
|
-
export type PreviewNotificationTemplateResponse = z.infer<typeof previewNotificationTemplateResponseSchema>;
|
|
27
|
+
};
|
|
28
|
+
missingVariables: string[];
|
|
29
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.previewNotificationTemplateRequestSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
// Request schema
|
|
6
6
|
exports.previewNotificationTemplateRequestSchema = zod_1.z.object({
|
|
@@ -10,14 +10,3 @@ exports.previewNotificationTemplateRequestSchema = zod_1.z.object({
|
|
|
10
10
|
entityId: zod_1.z.string(),
|
|
11
11
|
variables: zod_1.z.record(zod_1.z.any()).optional()
|
|
12
12
|
});
|
|
13
|
-
// Response schema
|
|
14
|
-
exports.previewNotificationTemplateResponseSchema = zod_1.z.object({
|
|
15
|
-
success: zod_1.z.boolean(),
|
|
16
|
-
preview: zod_1.z.object({
|
|
17
|
-
title: zod_1.z.string(),
|
|
18
|
-
body: zod_1.z.string(),
|
|
19
|
-
variables: zod_1.z.record(zod_1.z.any())
|
|
20
|
-
}).optional(),
|
|
21
|
-
missingVariables: zod_1.z.array(zod_1.z.string()).optional(),
|
|
22
|
-
error: zod_1.z.string().optional()
|
|
23
|
-
});
|
|
@@ -9,21 +9,6 @@ export declare const syncNotificationTemplateRequestSchema: z.ZodObject<{
|
|
|
9
9
|
sync: boolean;
|
|
10
10
|
}>;
|
|
11
11
|
export type SyncNotificationTemplateRequest = z.infer<typeof syncNotificationTemplateRequestSchema>;
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
error: z.ZodOptional<z.ZodString>;
|
|
16
|
-
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
success: boolean;
|
|
18
|
-
error?: string | undefined;
|
|
19
|
-
template?: any;
|
|
20
|
-
}, {
|
|
21
|
-
success: boolean;
|
|
22
|
-
error?: string | undefined;
|
|
23
|
-
template?: any;
|
|
24
|
-
}>;
|
|
25
|
-
export type SyncNotificationTemplateResponse = {
|
|
26
|
-
success: boolean;
|
|
27
|
-
template?: Serialized<NotificationTemplateData>;
|
|
28
|
-
error?: string;
|
|
29
|
-
};
|
|
12
|
+
export interface SyncNotificationTemplateResponse {
|
|
13
|
+
template: Serialized<NotificationTemplateData>;
|
|
14
|
+
}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.syncNotificationTemplateRequestSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
// Request schema
|
|
6
6
|
exports.syncNotificationTemplateRequestSchema = zod_1.z.object({
|
|
7
7
|
sync: zod_1.z.boolean() // true to sync with parent, false to unsync
|
|
8
8
|
});
|
|
9
|
-
// Response schema
|
|
10
|
-
exports.syncNotificationTemplateResponseSchema = zod_1.z.object({
|
|
11
|
-
success: zod_1.z.boolean(),
|
|
12
|
-
template: zod_1.z.any().optional(), // Will be Serialized<NotificationTemplateData>
|
|
13
|
-
error: zod_1.z.string().optional()
|
|
14
|
-
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Serialized } from "../../../utils";
|
|
3
|
-
import { NotificationTemplateData } from "../../models
|
|
3
|
+
import { NotificationTemplateData } from "../../models";
|
|
4
4
|
export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
|
|
5
5
|
name: z.ZodOptional<z.ZodString>;
|
|
6
6
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -64,21 +64,6 @@ export declare const updateNotificationTemplateRequestSchema: z.ZodObject<{
|
|
|
64
64
|
customized?: boolean | undefined;
|
|
65
65
|
}>;
|
|
66
66
|
export type UpdateNotificationTemplateRequest = z.infer<typeof updateNotificationTemplateRequestSchema>;
|
|
67
|
-
export
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
error: z.ZodOptional<z.ZodString>;
|
|
71
|
-
}, "strip", z.ZodTypeAny, {
|
|
72
|
-
success: boolean;
|
|
73
|
-
error?: string | undefined;
|
|
74
|
-
template?: any;
|
|
75
|
-
}, {
|
|
76
|
-
success: boolean;
|
|
77
|
-
error?: string | undefined;
|
|
78
|
-
template?: any;
|
|
79
|
-
}>;
|
|
80
|
-
export type UpdateNotificationTemplateResponse = {
|
|
81
|
-
success: boolean;
|
|
82
|
-
template?: Serialized<NotificationTemplateData>;
|
|
83
|
-
error?: string;
|
|
84
|
-
};
|
|
67
|
+
export interface UpdateNotificationTemplateResponse {
|
|
68
|
+
template: Serialized<NotificationTemplateData>;
|
|
69
|
+
}
|
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.updateNotificationTemplateRequestSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
6
|
// Request schema
|
|
7
7
|
exports.updateNotificationTemplateRequestSchema = zod_1.z.object({
|
|
8
|
-
name: zod_1.z.string().
|
|
9
|
-
description: zod_1.z.string().
|
|
8
|
+
name: zod_1.z.string().optional(),
|
|
9
|
+
description: zod_1.z.string().optional(),
|
|
10
10
|
trigger: zod_1.z.object({
|
|
11
|
-
type:
|
|
11
|
+
type: models_1.notificationTriggerTypeSchema,
|
|
12
12
|
conditions: zod_1.z.record(zod_1.z.any()),
|
|
13
13
|
timing: zod_1.z.record(zod_1.z.any())
|
|
14
14
|
}).optional(),
|
|
15
15
|
content: zod_1.z.object({
|
|
16
|
-
title: zod_1.z.string()
|
|
17
|
-
body: zod_1.z.string()
|
|
16
|
+
title: zod_1.z.string(),
|
|
17
|
+
body: zod_1.z.string(),
|
|
18
18
|
variables: zod_1.z.record(zod_1.z.string()).optional()
|
|
19
19
|
}).optional(),
|
|
20
20
|
active: zod_1.z.boolean().optional(),
|
|
21
21
|
customized: zod_1.z.boolean().optional()
|
|
22
22
|
});
|
|
23
|
-
// Response schema
|
|
24
|
-
exports.updateNotificationTemplateResponseSchema = zod_1.z.object({
|
|
25
|
-
success: zod_1.z.boolean(),
|
|
26
|
-
template: zod_1.z.any().optional(), // Will be Serialized<NotificationTemplateData>
|
|
27
|
-
error: zod_1.z.string().optional()
|
|
28
|
-
});
|
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
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 ? {
|
|
1
|
+
export type Serialized<T> = T extends Date ? string : T extends (infer U)[] ? Serialized<U>[] : T extends object ? {
|
|
3
2
|
[K in keyof T]: Serialized<T[K]>;
|
|
4
3
|
} : T;
|
|
5
4
|
export declare class Serializer {
|
|
6
5
|
static serialize<T>(obj: T): Serialized<T>;
|
|
7
6
|
static deserialize<T>(obj: Serialized<T>): T;
|
|
8
|
-
static serializeItemData(data: ItemData): Serialized<ItemData>;
|
|
9
|
-
static deserializeItemData(data: Serialized<ItemData>): ItemData;
|
|
10
|
-
static serializeHabitData(data: HabitData): Serialized<HabitData>;
|
|
11
|
-
static deserializeHabitData(data: Serialized<HabitData>): HabitData;
|
|
12
|
-
static serializeHabitDataEntry(data: HabitEntryData): Serialized<HabitEntryData>;
|
|
13
|
-
static serializeHabit(data: Habit): Serialized<Habit>;
|
|
14
|
-
static deserializeHabit(data: Serialized<Habit>): Habit;
|
|
15
|
-
static serializeHabitEntry(data: HabitEntry): Serialized<HabitEntry>;
|
|
16
|
-
static deserializeHabitEntry(data: Serialized<HabitEntry>): HabitEntry;
|
|
17
|
-
static deserializeHabitDataEntry(data: Serialized<HabitEntryData>): HabitEntryData;
|
|
18
|
-
static serializePerson(data: Person): Serialized<Person>;
|
|
19
|
-
static deserializePerson(data: Serialized<Person>): Person;
|
|
20
|
-
static serializePersonData(data: PersonData): Serialized<PersonData>;
|
|
21
|
-
static deserializePersonData(data: Serialized<PersonData>): PersonData;
|
|
22
|
-
static serializePersonNoteData(data: PersonNoteData): Serialized<PersonNoteData>;
|
|
23
|
-
static deserializePersonNoteData(data: Serialized<PersonNoteData>): PersonNoteData;
|
|
24
|
-
static serializeListItemData(data: ListItemData): Serialized<ListItemData>;
|
|
25
|
-
static deserializeListItemData(data: Serialized<ListItemData>): ListItemData;
|
|
26
|
-
static serializeListData(data: ListData): Serialized<ListData>;
|
|
27
|
-
static deserializeListData(data: Serialized<ListData>): ListData;
|
|
28
|
-
static serializeThoughtData(data: ThoughtData): Serialized<ThoughtData>;
|
|
29
|
-
static deserializeThoughtData(data: Serialized<ThoughtData>): ThoughtData;
|
|
30
|
-
static serializeUserData(data: UserData): Serialized<UserData>;
|
|
31
|
-
static deserializeUserData(data: Serialized<UserData>): UserData;
|
|
32
|
-
static serializeNotificationTemplateData(data: NotificationTemplateData): Serialized<NotificationTemplateData>;
|
|
33
|
-
static deserializeNotificationTemplateData(data: Serialized<NotificationTemplateData>): NotificationTemplateData;
|
|
34
7
|
}
|
|
@@ -8,120 +8,34 @@ class Serializer {
|
|
|
8
8
|
static deserialize(obj) {
|
|
9
9
|
return deserializeRecursive(obj);
|
|
10
10
|
}
|
|
11
|
-
static serializeItemData(data) {
|
|
12
|
-
return this.serialize(data);
|
|
13
|
-
}
|
|
14
|
-
static deserializeItemData(data) {
|
|
15
|
-
return this.deserialize(data);
|
|
16
|
-
}
|
|
17
|
-
static serializeHabitData(data) {
|
|
18
|
-
return this.serialize(data);
|
|
19
|
-
}
|
|
20
|
-
static deserializeHabitData(data) {
|
|
21
|
-
return this.deserialize(data);
|
|
22
|
-
}
|
|
23
|
-
static serializeHabitDataEntry(data) {
|
|
24
|
-
return this.serialize(data);
|
|
25
|
-
}
|
|
26
|
-
static serializeHabit(data) {
|
|
27
|
-
return this.serialize(data);
|
|
28
|
-
}
|
|
29
|
-
static deserializeHabit(data) {
|
|
30
|
-
return this.deserialize(data);
|
|
31
|
-
}
|
|
32
|
-
static serializeHabitEntry(data) {
|
|
33
|
-
return this.serialize(data);
|
|
34
|
-
}
|
|
35
|
-
static deserializeHabitEntry(data) {
|
|
36
|
-
return this.deserialize(data);
|
|
37
|
-
}
|
|
38
|
-
static deserializeHabitDataEntry(data) {
|
|
39
|
-
return this.deserialize(data);
|
|
40
|
-
}
|
|
41
|
-
static serializePerson(data) {
|
|
42
|
-
return this.serialize(data);
|
|
43
|
-
}
|
|
44
|
-
static deserializePerson(data) {
|
|
45
|
-
return this.deserialize(data);
|
|
46
|
-
}
|
|
47
|
-
static serializePersonData(data) {
|
|
48
|
-
return this.serialize(data);
|
|
49
|
-
}
|
|
50
|
-
static deserializePersonData(data) {
|
|
51
|
-
return this.deserialize(data);
|
|
52
|
-
}
|
|
53
|
-
static serializePersonNoteData(data) {
|
|
54
|
-
return this.serialize(data);
|
|
55
|
-
}
|
|
56
|
-
static deserializePersonNoteData(data) {
|
|
57
|
-
return this.deserialize(data);
|
|
58
|
-
}
|
|
59
|
-
static serializeListItemData(data) {
|
|
60
|
-
return this.serialize(data);
|
|
61
|
-
}
|
|
62
|
-
static deserializeListItemData(data) {
|
|
63
|
-
return this.deserialize(data);
|
|
64
|
-
}
|
|
65
|
-
static serializeListData(data) {
|
|
66
|
-
return this.serialize(data);
|
|
67
|
-
}
|
|
68
|
-
static deserializeListData(data) {
|
|
69
|
-
return this.deserialize(data);
|
|
70
|
-
}
|
|
71
|
-
static serializeThoughtData(data) {
|
|
72
|
-
return this.serialize(data);
|
|
73
|
-
}
|
|
74
|
-
static deserializeThoughtData(data) {
|
|
75
|
-
return this.deserialize(data);
|
|
76
|
-
}
|
|
77
|
-
static serializeUserData(data) {
|
|
78
|
-
return this.serialize(data);
|
|
79
|
-
}
|
|
80
|
-
static deserializeUserData(data) {
|
|
81
|
-
return this.deserialize(data);
|
|
82
|
-
}
|
|
83
|
-
static serializeNotificationTemplateData(data) {
|
|
84
|
-
return this.serialize(data);
|
|
85
|
-
}
|
|
86
|
-
static deserializeNotificationTemplateData(data) {
|
|
87
|
-
return this.deserialize(data);
|
|
88
|
-
}
|
|
89
11
|
}
|
|
90
12
|
exports.Serializer = Serializer;
|
|
91
13
|
function serializeRecursive(obj) {
|
|
92
|
-
if (obj === null || obj === undefined)
|
|
14
|
+
if (obj === null || obj === undefined)
|
|
93
15
|
return obj;
|
|
94
|
-
|
|
95
|
-
if (obj instanceof Date) {
|
|
16
|
+
if (obj instanceof Date)
|
|
96
17
|
return obj.toISOString();
|
|
97
|
-
|
|
98
|
-
if (Array.isArray(obj)) {
|
|
18
|
+
if (Array.isArray(obj))
|
|
99
19
|
return obj.map(item => serializeRecursive(item));
|
|
100
|
-
}
|
|
101
20
|
if (typeof obj === 'object') {
|
|
102
21
|
const result = {};
|
|
103
|
-
for (const [key, value] of Object.entries(obj))
|
|
22
|
+
for (const [key, value] of Object.entries(obj))
|
|
104
23
|
result[key] = serializeRecursive(value);
|
|
105
|
-
}
|
|
106
24
|
return result;
|
|
107
25
|
}
|
|
108
26
|
return obj;
|
|
109
27
|
}
|
|
110
28
|
function deserializeRecursive(obj) {
|
|
111
|
-
if (obj === null || obj === undefined)
|
|
29
|
+
if (obj === null || obj === undefined)
|
|
112
30
|
return obj;
|
|
113
|
-
|
|
114
|
-
if (typeof obj === 'string' && isISODateString(obj)) {
|
|
31
|
+
if (typeof obj === 'string' && isISODateString(obj))
|
|
115
32
|
return new Date(obj);
|
|
116
|
-
|
|
117
|
-
if (Array.isArray(obj)) {
|
|
33
|
+
if (Array.isArray(obj))
|
|
118
34
|
return obj.map(item => deserializeRecursive(item));
|
|
119
|
-
}
|
|
120
35
|
if (typeof obj === 'object') {
|
|
121
36
|
const result = {};
|
|
122
|
-
for (const [key, value] of Object.entries(obj))
|
|
37
|
+
for (const [key, value] of Object.entries(obj))
|
|
123
38
|
result[key] = deserializeRecursive(value);
|
|
124
|
-
}
|
|
125
39
|
return result;
|
|
126
40
|
}
|
|
127
41
|
return obj;
|
package/package.json
CHANGED
|
@@ -25,15 +25,6 @@ export const createNotificationTemplateRequestSchema = z.object({
|
|
|
25
25
|
|
|
26
26
|
export type CreateNotificationTemplateRequest = z.infer<typeof createNotificationTemplateRequestSchema>;
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
template: z.any().optional(), // Will be Serialized<NotificationTemplateData>
|
|
32
|
-
error: z.string().optional()
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
export type CreateNotificationTemplateResponse = {
|
|
36
|
-
success: boolean;
|
|
37
|
-
template?: Serialized<NotificationTemplateData>;
|
|
38
|
-
error?: string;
|
|
39
|
-
};
|
|
28
|
+
export interface CreateNotificationTemplateResponse {
|
|
29
|
+
template: Serialized<NotificationTemplateData>;
|
|
30
|
+
}
|
|
@@ -5,10 +5,4 @@ export const deleteNotificationTemplateRequestSchema = z.object({});
|
|
|
5
5
|
|
|
6
6
|
export type DeleteNotificationTemplateRequest = z.infer<typeof deleteNotificationTemplateRequestSchema>;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
export const deleteNotificationTemplateResponseSchema = z.object({
|
|
10
|
-
success: z.boolean(),
|
|
11
|
-
error: z.string().optional()
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export type DeleteNotificationTemplateResponse = z.infer<typeof deleteNotificationTemplateResponseSchema>;
|
|
8
|
+
export interface DeleteNotificationTemplateResponse {}
|
|
@@ -7,15 +7,6 @@ export const getNotificationTemplatesRequestSchema = z.object({});
|
|
|
7
7
|
|
|
8
8
|
export type GetNotificationTemplatesRequest = z.infer<typeof getNotificationTemplatesRequestSchema>;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
templates: z.array(z.any()).optional(), // Will be Serialized<NotificationTemplateData>[]
|
|
14
|
-
error: z.string().optional()
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export type GetNotificationTemplatesResponse = {
|
|
18
|
-
success: boolean;
|
|
19
|
-
templates?: Serialized<NotificationTemplateData>[];
|
|
20
|
-
error?: string;
|
|
21
|
-
};
|
|
10
|
+
export interface GetNotificationTemplatesResponse {
|
|
11
|
+
templates: Serialized<NotificationTemplateData>[];
|
|
12
|
+
}
|
|
@@ -11,16 +11,11 @@ export const previewNotificationTemplateRequestSchema = z.object({
|
|
|
11
11
|
|
|
12
12
|
export type PreviewNotificationTemplateRequest = z.infer<typeof previewNotificationTemplateRequestSchema>;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
missingVariables: z.array(z.string()).optional(),
|
|
23
|
-
error: z.string().optional()
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export type PreviewNotificationTemplateResponse = z.infer<typeof previewNotificationTemplateResponseSchema>;
|
|
14
|
+
export interface PreviewNotificationTemplateResponse {
|
|
15
|
+
preview: {
|
|
16
|
+
title: string;
|
|
17
|
+
body: string;
|
|
18
|
+
variables: Record<string, any>;
|
|
19
|
+
};
|
|
20
|
+
missingVariables: string[];
|
|
21
|
+
}
|
|
@@ -9,15 +9,6 @@ export const syncNotificationTemplateRequestSchema = z.object({
|
|
|
9
9
|
|
|
10
10
|
export type SyncNotificationTemplateRequest = z.infer<typeof syncNotificationTemplateRequestSchema>;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
template: z.any().optional(), // Will be Serialized<NotificationTemplateData>
|
|
16
|
-
error: z.string().optional()
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export type SyncNotificationTemplateResponse = {
|
|
20
|
-
success: boolean;
|
|
21
|
-
template?: Serialized<NotificationTemplateData>;
|
|
22
|
-
error?: string;
|
|
23
|
-
};
|
|
12
|
+
export interface SyncNotificationTemplateResponse {
|
|
13
|
+
template: Serialized<NotificationTemplateData>;
|
|
14
|
+
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Serialized } from "../../../utils";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
NotificationTemplateData,
|
|
5
|
+
notificationTriggerTypeSchema
|
|
6
|
+
} from "../../models";
|
|
4
7
|
|
|
5
8
|
// Request schema
|
|
6
9
|
export const updateNotificationTemplateRequestSchema = z.object({
|
|
7
|
-
name: z.string().
|
|
8
|
-
description: z.string().
|
|
10
|
+
name: z.string().optional(),
|
|
11
|
+
description: z.string().optional(),
|
|
9
12
|
trigger: z.object({
|
|
10
13
|
type: notificationTriggerTypeSchema,
|
|
11
14
|
conditions: z.record(z.any()),
|
|
12
15
|
timing: z.record(z.any())
|
|
13
16
|
}).optional(),
|
|
14
17
|
content: z.object({
|
|
15
|
-
title: z.string()
|
|
16
|
-
body: z.string()
|
|
18
|
+
title: z.string(),
|
|
19
|
+
body: z.string(),
|
|
17
20
|
variables: z.record(z.string()).optional()
|
|
18
21
|
}).optional(),
|
|
19
22
|
active: z.boolean().optional(),
|
|
@@ -22,15 +25,6 @@ export const updateNotificationTemplateRequestSchema = z.object({
|
|
|
22
25
|
|
|
23
26
|
export type UpdateNotificationTemplateRequest = z.infer<typeof updateNotificationTemplateRequestSchema>;
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
template: z.any().optional(), // Will be Serialized<NotificationTemplateData>
|
|
29
|
-
error: z.string().optional()
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export type UpdateNotificationTemplateResponse = {
|
|
33
|
-
success: boolean;
|
|
34
|
-
template?: Serialized<NotificationTemplateData>;
|
|
35
|
-
error?: string;
|
|
36
|
-
};
|
|
28
|
+
export interface UpdateNotificationTemplateResponse {
|
|
29
|
+
template: Serialized<NotificationTemplateData>;
|
|
30
|
+
}
|
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Habit,
|
|
3
|
-
HabitData, HabitEntry,
|
|
4
|
-
HabitEntryData,
|
|
5
|
-
ItemData, Person,
|
|
6
|
-
PersonData,
|
|
7
|
-
PersonNoteData,
|
|
8
|
-
NotificationTemplateData,
|
|
9
|
-
ListItemData, ListData,
|
|
10
|
-
ThoughtData,
|
|
11
|
-
UserData
|
|
12
|
-
} from "../types";
|
|
13
|
-
|
|
14
1
|
export type Serialized<T> = T extends Date
|
|
15
2
|
? string
|
|
16
|
-
: T extends
|
|
17
|
-
?
|
|
18
|
-
: T extends
|
|
19
|
-
?
|
|
20
|
-
: T
|
|
21
|
-
? Serialized<U>[]
|
|
22
|
-
: T extends object
|
|
23
|
-
? { [K in keyof T]: Serialized<T[K]> }
|
|
24
|
-
: T;
|
|
3
|
+
: T extends (infer U)[]
|
|
4
|
+
? Serialized<U>[]
|
|
5
|
+
: T extends object
|
|
6
|
+
? { [K in keyof T]: Serialized<T[K]> }
|
|
7
|
+
: T;
|
|
25
8
|
|
|
26
9
|
export class Serializer {
|
|
27
10
|
static serialize<T>(obj: T): Serialized<T> {
|
|
@@ -31,130 +14,17 @@ export class Serializer {
|
|
|
31
14
|
static deserialize<T>(obj: Serialized<T>): T {
|
|
32
15
|
return deserializeRecursive(obj) as T;
|
|
33
16
|
}
|
|
34
|
-
|
|
35
|
-
static serializeItemData(data: ItemData): Serialized<ItemData> {
|
|
36
|
-
return this.serialize(data);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static deserializeItemData(data: Serialized<ItemData>): ItemData {
|
|
40
|
-
return this.deserialize(data) as unknown as ItemData;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static serializeHabitData(data: HabitData): Serialized<HabitData> {
|
|
44
|
-
return this.serialize(data);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static deserializeHabitData(data: Serialized<HabitData>): HabitData {
|
|
48
|
-
return this.deserialize(data) as unknown as HabitData;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static serializeHabitDataEntry(data: HabitEntryData): Serialized<HabitEntryData> {
|
|
52
|
-
return this.serialize(data);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static serializeHabit(data: Habit): Serialized<Habit> {
|
|
56
|
-
return this.serialize(data);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
static deserializeHabit(data: Serialized<Habit>): Habit {
|
|
60
|
-
return this.deserialize(data) as unknown as Habit;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static serializeHabitEntry(data: HabitEntry): Serialized<HabitEntry> {
|
|
64
|
-
return this.serialize(data);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static deserializeHabitEntry(data: Serialized<HabitEntry>): HabitEntry {
|
|
68
|
-
return this.deserialize(data) as unknown as HabitEntry;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
static deserializeHabitDataEntry(data: Serialized<HabitEntryData>): HabitEntryData {
|
|
72
|
-
return this.deserialize(data) as unknown as HabitEntryData;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static serializePerson(data: Person): Serialized<Person> {
|
|
76
|
-
return this.serialize(data);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static deserializePerson(data: Serialized<Person>): Person {
|
|
80
|
-
return this.deserialize(data) as unknown as Person;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
static serializePersonData(data: PersonData): Serialized<PersonData> {
|
|
84
|
-
return this.serialize(data);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static deserializePersonData(data: Serialized<PersonData>): PersonData {
|
|
88
|
-
return this.deserialize(data) as unknown as PersonData;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
static serializePersonNoteData(data: PersonNoteData): Serialized<PersonNoteData> {
|
|
92
|
-
return this.serialize(data);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
static deserializePersonNoteData(data: Serialized<PersonNoteData>): PersonNoteData {
|
|
96
|
-
return this.deserialize(data) as unknown as PersonNoteData;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static serializeListItemData(data: ListItemData): Serialized<ListItemData> {
|
|
100
|
-
return this.serialize(data);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
static deserializeListItemData(data: Serialized<ListItemData>): ListItemData {
|
|
104
|
-
return this.deserialize(data) as unknown as ListItemData;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
static serializeListData(data: ListData): Serialized<ListData> {
|
|
108
|
-
return this.serialize(data);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
static deserializeListData(data: Serialized<ListData>): ListData {
|
|
112
|
-
return this.deserialize(data) as unknown as ListData;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
static serializeThoughtData(data: ThoughtData): Serialized<ThoughtData> {
|
|
116
|
-
return this.serialize(data);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
static deserializeThoughtData(data: Serialized<ThoughtData>): ThoughtData {
|
|
120
|
-
return this.deserialize(data) as unknown as ThoughtData;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
static serializeUserData(data: UserData): Serialized<UserData> {
|
|
124
|
-
return this.serialize(data);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
static deserializeUserData(data: Serialized<UserData>): UserData {
|
|
128
|
-
return this.deserialize(data) as unknown as UserData;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
static serializeNotificationTemplateData(data: NotificationTemplateData): Serialized<NotificationTemplateData> {
|
|
132
|
-
return this.serialize(data);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
static deserializeNotificationTemplateData(data: Serialized<NotificationTemplateData>): NotificationTemplateData {
|
|
136
|
-
return this.deserialize(data) as unknown as NotificationTemplateData;
|
|
137
|
-
}
|
|
138
17
|
}
|
|
139
18
|
|
|
140
19
|
function serializeRecursive(obj: any): any {
|
|
141
|
-
if (obj === null || obj === undefined)
|
|
142
|
-
|
|
143
|
-
}
|
|
20
|
+
if (obj === null || obj === undefined) return obj;
|
|
21
|
+
if (obj instanceof Date) return obj.toISOString();
|
|
144
22
|
|
|
145
|
-
if (obj
|
|
146
|
-
return obj.toISOString();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (Array.isArray(obj)) {
|
|
150
|
-
return obj.map(item => serializeRecursive(item));
|
|
151
|
-
}
|
|
23
|
+
if (Array.isArray(obj)) return obj.map(item => serializeRecursive(item));
|
|
152
24
|
|
|
153
25
|
if (typeof obj === 'object') {
|
|
154
26
|
const result: any = {};
|
|
155
|
-
for (const [key, value] of Object.entries(obj))
|
|
156
|
-
result[key] = serializeRecursive(value);
|
|
157
|
-
}
|
|
27
|
+
for (const [key, value] of Object.entries(obj)) result[key] = serializeRecursive(value);
|
|
158
28
|
return result;
|
|
159
29
|
}
|
|
160
30
|
|
|
@@ -162,23 +32,14 @@ function serializeRecursive(obj: any): any {
|
|
|
162
32
|
}
|
|
163
33
|
|
|
164
34
|
function deserializeRecursive(obj: any): any {
|
|
165
|
-
if (obj === null || obj === undefined)
|
|
166
|
-
|
|
167
|
-
}
|
|
35
|
+
if (obj === null || obj === undefined) return obj;
|
|
36
|
+
if (typeof obj === 'string' && isISODateString(obj)) return new Date(obj);
|
|
168
37
|
|
|
169
|
-
if (
|
|
170
|
-
return new Date(obj);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (Array.isArray(obj)) {
|
|
174
|
-
return obj.map(item => deserializeRecursive(item));
|
|
175
|
-
}
|
|
38
|
+
if (Array.isArray(obj)) return obj.map(item => deserializeRecursive(item));
|
|
176
39
|
|
|
177
40
|
if (typeof obj === 'object') {
|
|
178
41
|
const result: any = {};
|
|
179
|
-
for (const [key, value] of Object.entries(obj))
|
|
180
|
-
result[key] = deserializeRecursive(value);
|
|
181
|
-
}
|
|
42
|
+
for (const [key, value] of Object.entries(obj)) result[key] = deserializeRecursive(value);
|
|
182
43
|
return result;
|
|
183
44
|
}
|
|
184
45
|
|