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