@fonoster/common 0.7.22 → 0.7.25
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/dist/envs.d.ts +1 -0
- package/dist/envs.js +31 -0
- package/dist/errors/handleError.js +6 -1
- package/dist/errors/handleZodError.js +4 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/messages.d.ts +8 -0
- package/dist/messages.js +29 -0
- package/dist/notifications/createSendEmail.d.ts +3 -0
- package/dist/notifications/{createEmailSender.js → createSendEmail.js} +2 -2
- package/dist/notifications/createSendSmsTwilioImpl.d.ts +3 -0
- package/dist/notifications/createSendSmsTwilioImpl.js +54 -0
- package/dist/notifications/index.d.ts +3 -1
- package/dist/notifications/index.js +3 -1
- package/dist/notifications/types.d.ts +27 -0
- package/dist/notifications/types.js +2 -0
- package/dist/protos/identity.proto +35 -12
- package/dist/utils/createService.js +1 -0
- package/dist/validators/calls.d.ts +4 -4
- package/dist/validators/calls.js +18 -12
- package/dist/validators/common.d.ts +4 -1
- package/dist/validators/common.js +22 -3
- package/dist/validators/hostOrHostPortSchema.js +1 -1
- package/dist/validators/identity.d.ts +48 -6
- package/dist/validators/identity.js +55 -21
- package/dist/validators/secrets.js +3 -3
- package/dist/validators/sipnet/acls.d.ts +26 -2
- package/dist/validators/sipnet/acls.js +45 -2
- package/dist/validators/sipnet/agents.d.ts +41 -2
- package/dist/validators/sipnet/agents.js +23 -2
- package/dist/validators/sipnet/credentials.d.ts +20 -2
- package/dist/validators/sipnet/credentials.js +9 -2
- package/dist/validators/sipnet/domains.d.ts +43 -2
- package/dist/validators/sipnet/domains.js +32 -2
- package/dist/validators/sipnet/numbers.d.ts +29 -4
- package/dist/validators/sipnet/numbers.js +6 -0
- package/dist/validators/sipnet/trunks.d.ts +57 -1
- package/dist/validators/sipnet/trunks.js +45 -1
- package/package.json +3 -2
- package/dist/notifications/createEmailSender.d.ts +0 -17
|
@@ -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
|
|
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
|
-
.
|
|
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
|
|
49
|
-
|
|
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
|
|
66
|
-
|
|
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,28 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
declare const createAclRequestSchema: z.ZodObject<{
|
|
3
|
-
|
|
2
|
+
declare const createAclRequestSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
allow: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "atleastone">;
|
|
5
|
+
deny: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "atleastone">;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
name?: string;
|
|
8
|
+
allow?: [string, ...string[]];
|
|
9
|
+
deny?: [string, ...string[]];
|
|
10
|
+
}, {
|
|
11
|
+
name?: string;
|
|
12
|
+
allow?: [string, ...string[]];
|
|
13
|
+
deny?: [string, ...string[]];
|
|
14
|
+
}>;
|
|
15
|
+
declare const updateAclRequestSchema: z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "atleastone">>;
|
|
18
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "atleastone">>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
name?: string;
|
|
21
|
+
allow?: [string, ...string[]];
|
|
22
|
+
deny?: [string, ...string[]];
|
|
23
|
+
}, {
|
|
24
|
+
name?: string;
|
|
25
|
+
allow?: [string, ...string[]];
|
|
26
|
+
deny?: [string, ...string[]];
|
|
27
|
+
}>;
|
|
4
28
|
export { createAclRequestSchema, updateAclRequestSchema };
|
|
@@ -1,4 +1,27 @@
|
|
|
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 (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
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.updateAclRequestSchema = exports.createAclRequestSchema = void 0;
|
|
4
27
|
/*
|
|
@@ -19,8 +42,28 @@ exports.updateAclRequestSchema = exports.createAclRequestSchema = void 0;
|
|
|
19
42
|
* See the License for the specific language governing permissions and
|
|
20
43
|
* limitations under the License.
|
|
21
44
|
*/
|
|
45
|
+
const Validator = __importStar(require("validator"));
|
|
22
46
|
const zod_1 = require("zod");
|
|
23
|
-
const
|
|
47
|
+
const common_1 = require("../common");
|
|
48
|
+
const IP_OR_CIDR_MESSAGE = "Must be a valid IP or CIDR range";
|
|
49
|
+
const AT_LEAST_ONE_MESSAGE = "At least one IP or CIDR range is required";
|
|
50
|
+
const ipOrCidr = zod_1.z
|
|
51
|
+
.string()
|
|
52
|
+
.refine((value) => Validator.isIP(value, 4) || Validator.isIPRange(value, 4), {
|
|
53
|
+
message: IP_OR_CIDR_MESSAGE
|
|
54
|
+
});
|
|
55
|
+
const createAclRequestSchema = zod_1.z.object({
|
|
56
|
+
name: common_1.nameSchema,
|
|
57
|
+
allow: zod_1.z.array(ipOrCidr).nonempty({ message: AT_LEAST_ONE_MESSAGE }),
|
|
58
|
+
deny: zod_1.z.array(ipOrCidr).nonempty({ message: AT_LEAST_ONE_MESSAGE })
|
|
59
|
+
});
|
|
24
60
|
exports.createAclRequestSchema = createAclRequestSchema;
|
|
25
|
-
const updateAclRequestSchema = zod_1.z.object({
|
|
61
|
+
const updateAclRequestSchema = zod_1.z.object({
|
|
62
|
+
name: common_1.nameSchema,
|
|
63
|
+
allow: zod_1.z
|
|
64
|
+
.array(ipOrCidr)
|
|
65
|
+
.nonempty({ message: AT_LEAST_ONE_MESSAGE })
|
|
66
|
+
.optional(),
|
|
67
|
+
deny: zod_1.z.array(ipOrCidr).nonempty({ message: AT_LEAST_ONE_MESSAGE }).optional()
|
|
68
|
+
});
|
|
26
69
|
exports.updateAclRequestSchema = updateAclRequestSchema;
|
|
@@ -1,4 +1,43 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
declare const createAgentRequestSchema: z.ZodObject<{
|
|
3
|
-
|
|
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
|
|
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<{
|
|
3
|
-
|
|
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
|
|
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<{
|
|
3
|
-
|
|
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
|
|
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
|
-
|
|
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
|
})
|
|
@@ -1,4 +1,60 @@
|
|
|
1
|
+
import { Transport } from "@fonoster/types";
|
|
1
2
|
import { z } from "zod";
|
|
2
|
-
declare const createTrunkRequestSchema: z.ZodObject<{
|
|
3
|
+
declare const createTrunkRequestSchema: z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
sendRegister: z.ZodBoolean;
|
|
6
|
+
inboundUri: z.ZodEffects<z.ZodString, string, string>;
|
|
7
|
+
uris: z.ZodArray<z.ZodObject<{
|
|
8
|
+
host: z.ZodEffects<z.ZodString, string, string>;
|
|
9
|
+
port: z.ZodNumber;
|
|
10
|
+
transport: z.ZodNativeEnum<typeof Transport>;
|
|
11
|
+
user: z.ZodString;
|
|
12
|
+
weight: z.ZodNumber;
|
|
13
|
+
priority: z.ZodNumber;
|
|
14
|
+
enabled: z.ZodBoolean;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
host?: string;
|
|
17
|
+
port?: number;
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
transport?: Transport;
|
|
20
|
+
user?: string;
|
|
21
|
+
weight?: number;
|
|
22
|
+
priority?: number;
|
|
23
|
+
}, {
|
|
24
|
+
host?: string;
|
|
25
|
+
port?: number;
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
transport?: Transport;
|
|
28
|
+
user?: string;
|
|
29
|
+
weight?: number;
|
|
30
|
+
priority?: number;
|
|
31
|
+
}>, "many">;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
name?: string;
|
|
34
|
+
sendRegister?: boolean;
|
|
35
|
+
inboundUri?: string;
|
|
36
|
+
uris?: {
|
|
37
|
+
host?: string;
|
|
38
|
+
port?: number;
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
transport?: Transport;
|
|
41
|
+
user?: string;
|
|
42
|
+
weight?: number;
|
|
43
|
+
priority?: number;
|
|
44
|
+
}[];
|
|
45
|
+
}, {
|
|
46
|
+
name?: string;
|
|
47
|
+
sendRegister?: boolean;
|
|
48
|
+
inboundUri?: string;
|
|
49
|
+
uris?: {
|
|
50
|
+
host?: string;
|
|
51
|
+
port?: number;
|
|
52
|
+
enabled?: boolean;
|
|
53
|
+
transport?: Transport;
|
|
54
|
+
user?: string;
|
|
55
|
+
weight?: number;
|
|
56
|
+
priority?: number;
|
|
57
|
+
}[];
|
|
58
|
+
}>;
|
|
3
59
|
declare const updateTrunkRequestSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
4
60
|
export { createTrunkRequestSchema, updateTrunkRequestSchema };
|
|
@@ -1,4 +1,27 @@
|
|
|
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 (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
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.updateTrunkRequestSchema = exports.createTrunkRequestSchema = void 0;
|
|
4
27
|
/*
|
|
@@ -19,8 +42,29 @@ exports.updateTrunkRequestSchema = exports.createTrunkRequestSchema = void 0;
|
|
|
19
42
|
* See the License for the specific language governing permissions and
|
|
20
43
|
* limitations under the License.
|
|
21
44
|
*/
|
|
45
|
+
const types_1 = require("@fonoster/types");
|
|
46
|
+
const Validator = __importStar(require("validator"));
|
|
22
47
|
const zod_1 = require("zod");
|
|
23
|
-
const
|
|
48
|
+
const common_1 = require("../common");
|
|
49
|
+
const hostOrIPSchema = zod_1.z
|
|
50
|
+
.string()
|
|
51
|
+
.refine((host) => Validator.isIP(host, 4) || Validator.isFQDN(host), {
|
|
52
|
+
message: "Must be a valid IP or FQDN"
|
|
53
|
+
});
|
|
54
|
+
const createTrunkRequestSchema = zod_1.z.object({
|
|
55
|
+
name: common_1.nameSchema,
|
|
56
|
+
sendRegister: zod_1.z.boolean(),
|
|
57
|
+
inboundUri: hostOrIPSchema,
|
|
58
|
+
uris: zod_1.z.array(zod_1.z.object({
|
|
59
|
+
host: hostOrIPSchema,
|
|
60
|
+
port: zod_1.z.number(),
|
|
61
|
+
transport: zod_1.z.nativeEnum(types_1.Transport, { message: "Invalid transport" }),
|
|
62
|
+
user: zod_1.z.string(),
|
|
63
|
+
weight: zod_1.z.number(),
|
|
64
|
+
priority: zod_1.z.number(),
|
|
65
|
+
enabled: zod_1.z.boolean()
|
|
66
|
+
}))
|
|
67
|
+
});
|
|
24
68
|
exports.createTrunkRequestSchema = createTrunkRequestSchema;
|
|
25
69
|
const updateTrunkRequestSchema = zod_1.z.object({});
|
|
26
70
|
exports.updateTrunkRequestSchema = updateTrunkRequestSchema;
|