@routr/common 2.0.8-alpha.17 → 2.0.8-alpha.19

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.
Files changed (54) hide show
  1. package/dist/auth.d.ts +2 -2
  2. package/dist/connect/api/client.js +8 -10
  3. package/dist/connect/api/types.d.ts +4 -4
  4. package/dist/connect/config.d.ts +10 -6
  5. package/dist/connect/grpc_client.d.ts +2 -2
  6. package/dist/connect/index.d.ts +1 -1
  7. package/dist/connect/index.js +1 -1
  8. package/dist/connect/mappers/acl.d.ts +3 -0
  9. package/dist/connect/mappers/acl.js +19 -0
  10. package/dist/connect/mappers/agent.d.ts +3 -0
  11. package/dist/connect/mappers/agent.js +42 -0
  12. package/dist/connect/mappers/assertions.d.ts +3 -0
  13. package/dist/connect/mappers/assertions.js +43 -0
  14. package/dist/connect/mappers/credentials.d.ts +3 -0
  15. package/dist/connect/mappers/credentials.js +18 -0
  16. package/dist/connect/mappers/domain.d.ts +3 -0
  17. package/dist/connect/mappers/domain.js +19 -0
  18. package/dist/connect/mappers/index.d.ts +7 -0
  19. package/dist/connect/mappers/index.js +41 -0
  20. package/dist/connect/mappers/number.d.ts +3 -0
  21. package/dist/connect/mappers/number.js +26 -0
  22. package/dist/connect/mappers/peer.d.ts +3 -0
  23. package/dist/connect/mappers/peer.js +25 -0
  24. package/dist/connect/mappers/trunk.d.ts +3 -0
  25. package/dist/connect/mappers/trunk.js +34 -0
  26. package/dist/connect/protos/acl.proto +11 -16
  27. package/dist/connect/protos/agents.proto +19 -23
  28. package/dist/connect/protos/credentials.proto +8 -10
  29. package/dist/connect/protos/domains.proto +16 -18
  30. package/dist/connect/protos/numbers.proto +15 -25
  31. package/dist/connect/protos/peers.proto +46 -39
  32. package/dist/connect/protos/trunks.proto +16 -24
  33. package/dist/connect/schemas/acl.d.ts +2 -0
  34. package/dist/connect/schemas/acl.js +4 -2
  35. package/dist/connect/schemas/agent.d.ts +2 -0
  36. package/dist/connect/schemas/agent.js +6 -4
  37. package/dist/connect/schemas/crendentials.d.ts +4 -0
  38. package/dist/connect/schemas/crendentials.js +7 -3
  39. package/dist/connect/schemas/domain.d.ts +2 -0
  40. package/dist/connect/schemas/domain.js +4 -2
  41. package/dist/connect/schemas/number.d.ts +4 -0
  42. package/dist/connect/schemas/number.js +7 -3
  43. package/dist/connect/schemas/peer.d.ts +16 -0
  44. package/dist/connect/schemas/peer.js +19 -3
  45. package/dist/connect/schemas/trunk.d.ts +3 -0
  46. package/dist/connect/schemas/trunk.js +20 -4
  47. package/dist/connect/types.d.ts +20 -6
  48. package/dist/helper.js +2 -2
  49. package/dist/protos/location.proto +11 -1
  50. package/dist/types.d.ts +18 -22
  51. package/dist/types.js +16 -25
  52. package/package.json +2 -2
  53. package/dist/connect/converters.d.ts +0 -10
  54. package/dist/connect/converters.js +0 -178
package/dist/auth.d.ts CHANGED
@@ -2,8 +2,8 @@ import { AuthChallengeRequest, AuthChallengeResponse, ResponseType } from "./typ
2
2
  export declare const generateNonce: (algorithm?: string) => string;
