zmp-sdk 2.15.4 → 2.16.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.es.js CHANGED
@@ -25875,7 +25875,7 @@ function setup(env) {
25875
25875
 
25876
25876
  /**
25877
25877
  * Selects a color for a debug namespace
25878
- * @param {String} namespace The namespace string for the for the debug instance to be colored
25878
+ * @param {String} namespace The namespace string for the debug instance to be colored
25879
25879
  * @return {Number|String} An ANSI color code for the given namespace
25880
25880
  * @api private
25881
25881
  */
@@ -34857,7 +34857,16 @@ var Events;
34857
34857
  Events["AppResumed"] = "h5.event.resumed";
34858
34858
  Events["NetworkChanged"] = "h5.event.connection.changed";
34859
34859
  Events["OnDataCallback"] = "h5.event.webview.result";
34860
- })(Events || (Events = {}));
34860
+ Events["OpenApp"] = "h5.event.open.mp";
34861
+ })(Events || (Events = {}));
34862
+ var MediaPickerType;
34863
+ (function (MediaPickerType) {
34864
+ MediaPickerType[MediaPickerType["photo"] = 4] = "photo";
34865
+ MediaPickerType[MediaPickerType["video"] = 5] = "video";
34866
+ MediaPickerType[MediaPickerType["file"] = 6] = "file";
34867
+ MediaPickerType[MediaPickerType["multi_photo"] = 7] = "multi_photo";
34868
+ MediaPickerType[MediaPickerType["multi_video"] = 8] = "multi_video";
34869
+ })(MediaPickerType || (MediaPickerType = {}));
34861
34870
 
34862
34871
  const readCookie = (name) => {
34863
34872
  const ckString = document.cookie;
@@ -34918,6 +34927,9 @@ const readCookieFallback = (name) => {
34918
34927
  return ck;
34919
34928
  };
34920
34929
 
34930
+ const ZAPP_ID = window.zAppID;
34931
+ const APP_ID = window.APP_ID;
34932
+ const APP_CONFIG = window.APP_CONFIG || {};
34921
34933
  const ACTION = {
34922
34934
  GET_DOWNLOADED_STICKER: {
34923
34935
  name: 'action.get.downloaded.sticker'
@@ -35202,11 +35214,21 @@ const ACTION = {
35202
35214
  },
35203
35215
  MP_OPEN_PROFILE_PICKER: {
35204
35216
  name: 'action.mp.open.profile.picker',
35205
- version_live: { iOS: 999 }
35217
+ version_live: { iOS: 432 }
35206
35218
  },
35207
35219
  GET_SUPPORTED_ACTIONS: {
35208
35220
  name: 'action.get.supported.actions',
35209
35221
  white_list: true
35222
+ },
35223
+ MP_JOIN_WIFI: {
35224
+ name: 'action.mp.join.wifi',
35225
+ version_live: { android: 0, iOS: 999 },
35226
+ have_permission: false,
35227
+ white_list: false
35228
+ },
35229
+ PICK_MEDIA: {
35230
+ name: 'action.pick.media',
35231
+ version_live: { iOS: 999 }
35210
35232
  }
35211
35233
  };
35212
35234
  const ACTION_HAVE_CALLBACK = [
@@ -35599,15 +35621,6 @@ const isType = (argument, type) => {
35599
35621
  }
35600
35622
  return false;
35601
35623
  };
35602
- const isEmpty = (value) => {
35603
- return (
35604
- // null or undefined
35605
- value == null ||
35606
- // has length and it's zero
35607
- (value.hasOwnProperty('length') && value.length === 0) ||
35608
- // is an Object and has no keys
35609
- (value.constructor === Object && Object.keys(value).length === 0));
35610
- };
35611
35624
  const getToken = (name) => {
35612
35625
  return readCookieFallback(name);
35613
35626
  };
@@ -35729,24 +35742,13 @@ const checkIOSSupportAction = (action) => {
35729
35742
  const getZMPShareInfo = (appID, accessToken, shareTitle, shareDescription, shareThumbnail, sharePath) => __awaiter(void 0, void 0, void 0, function* () {
35730
35743
  const currentUrl = new URL(location.href);
35731
35744
  const params = new URLSearchParams();
35732
- const description = {
35733
- vi: '',
35734
- en: ''
35735
- };
35736
35745
  let path = `${currentUrl.pathname}${currentUrl.search}`;
35737
35746
  if (sharePath) {
35738
35747
  path = `/zapps/${appID}${sharePath[0] === '/' ? '' : '/'}${sharePath}`;
35739
35748
  }
35740
35749
  const validUrl = new URL(`https://zalo.me/app/link${path}`);
35741
- if (lodash.isString(shareDescription)) {
35742
- description.en = description.vi = shareDescription;
35743
- }
35744
- else if (lodash.isObject(shareDescription)) {
35745
- description.en = shareDescription.en || '';
35746
- description.vi = shareDescription.vi || '';
35747
- }
35748
35750
  params.append('title', shareTitle);
35749
- params.append('description', description.vi || description.en);
35751
+ params.append('description', shareDescription || '');
35750
35752
  params.append('thumbnail', shareThumbnail);
35751
35753
  params.append('url', validUrl.href);
35752
35754
  params.append('accessToken', accessToken || '');
@@ -35762,7 +35764,59 @@ const getZMPShareInfo = (appID, accessToken, shareTitle, shareDescription, share
35762
35764
  }
35763
35765
  validUrl.search = `${validUrl.search}&zshareId=${resData.data.shareId}`;
35764
35766
  return Object.assign(Object.assign({}, resData.data), { shareableLink: validUrl.href });
35765
- });
35767
+ });
35768
+ const checkData = (types, option) => (data) => {
35769
+ const validType = Array.isArray(types)
35770
+ ? types.some((type) => isType(data, type))
35771
+ : isType(data, types);
35772
+ if (!validType) {
35773
+ return {
35774
+ error: true,
35775
+ errorMessage: types
35776
+ };
35777
+ }
35778
+ if (option) {
35779
+ if (Array.isArray(option === null || option === void 0 ? void 0 : option.values)) {
35780
+ return {
35781
+ error: !(option === null || option === void 0 ? void 0 : option.values.includes(data)),
35782
+ errorMessage: option === null || option === void 0 ? void 0 : option.values.toString()
35783
+ };
35784
+ }
35785
+ if (lodash.isNumber(option === null || option === void 0 ? void 0 : option.maxLength)) {
35786
+ return {
35787
+ error: lodash.isString(data) && data.length > (option === null || option === void 0 ? void 0 : option.maxLength),
35788
+ errorMessage: `data length must <= ${option === null || option === void 0 ? void 0 : option.maxLength}`
35789
+ };
35790
+ }
35791
+ if (lodash.isNumber(option === null || option === void 0 ? void 0 : option.min) && lodash.isNumber(option === null || option === void 0 ? void 0 : option.max)) {
35792
+ return {
35793
+ error: data < (option === null || option === void 0 ? void 0 : option.min) || data > (option === null || option === void 0 ? void 0 : option.max),
35794
+ errorMessage: `data must be in between ${option === null || option === void 0 ? void 0 : option.min} and ${option === null || option === void 0 ? void 0 : option.max}`
35795
+ };
35796
+ }
35797
+ if (lodash.isNumber(option === null || option === void 0 ? void 0 : option.min)) {
35798
+ return {
35799
+ error: data < (option === null || option === void 0 ? void 0 : option.min),
35800
+ errorMessage: `data must >= ${option === null || option === void 0 ? void 0 : option.min}`
35801
+ };
35802
+ }
35803
+ if (lodash.isNumber(option === null || option === void 0 ? void 0 : option.max)) {
35804
+ return {
35805
+ error: data > (option === null || option === void 0 ? void 0 : option.max),
35806
+ errorMessage: `data must <= ${option === null || option === void 0 ? void 0 : option.max}`
35807
+ };
35808
+ }
35809
+ if (lodash.isRegExp(option === null || option === void 0 ? void 0 : option.regex)) {
35810
+ return {
35811
+ error: !option.regex.test(data),
35812
+ errorMessage: `data must valid`
35813
+ };
35814
+ }
35815
+ }
35816
+ return {
35817
+ error: false
35818
+ };
35819
+ };
35766
35820
 
35767
35821
  var eventemitter3 = createCommonjsModule(function (module) {
35768
35822
 
@@ -36161,7 +36215,9 @@ var CONFIG = (() => {
36161
36215
  '2G': device.isAndroid ? 2 : 2,
36162
36216
  '3G': device.isAndroid ? 15 : 2,
36163
36217
  '4G': device.isAndroid ? 13 : 2
36164
- }
36218
+ },
36219
+ MEDIA_PICKER_LIMIT: 1 * MB,
36220
+ MEDIA_PICKER_UPLOAD_SERVER: 'https://zapi-server.tungnt.xyz/upload/photos'
36165
36221
  };
36166
36222
  })();
36167
36223
 
@@ -36430,6 +36486,7 @@ class ZaloJSBridge extends eventemitter3 {
36430
36486
  }
36431
36487
  onJSCall(key, data) {
36432
36488
  try {
36489
+ this.debug('onJSCall', key, data);
36433
36490
  const parsedData = parseJSON(data);
36434
36491
  if (this._jsCallFuncCallbacks[key]) {
36435
36492
  const callback = this._jsCallFuncCallbacks[key].callback;
@@ -36457,6 +36514,7 @@ class ZaloJSBridge extends eventemitter3 {
36457
36514
  }
36458
36515
  onMultiJSCall(key, data) {
36459
36516
  try {
36517
+ this.debug('onMultiJSCall', key, data);
36460
36518
  const parsedData = parseJSON(data);
36461
36519
  if (this._jsCallFuncCallbacks[key]) {
36462
36520
  const callback = this._jsCallFuncCallbacks[key].callback;
@@ -36484,7 +36542,28 @@ class ZaloJSBridge extends eventemitter3 {
36484
36542
  this.debug(`eventId: ${eventId}, eventName: ${eventName}, eventData: ${eventData}`);
36485
36543
  const data = stringToData(eventData);
36486
36544
  this.debug(data);
36487
- this.events.emit(eventName, eventId, data);
36545
+ const convertedData = this.handleEventData(eventName, data);
36546
+ this.events.emit(eventName, eventId, convertedData);
36547
+ }
36548
+ handleEventData(eventName, data) {
36549
+ try {
36550
+ switch (eventName) {
36551
+ case Events.OpenApp:
36552
+ const { url } = data;
36553
+ const validUrl = new URL(url);
36554
+ const path = validUrl.pathname.split(`/zapps/${APP_ID}`)[1];
36555
+ return {
36556
+ path: `${path ? path : '/'}${validUrl.search}`
36557
+ };
36558
+ break;
36559
+ default:
36560
+ return data;
36561
+ break;
36562
+ }
36563
+ }
36564
+ catch (error) {
36565
+ return data;
36566
+ }
36488
36567
  }
36489
36568
  defaultCallback(data) {
36490
36569
  if (data !== null && data !== undefined) {
@@ -36625,6 +36704,11 @@ class ZJSBridgeProvider {
36625
36704
  const error = new NativeError(-5, `${action}: Client isn't support this action`);
36626
36705
  return reject(error);
36627
36706
  }
36707
+ else if (option === null || option === void 0 ? void 0 : option.delay) {
36708
+ setTimeout(() => {
36709
+ __classPrivateFieldGet(this, _ZJSBridgeProvider_bridge).jsCall(action, data, fn, option === null || option === void 0 ? void 0 : option.isMultiCallback, option === null || option === void 0 ? void 0 : option.nRetry, option === null || option === void 0 ? void 0 : option.haveTimeout);
36710
+ }, option.delay);
36711
+ }
36628
36712
  else {
36629
36713
  __classPrivateFieldGet(this, _ZJSBridgeProvider_bridge).jsCall(action, data, fn, option === null || option === void 0 ? void 0 : option.isMultiCallback, option === null || option === void 0 ? void 0 : option.nRetry, option === null || option === void 0 ? void 0 : option.haveTimeout);
36630
36714
  }
@@ -36633,7 +36717,7 @@ class ZJSBridgeProvider {
36633
36717
  }
36634
36718
  _ZJSBridgeProvider_bridge = new WeakMap();
36635
36719
 
36636
- var version = "2.15.4";
36720
+ var version = "2.16.2";
36637
36721
 
36638
36722
  class Basics {
36639
36723
  /**
@@ -37566,6 +37650,27 @@ class Device {
37566
37650
  });
37567
37651
  });
37568
37652
  }
37653
+ /**
37654
+ * Connect Wifi.
37655
+ * @async
37656
+ * @function connectWifi
37657
+ * @category Device
37658
+ *
37659
+ */
37660
+ static connectWifi(object) {
37661
+ return __awaiter(this, void 0, void 0, function* () {
37662
+ let securityType = 'open';
37663
+ if (lodash.isString(object.password) && object.password.length > 0) {
37664
+ securityType = 'wpa_wpa2';
37665
+ }
37666
+ return yield this.callNative(ACTION.MP_JOIN_WIFI.name, {
37667
+ ssid: object.SSID,
37668
+ securityType: securityType,
37669
+ password: object.password,
37670
+ hiddenSsid: object.hiddenSSID
37671
+ });
37672
+ });
37673
+ }
37569
37674
  }
37570
37675
 
37571
37676
  var _LocalResourceStorage_storage, _LocalResourceStorage_prefix, _LocalResourceStorage_resourceInfo;
@@ -38056,7 +38161,8 @@ class OpenApi {
38056
38161
  else {
38057
38162
  return Promise.reject(error);
38058
38163
  }
38059
- }
38164
+ },
38165
+ delay: this.isIOS ? 200 : 0
38060
38166
  });
38061
38167
  });
38062
38168
  }
@@ -38160,7 +38266,8 @@ class Location {
38160
38266
  else {
38161
38267
  return Promise.reject(error);
38162
38268
  }
38163
- }
38269
+ },
38270
+ delay: this.isIOS ? 200 : 0
38164
38271
  });
38165
38272
  });
38166
38273
  }
