@routr/pgdata 2.0.8-alpha.20 → 2.0.8-alpha.22

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.
@@ -1,49 +1,6 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.DomainManager = void 0;
27
- /*
28
- * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
29
- * http://github.com/fonoster
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
- /* eslint-disable require-jsdoc */
46
- const Validator = __importStar(require("validator"));
47
4
  const common_1 = require("@routr/common");
48
5
  const acl_1 = require("./acl");
49
6
  const manager_1 = require("./manager");
@@ -59,56 +16,42 @@ class DomainManager extends manager_1.EntityManager {
59
16
  };
60
17
  }
61
18
  validOrThrowCreate() {
62
- if (!this.domain.name) {
63
- throw new common_1.CommonErrors.BadRequestError("the friendly name for the resource is required");
64
- }
65
- if (!Validator.default.isLength(this.domain.name, { min: 3, max: 64 })) {
66
- throw new common_1.CommonErrors.BadRequestError("the friendly name must be between 3 and 64 characters");
67
- }
68
- if (!this.domain.domainUri) {
69
- throw new common_1.CommonErrors.BadRequestError("the domainUri is required");
70
- }
71
- if (!Validator.default.isFQDN(this.domain.domainUri)) {
72
- throw new common_1.CommonErrors.BadRequestError("the domainUri must be a valid fully qualified domain name");
73
- }
19
+ common_1.CommonConnect.hasNameOrThrow(this.domain.name);
20
+ common_1.CommonConnect.isValidNameOrThrow(this.domain.name);
21
+ common_1.CommonConnect.isValidDomainUriOrThrow(this.domain.domainUri);
74
22
  }
75
23
  validOrThrowUpdate() {
76
- if (!this.domain.ref) {
77
- throw new common_1.CommonErrors.BadRequestError("the reference to the resource is required");
78
- }
79
- if (!this.domain.name) {
80
- throw new common_1.CommonErrors.BadRequestError("the friendly name for the resource is required");
81
- }
82
- if (!Validator.default.isLength(this.domain.name, { min: 3, max: 64 })) {
83
- throw new common_1.CommonErrors.BadRequestError("the friendly name must be between 3 and 64 characters");
84
- }
24
+ common_1.CommonConnect.hasRefenceOrThrow(this.domain.ref);
25
+ common_1.CommonConnect.isValidNameOrThrow(this.domain.name);
85
26
  }
86
27
  mapToPrisma() {
28
+ var _a;
87
29
  return {
88
30
  // TODO: Set a default value for apiVersion
89
31
  apiVersion: "v2",
90
32
  ref: this.domain.ref,
91
33
  name: this.domain.name,
92
- accessControlListRef: this.domain.accessControlListRef,
34
+ accessControlListRef: this.domain.accessControlListRef || null,
93
35
  domainUri: this.domain.domainUri,
94
- extended: this.domain.extended,
95
- createdAt: this.domain.createdAt,
36
+ extended: this.domain.extended || {},
37
+ createdAt: this.domain.createdAt
38
+ ? new Date(this.domain.createdAt * 1000)
39
+ : undefined,
96
40
  updatedAt: this.domain.updatedAt
41
+ ? new Date(this.domain.updatedAt * 1000)
42
+ : undefined,
43
+ egressPolicies: {
44
+ create: (_a = this.domain.egressPolicies) === null || _a === void 0 ? void 0 : _a.map((policy) => ({
45
+ rule: policy.rule,
46
+ numberRef: policy.numberRef
47
+ }))
48
+ }
97
49
  };
98
50
  }
99
51
  static mapToDto(domain) {
100
52
  var _a;
101
- return {
102
- apiVersion: domain.apiVersion,
103
- ref: domain.ref,
104
- name: domain.name,
105
- accessControlListRef: (_a = domain.accessControlList) === null || _a === void 0 ? void 0 : _a.ref,
106
- accessControlList: acl_1.ACLManager.mapToDto(domain.accessControlList),
107
- domainUri: domain.domainUri,
108
- extended: domain.extended,
109
- createdAt: domain.createdAt,
110
- updatedAt: domain.updatedAt
111
- };
53
+ return domain
54
+ ? Object.assign(Object.assign({}, domain), { accessControlListRef: (_a = domain.accessControlList) === null || _a === void 0 ? void 0 : _a.ref, accessControlList: acl_1.ACLManager.mapToDto(domain.accessControlList), extended: domain.extended, createdAt: domain.createdAt.getTime() / 1000, updatedAt: domain.updatedAt.getTime() / 1000 }) : undefined;
112
55
  }
