@routr/common 2.0.8-alpha.14 → 2.0.8-alpha.15
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/api/client.d.ts +3 -0
- package/dist/connect/api/client.js +154 -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 +55 -0
- package/dist/connect/api/types.js +2 -0
- package/dist/connect/config.d.ts +109 -0
- package/dist/connect/config.js +2 -0
- package/dist/connect/converters.d.ts +10 -0
- package/dist/connect/converters.js +176 -0
- package/dist/connect/grpc_client.d.ts +8 -1
- package/dist/connect/grpc_client.js +44 -6
- package/dist/connect/index.d.ts +3 -1
- package/dist/connect/index.js +3 -1
- package/dist/connect/protos/acl.proto +117 -0
- package/dist/connect/protos/agents.proto +154 -0
- package/dist/connect/protos/credentials.proto +116 -0
- package/dist/connect/protos/domains.proto +150 -0
- package/dist/connect/protos/numbers.proto +184 -0
- package/dist/connect/protos/peers.proto +166 -0
- package/dist/connect/protos/trunks.proto +186 -0
- package/dist/connect/schemas/acl.d.ts +1 -0
- package/dist/connect/schemas/acl.js +3 -2
- package/dist/connect/schemas/agent.d.ts +1 -0
- package/dist/connect/schemas/agent.js +5 -4
- package/dist/connect/schemas/crendentials.d.ts +1 -0
- package/dist/connect/schemas/crendentials.js +2 -1
- package/dist/connect/schemas/domain.d.ts +2 -1
- package/dist/connect/schemas/domain.js +3 -2
- package/dist/connect/schemas/number.d.ts +1 -0
- package/dist/connect/schemas/number.js +4 -3
- package/dist/connect/schemas/peer.d.ts +1 -0
- package/dist/connect/schemas/peer.js +3 -2
- package/dist/connect/schemas/trunk.d.ts +3 -0
- package/dist/connect/schemas/trunk.js +6 -3
- package/dist/connect/types.d.ts +73 -24
- package/dist/connect/types.js +6 -29
- package/dist/errors.d.ts +35 -1
- package/dist/errors.js +51 -5
- package/dist/helper.d.ts +1 -0
- package/dist/helper.js +11 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -5
- package/dist/protos/common.proto +0 -2
- package/dist/protos/location.proto +3 -2
- package/dist/service.d.ts +2 -2
- package/dist/service.js +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +3 -3
- package/dist/connect/data_api.d.ts +0 -11
- package/dist/connect/data_api.js +0 -91
- package/dist/protos/resources.proto +0 -108
|
@@ -42,7 +42,8 @@ exports.default = {
|
|
|
42
42
|
description: "Resource's friendly name",
|
|
43
43
|
type: "string"
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
},
|
|
46
|
+
required: ["name"]
|
|
46
47
|
},
|
|
47
48
|
spec: {
|
|
48
49
|
description: "Operations spec for an Peer",
|
|
@@ -79,7 +80,7 @@ exports.default = {
|
|
|
79
80
|
type: "boolean"
|
|
80
81
|
}
|
|
81
82
|
},
|
|
82
|
-
required: ["username"
|
|
83
|
+
required: ["username"]
|
|
83
84
|
}
|
|
84
85
|
},
|
|
85
86
|
required: ["apiVersion", "kind", "ref", "metadata", "spec"]
|
|
@@ -23,6 +23,7 @@ declare const _default: {
|
|
|
23
23
|
type: string;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
required: string[];
|
|
26
27
|
};
|
|
27
28
|
spec: {
|
|
28
29
|
description: string;
|
|
@@ -86,6 +87,7 @@ declare const _default: {
|
|
|
86
87
|
type: string;
|
|
87
88
|
};
|
|
88
89
|
};
|
|
90
|
+
required: string[];
|
|
89
91
|
};
|
|
90
92
|
weight: {
|
|
91
93
|
description: string;
|
|
@@ -100,6 +102,7 @@ declare const _default: {
|
|
|
100
102
|
type: string;
|
|
101
103
|
};
|
|
102
104
|
};
|
|
105
|
+
required: string[];
|
|
103
106
|
};
|
|
104
107
|
};
|
|
105
108
|
};
|
|
@@ -42,7 +42,8 @@ exports.default = {
|
|
|
42
42
|
description: "Resource's friendly name",
|
|
43
43
|
type: "string"
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
},
|
|
46
|
+
required: ["name"]
|
|
46
47
|
},
|
|
47
48
|
spec: {
|
|
48
49
|
description: "Operations spec for an Trunk",
|
|
@@ -105,7 +106,8 @@ exports.default = {
|
|
|
105
106
|
description: "Username of the URI",
|
|
106
107
|
type: "string"
|
|
107
108
|
}
|
|
108
|
-
}
|
|
109
|
+
},
|
|
110
|
+
required: ["host", "port", "transport"]
|
|
109
111
|
},
|
|
110
112
|
weight: {
|
|
111
113
|
description: "Weight of the URI",
|
|
@@ -119,7 +121,8 @@ exports.default = {
|
|
|
119
121
|
description: "Whether the URI is enabled",
|
|
120
122
|
type: "boolean"
|
|
121
123
|
}
|
|
122
|
-
}
|
|
124
|
+
},
|
|
125
|
+
required: ["uri"]
|
|
123
126
|
}
|
|
124
127
|
}
|
|
125
128
|
},
|
package/dist/connect/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JsonData, Transport } from "../types";
|
|
1
2
|
export declare enum Kind {
|
|
2
3
|
AGENT = "agent",
|
|
3
4
|
PEER = "peer",
|
|
@@ -8,31 +9,79 @@ export declare enum Kind {
|
|
|
8
9
|
CREDENTIALS = "credentials",
|
|
9
10
|
ACL = "accesscontrollist"
|
|
10
11
|
}
|
|
11
|
-
export declare enum
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
FIND_NUMBER_BY_TELURL = "find_number_by_telurl",
|
|
17
|
-
FIND_TRUNKS_WITH_SEND_REGISTER = "find_trunks_with_send_register",
|
|
18
|
-
FIND_TRUNK_BY_REQUEST_URI = "find_trunk_by_request_uri"
|
|
19
|
-
}
|
|
20
|
-
export interface FindParameters {
|
|
21
|
-
kind: Kind;
|
|
22
|
-
criteria: FindCriteria;
|
|
23
|
-
parameters: Record<string, string>;
|
|
24
|
-
}
|
|
25
|
-
export interface DataAPI {
|
|
26
|
-
get: (ref: string) => Promise<Resource>;
|
|
27
|
-
findBy: (request: FindParameters) => Promise<Resource[]>;
|
|
28
|
-
}
|
|
29
|
-
export interface Resource {
|
|
12
|
+
export declare enum APIVersion {
|
|
13
|
+
V2DRAFT1 = "v2draft1",
|
|
14
|
+
V2 = "v2"
|
|
15
|
+
}
|
|
16
|
+
export interface RoutrResourceBase {
|
|
30
17
|
apiVersion: string;
|
|
31
|
-
kind: Kind;
|
|
32
18
|
ref: string;
|
|
33
|
-
|
|
19
|
+
name: string;
|
|
20
|
+
createdAt?: Date;
|
|
21
|
+
updatedAt?: Date;
|
|
22
|
+
extended?: JsonData;
|
|
23
|
+
}
|
|
24
|
+
export interface AccessControlList extends RoutrResourceBase {
|
|
25
|
+
allow: string[];
|
|
26
|
+
deny: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface Domain extends RoutrResourceBase {
|
|
29
|
+
domainUri: string;
|
|
30
|
+
accessControlList: AccessControlList;
|
|
31
|
+
egressPolicies: EgressPolicy[];
|
|
32
|
+
}
|
|
33
|
+
export interface EgressPolicy {
|
|
34
|
+
number: INumber;
|
|
35
|
+
rule: string;
|
|
36
|
+
}
|
|
37
|
+
export interface Agent extends RoutrResourceBase {
|
|
38
|
+
username: string;
|
|
39
|
+
privacy: string;
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
domain?: Domain;
|
|
42
|
+
credentials?: Credentials;
|
|
43
|
+
}
|
|
44
|
+
export interface Credentials extends RoutrResourceBase {
|
|
45
|
+
username: string;
|
|
46
|
+
password: string;
|
|
47
|
+
}
|
|
48
|
+
export interface INumber extends RoutrResourceBase {
|
|
49
|
+
telUrl: string;
|
|
50
|
+
aorLink: string;
|
|
51
|
+
city: string;
|
|
52
|
+
country: string;
|
|
53
|
+
countryIsoCode: string;
|
|
54
|
+
sessionAffinityHeader: string;
|
|
55
|
+
extraHeaders: {
|
|
34
56
|
name: string;
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
|
|
57
|
+
value: string;
|
|
58
|
+
}[];
|
|
59
|
+
trunk?: Trunk;
|
|
60
|
+
}
|
|
61
|
+
export interface Trunk extends RoutrResourceBase {
|
|
62
|
+
sendRegister: boolean;
|
|
63
|
+
inboundUri: string;
|
|
64
|
+
accessControlList?: AccessControlList;
|
|
65
|
+
inboundCredentials?: Credentials;
|
|
66
|
+
outboundCredentials?: Credentials;
|
|
67
|
+
uris: TrunkUri[];
|
|
68
|
+
}
|
|
69
|
+
export interface TrunkUri {
|
|
70
|
+
host: string;
|
|
71
|
+
port: number;
|
|
72
|
+
transport: Transport;
|
|
73
|
+
user: string;
|
|
74
|
+
weight: number;
|
|
75
|
+
priority: number;
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface Peer extends RoutrResourceBase {
|
|
79
|
+
username: string;
|
|
80
|
+
aor: string;
|
|
81
|
+
contactAddr: string;
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
accessControlList?: AccessControlList;
|
|
84
|
+
credentials?: Credentials;
|
|
38
85
|
}
|
|
86
|
+
export type RoutrResourceUnion = Agent | Peer | INumber | Trunk | Domain | Credentials | AccessControlList;
|
|
87
|
+
export type RoutableResourceUnion = Agent | Peer | INumber;
|
package/dist/connect/types.js
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (C) 2022 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
|
-
*/
|
|
3
|
+
exports.APIVersion = exports.Kind = void 0;
|
|
22
4
|
var Kind;
|
|
23
5
|
(function (Kind) {
|
|
24
6
|
Kind["AGENT"] = "agent";
|
|
@@ -30,13 +12,8 @@ var Kind;
|
|
|
30
12
|
Kind["CREDENTIALS"] = "credentials";
|
|
31
13
|
Kind["ACL"] = "accesscontrollist";
|
|
32
14
|
})(Kind = exports.Kind || (exports.Kind = {}));
|
|
33
|
-
var
|
|
34
|
-
(function (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
FindCriteria["FIND_DOMAIN_BY_DOMAINURI"] = "find_domain_by_domainuri";
|
|
39
|
-
FindCriteria["FIND_NUMBER_BY_TELURL"] = "find_number_by_telurl";
|
|
40
|
-
FindCriteria["FIND_TRUNKS_WITH_SEND_REGISTER"] = "find_trunks_with_send_register";
|
|
41
|
-
FindCriteria["FIND_TRUNK_BY_REQUEST_URI"] = "find_trunk_by_request_uri";
|
|
42
|
-
})(FindCriteria = exports.FindCriteria || (exports.FindCriteria = {}));
|
|
15
|
+
var APIVersion;
|
|
16
|
+
(function (APIVersion) {
|
|
17
|
+
APIVersion["V2DRAFT1"] = "v2draft1";
|
|
18
|
+
APIVersion["V2"] = "v2";
|
|
19
|
+
})(APIVersion = exports.APIVersion || (exports.APIVersion = {}));
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error thrown if the definition for a service is not found.
|
|
3
3
|
*/
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class ServiceDefinitionNotFoundError extends Error {
|
|
5
5
|
/**
|
|
6
6
|
* Constructs a new ServiceDefinitionNotFound error.
|
|
7
7
|
*
|
|
@@ -22,3 +22,37 @@ export declare class ServiceUnavailableError extends Error {
|
|
|
22
22
|
*/
|
|
23
23
|
constructor(address: string);
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Thrown for unimplemented handlers.
|
|
27
|
+
*/
|
|
28
|
+
export declare class UnimplementedError extends Error {
|
|
29
|
+
code: number;
|
|
30
|
+
/**
|
|
31
|
+
* Creates an instance of UnimplementedError.
|
|
32
|
+
*/
|
|
33
|
+
constructor();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Thrown if the resource is not found.
|
|
37
|
+
*/
|
|
38
|
+
export declare class ResourceNotFoundError extends Error {
|
|
39
|
+
code: number;
|
|
40
|
+
/**
|
|
41
|
+
* Creates an instance of UnimplementedError.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} ref - the reference of the resource
|
|
44
|
+
*/
|
|
45
|
+
constructor(ref: string);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Thrown if the request is invalid.
|
|
49
|
+
*/
|
|
50
|
+
export declare class BadRequestError extends Error {
|
|
51
|
+
code: number;
|
|
52
|
+
/**
|
|
53
|
+
* Creates an instance of UnimplementedError.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} message - optional message with the error. Defaults to "bad request."
|
|
56
|
+
*/
|
|
57
|
+
constructor(message?: string);
|
|
58
|
+
}
|
package/dist/errors.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.ServiceUnavailableError = exports.
|
|
26
|
+
exports.BadRequestError = exports.ResourceNotFoundError = exports.UnimplementedError = exports.ServiceUnavailableError = exports.ServiceDefinitionNotFoundError = void 0;
|
|
27
27
|
/*
|
|
28
28
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
29
29
|
* http://github.com/fonoster/routr
|
|
@@ -46,7 +46,7 @@ const grpc = __importStar(require("@grpc/grpc-js"));
|
|
|
46
46
|
/**
|
|
47
47
|
* Error thrown if the definition for a service is not found.
|
|
48
48
|
*/
|
|
49
|
-
class
|
|
49
|
+
class ServiceDefinitionNotFoundError extends Error {
|
|
50
50
|
/**
|
|
51
51
|
* Constructs a new ServiceDefinitionNotFound error.
|
|
52
52
|
*
|
|
@@ -54,12 +54,12 @@ class ServiceDefinitionNotFound extends Error {
|
|
|
54
54
|
* @param {string} version - The version of the service definition.
|
|
55
55
|
*/
|
|
56
56
|
constructor(name, version) {
|
|
57
|
-
super(`
|
|
57
|
+
super(`service definition for ${name}/${version} not found`);
|
|
58
58
|
// Set the prototype explicitly.
|
|
59
|
-
Object.setPrototypeOf(this,
|
|
59
|
+
Object.setPrototypeOf(this, ServiceDefinitionNotFoundError.prototype);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
exports.
|
|
62
|
+
exports.ServiceDefinitionNotFoundError = ServiceDefinitionNotFoundError;
|
|
63
63
|
/**
|
|
64
64
|
* Error thrown if the service is not available.
|
|
65
65
|
*/
|
|
@@ -76,3 +76,49 @@ class ServiceUnavailableError extends Error {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
79
|
+
/**
|
|
80
|
+
* Thrown for unimplemented handlers.
|
|
81
|
+
*/
|
|
82
|
+
class UnimplementedError extends Error {
|
|
83
|
+
/**
|
|
84
|
+
* Creates an instance of UnimplementedError.
|
|
85
|
+
*/
|
|
86
|
+
constructor() {
|
|
87
|
+
super("this operation is not supported/enabled in this data api implementation.");
|
|
88
|
+
this.code = grpc.status.UNIMPLEMENTED;
|
|
89
|
+
Object.setPrototypeOf(this, UnimplementedError.prototype);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.UnimplementedError = UnimplementedError;
|
|
93
|
+
/**
|
|
94
|
+
* Thrown if the resource is not found.
|
|
95
|
+
*/
|
|
96
|
+
class ResourceNotFoundError extends Error {
|
|
97
|
+
/**
|
|
98
|
+
* Creates an instance of UnimplementedError.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} ref - the reference of the resource
|
|
101
|
+
*/
|
|
102
|
+
constructor(ref) {
|
|
103
|
+
super(`resource not found: ${ref}`);
|
|
104
|
+
this.code = grpc.status.NOT_FOUND;
|
|
105
|
+
Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.ResourceNotFoundError = ResourceNotFoundError;
|
|
109
|
+
/**
|
|
110
|
+
* Thrown if the request is invalid.
|
|
111
|
+
*/
|
|
112
|
+
class BadRequestError extends Error {
|
|
113
|
+
/**
|
|
114
|
+
* Creates an instance of UnimplementedError.
|
|
115
|
+
*
|
|
116
|
+
* @param {string} message - optional message with the error. Defaults to "bad request."
|
|
117
|
+
*/
|
|
118
|
+
constructor(message) {
|
|
119
|
+
super(message !== null && message !== void 0 ? message : "bad request");
|
|
120
|
+
this.code = grpc.status.INVALID_ARGUMENT;
|
|
121
|
+
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.BadRequestError = BadRequestError;
|
package/dist/helper.d.ts
CHANGED
|
@@ -26,3 +26,4 @@ export declare const getListeningPoint: (listeningPoints: NetInterface[], transp
|
|
|
26
26
|
* @throws {Error} If the file is empty.
|
|
27
27
|
*/
|
|
28
28
|
export declare const readConfigFile: (path: string) => Record<string, any>;
|
|
29
|
+
export declare const toPascaleCase: (str: string) => string;
|
package/dist/helper.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.readConfigFile = exports.getListeningPoint = exports.deepCopy = void 0;
|
|
29
|
+
exports.toPascaleCase = exports.readConfigFile = exports.getListeningPoint = exports.deepCopy = void 0;
|
|
30
30
|
/*
|
|
31
31
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
32
32
|
* http://github.com/fonoster/routr
|
|
@@ -45,10 +45,10 @@ exports.readConfigFile = exports.getListeningPoint = exports.deepCopy = void 0;
|
|
|
45
45
|
* See the License for the specific language governing permissions and
|
|
46
46
|
* limitations under the License.
|
|
47
47
|
*/
|
|
48
|
-
const types_1 = require("./types");
|
|
49
|
-
const fs_1 = __importDefault(require("fs"));
|
|
50
48
|
const yaml = __importStar(require("js-yaml"));
|
|
51
49
|
const toml = __importStar(require("toml"));
|
|
50
|
+
const fs_1 = __importDefault(require("fs"));
|
|
51
|
+
const types_1 = require("./types");
|
|
52
52
|
/**
|
|
53
53
|
* Makes a deep copy of an object.
|
|
54
54
|
*
|
|
@@ -124,3 +124,11 @@ const readConfigFile = (path) => {
|
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
exports.readConfigFile = readConfigFile;
|
|
127
|
+
const toPascaleCase = (str) => {
|
|
128
|
+
return str
|
|
129
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => {
|
|
130
|
+
return index === 0 ? word.toUpperCase() : word.toUpperCase();
|
|
131
|
+
})
|
|
132
|
+
.replace(/\s+/g, "");
|
|
133
|
+
};
|
|
134
|
+
exports.toPascaleCase = toPascaleCase;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ServiceUnavailableError } from "./errors";
|
|
2
1
|
import createService, { getObjectProto, LOCATION_OBJECT_PROTO, PROCESSOR_OBJECT_PROTO } from "./service";
|
|
3
2
|
import { HeaderModifier, MessageRequest, MessageResponse, Method, NetInterface, ObjectProto, ProcessorConfig, Route, ServiceInfo, Transport } from "./types";
|
|
4
|
-
export { createService, getObjectProto, HeaderModifier, Route,
|
|
3
|
+
export { createService, getObjectProto, HeaderModifier, Route, Transport, ProcessorConfig, MessageRequest, MessageResponse, NetInterface, Method, ObjectProto, ServiceInfo, PROCESSOR_OBJECT_PROTO, LOCATION_OBJECT_PROTO };
|
|
4
|
+
export * as Auth from "./auth";
|
|
5
5
|
export * as Redis from "./redis";
|
|
6
|
-
export * as CommonTypes from "./types";
|
|
7
6
|
export * as Helper from "./helper";
|
|
8
7
|
export * as IpUtils from "./ip_utils";
|
|
9
8
|
export * as Tracer from "./tracer";
|
|
10
9
|
export * as Assertions from "./assertions";
|
|
11
10
|
export * as CommonConnect from "./connect";
|
|
12
11
|
export * as CommonRequester from "./requester";
|
|
13
|
-
export * as
|
|
12
|
+
export * as CommonTypes from "./types";
|
|
13
|
+
export * as CommonErrors from "./errors";
|
|
14
14
|
export * as ConnectSchemas from "./connect/schemas";
|
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.ConnectSchemas = 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,8 +42,6 @@ exports.ConnectSchemas = exports.Auth = exports.CommonRequester = exports.Common
|
|
|
42
42
|
* See the License for the specific language governing permissions and
|
|
43
43
|
* limitations under the License.
|
|
44
44
|
*/
|
|
45
|
-
const errors_1 = require("./errors");
|
|
46
|
-
Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return errors_1.ServiceUnavailableError; } });
|
|
47
45
|
const service_1 = __importStar(require("./service"));
|
|
48
46
|
exports.createService = service_1.default;
|
|
49
47
|
Object.defineProperty(exports, "getObjectProto", { enumerable: true, get: function () { return service_1.getObjectProto; } });
|
|
@@ -52,13 +50,14 @@ Object.defineProperty(exports, "PROCESSOR_OBJECT_PROTO", { enumerable: true, get
|
|
|
52
50
|
const types_1 = require("./types");
|
|
53
51
|
Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return types_1.Method; } });
|
|
54
52
|
Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return types_1.Transport; } });
|
|
53
|
+
exports.Auth = __importStar(require("./auth"));
|
|
55
54
|
exports.Redis = __importStar(require("./redis"));
|
|
56
|
-
exports.CommonTypes = __importStar(require("./types"));
|
|
57
55
|
exports.Helper = __importStar(require("./helper"));
|
|
58
56
|
exports.IpUtils = __importStar(require("./ip_utils"));
|
|
59
57
|
exports.Tracer = __importStar(require("./tracer"));
|
|
60
58
|
exports.Assertions = __importStar(require("./assertions"));
|
|
61
59
|
exports.CommonConnect = __importStar(require("./connect"));
|
|
62
60
|
exports.CommonRequester = __importStar(require("./requester"));
|
|
63
|
-
exports.
|
|
61
|
+
exports.CommonTypes = __importStar(require("./types"));
|
|
62
|
+
exports.CommonErrors = __importStar(require("./errors"));
|
|
64
63
|
exports.ConnectSchemas = __importStar(require("./connect/schemas"));
|
package/dist/protos/common.proto
CHANGED
|
@@ -25,13 +25,14 @@ 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
38
|
// A binding created by an actual endpoint (Softphone, PBX, Conference System, etc.)
|
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,6 @@
|
|
|
1
1
|
import { ServiceDefinition } from "@grpc/proto-loader";
|
|
2
|
+
import { JsonArray, JsonValue, Struct } from "pb-util/build";
|
|
3
|
+
export type JsonData = Record<string, string | number | boolean | JsonValue | JsonArray | Struct>;
|
|
2
4
|
export declare enum Method {
|
|
3
5
|
UNKNOWN = "UNKNOWN",
|
|
4
6
|
REGISTER = "REGISTER",
|
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.15",
|
|
4
4
|
"description": "Common package",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -10,7 +10,7 @@
|
|
|
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",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/js-yaml": "^4.0.5"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "713d176551252a157b5a7693ef8dba4e3e798dea"
|
|
54
54
|
}
|
|
@@ -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.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.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;
|