@redonvn/zalo-ads-sdk 0.2.14 → 0.2.16

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.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
@@ -3352,6 +3525,18 @@ var OP_ZaloAdsListAgencyCustomersWithBudget = {
3352
3525
  "cookieFields": [],
3353
3526
  "bodyFields": []
3354
3527
  };
3528
+ var OP_ZaloAdsGetApiBaAgencyEmployees = {
3529
+ "operationId": "ZaloAds_getApiBaAgencyEmployees",
3530
+ "method": "GET",
3531
+ "endpoint": "/api/ba/agency/employees",
3532
+ "baseUrl": "https://ads.zalo.me",
3533
+ "binaryFields": [],
3534
+ "pathFields": [],
3535
+ "queryFields": [],
3536
+ "headerFields": [],
3537
+ "cookieFields": [],
3538
+ "bodyFields": []
3539
+ };
3355
3540
  var OP_ZaloAdsGetApiNotifiesHeader = {
3356
3541
  "operationId": "ZaloAds_getApiNotifiesHeader",
3357
3542
  "method": "GET",
@@ -3401,6 +3586,9 @@ var ZaloAccountService = class {
3401
3586
  };
3402
3587
  return this.client.requestWithoutBody(OP_ZaloAdsListAgencyCustomersWithBudget, this.client.toTransportInput(OP_ZaloAdsListAgencyCustomersWithBudget, normalized), options);
3403
3588
  }
3589
+ getApiBaAgencyEmployees(request = {}, options) {
3590
+ return this.client.requestWithoutBody(OP_ZaloAdsGetApiBaAgencyEmployees, this.client.toTransportInput(OP_ZaloAdsGetApiBaAgencyEmployees, request), options);
3591
+ }
3404
3592
  getApiNotifiesHeader(request = {}, options) {
3405
3593
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiNotifiesHeader, this.client.toTransportInput(OP_ZaloAdsGetApiNotifiesHeader, request), options);
3406
3594
  }
@@ -3423,6 +3611,10 @@ var ZaloAccountService = class {
3423
3611
  getBaAccountAllGrantedMembers(...args) {
3424
3612
  return this.getApiBaAccountAllgrantedmembers(...args);
3425
3613
  }
3614
+ /** Danh sách nhân viên trực thuộc Agency */
3615
+ getBaAgencyEmployees(...args) {
3616
+ return this.getApiBaAgencyEmployees(...args);
3617
+ }
3426
3618
  /** Thông báo trên thanh tiêu đề */
3427
3619
  getNotifiesHeader(...args) {
3428
3620
  return this.getApiNotifiesHeader(...args);
@@ -5164,6 +5356,12 @@ var ZaloAdsService = class extends ZaloCampaignsService {
5164
5356
  listAgencyCustomersWithBudget(request = { limit: 15, offset: 0, joinDateAsc: true }, options) {
5165
5357
  return this.account.listAgencyCustomersWithBudget(request, options);
5166
5358
  }
5359
+ getApiBaAgencyEmployees(request = {}, options) {
5360
+ return this.account.getApiBaAgencyEmployees(request, options);
5361
+ }
5362
+ getBaAgencyEmployees(...args) {
5363
+ return this.account.getBaAgencyEmployees(...args);
5364
+ }
5167
5365
  getApiNotifiesHeader(request = {}, options) {
5168
5366
  return this.account.getApiNotifiesHeader(request, options);
5169
5367
  }
@@ -5666,10 +5864,60 @@ function validateListFormLeadsRequest(input) {
5666
5864
  } : void 0
5667
5865
  };
5668
5866
  }
5867
+ function validateToggleLeadNotificationRequest(input) {
5868
+ const errors = [];
5869
+ if (!input || typeof input !== "object") {
5870
+ return {
5871
+ isValid: false,
5872
+ 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."]
5873
+ };
5874
+ }
5875
+ const raw = input;
5876
+ const formId = typeof raw.formId === "string" ? raw.formId.trim() : raw.formId ? String(raw.formId).trim() : "";
5877
+ if (!formId) {
5878
+ 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.");
5879
+ }
5880
+ return {
5881
+ isValid: errors.length === 0,
5882
+ errors,
5883
+ data: errors.length === 0 ? { formId } : void 0
5884
+ };
5885
+ }
5886
+ function validateUpdateLeadNotificationIntervalRequest(input) {
5887
+ const errors = [];
5888
+ if (!input || typeof input !== "object") {
5889
+ return {
5890
+ isValid: false,
5891
+ 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."]
5892
+ };
5893
+ }
5894
+ const raw = input;
5895
+ const oaId = typeof raw.oaId === "string" ? raw.oaId.trim() : raw.oaId ? String(raw.oaId).trim() : "";
5896
+ const formId = typeof raw.formId === "string" ? raw.formId.trim() : raw.formId ? String(raw.formId).trim() : "";
5897
+ if (!oaId) {
5898
+ errors.push("M\xE3 Official Account ('oaId') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
5899
+ }
5900
+ if (!formId) {
5901
+ 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.");
5902
+ }
5903
+ const interval = Number(raw.interval);
5904
+ if (isNaN(interval) || ![0, 1, 6].includes(interval)) {
5905
+ 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).`);
5906
+ }
5907
+ return {
5908
+ isValid: errors.length === 0,
5909
+ errors,
5910
+ data: errors.length === 0 ? { oaId, formId, interval } : void 0
5911
+ };
5912
+ }
5669
5913
  var ZaloFormsValidator = {
5670
5914
  createForm: validateCreateFormRequest,
5671
5915
  listFormsByOfficialAccount: validateListFormsByOfficialAccountRequest,
5672
- listFormLeads: validateListFormLeadsRequest
5916
+ listFormLeads: validateListFormLeadsRequest,
5917
+ enableLeadNotification: validateToggleLeadNotificationRequest,
5918
+ disableLeadNotification: validateToggleLeadNotificationRequest,
5919
+ updateLeadNotificationInterval: validateUpdateLeadNotificationIntervalRequest,
5920
+ validateLeadNotificationInterval: validateUpdateLeadNotificationIntervalRequest
5673
5921
  };
5674
5922
 
5675
5923
  // src/services/forms.service.ts
@@ -6377,6 +6625,53 @@ function validateUpsertInstantPageFormRequest(input) {
6377
6625
  data: errors.length === 0 ? data : void 0
6378
6626
  };
6379
6627
  }
6628
+ function validateUpdateInstantPageSharesRequest(input) {
6629
+ const errors = [];
6630
+ if (!input || typeof input !== "object") {
6631
+ return {
6632
+ isValid: false,
6633
+ 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."]
6634
+ };
6635
+ }
6636
+ const obj = input;
6637
+ if (!isPositiveInteger2(obj.instantPageId)) {
6638
+ 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).");
6639
+ }
6640
+ if (!Array.isArray(obj.shares) || obj.shares.length === 0) {
6641
+ 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).");
6642
+ } else {
6643
+ const validPermissions = [1, 2, 3, 4];
6644
+ const seenUserIds = /* @__PURE__ */ new Set();
6645
+ obj.shares.forEach((item, idx) => {
6646
+ if (!item || typeof item !== "object") {
6647
+ 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.`);
6648
+ return;
6649
+ }
6650
+ const share = item;
6651
+ const userId = Number(share.userId);
6652
+ if (!Number.isInteger(userId) || userId <= 0) {
6653
+ 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}).`);
6654
+ } else if (seenUserIds.has(userId)) {
6655
+ 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.`);
6656
+ } else {
6657
+ seenUserIds.add(userId);
6658
+ }
6659
+ const permission = Number(share.permission);
6660
+ if (!validPermissions.includes(permission)) {
6661
+ 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).`);
6662
+ }
6663
+ });
6664
+ }
6665
+ const cleanData = {
6666
+ instantPageId: toPositiveInteger2(obj.instantPageId),
6667
+ shares: obj.shares || []
6668
+ };
6669
+ return {
6670
+ isValid: errors.length === 0,
6671
+ errors,
6672
+ data: errors.length === 0 ? cleanData : void 0
6673
+ };
6674
+ }
6380
6675
  var ZaloInstantPagesValidator = {
6381
6676
  validateCreateInstantPage: validateCreateInstantPageRequest,
6382
6677
  validateCloneInstantPage: validateCloneInstantPageRequest,
@@ -6385,6 +6680,8 @@ var ZaloInstantPagesValidator = {
6385
6680
  validateListInstantPageEditHistory: validateListInstantPageEditHistoryRequest,
6386
6681
  validateListInstantPageFormRecords: validateListInstantPageFormRecordsRequest,
6387
6682
  validateListInstantPageShares: validateListInstantPageSharesRequest,
6683
+ validateUpdateInstantPageShares: validateUpdateInstantPageSharesRequest,
6684
+ validateUpdateShares: validateUpdateInstantPageSharesRequest,
6388
6685
  validateListInstantPageUsers: validateListInstantPageUsersRequest,
6389
6686
  validateListMiniPageTemplates: validateListMiniPageTemplatesRequest,
6390
6687
  validateSearchInstantPages: validateSearchInstantPagesRequest,
@@ -7474,6 +7771,461 @@ var ZaloConversionsValidator = class {
7474
7771
  };
7475
7772
  }
7476
7773
  };
7774
+
7775
+ // src/validators/profile-ads.validator.ts
7776
+ var ZALO_PROFILE_ADS_SUB_CATEGORIES = {
7777
+ 10043: "B\u1EA5t \u0111\u1ED9ng s\u1EA3n",
7778
+ 10018: "C\xF4ng ngh\u1EC7 & Thi\u1EBFt b\u1ECB",
7779
+ 10097: "D\u1ECBch v\u1EE5 ti\u1EC7n \xEDch",
7780
+ 10020: "Du l\u1ECBch & L\u01B0u tr\xFA",
7781
+ 10021: "Gi\xE1o d\u1EE5c & \u0110\xE0o t\u1EA1o",
7782
+ 10024: "Mua s\u1EAFm & B\xE1n l\u1EBB",
7783
+ 10019: "M\u1EF9 ph\u1EA9m & L\xE0m \u0111\u1EB9p",
7784
+ 10014: "Nh\xE0 h\xE0ng & Qu\xE1n",
7785
+ 10094: "\xD4 t\xF4 & Xe m\xE1y",
7786
+ 10098: "S\u1EA3n xu\u1EA5t & Ch\u1EBF t\u1EA1o",
7787
+ 10044: "T\xE0i ch\xEDnh & Ng\xE2n h\xE0ng",
7788
+ 10099: "Thi\u1EBFt k\u1EBF & Thi c\xF4ng",
7789
+ 10017: "Th\u1EDDi trang & May m\u1EB7c",
7790
+ 10023: "Th\u1EF1c ph\u1EA9m & \u0110\u1ED3 u\u1ED1ng",
7791
+ 10016: "Truy\u1EC1n th\xF4ng & Gi\u1EA3i tr\xED",
7792
+ 10092: "Truy\u1EC1n th\xF4ng n\u1ED9i b\u1ED9",
7793
+ 10101: "Tuy\u1EC3n d\u1EE5ng & Vi\u1EC7c l\xE0m",
7794
+ 10100: "T\u01B0 v\u1EA5n & Qu\u1EA3n l\xFD",
7795
+ 10095: "V\u1EADn t\u1EA3i",
7796
+ 10093: "Vi\u1EC5n th\xF4ng",
7797
+ 10022: "Y t\u1EBF & D\u01B0\u1EE3c ph\u1EA9m",
7798
+ 10025: "D\u1ECBch v\u1EE5 kh\xE1c"
7799
+ };
7800
+ var ZALO_PROFILE_ADS_PROVINCES = {
7801
+ 1: "Th\xE0nh ph\u1ED1 H\xE0 N\u1ED9i",
7802
+ 4: "T\u1EC9nh Cao B\u1EB1ng",
7803
+ 8: "T\u1EC9nh Tuy\xEAn Quang",
7804
+ 11: "T\u1EC9nh \u0110i\u1EC7n Bi\xEAn",
7805
+ 12: "T\u1EC9nh Lai Ch\xE2u",
7806
+ 14: "T\u1EC9nh S\u01A1n La",
7807
+ 15: "T\u1EC9nh L\xE0o Cai",
7808
+ 19: "T\u1EC9nh Th\xE1i Nguy\xEAn",
7809
+ 20: "T\u1EC9nh L\u1EA1ng S\u01A1n",
7810
+ 22: "T\u1EC9nh Qu\u1EA3ng Ninh",
7811
+ 24: "T\u1EC9nh B\u1EAFc Ninh",
7812
+ 25: "T\u1EC9nh Ph\xFA Th\u1ECD",
7813
+ 31: "Th\xE0nh ph\u1ED1 H\u1EA3i Ph\xF2ng",
7814
+ 33: "T\u1EC9nh H\u01B0ng Y\xEAn",
7815
+ 37: "T\u1EC9nh Ninh B\xECnh",
7816
+ 38: "T\u1EC9nh Thanh H\xF3a",
7817
+ 40: "T\u1EC9nh Ngh\u1EC7 An",
7818
+ 42: "T\u1EC9nh H\xE0 T\u0129nh",
7819
+ 44: "T\u1EC9nh Qu\u1EA3ng Tr\u1ECB",
7820
+ 46: "Th\xE0nh ph\u1ED1 Hu\u1EBF",
7821
+ 48: "Th\xE0nh ph\u1ED1 \u0110\xE0 N\u1EB5ng",
7822
+ 51: "T\u1EC9nh Qu\u1EA3ng Ng\xE3i",
7823
+ 52: "T\u1EC9nh Gia Lai",
7824
+ 56: "T\u1EC9nh Kh\xE1nh H\xF2a",
7825
+ 66: "T\u1EC9nh \u0110\u1EAFk L\u1EAFk",
7826
+ 68: "T\u1EC9nh L\xE2m \u0110\u1ED3ng",
7827
+ 75: "T\u1EC9nh \u0110\u1ED3ng Nai",
7828
+ 79: "Th\xE0nh ph\u1ED1 H\u1ED3 Ch\xED Minh",
7829
+ 80: "T\u1EC9nh T\xE2y Ninh",
7830
+ 82: "T\u1EC9nh \u0110\u1ED3ng Th\xE1p",
7831
+ 86: "T\u1EC9nh V\u0129nh Long",
7832
+ 91: "T\u1EC9nh An Giang",
7833
+ 92: "Th\xE0nh ph\u1ED1 C\u1EA7n Th\u01A1",
7834
+ 96: "T\u1EC9nh C\xE0 Mau"
7835
+ };
7836
+ var VIETNAM_PHONE_REGEX = /^(84|0)(3[2-9]|5[2689]|7[06-9]|8[1-9]|9[0-9])[0-9]{7}$/;
7837
+ function isValidUrl2(val) {
7838
+ return /^(https?:\/\/|data:image\/)/i.test(val);
7839
+ }
7840
+ function validateCreateOaPageRequest(input) {
7841
+ const errors = [];
7842
+ if (!input || typeof input !== "object") {
7843
+ return {
7844
+ isValid: false,
7845
+ errors: ["D\u1EEF li\u1EC7u kh\u1EDFi t\u1EA1o Zalo Official Account ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng (object)."]
7846
+ };
7847
+ }
7848
+ const raw = input;
7849
+ const oaName = typeof raw.oaName === "string" ? raw.oaName.trim() : "";
7850
+ if (!oaName) {
7851
+ 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.");
7852
+ } else if (oaName.length < 2 || oaName.length > 40) {
7853
+ 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).`);
7854
+ } else {
7855
+ if (oaName.length > 5 && oaName === oaName.toUpperCase() && /[A-Z]/.test(oaName)) {
7856
+ 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.");
7857
+ }
7858
+ const forbiddenKeywords = ["s\u1ED1 1", "nh\u1EA5t vi\u1EC7t nam", "cam k\u1EBFt 100%", "tr\u1ECB d\u1EE9t \u0111i\u1EC3m"];
7859
+ for (const kw of forbiddenKeywords) {
7860
+ if (oaName.toLowerCase().includes(kw)) {
7861
+ 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}'.`);
7862
+ }
7863
+ }
7864
+ }
7865
+ const description = typeof raw.description === "string" ? raw.description.trim() : "";
7866
+ if (!description) {
7867
+ errors.push("Th\xF4ng tin m\xF4 t\u1EA3 ho\u1EA1t \u0111\u1ED9ng ('description') l\xE0 b\u1EAFt bu\u1ED9c.");
7868
+ } else if (description.length < 20 || description.length > 500) {
7869
+ 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).`);
7870
+ }
7871
+ const contactName = typeof raw.contactName === "string" ? raw.contactName.trim() : "";
7872
+ if (!contactName) {
7873
+ errors.push("H\u1ECD v\xE0 t\xEAn ng\u01B0\u1EDDi li\xEAn h\u1EC7 ('contactName') l\xE0 b\u1EAFt bu\u1ED9c.");
7874
+ } else if (contactName.split(/\s+/).length < 2) {
7875
+ 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).");
7876
+ }
7877
+ const contactPhone = typeof raw.contactPhone === "string" ? raw.contactPhone.trim() : String(raw.contactPhone || "").trim();
7878
+ if (!contactPhone) {
7879
+ errors.push("S\u1ED1 \u0111i\u1EC7n tho\u1EA1i li\xEAn h\u1EC7 ('contactPhone') l\xE0 b\u1EAFt bu\u1ED9c.");
7880
+ } else {
7881
+ const cleanPhone = contactPhone.replace(/\s+/g, "");
7882
+ if (!VIETNAM_PHONE_REGEX.test(cleanPhone)) {
7883
+ 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).`);
7884
+ }
7885
+ }
7886
+ const subCatId = Number(raw.subCategoryId);
7887
+ if (!subCatId || !ZALO_PROFILE_ADS_SUB_CATEGORIES[subCatId]) {
7888
+ errors.push(
7889
+ `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).`
7890
+ );
7891
+ }
7892
+ const provinceId = Number(raw.province);
7893
+ if (!provinceId || !ZALO_PROFILE_ADS_PROVINCES[provinceId]) {
7894
+ errors.push(
7895
+ `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).`
7896
+ );
7897
+ }
7898
+ const district = Number(raw.district);
7899
+ if (!district || !Number.isInteger(district) || district <= 0) {
7900
+ 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).");
7901
+ }
7902
+ const address = typeof raw.address === "string" ? raw.address.trim() : "";
7903
+ if (!address || address.length < 5) {
7904
+ 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.");
7905
+ }
7906
+ const avatarId = typeof raw.avatarId === "string" ? raw.avatarId.trim() : "";
7907
+ if (!avatarId) {
7908
+ 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.");
7909
+ }
7910
+ const coverId = typeof raw.coverId === "string" ? raw.coverId.trim() : "";
7911
+ if (!coverId) {
7912
+ 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.");
7913
+ }
7914
+ const cleanData = {
7915
+ option: "createpage",
7916
+ typeId: raw.typeId !== void 0 ? Number(raw.typeId) : 2,
7917
+ typeName: typeof raw.typeName === "string" ? raw.typeName : "store",
7918
+ tier: raw.tier !== void 0 ? Number(raw.tier) : 0,
7919
+ categoryId: raw.categoryId !== void 0 ? Number(raw.categoryId) : 10003,
7920
+ subCategoryId: subCatId,
7921
+ oaName,
7922
+ description,
7923
+ contactName,
7924
+ contactPhone,
7925
+ avatarId,
7926
+ coverId,
7927
+ province: provinceId,
7928
+ district,
7929
+ address,
7930
+ agreeTerm: raw.agreeTerm !== void 0 ? Boolean(raw.agreeTerm) : true,
7931
+ ...typeof raw["crsf-token"] === "string" ? { "crsf-token": raw["crsf-token"] } : {}
7932
+ };
7933
+ return {
7934
+ isValid: errors.length === 0,
7935
+ errors,
7936
+ data: errors.length === 0 ? cleanData : void 0
7937
+ };
7938
+ }
7939
+ function validateUploadMediaRequest(input, options) {
7940
+ const errors = [];
7941
+ if (!input || typeof input !== "object") {
7942
+ return {
7943
+ isValid: false,
7944
+ 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."]
7945
+ };
7946
+ }
7947
+ const raw = input;
7948
+ const fileField = options.mediaType === "avatar" ? raw["avatar-file"] ?? raw.file ?? raw.File : raw["cover-file"] ?? raw.file ?? raw.File;
7949
+ if (!fileField) {
7950
+ errors.push(`Tr\u01B0\u1EDDng t\u1EC7p \u1EA3nh ('${options.mediaType === "avatar" ? "avatar-file" : "cover-file"}') l\xE0 b\u1EAFt bu\u1ED9c.`);
7951
+ return { isValid: false, errors };
7952
+ }
7953
+ if (typeof fileField === "string") {
7954
+ const trimmed = fileField.trim();
7955
+ if (!trimmed) {
7956
+ errors.push("\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p \u1EA3nh kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
7957
+ } else if (!isValidUrl2(trimmed)) {
7958
+ 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.`);
7959
+ }
7960
+ }
7961
+ const maxBytes = options.maxSizeBytes || 15 * 1024 * 1024;
7962
+ if (typeof raw.sizeBytes === "number" && raw.sizeBytes > maxBytes) {
7963
+ const sizeMb = (raw.sizeBytes / (1024 * 1024)).toFixed(2);
7964
+ 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).`);
7965
+ }
7966
+ const minW = options.minWidth || (options.mediaType === "avatar" ? 150 : 320);
7967
+ const minH = options.minHeight || (options.mediaType === "avatar" ? 150 : 180);
7968
+ if (typeof raw.width === "number" && raw.width < minW) {
7969
+ errors.push(`Chi\u1EC1u r\u1ED9ng \u1EA3nh t\u1ED1i thi\u1EC3u ${minW}px (hi\u1EC7n t\u1EA1i: ${raw.width}px).`);
7970
+ }
7971
+ if (typeof raw.height === "number" && raw.height < minH) {
7972
+ errors.push(`Chi\u1EC1u cao \u1EA3nh t\u1ED1i thi\u1EC3u ${minH}px (hi\u1EC7n t\u1EA1i: ${raw.height}px).`);
7973
+ }
7974
+ return {
7975
+ isValid: errors.length === 0,
7976
+ errors,
7977
+ data: errors.length === 0 ? {
7978
+ file: fileField,
7979
+ isNew: typeof raw["is-new"] === "string" ? raw["is-new"] : "true",
7980
+ option: typeof raw.option === "string" ? raw.option : "update"
7981
+ } : void 0
7982
+ };
7983
+ }
7984
+ var ZaloProfileAdsValidator = {
7985
+ validateCreateOaPage: validateCreateOaPageRequest,
7986
+ validateUploadMedia: validateUploadMediaRequest,
7987
+ validateUploadAvatar: (input) => validateUploadMediaRequest(input, { mediaType: "avatar", minWidth: 150, minHeight: 150 }),
7988
+ validateUploadCover: (input) => validateUploadMediaRequest(input, { mediaType: "cover", minWidth: 320, minHeight: 180 })
7989
+ };
7990
+
7991
+ // src/validators/reports.validator.ts
7992
+ var MAX_REPORT_RANGE_SECONDS = 90 * 86400;
7993
+ var MAX_REPORT_RANGE_MS = MAX_REPORT_RANGE_SECONDS * 1e3;
7994
+ function validateUpsertCustomReportRequest(input) {
7995
+ const errors = [];
7996
+ if (!input || typeof input !== "object") {
7997
+ return {
7998
+ isValid: false,
7999
+ 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."]
8000
+ };
8001
+ }
8002
+ const raw = input;
8003
+ let id = 0;
8004
+ if (raw.id !== void 0 && raw.id !== null) {
8005
+ const parsedId = Number(raw.id);
8006
+ if (!Number.isInteger(parsedId) || parsedId < 0) {
8007
+ 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).");
8008
+ } else {
8009
+ id = parsedId;
8010
+ }
8011
+ }
8012
+ const name = typeof raw.name === "string" ? raw.name.trim() : "";
8013
+ if (!name) {
8014
+ 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.");
8015
+ } else if (name.length > 100) {
8016
+ 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).`);
8017
+ }
8018
+ const settings = [];
8019
+ if (!Array.isArray(raw.settings) || raw.settings.length === 0) {
8020
+ 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.");
8021
+ } else {
8022
+ for (const item of raw.settings) {
8023
+ const colId = Number(item);
8024
+ if (!Number.isInteger(colId) || colId <= 0) {
8025
+ 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.`);
8026
+ } else {
8027
+ if (!settings.includes(colId)) {
8028
+ settings.push(colId);
8029
+ }
8030
+ }
8031
+ }
8032
+ }
8033
+ const isDefault = Boolean(raw.isDefault);
8034
+ const cleanData = {
8035
+ id,
8036
+ name,
8037
+ settings,
8038
+ isDefault
8039
+ };
8040
+ return {
8041
+ isValid: errors.length === 0,
8042
+ errors,
8043
+ data: errors.length === 0 ? cleanData : void 0
8044
+ };
8045
+ }
8046
+ function validateDateRangeReportRequest(input) {
8047
+ const errors = [];
8048
+ if (!input || typeof input !== "object") {
8049
+ return {
8050
+ isValid: false,
8051
+ 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."]
8052
+ };
8053
+ }
8054
+ const raw = input;
8055
+ const rawStart = raw.startDate ?? raw.from;
8056
+ const rawEnd = raw.endDate ?? raw.to;
8057
+ if (rawStart === void 0 || rawStart === null) {
8058
+ errors.push("M\u1ED1c th\u1EDDi gian b\u1EAFt \u0111\u1EA7u ('startDate' ho\u1EB7c 'from') l\xE0 b\u1EAFt bu\u1ED9c.");
8059
+ }
8060
+ if (rawEnd === void 0 || rawEnd === null) {
8061
+ errors.push("M\u1ED1c th\u1EDDi gian k\u1EBFt th\xFAc ('endDate' ho\u1EB7c 'to') l\xE0 b\u1EAFt bu\u1ED9c.");
8062
+ }
8063
+ if (errors.length > 0) {
8064
+ return { isValid: false, errors };
8065
+ }
8066
+ const startNum = Number(rawStart);
8067
+ const endNum = Number(rawEnd);
8068
+ if (isNaN(startNum) || startNum <= 0) {
8069
+ 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.`);
8070
+ }
8071
+ if (isNaN(endNum) || endNum <= 0) {
8072
+ 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.`);
8073
+ }
8074
+ if (errors.length > 0) {
8075
+ return { isValid: false, errors };
8076
+ }
8077
+ const isMs = startNum > 1e10 || endNum > 1e10;
8078
+ const maxRange = isMs ? MAX_REPORT_RANGE_MS : MAX_REPORT_RANGE_SECONDS;
8079
+ if (endNum < startNum) {
8080
+ 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.");
8081
+ } else {
8082
+ const diff = endNum - startNum;
8083
+ if (diff > maxRange) {
8084
+ const days = isMs ? Math.round(diff / (86400 * 1e3)) : Math.round(diff / 86400);
8085
+ 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).`);
8086
+ }
8087
+ }
8088
+ let campaignId;
8089
+ if (raw.campaignId !== void 0 && raw.campaignId !== null) {
8090
+ const parsedCampId = Number(raw.campaignId);
8091
+ if (!Number.isInteger(parsedCampId) || parsedCampId <= 0) {
8092
+ errors.push("M\xE3 chi\u1EBFn d\u1ECBch ('campaignId') ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
8093
+ } else {
8094
+ campaignId = parsedCampId;
8095
+ }
8096
+ }
8097
+ const cleanData = {
8098
+ startDate: startNum,
8099
+ endDate: endNum,
8100
+ isMilliseconds: isMs,
8101
+ ...campaignId !== void 0 ? { campaignId } : {}
8102
+ };
8103
+ return {
8104
+ isValid: errors.length === 0,
8105
+ errors,
8106
+ data: errors.length === 0 ? cleanData : void 0
8107
+ };
8108
+ }
8109
+ var ZaloReportsValidator = {
8110
+ validateUpsertCustomReport: validateUpsertCustomReportRequest,
8111
+ validateDateRangeReport: validateDateRangeReportRequest
8112
+ };
8113
+
8114
+ // src/validators/media.validator.ts
8115
+ function isValidUrl3(val) {
8116
+ if (typeof val !== "string") return false;
8117
+ return /^https?:\/\/.+/i.test(val.trim());
8118
+ }
8119
+ function validateSaveMediaRequest(input) {
8120
+ const errors = [];
8121
+ if (!input) {
8122
+ return {
8123
+ isValid: false,
8124
+ errors: ["D\u1EEF li\u1EC7u l\u01B0u Media ('saveMedia') kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng."]
8125
+ };
8126
+ }
8127
+ let targetObj = input;
8128
+ if (typeof input === "string") {
8129
+ try {
8130
+ targetObj = JSON.parse(input);
8131
+ } catch {
8132
+ return {
8133
+ isValid: false,
8134
+ errors: ["Chu\u1ED7i JSON d\u1EEF li\u1EC7u Media ('data') kh\xF4ng \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng."]
8135
+ };
8136
+ }
8137
+ }
8138
+ if (!targetObj || typeof targetObj !== "object") {
8139
+ return {
8140
+ isValid: false,
8141
+ errors: ["D\u1EEF li\u1EC7u Media ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."]
8142
+ };
8143
+ }
8144
+ const rawObj = targetObj;
8145
+ let raw = rawObj;
8146
+ if (rawObj.data && typeof rawObj.data === "object") {
8147
+ raw = rawObj.data;
8148
+ } else if (typeof rawObj.data === "string") {
8149
+ try {
8150
+ raw = JSON.parse(rawObj.data);
8151
+ } catch {
8152
+ return {
8153
+ isValid: false,
8154
+ errors: ["Chu\u1ED7i JSON trong tr\u01B0\u1EDDng 'data' kh\xF4ng \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng."]
8155
+ };
8156
+ }
8157
+ }
8158
+ const name = typeof raw.Name === "string" ? raw.Name.trim() : typeof raw.name === "string" ? raw.name.trim() : "";
8159
+ if (!name) {
8160
+ 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.");
8161
+ } else if (name.length > 255) {
8162
+ 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).`);
8163
+ }
8164
+ const typeVal = raw.Type !== void 0 ? Number(raw.Type) : raw.type !== void 0 ? Number(raw.type) : NaN;
8165
+ if (typeVal !== 1 && typeVal !== 2) {
8166
+ 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).`);
8167
+ }
8168
+ const rawSettings = raw.Settings ?? raw.settings;
8169
+ if (!rawSettings || typeof rawSettings !== "object") {
8170
+ errors.push("C\u1EA5u h\xECnh t\u1EC7p media ('Settings') l\xE0 b\u1EAFt bu\u1ED9c.");
8171
+ return { isValid: false, errors };
8172
+ }
8173
+ const url = typeof rawSettings.Url === "string" ? rawSettings.Url.trim() : typeof rawSettings.url === "string" ? rawSettings.url.trim() : "";
8174
+ if (!url) {
8175
+ errors.push("\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p media ('Settings.Url') l\xE0 b\u1EAFt bu\u1ED9c.");
8176
+ } else if (!isValidUrl3(url)) {
8177
+ 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://.`);
8178
+ }
8179
+ const width = Number(rawSettings.Width ?? rawSettings.width);
8180
+ if (!Number.isInteger(width) || width <= 0) {
8181
+ 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}`);
8182
+ }
8183
+ const height = Number(rawSettings.Height ?? rawSettings.height);
8184
+ if (!Number.isInteger(height) || height <= 0) {
8185
+ 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}`);
8186
+ }
8187
+ let duration;
8188
+ let thumbUrl;
8189
+ if (typeVal === 2) {
8190
+ const dur = Number(rawSettings.Duration ?? rawSettings.duration);
8191
+ if (!isNaN(dur) && dur > 0) {
8192
+ if (dur > 600) {
8193
+ 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).`);
8194
+ } else {
8195
+ duration = dur;
8196
+ }
8197
+ } else {
8198
+ 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).");
8199
+ }
8200
+ const thumb = typeof rawSettings.ThumbUrl === "string" ? rawSettings.ThumbUrl.trim() : typeof rawSettings.thumbUrl === "string" ? rawSettings.thumbUrl.trim() : "";
8201
+ if (thumb) {
8202
+ if (!isValidUrl3(thumb)) {
8203
+ 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.`);
8204
+ } else {
8205
+ thumbUrl = thumb;
8206
+ }
8207
+ }
8208
+ }
8209
+ const cleanData = {
8210
+ Name: name,
8211
+ Type: typeVal,
8212
+ Settings: {
8213
+ Url: url,
8214
+ Width: width,
8215
+ Height: height,
8216
+ ...duration !== void 0 ? { Duration: duration } : {},
8217
+ ...thumbUrl !== void 0 ? { ThumbUrl: thumbUrl } : {}
8218
+ }
8219
+ };
8220
+ return {
8221
+ isValid: errors.length === 0,
8222
+ errors,
8223
+ data: errors.length === 0 ? cleanData : void 0
8224
+ };
8225
+ }
8226
+ var ZaloMediaValidator = {
8227
+ validateSaveMedia: validateSaveMediaRequest
8228
+ };
7477
8229
  // Annotate the CommonJS export names for ESM import in node:
7478
8230
  0 && (module.exports = {
7479
8231
  ALLOWED_CTAS_PER_AD_TYPE,
@@ -7486,12 +8238,17 @@ var ZaloConversionsValidator = class {
7486
8238
  AutomatedRuleTimeRangeEnum,
7487
8239
  ConversionLabelEnum,
7488
8240
  ConversionUrlTypeEnum,
8241
+ MAX_REPORT_RANGE_MS,
8242
+ MAX_REPORT_RANGE_SECONDS,
7489
8243
  MemoryZaloSessionStore,
7490
8244
  RedisZaloSessionStore,
7491
8245
  TieredZaloSessionStore,
7492
8246
  VALID_AD_TYPES,
7493
8247
  VALID_CAMPAIGN_TYPES,
8248
+ VIETNAM_PHONE_REGEX,
7494
8249
  ZALO_NEW_REGION_PROVINCE_CODES,
8250
+ ZALO_PROFILE_ADS_PROVINCES,
8251
+ ZALO_PROFILE_ADS_SUB_CATEGORIES,
7495
8252
  ZALO_PROVINCE_MERGE_MAPPING,
7496
8253
  ZALO_REGION_PROVINCE_CODES,
7497
8254
  ZaloAccountService,
@@ -7545,8 +8302,11 @@ var ZaloConversionsValidator = class {
7545
8302
  ZaloInstantPagesService,
7546
8303
  ZaloInstantPagesValidator,
7547
8304
  ZaloMediaService,
8305
+ ZaloMediaValidator,
7548
8306
  ZaloProfileAdsService,
8307
+ ZaloProfileAdsValidator,
7549
8308
  ZaloReportsService,
8309
+ ZaloReportsValidator,
7550
8310
  ZaloSdkError,
7551
8311
  ZaloSdkHttpClient,
7552
8312
  ZaloWidgetApiService,
@@ -7559,6 +8319,7 @@ var ZaloConversionsValidator = class {
7559
8319
  validateChangeCampaignStatusParams,
7560
8320
  validateCloneInstantPageRequest,
7561
8321
  validateCreateCampaignPayload,
8322
+ validateCreateCustomAudienceRequest,
7562
8323
  validateCreateFlowRequest,
7563
8324
  validateCreateFormEventAudienceRequest,
7564
8325
  validateCreateFormRequest,
@@ -7566,8 +8327,11 @@ var ZaloConversionsValidator = class {
7566
8327
  validateCreateLookalikeAudienceRequest,
7567
8328
  validateCreateMessageOaEventAudienceRequest,
7568
8329
  validateCreateMessagePersonalEventAudienceRequest,
8330
+ validateCreateOaPageRequest,
7569
8331
  validateCreatePhoneAudienceRequest,
7570
8332
  validateCreateSavedAudienceRequest,
8333
+ validateCropCoordinates,
8334
+ validateDateRangeReportRequest,
7571
8335
  validateDuplicateAdParams,
7572
8336
  validateEstimateAudienceRequest,
7573
8337
  validateGetInstantPageDetailRequest,
@@ -7583,10 +8347,17 @@ var ZaloConversionsValidator = class {
7583
8347
  validateListMiniPageTemplatesRequest,
7584
8348
  validateListOfficialAccountsRequest,
7585
8349
  validateRenameCampaignParams,
8350
+ validateSaveMediaRequest,
7586
8351
  validateSearchInstantPagesRequest,
8352
+ validateToggleLeadNotificationRequest,
7587
8353
  validateUpdateAdPayload,
7588
8354
  validateUpdateFlowRequest,
7589
8355
  validateUpdateInstantPageRequest,
8356
+ validateUpdateInstantPageSharesRequest,
8357
+ validateUpdateLeadNotificationIntervalRequest,
8358
+ validateUploadCustomAudiencePhoneListRequest,
8359
+ validateUploadMediaRequest,
8360
+ validateUpsertCustomReportRequest,
7590
8361
  validateUpsertInstantPageFormRequest
7591
8362
  });
7592
8363
  //# sourceMappingURL=index.js.map