zmp-sdk 2.52.0-beta.1 → 2.52.1-beta.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.
@@ -1 +1 @@
1
- import n from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import o,{object as e,string as t,number as i}from'./../external/zod/lib/index.mjs.js';import r from"../appEnv/index.js";import a from"../common/notFound.js";import{functionHandler as m}from"../utils/decorator.js";import s from"../common/apis/general/addVoucher.js";import{__generator as l}from'./../external/tslib/tslib.es6.js';var p=e({type:o.enum(["url","phone"]),value:t().min(1),cta:t().min(1)}),c=[e({title:t().min(1).max(200),name:t().min(1).max(200),desc:t().min(1).max(500).optional(),avatarUrl:t().url().max(500).optional(),code:t().min(1).max(64),display:o.enum(["qr_code","bar_code"]).default("qr_code").optional(),partner:t().min(1).optional(),merchantName:t().min(1).max(100),merchantOaId:t().min(1).max(50),merchantLogoUrl:t().url().max(500).optional(),ownerName:t().min(1).max(100),condition:t().min(1).max(500),conditionDetail:t().min(1).max(2e3).optional(),validAt:i().int().nonnegative().optional(),expiredAt:i().int().positive(),remindAt:i().int().nonnegative().optional(),actions:o.array(p).max(3).optional()})];function u(n){return d.apply(this,arguments)}function d(){return d=n((function(o){return l(this,(function(e){return[2,m("addVoucher",c,[o],(t=n((function(n,o){var e;return l(this,(function(t){switch(t.label){case 0:return e=o||n,r.isMp?[4,s(e)]:[3,2];case 1:return[2,t.sent()];case 2:return r.isMpWeb?[2,Promise.resolve()]:[2,Promise.reject(a("addVoucher",{}))]}}))})),function(n,o){return t.apply(this,arguments)}))];var t}))})),d.apply(this,arguments)}export{u as addVoucher};
1
+ import o from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import n,{object as e,string as r,number as i}from'./../external/zod/lib/index.mjs.js';import t from"../appEnv/index.js";import a from"../common/notFound.js";import{functionHandler as m}from"../utils/decorator.js";import s from"../common/apis/general/addVoucher.js";import{__generator as c}from'./../external/tslib/tslib.es6.js';var p=e({type:n.enum(["url","phone"]),value:r().min(1),cta:r().min(1)}),u=[e({name:r().min(1).max(200),condition:r().min(1).max(500),conditionDetail:r().min(1).max(2e3).optional(),validAt:i().int().nonnegative().optional(),expiredAt:i().int().positive(),code:r().min(1).max(140).optional(),display:n.enum(["qr_code","bar_code"]).default("qr_code").optional(),remindBefore:i().int().positive(),ownerName:r().min(1).max(100).optional(),merchantOaId:r().min(1).max(50),merchantName:r().min(1).max(100),merchantLogoUrl:r().url().max(500),actions:n.array(p).max(2).optional()})];function d(o){return l.apply(this,arguments)}function l(){return l=o((function(n){return c(this,(function(e){return[2,m("addVoucher",u,[n],(r=o((function(o,n){var e;return c(this,(function(r){switch(r.label){case 0:return e=n||o,t.isMp?[4,s(e)]:[3,2];case 1:return[2,r.sent()];case 2:return t.isMpWeb?[2,Promise.resolve()]:[2,Promise.reject(a("addVoucher",{}))]}}))})),function(o,n){return r.apply(this,arguments)}))];var r}))})),l.apply(this,arguments)}export{d as addVoucher};
@@ -1 +1 @@
1
- import e from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import r from"../../token.js";import{RESPONSE_CODE as n,MESSAGES as t,QRCARD_APIS as o}from"../../../constants.js";import{AppError as a}from"../../../utils/errorHandler.js";import i from"./openWebview.js";import{__generator as s}from'./../../../external/tslib/tslib.es6.js';var m,c=(m=e((function(e){var m,c,d,l,u,p,E;return s(this,(function(s){switch(s.label){case 0:return[4,r.jumpAndGetToken()];case 1:if(s.sent(),!(d=null===(m=r.miniProgramConfig)||void 0===m?void 0:m.jwt))throw new a(n.UNAUTHORIZED,t.LOGIN_REQUIRED);return(l=new URLSearchParams).append("data",JSON.stringify(function(e){return{title:e.title,name:e.name,desc:e.desc||e.ownerName,avatarUrl:e.avatarUrl||e.merchantLogoUrl,meta:{code:e.code,display:e.display||"qr_code",partner:e.partner,name:e.name,merchantName:e.merchantName,merchantOaId:e.merchantOaId,merchantLogoUrl:e.merchantLogoUrl,ownerName:e.ownerName,condition:e.condition,conditionDetail:e.conditionDetail,validAt:e.validAt,expiredAt:e.expiredAt,remindAt:e.remindAt,actions:e.actions}}}(e))),[4,fetch(o.ADD_VOUCHER,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",authorization:"Bearer ".concat(d)},body:l})];case 2:u=s.sent(),s.label=3;case 3:return s.trys.push([3,5,,6]),[4,u.json()];case 4:return p=s.sent(),[3,6];case 5:throw s.sent(),new a(n.VOUCHER_CREATE_FAILED,t.VOUCHER_CREATE_FAILED);case 6:if(0!==(null==p?void 0:p.err))throw new a("number"==typeof(null==p?void 0:p.err)?p.err:n.VOUCHER_CREATE_FAILED,function(e){var r="string"==typeof(null==e?void 0:e.msg)?e.msg.trim():"";return r||(-1===(null==e?void 0:e.err)?"Unknown exception":t.VOUCHER_CREATE_FAILED)}(p));if(!(E=null===(c=p.data)||void 0===c?void 0:c.deeplink))throw new a(n.VOUCHER_CREATE_FAILED,t.VOUCHER_CREATE_FAILED);return[4,i(E)];case 7:return s.sent(),[2]}}))})),function(e){return m.apply(this,arguments)});export{c as default};
1
+ import e from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import r from"../../token.js";import{RESPONSE_CODE as n,MESSAGES as t,QRCARD_APIS as o}from"../../../constants.js";import{AppError as i}from"../../../utils/errorHandler.js";import a from"./openWebview.js";import{__generator as s}from'./../../../external/tslib/tslib.es6.js';var d,c=(d=e((function(e){var d,c,m,l,u,E,p;return s(this,(function(s){switch(s.label){case 0:return[4,r.jumpAndGetToken()];case 1:if(s.sent(),!(m=null===(d=r.miniProgramConfig)||void 0===d?void 0:d.jwt))throw new i(n.UNAUTHORIZED,t.LOGIN_REQUIRED);return(l=new URLSearchParams).append("data",JSON.stringify(function(e){return{name:e.name,condition:e.condition,conditionDetail:e.conditionDetail,validAt:e.validAt,expiredAt:e.expiredAt,code:e.code,display:e.display||"qr_code",remindBefore:e.remindBefore,ownerName:e.ownerName,merchantOaId:e.merchantOaId,merchantName:e.merchantName,merchantLogoUrl:e.merchantLogoUrl,actions:e.actions}}(e))),[4,fetch(o.ADD_VOUCHER,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",authorization:"Bearer ".concat(m)},body:l})];case 2:u=s.sent(),s.label=3;case 3:return s.trys.push([3,5,,6]),[4,u.json()];case 4:return E=s.sent(),[3,6];case 5:throw s.sent(),new i(n.VOUCHER_CREATE_FAILED,t.VOUCHER_CREATE_FAILED);case 6:if(0!==(null==E?void 0:E.err))throw new i("number"==typeof(null==E?void 0:E.err)?E.err:n.VOUCHER_CREATE_FAILED,function(e){var r="string"==typeof(null==e?void 0:e.msg)?e.msg.trim():"";return r||(-1===(null==e?void 0:e.err)?"Unknown exception":t.VOUCHER_CREATE_FAILED)}(E));if(!(p=null===(c=E.data)||void 0===c?void 0:c.deeplink))throw new i(n.VOUCHER_CREATE_FAILED,t.VOUCHER_CREATE_FAILED);return[4,a(p)];case 7:return s.sent(),[2]}}))})),function(e){return d.apply(this,arguments)});export{c as default};
package/apis/index.d.ts CHANGED
@@ -1305,72 +1305,56 @@ type VoucherAction = {
1305
1305
  cta: string;
1306
1306
  };
1307
1307
  type AddVoucherData = {
1308
- /**
1309
- * Tiêu đề hiển thị trên card.
1310
- */
1311
- title: string;
1312
1308
  /**
1313
1309
  * Tên voucher / ưu đãi.
1314
1310
  */
1315
1311
  name: string;
1316
1312
  /**
1317
- * Tên chủ thẻ hiển thị phụ dưới tên voucher. Mặc định dùng `ownerName`.
1318
- */
1319
- desc?: string;
1320
- /**
1321
- * Logo hiển thị trên card. Mặc định dùng `merchantLogoUrl`.
1313
+ * Điều kiện áp dụng (chính), hiển thị trên chi tiết vé.
1322
1314
  */
1323
- avatarUrl?: string;
1315
+ condition: string;
1324
1316
  /**
1325
- * Nội dung encode vào QR hoặc barcode.
1317
+ * Điều kiện áp dụng chi tiết (phụ).
1326
1318
  */
1327
- code: string;
1328
- /**
1329
- * Loại mã hiển thị. Mặc định là `qr_code`.
1330
- */
1331
- display?: VoucherDisplayType;
1319
+ conditionDetail?: string;
1332
1320
  /**
1333
- * Nguồn phát hành voucher.
1321
+ * Thời gian bắt đầu hiệu lực, epoch milliseconds.
1334
1322
  */
1335
- partner?: string;
1323
+ validAt?: number;
1336
1324
  /**
1337
- * Tên thương hiệu / cửa hàng phát hành voucher.
1325
+ * Hạn sử dụng, epoch milliseconds.
1338
1326
  */
1339
- merchantName: string;
1340
- /**
1341
- * OA ID của merchant trên Zalo.
1342
- */
1343
- merchantOaId: string;
1327
+ expiredAt: number;
1344
1328
  /**
1345
- * Logo merchant.
1329
+ * Mã voucher; không truyền thì tự sinh QR OA của merchant.
1346
1330
  */
1347
- merchantLogoUrl?: string;
1331
+ code?: string;
1348
1332
  /**
1349
- * Tên người nhận voucher.
1333
+ * Loại mã hiển thị. Mặc định là `qr_code`.
1350
1334
  */
1351
- ownerName: string;
1335
+ display?: VoucherDisplayType;
1352
1336
  /**
1353
- * Điều kiện sử dụng tóm tắt.
1337
+ * Khoảng thời gian trước hạn để gửi nhắc, tính bằng milliseconds.
1354
1338
  */
1355
- condition: string;
1339
+ remindBefore: number;
1356
1340
  /**
1357
- * Điều kiện sử dụng đầy đủ.
1341
+ * Tên khách hàng sở hữu; không truyền thì không hiển thị trên vé.
1358
1342
  */
1359
- conditionDetail?: string;
1343
+ ownerName?: string;
1360
1344
  /**
1361
- * Thời điểm bắt đầu hiệu lực, epoch milliseconds.
1345
+ * OA ID của merchant trên Zalo.
1362
1346
  */
1363
- validAt?: number;
1347
+ merchantOaId: string;
1364
1348
  /**
1365
- * Thời điểm hết hạn, epoch milliseconds.
1349
+ * Tên OA / thương hiệu phát hành voucher.
1366
1350
  */
1367
- expiredAt: number;
1351
+ merchantName: string;
1368
1352
  /**
1369
- * Thời điểm gửi nhắc hạn, epoch milliseconds.
1353
+ * Logo OA, dùng làm logo hiển thị trên voucher.
1370
1354
  */
1371
- remindAt?: number;
1355
+ merchantLogoUrl: string;
1372
1356
  /**
1373
- * Danh sách CTA hiển thị trên thẻ.
1357
+ * Danh sách CTA hiển thị trên thẻ (tối đa 2).
1374
1358
  */
1375
1359
  actions?: VoucherAction[];
1376
1360
  };
@@ -4960,15 +4944,18 @@ declare function addRating(args?: AsyncVoidCallback): Promise<void>;
4960
4944
  * @zaloOnly Chỉ hoạt động khi chạy bên trong ứng dụng Zalo mobile.
4961
4945
  *
4962
4946
  * @param {string} name Tên voucher / ưu đãi.
4963
- * @param {string} code Nội dung encode vào QR hoặc barcode.
4964
- * @param {"qr_code" | "bar_code"} [display="qr_code"] Loại mã hiển thị.
4965
- * @param {string} merchantName Tên thương hiệu / cửa hàng phát hành voucher.
4947
+ * @param {string} condition Điều kiện áp dụng (chính), hiển thị trên chi tiết vé.
4948
+ * @param {number} expiredAt Hạn sử dụng, epoch milliseconds.
4949
+ * @param {number} remindBefore Khoảng thời gian trước hạn để gửi nhắc, tính bằng milliseconds.
4966
4950
  * @param {string} merchantOaId OA ID của merchant trên Zalo.
4967
- * @param {string} ownerName Tên người nhận voucher.
4968
- * @param {string} condition Điều kiện sử dụng tóm tắt.
4969
- * @param {number} expiredAt Thời điểm hết hạn, epoch milliseconds.
4970
- * @param {number} [remindAt] Thời điểm gửi nhắc hạn, epoch milliseconds.
4971
- * @param {VoucherAction[]} [actions] Danh sách CTA hiển thị trên thẻ.
4951
+ * @param {string} merchantName Tên OA / thương hiệu phát hành voucher.
4952
+ * @param {string} merchantLogoUrl Logo OA, dùng làm logo hiển thị trên voucher.
4953
+ * @param {string} [conditionDetail] Điều kiện áp dụng chi tiết (phụ).
4954
+ * @param {number} [validAt] Thời gian bắt đầu hiệu lực, epoch milliseconds.
4955
+ * @param {string} [code] Mã voucher; không truyền thì tự sinh QR OA của merchant.
4956
+ * @param {"qr_code" | "bar_code"} [display="qr_code"] Loại mã hiển thị.
4957
+ * @param {string} [ownerName] Tên khách hàng sở hữu; không truyền thì không hiển thị trên vé.
4958
+ * @param {VoucherAction[]} [actions] Danh sách CTA hiển thị trên thẻ (tối đa 2).
4972
4959
  *
4973
4960
  * @returns {Promise<void>} Promise resolve khi tạo thẻ thành công và deeplink đã
4974
4961
  * được mở; reject kèm mã lỗi từ server nếu thất bại.
@@ -4976,14 +4963,13 @@ declare function addRating(args?: AsyncVoidCallback): Promise<void>;
4976
4963
  * @example Thêm voucher vào Ví QR:
4977
4964
  * ```ts
4978
4965
  * await addVoucher({
4979
- * name: "Giảm 50k cho đơn từ 150k",
4980
- * code: "SPFOOD50K",
4981
- * merchantName: "Shopee Food",
4982
- * merchantOaId: "2712772826697148176",
4983
- * ownerName: "Nguyễn Văn A",
4984
- * condition: "Áp dụng cho đơn từ 150.000đ.",
4985
- * expiredAt: 1751299200000,
4986
- * remindAt: 1751212800000,
4966
+ * name: "Giảm 50% giá trị đơn hàng",
4967
+ * condition: "Áp dụng cho hóa đơn trên 200.000đ",
4968
+ * expiredAt: 1743440399000,
4969
+ * remindBefore: 3600000,
4970
+ * merchantOaId: "2646373759294038927",
4971
+ * merchantName: "The Face Shop",
4972
+ * merchantLogoUrl: "https://static.example.com/logo.png",
4987
4973
  * });
4988
4974
  * ```
4989
4975
  */
@@ -1 +1 @@
1
- var a="2.52.0-beta.1";export{a as version};
1
+ var a="2.52.1-beta.2";export{a as version};