@@ -38221,10 +38328,14 @@ class Media {
38221
38328
  return __awaiter(this, void 0, void 0, function* () {
38222
38329
  let data = {};
38223
38330
  if (!lodash.isEmpty(object.imageBase64Data)) {
38224
- data = Object.assign(Object.assign({}, data), { imageBase64Data: object.imageBase64Data });
38331
+ data = {
38332
+ imageBase64Data: object.imageBase64Data
38333
+ };
38225
38334
  }
38226
- else {
38227
- data = Object.assign(Object.assign({}, data), { imageUrl: object.imageUrl });
38335
+ else if (!lodash.isEmpty(object.imageUrl)) {
38336
+ data = {
38337
+ imageUrl: object.imageUrl
38338
+ };
38228
38339
  }
38229
38340
  return yield this.callNative(ACTION.SAVE_IMAGE_GALLERY.name, Object.assign({}, data));
38230
38341
  });
@@ -38411,17 +38522,25 @@ class Zalo {
38411
38522
  break;
38412
38523
  case 'zmp':
38413
38524
  const accessToken = yield this.getAccessToken();
38414
- if (lodash.isString(object.data.description)) {
38415
- object.data.description;
38416
- }
38417
- else if (lodash.isObject(object.data.description)) {
38418
- object.data.description.en || '';
38419
- object.data.description.vi || '';
38420
- }
38421
38525
  const zmpShareableInfo = yield getZMPShareInfo(this.getAppId(), accessToken || '', object.data.title, object.data.description, object.data.thumbnail, object.data.path);
38422
- getZaloVersion();
38423
- checkPlatform();
38424
- {
38526
+ if (window.forceShareZMP) {
38527
+ reqData = {
38528
+ data: {
38529
+ ZInstantAPIInfo: {
38530
+ url: `${zmpShareableInfo.zinstantApi}`,
38531
+ zinstantdata_id: `templateId=11412&appId=${this.getAppId()}&shareId=${zmpShareableInfo.shareId}`
38532
+ },
38533
+ previewMsgText: {
38534
+ msg: {
38535
+ en: 'Mini App',
38536
+ vi: 'Chương trình nhỏ'
38537
+ }
38538
+ },
38539
+ enableReactions: 1
38540
+ }
38541
+ };
38542
+ }
38543
+ else {
38425
38544
  reqData = {
38426
38545
  link: zmpShareableInfo.shareableLink,
38427
38546
  chatOnly: object.data.chatOnly ? 1 : 0
@@ -38450,11 +38569,23 @@ class Zalo {
38450
38569
  */
38451
38570
  static createShortcut(object) {
38452
38571
  return __awaiter(this, void 0, void 0, function* () {
38453
- yield this.callNative(ACTION.CREATE_SHORTCUT.name, {
38454
- url: `${CONFIG.MINI_APP_LINK}/${this.getAppId()}/`,
38455
- title: document.title,
38456
- iconUrl: `https:${getMetaValue('og:image:url')}`
38457
- });
38572
+ const isIOS = checkPlatform().isIOS;
38573
+ let iconURL = getMetaValue('og:image:url');
38574
+ if (!(iconURL === null || iconURL === void 0 ? void 0 : iconURL.includes('https'))) {
38575
+ iconURL = `https:${iconURL}`;
38576
+ }
38577
+ if (isIOS) {
38578
+ const iosShortcutURL = `https://mini.zalo.me/shortcut.html?appId=${this.getAppId()}&appName=${document.title}&appIcon=${iconURL}`;
38579
+ return yield this.callNative(ACTION.OPEN_OUTAPP.name, {
38580
+ url: encodeURI(iosShortcutURL)
38581
+ });
38582
+ }
38583
+ else
38584
+ return yield this.callNative(ACTION.CREATE_SHORTCUT.name, {
38585
+ url: `${CONFIG.MINI_APP_LINK}/${this.getAppId()}/`,
38586
+ title: document.title,
38587
+ iconUrl: iconURL
38588
+ });
38458
38589
  });
38459
38590
  }
38460
38591
  /**
@@ -38516,6 +38647,47 @@ class Zalo {
38516
38647
  });
38517
38648
  });
38518
38649
  }
38650
+ /**
38651
+ * Cho phép ứng dụng mở giao diện chọn media và get về list media url
38652
+ *
38653
+ * @async
38654
+ * @function openMediaPicker
38655
+ * @category Zalo
38656
+ *
38657
+ */
38658
+ static openMediaPicker(type, editView, silentRequest, maxSelectItem) {
38659
+ return __awaiter(this, void 0, void 0, function* () {
38660
+ const uploadSetting = {
38661
+ type: 0,
38662
+ url: CONFIG.MEDIA_PICKER_UPLOAD_SERVER,
38663
+ maxSize: CONFIG.MEDIA_PICKER_LIMIT
38664
+ };
38665
+ const defaultEditView = {
38666
+ enable: 1,
38667
+ aspect_ratio: '1:1'
38668
+ };
38669
+ return yield this.callNative(ACTION.PICK_MEDIA.name, {
38670
+ media_type: MediaPickerType[type],
38671
+ edit_view: Object.assign(Object.assign({}, defaultEditView), editView),
38672
+ silent_request: silentRequest,
38673
+ upload: uploadSetting,
38674
+ max_select_item: maxSelectItem
38675
+ }, {
38676
+ isMultiCallback: true,
38677
+ callback: (nativeData, error) => {
38678
+ var _a, _b;
38679
+ if (nativeData.error_code === 0) {
38680
+ const resultContent = stringToData((_a = nativeData.data) === null || _a === void 0 ? void 0 : _a.result_content);
38681
+ const res = {
38682
+ urls: (_b = resultContent === null || resultContent === void 0 ? void 0 : resultContent.data) === null || _b === void 0 ? void 0 : _b.urls
38683
+ };
38684
+ return Promise.resolve(res);
38685
+ }
38686
+ return Promise.reject(error);
38687
+ }
38688
+ });
38689
+ });
38690
+ }
38519
38691
  }
38520
38692
 
38521
38693
  class Routing {
@@ -38580,9 +38752,9 @@ class ZaloMiniProgramSDK extends ZJSBridgeProvider {
38580
38752
  constructor() {
38581
38753
  var _a, _b, _c, _d, _e, _f, _g, _h;
38582
38754
  super();
38583
- _ZaloMiniProgramSDK_zAppId.set(this, window.zAppID);
38584
- _ZaloMiniProgramSDK_appId.set(this, window.APP_ID);
38585
- _ZaloMiniProgramSDK_appConfig.set(this, window.APP_CONFIG || {});
38755
+ _ZaloMiniProgramSDK_zAppId.set(this, ZAPP_ID);
38756
+ _ZaloMiniProgramSDK_appId.set(this, APP_ID);
38757
+ _ZaloMiniProgramSDK_appConfig.set(this, APP_CONFIG);
38586
38758
  _ZaloMiniProgramSDK_zOAuth.set(this, void 0);
38587
38759
  _ZaloMiniProgramSDK_zOAuthVrf.set(this, void 0);
38588
38760
  _ZaloMiniProgramSDK_accessToken.set(this, void 0);
@@ -38596,6 +38768,7 @@ class ZaloMiniProgramSDK extends ZJSBridgeProvider {
38596
38768
  _ZaloMiniProgramSDK_tokenExpiresIn.set(this, void 0);
38597
38769
  _ZaloMiniProgramSDK_cookies.set(this, null);
38598
38770
  this.events = ZMPEEmitter.getInstance();
38771
+ this.isIOS = checkPlatform().isIOS;
38599
38772
  _ZaloMiniProgramSDK_actionBarConfig.set(this, void 0);
38600
38773
  this.getActionBarConfig = () => {
38601
38774
  return __classPrivateFieldGet(this, _ZaloMiniProgramSDK_actionBarConfig);
@@ -38686,6 +38859,8 @@ class ZaloMiniProgramSDK extends ZJSBridgeProvider {
38686
38859
  this.getPhoneNumber = OpenApi.getPhoneNumber;
38687
38860
  this.openProfilePicker = Zalo.openProfilePicker;
38688
38861
  _ZaloMiniProgramSDK_getActionsSupported.set(this, Zalo.getActionsSupported);
38862
+ this.connectWifi = Device.connectWifi;
38863
+ this.openMediaPicker = Zalo.openMediaPicker;
38689
38864
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_zOAuth, null);
38690
38865
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_zOAuthVrf, null);
38691
38866
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_accessToken, null);
@@ -38844,8 +39019,8 @@ _ZaloMiniProgramSDK_zAppId = new WeakMap(), _ZaloMiniProgramSDK_appId = new Weak
38844
39019
  var _MockSDK_appId, _MockSDK_appConfig, _MockSDK_zOAuth, _MockSDK_accessToken, _MockSDK_cache, _MockSDK_loggedId;
38845
39020
  class MockSDK {
38846
39021
  constructor() {
38847
- _MockSDK_appId.set(this, window.zAppID);
38848
- _MockSDK_appConfig.set(this, window.APP_CONFIG || {});
39022
+ _MockSDK_appId.set(this, ZAPP_ID);
39023
+ _MockSDK_appConfig.set(this, APP_CONFIG);
38849
39024
  _MockSDK_zOAuth.set(this, 'DEFAULT ZOAUTH');
38850
39025
  _MockSDK_accessToken.set(this, 'DEFAULT ACCESS TOKEN');
38851
39026
  _MockSDK_cache.set(this, {
@@ -39148,6 +39323,10 @@ class MockSDK {
39148
39323
  userIDs: []
39149
39324
  });
39150
39325
  };
39326
+ this.connectWifi = () => {
39327
+ console.warn('This api only works on zalo app');
39328
+ return Promise.resolve();
39329
+ };
39151
39330
  }
39152
39331
  on(event, fn, context) {
39153
39332
  throw new Error('Method not implemented.');
@@ -39161,6 +39340,12 @@ class MockSDK {
39161
39340
  removeAllListeners(event) {
39162
39341
  throw new Error('Method not implemented.');
39163
39342
  }
39343
+ openMediaPicker(type, editView, silentRequest, maxSelectItem) {
39344
+ console.warn('This api only works on zalo app');
39345
+ return Promise.resolve({
39346
+ urls: []
39347
+ });
39348
+ }
39164
39349
  }
39165
39350
  _MockSDK_appId = new WeakMap(), _MockSDK_appConfig = new WeakMap(), _MockSDK_zOAuth = new WeakMap(), _MockSDK_accessToken = new WeakMap(), _MockSDK_cache = new WeakMap(), _MockSDK_loggedId = new WeakMap();
39166
39351
 
@@ -40298,21 +40483,22 @@ var Reflect$1;
40298
40483
 
40299
40484
  const requiredMetadataKey = Symbol('required');
40300
40485
  const checkTypeMetadataKey = Symbol('checkType');
40301
- const required = (...args) => (target, propertyKey, parameterIndex) => {
40486
+ const required = (fields, option) => (target, propertyKey, parameterIndex) => {
40302
40487
  let existingRequiredParameters = Reflect.getOwnMetadata(requiredMetadataKey, target, propertyKey) || [];
40303
40488
  existingRequiredParameters.push({
40304
40489
  parameterIndex: parameterIndex,
40305
- fields: args
40490
+ fields: fields,
40491
+ option
40306
40492
  });
40307
40493
  Reflect.defineMetadata(requiredMetadataKey, existingRequiredParameters, target, propertyKey);
40308
40494
  };
40309
- const checkType = (type, properties, key) => (target, propertyKey, parameterIndex) => {
40495
+ const checkType = (type, properties, defaultValue) => (target, propertyKey, parameterIndex) => {
40310
40496
  let existingTypeCheckParameters = Reflect.getOwnMetadata(checkTypeMetadataKey, target, propertyKey) || [];
40311
40497
  existingTypeCheckParameters.push({
40312
40498
  parameterIndex: parameterIndex,
40313
40499
  type: type,
40314
40500
  properties: properties,
40315
- key: key
40501
+ defaultValue: defaultValue
40316
40502
  });
40317
40503
  Reflect.defineMetadata(checkTypeMetadataKey, existingTypeCheckParameters, target, propertyKey);
40318
40504
  };
@@ -40332,18 +40518,9 @@ const validate = (target, propertyName, descriptor) => {
40332
40518
  const checkTypeParameters = Reflect.getOwnMetadata(checkTypeMetadataKey, target, propertyName);
40333
40519
  if (checkTypeParameters) {
40334
40520
  checkTypeParameters.forEach((parameter) => {
40335
- const { parameterIndex, type, properties, key } = parameter;
40521
+ const { parameterIndex, type, properties, defaultValue } = parameter;
40336
40522
  let argument = arguments[parameterIndex];
40337
40523
  let argumentName = argsName[parameterIndex];
40338
- if (!lodash.isEmpty(key)) {
40339
- const deepFields = key === null || key === void 0 ? void 0 : key.split('.');
40340
- if (Array.isArray(deepFields) && deepFields.length > 0) {
40341
- deepFields.forEach((level) => {
40342
- argument = argument[level];
40343
- argumentName = `${argumentName}.${level}`;
40344
- });
40345
- }
40346
- }
40347
40524
  const parameterType = typeof argument;
40348
40525
  if (!lodash.isUndefined(argument)) {
40349
40526
  if (!isType(argument, type)) {
@@ -40355,20 +40532,24 @@ const validate = (target, propertyName, descriptor) => {
40355
40532
  }
40356
40533
  if (type === 'object') {
40357
40534
  Object.entries(properties).forEach(([propKey, propType]) => {
40358
- const propField = argument[propKey];
40359
- if (!lodash.isUndefined(propField)) {
40360
- if (Array.isArray(propType) && !propType.includes(propField)) {
40361
- throw apiResponse.error.wrongTypeParam(`${argumentName}.${propKey}`, `${propType}`.replace(/,/g, '|'), `'${propField}'`);
40362
- }
40363
- else if (!Array.isArray(propType) &&
40364
- !isType(propField, propType)) {
40365
- throw apiResponse.error.wrongTypeParam(`${argumentName}.${propKey}`, propType, Array.isArray(propField)
40366
- ? 'array'
40367
- : propField === null
40368
- ? 'null'
40369
- : typeof propField);
40535
+ const key = propKey.split('?')[0];
40536
+ const propValue = lodash.get(argument, key);
40537
+ if (!lodash.isUndefined(propValue) && !lodash.isNull(propValue)) {
40538
+ if (lodash.isFunction(propType)) {
40539
+ const res = propType(propValue);
40540
+ if (res && res.error) {
40541
+ throw apiResponse.error.wrongTypeParam(`${argumentName}.${key}`, res.errorMessage, typeof propValue);
40542
+ }
40370
40543
  }
40371
40544
  }
40545
+ else if (!propKey.includes('?')) {
40546
+ throw apiResponse.error.missingParam(propKey);
40547
+ }
40548
+ else if (lodash.isObject(lodash.get(argument, key.split('.')[0])) &&
40549
+ defaultValue &&
40550
+ !lodash.isUndefined(lodash.get(defaultValue, key))) {
40551
+ lodash.set(arguments[parameterIndex], key, lodash.get(defaultValue, key));
40552
+ }
40372
40553
  });
40373
40554
  }
40374
40555
  }
@@ -40376,18 +40557,24 @@ const validate = (target, propertyName, descriptor) => {
40376
40557
  }
40377
40558
  if (requiredParameters) {
40378
40559
  requiredParameters.forEach((parameter) => {
40379
- const { parameterIndex, fields } = parameter;
40560
+ const { parameterIndex, option, fields } = parameter;
40380
40561
  const argument = arguments[parameterIndex];
40381
- const argumentName = argsName[parameterIndex];
40382
- const parameterType = typeof argument;
40383
- if (!Array.isArray(argument) &&
40384
- parameterType === 'object' &&
40385
- fields.some((field) => lodash.isUndefined(argument[field]))) {
40386
- throw apiResponse.error.missingParam(`${fields} in ${argumentName}`);
40562
+ const condition = option === null || option === void 0 ? void 0 : option.if;
40563
+ const defaultValue = option === null || option === void 0 ? void 0 : option.defaultValue;
40564
+ let isMeetCondition = true;
40565
+ if (condition) {
40566
+ isMeetCondition = Object.keys(condition).every((key) => lodash.get(argument, key) === condition[key]);
40387
40567
  }
40388
- else if (parameterType !== 'object' &&
40389
- (parameterIndex >= arguments.length || lodash.isUndefined(argument))) {
40390
- throw apiResponse.error.missingParam(argumentName);
40568
+ if (isMeetCondition) {
40569
+ fields.forEach((field) => {
40570
+ if (lodash.isEmpty(lodash.get(argument, field))) {
40571
+ if (!lodash.isUndefined(lodash.get(defaultValue, field))) {
40572
+ lodash.set(arguments[parameterIndex], field, lodash.get(defaultValue, field));
40573
+ }
40574
+ else
40575
+ throw apiResponse.error.missingParam(field);
40576
+ }
40577
+ });
40391
40578
  }
40392
40579
  });
40393
40580
  }
@@ -40608,26 +40795,6 @@ class SDKCreator {
40608
40795
  }
40609
40796
  openPostFeed(object) {
40610
40797
  return __awaiter(this, void 0, void 0, function* () {
40611
- const type = object.type;
40612
- if (type === 'image' && isEmpty(object.data.imageUrl)) {
40613
- throw apiResponse.error.wrongTypeParam('object.data.imageUrl', 'valid url', 'invalid');
40614
- }
40615
- else if (type === 'link' &&
40616
- (isEmpty(object.data.link) || !isValidUrl(object.data.link))) {
40617
- throw apiResponse.error.wrongTypeParam('object.data.link', 'valid url', 'invalid');
40618
- }
40619
- else if (type === 'profile') {
40620
- if (isEmpty(object.data.id)) {
40621
- throw apiResponse.error.wrongTypeParam('object.data.id', 'valid id', 'empty');
40622
- }
40623
- else if (isEmpty(object.data.avatar) ||
40624
- !isValidUrl(object.data.avatar)) {
40625
- throw apiResponse.error.wrongTypeParam('object.data.avatar', 'valid url', 'invalid');
40626
- }
40627
- else if (isEmpty(object.data.displayName)) {
40628
- throw apiResponse.error.wrongTypeParam('object.data.displayName', 'valid displayName', 'empty');
40629
- }
40630
- }
40631
40798
  return yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).openPostFeed(object);
40632
40799
  });
40633
40800
  }
@@ -40643,61 +40810,6 @@ class SDKCreator {
40643
40810
  }
40644
40811
  openShareSheet(object) {
40645
40812
  return __awaiter(this, void 0, void 0, function* () {
40646
- const type = object.type;
40647
- if (type === 'image' && isEmpty(object.data.imageUrl)) {
40648
- throw apiResponse.error.wrongTypeParam('object.data.imageUrl', 'valid url', 'invalid');
40649
- }
40650
- else if (type === 'gif' &&
40651
- (isEmpty(object.data.gifUrl) || !isValidUrl(object.data.gifUrl))) {
40652
- throw apiResponse.error.wrongTypeParam('object.data.gifUrl', 'valid url', 'invalid');
40653
- }
40654
- else if (type === 'video') {
40655
- if (isEmpty(object.data.videoThumb) ||
40656
- !isValidUrl(object.data.videoThumb)) {
40657
- throw apiResponse.error.wrongTypeParam('object.data.videoThumb', 'valid url', 'invalid');
40658
- }
40659
- else if (isEmpty(object.data.videoUrl) ||
40660
- !isValidUrl(object.data.videoUrl)) {
40661
- throw apiResponse.error.wrongTypeParam('object.data.videoUrl', 'valid url', 'invalid');
40662
- }
40663
- }
40664
- else if (type === 'link' &&
40665
- (isEmpty(object.data.link) || !isValidUrl(object.data.link))) {
40666
- throw apiResponse.error.wrongTypeParam('object.data.link', 'valid url', 'invalid');
40667
- }
40668
- else if (type === 'oa' && isEmpty(object.data.id)) {
40669
- throw apiResponse.error.wrongTypeParam('object.data.id', 'valid id', 'empty');
40670
- }
40671
- else if (type === 'zmp') {
40672
- if (lodash.isNull(object.data.title) || lodash.isNull(object.data.description)) {
40673
- throw apiResponse.error.missingParam([
40674
- 'data.title',
40675
- 'data.description'
40676
- ]);
40677
- }
40678
- else {
40679
- const title = object.data.title;
40680
- const description = {
40681
- vi: '',
40682
- en: ''
40683
- };
40684
- if (lodash.isString(object.data.description)) {
40685
- description.en = description.vi = object.data.description;
40686
- }
40687
- else if (lodash.isObject(object.data.description)) {
40688
- description.en = object.data.description.en || '';
40689
- description.vi = object.data.description.vi || '';
40690
- }
40691
- else {
40692
- throw apiResponse.error.wrongTypeParam('data.description', 'string | {vi: string, en: string}', typeof object.data.description);
40693
- }
40694
- if (title.length > 100 ||
40695
- description.vi.length > 400 ||
40696
- description.en.length > 400)
40697
- throw apiResponse.error.lengthInvalid(`'title' or 'description'`);
40698
- object.data.description = description;
40699
- }
40700
- }
40701
40813
  return yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).openShareSheet(object);
40702
40814
  });
40703
40815
  }
@@ -40712,20 +40824,7 @@ class SDKCreator {
40712
40824
  });
40713
40825
  }
40714
40826
  openBioAuthentication(object) {
40715
- var _a;
40716
40827
  return __awaiter(this, void 0, void 0, function* () {
40717
- if (lodash.isUndefined(object.requireFingerprint)) {
40718
- object.requireFingerprint = true;
40719
- }
40720
- if (isEmpty((_a = object.ui) === null || _a === void 0 ? void 0 : _a.title)) {
40721
- object.ui = Object.assign(Object.assign({}, object.ui), { title: 'Xác thực' });
40722
- }
40723
- if (isEmpty(object.ui.subTitle)) {
40724
- object.ui = Object.assign(Object.assign({}, object.ui), { subTitle: 'Sử dụng sinh trắc học của bạn để xác thực' });
40725
- }
40726
- if (isEmpty(object.ui.negativeButtonText)) {
40727
- object.ui = Object.assign(Object.assign({}, object.ui), { negativeButtonText: 'Đóng' });
40728
- }
40729
40828
  return yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).openBioAuthentication(object);
40730
40829
  });
40731
40830
  }
@@ -40756,17 +40855,11 @@ class SDKCreator {
40756
40855
  }
40757
40856
  openSMS(object) {
40758
40857
  return __awaiter(this, void 0, void 0, function* () {
40759
- if (!/^\+?\d+$/.test(object.phoneNumber)) {
40760
- throw apiResponse.error.wrongTypeParam('object.phoneNumber', 'valid phone', 'invalid');
40761
- }
40762
40858
  yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).openSMS(object);
40763
40859
  });
40764
40860
  }
40765
40861
  viewOAQr(object) {
40766
40862
  return __awaiter(this, void 0, void 0, function* () {
40767
- if (lodash.isUndefined(object.displayName) || lodash.isNull(object.displayName)) {
40768
- object.displayName = '';
40769
- }
40770
40863
  yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).viewOAQr(object);
40771
40864
  });
40772
40865
  }
@@ -40775,14 +40868,13 @@ class SDKCreator {
40775
40868
  return yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).keepScreen(object);
40776
40869
  });
40777
40870
  }
40871
+ saveImageToGallery(object) {
40872
+ return __awaiter(this, void 0, void 0, function* () {
40873
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).saveImageToPhotosAlbum(object);
40874
+ });
40875
+ }
40778
40876
  saveImageToPhotosAlbum(object) {
40779
40877
  return __awaiter(this, void 0, void 0, function* () {
40780
- if (isEmpty(object.imageBase64Data) && isEmpty(object.imageUrl)) {
40781
- throw apiResponse.error.wrongTypeParam('object.imageBase64Data | object.imageUrl', 'valid data', 'invalid');
40782
- }
40783
- if (!isEmpty(object.imageUrl) && !isValidUrl(object.imageUrl)) {
40784
- throw apiResponse.error.wrongTypeParam('object.imageUrl', 'valid url', 'invalid');
40785
- }
40786
40878
  return yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).saveImageToPhotosAlbum(object);
40787
40879
  });
40788
40880
  }
@@ -40803,12 +40895,6 @@ class SDKCreator {
40803
40895
  }
40804
40896
  vibrate(object) {
40805
40897
  return __awaiter(this, void 0, void 0, function* () {
40806
- if (isEmpty(object.type)) {
40807
- object.type = 'oneShot';
40808
- }
40809
- if (isEmpty(object.milliseconds)) {
40810
- object.milliseconds = 500;
40811
- }
40812
40898
  yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).vibrate(object);
40813
40899
  });
40814
40900
  }
@@ -40837,41 +40923,33 @@ class SDKCreator {
40837
40923
  });
40838
40924
  }
40839
40925
  openProfilePicker(object) {
40840
- if (lodash.isUndefined(object.maxProfile) || object.maxProfile < 1) {
40841
- object.maxProfile = 1;
40842
- }
40843
- else if (object.maxProfile > 10) {
40844
- throw apiResponse.error.badRequest('maxProfile must be in between 1 and 10');
40845
- }
40846
- return __classPrivateFieldGet(this, _SDKCreator_sdkManager).openProfilePicker(object);
40926
+ return __awaiter(this, void 0, void 0, function* () {
40927
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).openProfilePicker(object);
40928
+ });
40847
40929
  }
40848
- getShareableLink(object) {
40930
+ connectWifi(object) {
40849
40931
  return __awaiter(this, void 0, void 0, function* () {
40850
- if (lodash.isNull(object.title) || lodash.isNull(object.description)) {
40851
- throw apiResponse.error.missingParam(['data.title', 'data.description']);
40932
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).connectWifi(object);
40933
+ });
40934
+ }
40935
+ openMediaPicker(object) {
40936
+ var _a, _b, _c;
40937
+ return __awaiter(this, void 0, void 0, function* () {
40938
+ const editView = {};
40939
+ if (lodash.isUndefined((_a = object.editView) === null || _a === void 0 ? void 0 : _a.enable) || ((_b = object.editView) === null || _b === void 0 ? void 0 : _b.enable)) {
40940
+ editView.enable = 1;
40852
40941
  }
40853
40942
  else {
40854
- const title = object.title;
40855
- const description = {
40856
- vi: '',
40857
- en: ''
40858
- };
40859
- if (lodash.isString(object.description)) {
40860
- description.en = description.vi = object.description;
40861
- }
40862
- else if (lodash.isObject(object.description)) {
40863
- description.en = object.description.en || '';
40864
- description.vi = object.description.vi || '';
40865
- }
40866
- else {
40867
- throw apiResponse.error.wrongTypeParam('data.description', 'string | {vi: string, en: string}', typeof object.description);
40868
- }
40869
- if (title.length > 100 ||
40870
- description.vi.length > 400 ||
40871
- description.en.length > 400)
40872
- throw apiResponse.error.lengthInvalid(`'title' or 'description'`);
40873
- object.description = description;
40943
+ editView.enable = 0;
40874
40944
  }
40945
+ editView.aspect_ratio = (_c = object.editView) === null || _c === void 0 ? void 0 : _c.aspectRatio;
40946
+ const silentRequest = object.silentRequest === true ? 1 : 0;
40947
+ const maxSelectItem = object.maxSelectItem;
40948
+ return yield __classPrivateFieldGet(this, _SDKCreator_sdkManager).openMediaPicker(object.type, editView, silentRequest, maxSelectItem);
40949
+ });
40950
+ }
40951
+ getShareableLink(object) {
40952
+ return __awaiter(this, void 0, void 0, function* () {
40875
40953
  const accessToken = yield this.getAccessToken();
40876
40954
  const zmpShareableInfo = yield getZMPShareInfo(window.APP_ID, accessToken || '', object.title, object.description, object.thumbnail, object.path);
40877
40955
  return zmpShareableInfo.shareableLink;
@@ -40898,60 +40976,53 @@ __decorate([
40898
40976
  handleError,
40899
40977
  validate,
40900
40978
  __param(0, checkType('object', {
40901
- title: 'string'
40902
- })),
40903
- __param(0, required('title'))
40979
+ title: checkData('string')
40980
+ }))
40904
40981
  ], SDKCreator.prototype, "setNavigationBarTitle", null);
40905
40982
  __decorate([
40906
40983
  handleError,
40907
40984
  validate,
40908
40985
  __param(0, checkType('object', {
40909
- color: 'string',
40910
- textColor: ['white', 'black'],
40911
- statusBarColor: 'string'
40912
- })),
40913
- __param(0, required('color'))
40986
+ color: checkData('string'),
40987
+ 'textColor?': checkData('string', { values: ['white', 'black'] }),
40988
+ 'statusBarColor?': checkData('string')
40989
+ }))
40914
40990
  ], SDKCreator.prototype, "setNavigationBarColor", null);
40915
40991
  __decorate([
40916
40992
  handleError,
40917
40993
  validate,
40918
40994
  __param(0, checkType('object', {
40919
- backgroundColor: 'string',
40920
- textColor: ['white', 'black']
40921
- })),
40922
- __param(0, required('backgroundColor'))
40995
+ backgroundColor: checkData('string'),
40996
+ 'textColor?': checkData('string', { values: ['white', 'black'] })
40997
+ }))
40923
40998
  ], SDKCreator.prototype, "setBackgroundColor", null);
40924
40999
  __decorate([
40925
41000
  handleError,
40926
41001
  validate,
40927
41002
  __param(0, checkType('object', {
40928
- type: ['none', 'back', 'home', 'both']
40929
- })),
40930
- __param(0, required('type'))
41003
+ type: checkData('string', { values: ['none', 'back', 'home', 'both'] })
41004
+ }))
40931
41005
  ], SDKCreator.prototype, "setNavigationBarLeftButton", null);
