@routr/common 2.0.8-alpha.2 → 2.0.8-alpha.20
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 +43 -4
- package/dist/auth.js +63 -1
- package/dist/connect/api/client.d.ts +3 -0
- package/dist/connect/api/client.js +158 -0
- package/dist/connect/api/index.d.ts +2 -0
- package/dist/connect/api/index.js +36 -0
- package/dist/connect/api/types.d.ts +51 -0
- package/dist/connect/api/types.js +2 -0
- package/dist/connect/client.d.ts +8 -0
- package/dist/connect/{grpc_client.js → client.js} +44 -6
- package/dist/connect/config.d.ts +113 -0
- package/dist/connect/config.js +2 -0
- package/dist/connect/connect_error.d.ts +21 -0
- package/dist/connect/connect_error.js +44 -0
- package/dist/connect/index.d.ts +4 -2
- package/dist/connect/index.js +4 -2
- 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 +112 -0
- package/dist/connect/protos/agents.proto +155 -0
- package/dist/connect/protos/credentials.proto +114 -0
- package/dist/connect/protos/domains.proto +148 -0
- package/dist/connect/protos/numbers.proto +174 -0
- package/dist/connect/protos/peers.proto +173 -0
- package/dist/connect/protos/trunks.proto +178 -0
- package/dist/connect/schemas/acl.d.ts +63 -0
- package/dist/connect/schemas/acl.js +82 -0
- package/dist/connect/schemas/agent.d.ts +62 -0
- package/dist/connect/schemas/agent.js +81 -0
- package/dist/connect/schemas/crendentials.d.ts +59 -0
- package/dist/connect/schemas/crendentials.js +78 -0
- package/dist/connect/schemas/domain.d.ts +75 -0
- package/dist/connect/schemas/domain.js +94 -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 +82 -0
- package/dist/connect/schemas/number.js +101 -0
- package/dist/connect/schemas/peer.d.ts +84 -0
- package/dist/connect/schemas/peer.js +103 -0
- package/dist/connect/schemas/trunk.d.ts +119 -0
- package/dist/connect/schemas/trunk.js +151 -0
- package/dist/connect/schemas/validators.d.ts +2 -0
- package/dist/connect/schemas/validators.js +43 -0
- package/dist/connect/types.d.ts +89 -23
- package/dist/connect/types.js +17 -37
- package/dist/errors.d.ts +35 -1
- package/dist/errors.js +51 -5
- package/dist/helper.d.ts +17 -4
- package/dist/helper.js +81 -7
- package/dist/index.d.ts +5 -4
- package/dist/index.js +5 -7
- package/dist/protos/common.proto +0 -2
- package/dist/protos/location.proto +22 -7
- package/dist/protos/sipmessage.proto +2 -0
- package/dist/service.d.ts +2 -2
- package/dist/service.js +1 -1
- package/dist/types.d.ts +52 -30
- package/dist/types.js +18 -11
- package/package.json +11 -5
- package/dist/connect/data_api.d.ts +0 -11
- package/dist/connect/data_api.js +0 -91
- package/dist/connect/grpc_client.d.ts +0 -1
- package/dist/protos/resources.proto +0 -108
package/dist/index.js
CHANGED
|
@@ -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.
|
|
26
|
+
exports.ConnectSchemas = exports.CommonErrors = exports.CommonTypes = exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.Tracer = exports.IpUtils = exports.Helper = exports.Redis = exports.Auth = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.Method = exports.Transport = exports.getObjectProto = exports.createService = void 0;
|
|
27
27
|
/*
|
|
28
28
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
29
29
|
* http://github.com/fonoster/routr
|
|
@@ -42,11 +42,6 @@ exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.T
|
|
|
42
42
|
* See the License for the specific language governing permissions and
|
|
43
43
|
* limitations under the License.
|
|
44
44
|
*/
|
|
45
|
-
const auth_1 = require("./auth");
|
|
46
|
-
Object.defineProperty(exports, "calculateAuthResponse", { enumerable: true, get: function () { return auth_1.calculateAuthResponse; } });
|
|
47
|
-
Object.defineProperty(exports, "generateNonce", { enumerable: true, get: function () { return auth_1.generateNonce; } });
|
|
48
|
-
const errors_1 = require("./errors");
|
|
49
|
-
Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return errors_1.ServiceUnavailableError; } });
|
|
50
45
|
const service_1 = __importStar(require("./service"));
|
|
51
46
|
exports.createService = service_1.default;
|
|
52
47
|
Object.defineProperty(exports, "getObjectProto", { enumerable: true, get: function () { return service_1.getObjectProto; } });
|
|
@@ -55,11 +50,14 @@ Object.defineProperty(exports, "PROCESSOR_OBJECT_PROTO", { enumerable: true, get
|
|
|
55
50
|
const types_1 = require("./types");
|
|
56
51
|
Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return types_1.Method; } });
|
|
57
52
|
Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return types_1.Transport; } });
|
|
53
|
+
exports.Auth = __importStar(require("./auth"));
|
|
58
54
|
exports.Redis = __importStar(require("./redis"));
|
|
59
|
-
exports.CommonTypes = __importStar(require("./types"));
|
|
60
55
|
exports.Helper = __importStar(require("./helper"));
|
|
61
56
|
exports.IpUtils = __importStar(require("./ip_utils"));
|
|
62
57
|
exports.Tracer = __importStar(require("./tracer"));
|
|
63
58
|
exports.Assertions = __importStar(require("./assertions"));
|
|
64
59
|
exports.CommonConnect = __importStar(require("./connect"));
|
|
65
60
|
exports.CommonRequester = __importStar(require("./requester"));
|
|
61
|
+
exports.CommonTypes = __importStar(require("./types"));
|
|
62
|
+
exports.CommonErrors = __importStar(require("./errors"));
|
|
63
|
+
exports.ConnectSchemas = __importStar(require("./connect/schemas"));
|
package/dist/protos/common.proto
CHANGED
|
@@ -25,16 +25,17 @@ option java_package = "io.routr.location";
|
|
|
25
25
|
option java_outer_classname = "LocationProto";
|
|
26
26
|
option objc_class_prefix = "LC";
|
|
27
27
|
|
|
28
|
+
import "google/protobuf/empty.proto";
|
|
28
29
|
import "common.proto";
|
|
29
30
|
import "processor.proto";
|
|
30
31
|
|
|
31
32
|
service Location {
|
|
32
|
-
rpc AddRoute (AddRouteRequest) returns (
|
|
33
|
+
rpc AddRoute (AddRouteRequest) returns (.google.protobuf.Empty) {}
|
|
33
34
|
rpc FindRoutes (FindRoutesRequest) returns (FindRoutesResponse) {}
|
|
34
|
-
rpc RemoveRoutes (RemoveRoutesRequest) returns (
|
|
35
|
+
rpc RemoveRoutes (RemoveRoutesRequest) returns (.google.protobuf.Empty) {}
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
// A binding
|
|
38
|
+
// A binding created by an actual endpoint (Softphone, PBX, Conference System, etc.)
|
|
38
39
|
message Route {
|
|
39
40
|
string user = 1;
|
|
40
41
|
string host = 2;
|
|
@@ -44,11 +45,13 @@ message Route {
|
|
|
44
45
|
int32 expires = 6;
|
|
45
46
|
int32 session_count = 7;
|
|
46
47
|
string edge_port_ref = 8;
|
|
47
|
-
fonoster.routr.processor.v2draft1.NetInterface
|
|
48
|
+
repeated fonoster.routr.processor.v2draft1.NetInterface listening_points = 9;
|
|
49
|
+
repeated string localnets = 10;
|
|
50
|
+
repeated string external_addrs = 11;
|
|
48
51
|
// During route creation, an endpoint can request to add labels than can later be
|
|
49
52
|
// used as selectors. For example, a Softphone can add a label `priority=1` to indicate
|
|
50
53
|
// that it is the prefered endpoint for the given AOR.
|
|
51
|
-
map<string, string> labels =
|
|
54
|
+
map<string, string> labels = 12;
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
message AddRouteRequest {
|
|
@@ -58,8 +61,20 @@ message AddRouteRequest {
|
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
message FindRoutesRequest {
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
}
|
|
73
|
+
string call_id = 1;
|
|
74
|
+
string aor = 2;
|
|
75
|
+
string session_affinity_ref = 3;
|
|
76
|
+
Backend backend = 4;
|
|
77
|
+
map<string, string> labels = 5;
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
message FindRoutesResponse {
|
package/dist/service.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ObjectProto, ServiceInfo } from "./types";
|
|
2
|
-
import {
|
|
2
|
+
import { ServiceDefinitionNotFoundError } from "./errors";
|
|
3
3
|
export declare const PROCESSOR_OBJECT_PROTO: unknown;
|
|
4
4
|
export declare const LOCATION_OBJECT_PROTO: unknown;
|
|
5
5
|
/**
|
|
@@ -8,7 +8,7 @@ export declare const LOCATION_OBJECT_PROTO: unknown;
|
|
|
8
8
|
* @param {ObjectProt} objectProto - The object proto to load.
|
|
9
9
|
* @return {A} The proto definition.
|
|
10
10
|
*/
|
|
11
|
-
export declare function getObjectProto<A>(objectProto: ObjectProto): A |
|
|
11
|
+
export declare function getObjectProto<A>(objectProto: ObjectProto): A | ServiceDefinitionNotFoundError;
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new service using the given service definition.
|
|
14
14
|
*
|
package/dist/service.js
CHANGED
|
@@ -62,7 +62,7 @@ function getObjectProto(objectProto) {
|
|
|
62
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];
|
|
63
63
|
return (objProto === null || objProto === void 0 ? void 0 : objProto[objectProto.version])
|
|
64
64
|
? objProto[objectProto.version]
|
|
65
|
-
: new errors_1.
|
|
65
|
+
: new errors_1.ServiceDefinitionNotFoundError(objectProto.name, objectProto.version);
|
|
66
66
|
}
|
|
67
67
|
exports.getObjectProto = getObjectProto;
|
|
68
68
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import * as grpc from "@grpc/grpc-js";
|
|
1
2
|
import { ServiceDefinition } from "@grpc/proto-loader";
|
|
3
|
+
import { JsonArray, JsonValue, Struct } from "pb-util/build";
|
|
4
|
+
export type JsonData = Record<string, string | number | boolean | JsonValue | JsonArray | Struct>;
|
|
2
5
|
export declare enum Method {
|
|
3
6
|
UNKNOWN = "UNKNOWN",
|
|
4
7
|
REGISTER = "REGISTER",
|
|
@@ -13,23 +16,32 @@ export declare enum Method {
|
|
|
13
16
|
OPTIONS = "OPTIONS"
|
|
14
17
|
}
|
|
15
18
|
export declare enum Transport {
|
|
16
|
-
TCP = "
|
|
17
|
-
UDP = "
|
|
18
|
-
TLS = "
|
|
19
|
-
SCTP = "
|
|
20
|
-
WS = "
|
|
21
|
-
WSS = "
|
|
19
|
+
TCP = "TCP",
|
|
20
|
+
UDP = "UDP",
|
|
21
|
+
TLS = "TLS",
|
|
22
|
+
SCTP = "SCTP",
|
|
23
|
+
WS = "WS",
|
|
24
|
+
WSS = "WSS"
|
|
25
|
+
}
|
|
26
|
+
export declare enum LoadBalancingAlgorithm {
|
|
27
|
+
ROUND_ROBIN = "ROUND-ROBIN",
|
|
28
|
+
LEAST_SESSIONS = "LEAST-SESSIONS"
|
|
22
29
|
}
|
|
23
30
|
export declare enum ExtraHeader {
|
|
24
31
|
REQUEST_URI = "X-Request-Uri",
|
|
25
32
|
GATEWAY_AUTH = "X-Gateway-Auth",
|
|
26
33
|
EDGEPORT_REF = "X-Edgeport-Ref",
|
|
27
|
-
SESSION_COUNT = "X-Session-Count"
|
|
34
|
+
SESSION_COUNT = "X-Session-Count",
|
|
35
|
+
DOD_NUMBER = "X-DOD-Number",
|
|
36
|
+
DOD_PRIVACY = "X-DOD-Privacy"
|
|
28
37
|
}
|
|
29
38
|
export declare enum Privacy {
|
|
30
|
-
NONE = "
|
|
31
|
-
PRIVATE = "
|
|
39
|
+
NONE = "NONE",
|
|
40
|
+
PRIVATE = "ID"
|
|
32
41
|
}
|
|
42
|
+
export type AuthorizationAlgorithm = "MD5";
|
|
43
|
+
export type AuthorizationScheme = "Digest";
|
|
44
|
+
export type Qop = "auth" | "auth-int" | "";
|
|
33
45
|
export interface NetInterface {
|
|
34
46
|
host: string;
|
|
35
47
|
port: number;
|
|
@@ -72,32 +84,32 @@ export interface ObjectProto {
|
|
|
72
84
|
export interface AuthChallengeRequest {
|
|
73
85
|
realm: string;
|
|
74
86
|
domain: string;
|
|
75
|
-
scheme: string;
|
|
76
|
-
nonce: string;
|
|
77
|
-
algorithm: string;
|
|
78
|
-
qop: string;
|
|
79
87
|
opaque: string;
|
|
80
88
|
stale: boolean;
|
|
89
|
+
nonce: string;
|
|
90
|
+
scheme: AuthorizationScheme;
|
|
91
|
+
algorithm: AuthorizationAlgorithm;
|
|
92
|
+
qop: Qop;
|
|
81
93
|
}
|
|
82
94
|
export interface AuthChallengeResponse {
|
|
83
95
|
realm: string;
|
|
84
96
|
domain: string;
|
|
85
|
-
scheme: string;
|
|
86
97
|
cNonce: string;
|
|
98
|
+
nonce: string;
|
|
87
99
|
nonceCount: number;
|
|
88
100
|
response: string;
|
|
89
101
|
username: string;
|
|
90
|
-
nonce: string;
|
|
91
|
-
algorithm: string;
|
|
92
|
-
qop: string;
|
|
93
102
|
opaque: string;
|
|
94
103
|
stale: boolean;
|
|
95
104
|
uri: string;
|
|
96
|
-
method:
|
|
105
|
+
method: Method;
|
|
106
|
+
scheme: AuthorizationScheme;
|
|
107
|
+
algorithm: AuthorizationAlgorithm;
|
|
108
|
+
qop: Qop;
|
|
97
109
|
}
|
|
98
110
|
export declare enum HeaderModifierAction {
|
|
99
|
-
ADD =
|
|
100
|
-
REMOVE =
|
|
111
|
+
ADD = 0,
|
|
112
|
+
REMOVE = 1
|
|
101
113
|
}
|
|
102
114
|
export interface HeaderModifier {
|
|
103
115
|
name: string;
|
|
@@ -110,10 +122,19 @@ export interface Route {
|
|
|
110
122
|
port: number;
|
|
111
123
|
transport: Transport;
|
|
112
124
|
registeredOn?: number;
|
|
125
|
+
/**
|
|
126
|
+
* Number of active sessions. This is used to determine if a route is
|
|
127
|
+
* overloaded and for load balancing.
|
|
128
|
+
*
|
|
129
|
+
* This value is reported by the endpoint during the REGISTER request,
|
|
130
|
+
* using the X-Session-Count header.
|
|
131
|
+
*/
|
|
113
132
|
sessionCount?: number;
|
|
114
133
|
expires?: number;
|
|
115
134
|
edgePortRef: string;
|
|
116
|
-
|
|
135
|
+
listeningPoints: NetInterface[];
|
|
136
|
+
localnets: string[];
|
|
137
|
+
externalAddrs: string[];
|
|
117
138
|
labels?: Map<string, string>;
|
|
118
139
|
headers?: HeaderModifier[];
|
|
119
140
|
}
|
|
@@ -189,17 +210,17 @@ export interface WWWAuthenticate {
|
|
|
189
210
|
}
|
|
190
211
|
export interface Authorization {
|
|
191
212
|
realm: string;
|
|
192
|
-
scheme:
|
|
213
|
+
scheme: AuthorizationScheme;
|
|
193
214
|
nonce: string;
|
|
194
215
|
cNonce: string;
|
|
195
216
|
nonceCount: number;
|
|
196
217
|
response: string;
|
|
197
218
|
username: string;
|
|
198
219
|
uri: string;
|
|
199
|
-
algorithm:
|
|
200
|
-
qop:
|
|
220
|
+
algorithm: AuthorizationAlgorithm;
|
|
221
|
+
qop: Qop;
|
|
201
222
|
opaque: string;
|
|
202
|
-
method?:
|
|
223
|
+
method?: Method;
|
|
203
224
|
}
|
|
204
225
|
export interface CallID {
|
|
205
226
|
callId: string;
|
|
@@ -221,7 +242,7 @@ export interface SipURI {
|
|
|
221
242
|
user?: string;
|
|
222
243
|
host: string;
|
|
223
244
|
port?: number;
|
|
224
|
-
transportParam:
|
|
245
|
+
transportParam: Transport;
|
|
225
246
|
mAddrParam?: string;
|
|
226
247
|
userParam?: string;
|
|
227
248
|
ttlParam?: number;
|
|
@@ -281,10 +302,10 @@ export interface SIPMessage {
|
|
|
281
302
|
wwwAuthenticate?: WWWAuthenticate;
|
|
282
303
|
maxForwards: MaxForwards;
|
|
283
304
|
authorization?: Authorization;
|
|
284
|
-
extensions
|
|
285
|
-
via
|
|
286
|
-
route
|
|
287
|
-
recordRoute
|
|
305
|
+
extensions: Extension[];
|
|
306
|
+
via: Via[];
|
|
307
|
+
route: RouteHeader[];
|
|
308
|
+
recordRoute: RecordRoute[];
|
|
288
309
|
}
|
|
289
310
|
export interface GrpcCallback {
|
|
290
311
|
(error: Error | {
|
|
@@ -293,4 +314,5 @@ export interface GrpcCallback {
|
|
|
293
314
|
}
|
|
294
315
|
export interface GrpcCall {
|
|
295
316
|
request: Record<string, any>;
|
|
317
|
+
metadata?: grpc.Metadata;
|
|
296
318
|
}
|
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.Privacy = exports.ExtraHeader = exports.Transport = exports.Method = void 0;
|
|
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,29 +17,36 @@ 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";
|
|
30
35
|
ExtraHeader["GATEWAY_AUTH"] = "X-Gateway-Auth";
|
|
31
36
|
ExtraHeader["EDGEPORT_REF"] = "X-Edgeport-Ref";
|
|
32
37
|
ExtraHeader["SESSION_COUNT"] = "X-Session-Count";
|
|
38
|
+
ExtraHeader["DOD_NUMBER"] = "X-DOD-Number";
|
|
39
|
+
ExtraHeader["DOD_PRIVACY"] = "X-DOD-Privacy";
|
|
33
40
|
})(ExtraHeader = exports.ExtraHeader || (exports.ExtraHeader = {}));
|
|
34
41
|
var Privacy;
|
|
35
42
|
(function (Privacy) {
|
|
36
|
-
Privacy["NONE"] = "
|
|
37
|
-
Privacy["PRIVATE"] = "
|
|
43
|
+
Privacy["NONE"] = "NONE";
|
|
44
|
+
Privacy["PRIVATE"] = "ID";
|
|
38
45
|
})(Privacy = exports.Privacy || (exports.Privacy = {}));
|
|
39
46
|
var HeaderModifierAction;
|
|
40
47
|
(function (HeaderModifierAction) {
|
|
41
|
-
HeaderModifierAction["ADD"] = "
|
|
42
|
-
HeaderModifierAction["REMOVE"] = "
|
|
48
|
+
HeaderModifierAction[HeaderModifierAction["ADD"] = 0] = "ADD";
|
|
49
|
+
HeaderModifierAction[HeaderModifierAction["REMOVE"] = 1] = "REMOVE";
|
|
43
50
|
})(HeaderModifierAction = exports.HeaderModifierAction || (exports.HeaderModifierAction = {}));
|
|
44
51
|
var ResponseType;
|
|
45
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.20",
|
|
4
4
|
"description": "Common package",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prebuild": "rimraf ./dist tsconfig.tsbuildinfo",
|
|
12
12
|
"build": "tsc -b tsconfig.json",
|
|
13
|
-
"postbuild": "
|
|
13
|
+
"postbuild": "cp -a src/protos dist/protos && cp -a src/connect/protos dist/connect/protos"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@fonoster/logger": "0.3.18",
|
|
17
|
-
"@grpc/grpc-js": "^1.
|
|
17
|
+
"@grpc/grpc-js": "^1.8.4",
|
|
18
18
|
"@grpc/proto-loader": "^0.6.9",
|
|
19
19
|
"@opentelemetry/api": "^1.0.4",
|
|
20
20
|
"@opentelemetry/exporter-jaeger": "^1.0.4",
|
|
@@ -24,9 +24,12 @@
|
|
|
24
24
|
"@opentelemetry/sdk-trace-base": "^1.0.4",
|
|
25
25
|
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
|
26
26
|
"@opentelemetry/semantic-conventions": "^1.0.4",
|
|
27
|
+
"ajv": "^6.12.6",
|
|
27
28
|
"fp-ts": "^2.11.8",
|
|
28
29
|
"ip-utils": "^2.4.0",
|
|
29
|
-
"
|
|
30
|
+
"js-yaml": "^4.1.0",
|
|
31
|
+
"pb-util": "^1.0.3",
|
|
32
|
+
"toml": "^3.0.0"
|
|
30
33
|
},
|
|
31
34
|
"directories": {
|
|
32
35
|
"src": "src",
|
|
@@ -45,5 +48,8 @@
|
|
|
45
48
|
"bugs": {
|
|
46
49
|
"url": "https://github.com/fonoster/routr/issues"
|
|
47
50
|
},
|
|
48
|
-
"
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/js-yaml": "^4.0.5"
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "a22ee8342d03f5dfe46fddba89ffe3e6d0d5deb6"
|
|
49
55
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FindParameters, Resource } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Data API for the Connect module.
|
|
4
|
-
*
|
|
5
|
-
* @param {string} apiAddr - The address of the API server
|
|
6
|
-
* @return {Promise<Resource[]>}
|
|
7
|
-
*/
|
|
8
|
-
export declare function dataAPI(apiAddr: string): {
|
|
9
|
-
get: (ref: string) => Promise<Resource>;
|
|
10
|
-
findBy: (request: FindParameters) => Promise<Resource[]>;
|
|
11
|
-
};
|
package/dist/connect/data_api.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
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.dataAPI = 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 protobufUtil = __importStar(require("pb-util"));
|
|
47
|
-
const errors_1 = require("../errors");
|
|
48
|
-
const grpc_client_1 = require("./grpc_client");
|
|
49
|
-
const jsonToStruct = protobufUtil.struct.encode;
|
|
50
|
-
const jsonFromStruct = protobufUtil.struct.decode;
|
|
51
|
-
/**
|
|
52
|
-
* Data API for the Connect module.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} apiAddr - The address of the API server
|
|
55
|
-
* @return {Promise<Resource[]>}
|
|
56
|
-
*/
|
|
57
|
-
function dataAPI(apiAddr) {
|
|
58
|
-
const client = new grpc_client_1.RESOURCES_PROTO.v2draft1.Resources(apiAddr, grpc.credentials.createInsecure());
|
|
59
|
-
return {
|
|
60
|
-
get: (ref) => new Promise((resolve, reject) => {
|
|
61
|
-
client.get({ ref }, (err, response) => {
|
|
62
|
-
if (err) {
|
|
63
|
-
return (err === null || err === void 0 ? void 0 : err.code) === grpc.status.UNAVAILABLE
|
|
64
|
-
? reject(new errors_1.ServiceUnavailableError(`api server at ${apiAddr} is unavailable`))
|
|
65
|
-
: reject(err);
|
|
66
|
-
}
|
|
67
|
-
// Convert back to Json
|
|
68
|
-
response.spec = jsonFromStruct(response.spec);
|
|
69
|
-
resolve(response);
|
|
70
|
-
});
|
|
71
|
-
}),
|
|
72
|
-
findBy: (request) => new Promise((resolve, reject) => {
|
|
73
|
-
request.parameters = jsonToStruct(request.parameters);
|
|
74
|
-
client.findBy(request, (err, response) => {
|
|
75
|
-
var _a;
|
|
76
|
-
if (err) {
|
|
77
|
-
return (err === null || err === void 0 ? void 0 : err.code) === grpc.status.UNAVAILABLE
|
|
78
|
-
? reject(new errors_1.ServiceUnavailableError(`api server at ${apiAddr} is unavailable`))
|
|
79
|
-
: reject(err);
|
|
80
|
-
}
|
|
81
|
-
const res = (_a = response === null || response === void 0 ? void 0 : response.resources) === null || _a === void 0 ? void 0 : _a.map((resource) => {
|
|
82
|
-
// Convert back to Json
|
|
83
|
-
resource.spec = jsonFromStruct(resource.spec);
|
|
84
|
-
return resource;
|
|
85
|
-
});
|
|
86
|
-
resolve(res);
|
|
87
|
-
});
|
|
88
|
-
})
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
exports.dataAPI = dataAPI;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const RESOURCES_PROTO: any;
|
|
@@ -1,108 +0,0 @@
|
|
|
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
|
-
// The resource's name
|
|
20
|
-
string name = 1;
|
|
21
|
-
// Created at
|
|
22
|
-
int32 create_time = 2;
|
|
23
|
-
// Updated at
|
|
24
|
-
int32 update_time = 3;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
message Resource {
|
|
28
|
-
// The resource's api version
|
|
29
|
-
string apiVersion = 1;
|
|
30
|
-
// The resource's kind
|
|
31
|
-
string kind = 2;
|
|
32
|
-
// The resource's unique identifier
|
|
33
|
-
string ref = 3;
|
|
34
|
-
// The resource's metadata
|
|
35
|
-
Metadata metadata = 4;
|
|
36
|
-
// The resource's data
|
|
37
|
-
.google.protobuf.Struct spec = 5;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
message CreateRequest {
|
|
41
|
-
Metadata metadata = 1;
|
|
42
|
-
.google.protobuf.Struct spec = 2;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
message UpdateRequest {
|
|
46
|
-
Metadata metadata = 1;
|
|
47
|
-
.google.protobuf.Struct spec = 2;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
message DeleteRequest {
|
|
51
|
-
string ref = 1;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
message GetRequest {
|
|
55
|
-
string ref = 1;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
message ListRequest {
|
|
59
|
-
// The maximum number of items in the list
|
|
60
|
-
int32 page_size = 1;
|
|
61
|
-
|
|
62
|
-
// The next_page_token value returned from the previous request, if any
|
|
63
|
-
string page_token = 2;
|
|
64
|
-
|
|
65
|
-
// The filter to apply to the list
|
|
66
|
-
string filter = 3;
|
|
67
|
-
|
|
68
|
-
// The type of resource to list
|
|
69
|
-
string kind = 4;
|
|
70
|
-
|
|
71
|
-
// Level of detail of the individual entities (reserved)
|
|
72
|
-
View view = 5;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
message ListResponse {
|
|
76
|
-
// List of Resources
|
|
77
|
-
repeated Resource resources = 1;
|
|
78
|
-
|
|
79
|
-
// Token to retrieve the next page of results, or empty if there are no more results in the list
|
|
80
|
-
string next_page_token = 2;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
message FindByRequest {
|
|
84
|
-
// The type of resource to find
|
|
85
|
-
string kind = 1;
|
|
86
|
-
|
|
87
|
-
// Search criteria for the request
|
|
88
|
-
string criteria = 2;
|
|
89
|
-
|
|
90
|
-
// Parameters to apply in combination with the search criteria
|
|
91
|
-
.google.protobuf.Struct parameters = 3;
|
|
92
|
-
|
|
93
|
-
// Level of detail of the individual entities (reserved)
|
|
94
|
-
View view = 4;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
message FindByResponse {
|
|
98
|
-
// List of Resources
|
|
99
|
-
repeated Resource resources = 1;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
enum View {
|
|
103
|
-
BASIC = 0;
|
|
104
|
-
STANDARD = 1;
|
|
105
|
-
FULL = 2;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
message Empty {}
|