@absolutejs/voice 0.0.22-beta.79 → 0.0.22-beta.80
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/index.d.ts +2 -0
- package/dist/index.js +108 -0
- package/dist/telephony/matrix.d.ts +97 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -84,10 +84,12 @@ export { createTwilioMediaStreamBridge, createTwilioVoiceRoutes, createTwilioVoi
|
|
|
84
84
|
export { evaluateVoiceTelephonyContract } from './telephony/contract';
|
|
85
85
|
export { createTelnyxVoiceResponse, createTelnyxVoiceRoutes, verifyVoiceTelnyxWebhookSignature } from './telephony/telnyx';
|
|
86
86
|
export { createPlivoVoiceResponse, createPlivoVoiceRoutes, signVoicePlivoWebhook, verifyVoicePlivoWebhookSignature } from './telephony/plivo';
|
|
87
|
+
export { createVoiceTelephonyCarrierMatrix, createVoiceTelephonyCarrierMatrixRoutes, renderVoiceTelephonyCarrierMatrixHTML } from './telephony/matrix';
|
|
87
88
|
export type { TwilioInboundMessage, TwilioMediaStreamBridge, TwilioMediaStreamBridgeOptions, TwilioMediaStreamSocket, TwilioOutboundClearMessage, TwilioOutboundMarkMessage, TwilioOutboundMediaMessage, TwilioOutboundMessage, TwilioVoiceRouteParameters, TwilioVoiceResponseOptions, TwilioVoiceSmokeCheck, TwilioVoiceSmokeOptions, TwilioVoiceSmokeReport, TwilioVoiceSetupOptions, TwilioVoiceSetupStatus, TwilioVoiceRoutesOptions } from './telephony/twilio';
|
|
88
89
|
export type { VoiceTelephonyContractIssue, VoiceTelephonyContractOptions, VoiceTelephonyContractReport, VoiceTelephonyContractRequirement, VoiceTelephonyProvider, VoiceTelephonySetupStatus, VoiceTelephonySmokeCheck, VoiceTelephonySmokeReport } from './telephony/contract';
|
|
89
90
|
export type { TelnyxVoiceResponseOptions, TelnyxVoiceRoutesOptions, TelnyxVoiceSetupOptions, TelnyxVoiceSetupStatus, TelnyxVoiceSmokeCheck, TelnyxVoiceSmokeOptions, TelnyxVoiceSmokeReport } from './telephony/telnyx';
|
|
90
91
|
export type { PlivoVoiceResponseOptions, PlivoVoiceRoutesOptions, PlivoVoiceSetupOptions, PlivoVoiceSetupStatus, PlivoVoiceSmokeCheck, PlivoVoiceSmokeOptions, PlivoVoiceSmokeReport } from './telephony/plivo';
|
|
92
|
+
export type { VoiceTelephonyCarrierMatrix, VoiceTelephonyCarrierMatrixEntry, VoiceTelephonyCarrierMatrixInput, VoiceTelephonyCarrierMatrixOptions, VoiceTelephonyCarrierMatrixRoutesOptions, VoiceTelephonyCarrierMatrixStatus } from './telephony/matrix';
|
|
91
93
|
export { shapeTelephonyAssistantText } from './telephony/response';
|
|
92
94
|
export type { TelephonyResponseShapeMode, TelephonyResponseShapeOptions } from './telephony/response';
|
|
93
95
|
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -16599,6 +16599,111 @@ var createPlivoVoiceRoutes = (options = {}) => {
|
|
|
16599
16599
|
return report;
|
|
16600
16600
|
});
|
|
16601
16601
|
};
|
|
16602
|
+
// src/telephony/matrix.ts
|
|
16603
|
+
import { Elysia as Elysia21 } from "elysia";
|
|
16604
|
+
var escapeHtml20 = (value) => value.replaceAll("&", "&").replaceAll('"', """).replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">");
|
|
16605
|
+
var labelForProvider = (provider) => provider.split("-").map((part) => `${part.slice(0, 1).toUpperCase()}${part.slice(1)}`).join(" ");
|
|
16606
|
+
var resolveEntryStatus = (contract, setup, smoke) => {
|
|
16607
|
+
if (!contract.pass || !setup.ready || smoke?.pass === false) {
|
|
16608
|
+
return "fail";
|
|
16609
|
+
}
|
|
16610
|
+
if (contract.issues.some((issue) => issue.severity === "warning") || setup.warnings.length > 0 || smoke?.checks.some((check) => check.status === "warn")) {
|
|
16611
|
+
return "warn";
|
|
16612
|
+
}
|
|
16613
|
+
return "pass";
|
|
16614
|
+
};
|
|
16615
|
+
var createVoiceTelephonyCarrierMatrix = (options) => {
|
|
16616
|
+
const entries = options.providers.map((provider) => {
|
|
16617
|
+
const contract = provider.contract ?? evaluateVoiceTelephonyContract({
|
|
16618
|
+
options: options.contract,
|
|
16619
|
+
setup: provider.setup,
|
|
16620
|
+
smoke: provider.smoke
|
|
16621
|
+
});
|
|
16622
|
+
const failures = provider.smoke?.checks.filter((check) => check.status === "fail").length ?? 0;
|
|
16623
|
+
const warnings = contract.issues.filter((issue) => issue.severity === "warning").length + (provider.smoke?.checks.filter((check) => check.status === "warn").length ?? 0);
|
|
16624
|
+
const errors = contract.issues.filter((issue) => issue.severity === "error").length;
|
|
16625
|
+
const status = resolveEntryStatus(contract, provider.setup, provider.smoke);
|
|
16626
|
+
return {
|
|
16627
|
+
contract,
|
|
16628
|
+
issues: contract.issues,
|
|
16629
|
+
name: provider.name ?? labelForProvider(provider.setup.provider),
|
|
16630
|
+
provider: provider.setup.provider,
|
|
16631
|
+
ready: provider.setup.ready,
|
|
16632
|
+
setup: provider.setup,
|
|
16633
|
+
smoke: provider.smoke,
|
|
16634
|
+
status,
|
|
16635
|
+
summary: {
|
|
16636
|
+
errors,
|
|
16637
|
+
failures,
|
|
16638
|
+
missing: provider.setup.missing.length,
|
|
16639
|
+
warnings
|
|
16640
|
+
}
|
|
16641
|
+
};
|
|
16642
|
+
});
|
|
16643
|
+
const summary = {
|
|
16644
|
+
contractsPassing: entries.filter((entry) => entry.contract.pass).length,
|
|
16645
|
+
failing: entries.filter((entry) => entry.status === "fail").length,
|
|
16646
|
+
providers: entries.length,
|
|
16647
|
+
ready: entries.filter((entry) => entry.ready).length,
|
|
16648
|
+
smokePassing: entries.filter((entry) => entry.smoke?.pass).length,
|
|
16649
|
+
warnings: entries.reduce((total, entry) => total + entry.summary.warnings, 0)
|
|
16650
|
+
};
|
|
16651
|
+
return {
|
|
16652
|
+
entries,
|
|
16653
|
+
generatedAt: options.generatedAt ?? Date.now(),
|
|
16654
|
+
pass: entries.length > 0 && entries.every((entry) => entry.status !== "fail"),
|
|
16655
|
+
summary
|
|
16656
|
+
};
|
|
16657
|
+
};
|
|
16658
|
+
var badgeStyles = {
|
|
16659
|
+
fail: "background:#fee2e2;color:#991b1b;border-color:#fecaca;",
|
|
16660
|
+
pass: "background:#dcfce7;color:#166534;border-color:#bbf7d0;",
|
|
16661
|
+
warn: "background:#fef3c7;color:#92400e;border-color:#fde68a;"
|
|
16662
|
+
};
|
|
16663
|
+
var renderVoiceTelephonyCarrierMatrixHTML = (matrix, options = {}) => `<main style="font-family: ui-sans-serif, system-ui; max-width: 1040px; margin: 40px auto; padding: 0 20px; color: #172033;">
|
|
16664
|
+
<p style="letter-spacing: .12em; text-transform: uppercase; color: #52606d;">Carrier matrix</p>
|
|
16665
|
+
<h1 style="font-size: 34px; margin: 0 0 8px;">${escapeHtml20(options.title ?? "AbsoluteJS Voice Carrier Matrix")}</h1>
|
|
16666
|
+
<p style="color:#52606d; margin: 0 0 24px;">${matrix.summary.ready}/${matrix.summary.providers} ready, ${matrix.summary.contractsPassing}/${matrix.summary.providers} contract passing, ${matrix.summary.smokePassing}/${matrix.summary.providers} smoke passing.</p>
|
|
16667
|
+
<section style="display:grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px;">
|
|
16668
|
+
${matrix.entries.map((entry) => `<article style="border:1px solid #d9e2ec; border-radius:18px; padding:18px; background:#fff; box-shadow:0 18px 48px rgba(15,23,42,.08);">
|
|
16669
|
+
<div style="display:flex; justify-content:space-between; gap:12px; align-items:center;">
|
|
16670
|
+
<h2 style="margin:0; font-size:20px;">${escapeHtml20(entry.name)}</h2>
|
|
16671
|
+
<span style="border:1px solid; border-radius:999px; padding:4px 10px; font-size:12px; font-weight:700; ${badgeStyles[entry.status]}">${escapeHtml20(entry.status.toUpperCase())}</span>
|
|
16672
|
+
</div>
|
|
16673
|
+
<dl style="display:grid; grid-template-columns: 1fr 1fr; gap:8px 12px; margin:16px 0;">
|
|
16674
|
+
<dt style="color:#64748b;">Setup</dt><dd style="margin:0; font-weight:700;">${entry.ready ? "Ready" : "Needs attention"}</dd>
|
|
16675
|
+
<dt style="color:#64748b;">Signing</dt><dd style="margin:0; font-weight:700;">${entry.setup.signing.configured ? entry.setup.signing.mode : "missing"}</dd>
|
|
16676
|
+
<dt style="color:#64748b;">Smoke</dt><dd style="margin:0; font-weight:700;">${entry.smoke ? entry.smoke.pass ? "Pass" : "Fail" : "Missing"}</dd>
|
|
16677
|
+
<dt style="color:#64748b;">Contract</dt><dd style="margin:0; font-weight:700;">${entry.contract.pass ? "Pass" : "Fail"}</dd>
|
|
16678
|
+
</dl>
|
|
16679
|
+
<p style="margin:0 0 8px; color:#475569;"><strong>Stream:</strong> <code>${escapeHtml20(entry.setup.urls.stream || "missing")}</code></p>
|
|
16680
|
+
<p style="margin:0 0 12px; color:#475569;"><strong>Webhook:</strong> <code>${escapeHtml20(entry.setup.urls.webhook || "missing")}</code></p>
|
|
16681
|
+
${entry.issues.length ? `<ul style="margin:12px 0 0; padding-left:18px;">${entry.issues.map((issue) => `<li>${escapeHtml20(issue.severity)}: ${escapeHtml20(issue.message)}</li>`).join("")}</ul>` : '<p style="margin:12px 0 0; color:#166534;">No contract issues.</p>'}
|
|
16682
|
+
</article>`).join("")}
|
|
16683
|
+
</section>
|
|
16684
|
+
</main>`;
|
|
16685
|
+
var createVoiceTelephonyCarrierMatrixRoutes = (options) => {
|
|
16686
|
+
const path = options.path ?? "/api/voice/telephony/carriers";
|
|
16687
|
+
return new Elysia21({
|
|
16688
|
+
name: options.name ?? "absolutejs-voice-telephony-carrier-matrix"
|
|
16689
|
+
}).get(path, async ({ query, request }) => {
|
|
16690
|
+
const providers = await options.load({ query, request });
|
|
16691
|
+
const matrix = createVoiceTelephonyCarrierMatrix({
|
|
16692
|
+
contract: options.contract,
|
|
16693
|
+
providers
|
|
16694
|
+
});
|
|
16695
|
+
if (query.format === "html") {
|
|
16696
|
+
return new Response(renderVoiceTelephonyCarrierMatrixHTML(matrix, {
|
|
16697
|
+
title: options.title
|
|
16698
|
+
}), {
|
|
16699
|
+
headers: {
|
|
16700
|
+
"content-type": "text/html; charset=utf-8"
|
|
16701
|
+
}
|
|
16702
|
+
});
|
|
16703
|
+
}
|
|
16704
|
+
return matrix;
|
|
16705
|
+
});
|
|
16706
|
+
};
|
|
16602
16707
|
// src/telephony/response.ts
|
|
16603
16708
|
var normalizeWhitespace = (value) => value.replace(/\s+/g, " ").trim();
|
|
16604
16709
|
var DEFAULT_MAX_WORDS = 12;
|
|
@@ -16711,6 +16816,7 @@ export {
|
|
|
16711
16816
|
renderVoiceTraceMarkdown,
|
|
16712
16817
|
renderVoiceTraceHTML,
|
|
16713
16818
|
renderVoiceToolContractHTML,
|
|
16819
|
+
renderVoiceTelephonyCarrierMatrixHTML,
|
|
16714
16820
|
renderVoiceSessionsHTML,
|
|
16715
16821
|
renderVoiceScenarioFixtureEvalHTML,
|
|
16716
16822
|
renderVoiceScenarioEvalHTML,
|
|
@@ -16786,6 +16892,8 @@ export {
|
|
|
16786
16892
|
createVoiceTelephonyWebhookRoutes,
|
|
16787
16893
|
createVoiceTelephonyWebhookHandler,
|
|
16788
16894
|
createVoiceTelephonyOutcomePolicy,
|
|
16895
|
+
createVoiceTelephonyCarrierMatrixRoutes,
|
|
16896
|
+
createVoiceTelephonyCarrierMatrix,
|
|
16789
16897
|
createVoiceTaskUpdatedEvent,
|
|
16790
16898
|
createVoiceTaskSLABreachedEvent,
|
|
16791
16899
|
createVoiceTaskCreatedEvent,
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type VoiceTelephonyContractOptions, type VoiceTelephonyContractReport, type VoiceTelephonyProvider, type VoiceTelephonySetupStatus, type VoiceTelephonySmokeReport } from './contract';
|
|
3
|
+
export type VoiceTelephonyCarrierMatrixStatus = 'fail' | 'pass' | 'warn';
|
|
4
|
+
export type VoiceTelephonyCarrierMatrixInput<TProvider extends VoiceTelephonyProvider = VoiceTelephonyProvider> = {
|
|
5
|
+
contract?: VoiceTelephonyContractReport<TProvider>;
|
|
6
|
+
name?: string;
|
|
7
|
+
setup: VoiceTelephonySetupStatus<TProvider>;
|
|
8
|
+
smoke?: VoiceTelephonySmokeReport<TProvider>;
|
|
9
|
+
};
|
|
10
|
+
export type VoiceTelephonyCarrierMatrixEntry<TProvider extends VoiceTelephonyProvider = VoiceTelephonyProvider> = {
|
|
11
|
+
contract: VoiceTelephonyContractReport<TProvider>;
|
|
12
|
+
issues: VoiceTelephonyContractReport<TProvider>['issues'];
|
|
13
|
+
name: string;
|
|
14
|
+
provider: TProvider;
|
|
15
|
+
ready: boolean;
|
|
16
|
+
setup: VoiceTelephonySetupStatus<TProvider>;
|
|
17
|
+
smoke?: VoiceTelephonySmokeReport<TProvider>;
|
|
18
|
+
status: VoiceTelephonyCarrierMatrixStatus;
|
|
19
|
+
summary: {
|
|
20
|
+
errors: number;
|
|
21
|
+
failures: number;
|
|
22
|
+
missing: number;
|
|
23
|
+
warnings: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type VoiceTelephonyCarrierMatrix = {
|
|
27
|
+
entries: VoiceTelephonyCarrierMatrixEntry[];
|
|
28
|
+
generatedAt: number;
|
|
29
|
+
pass: boolean;
|
|
30
|
+
summary: {
|
|
31
|
+
contractsPassing: number;
|
|
32
|
+
failing: number;
|
|
33
|
+
providers: number;
|
|
34
|
+
ready: number;
|
|
35
|
+
smokePassing: number;
|
|
36
|
+
warnings: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type VoiceTelephonyCarrierMatrixOptions = {
|
|
40
|
+
contract?: VoiceTelephonyContractOptions;
|
|
41
|
+
generatedAt?: number;
|
|
42
|
+
providers: VoiceTelephonyCarrierMatrixInput[];
|
|
43
|
+
};
|
|
44
|
+
export type VoiceTelephonyCarrierMatrixRoutesOptions = {
|
|
45
|
+
load: (input: {
|
|
46
|
+
query: Record<string, unknown>;
|
|
47
|
+
request: Request;
|
|
48
|
+
}) => Promise<VoiceTelephonyCarrierMatrixInput[]> | VoiceTelephonyCarrierMatrixInput[];
|
|
49
|
+
name?: string;
|
|
50
|
+
path?: string;
|
|
51
|
+
title?: string;
|
|
52
|
+
contract?: VoiceTelephonyContractOptions;
|
|
53
|
+
};
|
|
54
|
+
export declare const createVoiceTelephonyCarrierMatrix: (options: VoiceTelephonyCarrierMatrixOptions) => VoiceTelephonyCarrierMatrix;
|
|
55
|
+
export declare const renderVoiceTelephonyCarrierMatrixHTML: (matrix: VoiceTelephonyCarrierMatrix, options?: {
|
|
56
|
+
title?: string;
|
|
57
|
+
}) => string;
|
|
58
|
+
export declare const createVoiceTelephonyCarrierMatrixRoutes: (options: VoiceTelephonyCarrierMatrixRoutesOptions) => Elysia<"", {
|
|
59
|
+
decorator: {};
|
|
60
|
+
store: {};
|
|
61
|
+
derive: {};
|
|
62
|
+
resolve: {};
|
|
63
|
+
}, {
|
|
64
|
+
typebox: {};
|
|
65
|
+
error: {};
|
|
66
|
+
}, {
|
|
67
|
+
schema: {};
|
|
68
|
+
standaloneSchema: {};
|
|
69
|
+
macro: {};
|
|
70
|
+
macroFn: {};
|
|
71
|
+
parser: {};
|
|
72
|
+
response: {};
|
|
73
|
+
}, {
|
|
74
|
+
[x: string]: {
|
|
75
|
+
get: {
|
|
76
|
+
body: unknown;
|
|
77
|
+
params: {};
|
|
78
|
+
query: unknown;
|
|
79
|
+
headers: unknown;
|
|
80
|
+
response: {
|
|
81
|
+
200: Response | VoiceTelephonyCarrierMatrix;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
}, {
|
|
86
|
+
derive: {};
|
|
87
|
+
resolve: {};
|
|
88
|
+
schema: {};
|
|
89
|
+
standaloneSchema: {};
|
|
90
|
+
response: {};
|
|
91
|
+
}, {
|
|
92
|
+
derive: {};
|
|
93
|
+
resolve: {};
|
|
94
|
+
schema: {};
|
|
95
|
+
standaloneSchema: {};
|
|
96
|
+
response: {};
|
|
97
|
+
}>;
|