@fonoster/common 0.5.5 → 0.6.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/README.md +3 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +6 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +95 -0
- package/dist/grpcStatusMap.d.ts +4 -0
- package/dist/{envs.js → grpcStatusMap.js} +8 -6
- package/dist/index.d.ts +7 -8
- package/dist/index.js +38 -14
- package/dist/notifications/compileTemplate.d.ts +6 -0
- package/dist/{env_is_set.js → notifications/compileTemplate.js} +12 -14
- package/dist/notifications/createEmailSender.d.ts +17 -0
- package/dist/notifications/createEmailSender.js +55 -0
- package/dist/notifications/index.d.ts +2 -0
- package/dist/notifications/index.js +36 -0
- package/dist/protos/acls.proto +119 -0
- package/dist/protos/agents.proto +155 -0
- package/dist/protos/applications.proto +154 -0
- package/dist/protos/calls.proto +162 -0
- package/dist/protos/credentials.proto +119 -0
- package/dist/protos/domains.proto +127 -0
- package/dist/protos/identity.proto +286 -0
- package/dist/protos/numbers.proto +155 -0
- package/dist/protos/secrets.proto +113 -0
- package/dist/protos/trunks.proto +164 -0
- package/dist/protos/voice.proto +421 -0
- package/dist/tts/AzureVoices.d.ts +523 -0
- package/dist/tts/AzureVoices.js +3622 -0
- package/dist/tts/GoogleVoices.d.ts +475 -0
- package/dist/tts/GoogleVoices.js +3284 -0
- package/dist/tts/index.d.ts +3 -0
- package/dist/tts/index.js +37 -0
- package/dist/tts/types.d.ts +164 -0
- package/dist/tts/types.js +186 -0
- package/dist/utils/assertEnvsAreSet.d.ts +7 -0
- package/dist/utils/assertEnvsAreSet.js +37 -0
- package/dist/utils/assertFileExists.d.ts +5 -0
- package/dist/utils/assertFileExists.js +38 -0
- package/dist/utils/createInterceptingCall.d.ts +7 -0
- package/dist/utils/createInterceptingCall.js +9 -0
- package/dist/utils/createService.d.ts +9 -0
- package/dist/{service_runner.js → utils/createService.js} +15 -40
- package/dist/utils/datesMapper.d.ts +9 -0
- package/dist/utils/datesMapper.js +8 -0
- package/dist/utils/getServerCredentials.d.ts +10 -0
- package/dist/{trust_util.js → utils/getServerCredentials.js} +33 -37
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +42 -0
- package/dist/utils/toCamelCase.d.ts +2 -0
- package/dist/utils/toCamelCase.js +27 -0
- package/dist/utils/toPascalCase.d.ts +2 -0
- package/dist/{speech/plugin.js → utils/toPascalCase.js} +9 -13
- package/dist/voice/Dial.d.ts +23 -0
- package/dist/voice/Dial.js +19 -0
- package/dist/voice/Gather.d.ts +18 -0
- package/dist/voice/Gather.js +9 -0
- package/dist/voice/Mute.d.ts +13 -0
- package/dist/voice/Mute.js +9 -0
- package/dist/voice/Play.d.ts +12 -0
- package/dist/voice/PlayDtmf.d.ts +5 -0
- package/dist/voice/PlaybackControl.d.ts +13 -0
- package/dist/voice/PlaybackControl.js +11 -0
- package/dist/voice/Record.d.ts +18 -0
- package/dist/voice/Record.js +7 -0
- package/dist/voice/Say.d.ts +15 -0
- package/dist/voice/Say.js +2 -0
- package/dist/voice/Stream.d.ts +41 -0
- package/dist/voice/Stream.js +39 -0
- package/dist/voice/Verb.d.ts +9 -0
- package/dist/{healthcheck.js → voice/Verb.js} +2 -5
- package/dist/voice/index.d.ts +11 -0
- package/dist/voice/index.js +45 -0
- package/dist/voice/voice.d.ts +101 -0
- package/dist/voice/voice.js +44 -0
- package/package.json +28 -25
- package/LICENSE +0 -21
- package/dist/api_client.d.ts +0 -27
- package/dist/api_client.js +0 -110
- package/dist/env_is_set.d.ts +0 -1
- package/dist/envs.d.ts +0 -4
- package/dist/healthcheck.d.ts +0 -2
- package/dist/service_runner.d.ts +0 -13
- package/dist/speech/plugin.d.ts +0 -6
- package/dist/speech/types.d.ts +0 -17
- package/dist/trust_util.d.ts +0 -4
- package/dist/types.d.ts +0 -6
- /package/dist/{speech/types.js → voice/Play.js} +0 -0
- /package/dist/{types.js → voice/PlayDtmf.js} +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { DialRequest, DialStatus } from "./Dial";
|
|
2
|
+
import { GatherRequest, GatherResponse } from "./Gather";
|
|
3
|
+
import { MuteRequest } from "./Mute";
|
|
4
|
+
import { PlayRequest, PlayResponse } from "./Play";
|
|
5
|
+
import { PlayDtmfRequest } from "./PlayDtmf";
|
|
6
|
+
import { RecordRequest, RecordResponse } from "./Record";
|
|
7
|
+
import { SayRequest, SayResponse } from "./Say";
|
|
8
|
+
import { StartStreamRequest, StartStreamResponse, StopStreamRequest, StreamPayload } from "./Stream";
|
|
9
|
+
import { VerbRequest, VerbResponse, VoiceRequest } from "./Verb";
|
|
10
|
+
import { GRPCError } from "../errors";
|
|
11
|
+
declare const DATA: "data";
|
|
12
|
+
declare const END: "end";
|
|
13
|
+
declare const ERROR: "error";
|
|
14
|
+
declare enum StreamEvent {
|
|
15
|
+
DATA = "data",
|
|
16
|
+
END = "end",
|
|
17
|
+
ERROR = "error"
|
|
18
|
+
}
|
|
19
|
+
declare enum StreamContent {
|
|
20
|
+
ANSWER_REQUEST = "answerRequest",
|
|
21
|
+
ANSWER_RESPONSE = "answerResponse",
|
|
22
|
+
HANGUP_REQUEST = "hangupRequest",
|
|
23
|
+
HANGUP_RESPONSE = "hangupResponse",
|
|
24
|
+
PLAY_REQUEST = "playRequest",
|
|
25
|
+
PLAY_RESPONSE = "playResponse",
|
|
26
|
+
PLAY_DTMF_REQUEST = "playDtmfRequest",
|
|
27
|
+
PLAY_DTMF_RESPONSE = "playDtmfResponse",
|
|
28
|
+
PLAYBACK_CONTROL_REQUEST = "playbackControlRequest",
|
|
29
|
+
PLAYBACK_CONTROL_RESPONSE = "playbackControlResponse",
|
|
30
|
+
MUTE_REQUEST = "muteRequest",
|
|
31
|
+
MUTE_RESPONSE = "muteResponse",
|
|
32
|
+
UNMUTE_REQUEST = "unmuteRequest",
|
|
33
|
+
UNMUTE_RESPONSE = "unmuteResponse",
|
|
34
|
+
GATHER_REQUEST = "gatherRequest",
|
|
35
|
+
GATHER_RESPONSE = "gatherResponse",
|
|
36
|
+
SAY_REQUEST = "sayRequest",
|
|
37
|
+
SAY_RESPONSE = "sayResponse",
|
|
38
|
+
RECORD_REQUEST = "recordRequest",
|
|
39
|
+
RECORD_RESPONSE = "recordResponse",
|
|
40
|
+
DIAL_REQUEST = "dialRequest",
|
|
41
|
+
DIAL_RESPONSE = "dialResponse",
|
|
42
|
+
START_STREAM_REQUEST = "startStreamRequest",
|
|
43
|
+
START_STREAM_RESPONSE = "startStreamResponse",
|
|
44
|
+
STOP_STREAM_REQUEST = "stopStreamRequest",
|
|
45
|
+
STREAM_PAYLOAD = "streamPayload"
|
|
46
|
+
}
|
|
47
|
+
type VoiceClientConfig = {
|
|
48
|
+
appRef: string;
|
|
49
|
+
accessKeyId: string;
|
|
50
|
+
appEndpoint: string;
|
|
51
|
+
ingressNumber: string;
|
|
52
|
+
callerName: string;
|
|
53
|
+
callerNumber: string;
|
|
54
|
+
sessionRef: string;
|
|
55
|
+
sessionToken: string;
|
|
56
|
+
metadata?: Record<string, string>;
|
|
57
|
+
};
|
|
58
|
+
type VoiceIn = {
|
|
59
|
+
request?: VoiceRequest;
|
|
60
|
+
content?: StreamContent;
|
|
61
|
+
answerResponse?: VerbResponse;
|
|
62
|
+
hangupResponse?: VerbResponse;
|
|
63
|
+
playResponse?: PlayResponse;
|
|
64
|
+
playDtmfResponse?: VerbResponse;
|
|
65
|
+
playbackControlResponse?: VerbResponse;
|
|
66
|
+
muteResponse?: VerbResponse;
|
|
67
|
+
unmuteResponse?: VerbResponse;
|
|
68
|
+
gatherResponse?: GatherResponse;
|
|
69
|
+
sayResponse?: SayResponse;
|
|
70
|
+
recordResponse?: RecordResponse;
|
|
71
|
+
dialResponse?: {
|
|
72
|
+
status: DialStatus;
|
|
73
|
+
};
|
|
74
|
+
startStreamResponse?: StartStreamResponse;
|
|
75
|
+
streamPayload?: StreamPayload;
|
|
76
|
+
};
|
|
77
|
+
type VoiceOut = {
|
|
78
|
+
answerRequest?: VerbRequest;
|
|
79
|
+
hangupRequest?: VerbRequest;
|
|
80
|
+
playRequest?: PlayRequest;
|
|
81
|
+
playDtmfRequest?: PlayDtmfRequest;
|
|
82
|
+
playbackControlRequest?: VerbRequest;
|
|
83
|
+
muteRequest?: MuteRequest;
|
|
84
|
+
unmuteRequest?: MuteRequest;
|
|
85
|
+
gatherRequest?: GatherRequest;
|
|
86
|
+
sayRequest?: SayRequest;
|
|
87
|
+
recordRequest?: RecordRequest;
|
|
88
|
+
dialRequest?: DialRequest;
|
|
89
|
+
startStreamRequest?: StartStreamRequest;
|
|
90
|
+
stopStreamRequest?: StopStreamRequest;
|
|
91
|
+
streamPayload?: StreamPayload;
|
|
92
|
+
};
|
|
93
|
+
type BaseVoiceStream<T, W> = {
|
|
94
|
+
removeListener: (e: StreamEvent, cb: (voice: T) => void) => void;
|
|
95
|
+
on: (e: StreamEvent, cb: (voice: T) => void) => void;
|
|
96
|
+
write: (voice: W) => void;
|
|
97
|
+
end: () => void;
|
|
98
|
+
};
|
|
99
|
+
type VoiceSessionStreamServer = BaseVoiceStream<VoiceIn, VoiceOut>;
|
|
100
|
+
type VoiceSessionStreamClient = BaseVoiceStream<VoiceOut | GRPCError, VoiceIn | GRPCError>;
|
|
101
|
+
export { VoiceClientConfig, VoiceSessionStreamServer, VoiceSessionStreamClient, StreamEvent, StreamContent, VoiceIn, VoiceOut, DATA, END, ERROR };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERROR = exports.END = exports.DATA = exports.StreamContent = exports.StreamEvent = void 0;
|
|
4
|
+
const DATA = "data";
|
|
5
|
+
exports.DATA = DATA;
|
|
6
|
+
const END = "end";
|
|
7
|
+
exports.END = END;
|
|
8
|
+
const ERROR = "error";
|
|
9
|
+
exports.ERROR = ERROR;
|
|
10
|
+
var StreamEvent;
|
|
11
|
+
(function (StreamEvent) {
|
|
12
|
+
StreamEvent["DATA"] = "data";
|
|
13
|
+
StreamEvent["END"] = "end";
|
|
14
|
+
StreamEvent["ERROR"] = "error";
|
|
15
|
+
})(StreamEvent || (exports.StreamEvent = StreamEvent = {}));
|
|
16
|
+
var StreamContent;
|
|
17
|
+
(function (StreamContent) {
|
|
18
|
+
StreamContent["ANSWER_REQUEST"] = "answerRequest";
|
|
19
|
+
StreamContent["ANSWER_RESPONSE"] = "answerResponse";
|
|
20
|
+
StreamContent["HANGUP_REQUEST"] = "hangupRequest";
|
|
21
|
+
StreamContent["HANGUP_RESPONSE"] = "hangupResponse";
|
|
22
|
+
StreamContent["PLAY_REQUEST"] = "playRequest";
|
|
23
|
+
StreamContent["PLAY_RESPONSE"] = "playResponse";
|
|
24
|
+
StreamContent["PLAY_DTMF_REQUEST"] = "playDtmfRequest";
|
|
25
|
+
StreamContent["PLAY_DTMF_RESPONSE"] = "playDtmfResponse";
|
|
26
|
+
StreamContent["PLAYBACK_CONTROL_REQUEST"] = "playbackControlRequest";
|
|
27
|
+
StreamContent["PLAYBACK_CONTROL_RESPONSE"] = "playbackControlResponse";
|
|
28
|
+
StreamContent["MUTE_REQUEST"] = "muteRequest";
|
|
29
|
+
StreamContent["MUTE_RESPONSE"] = "muteResponse";
|
|
30
|
+
StreamContent["UNMUTE_REQUEST"] = "unmuteRequest";
|
|
31
|
+
StreamContent["UNMUTE_RESPONSE"] = "unmuteResponse";
|
|
32
|
+
StreamContent["GATHER_REQUEST"] = "gatherRequest";
|
|
33
|
+
StreamContent["GATHER_RESPONSE"] = "gatherResponse";
|
|
34
|
+
StreamContent["SAY_REQUEST"] = "sayRequest";
|
|
35
|
+
StreamContent["SAY_RESPONSE"] = "sayResponse";
|
|
36
|
+
StreamContent["RECORD_REQUEST"] = "recordRequest";
|
|
37
|
+
StreamContent["RECORD_RESPONSE"] = "recordResponse";
|
|
38
|
+
StreamContent["DIAL_REQUEST"] = "dialRequest";
|
|
39
|
+
StreamContent["DIAL_RESPONSE"] = "dialResponse";
|
|
40
|
+
StreamContent["START_STREAM_REQUEST"] = "startStreamRequest";
|
|
41
|
+
StreamContent["START_STREAM_RESPONSE"] = "startStreamResponse";
|
|
42
|
+
StreamContent["STOP_STREAM_REQUEST"] = "stopStreamRequest";
|
|
43
|
+
StreamContent["STREAM_PAYLOAD"] = "streamPayload";
|
|
44
|
+
})(StreamContent || (exports.StreamContent = StreamContent = {}));
|
package/package.json
CHANGED
|
@@ -1,42 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/common",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Common
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Common library for Fonoster projects",
|
|
5
|
+
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
5
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
6
|
-
"bugs": {
|
|
7
|
-
"url": "https://github.com/fonoster/fonoster/issues"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/fonoster/fonoster.git"
|
|
12
|
-
},
|
|
13
7
|
"license": "MIT",
|
|
14
|
-
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
15
8
|
"main": "dist/index",
|
|
16
9
|
"types": "dist/index",
|
|
17
10
|
"directories": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
11
|
+
"src": "src",
|
|
12
|
+
"test": "test"
|
|
20
13
|
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
24
14
|
"scripts": {
|
|
25
15
|
"prebuild": "rimraf ./dist tsconfig.tsbuildinfo",
|
|
26
|
-
"build": "tsc -b tsconfig.json"
|
|
16
|
+
"build": "tsc -b tsconfig.json",
|
|
17
|
+
"postbuild": "cp -a src/protos dist && node ../../.scripts/copy-hbs.js",
|
|
18
|
+
"clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo"
|
|
27
19
|
},
|
|
28
20
|
"dependencies": {
|
|
29
|
-
"@fonoster/
|
|
30
|
-
"@
|
|
31
|
-
"@grpc/
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"grpc-interceptors": "github:fonoster/node-grpc-interceptors"
|
|
21
|
+
"@fonoster/logger": "^0.6.0",
|
|
22
|
+
"@grpc/grpc-js": "^1.10.6",
|
|
23
|
+
"@grpc/proto-loader": "^0.7.12",
|
|
24
|
+
"grpc-health-check": "^2.0.2",
|
|
25
|
+
"handlebars": "^4.7.8",
|
|
26
|
+
"nodemailer": "^6.9.13",
|
|
27
|
+
"zod-validation-error": "^3.3.0"
|
|
37
28
|
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
38
32
|
"publishConfig": {
|
|
39
33
|
"access": "public"
|
|
40
34
|
},
|
|
41
|
-
"
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/fonoster/fonoster.git"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/fonoster/fonoster/issues"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/nodemailer": "^6.4.14"
|
|
44
|
+
}
|
|
42
45
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 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/dist/api_client.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ClientOptions } from "./types";
|
|
2
|
-
import { Metadata } from "@grpc/grpc-js";
|
|
3
|
-
export default class {
|
|
4
|
-
options: ClientOptions;
|
|
5
|
-
metadata: Metadata;
|
|
6
|
-
ServiceClient: any;
|
|
7
|
-
service: any;
|
|
8
|
-
/**
|
|
9
|
-
* Use the Options object to overwrite the service default configuration.
|
|
10
|
-
* @typedef {ClientOptions} Options
|
|
11
|
-
* @property {string} endpoint - The endpoint URI to send requests to.
|
|
12
|
-
* The endpoint should be a string like '{serviceHost}:{servicePort}'.
|
|
13
|
-
* @property {string} accessKeyId - your Fonoster access key ID.
|
|
14
|
-
* @property {string} accessKeySecret - your Fonoster secret access key.
|
|
15
|
-
* @property {string} bucket - The bucket to upload apps and media files.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Constructs a service object.
|
|
19
|
-
*
|
|
20
|
-
* @param {Options} options - Overwrite for the service's defaults configuration.
|
|
21
|
-
*/
|
|
22
|
-
constructor(ServiceClient: any, options: ClientOptions);
|
|
23
|
-
init(): void;
|
|
24
|
-
getOptions(): ClientOptions;
|
|
25
|
-
getService(): any;
|
|
26
|
-
getMeta(): Metadata;
|
|
27
|
-
}
|
package/dist/api_client.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
/*
|
|
27
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
28
|
-
* http://github.com/fonoster/fonoster
|
|
29
|
-
*
|
|
30
|
-
* This file is part of Fonoster
|
|
31
|
-
*
|
|
32
|
-
* Licensed under the MIT License (the "License");
|
|
33
|
-
* you may not use this file except in compliance with
|
|
34
|
-
* the License. You may obtain a copy of the License at
|
|
35
|
-
*
|
|
36
|
-
* https://opensource.org/licenses/MIT
|
|
37
|
-
*
|
|
38
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
39
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
40
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
41
|
-
* See the License for the specific language governing permissions and
|
|
42
|
-
* limitations under the License.
|
|
43
|
-
*/
|
|
44
|
-
const fs = __importStar(require("fs"));
|
|
45
|
-
const path = __importStar(require("path"));
|
|
46
|
-
const trust_util_1 = require("./trust_util");
|
|
47
|
-
const grpc_js_1 = require("@grpc/grpc-js");
|
|
48
|
-
const envs_1 = require("./envs");
|
|
49
|
-
const CONFIG_FILE = path.join(require("os").homedir(), ".fonoster", "config");
|
|
50
|
-
const configFileExit = () => fs.existsSync(CONFIG_FILE);
|
|
51
|
-
const getConfigFile = () => JSON.parse(fs.readFileSync(CONFIG_FILE).toString());
|
|
52
|
-
const defaultOptions = {
|
|
53
|
-
endpoint: envs_1.APISERVER_ENDPOINT || "api.fonoster.io",
|
|
54
|
-
accessKeyId: envs_1.APISERVER_ACCESS_KEY_ID,
|
|
55
|
-
accessKeySecret: envs_1.APISERVER_ACCESS_KEY_SECRET
|
|
56
|
-
};
|
|
57
|
-
class default_1 {
|
|
58
|
-
options;
|
|
59
|
-
metadata;
|
|
60
|
-
ServiceClient;
|
|
61
|
-
service;
|
|
62
|
-
/**
|
|
63
|
-
* Use the Options object to overwrite the service default configuration.
|
|
64
|
-
* @typedef {ClientOptions} Options
|
|
65
|
-
* @property {string} endpoint - The endpoint URI to send requests to.
|
|
66
|
-
* The endpoint should be a string like '{serviceHost}:{servicePort}'.
|
|
67
|
-
* @property {string} accessKeyId - your Fonoster access key ID.
|
|
68
|
-
* @property {string} accessKeySecret - your Fonoster secret access key.
|
|
69
|
-
* @property {string} bucket - The bucket to upload apps and media files.
|
|
70
|
-
*/
|
|
71
|
-
/**
|
|
72
|
-
* Constructs a service object.
|
|
73
|
-
*
|
|
74
|
-
* @param {Options} options - Overwrite for the service's defaults configuration.
|
|
75
|
-
*/
|
|
76
|
-
constructor(ServiceClient, options) {
|
|
77
|
-
this.ServiceClient = ServiceClient;
|
|
78
|
-
this.options = options;
|
|
79
|
-
}
|
|
80
|
-
init() {
|
|
81
|
-
try {
|
|
82
|
-
if (!this.options && configFileExit()) {
|
|
83
|
-
this.options = getConfigFile();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
throw new Error(`Malformed config file found at: ${CONFIG_FILE}`);
|
|
88
|
-
}
|
|
89
|
-
if (!this.options) {
|
|
90
|
-
this.options = defaultOptions;
|
|
91
|
-
}
|
|
92
|
-
if (!this.options.accessKeyId || !this.options.accessKeySecret) {
|
|
93
|
-
throw new Error("Not valid credentials found");
|
|
94
|
-
}
|
|
95
|
-
this.metadata = new grpc_js_1.Metadata();
|
|
96
|
-
this.metadata.add("access_key_id", this.options.accessKeyId);
|
|
97
|
-
this.metadata.add("access_key_secret", this.options.accessKeySecret);
|
|
98
|
-
this.service = new this.ServiceClient(this.options.endpoint || defaultOptions.endpoint, (0, trust_util_1.getClientCredentials)());
|
|
99
|
-
}
|
|
100
|
-
getOptions() {
|
|
101
|
-
return this.options;
|
|
102
|
-
}
|
|
103
|
-
getService() {
|
|
104
|
-
return this.service;
|
|
105
|
-
}
|
|
106
|
-
getMeta() {
|
|
107
|
-
return this.metadata;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
exports.default = default_1;
|
package/dist/env_is_set.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function assertEnvIsSet(name: string): void;
|
package/dist/envs.d.ts
DELETED
package/dist/healthcheck.d.ts
DELETED
package/dist/service_runner.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
interface ServiceInf {
|
|
2
|
-
name: string;
|
|
3
|
-
version: string;
|
|
4
|
-
service: any;
|
|
5
|
-
server: any;
|
|
6
|
-
}
|
|
7
|
-
interface Middleware {
|
|
8
|
-
name: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
middlewareObj: any;
|
|
11
|
-
}
|
|
12
|
-
export default function run(srvInfList: ServiceInf[], middlewareList?: Middleware[]): void;
|
|
13
|
-
export {};
|
package/dist/speech/plugin.d.ts
DELETED
package/dist/speech/types.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Stream } from "stream";
|
|
3
|
-
export interface SpeechProvider {
|
|
4
|
-
createSpeechTracker(options: unknown): SpeechTracker;
|
|
5
|
-
}
|
|
6
|
-
export interface SpeechTracker {
|
|
7
|
-
transcribe(stream: Stream): Promise<SpeechResult>;
|
|
8
|
-
streamTranscribe(stream: Stream): StreamSpeechResult;
|
|
9
|
-
}
|
|
10
|
-
export interface SpeechResult {
|
|
11
|
-
transcript: string;
|
|
12
|
-
isFinal: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface StreamSpeechResult {
|
|
15
|
-
on(events: string, callback: Function): void;
|
|
16
|
-
close: Function;
|
|
17
|
-
}
|
package/dist/trust_util.d.ts
DELETED
package/dist/types.d.ts
DELETED
|
File without changes
|
|
File without changes
|