mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor: sync service (#19225)
This commit is contained in:
parent
4c69511225
commit
35280b94cc
2 changed files with 235 additions and 234 deletions
|
|
@ -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] }) });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue