@burdenoff/microfe-timecampus 2026.1102.1 → 2026.1107.1
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/generated/global-types.d.ts +713 -244
- package/dist/generated/global-types.d.ts.map +1 -1
- package/dist/generated/wspace-operations.d.ts +300 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +1035 -903
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +17396 -467
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js +5 -1
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/index.js +7 -7
- package/dist/timecampus/TimeCampusRoutes.d.ts.map +1 -1
- package/dist/timecampus/TimeCampusRoutes.js +10 -6
- package/dist/timecampus/TimeCampusRoutes.js.map +1 -1
- package/dist/timecampus/index.js +7 -7
- package/dist/timecampus/pages/dashboard/ServerReportExports.d.ts.map +1 -1
- package/dist/timecampus/pages/dashboard/ServerReportExports.js +99 -99
- package/dist/timecampus/pages/dashboard/ServerReportExports.js.map +1 -1
- package/dist/timecampus/pages/dashboard/reportTemplates.d.ts +8 -0
- package/dist/timecampus/pages/dashboard/reportTemplates.d.ts.map +1 -1
- package/dist/timecampus/pages/dashboard/reportTemplates.js +29 -19
- package/dist/timecampus/pages/dashboard/reportTemplates.js.map +1 -1
- package/dist/timecampus/pages/extend/TimeTriggersPage.d.ts +2 -0
- package/dist/timecampus/pages/extend/TimeTriggersPage.d.ts.map +1 -0
- package/dist/timecampus/pages/extend/TimeTriggersPage.js +606 -0
- package/dist/timecampus/pages/extend/TimeTriggersPage.js.map +1 -0
- package/dist/timecampus/pages/extend/extendHelpers.d.ts.map +1 -1
- package/dist/timecampus/pages/extend/extendHelpers.js +43 -42
- package/dist/timecampus/pages/extend/extendHelpers.js.map +1 -1
- package/dist/timecampus/pages/extend/triggerHelpers.d.ts +50 -0
- package/dist/timecampus/pages/extend/triggerHelpers.d.ts.map +1 -0
- package/dist/timecampus/pages/extend/triggerHelpers.js +114 -0
- package/dist/timecampus/pages/extend/triggerHelpers.js.map +1 -0
- package/package.json +1 -1
|
@@ -3,78 +3,78 @@ import { StatusBadge as n } from "../../components/StatusBadge.js";
|
|
|
3
3
|
import { ProgressMeter as r } from "../../components/charts/ProgressMeter.js";
|
|
4
4
|
import "../../components/index.js";
|
|
5
5
|
import { TimeCampusExportFormat as i } from "../../../generated/wspace-types.js";
|
|
6
|
-
import {
|
|
7
|
-
import { useEffect as
|
|
8
|
-
import { Download as
|
|
9
|
-
import { jsx as
|
|
10
|
-
import { GlassCard as
|
|
6
|
+
import { EXPORT_START_FALLBACK_MESSAGE as a, REPORT_PERIODS as o, REPORT_TEMPLATES as s, buildReportName as c, describeExportStartError as l, exportStatusLabel as u, exportStatusTone as d, findReportTemplate as f, isTerminalExportStatus as p, resolveReportDateRange as m } from "./reportTemplates.js";
|
|
7
|
+
import { useEffect as h, useState as g } from "react";
|
|
8
|
+
import { Download as _, FileDown as v, Loader2 as y } from "lucide-react";
|
|
9
|
+
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
10
|
+
import { GlassCard as S } from "@burdenoff/fe-libs/ui";
|
|
11
11
|
//#region src/timecampus/pages/dashboard/ServerReportExports.tsx
|
|
12
|
-
var
|
|
13
|
-
function
|
|
12
|
+
var C = 3e3, w = 9e5;
|
|
13
|
+
function T(e) {
|
|
14
14
|
if (!e) return "";
|
|
15
15
|
let t = new Date(e);
|
|
16
16
|
return Number.isNaN(t.getTime()) ? "" : t.toLocaleString();
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
let [i, a] =
|
|
18
|
+
function E({ report: e }) {
|
|
19
|
+
let [i, a] = g(p(e.initial.status)), [o, s] = g(!1), [c, l] = g(0), { data: f, error: m, stopPolling: v, startPolling: S, refetch: E } = t({
|
|
20
20
|
variables: { id: e.jobId },
|
|
21
|
-
pollInterval: i || o ? 0 :
|
|
21
|
+
pollInterval: i || o ? 0 : C,
|
|
22
22
|
fetchPolicy: "network-only"
|
|
23
|
-
}), D =
|
|
24
|
-
|
|
25
|
-
(
|
|
23
|
+
}), D = f?.timeCampusExportJob ?? e.initial, O = D.status;
|
|
24
|
+
h(() => {
|
|
25
|
+
(p(O) || f?.timeCampusExportJob === null) && (v(), a(!0), s(!1));
|
|
26
26
|
}, [
|
|
27
27
|
O,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
]),
|
|
28
|
+
f,
|
|
29
|
+
v
|
|
30
|
+
]), h(() => {
|
|
31
31
|
if (i) return;
|
|
32
32
|
let e = window.setTimeout(() => {
|
|
33
|
-
|
|
34
|
-
},
|
|
33
|
+
v(), s(!0);
|
|
34
|
+
}, w);
|
|
35
35
|
return () => window.clearTimeout(e);
|
|
36
36
|
}, [
|
|
37
37
|
i,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
c,
|
|
39
|
+
v
|
|
40
40
|
]);
|
|
41
41
|
let k = () => {
|
|
42
|
-
s(!1),
|
|
43
|
-
}, A =
|
|
44
|
-
return /* @__PURE__ */
|
|
42
|
+
s(!1), l((e) => e + 1), S(C), E();
|
|
43
|
+
}, A = f !== void 0 && f.timeCampusExportJob === null, j = A ? "warning" : d(O), M = A ? "Unavailable" : u(O), N = !A && !p(O);
|
|
44
|
+
return /* @__PURE__ */ x("li", {
|
|
45
45
|
className: "flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3 sm:flex-row sm:items-center sm:justify-between",
|
|
46
46
|
"data-testid": "report-export-job",
|
|
47
47
|
"data-status": A ? "MISSING" : O,
|
|
48
|
-
children: [/* @__PURE__ */
|
|
48
|
+
children: [/* @__PURE__ */ x("div", {
|
|
49
49
|
className: "min-w-0 flex-1 space-y-1",
|
|
50
50
|
children: [
|
|
51
|
-
/* @__PURE__ */
|
|
51
|
+
/* @__PURE__ */ x("div", {
|
|
52
52
|
className: "flex flex-wrap items-center gap-2",
|
|
53
53
|
children: [
|
|
54
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ b("p", {
|
|
55
55
|
className: "truncate text-sm font-medium text-text-primary",
|
|
56
56
|
children: e.name
|
|
57
57
|
}),
|
|
58
|
-
/* @__PURE__ */
|
|
58
|
+
/* @__PURE__ */ b(n, {
|
|
59
59
|
variant: j,
|
|
60
60
|
label: M,
|
|
61
61
|
dot: !0
|
|
62
62
|
}),
|
|
63
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ b("span", {
|
|
64
64
|
className: "text-xs text-text-secondary",
|
|
65
65
|
children: D.format
|
|
66
66
|
})
|
|
67
67
|
]
|
|
68
68
|
}),
|
|
69
|
-
/* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ x("p", {
|
|
70
70
|
className: "text-xs text-text-secondary",
|
|
71
71
|
children: [
|
|
72
72
|
"Started ",
|
|
73
|
-
|
|
74
|
-
D.completedAt ? ` · finished ${
|
|
73
|
+
T(D.createdAt),
|
|
74
|
+
D.completedAt ? ` · finished ${T(D.completedAt)}` : ""
|
|
75
75
|
]
|
|
76
76
|
}),
|
|
77
|
-
N && /* @__PURE__ */
|
|
77
|
+
N && /* @__PURE__ */ b(r, {
|
|
78
78
|
value: D.progress ?? 0,
|
|
79
79
|
max: 100,
|
|
80
80
|
higherIsWorse: !1,
|
|
@@ -82,20 +82,20 @@ function w({ report: e }) {
|
|
|
82
82
|
format: (e) => `${Math.round(e)}%`,
|
|
83
83
|
size: "sm"
|
|
84
84
|
}),
|
|
85
|
-
O === "FAILED" && /* @__PURE__ */
|
|
85
|
+
O === "FAILED" && /* @__PURE__ */ b("p", {
|
|
86
86
|
className: "text-xs text-status-error-text",
|
|
87
87
|
children: D.errorMessage || "The export failed. Try generating it again."
|
|
88
88
|
}),
|
|
89
|
-
A && /* @__PURE__ */
|
|
89
|
+
A && /* @__PURE__ */ b("p", {
|
|
90
90
|
className: "text-xs text-text-secondary",
|
|
91
91
|
children: "This export is no longer available."
|
|
92
92
|
}),
|
|
93
|
-
o && !i && /* @__PURE__ */
|
|
93
|
+
o && !i && /* @__PURE__ */ x("p", {
|
|
94
94
|
className: "text-xs text-text-secondary",
|
|
95
95
|
children: [
|
|
96
96
|
"Still generating. Status checks paused to save requests; the export keeps running on the server.",
|
|
97
97
|
" ",
|
|
98
|
-
/* @__PURE__ */
|
|
98
|
+
/* @__PURE__ */ b("button", {
|
|
99
99
|
type: "button",
|
|
100
100
|
onClick: k,
|
|
101
101
|
className: "font-medium text-text-primary underline underline-offset-2",
|
|
@@ -103,115 +103,115 @@ function w({ report: e }) {
|
|
|
103
103
|
})
|
|
104
104
|
]
|
|
105
105
|
}),
|
|
106
|
-
|
|
106
|
+
m && !A && /* @__PURE__ */ x("p", {
|
|
107
107
|
className: "text-xs text-status-error-text",
|
|
108
|
-
children: ["Could not refresh the export status: ",
|
|
108
|
+
children: ["Could not refresh the export status: ", m.message]
|
|
109
109
|
})
|
|
110
110
|
]
|
|
111
|
-
}), /* @__PURE__ */
|
|
111
|
+
}), /* @__PURE__ */ x("div", {
|
|
112
112
|
className: "flex shrink-0 items-center gap-2",
|
|
113
|
-
children: [N && !o && /* @__PURE__ */
|
|
113
|
+
children: [N && !o && /* @__PURE__ */ b(y, {
|
|
114
114
|
className: "h-4 w-4 text-text-secondary motion-safe:animate-spin",
|
|
115
115
|
"aria-hidden": !0
|
|
116
|
-
}), O === "COMPLETED" && D.downloadUrl && /* @__PURE__ */
|
|
116
|
+
}), O === "COMPLETED" && D.downloadUrl && /* @__PURE__ */ x("a", {
|
|
117
117
|
href: D.downloadUrl,
|
|
118
118
|
target: "_blank",
|
|
119
119
|
rel: "noopener noreferrer",
|
|
120
120
|
className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90",
|
|
121
|
-
title: D.downloadExpiresAt ? `Link expires ${
|
|
122
|
-
children: [/* @__PURE__ */
|
|
121
|
+
title: D.downloadExpiresAt ? `Link expires ${T(D.downloadExpiresAt)}` : void 0,
|
|
122
|
+
children: [/* @__PURE__ */ b(_, { className: "h-4 w-4" }), "Download"]
|
|
123
123
|
})]
|
|
124
124
|
})]
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
let [t, n] =
|
|
129
|
-
|
|
130
|
-
let e =
|
|
127
|
+
function D() {
|
|
128
|
+
let [t, n] = g("time-entries"), [r, u] = g("30d"), [d, p] = g(i.Csv), [h, _] = g([]), [C, w] = g(null), [T, { loading: D }] = e(), O = f(t), k = async () => {
|
|
129
|
+
w(null);
|
|
130
|
+
let e = c(O, r);
|
|
131
131
|
try {
|
|
132
|
-
let t =
|
|
133
|
-
entityTypes:
|
|
134
|
-
format:
|
|
132
|
+
let t = await T({ variables: { input: {
|
|
133
|
+
entityTypes: O.entityTypes,
|
|
134
|
+
format: d,
|
|
135
135
|
includeMetadata: !0,
|
|
136
136
|
name: e,
|
|
137
|
-
...
|
|
138
|
-
} } })
|
|
139
|
-
if (!
|
|
140
|
-
|
|
137
|
+
...m(r)
|
|
138
|
+
} } }), n = t.data?.exportTimeCampusEntities;
|
|
139
|
+
if (!n) {
|
|
140
|
+
w(t.error ? l(t.error) : a);
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
jobId:
|
|
143
|
+
_((t) => [{
|
|
144
|
+
jobId: n.id,
|
|
145
145
|
name: e,
|
|
146
|
-
initial:
|
|
147
|
-
}, ...
|
|
146
|
+
initial: n
|
|
147
|
+
}, ...t]);
|
|
148
148
|
} catch (e) {
|
|
149
|
-
|
|
149
|
+
w(l(e));
|
|
150
150
|
}
|
|
151
|
-
},
|
|
152
|
-
return /* @__PURE__ */
|
|
151
|
+
}, A = "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary";
|
|
152
|
+
return /* @__PURE__ */ b("section", {
|
|
153
153
|
"data-testid": "server-report-exports",
|
|
154
154
|
"aria-label": "Generate a full report",
|
|
155
|
-
children: /* @__PURE__ */
|
|
155
|
+
children: /* @__PURE__ */ x(S, {
|
|
156
156
|
treatment: "glass",
|
|
157
157
|
className: "p-4 sm:p-5",
|
|
158
158
|
children: [
|
|
159
|
-
/* @__PURE__ */
|
|
159
|
+
/* @__PURE__ */ x("div", {
|
|
160
160
|
className: "flex items-start gap-3",
|
|
161
|
-
children: [/* @__PURE__ */
|
|
161
|
+
children: [/* @__PURE__ */ b("div", {
|
|
162
162
|
className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-status-info-bg text-status-info-text",
|
|
163
|
-
children: /* @__PURE__ */ v
|
|
164
|
-
}), /* @__PURE__ */
|
|
163
|
+
children: /* @__PURE__ */ b(v, { className: "h-5 w-5" })
|
|
164
|
+
}), /* @__PURE__ */ x("div", {
|
|
165
165
|
className: "min-w-0",
|
|
166
|
-
children: [/* @__PURE__ */
|
|
166
|
+
children: [/* @__PURE__ */ b("h2", {
|
|
167
167
|
className: "text-sm font-semibold text-text-primary",
|
|
168
168
|
children: "Generate a full report"
|
|
169
|
-
}), /* @__PURE__ */
|
|
169
|
+
}), /* @__PURE__ */ b("p", {
|
|
170
170
|
className: "mt-1 text-xs text-text-secondary",
|
|
171
171
|
children: "Built on the server from your complete records, not just what this page has loaded. Large reports keep generating in the background; the download appears here when it is ready."
|
|
172
172
|
})]
|
|
173
173
|
})]
|
|
174
174
|
}),
|
|
175
|
-
/* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ x("div", {
|
|
176
176
|
className: "mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",
|
|
177
177
|
children: [
|
|
178
|
-
/* @__PURE__ */
|
|
178
|
+
/* @__PURE__ */ x("label", {
|
|
179
179
|
className: "block text-xs font-medium text-text-secondary",
|
|
180
|
-
children: ["Report", /* @__PURE__ */
|
|
180
|
+
children: ["Report", /* @__PURE__ */ b("select", {
|
|
181
181
|
value: t,
|
|
182
182
|
onChange: (e) => n(e.target.value),
|
|
183
|
-
className:
|
|
183
|
+
className: A,
|
|
184
184
|
"aria-label": "Report template",
|
|
185
|
-
children:
|
|
185
|
+
children: s.map((e) => /* @__PURE__ */ b("option", {
|
|
186
186
|
value: e.id,
|
|
187
187
|
children: e.label
|
|
188
188
|
}, e.id))
|
|
189
189
|
})]
|
|
190
190
|
}),
|
|
191
|
-
/* @__PURE__ */
|
|
191
|
+
/* @__PURE__ */ x("label", {
|
|
192
192
|
className: "block text-xs font-medium text-text-secondary",
|
|
193
|
-
children: ["Period", /* @__PURE__ */
|
|
193
|
+
children: ["Period", /* @__PURE__ */ b("select", {
|
|
194
194
|
value: r,
|
|
195
|
-
onChange: (e) =>
|
|
196
|
-
className:
|
|
195
|
+
onChange: (e) => u(e.target.value),
|
|
196
|
+
className: A,
|
|
197
197
|
"aria-label": "Report period",
|
|
198
|
-
children:
|
|
198
|
+
children: o.map((e) => /* @__PURE__ */ b("option", {
|
|
199
199
|
value: e.id,
|
|
200
200
|
children: e.label
|
|
201
201
|
}, e.id))
|
|
202
202
|
})]
|
|
203
203
|
}),
|
|
204
|
-
/* @__PURE__ */
|
|
204
|
+
/* @__PURE__ */ x("label", {
|
|
205
205
|
className: "block text-xs font-medium text-text-secondary",
|
|
206
|
-
children: ["Format", /* @__PURE__ */
|
|
207
|
-
value:
|
|
208
|
-
onChange: (e) =>
|
|
209
|
-
className:
|
|
206
|
+
children: ["Format", /* @__PURE__ */ x("select", {
|
|
207
|
+
value: d,
|
|
208
|
+
onChange: (e) => p(e.target.value),
|
|
209
|
+
className: A,
|
|
210
210
|
"aria-label": "Report format",
|
|
211
|
-
children: [/* @__PURE__ */
|
|
211
|
+
children: [/* @__PURE__ */ b("option", {
|
|
212
212
|
value: i.Csv,
|
|
213
213
|
children: "CSV"
|
|
214
|
-
}), /* @__PURE__ */
|
|
214
|
+
}), /* @__PURE__ */ b("option", {
|
|
215
215
|
value: i.Json,
|
|
216
216
|
children: "JSON"
|
|
217
217
|
})]
|
|
@@ -219,32 +219,32 @@ function T() {
|
|
|
219
219
|
})
|
|
220
220
|
]
|
|
221
221
|
}),
|
|
222
|
-
/* @__PURE__ */
|
|
222
|
+
/* @__PURE__ */ b("p", {
|
|
223
223
|
className: "mt-2 text-xs text-text-secondary",
|
|
224
|
-
children:
|
|
224
|
+
children: O.description
|
|
225
225
|
}),
|
|
226
|
-
/* @__PURE__ */
|
|
226
|
+
/* @__PURE__ */ x("div", {
|
|
227
227
|
className: "mt-4 flex flex-wrap items-center gap-3",
|
|
228
|
-
children: [/* @__PURE__ */
|
|
228
|
+
children: [/* @__PURE__ */ x("button", {
|
|
229
229
|
type: "button",
|
|
230
|
-
onClick:
|
|
231
|
-
disabled:
|
|
230
|
+
onClick: k,
|
|
231
|
+
disabled: D,
|
|
232
232
|
className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-70",
|
|
233
|
-
children: [
|
|
234
|
-
}),
|
|
233
|
+
children: [D ? /* @__PURE__ */ b(y, { className: "h-4 w-4 motion-safe:animate-spin" }) : /* @__PURE__ */ b(v, { className: "h-4 w-4" }), D ? "Starting…" : "Generate report"]
|
|
234
|
+
}), C && /* @__PURE__ */ b("p", {
|
|
235
235
|
role: "alert",
|
|
236
236
|
className: "text-sm text-status-error-text",
|
|
237
|
-
children:
|
|
237
|
+
children: C
|
|
238
238
|
})]
|
|
239
239
|
}),
|
|
240
|
-
|
|
240
|
+
h.length > 0 && /* @__PURE__ */ x("div", {
|
|
241
241
|
className: "mt-5 border-t border-border-subtle pt-4",
|
|
242
|
-
children: [/* @__PURE__ */
|
|
242
|
+
children: [/* @__PURE__ */ b("h3", {
|
|
243
243
|
className: "text-xs font-semibold uppercase tracking-wide text-text-secondary",
|
|
244
244
|
children: "Generated this session"
|
|
245
|
-
}), /* @__PURE__ */
|
|
245
|
+
}), /* @__PURE__ */ b("ul", {
|
|
246
246
|
className: "mt-2 space-y-2",
|
|
247
|
-
children:
|
|
247
|
+
children: h.map((e) => /* @__PURE__ */ b(E, { report: e }, e.jobId))
|
|
248
248
|
})]
|
|
249
249
|
})
|
|
250
250
|
]
|
|
@@ -252,6 +252,6 @@ function T() {
|
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
254
|
//#endregion
|
|
255
|
-
export {
|
|
255
|
+
export { D as ServerReportExports };
|
|
256
256
|
|
|
257
257
|
//# sourceMappingURL=ServerReportExports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerReportExports.js","names":[],"sources":["../../../../src/timecampus/pages/dashboard/ServerReportExports.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { Download, FileDown, Loader2 } from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { StatusBadge, ProgressMeter } from \"../../components\";\nimport { TimeCampusExportFormat } from \"@/generated/wspace-types\";\nimport {\n useExportTimeCampusEntitiesMutation,\n useTimeCampusExportJobQuery,\n type TimeCampusExportJobFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport {\n REPORT_PERIODS,\n REPORT_TEMPLATES,\n buildReportName,\n exportStatusLabel,\n exportStatusTone,\n findReportTemplate,\n isTerminalExportStatus,\n resolveReportDateRange,\n type ReportPeriodId,\n type ReportTemplateId,\n} from \"./reportTemplates\";\n\nconst POLL_INTERVAL_MS = 3000;\n/**\n * Stop polling a job that has not settled after this long, so a stuck job\n * cannot keep the page firing requests forever. The user can resume.\n */\nconst MAX_POLL_DURATION_MS = 15 * 60 * 1000;\n\ninterface StartedReport {\n jobId: string;\n name: string;\n initial: TimeCampusExportJobFieldsFragment;\n}\n\nfunction formatTimestamp(value: string | null | undefined): string {\n if (!value) return \"\";\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? \"\" : date.toLocaleString();\n}\n\n/**\n * One generated report. Polls `timeCampusExportJob` until the job reaches a\n * terminal status, then offers the archive download.\n */\nfunction ReportJobRow({ report }: { report: StartedReport }) {\n const [settled, setSettled] = useState(\n isTerminalExportStatus(report.initial.status),\n );\n const [timedOut, setTimedOut] = useState(false);\n const [pollEpoch, setPollEpoch] = useState(0);\n const { data, error, stopPolling, startPolling, refetch } =\n useTimeCampusExportJobQuery({\n variables: { id: report.jobId },\n pollInterval: settled || timedOut ? 0 : POLL_INTERVAL_MS,\n fetchPolicy: \"network-only\",\n });\n\n const job = data?.timeCampusExportJob ?? report.initial;\n const status = job.status;\n\n useEffect(() => {\n if (isTerminalExportStatus(status) || data?.timeCampusExportJob === null) {\n stopPolling();\n setSettled(true);\n setTimedOut(false);\n }\n }, [status, data, stopPolling]);\n\n // Cap how long one job is polled. pollEpoch restarts the window when the\n // user resumes checking.\n useEffect(() => {\n if (settled) return undefined;\n const timer = window.setTimeout(() => {\n stopPolling();\n setTimedOut(true);\n }, MAX_POLL_DURATION_MS);\n return () => window.clearTimeout(timer);\n }, [settled, pollEpoch, stopPolling]);\n\n const handleResume = () => {\n setTimedOut(false);\n setPollEpoch((n) => n + 1);\n startPolling(POLL_INTERVAL_MS);\n void refetch();\n };\n\n const missing = data !== undefined && data.timeCampusExportJob === null;\n const tone = missing ? \"warning\" : exportStatusTone(status);\n const label = missing ? \"Unavailable\" : exportStatusLabel(status);\n const inFlight = !missing && !isTerminalExportStatus(status);\n\n return (\n <li\n className=\"flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3 sm:flex-row sm:items-center sm:justify-between\"\n data-testid=\"report-export-job\"\n data-status={missing ? \"MISSING\" : status}\n >\n <div className=\"min-w-0 flex-1 space-y-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {report.name}\n </p>\n <StatusBadge variant={tone} label={label} dot />\n <span className=\"text-xs text-text-secondary\">{job.format}</span>\n </div>\n <p className=\"text-xs text-text-secondary\">\n Started {formatTimestamp(job.createdAt)}\n {job.completedAt\n ? ` · finished ${formatTimestamp(job.completedAt)}`\n : \"\"}\n </p>\n {inFlight && (\n <ProgressMeter\n value={job.progress ?? 0}\n max={100}\n higherIsWorse={false}\n label=\"Progress\"\n format={(v) => `${Math.round(v)}%`}\n size=\"sm\"\n />\n )}\n {status === \"FAILED\" && (\n <p className=\"text-xs text-status-error-text\">\n {job.errorMessage || \"The export failed. Try generating it again.\"}\n </p>\n )}\n {missing && (\n <p className=\"text-xs text-text-secondary\">\n This export is no longer available.\n </p>\n )}\n {timedOut && !settled && (\n <p className=\"text-xs text-text-secondary\">\n Still generating. Status checks paused to save requests; the export\n keeps running on the server.{\" \"}\n <button\n type=\"button\"\n onClick={handleResume}\n className=\"font-medium text-text-primary underline underline-offset-2\"\n >\n Check again\n </button>\n </p>\n )}\n {error && !missing && (\n <p className=\"text-xs text-status-error-text\">\n Could not refresh the export status: {error.message}\n </p>\n )}\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {inFlight && !timedOut && (\n <Loader2\n className=\"h-4 w-4 text-text-secondary motion-safe:animate-spin\"\n aria-hidden\n />\n )}\n {status === \"COMPLETED\" && job.downloadUrl && (\n <a\n href={job.downloadUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90\"\n title={\n job.downloadExpiresAt\n ? `Link expires ${formatTimestamp(job.downloadExpiresAt)}`\n : undefined\n }\n >\n <Download className=\"h-4 w-4\" />\n Download\n </a>\n )}\n </div>\n </li>\n );\n}\n\n/**\n * Server-side report builder: pick a template, a period and a format, and\n * wspace-export-svc builds the full dataset asynchronously.\n */\nexport function ServerReportExports() {\n const [templateId, setTemplateId] =\n useState<ReportTemplateId>(\"time-entries\");\n const [period, setPeriod] = useState<ReportPeriodId>(\"30d\");\n const [format, setFormat] = useState<TimeCampusExportFormat>(\n TimeCampusExportFormat.Csv,\n );\n const [reports, setReports] = useState<StartedReport[]>([]);\n const [startError, setStartError] = useState<string | null>(null);\n const [exportEntities, { loading }] = useExportTimeCampusEntitiesMutation();\n\n const template = findReportTemplate(templateId);\n\n const handleGenerate = async () => {\n setStartError(null);\n const name = buildReportName(template, period);\n try {\n const result = await exportEntities({\n variables: {\n input: {\n entityTypes: template.entityTypes,\n format,\n includeMetadata: true,\n name,\n ...resolveReportDateRange(period),\n },\n },\n });\n const job = result.data?.exportTimeCampusEntities;\n if (!job) {\n setStartError(\"The export could not be started. Please try again.\");\n return;\n }\n setReports((prev) => [{ jobId: job.id, name, initial: job }, ...prev]);\n } catch (err) {\n setStartError(\n err instanceof Error\n ? err.message\n : \"The export could not be started. Please try again.\",\n );\n }\n };\n\n const fieldClass =\n \"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\";\n\n return (\n <section\n data-testid=\"server-report-exports\"\n aria-label=\"Generate a full report\"\n >\n <GlassCard treatment=\"glass\" className=\"p-4 sm:p-5\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-status-info-bg text-status-info-text\">\n <FileDown className=\"h-5 w-5\" />\n </div>\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-text-primary\">\n Generate a full report\n </h2>\n <p className=\"mt-1 text-xs text-text-secondary\">\n Built on the server from your complete records, not just what this\n page has loaded. Large reports keep generating in the background;\n the download appears here when it is ready.\n </p>\n </div>\n </div>\n\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <label className=\"block text-xs font-medium text-text-secondary\">\n Report\n <select\n value={templateId}\n onChange={(e) =>\n setTemplateId(e.target.value as ReportTemplateId)\n }\n className={fieldClass}\n aria-label=\"Report template\"\n >\n {REPORT_TEMPLATES.map((t) => (\n <option key={t.id} value={t.id}>\n {t.label}\n </option>\n ))}\n </select>\n </label>\n <label className=\"block text-xs font-medium text-text-secondary\">\n Period\n <select\n value={period}\n onChange={(e) => setPeriod(e.target.value as ReportPeriodId)}\n className={fieldClass}\n aria-label=\"Report period\"\n >\n {REPORT_PERIODS.map((p) => (\n <option key={p.id} value={p.id}>\n {p.label}\n </option>\n ))}\n </select>\n </label>\n <label className=\"block text-xs font-medium text-text-secondary\">\n Format\n <select\n value={format}\n onChange={(e) =>\n setFormat(e.target.value as TimeCampusExportFormat)\n }\n className={fieldClass}\n aria-label=\"Report format\"\n >\n <option value={TimeCampusExportFormat.Csv}>CSV</option>\n <option value={TimeCampusExportFormat.Json}>JSON</option>\n </select>\n </label>\n </div>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {template.description}\n </p>\n\n <div className=\"mt-4 flex flex-wrap items-center gap-3\">\n <button\n type=\"button\"\n onClick={handleGenerate}\n disabled={loading}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-70\"\n >\n {loading ? (\n <Loader2 className=\"h-4 w-4 motion-safe:animate-spin\" />\n ) : (\n <FileDown className=\"h-4 w-4\" />\n )}\n {loading ? \"Starting…\" : \"Generate report\"}\n </button>\n {startError && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {startError}\n </p>\n )}\n </div>\n\n {reports.length > 0 && (\n <div className=\"mt-5 border-t border-border-subtle pt-4\">\n <h3 className=\"text-xs font-semibold uppercase tracking-wide text-text-secondary\">\n Generated this session\n </h3>\n <ul className=\"mt-2 space-y-2\">\n {reports.map((report) => (\n <ReportJobRow key={report.jobId} report={report} />\n ))}\n </ul>\n </div>\n )}\n </GlassCard>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;AAuBA,IAAM,IAAmB,KAKnB,IAAuB;AAQ7B,SAAS,EAAgB,GAA0C;CACjE,IAAI,CAAC,GAAO,OAAO;CACnB,IAAM,IAAO,IAAI,KAAK,CAAK;CAC3B,OAAO,OAAO,MAAM,EAAK,QAAQ,CAAC,IAAI,KAAK,EAAK,eAAe;AACjE;AAMA,SAAS,EAAa,EAAE,aAAqC;CAC3D,IAAM,CAAC,GAAS,KAAc,EAC5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AU;MAAoE,UAAA;KAE9E,CAAA,GACJ,kBAAC,MAAD;MAAI,WAAU;MACX,UAAA,EAAQ,KAAK,MACZ,kBAAC,GAAD,EAAyC,UAAS,GAA/B,EAAO,KAAwB,CACnD;KACC,CAAA,CACD;;GAEE;;CACJ,CAAA;AAEb"}
|
|
1
|
+
{"version":3,"file":"ServerReportExports.js","names":[],"sources":["../../../../src/timecampus/pages/dashboard/ServerReportExports.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { Download, FileDown, Loader2 } from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { StatusBadge, ProgressMeter } from \"../../components\";\nimport { TimeCampusExportFormat } from \"@/generated/wspace-types\";\nimport {\n useExportTimeCampusEntitiesMutation,\n useTimeCampusExportJobQuery,\n type TimeCampusExportJobFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport {\n EXPORT_START_FALLBACK_MESSAGE,\n REPORT_PERIODS,\n REPORT_TEMPLATES,\n buildReportName,\n describeExportStartError,\n exportStatusLabel,\n exportStatusTone,\n findReportTemplate,\n isTerminalExportStatus,\n resolveReportDateRange,\n type ReportPeriodId,\n type ReportTemplateId,\n} from \"./reportTemplates\";\n\nconst POLL_INTERVAL_MS = 3000;\n/**\n * Stop polling a job that has not settled after this long, so a stuck job\n * cannot keep the page firing requests forever. The user can resume.\n */\nconst MAX_POLL_DURATION_MS = 15 * 60 * 1000;\n\ninterface StartedReport {\n jobId: string;\n name: string;\n initial: TimeCampusExportJobFieldsFragment;\n}\n\nfunction formatTimestamp(value: string | null | undefined): string {\n if (!value) return \"\";\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? \"\" : date.toLocaleString();\n}\n\n/**\n * One generated report. Polls `timeCampusExportJob` until the job reaches a\n * terminal status, then offers the archive download.\n */\nfunction ReportJobRow({ report }: { report: StartedReport }) {\n const [settled, setSettled] = useState(\n isTerminalExportStatus(report.initial.status),\n );\n const [timedOut, setTimedOut] = useState(false);\n const [pollEpoch, setPollEpoch] = useState(0);\n const { data, error, stopPolling, startPolling, refetch } =\n useTimeCampusExportJobQuery({\n variables: { id: report.jobId },\n pollInterval: settled || timedOut ? 0 : POLL_INTERVAL_MS,\n fetchPolicy: \"network-only\",\n });\n\n const job = data?.timeCampusExportJob ?? report.initial;\n const status = job.status;\n\n useEffect(() => {\n if (isTerminalExportStatus(status) || data?.timeCampusExportJob === null) {\n stopPolling();\n setSettled(true);\n setTimedOut(false);\n }\n }, [status, data, stopPolling]);\n\n // Cap how long one job is polled. pollEpoch restarts the window when the\n // user resumes checking.\n useEffect(() => {\n if (settled) return undefined;\n const timer = window.setTimeout(() => {\n stopPolling();\n setTimedOut(true);\n }, MAX_POLL_DURATION_MS);\n return () => window.clearTimeout(timer);\n }, [settled, pollEpoch, stopPolling]);\n\n const handleResume = () => {\n setTimedOut(false);\n setPollEpoch((n) => n + 1);\n startPolling(POLL_INTERVAL_MS);\n void refetch();\n };\n\n const missing = data !== undefined && data.timeCampusExportJob === null;\n const tone = missing ? \"warning\" : exportStatusTone(status);\n const label = missing ? \"Unavailable\" : exportStatusLabel(status);\n const inFlight = !missing && !isTerminalExportStatus(status);\n\n return (\n <li\n className=\"flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3 sm:flex-row sm:items-center sm:justify-between\"\n data-testid=\"report-export-job\"\n data-status={missing ? \"MISSING\" : status}\n >\n <div className=\"min-w-0 flex-1 space-y-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {report.name}\n </p>\n <StatusBadge variant={tone} label={label} dot />\n <span className=\"text-xs text-text-secondary\">{job.format}</span>\n </div>\n <p className=\"text-xs text-text-secondary\">\n Started {formatTimestamp(job.createdAt)}\n {job.completedAt\n ? ` · finished ${formatTimestamp(job.completedAt)}`\n : \"\"}\n </p>\n {inFlight && (\n <ProgressMeter\n value={job.progress ?? 0}\n max={100}\n higherIsWorse={false}\n label=\"Progress\"\n format={(v) => `${Math.round(v)}%`}\n size=\"sm\"\n />\n )}\n {status === \"FAILED\" && (\n <p className=\"text-xs text-status-error-text\">\n {job.errorMessage || \"The export failed. Try generating it again.\"}\n </p>\n )}\n {missing && (\n <p className=\"text-xs text-text-secondary\">\n This export is no longer available.\n </p>\n )}\n {timedOut && !settled && (\n <p className=\"text-xs text-text-secondary\">\n Still generating. Status checks paused to save requests; the export\n keeps running on the server.{\" \"}\n <button\n type=\"button\"\n onClick={handleResume}\n className=\"font-medium text-text-primary underline underline-offset-2\"\n >\n Check again\n </button>\n </p>\n )}\n {error && !missing && (\n <p className=\"text-xs text-status-error-text\">\n Could not refresh the export status: {error.message}\n </p>\n )}\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {inFlight && !timedOut && (\n <Loader2\n className=\"h-4 w-4 text-text-secondary motion-safe:animate-spin\"\n aria-hidden\n />\n )}\n {status === \"COMPLETED\" && job.downloadUrl && (\n <a\n href={job.downloadUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90\"\n title={\n job.downloadExpiresAt\n ? `Link expires ${formatTimestamp(job.downloadExpiresAt)}`\n : undefined\n }\n >\n <Download className=\"h-4 w-4\" />\n Download\n </a>\n )}\n </div>\n </li>\n );\n}\n\n/**\n * Server-side report builder: pick a template, a period and a format, and\n * wspace-export-svc builds the full dataset asynchronously.\n */\nexport function ServerReportExports() {\n const [templateId, setTemplateId] =\n useState<ReportTemplateId>(\"time-entries\");\n const [period, setPeriod] = useState<ReportPeriodId>(\"30d\");\n const [format, setFormat] = useState<TimeCampusExportFormat>(\n TimeCampusExportFormat.Csv,\n );\n const [reports, setReports] = useState<StartedReport[]>([]);\n const [startError, setStartError] = useState<string | null>(null);\n const [exportEntities, { loading }] = useExportTimeCampusEntitiesMutation();\n\n const template = findReportTemplate(templateId);\n\n const handleGenerate = async () => {\n setStartError(null);\n const name = buildReportName(template, period);\n try {\n const result = await exportEntities({\n variables: {\n input: {\n entityTypes: template.entityTypes,\n format,\n includeMetadata: true,\n name,\n ...resolveReportDateRange(period),\n },\n },\n });\n const job = result.data?.exportTimeCampusEntities;\n if (!job) {\n setStartError(\n result.error\n ? describeExportStartError(result.error)\n : EXPORT_START_FALLBACK_MESSAGE,\n );\n return;\n }\n setReports((prev) => [{ jobId: job.id, name, initial: job }, ...prev]);\n } catch (err) {\n setStartError(describeExportStartError(err));\n }\n };\n\n const fieldClass =\n \"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\";\n\n return (\n <section\n data-testid=\"server-report-exports\"\n aria-label=\"Generate a full report\"\n >\n <GlassCard treatment=\"glass\" className=\"p-4 sm:p-5\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-status-info-bg text-status-info-text\">\n <FileDown className=\"h-5 w-5\" />\n </div>\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-text-primary\">\n Generate a full report\n </h2>\n <p className=\"mt-1 text-xs text-text-secondary\">\n Built on the server from your complete records, not just what this\n page has loaded. Large reports keep generating in the background;\n the download appears here when it is ready.\n </p>\n </div>\n </div>\n\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <label className=\"block text-xs font-medium text-text-secondary\">\n Report\n <select\n value={templateId}\n onChange={(e) =>\n setTemplateId(e.target.value as ReportTemplateId)\n }\n className={fieldClass}\n aria-label=\"Report template\"\n >\n {REPORT_TEMPLATES.map((t) => (\n <option key={t.id} value={t.id}>\n {t.label}\n </option>\n ))}\n </select>\n </label>\n <label className=\"block text-xs font-medium text-text-secondary\">\n Period\n <select\n value={period}\n onChange={(e) => setPeriod(e.target.value as ReportPeriodId)}\n className={fieldClass}\n aria-label=\"Report period\"\n >\n {REPORT_PERIODS.map((p) => (\n <option key={p.id} value={p.id}>\n {p.label}\n </option>\n ))}\n </select>\n </label>\n <label className=\"block text-xs font-medium text-text-secondary\">\n Format\n <select\n value={format}\n onChange={(e) =>\n setFormat(e.target.value as TimeCampusExportFormat)\n }\n className={fieldClass}\n aria-label=\"Report format\"\n >\n <option value={TimeCampusExportFormat.Csv}>CSV</option>\n <option value={TimeCampusExportFormat.Json}>JSON</option>\n </select>\n </label>\n </div>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {template.description}\n </p>\n\n <div className=\"mt-4 flex flex-wrap items-center gap-3\">\n <button\n type=\"button\"\n onClick={handleGenerate}\n disabled={loading}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-70\"\n >\n {loading ? (\n <Loader2 className=\"h-4 w-4 motion-safe:animate-spin\" />\n ) : (\n <FileDown className=\"h-4 w-4\" />\n )}\n {loading ? \"Starting…\" : \"Generate report\"}\n </button>\n {startError && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {startError}\n </p>\n )}\n </div>\n\n {reports.length > 0 && (\n <div className=\"mt-5 border-t border-border-subtle pt-4\">\n <h3 className=\"text-xs font-semibold uppercase tracking-wide text-text-secondary\">\n Generated this session\n </h3>\n <ul className=\"mt-2 space-y-2\">\n {reports.map((report) => (\n <ReportJobRow key={report.jobId} report={report} />\n ))}\n </ul>\n </div>\n )}\n </GlassCard>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;AAyBA,IAAM,IAAmB,KAKnB,IAAuB;AAQ7B,SAAS,EAAgB,GAA0C;CACjE,IAAI,CAAC,GAAO,OAAO;CACnB,IAAM,IAAO,IAAI,KAAK,CAAK;CAC3B,OAAO,OAAO,MAAM,EAAK,QAAQ,CAAC,IAAI,KAAK,EAAK,eAAe;AACjE;AAMA,SAAS,EAAa,EAAE,aAAqC;CAC3D,IAAM,CAAC,GAAS,KAAc,EAC5B,EAAuB,EAAO,QAAQ,MAAM,CAC9C,GACM,CAAC,GAAU,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AAA,GACJ,kBAAC,MAAD;MAAI,WAAU;MACX,UAAA,EAAQ,KAAK,MACZ,kBAAC,GAAD,EAAyC,UAAS,GAA/B,EAAO,KAAwB,CACnD;KACC,CAAA,CACD;;GAEE;;CACJ,CAAA;AAEb"}
|
|
@@ -30,4 +30,12 @@ export declare function isTerminalExportStatus(status: string | null | undefined
|
|
|
30
30
|
export type ExportStatusTone = "info" | "success" | "warning" | "error";
|
|
31
31
|
export declare function exportStatusTone(status: string): ExportStatusTone;
|
|
32
32
|
export declare function exportStatusLabel(status: string): string;
|
|
33
|
+
export declare const EXPORT_START_FALLBACK_MESSAGE = "The export could not be started. Please try again.";
|
|
34
|
+
/**
|
|
35
|
+
* User-facing message for a failed `exportTimeCampusEntities` call. The
|
|
36
|
+
* TimeCampus Apollo client uses `errorPolicy: "all"`, so a GraphQL error
|
|
37
|
+
* arrives on `result.error` rather than as a thrown exception; both shapes
|
|
38
|
+
* are accepted here.
|
|
39
|
+
*/
|
|
40
|
+
export declare function describeExportStartError(error: unknown): string;
|
|
33
41
|
//# sourceMappingURL=reportTemplates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportTemplates.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/dashboard/reportTemplates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"reportTemplates.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/dashboard/reportTemplates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,gBAAgB,GAC1B,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAE3E,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,gBAAgB,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EA0DrD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAElE,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC;IACzC,EAAE,EAAE,cAAc,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,CAMA,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAID,4EAA4E;AAC5E,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,cAAc,EACtB,GAAG,GAAE,IAAiB,GACrB,eAAe,CAYjB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,gBAAgB,GAAG,cAAc,CAIvE;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,cAAc,GACrB,MAAM,CAIR;AAUD,4DAA4D;AAC5D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,WAEvE;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAExE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAKjE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAoBxD;AAED,eAAO,MAAM,6BAA6B,uDACY,CAAC;AAiBvD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQ/D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { extractBackendError as e } from "@burdenoff/fe-libs/shared/utils";
|
|
1
2
|
//#region src/timecampus/pages/dashboard/reportTemplates.ts
|
|
2
|
-
var
|
|
3
|
+
var t = [
|
|
3
4
|
{
|
|
4
5
|
id: "time-entries",
|
|
5
6
|
label: "Time entries",
|
|
@@ -53,7 +54,7 @@ var e = [
|
|
|
53
54
|
"timecampus_meeting_action_items"
|
|
54
55
|
]
|
|
55
56
|
}
|
|
56
|
-
],
|
|
57
|
+
], n = [
|
|
57
58
|
{
|
|
58
59
|
id: "7d",
|
|
59
60
|
label: "Last 7 days"
|
|
@@ -74,43 +75,43 @@ var e = [
|
|
|
74
75
|
id: "all",
|
|
75
76
|
label: "All time"
|
|
76
77
|
}
|
|
77
|
-
],
|
|
78
|
-
function
|
|
78
|
+
], r = 864e5;
|
|
79
|
+
function i(e, t = /* @__PURE__ */ new Date()) {
|
|
79
80
|
if (e === "all") return {};
|
|
80
|
-
let
|
|
81
|
+
let n = t.toISOString();
|
|
81
82
|
if (e === "ytd") return {
|
|
82
83
|
dateRangeStart: new Date(t.getFullYear(), 0, 1).toISOString(),
|
|
83
|
-
dateRangeEnd:
|
|
84
|
+
dateRangeEnd: n
|
|
84
85
|
};
|
|
85
86
|
let i = e === "7d" ? 7 : e === "30d" ? 30 : 90;
|
|
86
87
|
return {
|
|
87
|
-
dateRangeStart: (/* @__PURE__ */ new Date(t.getTime() - i *
|
|
88
|
-
dateRangeEnd:
|
|
88
|
+
dateRangeStart: (/* @__PURE__ */ new Date(t.getTime() - i * r)).toISOString(),
|
|
89
|
+
dateRangeEnd: n
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
|
-
function
|
|
92
|
-
let n =
|
|
93
|
-
if (!n) throw Error(`Unknown report template: ${
|
|
92
|
+
function a(e) {
|
|
93
|
+
let n = t.find((t) => t.id === e);
|
|
94
|
+
if (!n) throw Error(`Unknown report template: ${e}`);
|
|
94
95
|
return n;
|
|
95
96
|
}
|
|
96
|
-
function
|
|
97
|
-
let r =
|
|
97
|
+
function o(e, t) {
|
|
98
|
+
let r = n.find((e) => e.id === t)?.label ?? "All time";
|
|
98
99
|
return `${e.label} report — ${r}`;
|
|
99
100
|
}
|
|
100
|
-
var
|
|
101
|
+
var s = /* @__PURE__ */ new Set([
|
|
101
102
|
"COMPLETED",
|
|
102
103
|
"FAILED",
|
|
103
104
|
"CANCELLED",
|
|
104
105
|
"EXPIRED",
|
|
105
106
|
"DELETED"
|
|
106
107
|
]);
|
|
107
|
-
function s(e) {
|
|
108
|
-
return !!e && o.has(e);
|
|
109
|
-
}
|
|
110
108
|
function c(e) {
|
|
111
|
-
return e
|
|
109
|
+
return !!e && s.has(e);
|
|
112
110
|
}
|
|
113
111
|
function l(e) {
|
|
112
|
+
return e === "COMPLETED" ? "success" : e === "FAILED" ? "error" : s.has(e) ? "warning" : "info";
|
|
113
|
+
}
|
|
114
|
+
function u(e) {
|
|
114
115
|
switch (e) {
|
|
115
116
|
case "CREATED":
|
|
116
117
|
case "QUEUED": return "Queued";
|
|
@@ -123,7 +124,16 @@ function l(e) {
|
|
|
123
124
|
default: return e;
|
|
124
125
|
}
|
|
125
126
|
}
|
|
127
|
+
var d = "The export could not be started. Please try again.", f = {
|
|
128
|
+
QUOTA_NOT_PROVISIONED: "Full reports are not included in this workspace's TimeCampus plan. Upgrade the plan in Billing to generate them.",
|
|
129
|
+
QUOTA_EXHAUSTED: "This workspace has used all of its full reports for this month. Upgrade the plan in Billing or try again next month.",
|
|
130
|
+
QUOTA_EXCEEDED: "This workspace has used all of its full reports for this month. Upgrade the plan in Billing or try again next month."
|
|
131
|
+
};
|
|
132
|
+
function p(t) {
|
|
133
|
+
let n = e(t);
|
|
134
|
+
return n ? (n.code ? f[n.code] : void 0) || n.message || "The export could not be started. Please try again." : d;
|
|
135
|
+
}
|
|
126
136
|
//#endregion
|
|
127
|
-
export {
|
|
137
|
+
export { d as EXPORT_START_FALLBACK_MESSAGE, n as REPORT_PERIODS, t as REPORT_TEMPLATES, o as buildReportName, p as describeExportStartError, u as exportStatusLabel, l as exportStatusTone, a as findReportTemplate, c as isTerminalExportStatus, i as resolveReportDateRange };
|
|
128
138
|
|
|
129
139
|
//# sourceMappingURL=reportTemplates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportTemplates.js","names":[],"sources":["../../../../src/timecampus/pages/dashboard/reportTemplates.ts"],"sourcesContent":["/**\n * Server-side report templates for the Reports page (BOFF-4043).\n *\n * Each template maps to TimeCampus entity types that wspace-export-svc can\n * export; the backend (`exportTimeCampusEntities`) rejects anything else.\n */\n\nexport type ReportTemplateId =\n \"time-entries\" | \"projects\" | \"expenses\" | \"team\" | \"focus\" | \"meetings\";\n\nexport interface ReportTemplate {\n id: ReportTemplateId;\n label: string;\n description: string;\n entityTypes: string[];\n}\n\nexport const REPORT_TEMPLATES: readonly ReportTemplate[] = [\n {\n id: \"time-entries\",\n label: \"Time entries\",\n description:\n \"Every logged entry with project, task, duration and billable flag.\",\n entityTypes: [\"timecampus_time_entries\"],\n },\n {\n id: \"projects\",\n label: \"Projects & tasks\",\n description: \"Projects, their tasks and the clients they belong to.\",\n entityTypes: [\n \"timecampus_projects\",\n \"timecampus_tasks\",\n \"timecampus_clients\",\n ],\n },\n {\n id: \"expenses\",\n label: \"Expenses\",\n description:\n \"Expense entries with amounts, categories and approval status.\",\n entityTypes: [\"timecampus_expense_entries\"],\n },\n {\n id: \"team\",\n label: \"Team & resourcing\",\n description:\n \"Resource plans, allocations and timesheet approval requests for the team.\",\n entityTypes: [\n \"timecampus_resource_plans\",\n \"timecampus_resource_allocations\",\n \"timecampus_time_approval_requests\",\n ],\n },\n {\n id: \"focus\",\n label: \"Focus & productivity\",\n description:\n \"Pomodoro sessions, focus scores, work patterns and application usage.\",\n entityTypes: [\n \"timecampus_pomodoro_sessions\",\n \"timecampus_focus_scores\",\n \"timecampus_work_patterns\",\n \"timecampus_application_usages\",\n ],\n },\n {\n id: \"meetings\",\n label: \"Meetings\",\n description: \"Meetings with participants and action items.\",\n entityTypes: [\n \"timecampus_meeting_metas\",\n \"timecampus_meeting_participants\",\n \"timecampus_meeting_action_items\",\n ],\n },\n];\n\nexport type ReportPeriodId = \"7d\" | \"30d\" | \"90d\" | \"ytd\" | \"all\";\n\nexport const REPORT_PERIODS: ReadonlyArray<{\n id: ReportPeriodId;\n label: string;\n}> = [\n { id: \"7d\", label: \"Last 7 days\" },\n { id: \"30d\", label: \"Last 30 days\" },\n { id: \"90d\", label: \"Last 90 days\" },\n { id: \"ytd\", label: \"This year\" },\n { id: \"all\", label: \"All time\" },\n];\n\nexport interface ReportDateRange {\n dateRangeStart?: string;\n dateRangeEnd?: string;\n}\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\n/** Resolve a period into the ISO date range sent to the export mutation. */\nexport function resolveReportDateRange(\n period: ReportPeriodId,\n now: Date = new Date(),\n): ReportDateRange {\n if (period === \"all\") return {};\n const end = now.toISOString();\n if (period === \"ytd\") {\n const start = new Date(now.getFullYear(), 0, 1);\n return { dateRangeStart: start.toISOString(), dateRangeEnd: end };\n }\n const days = period === \"7d\" ? 7 : period === \"30d\" ? 30 : 90;\n return {\n dateRangeStart: new Date(now.getTime() - days * DAY_MS).toISOString(),\n dateRangeEnd: end,\n };\n}\n\nexport function findReportTemplate(id: ReportTemplateId): ReportTemplate {\n const template = REPORT_TEMPLATES.find((t) => t.id === id);\n if (!template) throw new Error(`Unknown report template: ${id}`);\n return template;\n}\n\nexport function buildReportName(\n template: ReportTemplate,\n period: ReportPeriodId,\n): string {\n const periodLabel =\n REPORT_PERIODS.find((p) => p.id === period)?.label ?? \"All time\";\n return `${template.label} report — ${periodLabel}`;\n}\n\nconst TERMINAL_STATUSES = new Set([\n \"COMPLETED\",\n \"FAILED\",\n \"CANCELLED\",\n \"EXPIRED\",\n \"DELETED\",\n]);\n\n/** True once an export job will not change status again. */\nexport function isTerminalExportStatus(status: string | null | undefined) {\n return !!status && TERMINAL_STATUSES.has(status);\n}\n\nexport type ExportStatusTone = \"info\" | \"success\" | \"warning\" | \"error\";\n\nexport function exportStatusTone(status: string): ExportStatusTone {\n if (status === \"COMPLETED\") return \"success\";\n if (status === \"FAILED\") return \"error\";\n if (TERMINAL_STATUSES.has(status)) return \"warning\";\n return \"info\";\n}\n\nexport function exportStatusLabel(status: string): string {\n switch (status) {\n case \"CREATED\":\n case \"QUEUED\":\n return \"Queued\";\n case \"RUNNING\":\n return \"Generating\";\n case \"COMPLETED\":\n return \"Ready\";\n case \"FAILED\":\n return \"Failed\";\n case \"CANCELLED\":\n return \"Cancelled\";\n case \"EXPIRED\":\n return \"Link expired\";\n case \"DELETED\":\n return \"Deleted\";\n default:\n return status;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"reportTemplates.js","names":[],"sources":["../../../../src/timecampus/pages/dashboard/reportTemplates.ts"],"sourcesContent":["/**\n * Server-side report templates for the Reports page (BOFF-4043).\n *\n * Each template maps to TimeCampus entity types that wspace-export-svc can\n * export; the backend (`exportTimeCampusEntities`) rejects anything else.\n */\n\nimport { extractBackendError } from \"@burdenoff/fe-libs/shared/utils\";\n\nexport type ReportTemplateId =\n \"time-entries\" | \"projects\" | \"expenses\" | \"team\" | \"focus\" | \"meetings\";\n\nexport interface ReportTemplate {\n id: ReportTemplateId;\n label: string;\n description: string;\n entityTypes: string[];\n}\n\nexport const REPORT_TEMPLATES: readonly ReportTemplate[] = [\n {\n id: \"time-entries\",\n label: \"Time entries\",\n description:\n \"Every logged entry with project, task, duration and billable flag.\",\n entityTypes: [\"timecampus_time_entries\"],\n },\n {\n id: \"projects\",\n label: \"Projects & tasks\",\n description: \"Projects, their tasks and the clients they belong to.\",\n entityTypes: [\n \"timecampus_projects\",\n \"timecampus_tasks\",\n \"timecampus_clients\",\n ],\n },\n {\n id: \"expenses\",\n label: \"Expenses\",\n description:\n \"Expense entries with amounts, categories and approval status.\",\n entityTypes: [\"timecampus_expense_entries\"],\n },\n {\n id: \"team\",\n label: \"Team & resourcing\",\n description:\n \"Resource plans, allocations and timesheet approval requests for the team.\",\n entityTypes: [\n \"timecampus_resource_plans\",\n \"timecampus_resource_allocations\",\n \"timecampus_time_approval_requests\",\n ],\n },\n {\n id: \"focus\",\n label: \"Focus & productivity\",\n description:\n \"Pomodoro sessions, focus scores, work patterns and application usage.\",\n entityTypes: [\n \"timecampus_pomodoro_sessions\",\n \"timecampus_focus_scores\",\n \"timecampus_work_patterns\",\n \"timecampus_application_usages\",\n ],\n },\n {\n id: \"meetings\",\n label: \"Meetings\",\n description: \"Meetings with participants and action items.\",\n entityTypes: [\n \"timecampus_meeting_metas\",\n \"timecampus_meeting_participants\",\n \"timecampus_meeting_action_items\",\n ],\n },\n];\n\nexport type ReportPeriodId = \"7d\" | \"30d\" | \"90d\" | \"ytd\" | \"all\";\n\nexport const REPORT_PERIODS: ReadonlyArray<{\n id: ReportPeriodId;\n label: string;\n}> = [\n { id: \"7d\", label: \"Last 7 days\" },\n { id: \"30d\", label: \"Last 30 days\" },\n { id: \"90d\", label: \"Last 90 days\" },\n { id: \"ytd\", label: \"This year\" },\n { id: \"all\", label: \"All time\" },\n];\n\nexport interface ReportDateRange {\n dateRangeStart?: string;\n dateRangeEnd?: string;\n}\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\n/** Resolve a period into the ISO date range sent to the export mutation. */\nexport function resolveReportDateRange(\n period: ReportPeriodId,\n now: Date = new Date(),\n): ReportDateRange {\n if (period === \"all\") return {};\n const end = now.toISOString();\n if (period === \"ytd\") {\n const start = new Date(now.getFullYear(), 0, 1);\n return { dateRangeStart: start.toISOString(), dateRangeEnd: end };\n }\n const days = period === \"7d\" ? 7 : period === \"30d\" ? 30 : 90;\n return {\n dateRangeStart: new Date(now.getTime() - days * DAY_MS).toISOString(),\n dateRangeEnd: end,\n };\n}\n\nexport function findReportTemplate(id: ReportTemplateId): ReportTemplate {\n const template = REPORT_TEMPLATES.find((t) => t.id === id);\n if (!template) throw new Error(`Unknown report template: ${id}`);\n return template;\n}\n\nexport function buildReportName(\n template: ReportTemplate,\n period: ReportPeriodId,\n): string {\n const periodLabel =\n REPORT_PERIODS.find((p) => p.id === period)?.label ?? \"All time\";\n return `${template.label} report — ${periodLabel}`;\n}\n\nconst TERMINAL_STATUSES = new Set([\n \"COMPLETED\",\n \"FAILED\",\n \"CANCELLED\",\n \"EXPIRED\",\n \"DELETED\",\n]);\n\n/** True once an export job will not change status again. */\nexport function isTerminalExportStatus(status: string | null | undefined) {\n return !!status && TERMINAL_STATUSES.has(status);\n}\n\nexport type ExportStatusTone = \"info\" | \"success\" | \"warning\" | \"error\";\n\nexport function exportStatusTone(status: string): ExportStatusTone {\n if (status === \"COMPLETED\") return \"success\";\n if (status === \"FAILED\") return \"error\";\n if (TERMINAL_STATUSES.has(status)) return \"warning\";\n return \"info\";\n}\n\nexport function exportStatusLabel(status: string): string {\n switch (status) {\n case \"CREATED\":\n case \"QUEUED\":\n return \"Queued\";\n case \"RUNNING\":\n return \"Generating\";\n case \"COMPLETED\":\n return \"Ready\";\n case \"FAILED\":\n return \"Failed\";\n case \"CANCELLED\":\n return \"Cancelled\";\n case \"EXPIRED\":\n return \"Link expired\";\n case \"DELETED\":\n return \"Deleted\";\n default:\n return status;\n }\n}\n\nexport const EXPORT_START_FALLBACK_MESSAGE =\n \"The export could not be started. Please try again.\";\n\n/**\n * Plan-limit codes the gateway's `@usage` check returns for\n * `exportTimeCampusEntities`. Each needs its own wording: \"please try again\"\n * is wrong for both, because retrying cannot succeed until the plan changes\n * (or, for an exhausted monthly allowance, the month rolls over).\n */\nconst EXPORT_QUOTA_MESSAGES: Readonly<Record<string, string>> = {\n QUOTA_NOT_PROVISIONED:\n \"Full reports are not included in this workspace's TimeCampus plan. Upgrade the plan in Billing to generate them.\",\n QUOTA_EXHAUSTED:\n \"This workspace has used all of its full reports for this month. Upgrade the plan in Billing or try again next month.\",\n QUOTA_EXCEEDED:\n \"This workspace has used all of its full reports for this month. Upgrade the plan in Billing or try again next month.\",\n};\n\n/**\n * User-facing message for a failed `exportTimeCampusEntities` call. The\n * TimeCampus Apollo client uses `errorPolicy: \"all\"`, so a GraphQL error\n * arrives on `result.error` rather than as a thrown exception; both shapes\n * are accepted here.\n */\nexport function describeExportStartError(error: unknown): string {\n const display = extractBackendError(error);\n if (!display) return EXPORT_START_FALLBACK_MESSAGE;\n const quotaMessage = display.code\n ? EXPORT_QUOTA_MESSAGES[display.code]\n : undefined;\n if (quotaMessage) return quotaMessage;\n return display.message || EXPORT_START_FALLBACK_MESSAGE;\n}\n"],"mappings":";;AAmBA,IAAa,IAA8C;CACzD;EACE,IAAI;EACJ,OAAO;EACP,aACE;EACF,aAAa,CAAC,yBAAyB;CACzC;CACA;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,aAAa;GACX;GACA;GACA;EACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,aACE;EACF,aAAa,CAAC,4BAA4B;CAC5C;CACA;EACE,IAAI;EACJ,OAAO;EACP,aACE;EACF,aAAa;GACX;GACA;GACA;EACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,aACE;EACF,aAAa;GACX;GACA;GACA;GACA;EACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,aAAa;GACX;GACA;GACA;EACF;CACF;AACF,GAIa,IAGR;CACH;EAAE,IAAI;EAAM,OAAO;CAAc;CACjC;EAAE,IAAI;EAAO,OAAO;CAAe;CACnC;EAAE,IAAI;EAAO,OAAO;CAAe;CACnC;EAAE,IAAI;EAAO,OAAO;CAAY;CAChC;EAAE,IAAI;EAAO,OAAO;CAAW;AACjC,GAOM,IAAS;AAGf,SAAgB,EACd,GACA,oBAAY,IAAI,KAAK,GACJ;CACjB,IAAI,MAAW,OAAO,OAAO,CAAC;CAC9B,IAAM,IAAM,EAAI,YAAY;CAC5B,IAAI,MAAW,OAEb,OAAO;EAAE,gBAAgB,IADP,KAAK,EAAI,YAAY,GAAG,GAAG,CACpB,CAAA,CAAM,YAAY;EAAG,cAAc;CAAI;CAElE,IAAM,IAAO,MAAW,OAAO,IAAI,MAAW,QAAQ,KAAK;CAC3D,OAAO;EACL,iCAAgB,IAAI,KAAK,EAAI,QAAQ,IAAI,IAAO,CAAM,EAAA,CAAE,YAAY;EACpE,cAAc;CAChB;AACF;AAEA,SAAgB,EAAmB,GAAsC;CACvE,IAAM,IAAW,EAAiB,MAAM,MAAM,EAAE,OAAO,CAAE;CACzD,IAAI,CAAC,GAAU,MAAU,MAAM,4BAA4B,GAAI;CAC/D,OAAO;AACT;AAEA,SAAgB,EACd,GACA,GACQ;CACR,IAAM,IACJ,EAAe,MAAM,MAAM,EAAE,OAAO,CAAM,CAAC,EAAE,SAAS;CACxD,OAAO,GAAG,EAAS,MAAM,YAAY;AACvC;AAEA,IAAM,oBAAoB,IAAI,IAAI;CAChC;CACA;CACA;CACA;CACA;AACF,CAAC;AAGD,SAAgB,EAAuB,GAAmC;CACxE,OAAO,CAAC,CAAC,KAAU,EAAkB,IAAI,CAAM;AACjD;AAIA,SAAgB,EAAiB,GAAkC;CAIjE,OAHI,MAAW,cAAoB,YAC/B,MAAW,WAAiB,UAC5B,EAAkB,IAAI,CAAM,IAAU,YACnC;AACT;AAEA,SAAgB,EAAkB,GAAwB;CACxD,QAAQ,GAAR;EACE,KAAK;EACL,KAAK,UACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,IAAa,IACX,sDAQI,IAA0D;CAC9D,uBACE;CACF,iBACE;CACF,gBACE;AACJ;AAQA,SAAgB,EAAyB,GAAwB;CAC/D,IAAM,IAAU,EAAoB,CAAK;CAMzC,OALK,KACgB,EAAQ,OACzB,EAAsB,EAAQ,QAC9B,KAAA,MAEG,EAAQ,WAAA,uDALM;AAMvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeTriggersPage.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/extend/TimeTriggersPage.tsx"],"names":[],"mappings":"AAqVA,wBAAgB,gBAAgB,gCA0Y/B"}
|