@fonoster/apiserver 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.
@@ -1,4 +1,4 @@
1
- import { InfluxDBClient } from "./types";
1
+ import { InfluxDBClient } from "@fonoster/common";
2
2
  declare function buildService(influxdb: InfluxDBClient): Promise<{
3
3
  definition: {
4
4
  serviceName: string;
@@ -1,3 +1,4 @@
1
- import { InfluxDBClient, ListCallsRequest, ListCallsResponse } from "./types";
1
+ import { ListCallsRequest, ListCallsResponse } from "@fonoster/types";
2
+ import { InfluxDBClient } from "@fonoster/common";
2
3
  declare function createFetchCalls(influxdb: InfluxDBClient): (accessKeyId: string, request: ListCallsRequest) => Promise<ListCallsResponse>;
3
4
  export { createFetchCalls };
@@ -30,8 +30,7 @@ exports.createFetchCalls = createFetchCalls;
30
30
  */
31
31
  const logger_1 = require("@fonoster/logger");
32
32
  const influxdb_client_1 = require("@influxdata/influxdb-client");
33
- const types_1 = require("./types");
34
- const envs_1 = require("../envs");
33
+ const common_1 = require("@fonoster/common");
35
34
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
36
35
  function createFetchCalls(influxdb) {
37
36
  return (accessKeyId, request) => __awaiter(this, void 0, void 0, function* () {
@@ -51,7 +50,7 @@ function createFetchCalls(influxdb) {
51
50
  const parsedBefore = before
52
51
  ? new Date(before).getTime() / 1000
53
52
  : new Date().getTime() / 1000;
54
- const query = (0, influxdb_client_1.flux) `from(bucket: "${envs_1.INFLUXDB_BUCKET}")
53
+ const query = (0, influxdb_client_1.flux) `from(bucket: "${common_1.INFLUXDB_CALLS_BUCKET}")
55
54
  |> range(start: ${parsedAfter})
56
55
  |> pivot(rowKey: ["callId"], columnKey: ["_field"], valueColumn: "_value")
57
56
  |> map(fn: (r) => ({
@@ -60,7 +59,7 @@ function createFetchCalls(influxdb) {
60
59
  startedAtParsed: int(v: r.startedAt) / 1000,
61
60
  }))
62
61
  |> filter(fn: (r) =>
63
- r._measurement == "${types_1.CALL_DETAIL_RECORD_MEASUREMENT}"
62
+ r._measurement == "${common_1.CALL_DETAIL_RECORD_MEASUREMENT}"
64
63
  and r.startedAtParsed < ${parsedBefore}
65
64
  ${accessKeyIdFilter}
66
65
  ${typeFilter}
@@ -1,3 +1,4 @@
1
- import { CallDetailRecord, InfluxDBClient } from "./types";
1
+ import { CallDetailRecord } from "@fonoster/types";
2
+ import { InfluxDBClient } from "@fonoster/common";
2
3
  declare function createFetchSingleCall(influxdb: InfluxDBClient): (accessKeyId: string, ref: string) => Promise<CallDetailRecord>;
3
4
  export { createFetchSingleCall };
@@ -30,19 +30,18 @@ exports.createFetchSingleCall = createFetchSingleCall;
30
30
  */
31
31
  const logger_1 = require("@fonoster/logger");
32
32
  const influxdb_client_1 = require("@influxdata/influxdb-client");
33
- const types_1 = require("./types");
34
- const envs_1 = require("../envs");
33
+ const common_1 = require("@fonoster/common");
35
34
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
36
35
  function createFetchSingleCall(influxdb) {
37
36
  return (accessKeyId, ref) => __awaiter(this, void 0, void 0, function* () {
38
- const query = (0, influxdb_client_1.flux) `from(bucket: "${envs_1.INFLUXDB_BUCKET}")
37
+ const query = (0, influxdb_client_1.flux) `from(bucket: "${common_1.INFLUXDB_CALLS_BUCKET}")
39
38
  |> range(start: -360d)
40
39
  |> pivot(rowKey: ["callId"], columnKey: ["_field"], valueColumn: "_value")
41
40
  |> map(fn: (r) => ({
42
41
  r with
43
42
  duration: int(v: r.endedAt) - int(v: r.startedAt)
44
43
  }))
45
- |> filter(fn: (r) => r._measurement == "${types_1.CALL_DETAIL_RECORD_MEASUREMENT}")
44
+ |> filter(fn: (r) => r._measurement == "${common_1.CALL_DETAIL_RECORD_MEASUREMENT}")
46
45
  |> filter(fn: (r) => r.ref == ${ref} and r.accessKeyId == "${accessKeyId}")
47
46
  |> sort(columns: ["_time"], desc: true)
48
47
  |> limit(n: 1)`;
@@ -1,5 +1,4 @@
1
- import { GrpcErrorMessage } from "@fonoster/common";
2
- import { InfluxDBClient } from "./types";
1
+ import { GrpcErrorMessage, InfluxDBClient } from "@fonoster/common";
3
2
  declare function getCall(influx: InfluxDBClient): (call: {
4
3
  request: unknown;
5
4
  }, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
@@ -1,5 +1,4 @@
1
- import { GrpcErrorMessage } from "@fonoster/common";
2
- import { InfluxDBClient } from "./types";
1
+ import { GrpcErrorMessage, InfluxDBClient } from "@fonoster/common";
3
2
  declare function listCalls(influx: InfluxDBClient): (call: {
4
3
  request: unknown;
5
4
  }, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
@@ -1,19 +1,5 @@
1
1
  import { DialStatus, GrpcErrorMessage } from "@fonoster/common";
2
- import { CallDirection, CallStatus, CallType } from "@fonoster/types";
3
- import { ParameterizedQuery } from "@influxdata/influxdb-client";
4
- declare const CALL_DETAIL_RECORD_MEASUREMENT = "cdr";
5
- type CallDetailRecord = {
6
- ref: string;
7
- callId: string;
8
- status: CallStatus;
9
- type: CallType;
10
- from: string;
11
- to: string;
12
- duration: number;
13
- direction: CallDirection;
14
- startedAt: number;
15
- endedAt: number;
16
- };
2
+ import { CallDetailRecord, CallStatus, CallType } from "@fonoster/types";
17
3
  type ListCallsRequest = {
18
4
  after?: string;
19
5
  before?: string;
@@ -31,9 +17,6 @@ type ListCallsResponse = {
31
17
  type GetCallRequest = {
32
18
  ref: string;
33
19
  };
34
- type InfluxDBClient = {
35
- collectRows(query: ParameterizedQuery): Promise<unknown[]>;
36
- };
37
20
  type CreateCallRequest = {
38
21
  from: string;
39
22
  to: string;
@@ -59,4 +42,4 @@ type TrackCallSubscriber = {
59
42
  on: (event: string, cb: (data: TrackCallResponse | Error) => void) => void;
60
43
  };
61
44
  };
62
- export { CALL_DETAIL_RECORD_MEASUREMENT, CallDetailRecord, CallDirection, CallPublisher, CallStatus, CallStream, CallType, CreateCallRequest, GetCallRequest, InfluxDBClient, ListCallsRequest, ListCallsResponse, TrackCallResponse, TrackCallSubscriber };
45
+ export { CallPublisher, CallStream, CreateCallRequest, GetCallRequest, ListCallsRequest, ListCallsResponse, TrackCallResponse, TrackCallSubscriber };
@@ -1,9 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CallType = exports.CallStatus = exports.CallDirection = exports.CALL_DETAIL_RECORD_MEASUREMENT = void 0;
4
- const types_1 = require("@fonoster/types");
5
- Object.defineProperty(exports, "CallDirection", { enumerable: true, get: function () { return types_1.CallDirection; } });
6
- Object.defineProperty(exports, "CallStatus", { enumerable: true, get: function () { return types_1.CallStatus; } });
7
- Object.defineProperty(exports, "CallType", { enumerable: true, get: function () { return types_1.CallType; } });
8
- const CALL_DETAIL_RECORD_MEASUREMENT = "cdr";
9
- exports.CALL_DETAIL_RECORD_MEASUREMENT = CALL_DETAIL_RECORD_MEASUREMENT;
package/dist/envs.d.ts CHANGED
@@ -27,7 +27,6 @@ export declare const AUTHZ_SERVICE_ENABLED: boolean;
27
27
  export declare const AUTHZ_SERVICE_HOST: string;
28
28
  export declare const AUTHZ_SERVICE_PORT: string | number;
29
29
  export declare const AUTHZ_SERVICE_METHODS: string[];
30
- export declare const INFLUXDB_BUCKET: string;
31
30
  export declare const INFLUXDB_ORG: string;
32
31
  export declare const INFLUXDB_PASSWORD: string;
33
32
  export declare const INFLUXDB_TOKEN: string;
package/dist/envs.js CHANGED
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.SMTP_SECURE = exports.SMTP_PORT = exports.SMTP_HOST = exports.SMTP_AUTH_USER = exports.SMTP_AUTH_PASS = exports.ROUTR_DEFAULT_PEER_USERNAME = exports.ROUTR_DEFAULT_PEER_PASSWORD = exports.ROUTR_DEFAULT_PEER_NAME = exports.ROUTR_DEFAULT_PEER_AOR = exports.ROUTR_API_ENDPOINT = exports.OWNER_PASSWORD = exports.OWNER_NAME = exports.OWNER_EMAIL = exports.NATS_URL = exports.INTEGRATIONS_FILE = exports.INFLUXDB_USERNAME = exports.INFLUXDB_URL = exports.INFLUXDB_TOKEN = exports.INFLUXDB_PASSWORD = exports.INFLUXDB_ORG = exports.INFLUXDB_BUCKET = exports.AUTHZ_SERVICE_METHODS = exports.AUTHZ_SERVICE_PORT = exports.AUTHZ_SERVICE_HOST = exports.AUTHZ_SERVICE_ENABLED = exports.IDENTITY_WORKSPACE_INVITATION_FAIL_URL = exports.IDENTITY_REFRESH_TOKEN_EXPIRES_IN = exports.IDENTITY_PUBLIC_KEY = exports.IDENTITY_PRIVATE_KEY = exports.IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET = exports.IDENTITY_OAUTH2_GITHUB_CLIENT_ID = exports.IDENTITY_OAUTH2_GITHUB_ENABLED = exports.IDENTITY_USER_VERIFICATION_REQUIRED = exports.IDENTITY_ISSUER = exports.IDENTITY_ID_TOKEN_EXPIRES_IN = exports.IDENTITY_AUDIENCE = exports.IDENTITY_ACCESS_TOKEN_EXPIRES_IN = exports.HTTP_BRIDGE_PORT = exports.DEFAULT_NATS_QUEUE_GROUP = exports.CLOAK_ENCRYPTION_KEY = exports.CALLS_TRACK_CALL_SUBJECT = exports.CALLS_CREATE_SUBJECT = exports.ASTERISK_TRUNK = exports.ASTERISK_SYSTEM_DOMAIN = exports.ASTERISK_ARI_USERNAME = exports.ASTERISK_ARI_SECRET = exports.ASTERISK_ARI_PROXY_URL = exports.APP_URL = exports.APISERVER_HOST = exports.APISERVER_BIND_ADDR = void 0;
8
- exports.TWILIO_PHONE_NUMBER = exports.TWILIO_AUTH_TOKEN = exports.TWILIO_ACCOUNT_SID = exports.TEMPLATES_DIR = exports.SMTP_SENDER = void 0;
7
+ exports.SMTP_SENDER = exports.SMTP_SECURE = exports.SMTP_PORT = exports.SMTP_HOST = exports.SMTP_AUTH_USER = exports.SMTP_AUTH_PASS = exports.ROUTR_DEFAULT_PEER_USERNAME = exports.ROUTR_DEFAULT_PEER_PASSWORD = exports.ROUTR_DEFAULT_PEER_NAME = exports.ROUTR_DEFAULT_PEER_AOR = exports.ROUTR_API_ENDPOINT = exports.OWNER_PASSWORD = exports.OWNER_NAME = exports.OWNER_EMAIL = exports.NATS_URL = exports.INTEGRATIONS_FILE = exports.INFLUXDB_USERNAME = exports.INFLUXDB_URL = exports.INFLUXDB_TOKEN = exports.INFLUXDB_PASSWORD = exports.INFLUXDB_ORG = exports.AUTHZ_SERVICE_METHODS = exports.AUTHZ_SERVICE_PORT = exports.AUTHZ_SERVICE_HOST = exports.AUTHZ_SERVICE_ENABLED = exports.IDENTITY_WORKSPACE_INVITATION_FAIL_URL = exports.IDENTITY_REFRESH_TOKEN_EXPIRES_IN = exports.IDENTITY_PUBLIC_KEY = exports.IDENTITY_PRIVATE_KEY = exports.IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET = exports.IDENTITY_OAUTH2_GITHUB_CLIENT_ID = exports.IDENTITY_OAUTH2_GITHUB_ENABLED = exports.IDENTITY_USER_VERIFICATION_REQUIRED = exports.IDENTITY_ISSUER = exports.IDENTITY_ID_TOKEN_EXPIRES_IN = exports.IDENTITY_AUDIENCE = exports.IDENTITY_ACCESS_TOKEN_EXPIRES_IN = exports.HTTP_BRIDGE_PORT = exports.DEFAULT_NATS_QUEUE_GROUP = exports.CLOAK_ENCRYPTION_KEY = exports.CALLS_TRACK_CALL_SUBJECT = exports.CALLS_CREATE_SUBJECT = exports.ASTERISK_TRUNK = exports.ASTERISK_SYSTEM_DOMAIN = exports.ASTERISK_ARI_USERNAME = exports.ASTERISK_ARI_SECRET = exports.ASTERISK_ARI_PROXY_URL = exports.APP_URL = exports.APISERVER_HOST = exports.APISERVER_BIND_ADDR = void 0;
8
+ exports.TWILIO_PHONE_NUMBER = exports.TWILIO_AUTH_TOKEN = exports.TWILIO_ACCOUNT_SID = exports.TEMPLATES_DIR = void 0;
9
9
  /*
10
10
  * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
11
11
  * http://github.com/fonoster/fonoster
@@ -49,7 +49,6 @@ const e = process.env;
49
49
  "INFLUXDB_INIT_USERNAME",
50
50
  "INFLUXDB_INIT_PASSWORD",
51
51
  "INFLUXDB_INIT_ORG",
52
- "INFLUXDB_INIT_BUCKET",
53
52
  "INFLUXDB_INIT_TOKEN",
54
53
  "NATS_URL"
55
54
  ]);
@@ -102,7 +101,6 @@ exports.AUTHZ_SERVICE_METHODS = e.AUTHZ_SERVICE_METHODS
102
101
  ? e.AUTHZ_SERVICE_METHODS.split(",")
103
102
  : ["/fonoster.calls.v1beta2.Calls/CreateCall"];
104
103
  // InfluxDB configurations
105
- exports.INFLUXDB_BUCKET = e.INFLUXDB_INIT_BUCKET;
106
104
  exports.INFLUXDB_ORG = e.INFLUXDB_INIT_ORG;
107
105
  exports.INFLUXDB_PASSWORD = e.INFLUXDB_INIT_PASSWORD;
108
106
  exports.INFLUXDB_TOKEN = e.INFLUXDB_INIT_TOKEN;
@@ -1,3 +1,3 @@
1
- import { CallDirection } from "../calls/types";
1
+ import { CallDirection } from "@fonoster/types";
2
2
  declare function mapCallDirectionToEnum(direction: string): CallDirection;
3
3
  export { mapCallDirectionToEnum };
@@ -19,7 +19,7 @@ exports.mapCallDirectionToEnum = mapCallDirectionToEnum;
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
- const types_1 = require("../calls/types");
22
+ const types_1 = require("@fonoster/types");
23
23
  function mapCallDirectionToEnum(direction) {
24
24
  switch (direction) {
25
25
  case "from-pstn":
package/dist/index.js CHANGED
@@ -66,13 +66,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
66
66
  */
67
67
  const identity_1 = require("@fonoster/identity");
68
68
  const logger_1 = require("@fonoster/logger");
69
- const types_1 = require("./calls/types");
70
69
  const runServices_1 = __importDefault(require("./core/runServices"));
71
70
  const upsertDefaultPeer_1 = require("./core/upsertDefaultPeer");
72
71
  const envs_1 = require("./envs");
73
72
  const createInfluxDbPub_1 = require("./events/createInfluxDbPub");
74
73
  const nats_1 = require("./events/nats");
75
74
  const transformEvent_1 = require("./events/transformEvent");
75
+ const common_1 = require("@fonoster/common");
76
76
  Promise.resolve().then(() => __importStar(require("./core/removeSwaggerNotice")));
77
77
  function main() {
78
78
  return __awaiter(this, void 0, void 0, function* () {
@@ -92,13 +92,13 @@ function main() {
92
92
  url: envs_1.INFLUXDB_URL,
93
93
  token: envs_1.INFLUXDB_TOKEN,
94
94
  org: envs_1.INFLUXDB_ORG,
95
- bucket: envs_1.INFLUXDB_BUCKET
95
+ bucket: common_1.INFLUXDB_CALLS_BUCKET
96
96
  });
97
97
  // Subscribe to NATs events
98
98
  (0, nats_1.watchNats)(envs_1.NATS_URL, (event) => {
99
99
  logger.verbose("received nats event", Object.assign({}, event));
100
100
  pubToInfluxDb({
101
- name: types_1.CALL_DETAIL_RECORD_MEASUREMENT,
101
+ name: common_1.CALL_DETAIL_RECORD_MEASUREMENT,
102
102
  tag: event.callId,
103
103
  data: (0, transformEvent_1.transformEvent)(event)
104
104
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/apiserver",
3
- "version": "0.8.20",
3
+ "version": "0.8.21",
4
4
  "description": "APIServer for Fonoster",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -21,13 +21,13 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@deepgram/sdk": "^3.5.1",
24
- "@fonoster/authz": "^0.8.20",
25
- "@fonoster/common": "^0.8.20",
26
- "@fonoster/identity": "^0.8.20",
24
+ "@fonoster/authz": "^0.8.21",
25
+ "@fonoster/common": "^0.8.21",
26
+ "@fonoster/identity": "^0.8.21",
27
27
  "@fonoster/logger": "^0.8.20",
28
- "@fonoster/sipnet": "^0.8.20",
28
+ "@fonoster/sipnet": "^0.8.21",
29
29
  "@fonoster/streams": "^0.8.20",
30
- "@fonoster/types": "^0.8.20",
30
+ "@fonoster/types": "^0.8.21",
31
31
  "@google-cloud/speech": "^6.6.0",
32
32
  "@google-cloud/text-to-speech": "^5.3.0",
33
33
  "@grpc/grpc-js": "~1.10.6",
@@ -73,5 +73,5 @@
73
73
  "@types/uuid": "^10.0.0",
74
74
  "@types/validator": "^13.12.0"
75
75
  },
76
- "gitHead": "4e605a379fec5ac31bf0a3d2f57cbd54da6c732b"
76
+ "gitHead": "2590a20d7309494faca50831ac0c0abdb14c2308"
77
77
  }