40932
41006
  __decorate([
40933
41007
  handleError,
40934
41008
  validate,
40935
41009
  __param(0, checkType('object', {
40936
- rotate: ['auto', 'portrait', 'landscape']
40937
- })),
40938
- __param(0, required('rotate'))
41010
+ rotate: checkData('string', { values: ['auto', 'portrait', 'landscape'] })
41011
+ }))
40939
41012
  ], SDKCreator.prototype, "setDeviceOrientation", null);
40940
41013
  __decorate([
40941
41014
  handleError,
40942
41015
  validate,
40943
41016
  __param(0, checkType('object', {
40944
- data: 'object'
40945
- })),
40946
- __param(0, required('data'))
41017
+ data: checkData('object')
41018
+ }))
40947
41019
  ], SDKCreator.prototype, "setStorage", null);
40948
41020
  __decorate([
40949
41021
  handleError,
40950
41022
  validate,
40951
41023
  __param(0, checkType('object', {
40952
- keys: 'array<string>'
40953
- })),
40954
- __param(0, required('keys'))
41024
+ keys: checkData('array<string>')
41025
+ }))
40955
41026
  ], SDKCreator.prototype, "getStorage", null);
40956
41027
  __decorate([
40957
41028
  handleError
@@ -40960,9 +41031,8 @@ __decorate([
40960
41031
  handleError,
40961
41032
  validate,
40962
41033
  __param(0, checkType('object', {
40963
- keys: 'array<string>'
40964
- })),
40965
- __param(0, required('keys'))
41034
+ keys: checkData('array<string>')
41035
+ }))
40966
41036
  ], SDKCreator.prototype, "removeStorage", null);
40967
41037
  __decorate([
40968
41038
  handleError
@@ -40971,7 +41041,9 @@ __decorate([
40971
41041
  handleError,
40972
41042
  validate,
40973
41043
  __param(0, checkType('object', {
40974
- avatarType: ['small', 'normal', 'large']
41044
+ 'avatarType?': checkData('string', {
41045
+ values: ['small', 'normal', 'large']
41046
+ })
40975
41047
  }))
40976
41048
  ], SDKCreator.prototype, "getUserInfo", null);
40977
41049
  __decorate([
@@ -41029,78 +41101,89 @@ __decorate([
41029
41101
  handleError,
41030
41102
  validate,
41031
41103
  __param(0, checkType('object', {
41032
- type: ['user', 'oa', 'aliasOA'],
41033
- id: 'string'
41034
- })),
41035
- __param(0, required('type', 'id'))
41104
+ type: checkData('string', { values: ['user', 'oa', 'aliasOA'] }),
41105
+ id: checkData('string')
41106
+ }))
41036
41107
  ], SDKCreator.prototype, "openProfile", null);
41037
41108
  __decorate([
41038
41109
  handleError,
41039
41110
  validate,
41040
41111
  __param(0, checkType('object', {
41041
- type: ['user', 'oa'],
41042
- id: 'string'
41043
- })),
41044
- __param(0, required('type', 'id'))
41112
+ type: checkData('string', { values: ['user', 'oa'] }),
41113
+ id: checkData('string')
41114
+ }))
41045
41115
  ], SDKCreator.prototype, "openChat", null);
41046
41116
  __decorate([
41047
41117
  handleError,
41048
41118
  validate,
41119
+ __param(0, required(['data.imageUrl'], { if: { type: 'image' } })),
41120
+ __param(0, required(['data.link'], { if: { type: 'link' } })),
41121
+ __param(0, required(['data.id'], { if: { type: 'profile' } })),
41049
41122
  __param(0, checkType('object', {
41050
- type: ['image', 'link', 'profile'],
41051
- data: 'object'
41052
- })),
41053
- __param(0, checkType('object', {
41054
- imageUrl: 'string',
41055
- link: 'string',
41056
- title: 'string',
41057
- thumb: 'string',
41058
- description: 'string',
41059
- avatar: 'string',
41060
- id: 'string',
41061
- displayName: 'string'
41062
- }, 'data')),
41063
- __param(0, required('type', 'data'))
41123
+ type: checkData('string', { values: ['image', 'link', 'profile'] }),
41124
+ data: checkData('object'),
41125
+ 'data.imageUrl?': checkData('url'),
41126
+ 'data.link?': checkData('url'),
41127
+ 'data.title?': checkData('string'),
41128
+ 'data.thumb?': checkData('url'),
41129
+ 'data.description?': checkData('string'),
41130
+ 'data.avatar?': checkData('url'),
41131
+ 'data.id?': checkData('string'),
41132
+ 'data.displayName?': checkData('string')
41133
+ }))
41064
41134
  ], SDKCreator.prototype, "openPostFeed", null);
