Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions packages/calling/src/SDKConnector/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@ export type Model = {
};
};

export type WDMDevice = {
url: string;
userId: string;
orgId: string;
version: string;
callingBehavior: string;
registered?: boolean;
webSocketUrl?: string;
register?: () => Promise<unknown>;
refresh?: () => Promise<unknown>;
/** WDM / device-registration settings (e.g. `webrtc-calling-over-ws`). */
settings?: Record<string, {value?: boolean} | undefined>;
features: {
developer: {
models: Model[];
get: (key: string) => {value: boolean} | undefined;
};
entitlement: {
models: Model[];
};
};
};

export type ServiceCatalog = {
serviceGroups: {
// cSpell:disable
Expand Down Expand Up @@ -99,28 +122,7 @@ export interface WebexSDK {
updateFeature?: (featureToggle: unknown) => void;
};
calendar: unknown;
device: {
url: string;
userId: string;
orgId: string;
version: string;
callingBehavior: string;
registered?: boolean;
webSocketUrl?: string;
register?: () => Promise<unknown>;
refresh?: () => Promise<unknown>;
/** WDM / device-registration settings (e.g. `webrtc-calling-over-ws`). */
settings?: Record<string, {value?: boolean} | undefined>;
features: {
developer: {
models: Model[];
get: (key: string) => {value: boolean} | undefined;
};
entitlement: {
models: Model[];
};
};
};
device: WDMDevice;
encryption: {
decryptText: (encryptionKeyUrl: string, encryptedData?: string) => Promise<string>;
encryptText: (encryptionKeyUrl: string, text?: string) => Promise<string>;
Expand Down
25 changes: 18 additions & 7 deletions packages/calling/src/common/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ import {
WEBEX_API_BTS,
BW_XSI_ENDPOINT_VERSION_WITH_SLASH,
} from './constants';
import {Model, WebexSDK} from '../SDKConnector/types';
import {Model, WDMDevice, WebexSDK} from '../SDKConnector/types';
import SDKConnector from '../SDKConnector';
import {CallSettingResponse} from '../CallSettings/types';
import {ContactResponse} from '../Contacts/types';
Expand Down Expand Up @@ -1216,16 +1216,16 @@ export const waitForMsecs = (msec: number) =>
});

/**
* Register calling backend.
* Determine the calling backend from the device object.
*
* @param webex -.
* @param device - The device object containing callingBehavior and entitlement features.
* @returns CallingBackEnd.
*/
export function getCallingBackEnd(webex: WebexSDK): CALLING_BACKEND {
const entModels: Model[] = webex.internal.device.features.entitlement.models;
export function resolveCallingBackend(device: WDMDevice): CALLING_BACKEND {
Comment thread
lismith2-cisco marked this conversation as resolved.
const entModels: Model[] = device.features.entitlement.models;
let callingBackend;

if (webex.internal.device.callingBehavior === NATIVE_WEBEX_TEAMS_CALLING) {
if (device.callingBehavior === NATIVE_WEBEX_TEAMS_CALLING) {
for (let i = 0; i < entModels.length; i += 1) {
if (
entModels[i][VALUES][KEY] === ENTITLEMENT_BASIC ||
Expand All @@ -1238,7 +1238,7 @@ export function getCallingBackEnd(webex: WebexSDK): CALLING_BACKEND {
break;
}
}
} else if (webex.internal.device.callingBehavior === NATIVE_SIP_CALL_TO_UCM) {
} else if (device.callingBehavior === NATIVE_SIP_CALL_TO_UCM) {
callingBackend = CALLING_BACKEND.UCM;
} else {
callingBackend = CALLING_BACKEND.INVALID;
Expand All @@ -1247,6 +1247,17 @@ export function getCallingBackEnd(webex: WebexSDK): CALLING_BACKEND {
return callingBackend as CALLING_BACKEND;
}

/**
* Register calling backend.
*
* @param webex -.
* @returns CallingBackEnd.
* @deprecated Use getCallingBackend(device) instead.
*/
export function getCallingBackEnd(webex: WebexSDK): CALLING_BACKEND {
return resolveCallingBackend(webex.internal.device);
}

/**
* Register XSI endpoint based on calling backend.
*
Expand Down
3 changes: 3 additions & 0 deletions packages/calling/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ export {
CallDetails,
CallDirection,
CallType,
CALLING_BACKEND,
DisplayInformation,
SORT,
SORT_BY,
} from './common/types';
export {resolveCallingBackend} from './common/Utils';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Export the documented getCallingBackend symbol

When consumers follow the new public API advertised by this change and import getCallingBackend from @webex/calling, the package still has no such named export; this entry point only exports resolveCallingBackend, while the deprecated wrapper's JSDoc also tells users to use getCallingBackend(device). Add or alias the exported function under the documented getCallingBackend name so the new API is actually available.

Useful? React with 👍 / 👎.

export {WDMDevice} from './SDKConnector/types';
export {CallError, LineError} from './Errors';
export {ICall, TransferType} from './CallingClient/calling/types';
export {LOGGER} from './Logger/types';
Expand Down
Loading