@fonoster/common 0.5.4 → 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.
Files changed (88) hide show
  1. package/README.md +3 -0
  2. package/dist/constants.d.ts +4 -0
  3. package/dist/constants.js +6 -0
  4. package/dist/errors.d.ts +8 -0
  5. package/dist/errors.js +95 -0
  6. package/dist/grpcStatusMap.d.ts +4 -0
  7. package/dist/{envs.js → grpcStatusMap.js} +8 -6
  8. package/dist/index.d.ts +7 -8
  9. package/dist/index.js +38 -14
  10. package/dist/notifications/compileTemplate.d.ts +6 -0
  11. package/dist/{env_is_set.js → notifications/compileTemplate.js} +12 -14
  12. package/dist/notifications/createEmailSender.d.ts +17 -0
  13. package/dist/notifications/createEmailSender.js +55 -0
  14. package/dist/notifications/index.d.ts +2 -0
  15. package/dist/notifications/index.js +36 -0
  16. package/dist/protos/acls.proto +119 -0
  17. package/dist/protos/agents.proto +155 -0
  18. package/dist/protos/applications.proto +154 -0
  19. package/dist/protos/calls.proto +162 -0
  20. package/dist/protos/credentials.proto +119 -0
  21. package/dist/protos/domains.proto +127 -0
  22. package/dist/protos/identity.proto +286 -0
  23. package/dist/protos/numbers.proto +155 -0
  24. package/dist/protos/secrets.proto +113 -0
  25. package/dist/protos/trunks.proto +164 -0
  26. package/dist/protos/voice.proto +421 -0
  27. package/dist/tts/AzureVoices.d.ts +523 -0
  28. package/dist/tts/AzureVoices.js +3622 -0
  29. package/dist/tts/GoogleVoices.d.ts +475 -0
  30. package/dist/tts/GoogleVoices.js +3284 -0
  31. package/dist/tts/index.d.ts +3 -0
  32. package/dist/tts/index.js +37 -0
  33. package/dist/tts/types.d.ts +164 -0
  34. package/dist/tts/types.js +186 -0
  35. package/dist/utils/assertEnvsAreSet.d.ts +7 -0
  36. package/dist/utils/assertEnvsAreSet.js +37 -0
  37. package/dist/utils/assertFileExists.d.ts +5 -0
  38. package/dist/utils/assertFileExists.js +38 -0
  39. package/dist/utils/createInterceptingCall.d.ts +7 -0
  40. package/dist/utils/createInterceptingCall.js +9 -0
  41. package/dist/utils/createService.d.ts +9 -0
  42. package/dist/{service_runner.js → utils/createService.js} +15 -40
  43. package/dist/utils/datesMapper.d.ts +9 -0
  44. package/dist/utils/datesMapper.js +8 -0
  45. package/dist/utils/getServerCredentials.d.ts +10 -0
  46. package/dist/{trust_util.js → utils/getServerCredentials.js} +33 -37
  47. package/dist/utils/index.d.ts +8 -0
  48. package/dist/utils/index.js +42 -0
  49. package/dist/utils/toCamelCase.d.ts +2 -0
  50. package/dist/utils/toCamelCase.js +27 -0
  51. package/dist/utils/toPascalCase.d.ts +2 -0
  52. package/dist/{speech/plugin.js → utils/toPascalCase.js} +9 -13
  53. package/dist/voice/Dial.d.ts +23 -0
  54. package/dist/voice/Dial.js +19 -0
  55. package/dist/voice/Gather.d.ts +18 -0
  56. package/dist/voice/Gather.js +9 -0
  57. package/dist/voice/Mute.d.ts +13 -0
  58. package/dist/voice/Mute.js +9 -0
  59. package/dist/voice/Play.d.ts +12 -0
  60. package/dist/voice/PlayDtmf.d.ts +5 -0
  61. package/dist/voice/PlaybackControl.d.ts +13 -0
  62. package/dist/voice/PlaybackControl.js +11 -0
  63. package/dist/voice/Record.d.ts +18 -0
  64. package/dist/voice/Record.js +7 -0
  65. package/dist/voice/Say.d.ts +15 -0
  66. package/dist/voice/Say.js +2 -0
  67. package/dist/voice/Stream.d.ts +41 -0
  68. package/dist/voice/Stream.js +39 -0
  69. package/dist/voice/Verb.d.ts +9 -0
  70. package/dist/{healthcheck.js → voice/Verb.js} +2 -5
  71. package/dist/voice/index.d.ts +11 -0
  72. package/dist/voice/index.js +45 -0
  73. package/dist/voice/voice.d.ts +101 -0
  74. package/dist/voice/voice.js +44 -0
  75. package/package.json +28 -25
  76. package/LICENSE +0 -21
  77. package/dist/api_client.d.ts +0 -27
  78. package/dist/api_client.js +0 -110
  79. package/dist/env_is_set.d.ts +0 -1
  80. package/dist/envs.d.ts +0 -4
  81. package/dist/healthcheck.d.ts +0 -2
  82. package/dist/service_runner.d.ts +0 -13
  83. package/dist/speech/plugin.d.ts +0 -6
  84. package/dist/speech/types.d.ts +0 -17
  85. package/dist/trust_util.d.ts +0 -4
  86. package/dist/types.d.ts +0 -6
  87. /package/dist/{speech/types.js → voice/Play.js} +0 -0
  88. /package/dist/{types.js → voice/PlayDtmf.js} +0 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
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
+
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,4 @@
1
+ import { ServingStatus } from "grpc-health-check";
2
+ export declare const GRPC_SERVING_STATUS: ServingStatus;
3
+ export declare const GRPC_NOT_SERVING_STATUS: ServingStatus;
4
+ export declare const STASIS_APP_NAME = "mediacontroller";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STASIS_APP_NAME = exports.GRPC_NOT_SERVING_STATUS = exports.GRPC_SERVING_STATUS = void 0;
4
+ exports.GRPC_SERVING_STATUS = "SERVING";
5
+ exports.GRPC_NOT_SERVING_STATUS = "NOT_SERVING";
6
+ exports.STASIS_APP_NAME = "mediacontroller";
@@ -0,0 +1,8 @@
1
+ type GRPCError = {
2
+ code: number;
3
+ message: string;
4
+ };
5
+ declare function handleError(error: Error | {
6
+ code: string;
7
+ }, callback: (error: GRPCError) => void): void;
8
+ export { handleError, GRPCError };
package/dist/errors.js ADDED
@@ -0,0 +1,95 @@
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
+ exports.handleError = void 0;
27
+ /*
28
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
29
+ * http://github.com/fonoster/fonoster
30
+ *
31
+ * This file is part of Fonoster
32
+ *
33
+ * Licensed under the MIT License (the "License");
34
+ * you may not use this file except in compliance with
35
+ * the License. You may obtain a copy of the License at
36
+ *
37
+ * https://opensource.org/licenses/MIT
38
+ *
39
+ * Unless required by applicable law or agreed to in writing, software
40
+ * distributed under the License is distributed on an "AS IS" BASIS,
41
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
+ * See the License for the specific language governing permissions and
43
+ * limitations under the License.
44
+ */
45
+ const logger_1 = require("@fonoster/logger");
46
+ const grpc = __importStar(require("@grpc/grpc-js"));
47
+ const grpc_js_1 = require("@grpc/grpc-js");
48
+ const zod_1 = require("zod");
49
+ const zod_validation_error_1 = require("zod-validation-error");
50
+ const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
51
+ function handleError(error, callback) {
52
+ const code = error.code;
53
+ if (error instanceof zod_1.z.ZodError) {
54
+ const validationError = (0, zod_validation_error_1.fromError)(error);
55
+ logger.error("validation error:", {
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
+ });
63
+ }
64
+ else if (code === "P2002" || code === grpc.status.ALREADY_EXISTS) {
65
+ const message = "Duplicated resource";
66
+ logger.error("duplicated entity error:", { message });
67
+ callback({ code: grpc_js_1.status.ALREADY_EXISTS, message });
68
+ }
69
+ else if (code === "P2025" || code === grpc.status.NOT_FOUND) {
70
+ const message = "The requested resource was not found";
71
+ logger.error("not found error:", { message });
72
+ callback({ code: grpc_js_1.status.NOT_FOUND, message });
73
+ }
74
+ else if (code === "P2003" || code === grpc.status.FAILED_PRECONDITION) {
75
+ // FIXME: Improve for clarity
76
+ const message = "Failed precondition error (e.g., missing dependency)";
77
+ logger.error("missing foreign key error:", { message });
78
+ callback({ code: grpc_js_1.status.FAILED_PRECONDITION, message });
79
+ }
80
+ else if (code === grpc.status.PERMISSION_DENIED) {
81
+ const message = "Permission denied";
82
+ logger.error("permission denied error:", { message });
83
+ callback({ code: grpc_js_1.status.PERMISSION_DENIED, message });
84
+ }
85
+ else if (code === grpc.status.UNAUTHENTICATED) {
86
+ const message = "Unauthenticated";
87
+ logger.error("unauthenticated error:", { message });
88
+ callback({ code: grpc_js_1.status.UNAUTHENTICATED, message });
89
+ }
90
+ else {
91
+ logger.error("unknown error:", error);
92
+ callback({ code: grpc_js_1.status.UNKNOWN, message: "Unknown error" });
93
+ }
94
+ }
95
+ exports.handleError = handleError;
@@ -0,0 +1,4 @@
1
+ declare const statusMap: {
2
+ "": import("grpc-health-check").ServingStatus;
3
+ };
4
+ export { statusMap };
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GRPC_ALLOW_INSECURE = exports.APISERVER_ACCESS_KEY_SECRET = exports.APISERVER_ACCESS_KEY_ID = exports.APISERVER_ENDPOINT = void 0;
3
+ exports.statusMap = void 0;
4
4
  /*
5
- * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
5
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
7
7
  *
8
8
  * This file is part of Fonoster
@@ -19,7 +19,9 @@ exports.GRPC_ALLOW_INSECURE = exports.APISERVER_ACCESS_KEY_SECRET = exports.APIS
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
- exports.APISERVER_ENDPOINT = process.env.APISERVER_ENDPOINT || "api.fonoster.io";
23
- exports.APISERVER_ACCESS_KEY_ID = process.env.APISERVER_ACCESS_KEY_ID;
24
- exports.APISERVER_ACCESS_KEY_SECRET = process.env.APISERVER_ACCESS_KEY_SECRET;
25
- exports.GRPC_ALLOW_INSECURE = process.env.GRPC_ALLOW_INSECURE || "false";
22
+ const constants_1 = require("./constants");
23
+ const statusMap = {
24
+ // By convention, the empty string represents the entire server
25
+ "": constants_1.GRPC_NOT_SERVING_STATUS
26
+ };
27
+ exports.statusMap = statusMap;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { ClientOptions } from "./types";
2
- import { getClientCredentials, getServerCredentials } from "./trust_util";
3
- import { Plugin } from "./speech/plugin";
4
- import { SpeechProvider, SpeechTracker, SpeechResult, StreamSpeechResult } from "./speech/types";
5
- import APIClient from "./api_client";
6
- import healthcheck from "./healthcheck";
7
- import runServices from "./service_runner";
8
- export { APIClient, ClientOptions, Plugin, SpeechTracker, SpeechResult, SpeechProvider, StreamSpeechResult, getClientCredentials, getServerCredentials, runServices, healthcheck };
1
+ export * from "./utils";
2
+ export * from "./notifications";
3
+ export * from "./errors";
4
+ export * from "./constants";
5
+ export * from "./grpcStatusMap";
6
+ export * from "./voice";
7
+ export * from "./tts";
package/dist/index.js CHANGED
@@ -1,17 +1,41 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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);
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.healthcheck = exports.runServices = exports.getServerCredentials = exports.getClientCredentials = exports.Plugin = exports.APIClient = void 0;
7
- const trust_util_1 = require("./trust_util");
8
- Object.defineProperty(exports, "getClientCredentials", { enumerable: true, get: function () { return trust_util_1.getClientCredentials; } });
9
- Object.defineProperty(exports, "getServerCredentials", { enumerable: true, get: function () { return trust_util_1.getServerCredentials; } });
10
- const plugin_1 = require("./speech/plugin");
11
- Object.defineProperty(exports, "Plugin", { enumerable: true, get: function () { return plugin_1.Plugin; } });
12
- const api_client_1 = __importDefault(require("./api_client"));
13
- exports.APIClient = api_client_1.default;
14
- const healthcheck_1 = __importDefault(require("./healthcheck"));
15
- exports.healthcheck = healthcheck_1.default;
16
- const service_runner_1 = __importDefault(require("./service_runner"));
17
- exports.runServices = service_runner_1.default;
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("./utils"), exports);
36
+ __exportStar(require("./notifications"), exports);
37
+ __exportStar(require("./errors"), exports);
38
+ __exportStar(require("./constants"), exports);
39
+ __exportStar(require("./grpcStatusMap"), exports);
40
+ __exportStar(require("./voice"), exports);
41
+ __exportStar(require("./tts"), exports);
@@ -0,0 +1,6 @@
1
+ type CompileTemplateParams = {
2
+ filePath: string;
3
+ data: Record<string, string>;
4
+ };
5
+ declare function compileTemplate(params: CompileTemplateParams): string;
6
+ export { compileTemplate, CompileTemplateParams };
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.compileTemplate = void 0;
6
7
  /*
7
- * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
8
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
8
9
  * http://github.com/fonoster/fonoster
9
10
  *
10
11
  * This file is part of Fonoster
@@ -21,18 +22,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
22
  * See the License for the specific language governing permissions and
22
23
  * limitations under the License.
23
24
  */
