@@ -0,0 +1,109 @@
|
||||
// The handlers of the module's procedures: each takes the service its kind may use and calls one use
|
||||
// case. No rule lives here.
|
||||
|
||||
import { implement } from "@conusai-kit/core"
|
||||
import { filesDeps } from "@conusai-kit/files"
|
||||
import {
|
||||
disposalList,
|
||||
documentDispose,
|
||||
documentGet,
|
||||
documentHold,
|
||||
documentList,
|
||||
documentRegister,
|
||||
retentionCreate,
|
||||
retentionList,
|
||||
versionAdd,
|
||||
} from "../contract/index.js"
|
||||
import {
|
||||
addVersion,
|
||||
createRetentionClass,
|
||||
disposeDocument,
|
||||
getDocument,
|
||||
listDisposalDue,
|
||||
listDocuments,
|
||||
listRetentionClasses,
|
||||
registerDocument,
|
||||
setLegalHold,
|
||||
} from "../core/archive.js"
|
||||
import { archiveServiceOf } from "./service.js"
|
||||
|
||||
const paged = (input: { after?: string | undefined; limit?: number | undefined }) => ({
|
||||
...(input.after === undefined ? {} : { after: input.after }),
|
||||
...(input.limit === undefined ? {} : { limit: input.limit }),
|
||||
})
|
||||
|
||||
export const documentListImpl = implement(documentList, ({ input, ctx }) =>
|
||||
listDocuments(archiveServiceOf(ctx.container, ctx.kind), {
|
||||
...(input.q === undefined ? {} : { q: input.q }),
|
||||
...paged(input),
|
||||
}),
|
||||
)
|
||||
|
||||
export const documentGetImpl = implement(documentGet, ({ input, ctx }) =>
|
||||
getDocument(archiveServiceOf(ctx.container, ctx.kind), input.documentId),
|
||||
)
|
||||
|
||||
export const documentRegisterImpl = implement(documentRegister, ({ input, ctx }) =>
|
||||
registerDocument(archiveServiceOf(ctx.container, "effect"), filesDeps(ctx.container), ctx.scope, {
|
||||
title: input.title,
|
||||
...(input.kind === undefined ? {} : { kind: input.kind }),
|
||||
retentionClass: input.retentionClass,
|
||||
fileId: input.fileId,
|
||||
requestId: input.requestId,
|
||||
}),
|
||||
)
|
||||
|
||||
export const versionAddImpl = implement(versionAdd, ({ input, ctx }) =>
|
||||
addVersion(archiveServiceOf(ctx.container, "effect"), filesDeps(ctx.container), ctx.scope, {
|
||||
documentId: input.documentId,
|
||||
revision: input.revision,
|
||||
fileId: input.fileId,
|
||||
requestId: input.requestId,
|
||||
}),
|
||||
)
|
||||
|
||||
export const documentHoldImpl = implement(documentHold, ({ input, ctx }) =>
|
||||
setLegalHold(archiveServiceOf(ctx.container, "effect"), ctx.scope, {
|
||||
documentId: input.documentId,
|
||||
revision: input.revision,
|
||||
legalHold: input.legalHold,
|
||||
requestId: input.requestId,
|
||||
}),
|
||||
)
|
||||
|
||||
export const documentDisposeImpl = implement(documentDispose, ({ input, ctx }) =>
|
||||
disposeDocument(archiveServiceOf(ctx.container, "effect"), ctx.scope, {
|
||||
documentId: input.documentId,
|
||||
revision: input.revision,
|
||||
requestId: input.requestId,
|
||||
}),
|
||||
)
|
||||
|
||||
export const retentionListImpl = implement(retentionList, ({ input, ctx }) =>
|
||||
listRetentionClasses(archiveServiceOf(ctx.container, ctx.kind), paged(input)),
|
||||
)
|
||||
|
||||
export const retentionCreateImpl = implement(retentionCreate, ({ input, ctx }) =>
|
||||
createRetentionClass(archiveServiceOf(ctx.container, "effect"), ctx.scope, {
|
||||
code: input.code,
|
||||
keepFor: input.keepFor,
|
||||
from: input.from,
|
||||
requestId: input.requestId,
|
||||
}),
|
||||
)
|
||||
|
||||
export const disposalListImpl = implement(disposalList, ({ input, ctx }) =>
|
||||
listDisposalDue(archiveServiceOf(ctx.container, ctx.kind), paged(input)),
|
||||
)
|
||||
|
||||
export const ARCHIVE_PROCEDURES = [
|
||||
documentListImpl,
|
||||
documentGetImpl,
|
||||
documentRegisterImpl,
|
||||
versionAddImpl,
|
||||
documentHoldImpl,
|
||||
documentDisposeImpl,
|
||||
retentionListImpl,
|
||||
retentionCreateImpl,
|
||||
disposalListImpl,
|
||||
]
|
||||
Reference in New Issue
Block a user