@burdenoff/microfe-support 2026.817.3 → 2026.819.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-operations.d.ts +237 -0
- package/dist/generated/global-operations.js +341 -227
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.d.ts +165 -17
- package/dist/generated/global-types.js.map +1 -1
- package/dist/node_modules/clsx/dist/clsx.js +7 -5
- package/dist/node_modules/clsx/dist/clsx.js.map +1 -1
- package/dist/node_modules/dompurify/dist/purify.es.js +399 -304
- package/dist/node_modules/dompurify/dist/purify.es.js.map +1 -1
- package/dist/node_modules/marked/lib/marked.esm.js +23 -17
- package/dist/node_modules/marked/lib/marked.esm.js.map +1 -1
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +130 -130
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -1
- package/dist/support/SupportAdminRoot.js +4 -2
- package/dist/support/SupportAdminRoot.js.map +1 -1
- package/dist/support/SupportAdminRoutes.js +2 -2
- package/dist/support/SupportAdminRoutes.js.map +1 -1
- package/dist/support/SupportUserRoot.js +4 -2
- package/dist/support/SupportUserRoot.js.map +1 -1
- package/dist/support/SupportUserRoutes.js +2 -2
- package/dist/support/SupportUserRoutes.js.map +1 -1
- package/dist/support/components/NotificationToast.js.map +1 -1
- package/dist/support/components/PageLayout.js.map +1 -1
- package/dist/support/components/RouteHelpers.js.map +1 -1
- package/dist/support/components/analytics/CategoryBreakdown.js.map +1 -1
- package/dist/support/components/analytics/MetricCard.js.map +1 -1
- package/dist/support/components/analytics/PriorityBreakdown.js.map +1 -1
- package/dist/support/components/analytics/SLAReport.js.map +1 -1
- package/dist/support/components/analytics/SatisfactionDistribution.js.map +1 -1
- package/dist/support/components/analytics/TopAgents.js.map +1 -1
- package/dist/support/components/analytics/TrendChart.js +5 -5
- package/dist/support/components/analytics/TrendChart.js.map +1 -1
- package/dist/support/components/careers/BulkCandidateActionGuidance.d.ts +6 -0
- package/dist/support/components/careers/BulkCandidateActionGuidance.js +28 -0
- package/dist/support/components/careers/BulkCandidateActionGuidance.js.map +1 -0
- package/dist/support/components/careers/BulkCandidateDialogs.d.ts +18 -0
- package/dist/support/components/careers/BulkCandidateDialogs.js +441 -0
- package/dist/support/components/careers/BulkCandidateDialogs.js.map +1 -0
- package/dist/support/components/careers/BulkOperationFeedback.d.ts +21 -0
- package/dist/support/components/careers/BulkOperationFeedback.js +194 -0
- package/dist/support/components/careers/BulkOperationFeedback.js.map +1 -0
- package/dist/support/components/careers/BulkSelectionSummary.d.ts +6 -0
- package/dist/support/components/careers/BulkSelectionSummary.js +15 -0
- package/dist/support/components/careers/BulkSelectionSummary.js.map +1 -0
- package/dist/support/components/kb/ArticleForm.js.map +1 -1
- package/dist/support/components/settings/CannedResponsesSettings.js.map +1 -1
- package/dist/support/components/settings/SLAPoliciesSettings.js.map +1 -1
- package/dist/support/components/settings/TicketCategoriesSettings.js.map +1 -1
- package/dist/support/components/tickets/AttachmentList.js.map +1 -1
- package/dist/support/components/tickets/MarkdownContent.js.map +1 -1
- package/dist/support/components/tickets/MessageComposer.js +2 -2
- package/dist/support/components/tickets/MessageComposer.js.map +1 -1
- package/dist/support/components/tickets/MessageThread.js +1 -1
- package/dist/support/components/tickets/MessageThread.js.map +1 -1
- package/dist/support/components/tickets/TicketDetailHeader.js.map +1 -1
- package/dist/support/components/tickets/TicketHeader.js.map +1 -1
- package/dist/support/components/tickets/TicketSidebar.js.map +1 -1
- package/dist/support/components/ui.d.ts +1 -1
- package/dist/support/components/ui.js +2 -2
- package/dist/support/constants/pipeline.d.ts +15 -0
- package/dist/support/constants/pipeline.js +73 -0
- package/dist/support/constants/pipeline.js.map +1 -0
- package/dist/support/events/rybbit.js.map +1 -1
- package/dist/support/hooks/index.js +6 -5
- package/dist/support/hooks/useAnalyticsOperations.js +1 -1
- package/dist/support/hooks/useAnalyticsOperations.js.map +1 -1
- package/dist/support/hooks/useAttachmentsFailedToast.js.map +1 -1
- package/dist/support/hooks/useChatOperations.js +7 -7
- package/dist/support/hooks/useChatOperations.js.map +1 -1
- package/dist/support/hooks/useKnowledgeBaseOperations.js.map +1 -1
- package/dist/support/hooks/useNotification.js.map +1 -1
- package/dist/support/hooks/useRegisterFooter.js.map +1 -1
- package/dist/support/hooks/useSettingsOperations.js.map +1 -1
- package/dist/support/hooks/useSupportAttachments.js.map +1 -1
- package/dist/support/hooks/useTicketListOperations.js.map +1 -1
- package/dist/support/hooks/useTicketOperations.js +76 -75
- package/dist/support/hooks/useTicketOperations.js.map +1 -1
- package/dist/support/index.js +11 -10
- package/dist/support/pages/AnalyticsPage.js.map +1 -1
- package/dist/support/pages/ArticleDetailAdminPage.js +1 -1
- package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
- package/dist/support/pages/ArticleDetailUserPage.js +1 -1
- package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
- package/dist/support/pages/ContactInquiriesPage.js.map +1 -1
- package/dist/support/pages/ContactInquiryDetailPage.js +4 -1
- package/dist/support/pages/ContactInquiryDetailPage.js.map +1 -1
- package/dist/support/pages/CreateArticlePage.js.map +1 -1
- package/dist/support/pages/CreateTicketPage.js +4 -3
- package/dist/support/pages/CreateTicketPage.js.map +1 -1
- package/dist/support/pages/EditArticlePage.js.map +1 -1
- package/dist/support/pages/InterviewersPage.js +127 -127
- package/dist/support/pages/InterviewersPage.js.map +1 -1
- package/dist/support/pages/JobApplicationDetailPage.js +627 -587
- package/dist/support/pages/JobApplicationDetailPage.js.map +1 -1
- package/dist/support/pages/JobApplicationsPage.js +652 -404
- package/dist/support/pages/JobApplicationsPage.js.map +1 -1
- package/dist/support/pages/JobPostingDetailPage.js +42 -5
- package/dist/support/pages/JobPostingDetailPage.js.map +1 -1
- package/dist/support/pages/JobPostingsPage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseAdminPage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
- package/dist/support/pages/SettingsPage.js.map +1 -1
- package/dist/support/pages/TicketDetailAdminPage.js +4 -1
- package/dist/support/pages/TicketDetailAdminPage.js.map +1 -1
- package/dist/support/pages/TicketDetailUserPage.js +4 -1
- package/dist/support/pages/TicketDetailUserPage.js.map +1 -1
- package/dist/support/pages/TicketListPage.js.map +1 -1
- package/dist/support/providers/SupportProvider.js.map +1 -1
- package/dist/support/store/supportStore.js.map +1 -1
- package/dist/support/utils/attachments.js +3 -3
- package/dist/support/utils/attachments.js.map +1 -1
- package/dist/support/utils/breadcrumbRegistry.js.map +1 -1
- package/dist/support/utils/bulkCandidateOperations.d.ts +174 -0
- package/dist/support/utils/bulkCandidateOperations.js +265 -0
- package/dist/support/utils/bulkCandidateOperations.js.map +1 -0
- package/dist/support/utils/categoryColors.js.map +1 -1
- package/dist/support/utils/cn.js +1 -1
- package/dist/support/utils/cn.js.map +1 -1
- package/dist/support/utils/context.js.map +1 -1
- package/dist/support/utils/errors.js.map +1 -1
- package/dist/support/utils/i18n.js.map +1 -1
- package/dist/support/utils/index.js +1 -1
- package/dist/support/utils/index.js.map +1 -1
- package/dist/support/utils/markdown.js +2 -2
- package/dist/support/utils/markdown.js.map +1 -1
- package/dist/support/utils/supportFiles.js.map +1 -1
- package/dist/support/utils/ticketFilters.js.map +1 -1
- package/dist/support/utils/uiTokens.js.map +1 -1
- package/package.json +23 -12
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
var e = class extends Error {
|
|
2
|
+
code;
|
|
3
|
+
constructor(e, t) {
|
|
4
|
+
super(t), this.code = e, this.name = "CandidateMaterializationError";
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
function t(t, n) {
|
|
8
|
+
if (t !== n) throw new e("STALE_SCOPE", "The application filters changed while candidates were loading.");
|
|
9
|
+
}
|
|
10
|
+
async function n({ scopeKey: n, expectedTotal: r, fetchPage: i, getCurrentScopeKey: a, pageSize: o }) {
|
|
11
|
+
let s = /* @__PURE__ */ new Map(), c = 0;
|
|
12
|
+
for (;;) {
|
|
13
|
+
t(n, a());
|
|
14
|
+
let l = await i(o, c);
|
|
15
|
+
if (t(n, a()), l.total !== r) throw new e("TOTAL_DRIFT", `The matching application total changed from ${r} to ${l.total}. Refresh and select again.`);
|
|
16
|
+
let u = l.items.length;
|
|
17
|
+
if (u > o) throw new e("INVALID_PAGE_LENGTH", `The server returned ${u} applications for a page limited to ${o}.`);
|
|
18
|
+
if (l.hasMore && u === 0) throw new e("EMPTY_PAGE_WITH_MORE", "The server reported more applications but returned an empty page.");
|
|
19
|
+
for (let e of l.items) s.has(e.id) || s.set(e.id, e);
|
|
20
|
+
if (c += u, !l.hasMore) {
|
|
21
|
+
if (s.size !== r) throw new e("UNIQUE_COUNT_MISMATCH", `Expected ${r} unique applications but loaded ${s.size}. Refresh and select again.`);
|
|
22
|
+
return [...s.values()];
|
|
23
|
+
}
|
|
24
|
+
if (c >= r) throw new e("TOTAL_DRIFT", "The server reported more applications after the frozen total had already been loaded.");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function r({ scopeKey: t, expectedTotal: r, fetchPage: i, getCurrentScopeKey: a, pageSize: o = 100 }) {
|
|
28
|
+
if (!Number.isInteger(r) || r < 0) throw new e("TOTAL_DRIFT", "The application total is invalid. Refresh the list and try again.");
|
|
29
|
+
if (!Number.isInteger(o) || o <= 0) throw new e("INVALID_PAGE_LENGTH", "The candidate page size must be a positive integer.");
|
|
30
|
+
let s = {
|
|
31
|
+
scopeKey: t,
|
|
32
|
+
expectedTotal: r,
|
|
33
|
+
fetchPage: i,
|
|
34
|
+
getCurrentScopeKey: a,
|
|
35
|
+
pageSize: o
|
|
36
|
+
}, c = await n(s), l = await n(s);
|
|
37
|
+
if (JSON.stringify(c) !== JSON.stringify(l)) throw new e("MEMBERSHIP_DRIFT", "Matching applications changed while candidates were loading. Refresh and select again.");
|
|
38
|
+
return l;
|
|
39
|
+
}
|
|
40
|
+
async function i({ scopeKey: t, applicationIds: n, fetchChunkPage: i, getCurrentScopeKey: a }) {
|
|
41
|
+
if (n.length === 0) return [];
|
|
42
|
+
if (new Set(n).size !== n.length) throw new e("UNIQUE_COUNT_MISMATCH", "Selected applications must have unique IDs.");
|
|
43
|
+
let o = /* @__PURE__ */ new Map();
|
|
44
|
+
for (let e of g(n)) {
|
|
45
|
+
let n = await r({
|
|
46
|
+
scopeKey: t,
|
|
47
|
+
expectedTotal: e.length,
|
|
48
|
+
getCurrentScopeKey: a,
|
|
49
|
+
fetchPage: (t, n) => i(e, t, n)
|
|
50
|
+
});
|
|
51
|
+
for (let e of n) o.set(e.id, e);
|
|
52
|
+
}
|
|
53
|
+
return n.map((t) => {
|
|
54
|
+
let n = o.get(t);
|
|
55
|
+
if (!n) throw new e("UNIQUE_COUNT_MISMATCH", "A selected application was not returned by its bounded validation query.");
|
|
56
|
+
return n;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function a() {
|
|
60
|
+
return {
|
|
61
|
+
mode: "explicit",
|
|
62
|
+
explicitIds: /* @__PURE__ */ new Set(),
|
|
63
|
+
allTargetIds: /* @__PURE__ */ new Set(),
|
|
64
|
+
excludedIds: /* @__PURE__ */ new Set()
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function o(e) {
|
|
68
|
+
return {
|
|
69
|
+
mode: "all",
|
|
70
|
+
explicitIds: /* @__PURE__ */ new Set(),
|
|
71
|
+
allTargetIds: new Set(e),
|
|
72
|
+
excludedIds: /* @__PURE__ */ new Set()
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function s(e) {
|
|
76
|
+
if (e.mode === "explicit") return new Set(e.explicitIds);
|
|
77
|
+
let t = new Set(e.allTargetIds);
|
|
78
|
+
for (let n of e.excludedIds) t.delete(n);
|
|
79
|
+
return t;
|
|
80
|
+
}
|
|
81
|
+
function c(e) {
|
|
82
|
+
return s(e).size;
|
|
83
|
+
}
|
|
84
|
+
function l(e, t) {
|
|
85
|
+
if (e.mode === "all") {
|
|
86
|
+
if (!e.allTargetIds.has(t)) return e;
|
|
87
|
+
let n = new Set(e.excludedIds);
|
|
88
|
+
return n.has(t) ? n.delete(t) : n.add(t), {
|
|
89
|
+
...e,
|
|
90
|
+
excludedIds: n
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
let n = new Set(e.explicitIds);
|
|
94
|
+
return n.has(t) ? n.delete(t) : n.add(t), {
|
|
95
|
+
...e,
|
|
96
|
+
explicitIds: n
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function u(e, t, n) {
|
|
100
|
+
if (e.mode === "all") {
|
|
101
|
+
let r = new Set(e.excludedIds);
|
|
102
|
+
for (let i of t) e.allTargetIds.has(i) && (n ? r.delete(i) : r.add(i));
|
|
103
|
+
return {
|
|
104
|
+
...e,
|
|
105
|
+
excludedIds: r
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
let r = new Set(e.explicitIds);
|
|
109
|
+
for (let e of t) n ? r.add(e) : r.delete(e);
|
|
110
|
+
return {
|
|
111
|
+
...e,
|
|
112
|
+
explicitIds: r
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function d(e) {
|
|
116
|
+
let t = c(e);
|
|
117
|
+
if (t === 0) return null;
|
|
118
|
+
if (e.mode === "all") {
|
|
119
|
+
let n = e.allTargetIds.size, r = n - t;
|
|
120
|
+
return r === 0 ? `All ${n} matching applications selected` : `${t} of ${n} matching applications selected (${r} excluded)`;
|
|
121
|
+
}
|
|
122
|
+
return `${t} ${t === 1 ? "application" : "applications"} selected`;
|
|
123
|
+
}
|
|
124
|
+
function f(e, t) {
|
|
125
|
+
let n = [], r = [];
|
|
126
|
+
for (let i of e) {
|
|
127
|
+
let e = i.interviewRounds.filter((e) => e.roundConfigId === t);
|
|
128
|
+
if (e.length !== 1) {
|
|
129
|
+
r.push({
|
|
130
|
+
target: i,
|
|
131
|
+
reason: e.length === 0 ? "MISSING" : "AMBIGUOUS"
|
|
132
|
+
});
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
let a = e[0];
|
|
136
|
+
n.push({
|
|
137
|
+
applicationId: i.id,
|
|
138
|
+
roundId: a.id,
|
|
139
|
+
target: i,
|
|
140
|
+
round: a
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
pairs: n,
|
|
145
|
+
unresolved: r
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
var p = class extends Error {
|
|
149
|
+
constructor(e) {
|
|
150
|
+
super(e), this.name = "CandidateChunkPreconditionError";
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
function m(e, t, n) {
|
|
154
|
+
let r = new Map(t.map((e) => [e.id, e]));
|
|
155
|
+
for (let t of e) {
|
|
156
|
+
let e = r.get(t);
|
|
157
|
+
if (!e || e.jobPostingId !== n) throw new p("A selected application no longer matches the frozen filter and posting. No request was sent for this chunk.");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function h(e, t, n, r) {
|
|
161
|
+
m(e.map((e) => e.applicationId), t, n);
|
|
162
|
+
let i = new Map(t.map((e) => [e.id, e]));
|
|
163
|
+
for (let t of e) {
|
|
164
|
+
let e = i.get(t.applicationId)?.interviewRounds.filter((e) => e.roundConfigId === r);
|
|
165
|
+
if (e?.length !== 1 || e[0]?.id !== t.roundId) throw new p("A selected candidate round changed after preview. No request was sent for this chunk.");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function g(e, t = 100) {
|
|
169
|
+
if (!Number.isInteger(t) || t <= 0) throw Error("Chunk size must be a positive integer.");
|
|
170
|
+
let n = [];
|
|
171
|
+
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
172
|
+
return n;
|
|
173
|
+
}
|
|
174
|
+
async function _({ items: e, initialAggregate: t, executeChunk: n, mergeResult: r, onProgress: i, chunkSize: a = 100 }) {
|
|
175
|
+
let o = g(e, a), s = [], c = t;
|
|
176
|
+
i?.({
|
|
177
|
+
processed: 0,
|
|
178
|
+
total: e.length
|
|
179
|
+
});
|
|
180
|
+
for (let t = 0; t < o.length; t += 1) {
|
|
181
|
+
let a = o[t];
|
|
182
|
+
try {
|
|
183
|
+
let o = await n(a, t);
|
|
184
|
+
c = r(c, o), s.push(...a), i?.({
|
|
185
|
+
processed: s.length,
|
|
186
|
+
total: e.length
|
|
187
|
+
});
|
|
188
|
+
} catch (e) {
|
|
189
|
+
let n = e instanceof p;
|
|
190
|
+
return {
|
|
191
|
+
aggregate: c,
|
|
192
|
+
processedItems: s,
|
|
193
|
+
ambiguousItems: n ? [] : [...a],
|
|
194
|
+
notStartedItems: n ? o.slice(t).flat() : o.slice(t + 1).flat(),
|
|
195
|
+
error: e
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
aggregate: c,
|
|
201
|
+
processedItems: s,
|
|
202
|
+
ambiguousItems: [],
|
|
203
|
+
notStartedItems: [],
|
|
204
|
+
error: null
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function v({ succeeded: e, skipped: t, failed: n, ambiguous: r = !1 }) {
|
|
208
|
+
return r || n > 0 && e === 0 && t === 0 ? "error" : n > 0 || t > 0 ? "warning" : "success";
|
|
209
|
+
}
|
|
210
|
+
function y() {
|
|
211
|
+
return {
|
|
212
|
+
succeeded: [],
|
|
213
|
+
skipped: [],
|
|
214
|
+
failed: []
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function b(e, t) {
|
|
218
|
+
return `${e}\0${t}`;
|
|
219
|
+
}
|
|
220
|
+
function x(e, t, n) {
|
|
221
|
+
let r = new Set(e), i = new Set(t);
|
|
222
|
+
if (r.size !== e.length || i.size !== t.length || r.size !== i.size || [...r].some((e) => !i.has(e))) throw Error(`${n} returned an incomplete, duplicate, or unexpected item result. The current chunk is ambiguous and later chunks were stopped.`);
|
|
223
|
+
}
|
|
224
|
+
function S(e, t) {
|
|
225
|
+
x(e.map((e) => b(e.applicationId, e.roundId)), [
|
|
226
|
+
...t.succeeded.map((e) => b(e.applicationId, e.roundId)),
|
|
227
|
+
...t.skipped.map((e) => b(e.applicationId, e.roundId)),
|
|
228
|
+
...t.failed.map((e) => b(e.applicationId, e.roundId))
|
|
229
|
+
], "The candidate email request");
|
|
230
|
+
}
|
|
231
|
+
function C(e, t) {
|
|
232
|
+
return {
|
|
233
|
+
succeeded: [...e.succeeded, ...t.succeeded],
|
|
234
|
+
skipped: [...e.skipped, ...t.skipped],
|
|
235
|
+
failed: [...e.failed, ...t.failed]
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function w() {
|
|
239
|
+
return {
|
|
240
|
+
created: [],
|
|
241
|
+
alreadyPresent: [],
|
|
242
|
+
failed: []
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function T(e, t) {
|
|
246
|
+
x(e, [
|
|
247
|
+
...t.created.map((e) => e.applicationId),
|
|
248
|
+
...t.alreadyPresent.map((e) => e.applicationId),
|
|
249
|
+
...t.failed.map((e) => e.applicationId)
|
|
250
|
+
], "The add-to-round request");
|
|
251
|
+
}
|
|
252
|
+
function E(e, t) {
|
|
253
|
+
return {
|
|
254
|
+
created: [...e.created, ...t.created],
|
|
255
|
+
alreadyPresent: [...e.alreadyPresent, ...t.alreadyPresent],
|
|
256
|
+
failed: [...e.failed, ...t.failed]
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function D(e, t) {
|
|
260
|
+
return e.emailLogs.some((e) => e.emailType === t);
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
export { p as CandidateChunkPreconditionError, e as CandidateMaterializationError, C as aggregateCandidateEmailResult, E as aggregateEnsureRoundResult, m as assertCandidateChunkMatchesCurrentScope, h as assertCandidateEmailChunkMatchesCurrentScope, S as assertCompleteCandidateEmailChunkResult, T as assertCompleteEnsureRoundChunkResult, g as chunkCandidateRequests, y as createEmptyCandidateEmailAggregate, a as createEmptyCandidateSelection, w as createEmptyEnsureRoundAggregate, _ as executeSequentialCandidateChunks, v as getBulkOperationNotificationSeverity, c as getCandidateSelectionCount, d as getCandidateSelectionSummary, s as getSelectedCandidateIds, D as hasCandidateEmailType, r as materializeCandidateTargets, i as materializeCandidateTargetsByIds, f as resolveExactCandidateRounds, o as selectAllMaterializedCandidates, u as setVisibleCandidateSelection, l as toggleCandidateSelection };
|
|
264
|
+
|
|
265
|
+
//# sourceMappingURL=bulkCandidateOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bulkCandidateOperations.js","names":[],"sources":["../../../src/support/utils/bulkCandidateOperations.ts"],"sourcesContent":["export const BULK_CANDIDATE_REQUEST_LIMIT = 100;\n\nexport interface CandidateRoundPreview {\n id: string;\n roundConfigId: string | null;\n name: string;\n roundType: string;\n emailLogs: ReadonlyArray<{\n emailType: string;\n }>;\n}\n\nexport interface BulkCandidateTarget {\n id: string;\n jobPostingId: string | null;\n interviewRounds: ReadonlyArray<CandidateRoundPreview>;\n}\n\nexport interface CandidateTargetPage<TTarget extends { id: string }> {\n items: ReadonlyArray<TTarget>;\n total: number;\n hasMore: boolean;\n}\n\nexport type CandidateMaterializationErrorCode =\n | 'STALE_SCOPE'\n | 'TOTAL_DRIFT'\n | 'EMPTY_PAGE_WITH_MORE'\n | 'INVALID_PAGE_LENGTH'\n | 'UNIQUE_COUNT_MISMATCH'\n | 'MEMBERSHIP_DRIFT';\n\nexport class CandidateMaterializationError extends Error {\n constructor(\n public readonly code: CandidateMaterializationErrorCode,\n message: string\n ) {\n super(message);\n this.name = 'CandidateMaterializationError';\n }\n}\n\ninterface MaterializeCandidateTargetsOptions<TTarget extends { id: string }> {\n scopeKey: string;\n expectedTotal: number;\n fetchPage: (limit: number, offset: number) => Promise<CandidateTargetPage<TTarget>>;\n getCurrentScopeKey: () => string;\n pageSize?: number;\n}\n\nfunction assertCurrentScope(scopeKey: string, currentScopeKey: string): void {\n if (scopeKey !== currentScopeKey) {\n throw new CandidateMaterializationError(\n 'STALE_SCOPE',\n 'The application filters changed while candidates were loading.'\n );\n }\n}\n\nasync function materializeCandidateTargetPass<TTarget extends { id: string }>({\n scopeKey,\n expectedTotal,\n fetchPage,\n getCurrentScopeKey,\n pageSize,\n}: Required<MaterializeCandidateTargetsOptions<TTarget>>): Promise<TTarget[]> {\n const targetsById = new Map<string, TTarget>();\n let offset = 0;\n\n while (true) {\n assertCurrentScope(scopeKey, getCurrentScopeKey());\n const page = await fetchPage(pageSize, offset);\n assertCurrentScope(scopeKey, getCurrentScopeKey());\n\n if (page.total !== expectedTotal) {\n throw new CandidateMaterializationError(\n 'TOTAL_DRIFT',\n `The matching application total changed from ${expectedTotal} to ${page.total}. Refresh and select again.`\n );\n }\n\n const rawPageLength = page.items.length;\n if (rawPageLength > pageSize) {\n throw new CandidateMaterializationError(\n 'INVALID_PAGE_LENGTH',\n `The server returned ${rawPageLength} applications for a page limited to ${pageSize}.`\n );\n }\n if (page.hasMore && rawPageLength === 0) {\n throw new CandidateMaterializationError(\n 'EMPTY_PAGE_WITH_MORE',\n 'The server reported more applications but returned an empty page.'\n );\n }\n\n for (const target of page.items) {\n if (!targetsById.has(target.id)) {\n targetsById.set(target.id, target);\n }\n }\n\n offset += rawPageLength;\n\n if (!page.hasMore) {\n if (targetsById.size !== expectedTotal) {\n throw new CandidateMaterializationError(\n 'UNIQUE_COUNT_MISMATCH',\n `Expected ${expectedTotal} unique applications but loaded ${targetsById.size}. Refresh and select again.`\n );\n }\n return [...targetsById.values()];\n }\n\n if (offset >= expectedTotal) {\n throw new CandidateMaterializationError(\n 'TOTAL_DRIFT',\n 'The server reported more applications after the frozen total had already been loaded.'\n );\n }\n }\n}\n\n/**\n * Materializes a frozen application-filter scope without trusting cached pages.\n * Two independent passes must return the same ordered target snapshots. This\n * catches offset-page membership shifts while preserving the 100-item page cap.\n */\nexport async function materializeCandidateTargets<TTarget extends { id: string }>({\n scopeKey,\n expectedTotal,\n fetchPage,\n getCurrentScopeKey,\n pageSize = BULK_CANDIDATE_REQUEST_LIMIT,\n}: MaterializeCandidateTargetsOptions<TTarget>): Promise<TTarget[]> {\n if (!Number.isInteger(expectedTotal) || expectedTotal < 0) {\n throw new CandidateMaterializationError(\n 'TOTAL_DRIFT',\n 'The application total is invalid. Refresh the list and try again.'\n );\n }\n if (!Number.isInteger(pageSize) || pageSize <= 0) {\n throw new CandidateMaterializationError(\n 'INVALID_PAGE_LENGTH',\n 'The candidate page size must be a positive integer.'\n );\n }\n\n const options = {\n scopeKey,\n expectedTotal,\n fetchPage,\n getCurrentScopeKey,\n pageSize,\n };\n const firstPass = await materializeCandidateTargetPass(options);\n const secondPass = await materializeCandidateTargetPass(options);\n\n if (JSON.stringify(firstPass) !== JSON.stringify(secondPass)) {\n throw new CandidateMaterializationError(\n 'MEMBERSHIP_DRIFT',\n 'Matching applications changed while candidates were loading. Refresh and select again.'\n );\n }\n\n return secondPass;\n}\n\ninterface MaterializeCandidateTargetsByIdsOptions<TTarget extends { id: string }> {\n scopeKey: string;\n applicationIds: ReadonlyArray<string>;\n fetchChunkPage: (\n applicationIds: ReadonlyArray<string>,\n limit: number,\n offset: number\n ) => Promise<CandidateTargetPage<TTarget>>;\n getCurrentScopeKey: () => string;\n}\n\n/**\n * Revalidates selected candidates in bounded ID chunks. Each chunk is filtered\n * by both its IDs and the frozen list filter, so earlier mutations cannot make\n * later validation rescan or reinterpret the full result set.\n */\nexport async function materializeCandidateTargetsByIds<TTarget extends { id: string }>({\n scopeKey,\n applicationIds,\n fetchChunkPage,\n getCurrentScopeKey,\n}: MaterializeCandidateTargetsByIdsOptions<TTarget>): Promise<TTarget[]> {\n if (applicationIds.length === 0) return [];\n if (new Set(applicationIds).size !== applicationIds.length) {\n throw new CandidateMaterializationError(\n 'UNIQUE_COUNT_MISMATCH',\n 'Selected applications must have unique IDs.'\n );\n }\n\n const targetsById = new Map<string, TTarget>();\n for (const applicationIdChunk of chunkCandidateRequests(applicationIds)) {\n const targets = await materializeCandidateTargets({\n scopeKey,\n expectedTotal: applicationIdChunk.length,\n getCurrentScopeKey,\n fetchPage: (limit, offset) => fetchChunkPage(applicationIdChunk, limit, offset),\n });\n for (const target of targets) targetsById.set(target.id, target);\n }\n\n return applicationIds.map((applicationId) => {\n const target = targetsById.get(applicationId);\n if (!target) {\n throw new CandidateMaterializationError(\n 'UNIQUE_COUNT_MISMATCH',\n 'A selected application was not returned by its bounded validation query.'\n );\n }\n return target;\n });\n}\n\nexport interface CandidateSelectionState {\n mode: 'explicit' | 'all';\n explicitIds: ReadonlySet<string>;\n allTargetIds: ReadonlySet<string>;\n excludedIds: ReadonlySet<string>;\n}\n\nexport function createEmptyCandidateSelection(): CandidateSelectionState {\n return {\n mode: 'explicit',\n explicitIds: new Set<string>(),\n allTargetIds: new Set<string>(),\n excludedIds: new Set<string>(),\n };\n}\n\nexport function selectAllMaterializedCandidates(\n applicationIds: ReadonlyArray<string>\n): CandidateSelectionState {\n return {\n mode: 'all',\n explicitIds: new Set<string>(),\n allTargetIds: new Set(applicationIds),\n excludedIds: new Set<string>(),\n };\n}\n\nexport function getSelectedCandidateIds(selection: CandidateSelectionState): Set<string> {\n if (selection.mode === 'explicit') {\n return new Set(selection.explicitIds);\n }\n\n const selectedIds = new Set(selection.allTargetIds);\n for (const excludedId of selection.excludedIds) {\n selectedIds.delete(excludedId);\n }\n return selectedIds;\n}\n\nexport function getCandidateSelectionCount(selection: CandidateSelectionState): number {\n return getSelectedCandidateIds(selection).size;\n}\n\nexport function toggleCandidateSelection(\n selection: CandidateSelectionState,\n applicationId: string\n): CandidateSelectionState {\n if (selection.mode === 'all') {\n if (!selection.allTargetIds.has(applicationId)) {\n return selection;\n }\n const excludedIds = new Set(selection.excludedIds);\n if (excludedIds.has(applicationId)) {\n excludedIds.delete(applicationId);\n } else {\n excludedIds.add(applicationId);\n }\n return { ...selection, excludedIds };\n }\n\n const explicitIds = new Set(selection.explicitIds);\n if (explicitIds.has(applicationId)) {\n explicitIds.delete(applicationId);\n } else {\n explicitIds.add(applicationId);\n }\n return { ...selection, explicitIds };\n}\n\nexport function setVisibleCandidateSelection(\n selection: CandidateSelectionState,\n visibleApplicationIds: ReadonlyArray<string>,\n selected: boolean\n): CandidateSelectionState {\n if (selection.mode === 'all') {\n const excludedIds = new Set(selection.excludedIds);\n for (const applicationId of visibleApplicationIds) {\n if (!selection.allTargetIds.has(applicationId)) continue;\n if (selected) {\n excludedIds.delete(applicationId);\n } else {\n excludedIds.add(applicationId);\n }\n }\n return { ...selection, excludedIds };\n }\n\n const explicitIds = new Set(selection.explicitIds);\n for (const applicationId of visibleApplicationIds) {\n if (selected) {\n explicitIds.add(applicationId);\n } else {\n explicitIds.delete(applicationId);\n }\n }\n return { ...selection, explicitIds };\n}\n\nexport function getCandidateSelectionSummary(selection: CandidateSelectionState): string | null {\n const selectedCount = getCandidateSelectionCount(selection);\n if (selectedCount === 0) return null;\n\n if (selection.mode === 'all') {\n const totalCount = selection.allTargetIds.size;\n const excludedCount = totalCount - selectedCount;\n if (excludedCount === 0) {\n return `All ${totalCount} matching applications selected`;\n }\n return `${selectedCount} of ${totalCount} matching applications selected (${excludedCount} excluded)`;\n }\n\n return `${selectedCount} ${selectedCount === 1 ? 'application' : 'applications'} selected`;\n}\n\nexport interface ExactRoundPair {\n applicationId: string;\n roundId: string;\n target: BulkCandidateTarget;\n round: CandidateRoundPreview;\n}\n\nexport interface UnresolvedCandidateRound {\n target: BulkCandidateTarget;\n reason: 'MISSING' | 'AMBIGUOUS';\n}\n\nexport interface ExactRoundResolution {\n pairs: ExactRoundPair[];\n unresolved: UnresolvedCandidateRound[];\n}\n\n/** Resolve only concrete rounds with the requested config ID; never guess by name or type. */\nexport function resolveExactCandidateRounds(\n targets: ReadonlyArray<BulkCandidateTarget>,\n roundConfigId: string\n): ExactRoundResolution {\n const pairs: ExactRoundPair[] = [];\n const unresolved: UnresolvedCandidateRound[] = [];\n\n for (const target of targets) {\n const matches = target.interviewRounds.filter((round) => round.roundConfigId === roundConfigId);\n if (matches.length !== 1) {\n unresolved.push({\n target,\n reason: matches.length === 0 ? 'MISSING' : 'AMBIGUOUS',\n });\n continue;\n }\n\n const round = matches[0];\n pairs.push({ applicationId: target.id, roundId: round.id, target, round });\n }\n\n return { pairs, unresolved };\n}\n\nexport class CandidateChunkPreconditionError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'CandidateChunkPreconditionError';\n }\n}\n\nexport function assertCandidateChunkMatchesCurrentScope(\n applicationIds: ReadonlyArray<string>,\n currentTargets: ReadonlyArray<BulkCandidateTarget>,\n jobPostingId: string\n): void {\n const currentById = new Map(currentTargets.map((target) => [target.id, target]));\n\n for (const applicationId of applicationIds) {\n const target = currentById.get(applicationId);\n if (!target || target.jobPostingId !== jobPostingId) {\n throw new CandidateChunkPreconditionError(\n 'A selected application no longer matches the frozen filter and posting. No request was sent for this chunk.'\n );\n }\n }\n}\n\nexport function assertCandidateEmailChunkMatchesCurrentScope(\n items: ReadonlyArray<{ applicationId: string; roundId: string }>,\n currentTargets: ReadonlyArray<BulkCandidateTarget>,\n jobPostingId: string,\n roundConfigId: string\n): void {\n assertCandidateChunkMatchesCurrentScope(\n items.map((item) => item.applicationId),\n currentTargets,\n jobPostingId\n );\n\n const currentById = new Map(currentTargets.map((target) => [target.id, target]));\n for (const item of items) {\n const target = currentById.get(item.applicationId);\n const matchingRounds = target?.interviewRounds.filter(\n (round) => round.roundConfigId === roundConfigId\n );\n if (matchingRounds?.length !== 1 || matchingRounds[0]?.id !== item.roundId) {\n throw new CandidateChunkPreconditionError(\n 'A selected candidate round changed after preview. No request was sent for this chunk.'\n );\n }\n }\n}\n\nexport function chunkCandidateRequests<T>(\n items: ReadonlyArray<T>,\n chunkSize = BULK_CANDIDATE_REQUEST_LIMIT\n): T[][] {\n if (!Number.isInteger(chunkSize) || chunkSize <= 0) {\n throw new Error('Chunk size must be a positive integer.');\n }\n\n const chunks: T[][] = [];\n for (let index = 0; index < items.length; index += chunkSize) {\n chunks.push(items.slice(index, index + chunkSize));\n }\n return chunks;\n}\n\nexport interface SequentialExecutionProgress {\n processed: number;\n total: number;\n}\n\nexport interface SequentialExecutionResult<TItem, TAggregate> {\n aggregate: TAggregate;\n processedItems: TItem[];\n ambiguousItems: TItem[];\n notStartedItems: TItem[];\n error: unknown | null;\n}\n\ninterface ExecuteSequentialCandidateChunksOptions<TItem, TBatchResult, TAggregate> {\n items: ReadonlyArray<TItem>;\n initialAggregate: TAggregate;\n executeChunk: (chunk: ReadonlyArray<TItem>, chunkIndex: number) => Promise<TBatchResult>;\n mergeResult: (aggregate: TAggregate, result: TBatchResult) => TAggregate;\n onProgress?: (progress: SequentialExecutionProgress) => void;\n chunkSize?: number;\n}\n\n/**\n * Executes each request once and in order. A thrown transport/missing-data error\n * makes the current chunk ambiguous and prevents every later chunk from starting.\n */\nexport async function executeSequentialCandidateChunks<TItem, TBatchResult, TAggregate>({\n items,\n initialAggregate,\n executeChunk,\n mergeResult,\n onProgress,\n chunkSize = BULK_CANDIDATE_REQUEST_LIMIT,\n}: ExecuteSequentialCandidateChunksOptions<TItem, TBatchResult, TAggregate>): Promise<\n SequentialExecutionResult<TItem, TAggregate>\n> {\n const chunks = chunkCandidateRequests(items, chunkSize);\n const processedItems: TItem[] = [];\n let aggregate = initialAggregate;\n\n onProgress?.({ processed: 0, total: items.length });\n\n for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex += 1) {\n const chunk = chunks[chunkIndex];\n try {\n const result = await executeChunk(chunk, chunkIndex);\n aggregate = mergeResult(aggregate, result);\n processedItems.push(...chunk);\n onProgress?.({ processed: processedItems.length, total: items.length });\n } catch (error) {\n const failedBeforeMutation = error instanceof CandidateChunkPreconditionError;\n return {\n aggregate,\n processedItems,\n ambiguousItems: failedBeforeMutation ? [] : [...chunk],\n notStartedItems: failedBeforeMutation\n ? chunks.slice(chunkIndex).flat()\n : chunks.slice(chunkIndex + 1).flat(),\n error,\n };\n }\n }\n\n return {\n aggregate,\n processedItems,\n ambiguousItems: [],\n notStartedItems: [],\n error: null,\n };\n}\n\nexport type BulkOperationNotificationSeverity = 'success' | 'warning' | 'error';\n\nexport function getBulkOperationNotificationSeverity({\n succeeded,\n skipped,\n failed,\n ambiguous = false,\n}: {\n succeeded: number;\n skipped: number;\n failed: number;\n ambiguous?: boolean;\n}): BulkOperationNotificationSeverity {\n if (ambiguous) return 'error';\n if (failed > 0 && succeeded === 0 && skipped === 0) return 'error';\n if (failed > 0 || skipped > 0) return 'warning';\n return 'success';\n}\n\nexport interface CandidateEmailSuccess {\n applicationId: string;\n roundId: string;\n}\n\nexport interface CandidateEmailSkip {\n applicationId: string;\n roundId: string;\n reason: string;\n message: string;\n}\n\nexport interface CandidateEmailFailure {\n applicationId: string;\n roundId: string;\n message: string;\n}\n\nexport interface CandidateEmailAggregate {\n succeeded: CandidateEmailSuccess[];\n skipped: CandidateEmailSkip[];\n failed: CandidateEmailFailure[];\n}\n\nexport function createEmptyCandidateEmailAggregate(): CandidateEmailAggregate {\n return { succeeded: [], skipped: [], failed: [] };\n}\n\nfunction candidateRoundKey(applicationId: string, roundId: string): string {\n return `${applicationId}\\0${roundId}`;\n}\n\nfunction assertExactResultKeys(\n expectedKeys: ReadonlyArray<string>,\n actualKeys: ReadonlyArray<string>,\n operationLabel: string\n): void {\n const expected = new Set(expectedKeys);\n const actual = new Set(actualKeys);\n if (\n expected.size !== expectedKeys.length ||\n actual.size !== actualKeys.length ||\n expected.size !== actual.size ||\n [...expected].some((key) => !actual.has(key))\n ) {\n throw new Error(\n `${operationLabel} returned an incomplete, duplicate, or unexpected item result. The current chunk is ambiguous and later chunks were stopped.`\n );\n }\n}\n\nexport function assertCompleteCandidateEmailChunkResult(\n requested: ReadonlyArray<{ applicationId: string; roundId: string }>,\n result: CandidateEmailAggregate\n): void {\n assertExactResultKeys(\n requested.map((item) => candidateRoundKey(item.applicationId, item.roundId)),\n [\n ...result.succeeded.map((item) => candidateRoundKey(item.applicationId, item.roundId)),\n ...result.skipped.map((item) => candidateRoundKey(item.applicationId, item.roundId)),\n ...result.failed.map((item) => candidateRoundKey(item.applicationId, item.roundId)),\n ],\n 'The candidate email request'\n );\n}\n\nexport function aggregateCandidateEmailResult(\n aggregate: CandidateEmailAggregate,\n result: CandidateEmailAggregate\n): CandidateEmailAggregate {\n return {\n succeeded: [...aggregate.succeeded, ...result.succeeded],\n skipped: [...aggregate.skipped, ...result.skipped],\n failed: [...aggregate.failed, ...result.failed],\n };\n}\n\nexport interface EnsuredRoundSummary {\n id: string;\n applicationId: string;\n}\n\nexport interface EnsureRoundFailure {\n applicationId: string;\n code: string;\n message: string;\n}\n\nexport interface EnsureRoundAggregate {\n created: EnsuredRoundSummary[];\n alreadyPresent: EnsuredRoundSummary[];\n failed: EnsureRoundFailure[];\n}\n\nexport function createEmptyEnsureRoundAggregate(): EnsureRoundAggregate {\n return { created: [], alreadyPresent: [], failed: [] };\n}\n\nexport function assertCompleteEnsureRoundChunkResult(\n requestedApplicationIds: ReadonlyArray<string>,\n result: EnsureRoundAggregate\n): void {\n assertExactResultKeys(\n requestedApplicationIds,\n [\n ...result.created.map((item) => item.applicationId),\n ...result.alreadyPresent.map((item) => item.applicationId),\n ...result.failed.map((item) => item.applicationId),\n ],\n 'The add-to-round request'\n );\n}\n\nexport function aggregateEnsureRoundResult(\n aggregate: EnsureRoundAggregate,\n result: EnsureRoundAggregate\n): EnsureRoundAggregate {\n return {\n created: [...aggregate.created, ...result.created],\n alreadyPresent: [...aggregate.alreadyPresent, ...result.alreadyPresent],\n failed: [...aggregate.failed, ...result.failed],\n };\n}\n\nexport function hasCandidateEmailType(round: CandidateRoundPreview, emailType: string): boolean {\n return round.emailLogs.some((log) => log.emailType === emailType);\n}\n"],"mappings":"AAgCA,IAAa,IAAb,cAAmD,MAAM;CAErC;CADlB,YACE,GACA,GACA;EAEA,AADA,MAAM,CAAO,GAHG,KAAA,OAAA,GAIhB,KAAK,OAAO;CACd;AACF;AAUA,SAAS,EAAmB,GAAkB,GAA+B;CAC3E,IAAI,MAAa,GACf,MAAM,IAAI,EACR,eACA,gEACF;AAEJ;AAEA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B,EACd,GACA,GACsB;CACtB,OAAO;EACL,SAAS,CAAC,GAAG,EAAU,SAAS,GAAG,EAAO,OAAO;EACjD,gBAAgB,CAAC,GAAG,EAAU,gBAAgB,GAAG,EAAO,cAAc;EACtE,QAAQ,CAAC,GAAG,EAAU,QAAQ,GAAG,EAAO,MAAM;CAChD;AACF;AAEA,SAAgB,EAAsB,GAA8B,GAA4B;CAC9F,OAAO,EAAM,UAAU,MAAM,MAAQ,EAAI,cAAc,CAAS;AAClE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"categoryColors.js","names":[],"sources":["../../../src/support/utils/categoryColors.ts"],"sourcesContent":["export type CategoryColorOption = {\n value: string;\n label: string;\n swatchClass: string;\n badgeClass: string;\n};\n\nexport const CATEGORY_COLOR_OPTIONS: CategoryColorOption[] = [\n {\n value: 'accent-blue',\n label: 'Blue',\n swatchClass: 'bg-accent-blue',\n badgeClass: 'bg-accent-blue-subtle text-accent-blue border-accent-blue/30',\n },\n {\n value: 'accent-purple',\n label: 'Purple',\n swatchClass: 'bg-accent-purple',\n badgeClass: 'bg-accent-purple-subtle text-accent-purple border-accent-purple/30',\n },\n {\n value: 'accent-teal',\n label: 'Teal',\n swatchClass: 'bg-accent-teal',\n badgeClass: 'bg-accent-teal-subtle text-accent-teal border-accent-teal/30',\n },\n {\n value: 'accent-indigo',\n label: 'Indigo',\n swatchClass: 'bg-accent-indigo',\n badgeClass: 'bg-accent-indigo-subtle text-accent-indigo border-accent-indigo/30',\n },\n {\n value: 'success',\n label: 'Success',\n swatchClass: 'bg-status-success-text',\n badgeClass: 'bg-status-success-bg-subtle text-status-success-text border-status-success-border',\n },\n {\n value: 'warning',\n label: 'Warning',\n swatchClass: 'bg-status-warning-text',\n badgeClass: 'bg-status-warning-bg-subtle text-status-warning-text border-status-warning-border',\n },\n {\n value: 'error',\n label: 'Error',\n swatchClass: 'bg-status-error-text',\n badgeClass: 'bg-status-error-bg-subtle text-status-error-text border-status-error-border',\n },\n {\n value: 'muted',\n label: 'Neutral',\n swatchClass: 'bg-muted-foreground',\n badgeClass: 'bg-bg-sunken text-text-secondary border-border-subtle',\n },\n];\n\nexport function getCategoryColorOption(color?: string | null): CategoryColorOption {\n return (\n CATEGORY_COLOR_OPTIONS.find((option) => option.value === color) ??\n CATEGORY_COLOR_OPTIONS[CATEGORY_COLOR_OPTIONS.length - 1]!\n );\n}\n\nexport function getCategoryBadgeClass(color?: string | null): string {\n return getCategoryColorOption(color).badgeClass;\n}\n\nexport function getCategorySwatchClass(color?: string | null): string {\n return getCategoryColorOption(color).swatchClass;\n}\n"],"mappings":";AAOA,IAAa,IAAgD;CAC3D;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;
|
|
1
|
+
{"version":3,"file":"categoryColors.js","names":[],"sources":["../../../src/support/utils/categoryColors.ts"],"sourcesContent":["export type CategoryColorOption = {\n value: string;\n label: string;\n swatchClass: string;\n badgeClass: string;\n};\n\nexport const CATEGORY_COLOR_OPTIONS: CategoryColorOption[] = [\n {\n value: 'accent-blue',\n label: 'Blue',\n swatchClass: 'bg-accent-blue',\n badgeClass: 'bg-accent-blue-subtle text-accent-blue border-accent-blue/30',\n },\n {\n value: 'accent-purple',\n label: 'Purple',\n swatchClass: 'bg-accent-purple',\n badgeClass: 'bg-accent-purple-subtle text-accent-purple border-accent-purple/30',\n },\n {\n value: 'accent-teal',\n label: 'Teal',\n swatchClass: 'bg-accent-teal',\n badgeClass: 'bg-accent-teal-subtle text-accent-teal border-accent-teal/30',\n },\n {\n value: 'accent-indigo',\n label: 'Indigo',\n swatchClass: 'bg-accent-indigo',\n badgeClass: 'bg-accent-indigo-subtle text-accent-indigo border-accent-indigo/30',\n },\n {\n value: 'success',\n label: 'Success',\n swatchClass: 'bg-status-success-text',\n badgeClass: 'bg-status-success-bg-subtle text-status-success-text border-status-success-border',\n },\n {\n value: 'warning',\n label: 'Warning',\n swatchClass: 'bg-status-warning-text',\n badgeClass: 'bg-status-warning-bg-subtle text-status-warning-text border-status-warning-border',\n },\n {\n value: 'error',\n label: 'Error',\n swatchClass: 'bg-status-error-text',\n badgeClass: 'bg-status-error-bg-subtle text-status-error-text border-status-error-border',\n },\n {\n value: 'muted',\n label: 'Neutral',\n swatchClass: 'bg-muted-foreground',\n badgeClass: 'bg-bg-sunken text-text-secondary border-border-subtle',\n },\n];\n\nexport function getCategoryColorOption(color?: string | null): CategoryColorOption {\n return (\n CATEGORY_COLOR_OPTIONS.find((option) => option.value === color) ??\n CATEGORY_COLOR_OPTIONS[CATEGORY_COLOR_OPTIONS.length - 1]!\n );\n}\n\nexport function getCategoryBadgeClass(color?: string | null): string {\n return getCategoryColorOption(color).badgeClass;\n}\n\nexport function getCategorySwatchClass(color?: string | null): string {\n return getCategoryColorOption(color).swatchClass;\n}\n"],"mappings":";AAOA,IAAa,IAAgD;CAC3D;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;CACd;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;CACd;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;CACd;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;CACd;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;CACd;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;CACd;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;CACd;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;CACd;AACF;AAEA,SAAgB,EAAuB,GAA4C;CACjF,OACE,EAAuB,MAAM,MAAW,EAAO,UAAU,CAAK,KAC9D,EAAuB,EAAuB,SAAS;AAE3D;AAEA,SAAgB,EAAsB,GAA+B;CACnE,OAAO,EAAuB,CAAK,CAAC,CAAC;AACvC;AAEA,SAAgB,EAAuB,GAA+B;CACpE,OAAO,EAAuB,CAAK,CAAC,CAAC;AACvC"}
|
package/dist/support/utils/cn.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cn.js","names":[],"sources":["../../../src/support/utils/cn.ts"],"sourcesContent":["import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/**\n * Utility function to merge Tailwind CSS classes\n * Combines clsx for conditional classes and tailwind-merge for deduplication\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"],"mappings":";;;AAOA,SAAgB,EAAG,GAAG,GAAsB;
|
|
1
|
+
{"version":3,"file":"cn.js","names":[],"sources":["../../../src/support/utils/cn.ts"],"sourcesContent":["import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/**\n * Utility function to merge Tailwind CSS classes\n * Combines clsx for conditional classes and tailwind-merge for deduplication\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"],"mappings":";;;AAOA,SAAgB,EAAG,GAAG,GAAsB;CAC1C,OAAO,EAAQ,EAAK,CAAM,CAAC;AAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../../src/support/utils/context.ts"],"sourcesContent":["import { getStoredOrganizationId } from '@burdenoff/fe-libs/shared/graphql/fetch';\n\nexport function resolveSupportProductId(explicitProductId?: string): string | undefined {\n if (explicitProductId) {\n return explicitProductId;\n }\n\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n const hostname = window.location.hostname.toLowerCase();\n const localMatch = hostname.match(/^([a-z0-9-]+)\\.local\\.burdenoff\\.com$/);\n if (localMatch?.[1]) {\n return localMatch[1];\n }\n\n const domainMatch = hostname.match(/^([a-z0-9-]+)\\./);\n return domainMatch?.[1];\n}\n\nexport function resolveSupportOrganizationId(explicitOrganizationId?: string): string | undefined {\n if (explicitOrganizationId) {\n return explicitOrganizationId;\n }\n\n const storedOrganizationId = getStoredOrganizationId();\n if (storedOrganizationId) {\n return storedOrganizationId;\n }\n\n const authStorageOrganizationId = getAuthStorageOrganizationId();\n if (authStorageOrganizationId) {\n return authStorageOrganizationId;\n }\n\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n return new URLSearchParams(window.location.search).get('org') ?? undefined;\n}\n\nfunction getAuthStorageOrganizationId(): string | undefined {\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n try {\n // These keys are owned by the host auth store in fe-libs. This fallback is\n // intentionally read-only and only covers shells that have not populated\n // the shared GraphQL organization helper yet.\n const activeProfileId = window.sessionStorage.getItem('bf-active-profile');\n if (!activeProfileId) {\n return undefined;\n }\n\n const rawAuthStorage = window.localStorage.getItem(`bf-p-${activeProfileId}-auth-storage`);\n if (!rawAuthStorage) {\n return undefined;\n }\n\n const authStorage = JSON.parse(rawAuthStorage) as {\n state?: { currentOrganizationId?: unknown };\n };\n return typeof authStorage.state?.currentOrganizationId === 'string'\n ? authStorage.state.currentOrganizationId\n : undefined;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;AAEA,SAAgB,EAAwB,GAAgD;
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../../src/support/utils/context.ts"],"sourcesContent":["import { getStoredOrganizationId } from '@burdenoff/fe-libs/shared/graphql/fetch';\n\nexport function resolveSupportProductId(explicitProductId?: string): string | undefined {\n if (explicitProductId) {\n return explicitProductId;\n }\n\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n const hostname = window.location.hostname.toLowerCase();\n const localMatch = hostname.match(/^([a-z0-9-]+)\\.local\\.burdenoff\\.com$/);\n if (localMatch?.[1]) {\n return localMatch[1];\n }\n\n const domainMatch = hostname.match(/^([a-z0-9-]+)\\./);\n return domainMatch?.[1];\n}\n\nexport function resolveSupportOrganizationId(explicitOrganizationId?: string): string | undefined {\n if (explicitOrganizationId) {\n return explicitOrganizationId;\n }\n\n const storedOrganizationId = getStoredOrganizationId();\n if (storedOrganizationId) {\n return storedOrganizationId;\n }\n\n const authStorageOrganizationId = getAuthStorageOrganizationId();\n if (authStorageOrganizationId) {\n return authStorageOrganizationId;\n }\n\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n return new URLSearchParams(window.location.search).get('org') ?? undefined;\n}\n\nfunction getAuthStorageOrganizationId(): string | undefined {\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n try {\n // These keys are owned by the host auth store in fe-libs. This fallback is\n // intentionally read-only and only covers shells that have not populated\n // the shared GraphQL organization helper yet.\n const activeProfileId = window.sessionStorage.getItem('bf-active-profile');\n if (!activeProfileId) {\n return undefined;\n }\n\n const rawAuthStorage = window.localStorage.getItem(`bf-p-${activeProfileId}-auth-storage`);\n if (!rawAuthStorage) {\n return undefined;\n }\n\n const authStorage = JSON.parse(rawAuthStorage) as {\n state?: { currentOrganizationId?: unknown };\n };\n return typeof authStorage.state?.currentOrganizationId === 'string'\n ? authStorage.state.currentOrganizationId\n : undefined;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;AAEA,SAAgB,EAAwB,GAAgD;CACtF,IAAI,GACF,OAAO;CAGT,IAAI,OAAO,SAAW,KACpB;CAGF,IAAM,IAAW,OAAO,SAAS,SAAS,YAAY,GAChD,IAAa,EAAS,MAAM,uCAAuC;CAMzE,OALI,IAAa,KACR,EAAW,KAGA,EAAS,MAAM,iBAC5B,CAAA,GAAc;AACvB;AAEA,SAAgB,EAA6B,GAAqD;CAChG,IAAI,GACF,OAAO;CAGT,IAAM,IAAuB,EAAwB;CACrD,IAAI,GACF,OAAO;CAGT,IAAM,IAA4B,EAA6B;CAC/D,IAAI,GACF,OAAO;CAGL,aAAO,SAAW,MAItB,OAAO,IAAI,gBAAgB,OAAO,SAAS,MAAM,CAAC,CAAC,IAAI,KAAK,KAAK,KAAA;AACnE;AAEA,SAAS,IAAmD;CACtD,aAAO,SAAW,MAItB,IAAI;EAIF,IAAM,IAAkB,OAAO,eAAe,QAAQ,mBAAmB;EACzE,IAAI,CAAC,GACH;EAGF,IAAM,IAAiB,OAAO,aAAa,QAAQ,QAAQ,EAAgB,cAAc;EACzF,IAAI,CAAC,GACH;EAGF,IAAM,IAAc,KAAK,MAAM,CAAc;EAG7C,OAAO,OAAO,EAAY,OAAO,yBAA0B,WACvD,EAAY,MAAM,wBAClB,KAAA;CACN,QAAQ;EACN;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../../../src/support/utils/errors.ts"],"sourcesContent":["export function extractErrorMessage(error: unknown, fallback: string): string {\n if (error instanceof Error && error.message) {\n return error.message.replace(/^(CombinedGraphQLError[s]?:\\s*)+/i, '');\n }\n return fallback;\n}\n\nexport function extractErrorCode(error: unknown): string | null {\n if (!error || typeof error !== 'object') {\n return null;\n }\n\n const graphQLErrors = (error as { graphQLErrors?: Array<{ extensions?: { code?: string } }> })\n .graphQLErrors;\n const code = graphQLErrors?.[0]?.extensions?.code;\n return typeof code === 'string' ? code : null;\n}\n"],"mappings":";AAAA,SAAgB,EAAoB,GAAgB,GAA0B;
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../../../src/support/utils/errors.ts"],"sourcesContent":["export function extractErrorMessage(error: unknown, fallback: string): string {\n if (error instanceof Error && error.message) {\n return error.message.replace(/^(CombinedGraphQLError[s]?:\\s*)+/i, '');\n }\n return fallback;\n}\n\nexport function extractErrorCode(error: unknown): string | null {\n if (!error || typeof error !== 'object') {\n return null;\n }\n\n const graphQLErrors = (error as { graphQLErrors?: Array<{ extensions?: { code?: string } }> })\n .graphQLErrors;\n const code = graphQLErrors?.[0]?.extensions?.code;\n return typeof code === 'string' ? code : null;\n}\n"],"mappings":";AAAA,SAAgB,EAAoB,GAAgB,GAA0B;CAI5E,OAHI,aAAiB,SAAS,EAAM,UAC3B,EAAM,QAAQ,QAAQ,qCAAqC,EAAE,IAE/D;AACT;AAEA,SAAgB,EAAiB,GAA+B;CAC9D,IAAI,CAAC,KAAS,OAAO,KAAU,UAC7B,OAAO;CAKT,IAAM,IAFiB,EACpB,gBAC0B,EAAE,EAAE,YAAY;CAC7C,OAAO,OAAO,KAAS,WAAW,IAAO;AAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","names":[],"sources":["../../../src/support/utils/i18n.ts"],"sourcesContent":["type TranslationParams = Record<string, string | number>;\n\ntype TranslateFn = (key: string, params?: TranslationParams) => string;\n\nexport function tWithFallback(\n t: TranslateFn,\n key: string,\n fallback: string,\n params?: TranslationParams\n): string {\n const translated = t(key, params);\n\n if (translated !== key) {\n return translated;\n }\n\n if (!params) {\n return fallback;\n }\n\n return Object.entries(params).reduce(\n (value, [paramKey, paramValue]) =>\n value\n .replace(`{{${paramKey}}}`, String(paramValue))\n .replace(`{${paramKey}}`, String(paramValue)),\n fallback\n );\n}\n"],"mappings":";AAIA,SAAgB,EACd,GACA,GACA,GACA,GACQ;CACR,IAAM,IAAa,EAAE,GAAK,
|
|
1
|
+
{"version":3,"file":"i18n.js","names":[],"sources":["../../../src/support/utils/i18n.ts"],"sourcesContent":["type TranslationParams = Record<string, string | number>;\n\ntype TranslateFn = (key: string, params?: TranslationParams) => string;\n\nexport function tWithFallback(\n t: TranslateFn,\n key: string,\n fallback: string,\n params?: TranslationParams\n): string {\n const translated = t(key, params);\n\n if (translated !== key) {\n return translated;\n }\n\n if (!params) {\n return fallback;\n }\n\n return Object.entries(params).reduce(\n (value, [paramKey, paramValue]) =>\n value\n .replace(`{{${paramKey}}}`, String(paramValue))\n .replace(`{${paramKey}}`, String(paramValue)),\n fallback\n );\n}\n"],"mappings":";AAIA,SAAgB,EACd,GACA,GACA,GACA,GACQ;CACR,IAAM,IAAa,EAAE,GAAK,CAAM;CAUhC,OARI,MAAe,IAId,IAIE,OAAO,QAAQ,CAAM,CAAC,CAAC,QAC3B,GAAO,CAAC,GAAU,OACjB,EACG,QAAQ,KAAK,EAAS,KAAK,OAAO,CAAU,CAAC,CAAC,CAC9C,QAAQ,IAAI,EAAS,IAAI,OAAO,CAAU,CAAC,GAChD,CACF,IATS,IAJA;AAcX"}
|
|
@@ -45,7 +45,7 @@ function o(e) {
|
|
|
45
45
|
"MB",
|
|
46
46
|
"GB"
|
|
47
47
|
], r = Math.floor(Math.log(e) / Math.log(t));
|
|
48
|
-
return Math.round(e / t **
|
|
48
|
+
return Math.round(e / t ** r * 100) / 100 + " " + n[r];
|
|
49
49
|
}
|
|
50
50
|
function s(e) {
|
|
51
51
|
let t = /* @__PURE__ */ new Date(), n = new Date(e), r = t.getTime() - n.getTime(), i = Math.floor(r / 6e4);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/support/utils/index.ts"],"sourcesContent":["import type { TicketStatus, TicketPriority, SLAMetrics } from '../types';\n\n/**\n * Join a base path with a sub-path, avoiding double slashes.\n * Used by Root components to construct navigation paths from basePath.\n */\nexport function joinPath(base: string, path: string): string {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n}\n\nexport function isAdminRole(role?: string | null): boolean {\n if (!role) return false;\n const normalizedRole = role.toUpperCase();\n return (\n normalizedRole === 'ADMIN' || normalizedRole === 'SUPER_ADMIN' || normalizedRole === 'OWNER'\n );\n}\n\n/** Humanise a ContactInquiry.category slug for display, e.g. \"plugin-developer\" → \"Plugin developer\". */\nexport function humanizeCategory(value?: string | null): string {\n if (!value) return '';\n return value.charAt(0).toUpperCase() + value.slice(1).replace(/-/g, ' ');\n}\n\n/**\n * Format ticket status for display\n */\nexport function formatTicketStatus(status: TicketStatus): string {\n const statusMap: Record<TicketStatus, string> = {\n OPEN: 'Open',\n IN_PROGRESS: 'In Progress',\n WAITING_ON_CUSTOMER: 'Waiting on Customer',\n WAITING_ON_THIRD_PARTY: 'Waiting on Third Party',\n RESOLVED: 'Resolved',\n CLOSED: 'Closed',\n };\n return statusMap[status] || status;\n}\n\n/**\n * Get color for ticket priority\n */\nexport function getPriorityColor(priority: TicketPriority): string {\n const colorMap: Record<TicketPriority, string> = {\n LOW: 'var(--color-status-success-bg)',\n MEDIUM: 'var(--color-status-warning-bg)',\n HIGH: 'var(--color-status-warning-bg)',\n CRITICAL: 'var(--color-status-error-bg)',\n };\n return colorMap[priority] || 'var(--color-muted-foreground)';\n}\n\n/**\n * Get icon for ticket priority\n */\nexport function getPriorityIcon(\n priority: import('../types').SupportTicketPriority | TicketPriority\n): string {\n const iconMap: Record<string, string> = {\n LOW: '🟢',\n NORMAL: '🟡',\n MEDIUM: '🟡',\n HIGH: '🟠',\n CRITICAL: '🔴',\n };\n return iconMap[priority] || '⚪';\n}\n\n/**\n * Format file size for display\n */\nexport function formatFileSize(bytes: number): string {\n if (bytes === 0) return '0 Bytes';\n\n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i];\n}\n\n/**\n * Format time ago (e.g., \"2 hours ago\")\n */\nexport function formatTimeAgo(date: string | Date): string {\n const now = new Date();\n const past = new Date(date);\n const diffMs = now.getTime() - past.getTime();\n const diffMins = Math.floor(diffMs / 60000);\n\n if (diffMins < 1) return 'just now';\n if (diffMins < 60) return `${diffMins} ${diffMins === 1 ? 'minute' : 'minutes'} ago`;\n\n const diffHours = Math.floor(diffMins / 60);\n if (diffHours < 24) return `${diffHours} ${diffHours === 1 ? 'hour' : 'hours'} ago`;\n\n const diffDays = Math.floor(diffHours / 24);\n if (diffDays < 7) return `${diffDays} ${diffDays === 1 ? 'day' : 'days'} ago`;\n\n const diffWeeks = Math.floor(diffDays / 7);\n if (diffWeeks < 4) return `${diffWeeks} ${diffWeeks === 1 ? 'week' : 'weeks'} ago`;\n\n const diffMonths = Math.floor(diffDays / 30);\n return `${diffMonths} ${diffMonths === 1 ? 'month' : 'months'} ago`;\n}\n\n/**\n * Format duration in minutes to human-readable string\n */\nexport function formatDuration(minutes: number): string {\n if (minutes < 60) return `${minutes}m`;\n\n const hours = Math.floor(minutes / 60);\n const mins = minutes % 60;\n\n if (hours < 24) {\n return mins > 0 ? `${hours}h ${mins}m` : `${hours}h`;\n }\n\n const days = Math.floor(hours / 24);\n const remainingHours = hours % 24;\n\n if (remainingHours > 0) {\n return `${days}d ${remainingHours}h`;\n }\n return `${days}d`;\n}\n\n/**\n * Calculate SLA breach percentage\n */\nexport function calculateSLAStatus(slaMetrics: SLAMetrics | undefined): {\n status: 'safe' | 'warning' | 'danger';\n label: string;\n color: string;\n} {\n if (!slaMetrics) {\n return { status: 'safe', label: 'No SLA', color: 'var(--color-neutral)' };\n }\n\n const { isMet, breachPercentage, minutesRemaining } = slaMetrics;\n\n if (!isMet) {\n return {\n status: 'danger',\n label: 'SLA Breached',\n color: 'var(--color-status-error-bg)',\n };\n }\n\n if (breachPercentage >= 75) {\n return {\n status: 'danger',\n label: `${formatDuration(minutesRemaining)} remaining`,\n color: 'var(--color-status-error-bg)',\n };\n }\n\n if (breachPercentage >= 50) {\n return {\n status: 'warning',\n label: `${formatDuration(minutesRemaining)} remaining`,\n color: 'var(--color-status-warning-bg)',\n };\n }\n\n return {\n status: 'safe',\n label: `${formatDuration(minutesRemaining)} remaining`,\n color: 'var(--color-status-success-bg)',\n };\n}\n\n/**\n * Truncate text with ellipsis\n */\nexport function truncateText(text: string, maxLength: number): string {\n if (text.length <= maxLength) return text;\n return text.substring(0, maxLength - 3) + '...';\n}\n\n/**\n * Extract initials from name\n */\nexport function getInitials(name: string): string {\n const parts = name.trim().split(/\\s+/);\n if (parts.length === 1) {\n return parts[0].substring(0, 2).toUpperCase();\n }\n return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();\n}\n\n/**\n * Validate email address\n */\nexport function isValidEmail(email: string): boolean {\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n return emailRegex.test(email);\n}\n\n/**\n * Generate color from string (for avatars, categories, etc.)\n */\nexport function stringToColor(str: string): string {\n const tokenColors = [\n 'var(--color-status-info-bg)',\n 'var(--color-accent-purple)',\n 'var(--color-accent-teal)',\n 'var(--color-accent-indigo)',\n 'var(--color-status-success-bg)',\n 'var(--color-status-warning-bg)',\n 'var(--color-status-error-bg)',\n 'var(--color-muted-foreground)',\n ];\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = str.charCodeAt(i) + ((hash << 5) - hash);\n }\n\n return tokenColors[Math.abs(hash) % tokenColors.length];\n}\n"],"mappings":";AAMA,SAAgB,EAAS,GAAc,GAAsB;
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/support/utils/index.ts"],"sourcesContent":["import type { TicketStatus, TicketPriority, SLAMetrics } from '../types';\n\n/**\n * Join a base path with a sub-path, avoiding double slashes.\n * Used by Root components to construct navigation paths from basePath.\n */\nexport function joinPath(base: string, path: string): string {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n}\n\nexport function isAdminRole(role?: string | null): boolean {\n if (!role) return false;\n const normalizedRole = role.toUpperCase();\n return (\n normalizedRole === 'ADMIN' || normalizedRole === 'SUPER_ADMIN' || normalizedRole === 'OWNER'\n );\n}\n\n/** Humanise a ContactInquiry.category slug for display, e.g. \"plugin-developer\" → \"Plugin developer\". */\nexport function humanizeCategory(value?: string | null): string {\n if (!value) return '';\n return value.charAt(0).toUpperCase() + value.slice(1).replace(/-/g, ' ');\n}\n\n/**\n * Format ticket status for display\n */\nexport function formatTicketStatus(status: TicketStatus): string {\n const statusMap: Record<TicketStatus, string> = {\n OPEN: 'Open',\n IN_PROGRESS: 'In Progress',\n WAITING_ON_CUSTOMER: 'Waiting on Customer',\n WAITING_ON_THIRD_PARTY: 'Waiting on Third Party',\n RESOLVED: 'Resolved',\n CLOSED: 'Closed',\n };\n return statusMap[status] || status;\n}\n\n/**\n * Get color for ticket priority\n */\nexport function getPriorityColor(priority: TicketPriority): string {\n const colorMap: Record<TicketPriority, string> = {\n LOW: 'var(--color-status-success-bg)',\n MEDIUM: 'var(--color-status-warning-bg)',\n HIGH: 'var(--color-status-warning-bg)',\n CRITICAL: 'var(--color-status-error-bg)',\n };\n return colorMap[priority] || 'var(--color-muted-foreground)';\n}\n\n/**\n * Get icon for ticket priority\n */\nexport function getPriorityIcon(\n priority: import('../types').SupportTicketPriority | TicketPriority\n): string {\n const iconMap: Record<string, string> = {\n LOW: '🟢',\n NORMAL: '🟡',\n MEDIUM: '🟡',\n HIGH: '🟠',\n CRITICAL: '🔴',\n };\n return iconMap[priority] || '⚪';\n}\n\n/**\n * Format file size for display\n */\nexport function formatFileSize(bytes: number): string {\n if (bytes === 0) return '0 Bytes';\n\n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i];\n}\n\n/**\n * Format time ago (e.g., \"2 hours ago\")\n */\nexport function formatTimeAgo(date: string | Date): string {\n const now = new Date();\n const past = new Date(date);\n const diffMs = now.getTime() - past.getTime();\n const diffMins = Math.floor(diffMs / 60000);\n\n if (diffMins < 1) return 'just now';\n if (diffMins < 60) return `${diffMins} ${diffMins === 1 ? 'minute' : 'minutes'} ago`;\n\n const diffHours = Math.floor(diffMins / 60);\n if (diffHours < 24) return `${diffHours} ${diffHours === 1 ? 'hour' : 'hours'} ago`;\n\n const diffDays = Math.floor(diffHours / 24);\n if (diffDays < 7) return `${diffDays} ${diffDays === 1 ? 'day' : 'days'} ago`;\n\n const diffWeeks = Math.floor(diffDays / 7);\n if (diffWeeks < 4) return `${diffWeeks} ${diffWeeks === 1 ? 'week' : 'weeks'} ago`;\n\n const diffMonths = Math.floor(diffDays / 30);\n return `${diffMonths} ${diffMonths === 1 ? 'month' : 'months'} ago`;\n}\n\n/**\n * Format duration in minutes to human-readable string\n */\nexport function formatDuration(minutes: number): string {\n if (minutes < 60) return `${minutes}m`;\n\n const hours = Math.floor(minutes / 60);\n const mins = minutes % 60;\n\n if (hours < 24) {\n return mins > 0 ? `${hours}h ${mins}m` : `${hours}h`;\n }\n\n const days = Math.floor(hours / 24);\n const remainingHours = hours % 24;\n\n if (remainingHours > 0) {\n return `${days}d ${remainingHours}h`;\n }\n return `${days}d`;\n}\n\n/**\n * Calculate SLA breach percentage\n */\nexport function calculateSLAStatus(slaMetrics: SLAMetrics | undefined): {\n status: 'safe' | 'warning' | 'danger';\n label: string;\n color: string;\n} {\n if (!slaMetrics) {\n return { status: 'safe', label: 'No SLA', color: 'var(--color-neutral)' };\n }\n\n const { isMet, breachPercentage, minutesRemaining } = slaMetrics;\n\n if (!isMet) {\n return {\n status: 'danger',\n label: 'SLA Breached',\n color: 'var(--color-status-error-bg)',\n };\n }\n\n if (breachPercentage >= 75) {\n return {\n status: 'danger',\n label: `${formatDuration(minutesRemaining)} remaining`,\n color: 'var(--color-status-error-bg)',\n };\n }\n\n if (breachPercentage >= 50) {\n return {\n status: 'warning',\n label: `${formatDuration(minutesRemaining)} remaining`,\n color: 'var(--color-status-warning-bg)',\n };\n }\n\n return {\n status: 'safe',\n label: `${formatDuration(minutesRemaining)} remaining`,\n color: 'var(--color-status-success-bg)',\n };\n}\n\n/**\n * Truncate text with ellipsis\n */\nexport function truncateText(text: string, maxLength: number): string {\n if (text.length <= maxLength) return text;\n return text.substring(0, maxLength - 3) + '...';\n}\n\n/**\n * Extract initials from name\n */\nexport function getInitials(name: string): string {\n const parts = name.trim().split(/\\s+/);\n if (parts.length === 1) {\n return parts[0].substring(0, 2).toUpperCase();\n }\n return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();\n}\n\n/**\n * Validate email address\n */\nexport function isValidEmail(email: string): boolean {\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n return emailRegex.test(email);\n}\n\n/**\n * Generate color from string (for avatars, categories, etc.)\n */\nexport function stringToColor(str: string): string {\n const tokenColors = [\n 'var(--color-status-info-bg)',\n 'var(--color-accent-purple)',\n 'var(--color-accent-teal)',\n 'var(--color-accent-indigo)',\n 'var(--color-status-success-bg)',\n 'var(--color-status-warning-bg)',\n 'var(--color-status-error-bg)',\n 'var(--color-muted-foreground)',\n ];\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = str.charCodeAt(i) + ((hash << 5) - hash);\n }\n\n return tokenColors[Math.abs(hash) % tokenColors.length];\n}\n"],"mappings":";AAMA,SAAgB,EAAS,GAAc,GAAsB;CAG3D,QAFkB,EAAK,SAAS,GAAG,IAAI,EAAK,MAAM,GAAG,EAAE,IAAI,MACzC,EAAK,WAAW,GAAG,IAAI,IAAO,IAAI;AAEtD;AAEA,SAAgB,EAAY,GAA+B;CACzD,IAAI,CAAC,GAAM,OAAO;CAClB,IAAM,IAAiB,EAAK,YAAY;CACxC,OACE,MAAmB,WAAW,MAAmB,iBAAiB,MAAmB;AAEzF;AAGA,SAAgB,EAAiB,GAA+B;CAE9D,OADK,IACE,EAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,EAAM,MAAM,CAAC,CAAC,CAAC,QAAQ,MAAM,GAAG,IADpD;AAErB;AAKA,SAAgB,EAAmB,GAA8B;CAS/D,OAAO;EAPL,MAAM;EACN,aAAa;EACb,qBAAqB;EACrB,wBAAwB;EACxB,UAAU;EACV,QAAQ;CAEH,EAAU,MAAW;AAC9B;AAKA,SAAgB,EAAiB,GAAkC;CAOjE,OAAO;EALL,KAAK;EACL,QAAQ;EACR,MAAM;EACN,UAAU;CAEL,EAAS,MAAa;AAC/B;AAKA,SAAgB,EACd,GACQ;CAQR,OAAO;EANL,KAAK;EACL,QAAQ;EACR,QAAQ;EACR,MAAM;EACN,UAAU;CAEL,EAAQ,MAAa;AAC9B;AAKA,SAAgB,EAAe,GAAuB;CACpD,IAAI,MAAU,GAAG,OAAO;CAExB,IAAM,IAAI,MACJ,IAAQ;EAAC;EAAS;EAAM;EAAM;CAAI,GAClC,IAAI,KAAK,MAAM,KAAK,IAAI,CAAK,IAAI,KAAK,IAAI,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O;EAAE,QAAQ;EAAQ,OAAO;EAAU,OAAO;CAAuB;CAG1E,IAAM,EAAE,UAAO,qBAAkB,wBAAqB;CA0BtD,OAxBK,IAQD,KAAoB,KACf;EACL,QAAQ;EACR,OAAO,GAAG,EAAe,CAAgB,EAAE;EAC3C,OAAO;CACT,IAGE,KAAoB,KACf;EACL,QAAQ;EACR,OAAO,GAAG,EAAe,CAAgB,EAAE;EAC3C,OAAO;CACT,IAGK;EACL,QAAQ;EACR,OAAO,GAAG,EAAe,CAAgB,EAAE;EAC3C,OAAO;CACT,IA3BS;EACL,QAAQ;EACR,OAAO;EACP,OAAO;CACT;AAwBJ;AAKA,SAAgB,EAAa,GAAc,GAA2B;CAEpE,OADI,EAAK,UAAU,IAAkB,IAC9B,EAAK,UAAU,GAAG,IAAY,CAAC,IAAI;AAC5C;AAKA,SAAgB,EAAY,GAAsB;CAChD,IAAM,IAAQ,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK;CAIrC,OAHI,EAAM,WAAW,IACZ,EAAM,EAAE,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,YAAY,KAEtC,EAAM,EAAE,CAAC,KAAK,EAAM,EAAM,SAAS,EAAE,CAAC,GAAA,CAAI,YAAY;AAChE;AAKA,SAAgB,EAAa,GAAwB;CAEnD,OAAO,6BAAW,KAAK,CAAK;AAC9B;AAKA,SAAgB,EAAc,GAAqB;CACjD,IAAM,IAAc;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,GACI,IAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,EAAI,QAAQ,KAC9B,IAAO,EAAI,WAAW,CAAC,MAAM,KAAQ,KAAK;CAG5C,OAAO,EAAY,KAAK,IAAI,CAAI,IAAI,EAAY;AAClD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import e from "../../node_modules/dompurify/dist/purify.es.js";
|
|
2
|
+
import { Marked as t, Renderer as n } from "../../node_modules/marked/lib/marked.esm.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region src/support/utils/markdown.ts
|
|
5
5
|
var r = new t({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","names":[],"sources":["../../../src/support/utils/markdown.ts"],"sourcesContent":["import DOMPurify from 'dompurify';\nimport { Marked, Renderer } from 'marked';\n\nimport '../styles/markdown.css';\n\nconst marked = new Marked({\n breaks: true,\n gfm: true,\n});\n\nconst renderer = new Renderer();\n\nfunction normalizeLanguage(language?: string): string {\n const normalized = language?.trim().toLowerCase();\n if (!normalized) {\n return 'plaintext';\n }\n\n const aliases: Record<string, string> = {\n js: 'javascript',\n ts: 'typescript',\n sh: 'bash',\n shell: 'bash',\n html: 'markup',\n md: 'markdown',\n };\n\n return aliases[normalized] ?? normalized;\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n .replaceAll('\"', '"')\n .replaceAll(\"'\", ''');\n}\n\nfunction applyTokenHighlighting(language: string, code: string): string {\n let highlighted = escapeHtml(code);\n const placeholders = new Map<string, string>();\n let tokenIndex = 0;\n\n const protect = (regex: RegExp, className: string) => {\n highlighted = highlighted.replace(regex, (match) => {\n const key = `§§TOKEN_${String.fromCharCode(65 + (tokenIndex % 26))}_${'x'.repeat(Math.floor(tokenIndex / 26) + 1)}§§`;\n tokenIndex += 1;\n placeholders.set(key, `<span class=\"token ${className}\">${match}</span>`);\n return key;\n });\n };\n\n protect(/(".*?")/g, 'string');\n protect(/(\\/\\/.*$)/gm, 'comment');\n\n const keywordRegex =\n language === 'json'\n ? /\\b(true|false|null)\\b/g\n : /\\b(async|await|break|case|catch|class|const|continue|default|delete|else|enum|export|extends|finally|for|function|if|implements|import|in|interface|let|new|return|switch|throw|try|type|var|while)\\b/g;\n\n highlighted = highlighted\n .replace(/\\b(\\d+(?:\\.\\d+)?)\\b/g, '<span class=\"token number\">$1</span>')\n .replace(keywordRegex, '<span class=\"token keyword\">$1</span>');\n\n for (const [key, value] of placeholders) {\n highlighted = highlighted.replaceAll(key, value);\n }\n\n return highlighted;\n}\n\nrenderer.code = ({ text, lang }) => {\n const language = normalizeLanguage(lang);\n const highlighted = applyTokenHighlighting(language, text);\n\n return `<pre><code class=\"language-${language}\">${highlighted}</code></pre>`;\n};\n\nmarked.use({ renderer });\n\nexport function renderSupportMarkdown(content: string): string {\n const rendered = marked.parse(content ?? '');\n return DOMPurify.sanitize(typeof rendered === 'string' ? rendered : String(rendered));\n}\n"],"mappings":";;;;AAKA,IAAM,IAAS,IAAI,EAAO;CACxB,QAAQ;CACR,KAAK;
|
|
1
|
+
{"version":3,"file":"markdown.js","names":[],"sources":["../../../src/support/utils/markdown.ts"],"sourcesContent":["import DOMPurify from 'dompurify';\nimport { Marked, Renderer } from 'marked';\n\nimport '../styles/markdown.css';\n\nconst marked = new Marked({\n breaks: true,\n gfm: true,\n});\n\nconst renderer = new Renderer();\n\nfunction normalizeLanguage(language?: string): string {\n const normalized = language?.trim().toLowerCase();\n if (!normalized) {\n return 'plaintext';\n }\n\n const aliases: Record<string, string> = {\n js: 'javascript',\n ts: 'typescript',\n sh: 'bash',\n shell: 'bash',\n html: 'markup',\n md: 'markdown',\n };\n\n return aliases[normalized] ?? normalized;\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n .replaceAll('\"', '"')\n .replaceAll(\"'\", ''');\n}\n\nfunction applyTokenHighlighting(language: string, code: string): string {\n let highlighted = escapeHtml(code);\n const placeholders = new Map<string, string>();\n let tokenIndex = 0;\n\n const protect = (regex: RegExp, className: string) => {\n highlighted = highlighted.replace(regex, (match) => {\n const key = `§§TOKEN_${String.fromCharCode(65 + (tokenIndex % 26))}_${'x'.repeat(Math.floor(tokenIndex / 26) + 1)}§§`;\n tokenIndex += 1;\n placeholders.set(key, `<span class=\"token ${className}\">${match}</span>`);\n return key;\n });\n };\n\n protect(/(".*?")/g, 'string');\n protect(/(\\/\\/.*$)/gm, 'comment');\n\n const keywordRegex =\n language === 'json'\n ? /\\b(true|false|null)\\b/g\n : /\\b(async|await|break|case|catch|class|const|continue|default|delete|else|enum|export|extends|finally|for|function|if|implements|import|in|interface|let|new|return|switch|throw|try|type|var|while)\\b/g;\n\n highlighted = highlighted\n .replace(/\\b(\\d+(?:\\.\\d+)?)\\b/g, '<span class=\"token number\">$1</span>')\n .replace(keywordRegex, '<span class=\"token keyword\">$1</span>');\n\n for (const [key, value] of placeholders) {\n highlighted = highlighted.replaceAll(key, value);\n }\n\n return highlighted;\n}\n\nrenderer.code = ({ text, lang }) => {\n const language = normalizeLanguage(lang);\n const highlighted = applyTokenHighlighting(language, text);\n\n return `<pre><code class=\"language-${language}\">${highlighted}</code></pre>`;\n};\n\nmarked.use({ renderer });\n\nexport function renderSupportMarkdown(content: string): string {\n const rendered = marked.parse(content ?? '');\n return DOMPurify.sanitize(typeof rendered === 'string' ? rendered : String(rendered));\n}\n"],"mappings":";;;;AAKA,IAAM,IAAS,IAAI,EAAO;CACxB,QAAQ;CACR,KAAK;AACP,CAAC,GAEK,IAAW,IAAI,EAAS;AAE9B,SAAS,EAAkB,GAA2B;CACpD,IAAM,IAAa,GAAU,KAAK,CAAC,CAAC,YAAY;CAchD,OAbK,IAaE;EARL,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,OAAO;EACP,MAAM;EACN,IAAI;CAGC,EAAQ,MAAe,IAZrB;AAaX;AAEA,SAAS,EAAW,GAAuB;CACzC,OAAO,EACJ,WAAW,KAAK,OAAO,CAAC,CACxB,WAAW,KAAK,MAAM,CAAC,CACvB,WAAW,KAAK,MAAM,CAAC,CACvB,WAAW,MAAK,QAAQ,CAAC,CACzB,WAAW,KAAK,OAAO;AAC5B;AAEA,SAAS,EAAuB,GAAkB,GAAsB;CACtE,IAAI,IAAc,EAAW,CAAI,GAC3B,oBAAe,IAAI,IAAoB,GACzC,IAAa,GAEX,KAAW,GAAe,MAAsB;EACpD,IAAc,EAAY,QAAQ,IAAQ,MAAU;GAClD,IAAM,IAAM,WAAW,OAAO,aAAa,KAAM,IAAa,EAAG,EAAE,GAAG,IAAI,OAAO,KAAK,MAAM,IAAa,EAAE,IAAI,CAAC,EAAE;GAGlH,OAFA,KAAc,GACd,EAAa,IAAI,GAAK,sBAAsB,EAAU,IAAI,EAAM,QAAQ,GACjE;EACT,CAAC;CACH;CAGA,AADA,EAAQ,sBAAsB,QAAQ,GACtC,EAAQ,eAAe,SAAS;CAEhC,IAAM,IACJ,MAAa,SACT,2BACA;CAEN,IAAc,EACX,QAAQ,wBAAwB,wCAAsC,CAAC,CACvE,QAAQ,GAAc,yCAAuC;CAEhE,KAAK,IAAM,CAAC,GAAK,MAAU,GACzB,IAAc,EAAY,WAAW,GAAK,CAAK;CAGjD,OAAO;AACT;AAEA,EAAS,QAAQ,EAAE,SAAM,cAAW;CAClC,IAAM,IAAW,EAAkB,CAAI;CAGvC,OAAO,8BAA8B,EAAS,IAF1B,EAAuB,GAAU,CAEH,EAAY;AAChE,GAEA,EAAO,IAAI,EAAE,YAAS,CAAC;AAEvB,SAAgB,EAAsB,GAAyB;CAC7D,IAAM,IAAW,EAAO,MAAM,KAAW,EAAE;CAC3C,OAAO,EAAU,SAAS,OAAO,KAAa,WAAW,IAAW,OAAO,CAAQ,CAAC;AACtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supportFiles.js","names":[],"sources":["../../../src/support/utils/supportFiles.ts"],"sourcesContent":["import { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql/fetch';\n\nexport interface SupportAttachmentRecord {\n id: string;\n name: string;\n mimeType: string;\n size: string;\n downloadUrl: string;\n}\n\ninterface SupportAttachmentUploadSession {\n sessionId: string;\n uploadType: string;\n uploadUrl?: string | null;\n partSize: number;\n totalParts: number;\n presignedUrls: Array<{ partNumber: number; url: string }>;\n}\n\nconst PREPARE_UPLOAD_MUTATION = `\n mutation PrepareSupportAttachmentUpload($input: PrepareSupportAttachmentUploadInput!) {\n prepareSupportAttachmentUpload(input: $input) {\n sessionId\n uploadType\n uploadUrl\n partSize\n totalParts\n presignedUrls {\n partNumber\n url\n }\n }\n }\n`;\n\nconst GET_PART_URLS_MUTATION = `\n mutation GetSupportAttachmentPartUploadUrls($ticketId: ID!, $sessionId: ID!, $partNumbers: [Int!]!) {\n getSupportAttachmentPartUploadUrls(ticketId: $ticketId, sessionId: $sessionId, partNumbers: $partNumbers) {\n partNumber\n url\n }\n }\n`;\n\nconst REGISTER_PART_MUTATION = `\n mutation RegisterSupportAttachmentPart($input: RegisterSupportAttachmentPartInput!) {\n registerSupportAttachmentPart(input: $input)\n }\n`;\n\nconst COMPLETE_UPLOAD_MUTATION = `\n mutation CompleteSupportAttachmentUpload($ticketId: ID!, $sessionId: ID!) {\n completeSupportAttachmentUpload(ticketId: $ticketId, sessionId: $sessionId) {\n id\n name\n mimeType\n size\n downloadUrl\n }\n }\n`;\n\nconst GET_ATTACHMENT_QUERY = `\n query SupportAttachment($ticketId: ID!, $fileId: ID!) {\n supportAttachment(ticketId: $ticketId, fileId: $fileId) {\n id\n name\n mimeType\n size\n downloadUrl\n }\n }\n`;\n\nfunction buildGlobalRequestContext() {\n return {\n gateway: 'global' as const,\n };\n}\n\nasync function uploadDirectFile(\n uploadUrl: string,\n file: File,\n onProgress?: (progress: number) => void\n): Promise<void> {\n await new Promise<void>((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n\n xhr.upload.addEventListener('progress', (event) => {\n if (event.lengthComputable) {\n onProgress?.(Math.round((event.loaded / event.total) * 100));\n }\n });\n\n xhr.addEventListener('load', () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n onProgress?.(100);\n resolve();\n return;\n }\n\n if (xhr.status === 403) {\n reject(\n new Error('Presigned URL expired before direct upload completed. Please try again.')\n );\n return;\n }\n\n reject(new Error(`Upload failed with status ${xhr.status}`));\n });\n\n xhr.addEventListener('error', () => reject(new Error('Upload failed')));\n xhr.addEventListener('abort', () => reject(new Error('Upload aborted')));\n\n xhr.open('PUT', uploadUrl);\n xhr.setRequestHeader('Content-Type', file.type || 'application/octet-stream');\n xhr.send(file);\n });\n}\n\nasync function uploadMultipartFile(\n ticketId: string,\n session: SupportAttachmentUploadSession,\n file: File,\n onProgress?: (progress: number) => void\n): Promise<void> {\n const uploadedBytesByPart = new Map<number, number>();\n const presignedMap = new Map(session.presignedUrls.map((part) => [part.partNumber, part.url]));\n\n const updateProgress = () => {\n const uploadedBytes = Array.from(uploadedBytesByPart.values()).reduce(\n (sum, value) => sum + value,\n 0\n );\n onProgress?.(Math.min(100, Math.round((uploadedBytes / file.size) * 100)));\n };\n\n const ensurePartUrl = async (partNumber: number) => {\n const existing = presignedMap.get(partNumber);\n if (existing) {\n return existing;\n }\n\n const response = await graphqlFetch<{\n getSupportAttachmentPartUploadUrls: Array<{ partNumber: number; url: string }>;\n }>({\n ...buildGlobalRequestContext(),\n query: GET_PART_URLS_MUTATION,\n variables: {\n ticketId,\n sessionId: session.sessionId,\n partNumbers: [partNumber],\n },\n operationName: 'GetSupportAttachmentPartUploadUrls',\n });\n\n const url = response.data?.getSupportAttachmentPartUploadUrls?.[0]?.url;\n if (response.errors?.length || !url) {\n throw new Error(response.errors?.[0]?.message || `Missing upload URL for part ${partNumber}`);\n }\n\n presignedMap.set(partNumber, url);\n return url;\n };\n\n for (let partNumber = 1; partNumber <= session.totalParts; partNumber += 1) {\n const start = (partNumber - 1) * session.partSize;\n const end = Math.min(start + session.partSize, file.size);\n const chunk = file.slice(start, end);\n let uploadUrl = await ensurePartUrl(partNumber);\n let response = await fetch(uploadUrl, {\n method: 'PUT',\n body: chunk,\n headers: {\n 'Content-Type': file.type || 'application/octet-stream',\n },\n });\n\n if (response.status === 403) {\n presignedMap.delete(partNumber);\n uploadUrl = await ensurePartUrl(partNumber);\n response = await fetch(uploadUrl, {\n method: 'PUT',\n body: chunk,\n headers: {\n 'Content-Type': file.type || 'application/octet-stream',\n },\n });\n }\n\n if (!response.ok) {\n if (response.status === 403) {\n throw new Error(`Presigned URL expired and retry failed for part ${partNumber}`);\n }\n throw new Error(`Failed to upload part ${partNumber}`);\n }\n\n uploadedBytesByPart.set(partNumber, chunk.size);\n updateProgress();\n\n const etag = response.headers.get('ETag') ?? `${partNumber}`;\n const registerResponse = await graphqlFetch<{ registerSupportAttachmentPart: boolean }>({\n ...buildGlobalRequestContext(),\n query: REGISTER_PART_MUTATION,\n variables: {\n input: {\n ticketId,\n sessionId: session.sessionId,\n partNumber,\n etag,\n },\n },\n operationName: 'RegisterSupportAttachmentPart',\n });\n\n if (registerResponse.errors?.length || !registerResponse.data?.registerSupportAttachmentPart) {\n throw new Error(\n registerResponse.errors?.[0]?.message || `Failed to register part ${partNumber}`\n );\n }\n }\n\n onProgress?.(100);\n}\n\nexport async function uploadSupportAttachmentFiles(options: {\n ticketId: string;\n files: File[];\n onFileProgress?: (fileName: string, progress: number) => void;\n}): Promise<{ files: SupportAttachmentRecord[] }> {\n const { ticketId, files, onFileProgress } = options;\n\n // Each file's upload pipeline (prepare → transfer → complete) is independent\n // of the others, so we run them concurrently.\n const uploadedFiles = await Promise.all(\n files.map(async (file) => {\n const extension = file.name.includes('.') ? (file.name.split('.').pop() ?? '') : '';\n const prepareResponse = await graphqlFetch<{\n prepareSupportAttachmentUpload: SupportAttachmentUploadSession;\n }>({\n ...buildGlobalRequestContext(),\n query: PREPARE_UPLOAD_MUTATION,\n variables: {\n input: {\n ticketId,\n fileName: file.name,\n fileSize: `${file.size}`,\n mimeType: file.type || 'application/octet-stream',\n extension,\n },\n },\n operationName: 'PrepareSupportAttachmentUpload',\n });\n\n const session = prepareResponse.data?.prepareSupportAttachmentUpload;\n if (prepareResponse.errors?.length || !session) {\n throw new Error(\n prepareResponse.errors?.[0]?.message || `Failed to prepare upload for ${file.name}`\n );\n }\n\n if (session.uploadUrl) {\n await uploadDirectFile(session.uploadUrl, file, (progress) =>\n onFileProgress?.(file.name, progress)\n );\n } else {\n await uploadMultipartFile(ticketId, session, file, (progress) =>\n onFileProgress?.(file.name, progress)\n );\n }\n\n const completeResponse = await graphqlFetch<{\n completeSupportAttachmentUpload: SupportAttachmentRecord;\n }>({\n ...buildGlobalRequestContext(),\n query: COMPLETE_UPLOAD_MUTATION,\n variables: {\n ticketId,\n sessionId: session.sessionId,\n },\n operationName: 'CompleteSupportAttachmentUpload',\n });\n\n const uploadedFile = completeResponse.data?.completeSupportAttachmentUpload;\n if (completeResponse.errors?.length || !uploadedFile) {\n throw new Error(\n completeResponse.errors?.[0]?.message || `Failed to finalize upload for ${file.name}`\n );\n }\n\n return uploadedFile;\n })\n );\n\n return {\n files: uploadedFiles,\n };\n}\n\nexport async function resolveSupportAttachmentFile(\n fileId: string,\n ticketId: string\n): Promise<SupportAttachmentRecord> {\n const response = await graphqlFetch<{\n supportAttachment: SupportAttachmentRecord;\n }>({\n ...buildGlobalRequestContext(),\n query: GET_ATTACHMENT_QUERY,\n variables: {\n ticketId,\n fileId,\n },\n operationName: 'SupportAttachment',\n });\n\n if (response.errors?.length || !response.data?.supportAttachment) {\n throw new Error(response.errors?.[0]?.message || `Failed to resolve attachment '${fileId}'`);\n }\n\n return response.data.supportAttachment;\n}\n"],"mappings":";;AAmBA,IAAM,IAA0B,yTAgB1B,IAAyB,yQASzB,IAAyB,sJAMzB,IAA2B,yPAY3B,IAAuB;AAY7B,SAAS,IAA4B;AACnC,QAAO,EACL,SAAS,UACV;;AAGH,eAAe,EACb,GACA,GACA,GACe;AACf,OAAM,IAAI,SAAe,GAAS,MAAW;EAC3C,IAAM,IAAM,IAAI,gBAAgB;AA8BhC,EA5BA,EAAI,OAAO,iBAAiB,aAAa,MAAU;AACjD,GAAI,EAAM,oBACR,IAAa,KAAK,MAAO,EAAM,SAAS,EAAM,QAAS,IAAI,CAAC;IAE9D,EAEF,EAAI,iBAAiB,cAAc;AACjC,OAAI,EAAI,UAAU,OAAO,EAAI,SAAS,KAAK;AAEzC,IADA,IAAa,I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AC9B,OAAO;GACP,WAAW,EACT,OAAO;IACL;IACA,UAAU,EAAK;IACf,UAAU,GAAG,EAAK;IAClB,UAAU,EAAK,QAAQ;IACvB;IACD,EACF;GACD,eAAe;GAChB,CAAC,EAEI,IAAU,EAAgB,MAAM;AACtC,MAAI,EAAgB,QAAQ,UAAU,CAAC,EACrC,OAAU,MACR,EAAgB,SAAS,IAAI,WAAW,gCAAgC,EAAK,OAC9E;AAGH,EAAI,EAAQ,YACV,MAAM,EAAiB,EAAQ,WAAW,IAAO,MAC/C,IAAiB,EAAK,MAAM,EAAS,CACtC,GAED,MAAM,EAAoB,GAAU,GAAS,IAAO,MAClD,IAAiB,EAAK,MAAM,EAAS,CACtC;EAGH,IAAM,IAAmB,MAAM,EAE5B;GACD,GAAG,GAA2B;GAC9B,OAAO;GACP,WAAW;IACT;IACA,WAAW,EAAQ;IACpB;GACD,eAAe;GAChB,CAAC,EAEI,IAAe,EAAiB,MAAM;AAC5C,MAAI,EAAiB,QAAQ,UAAU,CAAC,EACtC,OAAU,MACR,EAAiB,SAAS,IAAI,WAAW,iCAAiC,EAAK,OAChF;AAGH,SAAO;GACP,CACH,EAIA;;AAGH,eAAsB,EACpB,GACA,GACkC;CAClC,IAAM,IAAW,MAAM,EAEpB;EACD,GAAG,GAA2B;EAC9B,OAAO;EACP,WAAW;GACT;GACA;GACD;EACD,eAAe;EAChB,CAAC;AAEF,KAAI,EAAS,QAAQ,UAAU,CAAC,EAAS,MAAM,kBAC7C,OAAU,MAAM,EAAS,SAAS,IAAI,WAAW,iCAAiC,EAAO,GAAG;AAG9F,QAAO,EAAS,KAAK"}
|
|
1
|
+
{"version":3,"file":"supportFiles.js","names":[],"sources":["../../../src/support/utils/supportFiles.ts"],"sourcesContent":["import { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql/fetch';\n\nexport interface SupportAttachmentRecord {\n id: string;\n name: string;\n mimeType: string;\n size: string;\n downloadUrl: string;\n}\n\ninterface SupportAttachmentUploadSession {\n sessionId: string;\n uploadType: string;\n uploadUrl?: string | null;\n partSize: number;\n totalParts: number;\n presignedUrls: Array<{ partNumber: number; url: string }>;\n}\n\nconst PREPARE_UPLOAD_MUTATION = `\n mutation PrepareSupportAttachmentUpload($input: PrepareSupportAttachmentUploadInput!) {\n prepareSupportAttachmentUpload(input: $input) {\n sessionId\n uploadType\n uploadUrl\n partSize\n totalParts\n presignedUrls {\n partNumber\n url\n }\n }\n }\n`;\n\nconst GET_PART_URLS_MUTATION = `\n mutation GetSupportAttachmentPartUploadUrls($ticketId: ID!, $sessionId: ID!, $partNumbers: [Int!]!) {\n getSupportAttachmentPartUploadUrls(ticketId: $ticketId, sessionId: $sessionId, partNumbers: $partNumbers) {\n partNumber\n url\n }\n }\n`;\n\nconst REGISTER_PART_MUTATION = `\n mutation RegisterSupportAttachmentPart($input: RegisterSupportAttachmentPartInput!) {\n registerSupportAttachmentPart(input: $input)\n }\n`;\n\nconst COMPLETE_UPLOAD_MUTATION = `\n mutation CompleteSupportAttachmentUpload($ticketId: ID!, $sessionId: ID!) {\n completeSupportAttachmentUpload(ticketId: $ticketId, sessionId: $sessionId) {\n id\n name\n mimeType\n size\n downloadUrl\n }\n }\n`;\n\nconst GET_ATTACHMENT_QUERY = `\n query SupportAttachment($ticketId: ID!, $fileId: ID!) {\n supportAttachment(ticketId: $ticketId, fileId: $fileId) {\n id\n name\n mimeType\n size\n downloadUrl\n }\n }\n`;\n\nfunction buildGlobalRequestContext() {\n return {\n gateway: 'global' as const,\n };\n}\n\nasync function uploadDirectFile(\n uploadUrl: string,\n file: File,\n onProgress?: (progress: number) => void\n): Promise<void> {\n await new Promise<void>((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n\n xhr.upload.addEventListener('progress', (event) => {\n if (event.lengthComputable) {\n onProgress?.(Math.round((event.loaded / event.total) * 100));\n }\n });\n\n xhr.addEventListener('load', () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n onProgress?.(100);\n resolve();\n return;\n }\n\n if (xhr.status === 403) {\n reject(\n new Error('Presigned URL expired before direct upload completed. Please try again.')\n );\n return;\n }\n\n reject(new Error(`Upload failed with status ${xhr.status}`));\n });\n\n xhr.addEventListener('error', () => reject(new Error('Upload failed')));\n xhr.addEventListener('abort', () => reject(new Error('Upload aborted')));\n\n xhr.open('PUT', uploadUrl);\n xhr.setRequestHeader('Content-Type', file.type || 'application/octet-stream');\n xhr.send(file);\n });\n}\n\nasync function uploadMultipartFile(\n ticketId: string,\n session: SupportAttachmentUploadSession,\n file: File,\n onProgress?: (progress: number) => void\n): Promise<void> {\n const uploadedBytesByPart = new Map<number, number>();\n const presignedMap = new Map(session.presignedUrls.map((part) => [part.partNumber, part.url]));\n\n const updateProgress = () => {\n const uploadedBytes = Array.from(uploadedBytesByPart.values()).reduce(\n (sum, value) => sum + value,\n 0\n );\n onProgress?.(Math.min(100, Math.round((uploadedBytes / file.size) * 100)));\n };\n\n const ensurePartUrl = async (partNumber: number) => {\n const existing = presignedMap.get(partNumber);\n if (existing) {\n return existing;\n }\n\n const response = await graphqlFetch<{\n getSupportAttachmentPartUploadUrls: Array<{ partNumber: number; url: string }>;\n }>({\n ...buildGlobalRequestContext(),\n query: GET_PART_URLS_MUTATION,\n variables: {\n ticketId,\n sessionId: session.sessionId,\n partNumbers: [partNumber],\n },\n operationName: 'GetSupportAttachmentPartUploadUrls',\n });\n\n const url = response.data?.getSupportAttachmentPartUploadUrls?.[0]?.url;\n if (response.errors?.length || !url) {\n throw new Error(response.errors?.[0]?.message || `Missing upload URL for part ${partNumber}`);\n }\n\n presignedMap.set(partNumber, url);\n return url;\n };\n\n for (let partNumber = 1; partNumber <= session.totalParts; partNumber += 1) {\n const start = (partNumber - 1) * session.partSize;\n const end = Math.min(start + session.partSize, file.size);\n const chunk = file.slice(start, end);\n let uploadUrl = await ensurePartUrl(partNumber);\n let response = await fetch(uploadUrl, {\n method: 'PUT',\n body: chunk,\n headers: {\n 'Content-Type': file.type || 'application/octet-stream',\n },\n });\n\n if (response.status === 403) {\n presignedMap.delete(partNumber);\n uploadUrl = await ensurePartUrl(partNumber);\n response = await fetch(uploadUrl, {\n method: 'PUT',\n body: chunk,\n headers: {\n 'Content-Type': file.type || 'application/octet-stream',\n },\n });\n }\n\n if (!response.ok) {\n if (response.status === 403) {\n throw new Error(`Presigned URL expired and retry failed for part ${partNumber}`);\n }\n throw new Error(`Failed to upload part ${partNumber}`);\n }\n\n uploadedBytesByPart.set(partNumber, chunk.size);\n updateProgress();\n\n const etag = response.headers.get('ETag') ?? `${partNumber}`;\n const registerResponse = await graphqlFetch<{ registerSupportAttachmentPart: boolean }>({\n ...buildGlobalRequestContext(),\n query: REGISTER_PART_MUTATION,\n variables: {\n input: {\n ticketId,\n sessionId: session.sessionId,\n partNumber,\n etag,\n },\n },\n operationName: 'RegisterSupportAttachmentPart',\n });\n\n if (registerResponse.errors?.length || !registerResponse.data?.registerSupportAttachmentPart) {\n throw new Error(\n registerResponse.errors?.[0]?.message || `Failed to register part ${partNumber}`\n );\n }\n }\n\n onProgress?.(100);\n}\n\nexport async function uploadSupportAttachmentFiles(options: {\n ticketId: string;\n files: File[];\n onFileProgress?: (fileName: string, progress: number) => void;\n}): Promise<{ files: SupportAttachmentRecord[] }> {\n const { ticketId, files, onFileProgress } = options;\n\n // Each file's upload pipeline (prepare → transfer → complete) is independent\n // of the others, so we run them concurrently.\n const uploadedFiles = await Promise.all(\n files.map(async (file) => {\n const extension = file.name.includes('.') ? (file.name.split('.').pop() ?? '') : '';\n const prepareResponse = await graphqlFetch<{\n prepareSupportAttachmentUpload: SupportAttachmentUploadSession;\n }>({\n ...buildGlobalRequestContext(),\n query: PREPARE_UPLOAD_MUTATION,\n variables: {\n input: {\n ticketId,\n fileName: file.name,\n fileSize: `${file.size}`,\n mimeType: file.type || 'application/octet-stream',\n extension,\n },\n },\n operationName: 'PrepareSupportAttachmentUpload',\n });\n\n const session = prepareResponse.data?.prepareSupportAttachmentUpload;\n if (prepareResponse.errors?.length || !session) {\n throw new Error(\n prepareResponse.errors?.[0]?.message || `Failed to prepare upload for ${file.name}`\n );\n }\n\n if (session.uploadUrl) {\n await uploadDirectFile(session.uploadUrl, file, (progress) =>\n onFileProgress?.(file.name, progress)\n );\n } else {\n await uploadMultipartFile(ticketId, session, file, (progress) =>\n onFileProgress?.(file.name, progress)\n );\n }\n\n const completeResponse = await graphqlFetch<{\n completeSupportAttachmentUpload: SupportAttachmentRecord;\n }>({\n ...buildGlobalRequestContext(),\n query: COMPLETE_UPLOAD_MUTATION,\n variables: {\n ticketId,\n sessionId: session.sessionId,\n },\n operationName: 'CompleteSupportAttachmentUpload',\n });\n\n const uploadedFile = completeResponse.data?.completeSupportAttachmentUpload;\n if (completeResponse.errors?.length || !uploadedFile) {\n throw new Error(\n completeResponse.errors?.[0]?.message || `Failed to finalize upload for ${file.name}`\n );\n }\n\n return uploadedFile;\n })\n );\n\n return {\n files: uploadedFiles,\n };\n}\n\nexport async function resolveSupportAttachmentFile(\n fileId: string,\n ticketId: string\n): Promise<SupportAttachmentRecord> {\n const response = await graphqlFetch<{\n supportAttachment: SupportAttachmentRecord;\n }>({\n ...buildGlobalRequestContext(),\n query: GET_ATTACHMENT_QUERY,\n variables: {\n ticketId,\n fileId,\n },\n operationName: 'SupportAttachment',\n });\n\n if (response.errors?.length || !response.data?.supportAttachment) {\n throw new Error(response.errors?.[0]?.message || `Failed to resolve attachment '${fileId}'`);\n }\n\n return response.data.supportAttachment;\n}\n"],"mappings":";;AAmBA,IAAM,IAA0B,yTAgB1B,IAAyB,yQASzB,IAAyB,sJAMzB,IAA2B,yPAY3B,IAAuB;AAY7B,SAAS,IAA4B;CACnC,OAAO,EACL,SAAS,SACX;AACF;AAEA,eAAe,EACb,GACA,GACA,GACe;CACf,MAAM,IAAI,SAAe,GAAS,MAAW;EAC3C,IAAM,IAAM,IAAI,eAAe;EA8B/B,AA5BA,EAAI,OAAO,iBAAiB,aAAa,MAAU;GACjD,AAAI,EAAM,oBACR,IAAa,KAAK,MAAO,EAAM,SAA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ACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ticketFilters.js","names":[],"sources":["../../../src/support/utils/ticketFilters.ts"],"sourcesContent":["import {\n SupportTicketPriority,\n SupportTicketStatus,\n type SupportTicket,\n type SupportTicketFilterInput,\n} from '../../generated/global-types';\nimport type { TicketFilters } from '../store/supportStore';\n\nfunction mapStatusToEnum(status: string): SupportTicketStatus | undefined {\n const statusMap: Record<string, SupportTicketStatus> = {\n NEW: SupportTicketStatus.New,\n IN_PROGRESS: SupportTicketStatus.InProgress,\n RESOLVED: SupportTicketStatus.Resolved,\n CLOSED: SupportTicketStatus.Closed,\n REOPENED: SupportTicketStatus.Reopened,\n };\n return statusMap[status];\n}\n\nfunction mapPriorityToEnum(priority: string): SupportTicketPriority | undefined {\n const priorityMap: Record<string, SupportTicketPriority> = {\n CRITICAL: SupportTicketPriority.Critical,\n HIGH: SupportTicketPriority.High,\n NORMAL: SupportTicketPriority.Normal,\n LOW: SupportTicketPriority.Low,\n };\n return priorityMap[priority];\n}\n\nexport function buildTicketFilter(\n ticketFilter: TicketFilters\n): SupportTicketFilterInput | undefined {\n const filter: SupportTicketFilterInput = {};\n\n if (ticketFilter.status && ticketFilter.status !== 'all') {\n const statusEnum = mapStatusToEnum(ticketFilter.status);\n if (statusEnum) filter.status = statusEnum;\n }\n\n if (ticketFilter.priority && ticketFilter.priority !== 'all') {\n const priorityEnum = mapPriorityToEnum(ticketFilter.priority);\n if (priorityEnum) filter.priority = priorityEnum;\n }\n\n if (ticketFilter.categoryId) filter.categoryId = ticketFilter.categoryId;\n if (ticketFilter.assignedToId) filter.assignedTo = ticketFilter.assignedToId;\n if (ticketFilter.dateRange.start) filter.startDate = ticketFilter.dateRange.start.toISOString();\n if (ticketFilter.dateRange.end) filter.endDate = ticketFilter.dateRange.end.toISOString();\n if (ticketFilter.productId) {\n filter.context = {\n productId: ticketFilter.productId,\n };\n }\n\n return Object.keys(filter).length > 0 ? filter : undefined;\n}\n\nexport function scopeTicketFilterToProduct(\n filter: SupportTicketFilterInput | undefined,\n productId: string | undefined\n): SupportTicketFilterInput | undefined {\n if (!productId) return filter;\n\n return {\n ...filter,\n context: {\n ...filter?.context,\n productId,\n },\n };\n}\n\nexport function matchesTicketClientFilters(\n ticket: SupportTicket,\n ticketFilter: TicketFilters\n): boolean {\n if (ticketFilter.status !== 'all' && ticket.status !== ticketFilter.status) return false;\n if (ticketFilter.priority !== 'all' && ticket.priority !== ticketFilter.priority) return false;\n if (ticketFilter.categoryId && ticket.categoryId !== ticketFilter.categoryId) return false;\n if (ticketFilter.assignedToId && ticket.assignedTo !== ticketFilter.assignedToId) return false;\n if (ticketFilter.productId && ticket.context?.productId !== ticketFilter.productId) return false;\n\n if (ticketFilter.dateRange.start || ticketFilter.dateRange.end) {\n const createdAt = new Date(ticket.createdAt);\n if (ticketFilter.dateRange.start && createdAt < ticketFilter.dateRange.start) return false;\n if (ticketFilter.dateRange.end && createdAt > ticketFilter.dateRange.end) return false;\n }\n\n return true;\n}\n\nexport function matchesTicketSearch(ticket: SupportTicket, query: string): boolean {\n const normalizedQuery = query.trim().toLowerCase();\n if (!normalizedQuery) return true;\n const searchableDescription = ticket.description?.slice(0, 2000);\n // Search both legacy category text and the normalized category relation while tickets migrate.\n const searchableText = [\n ticket.subject,\n searchableDescription,\n ticket.ticketNumber,\n ticket.category,\n ticket.ticketCategory?.name,\n ]\n .filter((value): value is string => Boolean(value))\n .join(' ')\n .toLowerCase();\n\n const terms = normalizedQuery.split(/\\s+/);\n return terms.every((term) => searchableText.includes(term));\n}\n"],"mappings":";;AAQA,SAAS,EAAgB,GAAiD;
|
|
1
|
+
{"version":3,"file":"ticketFilters.js","names":[],"sources":["../../../src/support/utils/ticketFilters.ts"],"sourcesContent":["import {\n SupportTicketPriority,\n SupportTicketStatus,\n type SupportTicket,\n type SupportTicketFilterInput,\n} from '../../generated/global-types';\nimport type { TicketFilters } from '../store/supportStore';\n\nfunction mapStatusToEnum(status: string): SupportTicketStatus | undefined {\n const statusMap: Record<string, SupportTicketStatus> = {\n NEW: SupportTicketStatus.New,\n IN_PROGRESS: SupportTicketStatus.InProgress,\n RESOLVED: SupportTicketStatus.Resolved,\n CLOSED: SupportTicketStatus.Closed,\n REOPENED: SupportTicketStatus.Reopened,\n };\n return statusMap[status];\n}\n\nfunction mapPriorityToEnum(priority: string): SupportTicketPriority | undefined {\n const priorityMap: Record<string, SupportTicketPriority> = {\n CRITICAL: SupportTicketPriority.Critical,\n HIGH: SupportTicketPriority.High,\n NORMAL: SupportTicketPriority.Normal,\n LOW: SupportTicketPriority.Low,\n };\n return priorityMap[priority];\n}\n\nexport function buildTicketFilter(\n ticketFilter: TicketFilters\n): SupportTicketFilterInput | undefined {\n const filter: SupportTicketFilterInput = {};\n\n if (ticketFilter.status && ticketFilter.status !== 'all') {\n const statusEnum = mapStatusToEnum(ticketFilter.status);\n if (statusEnum) filter.status = statusEnum;\n }\n\n if (ticketFilter.priority && ticketFilter.priority !== 'all') {\n const priorityEnum = mapPriorityToEnum(ticketFilter.priority);\n if (priorityEnum) filter.priority = priorityEnum;\n }\n\n if (ticketFilter.categoryId) filter.categoryId = ticketFilter.categoryId;\n if (ticketFilter.assignedToId) filter.assignedTo = ticketFilter.assignedToId;\n if (ticketFilter.dateRange.start) filter.startDate = ticketFilter.dateRange.start.toISOString();\n if (ticketFilter.dateRange.end) filter.endDate = ticketFilter.dateRange.end.toISOString();\n if (ticketFilter.productId) {\n filter.context = {\n productId: ticketFilter.productId,\n };\n }\n\n return Object.keys(filter).length > 0 ? filter : undefined;\n}\n\nexport function scopeTicketFilterToProduct(\n filter: SupportTicketFilterInput | undefined,\n productId: string | undefined\n): SupportTicketFilterInput | undefined {\n if (!productId) return filter;\n\n return {\n ...filter,\n context: {\n ...filter?.context,\n productId,\n },\n };\n}\n\nexport function matchesTicketClientFilters(\n ticket: SupportTicket,\n ticketFilter: TicketFilters\n): boolean {\n if (ticketFilter.status !== 'all' && ticket.status !== ticketFilter.status) return false;\n if (ticketFilter.priority !== 'all' && ticket.priority !== ticketFilter.priority) return false;\n if (ticketFilter.categoryId && ticket.categoryId !== ticketFilter.categoryId) return false;\n if (ticketFilter.assignedToId && ticket.assignedTo !== ticketFilter.assignedToId) return false;\n if (ticketFilter.productId && ticket.context?.productId !== ticketFilter.productId) return false;\n\n if (ticketFilter.dateRange.start || ticketFilter.dateRange.end) {\n const createdAt = new Date(ticket.createdAt);\n if (ticketFilter.dateRange.start && createdAt < ticketFilter.dateRange.start) return false;\n if (ticketFilter.dateRange.end && createdAt > ticketFilter.dateRange.end) return false;\n }\n\n return true;\n}\n\nexport function matchesTicketSearch(ticket: SupportTicket, query: string): boolean {\n const normalizedQuery = query.trim().toLowerCase();\n if (!normalizedQuery) return true;\n const searchableDescription = ticket.description?.slice(0, 2000);\n // Search both legacy category text and the normalized category relation while tickets migrate.\n const searchableText = [\n ticket.subject,\n searchableDescription,\n ticket.ticketNumber,\n ticket.category,\n ticket.ticketCategory?.name,\n ]\n .filter((value): value is string => Boolean(value))\n .join(' ')\n .toLowerCase();\n\n const terms = normalizedQuery.split(/\\s+/);\n return terms.every((term) => searchableText.includes(term));\n}\n"],"mappings":";;AAQA,SAAS,EAAgB,GAAiD;CAQxE,OAAO;EANL,KAAK,EAAoB;EACzB,aAAa,EAAoB;EACjC,UAAU,EAAoB;EAC9B,QAAQ,EAAoB;EAC5B,UAAU,EAAoB;CAEzB,EAAU;AACnB;AAEA,SAAS,EAAkB,GAAqD;CAO9E,OAAO;EALL,UAAU,EAAsB;EAChC,MAAM,EAAsB;EAC5B,QAAQ,EAAsB;EAC9B,KAAK,EAAsB;CAEtB,EAAY;AACrB;AAEA,SAAgB,EACd,GACsC;CACtC,IAAM,IAAmC,CAAC;CAE1C,IAAI,EAAa,UAAU,EAAa,WAAW,OAAO;EACxD,IAAM,IAAa,EAAgB,EAAa,MAAM;EACtD,AAAI,MAAY,EAAO,SAAS;CAClC;CAEA,IAAI,EAAa,YAAY,EAAa,aAAa,OAAO;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