3
3
  export declare const buildAuthChallenge: (request: AuthChallengeRequest) => {
4
4
  realm: string;
5
- scheme: import("./types").AuthorizationScheme;
6
- algorithm: import("./types").AuthorizationAlgorithm;
5
+ scheme: "Digest";
6
+ algorithm: "MD5";
7
7
  qop: import("./types").Qop;
8
8
  opaque: string;
9
9
  stale: boolean;
@@ -44,12 +44,10 @@ exports.serviceAPI = exports.apiClient = void 0;
44
44
  */
45
45
  /* eslint-disable require-jsdoc */
46
46
  const grpc = __importStar(require("@grpc/grpc-js"));
47
- const protobufUtil = __importStar(require("pb-util"));
47
+ const pb_util_1 = require("pb-util");
48
48
  const errors_1 = require("../../errors");
49
49
  const grpc_client_1 = require("../grpc_client");
50
50
  const types_1 = require("../types");
51
- const jsonToStruct = protobufUtil.struct.encode;
52
- const structToJson = protobufUtil.struct.decode;
53
51
  function fire(err, apiAddr) {
54
52
  if (err.code === grpc.status.UNAVAILABLE) {
55
53
  return new errors_1.ServiceUnavailableError(`api server at ${apiAddr} is unavailable`);
@@ -79,28 +77,28 @@ function serviceAPI(options) {
79
77
  return {
80
78
  create: (request) => new Promise((resolve, reject) => {
81
79
  if (request.extended) {
82
- request.extended = jsonToStruct(request.extended);
80
+ request.extended = pb_util_1.struct.encode(request.extended);
83
81
  }
84
82
  client.create(request, (err, response) => {
85
83
  if (err) {
86
84
  return reject(fire(err, apiAddr));
87
85
  }
88
86
  if (response.extended) {
89
- response.extended = structToJson(response.extended);
87
+ response.extended = pb_util_1.struct.decode(response.extended);
90
88
  }
91
89
  resolve(response);
92
90
  });
93
91
  }),
94
92
  update: (request) => new Promise((resolve, reject) => {
95
93
  if (request.extended) {
96
- request.extended = jsonToStruct(request.extended);
94
+ request.extended = pb_util_1.struct.encode(request.extended);
97
95
  }
98
96
  client.update(request, (err, response) => {
99
97
  if (err) {
100
98
  return reject(fire(err, apiAddr));
101
99
  }
102
100
  if (response.extended) {
103
- response.extended = structToJson(response.extended);
101
+ response.extended = pb_util_1.struct.decode(response.extended);
104
102
  }
105
103
  resolve(response);
106
104
  });
@@ -111,7 +109,7 @@ function serviceAPI(options) {
111
109
  return reject(fire(err, apiAddr));
112
110
  }
113
111
  if (response.extended) {
114
- response.extended = structToJson(response.extended);
112
+ response.extended = pb_util_1.struct.decode(response.extended);
115
113
  }
116
114
  resolve(response);
117
115
  });
@@ -124,7 +122,7 @@ function serviceAPI(options) {
124
122
  }
125
123
  response.items.forEach((item) => {
126
124
  if (item.extended) {
127
- item.extended = structToJson(item.extended);
125
+ item.extended = pb_util_1.struct.decode(item.extended);
128
126
  }
129
127
  });
130
128
  resolve({
@@ -140,7 +138,7 @@ function serviceAPI(options) {
140
138
  }
141
139
  response.items.forEach((item) => {
142
140
  if (item.extended) {
143
- item.extended = structToJson(item.extended);
141
+ item.extended = pb_util_1.struct.decode(item.extended);
144
142
  }
145
143
  });
146
144
  resolve(response);
@@ -1,5 +1,5 @@
1
1
  import * as grpc from "@grpc/grpc-js";
2
- import { JsonData } from "../../types";
2
+ import { JsonObject } from "pb-util/build";
3
3
  import { AccessControlList, Agent, Credentials, Domain, INumber, Kind, Peer, Trunk } from "../types";
4
4
  export interface DataAPIOptions {
5
5
  apiAddr: string;
@@ -35,10 +35,10 @@ export type APIClient = {
35
35
  numbers: ServiceAPI<INumber>;
36
36
  };
37
37
  export type ServiceAPI<R extends {
38
- extended?: JsonData;
38
+ extended?: JsonObject;
39
39
  }> = {
40
- create: (request: JsonData) => Promise<R>;
41
- update: (request: JsonData) => Promise<R>;
40
+ create: (request: JsonObject) => Promise<R>;
41
+ update: (request: JsonObject) => Promise<R>;
42
42
  get: (ref: string) => Promise<R>;
43
43
  del: (ref: string) => Promise<void>;
44
44
  list: (request: {
@@ -1,4 +1,4 @@
1
- import { Privacy, Transport } from "../types";
1
+ import { LoadBalancingAlgorithm, Privacy, Transport } from "../types";
2
2
  import { Kind } from "./types";
3
3
  export interface ConfigBase {
4
4
  apiVersion: string;
@@ -31,9 +31,13 @@ export interface PeerConfig extends ConfigBase {
31
31
  spec: {
32
32
  aor: string;
33
33
  username: string;
34
- credentialsRef: string;
35
- contactAddr: string;
36
- enabled: boolean;
34
+ credentialsRef?: string;
35
+ contactAddr?: string;
36
+ enabled?: boolean;
37
+ loadBalancing?: {
38
+ algorithm: LoadBalancingAlgorithm;
39
+ withSessionAffinity: boolean;
40
+ };
37
41
  };
38
42
  }
39
43
  export interface CredentialsConfig extends ConfigBase {
@@ -48,10 +52,10 @@ export interface CredentialsConfig extends ConfigBase {
48
52
  export interface DomainConfig extends ConfigBase {
49
53
  kind: Kind.DOMAIN;
50
54
  spec: {
51
- accessControlListRef: string;
55
+ accessControlListRef?: string;
52
56
  context: {
53
57
  domainUri: string;
54
- egressPolicies: {
58
+ egressPolicies?: {
55
59
  rule: string;
56
60
  numberRef: string;
57
61
  }[];
@@ -1,8 +1,8 @@
1
1
  import * as grpc from "@grpc/grpc-js";
2
- import { Kind } from "./types";
2
+ import { Kind, KindWithoutUnknown } from "./types";
3
3
  export declare function createClient(options: {
4
4
  kind: Kind;
5
5
  credentials: grpc.ChannelCredentials;
6
6
  apiAddr: string;
7
7
  }): any;
8
- export declare function createService(kind: Kind): any;
8
+ export declare function createService(kind: KindWithoutUnknown): any;
@@ -2,4 +2,4 @@ export * from "./api";
2
2
  export * from "./grpc_client";
3
3
  export * from "./types";
4
4
  export * from "./config";
5
- export * from "./converters";
5
+ export * from "./mappers";
@@ -36,4 +36,4 @@ __exportStar(require("./api"), exports);
36
36
  __exportStar(require("./grpc_client"), exports);
37
37
  __exportStar(require("./types"), exports);
38
38
  __exportStar(require("./config"), exports);
39
- __exportStar(require("./converters"), exports);
39
+ __exportStar(require("./mappers"), exports);
@@ -0,0 +1,3 @@
1
+ import { AccessControlListConfig } from "../config";
2
+ import { AccessControlList } from "../types";
3
+ export declare function mapToACL(config: AccessControlListConfig): AccessControlList;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapToACL = void 0;
4
+ const schemas_1 = require("../schemas");
5
+ const types_1 = require("../types");
6
+ const assertions_1 = require("./assertions");
7
+ const valid = schemas_1.schemaValidators.get(types_1.Kind.ACL);
8
+ function mapToACL(config) {
9
+ var _a, _b, _c, _d;
10
+ (0, assertions_1.assertValidSchema)(config, valid);
11
+ return {
12
+ apiVersion: config.apiVersion,
13
+ ref: config.ref,
14
+ name: config.metadata.name,
15
+ allow: (_b = (_a = config.spec.accessControlList) === null || _a === void 0 ? void 0 : _a.allow) !== null && _b !== void 0 ? _b : [],
16
+ deny: (_d = (_c = config.spec.accessControlList) === null || _c === void 0 ? void 0 : _c.deny) !== null && _d !== void 0 ? _d : []
17
+ };
18
+ }
19
+ exports.mapToACL = mapToACL;
@@ -0,0 +1,3 @@
1
+ import { AgentConfig } from "../config";
2
+ import { Agent } from "../types";
3
+ export declare function mapToAgent(config: AgentConfig): Agent;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapToAgent = void 0;
4
+ /*
5
+ * Copyright (C) 2023 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
+ */
22
+ /* eslint-disable require-jsdoc */
23
+ const types_1 = require("../../types");
24
+ const schemas_1 = require("../schemas");
25
+ const types_2 = require("../types");
26
+ const assertions_1 = require("./assertions");
27
+ const valid = schemas_1.schemaValidators.get(types_2.Kind.AGENT);
28
+ function mapToAgent(config) {
29
+ var _a;
30
+ (0, assertions_1.assertValidSchema)(config, valid);
31
+ return {
32
+ apiVersion: config.apiVersion,
33
+ ref: config.ref,
34
+ name: config.metadata.name,
35
+ username: config.spec.username,
36
+ privacy: (_a = config.spec.privacy) !== null && _a !== void 0 ? _a : types_1.Privacy.NONE,
37
+ enabled: config.spec.enabled,
38
+ domainRef: config.spec.domainRef,
39
+ credentialsRef: config.spec.credentialsRef
40
+ };
41
+ }
42
+ exports.mapToAgent = mapToAgent;
@@ -0,0 +1,3 @@
1
+ import { UserConfig } from "../config";
2
+ export declare const assertValidSchema: (config: UserConfig, valid: (config: UserConfig) => boolean) => void;
3
+ export declare const assertValidAorSchema: (config: UserConfig) => void;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertValidAorSchema = exports.assertValidSchema = void 0;
4
+ /*
5
+ * Copyright (C) 2023 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
+ */
22
+ const logger_1 = require("@fonoster/logger");
23
+ const logger = (0, logger_1.getLogger)({ service: "common", filePath: __filename });
24
+ const assertValidSchema = (config, valid) => {
25
+ if (!valid(config)) {
26
+ const error = valid.errors[0];
27
+ logger.error("found a bad resource: " + error.message + " at `" + error.dataPath + "`");
28
+ process.exit(1);
29
+ }
30
+ };
31
+ exports.assertValidSchema = assertValidSchema;
32
+ const assertValidAorSchema = (config) => {
33
+ const spec = config.spec;
34
+ if (spec.aor.startsWith("backend:") && !spec.loadBalancing) {
35
+ logger.error("found a bad resource: balancing algorithm is required for `backend:` aors");
36
+ process.exit(1);
37
+ }
38
+ if (spec.aor.startsWith("sip:") && spec.loadBalancing) {
39
+ logger.error("found a bad resource: balancing algorithm is not allowed for `sip:` aors");
40
+ process.exit(1);
41
+ }
42
+ };
43
+ exports.assertValidAorSchema = assertValidAorSchema;
@@ -0,0 +1,3 @@
1
+ import { CredentialsConfig } from "../config";
2
+ import { Credentials } from "../types";
3
+ export declare function mapToCredentials(config: CredentialsConfig): Credentials;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapToCredentials = void 0;
4
+ const schemas_1 = require("../schemas");
5
+ const types_1 = require("../types");
6
+ const assertions_1 = require("./assertions");
7
+ const valid = schemas_1.schemaValidators.get(types_1.Kind.CREDENTIALS);
8
+ function mapToCredentials(config) {
9
+ (0, assertions_1.assertValidSchema)(config, valid);
10
+ return {
11
+ apiVersion: config.apiVersion,
12
+ ref: config.ref,
13
+ name: config.metadata.name,
14
+ username: config.spec.credentials.username,
15
+ password: config.spec.credentials.password
16
+ };
17
+ }
18
+ exports.mapToCredentials = mapToCredentials;
@@ -0,0 +1,3 @@
1
+ import { DomainConfig } from "../config";
2
+ import { Domain } from "../types";
3
+ export declare function mapToDomain(config: DomainConfig): Domain;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapToDomain = void 0;
4
+ const schemas_1 = require("../schemas");
5
+ const types_1 = require("../types");
6
+ const assertions_1 = require("./assertions");
7
+ const valid = schemas_1.schemaValidators.get(types_1.Kind.DOMAIN);
8
+ function mapToDomain(config) {
9
+ (0, assertions_1.assertValidSchema)(config, valid);
10
+ return {
11
+ apiVersion: config.apiVersion,
12
+ ref: config.ref,
13
+ name: config.metadata.name,
14
+ domainUri: config.spec.context.domainUri,
15
+ accessControlListRef: config.spec.accessControlListRef,
16
+ egressPolicies: config.spec.context.egressPolicies
17
+ };
18
+ }
19
+ exports.mapToDomain = mapToDomain;
@@ -0,0 +1,7 @@
1
+ export * from "./acl";
2
+ export * from "./agent";
3
+ export * from "./credentials";
4
+ export * from "./trunk";
5
+ export * from "./number";
6
+ export * from "./peer";
7
+ export * from "./domain";
@@ -0,0 +1,41 @@
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) 2023 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("./acl"), exports);
36
+ __exportStar(require("./agent"), exports);
37
+ __exportStar(require("./credentials"), exports);
38
+ __exportStar(require("./trunk"), exports);
39
+ __exportStar(require("./number"), exports);
40
+ __exportStar(require("./peer"), exports);
41
+ __exportStar(require("./domain"), exports);
@@ -0,0 +1,3 @@
1
+ import { NumberConfig } from "../config";
2
+ import { INumber } from "../types";
3
+ export declare function mapToNumber(config: NumberConfig): INumber;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapToNumber = void 0;
4
+ const schemas_1 = require("../schemas");
5
+ const types_1 = require("../types");
6
+ const assertions_1 = require("./assertions");
7
+ const valid = schemas_1.schemaValidators.get(types_1.Kind.NUMBER);
8
+ function mapToNumber(config) {
9
+ (0, assertions_1.assertValidSchema)(config, valid);
10
+ const metadata = config.metadata;
11
+ const location = config.spec.location;
12
+ return {
13
+ apiVersion: config.apiVersion,
14
+ ref: config.ref,
15
+ name: metadata.name,
16
+ city: metadata.geoInfo.city,
17
+ country: metadata.geoInfo.country,
18
+ countryISOCode: metadata.geoInfo.countryISOCode,
19
+ telUrl: location.telUrl,
20
+ aorLink: location.aorLink,
21
+ sessionAffinityHeader: location.sessionAffinityHeader,
22
+ extraHeaders: location.extraHeaders,
23
+ trunkRef: config.spec.trunkRef
24
+ };
25
+ }
26
+ exports.mapToNumber = mapToNumber;
@@ -0,0 +1,3 @@
1
+ import { PeerConfig } from "../config";
2
+ import { Peer } from "../types";
3
+ export declare function mapToPeer(config: PeerConfig): Peer;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapToPeer = void 0;
4
+ const schemas_1 = require("../schemas");
5
+ const types_1 = require("../types");
6
+ const assertions_1 = require("./assertions");
7
+ const valid = schemas_1.schemaValidators.get(types_1.Kind.PEER);
8
+ function mapToPeer(config) {
9
+ var _a, _b;
10
+ (0, assertions_1.assertValidSchema)(config, valid);
11
+ (0, assertions_1.assertValidAorSchema)(config);
12
+ return {
13
+ apiVersion: config.apiVersion,
14
+ ref: config.ref,
15
+ name: config.metadata.name,
16
+ username: config.spec.username,
17
+ aor: config.spec.aor,
18
+ contactAddr: config.spec.contactAddr,
19
+ enabled: config.spec.enabled,
20
+ credentialsRef: config.spec.credentialsRef,
21
+ balancingAlgorithm: (_a = config.spec.loadBalancing) === null || _a === void 0 ? void 0 : _a.algorithm.toUpperCase(),
22
+ withSessionAffinity: (_b = config.spec.loadBalancing) === null || _b === void 0 ? void 0 : _b.withSessionAffinity
23
+ };
24
+ }
25
+ exports.mapToPeer = mapToPeer;
@@ -0,0 +1,3 @@
1
+ import { TrunkConfig } from "../config";
2
+ import { Trunk } from "../types";
3
+ export declare function mapToTrunk(config: TrunkConfig): Trunk;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapToTrunk = void 0;
4
+ const schemas_1 = require("../schemas");
5
+ const types_1 = require("../types");
6
+ const assertions_1 = require("./assertions");
7
+ const valid = schemas_1.schemaValidators.get(types_1.Kind.TRUNK);
8
+ function mapToTrunk(config) {
9
+ var _a, _b, _c, _d, _e, _f;
10
+ (0, assertions_1.assertValidSchema)(config, valid);
11
+ return {
12
+ apiVersion: config.apiVersion,
13
+ ref: config.ref,
14
+ name: config.metadata.name,
15
+ sendRegister: config.spec.outbound.sendRegister,
16
+ inboundUri: (_a = config.spec.inbound) === null || _a === void 0 ? void 0 : _a.uri,
17
+ inboundCredentialsRef: (_b = config.spec.inbound) === null || _b === void 0 ? void 0 : _b.credentialsRef,
18
+ outboundCredentialsRef: (_c = config.spec.outbound) === null || _c === void 0 ? void 0 : _c.credentialsRef,
19
+ accessControlListRef: (_d = config.spec.inbound) === null || _d === void 0 ? void 0 : _d.accessControlListRef,
20
+ uris: (_f = (_e = config.spec.outbound) === null || _e === void 0 ? void 0 : _e.uris) === null || _f === void 0 ? void 0 : _f.map((entry) => {
21
+ var _a;
22
+ return {
23
+ user: entry.uri.user,
24
+ host: entry.uri.host,
25
+ port: entry.uri.port,
26
+ transport: (_a = entry.uri.transport) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
27
+ enabled: entry.enabled,
28
+ weight: entry.weight,
29
+ priority: entry.priority
30
+ };
31
+ })
32
+ };
33
+ }
34
+ exports.mapToTrunk = mapToTrunk;
@@ -20,6 +20,7 @@ syntax = "proto3";
20
20
 
21
21
  package fonoster.routr.connect.acl.v2draft1;
22
22
 
23
+ import "google/protobuf/struct.proto";
23
24
  import "google/protobuf/empty.proto";
24
25
 
25
26
  // AccessControlList(ACL) service definition
@@ -52,40 +53,34 @@ message AccessControlList {
52
53
  int32 created_at = 6;
53
54
  // The date the ACL was last updated
54
55
  int32 updated_at = 7;
56
+ // The extended attributes of the ACL
57
+ .google.protobuf.Struct extended = 8;
55
58
  }
56
59
 
57
60
  // The request message for the AccessControlList.Create method
58
61
  message CreateACLRequest {
59
- // The version of the API
60
- string api_version = 1;
61
62
  // A friendly name for the ACL
62
63
  string name = 2;
63
64
  // The list of allowed IP addresses
64
65
  repeated string allow = 3;
65
66
  // The list of denied IP addresses
66
67
  repeated string deny = 4;
67
- // The date the ACL was created
68
- int32 created_at = 5;
69
- // The date the ACL was last updated
70
- int32 updated_at = 6;
68
+ // The extended attributes of the ACL
69
+ .google.protobuf.Struct extended = 5;
71
70
  }
72
71
 
73
72
  // The request message for the AccessControlList.Update method
74
73
  message UpdateACLRequest {
75
- // The version of the API
76
- string api_version = 1;
77
74
  // The ACL reference
78
- string ref = 2;
75
+ string ref = 1;
79
76
  // A friendly name for the ACL
80
- string name = 3;
77
+ string name = 2;
81
78
  // The list of allowed IP addresses
82
- repeated string allow = 4;
79
+ repeated string allow = 3;
83
80
  // The list of denied IP addresses
84
- repeated string deny = 5;
85
- // The date the ACL was created
86
- int32 created_at = 6;
87
- // The date the ACL was last updated
88
- int32 updated_at = 7;
81
+ repeated string deny = 4;
82
+ // The extended attributes of the ACL
83
+ .google.protobuf.Struct extended = 5;
89
84
  }
90
85
 
91
86
  // The request message for the AccessControlList.Get method
@@ -74,44 +74,40 @@ message Agent {
74
74
 
75
75
  // The request message for the Agents.Create method
76
76
  message CreateAgentRequest {
77
- // The API version of the Agent
78
- string api_version = 1;
79
77
  // The name of the Agent
80
- string name = 2;
78
+ string name = 1;
81
79
  // The username of the Agent
82
- string username = 3;
80
+ string username = 2;
83
81
  // The password of the Agent
84
- Privacy privacy = 4;
82
+ Privacy privacy = 3;
85
83
  // The enabled status of the Agent
86
- bool enabled = 5;
87
- // The domain of the Agent
88
- fonoster.routr.connect.domains.v2draft1.Domain domain = 6;
89
- // The credentials of the Agent
90
- fonoster.routr.connect.credentials.v2draft1.Credentials credentials = 7;
84
+ bool enabled = 4;
85
+ // Reference to the Domain of the Agent
86
+ string domain_ref = 5;
87
+ // Reference to the Credentials of the Agent
88
+ string credentials_ref = 6;
91
89
  // The extended attributes of the Agent
92
- .google.protobuf.Struct extended = 8;
90
+ .google.protobuf.Struct extended = 7;
93
91
  }
94
92
 
95
93
  // The request message for the Agents.Update method
96
94
  message UpdateAgentRequest {
97
- // The API version of the Agent
98
- string api_version = 1;
99
95
  // The unique identifier of the Agent
100
- string ref = 2;
96
+ string ref = 1;
101
97
  // The name of the Agent
102
- string name = 3;
98
+ string name = 2;
103
99
  // The username of the Agent
104
- string username = 4;
100
+ string username = 3;
105
101
  // The privacy settings of the Agent
106
- Privacy privacy = 5;
102
+ Privacy privacy = 4;
107
103
  // The enabled status of the Agent
108
- bool enabled = 6;
109
- // The domain of the Agent
110
- fonoster.routr.connect.domains.v2draft1.Domain domain = 7;
111
- // The credentials of the Agent
112
- fonoster.routr.connect.credentials.v2draft1.Credentials credentials = 8;
104
+ bool enabled = 5;
105
+ // Reference to the Domain of the Agent
106
+ string domain_ref = 6;
107
+ // Reference to the Credentials of the Agent
108
+ string credentials_ref = 7;
113
109
  // The extended attributes of the Agent
114
- .google.protobuf.Struct extended = 9;
110
+ .google.protobuf.Struct extended = 8;
115
111
  }
116
112
 
117
113
  // The request message for the Agents.Get method