feat: add models package

This commit is contained in:
Karol Sójko
2022-07-05 20:47:11 +02:00
parent 60d1554ff7
commit b614c71e79
199 changed files with 8772 additions and 22 deletions

View File

@@ -0,0 +1,50 @@
import { Uuid } from '@standardnotes/common'
import { DeletedPayloadInterface, EncryptedPayloadInterface } from '../Payload'
import { ContextPayload } from './ContextPayload'
export interface ServerSyncPushContextualPayload extends ContextPayload {
auth_hash?: string
content: string | undefined
created_at_timestamp: number
created_at: Date
duplicate_of?: Uuid
enc_item_key?: string
items_key_id?: string
updated_at_timestamp: number
updated_at: Date
}
export function CreateEncryptedServerSyncPushPayload(
fromPayload: EncryptedPayloadInterface,
): ServerSyncPushContextualPayload {
return {
content_type: fromPayload.content_type,
created_at_timestamp: fromPayload.created_at_timestamp,
created_at: fromPayload.created_at,
deleted: false,
duplicate_of: fromPayload.duplicate_of,
updated_at_timestamp: fromPayload.updated_at_timestamp,
updated_at: fromPayload.updated_at,
uuid: fromPayload.uuid,
content: fromPayload.content,
enc_item_key: fromPayload.enc_item_key,
items_key_id: fromPayload.items_key_id,
auth_hash: fromPayload.auth_hash,
}
}
export function CreateDeletedServerSyncPushPayload(
fromPayload: DeletedPayloadInterface,
): ServerSyncPushContextualPayload {
return {
content_type: fromPayload.content_type,
created_at_timestamp: fromPayload.created_at_timestamp,
created_at: fromPayload.created_at,
deleted: true,
duplicate_of: fromPayload.duplicate_of,
updated_at_timestamp: fromPayload.updated_at_timestamp,
updated_at: fromPayload.updated_at,
uuid: fromPayload.uuid,
content: undefined,
}
}