@composable-os/pack-dailychecks 0.0.0-stage → 0.1.0-beta.13
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/LICENSE +109 -0
- package/dist/blocks/dailychecks-history/history.d.ts +8 -0
- package/dist/blocks/dailychecks-history/history.js +38 -0
- package/dist/blocks/dailychecks-native-today/today-screen.d.ts +6 -0
- package/dist/blocks/dailychecks-native-today/today-screen.js +92 -0
- package/dist/blocks/dailychecks-today/today.d.ts +6 -0
- package/dist/blocks/dailychecks-today/today.js +113 -0
- package/dist/client/index.d.ts +734 -0
- package/dist/client/index.js +185 -0
- package/dist/index.d.ts +350 -0
- package/dist/index.js +64 -0
- package/dist/tools.d.ts +314 -0
- package/dist/tools.js +199 -0
- package/package.json +36 -4
- package/README.md +0 -3
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// The Daily checklists pack's headless entry (ADR 0651; ADR 0418): functions and hooks over the
|
|
2
|
+
// typed client, no markup. A client app imports it as `@composable-os/pack-dailychecks/client` and
|
|
3
|
+
// hands it its client; the blocks (web and native) render what it returns. Web and native share
|
|
4
|
+
// this logic, not their screens (ADR 0403).
|
|
5
|
+
//
|
|
6
|
+
// It holds no rules: which checklists are due today, who may do one, who may tick for whom, that
|
|
7
|
+
// the last tick finishes it and that a finished or missed day never changes are the host's. A block
|
|
8
|
+
// shows the host's answer (`canTick`, `mayDo`, `youManage`) and its refusals, never works one out.
|
|
9
|
+
// What someone writes on a step, why it was not done and why it was ticked for them are on screen
|
|
10
|
+
// only: read with `gcTime: 0`, sent through `forgetAfter`, never in a query's key.
|
|
11
|
+
import { forgetAfter, packHooks, } from "@composable-os/client";
|
|
12
|
+
export { forgetAfter };
|
|
13
|
+
// --- Plain functions (display only) --------------------------------------------------------------
|
|
14
|
+
/** A day's state as a person reads it. */
|
|
15
|
+
export function dayStateLabel(state) {
|
|
16
|
+
switch (state) {
|
|
17
|
+
case "not_started":
|
|
18
|
+
return "Not started";
|
|
19
|
+
case "open":
|
|
20
|
+
return "In progress";
|
|
21
|
+
case "done":
|
|
22
|
+
return "Done";
|
|
23
|
+
default:
|
|
24
|
+
return "Missed";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** A step's tick as every screen shows it: what was ticked, by whom and for whom. */
|
|
28
|
+
export function tickLabel(tick) {
|
|
29
|
+
if (tick.state === "cleared")
|
|
30
|
+
return tick.label;
|
|
31
|
+
return `${tick.done ? "Done" : "Not done"}: ${tick.label}`;
|
|
32
|
+
}
|
|
33
|
+
/** A time of day in the business's zone. */
|
|
34
|
+
export function timeIn(iso, zone, locale = "en-AU") {
|
|
35
|
+
return new Intl.DateTimeFormat(locale, {
|
|
36
|
+
timeZone: zone,
|
|
37
|
+
hour: "numeric",
|
|
38
|
+
minute: "2-digit",
|
|
39
|
+
}).format(new Date(iso));
|
|
40
|
+
}
|
|
41
|
+
/** A `YYYY-MM-DD` date as a person reads it (a calendar date: no zone). */
|
|
42
|
+
export function dateLabel(date, locale = "en-AU") {
|
|
43
|
+
const [y, m, d] = date.split("-").map(Number);
|
|
44
|
+
return new Intl.DateTimeFormat(locale, {
|
|
45
|
+
timeZone: "UTC",
|
|
46
|
+
weekday: "short",
|
|
47
|
+
day: "numeric",
|
|
48
|
+
month: "short",
|
|
49
|
+
}).format(new Date(Date.UTC(y ?? 1970, (m ?? 1) - 1, d ?? 1)));
|
|
50
|
+
}
|
|
51
|
+
/** A `YYYY-MM-DD` date `days` later (or earlier). */
|
|
52
|
+
export function addDays(date, days) {
|
|
53
|
+
const [y, m, d] = date.split("-").map(Number);
|
|
54
|
+
return new Date(Date.UTC(y ?? 1970, (m ?? 1) - 1, (d ?? 1) + days)).toISOString().slice(0, 10);
|
|
55
|
+
}
|
|
56
|
+
/** The steps a day shows: its run's, or its preview before the run is made. */
|
|
57
|
+
export function stepsOf(item) {
|
|
58
|
+
return (item.run?.steps ??
|
|
59
|
+
(item.preview ?? []).map((s, position) => ({
|
|
60
|
+
...s,
|
|
61
|
+
position,
|
|
62
|
+
tick: null,
|
|
63
|
+
history: [],
|
|
64
|
+
missed: false,
|
|
65
|
+
})));
|
|
66
|
+
}
|
|
67
|
+
/** How a finished day reads: who finished it, for whom, and when. */
|
|
68
|
+
export function finishedLabel(item, locale = "en-AU", zone = "UTC") {
|
|
69
|
+
const run = item.run;
|
|
70
|
+
if (!run || run.state !== "done" || !run.closedAt)
|
|
71
|
+
return null;
|
|
72
|
+
const by = run.closedByName ?? "someone";
|
|
73
|
+
const forWhom = run.account && run.closedBy !== run.account && run.name ? ` for ${run.name}` : "";
|
|
74
|
+
return `Done by ${by}${forWhom} at ${timeIn(run.closedAt, zone, locale)}${item.late ? " (after it was due)" : ""}`;
|
|
75
|
+
}
|
|
76
|
+
// --- Refusals -----------------------------------------------------------------------------------
|
|
77
|
+
/** The rules a refusal of the day's checklists names, each with its own designed state. */
|
|
78
|
+
const HOST_RULES = [
|
|
79
|
+
"checklist_window",
|
|
80
|
+
"checklist_closed",
|
|
81
|
+
"checklist_not_your_tick",
|
|
82
|
+
"checklist_nothing_to_clear",
|
|
83
|
+
"checklist_too_many_ticks",
|
|
84
|
+
"checklist_for_why",
|
|
85
|
+
"checklist_for_whom",
|
|
86
|
+
"checklist_for_someone",
|
|
87
|
+
"checklist_not_theirs",
|
|
88
|
+
"checklist_note_needed",
|
|
89
|
+
"checklist_why",
|
|
90
|
+
"checklist_incomplete",
|
|
91
|
+
"checklists_manage",
|
|
92
|
+
"human_only",
|
|
93
|
+
];
|
|
94
|
+
const KNOWN = new Set(HOST_RULES);
|
|
95
|
+
const isHostRule = (rule) => KNOWN.has(rule);
|
|
96
|
+
const record = (value) => value && typeof value === "object" ? value : null;
|
|
97
|
+
/** What the host's refusal was, for the screen's designed state. */
|
|
98
|
+
export function dayRefusal(error) {
|
|
99
|
+
const e = record(error);
|
|
100
|
+
if (e?.name === "NetworkError") {
|
|
101
|
+
return {
|
|
102
|
+
kind: "network",
|
|
103
|
+
message: "We could not reach the business just now. Check your connection and try again.",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const details = record(e?.details);
|
|
107
|
+
const inner = record(details?.details);
|
|
108
|
+
const rule = typeof details?.rule === "string"
|
|
109
|
+
? details.rule
|
|
110
|
+
: typeof inner?.rule === "string"
|
|
111
|
+
? inner.rule
|
|
112
|
+
: null;
|
|
113
|
+
const message = typeof e?.message === "string" && e.message ? e.message : null;
|
|
114
|
+
if (rule && isHostRule(rule)) {
|
|
115
|
+
return { kind: rule, message: message ?? "That did not work. Try again." };
|
|
116
|
+
}
|
|
117
|
+
const code = typeof details?.code === "string" ? details.code : typeof e?.code === "string" ? e.code : null;
|
|
118
|
+
if (code === "forbidden") {
|
|
119
|
+
return { kind: "forbidden", message: "You can't do that. Ask whoever manages checklists." };
|
|
120
|
+
}
|
|
121
|
+
if (code === "not_found") {
|
|
122
|
+
return { kind: "not_found", message: "That checklist is not there for you. Refresh the page." };
|
|
123
|
+
}
|
|
124
|
+
if (code === "invalid_input" || code === "validation") {
|
|
125
|
+
return { kind: "invalid", message: message ?? "Something entered is not right." };
|
|
126
|
+
}
|
|
127
|
+
return { kind: "other", message: message ?? "That did not work. Try again." };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The operations each hook calls (ADR 0453). Every staff client and every role client holds the
|
|
131
|
+
* first four (the tools are every staff account's, ADR 0652); `useHistory` is for those who
|
|
132
|
+
* manage checklists (the host refuses anyone else).
|
|
133
|
+
*/
|
|
134
|
+
export const DAILYCHECKS_HOOKS_CALL = {
|
|
135
|
+
useToday: ["x.dailychecks.today"],
|
|
136
|
+
useDay: ["x.dailychecks.day"],
|
|
137
|
+
useTick: ["x.dailychecks.tick"],
|
|
138
|
+
useDone: ["x.dailychecks.done"],
|
|
139
|
+
useHistory: ["x.dailychecks.history"],
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Hooks for a React or React Native app:
|
|
143
|
+
* `const dailychecks = createDailyChecksHooks({ useQuery, useMutation }, api)`. `api` is the client
|
|
144
|
+
* the screen's user holds: a role client (a cleaner's, a coach's) or the staff client. The hooks it
|
|
145
|
+
* cannot back are not there.
|
|
146
|
+
*/
|
|
147
|
+
export function createDailyChecksHooks(react, client) {
|
|
148
|
+
return packHooks(client, DAILYCHECKS_HOOKS_CALL, (api) => allDailyChecksHooks(react, api));
|
|
149
|
+
}
|
|
150
|
+
function allDailyChecksHooks(react, api) {
|
|
151
|
+
const { useQuery, useMutation } = react;
|
|
152
|
+
return {
|
|
153
|
+
/** Today's checklists I may do (every one, if I manage checklists): on screen only. */
|
|
154
|
+
useToday(enabled = true) {
|
|
155
|
+
return useQuery({ ...api.query("x.dailychecks.today", {}), enabled, gcTime: 0 });
|
|
156
|
+
},
|
|
157
|
+
/** One checklist on one day (any day, for someone who manages checklists): on screen only. */
|
|
158
|
+
useDay(input) {
|
|
159
|
+
return useQuery({
|
|
160
|
+
...api.query("x.dailychecks.day", input ?? { template: "", date: "" }),
|
|
161
|
+
enabled: input !== null,
|
|
162
|
+
gcTime: 0,
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
/**
|
|
166
|
+
* Tick a step (a person's own act). What is written on it is forgotten once the call is over:
|
|
167
|
+
* call it through `forgetAfter`.
|
|
168
|
+
*/
|
|
169
|
+
useTick() {
|
|
170
|
+
return useMutation({ ...api.mutation("x.dailychecks.tick"), gcTime: 0 });
|
|
171
|
+
},
|
|
172
|
+
/** Finish it with optional steps left: final. */
|
|
173
|
+
useDone() {
|
|
174
|
+
return useMutation({ ...api.mutation("x.dailychecks.done"), gcTime: 0 });
|
|
175
|
+
},
|
|
176
|
+
/** How each day went (those who manage checklists): on screen only. */
|
|
177
|
+
useHistory(input) {
|
|
178
|
+
return useQuery({
|
|
179
|
+
...api.query("x.dailychecks.history", input ?? { from: "", to: "" }),
|
|
180
|
+
enabled: input !== null,
|
|
181
|
+
gcTime: 0,
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
declare const _default: import("@composable-os/sdk").Extension<{
|
|
2
|
+
readonly id: "dailychecks";
|
|
3
|
+
readonly version: "0.1.0";
|
|
4
|
+
readonly contractVersion: 1;
|
|
5
|
+
readonly label: "Daily checklists";
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly permissions: {
|
|
8
|
+
readonly operations: ["checklist.today", "checklist.day", "checklist.dayTick", "checklist.dayDone", "checklist.days"];
|
|
9
|
+
readonly modules: ["ops"];
|
|
10
|
+
};
|
|
11
|
+
readonly objects: {};
|
|
12
|
+
readonly tools: {
|
|
13
|
+
readonly today: import("@composable-os/sdk").ToolSpec<import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
14
|
+
zone: import("zod").ZodString;
|
|
15
|
+
date: import("zod").ZodString;
|
|
16
|
+
items: import("zod").ZodArray<import("zod").ZodObject<{
|
|
17
|
+
template: import("zod").ZodObject<{
|
|
18
|
+
id: import("zod").ZodString;
|
|
19
|
+
name: import("zod").ZodString;
|
|
20
|
+
purpose: import("zod").ZodNullable<import("zod").ZodString>;
|
|
21
|
+
}, import("zod/v4/core").$strip>;
|
|
22
|
+
date: import("zod").ZodString;
|
|
23
|
+
who: import("zod").ZodObject<{
|
|
24
|
+
kind: import("zod").ZodEnum<{
|
|
25
|
+
staff: "staff";
|
|
26
|
+
role: "role";
|
|
27
|
+
grant: "grant";
|
|
28
|
+
}>;
|
|
29
|
+
value: import("zod").ZodNullable<import("zod").ZodString>;
|
|
30
|
+
}, import("zod/v4/core").$strip>;
|
|
31
|
+
dueBy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
32
|
+
dueAt: import("zod").ZodNullable<import("zod").ZodString>;
|
|
33
|
+
opens: import("zod").ZodString;
|
|
34
|
+
closes: import("zod").ZodString;
|
|
35
|
+
state: import("zod").ZodEnum<{
|
|
36
|
+
not_started: "not_started";
|
|
37
|
+
open: "open";
|
|
38
|
+
done: "done";
|
|
39
|
+
missed: "missed";
|
|
40
|
+
}>;
|
|
41
|
+
late: import("zod").ZodBoolean;
|
|
42
|
+
run: import("zod").ZodNullable<import("zod").ZodObject<{
|
|
43
|
+
id: import("zod").ZodString;
|
|
44
|
+
object: import("zod").ZodString;
|
|
45
|
+
record: import("zod").ZodString;
|
|
46
|
+
template: import("zod").ZodObject<{
|
|
47
|
+
id: import("zod").ZodString;
|
|
48
|
+
name: import("zod").ZodString;
|
|
49
|
+
version: import("zod").ZodNumber;
|
|
50
|
+
}, import("zod/v4/core").$strip>;
|
|
51
|
+
state: import("zod").ZodEnum<{
|
|
52
|
+
open: "open";
|
|
53
|
+
done: "done";
|
|
54
|
+
missed: "missed";
|
|
55
|
+
cancelled: "cancelled";
|
|
56
|
+
}>;
|
|
57
|
+
account: import("zod").ZodNullable<import("zod").ZodString>;
|
|
58
|
+
name: import("zod").ZodNullable<import("zod").ZodString>;
|
|
59
|
+
opens: import("zod").ZodString;
|
|
60
|
+
closes: import("zod").ZodString;
|
|
61
|
+
tickUntil: import("zod").ZodString;
|
|
62
|
+
madeAt: import("zod").ZodString;
|
|
63
|
+
closedAt: import("zod").ZodNullable<import("zod").ZodString>;
|
|
64
|
+
closedBy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
65
|
+
closedByName: import("zod").ZodNullable<import("zod").ZodString>;
|
|
66
|
+
closedWhy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
67
|
+
steps: import("zod").ZodArray<import("zod").ZodObject<{
|
|
68
|
+
position: import("zod").ZodNumber;
|
|
69
|
+
text: import("zod").ZodString;
|
|
70
|
+
required: import("zod").ZodBoolean;
|
|
71
|
+
asksNote: import("zod").ZodBoolean;
|
|
72
|
+
tick: import("zod").ZodNullable<import("zod").ZodObject<{
|
|
73
|
+
id: import("zod").ZodString;
|
|
74
|
+
state: import("zod").ZodEnum<{
|
|
75
|
+
done: "done";
|
|
76
|
+
not_done: "not_done";
|
|
77
|
+
cleared: "cleared";
|
|
78
|
+
}>;
|
|
79
|
+
done: import("zod").ZodBoolean;
|
|
80
|
+
why: import("zod").ZodNullable<import("zod").ZodString>;
|
|
81
|
+
note: import("zod").ZodNullable<import("zod").ZodString>;
|
|
82
|
+
onBehalfWhy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
83
|
+
withheld: import("zod").ZodBoolean;
|
|
84
|
+
by: import("zod").ZodString;
|
|
85
|
+
byName: import("zod").ZodString;
|
|
86
|
+
for: import("zod").ZodString;
|
|
87
|
+
forName: import("zod").ZodString;
|
|
88
|
+
onBehalf: import("zod").ZodBoolean;
|
|
89
|
+
at: import("zod").ZodString;
|
|
90
|
+
label: import("zod").ZodString;
|
|
91
|
+
}, import("zod/v4/core").$strip>>;
|
|
92
|
+
history: import("zod").ZodArray<import("zod").ZodObject<{
|
|
93
|
+
id: import("zod").ZodString;
|
|
94
|
+
state: import("zod").ZodEnum<{
|
|
95
|
+
done: "done";
|
|
96
|
+
not_done: "not_done";
|
|
97
|
+
cleared: "cleared";
|
|
98
|
+
}>;
|
|
99
|
+
done: import("zod").ZodBoolean;
|
|
100
|
+
why: import("zod").ZodNullable<import("zod").ZodString>;
|
|
101
|
+
note: import("zod").ZodNullable<import("zod").ZodString>;
|
|
102
|
+
onBehalfWhy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
103
|
+
withheld: import("zod").ZodBoolean;
|
|
104
|
+
by: import("zod").ZodString;
|
|
105
|
+
byName: import("zod").ZodString;
|
|
106
|
+
for: import("zod").ZodString;
|
|
107
|
+
forName: import("zod").ZodString;
|
|
108
|
+
onBehalf: import("zod").ZodBoolean;
|
|
109
|
+
at: import("zod").ZodString;
|
|
110
|
+
label: import("zod").ZodString;
|
|
111
|
+
}, import("zod/v4/core").$strip>>;
|
|
112
|
+
historyTruncated: import("zod").ZodBoolean;
|
|
113
|
+
missed: import("zod").ZodBoolean;
|
|
114
|
+
}, import("zod/v4/core").$strip>>;
|
|
115
|
+
corrections: import("zod").ZodArray<import("zod").ZodObject<{
|
|
116
|
+
id: import("zod").ZodString;
|
|
117
|
+
text: import("zod").ZodString;
|
|
118
|
+
by: import("zod").ZodString;
|
|
119
|
+
byName: import("zod").ZodString;
|
|
120
|
+
at: import("zod").ZodString;
|
|
121
|
+
}, import("zod/v4/core").$strip>>;
|
|
122
|
+
}, import("zod/v4/core").$strip>>;
|
|
123
|
+
preview: import("zod").ZodNullable<import("zod").ZodArray<import("zod").ZodObject<{
|
|
124
|
+
text: import("zod").ZodString;
|
|
125
|
+
required: import("zod").ZodBoolean;
|
|
126
|
+
asksNote: import("zod").ZodBoolean;
|
|
127
|
+
}, import("zod/v4/core").$strip>>>;
|
|
128
|
+
mayDo: import("zod").ZodBoolean;
|
|
129
|
+
canTick: import("zod").ZodBoolean;
|
|
130
|
+
}, import("zod/v4/core").$strip>>;
|
|
131
|
+
you: import("zod").ZodString;
|
|
132
|
+
youManage: import("zod").ZodBoolean;
|
|
133
|
+
}, import("zod/v4/core").$strip>>;
|
|
134
|
+
readonly day: import("@composable-os/sdk").ToolSpec<import("zod").ZodObject<{
|
|
135
|
+
template: import("zod").ZodString;
|
|
136
|
+
date: import("zod").ZodString;
|
|
137
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
138
|
+
item: import("zod").ZodObject<{
|
|
139
|
+
template: import("zod").ZodObject<{
|
|
140
|
+
id: import("zod").ZodString;
|
|
141
|
+
name: import("zod").ZodString;
|
|
142
|
+
purpose: import("zod").ZodNullable<import("zod").ZodString>;
|
|
143
|
+
}, import("zod/v4/core").$strip>;
|
|
144
|
+
date: import("zod").ZodString;
|
|
145
|
+
who: import("zod").ZodObject<{
|
|
146
|
+
kind: import("zod").ZodEnum<{
|
|
147
|
+
staff: "staff";
|
|
148
|
+
role: "role";
|
|
149
|
+
grant: "grant";
|
|
150
|
+
}>;
|
|
151
|
+
value: import("zod").ZodNullable<import("zod").ZodString>;
|
|
152
|
+
}, import("zod/v4/core").$strip>;
|
|
153
|
+
dueBy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
154
|
+
dueAt: import("zod").ZodNullable<import("zod").ZodString>;
|
|
155
|
+
opens: import("zod").ZodString;
|
|
156
|
+
closes: import("zod").ZodString;
|
|
157
|
+
state: import("zod").ZodEnum<{
|
|
158
|
+
not_started: "not_started";
|
|
159
|
+
open: "open";
|
|
160
|
+
done: "done";
|
|
161
|
+
missed: "missed";
|
|
162
|
+
}>;
|
|
163
|
+
late: import("zod").ZodBoolean;
|
|
164
|
+
run: import("zod").ZodNullable<import("zod").ZodObject<{
|
|
165
|
+
id: import("zod").ZodString;
|
|
166
|
+
object: import("zod").ZodString;
|
|
167
|
+
record: import("zod").ZodString;
|
|
168
|
+
template: import("zod").ZodObject<{
|
|
169
|
+
id: import("zod").ZodString;
|
|
170
|
+
name: import("zod").ZodString;
|
|
171
|
+
version: import("zod").ZodNumber;
|
|
172
|
+
}, import("zod/v4/core").$strip>;
|
|
173
|
+
state: import("zod").ZodEnum<{
|
|
174
|
+
open: "open";
|
|
175
|
+
done: "done";
|
|
176
|
+
missed: "missed";
|
|
177
|
+
cancelled: "cancelled";
|
|
178
|
+
}>;
|
|
179
|
+
account: import("zod").ZodNullable<import("zod").ZodString>;
|
|
180
|
+
name: import("zod").ZodNullable<import("zod").ZodString>;
|
|
181
|
+
opens: import("zod").ZodString;
|
|
182
|
+
closes: import("zod").ZodString;
|
|
183
|
+
tickUntil: import("zod").ZodString;
|
|
184
|
+
madeAt: import("zod").ZodString;
|
|
185
|
+
closedAt: import("zod").ZodNullable<import("zod").ZodString>;
|
|
186
|
+
closedBy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
187
|
+
closedByName: import("zod").ZodNullable<import("zod").ZodString>;
|
|
188
|
+
closedWhy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
189
|
+
steps: import("zod").ZodArray<import("zod").ZodObject<{
|
|
190
|
+
position: import("zod").ZodNumber;
|
|
191
|
+
text: import("zod").ZodString;
|
|
192
|
+
required: import("zod").ZodBoolean;
|
|
193
|
+
asksNote: import("zod").ZodBoolean;
|
|
194
|
+
tick: import("zod").ZodNullable<import("zod").ZodObject<{
|
|
195
|
+
id: import("zod").ZodString;
|
|
196
|
+
state: import("zod").ZodEnum<{
|
|
197
|
+
done: "done";
|
|
198
|
+
not_done: "not_done";
|
|
199
|
+
cleared: "cleared";
|
|
200
|
+
}>;
|
|
201
|
+
done: import("zod").ZodBoolean;
|
|
202
|
+
why: import("zod").ZodNullable<import("zod").ZodString>;
|
|
203
|
+
note: import("zod").ZodNullable<import("zod").ZodString>;
|
|
204
|
+
onBehalfWhy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
205
|
+
withheld: import("zod").ZodBoolean;
|
|
206
|
+
by: import("zod").ZodString;
|
|
207
|
+
byName: import("zod").ZodString;
|
|
208
|
+
for: import("zod").ZodString;
|
|
209
|
+
forName: import("zod").ZodString;
|
|
210
|
+
onBehalf: import("zod").ZodBoolean;
|
|
211
|
+
at: import("zod").ZodString;
|
|
212
|
+
label: import("zod").ZodString;
|
|
213
|
+
}, import("zod/v4/core").$strip>>;
|
|
214
|
+
history: import("zod").ZodArray<import("zod").ZodObject<{
|
|
215
|
+
id: import("zod").ZodString;
|
|
216
|
+
state: import("zod").ZodEnum<{
|
|
217
|
+
done: "done";
|
|
218
|
+
not_done: "not_done";
|
|
219
|
+
cleared: "cleared";
|
|
220
|
+
}>;
|
|
221
|
+
done: import("zod").ZodBoolean;
|
|
222
|
+
why: import("zod").ZodNullable<import("zod").ZodString>;
|
|
223
|
+
note: import("zod").ZodNullable<import("zod").ZodString>;
|
|
224
|
+
onBehalfWhy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
225
|
+
withheld: import("zod").ZodBoolean;
|
|
226
|
+
by: import("zod").ZodString;
|
|
227
|
+
byName: import("zod").ZodString;
|
|
228
|
+
for: import("zod").ZodString;
|
|
229
|
+
forName: import("zod").ZodString;
|
|
230
|
+
onBehalf: import("zod").ZodBoolean;
|
|
231
|
+
at: import("zod").ZodString;
|
|
232
|
+
label: import("zod").ZodString;
|
|
233
|
+
}, import("zod/v4/core").$strip>>;
|
|
234
|
+
historyTruncated: import("zod").ZodBoolean;
|
|
235
|
+
missed: import("zod").ZodBoolean;
|
|
236
|
+
}, import("zod/v4/core").$strip>>;
|
|
237
|
+
corrections: import("zod").ZodArray<import("zod").ZodObject<{
|
|
238
|
+
id: import("zod").ZodString;
|
|
239
|
+
text: import("zod").ZodString;
|
|
240
|
+
by: import("zod").ZodString;
|
|
241
|
+
byName: import("zod").ZodString;
|
|
242
|
+
at: import("zod").ZodString;
|
|
243
|
+
}, import("zod/v4/core").$strip>>;
|
|
244
|
+
}, import("zod/v4/core").$strip>>;
|
|
245
|
+
preview: import("zod").ZodNullable<import("zod").ZodArray<import("zod").ZodObject<{
|
|
246
|
+
text: import("zod").ZodString;
|
|
247
|
+
required: import("zod").ZodBoolean;
|
|
248
|
+
asksNote: import("zod").ZodBoolean;
|
|
249
|
+
}, import("zod/v4/core").$strip>>>;
|
|
250
|
+
mayDo: import("zod").ZodBoolean;
|
|
251
|
+
canTick: import("zod").ZodBoolean;
|
|
252
|
+
}, import("zod/v4/core").$strip>;
|
|
253
|
+
zone: import("zod").ZodString;
|
|
254
|
+
doers: import("zod").ZodNullable<import("zod").ZodArray<import("zod").ZodObject<{
|
|
255
|
+
id: import("zod").ZodString;
|
|
256
|
+
name: import("zod").ZodString;
|
|
257
|
+
}, import("zod/v4/core").$strip>>>;
|
|
258
|
+
you: import("zod").ZodString;
|
|
259
|
+
youManage: import("zod").ZodBoolean;
|
|
260
|
+
}, import("zod/v4/core").$strip>>;
|
|
261
|
+
readonly tick: import("@composable-os/sdk").ToolSpec<import("zod").ZodObject<{
|
|
262
|
+
for: import("zod").ZodOptional<import("zod").ZodString>;
|
|
263
|
+
forWhy: import("zod").ZodOptional<import("zod").ZodString>;
|
|
264
|
+
step: import("zod").ZodNumber;
|
|
265
|
+
state: import("zod").ZodEnum<{
|
|
266
|
+
done: "done";
|
|
267
|
+
not_done: "not_done";
|
|
268
|
+
clear: "clear";
|
|
269
|
+
}>;
|
|
270
|
+
note: import("zod").ZodOptional<import("zod").ZodString>;
|
|
271
|
+
why: import("zod").ZodOptional<import("zod").ZodString>;
|
|
272
|
+
template: import("zod").ZodString;
|
|
273
|
+
date: import("zod").ZodString;
|
|
274
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
275
|
+
run: import("zod").ZodString;
|
|
276
|
+
step: import("zod").ZodNumber;
|
|
277
|
+
state: import("zod").ZodEnum<{
|
|
278
|
+
done: "done";
|
|
279
|
+
not_done: "not_done";
|
|
280
|
+
clear: "clear";
|
|
281
|
+
}>;
|
|
282
|
+
ticked: import("zod").ZodNumber;
|
|
283
|
+
of: import("zod").ZodNumber;
|
|
284
|
+
finished: import("zod").ZodBoolean;
|
|
285
|
+
}, import("zod/v4/core").$strip>>;
|
|
286
|
+
readonly done: import("@composable-os/sdk").ToolSpec<import("zod").ZodObject<{
|
|
287
|
+
for: import("zod").ZodOptional<import("zod").ZodString>;
|
|
288
|
+
forWhy: import("zod").ZodOptional<import("zod").ZodString>;
|
|
289
|
+
template: import("zod").ZodString;
|
|
290
|
+
date: import("zod").ZodString;
|
|
291
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
292
|
+
run: import("zod").ZodString;
|
|
293
|
+
state: import("zod").ZodLiteral<"done">;
|
|
294
|
+
}, import("zod/v4/core").$strip>>;
|
|
295
|
+
readonly history: import("@composable-os/sdk").ToolSpec<import("zod").ZodObject<{
|
|
296
|
+
from: import("zod").ZodString;
|
|
297
|
+
to: import("zod").ZodString;
|
|
298
|
+
template: import("zod").ZodOptional<import("zod").ZodString>;
|
|
299
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
300
|
+
zone: import("zod").ZodString;
|
|
301
|
+
days: import("zod").ZodArray<import("zod").ZodObject<{
|
|
302
|
+
run: import("zod").ZodString;
|
|
303
|
+
template: import("zod").ZodObject<{
|
|
304
|
+
id: import("zod").ZodString;
|
|
305
|
+
name: import("zod").ZodString;
|
|
306
|
+
}, import("zod/v4/core").$strip>;
|
|
307
|
+
date: import("zod").ZodString;
|
|
308
|
+
state: import("zod").ZodEnum<{
|
|
309
|
+
open: "open";
|
|
310
|
+
done: "done";
|
|
311
|
+
missed: "missed";
|
|
312
|
+
}>;
|
|
313
|
+
dueAt: import("zod").ZodNullable<import("zod").ZodString>;
|
|
314
|
+
late: import("zod").ZodBoolean;
|
|
315
|
+
finishedAt: import("zod").ZodNullable<import("zod").ZodString>;
|
|
316
|
+
finishedBy: import("zod").ZodNullable<import("zod").ZodString>;
|
|
317
|
+
finishedFor: import("zod").ZodNullable<import("zod").ZodString>;
|
|
318
|
+
steps: import("zod").ZodNumber;
|
|
319
|
+
ticked: import("zod").ZodNumber;
|
|
320
|
+
notDone: import("zod").ZodNumber;
|
|
321
|
+
onBehalf: import("zod").ZodNumber;
|
|
322
|
+
missed: import("zod").ZodArray<import("zod").ZodString>;
|
|
323
|
+
}, import("zod/v4/core").$strip>>;
|
|
324
|
+
truncated: import("zod").ZodBoolean;
|
|
325
|
+
}, import("zod/v4/core").$strip>>;
|
|
326
|
+
};
|
|
327
|
+
readonly screens: {
|
|
328
|
+
readonly today: {
|
|
329
|
+
readonly label: "Today's checklists";
|
|
330
|
+
readonly block: "dailychecks-today";
|
|
331
|
+
readonly export: "TodaysChecklists";
|
|
332
|
+
readonly nav: {
|
|
333
|
+
readonly group: "Checklists";
|
|
334
|
+
readonly order: 10;
|
|
335
|
+
};
|
|
336
|
+
readonly opens: readonly ["today", "tick"];
|
|
337
|
+
};
|
|
338
|
+
readonly history: {
|
|
339
|
+
readonly label: "Checklist history";
|
|
340
|
+
readonly block: "dailychecks-history";
|
|
341
|
+
readonly export: "ChecklistHistory";
|
|
342
|
+
readonly nav: {
|
|
343
|
+
readonly group: "Checklists";
|
|
344
|
+
readonly order: 20;
|
|
345
|
+
};
|
|
346
|
+
readonly opens: readonly ["history"];
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
}>;
|
|
350
|
+
export default _default;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Daily checklists (ADR 0651; a follow-on to stage 45 step 4b, ADR 0650): checklists done on their
|
|
2
|
+
// own, without a roster. Opening up, closing down, the cleaning: a checklist the business writes in
|
|
3
|
+
// Settings → Checklists, given a standing schedule there (the days it is due in the business's
|
|
4
|
+
// time zone, a time it is due by, and who may do it). Each due day has one run, which anyone who
|
|
5
|
+
// may do it ticks off; whoever ticks the last step finishes it; one not finished by the end of its
|
|
6
|
+
// day is missed. Those who manage checklists see how each day went and may tick for someone.
|
|
7
|
+
//
|
|
8
|
+
// Everything that is a rule is the host's (ADRs 0404, 0650 and 0651): the schedule is a core
|
|
9
|
+
// template's, the runs and ticks core tables, who may do it and who manages checklists held by the
|
|
10
|
+
// host's operations and the database's triggers. This pack is its screens and the tools they call,
|
|
11
|
+
// and adds no rule. It requires nothing: a business with no roster uses it alone, and a business
|
|
12
|
+
// with Rostering keeps a duty's checklist as it was (a duty shift's run is the shift's).
|
|
13
|
+
//
|
|
14
|
+
// Why a pack and not Rostering's or the base layer (ADR 0651): the operations are core, but a
|
|
15
|
+
// screen in the admin is a shipped pack's (stage 47, ADR 0660), and a screen in Rostering would be
|
|
16
|
+
// missing for a business that has not installed it. A small pack of its own carries the two
|
|
17
|
+
// screens and its blocks for the app, and nothing else.
|
|
18
|
+
import { defineExtension } from "@composable-os/sdk";
|
|
19
|
+
import { checklistDay, done, history, tickStep, today } from "./tools.js";
|
|
20
|
+
export default defineExtension({
|
|
21
|
+
id: "dailychecks",
|
|
22
|
+
version: "0.1.0",
|
|
23
|
+
contractVersion: 1,
|
|
24
|
+
label: "Daily checklists",
|
|
25
|
+
description: "Checklists done on their own: opening, closing and cleaning, due on set days by a set " +
|
|
26
|
+
"time, ticked off by whoever may do them, with how each day went for those who manage them.",
|
|
27
|
+
permissions: {
|
|
28
|
+
operations: [
|
|
29
|
+
"checklist.today",
|
|
30
|
+
"checklist.day",
|
|
31
|
+
"checklist.dayTick",
|
|
32
|
+
"checklist.dayDone",
|
|
33
|
+
"checklist.days",
|
|
34
|
+
],
|
|
35
|
+
modules: ["ops"],
|
|
36
|
+
},
|
|
37
|
+
objects: {},
|
|
38
|
+
tools: {
|
|
39
|
+
today,
|
|
40
|
+
day: checklistDay,
|
|
41
|
+
tick: tickStep,
|
|
42
|
+
done,
|
|
43
|
+
history,
|
|
44
|
+
},
|
|
45
|
+
// Staff screens in the product's admin (stage 47, ADR 0660): today's checklists for every staff
|
|
46
|
+
// account (each sees only the ones they may do; the host decides), and how each day went for
|
|
47
|
+
// those who manage checklists (checklists:write).
|
|
48
|
+
screens: {
|
|
49
|
+
today: {
|
|
50
|
+
label: "Today's checklists",
|
|
51
|
+
block: "dailychecks-today",
|
|
52
|
+
export: "TodaysChecklists",
|
|
53
|
+
nav: { group: "Checklists", order: 10 },
|
|
54
|
+
opens: ["today", "tick"],
|
|
55
|
+
},
|
|
56
|
+
history: {
|
|
57
|
+
label: "Checklist history",
|
|
58
|
+
block: "dailychecks-history",
|
|
59
|
+
export: "ChecklistHistory",
|
|
60
|
+
nav: { group: "Checklists", order: 20 },
|
|
61
|
+
opens: ["history"],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|