@diia-inhouse/utils 6.0.98 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/publicService.d.ts +2 -1
- package/dist/publicService.js +11 -0
- package/package.json +3 -3
package/dist/publicService.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InputPhoneCodeOrgParams } from "./interfaces/publicService.js";
|
|
2
|
-
import { UserTokenData } from "@diia-inhouse/types";
|
|
2
|
+
import { Logger, UserTokenData } from "@diia-inhouse/types";
|
|
3
3
|
import { ContactsResponse, DSBodyItem, InputPhoneCodeItem, InputPhoneCodeOrg, InputTextMlc, TextLabelMlc } from "@diia-inhouse/design-system";
|
|
4
4
|
|
|
5
5
|
//#region src/publicService.d.ts
|
|
@@ -54,6 +54,7 @@ declare const PublicServiceUtils: {
|
|
|
54
54
|
* extractPhoneNumber('380123456789', 'invalid') // throws Error(`Invalid country code`)
|
|
55
55
|
*/
|
|
56
56
|
extractPhoneNumber(phoneNumber: string, phoneCodeValue: string): string | never;
|
|
57
|
+
extractPhoneNumberSafe(phoneNumber: string, phoneCodeValue: string, logger: Logger): string | undefined;
|
|
57
58
|
};
|
|
58
59
|
//#endregion
|
|
59
60
|
export { PublicServiceUtils };
|
package/dist/publicService.js
CHANGED
|
@@ -132,6 +132,17 @@ const PublicServiceUtils = {
|
|
|
132
132
|
if (!countryCode) throw new Error("Invalid country code");
|
|
133
133
|
if (!cleanPhoneNumber.startsWith(countryCode.value)) throw new Error(`Phone number must start with country code ${countryCode.value}`);
|
|
134
134
|
return cleanPhoneNumber.slice(countryCode.value.length);
|
|
135
|
+
},
|
|
136
|
+
extractPhoneNumberSafe(phoneNumber, phoneCodeValue, logger) {
|
|
137
|
+
try {
|
|
138
|
+
return this.extractPhoneNumber(phoneNumber, phoneCodeValue);
|
|
139
|
+
} catch (err) {
|
|
140
|
+
logger.warn("Failed to extract phone number by country code", {
|
|
141
|
+
err,
|
|
142
|
+
phoneCodeValue
|
|
143
|
+
});
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
135
146
|
}
|
|
136
147
|
};
|
|
137
148
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diia-inhouse/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Generic utils",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@diia-inhouse/configs": "7.2.1",
|
|
61
61
|
"@diia-inhouse/errors": "2.2.25",
|
|
62
62
|
"@diia-inhouse/oxc-config": "2.1.4",
|
|
63
|
-
"@diia-inhouse/test": "8.3.
|
|
64
|
-
"@diia-inhouse/types": "14.2.
|
|
63
|
+
"@diia-inhouse/test": "8.3.14",
|
|
64
|
+
"@diia-inhouse/types": "14.2.8",
|
|
65
65
|
"@diia-inhouse/validators": "2.2.72",
|
|
66
66
|
"@slack/types": "2.21.1",
|
|
67
67
|
"@types/fast-levenshtein": "0.0.4",
|