@fonoster/common 0.7.4 → 0.7.7

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 (67) hide show
  1. package/README.md +2 -2
  2. package/dist/constants.d.ts +1 -1
  3. package/dist/constants.js +2 -2
  4. package/dist/errors/index.d.ts +1 -1
  5. package/dist/errors/index.js +1 -1
  6. package/dist/index.d.ts +7 -5
  7. package/dist/index.js +20 -5
  8. package/dist/notifications/compileTemplate.d.ts +1 -1
  9. package/dist/notifications/createEmailSender.d.ts +1 -1
  10. package/dist/protos/voice.proto +1 -2
  11. package/dist/tts/index.d.ts +1 -1
  12. package/dist/tts/index.js +2 -2
  13. package/dist/tts/types.d.ts +1 -1
  14. package/dist/tts/types.js +1 -1
  15. package/dist/types.d.ts +1 -1
  16. package/dist/utils/createService.d.ts +1 -1
  17. package/dist/utils/getServerCredentials.d.ts +1 -1
  18. package/dist/utils/getServerCredentials.js +0 -1
  19. package/dist/utils/index.d.ts +5 -2
  20. package/dist/utils/index.js +5 -2
  21. package/dist/utils/withErrorHandling.d.ts +5 -0
  22. package/dist/utils/withErrorHandling.js +42 -0
  23. package/dist/utils/withErrorHandlingAndValidation.d.ts +5 -0
  24. package/dist/utils/withErrorHandlingAndValidation.js +8 -0
  25. package/dist/utils/withValidation.d.ts +6 -0
  26. package/dist/utils/withValidation.js +18 -0
  27. package/dist/validators/calls.d.ts +48 -0
  28. package/dist/validators/calls.js +55 -0
  29. package/dist/validators/common.d.ts +19 -0
  30. package/dist/validators/common.js +33 -0
  31. package/dist/validators/hostOrHostPortSchema.d.ts +3 -0
  32. package/dist/validators/hostOrHostPortSchema.js +33 -0
  33. package/dist/validators/identity.d.ts +119 -0
  34. package/dist/validators/identity.js +93 -0
  35. package/dist/validators/index.d.ts +6 -0
  36. package/dist/validators/index.js +40 -0
  37. package/dist/validators/secrets.d.ts +12 -0
  38. package/dist/validators/secrets.js +35 -0
  39. package/dist/validators/sipnet/acls.d.ts +4 -0
  40. package/dist/validators/sipnet/acls.js +26 -0
  41. package/dist/validators/sipnet/agents.d.ts +4 -0
  42. package/dist/validators/sipnet/agents.js +26 -0
  43. package/dist/validators/sipnet/credentials.d.ts +4 -0
  44. package/dist/validators/sipnet/credentials.js +26 -0
  45. package/dist/validators/sipnet/domains.d.ts +4 -0
  46. package/dist/validators/sipnet/domains.js +26 -0
  47. package/dist/validators/sipnet/index.d.ts +6 -0
  48. package/dist/validators/sipnet/index.js +40 -0
  49. package/dist/validators/sipnet/numbers.d.ts +39 -0
  50. package/dist/validators/sipnet/numbers.js +50 -0
  51. package/dist/validators/sipnet/trunks.d.ts +4 -0
  52. package/dist/validators/sipnet/trunks.js +26 -0
  53. package/dist/voice/Dial.d.ts +1 -1
  54. package/dist/voice/Dial.js +1 -1
  55. package/dist/voice/Mute.d.ts +1 -1
  56. package/dist/voice/Play.d.ts +1 -1
  57. package/dist/voice/PlaybackControl.d.ts +1 -1
  58. package/dist/voice/Record.d.ts +1 -1
  59. package/dist/voice/Say.d.ts +1 -1
  60. package/dist/voice/Stream.d.ts +1 -1
  61. package/dist/voice/Stream.js +1 -1
  62. package/dist/voice/StreamGather.d.ts +1 -1
  63. package/dist/voice/index.d.ts +3 -3
  64. package/dist/voice/index.js +11 -11
  65. package/dist/voice/voice.d.ts +1 -1
  66. package/dist/voice/voice.js +1 -1
  67. package/package.json +4 -3
