@fonoster/apiserver 0.8.37 → 0.8.40

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.
@@ -10,9 +10,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createGetFnUtil = createGetFnUtil;
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 badRequestError_1 = require("../core/badRequestError");
13
32
  const notFoundError_1 = require("../core/notFoundError");
14
33
  function createGetFnUtil(prisma) {
15
34
  return (ref) => __awaiter(this, void 0, void 0, function* () {
35
+ if (!ref) {
36
+ throw (0, badRequestError_1.badRequestError)("The reference to the resource is required");
37
+ }
16
38
  const response = yield prisma.application.findUnique({
17
39
  where: { ref },
18
40
  include: {
@@ -6,11 +6,12 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
6
6
  goodbyeMessage: z.ZodString;
7
7
  systemErrorMessage: z.ZodString;
8
8
  initialDtmf: z.ZodOptional<z.ZodString>;
9
- maxSpeechWaitTimeout: z.ZodNumber;
9
+ maxSessionDuration: z.ZodDefault<z.ZodNumber>;
10
+ maxSpeechWaitTimeout: z.ZodDefault<z.ZodNumber>;
10
11
  transferOptions: z.ZodOptional<z.ZodObject<{
11
12
  phoneNumber: z.ZodString;
12
13
  message: z.ZodString;
13
- timeout: z.ZodOptional<z.ZodNumber>;
14
+ timeout: z.ZodDefault<z.ZodNumber>;
14
15
  }, "strip", z.ZodTypeAny, {
15
16
  message?: string;
16
17
  phoneNumber?: string;
@@ -20,10 +21,10 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
20
21
  phoneNumber?: string;
21
22
  timeout?: number;
22
23
  }>>;
23
- idleOptions: z.ZodOptional<z.ZodObject<{
24
+ idleOptions: z.ZodObject<{
24
25
  message: z.ZodString;
25
- timeout: z.ZodNumber;
26
- maxTimeoutCount: z.ZodNumber;
26
+ timeout: z.ZodDefault<z.ZodNumber>;
27
+ maxTimeoutCount: z.ZodDefault<z.ZodNumber>;
27
28
  }, "strip", z.ZodTypeAny, {
28
29
  message?: string;
29
30
  timeout?: number;
@@ -32,8 +33,8 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
32
33
  message?: string;
33
34
  timeout?: number;
34
35
  maxTimeoutCount?: number;
35
- }>>;
36
- vad: z.ZodObject<{
36
+ }>;
37
+ vad: z.ZodDefault<z.ZodObject<{
37
38
  pathToModel: z.ZodOptional<z.ZodString>;
38
39
  activationThreshold: z.ZodNumber;
39
40
  deactivationThreshold: z.ZodNumber;
@@ -48,13 +49,14 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
48
49
  activationThreshold?: number;
49
50
  deactivationThreshold?: number;
50
51
  debounceFrames?: number;
51
- }>;
52
+ }>>;
52
53
  }, "strip", z.ZodTypeAny, {
53
54
  firstMessage?: string;
54
55
  systemTemplate?: string;
55
56
  goodbyeMessage?: string;
56
57
  systemErrorMessage?: string;
57
58
  initialDtmf?: string;
59
+ maxSessionDuration?: number;
58
60
  maxSpeechWaitTimeout?: number;
59
61
  transferOptions?: {
60
62
  message?: string;
@@ -78,6 +80,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
78
80
  goodbyeMessage?: string;
79
81
  systemErrorMessage?: string;
80
82
  initialDtmf?: string;
83
+ maxSessionDuration?: number;
81
84
  maxSpeechWaitTimeout?: number;
82
85
  transferOptions?: {
83
86
  message?: string;
@@ -103,7 +106,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
103
106
  temperature: z.ZodNumber;
104
107
  maxTokens: z.ZodNumber;
105
108
  baseUrl: z.ZodOptional<z.ZodString>;
106
- knowledgeBase: z.ZodArray<z.ZodObject<{
109
+ knowledgeBase: z.ZodDefault<z.ZodArray<z.ZodObject<{
107
110
  type: z.ZodEnum<["s3"]>;
108
111
  title: z.ZodString;
109
112
  document: z.ZodString;
@@ -115,8 +118,8 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
115
118
  type?: "s3";
116
119
  title?: string;
117
120
  document?: string;
118
- }>, "many">;
119
- tools: z.ZodArray<z.ZodObject<{
121
+ }>, "many">>;
122
+ tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
120
123
  name: z.ZodString;
121
124
  description: z.ZodString;
122
125
  parameters: z.ZodObject<{
@@ -225,7 +228,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
225
228
  waitForResponse?: boolean;
226
229
  headers?: Record<string, string>;
227
230
  };
228
- }>, "many">;
231
+ }>, "many">>;
229
232
  }, "strip", z.ZodTypeAny, {
230
233
  provider?: import("@fonoster/common").LanguageModelProvider;
231
234
  apiKey?: string;
@@ -299,7 +302,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
299
302
  temperature: z.ZodNumber;
300
303
  maxTokens: z.ZodNumber;
301
304
  baseUrl: z.ZodOptional<z.ZodString>;
302
- knowledgeBase: z.ZodArray<z.ZodObject<{
305
+ knowledgeBase: z.ZodDefault<z.ZodArray<z.ZodObject<{
303
306
  type: z.ZodEnum<["s3"]>;
304
307
  title: z.ZodString;
305
308
  document: z.ZodString;
@@ -311,8 +314,8 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
311
314
  type?: "s3";
312
315
  title?: string;
313
316
  document?: string;
314
- }>, "many">;
315
- tools: z.ZodArray<z.ZodObject<{
317
+ }>, "many">>;
318
+ tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
316
319
  name: z.ZodString;
317
320
  description: z.ZodString;
318
321
  parameters: z.ZodObject<{
@@ -421,7 +424,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
421
424
  waitForResponse?: boolean;
422
425
  headers?: Record<string, string>;
423
426
  };
424
- }>, "many">;
427
+ }>, "many">>;
425
428
  }, "strip", z.ZodTypeAny, {
426
429
  provider?: import("@fonoster/common").LanguageModelProvider;
427
430
  apiKey?: string;
@@ -591,6 +594,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
591
594
  goodbyeMessage?: string;
592
595
  systemErrorMessage?: string;
593
596
  initialDtmf?: string;
597
+ maxSessionDuration?: number;
594
598
  maxSpeechWaitTimeout?: number;
595
599
  transferOptions?: {
596
600
  message?: string;
@@ -649,6 +653,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
649
653
  goodbyeMessage?: string;
650
654
  systemErrorMessage?: string;
651
655
  initialDtmf?: string;
656
+ maxSessionDuration?: number;
652
657
  maxSpeechWaitTimeout?: number;
653
658
  transferOptions?: {
654
659
  message?: string;
@@ -44,11 +44,12 @@ declare function createValidationSchema(request: {
44
44
  goodbyeMessage: z.ZodString;
45
45
  systemErrorMessage: z.ZodString;
46
46
  initialDtmf: z.ZodOptional<z.ZodString>;
47
- maxSpeechWaitTimeout: z.ZodNumber;
47
+ maxSessionDuration: z.ZodDefault<z.ZodNumber>;
48
+ maxSpeechWaitTimeout: z.ZodDefault<z.ZodNumber>;
48
49
  transferOptions: z.ZodOptional<z.ZodObject<{
49
50
  phoneNumber: z.ZodString;
50
51
  message: z.ZodString;
51
- timeout: z.ZodOptional<z.ZodNumber>;
52
+ timeout: z.ZodDefault<z.ZodNumber>;
52
53
  }, "strip", z.ZodTypeAny, {
53
54
  message?: string;
54
55
  phoneNumber?: string;
@@ -58,10 +59,10 @@ declare function createValidationSchema(request: {
58
59
  phoneNumber?: string;
59
60
  timeout?: number;
60
61
  }>>;
61
- idleOptions: z.ZodOptional<z.ZodObject<{
62
+ idleOptions: z.ZodObject<{
62
63
  message: z.ZodString;
63
- timeout: z.ZodNumber;
64
- maxTimeoutCount: z.ZodNumber;
64
+ timeout: z.ZodDefault<z.ZodNumber>;
65
+ maxTimeoutCount: z.ZodDefault<z.ZodNumber>;
65
66
  }, "strip", z.ZodTypeAny, {
66
67
  message?: string;
67
68
  timeout?: number;
@@ -70,8 +71,8 @@ declare function createValidationSchema(request: {
70
71
  message?: string;
71
72
  timeout?: number;
72
73
  maxTimeoutCount?: number;
73
- }>>;
74
- vad: z.ZodObject<{
74
+ }>;
75
+ vad: z.ZodDefault<z.ZodObject<{
75
76
  pathToModel: z.ZodOptional<z.ZodString>;
76
77
  activationThreshold: z.ZodNumber;
77
78
  deactivationThreshold: z.ZodNumber;
@@ -86,13 +87,14 @@ declare function createValidationSchema(request: {
86
87
  activationThreshold?: number;
87
88
  deactivationThreshold?: number;
88
89
  debounceFrames?: number;
89
- }>;
90
+ }>>;
90
91
  }, "strip", z.ZodTypeAny, {
91
92
  firstMessage?: string;
92
93
  systemTemplate?: string;
93
94
  goodbyeMessage?: string;
94
95
  systemErrorMessage?: string;
95
96
  initialDtmf?: string;
97
+ maxSessionDuration?: number;
96
98
  maxSpeechWaitTimeout?: number;
97
99
  transferOptions?: {
98
100
  message?: string;
@@ -116,6 +118,7 @@ declare function createValidationSchema(request: {
116
118
  goodbyeMessage?: string;
117
119
  systemErrorMessage?: string;
118
120
  initialDtmf?: string;
121
+ maxSessionDuration?: number;
119
122
  maxSpeechWaitTimeout?: number;
120
123
  transferOptions?: {
121
124
  message?: string;
@@ -141,7 +144,7 @@ declare function createValidationSchema(request: {
141
144
  temperature: z.ZodNumber;
142
145
  maxTokens: z.ZodNumber;
143
146
  baseUrl: z.ZodOptional<z.ZodString>;
144
- knowledgeBase: z.ZodArray<z.ZodObject<{
147
+ knowledgeBase: z.ZodDefault<z.ZodArray<z.ZodObject<{
145
148
  type: z.ZodEnum<["s3"]>;
146
149
  title: z.ZodString;
147
150
  document: z.ZodString;
@@ -153,8 +156,8 @@ declare function createValidationSchema(request: {
153
156
  type?: "s3";
154
157
  title?: string;
155
158
  document?: string;
156
- }>, "many">;
157
- tools: z.ZodArray<z.ZodObject<{
159
+ }>, "many">>;
160
+ tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
158
161
  name: z.ZodString;
159
162
  description: z.ZodString;
160
163
  parameters: z.ZodObject<{
@@ -263,7 +266,7 @@ declare function createValidationSchema(request: {
263
266
  waitForResponse?: boolean;
264
267
  headers?: Record<string, string>;
265
268
  };
266
- }>, "many">;
269
+ }>, "many">>;
267
270
  }, "strip", z.ZodTypeAny, {
268
271
  provider?: import("@fonoster/common").LanguageModelProvider;
269
272
  apiKey?: string;
@@ -337,7 +340,7 @@ declare function createValidationSchema(request: {
337
340
  temperature: z.ZodNumber;
338
341
  maxTokens: z.ZodNumber;
339
342
  baseUrl: z.ZodOptional<z.ZodString>;
340
- knowledgeBase: z.ZodArray<z.ZodObject<{
343
+ knowledgeBase: z.ZodDefault<z.ZodArray<z.ZodObject<{
341
344
  type: z.ZodEnum<["s3"]>;
342
345
  title: z.ZodString;
343
346
  document: z.ZodString;
@@ -349,8 +352,8 @@ declare function createValidationSchema(request: {
349
352
  type?: "s3";
350
353
  title?: string;
351
354
  document?: string;
352
- }>, "many">;
353
- tools: z.ZodArray<z.ZodObject<{
355
+ }>, "many">>;
356
+ tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
354
357
  name: z.ZodString;
355
358
  description: z.ZodString;
356
359
  parameters: z.ZodObject<{
@@ -459,7 +462,7 @@ declare function createValidationSchema(request: {
459
462
  waitForResponse?: boolean;
460
463
  headers?: Record<string, string>;
461
464
  };
462
- }>, "many">;
465
+ }>, "many">>;
463
466
  }, "strip", z.ZodTypeAny, {
464
467
  provider?: import("@fonoster/common").LanguageModelProvider;
465
468
  apiKey?: string;
@@ -629,6 +632,7 @@ declare function createValidationSchema(request: {
629
632
  goodbyeMessage?: string;
630
633
  systemErrorMessage?: string;
631
634
  initialDtmf?: string;
635
+ maxSessionDuration?: number;
632
636
  maxSpeechWaitTimeout?: number;
633
637
  transferOptions?: {
634
638
  message?: string;
@@ -687,6 +691,7 @@ declare function createValidationSchema(request: {
687
691
  goodbyeMessage?: string;
688
692
  systemErrorMessage?: string;
689
693
  initialDtmf?: string;
694
+ maxSessionDuration?: number;
690
695
  maxSpeechWaitTimeout?: number;
691
696
  transferOptions?: {
692
697
  message?: string;
@@ -747,6 +752,7 @@ declare function createValidationSchema(request: {
747
752
  goodbyeMessage?: string;
748
753
  systemErrorMessage?: string;
749
754
  initialDtmf?: string;
755
+ maxSessionDuration?: number;
750
756
  maxSpeechWaitTimeout?: number;
751
757
  transferOptions?: {
752
758
  message?: string;
@@ -808,6 +814,7 @@ declare function createValidationSchema(request: {
808
814
  goodbyeMessage?: string;
809
815
  systemErrorMessage?: string;
810
816
  initialDtmf?: string;
817
+ maxSessionDuration?: number;
811
818
  maxSpeechWaitTimeout?: number;
812
819
  transferOptions?: {
813
820
  message?: string;
@@ -869,6 +876,7 @@ declare function createValidationSchema(request: {
869
876
  goodbyeMessage?: string;
870
877
  systemErrorMessage?: string;
871
878
  initialDtmf?: string;
879
+ maxSessionDuration?: number;
872
880
  maxSpeechWaitTimeout?: number;
873
881
  transferOptions?: {
874
882
  message?: string;
@@ -930,6 +938,7 @@ declare function createValidationSchema(request: {
930
938
  goodbyeMessage?: string;
931
939
  systemErrorMessage?: string;
932
940
  initialDtmf?: string;
941
+ maxSessionDuration?: number;
933
942
  maxSpeechWaitTimeout?: number;
934
943
  transferOptions?: {
935
944
  message?: string;
@@ -1003,6 +1012,7 @@ declare function createValidationSchema(request: {
1003
1012
  goodbyeMessage?: string;
1004
1013
  systemErrorMessage?: string;
1005
1014
  initialDtmf?: string;
1015
+ maxSessionDuration?: number;
1006
1016
  maxSpeechWaitTimeout?: number;
1007
1017
  transferOptions?: {
1008
1018
  message?: string;
@@ -1079,6 +1089,7 @@ declare function createValidationSchema(request: {
1079
1089
  goodbyeMessage?: string;
1080
1090
  systemErrorMessage?: string;
1081
1091
  initialDtmf?: string;
1092
+ maxSessionDuration?: number;
1082
1093
  maxSpeechWaitTimeout?: number;
1083
1094
  transferOptions?: {
1084
1095
  message?: string;
@@ -0,0 +1,6 @@
1
+ import { status } from "@grpc/grpc-js";
2
+ declare const badRequestError: (message: string) => {
3
+ code: status;
4
+ message: string;
5
+ };
6
+ export { badRequestError };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.badRequestError = void 0;
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 grpc_js_1 = require("@grpc/grpc-js");
23
+ const badRequestError = (message) => ({
24
+ code: grpc_js_1.status.INVALID_ARGUMENT,
25
+ message
26
+ });
27
+ exports.badRequestError = badRequestError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/apiserver",
3
- "version": "0.8.37",
3
+ "version": "0.8.40",
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.36",
25
- "@fonoster/common": "^0.8.36",
26
- "@fonoster/identity": "^0.8.36",
27
- "@fonoster/logger": "^0.8.36",
28
- "@fonoster/sipnet": "^0.8.36",
29
- "@fonoster/streams": "^0.8.36",
30
- "@fonoster/types": "^0.8.36",
24
+ "@fonoster/authz": "^0.8.40",
25
+ "@fonoster/common": "^0.8.40",
26
+ "@fonoster/identity": "^0.8.40",
27
+ "@fonoster/logger": "^0.8.40",
28
+ "@fonoster/sipnet": "^0.8.40",
29
+ "@fonoster/streams": "^0.8.40",
30
+ "@fonoster/types": "^0.8.40",
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": "5c10b1239e9363fa9d0041047bb6f641f5305c65"
76
+ "gitHead": "2bbf3dadb6e1e178c4eefdeb4291a2e05eef0f2b"
77
77
  }