24
- const logger_1 = __importDefault(require("@fonoster/logger"));
25
- function assertEnvIsSet(name) {
26
- const register = require(process.env.SERVICES_ENVS ||
27
- "/home/fonoster/service_envs.json");
28
- const services = register.filter((service) => service.module === name);
29
- for (const value of services) {
30
- value.env.forEach(function (variable) {
31
- if (!(variable in process.env)) {
32
- logger_1.default.error(`The environment variable ${variable} is required but was not found`);
33
- process.exit(1);
34
- }
35
- });
25
+ const fs_1 = __importDefault(require("fs"));
26
+ const handlebars_1 = __importDefault(require("handlebars"));
27
+ function compileTemplate(params) {
28
+ const { filePath, data } = params;
29
+ if (!fs_1.default.existsSync(filePath)) {
30
+ throw new Error(`Template file not found: ${filePath}`);
36
31
  }
32
+ const source = fs_1.default.readFileSync(filePath, "utf-8").toString();
33
+ const template = handlebars_1.default.compile(source);
34
+ return template(data);
37
35
  }
38
- exports.default = assertEnvIsSet;
36
+ exports.compileTemplate = compileTemplate;
@@ -0,0 +1,17 @@
1
+ type EmailSenderConfig = {
2
+ sender: string;
3
+ host: string;
4
+ port: number;
5
+ secure: boolean;
6
+ auth: {
7
+ user: string;
8
+ pass: string;
9
+ };
10
+ };
11
+ type EmailParams = {
12
+ to: string;
13
+ subject: string;
14
+ html: string;
15
+ };
16
+ declare function createEmailSender(config: EmailSenderConfig): (params: EmailParams) => Promise<void>;
17
+ export { createEmailSender, EmailSenderConfig, EmailParams };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.createEmailSender = void 0;
13
+ /*
14
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
15
+ * http://github.com/fonoster/fonoster
16
+ *
17
+ * This file is part of Fonoster
18
+ *
19
+ * Licensed under the MIT License (the "License");
20
+ * you may not use this file except in compliance with
21
+ * the License. You may obtain a copy of the License at
22
+ *
23
+ * https://opensource.org/licenses/MIT
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
31
+ const logger_1 = require("@fonoster/logger");
32
+ const nodemailer_1 = require("nodemailer");
33
+ const logger = (0, logger_1.getLogger)({ service: "common", filePath: __filename });
34
+ function createEmailSender(config) {
35
+ const { sender, host, port, secure, auth } = config;
36
+ const transporter = (0, nodemailer_1.createTransport)({
37
+ host,
38
+ port,
39
+ secure,
40
+ auth
41
+ });
42
+ return function sendEmail(params) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const { to, subject, html } = params;
45
+ const info = yield transporter.sendMail({
46
+ from: sender,
47
+ to,
48
+ subject,
49
+ html
50
+ });
51
+ logger.verbose(`message sent: ${info.messageId}`);
52
+ });
53
+ };
54
+ }
55
+ exports.createEmailSender = createEmailSender;
@@ -0,0 +1,2 @@
1
+ export * from "./compileTemplate";
2
+ export * from "./createEmailSender";
@@ -0,0 +1,36 @@
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("./compileTemplate"), exports);
36
+ __exportStar(require("./createEmailSender"), exports);
@@ -0,0 +1,119 @@
1
+ /*
2
+ * Copyright (C) 2024 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
+ syntax = "proto3";
20
+
21
+ package fonoster.acls.v1beta2;
22
+
23
+ // AccessControlList(Acl) service definition
24
+ service Acls {
25
+ // Create a new Acl
26
+ rpc CreateAcl (CreateAclRequest) returns (CreateAclResponse) {}
27
+ // Update an existing Acl
28
+ rpc UpdateAcl (UpdateAclRequest) returns (UpdateAclResponse) {}
29
+ // Get an existing Acl
30
+ rpc GetAcl (GetAclRequest) returns (Acl) {}
31
+ // Delete an existing Acl
32
+ rpc DeleteAcl (DeleteAclRequest) returns (DeleteAclResponse) {}
33
+ // Get a list of Acls
34
+ rpc ListAcls (ListAclsRequest) returns (ListAclsResponse) {}
35
+ }
36
+
37
+ // The message for Acl resource
38
+ message Acl {
39
+ // The Acl reference
40
+ string ref = 1;
41
+ // A friendly name for the Acl
42
+ string name = 2;
43
+ // The list of allowed IP addresses
44
+ repeated string allow = 3;
45
+ // The list of denied IP addresses
46
+ repeated string deny = 4;
47
+ // The date the Acl was created
48
+ int64 created_at = 5;
49
+ // The date the Acl was last updated
50
+ int64 updated_at = 6;
51
+ }
52
+
53
+ // The request message for the Acl.CreateAcl method
54
+ message CreateAclRequest {
55
+ // A friendly name for the Acl
56
+ string name = 1;
57
+ // The list of allowed IP addresses
58
+ repeated string allow = 2;
59
+ // The list of denied IP addresses
60
+ repeated string deny = 3;
61
+ }
62
+
63
+ // The response message for the Acl.CreateAcl method
64
+ message CreateAclResponse {
65
+ // The Acl reference
66
+ string ref = 1;
67
+ }
68
+
69
+ // The request message for the Acl.UpdateAcl method
70
+ message UpdateAclRequest {
71
+ // The Acl reference
72
+ string ref = 1;
73
+ // A friendly name for the Acl
74
+ string name = 2;
75
+ // The list of allowed IP addresses
76
+ repeated string allow = 3;
77
+ // The list of denied IP addresses
78
+ repeated string deny = 4;
79
+ }
80
+
81
+ // The response message for the Acl.UpdateAcl method
82
+ message UpdateAclResponse {
83
+ // The Acl reference
84
+ string ref = 1;
85
+ }
86
+
87
+ // The request message for the Acl.GetAcl method
88
+ message GetAclRequest {
89
+ // The Acl reference
90
+ string ref = 1;
91
+ }
92
+
93
+ // The request message for the Acl.DeleteAcl method
94
+ message DeleteAclRequest {
95
+ // The Acl reference
96
+ string ref = 1;
97
+ }
98
+
99
+ // The response message for the Acl.DeleteAcl method
100
+ message DeleteAclResponse {
101
+ // The Acl reference
102
+ string ref = 1;
103
+ }
104
+
105
+ // The request message for the Acl.ListAcl method
106
+ message ListAclsRequest {
107
+ // The maximum number of items in the list
108
+ int32 page_size = 1;
109
+ // The next_page_token value returned from the previous request, if any
110
+ string page_token = 2;
111
+ }
112
+
113
+ // The response message for the Acl.ListAcl method
114
+ message ListAclsResponse {
115
+ // List of items
116
+ repeated Acl items = 1;
117
+ // Token to retrieve the next page of results, or empty if there are no more results in the list
118
+ string next_page_token = 2;
119
+ }
@@ -0,0 +1,155 @@
1
+ /*
2
+ * Copyright (C) 2024 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
+ syntax = "proto3";
20
+
21
+ package fonoster.agents.v1beta2;
22
+
23
+ import "domains.proto";
24
+ import "credentials.proto";
25
+
26
+ // The Agents service definition
27
+ service Agents {
28
+ // Create a new Agent
29
+ rpc CreateAgent (CreateAgentRequest) returns (CreateAgentResponse) {}
30
+ // Update an existing Agent
31
+ rpc UpdateAgent (UpdateAgentRequest) returns (UpdateAgentResponse) {}
32
+ // Get an existing Agent
33
+ rpc GetAgent (GetAgentRequest) returns (Agent) {}
34
+ // Delete an existing Agent
35
+ rpc DeleteAgent (DeleteAgentRequest) returns (DeleteAgentResponse) {}
36
+ // List all Agents
37
+ rpc ListAgents (ListAgentsRequest) returns (ListAgentsResponse) {}
38
+ }
39
+
40
+ // The message for a new Agent
41
+ message Agent {
42
+ // The unique identifier of the Agent
43
+ string ref = 1;
44
+ // The name of the Agent
45
+ string name = 2;
46
+ // The username of the Agent
47
+ string username = 3;
48
+ // The privacy settings of the Agent
49
+ Privacy privacy = 4;
50
+ // The enabled status of the Agent
51
+ bool enabled = 5;
52
+ // The created_at timestamp of the Agent
53
+ int64 created_at = 6;
54
+ // The updated_at timestamp of the Agent
55
+ int64 updated_at = 7;
56
+ // The maximum number of contacts that can be created for this Agent
57
+ int32 max_contacts = 8;
58
+ // Value to override the expires requested by the Agent
59
+ int32 expires = 9;
60
+ // The domain of the Agent
61
+ fonoster.domains.v1beta2.Domain domain = 10;
62
+ // The credentials of the Agent
63
+ fonoster.credentials.v1beta2.Credentials credentials = 11;
64
+ }
65
+
66
+ // The request message for Agents.CreateAgent
67
+ message CreateAgentRequest {
68
+ // The name of the Agent
69
+ string name = 1;
70
+ // The username of the Agent
71
+ string username = 2;
72
+ // The privacy settings of the Agent
73
+ Privacy privacy = 3;
74
+ // The enabled status of the Agent
75
+ bool enabled = 4;
76
+ // Reference to the Domain of the Agent
77
+ string domain_ref = 5;
78
+ // Reference to the Credentials of the Agent
79
+ string credentials_ref = 6;
80
+ // The maximum number of contacts that can be created for this Agent
81
+ int32 max_contacts = 7;
82
+ // Value to override the expires requested by the Agent
83
+ int32 expires = 8;
84
+ }
85
+
86
+ // The response message for Agents.CreateAgent
87
+ message CreateAgentResponse {
88
+ // The unique identifier of the Agent
89
+ string ref = 1;
90
+ }
91
+
92
+ // The request message for Agents.UpdateAgent
93
+ message UpdateAgentRequest {
94
+ // The unique identifier of the Agent
95
+ string ref = 1;
96
+ // The name of the Agent
97
+ string name = 2;
98
+ // The privacy settings of the Agent
99
+ Privacy privacy = 3;
100
+ // The enabled status of the Agent
101
+ bool enabled = 4;
102
+ // Reference to the Domain of the Agent
103
+ string domain_ref = 5;
104
+ // Reference to the Credentials of the Agent
105
+ string credentials_ref = 6;
106
+ // The maximum number of contacts that can be created for this Agent
107
+ int32 max_contacts = 7;
108
+ // Value to override the expires requested by the Agent
109
+ int32 expires = 8;
110
+ }
111
+
112
+ // The response message for Agents.UpdateAgent
113
+ message UpdateAgentResponse {
114
+ // The id of the updated Agent
115
+ string ref = 1;
116
+ }
117
+
118
+ // The request message for Agents.GetAgent
119
+ message GetAgentRequest {
120
+ // The unique identifier of the Agent
121
+ string ref = 1;
122
+ }
123
+
124
+ // The request message for Agents.DeleteAgent
125
+ message DeleteAgentRequest {
126
+ // The unique identifier of the Agent
127
+ string ref = 1;
128
+ }
129
+
130
+ // The response message for Agents.DeleteAgent
131
+ message DeleteAgentResponse {
132
+ // Echo back the id of the deleted Agent
133
+ string ref = 1;
134
+ }
135
+
136
+ // The request message for Agents.ListAgents
137
+ message ListAgentsRequest {
138
+ // The maximum number of items in the list
139
+ int32 page_size = 1;
140
+ // The next_page_token value returned from the previous request, if any
141
+ string page_token = 2;
142
+ }
143
+
144
+ // The response message for Agents.ListAgents
145
+ message ListAgentsResponse {
146
+ // List of Agents
147
+ repeated Agent items = 1;
148
+ // Token to retrieve the next page of results, or empty if there are no more results in the list
149
+ string next_page_token = 2;
150
+ }
151
+
152
+ enum Privacy {
153
+ PRIVATE = 0;
154
+ NONE = 1;
155
+ }