@fonoster/common 0.7.22 → 0.7.26

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 (42) hide show
  1. package/dist/envs.d.ts +1 -0
  2. package/dist/envs.js +31 -0
  3. package/dist/errors/handleError.js +23 -8
  4. package/dist/errors/handleZodError.js +4 -2
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +19 -8
  7. package/dist/messages.d.ts +8 -0
  8. package/dist/messages.js +29 -0
  9. package/dist/notifications/createSendEmail.d.ts +3 -0
  10. package/dist/notifications/{createEmailSender.js → createSendEmail.js} +2 -2
  11. package/dist/notifications/createSendSmsTwilioImpl.d.ts +3 -0
  12. package/dist/notifications/createSendSmsTwilioImpl.js +54 -0
  13. package/dist/notifications/index.d.ts +3 -1
  14. package/dist/notifications/index.js +3 -1
  15. package/dist/notifications/types.d.ts +27 -0
  16. package/dist/notifications/types.js +2 -0
  17. package/dist/protos/acls.proto +2 -8
  18. package/dist/protos/identity.proto +35 -12
  19. package/dist/utils/createService.js +18 -7
  20. package/dist/utils/getServerCredentials.js +17 -7
  21. package/dist/validators/calls.d.ts +4 -4
  22. package/dist/validators/calls.js +18 -12
  23. package/dist/validators/common.d.ts +4 -1
  24. package/dist/validators/common.js +22 -3
  25. package/dist/validators/hostOrHostPortSchema.js +1 -1
  26. package/dist/validators/identity.d.ts +48 -6
  27. package/dist/validators/identity.js +55 -21
  28. package/dist/validators/secrets.js +3 -3
  29. package/dist/validators/sipnet/acls.d.ts +20 -2
  30. package/dist/validators/sipnet/acls.js +53 -2
  31. package/dist/validators/sipnet/agents.d.ts +41 -2
  32. package/dist/validators/sipnet/agents.js +23 -2
  33. package/dist/validators/sipnet/credentials.d.ts +20 -2
  34. package/dist/validators/sipnet/credentials.js +9 -2
  35. package/dist/validators/sipnet/domains.d.ts +43 -2
  36. package/dist/validators/sipnet/domains.js +32 -2
  37. package/dist/validators/sipnet/numbers.d.ts +29 -4
  38. package/dist/validators/sipnet/numbers.js +6 -0
  39. package/dist/validators/sipnet/trunks.d.ts +57 -1
  40. package/dist/validators/sipnet/trunks.js +55 -1
  41. package/package.json +4 -3
  42. package/dist/notifications/createEmailSender.d.ts +0 -17
@@ -28,6 +28,6 @@ const hostOrHostPortSchema = zod_1.z
28
28
  const hostPortRegex = /^(?!:\/\/)([a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)*|(\d{1,3}\.){3}\d{1,3}):\d{1,5}$/;
29
29
  return hostRegex.test(value) || hostPortRegex.test(value);
30
30
  }, {
31
- message: "Invalid format. Expected 'host' or 'host:port'"
31
+ message: "Invalid format. Expects 'host' or 'host:port'"
32
32
  });
33
33
  exports.hostOrHostPortSchema = hostOrHostPortSchema;
@@ -9,7 +9,7 @@ declare const createWorkspaceRequestSchema: z.ZodObject<{
9
9
  }>;
