@routr/common 2.0.8-alpha.21 → 2.0.8-alpha.22
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.
|
@@ -33,4 +33,5 @@ export declare const isValidAOROrThrow: (aor: string) => void;
|
|
|
33
33
|
export declare const hasAORLinkOrThrow: (aorLink: string) => void;
|
|
34
34
|
export declare const isValidAORLinkOrThrow: (aorLink: string) => void;
|
|
35
35
|
export declare const isValidContactAddressOrThrow: (contactAddress: string) => void;
|
|
36
|
+
export declare const isValidE164OrThrow: (e164Number: string, countryISOCode: string, validateMobilePrefix: boolean) => void;
|
|
36
37
|
export declare const hasValidOutboundUrisOrThrow: (outboundUris: TrunkURI[]) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasValidOutboundUrisOrThrow = exports.isValidContactAddressOrThrow = exports.isValidAORLinkOrThrow = exports.hasAORLinkOrThrow = exports.isValidAOROrThrow = exports.hasAOROrThrow = exports.isValidInboundUriOrThrow = exports.hasInboundUriOrThrow = exports.hasCountryISOCodeOrThrow = exports.hasCountryOrThrow = exports.hasCityOrThrow = exports.isValidSessionAffinityHeaderOrThrow = exports.hasTelUrlOrThrow = exports.isValidDomainUriOrThrow = exports.hasDomainUriOrThrow = exports.hasPasswordOrThrow = exports.isValidUsernameOrThrow = exports.hasUsernameOrThrow = exports.isValidNameOrThrow = exports.hasNameOrThrow = exports.hasRefenceOrThrow = exports.hasValidACLRulesOrThrow = exports.hasACLRulesOrThrow = exports.isValidBalancingAlgorithmOrThrow = exports.hasValidHeadersOrThrow = void 0;
|
|
3
|
+
exports.hasValidOutboundUrisOrThrow = exports.isValidE164OrThrow = exports.isValidContactAddressOrThrow = exports.isValidAORLinkOrThrow = exports.hasAORLinkOrThrow = exports.isValidAOROrThrow = exports.hasAOROrThrow = exports.isValidInboundUriOrThrow = exports.hasInboundUriOrThrow = exports.hasCountryISOCodeOrThrow = exports.hasCountryOrThrow = exports.hasCityOrThrow = exports.isValidSessionAffinityHeaderOrThrow = exports.hasTelUrlOrThrow = exports.isValidDomainUriOrThrow = exports.hasDomainUriOrThrow = exports.hasPasswordOrThrow = exports.isValidUsernameOrThrow = exports.hasUsernameOrThrow = exports.isValidNameOrThrow = exports.hasNameOrThrow = exports.hasRefenceOrThrow = exports.hasValidACLRulesOrThrow = exports.hasACLRulesOrThrow = exports.isValidBalancingAlgorithmOrThrow = exports.hasValidHeadersOrThrow = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster
|
|
@@ -85,6 +85,13 @@ const isValidAORLinkOrThrow = (aorLink) => validOrThrow(validations_1.isValidAOR
|
|
|
85
85
|
exports.isValidAORLinkOrThrow = isValidAORLinkOrThrow;
|
|
86
86
|
const isValidContactAddressOrThrow = (contactAddress) => validOrThrow(validations_1.isValidContactAddress, contactAddress);
|
|
87
87
|
exports.isValidContactAddressOrThrow = isValidContactAddressOrThrow;
|
|
88
|
+
const isValidE164OrThrow = (e164Number, countryISOCode, validateMobilePrefix) => {
|
|
89
|
+
const R = (0, validations_1.isValidE164)(e164Number, countryISOCode, validateMobilePrefix);
|
|
90
|
+
if (R instanceof errors_1.BadRequestError) {
|
|
91
|
+
throw R;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.isValidE164OrThrow = isValidE164OrThrow;
|
|
88
95
|
const hasValidOutboundUrisOrThrow = (outboundUris) => outboundUris === null || outboundUris === void 0 ? void 0 : outboundUris.forEach((uri) => {
|
|
89
96
|
if ((0, validations_1.hasHost)(uri.host) instanceof errors_1.BadRequestError) {
|
|
90
97
|
throw (0, validations_1.hasHost)(uri.host);
|
|
@@ -40,3 +40,4 @@ export declare const isValidHost: (host: string) => true | BadRequestError;
|
|
|
40
40
|
export declare const isValidContactAddress: (contactAddress: string) => BadRequestError;
|
|
41
41
|
export declare const isValidPriority: (priority: string) => BadRequestError;
|
|
42
42
|
export declare const isValidWeight: (weight: string) => BadRequestError;
|
|
43
|
+
export declare const isValidE164: (e164Number: string, countryISOCode: string, validateMobilePrefix?: boolean) => BadRequestError;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.isValidWeight = exports.isValidPriority = exports.isValidContactAddress = exports.isValidHost = exports.hasHost = exports.isValidPort = exports.isValidBalancingAlgorithm = exports.isValidInboundUri = exports.hasInboundUri = exports.hasValidACLRules = exports.isValidACLRule = exports.hasACLRules = exports.hasCountryISOCode = exports.hasCountry = exports.hasCity = exports.isValidAORLink = exports.hasAORLink = exports.isValidAOR = exports.hasAOR = exports.hasValidHeaders = exports.isValidHeader = exports.isValidSessionAffinityHeader = exports.hasTelUrl = exports.isValidDomainUri = exports.hasDomainUri = exports.hasPassword = exports.isValidUsername = exports.hasUsername = exports.isValidName = exports.hasName = exports.hasReference = void 0;
|
|
26
|
+
exports.isValidE164 = exports.isValidWeight = exports.isValidPriority = exports.isValidContactAddress = exports.isValidHost = exports.hasHost = exports.isValidPort = exports.isValidBalancingAlgorithm = exports.isValidInboundUri = exports.hasInboundUri = exports.hasValidACLRules = exports.isValidACLRule = exports.hasACLRules = exports.hasCountryISOCode = exports.hasCountry = exports.hasCity = exports.isValidAORLink = exports.hasAORLink = exports.isValidAOR = exports.hasAOR = exports.hasValidHeaders = exports.isValidHeader = exports.isValidSessionAffinityHeader = exports.hasTelUrl = exports.isValidDomainUri = exports.hasDomainUri = exports.hasPassword = exports.isValidUsername = exports.hasUsername = exports.isValidName = exports.hasName = exports.hasReference = void 0;
|
|
27
27
|
/*
|
|
28
28
|
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
29
29
|
* http://github.com/fonoster
|
|
@@ -45,6 +45,7 @@ exports.isValidWeight = exports.isValidPriority = exports.isValidContactAddress
|
|
|
45
45
|
const Validator = __importStar(require("validator"));
|
|
46
46
|
const errors_1 = require("../errors");
|
|
47
47
|
const types_1 = require("../types");
|
|
48
|
+
const phone_1 = require("phone");
|
|
48
49
|
const hasReference = (ref) => ref ? true : new errors_1.BadRequestError("the reference to the resource is required");
|
|
49
50
|
exports.hasReference = hasReference;
|
|
50
51
|
const hasName = (name) => name
|
|
@@ -259,3 +260,13 @@ const isValidWeight = (weight) => {
|
|
|
259
260
|
}
|
|
260
261
|
};
|
|
261
262
|
exports.isValidWeight = isValidWeight;
|
|
263
|
+
const isValidE164 = (e164Number, countryISOCode, validateMobilePrefix = false) => {
|
|
264
|
+
const result = (0, phone_1.phone)(e164Number, {
|
|
265
|
+
country: countryISOCode,
|
|
266
|
+
validateMobilePrefix
|
|
267
|
+
});
|
|
268
|
+
if (!result.isValid) {
|
|
269
|
+
return new errors_1.BadRequestError("the telUrl must be a valid e164 number");
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
exports.isValidE164 = isValidE164;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/common",
|
|
3
|
-
"version": "2.0.8-alpha.
|
|
3
|
+
"version": "2.0.8-alpha.22",
|
|
4
4
|
"description": "Common package",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/js-yaml": "^4.0.5"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "7c1e14c20e077f817605be62cf61a68904583bb8"
|
|
56
56
|
}
|