sales-frontend-utils 0.0.28 → 0.0.30

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
@@ -108,15 +108,25 @@ var isStorybookEnv = () => {
108
108
  var getBusinessWorkDivisionCode = () => {
109
109
  return location.pathname.split("/")[1] ?? "";
110
110
  };
111
- var getDudApiHostNameFromEnvironment = (serviceCode, hostname) => {
112
- const environment = getEnvironmentFromHostname(hostname);
111
+ var getServiceCode = () => {
112
+ if (typeof window.isStorybookEnv === "boolean") {
113
+ return "";
114
+ } else {
115
+ return `/${location.pathname.split("/")[1]}`;
116
+ }
117
+ };
118
+ var getDudApiHostNameFromEnvironment = (hostname) => {
119
+ if (!isClient()) {
120
+ return "";
121
+ }
122
+ const environment = getEnvironmentFromHostname(hostname || location.hostname);
113
123
  switch (environment) {
114
124
  /**
115
125
  * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.
116
126
  * (cors이슈 해결을 위해 필수)
117
127
  */
118
128
  case "local":
119
- return `${serviceCode}/api/dud`;
129
+ return `${getServiceCode()}/api/dud`;
120
130
  /**
121
131
  * local 이 아닌 환경에서는 전체주소를 호출합니다.
122
132
  */
@@ -127,6 +137,33 @@ var getDudApiHostNameFromEnvironment = (serviceCode, hostname) => {
127
137
  case "prd":
128
138
  return `https://dsp-dud.hanwhalife.com`;
129
139
  default:
140
+ console.warn("DUD API environment is not defined");
141
+ return "";
142
+ }
143
+ };
144
+ var getDspApiHostNameFromEnvironment = (serviceCodeTo, hostname) => {
145
+ if (!isClient()) {
146
+ return "";
147
+ }
148
+ const environment = getEnvironmentFromHostname(hostname || location.hostname);
149
+ switch (environment) {
150
+ /**
151
+ * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.
152
+ * (cors이슈 해결을 위해 필수)
153
+ */
154
+ case "local":
155
+ return `${getServiceCode()}/api/${serviceCodeTo}`;
156
+ /**
157
+ * local 이 아닌 환경에서는 전체주소를 호출합니다.
158
+ */
159
+ case "dev":
160
+ return `https://nxl-dsp-dev.hanwhalife.com/api/${serviceCodeTo}`;
161
+ case "stg":
162
+ return `https://nxl-dsp-stg.hanwhalife.com/api/${serviceCodeTo}`;
163
+ case "prd":
164
+ return `https://nxl-dsp.hanwhalife.com/api/${serviceCodeTo}`;
165
+ default:
166
+ console.warn("DSP API environment is not defined");
130
167
  return "";
131
168
  }
132
169
  };
@@ -783,6 +820,7 @@ exports.getCurrentBrowserVersion = getCurrentBrowserVersion;
783
820
  exports.getCurrentOSName = getCurrentOSName;
784
821
  exports.getCurrentOSVersion = getCurrentOSVersion;
785
822
  exports.getDeviceModel = getDeviceModel;
823
+ exports.getDspApiHostNameFromEnvironment = getDspApiHostNameFromEnvironment;
786
824
  exports.getDspExecutionEnvironment = getDspExecutionEnvironment;
787
825
  exports.getDudApiHostNameFromEnvironment = getDudApiHostNameFromEnvironment;
788
826
  exports.getE2EDataIDs = getE2EDataIDs;
@@ -792,6 +830,7 @@ exports.getFormFactorFromUserAgent = getFormFactorFromUserAgent;
792
830
  exports.getOSName = getOSName;
793
831
  exports.getOSVersion = getOSVersion;
794
832
  exports.getOrCreateDeviceId = getOrCreateDeviceId;
833
+ exports.getServiceCode = getServiceCode;
795
834
  exports.getSubdomain = getSubdomain;
796
835
  exports.hasAstx2 = hasAstx2;
797
836
  exports.initASTX2 = initASTX2;