@routr/common 2.0.8-alpha.17 → 2.0.8-alpha.19
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/auth.d.ts +2 -2
- package/dist/connect/api/client.js +8 -10
- package/dist/connect/api/types.d.ts +4 -4
- package/dist/connect/config.d.ts +10 -6
- package/dist/connect/grpc_client.d.ts +2 -2
- package/dist/connect/index.d.ts +1 -1
- package/dist/connect/index.js +1 -1
- package/dist/connect/mappers/acl.d.ts +3 -0
- package/dist/connect/mappers/acl.js +19 -0
- package/dist/connect/mappers/agent.d.ts +3 -0
- package/dist/connect/mappers/agent.js +42 -0
- package/dist/connect/mappers/assertions.d.ts +3 -0
- package/dist/connect/mappers/assertions.js +43 -0
- package/dist/connect/mappers/credentials.d.ts +3 -0
- package/dist/connect/mappers/credentials.js +18 -0
- package/dist/connect/mappers/domain.d.ts +3 -0
- package/dist/connect/mappers/domain.js +19 -0
- package/dist/connect/mappers/index.d.ts +7 -0
- package/dist/connect/mappers/index.js +41 -0
- package/dist/connect/mappers/number.d.ts +3 -0
- package/dist/connect/mappers/number.js +26 -0
- package/dist/connect/mappers/peer.d.ts +3 -0
- package/dist/connect/mappers/peer.js +25 -0
- package/dist/connect/mappers/trunk.d.ts +3 -0
- package/dist/connect/mappers/trunk.js +34 -0
- package/dist/connect/protos/acl.proto +11 -16
- package/dist/connect/protos/agents.proto +19 -23
- package/dist/connect/protos/credentials.proto +8 -10
- package/dist/connect/protos/domains.proto +16 -18
- package/dist/connect/protos/numbers.proto +15 -25
- package/dist/connect/protos/peers.proto +46 -39
- package/dist/connect/protos/trunks.proto +16 -24
- package/dist/connect/schemas/acl.d.ts +2 -0
- package/dist/connect/schemas/acl.js +4 -2
- package/dist/connect/schemas/agent.d.ts +2 -0
- package/dist/connect/schemas/agent.js +6 -4
- package/dist/connect/schemas/crendentials.d.ts +4 -0
- package/dist/connect/schemas/crendentials.js +7 -3
- package/dist/connect/schemas/domain.d.ts +2 -0
- package/dist/connect/schemas/domain.js +4 -2
- package/dist/connect/schemas/number.d.ts +4 -0
- package/dist/connect/schemas/number.js +7 -3
- package/dist/connect/schemas/peer.d.ts +16 -0
- package/dist/connect/schemas/peer.js +19 -3
- package/dist/connect/schemas/trunk.d.ts +3 -0
- package/dist/connect/schemas/trunk.js +20 -4
- package/dist/connect/types.d.ts +20 -6
- package/dist/helper.js +2 -2
- package/dist/protos/location.proto +11 -1
- package/dist/types.d.ts +18 -22
- package/dist/types.js +16 -25
- package/package.json +2 -2
- package/dist/connect/converters.d.ts +0 -10
- package/dist/connect/converters.js +0 -178
|
@@ -25,7 +25,7 @@ exports.default = {
|
|
|
25
25
|
type: "object",
|
|
26
26
|
properties: {
|
|
27
27
|
apiVersion: {
|
|
28
|
-
enum: ["v2draft1", "v2
|
|
28
|
+
enum: ["v2draft1", "v2"]
|
|
29
29
|
},
|
|
30
30
|
kind: {
|
|
31
31
|
enum: ["Trunk", "trunk"]
|
|
@@ -40,7 +40,9 @@ exports.default = {
|
|
|
40
40
|
properties: {
|
|
41
41
|
name: {
|
|
42
42
|
description: "Resource's friendly name",
|
|
43
|
-
type: "string"
|
|
43
|
+
type: "string",
|
|
44
|
+
minLength: 3,
|
|
45
|
+
maxLength: 64
|
|
44
46
|
}
|
|
45
47
|
},
|
|
46
48
|
required: ["name"]
|
|
@@ -55,7 +57,8 @@ exports.default = {
|
|
|
55
57
|
properties: {
|
|
56
58
|
uri: {
|
|
57
59
|
description: "URI of the inbound endpoint",
|
|
58
|
-
type: "string"
|
|
60
|
+
type: "string",
|
|
61
|
+
maxLength: 255
|
|
59
62
|
},
|
|
60
63
|
accessControlListRef: {
|
|
61
64
|
description: "Reference to the ACL to be used for inbound traffic",
|
|
@@ -100,7 +103,20 @@ exports.default = {
|
|
|
100
103
|
},
|
|
101
104
|
transport: {
|
|
102
105
|
description: "Transport of the URI",
|
|
103
|
-
enum: [
|
|
106
|
+
enum: [
|
|
107
|
+
"TCP",
|
|
108
|
+
"SCTP",
|
|
109
|
+
"UDP",
|
|
110
|
+
"TLS",
|
|
111
|
+
"WS",
|
|
112
|
+
"WSS",
|
|
113
|
+
"tcp",
|
|
114
|
+
"sctp",
|
|
115
|
+
"udp",
|
|
116
|
+
"tls",
|
|
117
|
+
"ws",
|
|
118
|
+
"wss"
|
|
119
|
+
]
|
|
104
120
|
},
|
|
105
121
|
user: {
|
|
106
122
|
description: "Username of the URI",
|
package/dist/connect/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonObject } from "pb-util/build";
|
|
2
|
+
import { LoadBalancingAlgorithm, Privacy, Transport } from "../types";
|
|
2
3
|
export declare enum Kind {
|
|
3
4
|
AGENT = "agent",
|
|
4
5
|
PEER = "peer",
|
|
@@ -9,6 +10,7 @@ export declare enum Kind {
|
|
|
9
10
|
CREDENTIALS = "credentials",
|
|
10
11
|
ACL = "accesscontrollist"
|
|
11
12
|
}
|
|
13
|
+
export type KindWithoutUnknown = Exclude<Kind, Kind.UNKNOWN>;
|
|
12
14
|
export declare enum APIVersion {
|
|
13
15
|
V2DRAFT1 = "v2draft1",
|
|
14
16
|
V2 = "v2"
|
|
@@ -19,7 +21,7 @@ export interface BaseConnectModel {
|
|
|
19
21
|
name: string;
|
|
20
22
|
createdAt?: Date;
|
|
21
23
|
updatedAt?: Date;
|
|
22
|
-
extended?:
|
|
24
|
+
extended?: JsonObject;
|
|
23
25
|
}
|
|
24
26
|
export interface AccessControlList extends BaseConnectModel {
|
|
25
27
|
allow: string[];
|
|
@@ -27,18 +29,22 @@ export interface AccessControlList extends BaseConnectModel {
|
|
|
27
29
|
}
|
|
28
30
|
export interface Domain extends BaseConnectModel {
|
|
29
31
|
domainUri: string;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
accessControlListRef?: string;
|
|
33
|
+
accessControlList?: AccessControlList;
|
|
34
|
+
egressPolicies?: EgressPolicy[];
|
|
32
35
|
}
|
|
33
36
|
export interface EgressPolicy {
|
|
34
|
-
|
|
37
|
+
numberRef: string;
|
|
38
|
+
number?: INumber;
|
|
35
39
|
rule: string;
|
|
36
40
|
}
|
|
37
41
|
export interface Agent extends BaseConnectModel {
|
|
38
42
|
username: string;
|
|
39
43
|
privacy: Privacy;
|
|
40
44
|
enabled: boolean;
|
|
45
|
+
domainRef?: string;
|
|
41
46
|
domain?: Domain;
|
|
47
|
+
credentialsRef?: string;
|
|
42
48
|
credentials?: Credentials;
|
|
43
49
|
}
|
|
44
50
|
export interface Credentials extends BaseConnectModel {
|
|
@@ -50,19 +56,23 @@ export interface INumber extends BaseConnectModel {
|
|
|
50
56
|
aorLink: string;
|
|
51
57
|
city: string;
|
|
52
58
|
country: string;
|
|
53
|
-
|
|
59
|
+
countryISOCode: string;
|
|
54
60
|
sessionAffinityHeader: string;
|
|
55
61
|
extraHeaders: {
|
|
56
62
|
name: string;
|
|
57
63
|
value: string;
|
|
58
64
|
}[];
|
|
65
|
+
trunkRef?: string;
|
|
59
66
|
trunk?: Trunk;
|
|
60
67
|
}
|
|
61
68
|
export interface Trunk extends BaseConnectModel {
|
|
62
69
|
sendRegister: boolean;
|
|
63
70
|
inboundUri: string;
|
|
71
|
+
accessControlListRef?: string;
|
|
64
72
|
accessControlList?: AccessControlList;
|
|
73
|
+
inboundCredentialsRef?: string;
|
|
65
74
|
inboundCredentials?: Credentials;
|
|
75
|
+
outboundCredentialsRef?: string;
|
|
66
76
|
outboundCredentials?: Credentials;
|
|
67
77
|
uris: TrunkURI[];
|
|
68
78
|
}
|
|
@@ -80,8 +90,12 @@ export interface Peer extends BaseConnectModel {
|
|
|
80
90
|
aor: string;
|
|
81
91
|
contactAddr: string;
|
|
82
92
|
enabled: boolean;
|
|
93
|
+
accessControlListRef?: string;
|
|
83
94
|
accessControlList?: AccessControlList;
|
|
95
|
+
credentialsRef?: string;
|
|
84
96
|
credentials?: Credentials;
|
|
97
|
+
balancingAlgorithm?: LoadBalancingAlgorithm;
|
|
98
|
+
withSessionAffinity?: boolean;
|
|
85
99
|
}
|
|
86
100
|
export type ConnectModel = Agent | Peer | INumber | Trunk | Domain | Credentials | AccessControlList;
|
|
87
101
|
export type RoutableResourceUnion = Agent | Peer | INumber;
|
package/dist/helper.js
CHANGED
|
@@ -79,8 +79,8 @@ exports.deepCopy = deepCopy;
|
|
|
79
79
|
*/
|
|
80
80
|
const getListeningPoint = (listeningPoints, transport) => {
|
|
81
81
|
const listeningPoint = transport
|
|
82
|
-
? listeningPoints.find((lp) => lp.transport.
|
|
83
|
-
: listeningPoints.find((lp) => lp.transport.
|
|
82
|
+
? listeningPoints.find((lp) => lp.transport.toUpperCase() === transport.toUpperCase())
|
|
83
|
+
: listeningPoints.find((lp) => lp.transport.toUpperCase() === types_1.Transport.UDP);
|
|
84
84
|
if (!listeningPoint) {
|
|
85
85
|
throw new Error(`no listening point found for transport ${transport}`);
|
|
86
86
|
}
|
|
@@ -61,10 +61,20 @@ message AddRouteRequest {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
message FindRoutesRequest {
|
|
64
|
+
message Backend {
|
|
65
|
+
enum Algoritm {
|
|
66
|
+
ROUND_ROBIN = 0;
|
|
67
|
+
LEAST_SESSIONS = 1;
|
|
68
|
+
}
|
|
69
|
+
string ref = 1;
|
|
70
|
+
bool with_session_affinity = 2;
|
|
71
|
+
Algoritm algorithm = 3;
|
|
72
|
+
}
|
|
64
73
|
string call_id = 1;
|
|
65
74
|
string aor = 2;
|
|
66
75
|
string session_affinity_ref = 3;
|
|
67
|
-
|
|
76
|
+
Backend backend = 4;
|
|
77
|
+
map<string, string> labels = 5;
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
message FindRoutesResponse {
|
package/dist/types.d.ts
CHANGED
|
@@ -15,12 +15,16 @@ export declare enum Method {
|
|
|
15
15
|
OPTIONS = "OPTIONS"
|
|
16
16
|
}
|
|
17
17
|
export declare enum Transport {
|
|
18
|
-
TCP = "
|
|
19
|
-
UDP = "
|
|
20
|
-
TLS = "
|
|
21
|
-
SCTP = "
|
|
22
|
-
WS = "
|
|
23
|
-
WSS = "
|
|
18
|
+
TCP = "TCP",
|
|
19
|
+
UDP = "UDP",
|
|
20
|
+
TLS = "TLS",
|
|
21
|
+
SCTP = "SCTP",
|
|
22
|
+
WS = "WS",
|
|
23
|
+
WSS = "WSS"
|
|
24
|
+
}
|
|
25
|
+
export declare enum LoadBalancingAlgorithm {
|
|
26
|
+
ROUND_ROBIN = "ROUND-ROBIN",
|
|
27
|
+
LEAST_SESSIONS = "LEAST-SESSIONS"
|
|
24
28
|
}
|
|
25
29
|
export declare enum ExtraHeader {
|
|
26
30
|
REQUEST_URI = "X-Request-Uri",
|
|
@@ -31,20 +35,12 @@ export declare enum ExtraHeader {
|
|
|
31
35
|
DOD_PRIVACY = "X-DOD-Privacy"
|
|
32
36
|
}
|
|
33
37
|
export declare enum Privacy {
|
|
34
|
-
NONE = "
|
|
35
|
-
PRIVATE = "
|
|
36
|
-
}
|
|
37
|
-
export declare enum AuthorizationAlgorithm {
|
|
38
|
-
MD5 = "MD5"
|
|
39
|
-
}
|
|
40
|
-
export declare enum AuthorizationScheme {
|
|
41
|
-
DIGEST = "Digest"
|
|
42
|
-
}
|
|
43
|
-
export declare enum Qop {
|
|
44
|
-
AUTH = "auth",
|
|
45
|
-
AUTH_INT = "auth-int",
|
|
46
|
-
NONE = ""
|
|
38
|
+
NONE = "NONE",
|
|
39
|
+
PRIVATE = "ID"
|
|
47
40
|
}
|
|
41
|
+
export type AuthorizationAlgorithm = "MD5";
|
|
42
|
+
export type AuthorizationScheme = "Digest";
|
|
43
|
+
export type Qop = "auth" | "auth-int" | "";
|
|
48
44
|
export interface NetInterface {
|
|
49
45
|
host: string;
|
|
50
46
|
port: number;
|
|
@@ -111,8 +107,8 @@ export interface AuthChallengeResponse {
|
|
|
111
107
|
qop: Qop;
|
|
112
108
|
}
|
|
113
109
|
export declare enum HeaderModifierAction {
|
|
114
|
-
ADD =
|
|
115
|
-
REMOVE =
|
|
110
|
+
ADD = 0,
|
|
111
|
+
REMOVE = 1
|
|
116
112
|
}
|
|
117
113
|
export interface HeaderModifier {
|
|
118
114
|
name: string;
|
|
@@ -245,7 +241,7 @@ export interface SipURI {
|
|
|
245
241
|
user?: string;
|
|
246
242
|
host: string;
|
|
247
243
|
port?: number;
|
|
248
|
-
transportParam:
|
|
244
|
+
transportParam: Transport;
|
|
249
245
|
mAddrParam?: string;
|
|
250
246
|
userParam?: string;
|
|
251
247
|
ttlParam?: number;
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageType = exports.ResponseType = exports.HeaderModifierAction = exports.
|
|
3
|
+
exports.MessageType = exports.ResponseType = exports.HeaderModifierAction = exports.Privacy = exports.ExtraHeader = exports.LoadBalancingAlgorithm = exports.Transport = exports.Method = void 0;
|
|
4
4
|
var Method;
|
|
5
5
|
(function (Method) {
|
|
6
6
|
Method["UNKNOWN"] = "UNKNOWN";
|
|
@@ -17,13 +17,18 @@ var Method;
|
|
|
17
17
|
})(Method = exports.Method || (exports.Method = {}));
|
|
18
18
|
var Transport;
|
|
19
19
|
(function (Transport) {
|
|
20
|
-
Transport["TCP"] = "
|
|
21
|
-
Transport["UDP"] = "
|
|
22
|
-
Transport["TLS"] = "
|
|
23
|
-
Transport["SCTP"] = "
|
|
24
|
-
Transport["WS"] = "
|
|
25
|
-
Transport["WSS"] = "
|
|
20
|
+
Transport["TCP"] = "TCP";
|
|
21
|
+
Transport["UDP"] = "UDP";
|
|
22
|
+
Transport["TLS"] = "TLS";
|
|
23
|
+
Transport["SCTP"] = "SCTP";
|
|
24
|
+
Transport["WS"] = "WS";
|
|
25
|
+
Transport["WSS"] = "WSS";
|
|
26
26
|
})(Transport = exports.Transport || (exports.Transport = {}));
|
|
27
|
+
var LoadBalancingAlgorithm;
|
|
28
|
+
(function (LoadBalancingAlgorithm) {
|
|
29
|
+
LoadBalancingAlgorithm["ROUND_ROBIN"] = "ROUND-ROBIN";
|
|
30
|
+
LoadBalancingAlgorithm["LEAST_SESSIONS"] = "LEAST-SESSIONS";
|
|
31
|
+
})(LoadBalancingAlgorithm = exports.LoadBalancingAlgorithm || (exports.LoadBalancingAlgorithm = {}));
|
|
27
32
|
var ExtraHeader;
|
|
28
33
|
(function (ExtraHeader) {
|
|
29
34
|
ExtraHeader["REQUEST_URI"] = "X-Request-Uri";
|
|
@@ -35,27 +40,13 @@ var ExtraHeader;
|
|
|
35
40
|
})(ExtraHeader = exports.ExtraHeader || (exports.ExtraHeader = {}));
|
|
36
41
|
var Privacy;
|
|
37
42
|
(function (Privacy) {
|
|
38
|
-
Privacy["NONE"] = "
|
|
39
|
-
Privacy["PRIVATE"] = "
|
|
43
|
+
Privacy["NONE"] = "NONE";
|
|
44
|
+
Privacy["PRIVATE"] = "ID";
|
|
40
45
|
})(Privacy = exports.Privacy || (exports.Privacy = {}));
|
|
41
|
-
var AuthorizationAlgorithm;
|
|
42
|
-
(function (AuthorizationAlgorithm) {
|
|
43
|
-
AuthorizationAlgorithm["MD5"] = "MD5";
|
|
44
|
-
})(AuthorizationAlgorithm = exports.AuthorizationAlgorithm || (exports.AuthorizationAlgorithm = {}));
|
|
45
|
-
var AuthorizationScheme;
|
|
46
|
-
(function (AuthorizationScheme) {
|
|
47
|
-
AuthorizationScheme["DIGEST"] = "Digest";
|
|
48
|
-
})(AuthorizationScheme = exports.AuthorizationScheme || (exports.AuthorizationScheme = {}));
|
|
49
|
-
var Qop;
|
|
50
|
-
(function (Qop) {
|
|
51
|
-
Qop["AUTH"] = "auth";
|
|
52
|
-
Qop["AUTH_INT"] = "auth-int";
|
|
53
|
-
Qop["NONE"] = "";
|
|
54
|
-
})(Qop = exports.Qop || (exports.Qop = {}));
|
|
55
46
|
var HeaderModifierAction;
|
|
56
47
|
(function (HeaderModifierAction) {
|
|
57
|
-
HeaderModifierAction["ADD"] = "
|
|
58
|
-
HeaderModifierAction["REMOVE"] = "
|
|
48
|
+
HeaderModifierAction[HeaderModifierAction["ADD"] = 0] = "ADD";
|
|
49
|
+
HeaderModifierAction[HeaderModifierAction["REMOVE"] = 1] = "REMOVE";
|
|
59
50
|
})(HeaderModifierAction = exports.HeaderModifierAction || (exports.HeaderModifierAction = {}));
|
|
60
51
|
var ResponseType;
|
|
61
52
|
(function (ResponseType) {
|
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.19",
|
|
4
4
|
"description": "Common package",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/js-yaml": "^4.0.5"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "ff62abb0ff7704a79f98a8e0b10c0036b949cc11"
|
|
55
55
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { UserConfig } from "./config";
|
|
2
|
-
import { AccessControlList, Agent, Credentials, Domain, INumber, Peer, Trunk } from "./types";
|
|
3
|
-
export declare const getConverter: (kind: string) => typeof convertAgentConfigToAgent | typeof convertDomainConfigToDomain | typeof convertPeerConfigToPeer | typeof convertNumberConfigToNumber | typeof convertTrunkConfigToTrunk | typeof convertCredentialsConfigToCredentials | typeof convertACLConfigToACL;
|
|
4
|
-
export declare function convertAgentConfigToAgent(config: UserConfig, list: UserConfig[]): Agent;
|
|
5
|
-
export declare function convertDomainConfigToDomain(config: UserConfig, list: UserConfig[]): Domain;
|
|
6
|
-
export declare function convertPeerConfigToPeer(config: UserConfig, list: UserConfig[]): Peer;
|
|
7
|
-
export declare function convertNumberConfigToNumber(config: UserConfig, list: UserConfig[]): INumber;
|
|
8
|
-
export declare function convertTrunkConfigToTrunk(config: UserConfig, list: UserConfig[]): Trunk;
|
|
9
|
-
export declare function convertCredentialsConfigToCredentials(config: UserConfig): Credentials;
|
|
10
|
-
export declare function convertACLConfigToACL(config: UserConfig): AccessControlList;
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertACLConfigToACL = exports.convertCredentialsConfigToCredentials = exports.convertTrunkConfigToTrunk = exports.convertNumberConfigToNumber = exports.convertPeerConfigToPeer = exports.convertDomainConfigToDomain = exports.convertAgentConfigToAgent = exports.getConverter = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
6
|
-
* http://github.com/fonoster
|
|
7
|
-
*
|
|
8
|
-
* This file is part of Routr.
|
|
9
|
-
*
|
|
10
|
-
* Licensed under the MIT License (the "License");
|
|
11
|
-
* you may not use this file except in compliance with
|
|
12
|
-
* the License. You may obtain a copy of the License at
|
|
13
|
-
*
|
|
14
|
-
* https://opensource.org/licenses/MIT
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
* See the License for the specific language governing permissions and
|
|
20
|
-
* limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
/* eslint-disable require-jsdoc */
|
|
23
|
-
const logger_1 = require("@fonoster/logger");
|
|
24
|
-
const types_1 = require("../types");
|
|
25
|
-
const types_2 = require("./types");
|
|
26
|
-
const logger = (0, logger_1.getLogger)({ service: "simpledata", filePath: __filename });
|
|
27
|
-
const findByRef = (ref, list) => {
|
|
28
|
-
const resource = list.find((r) => r.ref === ref);
|
|
29
|
-
if (ref != null && resource == null) {
|
|
30
|
-
logger.error(`the resource with ref ${ref} does not exist in the configuration file; exiting`);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
return resource ? (0, exports.getConverter)(resource.kind)(resource, list) : null;
|
|
34
|
-
};
|
|
35
|
-
const getConverter = (kind) => {
|
|
36
|
-
switch (kind) {
|
|
37
|
-
case types_2.Kind.AGENT:
|
|
38
|
-
return convertAgentConfigToAgent;
|
|
39
|
-
case types_2.Kind.DOMAIN:
|
|
40
|
-
return convertDomainConfigToDomain;
|
|
41
|
-
case types_2.Kind.PEER:
|
|
42
|
-
return convertPeerConfigToPeer;
|
|
43
|
-
case types_2.Kind.NUMBER:
|
|
44
|
-
return convertNumberConfigToNumber;
|
|
45
|
-
case types_2.Kind.TRUNK:
|
|
46
|
-
return convertTrunkConfigToTrunk;
|
|
47
|
-
case types_2.Kind.CREDENTIALS:
|
|
48
|
-
return convertCredentialsConfigToCredentials;
|
|
49
|
-
case types_2.Kind.ACL:
|
|
50
|
-
return convertACLConfigToACL;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
exports.getConverter = getConverter;
|
|
54
|
-
function convertAgentConfigToAgent(config, list) {
|
|
55
|
-
var _a, _b;
|
|
56
|
-
if (config.kind !== types_2.Kind.AGENT)
|
|
57
|
-
throw new Error("invalid resource type `Agent`");
|
|
58
|
-
return {
|
|
59
|
-
apiVersion: config.apiVersion,
|
|
60
|
-
ref: config.ref,
|
|
61
|
-
name: config.metadata.name,
|
|
62
|
-
username: config.spec.username,
|
|
63
|
-
privacy: (_b = (_a = config.spec.privacy) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : types_1.Privacy.NONE,
|
|
64
|
-
enabled: config.spec.enabled,
|
|
65
|
-
domain: findByRef(config.spec.domainRef, list),
|
|
66
|
-
credentials: findByRef(config.spec.credentialsRef, list)
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
exports.convertAgentConfigToAgent = convertAgentConfigToAgent;
|
|
70
|
-
function convertDomainConfigToDomain(config, list) {
|
|
71
|
-
var _a;
|
|
72
|
-
if (config.kind !== types_2.Kind.DOMAIN)
|
|
73
|
-
throw new Error("invalid resource type `Domain`");
|
|
74
|
-
const egressPolicies = (_a = config.spec.context.egressPolicies) === null || _a === void 0 ? void 0 : _a.map((policy) => {
|
|
75
|
-
return {
|
|
76
|
-
rule: policy.rule,
|
|
77
|
-
number: findByRef(policy.numberRef, list)
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
return {
|
|
81
|
-
apiVersion: config.apiVersion,
|
|
82
|
-
ref: config.ref,
|
|
83
|
-
name: config.metadata.name,
|
|
84
|
-
domainUri: config.spec.context.domainUri,
|
|
85
|
-
accessControlList: findByRef(config.spec.accessControlListRef, list),
|
|
86
|
-
egressPolicies
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
exports.convertDomainConfigToDomain = convertDomainConfigToDomain;
|
|
90
|
-
function convertPeerConfigToPeer(config, list) {
|
|
91
|
-
if (config.kind !== types_2.Kind.PEER)
|
|
92
|
-
throw new Error("invalid resource type `Peer`");
|
|
93
|
-
return {
|
|
94
|
-
apiVersion: config.apiVersion,
|
|
95
|
-
ref: config.ref,
|
|
96
|
-
name: config.metadata.name,
|
|
97
|
-
username: config.spec.username,
|
|
98
|
-
aor: config.spec.aor,
|
|
99
|
-
contactAddr: config.spec.contactAddr,
|
|
100
|
-
enabled: config.spec.enabled,
|
|
101
|
-
credentials: findByRef(config.spec.credentialsRef, list)
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
exports.convertPeerConfigToPeer = convertPeerConfigToPeer;
|
|
105
|
-
function convertNumberConfigToNumber(config, list) {
|
|
106
|
-
if (config.kind !== types_2.Kind.NUMBER)
|
|
107
|
-
throw new Error("invalid resource type `Number`");
|
|
108
|
-
const metadata = config.metadata;
|
|
109
|
-
const location = config.spec.location;
|
|
110
|
-
return {
|
|
111
|
-
apiVersion: config.apiVersion,
|
|
112
|
-
ref: config.ref,
|
|
113
|
-
name: metadata.name,
|
|
114
|
-
city: metadata.geoInfo.city,
|
|
115
|
-
country: metadata.geoInfo.country,
|
|
116
|
-
countryIsoCode: metadata.geoInfo.countryISOCode,
|
|
117
|
-
telUrl: location.telUrl,
|
|
118
|
-
aorLink: location.aorLink,
|
|
119
|
-
sessionAffinityHeader: location.sessionAffinityHeader,
|
|
120
|
-
extraHeaders: location.extraHeaders,
|
|
121
|
-
trunk: findByRef(config.spec.trunkRef, list)
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
exports.convertNumberConfigToNumber = convertNumberConfigToNumber;
|
|
125
|
-
function convertTrunkConfigToTrunk(config, list) {
|
|
126
|
-
var _a;
|
|
127
|
-
if (config.kind !== types_2.Kind.TRUNK)
|
|
128
|
-
throw new Error("invalid resource type `Trunk`");
|
|
129
|
-
const inbound = config.spec.inbound;
|
|
130
|
-
const outbound = config.spec.outbound;
|
|
131
|
-
return {
|
|
132
|
-
apiVersion: config.apiVersion,
|
|
133
|
-
ref: config.ref,
|
|
134
|
-
name: config.metadata.name,
|
|
135
|
-
sendRegister: outbound.sendRegister,
|
|
136
|
-
inboundUri: inbound.uri,
|
|
137
|
-
inboundCredentials: findByRef(inbound.credentialsRef, list),
|
|
138
|
-
outboundCredentials: findByRef(outbound.credentialsRef, list),
|
|
139
|
-
accessControlList: findByRef(inbound.accessControlListRef, list),
|
|
140
|
-
uris: (_a = config.spec.outbound.uris) === null || _a === void 0 ? void 0 : _a.map((entry) => {
|
|
141
|
-
return {
|
|
142
|
-
user: entry.uri.user,
|
|
143
|
-
host: entry.uri.host,
|
|
144
|
-
port: entry.uri.port,
|
|
145
|
-
transport: entry.uri.transport,
|
|
146
|
-
enabled: entry.enabled,
|
|
147
|
-
weight: entry.weight,
|
|
148
|
-
priority: entry.priority
|
|
149
|
-
};
|
|
150
|
-
})
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
exports.convertTrunkConfigToTrunk = convertTrunkConfigToTrunk;
|
|
154
|
-
function convertCredentialsConfigToCredentials(config) {
|
|
155
|
-
if (config.kind !== types_2.Kind.CREDENTIALS)
|
|
156
|
-
throw new Error("invalid resource type `Credentials`");
|
|
157
|
-
return {
|
|
158
|
-
apiVersion: config.apiVersion,
|
|
159
|
-
ref: config.ref,
|
|
160
|
-
name: config.metadata.name,
|
|
161
|
-
username: config.spec.credentials.username,
|
|
162
|
-
password: config.spec.credentials.password
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
exports.convertCredentialsConfigToCredentials = convertCredentialsConfigToCredentials;
|
|
166
|
-
function convertACLConfigToACL(config) {
|
|
167
|
-
var _a, _b, _c, _d;
|
|
168
|
-
if (config.kind !== types_2.Kind.ACL)
|
|
169
|
-
throw new Error("invalid resource type `AccessControlList`");
|
|
170
|
-
return {
|
|
171
|
-
apiVersion: config.apiVersion,
|
|
172
|
-
ref: config.ref,
|
|
173
|
-
name: config.metadata.name,
|
|
174
|
-
allow: (_b = (_a = config.spec.accessControlList) === null || _a === void 0 ? void 0 : _a.allow) !== null && _b !== void 0 ? _b : [],
|
|
175
|
-
deny: (_d = (_c = config.spec.accessControlList) === null || _c === void 0 ? void 0 : _c.deny) !== null && _d !== void 0 ? _d : []
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
exports.convertACLConfigToACL = convertACLConfigToACL;
|