113
56
  }
114
57
  exports.DomainManager = DomainManager;
@@ -1,52 +1,10 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.NumberManager = void 0;
27
- /*
28
- * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
29
- * http://github.com/fonoster
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
- /* eslint-disable require-jsdoc */
46
- const Validator = __importStar(require("validator"));
47
4
  const common_1 = require("@routr/common");
48
5
  const manager_1 = require("./manager");
49
6
  const trunk_1 = require("./trunk");
7
+ const envs_1 = require("../envs");
50
8
  // Needs testing
51
9
  class NumberManager extends manager_1.EntityManager {
52
10
  constructor(number) {
@@ -66,52 +24,25 @@ class NumberManager extends manager_1.EntityManager {
66
24
  };
67
25
  }
68
26
  validOrThrowCreate() {
69
- if (!this.number.name) {
70
- throw new common_1.CommonErrors.BadRequestError("the friendly name for the resource is required");
71
- }
72
- if (!Validator.default.isLength(this.number.name, { min: 3, max: 64 })) {
73
- throw new common_1.CommonErrors.BadRequestError("the friendly name must be between 3 and 64 characters");
74
- }
75
- if (!this.number.telUrl) {
76
- // TODO: Consider adding a feature flag to validate e164
77
- throw new common_1.CommonErrors.BadRequestError("the telUrl is required");
78
- }
79
- if (this.number.sessionAffinityHeader) {
80
- if (!Validator.default.isAlphanumeric(this.number.sessionAffinityHeader)) {
81
- throw new common_1.CommonErrors.BadRequestError("the sessionAffinityHeader must be alphanumeric and without spaces");
82
- }
83
- }
84
- // TODO: We will need a better way to validate this so is a valid SIP URI
85
- if (this.number.aorLink) {
86
- if (!this.number.aorLink.startsWith("backend:") &&
87
- !this.number.aorLink.startsWith("sip:")) {
88
- throw new common_1.CommonErrors.BadRequestError("the aorLink must start with backend: or sip:");
89
- }
27
+ if (envs_1.ENFORCE_E164) {
28
+ common_1.CommonConnect.isValidE164OrThrow(this.number.telUrl, this.number.countryIsoCode, envs_1.ENFORCE_E164_WITH_MOBILE_PREFIX);
90
29
  }
30
+ common_1.CommonConnect.hasNameOrThrow(this.number.name);
31
+ common_1.CommonConnect.isValidNameOrThrow(this.number.name);
32
+ common_1.CommonConnect.hasTelUrlOrThrow(this.number.telUrl);
33
+ common_1.CommonConnect.isValidAORLinkOrThrow(this.number.aorLink);
34
+ common_1.CommonConnect.hasCityOrThrow(this.number.city);
35
+ common_1.CommonConnect.hasCountryOrThrow(this.number.country);
36
+ common_1.CommonConnect.hasCountryISOCodeOrThrow(this.number.countryIsoCode);
37
+ common_1.CommonConnect.hasValidHeadersOrThrow(this.number.extraHeaders);
38
+ common_1.CommonConnect.isValidSessionAffinityHeaderOrThrow(this.number.sessionAffinityHeader);
91
39
  }
92
- // TODO: Add validation for countryISOCode (it should be an enum)
93
40
  validOrThrowUpdate() {
94
- if (!this.number.ref) {
95
- throw new common_1.CommonErrors.BadRequestError("the reference to the resource is required");
96
- }
97
- if (!this.number.name) {
98
- throw new common_1.CommonErrors.BadRequestError("the friendly name for the resource is required");
99
- }
100
- if (!Validator.default.isLength(this.number.name, { min: 3, max: 64 })) {
101
- throw new common_1.CommonErrors.BadRequestError("the friendly name must be between 3 and 64 characters");
102
- }
103
- if (this.number.sessionAffinityHeader) {
104
- if (!Validator.default.isAlphanumeric(this.number.sessionAffinityHeader)) {
105
- throw new common_1.CommonErrors.BadRequestError("the sessionAffinityHeader must be alphanumeric and without spaces");
106
- }
107
- }
108
- // TODO: We will need a better way to validate this so is a valid SIP URI
109
- if (this.number.aorLink) {
110
- if (!this.number.aorLink.startsWith("backend:") &&
111
- !this.number.aorLink.startsWith("sip:")) {
112
- throw new common_1.CommonErrors.BadRequestError("the aorLink must start with backend: or sip:");
113
- }
114
- }
41
+ common_1.CommonConnect.hasRefenceOrThrow(this.number.ref);
42
+ common_1.CommonConnect.isValidNameOrThrow(this.number.name);
43
+ common_1.CommonConnect.isValidAORLinkOrThrow(this.number.aorLink);
44
+ common_1.CommonConnect.hasValidHeadersOrThrow(this.number.extraHeaders);
45
+ common_1.CommonConnect.isValidSessionAffinityHeaderOrThrow(this.number.sessionAffinityHeader);
115
46
  }
116
47
  mapToPrisma() {
117
48
  return {
@@ -119,37 +50,43 @@ class NumberManager extends manager_1.EntityManager {
119
50
  apiVersion: "v2",
120
51
  ref: this.number.ref,
121
52
  name: this.number.name,
122
- trunkRef: this.number.trunkRef,
53
+ trunkRef: this.number.trunkRef || null,
123
54
  telUrl: this.number.telUrl,
124
- aorLink: this.number.aorLink,
125
- city: this.number.city,
55
+ aorLink: this.number.aorLink || null,
56
+ city: this.number.city || undefined,
126
57
  country: this.number.country,
127
- countryISOCode: this.number.countryISOCode,
128
- sessionAffinityHeader: this.number.sessionAffinityHeader,
129
- extraHeaders: this.number.extraHeaders,
130
- extended: this.number.extended,
131
- createdAt: this.number.createdAt,
58
+ countryISOCode: this.number.countryIsoCode,
59
+ sessionAffinityHeader: this.number.sessionAffinityHeader || null,
60
+ extraHeaders: this.number.extraHeaders || null,
61
+ createdAt: this.number.createdAt
62
+ ? new Date(this.number.createdAt * 1000)
63
+ : undefined,
132
64
  updatedAt: this.number.updatedAt
65
+ ? new Date(this.number.updatedAt * 1000)
66
+ : undefined,
67
+ extended: this.number.extended || {}
133
68
  };
134
69
  }
135
70
  static mapToDto(number) {
136
- return {
137
- apiVersion: number.apiVersion,
138
- ref: number.ref,
139
- name: number.name,
140
- trunkRef: number.trunkRef,
141
- trunk: number.trunk ? trunk_1.TrunkManager.mapToDto(number.trunk) : undefined,
142
- telUrl: number.telUrl,
143
- aorLink: number.aorLink,
144
- city: number.city,
145
- country: number.country,
146
- countryISOCode: number.countryISOCode,
147
- sessionAffinityHeader: number.sessionAffinityHeader,
148
- extraHeaders: number.extraHeaders,
149
- extended: number.extended,
150
- createdAt: number.createdAt,
151
- updatedAt: number.updatedAt
152
- };
71
+ return number
72
+ ? {
73
+ apiVersion: number.apiVersion,
74
+ ref: number.ref,
75
+ name: number.name,
76
+ trunkRef: number.trunkRef,
77
+ trunk: trunk_1.TrunkManager.mapToDto(number.trunk),
78
+ telUrl: number.telUrl,
79
+ aorLink: number.aorLink,
80
+ city: number.city,
81
+ country: number.country,
82
+ countryIsoCode: number.countryISOCode,
83
+ sessionAffinityHeader: number.sessionAffinityHeader,
84
+ extraHeaders: number.extraHeaders,
85
+ extended: number.extended,
86
+ createdAt: number.createdAt.getTime() / 1000,
87
+ updatedAt: number.updatedAt.getTime() / 1000
88
+ }
89
+ : undefined;
153
90
  }
154
91
  }
155
92
  exports.NumberManager = NumberManager;
@@ -1,49 +1,6 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.PeerManager = void 0;
27
- /*
28
- * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
29
- * http://github.com/fonoster
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
- /* eslint-disable require-jsdoc */
46
- const Validator = __importStar(require("validator"));
47
4
  const common_1 = require("@routr/common");
48
5
  const acl_1 = require("./acl");
49
6
  const credentials_1 = require("./credentials");
@@ -61,66 +18,27 @@ class PeerManager extends manager_1.EntityManager {
61
18
  };
62
19
  }
63
20
  validOrThrowCreate() {
64
- if (!this.peer.name) {
65
- throw new common_1.CommonErrors.BadRequestError("the friendly name for the resource is required");
66
- }
67
- if (!Validator.default.isLength(this.peer.name, { min: 3, max: 64 })) {
68
- throw new common_1.CommonErrors.BadRequestError("the friendly name must be between 3 and 64 characters");
69
- }
70
- if (!this.peer.username) {
71
- throw new common_1.CommonErrors.BadRequestError("the username is required");
72
- }
73
- if (!Validator.default.isAlphanumeric(this.peer.username)) {
74
- throw new common_1.CommonErrors.BadRequestError("the username must be alphanumeric and without spaces");
75
- }
76
- if (!this.peer.aor) {
77
- throw new common_1.CommonErrors.BadRequestError("the address of record (aor) is required");
78
- }
79
- // TODO: We will need a better way to validate this so is a valid SIP URI
80
- if (!this.peer.aor.startsWith("backend:") &&
81
- !this.peer.aor.startsWith("sip:")) {
82
- throw new common_1.CommonErrors.BadRequestError("the aor schema must start with `backend:` or `sip:`");
83
- }
84
- if (this.peer.aor.startsWith("backend:")) {
85
- if (!this.peer.balancingAlgorithm) {
86
- throw new common_1.CommonErrors.BadRequestError("when the aor schema is `backend:`, the balancing algorithm is required");
87
- }
88
- }
89
- if (this.peer.aor.startsWith("sip:")) {
90
- if (this.peer.balancingAlgorithm) {
91
- throw new common_1.CommonErrors.BadRequestError("when the aor schema is `sip:`, the balancing algorithm is not allowed");
92
- }
93
- }
21
+ common_1.CommonConnect.hasNameOrThrow(this.peer.name);
22
+ common_1.CommonConnect.isValidNameOrThrow(this.peer.name);
23
+ common_1.CommonConnect.hasUsernameOrThrow(this.peer.username);
24
+ common_1.CommonConnect.isValidUsernameOrThrow(this.peer.username);
25
+ common_1.CommonConnect.hasAOROrThrow(this.peer.aor);
26
+ common_1.CommonConnect.isValidAOROrThrow(this.peer.aor);
27
+ common_1.CommonConnect.isValidContactAddressOrThrow(this.peer.contactAddr);
28
+ common_1.CommonConnect.isValidBalancingAlgorithmOrThrow(this.peer.aor, this.peer.balancingAlgorithm);
94
29
  }
95
30
  validOrThrowUpdate() {
96
- if (!this.peer.ref) {
97
- throw new common_1.CommonErrors.BadRequestError("the reference to the resource is required");
98
- }
99
- if (!this.peer.name) {
100
- throw new common_1.CommonErrors.BadRequestError("the friendly name for the resource is required");
101
- }
102
- if (!Validator.default.isLength(this.peer.name, { min: 3, max: 64 })) {
103
- throw new common_1.CommonErrors.BadRequestError("the friendly name must be between 3 and 64 characters");
104
- }
105
- if (this.peer.aor) {
106
- // TODO: We will need a better way to validate this so is a valid SIP URI
107
- if (!this.peer.aor.startsWith("backend:") &&
108
- !this.peer.aor.startsWith("sip:")) {
109
- throw new common_1.CommonErrors.BadRequestError("the aor schema must start with `backend:` or `sip:`");
110
- }
111
- }
112
- if (this.peer.aor.startsWith("backend:")) {
113
- if (!this.peer.balancingAlgorithm) {
114
- throw new common_1.CommonErrors.BadRequestError("when the aor schema is `backend:`, the balancing algorithm is required");
115
- }
116
- }
117
- if (this.peer.aor.startsWith("sip:")) {
118
- if (this.peer.balancingAlgorithm) {
119
- throw new common_1.CommonErrors.BadRequestError("when the aor schema is `sip:`, the balancing algorithm is not allowed");
120
- }
121
- }
31
+ common_1.CommonConnect.hasRefenceOrThrow(this.peer.ref);
32
+ common_1.CommonConnect.isValidNameOrThrow(this.peer.name);
33
+ common_1.CommonConnect.isValidUsernameOrThrow(this.peer.username);
34
+ common_1.CommonConnect.isValidAOROrThrow(this.peer.aor);
35
+ common_1.CommonConnect.isValidContactAddressOrThrow(this.peer.contactAddr);
36
+ common_1.CommonConnect.isValidBalancingAlgorithmOrThrow(this.peer.aor, this.peer.balancingAlgorithm);
122
37
  }
123
38
  mapToPrisma() {
39
+ const normalizeAlgorithm = (algorithm) => algorithm === common_1.CommonTypes.LoadBalancingAlgorithm.UNSPECIFIED
40
+ ? undefined
41
+ : algorithm;
124
42
  return {
125
43
  // TODO: Set a default value for apiVersion
126
44
  apiVersion: "v2",
@@ -129,36 +47,41 @@ class PeerManager extends manager_1.EntityManager {
129
47
  username: this.peer.username,
130
48
  aor: this.peer.aor,
131
49
  contactAddr: this.peer.contactAddr,
132
- balancingAlgorithm: this.peer
133
- .balancingAlgorithm,
50
+ balancingAlgorithm: normalizeAlgorithm(this.peer.balancingAlgorithm),
134
51
  withSessionAffinity: this.peer.withSessionAffinity,
135
52
  enabled: this.peer.enabled,
136
- credentialsRef: this.peer.credentialsRef,
137
- accessControlListRef: this.peer.accessControlListRef,
138
- createdAt: this.peer.createdAt,
139
- updatedAt: this.peer.updatedAt,
140
- extended: this.peer.extended
53
+ credentialsRef: this.peer.credentialsRef || null,
54
+ accessControlListRef: this.peer.accessControlListRef || null,
55
+ createdAt: this.peer.createdAt
56
+ ? new Date(this.peer.createdAt * 1000)
57
+ : undefined,
58
+ updatedAt: this.peer.updatedAt
59
+ ? new Date(this.peer.updatedAt * 1000)
60
+ : undefined,
61
+ extended: this.peer.extended || {}
141
62
  };
142
63
  }
143
64
  static mapToDto(peer) {
144
- return {
145
- apiVersion: peer.apiVersion,
146
- ref: peer.ref,
147
- name: peer.name,
148
- username: peer.username,
149
- aor: peer.aor,
150
- contactAddr: peer.contactAddr,
151
- balancingAlgorithm: peer.balancingAlgorithm,
152
- withSessionAffinity: peer.withSessionAffinity,
153
- enabled: peer.enabled,
154
- credentialsRef: peer.credentialsRef,
155
- credentials: credentials_1.CredentialsManager.mapToDto(peer.credentials),
156
- accessControlListRef: peer.accessControlListRef,
157
- accessControlList: acl_1.ACLManager.mapToDto(peer.accessControlList),
158
- createdAt: peer.createdAt,
159
- updatedAt: peer.updatedAt,
160
- extended: peer.extended
161
- };
65
+ return peer
66
+ ? {
67
+ apiVersion: peer.apiVersion,
68
+ ref: peer.ref,
69
+ name: peer.name,
70
+ username: peer.username,
71
+ aor: peer.aor,
72
+ contactAddr: peer.contactAddr,
73
+ balancingAlgorithm: peer.balancingAlgorithm,
74
+ withSessionAffinity: peer.withSessionAffinity,
75
+ enabled: peer.enabled,
76
+ credentialsRef: peer.credentialsRef,
77
+ credentials: credentials_1.CredentialsManager.mapToDto(peer.credentials),
78
+ accessControlListRef: peer.accessControlListRef,
79
+ accessControlList: acl_1.ACLManager.mapToDto(peer.accessControlList),
80
+ createdAt: peer.createdAt.getTime() / 1000,
81
+ updatedAt: peer.updatedAt.getTime() / 1000,
82
+ extended: peer.extended
83
+ }
84
+ : undefined;
162
85
  }
163
86
  }
164
87
  exports.PeerManager = PeerManager;
@@ -1,4 +1,4 @@
1
- import { Trunk as TrunkPrismaModel, Prisma } from "@prisma/client";
1
+ import { Trunk as TrunkPrismaModel, Prisma, TrunkURI } from "@prisma/client";
2
2
  import { CommonConnect as CC } from "@routr/common";
3
3
  import { JsonObject } from "pb-util/build";
4
4
  import { EntityManager } from "./manager";
@@ -12,11 +12,15 @@ type TrunkWithEagerLoading = Prisma.TrunkGetPayload<{
12
12
  }>;
13
13
  export declare class TrunkManager extends EntityManager {
14
14
  private trunk;
15
- constructor(trunk: CC.Trunk | Omit<CC.Trunk, "uris">);
15
+ constructor(trunk: CC.Trunk);
16
16
  static includeFields(): JsonObject;
17
17
  validOrThrowCreate(): void;
18
18
  validOrThrowUpdate(): void;
19
- mapToPrisma(): TrunkPrismaModel;
19
+ mapToPrisma(): TrunkPrismaModel & {
20
+ uris: {
21
+ create: Omit<TrunkURI, "ref" | "trunkRef">[];
22
+ };
23
+ };
20
24
  static mapToDto(trunk: TrunkWithEagerLoading): CC.Trunk;
21
25
  }
22
26
  export {};