Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mapping and utilities (VF-2613) #175

Merged
merged 2 commits into from
Jan 24, 2022
Merged

Conversation

DecathectZero
Copy link
Member

@DecathectZero DecathectZero commented Jan 24, 2022

Fixes or implements VF-2613

Brief description. What is this change?

moved a bunch of utility functions out from services to a centralized location, and started adding in the mappings patterns with proper declarations and consistent names.

Check my comments for where they originally came from

We were using the _invert method to invert the array, but this has side effects because of many to one/one to many mappings. So it is better to be explicit

@vf-service-account vf-service-account marked this pull request as draft January 24, 2022 20:57
Comment on lines +15 to +28
export const AmazonToGeneralIntentMap: Partial<Record<AmazonIntent, General.IntentName>> = {
[AmazonIntent.NO]: General.IntentName.NO,
[AmazonIntent.YES]: General.IntentName.YES,
[AmazonIntent.STOP]: General.IntentName.STOP,
[AmazonIntent.NEXT]: General.IntentName.NEXT,
[AmazonIntent.HELP]: General.IntentName.HELP,
[AmazonIntent.PAUSE]: General.IntentName.PAUSE,
[AmazonIntent.CANCEL]: General.IntentName.CANCEL,
[AmazonIntent.RESUME]: General.IntentName.RESUME,
[AmazonIntent.REPEAT]: General.IntentName.REPEAT,
[AmazonIntent.FALLBACK]: General.IntentName.NONE,
[AmazonIntent.PREVIOUS]: General.IntentName.PREVIOUS,
[AmazonIntent.START_OVER]: General.IntentName.START_OVER,
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +30 to +43
export const GeneralToAmazonIntentMap: Partial<Record<General.IntentName, AmazonIntent>> = {
[General.IntentName.NO]: AmazonIntent.NO,
[General.IntentName.YES]: AmazonIntent.YES,
[General.IntentName.STOP]: AmazonIntent.STOP,
[General.IntentName.NEXT]: AmazonIntent.NEXT,
[General.IntentName.HELP]: AmazonIntent.HELP,
[General.IntentName.PAUSE]: AmazonIntent.PAUSE,
[General.IntentName.CANCEL]: AmazonIntent.CANCEL,
[General.IntentName.RESUME]: AmazonIntent.RESUME,
[General.IntentName.REPEAT]: AmazonIntent.REPEAT,
[General.IntentName.NONE]: AmazonIntent.FALLBACK,
[General.IntentName.PREVIOUS]: AmazonIntent.PREVIOUS,
[General.IntentName.START_OVER]: AmazonIntent.START_OVER,
};
Copy link
Member Author

Choose a reason for hiding this comment

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

@sonarcloud
Copy link

sonarcloud bot commented Jan 24, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 9 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Comment on lines +45 to +57
export const AmazonToGeneralSlotMap: Partial<Record<SlotType, General.SlotType>> = {
[SlotType.TIME]: General.SlotType.DATETIME,
[SlotType.DATE]: General.SlotType.DATETIME,
[SlotType.FOUR_DIGIT_NUMBER]: General.SlotType.NUMBER,
[SlotType.NUMBER]: General.SlotType.NUMBER,
[SlotType.PHONENUMBER]: General.SlotType.PHONENUMBER,
[SlotType.PERSON]: General.SlotType.NAME,
[SlotType.DE_FIRST_NAME]: General.SlotType.NAME,
[SlotType.GB_FIRST_NAME]: General.SlotType.NAME,
[SlotType.US_FIRST_NAME]: General.SlotType.NAME,
[SlotType.FIRSTNAME]: General.SlotType.NAME,
[SlotType.ORDINAL]: General.SlotType.ORDINAL,
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +59 to +65
export const GeneralToAmazonSlotMap: Partial<Record<General.SlotType, SlotType>> = {
[General.SlotType.DATETIME]: SlotType.DATE,
[General.SlotType.NUMBER]: SlotType.NUMBER,
[General.SlotType.PHONENUMBER]: SlotType.PHONENUMBER,
[General.SlotType.NAME]: SlotType.FIRSTNAME,
[General.SlotType.ORDINAL]: SlotType.ORDINAL,
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +67 to +83
export const AmazonToGeneralLocaleMap: Record<Locale, General.Locale> = {
[Locale.EN_US]: General.Locale.EN_US,
[Locale.EN_AU]: General.Locale.EN_US,
[Locale.EN_CA]: General.Locale.EN_US,
[Locale.EN_IN]: General.Locale.EN_US,
[Locale.EN_GB]: General.Locale.EN_US,
[Locale.FR_CA]: General.Locale.FR_CA,
[Locale.ES_US]: General.Locale.ES_ES,
[Locale.FR_FR]: General.Locale.FR_FR,
[Locale.DE_DE]: General.Locale.DE_DE,
[Locale.IT_IT]: General.Locale.IT_IT,
[Locale.JA_JP]: General.Locale.JA_JP,
[Locale.ES_ES]: General.Locale.ES_ES,
[Locale.ES_MX]: General.Locale.ES_MX,
[Locale.PT_BR]: General.Locale.PT_BR,
[Locale.HI_IN]: General.Locale.HI_IN,
};
Copy link
Member Author

@DecathectZero DecathectZero Jan 24, 2022

Choose a reason for hiding this comment

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

Comment on lines +85 to +105
export const GeneralToAmazonLocaleMap: Record<General.Locale, Locale> = {
[General.Locale.EN_US]: Locale.EN_US,
[General.Locale.AR_AR]: Locale.EN_US, // FIXME: Unsupported language by Alexa
[General.Locale.ZH_CN]: Locale.EN_US, // FIXME: Unsupported language by Alexa
[General.Locale.NL_NL]: Locale.EN_US, // FIXME: Unsupported language by Alexa
[General.Locale.FR_FR]: Locale.FR_FR,
[General.Locale.FR_CA]: Locale.FR_CA,
[General.Locale.DE_DE]: Locale.DE_DE,
[General.Locale.GU_IN]: Locale.EN_US, // FIXME: Unsupported language by Alexa
[General.Locale.HI_IN]: Locale.HI_IN,
[General.Locale.IT_IT]: Locale.IT_IT,
[General.Locale.JA_JP]: Locale.JA_JP,
[General.Locale.KO_KR]: Locale.EN_US, // FIXME: Unsupported language by Alexa
[General.Locale.MR_IN]: Locale.EN_US, // FIXME: Unsupported language by Alexa
[General.Locale.PT_BR]: Locale.PT_BR,
[General.Locale.ES_ES]: Locale.ES_ES,
[General.Locale.ES_MX]: Locale.ES_MX,
[General.Locale.TA_IN]: Locale.EN_US, // FIXME: Unsupported language by Alexa
[General.Locale.TE_IN]: Locale.EN_US, // FIXME: Unsupported language by Alexa
[General.Locale.TR_TR]: Locale.EN_US, // FIXME: Unsupported language by Alexa
};
Copy link
Member Author

@DecathectZero DecathectZero Jan 24, 2022

Choose a reason for hiding this comment

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

@DecathectZero DecathectZero marked this pull request as ready for review January 24, 2022 21:04
@DecathectZero DecathectZero merged commit 2d2e59d into master Jan 24, 2022
@DecathectZero DecathectZero deleted the tyler/utilities/VF-2613 branch January 24, 2022 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants