@routr/common 2.0.5-alpha.9 → 2.0.6-alpha.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/assertions.d.ts +6 -0
- package/dist/assertions.js +37 -0
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +12 -4
- package/dist/connect/data_api.d.ts +11 -0
- package/dist/connect/data_api.js +91 -0
- package/dist/connect/grpc_client.d.ts +1 -0
- package/dist/connect/grpc_client.js +56 -0
- package/dist/connect/index.d.ts +3 -0
- package/dist/connect/index.js +37 -0
- package/dist/connect/types.d.ts +36 -0
- package/dist/connect/types.js +39 -0
- package/dist/errors.d.ts +18 -1
- package/dist/errors.js +43 -3
- package/dist/helper.d.ts +6 -0
- package/dist/helper.js +12 -5
- package/dist/index.d.ts +9 -3
- package/dist/index.js +18 -8
- package/dist/ip_utils.js +11 -11
- package/dist/protos/common.proto +18 -0
- package/dist/protos/location.proto +22 -9
- package/dist/protos/processor.proto +40 -0
- package/dist/protos/requester.proto +47 -0
- package/dist/protos/resources.proto +109 -0
- package/dist/protos/sipmessage.proto +47 -8
- package/dist/redis.d.ts +8 -0
- package/dist/redis.js +10 -0
- package/dist/requester/grpc_client.d.ts +1 -0
- package/dist/requester/grpc_client.js +56 -0
- package/dist/requester/index.d.ts +1 -0
- package/dist/requester/index.js +35 -0
- package/dist/service.d.ts +13 -2
- package/dist/service.js +49 -11
- package/dist/tracer.d.ts +7 -0
- package/dist/tracer.js +53 -0
- package/dist/types.d.ts +208 -7
- package/dist/types.js +88 -19
- package/package.json +13 -4
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/routr
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Routr
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
1
19
|
syntax = "proto3";
|
|
2
20
|
|
|
3
21
|
package fonoster.routr.location.v2draft1;
|
|
@@ -22,19 +40,14 @@ message Route {
|
|
|
22
40
|
string host = 2;
|
|
23
41
|
string port = 3;
|
|
24
42
|
fonoster.routr.common.v2draft1.Transport transport = 4;
|
|
25
|
-
|
|
43
|
+
int64 registered_on = 5;
|
|
26
44
|
int32 expires = 6;
|
|
27
45
|
int32 session_count = 7;
|
|
28
46
|
string edge_port_ref = 8;
|
|
29
47
|
fonoster.routr.processor.v2draft1.NetInterface listening_point = 9;
|
|
30
|
-
// During route creation, an endpoint can
|
|
31
|
-
// used as
|
|
32
|
-
// that it is the
|
|
33
|
-
//
|
|
34
|
-
// Another use case is to use the label to determine which endpoint will back certain
|
|
35
|
-
// feature. For example, we could use the label `backend=voice` to indicate that this
|
|
36
|
-
// route can serve voice applications. If the FindRoutes method includes the label the
|
|
37
|
-
// Location Service will only return routes that includes such label.
|
|
48
|
+
// During route creation, an endpoint can request to add labels than can later be
|
|
49
|
+
// used as selectors. For example, a Softphone can add a label `priority=1` to indicate
|
|
50
|
+
// that it is the prefered endpoint for the given AOR.
|
|
38
51
|
map<string, string> labels = 10;
|
|
39
52
|
}
|
|
40
53
|
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/routr
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Routr
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
1
19
|
syntax = "proto3";
|
|
2
20
|
|
|
3
21
|
package fonoster.routr.processor.v2draft1;
|
|
@@ -18,12 +36,34 @@ service Processor {
|
|
|
18
36
|
|
|
19
37
|
enum Method {
|
|
20
38
|
UNKNOWN = 0;
|
|
39
|
+
// Communicates user location (host name, IP)
|
|
21
40
|
REGISTER = 1;
|
|
41
|
+
// Establishes a session
|
|
22
42
|
INVITE = 2;
|
|
43
|
+
// Transports Instant Messages
|
|
23
44
|
MESSAGE = 3;
|
|
45
|
+
// Publishes an event to the Server
|
|
24
46
|
PUBLISH = 4;
|
|
47
|
+
// Notifies the subscriber of a new event
|
|
25
48
|
NOTIFY = 5;
|
|
49
|
+
// Subscribes for Notification from the notifier
|
|
26
50
|
SUBSCRIBE = 6;
|
|
51
|
+
// Confirms an INVITE request
|
|
52
|
+
ACK = 7;
|
|
53
|
+
// Terminates a session
|
|
54
|
+
BYE = 8;
|
|
55
|
+
// Cancels establishing of a session
|
|
56
|
+
CANCEL = 9;
|
|
57
|
+
// Communicates information about the capabilities of the calling and receiving SIP phones
|
|
58
|
+
OPTIONS = 10;
|
|
59
|
+
// Provisional Acknowledgement
|
|
60
|
+
PRACK = 11;
|
|
61
|
+
// Sends mid session information
|
|
62
|
+
INFO = 12;
|
|
63
|
+
// Asks the recipient to issue call transfer
|
|
64
|
+
REFER = 13;
|
|
65
|
+
// Modifies the state of a session
|
|
66
|
+
UPDATE = 14;
|
|
27
67
|
}
|
|
28
68
|
|
|
29
69
|
message NetInterface {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/routr
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Routr
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
syntax = "proto3";
|
|
20
|
+
|
|
21
|
+
package fonoster.routr.requester.v2draft1;
|
|
22
|
+
|
|
23
|
+
option java_multiple_files = true;
|
|
24
|
+
option java_package = "io.routr.requester";
|
|
25
|
+
option java_outer_classname = "RequesterProto";
|
|
26
|
+
option objc_class_prefix = "RP";
|
|
27
|
+
|
|
28
|
+
import "common.proto";
|
|
29
|
+
import "sipmessage.proto";
|
|
30
|
+
import "processor.proto";
|
|
31
|
+
|
|
32
|
+
// Requester service
|
|
33
|
+
service Requester {
|
|
34
|
+
// Send Message Request
|
|
35
|
+
rpc SendMessage (SendMessageRequest) returns (SendMessageResponse) {}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
message SendMessageRequest {
|
|
39
|
+
string target = 1;
|
|
40
|
+
fonoster.routr.processor.v2draft1.Method method = 2;
|
|
41
|
+
fonoster.routr.common.v2draft1.Transport transport = 3;
|
|
42
|
+
fonoster.routr.sipmessage.v2draft1.SIPMessage message = 4;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
message SendMessageResponse {
|
|
46
|
+
fonoster.routr.sipmessage.v2draft1.SIPMessage message = 1;
|
|
47
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// TODO: Show a link to were this proto was downloaded from
|
|
2
|
+
syntax = "proto3";
|
|
3
|
+
|
|
4
|
+
package fonoster.routr.resources.v2draft1;
|
|
5
|
+
|
|
6
|
+
import "google/protobuf/struct.proto";
|
|
7
|
+
|
|
8
|
+
// Resources service
|
|
9
|
+
service Resources {
|
|
10
|
+
rpc Create (CreateRequest) returns (Resource) {}
|
|
11
|
+
rpc Update (UpdateRequest) returns (Resource) {}
|
|
12
|
+
rpc Get (GetRequest) returns (Resource) {}
|
|
13
|
+
rpc Delete (DeleteRequest) returns (Empty) {}
|
|
14
|
+
rpc List (ListRequest) returns (ListResponse) {}
|
|
15
|
+
rpc FindBy (FindByRequest) returns (FindByResponse) {}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
message Metadata {
|
|
19
|
+
string ref = 1;
|
|
20
|
+
// The resource's name
|
|
21
|
+
string name = 2;
|
|
22
|
+
// Link to dependencies of this resource
|
|
23
|
+
repeated string depends_on = 3;
|
|
24
|
+
// Created at
|
|
25
|
+
int32 create_time = 4;
|
|
26
|
+
// Updated at
|
|
27
|
+
int32 update_time = 5;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
message Resource {
|
|
31
|
+
// The resource's api version
|
|
32
|
+
string apiVersion = 1;
|
|
33
|
+
// The resource's kind
|
|
34
|
+
string kind = 2;
|
|
35
|
+
// The resource's metadata
|
|
36
|
+
Metadata metadata = 3;
|
|
37
|
+
// The resource's data
|
|
38
|
+
.google.protobuf.Struct spec = 4;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
message CreateRequest {
|
|
42
|
+
Metadata metadata = 1;
|
|
43
|
+
.google.protobuf.Struct spec = 2;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
message UpdateRequest {
|
|
47
|
+
Metadata metadata = 1;
|
|
48
|
+
.google.protobuf.Struct spec = 2;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
message DeleteRequest {
|
|
52
|
+
string ref = 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
message GetRequest {
|
|
56
|
+
string ref = 1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
message ListRequest {
|
|
60
|
+
// The maximum number of items in the list
|
|
61
|
+
int32 page_size = 1;
|
|
62
|
+
|
|
63
|
+
// The next_page_token value returned from the previous request, if any
|
|
64
|
+
string page_token = 2;
|
|
65
|
+
|
|
66
|
+
// The filter to apply to the list
|
|
67
|
+
string filter = 3;
|
|
68
|
+
|
|
69
|
+
// The type of resource to list
|
|
70
|
+
string kind = 4;
|
|
71
|
+
|
|
72
|
+
// Level of detail of the individual entities (reserved)
|
|
73
|
+
View view = 5;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
message ListResponse {
|
|
77
|
+
// List of Resources
|
|
78
|
+
repeated Resource resources = 1;
|
|
79
|
+
|
|
80
|
+
// Token to retrieve the next page of results, or empty if there are no more results in the list
|
|
81
|
+
string next_page_token = 2;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
message FindByRequest {
|
|
85
|
+
// The type of resource to find
|
|
86
|
+
string kind = 1;
|
|
87
|
+
|
|
88
|
+
// Search criteria for the request
|
|
89
|
+
string criteria = 2;
|
|
90
|
+
|
|
91
|
+
// Parameters to apply in combination with the search criteria
|
|
92
|
+
.google.protobuf.Struct parameters = 3;
|
|
93
|
+
|
|
94
|
+
// Level of detail of the individual entities (reserved)
|
|
95
|
+
View view = 4;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
message FindByResponse {
|
|
99
|
+
// List of Resources
|
|
100
|
+
repeated Resource resources = 1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
enum View {
|
|
104
|
+
BASIC = 0;
|
|
105
|
+
STANDARD = 1;
|
|
106
|
+
FULL = 2;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
message Empty {}
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/routr
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Routr
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
1
19
|
syntax = "proto3";
|
|
2
20
|
|
|
3
21
|
package fonoster.routr.sipmessage.v2draft1;
|
|
@@ -53,7 +71,7 @@ enum ResponseType {
|
|
|
53
71
|
BAD_EVENT = 42;
|
|
54
72
|
REQUEST_PENDING = 43;
|
|
55
73
|
UNDECIPHERABLE = 44;
|
|
56
|
-
SERVER_ERROR =45;
|
|
74
|
+
SERVER_ERROR = 45;
|
|
57
75
|
SERVER_INTERNAL_ERROR = 46;
|
|
58
76
|
NOT_IMPLEMENTED = 47;
|
|
59
77
|
BAD_GATEWAY = 48;
|
|
@@ -90,7 +108,8 @@ message Authorization {
|
|
|
90
108
|
string response = 8;
|
|
91
109
|
string username = 9;
|
|
92
110
|
string uri = 10;
|
|
93
|
-
|
|
111
|
+
string method = 11;
|
|
112
|
+
int32 nonce_count = 12;
|
|
94
113
|
}
|
|
95
114
|
|
|
96
115
|
message CallID {
|
|
@@ -124,23 +143,40 @@ message SipURI {
|
|
|
124
143
|
int32 ttl_param = 8;
|
|
125
144
|
int32 port = 9;
|
|
126
145
|
bool lr_param = 10;
|
|
127
|
-
bool
|
|
146
|
+
bool bnc_param = 11;
|
|
147
|
+
bool secure = 12;
|
|
128
148
|
}
|
|
129
149
|
|
|
130
150
|
message Address {
|
|
131
151
|
SipURI uri = 1;
|
|
132
|
-
string
|
|
152
|
+
string display_name = 2;
|
|
133
153
|
bool wildcard = 3;
|
|
134
154
|
}
|
|
135
155
|
|
|
156
|
+
message MaxForwards {
|
|
157
|
+
int32 max_forwards = 1;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
message Route {
|
|
161
|
+
Address address = 1;
|
|
162
|
+
map<string, string> parameters = 2;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
message RecordRoute {
|
|
166
|
+
Address address = 1;
|
|
167
|
+
map<string, string> parameters = 2;
|
|
168
|
+
}
|
|
169
|
+
|
|
136
170
|
message From {
|
|
137
171
|
Address address = 1;
|
|
138
172
|
string tag = 2;
|
|
173
|
+
map<string, string> parameters = 3;
|
|
139
174
|
}
|
|
140
175
|
|
|
141
176
|
message To {
|
|
142
177
|
Address address = 1;
|
|
143
178
|
string tag = 2;
|
|
179
|
+
map<string, string> parameters = 3;
|
|
144
180
|
}
|
|
145
181
|
|
|
146
182
|
message Contact {
|
|
@@ -164,8 +200,11 @@ message SIPMessage {
|
|
|
164
200
|
CallID call_id = 6;
|
|
165
201
|
ContentLength content_length = 7;
|
|
166
202
|
Expires expires = 8;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
203
|
+
WWWAuthenticate www_authenticate = 9;
|
|
204
|
+
MaxForwards max_forwards = 10;
|
|
205
|
+
Authorization authorization = 11;
|
|
206
|
+
repeated Extension extensions = 12;
|
|
207
|
+
repeated Via via = 13;
|
|
208
|
+
repeated Route route = 14;
|
|
209
|
+
repeated RecordRoute record_route = 15;
|
|
171
210
|
}
|
package/dist/redis.d.ts
ADDED
package/dist/redis.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRedisUrlFromConfig = void 0;
|
|
4
|
+
const getRedisUrlFromConfig = (config) => {
|
|
5
|
+
return (`redis${config.secure ? "s" : ""}` +
|
|
6
|
+
`://${config.username ? config.username : ""}` +
|
|
7
|
+
`${config.password ? ":" + config.password + "@" : ""}` +
|
|
8
|
+
`${config.host}:${config.port}`);
|
|
9
|
+
};
|
|
10
|
+
exports.getRedisUrlFromConfig = getRedisUrlFromConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const REQUESTER_PROTO: any;
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.REQUESTER_PROTO = void 0;
|
|
27
|
+
/*
|
|
28
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
29
|
+
* http://github.com/fonoster/routr
|
|
30
|
+
*
|
|
31
|
+
* This file is part of Routr
|
|
32
|
+
*
|
|
33
|
+
* Licensed under the MIT License (the "License");
|
|
34
|
+
* you may not use this file except in compliance with
|
|
35
|
+
* the License. You may obtain a copy of the License at
|
|
36
|
+
*
|
|
37
|
+
* https://opensource.org/licenses/MIT
|
|
38
|
+
*
|
|
39
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
40
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
41
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
42
|
+
* See the License for the specific language governing permissions and
|
|
43
|
+
* limitations under the License.
|
|
44
|
+
*/
|
|
45
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
46
|
+
const protoLoader = require("@grpc/proto-loader");
|
|
47
|
+
const packageDefinition = protoLoader.loadSync(__dirname + "/../protos/requester.proto", {
|
|
48
|
+
keepCase: false,
|
|
49
|
+
longs: String,
|
|
50
|
+
enums: String,
|
|
51
|
+
defaults: true,
|
|
52
|
+
oneofs: true
|
|
53
|
+
});
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
|
|
56
|
+
exports.REQUESTER_PROTO = protoDescriptor.fonoster.routr.requester;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./grpc_client";
|
|
@@ -0,0 +1,35 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/*
|
|
18
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Routr.
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the MIT License (the "License");
|
|
24
|
+
* you may not use this file except in compliance with
|
|
25
|
+
* the License. You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* https://opensource.org/licenses/MIT
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
__exportStar(require("./grpc_client"), exports);
|
package/dist/service.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { ObjectProto, ServiceInfo } from "./types";
|
|
2
2
|
import { ServiceDefinitionNotFound } from "./errors";
|
|
3
|
-
export declare const PROCESSOR_OBJECT_PROTO:
|
|
4
|
-
export declare const LOCATION_OBJECT_PROTO:
|
|
3
|
+
export declare const PROCESSOR_OBJECT_PROTO: unknown;
|
|
4
|
+
export declare const LOCATION_OBJECT_PROTO: unknown;
|
|
5
|
+
/**
|
|
6
|
+
* Gets the proto definition for the given object.
|
|
7
|
+
*
|
|
8
|
+
* @param {ObjectProt} objectProto - The object proto to load.
|
|
9
|
+
* @return {A} The proto definition.
|
|
10
|
+
*/
|
|
5
11
|
export declare function getObjectProto<A>(objectProto: ObjectProto): A | ServiceDefinitionNotFound;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new service using the given service definition.
|
|
14
|
+
*
|
|
15
|
+
* @param {ServiceInfo} serviceInfo - The service info to create the service from.
|
|
16
|
+
*/
|
|
6
17
|
export default function createService(serviceInfo: ServiceInfo): void;
|
package/dist/service.js
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.getObjectProto = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = void 0;
|
|
7
27
|
const errors_1 = require("./errors");
|
|
8
|
-
const
|
|
9
|
-
const protoLoader = require(
|
|
10
|
-
const
|
|
28
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
29
|
+
const protoLoader = __importStar(require("@grpc/proto-loader"));
|
|
30
|
+
const logger_1 = require("@fonoster/logger");
|
|
31
|
+
const logger = (0, logger_1.getLogger)({ service: "common", filePath: __filename });
|
|
11
32
|
const loadOptions = {
|
|
12
33
|
keepCase: false,
|
|
13
34
|
longs: String,
|
|
@@ -15,29 +36,46 @@ const loadOptions = {
|
|
|
15
36
|
defaults: true,
|
|
16
37
|
oneofs: true
|
|
17
38
|
};
|
|
39
|
+
// TODO: Get version from the proto or package
|
|
40
|
+
const API_VERSION = "v2draft1";
|
|
18
41
|
// We currenly don't have a way to obtain the proto type
|
|
19
42
|
exports.PROCESSOR_OBJECT_PROTO = getObjectProto({
|
|
20
43
|
name: "processor",
|
|
21
|
-
version:
|
|
22
|
-
path: __dirname +
|
|
44
|
+
version: API_VERSION,
|
|
45
|
+
path: __dirname + "/protos/processor.proto"
|
|
23
46
|
});
|
|
24
47
|
exports.LOCATION_OBJECT_PROTO = getObjectProto({
|
|
25
48
|
name: "location",
|
|
26
|
-
version:
|
|
27
|
-
path: __dirname +
|
|
49
|
+
version: API_VERSION,
|
|
50
|
+
path: __dirname + "/protos/location.proto"
|
|
28
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* Gets the proto definition for the given object.
|
|
54
|
+
*
|
|
55
|
+
* @param {ObjectProt} objectProto - The object proto to load.
|
|
56
|
+
* @return {A} The proto definition.
|
|
57
|
+
*/
|
|
29
58
|
function getObjectProto(objectProto) {
|
|
30
59
|
var _a, _b;
|
|
31
60
|
const definitions = protoLoader.loadSync(objectProto.path, loadOptions);
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
62
|
const objProto = (_b = (_a = grpc.loadPackageDefinition(definitions)) === null || _a === void 0 ? void 0 : _a.fonoster) === null || _b === void 0 ? void 0 : _b.routr[objectProto.name];
|
|
33
|
-
return objProto
|
|
63
|
+
return (objProto === null || objProto === void 0 ? void 0 : objProto[objectProto.version])
|
|
34
64
|
? objProto[objectProto.version]
|
|
35
65
|
: new errors_1.ServiceDefinitionNotFound(objectProto.name, objectProto.version);
|
|
36
66
|
}
|
|
37
67
|
exports.getObjectProto = getObjectProto;
|
|
68
|
+
/**
|
|
69
|
+
* Creates a new service using the given service definition.
|
|
70
|
+
*
|
|
71
|
+
* @param {ServiceInfo} serviceInfo - The service info to create the service from.
|
|
72
|
+
*/
|
|
38
73
|
function createService(serviceInfo) {
|
|
39
74
|
const cb = () => {
|
|
40
|
-
|
|
75
|
+
logger.info("starting routr service", {
|
|
76
|
+
name: serviceInfo.name,
|
|
77
|
+
bindAddr: serviceInfo.bindAddr
|
|
78
|
+
});
|
|
41
79
|
server.start();
|
|
42
80
|
};
|
|
43
81
|
const credentials = grpc.ServerCredentials.createInsecure();
|
package/dist/tracer.d.ts
ADDED
package/dist/tracer.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
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.init = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster/routr
|
|
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 api_1 = __importDefault(require("@opentelemetry/api"));
|
|
26
|
+
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
27
|
+
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
28
|
+
const resources_1 = require("@opentelemetry/resources");
|
|
29
|
+
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
30
|
+
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
31
|
+
const exporter_jaeger_1 = require("@opentelemetry/exporter-jaeger");
|
|
32
|
+
const instrumentation_grpc_1 = require("@opentelemetry/instrumentation-grpc");
|
|
33
|
+
/**
|
|
34
|
+
* This function registers the instrumentations for the service.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} serviceName - The name of the service.
|
|
37
|
+
* @return {Tracer} The tracer object.
|
|
38
|
+
*/
|
|
39
|
+
function init(serviceName) {
|
|
40
|
+
const provider = new sdk_trace_node_1.NodeTracerProvider({
|
|
41
|
+
resource: new resources_1.Resource({
|
|
42
|
+
[semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: serviceName
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
const exporter = new exporter_jaeger_1.JaegerExporter();
|
|
46
|
+
provider.addSpanProcessor(new sdk_trace_base_1.SimpleSpanProcessor(exporter));
|
|
47
|
+
provider.register();
|
|
48
|
+
(0, instrumentation_1.registerInstrumentations)({
|
|
49
|
+
instrumentations: [new instrumentation_grpc_1.GrpcInstrumentation()]
|
|
50
|
+
});
|
|
51
|
+
return api_1.default.trace.getTracer("routr-tracer");
|
|
52
|
+
}
|
|
53
|
+
exports.init = init;
|