@absolutejs/voice 0.0.22-beta.76 → 0.0.22-beta.77

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 CHANGED
@@ -81,7 +81,9 @@ export type { VoiceS3ReviewStoreClient, VoiceS3ReviewStoreFile, VoiceS3ReviewSto
81
81
  export type { VoiceSQLiteRuntimeStorage, VoiceSQLiteStoreOptions } from './sqliteStore';
82
82
  export type { StoredVoiceIntegrationEvent, StoredVoiceExternalObjectMap, StoredVoiceOpsTask, VoiceExternalObjectMap, VoiceExternalObjectMapStore, VoiceOpsTaskAgeBucket, VoiceOpsTaskAnalyticsOptions, VoiceOpsTaskAnalyticsSummary, VoiceOpsTaskAssignmentRule, VoiceOpsTaskAssignmentRuleCondition, VoiceOpsTaskAssignmentRules, VoiceOpsTaskAssigneeAnalytics, VoiceOpsDispositionTaskPolicies, VoiceOpsSLABreachPolicy, VoiceIntegrationDeliveryStatus, VoiceIntegrationEvent, VoiceIntegrationEventStore, VoiceIntegrationSinkDelivery, VoiceIntegrationEventType, VoiceIntegrationWebhookConfig, VoiceOpsTask, VoiceOpsTaskHistoryEntry, VoiceOpsTaskKind, VoiceOpsTaskPolicy, VoiceOpsTaskPriority, VoiceOpsTaskStatus, VoiceOpsTaskStore, VoiceOpsTaskSummary, VoiceOpsTaskWorkerAnalytics } from './ops';
83
83
  export { createTwilioMediaStreamBridge, createTwilioVoiceRoutes, createTwilioVoiceResponse, decodeTwilioMulawBase64, encodeTwilioMulawBase64, transcodePCMToTwilioOutboundPayload, transcodeTwilioInboundPayloadToPCM16 } from './telephony/twilio';
84
+ export { evaluateVoiceTelephonyContract } from './telephony/contract';
84
85
  export type { TwilioInboundMessage, TwilioMediaStreamBridge, TwilioMediaStreamBridgeOptions, TwilioMediaStreamSocket, TwilioOutboundClearMessage, TwilioOutboundMarkMessage, TwilioOutboundMediaMessage, TwilioOutboundMessage, TwilioVoiceRouteParameters, TwilioVoiceResponseOptions, TwilioVoiceSmokeCheck, TwilioVoiceSmokeOptions, TwilioVoiceSmokeReport, TwilioVoiceSetupOptions, TwilioVoiceSetupStatus, TwilioVoiceRoutesOptions } from './telephony/twilio';
86
+ export type { VoiceTelephonyContractIssue, VoiceTelephonyContractOptions, VoiceTelephonyContractReport, VoiceTelephonyContractRequirement, VoiceTelephonyProvider, VoiceTelephonySetupStatus, VoiceTelephonySmokeCheck, VoiceTelephonySmokeReport } from './telephony/contract';
85
87
  export { shapeTelephonyAssistantText } from './telephony/response';
86
88
  export type { TelephonyResponseShapeMode, TelephonyResponseShapeOptions } from './telephony/response';
87
89
  export * from './types';
package/dist/index.js CHANGED
@@ -15904,6 +15904,85 @@ var createTwilioVoiceRoutes = (options) => {
15904
15904
  return report;
15905
15905
  });
15906
15906
  };
