@fonoster/common 0.8.20 → 0.8.21
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/constants.d.ts +2 -0
- package/dist/constants.js +3 -1
- package/dist/types.d.ts +1 -4
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/makeFetchSingleCall.d.ts +4 -0
- package/dist/utils/makeFetchSingleCall.js +49 -0
- package/dist/utils/types.d.ts +5 -0
- package/dist/utils/types.js +2 -0
- package/package.json +3 -2
package/dist/constants.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ import { ServingStatus } from "grpc-health-check";
|
|
|
2
2
|
export declare const GRPC_NOT_SERVING_STATUS: ServingStatus;
|
|
3
3
|
export declare const GRPC_SERVING_STATUS: ServingStatus;
|
|
4
4
|
export declare const STASIS_APP_NAME = "mediacontroller";
|
|
5
|
+
export declare const CALL_DETAIL_RECORD_MEASUREMENT = "cdr";
|
|
6
|
+
export declare const INFLUXDB_CALLS_BUCKET = "calls";
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.STASIS_APP_NAME = exports.GRPC_SERVING_STATUS = exports.GRPC_NOT_SERVING_STATUS = void 0;
|
|
3
|
+
exports.INFLUXDB_CALLS_BUCKET = exports.CALL_DETAIL_RECORD_MEASUREMENT = exports.STASIS_APP_NAME = exports.GRPC_SERVING_STATUS = exports.GRPC_NOT_SERVING_STATUS = void 0;
|
|
4
4
|
exports.GRPC_NOT_SERVING_STATUS = "NOT_SERVING";
|
|
5
5
|
exports.GRPC_SERVING_STATUS = "SERVING";
|
|
6
6
|
exports.STASIS_APP_NAME = "mediacontroller";
|
|
7
|
+
exports.CALL_DETAIL_RECORD_MEASUREMENT = "cdr";
|
|
8
|
+
exports.INFLUXDB_CALLS_BUCKET = "calls";
|
package/dist/types.d.ts
CHANGED
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -43,3 +43,4 @@ __exportStar(require("./toPascalCase"), exports);
|
|
|
43
43
|
__exportStar(require("./withErrorHandling"), exports);
|
|
44
44
|
__exportStar(require("./withErrorHandlingAndValidation"), exports);
|
|
45
45
|
__exportStar(require("./withValidation"), exports);
|
|
46
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createFetchSingleCall = createFetchSingleCall;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const influxdb_client_1 = require("@influxdata/influxdb-client");
|
|
32
|
+
const constants_1 = require("../constants");
|
|
33
|
+
function createFetchSingleCall(influxdb) {
|
|
34
|
+
return (accessKeyId, callId) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const query = (0, influxdb_client_1.flux) `from(bucket: "${constants_1.INFLUXDB_CALLS_BUCKET}")
|
|
36
|
+
|> range(start: -5m)
|
|
37
|
+
|> pivot(rowKey: ["callId"], columnKey: ["_field"], valueColumn: "_value")
|
|
38
|
+
|> map(fn: (r) => ({
|
|
39
|
+
r with
|
|
40
|
+
duration: int(v: r.endedAt) - int(v: r.startedAt)
|
|
41
|
+
}))
|
|
42
|
+
|> filter(fn: (r) => r._measurement == "${constants_1.CALL_DETAIL_RECORD_MEASUREMENT}")
|
|
43
|
+
|> filter(fn: (r) => r.callId == ${callId} and r.accessKeyId == "${accessKeyId}")
|
|
44
|
+
|> sort(columns: ["_time"], desc: true)
|
|
45
|
+
|> limit(n: 1)`;
|
|
46
|
+
const items = (yield influxdb.collectRows(query));
|
|
47
|
+
return items.length > 0 ? items[0] : null;
|
|
48
|
+
});
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/common",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.21",
|
|
4
4
|
"description": "Common library for Fonoster projects",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"@fonoster/logger": "^0.8.20",
|
|
22
22
|
"@grpc/grpc-js": "~1.10.6",
|
|
23
23
|
"@grpc/proto-loader": "^0.7.12",
|
|
24
|
+
"@influxdata/influxdb-client": "^1.35.0",
|
|
24
25
|
"dotenv": "^16.4.7",
|
|
25
26
|
"grpc-health-check": "^2.0.2",
|
|
26
27
|
"handlebars": "^4.7.8",
|
|
@@ -45,5 +46,5 @@
|
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/nodemailer": "^6.4.14"
|
|
47
48
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "2590a20d7309494faca50831ac0c0abdb14c2308"
|
|
49
50
|
}
|