MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / commitmentAgendaEntry

Function commitmentAgendaEntry

web/src/lib/commitment.ts:33–54  ·  view source on GitHub ↗
(view: ItemCommitmentView, ctx: { wsSlug: string; item: Item; collection: Collection | null; zone: string })

Source from the content-addressed store, hash-verified

31 * move compares roles.target.
32 */
33export function commitmentAgendaEntry(view: ItemCommitmentView, ctx: { wsSlug: string; item: Item; collection: Collection | null; zone: string }): AgendaEntry | null {
34 const next = view.next_occurrence;
35 const collection = ctx.collection?.slug ?? ctx.item.collection_slug;
36 if (!next || view.ended_at || view.error_code || !collection) return null;
37 const target = view.roles.target;
38 const scheduleZone = view.floating ? ctx.zone : view.tz ?? ctx.zone;
39 const at = target ? (isDateOnly(target) ? wallToInstant(`${target}T00:00`, scheduleZone) : target) : next.at;
40 const f = view.forecast;
41 return {
42 type: 'schedule', at, day: target ? roleDay(target, ctx.zone) : todayIn(ctx.zone, new Date(next.at)),
43 wall: next.wall, state: next.state, item_ref: view.item_ref, item_title: ctx.item.title, collection, workspace: ctx.wsSlug,
44 all_day: isDateOnly(target ?? view.dtstart), floating: view.floating, schedule_id: view.schedule_id, audience: view.audience,
45 roles: view.roles, roles_origin: view.roles.roles_origin,
46 ...(view.occurrence_key !== undefined ? { occurrence_key: view.occurrence_key } : {}),
47 ...(view.snoozed_until !== undefined ? { snoozed_until: view.snoozed_until } : {}),
48 ...(view.missed_count !== undefined ? { missed_count: view.missed_count } : {}),
49 ...(view.stale !== undefined ? { stale: view.stale } : {}),
50 ...(next.acknowledged_at !== undefined ? { acknowledged_at: next.acknowledged_at } : {}),
51 ...(next.acknowledged_by !== undefined ? { acknowledged_by: next.acknowledged_by } : {}),
52 ...(f ? { forecast: { value: f.value, set_by: f.set_by, ...(f.set_by_name !== undefined ? { set_by_name: f.set_by_name } : {}), set_by_kind: f.set_by_kind, set_at: f.set_at, source: f.source } } : {})
53 };
54}
55
56/** Once plus the server's eight shorthands (internal/schedule/shorthand.go), as canonical rules. */
57export const COMMITMENT_RECURRENCES = [

Callers 2

commitment.test.tsFile · 0.90
entryOfFunction · 0.90

Calls 4

isDateOnlyFunction · 0.90
wallToInstantFunction · 0.90
roleDayFunction · 0.90
todayInFunction · 0.90

Tested by 1

entryOfFunction · 0.72