41065
41135
  __decorate([
41066
41136
  handleError,
41067
41137
  validate,
41068
41138
  __param(0, checkType('object', {
41069
- id: 'string',
41070
- showDialogConfirm: 'boolean'
41071
- })),
41072
- __param(0, required('id'))
41139
+ id: checkData('string'),
41140
+ 'showDialogConfirm?': checkData('boolean')
41141
+ }))
41073
41142
  ], SDKCreator.prototype, "followOA", null);
41074
41143
  __decorate([
41075
41144
  handleError,
41076
41145
  validate,
41077
41146
  __param(0, checkType('object', {
41078
- id: 'string'
41079
- })),
41080
- __param(0, required('id'))
41147
+ id: checkData('string')
41148
+ }))
41081
41149
  ], SDKCreator.prototype, "unfollowOA", null);
41082
41150
  __decorate([
41083
41151
  handleError,
41084
41152
  validate,
41085
- __param(0, checkType('object', {
41086
- type: ['image', 'gif', 'video', 'link', 'oa', 'zmp'],
41087
- data: 'object'
41153
+ __param(0, required(['data.imageUrl'], { if: { type: 'image' } })),
41154
+ __param(0, required(['data.link'], { if: { type: 'link' } })),
41155
+ __param(0, required(['data.id'], { if: { type: 'oa' } })),
41156
+ __param(0, required(['data.gifUrl'], { if: { type: 'gif' } })),
41157
+ __param(0, required(['data.videoThumb', 'data.videoUrl'], { if: { type: 'video' } })),
41158
+ __param(0, required(['data.thumbnail', 'data.title', 'data.description'], {
41159
+ if: { type: 'zmp' },
41160
+ defaultValue: {
41161
+ data: {
41162
+ description: ''
41163
+ }
41164
+ }
41088
41165
  })),
41089
41166
  __param(0, checkType('object', {
41090
- imageUrl: 'string',
41091
- gifUrl: 'string',
41092
- width: 'number',
41093
- height: 'number',
41094
- videoThumb: 'string',
41095
- videoUrl: 'string',
41096
- link: 'string',
41097
- chatOnly: 'boolean',
41098
- id: 'string',
41099
- title: 'string',
41100
- thumbnail: 'url',
41101
- path: 'string'
41102
- }, 'data')),
41103
- __param(0, required('type', 'data'))
41167
+ type: checkData('string', {
41168
+ values: ['image', 'gif', 'video', 'link', 'oa', 'zmp']
41169
+ }),
41170
+ data: checkData('object'),
41171
+ 'data.imageUrl?': checkData('url'),
41172
+ 'data.gifUrl?': checkData('url'),
41173
+ 'data.width?': checkData('number'),
41174
+ 'data.height?': checkData('number'),
41175
+ 'data.videoThumb?': checkData('url'),
41176
+ 'data.videoUrl?': checkData('url'),
41177
+ 'data.link?': checkData('url'),
41178
+ 'data.chatOnly?': checkData('boolean'),
41179
+ 'data.id?': checkData('string'),
41180
+ 'data.thumbnail?': checkData('url'),
41181
+ 'data.path?': checkData('string'),
41182
+ 'data.title?': checkData('string', { maxLength: 100 }),
41183
+ 'data.description?': checkData(['string'], {
41184
+ maxLength: 400
41185
+ })
41186
+ }))
41104
41187
  ], SDKCreator.prototype, "openShareSheet", null);
