From 3343d137190c2581428337a709b6bb310b45804e Mon Sep 17 00:00:00 2001 From: Semperverus Date: Wed, 18 Sep 2024 15:30:50 -0700 Subject: [PATCH 1/8] Update TransformEvaluator.ts to include decomposeDiacriticalMarks Adds a very rudimentary decomposeDiacriticalMarks function to the Transform Evaluators. This code requires testing within the plugin itself, but the function to perform the decomposition itself has been tested independently. --- src/services/TransformEvaluator.ts | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/services/TransformEvaluator.ts b/src/services/TransformEvaluator.ts index 62ab650..dc60dff 100644 --- a/src/services/TransformEvaluator.ts +++ b/src/services/TransformEvaluator.ts @@ -276,6 +276,9 @@ export class TransformEvaluator { case 'dateFormat': result = await this.dateFormat(attributes); break; + case 'decomposeDiacriticalMarks': + result = await this.decomposeDiacriticalMarks(attributes); + break; case 'e164phone': result = await this.e164phone(attributes); break; @@ -901,6 +904,32 @@ export class TransformEvaluator { return result; } + async decomposeDiacriticalMarks(attributes: any) { + console.log("Entering method decomposeDiacriticalMarks"); + let result = undefined; + + let input = this.input; + + if (input === undefined) { + if (attributes.input !== undefined) { + input = attributes.input; + + if (typeof input === 'object') { + input = await this.evaluateChildTransform(input); + } + + if (input === undefined) { + return; + } + } + } + + result = input.normalize('NFD').replace(/[\u0300-\u036f]/g, ""); + + console.log("Exiting decomposeDiacriticalMarks. result=" + result); + return result; + } + async e164phone(attributes: any) { console.log("Entering method e164phone"); let result = undefined; @@ -1718,4 +1747,4 @@ export class TransformEvaluator { console.log("Exiting uuid. result=" + result); return result; } -} \ No newline at end of file +} From bd0eb713e614a196daade5d32523bbba4b211a19 Mon Sep 17 00:00:00 2001 From: Semperverus Date: Wed, 18 Sep 2024 16:33:55 -0700 Subject: [PATCH 2/8] Update TransformEvaluator.ts to correct decomposeDiacriticalMarks According to the IdentityNow developer documentation, they are using 'NFKD' mode, which is the "Compatibility Decomposition" mode. NFD will work, but may have edge cases. --- src/services/TransformEvaluator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/TransformEvaluator.ts b/src/services/TransformEvaluator.ts index dc60dff..54905e0 100644 --- a/src/services/TransformEvaluator.ts +++ b/src/services/TransformEvaluator.ts @@ -924,7 +924,7 @@ export class TransformEvaluator { } } - result = input.normalize('NFD').replace(/[\u0300-\u036f]/g, ""); + result = input.normalize('NFKD').replace(/[\u0300-\u036f]/g, ""); console.log("Exiting decomposeDiacriticalMarks. result=" + result); return result; From 3758166222b1b7965b41a1f82b8ffb26b21f4d20 Mon Sep 17 00:00:00 2001 From: Semperverus Date: Thu, 19 Sep 2024 09:49:52 -0700 Subject: [PATCH 3/8] Update stringUtils.ts to include decomposeDiacriticalMarks() Added decomposeDiacriticalMarks() method to stringUtils.ts per Yannick's request. This could be renamed to "removeDiacriticalMarks()" in the future as that is technically its function, but SailPoint's official naming convention dictates "decomposeDiacriticalMarks" so I provided this name for the sake of consistency between systems. --- src/utils/stringUtils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/utils/stringUtils.ts b/src/utils/stringUtils.ts index c323b60..0db8544 100644 --- a/src/utils/stringUtils.ts +++ b/src/utils/stringUtils.ts @@ -48,4 +48,12 @@ export function toCamelCase(input: string): string { return word; }).join(''); -} \ No newline at end of file +} + +export function decomposeDiacriticalMarks(input: string): string { + return input + // Decompose the string into separate unicode symbols for diacritical marks in compatibility mode, + .normalize('NFKD') + // Remove the unicode diacritical marks. + .replace(/[\u0300-\u036f]/g, ""); +} From 6deb85ce749950bd63e9adb38a6bc7a82a55428d Mon Sep 17 00:00:00 2001 From: Semperverus Date: Thu, 19 Sep 2024 10:11:36 -0700 Subject: [PATCH 4/8] Create decomposeDiacriticalMarks.test.ts Created the test suite for decomposeDiacriticalMarks() per Yannick's request. This test includes strings provided by SailPoint's documentation, Mozilla's example, and a long string of diacritical characters. --- .../unit/decomposeDiacriticalMarks.test.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/test/unit/decomposeDiacriticalMarks.test.ts diff --git a/src/test/unit/decomposeDiacriticalMarks.test.ts b/src/test/unit/decomposeDiacriticalMarks.test.ts new file mode 100644 index 0000000..9f04cf2 --- /dev/null +++ b/src/test/unit/decomposeDiacriticalMarks.test.ts @@ -0,0 +1,22 @@ +import * as assert from 'assert'; +import { it, describe } from 'mocha'; +import { toCamelCase } from '../../utils/stringUtils'; + +suite('decomposeDiacriticalMarks Test Suite', () => { + // vscode.window.showInformationMessage('Start all tests.'); + describe('decomposeDiacriticalMarks', () => { + const tests = [ + { args: 'Āric', expected: 'Aric' }, + { args: 'Dubçek', expected: 'Dubcek' }, + { args: 'Amélie', expected: 'Amelie' }, + { args: "àáâãäåçèéêëìíîïñòóôõöùúûüýÿ", expected: 'aaaaaaceeeeiiiinooooouuuuyy' }, + ]; + tests.forEach(({ args, expected }) => { + it(`should correctly format ${args}`, () => { + const result = decomposeDiacriticalMarks(args); + assert.strictEqual(result, expected); + }); + }); + }); + +}); From 1a18851bc140840db8dd5d9be212afae3ecb96f5 Mon Sep 17 00:00:00 2001 From: Semperverus Date: Thu, 19 Sep 2024 10:17:20 -0700 Subject: [PATCH 5/8] Update README.md for v1.3.2 Updated the Release Notes section of the readme to include mention of the decomposeDiacriticalMarks function that was added by Semperverus --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5303678..e7779e7 100644 --- a/README.md +++ b/README.md @@ -303,6 +303,10 @@ The patterns defined above use the following tokens: ## Release Notes +## 1.3.3 + +- Added support for `decomposeDiacriticalMarks` transform evaluation (cf. [#90](https://github.com/yannick-beot-sp/vscode-sailpoint-identitynow/issues/90) + ## 1.3.2 - Updated schema for lifefycle state (`identityState`) From 796b6893e718ad7dd533176751bff3c0994218a9 Mon Sep 17 00:00:00 2001 From: Semperverus Date: Thu, 19 Sep 2024 10:21:40 -0700 Subject: [PATCH 6/8] Update CHANGELOG.md to v1.3.3 Added notes about changes regarding decomposeDiacriticalMarks --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71641f4..04a5994 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ This changelog is following the recommended format by [keepachangelog](https://k ## [Unreleased] +## [1.3.3] - 2024-09-19 + +### Added + +- Added transform evaluation support for `decomposeDiacriticalMarks` (cf. [#90](https://github.com/yannick-beot-sp/vscode-sailpoint-identitynow/issues/90) + ## [1.3.2] - 2024-07-03 ### Added @@ -389,4 +395,4 @@ This changelog is following the recommended format by [keepachangelog](https://k - Open Sources and Transforms - Save Sources and Transforms - Create Transform -- Remove Transform \ No newline at end of file +- Remove Transform From 223922008242c0cc63ca6af3309a28f9a040cd85 Mon Sep 17 00:00:00 2001 From: Semperverus Date: Thu, 19 Sep 2024 10:24:27 -0700 Subject: [PATCH 7/8] Update CHANGELOG.md Added self as contributor --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04a5994..727c6cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ This changelog is following the recommended format by [keepachangelog](https://k ### Added -- Added transform evaluation support for `decomposeDiacriticalMarks` (cf. [#90](https://github.com/yannick-beot-sp/vscode-sailpoint-identitynow/issues/90) +- Added transform evaluation support for `decomposeDiacriticalMarks` (cf. [#90](https://github.com/yannick-beot-sp/vscode-sailpoint-identitynow/issues/90)) by [@Semperverus](https://github.com/Semperverus) ## [1.3.2] - 2024-07-03 From 14b70afe6fcea69ed8e715414a977e1c6aef462e Mon Sep 17 00:00:00 2001 From: Semperverus Date: Thu, 19 Sep 2024 10:26:29 -0700 Subject: [PATCH 8/8] Update README.md Included self as contributor --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7779e7..bc1424e 100644 --- a/README.md +++ b/README.md @@ -305,7 +305,7 @@ The patterns defined above use the following tokens: ## 1.3.3 -- Added support for `decomposeDiacriticalMarks` transform evaluation (cf. [#90](https://github.com/yannick-beot-sp/vscode-sailpoint-identitynow/issues/90) +- Added support for `decomposeDiacriticalMarks` transform evaluation (cf. [#90](https://github.com/yannick-beot-sp/vscode-sailpoint-identitynow/issues/90)) by [@Semperverus](https://github.com/Semperverus) ## 1.3.2