@routr/common 2.0.8-alpha.12 → 2.0.8-alpha.14
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/connect/schemas/acl.d.ts +60 -0
- package/dist/connect/schemas/acl.js +79 -0
- package/dist/connect/schemas/agent.d.ts +59 -0
- package/dist/connect/schemas/agent.js +78 -0
- package/dist/connect/schemas/crendentials.d.ts +54 -0
- package/dist/connect/schemas/crendentials.js +73 -0
- package/dist/connect/schemas/domain.d.ts +72 -0
- package/dist/connect/schemas/domain.js +91 -0
- package/dist/connect/schemas/index.d.ts +1 -0
- package/dist/connect/schemas/index.js +35 -0
- package/dist/connect/schemas/number.d.ts +77 -0
- package/dist/connect/schemas/number.js +96 -0
- package/dist/connect/schemas/peer.d.ts +67 -0
- package/dist/connect/schemas/peer.js +86 -0
- package/dist/connect/schemas/trunk.d.ts +113 -0
- package/dist/connect/schemas/trunk.js +132 -0
- package/dist/connect/schemas/validators.d.ts +2 -0
- package/dist/connect/schemas/validators.js +43 -0
- package/dist/connect/types.d.ts +2 -2
- package/dist/connect/types.js +2 -2
- package/dist/helper.d.ts +12 -0
- package/dist/helper.js +67 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/package.json +8 -3
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
exports.default = {
|
|
22
|
+
$id: "https://json-schema.org/draft/2020-12/schema",
|
|
23
|
+
title: "Number Schema",
|
|
24
|
+
description: "A JSON Schema for validating numbers.",
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
apiVersion: {
|
|
28
|
+
enum: ["v2draft1", "v2.0", "v2"]
|
|
29
|
+
},
|
|
30
|
+
kind: {
|
|
31
|
+
enum: ["Number", "number"]
|
|
32
|
+
},
|
|
33
|
+
ref: {
|
|
34
|
+
description: "Reference to the resource",
|
|
35
|
+
type: "string"
|
|
36
|
+
},
|
|
37
|
+
metadata: {
|
|
38
|
+
description: "Resource metadata",
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
name: {
|
|
42
|
+
description: "Resource's friendly name",
|
|
43
|
+
type: "string"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
spec: {
|
|
48
|
+
description: "Operations spec for Numbers",
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
trunkRef: {
|
|
52
|
+
description: "Reference to the trunk",
|
|
53
|
+
type: "string"
|
|
54
|
+
},
|
|
55
|
+
location: {
|
|
56
|
+
description: "Location of the number",
|
|
57
|
+
type: "object",
|
|
58
|
+
properties: {
|
|
59
|
+
telUrl: {
|
|
60
|
+
description: "Tel URL",
|
|
61
|
+
type: "string"
|
|
62
|
+
},
|
|
63
|
+
aorLink: {
|
|
64
|
+
description: "AOR link",
|
|
65
|
+
type: "string"
|
|
66
|
+
},
|
|
67
|
+
sessionAffinityHeader: {
|
|
68
|
+
description: "Session affinity",
|
|
69
|
+
type: "string"
|
|
70
|
+
},
|
|
71
|
+
extraHeaders: {
|
|
72
|
+
description: "Properties",
|
|
73
|
+
type: "array",
|
|
74
|
+
items: {
|
|
75
|
+
type: "object",
|
|
76
|
+
properties: {
|
|
77
|
+
name: {
|
|
78
|
+
description: "Name of the header",
|
|
79
|
+
type: "string"
|
|
80
|
+
},
|
|
81
|
+
value: {
|
|
82
|
+
description: "Value of the header",
|
|
83
|
+
type: "string"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
required: ["telUrl", "aorLink"]
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
required: ["trunkRef", "location"]
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
required: ["apiVersion", "kind", "ref", "metadata", "spec"]
|
|
96
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
$id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
type: string;
|
|
6
|
+
properties: {
|
|
7
|
+
apiVersion: {
|
|
8
|
+
enum: string[];
|
|
9
|
+
};
|
|
10
|
+
kind: {
|
|
11
|
+
enum: string[];
|
|
12
|
+
};
|
|
13
|
+
ref: {
|
|
14
|
+
description: string;
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
metadata: {
|
|
18
|
+
description: string;
|
|
19
|
+
type: string;
|
|
20
|
+
properties: {
|
|
21
|
+
name: {
|
|
22
|
+
description: string;
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
spec: {
|
|
28
|
+
description: string;
|
|
29
|
+
type: string;
|
|
30
|
+
properties: {
|
|
31
|
+
username: {
|
|
32
|
+
description: string;
|
|
33
|
+
type: string;
|
|
34
|
+
minLength: number;
|
|
35
|
+
maxLength: number;
|
|
36
|
+
readOnly: boolean;
|
|
37
|
+
};
|
|
38
|
+
aor: {
|
|
39
|
+
description: string;
|
|
40
|
+
type: string;
|
|
41
|
+
minLength: number;
|
|
42
|
+
maxLength: number;
|
|
43
|
+
};
|
|
44
|
+
contactAddr: {
|
|
45
|
+
description: string;
|
|
46
|
+
type: string;
|
|
47
|
+
maxLength: number;
|
|
48
|
+
};
|
|
49
|
+
credentialsRef: {
|
|
50
|
+
description: string;
|
|
51
|
+
type: string;
|
|
52
|
+
};
|
|
53
|
+
accessControlListRef: {
|
|
54
|
+
description: string;
|
|
55
|
+
type: string;
|
|
56
|
+
};
|
|
57
|
+
enabled: {
|
|
58
|
+
description: string;
|
|
59
|
+
type: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
required: string[];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
required: string[];
|
|
66
|
+
};
|
|
67
|
+
export default _default;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
exports.default = {
|
|
22
|
+
$id: "https://json-schema.org/draft/2020-12/schema",
|
|
23
|
+
title: "Agent validation schema",
|
|
24
|
+
description: "The spec defined for Peer validation",
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
apiVersion: {
|
|
28
|
+
enum: ["v2draft1", "v2.0", "v2"]
|
|
29
|
+
},
|
|
30
|
+
kind: {
|
|
31
|
+
enum: ["Peer", "peer"]
|
|
32
|
+
},
|
|
33
|
+
ref: {
|
|
34
|
+
description: "Reference to the resource",
|
|
35
|
+
type: "string"
|
|
36
|
+
},
|
|
37
|
+
metadata: {
|
|
38
|
+
description: "Resource metadata",
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
name: {
|
|
42
|
+
description: "Resource's friendly name",
|
|
43
|
+
type: "string"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
spec: {
|
|
48
|
+
description: "Operations spec for an Peer",
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
username: {
|
|
52
|
+
description: "The username for the Peer",
|
|
53
|
+
type: "string",
|
|
54
|
+
minLength: 3,
|
|
55
|
+
maxLength: 60,
|
|
56
|
+
readOnly: true
|
|
57
|
+
},
|
|
58
|
+
aor: {
|
|
59
|
+
description: "Address of the Peer (acceptable schemas are sip, backend.)",
|
|
60
|
+
type: "string",
|
|
61
|
+
minLength: 3,
|
|
62
|
+
maxLength: 255
|
|
63
|
+
},
|
|
64
|
+
contactAddr: {
|
|
65
|
+
description: "Contact address of the Peer",
|
|
66
|
+
type: "string",
|
|
67
|
+
maxLength: 255
|
|
68
|
+
},
|
|
69
|
+
credentialsRef: {
|
|
70
|
+
description: "The credential the Peer uses to authenticate",
|
|
71
|
+
type: "string"
|
|
72
|
+
},
|
|
73
|
+
accessControlListRef: {
|
|
74
|
+
description: "The ACL the Peer uses to control access to the Peer (Reserved for future use)",
|
|
75
|
+
type: "string"
|
|
76
|
+
},
|
|
77
|
+
enabled: {
|
|
78
|
+
description: "Whether the Peer is enabled",
|
|
79
|
+
type: "boolean"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
required: ["username", "aor"]
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
required: ["apiVersion", "kind", "ref", "metadata", "spec"]
|
|
86
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
$id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
type: string;
|
|
6
|
+
properties: {
|
|
7
|
+
apiVersion: {
|
|
8
|
+
enum: string[];
|
|
9
|
+
};
|
|
10
|
+
kind: {
|
|
11
|
+
enum: string[];
|
|
12
|
+
};
|
|
13
|
+
ref: {
|
|
14
|
+
description: string;
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
metadata: {
|
|
18
|
+
description: string;
|
|
19
|
+
type: string;
|
|
20
|
+
properties: {
|
|
21
|
+
name: {
|
|
22
|
+
description: string;
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
spec: {
|
|
28
|
+
description: string;
|
|
29
|
+
type: string;
|
|
30
|
+
properties: {
|
|
31
|
+
inbound: {
|
|
32
|
+
description: string;
|
|
33
|
+
type: string;
|
|
34
|
+
properties: {
|
|
35
|
+
uri: {
|
|
36
|
+
description: string;
|
|
37
|
+
type: string;
|
|
38
|
+
};
|
|
39
|
+
accessControlListRef: {
|
|
40
|
+
description: string;
|
|
41
|
+
type: string;
|
|
42
|
+
};
|
|
43
|
+
credentialsRef: {
|
|
44
|
+
description: string;
|
|
45
|
+
type: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
required: string[];
|
|
49
|
+
};
|
|
50
|
+
outbound: {
|
|
51
|
+
description: string;
|
|
52
|
+
type: string;
|
|
53
|
+
properties: {
|
|
54
|
+
sendRegister: {
|
|
55
|
+
description: string;
|
|
56
|
+
type: string;
|
|
57
|
+
};
|
|
58
|
+
credentialsRef: {
|
|
59
|
+
description: string;
|
|
60
|
+
type: string;
|
|
61
|
+
};
|
|
62
|
+
uris: {
|
|
63
|
+
description: string;
|
|
64
|
+
type: string;
|
|
65
|
+
items: {
|
|
66
|
+
type: string;
|
|
67
|
+
properties: {
|
|
68
|
+
uri: {
|
|
69
|
+
description: string;
|
|
70
|
+
type: string;
|
|
71
|
+
properties: {
|
|
72
|
+
host: {
|
|
73
|
+
description: string;
|
|
74
|
+
type: string;
|
|
75
|
+
};
|
|
76
|
+
port: {
|
|
77
|
+
description: string;
|
|
78
|
+
type: string;
|
|
79
|
+
};
|
|
80
|
+
transport: {
|
|
81
|
+
description: string;
|
|
82
|
+
enum: string[];
|
|
83
|
+
};
|
|
84
|
+
user: {
|
|
85
|
+
description: string;
|
|
86
|
+
type: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
weight: {
|
|
91
|
+
description: string;
|
|
92
|
+
type: string;
|
|
93
|
+
};
|
|
94
|
+
priority: {
|
|
95
|
+
description: string;
|
|
96
|
+
type: string;
|
|
97
|
+
};
|
|
98
|
+
enabled: {
|
|
99
|
+
description: string;
|
|
100
|
+
type: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
required: string[];
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
required: string[];
|
|
112
|
+
};
|
|
113
|
+
export default _default;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
exports.default = {
|
|
22
|
+
$id: "https://json-schema.org/draft/2020-12/schema",
|
|
23
|
+
title: "Agent validation schema",
|
|
24
|
+
description: "The spec defined for Peer validation",
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
apiVersion: {
|
|
28
|
+
enum: ["v2draft1", "v2.0", "v2"]
|
|
29
|
+
},
|
|
30
|
+
kind: {
|
|
31
|
+
enum: ["Trunk", "trunk"]
|
|
32
|
+
},
|
|
33
|
+
ref: {
|
|
34
|
+
description: "Reference to the resource",
|
|
35
|
+
type: "string"
|
|
36
|
+
},
|
|
37
|
+
metadata: {
|
|
38
|
+
description: "Resource metadata",
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
name: {
|
|
42
|
+
description: "Resource's friendly name",
|
|
43
|
+
type: "string"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
spec: {
|
|
48
|
+
description: "Operations spec for an Trunk",
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
inbound: {
|
|
52
|
+
description: "Inbound configuration",
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: {
|
|
55
|
+
uri: {
|
|
56
|
+
description: "URI of the inbound endpoint",
|
|
57
|
+
type: "string"
|
|
58
|
+
},
|
|
59
|
+
accessControlListRef: {
|
|
60
|
+
description: "Reference to the ACL to be used for inbound traffic",
|
|
61
|
+
type: "string"
|
|
62
|
+
},
|
|
63
|
+
credentialsRef: {
|
|
64
|
+
description: "Reference to the credentials to be used for inbound traffic",
|
|
65
|
+
type: "string"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
required: ["uri"]
|
|
69
|
+
},
|
|
70
|
+
outbound: {
|
|
71
|
+
description: "Outbound configuration",
|
|
72
|
+
type: "object",
|
|
73
|
+
properties: {
|
|
74
|
+
sendRegister: {
|
|
75
|
+
description: "Whether to send register messages",
|
|
76
|
+
type: "boolean"
|
|
77
|
+
},
|
|
78
|
+
credentialsRef: {
|
|
79
|
+
description: "Reference to the credentials to be used for outbound traffic",
|
|
80
|
+
type: "string"
|
|
81
|
+
},
|
|
82
|
+
uris: {
|
|
83
|
+
description: "List of URIs to be used for outbound traffic",
|
|
84
|
+
type: "array",
|
|
85
|
+
items: {
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: {
|
|
88
|
+
uri: {
|
|
89
|
+
description: "URI to be used for outbound traffic",
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: {
|
|
92
|
+
host: {
|
|
93
|
+
description: "Hostname of the URI",
|
|
94
|
+
type: "string"
|
|
95
|
+
},
|
|
96
|
+
port: {
|
|
97
|
+
description: "Port of the URI",
|
|
98
|
+
type: "integer"
|
|
99
|
+
},
|
|
100
|
+
transport: {
|
|
101
|
+
description: "Transport of the URI",
|
|
102
|
+
enum: ["tcp", "sctp", "udp", "tls", "ws", "wss"]
|
|
103
|
+
},
|
|
104
|
+
user: {
|
|
105
|
+
description: "Username of the URI",
|
|
106
|
+
type: "string"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
weight: {
|
|
111
|
+
description: "Weight of the URI",
|
|
112
|
+
type: "integer"
|
|
113
|
+
},
|
|
114
|
+
priority: {
|
|
115
|
+
description: "Priority of the URI",
|
|
116
|
+
type: "integer"
|
|
117
|
+
},
|
|
118
|
+
enabled: {
|
|
119
|
+
description: "Whether the URI is enabled",
|
|
120
|
+
type: "boolean"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
required: ["uris"]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
required: ["apiVersion", "kind", "ref", "metadata", "spec"]
|
|
132
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.schemaValidators = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Routr.
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the MIT License (the "License");
|
|
14
|
+
* you may not use this file except in compliance with
|
|
15
|
+
* the License. You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* https://opensource.org/licenses/MIT
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const types_1 = require("../types");
|
|
26
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
27
|
+
const acl_1 = __importDefault(require("./acl"));
|
|
28
|
+
const agent_1 = __importDefault(require("./agent"));
|
|
29
|
+
const crendentials_1 = __importDefault(require("./crendentials"));
|
|
30
|
+
const domain_1 = __importDefault(require("./domain"));
|
|
31
|
+
const number_1 = __importDefault(require("./number"));
|
|
32
|
+
const peer_1 = __importDefault(require("./peer"));
|
|
33
|
+
const trunk_1 = __importDefault(require("./trunk"));
|
|
34
|
+
const validator = (schema) => new ajv_1.default().compile(schema);
|
|
35
|
+
const schemaValidators = new Map();
|
|
36
|
+
exports.schemaValidators = schemaValidators;
|
|
37
|
+
schemaValidators.set(types_1.Kind.ACL, validator(acl_1.default));
|
|
38
|
+
schemaValidators.set(types_1.Kind.AGENT, validator(agent_1.default));
|
|
39
|
+
schemaValidators.set(types_1.Kind.CREDENTIALS, validator(crendentials_1.default));
|
|
40
|
+
schemaValidators.set(types_1.Kind.DOMAIN, validator(domain_1.default));
|
|
41
|
+
schemaValidators.set(types_1.Kind.NUMBER, validator(number_1.default));
|
|
42
|
+
schemaValidators.set(types_1.Kind.PEER, validator(peer_1.default));
|
|
43
|
+
schemaValidators.set(types_1.Kind.TRUNK, validator(trunk_1.default));
|
package/dist/connect/types.d.ts
CHANGED
|
@@ -5,13 +5,13 @@ export declare enum Kind {
|
|
|
5
5
|
TRUNK = "trunk",
|
|
6
6
|
DOMAIN = "domain",
|
|
7
7
|
UNKNOWN = "unknown",
|
|
8
|
-
|
|
8
|
+
CREDENTIALS = "credentials",
|
|
9
9
|
ACL = "accesscontrollist"
|
|
10
10
|
}
|
|
11
11
|
export declare enum FindCriteria {
|
|
12
12
|
FIND_AGENT_BY_USERNAME = "find_agent_by_username",
|
|
13
13
|
FIND_PEER_BY_USERNAME = "find_peer_by_username",
|
|
14
|
-
|
|
14
|
+
FIND_CREDENTIALS_BY_REFERENCE = "find_credentials_by_reference",
|
|
15
15
|
FIND_DOMAIN_BY_DOMAINURI = "find_domain_by_domainuri",
|
|
16
16
|
FIND_NUMBER_BY_TELURL = "find_number_by_telurl",
|
|
17
17
|
FIND_TRUNKS_WITH_SEND_REGISTER = "find_trunks_with_send_register",
|
package/dist/connect/types.js
CHANGED
|
@@ -27,14 +27,14 @@ var Kind;
|
|
|
27
27
|
Kind["TRUNK"] = "trunk";
|
|
28
28
|
Kind["DOMAIN"] = "domain";
|
|
29
29
|
Kind["UNKNOWN"] = "unknown";
|
|
30
|
-
Kind["
|
|
30
|
+
Kind["CREDENTIALS"] = "credentials";
|
|
31
31
|
Kind["ACL"] = "accesscontrollist";
|
|
32
32
|
})(Kind = exports.Kind || (exports.Kind = {}));
|
|
33
33
|
var FindCriteria;
|
|
34
34
|
(function (FindCriteria) {
|
|
35
35
|
FindCriteria["FIND_AGENT_BY_USERNAME"] = "find_agent_by_username";
|
|
36
36
|
FindCriteria["FIND_PEER_BY_USERNAME"] = "find_peer_by_username";
|
|
37
|
-
FindCriteria["
|
|
37
|
+
FindCriteria["FIND_CREDENTIALS_BY_REFERENCE"] = "find_credentials_by_reference";
|
|
38
38
|
FindCriteria["FIND_DOMAIN_BY_DOMAINURI"] = "find_domain_by_domainuri";
|
|
39
39
|
FindCriteria["FIND_NUMBER_BY_TELURL"] = "find_number_by_telurl";
|
|
40
40
|
FindCriteria["FIND_TRUNKS_WITH_SEND_REGISTER"] = "find_trunks_with_send_register";
|
package/dist/helper.d.ts
CHANGED
|
@@ -14,3 +14,15 @@ export declare const deepCopy: <T>(source: T) => T;
|
|
|
14
14
|
* @return {NetInterface} transport The deep copy of the source object.
|
|
15
15
|
*/
|
|
16
16
|
export declare const getListeningPoint: (listeningPoints: NetInterface[], transport: Transport) => NetInterface;
|
|
17
|
+
/**
|
|
18
|
+
* Reads a file and returns a JSON object or throws an error.
|
|
19
|
+
* The file must be a valid JSON, YAML, or TOML file.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} path - The path to the file.
|
|
22
|
+
* @return {object} The JSON object.
|
|
23
|
+
* @throws {Error} If the file is not a valid JSON, YAML, or TOML file.
|
|
24
|
+
* @throws {Error} If the file does not exist.
|
|
25
|
+
* @throws {Error} If the file is not readable.
|
|
26
|
+
* @throws {Error} If the file is empty.
|
|
27
|
+
*/
|
|
28
|
+
export declare const readConfigFile: (path: string) => Record<string, any>;
|
package/dist/helper.js
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getListeningPoint = exports.deepCopy = void 0;
|
|
29
|
+
exports.readConfigFile = exports.getListeningPoint = exports.deepCopy = void 0;
|
|
4
30
|
/*
|
|
5
31
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
6
32
|
* http://github.com/fonoster/routr
|
|
@@ -20,6 +46,9 @@ exports.getListeningPoint = exports.deepCopy = void 0;
|
|
|
20
46
|
* limitations under the License.
|
|
21
47
|
*/
|
|
22
48
|
const types_1 = require("./types");
|
|
49
|
+
const fs_1 = __importDefault(require("fs"));
|
|
50
|
+
const yaml = __importStar(require("js-yaml"));
|
|
51
|
+
const toml = __importStar(require("toml"));
|
|
23
52
|
/**
|
|
24
53
|
* Makes a deep copy of an object.
|
|
25
54
|
*
|
|
@@ -58,3 +87,40 @@ const getListeningPoint = (listeningPoints, transport) => {
|
|
|
58
87
|
return listeningPoint;
|
|
59
88
|
};
|
|
60
89
|
exports.getListeningPoint = getListeningPoint;
|
|
90
|
+
/**
|
|
91
|
+
* Reads a file and returns a JSON object or throws an error.
|
|
92
|
+
* The file must be a valid JSON, YAML, or TOML file.
|
|
93
|
+
*
|
|
94
|
+
* @param {string} path - The path to the file.
|
|
95
|
+
* @return {object} The JSON object.
|
|
96
|
+
* @throws {Error} If the file is not a valid JSON, YAML, or TOML file.
|
|
97
|
+
* @throws {Error} If the file does not exist.
|
|
98
|
+
* @throws {Error} If the file is not readable.
|
|
99
|
+
* @throws {Error} If the file is empty.
|
|
100
|
+
*/
|
|
101
|
+
const readConfigFile = (path) => {
|
|
102
|
+
if (!fs_1.default.existsSync(path) || !fs_1.default.statSync(path).isFile()) {
|
|
103
|
+
throw new Error(`config file ${path} does not exist`);
|
|
104
|
+
}
|
|
105
|
+
const content = fs_1.default.readFileSync(path, "utf8");
|
|
106
|
+
try {
|
|
107
|
+
return yaml.load(content);
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
// Ignore
|
|
111
|
+
}
|
|
112
|
+
// Experimental TOML support
|
|
113
|
+
try {
|
|
114
|
+
return toml.parse(content);
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
// Ignore
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return JSON.parse(content);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
throw new Error("file is not a valid JSON or YAML file");
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
exports.readConfigFile = readConfigFile;
|
package/dist/index.d.ts
CHANGED