@routr/connect 2.0.8-alpha.18 → 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 (2) hide show
  1. package/dist/router.js +21 -7
  2. package/package.json +5 -5
package/dist/router.js CHANGED
@@ -72,7 +72,7 @@ function router(location, apiClient) {
72
72
  case types_1.RoutingDirection.AGENT_TO_PSTN:
73
73
  return yield agentToPSTN(request, caller, requestURI.user);
74
74
  case types_1.RoutingDirection.FROM_PSTN:
75
- return yield fromPSTN(location, callee, request);
75
+ return yield fromPSTN(apiClient, location, callee, request);
76
76
  case types_1.RoutingDirection.PEER_TO_PSTN:
77
77
  return yield peerToPSTN(apiClient, request);
78
78
  default:
@@ -90,19 +90,33 @@ function agentToAgent(location, req) {
90
90
  /**
91
91
  * From PSTN routing.
92
92
  *
93
+ * @param {APIClient} apiClient - API client
93
94
  * @param {ILocationService} location - Location service
94
95
  * @param {Resource} callee - The callee
95
96
  * @param {MessageRequest} req - The request
96
97
  * @return {Promise<Route>}
97
98
  */
98
- function fromPSTN(location, callee, req) {
99
+ function fromPSTN(apiClient, location, callee, req) {
99
100
  var _a;
100
101
  return __awaiter(this, void 0, void 0, function* () {
101
102
  const sessionAffinityRef = processor_1.Extensions.getHeaderValue(req, callee.sessionAffinityHeader);
103
+ let backend;
104
+ if (callee.aorLink.startsWith("backend:")) {
105
+ const peer = (yield apiClient.peers.findBy({
106
+ fieldName: "aor",
107
+ fieldValue: callee.aorLink
108
+ })).items[0];
109
+ backend = {
110
+ ref: peer.ref,
111
+ balancingAlgorithm: peer.balancingAlgorithm,
112
+ withSessionAffinity: peer.withSessionAffinity
113
+ };
114
+ }
102
115
  const route = (yield location.findRoutes({
103
116
  aor: callee.aorLink,
104
117
  callId: req.ref,
105
- sessionAffinityRef
118
+ sessionAffinityRef,
119
+ backend
106
120
  }))[0];
107
121
  if (!route) {
108
122
  throw new location_1.NotRoutesFoundForAOR(callee.aorLink);
@@ -157,8 +171,8 @@ function agentToPSTN(req, agent, calleeNumber) {
157
171
  {
158
172
  name: "Privacy",
159
173
  value: ((_e = agent.privacy) === null || _e === void 0 ? void 0 : _e.toUpperCase()) === common_1.CommonTypes.Privacy.PRIVATE
160
- ? common_1.CommonTypes.Privacy.PRIVATE
161
- : common_1.CommonTypes.Privacy.NONE,
174
+ ? common_1.CommonTypes.Privacy.PRIVATE.toLowerCase()
175
+ : common_1.CommonTypes.Privacy.NONE.toLowerCase(),
162
176
  action: common_1.CommonTypes.HeaderModifierAction.ADD
163
177
  },
164
178
  (0, utils_1.createRemotePartyId)(trunk, policy.number),
@@ -200,8 +214,8 @@ function peerToPSTN(apiClient, req) {
200
214
  {
201
215
  name: "Privacy",
202
216
  value: (privacy === null || privacy === void 0 ? void 0 : privacy.toLocaleLowerCase()) === common_1.CommonTypes.Privacy.PRIVATE
203
- ? common_1.CommonTypes.Privacy.PRIVATE
204
- : common_1.CommonTypes.Privacy.NONE,
217
+ ? common_1.CommonTypes.Privacy.PRIVATE.toLowerCase()
218
+ : common_1.CommonTypes.Privacy.NONE.toLowerCase(),
205
219
  action: common_1.CommonTypes.HeaderModifierAction.ADD
206
220
  },
207
221
  (0, utils_1.createRemotePartyId)(number.trunk, number),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/connect",
3
- "version": "2.0.8-alpha.18",
3
+ "version": "2.0.8-alpha.19",
4
4
  "description": "Default processor",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -28,9 +28,9 @@
28
28
  "@opentelemetry/sdk-trace-base": "^1.0.4",
29
29
  "@opentelemetry/sdk-trace-node": "^1.0.4",
30
30
  "@opentelemetry/semantic-conventions": "^1.0.4",
31
- "@routr/common": "^2.0.8-alpha.18",
32
- "@routr/location": "^2.0.8-alpha.18",
33
- "@routr/processor": "^2.0.8-alpha.18"
31
+ "@routr/common": "^2.0.8-alpha.19",
32
+ "@routr/location": "^2.0.8-alpha.19",
33
+ "@routr/processor": "^2.0.8-alpha.19"
34
34
  },
35
35
  "files": [
36
36
  "dist"
@@ -45,5 +45,5 @@
45
45
  "bugs": {
46
46
  "url": "https://github.com/fonoster/routr/issues"
47
47
  },
48
- "gitHead": "66ce6b3ed832bb8c549d344b3367aceed4b6da8f"
48
+ "gitHead": "ff62abb0ff7704a79f98a8e0b10c0036b949cc11"
49
49
  }