@fonoster/apiserver 0.30.0 → 0.31.1
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/applications/buildService.d.ts +1 -1
- package/dist/applications/buildService.js +4 -3
- package/dist/applications/createCreateApplication.js +6 -3
- package/dist/applications/createCreateTestToken.d.ts +3 -1
- package/dist/applications/createCreateTestToken.js +18 -13
- package/dist/applications/createGetFnUtil.d.ts +1 -1
- package/dist/applications/createUpdateApplication.js +6 -4
- package/dist/applications/evalKeys.d.ts +7 -1
- package/dist/applications/evalKeys.js +9 -3
- package/dist/applications/session/appModel.d.ts +28 -4
- package/dist/applications/session/appModel.js +74 -35
- package/dist/billing/buildService.d.ts +24 -0
- package/dist/billing/buildService.js +116 -0
- package/dist/{migration/cli.js → bin/usage.js} +46 -22
- package/dist/calls/buildService.d.ts +1 -20
- package/dist/calls/buildService.js +50 -10
- package/dist/calls/createCall.d.ts +16 -2
- package/dist/calls/createCall.js +29 -6
- package/dist/calls/createCallPublisher.d.ts +6 -4
- package/dist/calls/createCallPublisher.js +6 -5
- package/dist/calls/createTrackCall.d.ts +16 -13
- package/dist/calls/createTrackCall.js +78 -55
- package/dist/calls/getCall.d.ts +3 -3
- package/dist/calls/getCall.js +2 -3
- package/dist/calls/listCalls.d.ts +4 -4
- package/dist/calls/listCalls.js +2 -3
- package/dist/calls/types.d.ts +2 -1
- package/dist/capabilities/createGetCapabilities.d.ts +3 -0
- package/dist/capabilities/createGetCapabilities.js +2 -1
- package/dist/config/index.js +1 -3
- package/dist/config/schema.d.ts +106 -102
- package/dist/config/schema.js +39 -47
- package/dist/core/applyCatalog.d.ts +3 -3
- package/dist/core/applyCatalog.js +5 -4
- package/dist/core/regionHooks.d.ts +1 -0
- package/dist/core/runServices.js +25 -4
- package/dist/core/services.d.ts +25 -1
- package/dist/core/services.js +35 -11
- package/dist/core/testTokenConfig.js +2 -2
- package/dist/core/upsertRoomrPeer.d.ts +6 -0
- package/dist/core/{upsertMediaNodePeer.js → upsertRoomrPeer.js} +9 -9
- package/dist/envs.d.ts +30 -16
- package/dist/envs.js +49 -31
- package/dist/index.js +23 -22
- package/dist/outbound/createNodeDirectory.d.ts +35 -13
- package/dist/outbound/createNodeDirectory.js +54 -20
- package/dist/outbound/index.d.ts +1 -0
- package/dist/outbound/index.js +1 -0
- package/dist/outbound/placeOutboundCall.d.ts +53 -13
- package/dist/outbound/placeOutboundCall.js +135 -88
- package/dist/outbound/placementSweep.d.ts +56 -0
- package/dist/outbound/placementSweep.js +127 -0
- package/dist/outbound/runOutboundCalls.d.ts +18 -14
- package/dist/outbound/runOutboundCalls.js +46 -34
- package/dist/providers/createProvidersHandlers.d.ts +1 -10
- package/dist/providers/createProvidersHandlers.js +20 -25
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.js +2 -2
- package/dist/providers/registryUsage.d.ts +2 -2
- package/dist/providers/registryUsage.js +5 -5
- package/dist/records/createIndexRecord.d.ts +26 -3
- package/dist/records/createIndexRecord.js +37 -10
- package/dist/records/createRecordsRouter.js +4 -2
- package/dist/records/createSearchRecords.d.ts +4 -3
- package/dist/records/createSearchRecords.js +9 -21
- package/dist/records/maintenance.d.ts +1 -1
- package/dist/records/maintenance.js +1 -1
- package/dist/records/runCallRecords.d.ts +2 -0
- package/dist/records/runCallRecords.js +1 -1
- package/dist/records/types.d.ts +2 -0
- package/dist/regions/configSync.d.ts +5 -5
- package/dist/regions/configSync.js +9 -9
- package/dist/regions/createRegionsRouter.d.ts +6 -6
- package/dist/regions/createRegionsRouter.js +5 -5
- package/dist/regions/link.js +1 -1
- package/dist/regions/runRegions.d.ts +2 -0
- package/dist/regions/runRegions.js +4 -0
- package/dist/regions/service.js +4 -4
- package/dist/regions/sources.d.ts +1 -1
- package/dist/regions/sources.js +4 -4
- package/dist/regions/status.js +5 -4
- package/dist/regions/types.d.ts +2 -2
- package/dist/usage/buildService.d.ts +16 -0
- package/dist/{calls/influxdb.js → usage/buildService.js} +16 -9
- package/dist/{events/createPerCallCache.d.ts → usage/createGetUsage.d.ts} +7 -7
- package/dist/usage/createGetUsage.js +118 -0
- package/dist/usage/ingestUsage.d.ts +7 -0
- package/dist/usage/ingestUsage.js +87 -0
- package/dist/usage/publishRecordedUsage.d.ts +52 -0
- package/dist/usage/publishRecordedUsage.js +103 -0
- package/dist/usage/publishUsage.d.ts +29 -0
- package/dist/usage/publishUsage.js +50 -0
- package/dist/usage/rebuildUsage.d.ts +48 -0
- package/dist/usage/rebuildUsage.js +104 -0
- package/dist/usage/runUsageConsumer.d.ts +22 -0
- package/dist/usage/runUsageConsumer.js +78 -0
- package/dist/usage/snapshotStorage.d.ts +14 -0
- package/dist/usage/snapshotStorage.js +95 -0
- package/dist/usage/types.d.ts +36 -0
- package/dist/voice/stt/types.js +1 -1
- package/dist/webhooks/lostCalls.d.ts +35 -12
- package/dist/webhooks/lostCalls.js +86 -48
- package/dist/webhooks/nodeCallEvents.d.ts +73 -0
- package/dist/webhooks/nodeCallEvents.js +177 -0
- package/dist/webhooks/runWebhookFanout.d.ts +10 -4
- package/dist/webhooks/runWebhookFanout.js +41 -39
- package/package.json +17 -19
- package/dist/applications/migration/PrismaApplicationStore.d.ts +0 -55
- package/dist/applications/migration/PrismaApplicationStore.js +0 -92
- package/dist/applications/migration/convertLegacyApplication.d.ts +0 -11
- package/dist/applications/migration/convertLegacyApplication.js +0 -112
- package/dist/applications/migration/index.d.ts +0 -22
- package/dist/applications/migration/index.js +0 -38
- package/dist/applications/migration/migrateApplications.d.ts +0 -43
- package/dist/applications/migration/migrateApplications.js +0 -87
- package/dist/applications/migration/types.d.ts +0 -92
- package/dist/applications/migration/types.js +0 -20
- package/dist/calls/createFetchCalls.d.ts +0 -22
- package/dist/calls/createFetchCalls.js +0 -88
- package/dist/calls/createFetchSingleCall.d.ts +0 -22
- package/dist/calls/createFetchSingleCall.js +0 -54
- package/dist/calls/influxdb.d.ts +0 -2
- package/dist/core/upsertMediaNodePeer.d.ts +0 -6
- package/dist/events/callRefs.d.ts +0 -29
- package/dist/events/callRefs.js +0 -103
- package/dist/events/createCdrWriter.d.ts +0 -25
- package/dist/events/createCdrWriter.js +0 -95
- package/dist/events/createInfluxDbPub.d.ts +0 -10
- package/dist/events/createInfluxDbPub.js +0 -46
- package/dist/events/createPerCallCache.js +0 -46
- package/dist/events/mapCallDirectionToEnum.d.ts +0 -21
- package/dist/events/mapCallDirectionToEnum.js +0 -37
- package/dist/events/nats.d.ts +0 -44
- package/dist/events/nats.js +0 -93
- package/dist/events/transformEvent.d.ts +0 -4
- package/dist/events/transformEvent.js +0 -87
- package/dist/events/types.d.ts +0 -26
- package/dist/migration/argv.d.ts +0 -22
- package/dist/migration/argv.js +0 -42
- package/dist/migration/catalogMapping.d.ts +0 -30
- package/dist/migration/catalogMapping.js +0 -53
- package/dist/migration/index.d.ts +0 -27
- package/dist/migration/index.js +0 -43
- package/dist/migration/migrateAssistants.d.ts +0 -8
- package/dist/migration/migrateAssistants.js +0 -169
- package/dist/migration/migrateCredentials.d.ts +0 -4
- package/dist/migration/migrateCredentials.js +0 -107
- package/dist/migration/migrateIntegrations.d.ts +0 -32
- package/dist/migration/migrateIntegrations.js +0 -136
- package/dist/migration/migrateLegacy.d.ts +0 -41
- package/dist/migration/migrateLegacy.js +0 -76
- package/dist/migration/providerKeys.d.ts +0 -14
- package/dist/migration/providerKeys.js +0 -61
- package/dist/migration/seedCatalog.d.ts +0 -2
- package/dist/migration/seedCatalog.js +0 -160
- package/dist/migration/types.d.ts +0 -42
- package/dist/migration/types.js +0 -31
- /package/dist/{migration/cli.d.ts → bin/usage.d.ts} +0 -0
- /package/dist/{events → usage}/types.js +0 -0
|
@@ -1,88 +0,0 @@
|
|
|
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.createFetchCalls = createFetchCalls;
|
|
13
|
-
/**
|
|
14
|
-
* Copyright (C) 2025 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 common_1 = require("@fonoster/common");
|
|
32
|
-
const logger_1 = require("@fonoster/logger");
|
|
33
|
-
const influxdb_client_1 = require("@influxdata/influxdb-client");
|
|
34
|
-
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
35
|
-
function createFetchCalls(influxdb) {
|
|
36
|
-
return (accessKeyId, request) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const { after, before, type, from, to, status, pageSize, pageToken } = request;
|
|
38
|
-
const accessKeyIdFilter = accessKeyId
|
|
39
|
-
? (0, influxdb_client_1.flux) `and r.accessKeyId == "${accessKeyId}"`
|
|
40
|
-
: (0, influxdb_client_1.flux) ``;
|
|
41
|
-
const typeFilter = type ? (0, influxdb_client_1.flux) `and r.type == "${type}"` : (0, influxdb_client_1.flux) ``;
|
|
42
|
-
const fromFilter = from ? (0, influxdb_client_1.flux) `and r.from == "${from}"` : (0, influxdb_client_1.flux) ``;
|
|
43
|
-
const toFilter = to ? (0, influxdb_client_1.flux) `and r.to == "${to}"` : (0, influxdb_client_1.flux) ``;
|
|
44
|
-
const statusFilter = status ? (0, influxdb_client_1.flux) `and r.status == "${status}"` : (0, influxdb_client_1.flux) ``;
|
|
45
|
-
const pageTokenFilter = pageToken
|
|
46
|
-
? (0, influxdb_client_1.flux) `|> filter(fn: (r) => r.startedAtParsed < int(v: ${pageToken}))`
|
|
47
|
-
: (0, influxdb_client_1.flux) ``;
|
|
48
|
-
const limit = (0, influxdb_client_1.flux) `|> limit(n: ${pageSize || 50})`;
|
|
49
|
-
const parsedAfter = after
|
|
50
|
-
? Math.trunc(new Date(after).getTime() / 1000)
|
|
51
|
-
: (0, influxdb_client_1.flux) `-30d`;
|
|
52
|
-
const parsedBefore = before
|
|
53
|
-
? new Date(before).getTime() / 1000
|
|
54
|
-
: new Date().getTime() / 1000;
|
|
55
|
-
const query = (0, influxdb_client_1.flux) `from(bucket: "${common_1.INFLUXDB_CALLS_BUCKET}")
|
|
56
|
-
|> range(start: ${parsedAfter})
|
|
57
|
-
|> pivot(rowKey: ["callId"], columnKey: ["_field"], valueColumn: "_value")
|
|
58
|
-
|> map(fn: (r) => ({
|
|
59
|
-
r with
|
|
60
|
-
duration: int(v: r.endedAt) - int(v: r.startedAt),
|
|
61
|
-
startedAtParsed: int(v: r.startedAt) / 1000,
|
|
62
|
-
}))
|
|
63
|
-
|> filter(fn: (r) =>
|
|
64
|
-
r._measurement == "${common_1.CALL_DETAIL_RECORD_MEASUREMENT}"
|
|
65
|
-
and r.startedAtParsed < ${parsedBefore}
|
|
66
|
-
${accessKeyIdFilter}
|
|
67
|
-
${typeFilter}
|
|
68
|
-
${fromFilter}
|
|
69
|
-
${toFilter}
|
|
70
|
-
${statusFilter})
|
|
71
|
-
|> group()
|
|
72
|
-
|> sort(columns: ["startedAtParsed"], desc: true)
|
|
73
|
-
${pageTokenFilter}
|
|
74
|
-
${limit}`;
|
|
75
|
-
logger.verbose("list calls request", {
|
|
76
|
-
accessKeyId,
|
|
77
|
-
after,
|
|
78
|
-
before,
|
|
79
|
-
query: query.toString()
|
|
80
|
-
});
|
|
81
|
-
const items = (yield influxdb.collectRows(query));
|
|
82
|
-
const nextPageToken = items.length > 0 ? items[items.length - 1].startedAt : "";
|
|
83
|
-
return {
|
|
84
|
-
nextPageToken: nextPageToken + "",
|
|
85
|
-
items
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
-
* http://github.com/fonoster/fonoster
|
|
4
|
-
*
|
|
5
|
-
* This file is part of Fonoster
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the MIT License (the "License");
|
|
8
|
-
* you may not use this file except in compliance with
|
|
9
|
-
* the License. You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* https://opensource.org/licenses/MIT
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
import { InfluxDBClient } from "@fonoster/common";
|
|
20
|
-
import { CallDetailRecord } from "@fonoster/types";
|
|
21
|
-
declare function createFetchSingleCall(influxdb: InfluxDBClient): (accessKeyId: string, ref: string) => Promise<CallDetailRecord>;
|
|
22
|
-
export { createFetchSingleCall };
|
|
@@ -1,54 +0,0 @@
|
|
|
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) 2025 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 common_1 = require("@fonoster/common");
|
|
32
|
-
const logger_1 = require("@fonoster/logger");
|
|
33
|
-
const influxdb_client_1 = require("@influxdata/influxdb-client");
|
|
34
|
-
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
35
|
-
function createFetchSingleCall(influxdb) {
|
|
36
|
-
return (accessKeyId, ref) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
// "ref" is a tag, so this filters before pivot runs and only ever
|
|
38
|
-
// touches the one matching series instead of every call in the range.
|
|
39
|
-
const query = (0, influxdb_client_1.flux) `from(bucket: "${common_1.INFLUXDB_CALLS_BUCKET}")
|
|
40
|
-
|> range(start: -30d)
|
|
41
|
-
|> filter(fn: (r) => r._measurement == "${common_1.CALL_DETAIL_RECORD_MEASUREMENT}" and r.ref == "${ref}")
|
|
42
|
-
|> pivot(rowKey: ["callId"], columnKey: ["_field"], valueColumn: "_value")
|
|
43
|
-
|> map(fn: (r) => ({
|
|
44
|
-
r with
|
|
45
|
-
duration: int(v: r.endedAt) - int(v: r.startedAt)
|
|
46
|
-
}))
|
|
47
|
-
|> filter(fn: (r) => r.accessKeyId == "${accessKeyId}")
|
|
48
|
-
|> sort(columns: ["_time"], desc: true)
|
|
49
|
-
|> limit(n: 1)`;
|
|
50
|
-
logger.verbose("fetch single call request", { accessKeyId, ref });
|
|
51
|
-
const items = (yield influxdb.collectRows(query));
|
|
52
|
-
return items.length > 0 ? items[0] : null;
|
|
53
|
-
});
|
|
54
|
-
}
|
package/dist/calls/influxdb.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The peer Go media nodes register under: least-sessions over `X-Session-Count`, any number of
|
|
3
|
-
* nodes (add-media-node 4.1). Created only when `routr.mediaNodePeer.password` is set.
|
|
4
|
-
*/
|
|
5
|
-
declare function upsertMediaNodePeer(attempt?: number, delayMs?: number): Promise<void>;
|
|
6
|
-
export { upsertMediaNodePeer };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { KV, NatsConnection } from "nats";
|
|
2
|
-
/**
|
|
3
|
-
* Routr call id → call ref, shared by every apiserver replica. A call's events (Routr's
|
|
4
|
-
* `routr.call.*`) are handled by whichever replica of the queue group gets them, and not every
|
|
5
|
-
* event carries the ref (an API call's `call.ended` has no X-Call-Ref), so the mapping cannot live
|
|
6
|
-
* in one replica's memory: another replica, or the same one after a restart, would write the
|
|
7
|
-
* call's later points without the ref and split its record (ST-1).
|
|
8
|
-
*/
|
|
9
|
-
export type CallRefStore = {
|
|
10
|
-
get(callId: string): Promise<string | undefined>;
|
|
11
|
-
set(callId: string, ref: string): Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
export declare const CALL_REFS_BUCKET = "fonoster_call_refs";
|
|
14
|
-
export declare const CALL_REFS_TTL_MS: number;
|
|
15
|
-
/** This process only (tests, or when the NATS user may not open the bucket). */
|
|
16
|
-
export declare function memoryCallRefs(ttlMs?: number): CallRefStore;
|
|
17
|
-
/** The mapping in a JetStream KV bucket; entries expire after a day. */
|
|
18
|
-
export declare function kvCallRefs(kv: KV): CallRefStore;
|
|
19
|
-
/**
|
|
20
|
-
* Opens (or creates) the shared bucket. Falls back to this process's memory, with a warning, when
|
|
21
|
-
* JetStream is off or the NATS user may not use the bucket: CDRs then split when another replica
|
|
22
|
-
* handles a call's later events (the behavior before ST-1).
|
|
23
|
-
*/
|
|
24
|
-
export declare function openCallRefs(nc: NatsConnection, logger: {
|
|
25
|
-
warn(m: string): void;
|
|
26
|
-
}, options?: {
|
|
27
|
-
bucket?: string;
|
|
28
|
-
ttlMs?: number;
|
|
29
|
-
}): Promise<CallRefStore>;
|
package/dist/events/callRefs.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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.CALL_REFS_TTL_MS = exports.CALL_REFS_BUCKET = void 0;
|
|
13
|
-
exports.memoryCallRefs = memoryCallRefs;
|
|
14
|
-
exports.kvCallRefs = kvCallRefs;
|
|
15
|
-
exports.openCallRefs = openCallRefs;
|
|
16
|
-
/**
|
|
17
|
-
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
18
|
-
* http://github.com/fonoster/fonoster
|
|
19
|
-
*
|
|
20
|
-
* This file is part of Fonoster
|
|
21
|
-
*
|
|
22
|
-
* Licensed under the MIT License (the "License");
|
|
23
|
-
* you may not use this file except in compliance with
|
|
24
|
-
* the License. You may obtain a copy of the License at
|
|
25
|
-
*
|
|
26
|
-
* https://opensource.org/licenses/MIT
|
|
27
|
-
*
|
|
28
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
-
* See the License for the specific language governing permissions and
|
|
32
|
-
* limitations under the License.
|
|
33
|
-
*/
|
|
34
|
-
const createPerCallCache_1 = require("./createPerCallCache");
|
|
35
|
-
exports.CALL_REFS_BUCKET = "fonoster_call_refs";
|
|
36
|
-
exports.CALL_REFS_TTL_MS = 24 * 60 * 60 * 1000;
|
|
37
|
-
const key = (callId) => callId.replace(/[^-_=/.a-zA-Z0-9]/g, "_");
|
|
38
|
-
/** This process only (tests, or when the NATS user may not open the bucket). */
|
|
39
|
-
function memoryCallRefs(ttlMs = exports.CALL_REFS_TTL_MS) {
|
|
40
|
-
const cache = (0, createPerCallCache_1.createPerCallCache)(ttlMs);
|
|
41
|
-
return {
|
|
42
|
-
get(callId) {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
return cache.get(callId);
|
|
45
|
-
});
|
|
46
|
-
},
|
|
47
|
-
set(callId, ref) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
cache.set(callId, ref);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
/** The mapping in a JetStream KV bucket; entries expire after a day. */
|
|
55
|
-
function kvCallRefs(kv) {
|
|
56
|
-
return {
|
|
57
|
-
get(callId) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const e = yield kv.get(key(callId));
|
|
60
|
-
return e && e.operation === "PUT" && e.value.length
|
|
61
|
-
? e.string()
|
|
62
|
-
: undefined;
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
set(callId, ref) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
yield kv.put(key(callId), ref);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Opens (or creates) the shared bucket. Falls back to this process's memory, with a warning, when
|
|
74
|
-
* JetStream is off or the NATS user may not use the bucket: CDRs then split when another replica
|
|
75
|
-
* handles a call's later events (the behavior before ST-1).
|
|
76
|
-
*/
|
|
77
|
-
function openCallRefs(nc_1, logger_1) {
|
|
78
|
-
return __awaiter(this, arguments, void 0, function* (nc, logger, options = {}) {
|
|
79
|
-
var _a, _b;
|
|
80
|
-
const bucket = (_a = options.bucket) !== null && _a !== void 0 ? _a : exports.CALL_REFS_BUCKET;
|
|
81
|
-
const views = nc.jetstream().views;
|
|
82
|
-
try {
|
|
83
|
-
let kv;
|
|
84
|
-
try {
|
|
85
|
-
kv = yield views.kv(bucket, {
|
|
86
|
-
history: 1,
|
|
87
|
-
ttl: (_b = options.ttlMs) !== null && _b !== void 0 ? _b : exports.CALL_REFS_TTL_MS,
|
|
88
|
-
description: "Fonoster: Routr call id -> call ref, for CDRs"
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
if (!/already in use/i.test(e.message))
|
|
93
|
-
throw e;
|
|
94
|
-
kv = yield views.kv(bucket, { bindOnly: true });
|
|
95
|
-
}
|
|
96
|
-
return kvCallRefs(kv);
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
99
|
-
logger.warn(`call refs: cannot open KV bucket ${bucket} (${e.message}); keeping them in memory, so CDRs of one call may split across replicas`);
|
|
100
|
-
return memoryCallRefs(options.ttlMs);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Point } from "@influxdata/influxdb-client";
|
|
2
|
-
import { CallRefStore } from "./callRefs";
|
|
3
|
-
type FonosterEvent = {
|
|
4
|
-
name: "cdr" | "error";
|
|
5
|
-
tag: string;
|
|
6
|
-
data: Record<string, unknown>;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Builds the InfluxDB point of one call event. A call's fields arrive across several events and
|
|
10
|
-
* not every one carries "ref" (e.g. an update with just endedAt/status). Every point of a call must
|
|
11
|
-
* share the same tag set for pivot to merge them into one record, so the call's ref is kept in a
|
|
12
|
-
* store shared by the replicas (CallRefStore) and reapplied to every later point.
|
|
13
|
-
*/
|
|
14
|
-
declare function createCdrWriter(deps: {
|
|
15
|
-
refs: CallRefStore;
|
|
16
|
-
write(point: Point): void;
|
|
17
|
-
/** How long an event without a ref waits for the call's first event (another replica). */
|
|
18
|
-
missRetryMs?: number;
|
|
19
|
-
}): (event: FonosterEvent) => Promise<Point>;
|
|
20
|
-
/** The CDR handler for one Routr call event (`routr.call.*`). */
|
|
21
|
-
declare function createCallEventHandler(deps: {
|
|
22
|
-
refs: CallRefStore;
|
|
23
|
-
write(point: Point): void;
|
|
24
|
-
}): (event: Record<string, unknown>) => Promise<Point>;
|
|
25
|
-
export { createCallEventHandler, createCdrWriter, FonosterEvent };
|
|
@@ -1,95 +0,0 @@
|
|
|
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.createCallEventHandler = createCallEventHandler;
|
|
13
|
-
exports.createCdrWriter = createCdrWriter;
|
|
14
|
-
/**
|
|
15
|
-
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
16
|
-
* http://github.com/fonoster/fonoster
|
|
17
|
-
*
|
|
18
|
-
* This file is part of Fonoster
|
|
19
|
-
*
|
|
20
|
-
* Licensed under the MIT License (the "License");
|
|
21
|
-
* you may not use this file except in compliance with
|
|
22
|
-
* the License. You may obtain a copy of the License at
|
|
23
|
-
*
|
|
24
|
-
* https://opensource.org/licenses/MIT
|
|
25
|
-
*
|
|
26
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
27
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
-
* See the License for the specific language governing permissions and
|
|
30
|
-
* limitations under the License.
|
|
31
|
-
*/
|
|
32
|
-
const common_1 = require("@fonoster/common");
|
|
33
|
-
const logger_1 = require("@fonoster/logger");
|
|
34
|
-
const influxdb_client_1 = require("@influxdata/influxdb-client");
|
|
35
|
-
const transformEvent_1 = require("./transformEvent");
|
|
36
|
-
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
37
|
-
/**
|
|
38
|
-
* Builds the InfluxDB point of one call event. A call's fields arrive across several events and
|
|
39
|
-
* not every one carries "ref" (e.g. an update with just endedAt/status). Every point of a call must
|
|
40
|
-
* share the same tag set for pivot to merge them into one record, so the call's ref is kept in a
|
|
41
|
-
* store shared by the replicas (CallRefStore) and reapplied to every later point.
|
|
42
|
-
*/
|
|
43
|
-
function createCdrWriter(deps) {
|
|
44
|
-
var _a;
|
|
45
|
-
const retryMs = (_a = deps.missRetryMs) !== null && _a !== void 0 ? _a : 200;
|
|
46
|
-
return (event) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const point = new influxdb_client_1.Point(event.name).tag("callId", event.tag);
|
|
48
|
-
let ref = event.data.ref ? String(event.data.ref) : undefined;
|
|
49
|
-
try {
|
|
50
|
-
if (ref)
|
|
51
|
-
yield deps.refs.set(event.tag, ref);
|
|
52
|
-
else {
|
|
53
|
-
// The call's first event may still be in flight on another replica: retry briefly.
|
|
54
|
-
for (let i = 0; i < 3 && !ref; i++) {
|
|
55
|
-
if (i)
|
|
56
|
-
yield new Promise((r) => setTimeout(r, retryMs));
|
|
57
|
-
ref = yield deps.refs.get(event.tag);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
logger.warn(`call refs: ${e.message}`);
|
|
63
|
-
}
|
|
64
|
-
if (ref)
|
|
65
|
-
point.tag("ref", ref);
|
|
66
|
-
Object.entries(event.data).forEach(([key, value]) => {
|
|
67
|
-
if (key === "ref" || value === undefined || value === null) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
else if (typeof value === "number") {
|
|
71
|
-
point.intField(key, value); // Or floatField for floating-point numbers
|
|
72
|
-
}
|
|
73
|
-
else if (typeof value === "boolean") {
|
|
74
|
-
point.booleanField(key, value);
|
|
75
|
-
}
|
|
76
|
-
else if (key === "startedAt" || key === "endedAt") {
|
|
77
|
-
point.stringField(key, new Date(String(value)).getTime());
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
point.stringField(key, String(value));
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
deps.write(point);
|
|
84
|
-
return point;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/** The CDR handler for one Routr call event (`routr.call.*`). */
|
|
88
|
-
function createCallEventHandler(deps) {
|
|
89
|
-
const writeCdr = createCdrWriter(deps);
|
|
90
|
-
return (event) => writeCdr({
|
|
91
|
-
name: common_1.CALL_DETAIL_RECORD_MEASUREMENT,
|
|
92
|
-
tag: event.callId,
|
|
93
|
-
data: (0, transformEvent_1.transformEvent)(event)
|
|
94
|
-
});
|
|
95
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Point } from "@influxdata/influxdb-client";
|
|
2
|
-
type InfluxDbPub = {
|
|
3
|
-
url: string;
|
|
4
|
-
token: string;
|
|
5
|
-
org: string;
|
|
6
|
-
bucket: string;
|
|
7
|
-
};
|
|
8
|
-
/** Writes points to the calls bucket (built by createCdrWriter). */
|
|
9
|
-
declare function createInfluxDbPub(config: InfluxDbPub): (point: Point) => void;
|
|
10
|
-
export { InfluxDbPub, createInfluxDbPub };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createInfluxDbPub = createInfluxDbPub;
|
|
4
|
-
/**
|
|
5
|
-
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
6
|
-
* http://github.com/fonoster/fonoster
|
|
7
|
-
*
|
|
8
|
-
* This file is part of Fonoster
|
|
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 influxdb_client_1 = require("@influxdata/influxdb-client");
|
|
24
|
-
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
25
|
-
/** Writes points to the calls bucket (built by createCdrWriter). */
|
|
26
|
-
function createInfluxDbPub(config) {
|
|
27
|
-
const { url, token, org, bucket } = config;
|
|
28
|
-
logger.info("creating influxdb client", { url, org, bucket });
|
|
29
|
-
const client = new influxdb_client_1.InfluxDB({ url, token });
|
|
30
|
-
const writeClient = client.getWriteApi(org, bucket, "ns");
|
|
31
|
-
return (point) => {
|
|
32
|
-
logger.verbose("writing event to InfluxDB", {
|
|
33
|
-
line: point.toLineProtocol()
|
|
34
|
-
});
|
|
35
|
-
try {
|
|
36
|
-
writeClient.writePoint(point);
|
|
37
|
-
// flush() rejects when InfluxDB is unreachable; unhandled, that killed the process (ST-B8).
|
|
38
|
-
writeClient
|
|
39
|
-
.flush()
|
|
40
|
-
.catch((error) => logger.warn(`error writing to InfluxDB: ${error.message}`));
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
logger.error("error writing to InfluxDB:", error);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
4
|
-
* http://github.com/fonoster/fonoster
|
|
5
|
-
*
|
|
6
|
-
* This file is part of Fonoster
|
|
7
|
-
*
|
|
8
|
-
* Licensed under the MIT License (the "License");
|
|
9
|
-
* you may not use this file except in compliance with
|
|
10
|
-
* the License. You may obtain a copy of the License at
|
|
11
|
-
*
|
|
12
|
-
* https://opensource.org/licenses/MIT
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
* See the License for the specific language governing permissions and
|
|
18
|
-
* limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.createPerCallCache = createPerCallCache;
|
|
22
|
-
/**
|
|
23
|
-
* Keeps a value stable across a call's lifetime (keyed by callId), pruned by
|
|
24
|
-
* age rather than by guessing which event is "final" from its fields.
|
|
25
|
-
*/
|
|
26
|
-
function createPerCallCache(ttlMs) {
|
|
27
|
-
const store = new Map();
|
|
28
|
-
const pruneInterval = setInterval(() => {
|
|
29
|
-
const cutoff = Date.now() - ttlMs;
|
|
30
|
-
store.forEach(({ lastSeenAt }, key) => {
|
|
31
|
-
if (lastSeenAt < cutoff) {
|
|
32
|
-
store.delete(key);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}, Math.min(ttlMs, 60 * 60 * 1000));
|
|
36
|
-
pruneInterval.unref();
|
|
37
|
-
return {
|
|
38
|
-
get(key) {
|
|
39
|
-
var _a;
|
|
40
|
-
return (_a = store.get(key)) === null || _a === void 0 ? void 0 : _a.value;
|
|
41
|
-
},
|
|
42
|
-
set(key, value) {
|
|
43
|
-
store.set(key, { value, lastSeenAt: Date.now() });
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
-
* http://github.com/fonoster/fonoster
|
|
4
|
-
*
|
|
5
|
-
* This file is part of Fonoster
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the MIT License (the "License");
|
|
8
|
-
* you may not use this file except in compliance with
|
|
9
|
-
* the License. You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* https://opensource.org/licenses/MIT
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
import { CallDirection } from "@fonoster/types";
|
|
20
|
-
declare function mapCallDirectionToEnum(direction: string): CallDirection;
|
|
21
|
-
export { mapCallDirectionToEnum };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapCallDirectionToEnum = mapCallDirectionToEnum;
|
|
4
|
-
/**
|
|
5
|
-
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
6
|
-
* http://github.com/fonoster/fonoster
|
|
7
|
-
*
|
|
8
|
-
* This file is part of Fonoster
|
|
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 types_1 = require("@fonoster/types");
|
|
23
|
-
function mapCallDirectionToEnum(direction) {
|
|
24
|
-
switch (direction) {
|
|
25
|
-
case "from-pstn":
|
|
26
|
-
return types_1.CallDirection.FROM_PSTN;
|
|
27
|
-
case "peer-to-pstn":
|
|
28
|
-
case "agent-to-pstn":
|
|
29
|
-
return types_1.CallDirection.TO_PSTN;
|
|
30
|
-
case "agent-to-agent":
|
|
31
|
-
case "agent-to-peer":
|
|
32
|
-
case "peer-to-agent":
|
|
33
|
-
return types_1.CallDirection.INTRA_NETWORK;
|
|
34
|
-
default:
|
|
35
|
-
throw new Error(`Invalid call direction: ${direction}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
package/dist/events/nats.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
-
* http://github.com/fonoster/fonoster
|
|
4
|
-
*
|
|
5
|
-
* This file is part of Fonoster
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the MIT License (the "License");
|
|
8
|
-
* you may not use this file except in compliance with
|
|
9
|
-
* the License. You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* https://opensource.org/licenses/MIT
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
import { NatsTarget } from "@fonoster/common";
|
|
20
|
-
import { Point } from "@influxdata/influxdb-client";
|
|
21
|
-
import { NatsConnection } from "nats";
|
|
22
|
-
import { CallRefStore } from "./callRefs";
|
|
23
|
-
/**
|
|
24
|
-
* One replica of the queue group handles each Routr call event (control-plane "Events processed
|
|
25
|
-
* once"): without it every replica wrote its own CDR points for every call (ST-1).
|
|
26
|
-
*/
|
|
27
|
-
export declare const CALL_EVENTS_QUEUE = "apiserver-cdr";
|
|
28
|
-
/**
|
|
29
|
-
* Subscribes to Routr's call events and writes one CDR point per event. Returns the unsubscribe
|
|
30
|
-
* function once the subscription is registered on the server.
|
|
31
|
-
*/
|
|
32
|
-
declare function subscribeCallEvents(nc: NatsConnection, write: (point: Point) => void, options?: {
|
|
33
|
-
refs?: CallRefStore;
|
|
34
|
-
queue?: string;
|
|
35
|
-
}): Promise<() => void>;
|
|
36
|
-
/**
|
|
37
|
-
* This method listens for call events from Routr and writes them as CDR points.
|
|
38
|
-
*
|
|
39
|
-
* @param {string} natsUrl - The NATS server URL
|
|
40
|
-
* @param {Function} write - Writes one point (InfluxDB)
|
|
41
|
-
* @return {void}
|
|
42
|
-
*/
|
|
43
|
-
declare function watchNats(nats: NatsTarget, write: (point: Point) => void): void;
|
|
44
|
-
export { subscribeCallEvents, watchNats };
|