@redonvn/zalo-ads-sdk 0.2.0 → 0.2.2

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
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -1030,9 +1040,16 @@ var ZaloSdkHttpClient = class {
1030
1040
  }
1031
1041
  async resolveFile(input) {
1032
1042
  if (typeof input === "string") {
1033
- const response = await this.fetchImpl(input);
1034
- if (!response.ok) throw new Error(`Cannot download upload file URL: HTTP ${response.status}.`);
1035
- return response.blob();
1043
+ if (/^(https?:|data:)/i.test(input)) {
1044
+ const response = await this.fetchImpl(input);
1045
+ if (!response.ok) throw new Error(`Cannot download upload file URL: HTTP ${response.status}.`);
1046
+ return response.blob();
1047
+ }
1048
+ const fs = await import("fs/promises");
1049
+ const bytes2 = await fs.readFile(input);
1050
+ const copy = new Uint8Array(bytes2.byteLength);
1051
+ copy.set(bytes2);
1052
+ return new Blob([copy.buffer], { type: inferMimeType(input) });
1036
1053
  }
1037
1054
  if (input instanceof Blob) return input;
1038
1055
  if (input instanceof ArrayBuffer) return new Blob([input]);
@@ -1054,14 +1071,36 @@ function appendQuery(params, key, value) {
1054
1071
  }
1055
1072
  function fileNameFrom(value) {
1056
1073
  if (typeof value === "string") {
1057
- try {
1058
- return new URL(value).pathname.split("/").pop() || "upload";
1059
- } catch {
1060
- return "upload";
1074
+ if (/^https?:/i.test(value)) {
1075
+ try {
1076
+ return new URL(value).pathname.split("/").pop() || "upload";
1077
+ } catch {
1078
+ return "upload";
1079
+ }
1061
1080
  }
1081
+ const base = value.split(/[\\/]/).pop();
1082
+ return base || "upload";
1083
+ }
1084
+ if (value && typeof value === "object" && "name" in value && typeof value.name === "string") {
1085
+ return value.name;
1086
+ }
1087
+ if (value instanceof Blob && value.type) {
1088
+ const ext = value.type.split("/")[1]?.replace("jpeg", "jpg");
1089
+ if (ext) return `upload.${ext}`;
1062
1090
  }
1063
1091
  return "upload";
1064
1092
  }
1093
+ function inferMimeType(filePath) {
1094
+ const lower = filePath.toLowerCase();
1095
+ if (lower.endsWith(".jpg") || lower.endsWith(".jpeg")) return "image/jpeg";
1096
+ if (lower.endsWith(".png")) return "image/png";
1097
+ if (lower.endsWith(".gif")) return "image/gif";
1098
+ if (lower.endsWith(".webp")) return "image/webp";
1099
+ if (lower.endsWith(".mp4")) return "video/mp4";
1100
+ if (lower.endsWith(".txt")) return "text/plain";
1101
+ if (lower.endsWith(".csv")) return "text/csv";
1102
+ return "application/octet-stream";
1103
+ }
1065
1104
  async function resolveHeaders(auth, context) {
1066
1105
  return { ...auth?.headers ?? {}, ...await auth?.getHeaders?.(context) ?? {} };
1067
1106
  }
@@ -1330,7 +1369,9 @@ var OP_ZaloAdsGetApiBaAccountAllaccessors = {
1330
1369
  "baseUrl": "https://ads.zalo.me",
1331
1370
  "binaryFields": [],
1332
1371
  "pathFields": [],
1333
- "queryFields": [],
1372
+ "queryFields": [
1373
+ "isShowAll"
1374
+ ],
1334
1375
  "headerFields": [],
1335
1376
  "cookieFields": [],
1336
1377
  "bodyFields": []
@@ -1483,7 +1524,9 @@ var OP_ZaloAdsGetApiSpellCheckV2 = {
1483
1524
  "baseUrl": "https://ads.zalo.me",
1484
1525
  "binaryFields": [],
1485
1526
  "pathFields": [],
1486
- "queryFields": [],
1527
+ "queryFields": [
1528
+ "text"
1529
+ ],
1487
1530
  "headerFields": [],
1488
1531
  "cookieFields": [],
1489
1532
  "bodyFields": []
@@ -1634,8 +1677,7 @@ var OP_ZaloAdsGetZaapiGetownedarticles = {
1634
1677
  "binaryFields": [],
1635
1678
  "pathFields": [],
1636
1679
  "queryFields": [
1637
- "pageId",
1638
- "oaId"
1680
+ "pageId"
1639
1681
  ],
1640
1682
  "headerFields": [],
1641
1683
  "cookieFields": [],
@@ -1764,14 +1806,14 @@ var OP_ZaloAdsPostApiMemberUploadImage = {
1764
1806
  "endpoint": "/api/member/upload-image",
1765
1807
  "baseUrl": "https://ads.zalo.me",
1766
1808
  "binaryFields": [
1767
- "file"
1809
+ "File"
1768
1810
  ],
1769
1811
  "pathFields": [],
1770
1812
  "queryFields": [],
1771
1813
  "headerFields": [],
1772
1814
  "cookieFields": [],
1773
1815
  "bodyFields": [
1774
- "file"
1816
+ "File"
1775
1817
  ]
1776
1818
  };
1777
1819
  var OP_ZaloAdsPostZaapiDeletead = {
@@ -2299,7 +2341,7 @@ var ZaloAdsService = class {
2299
2341
  getApiPlaceGetalldistricts(request = {}, options) {
2300
2342
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiPlaceGetalldistricts, this.client.toTransportInput(OP_ZaloAdsGetApiPlaceGetalldistricts, request), options);
2301
2343
  }
2302
- getApiSpellCheckV2(request = {}, options) {
2344
+ getApiSpellCheckV2(request, options) {
2303
2345
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiSpellCheckV2, this.client.toTransportInput(OP_ZaloAdsGetApiSpellCheckV2, request), options);
2304
2346
  }
2305
2347
  getApiWhoami(request = {}, options) {
@@ -2334,14 +2376,29 @@ var ZaloAdsService = class {
2334
2376
  getZaapiGetallpages(request = {}, options) {
2335
2377
  return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetallpages, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetallpages, request), options);
2336
2378
  }
2337
- getZaapiGetownedarticles(request = {}, options) {
2379
+ getAllPages(request = {}, options) {
2380
+ return this.getZaapiGetallpages(request, options);
2381
+ }
2382
+ getZaapiGetownedarticles(request, options) {
2338
2383
  return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetownedarticles, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetownedarticles, request), options);
2339
2384
  }
2385
+ getOwnedArticles(request, options) {
2386
+ return this.getZaapiGetownedarticles(request, options);
2387
+ }
2340
2388
  getZaapiGetownedpages(request = {}, options) {
2341
2389
  return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetownedpages, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetownedpages, request), options);
2342
2390
  }
2343
- listAgencyCustomersWithBudget(request, options) {
2344
- return this.client.requestWithoutBody(OP_ZaloAdsListAgencyCustomersWithBudget, this.client.toTransportInput(OP_ZaloAdsListAgencyCustomersWithBudget, request), options);
2391
+ getOwnedPages(request = {}, options) {
2392
+ return this.getZaapiGetownedpages(request, options);
2393
+ }
2394
+ listAgencyCustomersWithBudget(request = { limit: 15, offset: 0, joinDateAsc: true }, options) {
2395
+ const normalized = {
2396
+ limit: 15,
2397
+ offset: 0,
2398
+ joinDateAsc: true,
2399
+ ...request
2400
+ };
2401
+ return this.client.requestWithoutBody(OP_ZaloAdsListAgencyCustomersWithBudget, this.client.toTransportInput(OP_ZaloAdsListAgencyCustomersWithBudget, normalized), options);
2345
2402
  }
2346
2403
  listCustomReports(request = {}, options) {
2347
2404
  return this.client.requestWithoutBody(OP_ZaloAdsListCustomReports, this.client.toTransportInput(OP_ZaloAdsListCustomReports, request), options);
@@ -2362,7 +2419,15 @@ var ZaloAdsService = class {
2362
2419
  return this.client.requestFormUrlEncoded(OP_ZaloAdsPostApiMediaSave, this.client.toTransportInput(OP_ZaloAdsPostApiMediaSave, request), options);
2363
2420
  }
2364
2421
  postApiMemberUploadImage(request, options) {
2365
- return this.client.requestMultipart(OP_ZaloAdsPostApiMemberUploadImage, this.client.toTransportInput(OP_ZaloAdsPostApiMemberUploadImage, request), options);
2422
+ const normalized = {
2423
+ ...request,
2424
+ File: request.File ?? request.file
2425
+ };
2426
+ return this.client.requestMultipart(OP_ZaloAdsPostApiMemberUploadImage, this.client.toTransportInput(OP_ZaloAdsPostApiMemberUploadImage, normalized), options);
2427
+ }
2428
+ /** Alias tiện lợi cho `postApiMemberUploadImage` (`POST /api/member/upload-image`). */
2429
+ uploadImage(request, options) {
2430
+ return this.postApiMemberUploadImage(request, options);
2366
2431
  }
2367
2432
  postZaapiDeletead(request = {}, options) {
2368
2433
  return this.client.requestWithoutBody(OP_ZaloAdsPostZaapiDeletead, this.client.toTransportInput(OP_ZaloAdsPostZaapiDeletead, request), options);
@@ -2954,6 +3019,32 @@ var OP_ZaloProfileAdsUploadOaCover = {
2954
3019
  "is-new"
2955
3020
  ]
2956
3021
  };
3022
+ var OP_ZaloProfileAdsGetProvinces = {
3023
+ "operationId": "ZaloProfileAds_getProvinces",
3024
+ "method": "GET",
3025
+ "endpoint": "/ajax/get-province",
3026
+ "baseUrl": "https://profile.ads.zalo.me",
3027
+ "binaryFields": [],
3028
+ "pathFields": [],
3029
+ "queryFields": [],
3030
+ "headerFields": [],
3031
+ "cookieFields": [],
3032
+ "bodyFields": []
3033
+ };
3034
+ var OP_ZaloProfileAdsGetDistricts = {
3035
+ "operationId": "ZaloProfileAds_getDistricts",
3036
+ "method": "GET",
3037
+ "endpoint": "/ajax/get-district",
3038
+ "baseUrl": "https://profile.ads.zalo.me",
3039
+ "binaryFields": [],
3040
+ "pathFields": [],
3041
+ "queryFields": [
3042
+ "provinceId"
3043
+ ],
3044
+ "headerFields": [],
3045
+ "cookieFields": [],
3046
+ "bodyFields": []
3047
+ };
2957
3048
  var ZaloProfileAdsService = class {
2958
3049
  constructor(client) {
2959
3050
  this.client = client;
@@ -2966,6 +3057,11 @@ var ZaloProfileAdsService = class {
2966
3057
  }
2967
3058
  const normalizedRequest = {
2968
3059
  option: "createpage",
3060
+ typeId: 2,
3061
+ tier: 0,
3062
+ typeName: "store",
3063
+ categoryId: 10003,
3064
+ agreeTerm: true,
2969
3065
  ...request,
2970
3066
  ...csrfToken ? { "crsf-token": csrfToken } : {}
2971
3067
  };
@@ -2999,6 +3095,20 @@ var ZaloProfileAdsService = class {
2999
3095
  options
3000
3096
  );
3001
3097
  }
3098
+ getProvinces(options) {
3099
+ return this.client.requestWithoutBody(
3100
+ OP_ZaloProfileAdsGetProvinces,
3101
+ {},
3102
+ options
3103
+ );
3104
+ }
3105
+ getDistricts(request, options) {
3106
+ return this.client.requestWithoutBody(
3107
+ OP_ZaloProfileAdsGetDistricts,
3108
+ this.client.toTransportInput(OP_ZaloProfileAdsGetDistricts, request),
3109
+ options
3110
+ );
3111
+ }
3002
3112
  };
3003
3113
 
3004
3114
  // src/services/widget.service.ts