/* eslint-disable sonarjs/no-duplicate-string */ export const apiRules = [ { id: 'voice_ice_servers', name: 'Usage of voice.iceServers', description: 'Usage of manager.updateConfig({sdkOptions: {voice: {iceServers: []} }) has changed', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Since Flex UI 2.x, passing an array of custom ICE servers to use to connect media is now performed differently', deprecatedSince: '2.x', recommendation: { message: 'Do this instead', code: 'manager.updateConfig({\n sdkOptions: {\n voice: {\n acceptOptions: {\n rtcConfiguration: {\n iceServers: []\n }\n }\n }\n }\n});', link: 'https://www.twilio.com/docs/voice/sdks/javascript/v1/device#best-practice-note', }, parse: { type: 'ObjectExpression', locate: 'Identifier', filter: { name: 'iceServers', }, validate: { key: 'parent.node.key.name', value: 'voice', }, }, }, { id: 'twilio_css_classes', name: 'Deprecated CSS classes', type: 'css', description: 'Deprecated CSS classes', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Twilio classes have been deprecated in favor of Themes. Do not use .Twilio-* classnames.', deprecatedSince: '2.x', recommendation: { message: 'Use Themes for customizing styles instead', code: '', link: 'https://www.twilio.com/docs/flex/developer/ui-and-plugins/themes-branding-styling', }, parse: { type: 'ExpressionStatement', locate: 'Identifier', filter: { name: 'Twilio', }, }, }, { id: 'token_update_listener', name: 'Flex access token update listener changed', description: 'Flex access token update listener changed', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'loginHandler no longer supports listening to flex access token update event.', deprecatedSince: '2.x', recommendation: { message: "Please use the native Flex 'tokenUpdated' Event instead.", code: 'import { Manager } from "@twilio/flex-ui";\nconst manager = Manager.getInstance();\nmanager.events.addListener("tokenUpdated", (tokenPayload) => {});', link: 'https://www.twilio.com/docs/flex/developer/ui/migration-guide/migration-guide-2x-updates#new-flex-access-token-update-behavior', }, parse: { type: 'CallExpression', locate: 'Identifier', filter: { name: 'loginHandler', }, validate: { key: 'node.arguments[0].value', value: 'tokenUpdated', }, }, }, { id: 'task_methods', name: 'New Flex actions for TR SDK', description: 'New Flex actions for TR SDK', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Invoking methods on task objects directly is deprecated.', deprecatedSince: '2.x', recommendation: { placeholderMap: { transfer: 'TransferTask', setAttributes: 'SetTaskAttributes', wrapUp: 'WrapUpTask', complete: 'CompleteTask', hold: 'HoldCall', unhold: 'UnHold', holdParticipant: 'HoldParticipant', unholdParticipant: 'UnHoldParticipant', kick: 'KickParticipant', cancelTransfer: 'CancelTransfer', updateWorkerParticipation: 'UpdateWorkerParticipant', updateCustomerParticipant: 'UpdateCustomerParticipant', issueCallToWorker: 'IssueCallToWorker', dequeue: 'Dequeue', redirectCall: 'RedirectCall', endConference: 'EndConferenceForAll', }, message: 'Do this instead', code: 'Actions.invokeAction(\\"\\", {\n sid: \\"WRXXXXXXXXXXXXXXXXX\\",\n targetSid: targetSid,\n options: options\n}', link: 'https://www.twilio.com/docs/flex/developer/ui/migration-guide/migration-guide-2x-updates#new-actions-and-flex-events-for-the-taskrouter-sdk', }, parse: { type: 'CallExpression', locate: 'Identifier', filter: { name: [ 'transfer', 'setAttributes', 'wrapUp', 'complete', 'hold', 'holdParticipant', 'unHoldParticipant', 'unHold', 'kick', 'cancelTransfer', 'updateWorkerParticipant', 'updateCustomerParticipant', 'issueCallToWorker', 'dequeue', 'redirectCall', 'endConference', ], }, }, }, { id: 'get_region_code_from_number', name: 'getRegionCodeFromNumber method deprecated', description: 'CountryManager.getRegionCodeFromNumber is no longer available.', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'CountryManager.getRegionCodeFromNumber is no longer available.', deprecatedSince: '2.x', recommendation: { message: 'Please use getCountryKeyFromNumber instead.', code: '', }, parse: { type: 'CallExpression', locate: 'Identifier', filter: { name: 'getRegionCodeFromNumber', }, }, }, { id: 'task_channel_colors', name: 'colors property of taskChannel deprecated', description: 'colors property of taskChannel deprecated', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'In 2.x, items in the task list no longer have a colored element that can be configured according to the task channel.', deprecatedSince: '2.x', recommendation: { placeholderMap: { Voice: 'Voice', Chat: 'Chat', SMS: 'SMS', }, message: 'Colored element can be added to the TaskList for default channels like so:', code: "DefaultTaskChannels..addedComponents = [\n {\n target: 'TaskListItem',\n component: \n }\n];", }, parse: { type: 'MemberExpression', locate: 'Identifier', filter: { name: 'colors', }, validate: { key: 'node.object.property.name', value: ['Chat', 'Voice', 'SMS'], }, }, }, { id: 'incoming_call_listener', name: 'Listening to incoming calls has changed', description: 'Listening to incoming calls using voiceClient from flex manager has changed', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: "Listening to incoming calls using voiceClient like `voiceClient.on('connect',() =>{})` has been deprecated.", deprecatedSince: '2.x', recommendation: { message: 'To detect a running call within the Flex UI, listen for an incoming Voice event through the Flex Manager.', code: 'const manager = Flex.Manager.getInstance();\n\nmanager.voiceClient.on(\'incoming\', onVoiceClientConnectListener);\n\n// Listener function\nfunction onVoiceClientConnectListener (){\n console.log("Call detected");\n // Do something\n}\nTo detect a running call, use:\nActions.addListener("beforeAcceptTask", (payload) => {\n if (payload.task.taskChannelUniqueName === \'voice\') {\n console.log("Call detected");\n }\n});', link: 'https://www.twilio.com/docs/flex/developer/ui/migration-guide/migration-guide-2x-updates#listen-for-a-running-call-on-flex-ui-2xx for details', }, parse: { type: 'CallExpression', locate: 'Identifier', filter: { name: 'voiceClient', }, validate: { key: 'node.arguments[0].value', value: 'connect', }, }, }, { id: 'ui_attributes_color_themes', name: 'Deprecated colorThemes', description: 'Flex UI 2.x.x uses a new theming structure that more closely maps to the Twilio Paste design system. config.colorTheme is deprecated', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'The colorTheme property within the ui_attributes of the Flex configuration has been deprecated and is no longer supported.', deprecatedSince: '2.x', recommendation: { message: 'Use theme property of ui_attributes to either select light or dark modes.', code: 'const configuration = {\n theme: {\n isLight: false\n }\n};\nFlex.manager.updateConfig(configuration);', link: 'https://www.twilio.com/docs/flex/developer/ui/migration-guide/migration-guide-2x-updates#deprecated-predefined-themes', }, parse: { type: 'ObjectProperty', locate: 'Identifier', filter: { name: 'colorTheme', }, }, }, { id: 'conference_source', name: "Internal use property 'source' removed", description: "Internal use property 'source' removed", createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: "'source' is not a public property and may be removed in the future without notice", deprecatedSince: '2.x', recommendation: { message: 'Conference participants are available directly on the conference object at conference.participants. If you wish to retrieve channelType, it can be accessed from the associated task directly at task.channelType.', code: '', }, parse: { type: 'MemberExpression', locate: 'Identifier', filter: { name: 'source', }, validate: { key: 'parent.node.type', value: 'MemberExpression', }, }, }, { id: 'workers_data_table_compare_fn', name: 'Workers Data Table sorting changed', description: 'Workers Data Table sorting changed', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: "'WorkersDataTable.defaultProps.initialCompareFunction' is no longer available.", deprecatedSince: '2.x', recommendation: { message: "Use sortWorkers, sortCalls, and sortTasks on WorkersDataTable.defaultProps to specify the compare functions used by the workers, calls, and tasks columns.\nFor initial sorting, we've introduced a new prop, defaultSortColumn, to the WorkersDataTable where it will take the key as the value", code: '', link: 'https://assets.flex.twilio.com/docs/releases/flex-ui/2.5.0/programmable-components/components/WorkersDataTable/', }, parse: { type: 'MemberExpression', locate: 'Identifier', filter: { name: 'initialCompareFunction', }, }, }, { id: 'chat-channel-prop', name: 'Usage of chatChannel prop', description: "'chatChannel' prop in child component of certain dynamic components, has changed to 'conversation'.", createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: "Since Flex UI 2.x, 'chatChannel' prop in the child component of a few programmable components has changed to 'conversation'", deprecatedSince: '2.x', recommendation: { message: "Please use 'conversation' prop instead. Refer the link below to know the differences between chatChannel and conversation properties.", code: '', link: 'https://www.twilio.com/docs/flex/developer/ui/migration-guide/migration-guide-2x-updates#conversations-sdk', }, parse: [ { type: 'MemberExpression', locate: 'Identifier', filter: { name: 'chatChannel', }, validate: { key: 'node.property.name', value: 'chatChannel', }, }, { type: 'ObjectProperty', locate: 'Identifier', filter: { name: 'chatChannel', }, validate: { key: 'node.value.name', value: 'chatChannel', }, }, ], }, ]; export const versionRules = [ { id: 'react_1_x', name: 'Flex UI <> React compatibility', description: 'Flex UI React compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '1.x', warningMessage: 'Flex UI version 1.x requires React ^16.5.2', deprecatedSince: 'version string', recommendation: {}, packageName: 'react', packageVersion: '^16.5.2', }, { id: 'react_dom_1_x', name: 'Flex UI <> React-DOM compatibility', description: 'Flex UI React-DOM compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '1.x', warningMessage: 'Flex UI version 1.x requires React-dom ^16.5.2', deprecatedSince: 'version string', recommendation: {}, packageName: 'react-dom', packageVersion: '^16.5.2', }, { id: 'react_2_x', name: 'Flex UI React compatibility', description: 'Flex UI React compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Flex UI version 2.x requires React ^17.0.0', deprecatedSince: '', recommendation: {}, packageName: 'react', packageVersion: '^17.0.0', }, { id: 'react_dom_2_x', name: 'Flex UI React-DOM compatibility', description: 'Flex UI React-DOM compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Flex UI version 2.x requires React-dom ^17.0.0', deprecatedSince: '', recommendation: {}, packageName: 'react-dom', packageVersion: '^17.0.0', }, { id: 'redux_2_x', name: 'Flex UI Redux compatibility', description: 'Flex UI Redux compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Flex UI version 2.x requires Redux ^4.0.5', deprecatedSince: '', recommendation: {}, packageName: 'redux', packageVersion: '^4.0.5', }, { id: 'react_redux_2_x', name: 'Flex UI React-Redux compatibility', description: 'Flex UI React-Redux compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Flex UI version 2.x requires React-Redux ^7.2.2', deprecatedSince: '', recommendation: {}, packageName: 'react-redux', packageVersion: '^7.2.2', }, { id: 'redux_1_x', name: 'Flex UI Redux compatibility', description: 'Flex UI Redux compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '1.x', warningMessage: 'Flex UI version 1.x requires Redux 3.7.2', deprecatedSince: '', recommendation: {}, packageName: 'redux', packageVersion: '3.7.2', }, { id: 'react_redux_1_x', name: 'Flex UI React-Redux compatibility', description: 'Flex UI React-Redux compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '1.x', warningMessage: 'Flex UI version 1.x requires React-Redux ~5.1.0', deprecatedSince: '', recommendation: {}, packageName: 'react-redux', packageVersion: '~5.1.0', }, { id: 'react_router_dom_2_x', name: 'Flex UI react-router-dom compatibility', description: 'Flex UI react-router-dom compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Flex UI version 2.x requires react-router-dom ^5.2.0', deprecatedSince: '', recommendation: {}, packageName: 'react-router-dom', packageVersion: '^5.2.0', }, { id: 'react_router_dom_1_x', name: 'Flex UI react-router-dom compatibility', description: 'Flex UI react-router-dom compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '1.x', warningMessage: 'Flex UI version 1.x requires react-router-dom 4.3.1', deprecatedSince: '', recommendation: {}, packageName: 'react-router-dom', packageVersion: '4.3.1', }, { id: 'react_router_1_x', name: 'Flex UI react-router compatibility', description: 'Flex UI react-router compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '1.x', warningMessage: 'Flex UI version 1.x requires react-router 4.3.1', deprecatedSince: '', recommendation: {}, packageName: 'react-router', packageVersion: '4.3.1', }, { id: 'react_router_redux_2_x', name: 'Flex UI react-router-redux compatibility', description: 'Flex UI react-router-redux compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Flex UI version 2.x requires react-router-redux 4.3.1', deprecatedSince: '', recommendation: {}, packageName: 'react-router-redux', packageVersion: '4.3.1', }, { id: 'emotion_1_x', name: 'Flex UI emotion compatibility', description: 'Flex UI emotion compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '1.x', warningMessage: 'Flex UI version 1.x requires emotion 9.2.6', deprecatedSince: '', recommendation: {}, packageName: 'emotion', packageVersion: '9.2.6', }, { id: 'emotion_theming_1_x', name: 'Flex UI emotion-theming compatibility', description: 'Flex UI emotion-theming compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '1.x', warningMessage: 'Flex UI version 1.x requires emotion-theming 9.2.6', deprecatedSince: '', recommendation: {}, packageName: 'emotion-theming', packageVersion: '9.2.6', }, { id: 'react_emotion_1_x', name: 'Flex UI react-emotion compatibility', description: 'Flex UI react-emotion compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '1.x', warningMessage: 'Flex UI version 1.x requires react-emotion 9.2.6', deprecatedSince: '', recommendation: {}, packageName: 'react-emotion', packageVersion: '9.2.6', }, { id: 'create_emotion_styled_1_x', name: 'Flex UI create-emotion-styled compatibility', description: 'Flex UI create-emotion-styled compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '1.x', warningMessage: 'Flex UI version 1.x requires create-emotion-styled ^9.2.6', deprecatedSince: '', recommendation: {}, packageName: 'create-emotion-styled', packageVersion: '^9.2.6', }, { id: 'emotion_css_2_x', name: 'Flex UI emotion compatibility', description: 'Flex UI emotion compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Flex UI version 2.x requires @emotion/css ^11.1.3', deprecatedSince: '', recommendation: {}, packageName: '@emotion/css', packageVersion: '^11.1.3', }, { id: 'emotion_react_2_x', name: 'Flex UI emotion compatibility', description: 'Flex UI emotion compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Flex UI version 2.x requires @emotion/react ^11.1.5', deprecatedSince: '', recommendation: {}, packageName: '@emotion/react', packageVersion: '^11.1.5', }, { id: 'emotion_styled_2_x', name: 'Flex UI emotion compatibility', description: 'Flex UI emotion compatibility', createdBy: 'flex-runtime', createdAt: 'timestamp', status: 'active', flexVersion: '2.x', warningMessage: 'Flex UI version 2.x requires @emotion/styled ^11.1.5', deprecatedSince: '', recommendation: {}, packageName: '@emotion/styled', packageVersion: '^11.1.5', }, ];