@fonoster/apiserver 0.8.45 → 0.8.46

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.
@@ -29,6 +29,7 @@ const allowList = [
29
29
  "/fonoster.identity.v1beta2.Identity/ExchangeRefreshToken",
30
30
  "/fonoster.identity.v1beta2.Identity/SendVerificationCode",
31
31
  "/fonoster.identity.v1beta2.Identity/VerifyCode",
32
- "/fonoster.identity.v1beta2.Identity/GetPublicKey"
32
+ "/fonoster.identity.v1beta2.Identity/GetPublicKey",
33
+ "/fonoster.voice.v1beta2.Voice/CreateSession",
33
34
  ];
34
35
  exports.allowList = allowList;
@@ -0,0 +1,13 @@
1
+ import { VoiceSessionStreamServer } from "@fonoster/common";
2
+ declare function buildWelcomeDemoService(): {
3
+ definition: {
4
+ readonly serviceName: "Voice";
5
+ readonly pckg: "voice";
6
+ readonly version: "v1beta2";
7
+ readonly proto: "voice.proto";
8
+ };
9
+ handlers: {
10
+ createSession: (voice: VoiceSessionStreamServer) => void;
11
+ };
12
+ };
13
+ export { buildWelcomeDemoService };
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildWelcomeDemoService = buildWelcomeDemoService;
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 common_1 = require("@fonoster/common");
23
+ const logger_1 = require("@fonoster/logger");
24
+ const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
25
+ const SERVICE_DEFINITION = {
26
+ serviceName: "Voice",
27
+ pckg: "voice",
28
+ version: "v1beta2",
29
+ proto: "voice.proto"
30
+ };
31
+ function buildWelcomeDemoService() {
32
+ return {
33
+ definition: SERVICE_DEFINITION,
34
+ handlers: {
35
+ createSession: (voice) => {
36
+ let sessionRef;
37
+ voice.on(common_1.StreamEvent.DATA, (params) => {
38
+ try {
39
+ const { request, sayResponse } = params;
40
+ if (request) {
41
+ const { callerNumber } = request;
42
+ sessionRef = request.sessionRef;
43
+ logger.verbose("welcome demo session started", { sessionRef, callerNumber });
44
+ voice.write({
45
+ answerRequest: {
46
+ sessionRef: request.sessionRef
47
+ }
48
+ });
49
+ voice.write({
50
+ sayRequest: {
51
+ text: "Welcome to Fonoster! Your system is configured correctly and ready for voice application development. Goodbye!",
52
+ sessionRef: request.sessionRef
53
+ }
54
+ });
55
+ }
56
+ if (sayResponse && sessionRef) {
57
+ logger.verbose("hanging up welcome demo session", { sessionRef });
58
+ voice.write({
59
+ hangupRequest: {
60
+ sessionRef
61
+ }
62
+ });
63
+ }
64
+ }
65
+ catch (error) {
66
+ logger.error("error in welcome demo session", { sessionRef, error });
67
+ if (sessionRef) {
68
+ voice.write({
69
+ hangupRequest: { sessionRef }
70
+ });
71
+ }
72
+ voice.end();
73
+ }
74
+ });
75
+ voice.once(common_1.StreamEvent.END, () => {
76
+ voice.end();
77
+ logger.verbose("welcome demo session ended", { sessionRef });
78
+ });
79
+ voice.on(common_1.StreamEvent.ERROR, (error) => {
80
+ logger.error("stream error in welcome demo session", { sessionRef, error });
81
+ voice.end();
82
+ });
83
+ }
84
+ }
85
+ };
86
+ }
@@ -285,5 +285,15 @@ declare const services: Promise<[{
285
285
  request: unknown;
286
286
  }, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
287
287
  };
288
+ }, {
289
+ definition: {
290
+ readonly serviceName: "Voice";
291
+ readonly pckg: "voice";
292
+ readonly version: "v1beta2";
293
+ readonly proto: "voice.proto";
294
+ };
295
+ handlers: {
296
+ createSession: (voice: import("@fonoster/common").VoiceSessionStreamServer) => void;
297
+ };
288
298
  }]>;
289
299
  export default services;
@@ -28,6 +28,7 @@ const calls_1 = require("../calls");
28
28
  const influxdb_1 = require("../calls/influxdb");
29
29
  const secrets_1 = require("../secrets");
30
30
  const utils_1 = require("../utils");
31
+ const buildWelcomeDemoService_1 = require("./buildWelcomeDemoService");
31
32
  const applicationsService = (0, applications_1.buildApplicationsService)(db_1.prisma);
32
33
  const secretsService = (0, secrets_1.buildSecretsService)(db_1.prisma);
33
34
  const callsService = (0, calls_1.buildCallsService)(influxdb_1.influxdb);
@@ -38,6 +39,7 @@ const credentialsService = (0, sipnet_1.buildCredentialsService)(routrConfig_1.r
38
39
  const trunksService = (0, sipnet_1.buildTrunksService)(routrConfig_1.routrConfig);
39
40
  const numbersService = (0, sipnet_1.buildNumbersService)(routrConfig_1.routrConfig, (0, utils_1.createCheckNumberPreconditions)(db_1.prisma));
40
41
  const aclsService = (0, sipnet_1.buildAclsService)(routrConfig_1.routrConfig);
42
+ const welcomeDemoService = (0, buildWelcomeDemoService_1.buildWelcomeDemoService)();
41
43
  const services = Promise.all([
42
44
  applicationsService,
43
45
  secretsService,
@@ -48,6 +50,7 @@ const services = Promise.all([
48
50
  aclsService,
49
51
  numbersService,
50
52
  trunksService,
51
- domainsService
53
+ domainsService,
54
+ welcomeDemoService
52
55
  ]);
53
56
  exports.default = services;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/apiserver",
3
- "version": "0.8.45",
3
+ "version": "0.8.46",
4
4
  "description": "APIServer for Fonoster",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -73,5 +73,5 @@
73
73
  "@types/uuid": "^10.0.0",
74
74
  "@types/validator": "^13.12.0"
75
75
  },
76
- "gitHead": "5aabc6054bebd038f165d8614a2fd843dafdc1bb"
76
+ "gitHead": "f811ef9df8923fbfee40a9189d47056c4235fd65"
77
77
  }