15907
+ // src/telephony/contract.ts
15908
+ var DEFAULT_REQUIREMENTS = [
15909
+ "stream-url",
15910
+ "wss-stream",
15911
+ "webhook-url",
15912
+ "signed-webhook",
15913
+ "smoke-pass"
15914
+ ];
15915
+ var hasFailingSmokeCheck = (smoke) => smoke?.checks.some((check) => check.status === "fail") ?? false;
15916
+ var evaluateVoiceTelephonyContract = (input) => {
15917
+ const requirements = input.options?.requirements ?? DEFAULT_REQUIREMENTS;
15918
+ const issues = [];
15919
+ const hasRequirement = (requirement) => requirements.includes(requirement);
15920
+ if (hasRequirement("stream-url") && !input.setup.urls.stream) {
15921
+ issues.push({
15922
+ message: "Missing media stream URL.",
15923
+ requirement: "stream-url",
15924
+ severity: "error"
15925
+ });
15926
+ }
15927
+ if (hasRequirement("wss-stream") && !input.setup.urls.stream.startsWith("wss://")) {
15928
+ issues.push({
15929
+ message: "Media stream URL must use wss://.",
15930
+ requirement: "wss-stream",
15931
+ severity: "error"
15932
+ });
15933
+ }
15934
+ if (hasRequirement("webhook-url") && !input.setup.urls.webhook) {
15935
+ issues.push({
15936
+ message: "Missing carrier webhook URL.",
15937
+ requirement: "webhook-url",
15938
+ severity: "error"
15939
+ });
15940
+ }
15941
+ if (hasRequirement("signed-webhook") && !input.setup.signing.configured) {
15942
+ issues.push({
15943
+ message: "Carrier webhook signature verification is not configured.",
15944
+ requirement: "signed-webhook",
15945
+ severity: "error"
15946
+ });
15947
+ }
15948
+ if (hasRequirement("smoke-pass")) {
15949
+ if (!input.smoke) {
15950
+ issues.push({
15951
+ message: "Missing telephony smoke test report.",
15952
+ requirement: "smoke-pass",
15953
+ severity: "error"
15954
+ });
15955
+ } else if (!input.smoke.pass || hasFailingSmokeCheck(input.smoke)) {
15956
+ issues.push({
15957
+ message: "Telephony smoke test did not pass.",
15958
+ requirement: "smoke-pass",
15959
+ severity: "error"
15960
+ });
15961
+ }
15962
+ }
15963
+ for (const warning of input.setup.warnings) {
15964
+ issues.push({
15965
+ message: warning,
15966
+ requirement: "stream-url",
15967
+ severity: "warning"
15968
+ });
15969
+ }
15970
+ for (const name of input.setup.missing) {
15971
+ issues.push({
15972
+ message: `${name} is missing.`,
15973
+ requirement: "webhook-url",
15974
+ severity: "error"
15975
+ });
15976
+ }
15977
+ return {
15978
+ issues,
15979
+ pass: issues.every((issue) => issue.severity !== "error"),
15980
+ provider: input.setup.provider,
15981
+ requirements,
15982
+ setup: input.setup,
15983
+ smoke: input.smoke
15984
+ };
15985
+ };
15907
15986
  // src/telephony/response.ts
15908
15987
  var normalizeWhitespace = (value) => value.replace(/\s+/g, " ").trim();
15909
15988
  var DEFAULT_MAX_WORDS = 12;
