@redonvn/zalo-ads-sdk 0.2.14 → 0.2.15
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/index.d.mts +166 -1
- package/dist/index.d.ts +166 -1
- package/dist/index.js +749 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +730 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,12 +40,17 @@ __export(index_exports, {
|
|
|
40
40
|
AutomatedRuleTimeRangeEnum: () => AutomatedRuleTimeRangeEnum,
|
|
41
41
|
ConversionLabelEnum: () => ConversionLabelEnum,
|
|
42
42
|
ConversionUrlTypeEnum: () => ConversionUrlTypeEnum,
|
|
43
|
+
MAX_REPORT_RANGE_MS: () => MAX_REPORT_RANGE_MS,
|
|
44
|
+
MAX_REPORT_RANGE_SECONDS: () => MAX_REPORT_RANGE_SECONDS,
|
|
43
45
|
MemoryZaloSessionStore: () => MemoryZaloSessionStore,
|
|
44
46
|
RedisZaloSessionStore: () => RedisZaloSessionStore,
|
|
45
47
|
TieredZaloSessionStore: () => TieredZaloSessionStore,
|
|
46
48
|
VALID_AD_TYPES: () => VALID_AD_TYPES,
|
|
47
49
|
VALID_CAMPAIGN_TYPES: () => VALID_CAMPAIGN_TYPES,
|
|
50
|
+
VIETNAM_PHONE_REGEX: () => VIETNAM_PHONE_REGEX,
|
|
48
51
|
ZALO_NEW_REGION_PROVINCE_CODES: () => ZALO_NEW_REGION_PROVINCE_CODES,
|
|
52
|
+
ZALO_PROFILE_ADS_PROVINCES: () => ZALO_PROFILE_ADS_PROVINCES,
|
|
53
|
+
ZALO_PROFILE_ADS_SUB_CATEGORIES: () => ZALO_PROFILE_ADS_SUB_CATEGORIES,
|
|
49
54
|
ZALO_PROVINCE_MERGE_MAPPING: () => ZALO_PROVINCE_MERGE_MAPPING,
|
|
50
55
|
ZALO_REGION_PROVINCE_CODES: () => ZALO_REGION_PROVINCE_CODES,
|
|
51
56
|
ZaloAccountService: () => ZaloAccountService,
|
|
@@ -99,8 +104,11 @@ __export(index_exports, {
|
|
|
99
104
|
ZaloInstantPagesService: () => ZaloInstantPagesService,
|
|
100
105
|
ZaloInstantPagesValidator: () => ZaloInstantPagesValidator,
|
|
101
106
|
ZaloMediaService: () => ZaloMediaService,
|
|
107
|
+
ZaloMediaValidator: () => ZaloMediaValidator,
|
|
102
108
|
ZaloProfileAdsService: () => ZaloProfileAdsService,
|
|
109
|
+
ZaloProfileAdsValidator: () => ZaloProfileAdsValidator,
|
|
103
110
|
ZaloReportsService: () => ZaloReportsService,
|
|
111
|
+
ZaloReportsValidator: () => ZaloReportsValidator,
|
|
104
112
|
ZaloSdkError: () => ZaloSdkError,
|
|
105
113
|
ZaloSdkHttpClient: () => ZaloSdkHttpClient,
|
|
106
114
|
ZaloWidgetApiService: () => ZaloWidgetApiService,
|
|
@@ -114,6 +122,7 @@ __export(index_exports, {
|
|
|
114
122
|
validateChangeCampaignStatusParams: () => validateChangeCampaignStatusParams,
|
|
115
123
|
validateCloneInstantPageRequest: () => validateCloneInstantPageRequest,
|
|
116
124
|
validateCreateCampaignPayload: () => validateCreateCampaignPayload,
|
|
125
|
+
validateCreateCustomAudienceRequest: () => validateCreateCustomAudienceRequest,
|
|
117
126
|
validateCreateFlowRequest: () => validateCreateFlowRequest,
|
|
118
127
|
validateCreateFormEventAudienceRequest: () => validateCreateFormEventAudienceRequest,
|
|
119
128
|
validateCreateFormRequest: () => validateCreateFormRequest,
|
|
@@ -121,8 +130,11 @@ __export(index_exports, {
|
|
|
121
130
|
validateCreateLookalikeAudienceRequest: () => validateCreateLookalikeAudienceRequest,
|
|
122
131
|
validateCreateMessageOaEventAudienceRequest: () => validateCreateMessageOaEventAudienceRequest,
|
|
123
132
|
validateCreateMessagePersonalEventAudienceRequest: () => validateCreateMessagePersonalEventAudienceRequest,
|
|
133
|
+
validateCreateOaPageRequest: () => validateCreateOaPageRequest,
|
|
124
134
|
validateCreatePhoneAudienceRequest: () => validateCreatePhoneAudienceRequest,
|
|
125
135
|
validateCreateSavedAudienceRequest: () => validateCreateSavedAudienceRequest,
|
|
136
|
+
validateCropCoordinates: () => validateCropCoordinates,
|
|
137
|
+
validateDateRangeReportRequest: () => validateDateRangeReportRequest,
|
|
126
138
|
validateDuplicateAdParams: () => validateDuplicateAdParams,
|
|
127
139
|
validateEstimateAudienceRequest: () => validateEstimateAudienceRequest,
|
|
128
140
|
validateGetInstantPageDetailRequest: () => validateGetInstantPageDetailRequest,
|
|
@@ -138,10 +150,17 @@ __export(index_exports, {
|
|
|
138
150
|
validateListMiniPageTemplatesRequest: () => validateListMiniPageTemplatesRequest,
|
|
139
151
|
validateListOfficialAccountsRequest: () => validateListOfficialAccountsRequest,
|
|
140
152
|
validateRenameCampaignParams: () => validateRenameCampaignParams,
|
|
153
|
+
validateSaveMediaRequest: () => validateSaveMediaRequest,
|
|
141
154
|
validateSearchInstantPagesRequest: () => validateSearchInstantPagesRequest,
|
|
155
|
+
validateToggleLeadNotificationRequest: () => validateToggleLeadNotificationRequest,
|
|
142
156
|
validateUpdateAdPayload: () => validateUpdateAdPayload,
|
|
143
157
|
validateUpdateFlowRequest: () => validateUpdateFlowRequest,
|
|
144
158
|
validateUpdateInstantPageRequest: () => validateUpdateInstantPageRequest,
|
|
159
|
+
validateUpdateInstantPageSharesRequest: () => validateUpdateInstantPageSharesRequest,
|
|
160
|
+
validateUpdateLeadNotificationIntervalRequest: () => validateUpdateLeadNotificationIntervalRequest,
|
|
161
|
+
validateUploadCustomAudiencePhoneListRequest: () => validateUploadCustomAudiencePhoneListRequest,
|
|
162
|
+
validateUploadMediaRequest: () => validateUploadMediaRequest,
|
|
163
|
+
validateUpsertCustomReportRequest: () => validateUpsertCustomReportRequest,
|
|
145
164
|
validateUpsertInstantPageFormRequest: () => validateUpsertInstantPageFormRequest
|
|
146
165
|
});
|
|
147
166
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1683,14 +1702,102 @@ function validateEstimateAudienceRequest(input) {
|
|
|
1683
1702
|
} : void 0
|
|
1684
1703
|
};
|
|
1685
1704
|
}
|
|
1705
|
+
function validateUploadCustomAudiencePhoneListRequest(input) {
|
|
1706
|
+
const errors = [];
|
|
1707
|
+
if (!input || typeof input !== "object") {
|
|
1708
|
+
return {
|
|
1709
|
+
isValid: false,
|
|
1710
|
+
errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u t\u1EA3i danh s\xE1ch s\u1ED1 \u0111i\u1EC7n tho\u1EA1i ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."]
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
const raw = input;
|
|
1714
|
+
const file = raw.File ?? raw.file;
|
|
1715
|
+
if (!file) {
|
|
1716
|
+
errors.push("Tr\u01B0\u1EDDng t\u1EC7p danh s\xE1ch s\u1ED1 \u0111i\u1EC7n tho\u1EA1i ('File') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
1717
|
+
return { isValid: false, errors };
|
|
1718
|
+
}
|
|
1719
|
+
if (typeof file === "string") {
|
|
1720
|
+
const trimmed = file.trim();
|
|
1721
|
+
if (!trimmed) {
|
|
1722
|
+
errors.push("\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p danh s\xE1ch s\u1ED1 \u0111i\u1EC7n tho\u1EA1i kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
1723
|
+
} else if (!/^https?:\/\/.+/i.test(trimmed)) {
|
|
1724
|
+
errors.push(`\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p '${trimmed}' kh\xF4ng h\u1EE3p l\u1EC7. Ph\u1EA3i l\xE0 URL HTTP ho\u1EB7c HTTPS.`);
|
|
1725
|
+
}
|
|
1726
|
+
const cleanUrl = trimmed.split("?")[0].toLowerCase();
|
|
1727
|
+
if (!cleanUrl.endsWith(".txt") && !cleanUrl.endsWith(".csv")) {
|
|
1728
|
+
errors.push("T\u1EC7p danh s\xE1ch s\u1ED1 \u0111i\u1EC7n tho\u1EA1i ph\u1EA3i c\xF3 \u0111\u1ECBnh d\u1EA1ng .txt ho\u1EB7c .csv.");
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
const isHashRaw = raw.isHash !== void 0 ? String(raw.isHash).trim() : "0";
|
|
1732
|
+
if (isHashRaw !== "0" && isHashRaw !== "1") {
|
|
1733
|
+
errors.push(`Gi\xE1 tr\u1ECB 'isHash' kh\xF4ng h\u1EE3p l\u1EC7: '${raw.isHash}'. Ch\u1EC9 h\u1ED7 tr\u1EE3 '0' (danh s\xE1ch S\u0110T th\xF4) ho\u1EB7c '1' (danh s\xE1ch \u0111\xE3 b\u0103m).`);
|
|
1734
|
+
}
|
|
1735
|
+
const cleanData = {
|
|
1736
|
+
File: file,
|
|
1737
|
+
isHash: isHashRaw
|
|
1738
|
+
};
|
|
1739
|
+
return {
|
|
1740
|
+
isValid: errors.length === 0,
|
|
1741
|
+
errors,
|
|
1742
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
function validateCreateCustomAudienceRequest(input) {
|
|
1746
|
+
if (!input || typeof input !== "object") {
|
|
1747
|
+
return {
|
|
1748
|
+
isValid: false,
|
|
1749
|
+
errors: ["D\u1EEF li\u1EC7u t\u1EA1o \u0111\u1ED1i t\u01B0\u1EE3ng t\xF9y ch\u1EC9nh (Custom Audience) ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."]
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
const raw = input;
|
|
1753
|
+
const caType = Number(raw.caType);
|
|
1754
|
+
switch (caType) {
|
|
1755
|
+
case 1:
|
|
1756
|
+
return validateCreateSavedAudienceRequest(raw);
|
|
1757
|
+
case 3:
|
|
1758
|
+
return validateCreatePhoneAudienceRequest(raw);
|
|
1759
|
+
case 6:
|
|
1760
|
+
return validateCreateLookalikeAudienceRequest(raw);
|
|
1761
|
+
case 12:
|
|
1762
|
+
return validateCreateFormEventAudienceRequest(raw);
|
|
1763
|
+
case 11:
|
|
1764
|
+
return validateCreateMessageOaEventAudienceRequest(raw);
|
|
1765
|
+
case 14:
|
|
1766
|
+
return validateCreateMessagePersonalEventAudienceRequest(raw);
|
|
1767
|
+
default: {
|
|
1768
|
+
const errors = [];
|
|
1769
|
+
const name = typeof raw.name === "string" ? raw.name.trim() : "";
|
|
1770
|
+
if (!name) {
|
|
1771
|
+
errors.push("T\xEAn t\u1EADp \u0111\u1ED1i t\u01B0\u1EE3ng ('name') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
1772
|
+
} else if (name.length > 100) {
|
|
1773
|
+
errors.push(`T\xEAn t\u1EADp \u0111\u1ED1i t\u01B0\u1EE3ng kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 100 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${name.length} k\xFD t\u1EF1).`);
|
|
1774
|
+
}
|
|
1775
|
+
if (!Number.isInteger(caType) || caType <= 0) {
|
|
1776
|
+
errors.push(`Lo\u1EA1i \u0111\u1ED1i t\u01B0\u1EE3ng t\xF9y ch\u1EC9nh ('caType') kh\xF4ng h\u1EE3p l\u1EC7: ${raw.caType}.`);
|
|
1777
|
+
}
|
|
1778
|
+
if (!raw.targeting || typeof raw.targeting !== "object") {
|
|
1779
|
+
errors.push("C\u1EA5u h\xECnh nh\u1EAFm m\u1EE5c ti\xEAu ('targeting') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
1780
|
+
}
|
|
1781
|
+
return {
|
|
1782
|
+
isValid: errors.length === 0,
|
|
1783
|
+
errors,
|
|
1784
|
+
data: errors.length === 0 ? raw : void 0
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1686
1789
|
var ZaloAudiencesValidator = {
|
|
1790
|
+
createCustomAudience: validateCreateCustomAudienceRequest,
|
|
1687
1791
|
createSavedAudience: validateCreateSavedAudienceRequest,
|
|
1688
1792
|
createPhoneAudience: validateCreatePhoneAudienceRequest,
|
|
1689
1793
|
createLookalikeAudience: validateCreateLookalikeAudienceRequest,
|
|
1690
1794
|
createFormEventAudience: validateCreateFormEventAudienceRequest,
|
|
1691
1795
|
createMessageOaEventAudience: validateCreateMessageOaEventAudienceRequest,
|
|
1692
1796
|
createMessagePersonalEventAudience: validateCreateMessagePersonalEventAudienceRequest,
|
|
1693
|
-
estimateAudience: validateEstimateAudienceRequest
|
|
1797
|
+
estimateAudience: validateEstimateAudienceRequest,
|
|
1798
|
+
uploadPhoneList: validateUploadCustomAudiencePhoneListRequest,
|
|
1799
|
+
validateUploadPhoneList: validateUploadCustomAudiencePhoneListRequest,
|
|
1800
|
+
validateUploadCustomAudiencePhoneList: validateUploadCustomAudiencePhoneListRequest
|
|
1694
1801
|
};
|
|
1695
1802
|
|
|
1696
1803
|
// src/dtos/ads.dto.ts
|
|
@@ -2509,12 +2616,78 @@ function validateDuplicateAdParams(params) {
|
|
|
2509
2616
|
warnings
|
|
2510
2617
|
};
|
|
2511
2618
|
}
|
|
2619
|
+
function validateCropCoordinates(input) {
|
|
2620
|
+
const errors = [];
|
|
2621
|
+
const warnings = [];
|
|
2622
|
+
if (!input || typeof input !== "object") {
|
|
2623
|
+
return {
|
|
2624
|
+
isValid: false,
|
|
2625
|
+
errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u c\u1EAFt/t\u1EA3i \u1EA3nh qu\u1EA3ng c\xE1o ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."],
|
|
2626
|
+
warnings
|
|
2627
|
+
};
|
|
2628
|
+
}
|
|
2629
|
+
const raw = input;
|
|
2630
|
+
const file = raw.File ?? raw.file;
|
|
2631
|
+
if (!file) {
|
|
2632
|
+
errors.push("Tr\u01B0\u1EDDng t\u1EC7p \u1EA3nh ('File') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
2633
|
+
} else if (typeof file === "string" && !/^(https?:\/\/|data:image\/)/i.test(file.trim())) {
|
|
2634
|
+
errors.push("\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p \u1EA3nh ('File') ph\u1EA3i l\xE0 URL HTTP/HTTPS ho\u1EB7c data URL h\u1EE3p l\u1EC7.");
|
|
2635
|
+
}
|
|
2636
|
+
const x = raw.x !== void 0 ? Number(raw.x) : 0;
|
|
2637
|
+
const y = raw.y !== void 0 ? Number(raw.y) : 0;
|
|
2638
|
+
const width = raw.width !== void 0 ? Number(raw.width) : 0;
|
|
2639
|
+
const height = raw.height !== void 0 ? Number(raw.height) : 0;
|
|
2640
|
+
const scale = raw.scale !== void 0 ? Number(raw.scale) : 1;
|
|
2641
|
+
if (isNaN(x) || x < 0) {
|
|
2642
|
+
errors.push(`T\u1ECDa \u0111\u1ED9 x kh\xF4ng h\u1EE3p l\u1EC7: '${raw.x}'. Ph\u1EA3i l\xE0 s\u1ED1 kh\xF4ng \xE2m (>= 0).`);
|
|
2643
|
+
}
|
|
2644
|
+
if (isNaN(y) || y < 0) {
|
|
2645
|
+
errors.push(`T\u1ECDa \u0111\u1ED9 y kh\xF4ng h\u1EE3p l\u1EC7: '${raw.y}'. Ph\u1EA3i l\xE0 s\u1ED1 kh\xF4ng \xE2m (>= 0).`);
|
|
2646
|
+
}
|
|
2647
|
+
if (isNaN(width) || width < 0) {
|
|
2648
|
+
errors.push(`Chi\u1EC1u r\u1ED9ng khung c\u1EAFt ('width') kh\xF4ng h\u1EE3p l\u1EC7: '${raw.width}'. Ph\u1EA3i l\xE0 s\u1ED1 kh\xF4ng \xE2m.`);
|
|
2649
|
+
}
|
|
2650
|
+
if (isNaN(height) || height < 0) {
|
|
2651
|
+
errors.push(`Chi\u1EC1u cao khung c\u1EAFt ('height') kh\xF4ng h\u1EE3p l\u1EC7: '${raw.height}'. Ph\u1EA3i l\xE0 s\u1ED1 kh\xF4ng \xE2m.`);
|
|
2652
|
+
}
|
|
2653
|
+
if (isNaN(scale) || scale <= 0) {
|
|
2654
|
+
errors.push(`T\u1EF7 l\u1EC7 co d\xE3n ('scale') kh\xF4ng h\u1EE3p l\u1EC7: '${raw.scale}'. Ph\u1EA3i l\xE0 s\u1ED1 d\u01B0\u01A1ng (> 0).`);
|
|
2655
|
+
}
|
|
2656
|
+
if (width > 0 && height === 0 || height > 0 && width === 0) {
|
|
2657
|
+
errors.push("Khi \u0111\xE3 ch\u1EC9 \u0111\u1ECBnh c\u1EAFt \u1EA3nh, c\u1EA3 'width' v\xE0 'height' \u0111\u1EC1u ph\u1EA3i l\u1EDBn h\u01A1n 0.");
|
|
2658
|
+
}
|
|
2659
|
+
if (width > 0 && height > 0) {
|
|
2660
|
+
const ratio = width / height;
|
|
2661
|
+
const isLandscape = Math.abs(ratio - 1.92) < 0.2 || Math.abs(ratio - 1.91) < 0.2 || Math.abs(ratio - 1.78) < 0.2;
|
|
2662
|
+
const isSquare = Math.abs(ratio - 1) < 0.05;
|
|
2663
|
+
const isVertical = Math.abs(ratio - 0.5625) < 0.1;
|
|
2664
|
+
if (!isLandscape && !isSquare && !isVertical) {
|
|
2665
|
+
warnings.push(`T\u1EF7 l\u1EC7 khung c\u1EAFt (${width}x${height} ~ ${ratio.toFixed(2)}:1) kh\xE1c c\xE1c t\u1EF7 l\u1EC7 chu\u1EA9n c\u1EE7a Zalo Ads (16:9 / 1.92:1 ngang, 1:1 vu\xF4ng ho\u1EB7c 9:16 d\u1ECDc). H\xE3y ki\u1EC3m tra hi\u1EC3n th\u1ECB th\u1EF1c t\u1EBF.`);
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
const cleanData = {
|
|
2669
|
+
File: file,
|
|
2670
|
+
x,
|
|
2671
|
+
y,
|
|
2672
|
+
width,
|
|
2673
|
+
height,
|
|
2674
|
+
scale
|
|
2675
|
+
};
|
|
2676
|
+
return {
|
|
2677
|
+
isValid: errors.length === 0,
|
|
2678
|
+
errors,
|
|
2679
|
+
warnings,
|
|
2680
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
2681
|
+
};
|
|
2682
|
+
}
|
|
2512
2683
|
var ZaloCampaignsValidator = {
|
|
2513
2684
|
createCampaign: validateCreateCampaignPayload,
|
|
2514
2685
|
updateAd: validateUpdateAdPayload,
|
|
2515
2686
|
renameCampaign: validateRenameCampaignParams,
|
|
2516
2687
|
changeStatus: validateChangeCampaignStatusParams,
|
|
2517
|
-
duplicateAd: validateDuplicateAdParams
|
|
2688
|
+
duplicateAd: validateDuplicateAdParams,
|
|
2689
|
+
validateCropCoordinates,
|
|
2690
|
+
validateUploadCropAdImage: validateCropCoordinates
|
|
2518
2691
|
};
|
|
2519
2692
|
|
|
2520
2693
|
// src/services/campaigns.service.ts
|
|
@@ -5666,10 +5839,60 @@ function validateListFormLeadsRequest(input) {
|
|
|
5666
5839
|
} : void 0
|
|
5667
5840
|
};
|
|
5668
5841
|
}
|
|
5842
|
+
function validateToggleLeadNotificationRequest(input) {
|
|
5843
|
+
const errors = [];
|
|
5844
|
+
if (!input || typeof input !== "object") {
|
|
5845
|
+
return {
|
|
5846
|
+
isValid: false,
|
|
5847
|
+
errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u b\u1EADt/t\u1EAFt th\xF4ng b\xE1o lead ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."]
|
|
5848
|
+
};
|
|
5849
|
+
}
|
|
5850
|
+
const raw = input;
|
|
5851
|
+
const formId = typeof raw.formId === "string" ? raw.formId.trim() : raw.formId ? String(raw.formId).trim() : "";
|
|
5852
|
+
if (!formId) {
|
|
5853
|
+
errors.push("M\xE3 bi\u1EC3u m\u1EABu ('formId') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
5854
|
+
}
|
|
5855
|
+
return {
|
|
5856
|
+
isValid: errors.length === 0,
|
|
5857
|
+
errors,
|
|
5858
|
+
data: errors.length === 0 ? { formId } : void 0
|
|
5859
|
+
};
|
|
5860
|
+
}
|
|
5861
|
+
function validateUpdateLeadNotificationIntervalRequest(input) {
|
|
5862
|
+
const errors = [];
|
|
5863
|
+
if (!input || typeof input !== "object") {
|
|
5864
|
+
return {
|
|
5865
|
+
isValid: false,
|
|
5866
|
+
errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u c\u1EADp nh\u1EADt chu k\u1EF3 th\xF4ng b\xE1o lead ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."]
|
|
5867
|
+
};
|
|
5868
|
+
}
|
|
5869
|
+
const raw = input;
|
|
5870
|
+
const oaId = typeof raw.oaId === "string" ? raw.oaId.trim() : raw.oaId ? String(raw.oaId).trim() : "";
|
|
5871
|
+
const formId = typeof raw.formId === "string" ? raw.formId.trim() : raw.formId ? String(raw.formId).trim() : "";
|
|
5872
|
+
if (!oaId) {
|
|
5873
|
+
errors.push("M\xE3 Official Account ('oaId') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
5874
|
+
}
|
|
5875
|
+
if (!formId) {
|
|
5876
|
+
errors.push("M\xE3 bi\u1EC3u m\u1EABu ('formId') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
5877
|
+
}
|
|
5878
|
+
const interval = Number(raw.interval);
|
|
5879
|
+
if (isNaN(interval) || ![0, 1, 6].includes(interval)) {
|
|
5880
|
+
errors.push(`Chu k\u1EF3 th\xF4ng b\xE1o lead ('interval') '${raw.interval}' kh\xF4ng h\u1EE3p l\u1EC7. Ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn thu\u1ED9c [0, 1, 6] (0: Ngay l\u1EADp t\u1EE9c khi c\xF3 lead / INSTANT, 1 ho\u1EB7c 6: T\u1ED5ng h\u1EE3p theo ng\xE0y / DAILY).`);
|
|
5881
|
+
}
|
|
5882
|
+
return {
|
|
5883
|
+
isValid: errors.length === 0,
|
|
5884
|
+
errors,
|
|
5885
|
+
data: errors.length === 0 ? { oaId, formId, interval } : void 0
|
|
5886
|
+
};
|
|
5887
|
+
}
|
|
5669
5888
|
var ZaloFormsValidator = {
|
|
5670
5889
|
createForm: validateCreateFormRequest,
|
|
5671
5890
|
listFormsByOfficialAccount: validateListFormsByOfficialAccountRequest,
|
|
5672
|
-
listFormLeads: validateListFormLeadsRequest
|
|
5891
|
+
listFormLeads: validateListFormLeadsRequest,
|
|
5892
|
+
enableLeadNotification: validateToggleLeadNotificationRequest,
|
|
5893
|
+
disableLeadNotification: validateToggleLeadNotificationRequest,
|
|
5894
|
+
updateLeadNotificationInterval: validateUpdateLeadNotificationIntervalRequest,
|
|
5895
|
+
validateLeadNotificationInterval: validateUpdateLeadNotificationIntervalRequest
|
|
5673
5896
|
};
|
|
5674
5897
|
|
|
5675
5898
|
// src/services/forms.service.ts
|
|
@@ -6377,6 +6600,53 @@ function validateUpsertInstantPageFormRequest(input) {
|
|
|
6377
6600
|
data: errors.length === 0 ? data : void 0
|
|
6378
6601
|
};
|
|
6379
6602
|
}
|
|
6603
|
+
function validateUpdateInstantPageSharesRequest(input) {
|
|
6604
|
+
const errors = [];
|
|
6605
|
+
if (!input || typeof input !== "object") {
|
|
6606
|
+
return {
|
|
6607
|
+
isValid: false,
|
|
6608
|
+
errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u c\u1EADp nh\u1EADt quy\u1EC1n chia s\u1EBB Instant Page ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."]
|
|
6609
|
+
};
|
|
6610
|
+
}
|
|
6611
|
+
const obj = input;
|
|
6612
|
+
if (!isPositiveInteger2(obj.instantPageId)) {
|
|
6613
|
+
errors.push("Tr\u01B0\u1EDDng 'instantPageId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
6614
|
+
}
|
|
6615
|
+
if (!Array.isArray(obj.shares) || obj.shares.length === 0) {
|
|
6616
|
+
errors.push("Tr\u01B0\u1EDDng 'shares' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i ch\u1EE9a \xEDt nh\u1EA5t m\u1ED9t ng\u01B0\u1EDDi d\xF9ng \u0111\u01B0\u1EE3c ph\xE2n quy\u1EC1n (minItems: 1).");
|
|
6617
|
+
} else {
|
|
6618
|
+
const validPermissions = [1, 2, 3, 4];
|
|
6619
|
+
const seenUserIds = /* @__PURE__ */ new Set();
|
|
6620
|
+
obj.shares.forEach((item, idx) => {
|
|
6621
|
+
if (!item || typeof item !== "object") {
|
|
6622
|
+
errors.push(`Ph\u1EA7n t\u1EED th\u1EE9 ${idx + 1} trong danh s\xE1ch 'shares' ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng.`);
|
|
6623
|
+
return;
|
|
6624
|
+
}
|
|
6625
|
+
const share = item;
|
|
6626
|
+
const userId = Number(share.userId);
|
|
6627
|
+
if (!Number.isInteger(userId) || userId <= 0) {
|
|
6628
|
+
errors.push(`Ph\u1EA7n t\u1EED th\u1EE9 ${idx + 1}: Tr\u01B0\u1EDDng 'userId' ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng \u0111\u1ECBnh danh Zalo (hi\u1EC7n t\u1EA1i: ${share.userId}).`);
|
|
6629
|
+
} else if (seenUserIds.has(userId)) {
|
|
6630
|
+
errors.push(`Ph\u1EA7n t\u1EED th\u1EE9 ${idx + 1}: ID ng\u01B0\u1EDDi d\xF9ng '${userId}' b\u1ECB tr\xF9ng l\u1EB7p trong danh s\xE1ch ph\xE2n quy\u1EC1n.`);
|
|
6631
|
+
} else {
|
|
6632
|
+
seenUserIds.add(userId);
|
|
6633
|
+
}
|
|
6634
|
+
const permission = Number(share.permission);
|
|
6635
|
+
if (!validPermissions.includes(permission)) {
|
|
6636
|
+
errors.push(`Ph\u1EA7n t\u1EED th\u1EE9 ${idx + 1}: Quy\u1EC1n 'permission' kh\xF4ng h\u1EE3p l\u1EC7: ${share.permission}. Ph\u1EA3i thu\u1ED9c [1, 2, 3, 4] (1: ADMIN, 2: UPDATE_PAGE, 3: DOWNLOAD_INFO, 4: READ_ONLY).`);
|
|
6637
|
+
}
|
|
6638
|
+
});
|
|
6639
|
+
}
|
|
6640
|
+
const cleanData = {
|
|
6641
|
+
instantPageId: toPositiveInteger2(obj.instantPageId),
|
|
6642
|
+
shares: obj.shares || []
|
|
6643
|
+
};
|
|
6644
|
+
return {
|
|
6645
|
+
isValid: errors.length === 0,
|
|
6646
|
+
errors,
|
|
6647
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
6648
|
+
};
|
|
6649
|
+
}
|
|
6380
6650
|
var ZaloInstantPagesValidator = {
|
|
6381
6651
|
validateCreateInstantPage: validateCreateInstantPageRequest,
|
|
6382
6652
|
validateCloneInstantPage: validateCloneInstantPageRequest,
|
|
@@ -6385,6 +6655,8 @@ var ZaloInstantPagesValidator = {
|
|
|
6385
6655
|
validateListInstantPageEditHistory: validateListInstantPageEditHistoryRequest,
|
|
6386
6656
|
validateListInstantPageFormRecords: validateListInstantPageFormRecordsRequest,
|
|
6387
6657
|
validateListInstantPageShares: validateListInstantPageSharesRequest,
|
|
6658
|
+
validateUpdateInstantPageShares: validateUpdateInstantPageSharesRequest,
|
|
6659
|
+
validateUpdateShares: validateUpdateInstantPageSharesRequest,
|
|
6388
6660
|
validateListInstantPageUsers: validateListInstantPageUsersRequest,
|
|
6389
6661
|
validateListMiniPageTemplates: validateListMiniPageTemplatesRequest,
|
|
6390
6662
|
validateSearchInstantPages: validateSearchInstantPagesRequest,
|
|
@@ -7474,6 +7746,461 @@ var ZaloConversionsValidator = class {
|
|
|
7474
7746
|
};
|
|
7475
7747
|
}
|
|
7476
7748
|
};
|
|
7749
|
+
|
|
7750
|
+
// src/validators/profile-ads.validator.ts
|
|
7751
|
+
var ZALO_PROFILE_ADS_SUB_CATEGORIES = {
|
|
7752
|
+
10043: "B\u1EA5t \u0111\u1ED9ng s\u1EA3n",
|
|
7753
|
+
10018: "C\xF4ng ngh\u1EC7 & Thi\u1EBFt b\u1ECB",
|
|
7754
|
+
10097: "D\u1ECBch v\u1EE5 ti\u1EC7n \xEDch",
|
|
7755
|
+
10020: "Du l\u1ECBch & L\u01B0u tr\xFA",
|
|
7756
|
+
10021: "Gi\xE1o d\u1EE5c & \u0110\xE0o t\u1EA1o",
|
|
7757
|
+
10024: "Mua s\u1EAFm & B\xE1n l\u1EBB",
|
|
7758
|
+
10019: "M\u1EF9 ph\u1EA9m & L\xE0m \u0111\u1EB9p",
|
|
7759
|
+
10014: "Nh\xE0 h\xE0ng & Qu\xE1n",
|
|
7760
|
+
10094: "\xD4 t\xF4 & Xe m\xE1y",
|
|
7761
|
+
10098: "S\u1EA3n xu\u1EA5t & Ch\u1EBF t\u1EA1o",
|
|
7762
|
+
10044: "T\xE0i ch\xEDnh & Ng\xE2n h\xE0ng",
|
|
7763
|
+
10099: "Thi\u1EBFt k\u1EBF & Thi c\xF4ng",
|
|
7764
|
+
10017: "Th\u1EDDi trang & May m\u1EB7c",
|
|
7765
|
+
10023: "Th\u1EF1c ph\u1EA9m & \u0110\u1ED3 u\u1ED1ng",
|
|
7766
|
+
10016: "Truy\u1EC1n th\xF4ng & Gi\u1EA3i tr\xED",
|
|
7767
|
+
10092: "Truy\u1EC1n th\xF4ng n\u1ED9i b\u1ED9",
|
|
7768
|
+
10101: "Tuy\u1EC3n d\u1EE5ng & Vi\u1EC7c l\xE0m",
|
|
7769
|
+
10100: "T\u01B0 v\u1EA5n & Qu\u1EA3n l\xFD",
|
|
7770
|
+
10095: "V\u1EADn t\u1EA3i",
|
|
7771
|
+
10093: "Vi\u1EC5n th\xF4ng",
|
|
7772
|
+
10022: "Y t\u1EBF & D\u01B0\u1EE3c ph\u1EA9m",
|
|
7773
|
+
10025: "D\u1ECBch v\u1EE5 kh\xE1c"
|
|
7774
|
+
};
|
|
7775
|
+
var ZALO_PROFILE_ADS_PROVINCES = {
|
|
7776
|
+
1: "Th\xE0nh ph\u1ED1 H\xE0 N\u1ED9i",
|
|
7777
|
+
4: "T\u1EC9nh Cao B\u1EB1ng",
|
|
7778
|
+
8: "T\u1EC9nh Tuy\xEAn Quang",
|
|
7779
|
+
11: "T\u1EC9nh \u0110i\u1EC7n Bi\xEAn",
|
|
7780
|
+
12: "T\u1EC9nh Lai Ch\xE2u",
|
|
7781
|
+
14: "T\u1EC9nh S\u01A1n La",
|
|
7782
|
+
15: "T\u1EC9nh L\xE0o Cai",
|
|
7783
|
+
19: "T\u1EC9nh Th\xE1i Nguy\xEAn",
|
|
7784
|
+
20: "T\u1EC9nh L\u1EA1ng S\u01A1n",
|
|
7785
|
+
22: "T\u1EC9nh Qu\u1EA3ng Ninh",
|
|
7786
|
+
24: "T\u1EC9nh B\u1EAFc Ninh",
|
|
7787
|
+
25: "T\u1EC9nh Ph\xFA Th\u1ECD",
|
|
7788
|
+
31: "Th\xE0nh ph\u1ED1 H\u1EA3i Ph\xF2ng",
|
|
7789
|
+
33: "T\u1EC9nh H\u01B0ng Y\xEAn",
|
|
7790
|
+
37: "T\u1EC9nh Ninh B\xECnh",
|
|
7791
|
+
38: "T\u1EC9nh Thanh H\xF3a",
|
|
7792
|
+
40: "T\u1EC9nh Ngh\u1EC7 An",
|
|
7793
|
+
42: "T\u1EC9nh H\xE0 T\u0129nh",
|
|
7794
|
+
44: "T\u1EC9nh Qu\u1EA3ng Tr\u1ECB",
|
|
7795
|
+
46: "Th\xE0nh ph\u1ED1 Hu\u1EBF",
|
|
7796
|
+
48: "Th\xE0nh ph\u1ED1 \u0110\xE0 N\u1EB5ng",
|
|
7797
|
+
51: "T\u1EC9nh Qu\u1EA3ng Ng\xE3i",
|
|
7798
|
+
52: "T\u1EC9nh Gia Lai",
|
|
7799
|
+
56: "T\u1EC9nh Kh\xE1nh H\xF2a",
|
|
7800
|
+
66: "T\u1EC9nh \u0110\u1EAFk L\u1EAFk",
|
|
7801
|
+
68: "T\u1EC9nh L\xE2m \u0110\u1ED3ng",
|
|
7802
|
+
75: "T\u1EC9nh \u0110\u1ED3ng Nai",
|
|
7803
|
+
79: "Th\xE0nh ph\u1ED1 H\u1ED3 Ch\xED Minh",
|
|
7804
|
+
80: "T\u1EC9nh T\xE2y Ninh",
|
|
7805
|
+
82: "T\u1EC9nh \u0110\u1ED3ng Th\xE1p",
|
|
7806
|
+
86: "T\u1EC9nh V\u0129nh Long",
|
|
7807
|
+
91: "T\u1EC9nh An Giang",
|
|
7808
|
+
92: "Th\xE0nh ph\u1ED1 C\u1EA7n Th\u01A1",
|
|
7809
|
+
96: "T\u1EC9nh C\xE0 Mau"
|
|
7810
|
+
};
|
|
7811
|
+
var VIETNAM_PHONE_REGEX = /^(84|0)(3[2-9]|5[2689]|7[06-9]|8[1-9]|9[0-9])[0-9]{7}$/;
|
|
7812
|
+
function isValidUrl2(val) {
|
|
7813
|
+
return /^(https?:\/\/|data:image\/)/i.test(val);
|
|
7814
|
+
}
|
|
7815
|
+
function validateCreateOaPageRequest(input) {
|
|
7816
|
+
const errors = [];
|
|
7817
|
+
if (!input || typeof input !== "object") {
|
|
7818
|
+
return {
|
|
7819
|
+
isValid: false,
|
|
7820
|
+
errors: ["D\u1EEF li\u1EC7u kh\u1EDFi t\u1EA1o Zalo Official Account ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng (object)."]
|
|
7821
|
+
};
|
|
7822
|
+
}
|
|
7823
|
+
const raw = input;
|
|
7824
|
+
const oaName = typeof raw.oaName === "string" ? raw.oaName.trim() : "";
|
|
7825
|
+
if (!oaName) {
|
|
7826
|
+
errors.push("T\xEAn trang Official Account ('oaName') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
7827
|
+
} else if (oaName.length < 2 || oaName.length > 40) {
|
|
7828
|
+
errors.push(`T\xEAn trang Official Account ph\u1EA3i t\u1EEB 2 \u0111\u1EBFn 40 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${oaName.length} k\xFD t\u1EF1).`);
|
|
7829
|
+
} else {
|
|
7830
|
+
if (oaName.length > 5 && oaName === oaName.toUpperCase() && /[A-Z]/.test(oaName)) {
|
|
7831
|
+
errors.push("T\xEAn trang Official Account kh\xF4ng \u0111\u01B0\u1EE3c vi\u1EBFt in hoa to\xE0n b\u1ED9 c\xE1c t\u1EEB. Vui l\xF2ng vi\u1EBFt theo ng\u1EEF ph\xE1p ti\u1EBFng Vi\u1EC7t chu\u1EA9n.");
|
|
7832
|
+
}
|
|
7833
|
+
const forbiddenKeywords = ["s\u1ED1 1", "nh\u1EA5t vi\u1EC7t nam", "cam k\u1EBFt 100%", "tr\u1ECB d\u1EE9t \u0111i\u1EC3m"];
|
|
7834
|
+
for (const kw of forbiddenKeywords) {
|
|
7835
|
+
if (oaName.toLowerCase().includes(kw)) {
|
|
7836
|
+
errors.push(`T\xEAn trang Official Account ch\u1EE9a t\u1EEB ng\u1EEF cam k\u1EBFt/ph\xF4 tr\u01B0\u01A1ng kh\xF4ng h\u1EE3p l\u1EC7: '${kw}'.`);
|
|
7837
|
+
}
|
|
7838
|
+
}
|
|
7839
|
+
}
|
|
7840
|
+
const description = typeof raw.description === "string" ? raw.description.trim() : "";
|
|
7841
|
+
if (!description) {
|
|
7842
|
+
errors.push("Th\xF4ng tin m\xF4 t\u1EA3 ho\u1EA1t \u0111\u1ED9ng ('description') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
7843
|
+
} else if (description.length < 20 || description.length > 500) {
|
|
7844
|
+
errors.push(`Th\xF4ng tin m\xF4 t\u1EA3 ho\u1EA1t \u0111\u1ED9ng ph\u1EA3i t\u1EEB 20 \u0111\u1EBFn 500 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${description.length} k\xFD t\u1EF1).`);
|
|
7845
|
+
}
|
|
7846
|
+
const contactName = typeof raw.contactName === "string" ? raw.contactName.trim() : "";
|
|
7847
|
+
if (!contactName) {
|
|
7848
|
+
errors.push("H\u1ECD v\xE0 t\xEAn ng\u01B0\u1EDDi li\xEAn h\u1EC7 ('contactName') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
7849
|
+
} else if (contactName.split(/\s+/).length < 2) {
|
|
7850
|
+
errors.push("H\u1ECD v\xE0 t\xEAn ng\u01B0\u1EDDi li\xEAn h\u1EC7 ph\u1EA3i c\xF3 \xEDt nh\u1EA5t 2 t\u1EEB (h\u1ECD v\xE0 t\xEAn).");
|
|
7851
|
+
}
|
|
7852
|
+
const contactPhone = typeof raw.contactPhone === "string" ? raw.contactPhone.trim() : String(raw.contactPhone || "").trim();
|
|
7853
|
+
if (!contactPhone) {
|
|
7854
|
+
errors.push("S\u1ED1 \u0111i\u1EC7n tho\u1EA1i li\xEAn h\u1EC7 ('contactPhone') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
7855
|
+
} else {
|
|
7856
|
+
const cleanPhone = contactPhone.replace(/\s+/g, "");
|
|
7857
|
+
if (!VIETNAM_PHONE_REGEX.test(cleanPhone)) {
|
|
7858
|
+
errors.push(`S\u1ED1 \u0111i\u1EC7n tho\u1EA1i li\xEAn h\u1EC7 '${contactPhone}' kh\xF4ng h\u1EE3p l\u1EC7. Ph\u1EA3i l\xE0 s\u1ED1 di \u0111\u1ED9ng Vi\u1EC7t Nam 10 ch\u1EEF s\u1ED1 (v\xED d\u1EE5: 0901234567 ho\u1EB7c 84901234567).`);
|
|
7859
|
+
}
|
|
7860
|
+
}
|
|
7861
|
+
const subCatId = Number(raw.subCategoryId);
|
|
7862
|
+
if (!subCatId || !ZALO_PROFILE_ADS_SUB_CATEGORIES[subCatId]) {
|
|
7863
|
+
errors.push(
|
|
7864
|
+
`M\xE3 danh m\u1EE5c ho\u1EA1t \u0111\u1ED9ng ('subCategoryId') '${raw.subCategoryId}' kh\xF4ng h\u1EE3p l\u1EC7. Ph\u1EA3i thu\u1ED9c 22 m\xE3 danh m\u1EE5c chu\u1EA9n tr\xEAn Zalo Ads Profile (v\xED d\u1EE5: 10018: C\xF4ng ngh\u1EC7 & Thi\u1EBFt b\u1ECB, 10043: B\u1EA5t \u0111\u1ED9ng s\u1EA3n, 10024: Mua s\u1EAFm & B\xE1n l\u1EBB).`
|
|
7865
|
+
);
|
|
7866
|
+
}
|
|
7867
|
+
const provinceId = Number(raw.province);
|
|
7868
|
+
if (!provinceId || !ZALO_PROFILE_ADS_PROVINCES[provinceId]) {
|
|
7869
|
+
errors.push(
|
|
7870
|
+
`M\xE3 T\u1EC9nh/Th\xE0nh ph\u1ED1 ('province') '${raw.province}' kh\xF4ng h\u1EE3p l\u1EC7. Ph\u1EA3i thu\u1ED9c 34 m\xE3 h\xE0nh ch\xEDnh chu\u1EA9n tr\xEAn Zalo Ads Profile (v\xED d\u1EE5: 1: H\xE0 N\u1ED9i, 79: TP.HCM, 48: \u0110\xE0 N\u1EB5ng).`
|
|
7871
|
+
);
|
|
7872
|
+
}
|
|
7873
|
+
const district = Number(raw.district);
|
|
7874
|
+
if (!district || !Number.isInteger(district) || district <= 0) {
|
|
7875
|
+
errors.push("M\xE3 Ph\u01B0\u1EDDng/X\xE3 ('district') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
7876
|
+
}
|
|
7877
|
+
const address = typeof raw.address === "string" ? raw.address.trim() : "";
|
|
7878
|
+
if (!address || address.length < 5) {
|
|
7879
|
+
errors.push("\u0110\u1ECBa ch\u1EC9 ho\u1EA1t \u0111\u1ED9ng chi ti\u1EBFt ('address') ph\u1EA3i c\xF3 \u0111\u1ED9 d\xE0i t\u1ED1i thi\u1EC3u 5 k\xFD t\u1EF1.");
|
|
7880
|
+
}
|
|
7881
|
+
const avatarId = typeof raw.avatarId === "string" ? raw.avatarId.trim() : "";
|
|
7882
|
+
if (!avatarId) {
|
|
7883
|
+
errors.push("M\xE3 \u0111\u1ECBnh danh \u1EA3nh \u0111\u1EA1i di\u1EC7n ('avatarId') l\xE0 b\u1EAFt bu\u1ED9c. H\xE3y t\u1EA3i \u1EA3nh qua API uploadOaAvatar tr\u01B0\u1EDBc.");
|
|
7884
|
+
}
|
|
7885
|
+
const coverId = typeof raw.coverId === "string" ? raw.coverId.trim() : "";
|
|
7886
|
+
if (!coverId) {
|
|
7887
|
+
errors.push("M\xE3 \u0111\u1ECBnh danh \u1EA3nh b\xECa ('coverId') l\xE0 b\u1EAFt bu\u1ED9c. H\xE3y t\u1EA3i \u1EA3nh qua API uploadOaCover tr\u01B0\u1EDBc.");
|
|
7888
|
+
}
|
|
7889
|
+
const cleanData = {
|
|
7890
|
+
option: "createpage",
|
|
7891
|
+
typeId: raw.typeId !== void 0 ? Number(raw.typeId) : 2,
|
|
7892
|
+
typeName: typeof raw.typeName === "string" ? raw.typeName : "store",
|
|
7893
|
+
tier: raw.tier !== void 0 ? Number(raw.tier) : 0,
|
|
7894
|
+
categoryId: raw.categoryId !== void 0 ? Number(raw.categoryId) : 10003,
|
|
7895
|
+
subCategoryId: subCatId,
|
|
7896
|
+
oaName,
|
|
7897
|
+
description,
|
|
7898
|
+
contactName,
|
|
7899
|
+
contactPhone,
|
|
7900
|
+
avatarId,
|
|
7901
|
+
coverId,
|
|
7902
|
+
province: provinceId,
|
|
7903
|
+
district,
|
|
7904
|
+
address,
|
|
7905
|
+
agreeTerm: raw.agreeTerm !== void 0 ? Boolean(raw.agreeTerm) : true,
|
|
7906
|
+
...typeof raw["crsf-token"] === "string" ? { "crsf-token": raw["crsf-token"] } : {}
|
|
7907
|
+
};
|
|
7908
|
+
return {
|
|
7909
|
+
isValid: errors.length === 0,
|
|
7910
|
+
errors,
|
|
7911
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
7912
|
+
};
|
|
7913
|
+
}
|
|
7914
|
+
function validateUploadMediaRequest(input, options) {
|
|
7915
|
+
const errors = [];
|
|
7916
|
+
if (!input || typeof input !== "object") {
|
|
7917
|
+
return {
|
|
7918
|
+
isValid: false,
|
|
7919
|
+
errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u t\u1EA3i \u1EA3nh l\xEAn ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."]
|
|
7920
|
+
};
|
|
7921
|
+
}
|
|
7922
|
+
const raw = input;
|
|
7923
|
+
const fileField = options.mediaType === "avatar" ? raw["avatar-file"] ?? raw.file ?? raw.File : raw["cover-file"] ?? raw.file ?? raw.File;
|
|
7924
|
+
if (!fileField) {
|
|
7925
|
+
errors.push(`Tr\u01B0\u1EDDng t\u1EC7p \u1EA3nh ('${options.mediaType === "avatar" ? "avatar-file" : "cover-file"}') l\xE0 b\u1EAFt bu\u1ED9c.`);
|
|
7926
|
+
return { isValid: false, errors };
|
|
7927
|
+
}
|
|
7928
|
+
if (typeof fileField === "string") {
|
|
7929
|
+
const trimmed = fileField.trim();
|
|
7930
|
+
if (!trimmed) {
|
|
7931
|
+
errors.push("\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p \u1EA3nh kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
7932
|
+
} else if (!isValidUrl2(trimmed)) {
|
|
7933
|
+
errors.push(`\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p '${trimmed}' kh\xF4ng h\u1EE3p l\u1EC7. Ph\u1EA3i l\xE0 URL HTTP/HTTPS c\xF4ng khai ho\u1EB7c data URL.`);
|
|
7934
|
+
}
|
|
7935
|
+
}
|
|
7936
|
+
const maxBytes = options.maxSizeBytes || 15 * 1024 * 1024;
|
|
7937
|
+
if (typeof raw.sizeBytes === "number" && raw.sizeBytes > maxBytes) {
|
|
7938
|
+
const sizeMb = (raw.sizeBytes / (1024 * 1024)).toFixed(2);
|
|
7939
|
+
errors.push(`Dung l\u01B0\u1EE3ng \u1EA3nh v\u01B0\u1EE3t qu\xE1 gi\u1EDBi h\u1EA1n t\u1ED1i \u0111a 15MB (dung l\u01B0\u1EE3ng: ${sizeMb}MB).`);
|
|
7940
|
+
}
|
|
7941
|
+
const minW = options.minWidth || (options.mediaType === "avatar" ? 150 : 320);
|
|
7942
|
+
const minH = options.minHeight || (options.mediaType === "avatar" ? 150 : 180);
|
|
7943
|
+
if (typeof raw.width === "number" && raw.width < minW) {
|
|
7944
|
+
errors.push(`Chi\u1EC1u r\u1ED9ng \u1EA3nh t\u1ED1i thi\u1EC3u ${minW}px (hi\u1EC7n t\u1EA1i: ${raw.width}px).`);
|
|
7945
|
+
}
|
|
7946
|
+
if (typeof raw.height === "number" && raw.height < minH) {
|
|
7947
|
+
errors.push(`Chi\u1EC1u cao \u1EA3nh t\u1ED1i thi\u1EC3u ${minH}px (hi\u1EC7n t\u1EA1i: ${raw.height}px).`);
|
|
7948
|
+
}
|
|
7949
|
+
return {
|
|
7950
|
+
isValid: errors.length === 0,
|
|
7951
|
+
errors,
|
|
7952
|
+
data: errors.length === 0 ? {
|
|
7953
|
+
file: fileField,
|
|
7954
|
+
isNew: typeof raw["is-new"] === "string" ? raw["is-new"] : "true",
|
|
7955
|
+
option: typeof raw.option === "string" ? raw.option : "update"
|
|
7956
|
+
} : void 0
|
|
7957
|
+
};
|
|
7958
|
+
}
|
|
7959
|
+
var ZaloProfileAdsValidator = {
|
|
7960
|
+
validateCreateOaPage: validateCreateOaPageRequest,
|
|
7961
|
+
validateUploadMedia: validateUploadMediaRequest,
|
|
7962
|
+
validateUploadAvatar: (input) => validateUploadMediaRequest(input, { mediaType: "avatar", minWidth: 150, minHeight: 150 }),
|
|
7963
|
+
validateUploadCover: (input) => validateUploadMediaRequest(input, { mediaType: "cover", minWidth: 320, minHeight: 180 })
|
|
7964
|
+
};
|
|
7965
|
+
|
|
7966
|
+
// src/validators/reports.validator.ts
|
|
7967
|
+
var MAX_REPORT_RANGE_SECONDS = 90 * 86400;
|
|
7968
|
+
var MAX_REPORT_RANGE_MS = MAX_REPORT_RANGE_SECONDS * 1e3;
|
|
7969
|
+
function validateUpsertCustomReportRequest(input) {
|
|
7970
|
+
const errors = [];
|
|
7971
|
+
if (!input || typeof input !== "object") {
|
|
7972
|
+
return {
|
|
7973
|
+
isValid: false,
|
|
7974
|
+
errors: ["D\u1EEF li\u1EC7u c\u1EA5u h\xECnh b\xE1o c\xE1o t\xF9y ch\u1EC9nh ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."]
|
|
7975
|
+
};
|
|
7976
|
+
}
|
|
7977
|
+
const raw = input;
|
|
7978
|
+
let id = 0;
|
|
7979
|
+
if (raw.id !== void 0 && raw.id !== null) {
|
|
7980
|
+
const parsedId = Number(raw.id);
|
|
7981
|
+
if (!Number.isInteger(parsedId) || parsedId < 0) {
|
|
7982
|
+
errors.push("Tr\u01B0\u1EDDng 'id' ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn kh\xF4ng \xE2m (0 khi t\u1EA1o m\u1EDBi, > 0 khi c\u1EADp nh\u1EADt).");
|
|
7983
|
+
} else {
|
|
7984
|
+
id = parsedId;
|
|
7985
|
+
}
|
|
7986
|
+
}
|
|
7987
|
+
const name = typeof raw.name === "string" ? raw.name.trim() : "";
|
|
7988
|
+
if (!name) {
|
|
7989
|
+
errors.push("T\xEAn b\xE1o c\xE1o t\xF9y ch\u1EC9nh ('name') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
7990
|
+
} else if (name.length > 100) {
|
|
7991
|
+
errors.push(`T\xEAn b\xE1o c\xE1o t\xF9y ch\u1EC9nh kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 100 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${name.length} k\xFD t\u1EF1).`);
|
|
7992
|
+
}
|
|
7993
|
+
const settings = [];
|
|
7994
|
+
if (!Array.isArray(raw.settings) || raw.settings.length === 0) {
|
|
7995
|
+
errors.push("Danh s\xE1ch ch\u1EC9 s\u1ED1 c\u1ED9t ('settings') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i c\xF3 \xEDt nh\u1EA5t 1 ch\u1EC9 s\u1ED1.");
|
|
7996
|
+
} else {
|
|
7997
|
+
for (const item of raw.settings) {
|
|
7998
|
+
const colId = Number(item);
|
|
7999
|
+
if (!Number.isInteger(colId) || colId <= 0) {
|
|
8000
|
+
errors.push(`M\xE3 ch\u1EC9 s\u1ED1 c\u1ED9t '${item}' kh\xF4ng h\u1EE3p l\u1EC7. Ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng.`);
|
|
8001
|
+
} else {
|
|
8002
|
+
if (!settings.includes(colId)) {
|
|
8003
|
+
settings.push(colId);
|
|
8004
|
+
}
|
|
8005
|
+
}
|
|
8006
|
+
}
|
|
8007
|
+
}
|
|
8008
|
+
const isDefault = Boolean(raw.isDefault);
|
|
8009
|
+
const cleanData = {
|
|
8010
|
+
id,
|
|
8011
|
+
name,
|
|
8012
|
+
settings,
|
|
8013
|
+
isDefault
|
|
8014
|
+
};
|
|
8015
|
+
return {
|
|
8016
|
+
isValid: errors.length === 0,
|
|
8017
|
+
errors,
|
|
8018
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
8019
|
+
};
|
|
8020
|
+
}
|
|
8021
|
+
function validateDateRangeReportRequest(input) {
|
|
8022
|
+
const errors = [];
|
|
8023
|
+
if (!input || typeof input !== "object") {
|
|
8024
|
+
return {
|
|
8025
|
+
isValid: false,
|
|
8026
|
+
errors: ["Tham s\u1ED1 truy v\u1EA5n kho\u1EA3ng th\u1EDDi gian b\xE1o c\xE1o ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."]
|
|
8027
|
+
};
|
|
8028
|
+
}
|
|
8029
|
+
const raw = input;
|
|
8030
|
+
const rawStart = raw.startDate ?? raw.from;
|
|
8031
|
+
const rawEnd = raw.endDate ?? raw.to;
|
|
8032
|
+
if (rawStart === void 0 || rawStart === null) {
|
|
8033
|
+
errors.push("M\u1ED1c th\u1EDDi gian b\u1EAFt \u0111\u1EA7u ('startDate' ho\u1EB7c 'from') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
8034
|
+
}
|
|
8035
|
+
if (rawEnd === void 0 || rawEnd === null) {
|
|
8036
|
+
errors.push("M\u1ED1c th\u1EDDi gian k\u1EBFt th\xFAc ('endDate' ho\u1EB7c 'to') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
8037
|
+
}
|
|
8038
|
+
if (errors.length > 0) {
|
|
8039
|
+
return { isValid: false, errors };
|
|
8040
|
+
}
|
|
8041
|
+
const startNum = Number(rawStart);
|
|
8042
|
+
const endNum = Number(rawEnd);
|
|
8043
|
+
if (isNaN(startNum) || startNum <= 0) {
|
|
8044
|
+
errors.push(`M\u1ED1c th\u1EDDi gian b\u1EAFt \u0111\u1EA7u '${rawStart}' kh\xF4ng h\u1EE3p l\u1EC7. Ph\u1EA3i l\xE0 Unix timestamp d\u01B0\u01A1ng.`);
|
|
8045
|
+
}
|
|
8046
|
+
if (isNaN(endNum) || endNum <= 0) {
|
|
8047
|
+
errors.push(`M\u1ED1c th\u1EDDi gian k\u1EBFt th\xFAc '${rawEnd}' kh\xF4ng h\u1EE3p l\u1EC7. Ph\u1EA3i l\xE0 Unix timestamp d\u01B0\u01A1ng.`);
|
|
8048
|
+
}
|
|
8049
|
+
if (errors.length > 0) {
|
|
8050
|
+
return { isValid: false, errors };
|
|
8051
|
+
}
|
|
8052
|
+
const isMs = startNum > 1e10 || endNum > 1e10;
|
|
8053
|
+
const maxRange = isMs ? MAX_REPORT_RANGE_MS : MAX_REPORT_RANGE_SECONDS;
|
|
8054
|
+
if (endNum < startNum) {
|
|
8055
|
+
errors.push("M\u1ED1c th\u1EDDi gian k\u1EBFt th\xFAc ph\u1EA3i l\u1EDBn h\u01A1n ho\u1EB7c b\u1EB1ng m\u1ED1c th\u1EDDi gian b\u1EAFt \u0111\u1EA7u.");
|
|
8056
|
+
} else {
|
|
8057
|
+
const diff = endNum - startNum;
|
|
8058
|
+
if (diff > maxRange) {
|
|
8059
|
+
const days = isMs ? Math.round(diff / (86400 * 1e3)) : Math.round(diff / 86400);
|
|
8060
|
+
errors.push(`Kho\u1EA3ng th\u1EDDi gian truy v\u1EA5n b\xE1o c\xE1o kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 90 ng\xE0y theo ch\xEDnh s\xE1ch Zalo Ads (kho\u1EA3ng th\u1EDDi gian hi\u1EC7n t\u1EA1i: ${days} ng\xE0y).`);
|
|
8061
|
+
}
|
|
8062
|
+
}
|
|
8063
|
+
let campaignId;
|
|
8064
|
+
if (raw.campaignId !== void 0 && raw.campaignId !== null) {
|
|
8065
|
+
const parsedCampId = Number(raw.campaignId);
|
|
8066
|
+
if (!Number.isInteger(parsedCampId) || parsedCampId <= 0) {
|
|
8067
|
+
errors.push("M\xE3 chi\u1EBFn d\u1ECBch ('campaignId') ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
8068
|
+
} else {
|
|
8069
|
+
campaignId = parsedCampId;
|
|
8070
|
+
}
|
|
8071
|
+
}
|
|
8072
|
+
const cleanData = {
|
|
8073
|
+
startDate: startNum,
|
|
8074
|
+
endDate: endNum,
|
|
8075
|
+
isMilliseconds: isMs,
|
|
8076
|
+
...campaignId !== void 0 ? { campaignId } : {}
|
|
8077
|
+
};
|
|
8078
|
+
return {
|
|
8079
|
+
isValid: errors.length === 0,
|
|
8080
|
+
errors,
|
|
8081
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
8082
|
+
};
|
|
8083
|
+
}
|
|
8084
|
+
var ZaloReportsValidator = {
|
|
8085
|
+
validateUpsertCustomReport: validateUpsertCustomReportRequest,
|
|
8086
|
+
validateDateRangeReport: validateDateRangeReportRequest
|
|
8087
|
+
};
|
|
8088
|
+
|
|
8089
|
+
// src/validators/media.validator.ts
|
|
8090
|
+
function isValidUrl3(val) {
|
|
8091
|
+
if (typeof val !== "string") return false;
|
|
8092
|
+
return /^https?:\/\/.+/i.test(val.trim());
|
|
8093
|
+
}
|
|
8094
|
+
function validateSaveMediaRequest(input) {
|
|
8095
|
+
const errors = [];
|
|
8096
|
+
if (!input) {
|
|
8097
|
+
return {
|
|
8098
|
+
isValid: false,
|
|
8099
|
+
errors: ["D\u1EEF li\u1EC7u l\u01B0u Media ('saveMedia') kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng."]
|
|
8100
|
+
};
|
|
8101
|
+
}
|
|
8102
|
+
let targetObj = input;
|
|
8103
|
+
if (typeof input === "string") {
|
|
8104
|
+
try {
|
|
8105
|
+
targetObj = JSON.parse(input);
|
|
8106
|
+
} catch {
|
|
8107
|
+
return {
|
|
8108
|
+
isValid: false,
|
|
8109
|
+
errors: ["Chu\u1ED7i JSON d\u1EEF li\u1EC7u Media ('data') kh\xF4ng \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng."]
|
|
8110
|
+
};
|
|
8111
|
+
}
|
|
8112
|
+
}
|
|
8113
|
+
if (!targetObj || typeof targetObj !== "object") {
|
|
8114
|
+
return {
|
|
8115
|
+
isValid: false,
|
|
8116
|
+
errors: ["D\u1EEF li\u1EC7u Media ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."]
|
|
8117
|
+
};
|
|
8118
|
+
}
|
|
8119
|
+
const rawObj = targetObj;
|
|
8120
|
+
let raw = rawObj;
|
|
8121
|
+
if (rawObj.data && typeof rawObj.data === "object") {
|
|
8122
|
+
raw = rawObj.data;
|
|
8123
|
+
} else if (typeof rawObj.data === "string") {
|
|
8124
|
+
try {
|
|
8125
|
+
raw = JSON.parse(rawObj.data);
|
|
8126
|
+
} catch {
|
|
8127
|
+
return {
|
|
8128
|
+
isValid: false,
|
|
8129
|
+
errors: ["Chu\u1ED7i JSON trong tr\u01B0\u1EDDng 'data' kh\xF4ng \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng."]
|
|
8130
|
+
};
|
|
8131
|
+
}
|
|
8132
|
+
}
|
|
8133
|
+
const name = typeof raw.Name === "string" ? raw.Name.trim() : typeof raw.name === "string" ? raw.name.trim() : "";
|
|
8134
|
+
if (!name) {
|
|
8135
|
+
errors.push("T\xEAn t\u1EC7p media ('Name') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
8136
|
+
} else if (name.length > 255) {
|
|
8137
|
+
errors.push(`T\xEAn t\u1EC7p media kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 255 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${name.length} k\xFD t\u1EF1).`);
|
|
8138
|
+
}
|
|
8139
|
+
const typeVal = raw.Type !== void 0 ? Number(raw.Type) : raw.type !== void 0 ? Number(raw.type) : NaN;
|
|
8140
|
+
if (typeVal !== 1 && typeVal !== 2) {
|
|
8141
|
+
errors.push(`Lo\u1EA1i media ('Type') kh\xF4ng h\u1EE3p l\u1EC7: '${raw.Type ?? raw.type}'. Ch\u1EC9 h\u1ED7 tr\u1EE3 1 (\u1EA2nh) ho\u1EB7c 2 (Video).`);
|
|
8142
|
+
}
|
|
8143
|
+
const rawSettings = raw.Settings ?? raw.settings;
|
|
8144
|
+
if (!rawSettings || typeof rawSettings !== "object") {
|
|
8145
|
+
errors.push("C\u1EA5u h\xECnh t\u1EC7p media ('Settings') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
8146
|
+
return { isValid: false, errors };
|
|
8147
|
+
}
|
|
8148
|
+
const url = typeof rawSettings.Url === "string" ? rawSettings.Url.trim() : typeof rawSettings.url === "string" ? rawSettings.url.trim() : "";
|
|
8149
|
+
if (!url) {
|
|
8150
|
+
errors.push("\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p media ('Settings.Url') l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
8151
|
+
} else if (!isValidUrl3(url)) {
|
|
8152
|
+
errors.push(`\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p media ('Settings.Url') kh\xF4ng h\u1EE3p l\u1EC7: '${url}'. Ph\u1EA3i l\xE0 URL HTTP ho\u1EB7c HTTPS b\u1EAFt \u0111\u1EA7u b\u1EB1ng http:// ho\u1EB7c https://.`);
|
|
8153
|
+
}
|
|
8154
|
+
const width = Number(rawSettings.Width ?? rawSettings.width);
|
|
8155
|
+
if (!Number.isInteger(width) || width <= 0) {
|
|
8156
|
+
errors.push(`Chi\u1EC1u r\u1ED9ng t\u1EC7p media ('Settings.Width') ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0). Hi\u1EC7n t\u1EA1i: ${rawSettings.Width ?? rawSettings.width}`);
|
|
8157
|
+
}
|
|
8158
|
+
const height = Number(rawSettings.Height ?? rawSettings.height);
|
|
8159
|
+
if (!Number.isInteger(height) || height <= 0) {
|
|
8160
|
+
errors.push(`Chi\u1EC1u cao t\u1EC7p media ('Settings.Height') ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0). Hi\u1EC7n t\u1EA1i: ${rawSettings.Height ?? rawSettings.height}`);
|
|
8161
|
+
}
|
|
8162
|
+
let duration;
|
|
8163
|
+
let thumbUrl;
|
|
8164
|
+
if (typeVal === 2) {
|
|
8165
|
+
const dur = Number(rawSettings.Duration ?? rawSettings.duration);
|
|
8166
|
+
if (!isNaN(dur) && dur > 0) {
|
|
8167
|
+
if (dur > 600) {
|
|
8168
|
+
errors.push(`Th\u1EDDi l\u01B0\u1EE3ng video ('Settings.Duration') kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 600 gi\xE2y (hi\u1EC7n t\u1EA1i: ${dur}s).`);
|
|
8169
|
+
} else {
|
|
8170
|
+
duration = dur;
|
|
8171
|
+
}
|
|
8172
|
+
} else {
|
|
8173
|
+
errors.push("V\u1EDBi lo\u1EA1i media Video (Type = 2), th\u1EDDi l\u01B0\u1EE3ng video ('Settings.Duration') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 d\u01B0\u01A1ng (> 0).");
|
|
8174
|
+
}
|
|
8175
|
+
const thumb = typeof rawSettings.ThumbUrl === "string" ? rawSettings.ThumbUrl.trim() : typeof rawSettings.thumbUrl === "string" ? rawSettings.thumbUrl.trim() : "";
|
|
8176
|
+
if (thumb) {
|
|
8177
|
+
if (!isValidUrl3(thumb)) {
|
|
8178
|
+
errors.push(`\u1EA2nh thu nh\u1ECF c\u1EE7a video ('Settings.ThumbUrl') kh\xF4ng h\u1EE3p l\u1EC7: '${thumb}'. Ph\u1EA3i l\xE0 URL HTTP/HTTPS.`);
|
|
8179
|
+
} else {
|
|
8180
|
+
thumbUrl = thumb;
|
|
8181
|
+
}
|
|
8182
|
+
}
|
|
8183
|
+
}
|
|
8184
|
+
const cleanData = {
|
|
8185
|
+
Name: name,
|
|
8186
|
+
Type: typeVal,
|
|
8187
|
+
Settings: {
|
|
8188
|
+
Url: url,
|
|
8189
|
+
Width: width,
|
|
8190
|
+
Height: height,
|
|
8191
|
+
...duration !== void 0 ? { Duration: duration } : {},
|
|
8192
|
+
...thumbUrl !== void 0 ? { ThumbUrl: thumbUrl } : {}
|
|
8193
|
+
}
|
|
8194
|
+
};
|
|
8195
|
+
return {
|
|
8196
|
+
isValid: errors.length === 0,
|
|
8197
|
+
errors,
|
|
8198
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
8199
|
+
};
|
|
8200
|
+
}
|
|
8201
|
+
var ZaloMediaValidator = {
|
|
8202
|
+
validateSaveMedia: validateSaveMediaRequest
|
|
8203
|
+
};
|
|
7477
8204
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7478
8205
|
0 && (module.exports = {
|
|
7479
8206
|
ALLOWED_CTAS_PER_AD_TYPE,
|
|
@@ -7486,12 +8213,17 @@ var ZaloConversionsValidator = class {
|
|
|
7486
8213
|
AutomatedRuleTimeRangeEnum,
|
|
7487
8214
|
ConversionLabelEnum,
|
|
7488
8215
|
ConversionUrlTypeEnum,
|
|
8216
|
+
MAX_REPORT_RANGE_MS,
|
|
8217
|
+
MAX_REPORT_RANGE_SECONDS,
|
|
7489
8218
|
MemoryZaloSessionStore,
|
|
7490
8219
|
RedisZaloSessionStore,
|
|
7491
8220
|
TieredZaloSessionStore,
|
|
7492
8221
|
VALID_AD_TYPES,
|
|
7493
8222
|
VALID_CAMPAIGN_TYPES,
|
|
8223
|
+
VIETNAM_PHONE_REGEX,
|
|
7494
8224
|
ZALO_NEW_REGION_PROVINCE_CODES,
|
|
8225
|
+
ZALO_PROFILE_ADS_PROVINCES,
|
|
8226
|
+
ZALO_PROFILE_ADS_SUB_CATEGORIES,
|
|
7495
8227
|
ZALO_PROVINCE_MERGE_MAPPING,
|
|
7496
8228
|
ZALO_REGION_PROVINCE_CODES,
|
|
7497
8229
|
ZaloAccountService,
|
|
@@ -7545,8 +8277,11 @@ var ZaloConversionsValidator = class {
|
|
|
7545
8277
|
ZaloInstantPagesService,
|
|
7546
8278
|
ZaloInstantPagesValidator,
|
|
7547
8279
|
ZaloMediaService,
|
|
8280
|
+
ZaloMediaValidator,
|
|
7548
8281
|
ZaloProfileAdsService,
|
|
8282
|
+
ZaloProfileAdsValidator,
|
|
7549
8283
|
ZaloReportsService,
|
|
8284
|
+
ZaloReportsValidator,
|
|
7550
8285
|
ZaloSdkError,
|
|
7551
8286
|
ZaloSdkHttpClient,
|
|
7552
8287
|
ZaloWidgetApiService,
|
|
@@ -7559,6 +8294,7 @@ var ZaloConversionsValidator = class {
|
|
|
7559
8294
|
validateChangeCampaignStatusParams,
|
|
7560
8295
|
validateCloneInstantPageRequest,
|
|
7561
8296
|
validateCreateCampaignPayload,
|
|
8297
|
+
validateCreateCustomAudienceRequest,
|
|
7562
8298
|
validateCreateFlowRequest,
|
|
7563
8299
|
validateCreateFormEventAudienceRequest,
|
|
7564
8300
|
validateCreateFormRequest,
|
|
@@ -7566,8 +8302,11 @@ var ZaloConversionsValidator = class {
|
|
|
7566
8302
|
validateCreateLookalikeAudienceRequest,
|
|
7567
8303
|
validateCreateMessageOaEventAudienceRequest,
|
|
7568
8304
|
validateCreateMessagePersonalEventAudienceRequest,
|
|
8305
|
+
validateCreateOaPageRequest,
|
|
7569
8306
|
validateCreatePhoneAudienceRequest,
|
|
7570
8307
|
validateCreateSavedAudienceRequest,
|
|
8308
|
+
validateCropCoordinates,
|
|
8309
|
+
validateDateRangeReportRequest,
|
|
7571
8310
|
validateDuplicateAdParams,
|
|
7572
8311
|
validateEstimateAudienceRequest,
|
|
7573
8312
|
validateGetInstantPageDetailRequest,
|
|
@@ -7583,10 +8322,17 @@ var ZaloConversionsValidator = class {
|
|
|
7583
8322
|
validateListMiniPageTemplatesRequest,
|
|
7584
8323
|
validateListOfficialAccountsRequest,
|
|
7585
8324
|
validateRenameCampaignParams,
|
|
8325
|
+
validateSaveMediaRequest,
|
|
7586
8326
|
validateSearchInstantPagesRequest,
|
|
8327
|
+
validateToggleLeadNotificationRequest,
|
|
7587
8328
|
validateUpdateAdPayload,
|
|
7588
8329
|
validateUpdateFlowRequest,
|
|
7589
8330
|
validateUpdateInstantPageRequest,
|
|
8331
|
+
validateUpdateInstantPageSharesRequest,
|
|
8332
|
+
validateUpdateLeadNotificationIntervalRequest,
|
|
8333
|
+
validateUploadCustomAudiencePhoneListRequest,
|
|
8334
|
+
validateUploadMediaRequest,
|
|
8335
|
+
validateUpsertCustomReportRequest,
|
|
7590
8336
|
validateUpsertInstantPageFormRequest
|
|
7591
8337
|
});
|
|
7592
8338
|
//# sourceMappingURL=index.js.map
|