mirror of
https://github.com/immich-app/immich.git
synced 2025-12-23 01:11:36 +03:00
refactor: sync service (#19225)
This commit is contained in:
@@ -18,14 +18,17 @@ export const toAck = ({ type, updateId, extraId }: SyncAck) =>
|
||||
|
||||
export const mapJsonLine = (object: unknown) => JSON.stringify(object) + '\n';
|
||||
|
||||
export type SerializeOptions<T extends keyof SyncItem, D extends SyncItem[T]> = {
|
||||
type: T;
|
||||
data: Exact<SyncItem[T], D>;
|
||||
ids: [string] | [string, string];
|
||||
ackType?: SyncEntityType;
|
||||
};
|
||||
|
||||
export const serialize = <T extends keyof SyncItem, D extends SyncItem[T]>({
|
||||
type,
|
||||
data,
|
||||
ids,
|
||||
ackType,
|
||||
}: {
|
||||
type: T;
|
||||
data: Exact<SyncItem[T], D>;
|
||||
ids: [string] | [string, string];
|
||||
ackType?: SyncEntityType;
|
||||
}) => mapJsonLine({ type, data, ack: toAck({ type: ackType ?? type, updateId: ids[0], extraId: ids[1] }) });
|
||||
}: SerializeOptions<T, D>) =>
|
||||
mapJsonLine({ type, data, ack: toAck({ type: ackType ?? type, updateId: ids[0], extraId: ids[1] }) });
|
||||
|
||||
Reference in New Issue
Block a user