@@ -16046,6 +16125,7 @@ export {
16046
16125
  failVoiceOpsTask,
16047
16126
  exportVoiceTrace,
16048
16127
  evaluateVoiceTrace,
16128
+ evaluateVoiceTelephonyContract,
16049
16129
  evaluateVoiceQuality,
16050
16130
  encodeTwilioMulawBase64,
16051
16131
  deliverVoiceTraceEventsToSinks,
@@ -0,0 +1,61 @@
1
+ export type VoiceTelephonyProvider = 'generic' | 'plivo' | 'telnyx' | 'twilio';
2
+ export type VoiceTelephonySetupStatus<TProvider extends VoiceTelephonyProvider = VoiceTelephonyProvider> = {
3
+ generatedAt: number;
4
+ missing: string[];
5
+ provider: TProvider;
6
+ ready: boolean;
7
+ signing: {
8
+ configured: boolean;
9
+ mode: 'custom' | 'none' | 'provider-signature' | 'twilio-signature';
10
+ verificationUrl?: string;
11
+ };
12
+ urls: {
13
+ stream: string;
14
+ twiml?: string;
15
+ webhook: string;
16
+ };
17
+ warnings: string[];
18
+ };
19
+ export type VoiceTelephonySmokeCheck = {
20
+ details?: Record<string, unknown>;
21
+ message?: string;
22
+ name: string;
23
+ status: 'fail' | 'pass' | 'warn';
24
+ };
25
+ export type VoiceTelephonySmokeReport<TProvider extends VoiceTelephonyProvider = VoiceTelephonyProvider> = {
26
+ checks: VoiceTelephonySmokeCheck[];
27
+ generatedAt: number;
28
+ pass: boolean;
29
+ provider: TProvider;
30
+ setup: VoiceTelephonySetupStatus<TProvider>;
31
+ twiml?: {
32
+ status: number;
33
+ streamUrl?: string;
34
+ };
35
+ webhook?: {
36
+ body?: unknown;
37
+ status: number;
38
+ };
39
+ };
40
+ export type VoiceTelephonyContractRequirement = 'signed-webhook' | 'smoke-pass' | 'stream-url' | 'webhook-url' | 'wss-stream';
41
+ export type VoiceTelephonyContractIssue = {
42
+ requirement: VoiceTelephonyContractRequirement;
43
+ severity: 'error' | 'warning';
44
+ message: string;
45
+ };
46
+ export type VoiceTelephonyContractReport<TProvider extends VoiceTelephonyProvider = VoiceTelephonyProvider> = {
47
+ issues: VoiceTelephonyContractIssue[];
48
+ pass: boolean;
49
+ provider: TProvider;
50
+ requirements: VoiceTelephonyContractRequirement[];
51
+ setup: VoiceTelephonySetupStatus<TProvider>;
52
+ smoke?: VoiceTelephonySmokeReport<TProvider>;
53
+ };
54
+ export type VoiceTelephonyContractOptions = {
55
+ requirements?: VoiceTelephonyContractRequirement[];
56
+ };
57
+ export declare const evaluateVoiceTelephonyContract: <TProvider extends VoiceTelephonyProvider>(input: {
58
+ options?: VoiceTelephonyContractOptions;
59
+ setup: VoiceTelephonySetupStatus<TProvider>;
60
+ smoke?: VoiceTelephonySmokeReport<TProvider>;
61
+ }) => VoiceTelephonyContractReport<TProvider>;
@@ -1,4 +1,5 @@
1
1
  import { Elysia } from 'elysia';
2
+ import type { VoiceTelephonySetupStatus, VoiceTelephonySmokeCheck, VoiceTelephonySmokeReport } from './contract';
2
3
  import { type VoiceTelephonyOutcomePolicy, type VoiceTelephonyWebhookRoutesOptions } from '../telephonyOutcome';
3
4
  import { type VoiceCallReviewArtifact, type VoiceCallReviewConfig } from '../testing/review';
4
5
  import type { AudioFormat, VoiceLogger, VoicePluginConfig, VoiceSessionRecord, VoiceServerMessage } from '../types';
@@ -113,48 +114,19 @@ export type TwilioVoiceRouteParameters = Record<string, string | number | boolea
113
114
  query: Record<string, unknown>;
114
115
  request: Request;
115
116
  }) => Promise<Record<string, string | number | boolean | undefined>> | Record<string, string | number | boolean | undefined>);
116
- export type TwilioVoiceSetupStatus = {
117
- generatedAt: number;
118
- missing: string[];
119
- provider: 'twilio';
120
- ready: boolean;
121
- signing: {
122
- configured: boolean;
123
- mode: 'custom' | 'none' | 'twilio-signature';
124
- verificationUrl?: string;
125
- };
126
- urls: {
127
- stream: string;
117
+ export type TwilioVoiceSetupStatus = VoiceTelephonySetupStatus<'twilio'> & {
118
+ urls: VoiceTelephonySetupStatus<'twilio'>['urls'] & {
128
119
  twiml: string;
129
- webhook: string;
130
120
  };
131
- warnings: string[];
132
121
  };
133
122
  export type TwilioVoiceSetupOptions = {
134
123
  path?: false | string;
135
124
  requiredEnv?: Record<string, string | undefined>;
136
125
  title?: string;
137
126
  };
138
- export type TwilioVoiceSmokeCheck = {
139
- details?: Record<string, unknown>;
140
- message?: string;
141
- name: string;
142
- status: 'fail' | 'pass' | 'warn';
143
- };
144
- export type TwilioVoiceSmokeReport = {
145
- checks: TwilioVoiceSmokeCheck[];
146
- generatedAt: number;
147
- pass: boolean;
148
- provider: 'twilio';
127
+ export type TwilioVoiceSmokeCheck = VoiceTelephonySmokeCheck;
128
+ export type TwilioVoiceSmokeReport = VoiceTelephonySmokeReport<'twilio'> & {
149
129
  setup: TwilioVoiceSetupStatus;
150
- twiml?: {
151
- status: number;
152
- streamUrl?: string;
153
- };
154
- webhook?: {
155
- body?: unknown;
156
- status: number;
157
- };
158
130
  };
159
131
  export type TwilioVoiceSmokeOptions = {
160
132
  callSid?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.76",
3
+ "version": "0.0.22-beta.77",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",