@softomnitel/omnicall-kit 0.1.0-rc.0
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/LICENSE +4 -0
- package/README.md +34 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/account-activate-commands.d.ts +30 -0
- package/dist/internal/account-activate-commands.d.ts.map +1 -0
- package/dist/internal/account-activate-commands.js +94 -0
- package/dist/internal/account-activate-commands.js.map +1 -0
- package/dist/internal/account-activate-wire.d.ts +16 -0
- package/dist/internal/account-activate-wire.d.ts.map +1 -0
- package/dist/internal/account-activate-wire.js +22 -0
- package/dist/internal/account-activate-wire.js.map +1 -0
- package/dist/internal/account-logout-commands.d.ts +23 -0
- package/dist/internal/account-logout-commands.d.ts.map +1 -0
- package/dist/internal/account-logout-commands.js +51 -0
- package/dist/internal/account-logout-commands.js.map +1 -0
- package/dist/internal/account-logout-wire.d.ts +15 -0
- package/dist/internal/account-logout-wire.d.ts.map +1 -0
- package/dist/internal/account-logout-wire.js +24 -0
- package/dist/internal/account-logout-wire.js.map +1 -0
- package/dist/internal/auth-grants.d.ts +6 -0
- package/dist/internal/auth-grants.d.ts.map +1 -0
- package/dist/internal/auth-grants.js +16 -0
- package/dist/internal/auth-grants.js.map +1 -0
- package/dist/internal/auth-inbound.d.ts +35 -0
- package/dist/internal/auth-inbound.d.ts.map +1 -0
- package/dist/internal/auth-inbound.js +86 -0
- package/dist/internal/auth-inbound.js.map +1 -0
- package/dist/internal/auth-orchestrator.d.ts +36 -0
- package/dist/internal/auth-orchestrator.d.ts.map +1 -0
- package/dist/internal/auth-orchestrator.js +217 -0
- package/dist/internal/auth-orchestrator.js.map +1 -0
- package/dist/internal/auth-pop-flow.d.ts +38 -0
- package/dist/internal/auth-pop-flow.d.ts.map +1 -0
- package/dist/internal/auth-pop-flow.js +80 -0
- package/dist/internal/auth-pop-flow.js.map +1 -0
- package/dist/internal/auth-wire.d.ts +37 -0
- package/dist/internal/auth-wire.d.ts.map +1 -0
- package/dist/internal/auth-wire.js +62 -0
- package/dist/internal/auth-wire.js.map +1 -0
- package/dist/internal/base64url.d.ts +7 -0
- package/dist/internal/base64url.d.ts.map +1 -0
- package/dist/internal/base64url.js +28 -0
- package/dist/internal/base64url.js.map +1 -0
- package/dist/internal/browser-websocket-transport.d.ts +36 -0
- package/dist/internal/browser-websocket-transport.d.ts.map +1 -0
- package/dist/internal/browser-websocket-transport.js +131 -0
- package/dist/internal/browser-websocket-transport.js.map +1 -0
- package/dist/internal/call-commands.d.ts +32 -0
- package/dist/internal/call-commands.d.ts.map +1 -0
- package/dist/internal/call-commands.js +60 -0
- package/dist/internal/call-commands.js.map +1 -0
- package/dist/internal/call-wire.d.ts +24 -0
- package/dist/internal/call-wire.d.ts.map +1 -0
- package/dist/internal/call-wire.js +37 -0
- package/dist/internal/call-wire.js.map +1 -0
- package/dist/internal/client-error-details.d.ts +60 -0
- package/dist/internal/client-error-details.d.ts.map +1 -0
- package/dist/internal/client-error-details.js +98 -0
- package/dist/internal/client-error-details.js.map +1 -0
- package/dist/internal/client-errors.d.ts +38 -0
- package/dist/internal/client-errors.d.ts.map +1 -0
- package/dist/internal/client-errors.js +37 -0
- package/dist/internal/client-errors.js.map +1 -0
- package/dist/internal/command-classification.d.ts +7 -0
- package/dist/internal/command-classification.d.ts.map +1 -0
- package/dist/internal/command-classification.js +14 -0
- package/dist/internal/command-classification.js.map +1 -0
- package/dist/internal/connection-session.d.ts +61 -0
- package/dist/internal/connection-session.d.ts.map +1 -0
- package/dist/internal/connection-session.js +333 -0
- package/dist/internal/connection-session.js.map +1 -0
- package/dist/internal/connection-state.d.ts +13 -0
- package/dist/internal/connection-state.d.ts.map +1 -0
- package/dist/internal/connection-state.js +75 -0
- package/dist/internal/connection-state.js.map +1 -0
- package/dist/internal/diagnostics.d.ts +36 -0
- package/dist/internal/diagnostics.d.ts.map +1 -0
- package/dist/internal/diagnostics.js +51 -0
- package/dist/internal/diagnostics.js.map +1 -0
- package/dist/internal/event-subscription.d.ts +23 -0
- package/dist/internal/event-subscription.d.ts.map +1 -0
- package/dist/internal/event-subscription.js +62 -0
- package/dist/internal/event-subscription.js.map +1 -0
- package/dist/internal/heartbeat-controller.d.ts +27 -0
- package/dist/internal/heartbeat-controller.d.ts.map +1 -0
- package/dist/internal/heartbeat-controller.js +58 -0
- package/dist/internal/heartbeat-controller.js.map +1 -0
- package/dist/internal/operator-commands.d.ts +46 -0
- package/dist/internal/operator-commands.d.ts.map +1 -0
- package/dist/internal/operator-commands.js +93 -0
- package/dist/internal/operator-commands.js.map +1 -0
- package/dist/internal/operator-wire.d.ts +20 -0
- package/dist/internal/operator-wire.d.ts.map +1 -0
- package/dist/internal/operator-wire.js +33 -0
- package/dist/internal/operator-wire.js.map +1 -0
- package/dist/internal/origin-policy-errors.d.ts +22 -0
- package/dist/internal/origin-policy-errors.d.ts.map +1 -0
- package/dist/internal/origin-policy-errors.js +67 -0
- package/dist/internal/origin-policy-errors.js.map +1 -0
- package/dist/internal/pop-crypto.d.ts +23 -0
- package/dist/internal/pop-crypto.d.ts.map +1 -0
- package/dist/internal/pop-crypto.js +48 -0
- package/dist/internal/pop-crypto.js.map +1 -0
- package/dist/internal/pop-key-store.d.ts +28 -0
- package/dist/internal/pop-key-store.d.ts.map +1 -0
- package/dist/internal/pop-key-store.js +153 -0
- package/dist/internal/pop-key-store.js.map +1 -0
- package/dist/internal/product-commands.d.ts +33 -0
- package/dist/internal/product-commands.d.ts.map +1 -0
- package/dist/internal/product-commands.js +70 -0
- package/dist/internal/product-commands.js.map +1 -0
- package/dist/internal/product-inbound.d.ts +15 -0
- package/dist/internal/product-inbound.d.ts.map +1 -0
- package/dist/internal/product-inbound.js +31 -0
- package/dist/internal/product-inbound.js.map +1 -0
- package/dist/internal/product-orchestrator.d.ts +46 -0
- package/dist/internal/product-orchestrator.d.ts.map +1 -0
- package/dist/internal/product-orchestrator.js +188 -0
- package/dist/internal/product-orchestrator.js.map +1 -0
- package/dist/internal/product-wire.d.ts +29 -0
- package/dist/internal/product-wire.d.ts.map +1 -0
- package/dist/internal/product-wire.js +54 -0
- package/dist/internal/product-wire.js.map +1 -0
- package/dist/internal/public-event-map.d.ts +27 -0
- package/dist/internal/public-event-map.d.ts.map +1 -0
- package/dist/internal/public-event-map.js +38 -0
- package/dist/internal/public-event-map.js.map +1 -0
- package/dist/internal/reconnect-policy.d.ts +16 -0
- package/dist/internal/reconnect-policy.d.ts.map +1 -0
- package/dist/internal/reconnect-policy.js +23 -0
- package/dist/internal/reconnect-policy.js.map +1 -0
- package/dist/internal/request-correlator.d.ts +41 -0
- package/dist/internal/request-correlator.d.ts.map +1 -0
- package/dist/internal/request-correlator.js +130 -0
- package/dist/internal/request-correlator.js.map +1 -0
- package/dist/internal/requested-capabilities.d.ts +10 -0
- package/dist/internal/requested-capabilities.d.ts.map +1 -0
- package/dist/internal/requested-capabilities.js +25 -0
- package/dist/internal/requested-capabilities.js.map +1 -0
- package/dist/internal/scheduler.d.ts +41 -0
- package/dist/internal/scheduler.d.ts.map +1 -0
- package/dist/internal/scheduler.js +104 -0
- package/dist/internal/scheduler.js.map +1 -0
- package/dist/internal/session-identity.d.ts +16 -0
- package/dist/internal/session-identity.d.ts.map +1 -0
- package/dist/internal/session-identity.js +13 -0
- package/dist/internal/session-identity.js.map +1 -0
- package/dist/internal/snapshot-acquisition.d.ts +21 -0
- package/dist/internal/snapshot-acquisition.d.ts.map +1 -0
- package/dist/internal/snapshot-acquisition.js +40 -0
- package/dist/internal/snapshot-acquisition.js.map +1 -0
- package/dist/internal/snapshot-cache.d.ts +13 -0
- package/dist/internal/snapshot-cache.d.ts.map +1 -0
- package/dist/internal/snapshot-cache.js +18 -0
- package/dist/internal/snapshot-cache.js.map +1 -0
- package/dist/internal/transport-port.d.ts +34 -0
- package/dist/internal/transport-port.d.ts.map +1 -0
- package/dist/internal/transport-port.js +7 -0
- package/dist/internal/transport-port.js.map +1 -0
- package/dist/internal/window-commands.d.ts +23 -0
- package/dist/internal/window-commands.d.ts.map +1 -0
- package/dist/internal/window-commands.js +76 -0
- package/dist/internal/window-commands.js.map +1 -0
- package/dist/public/auth-client.d.ts +87 -0
- package/dist/public/auth-client.d.ts.map +1 -0
- package/dist/public/auth-client.js +116 -0
- package/dist/public/auth-client.js.map +1 -0
- package/dist/public/omnicall-client-api.d.ts +159 -0
- package/dist/public/omnicall-client-api.d.ts.map +1 -0
- package/dist/public/omnicall-client-api.js +5 -0
- package/dist/public/omnicall-client-api.js.map +1 -0
- package/dist/public/omnicall-client.d.ts +22 -0
- package/dist/public/omnicall-client.d.ts.map +1 -0
- package/dist/public/omnicall-client.js +171 -0
- package/dist/public/omnicall-client.js.map +1 -0
- package/dist/public/protocol-reexports.d.ts +41 -0
- package/dist/public/protocol-reexports.d.ts.map +1 -0
- package/dist/public/protocol-reexports.js +7 -0
- package/dist/public/protocol-reexports.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official browser WebSocket adapter for {@link TransportPort}.
|
|
3
|
+
* Protocol / reconnect / auth stay in the connection session — this is bytes only.
|
|
4
|
+
*/
|
|
5
|
+
const UNSUPPORTED_DATA_CLOSE_CODE = 1003;
|
|
6
|
+
const UNSUPPORTED_DATA_REASON = 'unsupported_data';
|
|
7
|
+
function resolveWebSocketConstructor(override) {
|
|
8
|
+
if (override !== undefined) {
|
|
9
|
+
return override;
|
|
10
|
+
}
|
|
11
|
+
const globalCtor = globalThis.WebSocket;
|
|
12
|
+
if (typeof globalCtor !== 'function') {
|
|
13
|
+
throw new Error('OmniCall Kit: WebSocket is unavailable. Pass transportFactory (tests/Node) or run in a browser with WebSocket.');
|
|
14
|
+
}
|
|
15
|
+
return globalCtor;
|
|
16
|
+
}
|
|
17
|
+
function subscribe(set, handler) {
|
|
18
|
+
set.add(handler);
|
|
19
|
+
return () => {
|
|
20
|
+
set.delete(handler);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function emitClose(listeners, code, reason) {
|
|
24
|
+
const info = Object.freeze({ code, reason });
|
|
25
|
+
for (const listener of listeners) {
|
|
26
|
+
listener(info);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function emitError(listeners, info) {
|
|
30
|
+
const frozen = Object.freeze(info);
|
|
31
|
+
for (const listener of listeners) {
|
|
32
|
+
listener(frozen);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function normalizeMessageData(data) {
|
|
36
|
+
return typeof data === 'string' ? data : undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create one browser WebSocket transport instance.
|
|
40
|
+
* Call once per connect/reconnect attempt (via `transportFactory`).
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export function createBrowserWebSocketTransport(options) {
|
|
44
|
+
let socket;
|
|
45
|
+
let openReadyState = 1;
|
|
46
|
+
let connectAttempted = false;
|
|
47
|
+
const openListeners = new Set();
|
|
48
|
+
const messageListeners = new Set();
|
|
49
|
+
const closeListeners = new Set();
|
|
50
|
+
const errorListeners = new Set();
|
|
51
|
+
const clearSocket = () => {
|
|
52
|
+
socket = undefined;
|
|
53
|
+
};
|
|
54
|
+
const attachHandlers = (ws) => {
|
|
55
|
+
ws.binaryType = 'blob';
|
|
56
|
+
ws.onopen = () => {
|
|
57
|
+
for (const listener of openListeners) {
|
|
58
|
+
listener();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
ws.onmessage = (event) => {
|
|
62
|
+
const text = normalizeMessageData(event.data);
|
|
63
|
+
if (text === undefined) {
|
|
64
|
+
emitError(errorListeners, {
|
|
65
|
+
name: 'WebSocketError',
|
|
66
|
+
message: 'unsupported_data'
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
ws.close(UNSUPPORTED_DATA_CLOSE_CODE, UNSUPPORTED_DATA_REASON);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
emitClose(closeListeners, UNSUPPORTED_DATA_CLOSE_CODE, UNSUPPORTED_DATA_REASON);
|
|
73
|
+
clearSocket();
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
for (const listener of messageListeners) {
|
|
78
|
+
listener(text);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
ws.onerror = () => {
|
|
82
|
+
emitError(errorListeners, {
|
|
83
|
+
name: 'WebSocketError',
|
|
84
|
+
message: 'transport_error'
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
ws.onclose = (event) => {
|
|
88
|
+
clearSocket();
|
|
89
|
+
emitClose(closeListeners, event.code, event.reason ?? '');
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
connect: (url) => {
|
|
94
|
+
if (connectAttempted || socket !== undefined) {
|
|
95
|
+
throw new Error('BrowserWebSocketTransport already used; create a new instance');
|
|
96
|
+
}
|
|
97
|
+
connectAttempted = true;
|
|
98
|
+
const WebSocketCtor = resolveWebSocketConstructor(options?.webSocket);
|
|
99
|
+
openReadyState = WebSocketCtor.OPEN;
|
|
100
|
+
const ws = new WebSocketCtor(url);
|
|
101
|
+
socket = ws;
|
|
102
|
+
attachHandlers(ws);
|
|
103
|
+
},
|
|
104
|
+
send: (data) => {
|
|
105
|
+
if (socket === undefined || socket.readyState !== openReadyState) {
|
|
106
|
+
throw new Error('BrowserWebSocketTransport is not open');
|
|
107
|
+
}
|
|
108
|
+
socket.send(data);
|
|
109
|
+
},
|
|
110
|
+
close: (code = 1000, reason = '') => {
|
|
111
|
+
if (socket === undefined) {
|
|
112
|
+
if (connectAttempted) {
|
|
113
|
+
emitClose(closeListeners, code, reason);
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
socket.close(code, reason);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
clearSocket();
|
|
122
|
+
emitClose(closeListeners, code, reason);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
onOpen: (handler) => subscribe(openListeners, handler),
|
|
126
|
+
onMessage: (handler) => subscribe(messageListeners, handler),
|
|
127
|
+
onClose: (handler) => subscribe(closeListeners, handler),
|
|
128
|
+
onError: (handler) => subscribe(errorListeners, handler)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=browser-websocket-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-websocket-transport.js","sourceRoot":"","sources":["../../src/internal/browser-websocket-transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqCH,MAAM,2BAA2B,GAAG,IAAI,CAAC;AACzC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAEnD,SAAS,2BAA2B,CAClC,QAAiD;IAEjD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,UAAU,GACd,UACD,CAAC,SAAS,CAAC;IACZ,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,SAAS,CAChB,GAAmB,EACnB,OAA2B;IAE3B,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjB,OAAO,GAAG,EAAE;QACV,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAChB,SAA0C,EAC1C,IAAY,EACZ,MAAc;IAEd,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,QAAQ,CAAC,IAAI,CAAC,C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
|
|
4
|
+
import { type CapabilityId } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
import type { ConnectionSession } from './connection-session.js';
|
|
6
|
+
import type { Scheduler } from './scheduler.js';
|
|
7
|
+
export type CallMutationResult = {
|
|
8
|
+
readonly callId: string;
|
|
9
|
+
readonly revision: number;
|
|
10
|
+
};
|
|
11
|
+
export type CallControlType = 'call:answer' | 'call:reject' | 'call:hangup' | 'call:hold' | 'call:resume' | 'call:mute' | 'call:unmute';
|
|
12
|
+
export type CallCommandApi = {
|
|
13
|
+
readonly originateCall: (input: {
|
|
14
|
+
readonly destination: string;
|
|
15
|
+
readonly expectedRevision: number;
|
|
16
|
+
}) => Promise<CallMutationResult>;
|
|
17
|
+
readonly controlCall: (type: CallControlType, input: {
|
|
18
|
+
readonly callId: string;
|
|
19
|
+
readonly expectedRevision: number;
|
|
20
|
+
}) => Promise<CallMutationResult>;
|
|
21
|
+
readonly sendDtmf: (input: {
|
|
22
|
+
readonly callId: string;
|
|
23
|
+
readonly digits: string;
|
|
24
|
+
readonly expectedRevision: number;
|
|
25
|
+
}) => Promise<CallMutationResult>;
|
|
26
|
+
};
|
|
27
|
+
export declare function createCallCommandApi(deps: {
|
|
28
|
+
readonly connection: ConnectionSession;
|
|
29
|
+
readonly scheduler: Scheduler;
|
|
30
|
+
readonly getGrantedCapabilities: () => readonly CapabilityId[];
|
|
31
|
+
}): CallCommandApi;
|
|
32
|
+
//# sourceMappingURL=call-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-commands.d.ts","sourceRoot":"","sources":["../../src/internal/call-commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,gCAAgC,CAAC;AAOxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAWjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,kBAAk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apability } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
import { buildCallControlBody, buildCallOriginateBody, buildCallSendDtmfBody } from './call-wire.js';
|
|
6
|
+
import { createClientError } from './client-errors.js';
|
|
7
|
+
import { guardReady, mapReplyFailure, readCallMutationResult, requireWireIdentity } from './product-commands.js';
|
|
8
|
+
const CONTROL_CAPABILITY = {
|
|
9
|
+
'call:answer': 'call.answer',
|
|
10
|
+
'call:reject': 'call.reject',
|
|
11
|
+
'call:hangup': 'call.hangup',
|
|
12
|
+
'call:hold': 'call.hold',
|
|
13
|
+
'call:resume': 'call.hold',
|
|
14
|
+
'call:mute': 'call.mute',
|
|
15
|
+
'call:unmute': 'call.mute'
|
|
16
|
+
};
|
|
17
|
+
function guardCallCapability(granted, capability) {
|
|
18
|
+
if (!sessionHasCapability(granted, capability)) {
|
|
19
|
+
return createClientError({ code: 'forbidden', retryable: false });
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
export function createCallCommandApi(deps) {
|
|
24
|
+
const runCallMutation = async (commandType, capability, buildBody) => {
|
|
25
|
+
const notReady = guardReady(deps.connection);
|
|
26
|
+
if (notReady !== undefined) {
|
|
27
|
+
return Promise.reject(notReady);
|
|
28
|
+
}
|
|
29
|
+
const missingCap = guardCallCapability(deps.getGrantedCapabilities(), capability);
|
|
30
|
+
if (missingCap !== undefined) {
|
|
31
|
+
return Promise.reject(missingCap);
|
|
32
|
+
}
|
|
33
|
+
const identity = requireWireIdentity(deps.connection);
|
|
34
|
+
if ('code' in identity) {
|
|
35
|
+
return Promise.reject(identity);
|
|
36
|
+
}
|
|
37
|
+
const requestId = crypto.randomUUID();
|
|
38
|
+
const fields = {
|
|
39
|
+
requestId,
|
|
40
|
+
serverInstanceId: identity.serverInstanceId,
|
|
41
|
+
sessionEpoch: identity.sessionEpoch,
|
|
42
|
+
occurredAtMs: deps.scheduler.now()
|
|
43
|
+
};
|
|
44
|
+
const result = await deps.connection.request({
|
|
45
|
+
requestId,
|
|
46
|
+
commandType,
|
|
47
|
+
body: buildBody(fields)
|
|
48
|
+
});
|
|
49
|
+
if (!result.ok || !result.reply.ok) {
|
|
50
|
+
return Promise.reject(mapReplyFailure(result));
|
|
51
|
+
}
|
|
52
|
+
return readCallMutationResult(result.reply);
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
originateCall: (input) => runCallMutation('call:originate', 'call.originate', (fields) => buildCallOriginateBody(fields, input)),
|
|
56
|
+
controlCall: (type, input) => runCallMutation(type, CONTROL_CAPABILITY[type], (fields) => buildCallControlBody(type, fields, input)),
|
|
57
|
+
sendDtmf: (input) => runCallMutation('call:send-dtmf', 'call.control', (fields) => buildCallSendDtmfBody(fields, input))
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=call-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-commands.js","sourceRoot":"","sources":["../../src/internal/call-commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,oBAAoB,EAGrB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAiB/B,MAAM,kBAAkB,GAAoD;IAC1E,aAAa,EAAE,aAAa;IAC5B,aAAa,EAAE,aAAa;IAC5B,aAAa,EAAE,aAAa;IAC5B,WAAW,EAAE,WAAW;IACxB,aAAa,EAAE,WAAW;IAC1B,WAAW,EAAE,WAAW;IACxB,aAAa,EAAE,WAAW;CAC3B,CAAC;AAkBF,SAAS,mBAAmB,CAC1B,OAAgC,EAChC,UAAwB;IAExB,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,EAA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AC,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YACnC,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,sBAAsB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC,CAAC;IAEF,OAAO;QACL,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CACvB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,CAAC,MAAM,EAAE,EAAE,CAC7D,sBAAsB,CAAC,MAAM,EAAE,KAAK,CAAC,CACtC;QACH,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAC3B,eAAe,CAAC,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CACzD,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAC1C;QACH,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAClB,eAAe,CAAC,gBAAgB,EAAE,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAC3D,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,CACrC;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call mutation wire builders (SDK-06). Schema-aligned outbound frames.
|
|
3
|
+
*/
|
|
4
|
+
type WireIdentity = {
|
|
5
|
+
readonly requestId: string;
|
|
6
|
+
readonly serverInstanceId: string;
|
|
7
|
+
readonly sessionEpoch: string;
|
|
8
|
+
readonly occurredAtMs: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function buildCallOriginateBody(identity: WireIdentity, input: {
|
|
11
|
+
readonly destination: string;
|
|
12
|
+
readonly expectedRevision: number;
|
|
13
|
+
}): string;
|
|
14
|
+
export declare function buildCallControlBody(type: 'call:answer' | 'call:reject' | 'call:hangup' | 'call:hold' | 'call:resume' | 'call:mute' | 'call:unmute', identity: WireIdentity, input: {
|
|
15
|
+
readonly callId: string;
|
|
16
|
+
readonly expectedRevision: number;
|
|
17
|
+
}): string;
|
|
18
|
+
export declare function buildCallSendDtmfBody(identity: WireIdentity, input: {
|
|
19
|
+
readonly callId: string;
|
|
20
|
+
readonly digits: string;
|
|
21
|
+
readonly expectedRevision: number;
|
|
22
|
+
}): string;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=call-wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-wire.d.ts","sourceRoot":"","sources":["../../src/internal/call-wire.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B,CAAC;AAmBF,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,GACzE,MAAM,CAKR;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EACA,aAAa,GACb,aAAa,GACb,aAAa,GACb,WAAW,GACX,aAAa,GACb,WAAW,GACX,aAAa,EACjB,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,GACpE,MAAM,CAKR;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE;IACL,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC,GACA,MAAM,CAMR"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call mutation wire builders (SDK-06). Schema-aligned outbound frames.
|
|
3
|
+
*/
|
|
4
|
+
import { PROTOCOL_MAJOR } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
import { isoNow } from './auth-wire.js';
|
|
6
|
+
function envelope(type, identity, payload) {
|
|
7
|
+
return JSON.stringify({
|
|
8
|
+
protocolVersion: PROTOCOL_MAJOR,
|
|
9
|
+
kind: 'command',
|
|
10
|
+
type,
|
|
11
|
+
requestId: identity.requestId,
|
|
12
|
+
serverInstanceId: identity.serverInstanceId,
|
|
13
|
+
sessionEpoch: identity.sessionEpoch,
|
|
14
|
+
occurredAt: isoNow(identity.occurredAtMs),
|
|
15
|
+
payload
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function buildCallOriginateBody(identity, input) {
|
|
19
|
+
return envelope('call:originate', identity, {
|
|
20
|
+
destination: input.destination,
|
|
21
|
+
expectedRevision: input.expectedRevision
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function buildCallControlBody(type, identity, input) {
|
|
25
|
+
return envelope(type, identity, {
|
|
26
|
+
callId: input.callId,
|
|
27
|
+
expectedRevision: input.expectedRevision
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function buildCallSendDtmfBody(identity, input) {
|
|
31
|
+
return envelope('call:send-dtmf', identity, {
|
|
32
|
+
callId: input.callId,
|
|
33
|
+
digits: input.digits,
|
|
34
|
+
expectedRevision: input.expectedRevision
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=call-wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-wire.js","sourceRoot":"","sources":["../../src/internal/call-wire.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO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
|
+
* Raw `details` stays WireJsonObject for forward compatibility; hosts should use
|
|
4
|
+
* these helpers instead of indexing unknown keys.
|
|
5
|
+
*/
|
|
6
|
+
import type { WireJsonObject } from '@softomnitel/omnicall-protocol';
|
|
7
|
+
import { type OmniCallClientError } from './client-errors.js';
|
|
8
|
+
import type { OperatorReason } from './operator-commands.js';
|
|
9
|
+
/**
|
|
10
|
+
* Logout / human-step details for `interaction_required`.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export type InteractionRequiredDetails = {
|
|
14
|
+
readonly requiresReason: true;
|
|
15
|
+
readonly reasons: readonly OperatorReason[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Common `conflict` detail keys (activate pending, finish-appeal gate, hide busy).
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export type ConflictErrorDetails = {
|
|
22
|
+
readonly failure_kind?: string;
|
|
23
|
+
readonly activate_consent_pending?: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Common `operation_failed` detail keys (e.g. originate preflight).
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export type OperationFailedDetails = {
|
|
30
|
+
readonly failure_kind?: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Parse logout-style `interaction_required` details.
|
|
34
|
+
* Returns `undefined` when shape is absent or malformed (fail closed for hosts).
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare function readInteractionRequiredDetails(details: WireJsonObject | undefined): InteractionRequiredDetails | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Best-effort typed view of `conflict` details (additive keys only).
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export declare function readConflictErrorDetails(details: WireJsonObject | undefined): ConflictErrorDetails | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Best-effort typed view of `operation_failed` details.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare function readOperationFailedDetails(details: WireJsonObject | undefined): OperationFailedDetails | undefined;
|
|
48
|
+
/** @public */
|
|
49
|
+
export declare function isInteractionRequiredError(error: unknown): error is OmniCallClientError & {
|
|
50
|
+
readonly code: 'interaction_required';
|
|
51
|
+
};
|
|
52
|
+
/** @public */
|
|
53
|
+
export declare function isConflictError(error: unknown): error is OmniCallClientError & {
|
|
54
|
+
readonly code: 'conflict';
|
|
55
|
+
};
|
|
56
|
+
/** @public */
|
|
57
|
+
export declare function isOperationFailedError(error: unknown): error is OmniCallClientError & {
|
|
58
|
+
readonly code: 'operation_failed';
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=client-error-details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-error-details.d.ts","sourceRoot":"","sources":["../../src/internal/client-error-details.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;CAC7C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;CAC7C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAWF;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,cAAc,GAAG,SAAS,GAClC,0BAA0B,GAAG,SAAS,CA+BxC;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,cAAc,GAAG,SAAS,GAClC,oBAAoB,GAAG,SAAS,CAqBlC;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,cAAc,GAAG,SAAS,GAClC,sBAAsB,GAAG,SAAS,CAUpC;AAED,cAAc;AACd,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,mBAAmB,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;CAAE,CAE1E;AAED,cAAc;AACd,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,mBAAmB,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAE9D;AAED,cAAc;AACd,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,mBAAmB,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAEtE"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed readers for common OmniCallClientError.details shapes.
|
|
3
|
+
* Raw `details` stays WireJsonObject for forward compatibility; hosts should use
|
|
4
|
+
* these helpers instead of indexing unknown keys.
|
|
5
|
+
*/
|
|
6
|
+
import { isOmniCallClientError } from './client-errors.js';
|
|
7
|
+
function asRecord(details) {
|
|
8
|
+
if (details === undefined) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
return details;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parse logout-style `interaction_required` details.
|
|
15
|
+
* Returns `undefined` when shape is absent or malformed (fail closed for hosts).
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export function readInteractionRequiredDetails(details) {
|
|
19
|
+
const record = asRecord(details);
|
|
20
|
+
if (record === undefined || record['requiresReason'] !== true) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const raw = record['reasons'];
|
|
24
|
+
if (!Array.isArray(raw)) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const reasons = [];
|
|
28
|
+
for (const item of raw) {
|
|
29
|
+
if (typeof item !== 'object' || item === null) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const row = item;
|
|
33
|
+
const id = row['id'];
|
|
34
|
+
const label = row['label'];
|
|
35
|
+
const kind = row['kind'];
|
|
36
|
+
if (typeof id !== 'number' ||
|
|
37
|
+
!Number.isInteger(id) ||
|
|
38
|
+
id < 0 ||
|
|
39
|
+
typeof label !== 'string' ||
|
|
40
|
+
label.length === 0 ||
|
|
41
|
+
(kind !== 'ready' && kind !== 'break' && kind !== 'logout')) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
reasons.push({ id, label, kind });
|
|
45
|
+
}
|
|
46
|
+
return { requiresReason: true, reasons };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Best-effort typed view of `conflict` details (additive keys only).
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export function readConflictErrorDetails(details) {
|
|
53
|
+
const record = asRecord(details);
|
|
54
|
+
if (record === undefined) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const failureKind = record['failure_kind'];
|
|
58
|
+
const pending = record['activate_consent_pending'];
|
|
59
|
+
const out = {};
|
|
60
|
+
if (typeof failureKind === 'string' && failureKind.length > 0) {
|
|
61
|
+
out.failure_kind = failureKind;
|
|
62
|
+
}
|
|
63
|
+
if (typeof pending === 'boolean') {
|
|
64
|
+
out.activate_consent_pending = pending;
|
|
65
|
+
}
|
|
66
|
+
if (out.failure_kind === undefined && out.activate_consent_pending === undefined) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Best-effort typed view of `operation_failed` details.
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export function readOperationFailedDetails(details) {
|
|
76
|
+
const record = asRecord(details);
|
|
77
|
+
if (record === undefined) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const failureKind = record['failure_kind'];
|
|
81
|
+
if (typeof failureKind !== 'string' || failureKind.length === 0) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
return { failure_kind: failureKind };
|
|
85
|
+
}
|
|
86
|
+
/** @public */
|
|
87
|
+
export function isInteractionRequiredError(error) {
|
|
88
|
+
return isOmniCallClientError(error) && error.code === 'interaction_required';
|
|
89
|
+
}
|
|
90
|
+
/** @public */
|
|
91
|
+
export function isConflictError(error) {
|
|
92
|
+
return isOmniCallClientError(error) && error.code === 'conflict';
|
|
93
|
+
}
|
|
94
|
+
/** @public */
|
|
95
|
+
export function isOperationFailedError(error) {
|
|
96
|
+
return isOmniCallClientError(error) && error.code === 'operation_failed';
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=client-error-details.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-error-details.js","sourceRoot":"","sources":["../../src/internal/client-error-details.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,qBAAqB,EAEtB,MAAM,oBAAoB,CAAC;AA6B5B,SAAS,QAAQ,CACf,OAAmC;IAEnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAAmC;IAEnC,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9D,OAAO,SAAS,CAA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,CAAC;AACnE,CAAC;AAED,cAAc;AACd,MAAM,UAAU,sBAAsB,CACpC,KAAc;IAEd,OAAO,qBAAqB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed client failures for Promise-returning product commands.
|
|
3
|
+
*/
|
|
4
|
+
import type { ProtocolErrorCode, WireJsonObject } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
/**
|
|
6
|
+
* Typed failure for OmniCallClient commands.
|
|
7
|
+
* Prefer `isOmniCallClientError` + `readInteractionRequiredDetails` /
|
|
8
|
+
* `readConflictErrorDetails` / `readOperationFailedDetails` over raw `details` indexing.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare class OmniCallClientError extends Error {
|
|
12
|
+
readonly name = "OmniCallClientError";
|
|
13
|
+
/** Stable protocol / client error code. */
|
|
14
|
+
readonly code: ProtocolErrorCode;
|
|
15
|
+
/** Whether a later retry may succeed without user policy change. */
|
|
16
|
+
readonly retryable: boolean;
|
|
17
|
+
/** Present on many `stale_state` failures — refresh snapshot before retry. */
|
|
18
|
+
readonly currentRevision: number | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Safe JSON details (never secrets). Shape varies by `code`; use typed readers.
|
|
21
|
+
*/
|
|
22
|
+
readonly details: WireJsonObject | undefined;
|
|
23
|
+
constructor(input: {
|
|
24
|
+
readonly code: ProtocolErrorCode;
|
|
25
|
+
readonly retryable: boolean;
|
|
26
|
+
readonly currentRevision?: number;
|
|
27
|
+
readonly details?: WireJsonObject;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export declare function createClientError(input: {
|
|
31
|
+
readonly code: ProtocolErrorCode;
|
|
32
|
+
readonly retryable: boolean;
|
|
33
|
+
readonly currentRevision?: number;
|
|
34
|
+
readonly details?: WireJsonObject;
|
|
35
|
+
}): OmniCallClientError;
|
|
36
|
+
/** @public */
|
|
37
|
+
export declare function isOmniCallClientError(value: unknown): value is OmniCallClientError;
|
|
38
|
+
//# sourceMappingURL=client-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-errors.d.ts","sourceRoot":"","sources":["../../src/internal/client-errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAExF;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,SAAkB,IAAI,yBAAyB;IAE/C,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAEjC,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,8EAA8E;IAC9E,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,CAAC;gBAEjC,KAAK,EAAE;QACjB,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;QACjC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;QAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;QAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;KACnC;CAOF;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC,GAAG,mBAAmB,CAEtB;AAED,cAAc;AACd,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAElF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed client failures for Promise-returning product commands.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Typed failure for OmniCallClient commands.
|
|
6
|
+
* Prefer `isOmniCallClientError` + `readInteractionRequiredDetails` /
|
|
7
|
+
* `readConflictErrorDetails` / `readOperationFailedDetails` over raw `details` indexing.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export class OmniCallClientError extends Error {
|
|
11
|
+
name = 'OmniCallClientError';
|
|
12
|
+
/** Stable protocol / client error code. */
|
|
13
|
+
code;
|
|
14
|
+
/** Whether a later retry may succeed without user policy change. */
|
|
15
|
+
retryable;
|
|
16
|
+
/** Present on many `stale_state` failures — refresh snapshot before retry. */
|
|
17
|
+
currentRevision;
|
|
18
|
+
/**
|
|
19
|
+
* Safe JSON details (never secrets). Shape varies by `code`; use typed readers.
|
|
20
|
+
*/
|
|
21
|
+
details;
|
|
22
|
+
constructor(input) {
|
|
23
|
+
super(input.code);
|
|
24
|
+
this.code = input.code;
|
|
25
|
+
this.retryable = input.retryable;
|
|
26
|
+
this.currentRevision = input.currentRevision;
|
|
27
|
+
this.details = input.details;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function createClientError(input) {
|
|
31
|
+
return new OmniCallClientError(input);
|
|
32
|
+
}
|
|
33
|
+
/** @public */
|
|
34
|
+
export function isOmniCallClientError(value) {
|
|
35
|
+
return value instanceof OmniCallClientError;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=client-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-errors.js","sourceRoot":"","sources":["../../src/internal/client-errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC1B,IAAI,GAAG,qBAAqB,CAAC;IAE/C,2CAA2C;IAClC,IAAI,CAAoB;IAEjC,oEAAoE;IAC3D,SAAS,CAAU;IAE5B,8EAA8E;IACrE,eAAe,CAAqB;IAE7C;;OAEG;IACM,OAAO,CAA6B;IAE7C,YAAY,KAKX;QACC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,KAKjC;IACC,OAAO,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC;AAED,cAAc;AACd,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,OAAO,KAAK,YAAY,mBAAmB,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side classification for reconnect safety.
|
|
3
|
+
* Non-idempotent mutations must never be silently replayed.
|
|
4
|
+
*/
|
|
5
|
+
import type { CommandType } from '@softomnitel/omnicall-protocol';
|
|
6
|
+
export declare function isMutationCommand(commandType: CommandType): boolean;
|
|
7
|
+
//# sourceMappingURL=command-classification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-classification.d.ts","sourceRoot":"","sources":["../../src/internal/command-classification.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AASlE,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAEnE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side classification for reconnect safety.
|
|
3
|
+
* Non-idempotent mutations must never be silently replayed.
|
|
4
|
+
*/
|
|
5
|
+
const IDEMPOTENT_COMMANDS = new Set([
|
|
6
|
+
'sdk:get-snapshot',
|
|
7
|
+
'sdk:ping',
|
|
8
|
+
'window:get-state',
|
|
9
|
+
'operator:get-reasons'
|
|
10
|
+
]);
|
|
11
|
+
export function isMutationCommand(commandType) {
|
|
12
|
+
return !IDEMPOTENT_COMMANDS.has(commandType);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=command-classification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-classification.js","sourceRoot":"","sources":["../../src/internal/command-classification.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,mBAAmB,GAA6B,IAAI,GAAG,CAAC;IAC5D,kBAAkB;IAClB,UAAU;IACV,kBAAkB;IAClB,sBAAsB;CACvB,CAAC,CAAC;AAEH,MAAM,UAAU,iBAAiB,CAAC,WAAwB;IACxD,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC/C,CAAC"}
|