@krak-stack/notifications-admin 0.1.0 → 0.2.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/CHANGELOG.md +25 -0
- package/README.md +191 -3
- package/dist/atoms.d.ts +1 -0
- package/dist/atoms.js +33 -14
- package/dist/chunk-4r5x0qzz.js +522 -0
- package/dist/chunk-aqmv7g24.js +29 -0
- package/dist/{chunk-8nawv50q.js → chunk-d32m2dmf.js} +185 -145
- package/dist/chunk-ghs5tkqn.js +37 -0
- package/dist/client-options.d.ts +9 -0
- package/dist/deliveries.d.ts +69 -1
- package/dist/deliveries.js +11 -2
- package/dist/delivery.atom.d.ts +95 -9
- package/dist/hooks.d.ts +21 -0
- package/dist/hooks.js +6 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +25 -3
- package/dist/operations.atom.d.ts +6 -4
- package/dist/operations.d.ts +39 -1
- package/dist/operations.js +9 -2
- package/dist/presentation.d.ts +25 -0
- package/dist/presentation.js +10 -0
- package/package.json +15 -7
- package/dist/chunk-nk9ge6g9.js +0 -378
|
@@ -9,17 +9,20 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
Tabs,
|
|
11
11
|
TabsList,
|
|
12
|
-
TabsTrigger
|
|
13
|
-
|
|
12
|
+
TabsTrigger,
|
|
13
|
+
NotificationAttemptHistory2
|
|
14
|
+
} from "./chunk-4r5x0qzz.js";
|
|
15
|
+
import {
|
|
16
|
+
NotificationTable2,
|
|
17
|
+
NotificationReference2
|
|
18
|
+
} from "./chunk-aqmv7g24.js";
|
|
14
19
|
|
|
15
20
|
// src/operations.tsx
|
|
16
21
|
import { useState } from "react";
|
|
17
22
|
import { Effect, Schema } from "effect";
|
|
18
23
|
import * as S from "@krak-stack/notifications/admin/operations.schema";
|
|
19
|
-
import {
|
|
20
|
-
DataTable
|
|
21
|
-
} from "@krak-stack/registry/data-table";
|
|
22
24
|
import { useAppForm } from "@krak-stack/registry/form";
|
|
25
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
23
26
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
24
27
|
var views = S.OperationsView.literals;
|
|
25
28
|
var metricKeys = [
|
|
@@ -45,10 +48,15 @@ var Records = ({
|
|
|
45
48
|
items,
|
|
46
49
|
columns,
|
|
47
50
|
m,
|
|
48
|
-
table
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
table,
|
|
52
|
+
tableId,
|
|
53
|
+
tableOptions
|
|
54
|
+
}) => /* @__PURE__ */ jsx(NotificationTable2, {
|
|
55
|
+
notificationTable: tableId,
|
|
56
|
+
initialState: tableOptions?.initialState,
|
|
57
|
+
className: tableOptions?.className,
|
|
58
|
+
rowData: table?.status?.error ? [] : items ?? [],
|
|
59
|
+
columnDefs: (tableOptions?.columns?.(columns) ?? columns).map((column) => column.colId === "inspect" || column.colId === "remove" ? {
|
|
52
60
|
...column,
|
|
53
61
|
sortable: false,
|
|
54
62
|
filterable: false,
|
|
@@ -63,6 +71,15 @@ var Records = ({
|
|
|
63
71
|
},
|
|
64
72
|
...table
|
|
65
73
|
});
|
|
74
|
+
var recordControls = (p) => ({
|
|
75
|
+
state: p.tableState,
|
|
76
|
+
onStateChange: p.onTableStateChange,
|
|
77
|
+
status: { loading: p.pending, error: p.error },
|
|
78
|
+
features: {
|
|
79
|
+
pagination: p.total === undefined ? { mode: "client" } : { mode: "server", rowCount: p.error ? 0 : p.total },
|
|
80
|
+
refresh: p.onRefresh
|
|
81
|
+
}
|
|
82
|
+
});
|
|
66
83
|
var OverviewWindowForm2 = ({
|
|
67
84
|
filters,
|
|
68
85
|
m,
|
|
@@ -129,7 +146,11 @@ var SuppressionDialog = ({
|
|
|
129
146
|
onSubmit: async ({ value }) => {
|
|
130
147
|
setFailure(undefined);
|
|
131
148
|
try {
|
|
132
|
-
if (record)
|
|
149
|
+
if (record && !onRemove || !record && !onAdd) {
|
|
150
|
+
setFailure(m.failed);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (record && onRemove)
|
|
133
154
|
await onRemove({
|
|
134
155
|
id: record.id,
|
|
135
156
|
payload: {
|
|
@@ -138,7 +159,7 @@ var SuppressionDialog = ({
|
|
|
138
159
|
reason: value.reason
|
|
139
160
|
}
|
|
140
161
|
});
|
|
141
|
-
else
|
|
162
|
+
else if (onAdd)
|
|
142
163
|
await onAdd({ requestId, email: value.email, reason: value.reason });
|
|
143
164
|
onClose();
|
|
144
165
|
} catch {
|
|
@@ -215,56 +236,10 @@ var SuppressionDialog = ({
|
|
|
215
236
|
})
|
|
216
237
|
});
|
|
217
238
|
};
|
|
218
|
-
var
|
|
219
|
-
const
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
onStateChange: p.onTableStateChange,
|
|
223
|
-
status: { loading: p.pending, error: p.error },
|
|
224
|
-
features: {
|
|
225
|
-
pagination: p.total === undefined ? { mode: "client" } : { mode: "server", rowCount: p.total },
|
|
226
|
-
refresh: p.onRefresh
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
const [manage, setManage] = useState();
|
|
230
|
-
const date = (value) => value ? value.toLocaleString() : m.never;
|
|
231
|
-
const activityColumns = [
|
|
232
|
-
{ field: "email", headerName: m.email },
|
|
233
|
-
{ field: "subject", headerName: m.subject },
|
|
234
|
-
{
|
|
235
|
-
field: "status",
|
|
236
|
-
headerName: m.status,
|
|
237
|
-
filterOptions: Object.entries(m.statuses).map(([value, label]) => ({
|
|
238
|
-
value,
|
|
239
|
-
label
|
|
240
|
-
})),
|
|
241
|
-
cellRenderer: ({ data }) => m.statuses[data.status]
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
field: "campaignName",
|
|
245
|
-
headerName: m.campaign,
|
|
246
|
-
cellRenderer: ({ data }) => data.campaignId && p.onCampaign ? /* @__PURE__ */ jsx(Button, {
|
|
247
|
-
variant: "link",
|
|
248
|
-
onClick: () => p.onCampaign?.(data.campaignId),
|
|
249
|
-
children: data.campaignName
|
|
250
|
-
}) : data.campaignName ?? "—"
|
|
251
|
-
},
|
|
252
|
-
{ field: "attempts", headerName: m.attempts, type: "number" },
|
|
253
|
-
{ field: "provider", headerName: m.provider },
|
|
254
|
-
{ field: "errorMessage", headerName: m.reason },
|
|
255
|
-
{ field: "createdAt", headerName: m.created, type: "date" },
|
|
256
|
-
{ field: "scheduledFor", headerName: m.scheduled, type: "date" },
|
|
257
|
-
{ field: "sentAt", headerName: m.accepted, type: "date" },
|
|
258
|
-
{
|
|
259
|
-
colId: "inspect",
|
|
260
|
-
headerName: m.inspect,
|
|
261
|
-
cellRenderer: ({ data }) => /* @__PURE__ */ jsx(Button, {
|
|
262
|
-
variant: "outline",
|
|
263
|
-
onClick: () => p.onInspect(data.id),
|
|
264
|
-
children: m.inspect
|
|
265
|
-
})
|
|
266
|
-
}
|
|
267
|
-
];
|
|
239
|
+
var NotificationFeedbackTable2 = (p) => {
|
|
240
|
+
const m = p.messages;
|
|
241
|
+
const locale = useKrakstackLocale();
|
|
242
|
+
const date = (value) => value ? value.toLocaleString(locale) : m.never;
|
|
268
243
|
const feedbackColumns = [
|
|
269
244
|
{ field: "recipientAddress", headerName: m.email },
|
|
270
245
|
{
|
|
@@ -323,6 +298,23 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
323
298
|
}) : "—"
|
|
324
299
|
}
|
|
325
300
|
];
|
|
301
|
+
return /* @__PURE__ */ jsx(Records, {
|
|
302
|
+
items: p.items,
|
|
303
|
+
columns: feedbackColumns,
|
|
304
|
+
m,
|
|
305
|
+
table: recordControls(p),
|
|
306
|
+
tableId: "feedback",
|
|
307
|
+
tableOptions: p.tableOptions
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
var NotificationSuppressions2 = (p) => {
|
|
311
|
+
const m = p.messages;
|
|
312
|
+
const locale = useKrakstackLocale();
|
|
313
|
+
const date = (value) => value ? value.toLocaleString(locale) : m.never;
|
|
314
|
+
const [manage, setManage] = useState();
|
|
315
|
+
const canManage = manage === null ? !!p.onAddSuppression : !!p.onRemoveSuppression;
|
|
316
|
+
if ((p.error || !canManage) && manage !== undefined)
|
|
317
|
+
setManage(undefined);
|
|
326
318
|
const suppressionColumns = [
|
|
327
319
|
{ field: "email", headerName: m.email },
|
|
328
320
|
{
|
|
@@ -360,6 +352,34 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
360
352
|
})
|
|
361
353
|
}
|
|
362
354
|
];
|
|
355
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
356
|
+
children: [
|
|
357
|
+
!p.error && p.onAddSuppression && /* @__PURE__ */ jsx(Button, {
|
|
358
|
+
onClick: () => setManage(null),
|
|
359
|
+
children: m.addSuppression
|
|
360
|
+
}),
|
|
361
|
+
/* @__PURE__ */ jsx(Records, {
|
|
362
|
+
items: p.items,
|
|
363
|
+
columns: p.onRemoveSuppression ? suppressionColumns : suppressionColumns.filter((column) => column.colId !== "remove"),
|
|
364
|
+
m,
|
|
365
|
+
table: recordControls(p),
|
|
366
|
+
tableId: "suppressions",
|
|
367
|
+
tableOptions: p.tableOptions
|
|
368
|
+
}),
|
|
369
|
+
!p.error && canManage && manage !== undefined && /* @__PURE__ */ jsx(SuppressionDialog, {
|
|
370
|
+
record: manage,
|
|
371
|
+
m,
|
|
372
|
+
onAdd: p.onAddSuppression,
|
|
373
|
+
onRemove: p.onRemoveSuppression,
|
|
374
|
+
onClose: () => setManage(undefined)
|
|
375
|
+
})
|
|
376
|
+
]
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
var NotificationSuppressionAudit2 = (p) => {
|
|
380
|
+
const m = p.messages;
|
|
381
|
+
const locale = useKrakstackLocale();
|
|
382
|
+
const date = (value) => value ? value.toLocaleString(locale) : m.never;
|
|
363
383
|
const auditColumns = [
|
|
364
384
|
{ field: "email", headerName: m.email },
|
|
365
385
|
{
|
|
@@ -383,13 +403,71 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
383
403
|
{ field: "requestId", headerName: m.requestId },
|
|
384
404
|
{ field: "suppressionId", headerName: m.id }
|
|
385
405
|
];
|
|
406
|
+
return /* @__PURE__ */ jsx(Records, {
|
|
407
|
+
items: p.items?.map((row) => ({ ...row, id: row.requestId })),
|
|
408
|
+
columns: auditColumns,
|
|
409
|
+
m,
|
|
410
|
+
table: recordControls(p),
|
|
411
|
+
tableId: "suppression-audit",
|
|
412
|
+
tableOptions: p.tableOptions
|
|
413
|
+
});
|
|
414
|
+
};
|
|
415
|
+
var SendOperationsAdmin2 = (p) => {
|
|
416
|
+
const { messages: m, view } = p;
|
|
417
|
+
const locale = useKrakstackLocale();
|
|
418
|
+
const date = (value) => value ? value.toLocaleString(locale) : m.never;
|
|
419
|
+
const tableControls = recordControls(p);
|
|
420
|
+
const visibleViews = p.views ?? views;
|
|
421
|
+
const activityColumns = [
|
|
422
|
+
{ field: "email", headerName: m.email },
|
|
423
|
+
{ field: "subject", headerName: m.subject },
|
|
424
|
+
{
|
|
425
|
+
field: "status",
|
|
426
|
+
headerName: m.status,
|
|
427
|
+
filterOptions: Object.entries(m.statuses).map(([value, label]) => ({
|
|
428
|
+
value,
|
|
429
|
+
label
|
|
430
|
+
})),
|
|
431
|
+
cellRenderer: ({ data }) => m.statuses[data.status]
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
field: "campaignName",
|
|
435
|
+
headerName: m.campaign,
|
|
436
|
+
cellRenderer: ({ data }) => data.campaignId && p.onCampaign ? /* @__PURE__ */ jsx(Button, {
|
|
437
|
+
variant: "link",
|
|
438
|
+
onClick: () => {
|
|
439
|
+
if (data.campaignId)
|
|
440
|
+
p.onCampaign?.(data.campaignId);
|
|
441
|
+
},
|
|
442
|
+
children: data.campaignName
|
|
443
|
+
}) : data.campaignName ?? "—"
|
|
444
|
+
},
|
|
445
|
+
{ field: "attempts", headerName: m.attempts, type: "number" },
|
|
446
|
+
{ field: "provider", headerName: m.provider },
|
|
447
|
+
{ field: "errorMessage", headerName: m.reason },
|
|
448
|
+
{ field: "createdAt", headerName: m.created, type: "date" },
|
|
449
|
+
{ field: "scheduledFor", headerName: m.scheduled, type: "date" },
|
|
450
|
+
{ field: "sentAt", headerName: m.accepted, type: "date" },
|
|
451
|
+
{
|
|
452
|
+
colId: "inspect",
|
|
453
|
+
headerName: m.inspect,
|
|
454
|
+
cellRenderer: ({ data }) => /* @__PURE__ */ jsx(Button, {
|
|
455
|
+
variant: "outline",
|
|
456
|
+
onClick: () => p.onInspect(data.id),
|
|
457
|
+
children: m.inspect
|
|
458
|
+
})
|
|
459
|
+
}
|
|
460
|
+
];
|
|
386
461
|
const recipientColumns = [
|
|
387
462
|
{ field: "email", headerName: m.email },
|
|
388
463
|
{
|
|
389
464
|
field: "status",
|
|
390
465
|
headerName: m.status,
|
|
391
466
|
cellRenderer: ({ data }) => m.recipientStatuses[data.status],
|
|
392
|
-
filterOptions: Object.entries(m.recipientStatuses).map(([value, label]) => ({
|
|
467
|
+
filterOptions: Object.entries(m.recipientStatuses).map(([value, label]) => ({
|
|
468
|
+
value,
|
|
469
|
+
label
|
|
470
|
+
}))
|
|
393
471
|
},
|
|
394
472
|
{ field: "reason", headerName: m.reason },
|
|
395
473
|
{
|
|
@@ -403,11 +481,13 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
403
481
|
}
|
|
404
482
|
];
|
|
405
483
|
const delivery = p.inspection?.delivery;
|
|
484
|
+
if (!visibleViews.includes(view))
|
|
485
|
+
return null;
|
|
406
486
|
return /* @__PURE__ */ jsxs("section", {
|
|
407
487
|
className: "space-y-4",
|
|
408
488
|
"aria-busy": p.pending,
|
|
409
489
|
children: [
|
|
410
|
-
/* @__PURE__ */ jsxs("header", {
|
|
490
|
+
p.header !== false && /* @__PURE__ */ jsxs("header", {
|
|
411
491
|
className: "flex items-start justify-between gap-4",
|
|
412
492
|
children: [
|
|
413
493
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -428,13 +508,17 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
428
508
|
})
|
|
429
509
|
]
|
|
430
510
|
}),
|
|
431
|
-
/* @__PURE__ */ jsx(Tabs, {
|
|
511
|
+
p.navigation !== false && /* @__PURE__ */ jsx(Tabs, {
|
|
432
512
|
value: view,
|
|
433
|
-
onValueChange: (value) =>
|
|
513
|
+
onValueChange: (value) => {
|
|
514
|
+
const next = Schema.decodeUnknownSync(S.OperationsView)(value);
|
|
515
|
+
if (visibleViews.includes(next))
|
|
516
|
+
p.onView(next);
|
|
517
|
+
},
|
|
434
518
|
children: /* @__PURE__ */ jsx(TabsList, {
|
|
435
519
|
className: "h-auto flex-wrap",
|
|
436
520
|
"aria-label": m.title,
|
|
437
|
-
children:
|
|
521
|
+
children: visibleViews.map((v) => /* @__PURE__ */ jsx(TabsTrigger, {
|
|
438
522
|
value: v,
|
|
439
523
|
children: m.views[v]
|
|
440
524
|
}, v))
|
|
@@ -471,7 +555,7 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
471
555
|
role: "status",
|
|
472
556
|
children: m.loading
|
|
473
557
|
}),
|
|
474
|
-
view === "overview" && p.overview && /* @__PURE__ */ jsx("dl", {
|
|
558
|
+
view === "overview" && p.overview && !p.error && /* @__PURE__ */ jsx("dl", {
|
|
475
559
|
className: "grid gap-3 sm:grid-cols-3",
|
|
476
560
|
children: metricKeys.map((key) => /* @__PURE__ */ jsxs("div", {
|
|
477
561
|
role: "group",
|
|
@@ -492,38 +576,26 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
492
576
|
items: p.activity?.items,
|
|
493
577
|
columns: activityColumns,
|
|
494
578
|
m,
|
|
495
|
-
table: tableControls
|
|
579
|
+
table: tableControls,
|
|
580
|
+
tableId: "operations-activity"
|
|
496
581
|
}),
|
|
497
|
-
view === "feedback" && /* @__PURE__ */ jsx(
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
m,
|
|
501
|
-
table: tableControls
|
|
582
|
+
view === "feedback" && /* @__PURE__ */ jsx(NotificationFeedbackTable2, {
|
|
583
|
+
...p,
|
|
584
|
+
items: p.feedback?.items
|
|
502
585
|
}),
|
|
503
|
-
view === "suppressions" && /* @__PURE__ */
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
onClick: () => setManage(null),
|
|
507
|
-
children: m.addSuppression
|
|
508
|
-
}),
|
|
509
|
-
/* @__PURE__ */ jsx(Records, {
|
|
510
|
-
items: p.suppressions?.items,
|
|
511
|
-
columns: suppressionColumns,
|
|
512
|
-
table: tableControls,
|
|
513
|
-
m
|
|
514
|
-
})
|
|
515
|
-
]
|
|
586
|
+
view === "suppressions" && /* @__PURE__ */ jsx(NotificationSuppressions2, {
|
|
587
|
+
...p,
|
|
588
|
+
items: p.suppressions?.items
|
|
516
589
|
}),
|
|
517
|
-
view === "audit" && /* @__PURE__ */ jsx(
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
table: tableControls,
|
|
521
|
-
m
|
|
590
|
+
view === "audit" && /* @__PURE__ */ jsx(NotificationSuppressionAudit2, {
|
|
591
|
+
...p,
|
|
592
|
+
items: p.audit?.items
|
|
522
593
|
}),
|
|
523
594
|
view === "recipients" && (p.filters.campaignId ? /* @__PURE__ */ jsx(Records, {
|
|
524
595
|
items: p.recipients?.items,
|
|
525
596
|
columns: recipientColumns,
|
|
526
597
|
table: tableControls,
|
|
598
|
+
tableId: "campaign-recipients",
|
|
527
599
|
m
|
|
528
600
|
}) : /* @__PURE__ */ jsx("p", {
|
|
529
601
|
children: m.recipientsHint
|
|
@@ -550,7 +622,7 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
550
622
|
role: "status",
|
|
551
623
|
children: m.loading
|
|
552
624
|
}),
|
|
553
|
-
delivery && /* @__PURE__ */ jsxs(Fragment, {
|
|
625
|
+
delivery && !p.error && /* @__PURE__ */ jsxs(Fragment, {
|
|
554
626
|
children: [
|
|
555
627
|
p.onContact && /* @__PURE__ */ jsx(Button, {
|
|
556
628
|
variant: "outline",
|
|
@@ -560,8 +632,20 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
560
632
|
/* @__PURE__ */ jsx("dl", {
|
|
561
633
|
className: "grid gap-2 break-all sm:grid-cols-2",
|
|
562
634
|
children: [
|
|
563
|
-
[
|
|
564
|
-
|
|
635
|
+
[
|
|
636
|
+
m.id,
|
|
637
|
+
/* @__PURE__ */ jsx(NotificationReference2, {
|
|
638
|
+
kind: "delivery",
|
|
639
|
+
id: delivery.id
|
|
640
|
+
}, "delivery")
|
|
641
|
+
],
|
|
642
|
+
[
|
|
643
|
+
m.contactId,
|
|
644
|
+
/* @__PURE__ */ jsx(NotificationReference2, {
|
|
645
|
+
kind: "contact",
|
|
646
|
+
id: delivery.contactId
|
|
647
|
+
}, "contact")
|
|
648
|
+
],
|
|
565
649
|
[m.email, delivery.email],
|
|
566
650
|
[m.subject, delivery.subject],
|
|
567
651
|
[m.status, m.statuses[delivery.status]],
|
|
@@ -578,7 +662,7 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
578
662
|
[m.scheduled, date(delivery.scheduledFor)],
|
|
579
663
|
[m.updated, date(delivery.updatedAt)],
|
|
580
664
|
[m.accepted, date(delivery.sentAt)]
|
|
581
|
-
].map(([label, value]) => /* @__PURE__ */ jsxs("div", {
|
|
665
|
+
].map(([label, value], index) => /* @__PURE__ */ jsxs("div", {
|
|
582
666
|
children: [
|
|
583
667
|
/* @__PURE__ */ jsx("dt", {
|
|
584
668
|
className: "font-semibold",
|
|
@@ -588,7 +672,7 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
588
672
|
children: value ?? "—"
|
|
589
673
|
})
|
|
590
674
|
]
|
|
591
|
-
},
|
|
675
|
+
}, index))
|
|
592
676
|
}),
|
|
593
677
|
/* @__PURE__ */ jsx("dl", {
|
|
594
678
|
children: [
|
|
@@ -610,47 +694,10 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
610
694
|
/* @__PURE__ */ jsx("h3", {
|
|
611
695
|
children: m.attempts
|
|
612
696
|
}),
|
|
613
|
-
/* @__PURE__ */ jsx(
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
{ field: "generation", headerName: m.generation },
|
|
618
|
-
{ field: "attempt", headerName: m.attempts },
|
|
619
|
-
{
|
|
620
|
-
colId: "outcome",
|
|
621
|
-
headerName: m.outcome,
|
|
622
|
-
cellRenderer: ({ data }) => data.outcome ? m.outcomes[data.outcome._tag] : m.pending
|
|
623
|
-
},
|
|
624
|
-
{
|
|
625
|
-
colId: "reason",
|
|
626
|
-
headerName: m.reason,
|
|
627
|
-
cellRenderer: ({ data }) => {
|
|
628
|
-
const outcome = data.outcome;
|
|
629
|
-
if (!outcome)
|
|
630
|
-
return "—";
|
|
631
|
-
switch (outcome._tag) {
|
|
632
|
-
case "Sent":
|
|
633
|
-
return outcome.providerMessageId ?? "—";
|
|
634
|
-
case "Skipped":
|
|
635
|
-
return outcome.reason;
|
|
636
|
-
case "RetryableFailure":
|
|
637
|
-
case "PermanentFailure":
|
|
638
|
-
case "Unavailable":
|
|
639
|
-
return outcome.message;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
colId: "started",
|
|
645
|
-
headerName: m.started,
|
|
646
|
-
cellRenderer: ({ data }) => date(data.startedAt)
|
|
647
|
-
},
|
|
648
|
-
{
|
|
649
|
-
colId: "completed",
|
|
650
|
-
headerName: m.completed,
|
|
651
|
-
cellRenderer: ({ data }) => date(data.completedAt)
|
|
652
|
-
}
|
|
653
|
-
]
|
|
697
|
+
/* @__PURE__ */ jsx(NotificationAttemptHistory2, {
|
|
698
|
+
messages: m,
|
|
699
|
+
attempts: p.inspection?.attempts ?? [],
|
|
700
|
+
tableId: "operations-attempts"
|
|
654
701
|
}),
|
|
655
702
|
/* @__PURE__ */ jsx(Button, {
|
|
656
703
|
onClick: () => {
|
|
@@ -673,16 +720,9 @@ var SendOperationsAdmin2 = (p) => {
|
|
|
673
720
|
})
|
|
674
721
|
]
|
|
675
722
|
})
|
|
676
|
-
}),
|
|
677
|
-
manage !== undefined && /* @__PURE__ */ jsx(SuppressionDialog, {
|
|
678
|
-
record: manage,
|
|
679
|
-
m,
|
|
680
|
-
onAdd: p.onAddSuppression,
|
|
681
|
-
onRemove: p.onRemoveSuppression,
|
|
682
|
-
onClose: () => setManage(undefined)
|
|
683
723
|
})
|
|
684
724
|
]
|
|
685
725
|
});
|
|
686
726
|
};
|
|
687
727
|
|
|
688
|
-
export { SendOperationsAdmin2 };
|
|
728
|
+
export { NotificationFeedbackTable2, NotificationSuppressions2, NotificationSuppressionAudit2, SendOperationsAdmin2 };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/hooks.ts
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useAtomRefresh, useAtomValue } from "@effect/atom-react";
|
|
4
|
+
import { Option } from "effect";
|
|
5
|
+
import { AsyncResult } from "effect/reactivity";
|
|
6
|
+
var useNotificationQuery2 = (resource, options) => {
|
|
7
|
+
const result = useAtomValue(resource.atom);
|
|
8
|
+
const failed = AsyncResult.isFailure(result);
|
|
9
|
+
const data = failed ? undefined : Option.getOrUndefined(AsyncResult.value(result));
|
|
10
|
+
const total = data === undefined ? undefined : options.total?.(data);
|
|
11
|
+
const [previous, setPrevious] = useState({
|
|
12
|
+
key: options.retentionKey,
|
|
13
|
+
total: total ?? 0
|
|
14
|
+
});
|
|
15
|
+
const retainedTotal = failed ? 0 : total ?? (previous.key === options.retentionKey ? previous.total : 0);
|
|
16
|
+
if (previous.key !== options.retentionKey || previous.total !== retainedTotal) {
|
|
17
|
+
setPrevious({ key: options.retentionKey, total: retainedTotal });
|
|
18
|
+
}
|
|
19
|
+
const refresh = useAtomRefresh(resource.refresh);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const interval = options.refreshIntervalMillis;
|
|
22
|
+
if (interval === undefined || interval <= 0)
|
|
23
|
+
return;
|
|
24
|
+
const timer = setInterval(refresh, interval);
|
|
25
|
+
return () => clearInterval(timer);
|
|
26
|
+
}, [refresh, options.refreshIntervalMillis]);
|
|
27
|
+
return {
|
|
28
|
+
result,
|
|
29
|
+
data,
|
|
30
|
+
total: retainedTotal,
|
|
31
|
+
failed,
|
|
32
|
+
refresh,
|
|
33
|
+
pending: AsyncResult.isInitial(result) || AsyncResult.isWaiting(result)
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { useNotificationQuery2 };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Layer } from "effect";
|
|
2
|
+
import type { HttpClient } from "effect/http";
|
|
3
|
+
export interface NotificationAdminClientOptions {
|
|
4
|
+
readonly baseUrl: string;
|
|
5
|
+
/** Non-secret cache identity. Recreate factories when the session/grants change. */
|
|
6
|
+
readonly authorizationKey: string;
|
|
7
|
+
/** Host-provided cookie/CSRF transport; provide its dependencies beforehand. */
|
|
8
|
+
readonly httpClient?: Layer.Layer<HttpClient.HttpClient>;
|
|
9
|
+
}
|
package/dist/deliveries.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as S from "@krak-stack/notifications/admin/delivery.schema";
|
|
2
|
-
import {
|
|
2
|
+
import type { DataTablePublicState } from "@krak-stack/registry/data-table";
|
|
3
3
|
import type { SendOperationsMessages } from "./operations.js";
|
|
4
|
+
import { type NotificationTableOptions, type NotificationTableId } from "./presentation.js";
|
|
4
5
|
export interface NotificationDeliveryMessages {
|
|
5
6
|
readonly common: SendOperationsMessages;
|
|
6
7
|
readonly title: string;
|
|
@@ -17,6 +18,62 @@ export interface NotificationDeliveryMessages {
|
|
|
17
18
|
readonly feedbackNotice: string;
|
|
18
19
|
readonly feedbackCovered: string;
|
|
19
20
|
readonly feedbackUnavailable: string;
|
|
21
|
+
readonly sections?: {
|
|
22
|
+
readonly summary: string;
|
|
23
|
+
readonly sending: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
interface ReadState {
|
|
27
|
+
readonly pending?: boolean;
|
|
28
|
+
/** A failed protected read hides retained data, not just an error banner. */
|
|
29
|
+
readonly error?: string;
|
|
30
|
+
}
|
|
31
|
+
export type NotificationAttemptHistoryMessages = Pick<SendOperationsMessages, "generation" | "attempts" | "outcome" | "outcomes" | "pending" | "reason" | "started" | "completed" | "empty" | "loading">;
|
|
32
|
+
export type NotificationDeliveryActivityMessages = Pick<NotificationDeliveryMessages, "source" | "sources" | "recipientUserId" | "organizationId" | "workspaceId" | "eventKey" | "template" | "purposes"> & {
|
|
33
|
+
readonly common: Pick<SendOperationsMessages, "email" | "purpose" | "status" | "statuses" | "attempts" | "provider" | "created" | "accepted" | "inspect" | "empty" | "loading">;
|
|
34
|
+
};
|
|
35
|
+
export type NotificationDeliveryOverviewMessages = Pick<NotificationDeliveryMessages, "feedbackCovered" | "feedbackUnavailable" | "feedbackNotice"> & {
|
|
36
|
+
readonly common: {
|
|
37
|
+
readonly loading: string;
|
|
38
|
+
readonly metrics: Pick<SendOperationsMessages["metrics"], Exclude<NotificationDeliveryMetric, "feedbackCovered" | "feedbackUnavailable">>;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type NotificationDeliveryDetailsMessages = Pick<NotificationDeliveryMessages, "source" | "sources" | "recipientUserId" | "organizationId" | "workspaceId" | "eventKey" | "template" | "purposes" | "sections" | "references"> & {
|
|
42
|
+
readonly common: NotificationAttemptHistoryMessages & Pick<SendOperationsMessages, "email" | "purpose" | "status" | "statuses" | "created" | "scheduled" | "accepted" | "id" | "provider" | "providerMessageId" | "updated" | "contactId" | "campaign"> & {
|
|
43
|
+
readonly views: Pick<SendOperationsMessages["views"], "overview">;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export interface NotificationDeliveryActivityProps extends ReadState {
|
|
47
|
+
readonly messages: NotificationDeliveryActivityMessages;
|
|
48
|
+
readonly activity?: typeof S.AdminDeliveryPage.Type;
|
|
49
|
+
readonly table: DataTablePublicState;
|
|
50
|
+
readonly total: number;
|
|
51
|
+
readonly onTable: (table: DataTablePublicState) => void;
|
|
52
|
+
readonly onInspect: (id: string) => void;
|
|
53
|
+
readonly onRefresh?: () => void;
|
|
54
|
+
readonly tableOptions?: NotificationTableOptions<typeof S.AdminDelivery.Type>;
|
|
55
|
+
}
|
|
56
|
+
export type NotificationDeliveryMetric = keyof typeof S.DeliveryOverview.Type;
|
|
57
|
+
export interface NotificationDeliveryOverviewProps extends ReadState {
|
|
58
|
+
readonly messages: NotificationDeliveryOverviewMessages;
|
|
59
|
+
readonly overview?: typeof S.DeliveryOverview.Type;
|
|
60
|
+
readonly variant?: "cards" | "rows";
|
|
61
|
+
readonly groups?: ReadonlyArray<{
|
|
62
|
+
readonly label?: string;
|
|
63
|
+
readonly metrics: ReadonlyArray<NotificationDeliveryMetric>;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
export interface NotificationAttemptHistoryProps extends ReadState {
|
|
67
|
+
readonly messages: NotificationAttemptHistoryMessages;
|
|
68
|
+
readonly attempts: (typeof S.AdminDeliveryInspection.Type)["attempts"];
|
|
69
|
+
readonly tableOptions?: NotificationTableOptions<(typeof S.AdminDeliveryInspection.Type)["attempts"][number]>;
|
|
70
|
+
readonly tableId?: Extract<NotificationTableId, "delivery-attempts" | "operations-attempts">;
|
|
71
|
+
}
|
|
72
|
+
export interface NotificationDeliveryDetailsProps extends ReadState {
|
|
73
|
+
readonly messages: NotificationDeliveryDetailsMessages;
|
|
74
|
+
readonly inspection?: typeof S.AdminDeliveryInspection.Type;
|
|
75
|
+
readonly onContact?: (id: string) => void;
|
|
76
|
+
readonly onCampaign?: (id: string) => void;
|
|
20
77
|
}
|
|
21
78
|
export interface NotificationDeliveriesProps {
|
|
22
79
|
readonly messages: NotificationDeliveryMessages;
|
|
@@ -38,5 +95,16 @@ export interface NotificationDeliveriesProps {
|
|
|
38
95
|
readonly onRefresh: () => void;
|
|
39
96
|
readonly onContact?: (id: string) => void;
|
|
40
97
|
readonly onCampaign?: (id: string) => void;
|
|
98
|
+
readonly header?: boolean;
|
|
99
|
+
readonly navigation?: boolean;
|
|
100
|
+
readonly sourcePicker?: boolean;
|
|
101
|
+
readonly tableOptions?: NotificationDeliveryActivityProps["tableOptions"];
|
|
41
102
|
}
|
|
103
|
+
export declare const NotificationDeliveryOverview: (p: NotificationDeliveryOverviewProps) => import("react").JSX.Element | null;
|
|
104
|
+
export declare const NotificationDeliveryActivity: (p: NotificationDeliveryActivityProps) => import("react").JSX.Element;
|
|
105
|
+
export declare const NotificationAttemptHistory: (p: NotificationAttemptHistoryProps) => import("react").JSX.Element;
|
|
106
|
+
/** Read-only content for a host dialog, drawer or route; no fetching or shell. */
|
|
107
|
+
export declare const NotificationDeliveryDetails: (p: NotificationDeliveryDetailsProps) => import("react").JSX.Element;
|
|
108
|
+
/** Backwards-compatible default composition; hosts can mount the sections alone. */
|
|
42
109
|
export declare const NotificationDeliveries: (p: NotificationDeliveriesProps) => import("react").JSX.Element;
|
|
110
|
+
export {};
|
package/dist/deliveries.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
NotificationDeliveryOverview2,
|
|
3
|
+
NotificationDeliveryActivity2,
|
|
4
|
+
NotificationAttemptHistory2,
|
|
5
|
+
NotificationDeliveryDetails2,
|
|
2
6
|
NotificationDeliveries2
|
|
3
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4r5x0qzz.js";
|
|
4
8
|
import"./chunk-tck9drx2.js";
|
|
9
|
+
import"./chunk-aqmv7g24.js";
|
|
5
10
|
export {
|
|
6
|
-
|
|
11
|
+
NotificationAttemptHistory2 as NotificationAttemptHistory,
|
|
12
|
+
NotificationDeliveries2 as NotificationDeliveries,
|
|
13
|
+
NotificationDeliveryActivity2 as NotificationDeliveryActivity,
|
|
14
|
+
NotificationDeliveryDetails2 as NotificationDeliveryDetails,
|
|
15
|
+
NotificationDeliveryOverview2 as NotificationDeliveryOverview
|
|
7
16
|
};
|