@@ -0,0 +1,46 @@
|
||||
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
import { token } from "@conusai-kit/core"
|
||||
import type { CommentReceipt, CommentView, TaskReceipt, TaskView } from "../contract/index.js"
|
||||
export interface Page<T> {
|
||||
rows: T[]
|
||||
after?: string
|
||||
}
|
||||
export interface TaskRecord extends TaskView {
|
||||
targets: string[]
|
||||
}
|
||||
export interface ActivitiesReads {
|
||||
readonly bindingId: string
|
||||
list(input: { target: string; status?: "open" | "done" | "cancelled"; after?: string }): Promise<Page<TaskView>>
|
||||
get(taskId: string): Promise<TaskRecord>
|
||||
comments(input: { taskId: string; after?: string }): Promise<Page<CommentView>>
|
||||
timeline(input: { target: string; after?: string }): Promise<Page<TaskView>>
|
||||
}
|
||||
export interface ActivitiesService extends ActivitiesReads {
|
||||
create(input: {
|
||||
subject: string
|
||||
body: string
|
||||
target: string
|
||||
participant: string
|
||||
key: string
|
||||
}): Promise<TaskReceipt>
|
||||
update(input: {
|
||||
task: TaskRecord
|
||||
target: string
|
||||
subject: string
|
||||
body: string
|
||||
expectedVersion: string
|
||||
key: string
|
||||
}): Promise<TaskReceipt>
|
||||
change(input: { taskId: string; state: "done" | "open"; expectedVersion: string; key: string }): Promise<TaskReceipt>
|
||||
comment(input: { taskId: string; body: string; expectedVersion: string; key: string }): Promise<CommentReceipt>
|
||||
}
|
||||
export const readsOf = (service: ActivitiesReads): ActivitiesReads => ({
|
||||
bindingId: service.bindingId,
|
||||
list: (input) => service.list(input),
|
||||
get: (id) => service.get(id),
|
||||
comments: (input) => service.comments(input),
|
||||
timeline: (input) => service.timeline(input),
|
||||
})
|
||||
export const ACTIVITIES_SERVICE = token<ActivitiesService>("activities.service", {
|
||||
views: { read: readsOf, write: readsOf },
|
||||
})
|
||||
Reference in New Issue
Block a user