@mccaskie-labs/workbench-roster 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui.js ADDED
@@ -0,0 +1,198 @@
1
+ // The owner's week and staff pages and a person's own page: plain HTML
2
+ // strings, no script of their own, mobile first. Every change is a form post
3
+ // to the project's endpoint (behind the owner's sign-in), which hands the
4
+ // fields to rosterAction with the signed-in owner's account. Every element
5
+ // carries a wb-roster-* class (ROSTER_STYLES), and every control is at least
6
+ // 44 px tall. Taking someone off the roster needs its tick box.
7
+ import { RosterError } from "./errors.js";
8
+ import { dayText, localeFor, spanText, timeText, words } from "./format.js";
9
+ import { addDays, clockMinutes, todayIn } from "./time.js";
10
+ const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
11
+ const ctx = (o) => ({ say: words(o), locale: localeFor(o.lang, o.locale), tz: o.config.time_zone });
12
+ const roleTitle = (o, r) => (r ? (o.config.roles?.[r]?.title ?? r) : null);
13
+ const hidden = (fields) => Object.entries(fields).map(([k, v]) => `<input type="hidden" name="${k}" value="${esc(v)}">`).join("");
14
+ const leaveDays = (l, tz) => ({ from: todayIn(tz, new Date(l.starts_at)), to: todayIn(tz, new Date(Date.parse(l.ends_at) - 1)) });
15
+ function shiftParts(s, o, c, withName) {
16
+ const role = roleTitle(o, s.role);
17
+ return [
18
+ withName ? `<span class="wb-roster-who">${esc(s.staff_name)}</span>` : "",
19
+ `<span class="wb-roster-time">${esc(withName ? `${timeText(s.starts_at, c.tz, c.locale)} – ${timeText(s.ends_at, c.tz, c.locale)}` : spanText(s.starts_at, s.ends_at, c.tz, c.locale))}</span>`,
20
+ role ? `<span class="wb-roster-role">${esc(role)}</span>` : "",
21
+ s.break_minutes ? `<span class="wb-roster-break">${esc(c.say("shift.break", { minutes: s.break_minutes }))}</span>` : "",
22
+ s.note ? `<span class="wb-roster-note">${esc(s.note)}</span>` : "",
23
+ ].join("");
24
+ }
25
+ function gapText(g, o, c) {
26
+ const role = (g.role ? roleTitle(o, g.role) : null) ?? c.say("gaps.anyone");
27
+ const when = `${g.title ? `${g.title}, ` : ""}${spanText(g.start, g.end, c.tz, c.locale)}`;
28
+ return g.rostered === 0 ? c.say("gaps.nobody", { when, role }) : c.say("gaps.short", { when, role, rostered: g.rostered, needed: g.needed });
29
+ }
30
+ const field = (id, label, control) => `<div class="wb-roster-field"><label class="wb-roster-label" for="${id}">${esc(label)}</label>${control}</div>`;
31
+ const option = (value, label, selected = false) => `<option class="wb-roster-option" value="${esc(value)}"${selected ? " selected" : ""}>${esc(label)}</option>`;
32
+ /** The owner's week: its state, Last and Next week, the gaps, each day's shifts with Remove, Add a shift, Publish or Send changes, Copy last week and Download hours. */
33
+ export function renderWeek(v, o) {
34
+ const c = ctx(o);
35
+ const status = v.status === "draft" ? "draft" : v.unsent ? "unsent" : "published";
36
+ const statusText = c.say(status === "draft" ? "week.draft" : status === "unsent" ? "week.unsent" : "week.published");
37
+ const done = o.done ? `<p class="wb-roster-done" role="status">${esc(c.say(`done.${o.done}`))}</p>` : "";
38
+ const nav = `<nav class="wb-roster-nav"><a class="wb-roster-nav-link" href="${esc(o.weekUrl(addDays(v.week, -7)))}">${esc(c.say("week.prev"))}</a><a class="wb-roster-nav-link" href="${esc(o.weekUrl(addDays(v.week, 7)))}">${esc(c.say("week.next"))}</a></nav>`;
39
+ const flagged = new Map((o.gaps?.clashes ?? []).map((x) => [x.shift.id, x.reason]));
40
+ let gaps = "";
41
+ if (o.gaps) {
42
+ const items = [
43
+ ...o.gaps.gaps.map((g) => `<li class="wb-roster-gap">${esc(gapText(g, o, c))}</li>`),
44
+ ...o.gaps.clashes.map((x) => `<li class="wb-roster-gap wb-roster-gap-clash">${esc(`${x.shift.staff_name}: ${c.say(x.reason === "on_leave" ? "shift.on_leave" : "shift.removed")}, ${spanText(x.shift.starts_at, x.shift.ends_at, c.tz, c.locale)}`)}</li>`),
45
+ ];
46
+ gaps = `<section class="wb-roster-gaps"><h3 class="wb-roster-heading">${esc(c.say("gaps.title"))}</h3>${items.length ? `<ul class="wb-roster-gap-list">${items.join("")}</ul>` : `<p class="wb-roster-ok">${esc(c.say("gaps.none"))}</p>`}</section>`;
47
+ }
48
+ const dayHtml = v.days
49
+ .map((d) => {
50
+ const shifts = v.shifts.filter((s) => todayIn(c.tz, new Date(s.starts_at)) === d);
51
+ const list = shifts.length
52
+ ? `<ul class="wb-roster-shifts">${shifts
53
+ .map((s) => {
54
+ const flag = flagged.get(s.id);
55
+ return `<li class="wb-roster-shift">${shiftParts(s, o, c, true)}${flag ? `<span class="wb-roster-flag">${esc(c.say(flag === "on_leave" ? "shift.on_leave" : "shift.removed"))}</span>` : ""}<form class="wb-roster-inline" method="post" action="${esc(o.endpoint)}">${hidden({ action: "remove_shift", shift: s.id, week: v.week })}<button class="wb-roster-remove" type="submit">${esc(c.say("shift.remove"))}</button></form></li>`;
56
+ })
57
+ .join("")}</ul>`
58
+ : `<p class="wb-roster-empty">${esc(c.say("week.none"))}</p>`;
59
+ return `<section class="wb-roster-day"><h3 class="wb-roster-day-title">${esc(dayText(d, c.locale))}</h3>${list}</section>`;
60
+ })
61
+ .join("");
62
+ const active = v.staff.filter((s) => s.active);
63
+ const roles = Object.entries(o.config.roles ?? {});
64
+ const add = active.length
65
+ ? `<form class="wb-roster-form" method="post" action="${esc(o.endpoint)}">${hidden({ action: "add_shift", week: v.week })}<h3 class="wb-roster-heading">${esc(c.say("add.title"))}</h3>${field("wb-roster-staff", c.say("add.person"), `<select class="wb-roster-select" id="wb-roster-staff" name="staff" required>${active.map((s) => option(s.id, s.name)).join("")}</select>`)}${field("wb-roster-on", c.say("add.day"), `<select class="wb-roster-select" id="wb-roster-on" name="day" required>${v.days.map((d) => option(d, dayText(d, c.locale))).join("")}</select>`)}${field("wb-roster-start", c.say("add.start"), `<input class="wb-roster-input" id="wb-roster-start" type="time" name="start" required>`)}${field("wb-roster-end", c.say("add.end"), `<input class="wb-roster-input" id="wb-roster-end" type="time" name="end" required>`)}${roles.length ? field("wb-roster-role", c.say("add.role"), `<select class="wb-roster-select" id="wb-roster-role" name="role">${option("", c.say("add.role_any"))}${roles.map(([k, r]) => option(k, r.title)).join("")}</select>`) : ""}${field("wb-roster-break", c.say("add.break"), `<input class="wb-roster-input" id="wb-roster-break" type="number" name="break" min="0" max="240" step="5" value="0" inputmode="numeric">`)}${field("wb-roster-note", c.say("add.note"), `<input class="wb-roster-input" id="wb-roster-note" type="text" name="note" maxlength="200" autocomplete="off">`)}<button class="wb-roster-button" type="submit">${esc(c.say("add.button"))}</button></form>`
66
+ : "";
67
+ const actions = [
68
+ v.status === "draft" || v.unsent ? `<form class="wb-roster-inline" method="post" action="${esc(o.endpoint)}">${hidden({ action: "publish", week: v.week })}<button class="wb-roster-publish" type="submit">${esc(c.say(v.status === "draft" ? "week.publish" : "week.send"))}</button></form>` : "",
69
+ v.shifts.length === 0 ? `<form class="wb-roster-inline" method="post" action="${esc(o.endpoint)}">${hidden({ action: "copy_week", week: v.week })}<button class="wb-roster-secondary" type="submit">${esc(c.say("week.copy"))}</button></form>` : "",
70
+ o.exportUrl ? `<a class="wb-roster-export" href="${esc(o.exportUrl)}" download>${esc(c.say("week.export"))}</a>` : "",
71
+ ].join("");
72
+ return `<section class="wb-roster-week"><h2 class="wb-roster-title">${esc(c.say("week.title", { date: dayText(v.week, c.locale) }))}</h2><p class="wb-roster-status" data-status="${status}">${esc(statusText)}</p>${done}${nav}${gaps}<div class="wb-roster-days">${dayHtml}</div>${add}${actions ? `<div class="wb-roster-actions">${actions}</div>` : ""}</section>`;
73
+ }
74
+ /** The owner's staff page: each person with their leave, Email them their link, Add leave and Take off the roster; then Add person. */
75
+ export function renderStaff(staff, o) {
76
+ const c = ctx(o);
77
+ const done = o.done ? `<p class="wb-roster-done" role="status">${esc(c.say(`done.${o.done}`))}</p>` : "";
78
+ const roles = Object.entries(o.config.roles ?? {});
79
+ const active = staff.filter((s) => s.active);
80
+ const people = active.length
81
+ ? `<ul class="wb-roster-people">${active
82
+ .map((s) => {
83
+ const detail = [s.email, ...s.roles.map((r) => roleTitle(o, r) ?? r), s.resource].filter(Boolean).join(" · ");
84
+ const theirs = (o.leave ?? []).filter((l) => l.staff === s.id);
85
+ const leave = theirs.length
86
+ ? `<ul class="wb-roster-leave-list">${theirs
87
+ .map((l) => {
88
+ const d = leaveDays(l, c.tz);
89
+ return `<li class="wb-roster-leave"><span class="wb-roster-time">${esc(c.say("leave.when", { from: dayText(d.from, c.locale), to: dayText(d.to, c.locale) }))}</span><form class="wb-roster-inline" method="post" action="${esc(o.endpoint)}">${hidden({ action: "remove_leave", leave: l.id })}<button class="wb-roster-remove" type="submit">${esc(c.say("leave.remove"))}</button></form></li>`;
90
+ })
91
+ .join("")}</ul>`
92
+ : `<p class="wb-roster-empty">${esc(c.say("leave.none"))}</p>`;
93
+ const id = `wb-roster-${s.id.slice(0, 8)}`;
94
+ const leaveForm = `<form class="wb-roster-form" method="post" action="${esc(o.endpoint)}">${hidden({ action: "add_leave", staff: s.id })}${field(`${id}-from`, c.say("leave.from"), `<input class="wb-roster-input" id="${id}-from" type="date" name="from" required>`)}${field(`${id}-to`, c.say("leave.to"), `<input class="wb-roster-input" id="${id}-to" type="date" name="to" required>`)}<button class="wb-roster-secondary" type="submit">${esc(c.say("leave.add"))}</button></form>`;
95
+ const link = `<form class="wb-roster-inline" method="post" action="${esc(o.endpoint)}">${hidden({ action: "send_link", staff: s.id })}<button class="wb-roster-secondary" type="submit">${esc(c.say("staff.link"))}</button></form>`;
96
+ const remove = `<form class="wb-roster-remove-form" method="post" action="${esc(o.endpoint)}">${hidden({ action: "remove_staff", staff: s.id })}<label class="wb-roster-confirm"><input class="wb-roster-check" type="checkbox" name="confirm" value="yes" required> ${esc(c.say("staff.remove_confirm"))}</label><button class="wb-roster-danger" type="submit">${esc(c.say("staff.remove"))}</button></form>`;
97
+ return `<li class="wb-roster-person"><span class="wb-roster-who">${esc(s.name)}</span><span class="wb-roster-detail">${esc(detail)}</span><span class="wb-roster-flag">${esc(c.say(s.has_link ? "staff.link_sent" : "staff.no_link"))}</span><h3 class="wb-roster-heading">${esc(c.say("leave.title"))}</h3>${leave}${leaveForm}${link}${remove}</li>`;
98
+ })
99
+ .join("")}</ul>`
100
+ : `<p class="wb-roster-empty">${esc(c.say("staff.empty"))}</p>`;
101
+ const roleBoxes = roles.length
102
+ ? `<fieldset class="wb-roster-roles"><legend class="wb-roster-label">${esc(c.say("staff.roles"))}</legend>${roles.map(([k, r]) => `<label class="wb-roster-confirm"><input class="wb-roster-check" type="checkbox" name="roles" value="${esc(k)}"> ${esc(r.title)}</label>`).join("")}</fieldset>`
103
+ : "";
104
+ const add = `<form class="wb-roster-form" method="post" action="${esc(o.endpoint)}">${hidden({ action: "save_staff" })}<h3 class="wb-roster-heading">${esc(c.say("staff.add"))}</h3>${field("wb-roster-name", c.say("staff.name"), `<input class="wb-roster-input" id="wb-roster-name" type="text" name="name" maxlength="100" required autocomplete="off">`)}${field("wb-roster-email", c.say("staff.email"), `<input class="wb-roster-input" id="wb-roster-email" type="email" name="email" maxlength="254" required autocomplete="off">`)}${roleBoxes}${field("wb-roster-resource", c.say("staff.resource"), `<input class="wb-roster-input" id="wb-roster-resource" type="text" name="resource" maxlength="40" pattern="[a-z0-9][a-z0-9\\-]*" autocomplete="off">`)}<p class="wb-roster-hint">${esc(c.say("staff.resource_hint"))}</p><button class="wb-roster-button" type="submit">${esc(c.say("staff.add"))}</button></form>`;
105
+ return `<section class="wb-roster-staff"><h2 class="wb-roster-title">${esc(c.say("staff.title"))}</h2>${done}${people}${add}</section>`;
106
+ }
107
+ /** A person's own page, from roster.mine(token): their coming shifts, their leave, and Add my shifts to my calendar. */
108
+ export function renderMyShifts(v, o) {
109
+ const c = ctx(o);
110
+ const shifts = v.shifts.length ? `<ul class="wb-roster-shifts">${v.shifts.map((s) => `<li class="wb-roster-shift">${shiftParts(s, o, c, false)}</li>`).join("")}</ul>` : `<p class="wb-roster-empty">${esc(c.say("mine.none"))}</p>`;
111
+ const leave = v.leave.length
112
+ ? `<ul class="wb-roster-leave-list">${v.leave
113
+ .map((l) => {
114
+ const d = leaveDays(l, c.tz);
115
+ return `<li class="wb-roster-leave"><span class="wb-roster-time">${esc(c.say("mine.leave", { from: dayText(d.from, c.locale), to: dayText(d.to, c.locale) }))}</span></li>`;
116
+ })
117
+ .join("")}</ul>`
118
+ : "";
119
+ const calendar = o.feedUrl ? `<a class="wb-roster-calendar" href="${esc(o.feedUrl)}">${esc(c.say("mine.calendar"))}</a>` : "";
120
+ return `<article class="wb-roster-mine"><h2 class="wb-roster-title">${esc(c.say("mine.title", { name: v.staff.name }))}</h2>${shifts}${leave}${calendar}<p class="wb-roster-hint">${esc(c.say("mine.private"))}</p></article>`;
121
+ }
122
+ const field1 = (body, k) => {
123
+ const v = body[k];
124
+ return typeof v === "string" ? v.trim() : "";
125
+ };
126
+ /**
127
+ * The project's endpoint (behind the owner's sign-in) hands the posted form
128
+ * fields here with the signed-in owner's account: add_shift, remove_shift,
129
+ * publish (also Send changes), copy_week, save_staff, remove_staff (needs
130
+ * confirm=yes), send_link, add_leave and remove_leave. Another account's
131
+ * shift or person is answered as unknown.
132
+ */
133
+ export async function rosterAction(roster, body, account) {
134
+ try {
135
+ const action = field1(body, "action");
136
+ const week = field1(body, "week");
137
+ switch (action) {
138
+ case "add_shift": {
139
+ const d = field1(body, "day");
140
+ const from = field1(body, "start");
141
+ const to = field1(body, "end");
142
+ if (clockMinutes(from) === null || clockMinutes(to) === null)
143
+ throw new RosterError("bad_input", "start and end are times such as 09:00");
144
+ // An end at or before the start is the next day: a night shift.
145
+ const end = roster.at((clockMinutes(to) ?? 0) <= (clockMinutes(from) ?? 0) ? addDays(d, 1) : d, to);
146
+ const brk = field1(body, "break");
147
+ const s = await roster.addShift(account, { staff: field1(body, "staff"), start: roster.at(d, from), end, role: field1(body, "role") || null, break_minutes: brk ? Number(brk) : 0, note: field1(body, "note") || null });
148
+ return { status: 200, body: { ok: true, action, done: "add_shift", week: s.week } };
149
+ }
150
+ case "remove_shift":
151
+ if (!(await roster.removeShift(account, field1(body, "shift"))))
152
+ throw new RosterError("unknown_shift", "no such shift");
153
+ return { status: 200, body: { ok: true, action, done: "remove_shift", ...(week ? { week } : {}) } };
154
+ case "publish": {
155
+ const r = await roster.publish(account, week);
156
+ return { status: 200, body: { ok: true, action, done: "publish", week: r.week.week, emailed: r.emailed } };
157
+ }
158
+ case "copy_week": {
159
+ const r = await roster.copyWeek(account, addDays(week, -7), week);
160
+ return { status: 200, body: { ok: true, action, done: "copy", week, copied: r.copied, skipped: r.skipped } };
161
+ }
162
+ case "save_staff": {
163
+ const raw = body.roles;
164
+ const roles = Array.isArray(raw) ? raw.map(String) : typeof raw === "string" && raw ? raw.split(",").map((r) => r.trim()).filter(Boolean) : [];
165
+ const id = field1(body, "id");
166
+ await roster.saveStaff(account, { ...(id ? { id } : {}), name: field1(body, "name"), email: field1(body, "email"), roles, resource: field1(body, "resource") || null });
167
+ return { status: 200, body: { ok: true, action, done: "save_staff" } };
168
+ }
169
+ case "remove_staff":
170
+ if (body.confirm !== "yes")
171
+ throw new RosterError("bad_input", "tick the box to take this person off the roster");
172
+ if (!(await roster.removeStaff(account, field1(body, "staff"))))
173
+ throw new RosterError("unknown_staff", "no such person on the roster");
174
+ return { status: 200, body: { ok: true, action, done: "remove_staff" } };
175
+ case "send_link": {
176
+ const r = await roster.sendLink(account, field1(body, "staff"));
177
+ return { status: 200, body: { ok: true, action, done: "send_link", emailed: r.emailed } };
178
+ }
179
+ case "add_leave":
180
+ await roster.addLeave(account, { staff: field1(body, "staff"), from: field1(body, "from"), to: field1(body, "to") });
181
+ return { status: 200, body: { ok: true, action, done: "add_leave" } };
182
+ case "remove_leave":
183
+ if (!(await roster.removeLeave(account, field1(body, "leave"))))
184
+ throw new RosterError("unknown_shift", "no such leave");
185
+ return { status: 200, body: { ok: true, action, done: "remove_leave" } };
186
+ default:
187
+ throw new RosterError("bad_input", "action must be add_shift, remove_shift, publish, copy_week, save_staff, remove_staff, send_link, add_leave or remove_leave");
188
+ }
189
+ }
190
+ catch (e) {
191
+ if (e instanceof RosterError) {
192
+ const status = e.code === "unknown_staff" || e.code === "unknown_shift" ? 404 : e.code === "clash" || e.code === "on_leave" || e.code === "taken" || e.code === "not_empty" ? 409 : e.code === "store_failed" ? 502 : e.code === "bad_config" ? 500 : 400;
193
+ const message = e.code === "store_failed" || e.code === "bad_config" ? "roster: it failed on the app's side (the detail is in the result's cause, for the log)" : e.message;
194
+ return { status, body: { ok: false, error: e.code, message }, cause: e };
195
+ }
196
+ throw e;
197
+ }
198
+ }
@@ -0,0 +1,3 @@
1
+ export declare const ROSTER_WORD_KEYS: readonly ["week.title", "week.draft", "week.published", "week.unsent", "week.prev", "week.next", "week.none", "week.publish", "week.send", "week.copy", "week.export", "shift.break", "shift.remove", "shift.on_leave", "shift.removed", "add.title", "add.person", "add.day", "add.start", "add.end", "add.role", "add.role_any", "add.break", "add.note", "add.button", "gaps.title", "gaps.none", "gaps.nobody", "gaps.short", "gaps.anyone", "staff.title", "staff.empty", "staff.name", "staff.email", "staff.roles", "staff.resource", "staff.resource_hint", "staff.add", "staff.save", "staff.link", "staff.link_sent", "staff.no_link", "staff.remove", "staff.remove_confirm", "leave.title", "leave.none", "leave.from", "leave.to", "leave.add", "leave.remove", "leave.when", "mine.title", "mine.none", "mine.calendar", "mine.private", "mine.leave", "done.add_shift", "done.remove_shift", "done.publish", "done.copy", "done.save_staff", "done.remove_staff", "done.send_link", "done.add_leave", "done.remove_leave", "email.week.subject", "email.changed.subject", "email.hello", "email.week.intro", "email.changed.intro", "email.none", "email.gone", "email.calendar", "email.footer", "email.link.subject", "email.link.body", "email.link.feed", "email.link.keep", "ics.cancelled", "csv.date", "csv.name", "csv.role", "csv.start", "csv.end", "csv.break", "csv.hours"];
2
+ export type RosterWordKey = (typeof ROSTER_WORD_KEYS)[number];
3
+ export declare const ROSTER_WORDS: Readonly<Record<"en" | "tl" | "taglish", Readonly<Record<RosterWordKey, string>>>>;
package/dist/words.js ADDED
@@ -0,0 +1,358 @@
1
+ // The roster's words, keyed as the project's strings catalogue keys them
2
+ // (`ui.wbroster.*`), in English, Tagalog and Taglish. A project copies them
3
+ // into its catalogue (or keeps its own) and passes its `t`; a word the
4
+ // catalogue lacks falls back to the words here. The Tagalog and Taglish are
5
+ // starter words: have a fluent reader check them before a client sees them.
6
+ export const ROSTER_WORD_KEYS = [
7
+ "week.title",
8
+ "week.draft",
9
+ "week.published",
10
+ "week.unsent",
11
+ "week.prev",
12
+ "week.next",
13
+ "week.none",
14
+ "week.publish",
15
+ "week.send",
16
+ "week.copy",
17
+ "week.export",
18
+ "shift.break",
19
+ "shift.remove",
20
+ "shift.on_leave",
21
+ "shift.removed",
22
+ "add.title",
23
+ "add.person",
24
+ "add.day",
25
+ "add.start",
26
+ "add.end",
27
+ "add.role",
28
+ "add.role_any",
29
+ "add.break",
30
+ "add.note",
31
+ "add.button",
32
+ "gaps.title",
33
+ "gaps.none",
34
+ "gaps.nobody",
35
+ "gaps.short",
36
+ "gaps.anyone",
37
+ "staff.title",
38
+ "staff.empty",
39
+ "staff.name",
40
+ "staff.email",
41
+ "staff.roles",
42
+ "staff.resource",
43
+ "staff.resource_hint",
44
+ "staff.add",
45
+ "staff.save",
46
+ "staff.link",
47
+ "staff.link_sent",
48
+ "staff.no_link",
49
+ "staff.remove",
50
+ "staff.remove_confirm",
51
+ "leave.title",
52
+ "leave.none",
53
+ "leave.from",
54
+ "leave.to",
55
+ "leave.add",
56
+ "leave.remove",
57
+ "leave.when",
58
+ "mine.title",
59
+ "mine.none",
60
+ "mine.calendar",
61
+ "mine.private",
62
+ "mine.leave",
63
+ "done.add_shift",
64
+ "done.remove_shift",
65
+ "done.publish",
66
+ "done.copy",
67
+ "done.save_staff",
68
+ "done.remove_staff",
69
+ "done.send_link",
70
+ "done.add_leave",
71
+ "done.remove_leave",
72
+ "email.week.subject",
73
+ "email.changed.subject",
74
+ "email.hello",
75
+ "email.week.intro",
76
+ "email.changed.intro",
77
+ "email.none",
78
+ "email.gone",
79
+ "email.calendar",
80
+ "email.footer",
81
+ "email.link.subject",
82
+ "email.link.body",
83
+ "email.link.feed",
84
+ "email.link.keep",
85
+ "ics.cancelled",
86
+ "csv.date",
87
+ "csv.name",
88
+ "csv.role",
89
+ "csv.start",
90
+ "csv.end",
91
+ "csv.break",
92
+ "csv.hours",
93
+ ];
94
+ const en = {
95
+ "week.title": "Roster: week of {date}",
96
+ "week.draft": "Draft: staff can't see this week yet",
97
+ "week.published": "Published",
98
+ "week.unsent": "Published, with changes staff haven't been told about yet",
99
+ "week.prev": "Last week",
100
+ "week.next": "Next week",
101
+ "week.none": "No shifts",
102
+ "week.publish": "Publish and email staff",
103
+ "week.send": "Send the changes now",
104
+ "week.copy": "Copy last week's shifts",
105
+ "week.export": "Download hours",
106
+ "shift.break": "{minutes} min break",
107
+ "shift.remove": "Remove",
108
+ "shift.on_leave": "On leave",
109
+ "shift.removed": "No longer on the roster",
110
+ "add.title": "Add a shift",
111
+ "add.person": "Who",
112
+ "add.day": "Day",
113
+ "add.start": "Starts",
114
+ "add.end": "Ends",
115
+ "add.role": "Doing",
116
+ "add.role_any": "Any of their roles",
117
+ "add.break": "Unpaid break (minutes)",
118
+ "add.note": "Note for them",
119
+ "add.button": "Add shift",
120
+ "gaps.title": "Gaps",
121
+ "gaps.none": "Every time that needs people has them.",
122
+ "gaps.nobody": "{when}: no {role} on",
123
+ "gaps.short": "{when}: {rostered} of {needed} {role} on",
124
+ "gaps.anyone": "staff",
125
+ "staff.title": "Staff",
126
+ "staff.empty": "Nobody on the roster yet. Add each person below.",
127
+ "staff.name": "Name",
128
+ "staff.email": "Email",
129
+ "staff.roles": "Can work as",
130
+ "staff.resource": "Name in bookings",
131
+ "staff.resource_hint": "Only for people customers book. It's their name in bookings.json, such as dr-lee.",
132
+ "staff.add": "Add person",
133
+ "staff.save": "Save",
134
+ "staff.link": "Email them their link",
135
+ "staff.link_sent": "Has their link",
136
+ "staff.no_link": "No link yet",
137
+ "staff.remove": "Take off the roster",
138
+ "staff.remove_confirm": "Yes, take them off. Their shifts from now on are removed.",
139
+ "leave.title": "Leave",
140
+ "leave.none": "No leave coming up.",
141
+ "leave.from": "First day away",
142
+ "leave.to": "Last day away",
143
+ "leave.add": "Add leave",
144
+ "leave.remove": "Remove",
145
+ "leave.when": "{from} to {to}",
146
+ "mine.title": "{name}'s shifts",
147
+ "mine.none": "No shifts coming up.",
148
+ "mine.calendar": "Add my shifts to my calendar",
149
+ "mine.private": "This page is yours: keep its address to yourself.",
150
+ "mine.leave": "Away {from} to {to}",
151
+ "done.add_shift": "Shift added.",
152
+ "done.remove_shift": "Shift removed.",
153
+ "done.publish": "Done. Staff have been emailed.",
154
+ "done.copy": "Last week's shifts copied.",
155
+ "done.save_staff": "Saved.",
156
+ "done.remove_staff": "Taken off the roster.",
157
+ "done.send_link": "Their link has been emailed.",
158
+ "done.add_leave": "Leave added.",
159
+ "done.remove_leave": "Leave removed.",
160
+ "email.week.subject": "Your shifts: week of {week}",
161
+ "email.changed.subject": "Your shifts have changed: week of {week}",
162
+ "email.hello": "Hi {name},",
163
+ "email.week.intro": "Here are your shifts at {business} for the week of {week}:",
164
+ "email.changed.intro": "Your shifts at {business} for the week of {week} have changed. This is your week now:",
165
+ "email.none": "You have no shifts that week.",
166
+ "email.gone": "No longer rostered: {when}",
167
+ "email.calendar": "The attached calendar file adds them to your calendar.",
168
+ "email.footer": "Sent by {business}'s roster.",
169
+ "email.link.subject": "Your roster link for {business}",
170
+ "email.link.body": "{business} keeps its roster here. Your shifts are on your own page: {url}",
171
+ "email.link.feed": "To see them in Google Calendar, Outlook or Apple Calendar, add this calendar by its address: {url}",
172
+ "email.link.keep": "Keep these links to yourself. A new link stops the old one working.",
173
+ "ics.cancelled": "Shift cancelled",
174
+ "csv.date": "Date",
175
+ "csv.name": "Name",
176
+ "csv.role": "Role",
177
+ "csv.start": "Start",
178
+ "csv.end": "End",
179
+ "csv.break": "Break (minutes)",
180
+ "csv.hours": "Hours",
181
+ };
182
+ const tl = {
183
+ "week.title": "Iskedyul: linggo ng {date}",
184
+ "week.draft": "Draft: hindi pa ito nakikita ng mga tauhan",
185
+ "week.published": "Nailathala na",
186
+ "week.unsent": "Nailathala na, may mga pagbabagong hindi pa naipapaalam sa mga tauhan",
187
+ "week.prev": "Nakaraang linggo",
188
+ "week.next": "Susunod na linggo",
189
+ "week.none": "Walang shift",
190
+ "week.publish": "Ilathala at i-email ang mga tauhan",
191
+ "week.send": "Ipadala na ang mga pagbabago",
192
+ "week.copy": "Kopyahin ang mga shift noong nakaraang linggo",
193
+ "week.export": "I-download ang mga oras",
194
+ "shift.break": "{minutes} minutong pahinga",
195
+ "shift.remove": "Alisin",
196
+ "shift.on_leave": "Naka-leave",
197
+ "shift.removed": "Wala na sa iskedyul",
198
+ "add.title": "Magdagdag ng shift",
199
+ "add.person": "Sino",
200
+ "add.day": "Araw",
201
+ "add.start": "Simula",
202
+ "add.end": "Tapos",
203
+ "add.role": "Gagawin",
204
+ "add.role_any": "Alinman sa kanilang tungkulin",
205
+ "add.break": "Pahingang walang bayad (minuto)",
206
+ "add.note": "Paalala para sa kanila",
207
+ "add.button": "Idagdag ang shift",
208
+ "gaps.title": "Mga kulang",
209
+ "gaps.none": "May tao sa bawat oras na kailangan.",
210
+ "gaps.nobody": "{when}: walang {role}",
211
+ "gaps.short": "{when}: {rostered} sa {needed} na {role} lang",
212
+ "gaps.anyone": "tauhan",
213
+ "staff.title": "Mga tauhan",
214
+ "staff.empty": "Wala pang tao sa iskedyul. Idagdag ang bawat isa sa ibaba.",
215
+ "staff.name": "Pangalan",
216
+ "staff.email": "Email",
217
+ "staff.roles": "Puwedeng maging",
218
+ "staff.resource": "Pangalan sa bookings",
219
+ "staff.resource_hint": "Para lang sa mga bina-book ng customer. Ito ang pangalan nila sa bookings.json, gaya ng dr-lee.",
220
+ "staff.add": "Idagdag ang tao",
221
+ "staff.save": "I-save",
222
+ "staff.link": "I-email ang kanilang link",
223
+ "staff.link_sent": "May link na",
224
+ "staff.no_link": "Wala pang link",
225
+ "staff.remove": "Alisin sa iskedyul",
226
+ "staff.remove_confirm": "Oo, alisin sila. Aalisin ang mga shift nila mula ngayon.",
227
+ "leave.title": "Leave",
228
+ "leave.none": "Walang paparating na leave.",
229
+ "leave.from": "Unang araw na wala",
230
+ "leave.to": "Huling araw na wala",
231
+ "leave.add": "Idagdag ang leave",
232
+ "leave.remove": "Alisin",
233
+ "leave.when": "{from} hanggang {to}",
234
+ "mine.title": "Mga shift ni {name}",
235
+ "mine.none": "Walang paparating na shift.",
236
+ "mine.calendar": "Idagdag ang mga shift ko sa aking kalendaryo",
237
+ "mine.private": "Sa iyo ang page na ito: huwag ibahagi ang address nito.",
238
+ "mine.leave": "Wala mula {from} hanggang {to}",
239
+ "done.add_shift": "Naidagdag ang shift.",
240
+ "done.remove_shift": "Naalis ang shift.",
241
+ "done.publish": "Tapos na. Na-email na ang mga tauhan.",
242
+ "done.copy": "Nakopya ang mga shift noong nakaraang linggo.",
243
+ "done.save_staff": "Na-save.",
244
+ "done.remove_staff": "Naalis na sa iskedyul.",
245
+ "done.send_link": "Na-email na ang kanilang link.",
246
+ "done.add_leave": "Naidagdag ang leave.",
247
+ "done.remove_leave": "Naalis ang leave.",
248
+ "email.week.subject": "Ang iyong mga shift: linggo ng {week}",
249
+ "email.changed.subject": "Nagbago ang iyong mga shift: linggo ng {week}",
250
+ "email.hello": "Hi {name},",
251
+ "email.week.intro": "Narito ang iyong mga shift sa {business} para sa linggo ng {week}:",
252
+ "email.changed.intro": "Nagbago ang iyong mga shift sa {business} para sa linggo ng {week}. Ito na ang iyong linggo:",
253
+ "email.none": "Wala kang shift sa linggong iyon.",
254
+ "email.gone": "Hindi na naka-iskedyul: {when}",
255
+ "email.calendar": "Idinadagdag ng kalakip na calendar file ang mga ito sa iyong kalendaryo.",
256
+ "email.footer": "Ipinadala ng iskedyul ng {business}.",
257
+ "email.link.subject": "Ang iyong link sa iskedyul ng {business}",
258
+ "email.link.body": "Dito inilalagay ng {business} ang iskedyul nito. Nasa sarili mong page ang iyong mga shift: {url}",
259
+ "email.link.feed": "Para makita ang mga ito sa Google Calendar, Outlook o Apple Calendar, idagdag ang kalendaryong ito gamit ang address nito: {url}",
260
+ "email.link.keep": "Huwag ibahagi ang mga link na ito. Kapag may bagong link, hindi na gagana ang luma.",
261
+ "ics.cancelled": "Kinansela ang shift",
262
+ "csv.date": "Petsa",
263
+ "csv.name": "Pangalan",
264
+ "csv.role": "Tungkulin",
265
+ "csv.start": "Simula",
266
+ "csv.end": "Tapos",
267
+ "csv.break": "Pahinga (minuto)",
268
+ "csv.hours": "Oras",
269
+ };
270
+ const taglish = {
271
+ "week.title": "Roster: week ng {date}",
272
+ "week.draft": "Draft: hindi pa ito nakikita ng staff",
273
+ "week.published": "Published na",
274
+ "week.unsent": "Published na, may changes na hindi pa nasasabi sa staff",
275
+ "week.prev": "Last week",
276
+ "week.next": "Next week",
277
+ "week.none": "Walang shift",
278
+ "week.publish": "I-publish at i-email ang staff",
279
+ "week.send": "I-send na ang changes",
280
+ "week.copy": "I-copy ang shifts ng last week",
281
+ "week.export": "I-download ang hours",
282
+ "shift.break": "{minutes} min na break",
283
+ "shift.remove": "Tanggalin",
284
+ "shift.on_leave": "Naka-leave",
285
+ "shift.removed": "Wala na sa roster",
286
+ "add.title": "Mag-add ng shift",
287
+ "add.person": "Sino",
288
+ "add.day": "Araw",
289
+ "add.start": "Start",
290
+ "add.end": "End",
291
+ "add.role": "Role",
292
+ "add.role_any": "Kahit anong role nila",
293
+ "add.break": "Unpaid break (minutes)",
294
+ "add.note": "Note para sa kanila",
295
+ "add.button": "I-add ang shift",
296
+ "gaps.title": "Mga kulang",
297
+ "gaps.none": "May tao sa lahat ng oras na kailangan.",
298
+ "gaps.nobody": "{when}: walang {role}",
299
+ "gaps.short": "{when}: {rostered} of {needed} na {role} lang",
300
+ "gaps.anyone": "staff",
301
+ "staff.title": "Staff",
302
+ "staff.empty": "Wala pang tao sa roster. I-add ang bawat isa sa baba.",
303
+ "staff.name": "Name",
304
+ "staff.email": "Email",
305
+ "staff.roles": "Puwedeng maging",
306
+ "staff.resource": "Name sa bookings",
307
+ "staff.resource_hint": "Para lang sa bina-book ng customers. Ito ang name nila sa bookings.json, gaya ng dr-lee.",
308
+ "staff.add": "I-add ang tao",
309
+ "staff.save": "I-save",
310
+ "staff.link": "I-email ang link nila",
311
+ "staff.link_sent": "May link na",
312
+ "staff.no_link": "Wala pang link",
313
+ "staff.remove": "Tanggalin sa roster",
314
+ "staff.remove_confirm": "Oo, tanggalin sila. Matatanggal ang shifts nila from now on.",
315
+ "leave.title": "Leave",
316
+ "leave.none": "Walang upcoming na leave.",
317
+ "leave.from": "First day na wala",
318
+ "leave.to": "Last day na wala",
319
+ "leave.add": "I-add ang leave",
320
+ "leave.remove": "Tanggalin",
321
+ "leave.when": "{from} to {to}",
322
+ "mine.title": "Shifts ni {name}",
323
+ "mine.none": "Walang upcoming na shift.",
324
+ "mine.calendar": "I-add ang shifts ko sa calendar ko",
325
+ "mine.private": "Sa'yo ang page na 'to: 'wag i-share ang address.",
326
+ "mine.leave": "Wala from {from} to {to}",
327
+ "done.add_shift": "Na-add ang shift.",
328
+ "done.remove_shift": "Natanggal ang shift.",
329
+ "done.publish": "Done. Na-email na ang staff.",
330
+ "done.copy": "Na-copy ang shifts ng last week.",
331
+ "done.save_staff": "Na-save.",
332
+ "done.remove_staff": "Natanggal na sa roster.",
333
+ "done.send_link": "Na-email na ang link nila.",
334
+ "done.add_leave": "Na-add ang leave.",
335
+ "done.remove_leave": "Natanggal ang leave.",
336
+ "email.week.subject": "Shifts mo: week ng {week}",
337
+ "email.changed.subject": "May changes sa shifts mo: week ng {week}",
338
+ "email.hello": "Hi {name},",
339
+ "email.week.intro": "Heto ang shifts mo sa {business} para sa week ng {week}:",
340
+ "email.changed.intro": "May changes sa shifts mo sa {business} para sa week ng {week}. Ito na ang week mo:",
341
+ "email.none": "Wala kang shift sa week na 'yon.",
342
+ "email.gone": "Hindi na naka-roster: {when}",
343
+ "email.calendar": "Ina-add ng naka-attach na calendar file ang mga ito sa calendar mo.",
344
+ "email.footer": "Sent ng roster ng {business}.",
345
+ "email.link.subject": "Ang roster link mo sa {business}",
346
+ "email.link.body": "Dito nilalagay ng {business} ang roster nila. Nasa sarili mong page ang shifts mo: {url}",
347
+ "email.link.feed": "Para makita sa Google Calendar, Outlook o Apple Calendar, i-add ang calendar na 'to gamit ang address: {url}",
348
+ "email.link.keep": "'Wag i-share ang links na 'to. Pag may bagong link, hindi na gagana ang luma.",
349
+ "ics.cancelled": "Cancelled ang shift",
350
+ "csv.date": "Date",
351
+ "csv.name": "Name",
352
+ "csv.role": "Role",
353
+ "csv.start": "Start",
354
+ "csv.end": "End",
355
+ "csv.break": "Break (minutes)",
356
+ "csv.hours": "Hours",
357
+ };
358
+ export const ROSTER_WORDS = { en, tl, taglish };
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "@mccaskie-labs/workbench-roster",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "A staff roster for Workbench apps: staff, shifts and leave in the app's own database. The owner builds a week and publishes it; each person is emailed their shifts with a calendar file and has their own page and calendar feed, and later changes are emailed to the people they touch. A gaps check finds times with too few people on, hoursFor() keeps bookings inside rostered shifts, and the hours export goes to the owner's own payroll. No pay rates and no AI.",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mccaskie-labs/workbench.git",
10
+ "directory": "packages/roster"
11
+ },
12
+ "engines": {
13
+ "node": ">=24"
14
+ },
15
+ "sideEffects": false,
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./styles": {
22
+ "types": "./dist/styles.d.ts",
23
+ "default": "./dist/styles.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "bin": {
28
+ "workbench-roster": "./dist/cli.js"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "README.md",
33
+ "CHANGELOG.md"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "scripts": {
39
+ "typecheck": "tsc -p tsconfig.check.json && tsc -p test/tsconfig.json",
40
+ "test": "vitest run",
41
+ "test:store": "vitest run --config vitest.db.config.ts",
42
+ "build": "node scripts/build.mjs",
43
+ "prepack": "node scripts/build.mjs"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "24.19.2",
47
+ "postgres": "4.1.0",
48
+ "vitest": "^5.1.0"
49
+ }
50
+ }