-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: refactoring currency module to use central geo data [ATLAS-167] #119
Merged
Merged
Changes from 45 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
04be70f
[chore]: migrate convertToMajorUnit from modular data to geo data
RgnDunes 0a31e95
[chore]: migrate convertToMinorUnit from modular data to geo data
RgnDunes 0a99b1e
[chore]: migrate getCurrencySymbol, getCurrencyList from modular data…
RgnDunes cecfc5e
[fix]: minor typo issues
RgnDunes 94a60b4
[chore]: remove module currency data
RgnDunes a1bd63f
[fix]: fixed exception message and respective UT for currency module
RgnDunes f94e5ce
[feat]: add getters for currency name and denominations and their UTs
RgnDunes f4a42e4
Merge remote-tracking branch 'origin/master' into feat/currency-geo-d…
RgnDunes 803a5fc
[feat]: i18nify-data alias path added for static imports
tarun-khanna a8665df
Merge branch 'master' of github.com:razorpay/i18nify into feat/i18nif…
tarun-khanna 345bbcb
Create six-seals-matter.md
tarun-khanna 18fb57b
[chore]: Merge remote-tracking branch 'origin/feat/i18nify-data-alias…
RgnDunes fb69967
[fix]: update i18nify-data imports
RgnDunes 31116f1
[chore]: alias mapping added in jest config
tarun-khanna a33b6ed
Merge branch 'feat/i18nify-data-alias' of github.com:razorpay/i18nify…
tarun-khanna 155bcdb
Merge remote-tracking branch 'origin/feat/i18nify-data-alias' into fe…
RgnDunes e8e64d2
[fix]: fix e2e
RgnDunes 8e1cdbe
Create chilly-timers-impress.md
RgnDunes 0a37540
[chore]: removed extra changeset file
RgnDunes dff98c0
[fix]: remove unused code
RgnDunes 010849b
[fix]: jst coverage
RgnDunes 2104a53
[chore]: Merge remote-tracking branch 'origin/master' into feat/curre…
RgnDunes 883fd57
[chore]: add config for build time support
RgnDunes 6568461
[chore]: modify existing currency apis to use json subset created dur…
RgnDunes 58fd032
[fix]: fix build issues
RgnDunes 92cfe26
[fix]: fix build issues
RgnDunes d969053
[fix]: fix build issues
RgnDunes 847cc99
[feat]: add prebuild command in validate.yml
RgnDunes 051550d
[fix]: update script.js
RgnDunes 8ba0688
[fix]: update script.js
RgnDunes 4fd7677
[fix]: update script.js
RgnDunes 684fff0
[fix]: fix ts errors
RgnDunes 3f0646f
[feat]: add codeCov GH action prebuild step
RgnDunes 719e25c
[feat]: add working-directory for prebuild step in codeCov
RgnDunes 08c270a
[chore]: modifies script.js to script.ts
RgnDunes e6c1a19
[fix]: remove script.js
RgnDunes 550f6e4
[resolve]: resolve review comments
RgnDunes 6f2c12d
[chore]: migrated scripts to cript folder
RgnDunes 2190465
[prettier]: apply prettier formatting
RgnDunes b0e180e
Merge remote-tracking branch 'origin/master' into feat/currency-geo-d…
RgnDunes 31db929
Merge remote-tracking branch 'origin/master' into feat/currency-geo-d…
RgnDunes de316a9
Merge remote-tracking branch 'origin/master' into feat/currency-geo-d…
RgnDunes 42b8869
[fix]: rollup json import fix
RgnDunes 77eefa5
Merge remote-tracking branch 'origin/master' into feat/currency-geo-d…
RgnDunes b7af662
Merge branch 'master' into feat/currency-geo-data-migration
RgnDunes dfdb503
[chore]: resolve review comments
RgnDunes da3d1cd
Merge branch 'master' into feat/currency-geo-data-migration
RgnDunes 07cef04
[test]: dummy commit
RgnDunes 45c43ca
[chore]: remove redundant type assertions
RgnDunes 9349cee
[chore]: remove redundant type assertions
RgnDunes 6f68562
[chore]: resolve review comments
RgnDunes File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@razorpay/i18nify-js': patch | ||
--- | ||
|
||
feat: refactoring currency module to use central geo data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/i18nify-js/scripts/jsonSubsets/currency/transformCurrencyConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Creates a smaller json currency configuration from parent i18nify-data. | ||
* | ||
* @example | ||
* {"AFN": { | ||
"name": "Afghani", | ||
"numeric_code": "971", | ||
"minor_unit": "2", | ||
"symbol": "؋", | ||
"physical_currency_denominations": [ | ||
"1", | ||
"2", | ||
"5", | ||
"10", | ||
"20", | ||
"50", | ||
"100", | ||
"500", | ||
"1000" | ||
] | ||
} | ||
transforms to | ||
{"AFN": { | ||
"name": "Afghani", | ||
"minor_unit": "2", | ||
"symbol": "؋" | ||
} | ||
} | ||
* | ||
*/ | ||
|
||
export default () => { | ||
const DATA = require('#/i18nify-data/currency/data.json'); | ||
|
||
const currencyInfo = DATA.currency_information; | ||
|
||
const currencyConfigSubset = Object.keys(currencyInfo).reduce( | ||
(acc: any, curr: any) => { | ||
acc[curr] = { | ||
name: currencyInfo[curr].name, | ||
minor_unit: currencyInfo[curr].minor_unit, | ||
symbol: currencyInfo[curr].symbol, | ||
}; | ||
return acc; | ||
}, | ||
{}, | ||
); | ||
|
||
return { | ||
data: currencyConfigSubset, | ||
subsetFilePath: './src/modules/currency/data/currencyConfig.json', | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import transformFormatterConfig from './phoneNumber/transformFormatterConfig'; | ||
import transformRegexConfig from './phoneNumber/transformRegexConfig'; | ||
import transformCurrencyConfig from './currency/transformCurrencyConfig'; | ||
import createModuleSubsetFile from './createFile'; | ||
|
||
createModuleSubsetFile(transformFormatterConfig()); | ||
createModuleSubsetFile(transformRegexConfig()); | ||
createModuleSubsetFile(transformCurrencyConfig()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { getIntlInstanceWithOptions, getLocale } from '..'; | ||
import { setState } from '../../../core'; | ||
import { CurrencyCodeType } from '../../../currency/types'; | ||
|
||
describe('getIntlInstanceWithOptions', () => { | ||
it('should return a valid Intl.NumberFormat object', () => { | ||
|
@@ -21,7 +22,7 @@ describe('getIntlInstanceWithOptions', () => { | |
}); | ||
|
||
it('should handle currency options', () => { | ||
const currency = 'EUR'; | ||
const currency = 'EUR' as CurrencyCodeType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redundant type cast. |
||
const intlProps = getIntlInstanceWithOptions({ currency }); | ||
const resolvedOptions = intlProps.resolvedOptions(); | ||
expect(resolvedOptions.style).toBe('currency'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this required in declaration types ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it fixes below error that occurs while creating build, during declaration file creation (
src/modules/currency/index.ts → lib/esm/currency/index.d.ts
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still required ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes tried removing it, and above error pops again while creating build.