@fonoster/apiserver 0.8.25 → 0.8.27
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.js +10 -10
- package/dist/applications/{createApplication.d.ts → createCreateApplication.d.ts} +2 -2
- package/dist/applications/{createApplication.js → createCreateApplication.js} +14 -7
- package/dist/applications/{getApplication.d.ts → createDeleteApplication.d.ts} +2 -2
- package/dist/applications/{deleteApplication.js → createDeleteApplication.js} +4 -4
- package/dist/applications/{updateApplication.d.ts → createGetApplication.d.ts} +2 -2
- package/dist/applications/{getApplication.js → createGetApplication.js} +4 -4
- package/dist/applications/createGetFnUtil.d.ts +2 -0
- package/dist/applications/{listApplications.d.ts → createListApplications.d.ts} +2 -2
- package/dist/applications/{listApplications.js → createListApplications.js} +5 -6
- package/dist/applications/{deleteApplication.d.ts → createUpdateApplication.d.ts} +2 -2
- package/dist/applications/{updateApplication.js → createUpdateApplication.js} +7 -7
- package/dist/applications/utils/applicationWithEncodedStruct.js +2 -0
- package/dist/applications/utils/convertToApplicationData.d.ts +2 -2
- package/dist/applications/validation/assistantWithoutApiKeySchema.d.ts +671 -0
- package/dist/applications/validation/assistantWithoutApiKeySchema.js +35 -0
- package/dist/applications/validation/createValidationSchema.d.ts +1107 -0
- package/dist/applications/validation/createValidationSchema.js +67 -0
- package/dist/applications/validation/speechValidators.d.ts +29 -0
- package/dist/applications/{utils/getApplicationValidationSchema.js → validation/speechValidators.js} +3 -28
- package/dist/applications/{utils → validation}/validOrThrow.js +3 -2
- package/dist/calls/buildService.js +2 -2
- package/dist/calls/createCall.js +1 -2
- package/dist/calls/{makeTrackCall.d.ts → createTrackCall.d.ts} +2 -2
- package/dist/calls/{makeTrackCall.js → createTrackCall.js} +4 -4
- package/dist/calls/getCall.js +1 -2
- package/dist/calls/listCalls.js +1 -2
- package/dist/core/httpBridge.js +1 -1
- package/dist/core/runServices.js +2 -3
- package/dist/core/seed.js +11 -1
- package/dist/core/services.js +1 -1
- package/dist/envs.d.ts +1 -0
- package/dist/envs.js +3 -2
- package/dist/secrets/createGetFnUtil.js +12 -10
- package/dist/secrets/createSecret.js +1 -2
- package/dist/secrets/listSecrets.js +1 -2
- package/dist/secrets/updateSecret.js +1 -2
- package/dist/utils/createCheckNumberPreconditions.d.ts +6 -0
- package/dist/utils/{makeCheckNumberPreconditions.js → createCheckNumberPreconditions.js} +4 -4
- package/dist/utils/createHandleDialEventsWithNats.d.ts +5 -0
- package/dist/utils/{makeHandleDialEventsWithNats.js → createHandleDialEventsWithNats.js} +10 -8
- package/dist/utils/createHandleDialEventsWithVoiceClient.d.ts +5 -0
- package/dist/utils/{makeHandleDialEventsWithVoiceClient.js → createHandleDialEventsWithVoiceClient.js} +13 -11
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +3 -3
- package/dist/voice/VoiceClientImpl.js +13 -7
- package/dist/voice/VoiceDispatcher.js +16 -17
- package/dist/voice/connectToAri.js +3 -3
- package/dist/voice/{makeCreateVoiceClient.d.ts → createCreateVoiceClient.d.ts} +2 -2
- package/dist/voice/createCreateVoiceClient.js +76 -0
- package/dist/voice/handlers/createAnswerHandler.d.ts +5 -0
- package/dist/voice/handlers/{Answer.js → createAnswerHandler.js} +2 -2
- package/dist/voice/handlers/createHangupHandler.d.ts +5 -0
- package/dist/voice/handlers/{Hangup.js → createHangupHandler.js} +2 -2
- package/dist/voice/handlers/createMuteHandler.d.ts +4 -0
- package/dist/voice/handlers/{Mute.js → createMuteHandler.js} +2 -2
- package/dist/voice/handlers/createPlayDtmfHandler.d.ts +4 -0
- package/dist/voice/handlers/{PlayDtmf.js → createPlayDtmfHandler.js} +2 -2
- package/dist/voice/handlers/createPlayHandler.d.ts +4 -0
- package/dist/voice/handlers/{Play.js → createPlayHandler.js} +2 -2
- package/dist/voice/handlers/createPlaybackControlHandler.d.ts +4 -0
- package/dist/voice/handlers/{PlaybackControl.js → createPlaybackControlHandler.js} +2 -2
- package/dist/voice/handlers/createRecordHandler.d.ts +4 -0
- package/dist/voice/handlers/{Record.js → createRecordHandler.js} +2 -2
- package/dist/voice/handlers/createSayHandler.d.ts +4 -0
- package/dist/voice/handlers/{Say.js → createSayHandler.js} +2 -2
- package/dist/voice/handlers/createStreamGatherHandler.d.ts +3 -0
- package/dist/voice/handlers/{StreamGather.js → createStreamGatherHandler.js} +2 -2
- package/dist/voice/handlers/{StreamGather.d.ts → createStreamHandler.d.ts} +2 -2
- package/dist/voice/handlers/{Stream.js → createStreamHandler.js} +2 -2
- package/dist/voice/handlers/createUnmuteHandler.d.ts +4 -0
- package/dist/voice/handlers/{Unmute.js → createUnmuteHandler.js} +2 -2
- package/dist/voice/handlers/dial/createDialHandler.d.ts +5 -0
- package/dist/voice/handlers/dial/createDialHandler.js +78 -0
- package/dist/voice/handlers/dial/index.d.ts +1 -0
- package/dist/voice/handlers/dial/index.js +35 -0
- package/dist/voice/handlers/gather/createGatherHandler.d.ts +3 -0
- package/dist/voice/handlers/gather/{Gather.js → createGatherHandler.js} +2 -2
- package/dist/voice/handlers/index.d.ts +13 -12
- package/dist/voice/handlers/index.js +13 -12
- package/dist/voice/integrations/createCreateContainer.d.ts +4 -0
- package/dist/voice/integrations/{makeCreateContainer.js → createCreateContainer.js} +28 -26
- package/dist/voice/integrations/getSttConfig.js +20 -2
- package/dist/voice/integrations/getTtsConfig.js +2 -2
- package/dist/voice/integrations/index.d.ts +1 -1
- package/dist/voice/integrations/index.js +1 -1
- package/dist/voice/stt/types.d.ts +1 -1
- package/dist/voice/utils/createGetChannelVar.d.ts +4 -0
- package/dist/voice/utils/{makeGetChannelVar.js → createGetChannelVar.js} +14 -12
- package/dist/voice/utils/createGetChannelVarWithoutThrow.d.ts +4 -0
- package/dist/voice/utils/{makeGetChannelVarWithoutThrow.js → createGetChannelVarWithoutThrow.js} +14 -12
- package/dist/voice/utils/index.d.ts +2 -2
- package/dist/voice/utils/index.js +2 -2
- package/package.json +9 -9
- package/dist/applications/utils/getApplicationValidationSchema.d.ts +0 -64
- package/dist/utils/makeCheckNumberPreconditions.d.ts +0 -6
- package/dist/utils/makeHandleDialEventsWithNats.d.ts +0 -5
- package/dist/utils/makeHandleDialEventsWithVoiceClient.d.ts +0 -5
- package/dist/voice/handlers/Answer.d.ts +0 -5
- package/dist/voice/handlers/Hangup.d.ts +0 -5
- package/dist/voice/handlers/Mute.d.ts +0 -4
- package/dist/voice/handlers/Play.d.ts +0 -4
- package/dist/voice/handlers/PlayDtmf.d.ts +0 -4
- package/dist/voice/handlers/PlaybackControl.d.ts +0 -4
- package/dist/voice/handlers/Record.d.ts +0 -4
- package/dist/voice/handlers/Say.d.ts +0 -4
- package/dist/voice/handlers/Stream.d.ts +0 -3
- package/dist/voice/handlers/Unmute.d.ts +0 -4
- package/dist/voice/handlers/dial/Dial.d.ts +0 -5
- package/dist/voice/handlers/dial/Dial.js +0 -76
- package/dist/voice/handlers/gather/Gather.d.ts +0 -3
- package/dist/voice/integrations/findIntegrationsCredentials.d.ts +0 -3
- package/dist/voice/integrations/findIntegrationsCredentials.js +0 -7
- package/dist/voice/integrations/makeCreateContainer.d.ts +0 -4
- package/dist/voice/makeCreateVoiceClient.js +0 -74
- package/dist/voice/utils/makeGetChannelVar.d.ts +0 -4
- package/dist/voice/utils/makeGetChannelVarWithoutThrow.d.ts +0 -4
- /package/dist/applications/{utils → validation}/prepareForValidation.d.ts +0 -0
- /package/dist/applications/{utils → validation}/prepareForValidation.js +0 -0
- /package/dist/applications/{utils → validation}/validOrThrow.d.ts +0 -0
|
@@ -19,11 +19,11 @@ exports.buildService = buildService;
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
22
|
+
const createCreateApplication_1 = require("./createCreateApplication");
|
|
23
|
+
const createDeleteApplication_1 = require("./createDeleteApplication");
|
|
24
|
+
const createGetApplication_1 = require("./createGetApplication");
|
|
25
|
+
const createListApplications_1 = require("./createListApplications");
|
|
26
|
+
const createUpdateApplication_1 = require("./createUpdateApplication");
|
|
27
27
|
function buildService(prisma) {
|
|
28
28
|
return {
|
|
29
29
|
definition: {
|
|
@@ -33,11 +33,11 @@ function buildService(prisma) {
|
|
|
33
33
|
proto: "applications.proto"
|
|
34
34
|
},
|
|
35
35
|
handlers: {
|
|
36
|
-
createApplication: (0,
|
|
37
|
-
getApplication: (0,
|
|
38
|
-
listApplications: (0,
|
|
39
|
-
deleteApplication: (0,
|
|
40
|
-
updateApplication: (0,
|
|
36
|
+
createApplication: (0, createCreateApplication_1.createCreateApplication)(prisma),
|
|
37
|
+
getApplication: (0, createGetApplication_1.createGetApplication)(prisma),
|
|
38
|
+
listApplications: (0, createListApplications_1.createListApplications)(prisma),
|
|
39
|
+
deleteApplication: (0, createDeleteApplication_1.createDeleteApplication)(prisma),
|
|
40
|
+
updateApplication: (0, createUpdateApplication_1.createUpdateApplication)(prisma)
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GrpcErrorMessage } from "@fonoster/common";
|
|
2
2
|
import { Prisma } from "../core/db";
|
|
3
|
-
declare function
|
|
3
|
+
declare function createCreateApplication(prisma: Prisma): (call: {
|
|
4
4
|
request: unknown;
|
|
5
5
|
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
6
|
-
export {
|
|
6
|
+
export { createCreateApplication };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.createCreateApplication = createCreateApplication;
|
|
13
13
|
/*
|
|
14
14
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
15
|
* http://github.com/fonoster/fonoster
|
|
@@ -29,25 +29,32 @@ exports.createApplication = createApplication;
|
|
|
29
29
|
* limitations under the License.
|
|
30
30
|
*/
|
|
31
31
|
const common_1 = require("@fonoster/common");
|
|
32
|
-
const identity_1 = require("@fonoster/identity");
|
|
33
32
|
const logger_1 = require("@fonoster/logger");
|
|
34
33
|
const convertToApplicationData_1 = require("./utils/convertToApplicationData");
|
|
35
|
-
const validOrThrow_1 = require("./
|
|
34
|
+
const validOrThrow_1 = require("./validation/validOrThrow");
|
|
35
|
+
const envs_1 = require("../envs");
|
|
36
|
+
const client_1 = require("@prisma/client");
|
|
36
37
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
37
|
-
function
|
|
38
|
-
const
|
|
38
|
+
function createCreateApplication(prisma) {
|
|
39
|
+
const createApplication = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
39
40
|
const { request } = call;
|
|
40
41
|
const { type } = request;
|
|
41
|
-
const accessKeyId = (0,
|
|
42
|
+
const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
|
|
42
43
|
logger.verbose("call to createApplication", {
|
|
43
44
|
accessKeyId,
|
|
44
45
|
type
|
|
45
46
|
});
|
|
47
|
+
if (type === client_1.ApplicationType.AUTOPILOT && !request.endpoint) {
|
|
48
|
+
logger.verbose("setting default endpoint for autopilot application", {
|
|
49
|
+
autopilotEndpoint: envs_1.APISERVER_AUTOPILOT_ENDPOINT
|
|
50
|
+
});
|
|
51
|
+
request.endpoint = envs_1.APISERVER_AUTOPILOT_ENDPOINT;
|
|
52
|
+
}
|
|
46
53
|
(0, validOrThrow_1.validOrThrow)(request);
|
|
47
54
|
const result = yield prisma.application.create({
|
|
48
55
|
data: Object.assign(Object.assign({}, (0, convertToApplicationData_1.convertToApplicationData)(request)), { accessKeyId })
|
|
49
56
|
});
|
|
50
57
|
callback(null, { ref: result.ref });
|
|
51
58
|
});
|
|
52
|
-
return (0, common_1.withErrorHandling)(
|
|
59
|
+
return (0, common_1.withErrorHandling)(createApplication);
|
|
53
60
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Prisma } from "../core/db";
|
|
2
|
-
declare function
|
|
2
|
+
declare function createDeleteApplication(prisma: Prisma): (call: {
|
|
3
3
|
request: unknown;
|
|
4
4
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
5
|
-
export {
|
|
5
|
+
export { createDeleteApplication };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.createDeleteApplication = createDeleteApplication;
|
|
13
13
|
/*
|
|
14
14
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
15
|
* http://github.com/fonoster/fonoster
|
|
@@ -33,13 +33,13 @@ const identity_1 = require("@fonoster/identity");
|
|
|
33
33
|
const logger_1 = require("@fonoster/logger");
|
|
34
34
|
const createGetFnUtil_1 = require("./createGetFnUtil");
|
|
35
35
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
36
|
-
function
|
|
36
|
+
function createDeleteApplication(prisma) {
|
|
37
37
|
const getFn = (0, createGetFnUtil_1.createGetFnUtil)(prisma);
|
|
38
|
-
const
|
|
38
|
+
const deleteApplication = (call) => __awaiter(this, void 0, void 0, function* () {
|
|
39
39
|
const { ref } = call.request;
|
|
40
40
|
logger.verbose("call to deleteApplication", { ref });
|
|
41
41
|
yield prisma.application.delete({ where: { ref } });
|
|
42
42
|
return { ref };
|
|
43
43
|
});
|
|
44
|
-
return (0, common_1.withErrorHandlingAndValidation)((0, identity_1.withAccess)(
|
|
44
|
+
return (0, common_1.withErrorHandlingAndValidation)((0, identity_1.withAccess)(deleteApplication, (ref) => getFn(ref)), common_1.Validators.emptySchema);
|
|
45
45
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Prisma } from "../core/db";
|
|
2
|
-
declare function
|
|
2
|
+
declare function createGetApplication(prisma: Prisma): (call: {
|
|
3
3
|
request: unknown;
|
|
4
4
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
5
|
-
export {
|
|
5
|
+
export { createGetApplication };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.createGetApplication = createGetApplication;
|
|
13
13
|
/*
|
|
14
14
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
15
|
* http://github.com/fonoster/fonoster
|
|
@@ -34,13 +34,13 @@ const createGetFnUtil_1 = require("./createGetFnUtil");
|
|
|
34
34
|
const applicationWithEncodedStruct_1 = require("./utils/applicationWithEncodedStruct");
|
|
35
35
|
const withErrorHandlingAndValidationAndAccess_1 = require("../utils/withErrorHandlingAndValidationAndAccess");
|
|
36
36
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
37
|
-
function
|
|
37
|
+
function createGetApplication(prisma) {
|
|
38
38
|
const getFn = (0, createGetFnUtil_1.createGetFnUtil)(prisma);
|
|
39
|
-
const
|
|
39
|
+
const getApplication = (call) => __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
const { ref } = call.request;
|
|
41
41
|
logger.verbose("call to getApplication", { ref });
|
|
42
42
|
const result = yield getFn(ref);
|
|
43
43
|
return result ? (0, applicationWithEncodedStruct_1.applicationWithEncodedStruct)(result) : null;
|
|
44
44
|
});
|
|
45
|
-
return (0, withErrorHandlingAndValidationAndAccess_1.withErrorHandlingAndValidationAndAccess)(
|
|
45
|
+
return (0, withErrorHandlingAndValidationAndAccess_1.withErrorHandlingAndValidationAndAccess)(getApplication, (ref) => getFn(ref), common_1.Validators.emptySchema);
|
|
46
46
|
}
|
|
@@ -6,12 +6,14 @@ declare function createGetFnUtil(prisma: Prisma): (ref: string) => Promise<{
|
|
|
6
6
|
textToSpeech: {
|
|
7
7
|
ref: string;
|
|
8
8
|
config: import("@prisma/client/runtime/library").JsonValue;
|
|
9
|
+
credentials: string;
|
|
9
10
|
productRef: string;
|
|
10
11
|
applicationRef: string;
|
|
11
12
|
};
|
|
12
13
|
speechToText: {
|
|
13
14
|
ref: string;
|
|
14
15
|
config: import("@prisma/client/runtime/library").JsonValue;
|
|
16
|
+
credentials: string;
|
|
15
17
|
productRef: string;
|
|
16
18
|
applicationRef: string;
|
|
17
19
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GrpcErrorMessage } from "@fonoster/common";
|
|
2
2
|
import { Prisma } from "../core/db";
|
|
3
|
-
declare function
|
|
3
|
+
declare function createListApplications(prisma: Prisma): (call: {
|
|
4
4
|
request: unknown;
|
|
5
5
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
6
|
-
export {
|
|
6
|
+
export { createListApplications };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.createListApplications = createListApplications;
|
|
13
13
|
/*
|
|
14
14
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
15
|
* http://github.com/fonoster/fonoster
|
|
@@ -29,15 +29,14 @@ exports.listApplications = listApplications;
|
|
|
29
29
|
* limitations under the License.
|
|
30
30
|
*/
|
|
31
31
|
const common_1 = require("@fonoster/common");
|
|
32
|
-
const identity_1 = require("@fonoster/identity");
|
|
33
32
|
const logger_1 = require("@fonoster/logger");
|
|
34
33
|
const applicationWithEncodedStruct_1 = require("./utils/applicationWithEncodedStruct");
|
|
35
34
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
36
|
-
function
|
|
37
|
-
const
|
|
35
|
+
function createListApplications(prisma) {
|
|
36
|
+
const listApplications = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
38
37
|
var _a;
|
|
39
38
|
const { pageSize, pageToken } = call.request;
|
|
40
|
-
const accessKeyId = (0,
|
|
39
|
+
const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
|
|
41
40
|
logger.verbose("call to getApplication", {
|
|
42
41
|
accessKeyId,
|
|
43
42
|
pageSize,
|
|
@@ -60,5 +59,5 @@ function listApplications(prisma) {
|
|
|
60
59
|
nextPageToken: (_a = result[result.length - 1]) === null || _a === void 0 ? void 0 : _a.ref
|
|
61
60
|
});
|
|
62
61
|
});
|
|
63
|
-
return (0, common_1.withErrorHandlingAndValidation)(
|
|
62
|
+
return (0, common_1.withErrorHandlingAndValidation)(listApplications, common_1.Validators.listRequestSchema);
|
|
64
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Prisma } from "../core/db";
|
|
2
|
-
declare function
|
|
2
|
+
declare function createUpdateApplication(prisma: Prisma): (call: {
|
|
3
3
|
request: unknown;
|
|
4
4
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
5
|
-
export {
|
|
5
|
+
export { createUpdateApplication };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.createUpdateApplication = createUpdateApplication;
|
|
13
13
|
/*
|
|
14
14
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
15
|
* http://github.com/fonoster/fonoster
|
|
@@ -29,18 +29,18 @@ exports.updateApplication = updateApplication;
|
|
|
29
29
|
* limitations under the License.
|
|
30
30
|
*/
|
|
31
31
|
const common_1 = require("@fonoster/common");
|
|
32
|
-
const identity_1 = require("@fonoster/identity");
|
|
33
32
|
const logger_1 = require("@fonoster/logger");
|
|
34
33
|
const createGetFnUtil_1 = require("./createGetFnUtil");
|
|
35
34
|
const convertToApplicationData_1 = require("./utils/convertToApplicationData");
|
|
36
|
-
const validOrThrow_1 = require("./
|
|
35
|
+
const validOrThrow_1 = require("./validation/validOrThrow");
|
|
36
|
+
const identity_1 = require("@fonoster/identity");
|
|
37
37
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
38
|
-
function
|
|
38
|
+
function createUpdateApplication(prisma) {
|
|
39
39
|
const getFn = (0, createGetFnUtil_1.createGetFnUtil)(prisma);
|
|
40
|
-
const
|
|
40
|
+
const updateApplication = (call) => __awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
const { request } = call;
|
|
42
42
|
const { type, ref: applicationRef } = request;
|
|
43
|
-
const accessKeyId = (0,
|
|
43
|
+
const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
|
|
44
44
|
(0, validOrThrow_1.validOrThrow)(request);
|
|
45
45
|
logger.verbose("call to updateApplication", {
|
|
46
46
|
accessKeyId,
|
|
@@ -72,5 +72,5 @@ function updateApplication(prisma) {
|
|
|
72
72
|
]);
|
|
73
73
|
return { ref: applicationRef };
|
|
74
74
|
});
|
|
75
|
-
return (0, common_1.withErrorHandling)((0, identity_1.withAccess)(
|
|
75
|
+
return (0, common_1.withErrorHandling)((0, identity_1.withAccess)(updateApplication, (ref) => getFn(ref)));
|
|
76
76
|
}
|
|
@@ -27,9 +27,11 @@ function applicationWithEncodedStruct(application) {
|
|
|
27
27
|
};
|
|
28
28
|
const result = Object.assign({}, application);
|
|
29
29
|
if (application.textToSpeech) {
|
|
30
|
+
delete application.textToSpeech.credentials;
|
|
30
31
|
result.textToSpeech = Object.assign(Object.assign({}, application.textToSpeech), { config: encodeConfig(application.textToSpeech) });
|
|
31
32
|
}
|
|
32
33
|
if (application.speechToText) {
|
|
34
|
+
delete application.speechToText.credentials;
|
|
33
35
|
result.speechToText = Object.assign(Object.assign({}, application.speechToText), { config: encodeConfig(application.speechToText) });
|
|
34
36
|
}
|
|
35
37
|
if (application.intelligence) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CreateApplicationRequest, UpdateApplicationRequest } from "@fonoster/types";
|
|
2
|
-
import {
|
|
3
|
-
declare function convertToApplicationData(request: CreateApplicationRequest | UpdateApplicationRequest):
|
|
2
|
+
import { Application } from "@prisma/client";
|
|
3
|
+
declare function convertToApplicationData(request: CreateApplicationRequest | UpdateApplicationRequest): Application;
|
|
4
4
|
export { convertToApplicationData };
|