package/README.md CHANGED
@@ -1,3 +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" />
1
+ [![Discord](https://img.shields.io/discord/1016419835455996076?color=5865F2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/4QWgSz4hTC) ![GitHub](https://img.shields.io/github/license/fonoster/fonoster?color=%2347b96d) ![Twitter Follow](https://img.shields.io/twitter/follow/fonoster?style=social)
2
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).
3
+ This module is part of the [Fonoster](https://fonoster.com) open-source. 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).
@@ -1,4 +1,4 @@
1
1
  import { ServingStatus } from "grpc-health-check";
2
- export declare const GRPC_SERVING_STATUS: ServingStatus;
3
2
  export declare const GRPC_NOT_SERVING_STATUS: ServingStatus;
3
+ export declare const GRPC_SERVING_STATUS: ServingStatus;
4
4
  export declare const STASIS_APP_NAME = "mediacontroller";
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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";
3
+ exports.STASIS_APP_NAME = exports.GRPC_SERVING_STATUS = exports.GRPC_NOT_SERVING_STATUS = void 0;
5
4
  exports.GRPC_NOT_SERVING_STATUS = "NOT_SERVING";
5
+ exports.GRPC_SERVING_STATUS = "SERVING";
6
6
  exports.STASIS_APP_NAME = "mediacontroller";
@@ -1,4 +1,4 @@
1
- export * from "./handleError";
2
1
  export * from "./PrismaErrorEnum";
2
+ export * from "./handleError";
3
3
  export * from "./handleZodError";
4
4
  export * from "./types";
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./PrismaErrorEnum"), exports);
17
18
  /*
18
19
  * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
19
20
  * http://github.com/fonoster/fonoster
@@ -33,6 +34,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
34
  * limitations under the License.
34
35
  */
35
36
  __exportStar(require("./handleError"), exports);
36
- __exportStar(require("./PrismaErrorEnum"), exports);
37
37
  __exportStar(require("./handleZodError"), exports);
38
38
  __exportStar(require("./types"), exports);
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- export * from "./utils";
2
- export * from "./notifications";
3
- export * from "./errors";
1
+ export * from "./GrpcError";
4
2
  export * from "./constants";
3
+ export * from "./errors";
5
4
  export * from "./grpcStatusMap";
6
- export * from "./voice";
5
+ export * from "./notifications";
7
6
  export * from "./tts";
8
7
  export * from "./types";
9
- export * from "./GrpcError";
8
+ export * from "./utils";
9
+ export * as Validators from "./validators";
10
+ export * from "./validators";
11
+ export * from "./voice";
package/dist/index.js CHANGED
@@ -10,10 +10,23 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
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
+ });
13
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
20
  };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
16
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.Validators = void 0;
17
30
  /*
18
31
  * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
19
32
  * http://github.com/fonoster/fonoster
@@ -32,12 +45,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
32
45
  * See the License for the specific language governing permissions and
33
46
  * limitations under the License.
34
47
  */
35
- __exportStar(require("./utils"), exports);
36
- __exportStar(require("./notifications"), exports);
37
- __exportStar(require("./errors"), exports);
48
+ __exportStar(require("./GrpcError"), exports);
38
49
  __exportStar(require("./constants"), exports);
50
+ __exportStar(require("./errors"), exports);
39
51
  __exportStar(require("./grpcStatusMap"), exports);
40
- __exportStar(require("./voice"), exports);
52
+ __exportStar(require("./notifications"), exports);
41
53
  __exportStar(require("./tts"), exports);
42
54
  __exportStar(require("./types"), exports);
