@routr/common 2.0.8-alpha.3 → 2.0.8-alpha.30
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/assertions.d.ts +37 -0
- package/dist/connect/assertions.js +112 -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 +7 -2
- package/dist/connect/index.js +7 -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 +26 -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 +153 -0
- package/dist/connect/protos/credentials.proto +114 -0
- package/dist/connect/protos/domains.proto +146 -0
- package/dist/connect/protos/numbers.proto +166 -0
- package/dist/connect/protos/peers.proto +174 -0
- package/dist/connect/protos/trunks.proto +178 -0
- package/dist/connect/schemas/acl.d.ts +66 -0
- package/dist/connect/schemas/acl.js +85 -0
- package/dist/connect/schemas/agent.d.ts +61 -0
- package/dist/connect/schemas/agent.js +80 -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 +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 +81 -0
- package/dist/connect/schemas/number.js +100 -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 +125 -0
- package/dist/connect/schemas/trunk.js +157 -0
- package/dist/connect/schemas/validators.d.ts +2 -0
- package/dist/connect/schemas/validators.js +43 -0
- package/dist/connect/types.d.ts +91 -23
- package/dist/connect/types.js +17 -37
- package/dist/connect/validations.d.ts +43 -0
- package/dist/connect/validations.js +272 -0
- package/dist/envs.d.ts +2 -0
- package/dist/envs.js +23 -0
- 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 +6 -4
- package/dist/index.js +6 -7
- package/dist/protos/common.proto +0 -2
- package/dist/protos/location.proto +22 -7
- package/dist/protos/processor.proto +2 -1
- package/dist/protos/sipmessage.proto +7 -0
- package/dist/service.d.ts +2 -2
- package/dist/service.js +1 -1
- package/dist/types.d.ts +118 -88
- package/dist/types.js +77 -69
- package/package.json +13 -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/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 {}
|