@fonoster/common 0.6.0 → 0.6.1-alpha.0
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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/GrpcError.d.ts +5 -0
- package/dist/GrpcError.js +29 -0
- package/dist/errors/PrismaErrorEnum.d.ts +6 -0
- package/dist/errors/PrismaErrorEnum.js +27 -0
- package/dist/errors/handleError.d.ts +6 -0
- package/dist/{errors.js → errors/handleError.js} +31 -40
- package/dist/errors/handleZodError.d.ts +4 -0
- package/dist/errors/handleZodError.js +41 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +38 -0
- package/dist/errors/types.d.ts +5 -0
- package/dist/errors/types.js +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/protos/calls.proto +4 -2
- package/dist/protos/identity.proto +1 -1
- package/dist/protos/numbers.proto +33 -36
- package/dist/types/applications.d.ts +57 -0
- package/dist/types/applications.js +7 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +35 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.js +2 -0
- package/dist/utils/createService.d.ts +2 -2
- package/dist/utils/createService.js +3 -3
- package/dist/voice/voice.d.ts +2 -2
- package/package.json +4 -3
- package/dist/errors.d.ts +0 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Fonoster Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
<a href="https://gitpod.io/#https://github.com/fonoster/fonoster"> <img src="https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod" alt="Contribute with Gitpod" />
|
|
2
2
|
|
|
3
3
|
This module is part of the \[Fonoster\](https://fonoster.com) project. By itself, it does not do much. It is intended to be used as a dependency for other modules. For more information about the project, please visit \[https://github.com/fonoster/fonoster\](https://github.com/fonoster/fonoster).a](../apiserver/README.md)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GrpcError = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 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
|
+
class GrpcError extends Error {
|
|
23
|
+
constructor(code, message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.code = code;
|
|
26
|
+
Object.setPrototypeOf(this, GrpcError.prototype);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.GrpcError = GrpcError;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrismaErrorEnum = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 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
|
+
var PrismaErrorEnum;
|
|
23
|
+
(function (PrismaErrorEnum) {
|
|
24
|
+
PrismaErrorEnum["RECORD_ALREADY_EXISTS"] = "P2002";
|
|
25
|
+
PrismaErrorEnum["RECORD_NOT_FOUND"] = "P2025";
|
|
26
|
+
PrismaErrorEnum["FAILED_PRECONDITION"] = "P2003";
|
|
27
|
+
})(PrismaErrorEnum || (exports.PrismaErrorEnum = PrismaErrorEnum = {}));
|
|
@@ -46,50 +46,41 @@ const logger_1 = require("@fonoster/logger");
|
|
|
46
46
|
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
47
47
|
const grpc_js_1 = require("@grpc/grpc-js");
|
|
48
48
|
const zod_1 = require("zod");
|
|
49
|
-
const
|
|
49
|
+
const handleZodError_1 = require("./handleZodError");
|
|
50
|
+
const PrismaErrorEnum_1 = require("./PrismaErrorEnum");
|
|
50
51
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
51
52
|
function handleError(error, callback) {
|
|
52
|
-
const code = error.code;
|
|
53
53
|
if (error instanceof zod_1.z.ZodError) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
message: validationError.toString()
|
|
57
|
-
});
|
|
58
|
-
logger.error("validation error:", { message: error });
|
|
59
|
-
callback({
|
|
60
|
-
code: grpc_js_1.status.INVALID_ARGUMENT,
|
|
61
|
-
message: validationError.toString()
|
|
62
|
-
});
|
|
54
|
+
(0, handleZodError_1.handleZodError)(error, callback);
|
|
55
|
+
return;
|
|
63
56
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
logger.error(
|
|
67
|
-
callback({ code:
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
logger.error("unknown error:", error);
|
|
92
|
-
callback({ code: grpc_js_1.status.UNKNOWN, message: "Unknown error" });
|
|
57
|
+
const { code, message } = error;
|
|
58
|
+
const logAndCallback = (errorCode, errorMessage, logMessage) => {
|
|
59
|
+
logger.error(logMessage, { message: errorMessage });
|
|
60
|
+
callback({ code: errorCode, message: errorMessage });
|
|
61
|
+
};
|
|
62
|
+
switch (code) {
|
|
63
|
+
case PrismaErrorEnum_1.PrismaErrorEnum.RECORD_ALREADY_EXISTS:
|
|
64
|
+
case grpc.status.ALREADY_EXISTS:
|
|
65
|
+
logAndCallback(grpc_js_1.status.ALREADY_EXISTS, message || "Duplicated resource", "duplicated entity error");
|
|
66
|
+
break;
|
|
67
|
+
case PrismaErrorEnum_1.PrismaErrorEnum.RECORD_NOT_FOUND:
|
|
68
|
+
case grpc.status.NOT_FOUND:
|
|
69
|
+
logAndCallback(grpc_js_1.status.NOT_FOUND, message || "The requested resource was not found", "not found error");
|
|
70
|
+
break;
|
|
71
|
+
case PrismaErrorEnum_1.PrismaErrorEnum.FAILED_PRECONDITION:
|
|
72
|
+
case grpc.status.FAILED_PRECONDITION:
|
|
73
|
+
logAndCallback(grpc_js_1.status.FAILED_PRECONDITION, message || "Failed precondition error (e.g., missing dependency)", "failed precondition error");
|
|
74
|
+
break;
|
|
75
|
+
case grpc.status.PERMISSION_DENIED:
|
|
76
|
+
logAndCallback(grpc_js_1.status.PERMISSION_DENIED, message || "Permission denied", "permission denied error");
|
|
77
|
+
break;
|
|
78
|
+
case grpc.status.UNAUTHENTICATED:
|
|
79
|
+
logAndCallback(grpc_js_1.status.UNAUTHENTICATED, message || "Unauthenticated", "unauthenticated error");
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
logger.error("unknown error:", error);
|
|
83
|
+
callback({ code: grpc_js_1.status.UNKNOWN, message: message || "Unknown error" });
|
|
93
84
|
}
|
|
94
85
|
}
|
|
95
86
|
exports.handleError = handleError;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleZodError = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 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 logger_1 = require("@fonoster/logger");
|
|
23
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
24
|
+
const zod_validation_error_1 = require("zod-validation-error");
|
|
25
|
+
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
26
|
+
function handleZodError(error, callback) {
|
|
27
|
+
if ((error === null || error === void 0 ? void 0 : error.issues[0].code) === "custom") {
|
|
28
|
+
const message = error === null || error === void 0 ? void 0 : error.issues[0].message;
|
|
29
|
+
logger.error("custom validation error", { message });
|
|
30
|
+
callback({ code: grpc_js_1.status.INVALID_ARGUMENT, message });
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const validationError = (0, zod_validation_error_1.fromError)(error);
|
|
34
|
+
logger.error("validation error", { message: validationError.toString() });
|
|
35
|
+
callback({
|
|
36
|
+
code: grpc_js_1.status.INVALID_ARGUMENT,
|
|
37
|
+
message: validationError.toString()
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.handleZodError = handleZodError;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/*
|
|
18
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Fonoster
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the MIT License (the "License");
|
|
24
|
+
* you may not use this file except in compliance with
|
|
25
|
+
* the License. You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* https://opensource.org/licenses/MIT
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
__exportStar(require("./handleError"), exports);
|
|
36
|
+
__exportStar(require("./PrismaErrorEnum"), exports);
|
|
37
|
+
__exportStar(require("./handleZodError"), exports);
|
|
38
|
+
__exportStar(require("./types"), exports);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -39,3 +39,6 @@ __exportStar(require("./constants"), exports);
|
|
|
39
39
|
__exportStar(require("./grpcStatusMap"), exports);
|
|
40
40
|
__exportStar(require("./voice"), exports);
|
|
41
41
|
__exportStar(require("./tts"), exports);
|
|
42
|
+
__exportStar(require("./types/"), exports);
|
|
43
|
+
__exportStar(require("./types"), exports);
|
|
44
|
+
__exportStar(require("./GrpcError"), exports);
|
package/dist/protos/calls.proto
CHANGED
|
@@ -61,11 +61,13 @@ enum CallStatus {
|
|
|
61
61
|
COMPLETED = 3;
|
|
62
62
|
FAILED = 4;
|
|
63
63
|
BUSY = 5;
|
|
64
|
-
|
|
64
|
+
// TODO: Refactor to avoid clash with HangupCause
|
|
65
|
+
// NO_ANSWER = 6;
|
|
65
66
|
CANCELED = 7;
|
|
66
67
|
REJECTED = 8;
|
|
67
68
|
TIMEOUT = 9;
|
|
68
|
-
|
|
69
|
+
// TODO: Refactor to avoid clash with HangupCause
|
|
70
|
+
// UNKNOWN = 10;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
enum CallDirection {
|
|
@@ -44,30 +44,25 @@ message Number {
|
|
|
44
44
|
string name = 2;
|
|
45
45
|
// The tel_url of the Number
|
|
46
46
|
string tel_url = 3;
|
|
47
|
-
// The aor_link of the Number
|
|
48
|
-
string aor_link = 4;
|
|
49
47
|
// The city of the Number
|
|
50
|
-
string city =
|
|
48
|
+
string city = 4;
|
|
51
49
|
// The country of the Number
|
|
52
|
-
string country =
|
|
50
|
+
string country = 5;
|
|
53
51
|
// The country_iso_code of the Number
|
|
54
|
-
string country_iso_code =
|
|
55
|
-
// The header to use for session affinity
|
|
56
|
-
string session_affinity_header = 8;
|
|
57
|
-
// Extra headers to send to the trunk
|
|
58
|
-
repeated ExtraHeader extra_headers = 9;
|
|
52
|
+
string country_iso_code = 6;
|
|
59
53
|
// The date when the Number was created
|
|
60
|
-
int64 created_at =
|
|
54
|
+
int64 created_at = 7;
|
|
61
55
|
// The date when the Number was last updated
|
|
62
|
-
int64 updated_at =
|
|
56
|
+
int64 updated_at = 8;
|
|
63
57
|
// The trunk this number is associated with
|
|
64
|
-
fonoster.trunks.v1beta2.Trunk trunk =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// The
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
fonoster.trunks.v1beta2.Trunk trunk = 9;
|
|
59
|
+
// This dictates how the number will handle incoming calls
|
|
60
|
+
oneof ingress_handler {
|
|
61
|
+
// The call will be forwarded to this agent
|
|
62
|
+
string agent_aor = 10;
|
|
63
|
+
// The call will be forward to this application
|
|
64
|
+
string app_ref = 11;
|
|
65
|
+
}
|
|
71
66
|
}
|
|
72
67
|
|
|
73
68
|
// The request message for Numbers.CreateNumber
|
|
@@ -76,20 +71,21 @@ message CreateNumberRequest {
|
|
|
76
71
|
string name = 1;
|
|
77
72
|
// The tel_url of the Number
|
|
78
73
|
string tel_url = 2;
|
|
79
|
-
// The aor_link of the Number
|
|
80
|
-
string aor_link = 3;
|
|
81
74
|
// The city of the Number
|
|
82
|
-
string city =
|
|
75
|
+
string city = 3;
|
|
83
76
|
// The country of the Number
|
|
84
|
-
string country =
|
|
77
|
+
string country = 4;
|
|
85
78
|
// The country_iso_code of the Number
|
|
86
|
-
string country_iso_code =
|
|
87
|
-
// The header to use for session affinity
|
|
88
|
-
string session_affinity_header = 7;
|
|
89
|
-
// Extra headers to send to the trunk
|
|
90
|
-
repeated ExtraHeader extra_headers = 8;
|
|
79
|
+
string country_iso_code = 5;
|
|
91
80
|
// Reference to the trunk this number is associated with
|
|
92
|
-
string trunk_ref =
|
|
81
|
+
string trunk_ref = 6;
|
|
82
|
+
// This dictates how the number will handle incoming calls
|
|
83
|
+
oneof ingress_handler {
|
|
84
|
+
// The call will be forwarded to this agent
|
|
85
|
+
string agent_aor = 7;
|
|
86
|
+
// The call will be forward to this application
|
|
87
|
+
string app_ref = 8;
|
|
88
|
+
}
|
|
93
89
|
}
|
|
94
90
|
|
|
95
91
|
// The response message for Numbers.CreateNumber
|
|
@@ -104,14 +100,15 @@ message UpdateNumberRequest {
|
|
|
104
100
|
string ref = 1;
|
|
105
101
|
// The name of the Number
|
|
106
102
|
string name = 2;
|
|
107
|
-
// The aor_link of the Number
|
|
108
|
-
string aor_link = 4;
|
|
109
|
-
// The header to use for session affinity
|
|
110
|
-
string session_affinity_header = 8;
|
|
111
|
-
// Extra headers to send to the trunk
|
|
112
|
-
repeated ExtraHeader extra_headers = 9;
|
|
113
103
|
// Reference to the trunk this number is associated with
|
|
114
|
-
string trunk_ref =
|
|
104
|
+
string trunk_ref = 3;
|
|
105
|
+
// This dictates how the number will handle incoming calls
|
|
106
|
+
oneof ingress_handler {
|
|
107
|
+
// The call will be forwarded to this agent
|
|
108
|
+
string agent_aor = 4;
|
|
109
|
+
// The call will be forward to this application
|
|
110
|
+
string app_ref = 5;
|
|
111
|
+
}
|
|
115
112
|
}
|
|
116
113
|
|
|
117
114
|
// The response message for Numbers.UpdateNumber
|
|
@@ -152,4 +149,4 @@ message ListNumbersResponse {
|
|
|
152
149
|
repeated Number items = 1;
|
|
153
150
|
// Token to retrieve the next page of results, or empty if there are no more results in the list
|
|
154
151
|
string next_page_token = 2;
|
|
155
|
-
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BaseApiObject } from "../types";
|
|
2
|
+
declare enum ApplicationType {
|
|
3
|
+
PROGRAMMABLE_VOICE = "PROGRAMMABLE_VOICE"
|
|
4
|
+
}
|
|
5
|
+
type Application = {
|
|
6
|
+
ref: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: ApplicationType;
|
|
9
|
+
appEndpoint: string;
|
|
10
|
+
textToSpeech: {
|
|
11
|
+
productRef: string;
|
|
12
|
+
config: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
speechToText: {
|
|
15
|
+
productRef: string;
|
|
16
|
+
config: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
intelligence: {
|
|
19
|
+
productRef: string;
|
|
20
|
+
config: Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
updatedAt: Date;
|
|
24
|
+
};
|
|
25
|
+
type CreateApplicationRequest = {
|
|
26
|
+
name: string;
|
|
27
|
+
type: ApplicationType;
|
|
28
|
+
appEndpoint?: string;
|
|
29
|
+
textToSpeech?: {
|
|
30
|
+
productRef: string;
|
|
31
|
+
config: Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
speechToText?: {
|
|
34
|
+
productRef: string;
|
|
35
|
+
config: Record<string, unknown>;
|
|
36
|
+
};
|
|
37
|
+
intelligence?: {
|
|
38
|
+
productRef: string;
|
|
39
|
+
credentials: Record<string, unknown>;
|
|
40
|
+
config: Record<string, unknown>;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
type CreateApplicationResponse = BaseApiObject;
|
|
44
|
+
type UpdateApplicationRequest = BaseApiObject & Partial<CreateApplicationRequest>;
|
|
45
|
+
type GetApplicationRequest = BaseApiObject;
|
|
46
|
+
type UpdateApplicationResponse = BaseApiObject;
|
|
47
|
+
type DeleteApplicationRequest = BaseApiObject;
|
|
48
|
+
type DeleteApplicationResponse = BaseApiObject;
|
|
49
|
+
type ListApplicationsRequest = {
|
|
50
|
+
pageSize: number;
|
|
51
|
+
pageToken: string;
|
|
52
|
+
};
|
|
53
|
+
type ListApplicationsResponse = {
|
|
54
|
+
nextPageToken?: string;
|
|
55
|
+
items: Application[];
|
|
56
|
+
};
|
|
57
|
+
export { Application, CreateApplicationRequest, CreateApplicationResponse, UpdateApplicationRequest, UpdateApplicationResponse, DeleteApplicationRequest, DeleteApplicationResponse, ListApplicationsRequest, ListApplicationsResponse, GetApplicationRequest, ApplicationType };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApplicationType = void 0;
|
|
4
|
+
var ApplicationType;
|
|
5
|
+
(function (ApplicationType) {
|
|
6
|
+
ApplicationType["PROGRAMMABLE_VOICE"] = "PROGRAMMABLE_VOICE";
|
|
7
|
+
})(ApplicationType || (exports.ApplicationType = ApplicationType = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./applications";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/*
|
|
18
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Fonoster
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the MIT License (the "License");
|
|
24
|
+
* you may not use this file except in compliance with
|
|
25
|
+
* the License. You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* https://opensource.org/licenses/MIT
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
__exportStar(require("./applications"), exports);
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -5,5 +5,5 @@ type ServiceDefinitionParams = {
|
|
|
5
5
|
proto: string;
|
|
6
6
|
version: string;
|
|
7
7
|
};
|
|
8
|
-
declare function
|
|
9
|
-
export {
|
|
8
|
+
declare function createServiceDefinition(params: ServiceDefinitionParams): grpc.ServiceDefinition<grpc.UntypedServiceImplementation>;
|
|
9
|
+
export { createServiceDefinition, ServiceDefinitionParams };
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.createServiceDefinition = void 0;
|
|
27
27
|
/*
|
|
28
28
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
29
29
|
* http://github.com/fonoster/fonoster
|
|
@@ -51,9 +51,9 @@ const loadOptions = {
|
|
|
51
51
|
defaults: false,
|
|
52
52
|
oneofs: true
|
|
53
53
|
};
|
|
54
|
-
function
|
|
54
|
+
function createServiceDefinition(params) {
|
|
55
55
|
const pathToProto = `${__dirname}/../protos/${params.proto}`;
|
|
56
56
|
const definitions = protoLoader.loadSync(pathToProto, loadOptions);
|
|
57
57
|
return grpc.loadPackageDefinition(definitions).fonoster[params.pckg][params.version][params.serviceName].service;
|
|
58
58
|
}
|
|
59
|
-
exports.
|
|
59
|
+
exports.createServiceDefinition = createServiceDefinition;
|
package/dist/voice/voice.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { RecordRequest, RecordResponse } from "./Record";
|
|
|
7
7
|
import { SayRequest, SayResponse } from "./Say";
|
|
8
8
|
import { StartStreamRequest, StartStreamResponse, StopStreamRequest, StreamPayload } from "./Stream";
|
|
9
9
|
import { VerbRequest, VerbResponse, VoiceRequest } from "./Verb";
|
|
10
|
-
import {
|
|
10
|
+
import { GrpcError } from "../GrpcError";
|
|
11
11
|
declare const DATA: "data";
|
|
12
12
|
declare const END: "end";
|
|
13
13
|
declare const ERROR: "error";
|
|
@@ -97,5 +97,5 @@ type BaseVoiceStream<T, W> = {
|
|
|
97
97
|
end: () => void;
|
|
98
98
|
};
|
|
99
99
|
type VoiceSessionStreamServer = BaseVoiceStream<VoiceIn, VoiceOut>;
|
|
100
|
-
type VoiceSessionStreamClient = BaseVoiceStream<VoiceOut |
|
|
100
|
+
type VoiceSessionStreamClient = BaseVoiceStream<VoiceOut | GrpcError, VoiceIn | GrpcError>;
|
|
101
101
|
export { VoiceClientConfig, VoiceSessionStreamServer, VoiceSessionStreamClient, StreamEvent, StreamContent, VoiceIn, VoiceOut, DATA, END, ERROR };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/common",
|
|
3
|
-
"version": "0.6.0",
|
|
3
|
+
"version": "0.6.1-alpha.0",
|
|
4
4
|
"description": "Common library for Fonoster projects",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@fonoster/logger": "^0.6.0",
|
|
21
|
+
"@fonoster/logger": "^0.6.1-alpha.0",
|
|
22
22
|
"@grpc/grpc-js": "^1.10.6",
|
|
23
23
|
"@grpc/proto-loader": "^0.7.12",
|
|
24
24
|
"grpc-health-check": "^2.0.2",
|
|
@@ -41,5 +41,6 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/nodemailer": "^6.4.14"
|
|
44
|
-
}
|
|
44
|
+
},
|
|
45
|
+
"gitHead": "2cdd1508146747550fe048c35d9a010d04f6d3aa"
|
|
45
46
|
}
|