Skip to content

Commit a6b9f01

Browse files
committed
fix code style
1 parent 4638a8f commit a6b9f01

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/utils/merge.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import { GroupedEventDBScheme, RepetitionDBScheme } from '@hawk.so/types';
99
* the original repetition payload using the very first event and its difference
1010
* between its repetition
1111
*
12+
* @deprecated remove after checking that all repetitions has no payloads in db
1213
* @param originalEvent - the very first event we received
1314
* @param repetition - the difference with its repetition, for the repetition we want to display
1415
* @returns fully assembled payload of the current repetition
1516
*/
16-
export function repetitionAssembler(originalEvent: Record<string, any>, repetition: { [key: string]: any }): any {
17+
export function repetitionAssembler(originalEvent: GroupedEventDBScheme['payload'], repetition: GroupedEventDBScheme['payload']): GroupedEventDBScheme['payload'] {
1718
const customizer = (originalParam: any, repetitionParam: any): any => {
1819
if (repetitionParam === null) {
1920
return originalParam;
@@ -39,15 +40,29 @@ export function repetitionAssembler(originalEvent: Record<string, any>, repetiti
3940
return mergeWith(cloneDeep(originalEvent), cloneDeep(repetition), customizer);
4041
}
4142

42-
function parsePayloadField(payload: any, field: string) {
43+
/**
44+
* Parse addons and context fields from string to object, in db it stores as string
45+
*
46+
* @param payload - the payload of the event
47+
* @param field - the field to parse, can be 'addons' or 'context'
48+
* @returns the payload with parsed field
49+
*/
50+
function parsePayloadField(payload: GroupedEventDBScheme['payload'], field: 'addons' | 'context') {
4351
if (payload && payload[field] && typeof payload[field] === 'string') {
4452
payload[field] = JSON.parse(payload[field]);
4553
}
4654

4755
return payload;
4856
}
4957

50-
function stringifyPayloadField(payload: any, field: string) {
58+
/**
59+
* Stringify addons and context fields from object to string, in db it stores as string
60+
*
61+
* @param payload - the payload of the event
62+
* @param field - the field to stringify, can be 'addons' or 'context'
63+
* @returns the payload with stringified field
64+
*/
65+
function stringifyPayloadField(payload: GroupedEventDBScheme['payload'], field: 'addons' | 'context') {
5166
if (payload && payload[field]) {
5267
payload[field] = JSON.stringify(payload[field]);
5368
}
@@ -107,7 +122,7 @@ export function composeFullRepetitionEvent(originalEvent: GroupedEventDBScheme,
107122

108123
/**
109124
* Old delta format (repetition.payload is not null)
110-
* @todo remove after July 5 2025
125+
* @todo remove after checking that all repetitions has no payloads in db
111126
*/
112127
event.payload = repetitionAssembler(event.payload, repetition.payload);
113128

0 commit comments

Comments
 (0)