redai-automation-web-sdk 1.0.1
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/README.md +715 -0
- package/dist/client/AutomationWebClient.d.ts +188 -0
- package/dist/client/AutomationWebClient.d.ts.map +1 -0
- package/dist/client/AutomationWebClient.js +370 -0
- package/dist/client/AutomationWebClient.js.map +1 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +21 -0
- package/dist/client/index.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/dist/services/auth/auth.service.d.ts +78 -0
- package/dist/services/auth/auth.service.d.ts.map +1 -0
- package/dist/services/auth/auth.service.js +227 -0
- package/dist/services/auth/auth.service.js.map +1 -0
- package/dist/services/auth/index.d.ts +5 -0
- package/dist/services/auth/index.d.ts.map +1 -0
- package/dist/services/auth/index.js +21 -0
- package/dist/services/auth/index.js.map +1 -0
- package/dist/services/bulk/bulk.service.d.ts +201 -0
- package/dist/services/bulk/bulk.service.d.ts.map +1 -0
- package/dist/services/bulk/bulk.service.js +114 -0
- package/dist/services/bulk/bulk.service.js.map +1 -0
- package/dist/services/bulk/index.d.ts +5 -0
- package/dist/services/bulk/index.d.ts.map +1 -0
- package/dist/services/bulk/index.js +21 -0
- package/dist/services/bulk/index.js.map +1 -0
- package/dist/services/conversations/conversations.service.d.ts +187 -0
- package/dist/services/conversations/conversations.service.d.ts.map +1 -0
- package/dist/services/conversations/conversations.service.js +119 -0
- package/dist/services/conversations/conversations.service.js.map +1 -0
- package/dist/services/conversations/index.d.ts +6 -0
- package/dist/services/conversations/index.d.ts.map +1 -0
- package/dist/services/conversations/index.js +13 -0
- package/dist/services/conversations/index.js.map +1 -0
- package/dist/services/friends/friends.service.d.ts +499 -0
- package/dist/services/friends/friends.service.d.ts.map +1 -0
- package/dist/services/friends/friends.service.js +288 -0
- package/dist/services/friends/friends.service.js.map +1 -0
- package/dist/services/friends/index.d.ts +6 -0
- package/dist/services/friends/index.d.ts.map +1 -0
- package/dist/services/friends/index.js +10 -0
- package/dist/services/friends/index.js.map +1 -0
- package/dist/services/groups/groups.service.d.ts +366 -0
- package/dist/services/groups/groups.service.d.ts.map +1 -0
- package/dist/services/groups/groups.service.js +250 -0
- package/dist/services/groups/groups.service.js.map +1 -0
- package/dist/services/groups/index.d.ts +6 -0
- package/dist/services/groups/index.d.ts.map +1 -0
- package/dist/services/groups/index.js +10 -0
- package/dist/services/groups/index.js.map +1 -0
- package/dist/services/messaging/index.d.ts +6 -0
- package/dist/services/messaging/index.d.ts.map +1 -0
- package/dist/services/messaging/index.js +10 -0
- package/dist/services/messaging/index.js.map +1 -0
- package/dist/services/messaging/messaging.service.d.ts +186 -0
- package/dist/services/messaging/messaging.service.d.ts.map +1 -0
- package/dist/services/messaging/messaging.service.js +212 -0
- package/dist/services/messaging/messaging.service.js.map +1 -0
- package/dist/services/user-info/index.d.ts +6 -0
- package/dist/services/user-info/index.d.ts.map +1 -0
- package/dist/services/user-info/index.js +10 -0
- package/dist/services/user-info/index.js.map +1 -0
- package/dist/services/user-info/user-info.service.d.ts +168 -0
- package/dist/services/user-info/user-info.service.d.ts.map +1 -0
- package/dist/services/user-info/user-info.service.js +85 -0
- package/dist/services/user-info/user-info.service.js.map +1 -0
- package/dist/services/webhook/index.d.ts +6 -0
- package/dist/services/webhook/index.d.ts.map +1 -0
- package/dist/services/webhook/index.js +10 -0
- package/dist/services/webhook/index.js.map +1 -0
- package/dist/services/webhook/webhook.service.d.ts +303 -0
- package/dist/services/webhook/webhook.service.d.ts.map +1 -0
- package/dist/services/webhook/webhook.service.js +133 -0
- package/dist/services/webhook/webhook.service.js.map +1 -0
- package/dist/types/auth.types.d.ts +384 -0
- package/dist/types/auth.types.d.ts.map +1 -0
- package/dist/types/auth.types.js +28 -0
- package/dist/types/auth.types.js.map +1 -0
- package/dist/types/bulk.types.d.ts +553 -0
- package/dist/types/bulk.types.d.ts.map +1 -0
- package/dist/types/bulk.types.js +31 -0
- package/dist/types/bulk.types.js.map +1 -0
- package/dist/types/common.types.d.ts +301 -0
- package/dist/types/common.types.d.ts.map +1 -0
- package/dist/types/common.types.js +58 -0
- package/dist/types/common.types.js.map +1 -0
- package/dist/types/friends.types.d.ts +566 -0
- package/dist/types/friends.types.d.ts.map +1 -0
- package/dist/types/friends.types.js +39 -0
- package/dist/types/friends.types.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +38 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/job/event-job.types.d.ts +147 -0
- package/dist/types/job/event-job.types.d.ts.map +1 -0
- package/dist/types/job/event-job.types.js +7 -0
- package/dist/types/job/event-job.types.js.map +1 -0
- package/dist/types/job/friend-group-job.types.d.ts +183 -0
- package/dist/types/job/friend-group-job.types.d.ts.map +1 -0
- package/dist/types/job/friend-group-job.types.js +7 -0
- package/dist/types/job/friend-group-job.types.js.map +1 -0
- package/dist/types/job/index.d.ts +88 -0
- package/dist/types/job/index.d.ts.map +1 -0
- package/dist/types/job/index.js +260 -0
- package/dist/types/job/index.js.map +1 -0
- package/dist/types/job/message-job.types.d.ts +181 -0
- package/dist/types/job/message-job.types.d.ts.map +1 -0
- package/dist/types/job/message-job.types.js +7 -0
- package/dist/types/job/message-job.types.js.map +1 -0
- package/dist/types/job/system-job.types.d.ts +235 -0
- package/dist/types/job/system-job.types.d.ts.map +1 -0
- package/dist/types/job/system-job.types.js +7 -0
- package/dist/types/job/system-job.types.js.map +1 -0
- package/dist/types/job/webhook-job.types.d.ts +219 -0
- package/dist/types/job/webhook-job.types.d.ts.map +1 -0
- package/dist/types/job/webhook-job.types.js +202 -0
- package/dist/types/job/webhook-job.types.js.map +1 -0
- package/dist/types/messaging.types.d.ts +565 -0
- package/dist/types/messaging.types.d.ts.map +1 -0
- package/dist/types/messaging.types.js +34 -0
- package/dist/types/messaging.types.js.map +1 -0
- package/dist/types/webhook/delivered-message.d.ts +47 -0
- package/dist/types/webhook/delivered-message.d.ts.map +1 -0
- package/dist/types/webhook/delivered-message.js +34 -0
- package/dist/types/webhook/delivered-message.js.map +1 -0
- package/dist/types/webhook/enums.d.ts +149 -0
- package/dist/types/webhook/enums.d.ts.map +1 -0
- package/dist/types/webhook/enums.js +160 -0
- package/dist/types/webhook/enums.js.map +1 -0
- package/dist/types/webhook/friend-event.d.ts +134 -0
- package/dist/types/webhook/friend-event.d.ts.map +1 -0
- package/dist/types/webhook/friend-event.js +79 -0
- package/dist/types/webhook/friend-event.js.map +1 -0
- package/dist/types/webhook/group-event.d.ts +223 -0
- package/dist/types/webhook/group-event.d.ts.map +1 -0
- package/dist/types/webhook/group-event.js +69 -0
- package/dist/types/webhook/group-event.js.map +1 -0
- package/dist/types/webhook/index.d.ts +25 -0
- package/dist/types/webhook/index.d.ts.map +1 -0
- package/dist/types/webhook/index.js +46 -0
- package/dist/types/webhook/index.js.map +1 -0
- package/dist/types/webhook/message.d.ts +123 -0
- package/dist/types/webhook/message.d.ts.map +1 -0
- package/dist/types/webhook/message.js +39 -0
- package/dist/types/webhook/message.js.map +1 -0
- package/dist/types/webhook/reaction.d.ts +40 -0
- package/dist/types/webhook/reaction.d.ts.map +1 -0
- package/dist/types/webhook/reaction.js +24 -0
- package/dist/types/webhook/reaction.js.map +1 -0
- package/dist/types/webhook/seen-message.d.ts +46 -0
- package/dist/types/webhook/seen-message.d.ts.map +1 -0
- package/dist/types/webhook/seen-message.js +34 -0
- package/dist/types/webhook/seen-message.js.map +1 -0
- package/dist/types/webhook/typing.d.ts +44 -0
- package/dist/types/webhook/typing.d.ts.map +1 -0
- package/dist/types/webhook/typing.js +35 -0
- package/dist/types/webhook/typing.js.map +1 -0
- package/dist/types/webhook/undo.d.ts +48 -0
- package/dist/types/webhook/undo.d.ts.map +1 -0
- package/dist/types/webhook/undo.js +24 -0
- package/dist/types/webhook/undo.js.map +1 -0
- package/dist/types/webhook.types.d.ts +451 -0
- package/dist/types/webhook.types.d.ts.map +1 -0
- package/dist/types/webhook.types.js +223 -0
- package/dist/types/webhook.types.js.map +1 -0
- package/dist/utils/event.utils.d.ts +119 -0
- package/dist/utils/event.utils.d.ts.map +1 -0
- package/dist/utils/event.utils.js +306 -0
- package/dist/utils/event.utils.js.map +1 -0
- package/dist/utils/format.utils.d.ts +128 -0
- package/dist/utils/format.utils.d.ts.map +1 -0
- package/dist/utils/format.utils.js +312 -0
- package/dist/utils/format.utils.js.map +1 -0
- package/dist/utils/http.utils.d.ts +111 -0
- package/dist/utils/http.utils.d.ts.map +1 -0
- package/dist/utils/http.utils.js +336 -0
- package/dist/utils/http.utils.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/validation.utils.d.ts +118 -0
- package/dist/utils/validation.utils.d.ts.map +1 -0
- package/dist/utils/validation.utils.js +326 -0
- package/dist/utils/validation.utils.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Validation utility functions
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ValidationUtils = exports.ValidationError = void 0;
|
|
7
|
+
const common_types_1 = require("../types/common.types");
|
|
8
|
+
const bulk_types_1 = require("../types/bulk.types");
|
|
9
|
+
/**
|
|
10
|
+
* Validation error class
|
|
11
|
+
*/
|
|
12
|
+
class ValidationError extends Error {
|
|
13
|
+
constructor(message, field) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.field = field;
|
|
16
|
+
this.name = 'ValidationError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ValidationError = ValidationError;
|
|
20
|
+
/**
|
|
21
|
+
* Validation utility class
|
|
22
|
+
*/
|
|
23
|
+
class ValidationUtils {
|
|
24
|
+
/**
|
|
25
|
+
* Validate session ID format
|
|
26
|
+
*/
|
|
27
|
+
static validateSessionId(sessionId) {
|
|
28
|
+
if (!sessionId || typeof sessionId !== 'string') {
|
|
29
|
+
throw new ValidationError('Session ID is required and must be a string', 'sessionId');
|
|
30
|
+
}
|
|
31
|
+
if (sessionId.trim().length === 0) {
|
|
32
|
+
throw new ValidationError('Session ID cannot be empty', 'sessionId');
|
|
33
|
+
}
|
|
34
|
+
// Check if it matches expected format (session-uuid)
|
|
35
|
+
const sessionIdPattern = /^session-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
36
|
+
if (!sessionIdPattern.test(sessionId)) {
|
|
37
|
+
throw new ValidationError('Session ID format is invalid', 'sessionId');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Validate user UUID format
|
|
42
|
+
*/
|
|
43
|
+
static validateUserUuid(userUuid) {
|
|
44
|
+
if (!userUuid || typeof userUuid !== 'string') {
|
|
45
|
+
throw new ValidationError('User UUID is required and must be a string', 'userUuid');
|
|
46
|
+
}
|
|
47
|
+
const uuidPattern = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
48
|
+
if (!uuidPattern.test(userUuid)) {
|
|
49
|
+
throw new ValidationError('User UUID format is invalid', 'userUuid');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Validate thread ID
|
|
54
|
+
*/
|
|
55
|
+
static validateThreadId(threadId) {
|
|
56
|
+
if (!threadId || typeof threadId !== 'string') {
|
|
57
|
+
throw new ValidationError('Thread ID is required and must be a string', 'threadId');
|
|
58
|
+
}
|
|
59
|
+
if (threadId.trim().length === 0) {
|
|
60
|
+
throw new ValidationError('Thread ID cannot be empty', 'threadId');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Validate thread type
|
|
65
|
+
*/
|
|
66
|
+
static validateThreadType(threadType) {
|
|
67
|
+
if (!Object.values(common_types_1.ThreadType).includes(threadType)) {
|
|
68
|
+
throw new ValidationError(`Thread type must be one of: ${Object.values(common_types_1.ThreadType).join(', ')}`, 'threadType');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate message content
|
|
73
|
+
*/
|
|
74
|
+
static validateMessageContent(content) {
|
|
75
|
+
if (!content || typeof content !== 'string') {
|
|
76
|
+
throw new ValidationError('Message content is required and must be a string', 'content');
|
|
77
|
+
}
|
|
78
|
+
if (content.trim().length === 0) {
|
|
79
|
+
throw new ValidationError('Message content cannot be empty', 'content');
|
|
80
|
+
}
|
|
81
|
+
// Check maximum length (Zalo limit is typically 2000 characters)
|
|
82
|
+
if (content.length > 2000) {
|
|
83
|
+
throw new ValidationError('Message content exceeds maximum length of 2000 characters', 'content');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Validate URL format
|
|
88
|
+
*/
|
|
89
|
+
static validateUrl(url, fieldName = 'url') {
|
|
90
|
+
if (!url || typeof url !== 'string') {
|
|
91
|
+
throw new ValidationError(`${fieldName} is required and must be a string`, fieldName);
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
new URL(url);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
throw new ValidationError(`${fieldName} must be a valid URL`, fieldName);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Validate urgency level
|
|
102
|
+
*/
|
|
103
|
+
static validateUrgency(urgency) {
|
|
104
|
+
if (!Object.values(common_types_1.Urgency).includes(urgency)) {
|
|
105
|
+
throw new ValidationError(`Urgency must be one of: ${Object.values(common_types_1.Urgency).join(', ')}`, 'urgency');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Validate phone number format (Vietnamese)
|
|
110
|
+
*/
|
|
111
|
+
static validatePhoneNumber(phoneNumber) {
|
|
112
|
+
if (!phoneNumber || typeof phoneNumber !== 'string') {
|
|
113
|
+
throw new ValidationError('Phone number is required and must be a string', 'phoneNumber');
|
|
114
|
+
}
|
|
115
|
+
// Vietnamese phone number patterns
|
|
116
|
+
const patterns = [
|
|
117
|
+
/^(\+84|84|0)(3[2-9]|5[6|8|9]|7[0|6-9]|8[1-6|8|9]|9[0-4|6-9])[0-9]{7}$/, // Mobile
|
|
118
|
+
/^(\+84|84|0)(2[0-9])[0-9]{8}$/, // Landline
|
|
119
|
+
];
|
|
120
|
+
const isValid = patterns.some(pattern => pattern.test(phoneNumber.replace(/\s/g, '')));
|
|
121
|
+
if (!isValid) {
|
|
122
|
+
throw new ValidationError('Phone number format is invalid', 'phoneNumber');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Validate email format
|
|
127
|
+
*/
|
|
128
|
+
static validateEmail(email) {
|
|
129
|
+
if (!email || typeof email !== 'string') {
|
|
130
|
+
throw new ValidationError('Email is required and must be a string', 'email');
|
|
131
|
+
}
|
|
132
|
+
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
133
|
+
if (!emailPattern.test(email)) {
|
|
134
|
+
throw new ValidationError('Email format is invalid', 'email');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Validate array of IDs
|
|
139
|
+
*/
|
|
140
|
+
static validateIdArray(ids, fieldName, minLength = 1) {
|
|
141
|
+
if (!Array.isArray(ids)) {
|
|
142
|
+
throw new ValidationError(`${fieldName} must be an array`, fieldName);
|
|
143
|
+
}
|
|
144
|
+
if (ids.length < minLength) {
|
|
145
|
+
throw new ValidationError(`${fieldName} must contain at least ${minLength} item(s)`, fieldName);
|
|
146
|
+
}
|
|
147
|
+
ids.forEach((id, index) => {
|
|
148
|
+
if (!id || typeof id !== 'string' || id.trim().length === 0) {
|
|
149
|
+
throw new ValidationError(`${fieldName}[${index}] must be a non-empty string`, fieldName);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Validate pagination parameters
|
|
155
|
+
*/
|
|
156
|
+
static validatePagination(page, limit) {
|
|
157
|
+
if (page !== undefined) {
|
|
158
|
+
if (!Number.isInteger(page) || page < 1) {
|
|
159
|
+
throw new ValidationError('Page must be a positive integer', 'page');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (limit !== undefined) {
|
|
163
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 100) {
|
|
164
|
+
throw new ValidationError('Limit must be an integer between 1 and 100', 'limit');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Validate file size
|
|
170
|
+
*/
|
|
171
|
+
static validateFileSize(size, maxSize = 50 * 1024 * 1024) {
|
|
172
|
+
if (!Number.isInteger(size) || size < 0) {
|
|
173
|
+
throw new ValidationError('File size must be a non-negative integer', 'fileSize');
|
|
174
|
+
}
|
|
175
|
+
if (size > maxSize) {
|
|
176
|
+
throw new ValidationError(`File size exceeds maximum allowed size of ${this.formatFileSize(maxSize)}`, 'fileSize');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Validate message content type
|
|
181
|
+
*/
|
|
182
|
+
static validateMessageContentType(type) {
|
|
183
|
+
if (!Object.values(bulk_types_1.MessageContentType).includes(type)) {
|
|
184
|
+
throw new ValidationError(`Message content type must be one of: ${Object.values(bulk_types_1.MessageContentType).join(', ')}`, 'type');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Validate timeout value
|
|
189
|
+
*/
|
|
190
|
+
static validateTimeout(timeout) {
|
|
191
|
+
if (!Number.isInteger(timeout) || timeout < 1000 || timeout > 300000) { // 1s to 5min
|
|
192
|
+
throw new ValidationError('Timeout must be an integer between 1000 and 300000 milliseconds', 'timeout');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Validate delay value
|
|
197
|
+
*/
|
|
198
|
+
static validateDelay(delay) {
|
|
199
|
+
if (!Number.isInteger(delay) || delay < 0 || delay > 60000) { // 0 to 1 minute
|
|
200
|
+
throw new ValidationError('Delay must be an integer between 0 and 60000 milliseconds', 'delay');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Validate batch size
|
|
205
|
+
*/
|
|
206
|
+
static validateBatchSize(batchSize) {
|
|
207
|
+
if (!Number.isInteger(batchSize) || batchSize < 1 || batchSize > 100) {
|
|
208
|
+
throw new ValidationError('Batch size must be an integer between 1 and 100', 'batchSize');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Validate retry count
|
|
213
|
+
*/
|
|
214
|
+
static validateRetryCount(retryCount) {
|
|
215
|
+
if (!Number.isInteger(retryCount) || retryCount < 0 || retryCount > 10) {
|
|
216
|
+
throw new ValidationError('Retry count must be an integer between 0 and 10', 'retryCount');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Validate SDK configuration
|
|
221
|
+
*/
|
|
222
|
+
static validateConfig(config) {
|
|
223
|
+
// Validate base URL
|
|
224
|
+
this.validateUrl(config.baseUrl, 'baseUrl');
|
|
225
|
+
// Validate optional numeric fields
|
|
226
|
+
if (config.timeout !== undefined) {
|
|
227
|
+
this.validateTimeout(config.timeout);
|
|
228
|
+
}
|
|
229
|
+
if (config.retryCount !== undefined) {
|
|
230
|
+
this.validateRetryCount(config.retryCount);
|
|
231
|
+
}
|
|
232
|
+
if (config.retryDelay !== undefined) {
|
|
233
|
+
this.validateDelay(config.retryDelay);
|
|
234
|
+
}
|
|
235
|
+
// Validate user agent
|
|
236
|
+
if (config.userAgent !== undefined && typeof config.userAgent !== 'string') {
|
|
237
|
+
throw new ValidationError('User agent must be a string', 'userAgent');
|
|
238
|
+
}
|
|
239
|
+
// Validate logging flag
|
|
240
|
+
if (config.logging !== undefined && typeof config.logging !== 'boolean') {
|
|
241
|
+
throw new ValidationError('Logging must be a boolean', 'logging');
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Validate date string format
|
|
246
|
+
*/
|
|
247
|
+
static validateDateString(dateString, fieldName = 'date') {
|
|
248
|
+
if (!dateString || typeof dateString !== 'string') {
|
|
249
|
+
throw new ValidationError(`${fieldName} is required and must be a string`, fieldName);
|
|
250
|
+
}
|
|
251
|
+
const date = new Date(dateString);
|
|
252
|
+
if (isNaN(date.getTime())) {
|
|
253
|
+
throw new ValidationError(`${fieldName} must be a valid date string`, fieldName);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Validate date range
|
|
258
|
+
*/
|
|
259
|
+
static validateDateRange(startDate, endDate) {
|
|
260
|
+
this.validateDateString(startDate, 'startDate');
|
|
261
|
+
this.validateDateString(endDate, 'endDate');
|
|
262
|
+
const start = new Date(startDate);
|
|
263
|
+
const end = new Date(endDate);
|
|
264
|
+
if (start >= end) {
|
|
265
|
+
throw new ValidationError('Start date must be before end date');
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Format file size for error messages
|
|
270
|
+
*/
|
|
271
|
+
static formatFileSize(bytes) {
|
|
272
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
273
|
+
if (bytes === 0)
|
|
274
|
+
return '0 Bytes';
|
|
275
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
276
|
+
return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i];
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Sanitize string input
|
|
280
|
+
*/
|
|
281
|
+
static sanitizeString(input) {
|
|
282
|
+
if (typeof input !== 'string') {
|
|
283
|
+
return '';
|
|
284
|
+
}
|
|
285
|
+
return input
|
|
286
|
+
.trim()
|
|
287
|
+
.replace(/[\x00-\x1F\x7F]/g, '') // Remove control characters
|
|
288
|
+
.replace(/\s+/g, ' '); // Normalize whitespace
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Validate and sanitize message content
|
|
292
|
+
*/
|
|
293
|
+
static sanitizeMessageContent(content) {
|
|
294
|
+
const sanitized = this.sanitizeString(content);
|
|
295
|
+
this.validateMessageContent(sanitized);
|
|
296
|
+
return sanitized;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Check if value is empty
|
|
300
|
+
*/
|
|
301
|
+
static isEmpty(value) {
|
|
302
|
+
if (value === null || value === undefined) {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
if (typeof value === 'string') {
|
|
306
|
+
return value.trim().length === 0;
|
|
307
|
+
}
|
|
308
|
+
if (Array.isArray(value)) {
|
|
309
|
+
return value.length === 0;
|
|
310
|
+
}
|
|
311
|
+
if (typeof value === 'object') {
|
|
312
|
+
return Object.keys(value).length === 0;
|
|
313
|
+
}
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Validate required field
|
|
318
|
+
*/
|
|
319
|
+
static validateRequired(value, fieldName) {
|
|
320
|
+
if (this.isEmpty(value)) {
|
|
321
|
+
throw new ValidationError(`${fieldName} is required`, fieldName);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
exports.ValidationUtils = ValidationUtils;
|
|
326
|
+
//# sourceMappingURL=validation.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.utils.js","sourceRoot":"","sources":["../../src/utils/validation.utils.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,wDAAiF;AACjF,oDAAyD;AAEzD;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe,EAAS,KAAc;QAChD,KAAK,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O,IAAI,CAAC;QACd,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC;QACnC,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAU,EAAE,SAAiB;QACnD,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CAAC,GAAG,SAAS,cAAc,EAAE,SAAS,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF;AA3WD,0CA2WC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "redai-automation-web-sdk",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "TypeScript SDK for RedAI Automation Web API - Zalo Personal automation and messaging. 100% compatible with automation-web backend.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"build:cjs": "tsc -p tsconfig.json",
|
|
16
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
17
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
18
|
+
"clean": "rimraf dist",
|
|
19
|
+
"dev": "tsc -w",
|
|
20
|
+
"test": "jest",
|
|
21
|
+
"test:watch": "jest --watch",
|
|
22
|
+
"test:coverage": "jest --coverage",
|
|
23
|
+
"lint": "eslint src/**/*.ts",
|
|
24
|
+
"lint:fix": "eslint src/**/*.ts --fix",
|
|
25
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
26
|
+
"docs": "typedoc src/index.ts",
|
|
27
|
+
"prepublishOnly": "echo 'Skipping build for now'",
|
|
28
|
+
"example:basic": "ts-node examples/basic-usage.ts",
|
|
29
|
+
"example:messaging": "ts-node examples/messaging.ts",
|
|
30
|
+
"example:webhook": "ts-node examples/webhook-handling.ts"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"zalo",
|
|
34
|
+
"automation",
|
|
35
|
+
"messaging",
|
|
36
|
+
"webhook",
|
|
37
|
+
"typescript",
|
|
38
|
+
"sdk",
|
|
39
|
+
"redai",
|
|
40
|
+
"zalo-personal",
|
|
41
|
+
"bulk-messaging",
|
|
42
|
+
"chatbot"
|
|
43
|
+
],
|
|
44
|
+
"author": "RedAI Team",
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/redai/automation-web-sdk.git"
|
|
49
|
+
},
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/redai/automation-web-sdk/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/redai/automation-web-sdk#readme",
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"axios": "^1.11.0",
|
|
56
|
+
"class-transformer": "^0.5.1",
|
|
57
|
+
"class-validator": "^0.14.2",
|
|
58
|
+
"reflect-metadata": "^0.2.2",
|
|
59
|
+
"eventemitter3": "^5.0.1"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/node": "^20.3.1",
|
|
63
|
+
"@types/jest": "^29.5.2",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
65
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
66
|
+
"eslint": "^8.42.0",
|
|
67
|
+
"eslint-config-prettier": "^9.0.0",
|
|
68
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
69
|
+
"jest": "^29.5.0",
|
|
70
|
+
"prettier": "^3.0.0",
|
|
71
|
+
"rimraf": "^5.0.0",
|
|
72
|
+
"ts-jest": "^29.1.0",
|
|
73
|
+
"ts-node": "^10.9.1",
|
|
74
|
+
"typedoc": "^0.25.0",
|
|
75
|
+
"typescript": "^5.5.3"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"typescript": ">=4.5.0"
|
|
79
|
+
},
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": ">=16.0.0",
|
|
82
|
+
"npm": ">=8.0.0"
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public",
|
|
86
|
+
"registry": "https://registry.npmjs.org/"
|
|
87
|
+
}
|
|
88
|
+
}
|