41105
41188
  __decorate([
41106
41189
  handleError
@@ -41111,17 +41194,21 @@ __decorate([
41111
41194
  __decorate([
41112
41195
  handleError,
41113
41196
  validate,
41114
- __param(0, required('secretData')),
41115
41197
  __param(0, checkType('object', {
41116
- secretData: 'string',
41117
- ui: 'object',
41118
- requireFingerprint: 'boolean'
41119
- })),
41120
- __param(0, checkType('object', {
41121
- title: 'string',
41122
- subTitle: 'string',
41123
- negativeButtonText: 'string'
41124
- }, 'ui'))
41198
+ secretData: checkData('string'),
41199
+ 'ui?': checkData('object'),
41200
+ 'ui.title?': checkData('string'),
41201
+ 'ui.subTitle?': checkData('string'),
41202
+ 'ui.negativeButtonText?': checkData('string'),
41203
+ 'requireFingerprint?': checkData('boolean')
41204
+ }, {
41205
+ requireFingerprint: true,
41206
+ ui: {
41207
+ title: 'Xác thực',
41208
+ subTitle: 'Sử dụng sinh trắc học của bạn để xác thực',
41209
+ negativeButtonText: 'Đóng'
41210
+ }
41211
+ }))
41125
41212
  ], SDKCreator.prototype, "openBioAuthentication", null);
41126
41213
  __decorate([
41127
41214
  handleError
@@ -41129,12 +41216,17 @@ __decorate([
41129
41216
  __decorate([
41130
41217
  handleError,
41131
41218
  validate,
41132
- __param(0, required('toUserId'))
41219
+ __param(0, checkType('object', {
41220
+ toUserId: checkData('string'),
41221
+ 'title?': checkData('string')
41222
+ }))
41133
41223
  ], SDKCreator.prototype, "sendLocation", null);
41134
41224
  __decorate([
41135
41225
  handleError,
41136
41226
  validate,
41137
- __param(0, required('message'))
41227
+ __param(0, checkType('object', {
41228
+ message: checkData('string')
41229
+ }))
41138
41230
  ], SDKCreator.prototype, "showToast", null);
41139
41231
  __decorate([
41140
41232
  handleError
@@ -41142,27 +41234,26 @@ __decorate([
41142
41234
  __decorate([
41143
41235
  handleError,
41144
41236
  validate,
41145
- __param(0, required('phoneNumber')),
41146
41237
  __param(0, checkType('object', {
41147
- phoneNumber: 'string'
41238
+ phoneNumber: checkData('string')
41148
41239
  }))
41149
41240
  ], SDKCreator.prototype, "openPhone", null);
41150
41241
  __decorate([
41151
41242
  handleError,
41152
41243
  validate,
41153
- __param(0, required('content', 'phoneNumber')),
41154
41244
  __param(0, checkType('object', {
41155
- content: 'string',
41156
- phoneNumber: 'string'
41245
+ content: checkData('string'),
41246
+ phoneNumber: checkData('string', { regex: /^\+?\d+$/ })
41157
41247
  }))
41158
41248
  ], SDKCreator.prototype, "openSMS", null);
41159
41249
  __decorate([
41160
41250
  handleError,
41161
41251
  validate,
41162
- __param(0, required('id')),
41163
41252
  __param(0, checkType('object', {
41164
- id: 'string',
41165
- displayName: 'string'
41253
+ id: checkData('string'),
41254
+ 'displayName?': checkData('string')
41255
+ }, {
41256
+ displayName: ''
41166
41257
  }))
41167
41258
  ], SDKCreator.prototype, "viewOAQr", null);
41168
41259
  __decorate([
@@ -41172,34 +41263,42 @@ __decorate([
41172
41263
  handleError,
41173
41264
  validate,
41174
41265
  __param(0, checkType('object', {
41175
- imageBase64Data: 'string',
41176
- imageUrl: 'string',
41177
- type: 'string'
41266
+ 'imageBase64Data?': checkData('string'),
41267
+ 'imageUrl?': checkData('url')
41268
+ }))
41269
+ ], SDKCreator.prototype, "saveImageToGallery", null);
41270
+ __decorate([
41271
+ handleError,
41272
+ validate,
41273
+ __param(0, checkType('object', {
41274
+ 'imageBase64Data?': checkData('string'),
41275
+ 'imageUrl?': checkData('url')
41178
41276
  }))
41179
41277
  ], SDKCreator.prototype, "saveImageToPhotosAlbum", null);
41180
41278
  __decorate([
41181
41279
  handleError,
41182
41280
  validate,
41183
- __param(0, required('appId')),
41184
41281
  __param(0, checkType('object', {
41185
- appId: 'string',
41186
- params: 'object'
41282
+ appId: checkData('string'),
41283
+ 'params?': checkData('object')
41187
41284
  }))
41188
41285
  ], SDKCreator.prototype, "openMiniApp", null);
41189
41286
  __decorate([
41190
41287
  handleError,
41191
41288
  validate,
41192
41289
  __param(0, checkType('object', {
41193
- type: ['oneShot'],
41194
- milliseconds: 'number'
41290
+ 'type?': checkData('string', { values: ['oneShot'] }),
41291
+ 'milliseconds?': checkData('number')
41292
+ }, {
41293
+ type: 'oneShot',
41294
+ milliseconds: 500
41195
41295
  }))
41196
41296
  ], SDKCreator.prototype, "vibrate", null);
41197
41297
  __decorate([
41198
41298
  handleError,
41199
41299
  validate,
41200
- __param(0, required('url')),
41201
41300
  __param(0, checkType('object', {
41202
- url: 'string'
41301
+ url: checkData('string')
41203
41302
  }))
41204
41303
  ], SDKCreator.prototype, "openWebview", null);
41205
41304
  __decorate([
@@ -41221,16 +41320,45 @@ __decorate([
41221
41320
  handleError,
41222
41321
  validate,
41223
41322
  __param(0, checkType('object', {
41224
- maxProfile: 'number'
41323
+ 'maxProfile?': checkData('number', { min: 1, max: 10 })
41324
+ }, {
41325
+ maxProfile: 1
41225
41326
  }))
41226
41327
  ], SDKCreator.prototype, "openProfilePicker", null);
41328
+ __decorate([
41329
+ handleError,
41330
+ validate,
41331
+ __param(0, required(['SSID'])),
41332
+ __param(0, checkType('object', {
41333
+ SSID: checkData('string'),
41334
+ 'password?': checkData('string'),
41335
+ 'hiddenSSID?': checkData('boolean')
41336
+ }))
41337
+ ], SDKCreator.prototype, "connectWifi", null);
41338
+ __decorate([
41339
+ handleError,
41340
+ validate,
41341
+ __param(0, checkType('object', {
41342
+ type: checkData('string', {
41343
+ values: ['photo', 'video', 'file', 'multi_photo', 'multi_video']
41344
+ }),
41345
+ 'editView?': checkData('object'),
41346
+ 'editView.enable?': checkData('boolean'),
41347
+ 'editView.aspectRatio?': checkData('string', { regex: /^\d+:\d+$/ }),
41348
+ 'silentRequest?': checkData('boolean'),
41349
+ 'maxSelectItem?': checkData('number', { min: 1 })
41350
+ }))
41351
+ ], SDKCreator.prototype, "openMediaPicker", null);
41227
41352
  __decorate([
41228
41353
  handleError,
41229
41354
  validate,
41230
41355
  __param(0, checkType('object', {
41231
- title: 'string',
41232
- thumbnail: 'url',
41233
- path: 'string'
41356
+ title: checkData('string', { maxLength: 100 }),
41357
+ 'thumbnail?': checkData('url'),
41358
+ 'path?': checkData('url'),
41359
+ description: checkData(['string'], { maxLength: 400 })
41360
+ }, {
41361
+ description: ''
41234
41362
  }))
41235
41363
  ], SDKCreator.prototype, "getShareableLink", null);
41236
41364
  class ZaloMiniAppSDKCreator extends SDKCreator {
@@ -41271,4 +41399,4 @@ else {
41271
41399
  window.ZaloMiniAppSDK = app;
41272
41400
 
41273
41401
  export default app;
41274
- export { ChatType, Events, NativeCode, NetworkType, OrientationType, PlatformType, PostFeedType, ProfileType, SDKCreator, ShareSheetType, VibrateType };
41402
+ export { ChatType, Events, MediaPickerType, NativeCode, NetworkType, OrientationType, PlatformType, PostFeedType, ProfileType, SDKCreator, ShareSheetType, VibrateType };