@fonoster/apiserver 0.13.4 → 0.13.6
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 +3 -18
- package/dist/applications/buildService.js +24 -1
- package/dist/applications/validation/assistantWithoutApiKeySchema.d.ts +14 -14
- package/dist/applications/validation/createValidationSchema.d.ts +20 -20
- package/dist/core/services.d.ts +3 -0
- package/dist/utils/getIntegrationsFromFile.d.ts +2 -0
- package/dist/utils/getIntegrationsFromFile.js +49 -0
- package/dist/voice/integrations/createCreateContainer.js +2 -23
- package/dist/voice/integrations/getSttConfig.d.ts +1 -2
- package/dist/voice/integrations/getTtsConfig.d.ts +19 -1
- package/dist/voice/integrations/types.d.ts +1 -5
- package/package.json +10 -9
|
@@ -1,21 +1,3 @@
|
|
|
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
1
|
import { Prisma } from "../core/db";
|
|
20
2
|
declare function buildService(prisma: Prisma): {
|
|
21
3
|
definition: {
|
|
@@ -40,6 +22,9 @@ declare function buildService(prisma: Prisma): {
|
|
|
40
22
|
updateApplication: (call: {
|
|
41
23
|
request: unknown;
|
|
42
24
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
25
|
+
evaluateIntelligence: (call: {
|
|
26
|
+
request: unknown;
|
|
27
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
43
28
|
};
|
|
44
29
|
};
|
|
45
30
|
export { buildService };
|
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildService = buildService;
|
|
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 autopilot_1 = require("@fonoster/autopilot");
|
|
23
|
+
const envs_1 = require("../envs");
|
|
24
|
+
const getIntegrationsFromFile_1 = require("../utils/getIntegrationsFromFile");
|
|
4
25
|
const createCreateApplication_1 = require("./createCreateApplication");
|
|
5
26
|
const createDeleteApplication_1 = require("./createDeleteApplication");
|
|
6
27
|
const createGetApplication_1 = require("./createGetApplication");
|
|
7
28
|
const createListApplications_1 = require("./createListApplications");
|
|
8
29
|
const createUpdateApplication_1 = require("./createUpdateApplication");
|
|
9
30
|
function buildService(prisma) {
|
|
31
|
+
const integrations = (0, getIntegrationsFromFile_1.getIntegrationsFromFile)(envs_1.INTEGRATIONS_FILE);
|
|
10
32
|
return {
|
|
11
33
|
definition: {
|
|
12
34
|
serviceName: "Applications",
|
|
@@ -19,7 +41,8 @@ function buildService(prisma) {
|
|
|
19
41
|
getApplication: (0, createGetApplication_1.createGetApplication)(prisma),
|
|
20
42
|
listApplications: (0, createListApplications_1.createListApplications)(prisma),
|
|
21
43
|
deleteApplication: (0, createDeleteApplication_1.createDeleteApplication)(prisma),
|
|
22
|
-
updateApplication: (0, createUpdateApplication_1.createUpdateApplication)(prisma)
|
|
44
|
+
updateApplication: (0, createUpdateApplication_1.createUpdateApplication)(prisma),
|
|
45
|
+
evaluateIntelligence: (0, autopilot_1.createEvaluateIntelligence)(integrations)
|
|
23
46
|
}
|
|
24
47
|
};
|
|
25
48
|
}
|
|
@@ -119,7 +119,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
119
119
|
evalsLanguageModel: z.ZodObject<{
|
|
120
120
|
provider: z.ZodEnum<["openai"]>;
|
|
121
121
|
model: z.ZodString;
|
|
122
|
-
apiKey: z.ZodString
|
|
122
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
123
123
|
}, "strip", z.ZodTypeAny, {
|
|
124
124
|
provider?: "openai";
|
|
125
125
|
apiKey?: string;
|
|
@@ -153,13 +153,13 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
153
153
|
userInput: z.ZodString;
|
|
154
154
|
expected: z.ZodObject<{
|
|
155
155
|
text: z.ZodObject<{
|
|
156
|
-
type: z.ZodEnum<["
|
|
156
|
+
type: z.ZodEnum<["EXACT", "SIMILAR"]>;
|
|
157
157
|
response: z.ZodString;
|
|
158
158
|
}, "strip", z.ZodTypeAny, {
|
|
159
|
-
type?: "
|
|
159
|
+
type?: "EXACT" | "SIMILAR";
|
|
160
160
|
response?: string;
|
|
161
161
|
}, {
|
|
162
|
-
type?: "
|
|
162
|
+
type?: "EXACT" | "SIMILAR";
|
|
163
163
|
response?: string;
|
|
164
164
|
}>;
|
|
165
165
|
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -178,7 +178,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
178
178
|
tool?: string;
|
|
179
179
|
}[];
|
|
180
180
|
text?: {
|
|
181
|
-
type?: "
|
|
181
|
+
type?: "EXACT" | "SIMILAR";
|
|
182
182
|
response?: string;
|
|
183
183
|
};
|
|
184
184
|
}, {
|
|
@@ -187,7 +187,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
187
187
|
tool?: string;
|
|
188
188
|
}[];
|
|
189
189
|
text?: {
|
|
190
|
-
type?: "
|
|
190
|
+
type?: "EXACT" | "SIMILAR";
|
|
191
191
|
response?: string;
|
|
192
192
|
};
|
|
193
193
|
}>;
|
|
@@ -198,7 +198,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
198
198
|
tool?: string;
|
|
199
199
|
}[];
|
|
200
200
|
text?: {
|
|
201
|
-
type?: "
|
|
201
|
+
type?: "EXACT" | "SIMILAR";
|
|
202
202
|
response?: string;
|
|
203
203
|
};
|
|
204
204
|
};
|
|
@@ -210,7 +210,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
210
210
|
tool?: string;
|
|
211
211
|
}[];
|
|
212
212
|
text?: {
|
|
213
|
-
type?: "
|
|
213
|
+
type?: "EXACT" | "SIMILAR";
|
|
214
214
|
response?: string;
|
|
215
215
|
};
|
|
216
216
|
};
|
|
@@ -232,7 +232,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
232
232
|
tool?: string;
|
|
233
233
|
}[];
|
|
234
234
|
text?: {
|
|
235
|
-
type?: "
|
|
235
|
+
type?: "EXACT" | "SIMILAR";
|
|
236
236
|
response?: string;
|
|
237
237
|
};
|
|
238
238
|
};
|
|
@@ -254,7 +254,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
254
254
|
tool?: string;
|
|
255
255
|
}[];
|
|
256
256
|
text?: {
|
|
257
|
-
type?: "
|
|
257
|
+
type?: "EXACT" | "SIMILAR";
|
|
258
258
|
response?: string;
|
|
259
259
|
};
|
|
260
260
|
};
|
|
@@ -284,7 +284,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
284
284
|
tool?: string;
|
|
285
285
|
}[];
|
|
286
286
|
text?: {
|
|
287
|
-
type?: "
|
|
287
|
+
type?: "EXACT" | "SIMILAR";
|
|
288
288
|
response?: string;
|
|
289
289
|
};
|
|
290
290
|
};
|
|
@@ -314,7 +314,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
314
314
|
tool?: string;
|
|
315
315
|
}[];
|
|
316
316
|
text?: {
|
|
317
|
-
type?: "
|
|
317
|
+
type?: "EXACT" | "SIMILAR";
|
|
318
318
|
response?: string;
|
|
319
319
|
};
|
|
320
320
|
};
|
|
@@ -660,7 +660,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
660
660
|
tool?: string;
|
|
661
661
|
}[];
|
|
662
662
|
text?: {
|
|
663
|
-
type?: "
|
|
663
|
+
type?: "EXACT" | "SIMILAR";
|
|
664
664
|
response?: string;
|
|
665
665
|
};
|
|
666
666
|
};
|
|
@@ -756,7 +756,7 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<{
|
|
|
756
756
|
tool?: string;
|
|
757
757
|
}[];
|
|
758
758
|
text?: {
|
|
759
|
-
type?: "
|
|
759
|
+
type?: "EXACT" | "SIMILAR";
|
|
760
760
|
response?: string;
|
|
761
761
|
};
|
|
762
762
|
};
|
|
@@ -157,7 +157,7 @@ declare function createValidationSchema(request: {
|
|
|
157
157
|
evalsLanguageModel: z.ZodObject<{
|
|
158
158
|
provider: z.ZodEnum<["openai"]>;
|
|
159
159
|
model: z.ZodString;
|
|
160
|
-
apiKey: z.ZodString
|
|
160
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
161
161
|
}, "strip", z.ZodTypeAny, {
|
|
162
162
|
provider?: "openai";
|
|
163
163
|
apiKey?: string;
|
|
@@ -191,13 +191,13 @@ declare function createValidationSchema(request: {
|
|
|
191
191
|
userInput: z.ZodString;
|
|
192
192
|
expected: z.ZodObject<{
|
|
193
193
|
text: z.ZodObject<{
|
|
194
|
-
type: z.ZodEnum<["
|
|
194
|
+
type: z.ZodEnum<["EXACT", "SIMILAR"]>;
|
|
195
195
|
response: z.ZodString;
|
|
196
196
|
}, "strip", z.ZodTypeAny, {
|
|
197
|
-
type?: "
|
|
197
|
+
type?: "EXACT" | "SIMILAR";
|
|
198
198
|
response?: string;
|
|
199
199
|
}, {
|
|
200
|
-
type?: "
|
|
200
|
+
type?: "EXACT" | "SIMILAR";
|
|
201
201
|
response?: string;
|
|
202
202
|
}>;
|
|
203
203
|
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -216,7 +216,7 @@ declare function createValidationSchema(request: {
|
|
|
216
216
|
tool?: string;
|
|
217
217
|
}[];
|
|
218
218
|
text?: {
|
|
219
|
-
type?: "
|
|
219
|
+
type?: "EXACT" | "SIMILAR";
|
|
220
220
|
response?: string;
|
|
221
221
|
};
|
|
222
222
|
}, {
|
|
@@ -225,7 +225,7 @@ declare function createValidationSchema(request: {
|
|
|
225
225
|
tool?: string;
|
|
226
226
|
}[];
|
|
227
227
|
text?: {
|
|
228
|
-
type?: "
|
|
228
|
+
type?: "EXACT" | "SIMILAR";
|
|
229
229
|
response?: string;
|
|
230
230
|
};
|
|
231
231
|
}>;
|
|
@@ -236,7 +236,7 @@ declare function createValidationSchema(request: {
|
|
|
236
236
|
tool?: string;
|
|
237
237
|
}[];
|
|
238
238
|
text?: {
|
|
239
|
-
type?: "
|
|
239
|
+
type?: "EXACT" | "SIMILAR";
|
|
240
240
|
response?: string;
|
|
241
241
|
};
|
|
242
242
|
};
|
|
@@ -248,7 +248,7 @@ declare function createValidationSchema(request: {
|
|
|
248
248
|
tool?: string;
|
|
249
249
|
}[];
|
|
250
250
|
text?: {
|
|
251
|
-
type?: "
|
|
251
|
+
type?: "EXACT" | "SIMILAR";
|
|
252
252
|
response?: string;
|
|
253
253
|
};
|
|
254
254
|
};
|
|
@@ -270,7 +270,7 @@ declare function createValidationSchema(request: {
|
|
|
270
270
|
tool?: string;
|
|
271
271
|
}[];
|
|
272
272
|
text?: {
|
|
273
|
-
type?: "
|
|
273
|
+
type?: "EXACT" | "SIMILAR";
|
|
274
274
|
response?: string;
|
|
275
275
|
};
|
|
276
276
|
};
|
|
@@ -292,7 +292,7 @@ declare function createValidationSchema(request: {
|
|
|
292
292
|
tool?: string;
|
|
293
293
|
}[];
|
|
294
294
|
text?: {
|
|
295
|
-
type?: "
|
|
295
|
+
type?: "EXACT" | "SIMILAR";
|
|
296
296
|
response?: string;
|
|
297
297
|
};
|
|
298
298
|
};
|
|
@@ -322,7 +322,7 @@ declare function createValidationSchema(request: {
|
|
|
322
322
|
tool?: string;
|
|
323
323
|
}[];
|
|
324
324
|
text?: {
|
|
325
|
-
type?: "
|
|
325
|
+
type?: "EXACT" | "SIMILAR";
|
|
326
326
|
response?: string;
|
|
327
327
|
};
|
|
328
328
|
};
|
|
@@ -352,7 +352,7 @@ declare function createValidationSchema(request: {
|
|
|
352
352
|
tool?: string;
|
|
353
353
|
}[];
|
|
354
354
|
text?: {
|
|
355
|
-
type?: "
|
|
355
|
+
type?: "EXACT" | "SIMILAR";
|
|
356
356
|
response?: string;
|
|
357
357
|
};
|
|
358
358
|
};
|
|
@@ -698,7 +698,7 @@ declare function createValidationSchema(request: {
|
|
|
698
698
|
tool?: string;
|
|
699
699
|
}[];
|
|
700
700
|
text?: {
|
|
701
|
-
type?: "
|
|
701
|
+
type?: "EXACT" | "SIMILAR";
|
|
702
702
|
response?: string;
|
|
703
703
|
};
|
|
704
704
|
};
|
|
@@ -794,7 +794,7 @@ declare function createValidationSchema(request: {
|
|
|
794
794
|
tool?: string;
|
|
795
795
|
}[];
|
|
796
796
|
text?: {
|
|
797
|
-
type?: "
|
|
797
|
+
type?: "EXACT" | "SIMILAR";
|
|
798
798
|
response?: string;
|
|
799
799
|
};
|
|
800
800
|
};
|
|
@@ -892,7 +892,7 @@ declare function createValidationSchema(request: {
|
|
|
892
892
|
tool?: string;
|
|
893
893
|
}[];
|
|
894
894
|
text?: {
|
|
895
|
-
type?: "
|
|
895
|
+
type?: "EXACT" | "SIMILAR";
|
|
896
896
|
response?: string;
|
|
897
897
|
};
|
|
898
898
|
};
|
|
@@ -991,7 +991,7 @@ declare function createValidationSchema(request: {
|
|
|
991
991
|
tool?: string;
|
|
992
992
|
}[];
|
|
993
993
|
text?: {
|
|
994
|
-
type?: "
|
|
994
|
+
type?: "EXACT" | "SIMILAR";
|
|
995
995
|
response?: string;
|
|
996
996
|
};
|
|
997
997
|
};
|
|
@@ -1090,7 +1090,7 @@ declare function createValidationSchema(request: {
|
|
|
1090
1090
|
tool?: string;
|
|
1091
1091
|
}[];
|
|
1092
1092
|
text?: {
|
|
1093
|
-
type?: "
|
|
1093
|
+
type?: "EXACT" | "SIMILAR";
|
|
1094
1094
|
response?: string;
|
|
1095
1095
|
};
|
|
1096
1096
|
};
|
|
@@ -1189,7 +1189,7 @@ declare function createValidationSchema(request: {
|
|
|
1189
1189
|
tool?: string;
|
|
1190
1190
|
}[];
|
|
1191
1191
|
text?: {
|
|
1192
|
-
type?: "
|
|
1192
|
+
type?: "EXACT" | "SIMILAR";
|
|
1193
1193
|
response?: string;
|
|
1194
1194
|
};
|
|
1195
1195
|
};
|
|
@@ -1300,7 +1300,7 @@ declare function createValidationSchema(request: {
|
|
|
1300
1300
|
tool?: string;
|
|
1301
1301
|
}[];
|
|
1302
1302
|
text?: {
|
|
1303
|
-
type?: "
|
|
1303
|
+
type?: "EXACT" | "SIMILAR";
|
|
1304
1304
|
response?: string;
|
|
1305
1305
|
};
|
|
1306
1306
|
};
|
|
@@ -1414,7 +1414,7 @@ declare function createValidationSchema(request: {
|
|
|
1414
1414
|
tool?: string;
|
|
1415
1415
|
}[];
|
|
1416
1416
|
text?: {
|
|
1417
|
-
type?: "
|
|
1417
|
+
type?: "EXACT" | "SIMILAR";
|
|
1418
1418
|
response?: string;
|
|
1419
1419
|
};
|
|
1420
1420
|
};
|
package/dist/core/services.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ declare const services: Promise<[{
|
|
|
21
21
|
updateApplication: (call: {
|
|
22
22
|
request: unknown;
|
|
23
23
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
24
|
+
evaluateIntelligence: (call: {
|
|
25
|
+
request: unknown;
|
|
26
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
24
27
|
};
|
|
25
28
|
}, {
|
|
26
29
|
definition: {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getIntegrationsFromFile = getIntegrationsFromFile;
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster/fonoster
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Fonoster
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the MIT License (the "License");
|
|
14
|
+
* you may not use this file except in compliance with
|
|
15
|
+
* the License. You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* https://opensource.org/licenses/MIT
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const fs_1 = __importDefault(require("fs"));
|
|
26
|
+
const logger_1 = require("@fonoster/logger");
|
|
27
|
+
const zod_1 = require("zod");
|
|
28
|
+
const zod_validation_error_1 = require("zod-validation-error");
|
|
29
|
+
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
30
|
+
const integrationsConfigSchema = zod_1.z.array(zod_1.z.object({
|
|
31
|
+
name: zod_1.z.string(),
|
|
32
|
+
productRef: zod_1.z.string(),
|
|
33
|
+
type: zod_1.z.enum(["tts", "stt", "llm"]),
|
|
34
|
+
credentials: zod_1.z.record(zod_1.z.unknown())
|
|
35
|
+
}));
|
|
36
|
+
function getIntegrationsFromFile(pathToIntegrations) {
|
|
37
|
+
const integrationsFile = fs_1.default.readFileSync(pathToIntegrations, "utf8");
|
|
38
|
+
const integrations = JSON.parse(integrationsFile);
|
|
39
|
+
try {
|
|
40
|
+
integrationsConfigSchema.parse(integrations);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
// fatal error
|
|
44
|
+
const message = (0, zod_validation_error_1.fromError)(e, { prefix: null }).toString();
|
|
45
|
+
logger.error("integrations config is invalid", { message });
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
return integrations;
|
|
49
|
+
}
|
|
@@ -8,9 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.createCreateContainer = createCreateContainer;
|
|
16
13
|
/**
|
|
@@ -31,37 +28,19 @@ exports.createCreateContainer = createCreateContainer;
|
|
|
31
28
|
* See the License for the specific language governing permissions and
|
|
32
29
|
* limitations under the License.
|
|
33
30
|
*/
|
|
34
|
-
const fs_1 = __importDefault(require("fs"));
|
|
35
31
|
const common_1 = require("@fonoster/common");
|
|
36
32
|
const logger_1 = require("@fonoster/logger");
|
|
37
|
-
const zod_1 = require("zod");
|
|
38
|
-
const zod_validation_error_1 = require("zod-validation-error");
|
|
39
33
|
const envs_1 = require("../../envs");
|
|
34
|
+
const getIntegrationsFromFile_1 = require("../../utils/getIntegrationsFromFile");
|
|
40
35
|
const SpeechToTextFactory_1 = require("../stt/SpeechToTextFactory");
|
|
41
36
|
const TextToSpeechFactory_1 = require("../tts/TextToSpeechFactory");
|
|
42
37
|
const ApplicationNotFoundError_1 = require("./ApplicationNotFoundError");
|
|
43
38
|
const getSttConfig_1 = require("./getSttConfig");
|
|
44
39
|
const getTtsConfig_1 = require("./getTtsConfig");
|
|
45
40
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
46
|
-
const integrationsConfigSchema = zod_1.z.array(zod_1.z.object({
|
|
47
|
-
name: zod_1.z.string(),
|
|
48
|
-
productRef: zod_1.z.string(),
|
|
49
|
-
type: zod_1.z.enum(["tts", "stt", "llm"]),
|
|
50
|
-
credentials: zod_1.z.record(zod_1.z.unknown())
|
|
51
|
-
}));
|
|
52
41
|
function createCreateContainer(prisma, pathToIntegrations) {
|
|
53
42
|
logger.verbose("loading integrations config", { pathToIntegrations });
|
|
54
|
-
const
|
|
55
|
-
const integrations = JSON.parse(integrationsFile);
|
|
56
|
-
try {
|
|
57
|
-
integrationsConfigSchema.parse(integrations);
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
// fatal error
|
|
61
|
-
const message = (0, zod_validation_error_1.fromError)(e, { prefix: null }).toString();
|
|
62
|
-
logger.error("integrations config is invalid", { message });
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
43
|
+
const integrations = (0, getIntegrationsFromFile_1.getIntegrationsFromFile)(pathToIntegrations);
|
|
65
44
|
return function createContainer(appRef) {
|
|
66
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
46
|
logger.verbose("creating integrations container", { appRef });
|
|
@@ -16,9 +16,8 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { VoiceLanguage } from "@fonoster/common";
|
|
19
|
+
import { IntegrationConfig, VoiceLanguage } from "@fonoster/common";
|
|
20
20
|
import { Application } from "@fonoster/types";
|
|
21
|
-
import { IntegrationConfig } from "./types";
|
|
22
21
|
declare function getSttConfig(integrations: IntegrationConfig[], app: Application): {
|
|
23
22
|
config: {
|
|
24
23
|
languageCode: VoiceLanguage;
|
|
@@ -1,5 +1,23 @@
|
|
|
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 { IntegrationConfig } from "@fonoster/common";
|
|
1
20
|
import { Application } from "@fonoster/types";
|
|
2
|
-
import { IntegrationConfig } from "./types";
|
|
3
21
|
declare function getTtsConfig(integrations: IntegrationConfig[], app: Application): {
|
|
4
22
|
config: Record<string, unknown>;
|
|
5
23
|
credentials: Record<string, unknown>;
|
|
@@ -18,10 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { AbstractSpeechToText } from "../stt/AbstractSpeechToText";
|
|
20
20
|
import { AbstractTextToSpeech } from "../tts/AbstractTextToSpeech";
|
|
21
|
-
type IntegrationConfig = {
|
|
22
|
-
productRef: string;
|
|
23
|
-
credentials: Record<string, unknown>;
|
|
24
|
-
};
|
|
25
21
|
type IntegrationsContainer = {
|
|
26
22
|
ref: string;
|
|
27
23
|
accessKeyId: string;
|
|
@@ -30,4 +26,4 @@ type IntegrationsContainer = {
|
|
|
30
26
|
stt: AbstractSpeechToText<unknown>;
|
|
31
27
|
};
|
|
32
28
|
type CreateContainer = (appRef: string) => Promise<IntegrationsContainer>;
|
|
33
|
-
export { CreateContainer,
|
|
29
|
+
export { CreateContainer, IntegrationsContainer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/apiserver",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.6",
|
|
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,14 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@deepgram/sdk": "^3.5.1",
|
|
24
|
-
"@fonoster/authz": "^0.13.
|
|
25
|
-
"@fonoster/
|
|
26
|
-
"@fonoster/
|
|
27
|
-
"@fonoster/
|
|
28
|
-
"@fonoster/
|
|
29
|
-
"@fonoster/
|
|
30
|
-
"@fonoster/
|
|
24
|
+
"@fonoster/authz": "^0.13.5",
|
|
25
|
+
"@fonoster/autopilot": "^0.13.6",
|
|
26
|
+
"@fonoster/common": "^0.13.5",
|
|
27
|
+
"@fonoster/identity": "^0.13.5",
|
|
28
|
+
"@fonoster/logger": "^0.13.5",
|
|
29
|
+
"@fonoster/sipnet": "^0.13.5",
|
|
30
|
+
"@fonoster/streams": "^0.13.5",
|
|
31
|
+
"@fonoster/types": "^0.13.5",
|
|
31
32
|
"@google-cloud/speech": "^6.6.0",
|
|
32
33
|
"@google-cloud/text-to-speech": "^5.3.0",
|
|
33
34
|
"@grpc/grpc-js": "~1.10.6",
|
|
@@ -73,5 +74,5 @@
|
|
|
73
74
|
"@types/uuid": "^10.0.0",
|
|
74
75
|
"@types/validator": "^13.12.0"
|
|
75
76
|
},
|
|
76
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "3a7475662a53e7834b64c67cafc677803f25f93a"
|
|
77
78
|
}
|