sales-frontend-bridge 0.0.46 → 0.0.48

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.cjs CHANGED
@@ -1493,6 +1493,7 @@ var IframeBridgeCore = class extends CommonBridgeCore {
1493
1493
  * @param event
1494
1494
  */
1495
1495
  handleMessageEventResponse(event) {
1496
+ console.log("[IframeBridgeCore] \uBD80\uBAA8 \uC751\uB2F5:: ", event);
1496
1497
  const { promiseId, isSuccess, data } = event.data;
1497
1498
  if (this.responseHandler) {
1498
1499
  this.responseHandler({ promiseId, isSuccess, data });
@@ -1504,22 +1505,24 @@ var IframeBridgeCore = class extends CommonBridgeCore {
1504
1505
  /**
1505
1506
  * Iframe 통신
1506
1507
  * @param eventName
1507
- * @param option
1508
+ * @param data
1508
1509
  * @returns
1509
1510
  */
1510
- async callToTarget(eventName, option) {
1511
+ async callToTarget(eventName, data) {
1511
1512
  return new Promise((resolve, reject) => {
1512
1513
  const promiseId = `${eventName}_${this.generatePromiseId()}`;
1513
1514
  this.pendingPromises.set(promiseId, { resolve, reject });
1514
1515
  try {
1515
1516
  const command = {
1517
+ service: "native",
1516
1518
  eventName,
1517
1519
  promiseId,
1518
- option
1520
+ data
1519
1521
  };
1520
1522
  console.log("[IframeBridgeCore callToIframe] command::", command);
1521
1523
  const platform = salesFrontendUtils.getDspExecutionEnvironment();
1522
1524
  if (platform === "iframe") {
1525
+ console.log("[IframeBridgeCore callToIframe] \uBD80\uBAA8 \uD638\uCD9C \uC9C1\uC804");
1523
1526
  window.parent.postMessage(command, "*");
1524
1527
  const promise = this.pendingPromises.get(promiseId);
1525
1528
  if (promise) {
@@ -1569,11 +1572,34 @@ var IframeBridge = class extends CommonBridge {
1569
1572
  }
1570
1573
  /**
1571
1574
  * 영업포탈 tab open
1572
- * @param options
1575
+ * @param option
1576
+ * @returns
1577
+ */
1578
+ async openMdi(option) {
1579
+ return this.core.callToTarget("openMdi", option);
1580
+ }
1581
+ /**
1582
+ * 영업포털 부모의 세션연장, 오픈되어 있는 타 시스템 세션타임 연장
1583
+ * @returns
1584
+ */
1585
+ async dspKeepCallerSession() {
1586
+ return this.core.callToTarget("dspKeepCallerSession");
1587
+ }
1588
+ /**
1589
+ * 영업포털 메뉴정보에 있는 메뉴 오픈(새탭 생성)
1590
+ * @param option
1591
+ * @returns
1592
+ */
1593
+ async dspMenuWindowOpen(option) {
1594
+ return this.core.callToTarget("dspMenuWindowOpen", option);
1595
+ }
1596
+ /**
1597
+ * 영업포털 메뉴정보에 없는 메뉴를 오픈(새탭 생성 & 약속된 타켓 메뉴정보를 해당 시스템에 전달)
1598
+ * @param option
1573
1599
  * @returns
1574
1600
  */
1575
- async openMdi(options) {
1576
- return this.core.callToTarget("openMdi", options);
1601
+ async dspSimpleWindowOpen(option) {
1602
+ return this.core.callToTarget("dspSimpleWindowOpen", option);
1577
1603
  }
1578
1604
  // TODO: 필요 플러그인들 추가
1579
1605
  };
@@ -1998,7 +2024,7 @@ var NativeBridge = class extends CommonBridge {
1998
2024
  * @example
1999
2025
  * ```tsx
2000
2026
  * // 사용 예시
2001
- * Bridge.native.closeWeb()
2027
+ * Bridge.native.exitApp()
2002
2028
  * ```
2003
2029
  */
2004
2030
  exitApp() {
@@ -2009,7 +2035,7 @@ var NativeBridge = class extends CommonBridge {
2009
2035
  * @example
2010
2036
  * ```tsx
2011
2037
  * // 사용 예시
2012
- * Bridge.native.closeWeb()
2038
+ * Bridge.native.getAppInfo()
2013
2039
  * ```
2014
2040
  */
2015
2041
  getAppInfo() {
@@ -2039,6 +2065,7 @@ var NativeBridgeOz = class extends CommonBridge {
2039
2065
  * // 사용 예시:
2040
2066
  * // OZ가 반환하는 모든 값은 문자열(string)입니다.
2041
2067
  * // 숫자도 '1', boolean도 'true' 형태로 전달됩니다.
2068
+ * // 리턴값이 null이 나올수 있음
2042
2069
  * const { data } = await Bridge.nativeOz.getInformation({ command: 'INPUT_JSON' });
2043
2070
  * ```
2044
2071
  */
@@ -2106,23 +2133,6 @@ var NativeBridgeOz = class extends CommonBridge {
2106
2133
  Object.assign({ delimiter: "\n" }, options)
2107
2134
  );
2108
2135
  }
2109
- /**
2110
- * ### Bridge for Oz
2111
- * 현재 보고서의 `OnExternalEvent` 이벤트를 실행하고, `OnExternalEvent` 이벤트에서 전달한 값을 string 형태로 리턴받습니다.
2112
- * - 서명이미지 크롭
2113
- * - 중간저장 서명이미지 추출
2114
- * @example
2115
- * ```tsx
2116
- * // 사용 예시
2117
- * await Bridge.nativeOz.triggerExternalEvent({ param1: 'signer' });
2118
- * ```
2119
- */
2120
- async triggerExternalEvent(options) {
2121
- return this.core.callToTarget(
2122
- "triggerExternalEvent",
2123
- Object.assign({ param1: "", param2: "", param3: "", param4: "" }, options)
2124
- );
2125
- }
2126
2136
  /**
2127
2137
  * ### Bridge for Oz
2128
2138
  * 지정한 보고서의 `OnExternalEvent` 이벤트를 실행하고, `OnExternalEvent` 이벤트에서 전달한 값을 string 형태로 리턴받습니다.
@@ -2653,6 +2663,9 @@ async function MovePage(page) {
2653
2663
  }
2654
2664
  async function getCurrentPage() {
2655
2665
  const { data } = await Bridge.nativeOz.getInformation({ command: `CURRENT_PAGE` });
2666
+ if (data === null) {
2667
+ throw new Error(`Bridge returned null for command: CURRENT_PAGE`);
2668
+ }
2656
2669
  return Number(data);
2657
2670
  }
2658
2671
  var getTotalPageMemo = (() => {
@@ -2686,6 +2699,9 @@ var getReportCountMemo = (() => {
2686
2699
  cache = (async () => {
2687
2700
  try {
2688
2701
  const { data } = await Bridge.nativeOz.getInformation({ command: "REPORT_COUNT" });
2702
+ if (data === null) {
2703
+ throw new Error(`Bridge returned null for command: REPORT_COUNT`);
2704
+ }
2689
2705
  return Number(data);
2690
2706
  } catch (e) {
2691
2707
  cache = null;
@@ -2744,9 +2760,7 @@ async function CommentHandler({ type, btnID }) {
2744
2760
  }
2745
2761
  }
2746
2762
  async function isCommentMode() {
2747
- const { data } = await Bridge.nativeOz.getInformation({
2748
- command: `COMMENT_MODE`
2749
- });
2763
+ const { data } = await Bridge.nativeOz.getInformation({ command: `COMMENT_MODE` });
2750
2764
  return data === "comment";
2751
2765
  }
2752
2766
  async function setCommentMode(penConfig) {
@@ -2893,7 +2907,7 @@ async function SignatureInProgressHandler() {
2893
2907
  await validateAllPages(pageCount);
2894
2908
  }
2895
2909
  async function SignatureInMissingHandler() {
2896
- const { data: { result } } = await Bridge.nativeOz.showAlert({
2910
+ const { data: result } = await Bridge.nativeOz.showAlert({
2897
2911
  title: "\uC785\uB825\uD558\uC9C0 \uC54A\uC740 \uD56D\uBAA9\uC774 \uC788\uC2B5\uB2C8\uB2E4",
2898
2912
  message: "\uD574\uB2F9 \uD56D\uBAA9\uC73C\uB85C \uC774\uB3D9\uD558\uC5EC \uC785\uB825\uC744 \uC644\uB8CC\uD574\uC8FC\uC138\uC694.",
2899
2913
  buttons: {
@@ -2976,6 +2990,20 @@ function base64ToBlob(base64) {
2976
2990
  const bytes = Uint8Array.from(atob(data || base64), (c) => c.charCodeAt(0));
2977
2991
  return new Blob([bytes], { type: mime });
2978
2992
  }
2993
+ async function blobToBase64(blob) {
2994
+ return new Promise((resolve, reject) => {
2995
+ const reader = new FileReader();
2996
+ reader.onloadend = () => {
2997
+ if (typeof reader.result === "string") {
2998
+ resolve(reader.result);
2999
+ } else {
3000
+ reject(new Error("Failed to convert Blob to Base64 string"));
3001
+ }
3002
+ };
3003
+ reader.onerror = () => reject(reader.error);
3004
+ reader.readAsDataURL(blob);
3005
+ });
3006
+ }
2979
3007
  async function postFiletoDud(imageStr) {
2980
3008
  const formData = new FormData();
2981
3009
  formData.append("data", base64ToBlob(imageStr), "test.png");
@@ -3027,17 +3055,12 @@ async function getFileFromDud(fileMgmtId) {
3027
3055
  body: JSON.stringify({ fileMgmtId, outputType })
3028
3056
  });
3029
3057
  const blob = await response.blob();
3030
- const base64String = await new Promise((resolve, reject) => {
3031
- const reader = new FileReader();
3032
- reader.onloadend = () => resolve(reader.result);
3033
- reader.onerror = reject;
3034
- reader.readAsDataURL(blob);
3035
- });
3058
+ const base64String = await blobToBase64(blob);
3036
3059
  return base64String;
3037
3060
  }
3038
3061
 
3039
3062
  // src/oz/utils/bridge-util/create-report-util.ts
3040
- async function CreateOzParam({ documentList, extraData = {}, roleCd }) {
3063
+ async function CreateOzParam({ documentList, extraData = {}, roleCd, jijungInfo = "" }) {
3041
3064
  if (documentList.length === 0) {
3042
3065
  throw new Error("\uBB38\uC11C\uBAA9\uB85D\uC774 \uBE44\uC5B4\uC788\uC2B5\uB2C8\uB2E4");
3043
3066
  }
@@ -3057,8 +3080,10 @@ async function CreateOzParam({ documentList, extraData = {}, roleCd }) {
3057
3080
  const args = [
3058
3081
  // 모든서식에 공통으로 필요한 docCd param 추가
3059
3082
  `docCd=${docCode}`,
3060
- // `roleCd=11,28`,
3061
- `${roleCd}`,
3083
+ // 모든서식에 공통으로 필요한 roleCode 정보 추가
3084
+ `roleCd=${roleCd}`,
3085
+ // 모든서식에 공통으로 필요한 지정대리인 정보 추가
3086
+ `jijungInfo=${jijungInfo}`,
3062
3087
  ...ensureArray(data.args)
3063
3088
  ];
3064
3089
  args.forEach((arg, idx2) => result.push(`${prefix}connection.args${idx2 + 1}=${arg}`));
@@ -3122,6 +3147,9 @@ async function getDraftDataHandler(rawOzRequest, documentIndexMap) {
3122
3147
  throw new Error(`Invalid document code: ${docCd}`);
3123
3148
  }
3124
3149
  const { data } = await Bridge.nativeOz.getInformation({ command: `INPUT_JSON_AT=${documentIndex}` });
3150
+ if (data === null) {
3151
+ throw new Error(`Bridge returned null for document: ${docCd} (command=INPUT_JSON_AT=${documentIndex})`);
3152
+ }
3125
3153
  const documentJson = JSON.parse(data);
3126
3154
  const signDataMap = Object.keys(signKeyMap).reduce((acc, key) => {
3127
3155
  acc[key] = documentJson[key];
@@ -3193,6 +3221,8 @@ exports.PromiseWithResolvers = PromiseWithResolvers;
3193
3221
  exports.SaveTotalPdf = SaveTotalPdf;
3194
3222
  exports.SignatureHandler = SignatureHandler;
3195
3223
  exports.TopHandler = TopHandler;
3224
+ exports.base64ToBlob = base64ToBlob;
3225
+ exports.blobToBase64 = blobToBase64;
3196
3226
  exports.btnStyle = btnStyle;
3197
3227
  exports.categorizeByPageRange = categorizeByPageRange;
3198
3228
  exports.checkDocumentsValidityByIndex = checkDocumentsValidityByIndex;