43
- __exportStar(require("./GrpcError"), exports);
55
+ __exportStar(require("./utils"), exports);
56
+ exports.Validators = __importStar(require("./validators"));
57
+ __exportStar(require("./validators"), exports);
58
+ __exportStar(require("./voice"), exports);
@@ -3,4 +3,4 @@ type CompileTemplateParams = {
3
3
  data: Record<string, string>;
4
4
  };
5
5
  declare function compileTemplate(params: CompileTemplateParams): string;
6
- export { compileTemplate, CompileTemplateParams };
6
+ export { CompileTemplateParams, compileTemplate };
@@ -14,4 +14,4 @@ type EmailParams = {
14
14
  html: string;
15
15
  };
16
16
  declare function createEmailSender(config: EmailSenderConfig): (params: EmailParams) => Promise<void>;
17
- export { createEmailSender, EmailSenderConfig, EmailParams };
17
+ export { EmailParams, EmailSenderConfig, createEmailSender };
@@ -312,8 +312,7 @@ message StreamPayload {
312
312
 
313
313
  // The audio data
314
314
  bytes data = 4;
315
-
316
- // TODO: Consider turning this into a enum
315
+
317
316
  // (Q. should we use the same error codes as gRPC?)
318
317
  // Error code if any
319
318
  string code = 5;
@@ -1,4 +1,4 @@
1
- export * from "./GoogleVoices";
2
1
  export * from "./AzureVoices";
3
2
  export * from "./DeepgramVoices";
3
+ export * from "./GoogleVoices";
4
4
  export * from "./types";
package/dist/tts/index.js CHANGED
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AzureVoices"), exports);
18
+ __exportStar(require("./DeepgramVoices"), exports);
17
19
  /*
18
20
  * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
19
21
  * http://github.com/fonoster/fonoster
@@ -33,6 +35,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
35
  * limitations under the License.
34
36
  */
35
37
  __exportStar(require("./GoogleVoices"), exports);
36
- __exportStar(require("./AzureVoices"), exports);
37
- __exportStar(require("./DeepgramVoices"), exports);
38
38
  __exportStar(require("./types"), exports);
@@ -161,4 +161,4 @@ declare enum VoiceGender {
161
161
  FEMALE = 1,
162
162
  NEUTRAL = 2
163
163
  }
164
- export { VoiceLanguage, VoiceGender };
164
+ export { VoiceGender, VoiceLanguage };
package/dist/tts/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VoiceGender = exports.VoiceLanguage = void 0;
3
+ exports.VoiceLanguage = exports.VoiceGender = void 0;
4
4
  /*
5
5
  * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
package/dist/types.d.ts CHANGED
@@ -5,4 +5,4 @@ type NumberPreconditionsCheck = (request: {
5
5
  appRef?: string;
6
6
  agentAor?: string;
7
7
  }) => Promise<void>;
8
- export { NumberPreconditionsCheck, BaseApiObject };
8
+ export { BaseApiObject, NumberPreconditionsCheck };
@@ -6,4 +6,4 @@ type ServiceDefinitionParams = {
6
6
  version: string;
7
7
  };
8
8
  declare function createServiceDefinition(params: ServiceDefinitionParams): grpc.ServiceDefinition<grpc.UntypedServiceImplementation>;
9
- export { createServiceDefinition, ServiceDefinitionParams };
9
+ export { ServiceDefinitionParams, createServiceDefinition };
@@ -7,4 +7,4 @@ type CredentialsConfig = {
7
7
  serverKey?: string;
8
8
  };
9
9
  declare function getServerCredentials(config: CredentialsConfig): Promise<grpc.ServerCredentials>;
10
- export { getServerCredentials, CredentialsConfig };
10
+ export { CredentialsConfig, getServerCredentials };
@@ -66,7 +66,6 @@ function getServerCredentials(config) {
66
66
  serverKey
67
67
  });
68
68
  if (tlsOn) {
69
- // TODO: Assert that all the required fields are present
70
69
  const cacert = verifyClientCert ? fs.readFileSync(caCert) : null;
71
70
  return grpc.ServerCredentials.createSsl(cacert, [
72
71
  {
@@ -1,8 +1,11 @@
1
1
  export * from "./assertEnvsAreSet";
2
2
  export * from "./assertFileExists";
3
- export * from "./createService";
4
3
  export * from "./createInterceptingCall";
4
+ export * from "./createService";
5
5
  export * from "./datesMapper";
6
6
  export * from "./getServerCredentials";
7
- export * from "./toPascalCase";
8
7
  export * from "./toCamelCase";
8
+ export * from "./toPascalCase";
9
+ export * from "./withErrorHandling";
10
+ export * from "./withErrorHandlingAndValidation";
11
+ export * from "./withValidation";
@@ -34,9 +34,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
34
  */
35
35
  __exportStar(require("./assertEnvsAreSet"), exports);
36
36
  __exportStar(require("./assertFileExists"), exports);
37
- __exportStar(require("./createService"), exports);
38
37
  __exportStar(require("./createInterceptingCall"), exports);
38
+ __exportStar(require("./createService"), exports);
39
39
  __exportStar(require("./datesMapper"), exports);
40
40
  __exportStar(require("./getServerCredentials"), exports);
41
- __exportStar(require("./toPascalCase"), exports);
42
41
  __exportStar(require("./toCamelCase"), exports);
42
+ __exportStar(require("./toPascalCase"), exports);
43
+ __exportStar(require("./withErrorHandling"), exports);
44
+ __exportStar(require("./withErrorHandlingAndValidation"), exports);
45
+ __exportStar(require("./withValidation"), exports);
@@ -0,0 +1,5 @@
1
+ import { GrpcErrorMessage } from "../errors";
2
+ declare function withErrorHandling(fn: Function): (call: {
3
+ request: unknown;
4
+ }, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
5
+ export { withErrorHandling };
@@ -0,0 +1,42 @@
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.withErrorHandling = withErrorHandling;
13
+ /* eslint-disable @typescript-eslint/ban-types */
14
+ /*
15
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
16
+ * http://github.com/fonoster/fonoster
17
+ *
18
+ * This file is part of Fonoster
19
+ *
20
+ * Licensed under the MIT License (the "License");
21
+ * you may not use this file except in compliance with
22
+ * the License. You may obtain a copy of the License at
23
+ *
24
+ * https://opensource.org/licenses/MIT
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS,
28
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ * See the License for the specific language governing permissions and
30
+ * limitations under the License.
31
+ */
32
+ const errors_1 = require("../errors");
33
+ function withErrorHandling(fn) {
34
+ return (call, callback) => __awaiter(this, void 0, void 0, function* () {
35
+ try {
36
+ yield fn(call, callback);
37
+ }
38
+ catch (error) {
39
+ (0, errors_1.handleError)(error, callback);
40
+ }
41
+ });
42
+ }
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ declare function withErrorHandlingAndValidation(fn: Function, schema: z.ZodSchema): (call: {
3
+ request: unknown;
4
+ }, callback: (error?: import("..").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
5
+ export { withErrorHandlingAndValidation };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withErrorHandlingAndValidation = withErrorHandlingAndValidation;
4
+ const withErrorHandling_1 = require("./withErrorHandling");
5
+ const withValidation_1 = require("./withValidation");
6
+ function withErrorHandlingAndValidation(fn, schema) {
7
+ return (0, withErrorHandling_1.withErrorHandling)((0, withValidation_1.withValidation)(fn, schema));
8
+ }
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+ import { GrpcErrorMessage } from "../errors";
3
+ declare function withValidation(fn: Function, schema: z.ZodSchema): (call: {
4
+ request: unknown;
5
+ }, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
6
+ export { withValidation };
@@ -0,0 +1,18 @@
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.withValidation = withValidation;
13
+ function withValidation(fn, schema) {
14
+ return (call, callback) => __awaiter(this, void 0, void 0, function* () {
15
+ schema.parse(call.request);
16
+ yield fn(call, callback);
17
+ });
18
+ }
@@ -0,0 +1,48 @@
1
+ import { CallStatus, CallType } from "@fonoster/types";
2
+ import { z } from "zod";
3
+ declare const createCallRequestSchema: z.ZodObject<{
4
+ from: z.ZodString;
5
+ to: z.ZodString;
6
+ appRef: z.ZodString;
7
+ timeout: z.ZodOptional<z.ZodNumber>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ timeout?: number;
10
+ from?: string;
11
+ to?: string;
12
+ appRef?: string;
13
+ }, {
14
+ timeout?: number;
15
+ from?: string;
16
+ to?: string;
17
+ appRef?: string;
18
+ }>;
19
+ declare const getCallRequestSchema: z.ZodObject<{
20
+ ref: z.ZodString;
21
+ }, "strip", z.ZodTypeAny, {
22
+ ref?: string;
23
+ }, {
24
+ ref?: string;
25
+ }>;
26
+ declare const listCallsRequestSchema: z.ZodObject<{
27
+ after: z.ZodOptional<z.ZodString>;
28
+ before: z.ZodOptional<z.ZodString>;
29
+ pageSize: z.ZodOptional<z.ZodNumber>;
30
+ type: z.ZodOptional<z.ZodNativeEnum<typeof CallType>>;
31
+ status: z.ZodOptional<z.ZodNativeEnum<typeof CallStatus>>;
32
+ pageToken: z.ZodOptional<z.ZodString>;
33
+ }, "strip", z.ZodTypeAny, {
34
+ type?: CallType;
35
+ status?: CallStatus;
36
+ after?: string;
37
+ before?: string;
38
+ pageSize?: number;
39
+ pageToken?: string;
40
+ }, {
41
+ type?: CallType;
42
+ status?: CallStatus;
43
+ after?: string;
44
+ before?: string;
45
+ pageSize?: number;
46
+ pageToken?: string;
47
+ }>;
48
+ export { createCallRequestSchema, getCallRequestSchema, listCallsRequestSchema };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listCallsRequestSchema = exports.getCallRequestSchema = exports.createCallRequestSchema = 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 types_1 = require("@fonoster/types");
23
+ const zod_1 = require("zod");
24
+ const createCallRequestSchema = zod_1.z.object({
25
+ from: zod_1.z.string(),
26
+ to: zod_1.z.string(),
27
+ appRef: zod_1.z.string().uuid("Invalid call reference"),
28
+ timeout: zod_1.z.number().max(120, "Timeout must be less than 120s").optional()
29
+ });
30
+ exports.createCallRequestSchema = createCallRequestSchema;
31
+ const getCallRequestSchema = zod_1.z.object({
32
+ ref: zod_1.z.string().uuid("Invalid call reference")
33
+ });
34
+ exports.getCallRequestSchema = getCallRequestSchema;
35
+ const listCallsRequestSchema = zod_1.z.object({
36
+ after: zod_1.z
37
+ .string()
38
+ .datetime({ offset: true, message: "The date must be a valid ISO 8601" })
39
+ .optional(),
40
+ before: zod_1.z
41
+ .string()
42
+ .datetime({ offset: true, message: "The date must be a valid ISO 8601" })
43
+ .optional(),
44
+ pageSize: zod_1.z.number({ message: "Invalid pageSize value" }).optional(),
45
+ type: zod_1.z
46
+ .nativeEnum(types_1.CallType, {
47
+ message: "Invalid call type"
48
+ })
49
+ .optional(),
50
+ status: zod_1.z
51
+ .nativeEnum(types_1.CallStatus, { message: "Invalid call status" })
52
+ .optional(),
53
+ pageToken: zod_1.z.string({ message: "The pageToken must be a string" }).optional()
54
+ });
55
+ exports.listCallsRequestSchema = listCallsRequestSchema;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ declare const baseApiObjectSchema: z.ZodObject<{
3
+ ref: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ ref?: string;
6
+ }, {
7
+ ref?: string;
8
+ }>;
9
+ declare const listRequestSchema: z.ZodOptional<z.ZodObject<{
10
+ pageSize: z.ZodOptional<z.ZodNumber>;
11
+ pageToken: z.ZodOptional<z.ZodString>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ pageSize?: number;
14
+ pageToken?: string;
15
+ }, {
16
+ pageSize?: number;
17
+ pageToken?: string;
18
+ }>>;
19
+ export { baseApiObjectSchema, listRequestSchema };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listRequestSchema = exports.baseApiObjectSchema = 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 zod_1 = require("zod");
23
+ const baseApiObjectSchema = zod_1.z.object({
24
+ ref: zod_1.z.string()
25
+ });
26
+ exports.baseApiObjectSchema = baseApiObjectSchema;
27
+ const listRequestSchema = zod_1.z
28
+ .object({
29
+ pageSize: zod_1.z.number().optional(),
30
+ pageToken: zod_1.z.string().optional()
31
+ })
32
+ .optional();
33
+ exports.listRequestSchema = listRequestSchema;
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+ declare const hostOrHostPortSchema: z.ZodEffects<z.ZodOptional<z.ZodString>, string, string>;
3
+ export { hostOrHostPortSchema };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hostOrHostPortSchema = 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 zod_1 = require("zod");
23
+ const hostOrHostPortSchema = zod_1.z
24
+ .string()
25
+ .optional()
26
+ .refine((value) => {
27
+ const hostRegex = /^(?!:\/\/)([a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)*|(\d{1,3}\.){3}\d{1,3})$/;
28
+ const hostPortRegex = /^(?!:\/\/)([a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)*|(\d{1,3}\.){3}\d{1,3}):\d{1,5}$/;
29
+ return hostRegex.test(value) || hostPortRegex.test(value);
30
+ }, {
31
+ message: "Invalid format. Expected 'host' or 'host:port'"
32
+ });
33
+ exports.hostOrHostPortSchema = hostOrHostPortSchema;
@@ -0,0 +1,119 @@
1
+ import { ApiRoleEnum, WorkspaceRoleEnum } from "@fonoster/types";
2
+ import { z } from "zod";
3
+ declare const createWorkspaceRequestSchema: z.ZodObject<{
4
+ name: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ name?: string;
7
+ }, {
8
+ name?: string;
9
+ }>;
10
+ declare const createApiKeyRequestSchema: z.ZodObject<{
11
+ role: z.ZodEnum<[ApiRoleEnum]>;
12
+ expiresAt: z.ZodOptional<z.ZodEffects<z.ZodNumber, number, number>>;
13
+ }, "strip", z.ZodTypeAny, {
14
+ role?: ApiRoleEnum;
15
+ expiresAt?: number;
16
+ }, {
17
+ role?: ApiRoleEnum;
18
+ expiresAt?: number;
19
+ }>;
20
+ declare const exchangeApiKeysRequestSchema: z.ZodObject<{
21
+ accessKeyId: z.ZodString;
22
+ accessKeySecret: z.ZodString;
23
+ }, "strip", z.ZodTypeAny, {
24
+ accessKeyId?: string;
25
+ accessKeySecret?: string;
26
+ }, {
27
+ accessKeyId?: string;
28
+ accessKeySecret?: string;
29
+ }>;
30
+ declare const exchangeCredentialsRequestSchema: z.ZodObject<{
31
+ username: z.ZodString;
32
+ password: z.ZodString;
33
+ }, "strip", z.ZodTypeAny, {
34
+ username?: string;
35
+ password?: string;
36
+ }, {
37
+ username?: string;
38
+ password?: string;
39
+ }>;
40
+ declare const exchangeRefreshTokenRequestSchema: z.ZodObject<{
41
+ refreshToken: z.ZodString;
42
+ }, "strip", z.ZodTypeAny, {
43
+ refreshToken?: string;
44
+ }, {
45
+ refreshToken?: string;
46
+ }>;
47
+ declare const createUserRequestSchema: z.ZodObject<{
48
+ name: z.ZodString;
49
+ email: z.ZodString;
50
+ password: z.ZodString;
51
+ avatar: z.ZodString;
52
+ }, "strip", z.ZodTypeAny, {
53
+ name?: string;
54
+ email?: string;
55
+ password?: string;
56
+ avatar?: string;
57
+ }, {
58
+ name?: string;
59
+ email?: string;
60
+ password?: string;
61
+ avatar?: string;
62
+ }>;
63
+ declare const updateUserRequestSchema: z.ZodObject<{
64
+ ref: z.ZodString;
65
+ name: z.ZodUnion<[z.ZodString, z.ZodOptional<z.ZodString>]>;
66
+ password: z.ZodUnion<[z.ZodString, z.ZodOptional<z.ZodString>]>;
67
+ avatar: z.ZodUnion<[z.ZodString, z.ZodOptional<z.ZodString>]>;
68
+ }, "strip", z.ZodTypeAny, {
69
+ name?: string;
70
+ ref?: string;
71
+ password?: string;
72
+ avatar?: string;
73
+ }, {
74
+ name?: string;
75
+ ref?: string;
76
+ password?: string;
77
+ avatar?: string;
78
+ }>;
79
+ declare const inviteUserToWorkspaceRequestSchema: z.ZodObject<{
80
+ email: z.ZodString;
81
+ name: z.ZodString;
82
+ role: z.ZodEnum<[WorkspaceRoleEnum.ADMIN, WorkspaceRoleEnum.USER]>;
83
+ password: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
84
+ }, "strip", z.ZodTypeAny, {
85
+ name?: string;
86
+ email?: string;
87
+ role?: WorkspaceRoleEnum.ADMIN | WorkspaceRoleEnum.USER;
88
+ password?: string;
89
+ }, {
90
+ name?: string;
91
+ email?: string;
92
+ role?: WorkspaceRoleEnum.ADMIN | WorkspaceRoleEnum.USER;
93
+ password?: string;
94
+ }>;
95
+ declare const resendWorkspaceMembershipInvitationRequestSchema: z.ZodObject<{
96
+ userRef: z.ZodString;
97
+ }, "strip", z.ZodTypeAny, {
98
+ userRef?: string;
99
+ }, {
100
+ userRef?: string;
101
+ }>;
102
+ declare const updateWorkspaceRequestSchema: z.ZodObject<{
103
+ ref: z.ZodString;
104
+ name: z.ZodUnion<[z.ZodString, z.ZodOptional<z.ZodString>]>;
105
+ }, "strip", z.ZodTypeAny, {
106
+ name?: string;
107
+ ref?: string;
108
+ }, {
109
+ name?: string;
110
+ ref?: string;
111
+ }>;
112
+ declare const removeUserFromWorkspaceRequestSchema: z.ZodObject<{
113
+ userRef: z.ZodString;
114
+ }, "strip", z.ZodTypeAny, {
115
+ userRef?: string;
116
+ }, {
117
+ userRef?: string;
118
+ }>;
119
+ export { createApiKeyRequestSchema, createUserRequestSchema, createWorkspaceRequestSchema, exchangeApiKeysRequestSchema, exchangeCredentialsRequestSchema, exchangeRefreshTokenRequestSchema, inviteUserToWorkspaceRequestSchema, removeUserFromWorkspaceRequestSchema, resendWorkspaceMembershipInvitationRequestSchema, updateUserRequestSchema, updateWorkspaceRequestSchema };