(
session: GoalQueueSession,
input: { readonly objective: string },
)
| 43 | } |
| 44 | |
| 45 | export async function appendGoalQueueItem( |
| 46 | session: GoalQueueSession, |
| 47 | input: { readonly objective: string }, |
| 48 | ): Promise<GoalQueueSnapshot> { |
| 49 | const objective = normalizeObjective(input.objective); |
| 50 | return withQueueMutationLock(session, async () => { |
| 51 | const state = await readQueueFile(session); |
| 52 | const now = new Date().toISOString(); |
| 53 | const goal: UpcomingGoal = { |
| 54 | id: randomUUID(), |
| 55 | objective, |
| 56 | createdAt: now, |
| 57 | updatedAt: now, |
| 58 | }; |
| 59 | const next: GoalQueueFile = { version: GOAL_QUEUE_VERSION, goals: [...state.goals, goal] }; |
| 60 | await writeQueueFile(session, next); |
| 61 | return toSnapshot(next); |
| 62 | }); |
| 63 | } |
| 64 | |
| 65 | export async function updateGoalQueueItem( |
| 66 | session: GoalQueueSession, |
no test coverage detected