@absolutejs/voice 0.0.22-beta.152 → 0.0.22-beta.153
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/README.md +2 -0
- package/dist/angular/index.js +126 -1
- package/dist/angular/voice-delivery-runtime.component.d.ts +3 -0
- package/dist/angular/voice-delivery-runtime.service.d.ts +4 -0
- package/dist/client/deliveryRuntime.d.ts +15 -0
- package/dist/client/deliveryRuntimeWidget.d.ts +3 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +85 -1
- package/dist/deliveryRuntime.d.ts +13 -1
- package/dist/index.js +44 -1
- package/dist/react/VoiceDeliveryRuntime.d.ts +2 -1
- package/dist/react/index.js +114 -2
- package/dist/react/useVoiceDeliveryRuntime.d.ts +5 -0
- package/dist/svelte/createVoiceDeliveryRuntime.d.ts +2 -0
- package/dist/svelte/index.js +87 -2
- package/dist/vue/VoiceDeliveryRuntime.d.ts +9 -0
- package/dist/vue/index.js +116 -1
- package/dist/vue/useVoiceDeliveryRuntime.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type VoiceDeliveryRuntimeWidgetOptions } from '../client/deliveryRuntimeWidget';
|
|
2
2
|
export type VoiceDeliveryRuntimeProps = VoiceDeliveryRuntimeWidgetOptions & {
|
|
3
3
|
className?: string;
|
|
4
|
+
includeActions?: boolean;
|
|
4
5
|
path?: string;
|
|
5
6
|
};
|
|
6
|
-
export declare const VoiceDeliveryRuntime: ({ className, path, ...options }: VoiceDeliveryRuntimeProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const VoiceDeliveryRuntime: ({ className, includeActions, path, ...options }: VoiceDeliveryRuntimeProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/react/index.js
CHANGED
|
@@ -388,6 +388,12 @@ var VoiceOpsStatus = ({
|
|
|
388
388
|
}, undefined, true, undefined, this);
|
|
389
389
|
};
|
|
390
390
|
// src/client/deliveryRuntime.ts
|
|
391
|
+
var getDefaultActionPath = (path, action, options) => {
|
|
392
|
+
if (action === "tick") {
|
|
393
|
+
return options.tickPath ?? `${path.replace(/\/$/, "")}/tick`;
|
|
394
|
+
}
|
|
395
|
+
return options.requeueDeadLettersPath ?? `${path.replace(/\/$/, "")}/requeue-dead-letters`;
|
|
396
|
+
};
|
|
391
397
|
var fetchVoiceDeliveryRuntime = async (path = "/api/voice-delivery-runtime", options = {}) => {
|
|
392
398
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
393
399
|
const response = await fetchImpl(path);
|
|
@@ -396,11 +402,29 @@ var fetchVoiceDeliveryRuntime = async (path = "/api/voice-delivery-runtime", opt
|
|
|
396
402
|
}
|
|
397
403
|
return await response.json();
|
|
398
404
|
};
|
|
405
|
+
var runVoiceDeliveryRuntimeAction = async (action, path = "/api/voice-delivery-runtime", options = {}) => {
|
|
406
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
407
|
+
const response = await fetchImpl(getDefaultActionPath(path, action, options), {
|
|
408
|
+
method: "POST"
|
|
409
|
+
});
|
|
410
|
+
if (!response.ok) {
|
|
411
|
+
throw new Error(`Voice delivery runtime ${action} failed: HTTP ${response.status}`);
|
|
412
|
+
}
|
|
413
|
+
const body = await response.json();
|
|
414
|
+
return {
|
|
415
|
+
action,
|
|
416
|
+
result: body.result,
|
|
417
|
+
summary: body.summary,
|
|
418
|
+
updatedAt: Date.now()
|
|
419
|
+
};
|
|
420
|
+
};
|
|
399
421
|
var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", options = {}) => {
|
|
400
422
|
const listeners = new Set;
|
|
401
423
|
let closed = false;
|
|
402
424
|
let timer;
|
|
403
425
|
let snapshot = {
|
|
426
|
+
actionError: null,
|
|
427
|
+
actionStatus: "idle",
|
|
404
428
|
error: null,
|
|
405
429
|
isLoading: false
|
|
406
430
|
};
|
|
@@ -422,6 +446,7 @@ var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", opt
|
|
|
422
446
|
try {
|
|
423
447
|
const report = await fetchVoiceDeliveryRuntime(path, options);
|
|
424
448
|
snapshot = {
|
|
449
|
+
...snapshot,
|
|
425
450
|
error: null,
|
|
426
451
|
isLoading: false,
|
|
427
452
|
report,
|
|
@@ -439,6 +464,37 @@ var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", opt
|
|
|
439
464
|
throw error;
|
|
440
465
|
}
|
|
441
466
|
};
|
|
467
|
+
const runAction = async (action) => {
|
|
468
|
+
if (closed) {
|
|
469
|
+
return snapshot.lastAction;
|
|
470
|
+
}
|
|
471
|
+
snapshot = {
|
|
472
|
+
...snapshot,
|
|
473
|
+
actionError: null,
|
|
474
|
+
actionStatus: "running"
|
|
475
|
+
};
|
|
476
|
+
emit();
|
|
477
|
+
try {
|
|
478
|
+
const result = await runVoiceDeliveryRuntimeAction(action, path, options);
|
|
479
|
+
snapshot = {
|
|
480
|
+
...snapshot,
|
|
481
|
+
actionError: null,
|
|
482
|
+
actionStatus: "completed",
|
|
483
|
+
lastAction: result
|
|
484
|
+
};
|
|
485
|
+
emit();
|
|
486
|
+
await refresh();
|
|
487
|
+
return result;
|
|
488
|
+
} catch (error) {
|
|
489
|
+
snapshot = {
|
|
490
|
+
...snapshot,
|
|
491
|
+
actionError: error instanceof Error ? error.message : String(error),
|
|
492
|
+
actionStatus: "failed"
|
|
493
|
+
};
|
|
494
|
+
emit();
|
|
495
|
+
throw error;
|
|
496
|
+
}
|
|
497
|
+
};
|
|
442
498
|
const close = () => {
|
|
443
499
|
closed = true;
|
|
444
500
|
if (timer) {
|
|
@@ -456,7 +512,9 @@ var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", opt
|
|
|
456
512
|
close,
|
|
457
513
|
getServerSnapshot: () => snapshot,
|
|
458
514
|
getSnapshot: () => snapshot,
|
|
515
|
+
requeueDeadLetters: () => runAction("requeue-dead-letters"),
|
|
459
516
|
refresh,
|
|
517
|
+
tick: () => runAction("tick"),
|
|
460
518
|
subscribe: (listener) => {
|
|
461
519
|
listeners.add(listener);
|
|
462
520
|
return () => {
|
|
@@ -505,6 +563,8 @@ var createVoiceDeliveryRuntimeViewModel = (snapshot, options = {}) => {
|
|
|
505
563
|
return {
|
|
506
564
|
description: options.description ?? DEFAULT_DESCRIPTION2,
|
|
507
565
|
error: snapshot.error,
|
|
566
|
+
actionError: snapshot.actionError,
|
|
567
|
+
actionStatus: snapshot.actionStatus,
|
|
508
568
|
isLoading: snapshot.isLoading,
|
|
509
569
|
isRunning: Boolean(report?.isRunning),
|
|
510
570
|
label: snapshot.error ? "Unavailable" : report ? report.isRunning ? "Running" : "Stopped" : "Checking",
|
|
@@ -521,6 +581,11 @@ var renderVoiceDeliveryRuntimeHTML = (snapshot, options = {}) => {
|
|
|
521
581
|
<strong>${escapeHtml2(surface.detail)}</strong>
|
|
522
582
|
<small>${String(surface.failed)} failed · ${String(surface.deadLettered)} dead-lettered</small>
|
|
523
583
|
</li>`).join("");
|
|
584
|
+
const actions = options.includeActions === false ? "" : `<div class="absolute-voice-delivery-runtime__actions">
|
|
585
|
+
<button type="button" data-absolute-voice-delivery-runtime-action="tick">${model.actionStatus === "running" ? "Working..." : "Tick workers"}</button>
|
|
586
|
+
<button type="button" data-absolute-voice-delivery-runtime-action="requeue-dead-letters"${model.surfaces.some((surface) => surface.deadLettered > 0) ? "" : " disabled"}>Requeue dead letters</button>
|
|
587
|
+
</div>`;
|
|
588
|
+
const actionError = model.actionError ? `<p class="absolute-voice-delivery-runtime__error">${escapeHtml2(model.actionError)}</p>` : "";
|
|
524
589
|
return `<section class="absolute-voice-delivery-runtime absolute-voice-delivery-runtime--${escapeHtml2(model.status)}">
|
|
525
590
|
<header class="absolute-voice-delivery-runtime__header">
|
|
526
591
|
<span class="absolute-voice-delivery-runtime__eyebrow">${escapeHtml2(model.title)}</span>
|
|
@@ -528,20 +593,38 @@ var renderVoiceDeliveryRuntimeHTML = (snapshot, options = {}) => {
|
|
|
528
593
|
</header>
|
|
529
594
|
<p class="absolute-voice-delivery-runtime__description">${escapeHtml2(model.description)}</p>
|
|
530
595
|
<ul class="absolute-voice-delivery-runtime__surfaces">${surfaces}</ul>
|
|
596
|
+
${actions}
|
|
597
|
+
${actionError}
|
|
531
598
|
${model.error ? `<p class="absolute-voice-delivery-runtime__error">${escapeHtml2(model.error)}</p>` : ""}
|
|
532
599
|
</section>`;
|
|
533
600
|
};
|
|
534
|
-
var getVoiceDeliveryRuntimeCSS = () => `.absolute-voice-delivery-runtime{border:1px solid #c9d8cf;border-radius:20px;background:#f6fff9;color:#0d1b12;padding:18px;box-shadow:0 18px 40px rgba(19,55,35,.12);font-family:inherit}.absolute-voice-delivery-runtime--warn,.absolute-voice-delivery-runtime--error{border-color:#f2b56b;background:#fff9ed}.absolute-voice-delivery-runtime__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-delivery-runtime__eyebrow{color:#4e6b59;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-delivery-runtime__label{font-size:28px;line-height:1}.absolute-voice-delivery-runtime__description{color:#33483b;margin:12px 0 0}.absolute-voice-delivery-runtime__surfaces{display:grid;gap:8px;list-style:none;margin:16px 0 0;padding:0}.absolute-voice-delivery-runtime__surface{background:#fff;border:1px solid #d9eadf;border-radius:14px;display:grid;gap:4px;padding:10px 12px}.absolute-voice-delivery-runtime__surface--warn{border-color:#f2b56b}.absolute-voice-delivery-runtime__surface--disabled{opacity:.72}.absolute-voice-delivery-runtime__surface span,.absolute-voice-delivery-runtime__surface small{color:#587063}.absolute-voice-delivery-runtime__error{color:#9f1239;font-weight:700}`;
|
|
601
|
+
var getVoiceDeliveryRuntimeCSS = () => `.absolute-voice-delivery-runtime{border:1px solid #c9d8cf;border-radius:20px;background:#f6fff9;color:#0d1b12;padding:18px;box-shadow:0 18px 40px rgba(19,55,35,.12);font-family:inherit}.absolute-voice-delivery-runtime--warn,.absolute-voice-delivery-runtime--error{border-color:#f2b56b;background:#fff9ed}.absolute-voice-delivery-runtime__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-delivery-runtime__eyebrow{color:#4e6b59;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-delivery-runtime__label{font-size:28px;line-height:1}.absolute-voice-delivery-runtime__description{color:#33483b;margin:12px 0 0}.absolute-voice-delivery-runtime__surfaces{display:grid;gap:8px;list-style:none;margin:16px 0 0;padding:0}.absolute-voice-delivery-runtime__surface{background:#fff;border:1px solid #d9eadf;border-radius:14px;display:grid;gap:4px;padding:10px 12px}.absolute-voice-delivery-runtime__surface--warn{border-color:#f2b56b}.absolute-voice-delivery-runtime__surface--disabled{opacity:.72}.absolute-voice-delivery-runtime__surface span,.absolute-voice-delivery-runtime__surface small{color:#587063}.absolute-voice-delivery-runtime__actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.absolute-voice-delivery-runtime__actions button{background:#134e2d;border:0;border-radius:999px;color:#f6fff9;cursor:pointer;font:inherit;font-weight:800;padding:8px 12px}.absolute-voice-delivery-runtime__actions button:disabled{cursor:not-allowed;opacity:.48}.absolute-voice-delivery-runtime__error{color:#9f1239;font-weight:700}`;
|
|
535
602
|
var mountVoiceDeliveryRuntime = (element, path = "/api/voice-delivery-runtime", options = {}) => {
|
|
536
603
|
const store = createVoiceDeliveryRuntimeStore(path, options);
|
|
537
604
|
const render = () => {
|
|
538
605
|
element.innerHTML = renderVoiceDeliveryRuntimeHTML(store.getSnapshot(), options);
|
|
539
606
|
};
|
|
540
607
|
const unsubscribe = store.subscribe(render);
|
|
608
|
+
const handleClick = (event) => {
|
|
609
|
+
const target = event.target;
|
|
610
|
+
if (!(target instanceof Element)) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
const action = target.closest("[data-absolute-voice-delivery-runtime-action]");
|
|
614
|
+
const actionName = action?.getAttribute("data-absolute-voice-delivery-runtime-action");
|
|
615
|
+
if (actionName === "tick") {
|
|
616
|
+
store.tick().catch(() => {});
|
|
617
|
+
}
|
|
618
|
+
if (actionName === "requeue-dead-letters") {
|
|
619
|
+
store.requeueDeadLetters().catch(() => {});
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
element.addEventListener?.("click", handleClick);
|
|
541
623
|
render();
|
|
542
624
|
store.refresh().catch(() => {});
|
|
543
625
|
return {
|
|
544
626
|
close: () => {
|
|
627
|
+
element.removeEventListener?.("click", handleClick);
|
|
545
628
|
unsubscribe();
|
|
546
629
|
store.close();
|
|
547
630
|
},
|
|
@@ -583,7 +666,9 @@ var useVoiceDeliveryRuntime = (path = "/api/voice-delivery-runtime", options = {
|
|
|
583
666
|
}, [store]);
|
|
584
667
|
return {
|
|
585
668
|
...useSyncExternalStore2(store.subscribe, store.getSnapshot, store.getServerSnapshot),
|
|
586
|
-
|
|
669
|
+
requeueDeadLetters: store.requeueDeadLetters,
|
|
670
|
+
refresh: store.refresh,
|
|
671
|
+
tick: store.tick
|
|
587
672
|
};
|
|
588
673
|
};
|
|
589
674
|
|
|
@@ -591,11 +676,13 @@ var useVoiceDeliveryRuntime = (path = "/api/voice-delivery-runtime", options = {
|
|
|
591
676
|
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
592
677
|
var VoiceDeliveryRuntime = ({
|
|
593
678
|
className,
|
|
679
|
+
includeActions = true,
|
|
594
680
|
path = "/api/voice-delivery-runtime",
|
|
595
681
|
...options
|
|
596
682
|
}) => {
|
|
597
683
|
const snapshot = useVoiceDeliveryRuntime(path, options);
|
|
598
684
|
const model = createVoiceDeliveryRuntimeViewModel(snapshot, options);
|
|
685
|
+
const hasDeadLetters = model.surfaces.some((surface) => surface.deadLettered > 0);
|
|
599
686
|
return /* @__PURE__ */ jsxDEV2("section", {
|
|
600
687
|
className: [
|
|
601
688
|
"absolute-voice-delivery-runtime",
|
|
@@ -642,6 +729,31 @@ var VoiceDeliveryRuntime = ({
|
|
|
642
729
|
]
|
|
643
730
|
}, surface.id, true, undefined, this))
|
|
644
731
|
}, undefined, false, undefined, this),
|
|
732
|
+
includeActions ? /* @__PURE__ */ jsxDEV2("div", {
|
|
733
|
+
className: "absolute-voice-delivery-runtime__actions",
|
|
734
|
+
children: [
|
|
735
|
+
/* @__PURE__ */ jsxDEV2("button", {
|
|
736
|
+
disabled: model.actionStatus === "running",
|
|
737
|
+
onClick: () => {
|
|
738
|
+
snapshot.tick().catch(() => {});
|
|
739
|
+
},
|
|
740
|
+
type: "button",
|
|
741
|
+
children: model.actionStatus === "running" ? "Working..." : "Tick workers"
|
|
742
|
+
}, undefined, false, undefined, this),
|
|
743
|
+
/* @__PURE__ */ jsxDEV2("button", {
|
|
744
|
+
disabled: model.actionStatus === "running" || !hasDeadLetters,
|
|
745
|
+
onClick: () => {
|
|
746
|
+
snapshot.requeueDeadLetters().catch(() => {});
|
|
747
|
+
},
|
|
748
|
+
type: "button",
|
|
749
|
+
children: "Requeue dead letters"
|
|
750
|
+
}, undefined, false, undefined, this)
|
|
751
|
+
]
|
|
752
|
+
}, undefined, true, undefined, this) : null,
|
|
753
|
+
model.actionError ? /* @__PURE__ */ jsxDEV2("p", {
|
|
754
|
+
className: "absolute-voice-delivery-runtime__error",
|
|
755
|
+
children: model.actionError
|
|
756
|
+
}, undefined, false, undefined, this) : null,
|
|
645
757
|
model.error ? /* @__PURE__ */ jsxDEV2("p", {
|
|
646
758
|
className: "absolute-voice-delivery-runtime__error",
|
|
647
759
|
children: model.error
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { type VoiceDeliveryRuntimeClientOptions } from '../client/deliveryRuntime';
|
|
2
2
|
export declare const useVoiceDeliveryRuntime: (path?: string, options?: VoiceDeliveryRuntimeClientOptions) => {
|
|
3
|
+
requeueDeadLetters: () => Promise<import("../client").VoiceDeliveryRuntimeActionResult | undefined>;
|
|
3
4
|
refresh: () => Promise<import("..").VoiceDeliveryRuntimeReport | undefined>;
|
|
5
|
+
tick: () => Promise<import("../client").VoiceDeliveryRuntimeActionResult | undefined>;
|
|
6
|
+
actionError: string | null;
|
|
7
|
+
actionStatus: "idle" | "running" | "completed" | "failed";
|
|
4
8
|
error: string | null;
|
|
5
9
|
isLoading: boolean;
|
|
10
|
+
lastAction?: import("../client").VoiceDeliveryRuntimeActionResult;
|
|
6
11
|
report?: import("..").VoiceDeliveryRuntimeReport;
|
|
7
12
|
updatedAt?: number;
|
|
8
13
|
};
|
|
@@ -4,6 +4,8 @@ export declare const createVoiceDeliveryRuntime: (path?: string, options?: Voice
|
|
|
4
4
|
getHTML: () => string;
|
|
5
5
|
getSnapshot: () => import("../client").VoiceDeliveryRuntimeSnapshot;
|
|
6
6
|
getViewModel: () => import("../client").VoiceDeliveryRuntimeViewModel;
|
|
7
|
+
requeueDeadLetters: () => Promise<import("../client").VoiceDeliveryRuntimeActionResult | undefined>;
|
|
7
8
|
refresh: () => Promise<import("..").VoiceDeliveryRuntimeReport | undefined>;
|
|
8
9
|
subscribe: (listener: () => void) => () => void;
|
|
10
|
+
tick: () => Promise<import("../client").VoiceDeliveryRuntimeActionResult | undefined>;
|
|
9
11
|
};
|
package/dist/svelte/index.js
CHANGED
|
@@ -190,6 +190,12 @@ var createVoiceCampaignDialerProofStore = (path = "/api/voice/campaigns/dialer-p
|
|
|
190
190
|
// src/svelte/createVoiceCampaignDialerProof.ts
|
|
191
191
|
var createVoiceCampaignDialerProof = (path = "/api/voice/campaigns/dialer-proof", options = {}) => createVoiceCampaignDialerProofStore(path, options);
|
|
192
192
|
// src/client/deliveryRuntime.ts
|
|
193
|
+
var getDefaultActionPath = (path, action, options) => {
|
|
194
|
+
if (action === "tick") {
|
|
195
|
+
return options.tickPath ?? `${path.replace(/\/$/, "")}/tick`;
|
|
196
|
+
}
|
|
197
|
+
return options.requeueDeadLettersPath ?? `${path.replace(/\/$/, "")}/requeue-dead-letters`;
|
|
198
|
+
};
|
|
193
199
|
var fetchVoiceDeliveryRuntime = async (path = "/api/voice-delivery-runtime", options = {}) => {
|
|
194
200
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
195
201
|
const response = await fetchImpl(path);
|
|
@@ -198,11 +204,29 @@ var fetchVoiceDeliveryRuntime = async (path = "/api/voice-delivery-runtime", opt
|
|
|
198
204
|
}
|
|
199
205
|
return await response.json();
|
|
200
206
|
};
|
|
207
|
+
var runVoiceDeliveryRuntimeAction = async (action, path = "/api/voice-delivery-runtime", options = {}) => {
|
|
208
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
209
|
+
const response = await fetchImpl(getDefaultActionPath(path, action, options), {
|
|
210
|
+
method: "POST"
|
|
211
|
+
});
|
|
212
|
+
if (!response.ok) {
|
|
213
|
+
throw new Error(`Voice delivery runtime ${action} failed: HTTP ${response.status}`);
|
|
214
|
+
}
|
|
215
|
+
const body = await response.json();
|
|
216
|
+
return {
|
|
217
|
+
action,
|
|
218
|
+
result: body.result,
|
|
219
|
+
summary: body.summary,
|
|
220
|
+
updatedAt: Date.now()
|
|
221
|
+
};
|
|
222
|
+
};
|
|
201
223
|
var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", options = {}) => {
|
|
202
224
|
const listeners = new Set;
|
|
203
225
|
let closed = false;
|
|
204
226
|
let timer;
|
|
205
227
|
let snapshot = {
|
|
228
|
+
actionError: null,
|
|
229
|
+
actionStatus: "idle",
|
|
206
230
|
error: null,
|
|
207
231
|
isLoading: false
|
|
208
232
|
};
|
|
@@ -224,6 +248,7 @@ var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", opt
|
|
|
224
248
|
try {
|
|
225
249
|
const report = await fetchVoiceDeliveryRuntime(path, options);
|
|
226
250
|
snapshot = {
|
|
251
|
+
...snapshot,
|
|
227
252
|
error: null,
|
|
228
253
|
isLoading: false,
|
|
229
254
|
report,
|
|
@@ -241,6 +266,37 @@ var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", opt
|
|
|
241
266
|
throw error;
|
|
242
267
|
}
|
|
243
268
|
};
|
|
269
|
+
const runAction = async (action) => {
|
|
270
|
+
if (closed) {
|
|
271
|
+
return snapshot.lastAction;
|
|
272
|
+
}
|
|
273
|
+
snapshot = {
|
|
274
|
+
...snapshot,
|
|
275
|
+
actionError: null,
|
|
276
|
+
actionStatus: "running"
|
|
277
|
+
};
|
|
278
|
+
emit();
|
|
279
|
+
try {
|
|
280
|
+
const result = await runVoiceDeliveryRuntimeAction(action, path, options);
|
|
281
|
+
snapshot = {
|
|
282
|
+
...snapshot,
|
|
283
|
+
actionError: null,
|
|
284
|
+
actionStatus: "completed",
|
|
285
|
+
lastAction: result
|
|
286
|
+
};
|
|
287
|
+
emit();
|
|
288
|
+
await refresh();
|
|
289
|
+
return result;
|
|
290
|
+
} catch (error) {
|
|
291
|
+
snapshot = {
|
|
292
|
+
...snapshot,
|
|
293
|
+
actionError: error instanceof Error ? error.message : String(error),
|
|
294
|
+
actionStatus: "failed"
|
|
295
|
+
};
|
|
296
|
+
emit();
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
244
300
|
const close = () => {
|
|
245
301
|
closed = true;
|
|
246
302
|
if (timer) {
|
|
@@ -258,7 +314,9 @@ var createVoiceDeliveryRuntimeStore = (path = "/api/voice-delivery-runtime", opt
|
|
|
258
314
|
close,
|
|
259
315
|
getServerSnapshot: () => snapshot,
|
|
260
316
|
getSnapshot: () => snapshot,
|
|
317
|
+
requeueDeadLetters: () => runAction("requeue-dead-letters"),
|
|
261
318
|
refresh,
|
|
319
|
+
tick: () => runAction("tick"),
|
|
262
320
|
subscribe: (listener) => {
|
|
263
321
|
listeners.add(listener);
|
|
264
322
|
return () => {
|
|
@@ -307,6 +365,8 @@ var createVoiceDeliveryRuntimeViewModel = (snapshot, options = {}) => {
|
|
|
307
365
|
return {
|
|
308
366
|
description: options.description ?? DEFAULT_DESCRIPTION,
|
|
309
367
|
error: snapshot.error,
|
|
368
|
+
actionError: snapshot.actionError,
|
|
369
|
+
actionStatus: snapshot.actionStatus,
|
|
310
370
|
isLoading: snapshot.isLoading,
|
|
311
371
|
isRunning: Boolean(report?.isRunning),
|
|
312
372
|
label: snapshot.error ? "Unavailable" : report ? report.isRunning ? "Running" : "Stopped" : "Checking",
|
|
@@ -323,6 +383,11 @@ var renderVoiceDeliveryRuntimeHTML = (snapshot, options = {}) => {
|
|
|
323
383
|
<strong>${escapeHtml(surface.detail)}</strong>
|
|
324
384
|
<small>${String(surface.failed)} failed · ${String(surface.deadLettered)} dead-lettered</small>
|
|
325
385
|
</li>`).join("");
|
|
386
|
+
const actions = options.includeActions === false ? "" : `<div class="absolute-voice-delivery-runtime__actions">
|
|
387
|
+
<button type="button" data-absolute-voice-delivery-runtime-action="tick">${model.actionStatus === "running" ? "Working..." : "Tick workers"}</button>
|
|
388
|
+
<button type="button" data-absolute-voice-delivery-runtime-action="requeue-dead-letters"${model.surfaces.some((surface) => surface.deadLettered > 0) ? "" : " disabled"}>Requeue dead letters</button>
|
|
389
|
+
</div>`;
|
|
390
|
+
const actionError = model.actionError ? `<p class="absolute-voice-delivery-runtime__error">${escapeHtml(model.actionError)}</p>` : "";
|
|
326
391
|
return `<section class="absolute-voice-delivery-runtime absolute-voice-delivery-runtime--${escapeHtml(model.status)}">
|
|
327
392
|
<header class="absolute-voice-delivery-runtime__header">
|
|
328
393
|
<span class="absolute-voice-delivery-runtime__eyebrow">${escapeHtml(model.title)}</span>
|
|
@@ -330,20 +395,38 @@ var renderVoiceDeliveryRuntimeHTML = (snapshot, options = {}) => {
|
|
|
330
395
|
</header>
|
|
331
396
|
<p class="absolute-voice-delivery-runtime__description">${escapeHtml(model.description)}</p>
|
|
332
397
|
<ul class="absolute-voice-delivery-runtime__surfaces">${surfaces}</ul>
|
|
398
|
+
${actions}
|
|
399
|
+
${actionError}
|
|
333
400
|
${model.error ? `<p class="absolute-voice-delivery-runtime__error">${escapeHtml(model.error)}</p>` : ""}
|
|
334
401
|
</section>`;
|
|
335
402
|
};
|
|
336
|
-
var getVoiceDeliveryRuntimeCSS = () => `.absolute-voice-delivery-runtime{border:1px solid #c9d8cf;border-radius:20px;background:#f6fff9;color:#0d1b12;padding:18px;box-shadow:0 18px 40px rgba(19,55,35,.12);font-family:inherit}.absolute-voice-delivery-runtime--warn,.absolute-voice-delivery-runtime--error{border-color:#f2b56b;background:#fff9ed}.absolute-voice-delivery-runtime__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-delivery-runtime__eyebrow{color:#4e6b59;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-delivery-runtime__label{font-size:28px;line-height:1}.absolute-voice-delivery-runtime__description{color:#33483b;margin:12px 0 0}.absolute-voice-delivery-runtime__surfaces{display:grid;gap:8px;list-style:none;margin:16px 0 0;padding:0}.absolute-voice-delivery-runtime__surface{background:#fff;border:1px solid #d9eadf;border-radius:14px;display:grid;gap:4px;padding:10px 12px}.absolute-voice-delivery-runtime__surface--warn{border-color:#f2b56b}.absolute-voice-delivery-runtime__surface--disabled{opacity:.72}.absolute-voice-delivery-runtime__surface span,.absolute-voice-delivery-runtime__surface small{color:#587063}.absolute-voice-delivery-runtime__error{color:#9f1239;font-weight:700}`;
|
|
403
|
+
var getVoiceDeliveryRuntimeCSS = () => `.absolute-voice-delivery-runtime{border:1px solid #c9d8cf;border-radius:20px;background:#f6fff9;color:#0d1b12;padding:18px;box-shadow:0 18px 40px rgba(19,55,35,.12);font-family:inherit}.absolute-voice-delivery-runtime--warn,.absolute-voice-delivery-runtime--error{border-color:#f2b56b;background:#fff9ed}.absolute-voice-delivery-runtime__header{align-items:start;display:flex;gap:12px;justify-content:space-between}.absolute-voice-delivery-runtime__eyebrow{color:#4e6b59;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.absolute-voice-delivery-runtime__label{font-size:28px;line-height:1}.absolute-voice-delivery-runtime__description{color:#33483b;margin:12px 0 0}.absolute-voice-delivery-runtime__surfaces{display:grid;gap:8px;list-style:none;margin:16px 0 0;padding:0}.absolute-voice-delivery-runtime__surface{background:#fff;border:1px solid #d9eadf;border-radius:14px;display:grid;gap:4px;padding:10px 12px}.absolute-voice-delivery-runtime__surface--warn{border-color:#f2b56b}.absolute-voice-delivery-runtime__surface--disabled{opacity:.72}.absolute-voice-delivery-runtime__surface span,.absolute-voice-delivery-runtime__surface small{color:#587063}.absolute-voice-delivery-runtime__actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.absolute-voice-delivery-runtime__actions button{background:#134e2d;border:0;border-radius:999px;color:#f6fff9;cursor:pointer;font:inherit;font-weight:800;padding:8px 12px}.absolute-voice-delivery-runtime__actions button:disabled{cursor:not-allowed;opacity:.48}.absolute-voice-delivery-runtime__error{color:#9f1239;font-weight:700}`;
|
|
337
404
|
var mountVoiceDeliveryRuntime = (element, path = "/api/voice-delivery-runtime", options = {}) => {
|
|
338
405
|
const store = createVoiceDeliveryRuntimeStore(path, options);
|
|
339
406
|
const render = () => {
|
|
340
407
|
element.innerHTML = renderVoiceDeliveryRuntimeHTML(store.getSnapshot(), options);
|
|
341
408
|
};
|
|
342
409
|
const unsubscribe = store.subscribe(render);
|
|
410
|
+
const handleClick = (event) => {
|
|
411
|
+
const target = event.target;
|
|
412
|
+
if (!(target instanceof Element)) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const action = target.closest("[data-absolute-voice-delivery-runtime-action]");
|
|
416
|
+
const actionName = action?.getAttribute("data-absolute-voice-delivery-runtime-action");
|
|
417
|
+
if (actionName === "tick") {
|
|
418
|
+
store.tick().catch(() => {});
|
|
419
|
+
}
|
|
420
|
+
if (actionName === "requeue-dead-letters") {
|
|
421
|
+
store.requeueDeadLetters().catch(() => {});
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
element.addEventListener?.("click", handleClick);
|
|
343
425
|
render();
|
|
344
426
|
store.refresh().catch(() => {});
|
|
345
427
|
return {
|
|
346
428
|
close: () => {
|
|
429
|
+
element.removeEventListener?.("click", handleClick);
|
|
347
430
|
unsubscribe();
|
|
348
431
|
store.close();
|
|
349
432
|
},
|
|
@@ -379,8 +462,10 @@ var createVoiceDeliveryRuntime = (path = "/api/voice-delivery-runtime", options
|
|
|
379
462
|
getHTML: () => renderVoiceDeliveryRuntimeHTML(store.getSnapshot(), options),
|
|
380
463
|
getSnapshot: store.getSnapshot,
|
|
381
464
|
getViewModel: () => createVoiceDeliveryRuntimeViewModel(store.getSnapshot(), options),
|
|
465
|
+
requeueDeadLetters: store.requeueDeadLetters,
|
|
382
466
|
refresh: store.refresh,
|
|
383
|
-
subscribe: store.subscribe
|
|
467
|
+
subscribe: store.subscribe,
|
|
468
|
+
tick: store.tick
|
|
384
469
|
};
|
|
385
470
|
};
|
|
386
471
|
// src/client/opsStatus.ts
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export declare const VoiceDeliveryRuntime: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
2
|
description: StringConstructor;
|
|
3
|
+
includeActions: {
|
|
4
|
+
default: boolean;
|
|
5
|
+
type: BooleanConstructor;
|
|
6
|
+
};
|
|
3
7
|
intervalMs: NumberConstructor;
|
|
4
8
|
path: {
|
|
5
9
|
default: string;
|
|
@@ -10,6 +14,10 @@ export declare const VoiceDeliveryRuntime: import("vue").DefineComponent<import(
|
|
|
10
14
|
[key: string]: any;
|
|
11
15
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
12
16
|
description: StringConstructor;
|
|
17
|
+
includeActions: {
|
|
18
|
+
default: boolean;
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
};
|
|
13
21
|
intervalMs: NumberConstructor;
|
|
14
22
|
path: {
|
|
15
23
|
default: string;
|
|
@@ -18,4 +26,5 @@ export declare const VoiceDeliveryRuntime: import("vue").DefineComponent<import(
|
|
|
18
26
|
title: StringConstructor;
|
|
19
27
|
}>> & Readonly<{}>, {
|
|
20
28
|
path: string;
|
|
29
|
+
includeActions: boolean;
|
|
21
30
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|