@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.d.mts +943 -486
- package/dist/index.d.ts +943 -486
- package/dist/index.js +128 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -970,9 +970,16 @@ var ZaloSdkHttpClient = class {
|
|
|
970
970
|
}
|
|
971
971
|
async resolveFile(input) {
|
|
972
972
|
if (typeof input === "string") {
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
973
|
+
if (/^(https?:|data:)/i.test(input)) {
|
|
974
|
+
const response = await this.fetchImpl(input);
|
|
975
|
+
if (!response.ok) throw new Error(`Cannot download upload file URL: HTTP ${response.status}.`);
|
|
976
|
+
return response.blob();
|
|
977
|
+
}
|
|
978
|
+
const fs = await import("fs/promises");
|
|
979
|
+
const bytes2 = await fs.readFile(input);
|
|
980
|
+
const copy = new Uint8Array(bytes2.byteLength);
|
|
981
|
+
copy.set(bytes2);
|
|
982
|
+
return new Blob([copy.buffer], { type: inferMimeType(input) });
|
|
976
983
|
}
|
|
977
984
|
if (input instanceof Blob) return input;
|
|
978
985
|
if (input instanceof ArrayBuffer) return new Blob([input]);
|
|
@@ -994,14 +1001,36 @@ function appendQuery(params, key, value) {
|
|
|
994
1001
|
}
|
|
995
1002
|
function fileNameFrom(value) {
|
|
996
1003
|
if (typeof value === "string") {
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1004
|
+
if (/^https?:/i.test(value)) {
|
|
1005
|
+
try {
|
|
1006
|
+
return new URL(value).pathname.split("/").pop() || "upload";
|
|
1007
|
+
} catch {
|
|
1008
|
+
return "upload";
|
|
1009
|
+
}
|
|
1001
1010
|
}
|
|
1011
|
+
const base = value.split(/[\\/]/).pop();
|
|
1012
|
+
return base || "upload";
|
|
1013
|
+
}
|
|
1014
|
+
if (value && typeof value === "object" && "name" in value && typeof value.name === "string") {
|
|
1015
|
+
return value.name;
|
|
1016
|
+
}
|
|
1017
|
+
if (value instanceof Blob && value.type) {
|
|
1018
|
+
const ext = value.type.split("/")[1]?.replace("jpeg", "jpg");
|
|
1019
|
+
if (ext) return `upload.${ext}`;
|
|
1002
1020
|
}
|
|
1003
1021
|
return "upload";
|
|
1004
1022
|
}
|
|
1023
|
+
function inferMimeType(filePath) {
|
|
1024
|
+
const lower = filePath.toLowerCase();
|
|
1025
|
+
if (lower.endsWith(".jpg") || lower.endsWith(".jpeg")) return "image/jpeg";
|
|
1026
|
+
if (lower.endsWith(".png")) return "image/png";
|
|
1027
|
+
if (lower.endsWith(".gif")) return "image/gif";
|
|
1028
|
+
if (lower.endsWith(".webp")) return "image/webp";
|
|
1029
|
+
if (lower.endsWith(".mp4")) return "video/mp4";
|
|
1030
|
+
if (lower.endsWith(".txt")) return "text/plain";
|
|
1031
|
+
if (lower.endsWith(".csv")) return "text/csv";
|
|
1032
|
+
return "application/octet-stream";
|
|
1033
|
+
}
|
|
1005
1034
|
async function resolveHeaders(auth, context) {
|
|
1006
1035
|
return { ...auth?.headers ?? {}, ...await auth?.getHeaders?.(context) ?? {} };
|
|
1007
1036
|
}
|
|
@@ -1270,7 +1299,9 @@ var OP_ZaloAdsGetApiBaAccountAllaccessors = {
|
|
|
1270
1299
|
"baseUrl": "https://ads.zalo.me",
|
|
1271
1300
|
"binaryFields": [],
|
|
1272
1301
|
"pathFields": [],
|
|
1273
|
-
"queryFields": [
|
|
1302
|
+
"queryFields": [
|
|
1303
|
+
"isShowAll"
|
|
1304
|
+
],
|
|
1274
1305
|
"headerFields": [],
|
|
1275
1306
|
"cookieFields": [],
|
|
1276
1307
|
"bodyFields": []
|
|
@@ -1423,7 +1454,9 @@ var OP_ZaloAdsGetApiSpellCheckV2 = {
|
|
|
1423
1454
|
"baseUrl": "https://ads.zalo.me",
|
|
1424
1455
|
"binaryFields": [],
|
|
1425
1456
|
"pathFields": [],
|
|
1426
|
-
"queryFields": [
|
|
1457
|
+
"queryFields": [
|
|
1458
|
+
"text"
|
|
1459
|
+
],
|
|
1427
1460
|
"headerFields": [],
|
|
1428
1461
|
"cookieFields": [],
|
|
1429
1462
|
"bodyFields": []
|
|
@@ -1574,8 +1607,7 @@ var OP_ZaloAdsGetZaapiGetownedarticles = {
|
|
|
1574
1607
|
"binaryFields": [],
|
|
1575
1608
|
"pathFields": [],
|
|
1576
1609
|
"queryFields": [
|
|
1577
|
-
"pageId"
|
|
1578
|
-
"oaId"
|
|
1610
|
+
"pageId"
|
|
1579
1611
|
],
|
|
1580
1612
|
"headerFields": [],
|
|
1581
1613
|
"cookieFields": [],
|
|
@@ -1704,14 +1736,14 @@ var OP_ZaloAdsPostApiMemberUploadImage = {
|
|
|
1704
1736
|
"endpoint": "/api/member/upload-image",
|
|
1705
1737
|
"baseUrl": "https://ads.zalo.me",
|
|
1706
1738
|
"binaryFields": [
|
|
1707
|
-
"
|
|
1739
|
+
"File"
|
|
1708
1740
|
],
|
|
1709
1741
|
"pathFields": [],
|
|
1710
1742
|
"queryFields": [],
|
|
1711
1743
|
"headerFields": [],
|
|
1712
1744
|
"cookieFields": [],
|
|
1713
1745
|
"bodyFields": [
|
|
1714
|
-
"
|
|
1746
|
+
"File"
|
|
1715
1747
|
]
|
|
1716
1748
|
};
|
|
1717
1749
|
var OP_ZaloAdsPostZaapiDeletead = {
|
|
@@ -2239,7 +2271,7 @@ var ZaloAdsService = class {
|
|
|
2239
2271
|
getApiPlaceGetalldistricts(request = {}, options) {
|
|
2240
2272
|
return this.client.requestWithoutBody(OP_ZaloAdsGetApiPlaceGetalldistricts, this.client.toTransportInput(OP_ZaloAdsGetApiPlaceGetalldistricts, request), options);
|
|
2241
2273
|
}
|
|
2242
|
-
getApiSpellCheckV2(request
|
|
2274
|
+
getApiSpellCheckV2(request, options) {
|
|
2243
2275
|
return this.client.requestWithoutBody(OP_ZaloAdsGetApiSpellCheckV2, this.client.toTransportInput(OP_ZaloAdsGetApiSpellCheckV2, request), options);
|
|
2244
2276
|
}
|
|
2245
2277
|
getApiWhoami(request = {}, options) {
|
|
@@ -2274,14 +2306,29 @@ var ZaloAdsService = class {
|
|
|
2274
2306
|
getZaapiGetallpages(request = {}, options) {
|
|
2275
2307
|
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetallpages, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetallpages, request), options);
|
|
2276
2308
|
}
|
|
2277
|
-
|
|
2309
|
+
getAllPages(request = {}, options) {
|
|
2310
|
+
return this.getZaapiGetallpages(request, options);
|
|
2311
|
+
}
|
|
2312
|
+
getZaapiGetownedarticles(request, options) {
|
|
2278
2313
|
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetownedarticles, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetownedarticles, request), options);
|
|
2279
2314
|
}
|
|
2315
|
+
getOwnedArticles(request, options) {
|
|
2316
|
+
return this.getZaapiGetownedarticles(request, options);
|
|
2317
|
+
}
|
|
2280
2318
|
getZaapiGetownedpages(request = {}, options) {
|
|
2281
2319
|
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetownedpages, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetownedpages, request), options);
|
|
2282
2320
|
}
|
|
2283
|
-
|
|
2284
|
-
return this.
|
|
2321
|
+
getOwnedPages(request = {}, options) {
|
|
2322
|
+
return this.getZaapiGetownedpages(request, options);
|
|
2323
|
+
}
|
|
2324
|
+
listAgencyCustomersWithBudget(request = { limit: 15, offset: 0, joinDateAsc: true }, options) {
|
|
2325
|
+
const normalized = {
|
|
2326
|
+
limit: 15,
|
|
2327
|
+
offset: 0,
|
|
2328
|
+
joinDateAsc: true,
|
|
2329
|
+
...request
|
|
2330
|
+
};
|
|
2331
|
+
return this.client.requestWithoutBody(OP_ZaloAdsListAgencyCustomersWithBudget, this.client.toTransportInput(OP_ZaloAdsListAgencyCustomersWithBudget, normalized), options);
|
|
2285
2332
|
}
|
|
2286
2333
|
listCustomReports(request = {}, options) {
|
|
2287
2334
|
return this.client.requestWithoutBody(OP_ZaloAdsListCustomReports, this.client.toTransportInput(OP_ZaloAdsListCustomReports, request), options);
|
|
@@ -2302,7 +2349,15 @@ var ZaloAdsService = class {
|
|
|
2302
2349
|
return this.client.requestFormUrlEncoded(OP_ZaloAdsPostApiMediaSave, this.client.toTransportInput(OP_ZaloAdsPostApiMediaSave, request), options);
|
|
2303
2350
|
}
|
|
2304
2351
|
postApiMemberUploadImage(request, options) {
|
|
2305
|
-
|
|
2352
|
+
const normalized = {
|
|
2353
|
+
...request,
|
|
2354
|
+
File: request.File ?? request.file
|
|
2355
|
+
};
|
|
2356
|
+
return this.client.requestMultipart(OP_ZaloAdsPostApiMemberUploadImage, this.client.toTransportInput(OP_ZaloAdsPostApiMemberUploadImage, normalized), options);
|
|
2357
|
+
}
|
|
2358
|
+
/** Alias tiện lợi cho `postApiMemberUploadImage` (`POST /api/member/upload-image`). */
|
|
2359
|
+
uploadImage(request, options) {
|
|
2360
|
+
return this.postApiMemberUploadImage(request, options);
|
|
2306
2361
|
}
|
|
2307
2362
|
postZaapiDeletead(request = {}, options) {
|
|
2308
2363
|
return this.client.requestWithoutBody(OP_ZaloAdsPostZaapiDeletead, this.client.toTransportInput(OP_ZaloAdsPostZaapiDeletead, request), options);
|
|
@@ -2894,6 +2949,32 @@ var OP_ZaloProfileAdsUploadOaCover = {
|
|
|
2894
2949
|
"is-new"
|
|
2895
2950
|
]
|
|
2896
2951
|
};
|
|
2952
|
+
var OP_ZaloProfileAdsGetProvinces = {
|
|
2953
|
+
"operationId": "ZaloProfileAds_getProvinces",
|
|
2954
|
+
"method": "GET",
|
|
2955
|
+
"endpoint": "/ajax/get-province",
|
|
2956
|
+
"baseUrl": "https://profile.ads.zalo.me",
|
|
2957
|
+
"binaryFields": [],
|
|
2958
|
+
"pathFields": [],
|
|
2959
|
+
"queryFields": [],
|
|
2960
|
+
"headerFields": [],
|
|
2961
|
+
"cookieFields": [],
|
|
2962
|
+
"bodyFields": []
|
|
2963
|
+
};
|
|
2964
|
+
var OP_ZaloProfileAdsGetDistricts = {
|
|
2965
|
+
"operationId": "ZaloProfileAds_getDistricts",
|
|
2966
|
+
"method": "GET",
|
|
2967
|
+
"endpoint": "/ajax/get-district",
|
|
2968
|
+
"baseUrl": "https://profile.ads.zalo.me",
|
|
2969
|
+
"binaryFields": [],
|
|
2970
|
+
"pathFields": [],
|
|
2971
|
+
"queryFields": [
|
|
2972
|
+
"provinceId"
|
|
2973
|
+
],
|
|
2974
|
+
"headerFields": [],
|
|
2975
|
+
"cookieFields": [],
|
|
2976
|
+
"bodyFields": []
|
|
2977
|
+
};
|
|
2897
2978
|
var ZaloProfileAdsService = class {
|
|
2898
2979
|
constructor(client) {
|
|
2899
2980
|
this.client = client;
|
|
@@ -2906,6 +2987,11 @@ var ZaloProfileAdsService = class {
|
|
|
2906
2987
|
}
|
|
2907
2988
|
const normalizedRequest = {
|
|
2908
2989
|
option: "createpage",
|
|
2990
|
+
typeId: 2,
|
|
2991
|
+
tier: 0,
|
|
2992
|
+
typeName: "store",
|
|
2993
|
+
categoryId: 10003,
|
|
2994
|
+
agreeTerm: true,
|
|
2909
2995
|
...request,
|
|
2910
2996
|
...csrfToken ? { "crsf-token": csrfToken } : {}
|
|
2911
2997
|
};
|
|
@@ -2939,6 +3025,20 @@ var ZaloProfileAdsService = class {
|
|
|
2939
3025
|
options
|
|
2940
3026
|
);
|
|
2941
3027
|
}
|
|
3028
|
+
getProvinces(options) {
|
|
3029
|
+
return this.client.requestWithoutBody(
|
|
3030
|
+
OP_ZaloProfileAdsGetProvinces,
|
|
3031
|
+
{},
|
|
3032
|
+
options
|
|
3033
|
+
);
|
|
3034
|
+
}
|
|
3035
|
+
getDistricts(request, options) {
|
|
3036
|
+
return this.client.requestWithoutBody(
|
|
3037
|
+
OP_ZaloProfileAdsGetDistricts,
|
|
3038
|
+
this.client.toTransportInput(OP_ZaloProfileAdsGetDistricts, request),
|
|
3039
|
+
options
|
|
3040
|
+
);
|
|
3041
|
+
}
|
|
2942
3042
|
};
|
|
2943
3043
|
|
|
2944
3044
|
// src/services/widget.service.ts
|