10
10
  declare const createApiKeyRequestSchema: z.ZodObject<{
11
11
  role: z.ZodEnum<[ApiRoleEnum]>;
12
- expiresAt: z.ZodOptional<z.ZodEffects<z.ZodNumber, number, number>>;
12
+ expiresAt: z.ZodOptional<z.ZodNumber>;
13
13
  }, "strip", z.ZodTypeAny, {
14
14
  role?: ApiRoleEnum;
15
15
  expiresAt?: number;
@@ -30,12 +30,28 @@ declare const exchangeApiKeysRequestSchema: z.ZodObject<{
30
30
  declare const exchangeCredentialsRequestSchema: z.ZodObject<{
31
31
  username: z.ZodString;
32
32
  password: z.ZodString;
33
+ verificationCode: z.ZodOptional<z.ZodString>;
33
34
  }, "strip", z.ZodTypeAny, {
34
35
  username?: string;
35
36
  password?: string;
37
+ verificationCode?: string;
36
38
  }, {
37
39
  username?: string;
38
40
  password?: string;
41
+ verificationCode?: string;
42
+ }>;
43
+ declare const exchangeOauth2RequestSchema: z.ZodObject<{
44
+ provider: z.ZodDefault<z.ZodEnum<["GITHUB"]>>;
45
+ username: z.ZodString;
46
+ code: z.ZodString;
47
+ }, "strip", z.ZodTypeAny, {
48
+ code?: string;
49
+ username?: string;
50
+ provider?: "GITHUB";
51
+ }, {
52
+ code?: string;
53
+ username?: string;
54
+ provider?: "GITHUB";
39
55
  }>;
40
56
  declare const exchangeRefreshTokenRequestSchema: z.ZodObject<{
41
57
  refreshToken: z.ZodString;
@@ -51,13 +67,13 @@ declare const createUserRequestSchema: z.ZodObject<{
51
67
  avatar: z.ZodString;
52
68
  }, "strip", z.ZodTypeAny, {
53
69
  name?: string;
54
- email?: string;
55
70
  password?: string;
71
+ email?: string;
56
72
  avatar?: string;
57
73
  }, {
58
74
  name?: string;
59
- email?: string;
60
75
  password?: string;
76
+ email?: string;
61
77
  avatar?: string;
62
78
  }>;
63
79
  declare const updateUserRequestSchema: z.ZodObject<{
@@ -83,14 +99,14 @@ declare const inviteUserToWorkspaceRequestSchema: z.ZodObject<{
83
99
  password: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
84
100
  }, "strip", z.ZodTypeAny, {
85
101
  name?: string;
86
- email?: string;
87
102
  role?: WorkspaceRoleEnum.ADMIN | WorkspaceRoleEnum.USER;
88
103
  password?: string;
104
+ email?: string;
89
105
  }, {
90
106
  name?: string;
91
- email?: string;
92
107
  role?: WorkspaceRoleEnum.ADMIN | WorkspaceRoleEnum.USER;
93
108
  password?: string;
109
+ email?: string;
94
110
  }>;
95
111
  declare const resendWorkspaceMembershipInvitationRequestSchema: z.ZodObject<{
96
112
  userRef: z.ZodString;
@@ -116,4 +132,30 @@ declare const removeUserFromWorkspaceRequestSchema: z.ZodObject<{
116
132
  }, {
117
133
  userRef?: string;
118
134
  }>;
119
- export { createApiKeyRequestSchema, createUserRequestSchema, createWorkspaceRequestSchema, exchangeApiKeysRequestSchema, exchangeCredentialsRequestSchema, exchangeRefreshTokenRequestSchema, inviteUserToWorkspaceRequestSchema, removeUserFromWorkspaceRequestSchema, resendWorkspaceMembershipInvitationRequestSchema, updateUserRequestSchema, updateWorkspaceRequestSchema };
135
+ declare const sendVerificationCodeRequestSchema: z.ZodObject<{
136
+ contactType: z.ZodDefault<z.ZodEnum<["EMAIL", "PHONE"]>>;
137
+ value: z.ZodString;
138
+ }, "strip", z.ZodTypeAny, {
139
+ value?: string;
140
+ contactType?: "EMAIL" | "PHONE";
141
+ }, {
142
+ value?: string;
143
+ contactType?: "EMAIL" | "PHONE";
144
+ }>;
145
+ declare const verifyCodeRequestSchema: z.ZodObject<{
146
+ username: z.ZodString;
147
+ contactType: z.ZodDefault<z.ZodEnum<["EMAIL", "PHONE"]>>;
148
+ value: z.ZodString;
149
+ verificationCode: z.ZodString;
150
+ }, "strip", z.ZodTypeAny, {
151
+ value?: string;
152
+ username?: string;
153
+ verificationCode?: string;
154
+ contactType?: "EMAIL" | "PHONE";
155
+ }, {
156
+ value?: string;
157
+ username?: string;
158
+ verificationCode?: string;
159
+ contactType?: "EMAIL" | "PHONE";
160
+ }>;
161
+ export { createApiKeyRequestSchema, createUserRequestSchema, createWorkspaceRequestSchema, exchangeApiKeysRequestSchema, exchangeCredentialsRequestSchema, exchangeOauth2RequestSchema, exchangeRefreshTokenRequestSchema, inviteUserToWorkspaceRequestSchema, removeUserFromWorkspaceRequestSchema, resendWorkspaceMembershipInvitationRequestSchema, sendVerificationCodeRequestSchema, updateUserRequestSchema, updateWorkspaceRequestSchema, verifyCodeRequestSchema };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateWorkspaceRequestSchema = exports.updateUserRequestSchema = exports.resendWorkspaceMembershipInvitationRequestSchema = exports.removeUserFromWorkspaceRequestSchema = exports.inviteUserToWorkspaceRequestSchema = exports.exchangeRefreshTokenRequestSchema = exports.exchangeCredentialsRequestSchema = exports.exchangeApiKeysRequestSchema = exports.createWorkspaceRequestSchema = exports.createUserRequestSchema = exports.createApiKeyRequestSchema = void 0;
3
+ exports.verifyCodeRequestSchema = exports.updateWorkspaceRequestSchema = exports.updateUserRequestSchema = exports.sendVerificationCodeRequestSchema = exports.resendWorkspaceMembershipInvitationRequestSchema = exports.removeUserFromWorkspaceRequestSchema = exports.inviteUserToWorkspaceRequestSchema = exports.exchangeRefreshTokenRequestSchema = exports.exchangeOauth2RequestSchema = exports.exchangeCredentialsRequestSchema = exports.exchangeApiKeysRequestSchema = exports.createWorkspaceRequestSchema = exports.createUserRequestSchema = exports.createApiKeyRequestSchema = void 0;
4
4
  /*
5
5
  * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
@@ -21,6 +21,7 @@ exports.updateWorkspaceRequestSchema = exports.updateUserRequestSchema = exports
21
21
  */
22
22
  const types_1 = require("@fonoster/types");
23
23
  const zod_1 = require("zod");
24
+ const messages_1 = require("../messages");
24
25
  const MIN_NAME_MESSAGE = "The name is required";
25
26
  const MAX_NAME_MESSAGE = "Name must contain at most 50 characters";
26
27
  const EMAIL_MESSAGE = "Invalid email";
@@ -28,66 +29,99 @@ const PASSWORD_MESSAGE = "Password must contain at least 8 characters";
28
29
  const USER_REF_MESSAGE = "Invalid user reference";
29
30
  const WORKSPACE_REF_MESSAGE = "Invalid workspace reference";
30
31
  const createWorkspaceRequestSchema = zod_1.z.object({
31
- name: zod_1.z.string().min(1, MIN_NAME_MESSAGE).max(50, MAX_NAME_MESSAGE)
32
+ name: zod_1.z
33
+ .string()
34
+ .min(1, { message: MIN_NAME_MESSAGE })
35
+ .max(50, { message: MAX_NAME_MESSAGE })
32
36
  });
33
37
  exports.createWorkspaceRequestSchema = createWorkspaceRequestSchema;
34
38
  const createApiKeyRequestSchema = zod_1.z.object({
35
39
  role: zod_1.z.enum([types_1.ApiRoleEnum.WORKSPACE_ADMIN]),
36
40
  expiresAt: zod_1.z
37
41
  .number()
38
- .transform((value) => (value === 0 ? null : value))
42
+ .int({ message: messages_1.POSITIVE_INTEGER_MESSAGE })
43
+ .positive({ message: messages_1.POSITIVE_INTEGER_MESSAGE })
39
44
  .optional()
40
45
  });
41
46
  exports.createApiKeyRequestSchema = createApiKeyRequestSchema;
42
47
  const exchangeApiKeysRequestSchema = zod_1.z.object({
43
- accessKeyId: zod_1.z.string().uuid("Invalid accessKeyId"),
48
+ accessKeyId: zod_1.z.string().uuid({ message: "Invalid accessKeyId" }),
44
49
  accessKeySecret: zod_1.z.string()
45
50
  });
46
51
  exports.exchangeApiKeysRequestSchema = exchangeApiKeysRequestSchema;
47
52
  const exchangeCredentialsRequestSchema = zod_1.z.object({
48
- username: zod_1.z.string().email("Invalid username, must be an email address"),
49
- password: zod_1.z.string()
53
+ username: zod_1.z
54
+ .string()
55
+ .email({ message: "Invalid username. Must be an email address" }),
56
+ password: zod_1.z.string(),
57
+ verificationCode: zod_1.z.string().optional()
50
58
  });
51
59
  exports.exchangeCredentialsRequestSchema = exchangeCredentialsRequestSchema;
60
+ const exchangeOauth2RequestSchema = zod_1.z.object({
61
+ provider: zod_1.z.enum(["GITHUB"]).default("GITHUB"),
62
+ username: zod_1.z
63
+ .string()
64
+ .email({ message: "Invalid username. Must be an email address" }),
65
+ code: zod_1.z.string()
66
+ });
67
+ exports.exchangeOauth2RequestSchema = exchangeOauth2RequestSchema;
52
68
  const exchangeRefreshTokenRequestSchema = zod_1.z.object({
53
69
  refreshToken: zod_1.z.string()
54
70
  });
55
71
  exports.exchangeRefreshTokenRequestSchema = exchangeRefreshTokenRequestSchema;
56
72
  const createUserRequestSchema = zod_1.z.object({
57
- name: zod_1.z.string().max(50, MAX_NAME_MESSAGE),
58
- email: zod_1.z.string().email(EMAIL_MESSAGE),
59
- password: zod_1.z.string().min(8, PASSWORD_MESSAGE).max(100),
60
- avatar: zod_1.z.string().url().max(255, "Invalid avatar URL")
73
+ name: zod_1.z.string().max(50, { message: MAX_NAME_MESSAGE }),
74
+ email: zod_1.z.string().email({ message: EMAIL_MESSAGE }),
75
+ password: zod_1.z.string().min(8, { message: PASSWORD_MESSAGE }).max(100),
76
+ avatar: zod_1.z.string().url().max(255, { message: "Invalid avatar URL" })
61
77
  });
62
78
  exports.createUserRequestSchema = createUserRequestSchema;
63
79
  const updateUserRequestSchema = zod_1.z.object({
64
- ref: zod_1.z.string().uuid(USER_REF_MESSAGE),
65
- name: zod_1.z.string().max(50, MAX_NAME_MESSAGE).or(zod_1.z.string().optional()),
66
- password: zod_1.z.string().min(8, PASSWORD_MESSAGE).or(zod_1.z.string().optional()),
80
+ ref: zod_1.z.string().uuid({ message: USER_REF_MESSAGE }),
81
+ name: zod_1.z
82
+ .string()
83
+ .max(50, { message: MAX_NAME_MESSAGE })
84
+ .or(zod_1.z.string().optional()),
85
+ password: zod_1.z
86
+ .string()
87
+ .min(8, { message: PASSWORD_MESSAGE })
88
+ .or(zod_1.z.string().optional()),
67
89
  avatar: zod_1.z.string().url().or(zod_1.z.string().optional())
68
90
  });
69
91
  exports.updateUserRequestSchema = updateUserRequestSchema;
70
92
  const inviteUserToWorkspaceRequestSchema = zod_1.z.object({
71
- email: zod_1.z.string().email(EMAIL_MESSAGE),
72
- name: zod_1.z.string().max(50, MAX_NAME_MESSAGE),
93
+ email: zod_1.z.string().email({ message: EMAIL_MESSAGE }),
94
+ name: zod_1.z.string().max(50, { message: MAX_NAME_MESSAGE }),
73
95
  role: zod_1.z.enum([types_1.WorkspaceRoleEnum.ADMIN, types_1.WorkspaceRoleEnum.USER]),
74
- password: zod_1.z.string().min(8, PASSWORD_MESSAGE).or(zod_1.z.undefined())
96
+ password: zod_1.z.string().min(8, { message: PASSWORD_MESSAGE }).or(zod_1.z.undefined())
75
97
  });
76
98
  exports.inviteUserToWorkspaceRequestSchema = inviteUserToWorkspaceRequestSchema;
77
99
  const resendWorkspaceMembershipInvitationRequestSchema = zod_1.z.object({
78
- userRef: zod_1.z.string().uuid(USER_REF_MESSAGE)
100
+ userRef: zod_1.z.string().uuid({ message: USER_REF_MESSAGE })
79
101
  });
80
102
  exports.resendWorkspaceMembershipInvitationRequestSchema = resendWorkspaceMembershipInvitationRequestSchema;
81
103
  const updateWorkspaceRequestSchema = zod_1.z.object({
82
- ref: zod_1.z.string().uuid(WORKSPACE_REF_MESSAGE),
104
+ ref: zod_1.z.string().uuid({ message: WORKSPACE_REF_MESSAGE }),
83
105
  name: zod_1.z
84
106
  .string()
85
- .min(1, MIN_NAME_MESSAGE)
86
- .max(50, MAX_NAME_MESSAGE)
107
+ .min(1, { message: MIN_NAME_MESSAGE })
108
+ .max(50, { message: MAX_NAME_MESSAGE })
87
109
  .or(zod_1.z.string().optional())
88
110
  });
89
111
  exports.updateWorkspaceRequestSchema = updateWorkspaceRequestSchema;
90
112
  const removeUserFromWorkspaceRequestSchema = zod_1.z.object({
91
- userRef: zod_1.z.string().uuid(USER_REF_MESSAGE)
113
+ userRef: zod_1.z.string().uuid({ message: USER_REF_MESSAGE })
92
114
  });
93
115
  exports.removeUserFromWorkspaceRequestSchema = removeUserFromWorkspaceRequestSchema;
116
+ const sendVerificationCodeRequestSchema = zod_1.z.object({
117
+ contactType: zod_1.z.enum(["EMAIL", "PHONE"]).default("EMAIL"),
118
+ value: zod_1.z.string()
119
+ });
120
+ exports.sendVerificationCodeRequestSchema = sendVerificationCodeRequestSchema;
121
+ const verifyCodeRequestSchema = zod_1.z.object({
122
+ username: zod_1.z.string(),
123
+ contactType: zod_1.z.enum(["EMAIL", "PHONE"]).default("EMAIL"),
124
+ value: zod_1.z.string(),
125
+ verificationCode: zod_1.z.string()
126
+ });
127
+ exports.verifyCodeRequestSchema = verifyCodeRequestSchema;
@@ -26,10 +26,10 @@ const createSecretRequestSchema = zod_1.z.object({
26
26
  name: zod_1.z
27
27
  .string()
28
28
  .regex(validNameRegex, {
29
- message: "Name can only contain letters, numbers, underscores, or hyphens. No spaces allowed."
29
+ message: "Name can only contain letters, numbers, underscores, or hyphens. No spaces allowed"
30
30
  })
31
- .min(3, { message: "Name must be at least 3 characters long." })
32
- .max(32, { message: "Name must be at most 32 characters long." }),
31
+ .min(3, { message: "Name must be at least 3 characters long" })
32
+ .max(32, { message: "Name must be at most 32 characters long" }),
33
33
  secret: zod_1.z.string()
34
34
  });
35
35
  exports.createSecretRequestSchema = createSecretRequestSchema;
@@ -1,4 +1,22 @@
1
1
  import { z } from "zod";
2
- declare const createAclRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
3
- declare const updateAclRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
2
+ declare const createAclRequestSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ allow: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "atleastone">;
5
+ }, "strip", z.ZodTypeAny, {
6
+ name?: string;
7
+ allow?: [string, ...string[]];
8
+ }, {
9
+ name?: string;
10
+ allow?: [string, ...string[]];
11
+ }>;
12
+ declare const updateAclRequestSchema: z.ZodObject<{
13
+ name: z.ZodString;
14
+ allow: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "atleastone">>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ name?: string;
17
+ allow?: [string, ...string[]];
18
+ }, {
19
+ name?: string;
20
+ allow?: [string, ...string[]];
21
+ }>;
4
22
  export { createAclRequestSchema, updateAclRequestSchema };
@@ -1,4 +1,37 @@
1
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.updateAclRequestSchema = exports.createAclRequestSchema = void 0;
4
37
  /*
@@ -19,8 +52,26 @@ exports.updateAclRequestSchema = exports.createAclRequestSchema = void 0;
19
52
  * See the License for the specific language governing permissions and
20
53
  * limitations under the License.
21
54
  */
55
+ const Validator = __importStar(require("validator"));
22
56
  const zod_1 = require("zod");
23
- const createAclRequestSchema = zod_1.z.object({});
57
+ const common_1 = require("../common");
58
+ const IP_OR_CIDR_MESSAGE = "Must be a valid IP or CIDR range";
59
+ const AT_LEAST_ONE_MESSAGE = "At least one IP or CIDR range is required";
60
+ const ipOrCidr = zod_1.z
61
+ .string()
62
+ .refine((value) => Validator.isIP(value, 4) || Validator.isIPRange(value, 4), {
63
+ message: IP_OR_CIDR_MESSAGE
64
+ });
65
+ const createAclRequestSchema = zod_1.z.object({
66
+ name: common_1.nameSchema,
67
+ allow: zod_1.z.array(ipOrCidr).nonempty({ message: AT_LEAST_ONE_MESSAGE })
68
+ });
24
69
  exports.createAclRequestSchema = createAclRequestSchema;
25
- const updateAclRequestSchema = zod_1.z.object({});
70
+ const updateAclRequestSchema = zod_1.z.object({
71
+ name: common_1.nameSchema,
72
+ allow: zod_1.z
73
+ .array(ipOrCidr)
74
+ .nonempty({ message: AT_LEAST_ONE_MESSAGE })
75
+ .optional()
76
+ });
26
77
  exports.updateAclRequestSchema = updateAclRequestSchema;
@@ -1,4 +1,43 @@
1
1
  import { z } from "zod";
2
- declare const createAgentRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
3
- declare const updateAgentRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
2
+ declare const createAgentRequestSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ username: z.ZodString;
5
+ privacy: z.ZodOptional<z.ZodEnum<["PRIVATE", "NONE"]>>;
6
+ enabled: z.ZodOptional<z.ZodBoolean>;
7
+ maxContacts: z.ZodOptional<z.ZodNumber>;
8
+ expires: z.ZodOptional<z.ZodNumber>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ name?: string;
11
+ username?: string;
12
+ privacy?: "PRIVATE" | "NONE";
13
+ enabled?: boolean;
14
+ maxContacts?: number;
15
+ expires?: number;
16
+ }, {
17
+ name?: string;
18
+ username?: string;
19
+ privacy?: "PRIVATE" | "NONE";
20
+ enabled?: boolean;
21
+ maxContacts?: number;
22
+ expires?: number;
23
+ }>;
24
+ declare const updateAgentRequestSchema: z.ZodObject<{
25
+ name: z.ZodOptional<z.ZodString>;
26
+ privacy: z.ZodOptional<z.ZodEnum<["PRIVATE", "NONE"]>>;
27
+ enabled: z.ZodOptional<z.ZodBoolean>;
28
+ maxContacts: z.ZodOptional<z.ZodNumber>;
29
+ expires: z.ZodOptional<z.ZodNumber>;
30
+ }, "strip", z.ZodTypeAny, {
31
+ name?: string;
32
+ privacy?: "PRIVATE" | "NONE";
33
+ enabled?: boolean;
34
+ maxContacts?: number;
35
+ expires?: number;
36
+ }, {
37
+ name?: string;
38
+ privacy?: "PRIVATE" | "NONE";
39
+ enabled?: boolean;
40
+ maxContacts?: number;
41
+ expires?: number;
42
+ }>;
4
43
  export { createAgentRequestSchema, updateAgentRequestSchema };
@@ -20,7 +20,28 @@ exports.updateAgentRequestSchema = exports.createAgentRequestSchema = void 0;
20
20
  * limitations under the License.
21
21
  */
22
22
  const zod_1 = require("zod");
23
- const createAgentRequestSchema = zod_1.z.object({});
23
+ const messages_1 = require("../../messages");
24
+ const common_1 = require("../common");
25
+ const createAgentRequestSchema = zod_1.z.object({
26
+ name: common_1.nameSchema,
27
+ username: common_1.usernameSchema,
28
+ privacy: zod_1.z.enum(["PRIVATE", "NONE"]).optional(),
29
+ enabled: zod_1.z.boolean().optional(),
30
+ maxContacts: zod_1.z
31
+ .number()
32
+ .positive({ message: messages_1.POSITIVE_INTEGER_MESSAGE })
33
+ .optional(),
34
+ expires: zod_1.z.number().positive({ message: messages_1.POSITIVE_INTEGER_MESSAGE }).optional()
35
+ });
24
36
  exports.createAgentRequestSchema = createAgentRequestSchema;
25
- const updateAgentRequestSchema = zod_1.z.object({});
37
+ const updateAgentRequestSchema = zod_1.z.object({
38
+ name: common_1.nameSchema.optional(),
39
+ privacy: zod_1.z.enum(["PRIVATE", "NONE"]).optional(),
40
+ enabled: zod_1.z.boolean().optional(),
41
+ maxContacts: zod_1.z
42
+ .number()
43
+ .positive({ message: messages_1.POSITIVE_INTEGER_MESSAGE })
44
+ .optional(),
45
+ expires: zod_1.z.number().positive({ message: messages_1.POSITIVE_INTEGER_MESSAGE }).optional()
46
+ });
26
47
  exports.updateAgentRequestSchema = updateAgentRequestSchema;
@@ -1,4 +1,22 @@
1
1
  import { z } from "zod";
2
- declare const createCredentialsRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
3
- declare const updateCredentialsRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
2
+ declare const createCredentialsRequestSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ username: z.ZodString;
5
+ password: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ name?: string;
8
+ username?: string;
9
+ password?: string;
10
+ }, {
11
+ name?: string;
12
+ username?: string;
13
+ password?: string;
14
+ }>;
15
+ declare const updateCredentialsRequestSchema: z.ZodObject<{
16
+ name: z.ZodString;
17
+ }, "strip", z.ZodTypeAny, {
18
+ name?: string;
19
+ }, {
20
+ name?: string;
21
+ }>;
4
22
  export { createCredentialsRequestSchema, updateCredentialsRequestSchema };
@@ -20,7 +20,14 @@ exports.updateCredentialsRequestSchema = exports.createCredentialsRequestSchema
20
20
  * limitations under the License.
21
21
  */
22
22
  const zod_1 = require("zod");
23
- const createCredentialsRequestSchema = zod_1.z.object({});
23
+ const common_1 = require("../common");
24
+ const createCredentialsRequestSchema = zod_1.z.object({
25
+ name: common_1.nameSchema,
26
+ username: common_1.usernameSchema,
27
+ password: zod_1.z.string()
28
+ });
24
29
  exports.createCredentialsRequestSchema = createCredentialsRequestSchema;
25
- const updateCredentialsRequestSchema = zod_1.z.object({});
30
+ const updateCredentialsRequestSchema = zod_1.z.object({
31
+ name: common_1.nameSchema
32
+ });
26
33
  exports.updateCredentialsRequestSchema = updateCredentialsRequestSchema;
@@ -1,4 +1,45 @@
1
1
  import { z } from "zod";
2
- declare const createDomainRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
3
- declare const updateDomainRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
2
+ declare const createDomainRequestSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ domainUri: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
5
+ egressPolicies: z.ZodOptional<z.ZodArray<z.ZodObject<{
6
+ rule: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ rule?: string;
9
+ }, {
10
+ rule?: string;
11
+ }>, "many">>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ name?: string;
14
+ domainUri?: string;
15
+ egressPolicies?: {
16
+ rule?: string;
17
+ }[];
18
+ }, {
19
+ name?: string;
20
+ domainUri?: string;
21
+ egressPolicies?: {
22
+ rule?: string;
23
+ }[];
24
+ }>;
25
+ declare const updateDomainRequestSchema: z.ZodObject<{
26
+ name: z.ZodOptional<z.ZodString>;
27
+ egressPolicies: z.ZodOptional<z.ZodArray<z.ZodObject<{
28
+ rule: z.ZodString;
29
+ }, "strip", z.ZodTypeAny, {
30
+ rule?: string;
31
+ }, {
32
+ rule?: string;
33
+ }>, "many">>;
34
+ }, "strip", z.ZodTypeAny, {
35
+ name?: string;
36
+ egressPolicies?: {
37
+ rule?: string;
38
+ }[];
39
+ }, {
40
+ name?: string;
41
+ egressPolicies?: {
42
+ rule?: string;
43
+ }[];
44
+ }>;
4
45
  export { createDomainRequestSchema, updateDomainRequestSchema };
@@ -20,7 +20,37 @@ exports.updateDomainRequestSchema = exports.createDomainRequestSchema = void 0;
20
20
  * limitations under the License.
21
21
  */
22
22
  const zod_1 = require("zod");
23
- const createDomainRequestSchema = zod_1.z.object({});
23
+ const envs_1 = require("../../envs");
24
+ const common_1 = require("../common");
25
+ const domainSchema = zod_1.z
26
+ .string()
27
+ .refine((domain) => {
28
+ const domainRegex = /^[a-zA-Z0-9-]+(\.[a-zA-Z]{2,})+$/;
29
+ return domainRegex.test(domain);
30
+ }, {
31
+ message: "Invalid domain format"
32
+ })
33
+ .refine((domain) => {
34
+ return domain.endsWith(envs_1.ROOT_DOMAIN);
35
+ }, {
36
+ message: `Domain must end with "${envs_1.ROOT_DOMAIN}"`
37
+ });
38
+ const createDomainRequestSchema = zod_1.z.object({
39
+ name: common_1.nameSchema,
40
+ domainUri: domainSchema,
41
+ egressPolicies: zod_1.z
42
+ .array(zod_1.z.object({
43
+ rule: zod_1.z.string()
44
+ }))
45
+ .optional()
46
+ });
24
47
  exports.createDomainRequestSchema = createDomainRequestSchema;
25
- const updateDomainRequestSchema = zod_1.z.object({});
48
+ const updateDomainRequestSchema = zod_1.z.object({
49
+ name: common_1.nameSchema.optional(),
50
+ egressPolicies: zod_1.z
51
+ .array(zod_1.z.object({
52
+ rule: zod_1.z.string()
53
+ }))
54
+ .optional()
55
+ });
26
56
  exports.updateDomainRequestSchema = updateDomainRequestSchema;
@@ -1,38 +1,63 @@
1
1
  import { z } from "zod";
2
2
  declare const createNumberRequestSchema: z.ZodEffects<z.ZodObject<{
3
+ name: z.ZodString;
4
+ telUrl: z.ZodString;
5
+ city: z.ZodString;
6
+ country: z.ZodString;
3
7
  agentAor: z.ZodOptional<z.ZodString>;
4
8
  appRef: z.ZodOptional<z.ZodString>;
5
9
  countryIsoCode: z.ZodEffects<z.ZodString, string, string>;
6
10
  }, "strip", z.ZodTypeAny, {
7
- countryIsoCode?: string;
11
+ name?: string;
8
12
  appRef?: string;
13
+ telUrl?: string;
14
+ city?: string;
15
+ country?: string;
9
16
  agentAor?: string;
10
- }, {
11
17
  countryIsoCode?: string;
18
+ }, {
19
+ name?: string;
12
20
  appRef?: string;
21
+ telUrl?: string;
22
+ city?: string;
23
+ country?: string;
13
24
  agentAor?: string;
14
- }>, {
15
25
  countryIsoCode?: string;
26
+ }>, {
27
+ name?: string;
16
28
  appRef?: string;
29
+ telUrl?: string;
30
+ city?: string;
31
+ country?: string;
17
32
  agentAor?: string;
18
- }, {
19
33
  countryIsoCode?: string;
34
+ }, {
35
+ name?: string;
20
36
  appRef?: string;
37
+ telUrl?: string;
38
+ city?: string;
39
+ country?: string;
21
40
  agentAor?: string;
41
+ countryIsoCode?: string;
22
42
  }>;
23
43
  declare const updateNumberRequestSchema: z.ZodEffects<z.ZodObject<{
44
+ name: z.ZodOptional<z.ZodString>;
24
45
  agentAor: z.ZodOptional<z.ZodString>;
25
46
  appRef: z.ZodOptional<z.ZodString>;
26
47
  }, "strip", z.ZodTypeAny, {
48
+ name?: string;
27
49
  appRef?: string;
28
50
  agentAor?: string;
29
51
  }, {
52
+ name?: string;
30
53
  appRef?: string;
31
54
  agentAor?: string;
32
55
  }>, {
56
+ name?: string;
33
57
  appRef?: string;
34
58
  agentAor?: string;
35
59
  }, {
60
+ name?: string;
36
61
  appRef?: string;
37
62
  agentAor?: string;
38
63
  }>;
@@ -24,6 +24,7 @@ exports.updateNumberRequestSchema = exports.createNumberRequestSchema = void 0;
24
24
  */
25
25
  const isISO31661Alpha2_1 = __importDefault(require("validator/lib/isISO31661Alpha2"));
26
26
  const zod_1 = require("zod");
27
+ const common_1 = require("../common");
27
28
  const sipUriRegex = /^sip:[a-zA-Z0-9_.-]+@[a-zA-Z0-9_.-]+$/;
28
29
  const sipUriSchema = zod_1.z.string().regex(sipUriRegex, "Invalid SIP URI");
29
30
  const countryIsoCodeSchema = zod_1.z.string().refine((val) => (0, isISO31661Alpha2_1.default)(val), {
@@ -31,6 +32,10 @@ const countryIsoCodeSchema = zod_1.z.string().refine((val) => (0, isISO31661Alph
31
32
  });
32
33
  const createNumberRequestSchema = zod_1.z
33
34
  .object({
35
+ name: common_1.nameSchema,
36
+ telUrl: zod_1.z.string(),
37
+ city: zod_1.z.string(),
38
+ country: zod_1.z.string(),
34
39
  agentAor: sipUriSchema.optional(),
35
40
  appRef: zod_1.z.string().optional(),
36
41
  countryIsoCode: countryIsoCodeSchema
@@ -41,6 +46,7 @@ const createNumberRequestSchema = zod_1.z
41
46
  exports.createNumberRequestSchema = createNumberRequestSchema;
42
47
  const updateNumberRequestSchema = zod_1.z
43
48
  .object({
49
+ name: common_1.nameSchema.optional(),
44
50
  agentAor: sipUriSchema.optional(),
45
51
  appRef: zod_1.z.string().optional()
46
52
  })