n8n-nodes-zalo-nnt
Version:
Unofficial Zalo integration for n8n - Send messages, manage groups, user operations with QR login. No API key required, works via browser simulation.
166 lines • 5.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateGroupId = validateGroupId;
exports.validateUserId = validateUserId;
exports.validateUserIds = validateUserIds;
exports.validateGroupName = validateGroupName;
exports.validateImageUrl = validateImageUrl;
exports.validateLimit = validateLimit;
exports.validateNoteContent = validateNoteContent;
exports.parseUserIds = parseUserIds;
exports.validateGroupLink = validateGroupLink;
exports.validateGroupIds = validateGroupIds;
exports.parseGroupIds = parseGroupIds;
exports.validateMemberIds = validateMemberIds;
exports.parseMemberIds = parseMemberIds;
exports.validatePage = validatePage;
exports.validateCount = validateCount;
exports.validateTimestamp = validateTimestamp;
function validateGroupId(groupId) {
if (!groupId || typeof groupId !== 'string' || groupId.trim().length === 0) {
throw new Error('Group ID is required and must be a non-empty string');
}
}
function validateUserId(userId) {
if (!userId || typeof userId !== 'string' || userId.trim().length === 0) {
throw new Error('User ID is required and must be a non-empty string');
}
}
function validateUserIds(userIds) {
if (!userIds || typeof userIds !== 'string' || userIds.trim().length === 0) {
throw new Error('User IDs are required and must be a non-empty string');
}
const userList = userIds
.split(',')
.map((id) => id.trim())
.filter((id) => id.length > 0);
if (userList.length === 0) {
throw new Error('At least one valid User ID is required');
}
}
function validateGroupName(groupName) {
if (!groupName || typeof groupName !== 'string' || groupName.trim().length === 0) {
throw new Error('Group name is required and must be a non-empty string');
}
if (groupName.length > 255) {
throw new Error('Group name must not exceed 255 characters');
}
}
function validateImageUrl(imageUrl) {
if (!imageUrl || typeof imageUrl !== 'string' || imageUrl.trim().length === 0) {
throw new Error('Image URL is required and must be a non-empty string');
}
const urlPattern = /^https?:\/\/.+/i;
if (!urlPattern.test(imageUrl)) {
throw new Error('Image URL must be a valid HTTP or HTTPS URL');
}
}
function validateLimit(limit) {
if (typeof limit !== 'number' || isNaN(limit)) {
throw new Error('Limit must be a valid number');
}
if (limit < 1) {
throw new Error('Limit must be at least 1');
}
if (limit > 1000) {
throw new Error('Limit must not exceed 1000');
}
}
function validateNoteContent(content) {
if (!content || typeof content !== 'string' || content.trim().length === 0) {
throw new Error('Note content is required and must be a non-empty string');
}
if (content.length > 5000) {
throw new Error('Note content must not exceed 5000 characters');
}
}
function parseUserIds(userIds) {
return userIds
.split(',')
.map((id) => id.trim())
.filter((id) => id.length > 0);
}
function validateGroupLink(groupLink) {
if (!groupLink || typeof groupLink !== 'string' || groupLink.trim().length === 0) {
throw new Error('Group link is required and must be a non-empty string');
}
const urlPattern = /^https?:\/\/.+/i;
if (!urlPattern.test(groupLink)) {
throw new Error('Group link must be a valid HTTP or HTTPS URL');
}
}
function validateGroupIds(groupIds) {
if (!groupIds || typeof groupIds !== 'string' || groupIds.trim().length === 0) {
throw new Error('Group IDs are required and must be a non-empty string');
}
const groupList = groupIds
.split(',')
.map((id) => id.trim())
.filter((id) => id.length > 0);
if (groupList.length === 0) {
throw new Error('At least one valid Group ID is required');
}
}
function parseGroupIds(groupIds) {
return groupIds
.split(',')
.map((id) => id.trim())
.filter((id) => id.length > 0);
}
function validateMemberIds(memberIds) {
if (!memberIds || typeof memberIds !== 'string' || memberIds.trim().length === 0) {
throw new Error('Member IDs are required and must be a non-empty string');
}
const memberList = memberIds
.split(',')
.map((id) => id.trim())
.filter((id) => id.length > 0);
if (memberList.length === 0) {
throw new Error('At least one valid Member ID is required');
}
}
function parseMemberIds(memberIds) {
return memberIds
.split(',')
.map((id) => id.trim())
.filter((id) => id.length > 0);
}
function validatePage(page) {
if (page !== undefined) {
if (typeof page !== 'number' || isNaN(page)) {
throw new Error('Page must be a valid number');
}
if (page < 1) {
throw new Error('Page must be at least 1');
}
}
}
function validateCount(count) {
if (count !== undefined) {
if (typeof count !== 'number' || isNaN(count)) {
throw new Error('Count must be a valid number');
}
if (count < 1) {
throw new Error('Count must be at least 1');
}
if (count > 100) {
throw new Error('Count must not exceed 100');
}
}
}
function validateTimestamp(timestamp) {
if (timestamp !== undefined) {
if (typeof timestamp !== 'number' || isNaN(timestamp)) {
throw new Error('Timestamp must be a valid number');
}
if (timestamp < 0) {
throw new Error('Timestamp must be a positive number');
}
const minTimestamp = 946684800;
const maxTimestamp = 4102444800;
if (timestamp < minTimestamp || timestamp > maxTimestamp) {
throw new Error('Timestamp should be a valid Unix timestamp in seconds');
}
}
}
//# sourceMappingURL=validator.js.map