42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
import type { CreateNotificationParams, LogPublicationParams, WriteObjectParams } from './types'
|
|
import type { ObjectType } from '../objectCache'
|
|
|
|
export async function writeObjectDirect(params: WriteObjectParams): Promise<void> {
|
|
const { objectCache } = await import('../objectCache')
|
|
await objectCache.set({
|
|
objectType: params.objectType,
|
|
hash: params.hash,
|
|
event: params.event,
|
|
parsed: params.parsed,
|
|
version: params.version,
|
|
hidden: params.hidden,
|
|
...(params.index !== undefined ? { index: params.index } : {}),
|
|
...(params.published !== undefined ? { published: params.published } : {}),
|
|
})
|
|
}
|
|
|
|
export async function updatePublishedDirect(params: { objectType: ObjectType; id: string; published: false | string[] }): Promise<void> {
|
|
const { objectCache } = await import('../objectCache')
|
|
await objectCache.updatePublished(params.objectType, params.id, params.published)
|
|
}
|
|
|
|
export async function createNotificationDirect(params: CreateNotificationParams): Promise<void> {
|
|
const { notificationService } = await import('../notificationService')
|
|
const notificationParams: Parameters<typeof notificationService.createNotification>[0] = {
|
|
type: params.type as Parameters<typeof notificationService.createNotification>[0]['type'],
|
|
objectType: params.objectType,
|
|
objectId: params.objectId,
|
|
eventId: params.eventId,
|
|
}
|
|
if (params.data !== undefined) {
|
|
notificationParams.data = params.data
|
|
}
|
|
await notificationService.createNotification(notificationParams)
|
|
}
|
|
|
|
export async function logPublicationDirect(params: LogPublicationParams): Promise<void> {
|
|
const { publishLog } = await import('../publishLog')
|
|
await publishLog.logPublicationDirect(params)
|
|
}
|
|
|