@things-factory/meta-ui 7.0.1-alpha.11 → 7.0.1-alpha.13

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.
@@ -0,0 +1,120 @@
1
+ /**
2
+ * @license
3
+ * Copyright © HatioLab Inc. All rights reserved.
4
+ * @author Shortstop <shortstop@hatiolab.com>
5
+ * @description REST 서비스 핸들링 유틸리티 함수 정의
6
+ */
7
+ export class RestServiceUtil {
8
+ /**
9
+ * @description REST 서비스 응답이 에러인 경우 Error 메시지 표시
10
+ ****************************************************
11
+ * @param {Object} response 응답
12
+ */
13
+ static showRestErrorResponse(response: any): Promise<any>;
14
+ /**
15
+ * @description REST 서비스 실행 시 발생한 예외 표시
16
+ *************************************************
17
+ * @param {Object} exception 에러 Object
18
+ */
19
+ static showRestException(exception: any): Promise<void>;
20
+ /**
21
+ * @description 레코드의 id를 이용해 데이터 한 건 조회
22
+ *********************************************
23
+ * @param {String} url 조회할 서비스 URL
24
+ * @param {Object} params 파라미터
25
+ * @return {Object} 조회한 레코드
26
+ */
27
+ static restGet(url: string, params: any): any;
28
+ /**
29
+ * @description 메소드 PUT인 REST 서비스 호출
30
+ *********************************************
31
+ * @param {String} url 서비스 URL
32
+ * @param {Object} params 파라미터
33
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
34
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
35
+ * @param {Function} successCallback 성공 콜백
36
+ * @param {Function} failureCallback 실패 콜백
37
+ * @return {Object}
38
+ */
39
+ static restPut(url: string, params: any, confirmTitleKey: string, confirmMsgKey: string, successCallback: Function, failureCallback: Function): any;
40
+ /**
41
+ * @description 메소드 POST인 REST 서비스 호출
42
+ *********************************************
43
+ * @param {String} url 서비스 URL
44
+ * @param {Object} params 파라미터
45
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
46
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
47
+ * @param {Function} successCallback 성공 콜백
48
+ * @param {Function} failureCallback 실패 콜백
49
+ * @return {Object}
50
+ */
51
+ static restPost(url: string, params: any, confirmTitleKey: string, confirmMsgKey: string, successCallback: Function, failureCallback: Function): any;
52
+ /**
53
+ * @description 메소드 DELETE인 REST 서비스 호출
54
+ *********************************************
55
+ * @param {String} url 서비스 URL
56
+ * @param {Object} params 파라미터
57
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
58
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
59
+ * @param {Function} successCallback 성공 콜백
60
+ * @param {Function} failureCallback 실패 콜백
61
+ * @return {Object}
62
+ */
63
+ static restDelete(url: string, params: any, confirmTitleKey: string, confirmMsgKey: string, successCallback: Function, failureCallback: Function): any;
64
+ /**
65
+ * @description REST 서비스 호출
66
+ *********************************************
67
+ * @param {String} method 메소드
68
+ * @param {String} url 서비스 URL
69
+ * @param {Object} params 파라미터
70
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
71
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
72
+ * @param {Function} successCallback 성공 콜백
73
+ * @param {Function} failureCallback 실패 콜백
74
+ * @return {Object}
75
+ */
76
+ static callRest(method: string, url: string, params: any, confirmTitleKey: string, confirmMsgKey: string, successCallback: Function, failureCallback: Function): any;
77
+ /**
78
+ * @description REST 서버에 GET 방식 호출, response 리턴
79
+ *******************************************************
80
+ * @param {String} url
81
+ * @param {*} params
82
+ * @param {Boolean} responseJson
83
+ * @returns response 리턴
84
+ */
85
+ static callRestGet(url: string, params: any, responseJson: boolean): Promise<any>;
86
+ /**
87
+ * @description REST 서버에 POST 방식 호출, 서버 response 자체를 리턴
88
+ *****************************************************************
89
+ * @param {*} url
90
+ * @param {*} bodyObj
91
+ * @param {Boolean} responseJson 응답 JSON을 받을 지 여부
92
+ * @returns response 리턴
93
+ */
94
+ static callRestPost(url: any, bodyObj: any, responseJson: boolean): Promise<any>;
95
+ /**
96
+ * @description REST 서버에 PUT 방식 호출, 서버 Response 자체를 리턴
97
+ ****************************************************************
98
+ * @param {String} url
99
+ * @param {Object} bodyObj
100
+ * @param {Boolean} responseJson 응답 JSON을 받을 지 여부
101
+ * @returns 서버 response 리턴
102
+ */
103
+ static callRestPut(url: string, bodyObj: any, responseJson: boolean): Promise<any>;
104
+ /**
105
+ * @description REST 서버에 DELETE 방식 호출 후 서버 response를 리턴
106
+ ****************************************************************
107
+ * @param {String} url
108
+ * @param {Object} bodyObj
109
+ * @param {Boolean} responseJson 응답 JSON을 받을 지 여부
110
+ * @returns response 리턴
111
+ */
112
+ static restCallDelete(url: string, bodyObj: any, responseJson: boolean): Promise<any>;
113
+ /**
114
+ * @description response 상태 체크 후 에러이면 에러 메시지 표시
115
+ *******************************************************
116
+ * @param {Object} res
117
+ * @param {Boolean} responseJson
118
+ */
119
+ static checkResponse(res: any, responseJson: boolean): Promise<any>;
120
+ }
@@ -0,0 +1,291 @@
1
+ import { decreaseActiveRequestCounter, increaseActiveRequestCounter } from '@operato/graphql';
2
+ import { TermsUtil } from './terms-util';
3
+ import { UiUtil } from './ui-util';
4
+ /**
5
+ * @license
6
+ * Copyright © HatioLab Inc. All rights reserved.
7
+ * @author Shortstop <shortstop@hatiolab.com>
8
+ * @description REST 서비스 핸들링 유틸리티 함수 정의
9
+ */
10
+ export class RestServiceUtil {
11
+ /**
12
+ * @description REST 서비스 응답이 에러인 경우 Error 메시지 표시
13
+ ****************************************************
14
+ * @param {Object} response 응답
15
+ */
16
+ static async showRestErrorResponse(response) {
17
+ if (response.status && response.status >= 400) {
18
+ try {
19
+ let errData = await response.json();
20
+ let errMsg = errData.code && errData.msg ? `${errData.code} - ${errData.msg}` : TermsUtil.tText('unexpected_server_error');
21
+ UiUtil.showAlertPopup('title.error', errMsg, 'error', 'confirm');
22
+ return errData;
23
+ }
24
+ catch (err) {
25
+ UiUtil.showAlertPopup('title.error', err, 'error', 'confirm');
26
+ return false;
27
+ }
28
+ }
29
+ }
30
+ /**
31
+ * @description REST 서비스 실행 시 발생한 예외 표시
32
+ *************************************************
33
+ * @param {Object} exception 에러 Object
34
+ */
35
+ static async showRestException(exception) {
36
+ if (exception) {
37
+ await UiUtil.showAlertPopup('REST Service Error', exception.message, 'error', 'confirm');
38
+ }
39
+ }
40
+ /**
41
+ * @description 레코드의 id를 이용해 데이터 한 건 조회
42
+ *********************************************
43
+ * @param {String} url 조회할 서비스 URL
44
+ * @param {Object} params 파라미터
45
+ * @return {Object} 조회한 레코드
46
+ */
47
+ static async restGet(url, params) {
48
+ let res = await RestServiceUtil.callRestGet(url, params, false);
49
+ if (res && res.status && res.status < 400) {
50
+ return await res.json();
51
+ }
52
+ return null;
53
+ }
54
+ /**
55
+ * @description 메소드 PUT인 REST 서비스 호출
56
+ *********************************************
57
+ * @param {String} url 서비스 URL
58
+ * @param {Object} params 파라미터
59
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
60
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
61
+ * @param {Function} successCallback 성공 콜백
62
+ * @param {Function} failureCallback 실패 콜백
63
+ * @return {Object}
64
+ */
65
+ static async restPut(url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {
66
+ return await RestServiceUtil.callRest('PUT', url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback);
67
+ }
68
+ /**
69
+ * @description 메소드 POST인 REST 서비스 호출
70
+ *********************************************
71
+ * @param {String} url 서비스 URL
72
+ * @param {Object} params 파라미터
73
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
74
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
75
+ * @param {Function} successCallback 성공 콜백
76
+ * @param {Function} failureCallback 실패 콜백
77
+ * @return {Object}
78
+ */
79
+ static async restPost(url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {
80
+ return await RestServiceUtil.callRest('POST', url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback);
81
+ }
82
+ /**
83
+ * @description 메소드 DELETE인 REST 서비스 호출
84
+ *********************************************
85
+ * @param {String} url 서비스 URL
86
+ * @param {Object} params 파라미터
87
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
88
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
89
+ * @param {Function} successCallback 성공 콜백
90
+ * @param {Function} failureCallback 실패 콜백
91
+ * @return {Object}
92
+ */
93
+ static async restDelete(url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {
94
+ return await RestServiceUtil.callRest('DELETE', url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback);
95
+ }
96
+ /**
97
+ * @description REST 서비스 호출
98
+ *********************************************
99
+ * @param {String} method 메소드
100
+ * @param {String} url 서비스 URL
101
+ * @param {Object} params 파라미터
102
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
103
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
104
+ * @param {Function} successCallback 성공 콜백
105
+ * @param {Function} failureCallback 실패 콜백
106
+ * @return {Object}
107
+ */
108
+ static async callRest(method, url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {
109
+ let confirm = confirmMsgKey
110
+ ? await UiUtil.showAlertPopup(confirmTitleKey, confirmMsgKey, 'question', 'confirm', 'cancel')
111
+ : true;
112
+ if (confirm) {
113
+ // 서비스 호출 결과
114
+ let res = null;
115
+ if (method == 'POST') {
116
+ res = await restCallPost(url, params, false);
117
+ }
118
+ else if (method == 'PUT') {
119
+ res = await restCallPut(url, params, false);
120
+ }
121
+ else if (method == 'DELETE') {
122
+ res = await restCallDelete(url, params, false);
123
+ }
124
+ if (res && res.status && res.status < 400) {
125
+ UiUtil.showToast('info', TermsUtil.tText('Success to Process'));
126
+ if (successCallback)
127
+ successCallback();
128
+ return res.json ? await res.json() : res;
129
+ }
130
+ else {
131
+ if (failureCallback)
132
+ failureCallback();
133
+ }
134
+ }
135
+ return null;
136
+ }
137
+ /**
138
+ * @description REST 서버에 GET 방식 호출, response 리턴
139
+ *******************************************************
140
+ * @param {String} url
141
+ * @param {*} params
142
+ * @param {Boolean} responseJson
143
+ * @returns response 리턴
144
+ */
145
+ static async callRestGet(url, params, responseJson) {
146
+ try {
147
+ increaseActiveRequestCounter();
148
+ if (params == null || typeof params == undefined) {
149
+ }
150
+ else if (typeof params == 'string') {
151
+ url = `${url}?${params}`;
152
+ }
153
+ else if (Array.isArray(params)) {
154
+ url += '?';
155
+ params.forEach((item, index, array) => {
156
+ url += `${item['name']}=${item['value']}&`;
157
+ });
158
+ }
159
+ else if (Object.keys(params).length > 0) {
160
+ url += '?';
161
+ for (let param in params) {
162
+ url += `${param}=${params[param]}&`;
163
+ }
164
+ }
165
+ const res = await fetch(url, {
166
+ method: 'GET',
167
+ headers: {
168
+ 'Content-type': 'application/json',
169
+ Accept: 'application/json',
170
+ 'x-locale': currentLocale()
171
+ }
172
+ });
173
+ const resJson = responseJson ? responseJson : false;
174
+ return await checkResponse(res, resJson);
175
+ }
176
+ finally {
177
+ decreaseActiveRequestCounter();
178
+ }
179
+ }
180
+ /**
181
+ * @description REST 서버에 POST 방식 호출, 서버 response 자체를 리턴
182
+ *****************************************************************
183
+ * @param {*} url
184
+ * @param {*} bodyObj
185
+ * @param {Boolean} responseJson 응답 JSON을 받을 지 여부
186
+ * @returns response 리턴
187
+ */
188
+ static async callRestPost(url, bodyObj, responseJson) {
189
+ const bodyStr = typeof bodyObj === 'string' ? bodyObj : JSON.stringify(bodyObj);
190
+ try {
191
+ increaseActiveRequestCounter();
192
+ const res = await fetch(url, {
193
+ method: 'POST',
194
+ headers: {
195
+ 'Content-type': 'application/json',
196
+ Accept: 'application/json',
197
+ 'x-locale': currentLocale()
198
+ },
199
+ body: bodyStr
200
+ });
201
+ const resJson = responseJson ? responseJson : false;
202
+ return await checkResponse(res, resJson);
203
+ }
204
+ finally {
205
+ decreaseActiveRequestCounter();
206
+ }
207
+ }
208
+ /**
209
+ * @description REST 서버에 PUT 방식 호출, 서버 Response 자체를 리턴
210
+ ****************************************************************
211
+ * @param {String} url
212
+ * @param {Object} bodyObj
213
+ * @param {Boolean} responseJson 응답 JSON을 받을 지 여부
214
+ * @returns 서버 response 리턴
215
+ */
216
+ static async callRestPut(url, bodyObj, responseJson) {
217
+ try {
218
+ increaseActiveRequestCounter();
219
+ const bodyStr = typeof bodyObj === 'string' ? bodyObj : JSON.stringify(bodyObj);
220
+ const res = await fetch(url, {
221
+ method: 'PUT',
222
+ credentials: 'include',
223
+ headers: {
224
+ 'Content-type': 'application/json',
225
+ Accept: 'application/json',
226
+ 'x-locale': currentLocale()
227
+ },
228
+ body: bodyStr
229
+ });
230
+ const resJson = responseJson ? responseJson : false;
231
+ return await checkResponse(res, resJson);
232
+ }
233
+ finally {
234
+ decreaseActiveRequestCounter();
235
+ }
236
+ }
237
+ /**
238
+ * @description REST 서버에 DELETE 방식 호출 후 서버 response를 리턴
239
+ ****************************************************************
240
+ * @param {String} url
241
+ * @param {Object} bodyObj
242
+ * @param {Boolean} responseJson 응답 JSON을 받을 지 여부
243
+ * @returns response 리턴
244
+ */
245
+ static async restCallDelete(url, bodyObj, responseJson) {
246
+ try {
247
+ increaseActiveRequestCounter();
248
+ const bodyStr = typeof bodyObj === 'string' ? bodyObj : JSON.stringify(bodyObj);
249
+ const res = await fetch(url, {
250
+ method: 'DELETE',
251
+ headers: {
252
+ 'Content-type': 'application/json',
253
+ Accept: 'application/json',
254
+ 'x-locale': currentLocale()
255
+ },
256
+ body: bodyStr
257
+ });
258
+ const resJson = responseJson ? responseJson : false;
259
+ return await checkResponse(res, resJson);
260
+ }
261
+ finally {
262
+ decreaseActiveRequestCounter();
263
+ }
264
+ }
265
+ /**
266
+ * @description response 상태 체크 후 에러이면 에러 메시지 표시
267
+ *******************************************************
268
+ * @param {Object} res
269
+ * @param {Boolean} responseJson
270
+ */
271
+ static async checkResponse(res, responseJson) {
272
+ if (res && res.status && res.status >= 400) {
273
+ try {
274
+ let isJson = await res.json ? true : false;
275
+ let errData = isJson ? await res.json() : await res.text();
276
+ let errMsg = (typeof errData == 'string') ?
277
+ errData :
278
+ (errData.code && errData.msg ? `${errData.code} - ${errData.msg}` : TermsUtil.tText('unexpected_server_error'));
279
+ await UiUtil.showAlertPopup('title.error', errMsg, 'error', 'confirm');
280
+ return errData;
281
+ }
282
+ catch (err) {
283
+ console.log(err);
284
+ }
285
+ }
286
+ else {
287
+ return responseJson === true && res.json ? await res.json() : res;
288
+ }
289
+ }
290
+ }
291
+ //# sourceMappingURL=rest-service-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-service-util.js","sourceRoot":"","sources":["../../client/utils/rest-service-util.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAE7F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAC1B;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,QAAQ;QACzC,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE;YAC7C,IAAI;gBACF,IAAI,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;gBACnC,IAAI,MAAM,GACR,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;gBAC/G,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;gBAChE,OAAO,OAAO,CAAA;aACf;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;gBAC7D,OAAO,KAAK,CAAA;aACb;SACF;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CA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BAC3C,IAAI,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;gBAC3D,IAAI,MAAM,GAAG,CAAC,OAAO,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC;oBACzC,OAAO,CAAC,CAAC;oBACT,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAA;gBAEjH,MAAM,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;gBACtE,OAAO,OAAO,CAAC;aAChB;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;aACjB;SACF;aAAM;YACL,OAAO,YAAY,KAAK,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;SAClE;IACH,CAAC;CACF","sourcesContent":["import { decreaseActiveRequestCounter, increaseActiveRequestCounter } from '@operato/graphql'\n\nimport { TermsUtil } from './terms-util'\nimport { UiUtil } from './ui-util'\n\n/**\n * @license\n * Copyright © HatioLab Inc. All rights reserved.\n * @author Shortstop <shortstop@hatiolab.com>\n * @description REST 서비스 핸들링 유틸리티 함수 정의\n */\nexport class RestServiceUtil {\n /**\n * @description REST 서비스 응답이 에러인 경우 Error 메시지 표시\n ****************************************************\n * @param {Object} response 응답\n */\n static async showRestErrorResponse(response) {\n if (response.status && response.status >= 400) {\n try {\n let errData = await response.json()\n let errMsg =\n errData.code && errData.msg ? `${errData.code} - ${errData.msg}` : TermsUtil.tText('unexpected_server_error')\n UiUtil.showAlertPopup('title.error', errMsg, 'error', 'confirm')\n return errData\n } catch (err) {\n UiUtil.showAlertPopup('title.error', err, 'error', 'confirm')\n return false\n }\n }\n }\n\n /**\n * @description REST 서비스 실행 시 발생한 예외 표시\n *************************************************\n * @param {Object} exception 에러 Object\n */\n static async showRestException(exception) {\n if (exception) {\n await UiUtil.showAlertPopup('REST Service Error', exception.message, 'error', 'confirm')\n }\n }\n\n /**\n * @description 레코드의 id를 이용해 데이터 한 건 조회\n *********************************************\n * @param {String} url 조회할 서비스 URL\n * @param {Object} params 파라미터\n * @return {Object} 조회한 레코드\n */\n static async restGet(url, params) {\n let res = await RestServiceUtil.callRestGet(url, params, false)\n if (res && res.status && res.status < 400) {\n return await res.json()\n }\n\n return null\n }\n\n /**\n * @description 메소드 PUT인 REST 서비스 호출\n *********************************************\n * @param {String} url 서비스 URL\n * @param {Object} params 파라미터\n * @param {String} confirmTitleKey 확인 타이틀 용어 키\n * @param {String} confirmMsgKey 확인 메시지 용어 키\n * @param {Function} successCallback 성공 콜백\n * @param {Function} failureCallback 실패 콜백\n * @return {Object}\n */\n static async restPut(url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {\n return await RestServiceUtil.callRest(\n 'PUT',\n url,\n params,\n confirmTitleKey,\n confirmMsgKey,\n successCallback,\n failureCallback\n )\n }\n\n /**\n * @description 메소드 POST인 REST 서비스 호출\n *********************************************\n * @param {String} url 서비스 URL\n * @param {Object} params 파라미터\n * @param {String} confirmTitleKey 확인 타이틀 용어 키\n * @param {String} confirmMsgKey 확인 메시지 용어 키\n * @param {Function} successCallback 성공 콜백\n * @param {Function} failureCallback 실패 콜백\n * @return {Object}\n */\n static async restPost(url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {\n return await RestServiceUtil.callRest(\n 'POST',\n url,\n params,\n confirmTitleKey,\n confirmMsgKey,\n successCallback,\n failureCallback\n )\n }\n\n /**\n * @description 메소드 DELETE인 REST 서비스 호출\n *********************************************\n * @param {String} url 서비스 URL\n * @param {Object} params 파라미터\n * @param {String} confirmTitleKey 확인 타이틀 용어 키\n * @param {String} confirmMsgKey 확인 메시지 용어 키\n * @param {Function} successCallback 성공 콜백\n * @param {Function} failureCallback 실패 콜백\n * @return {Object}\n */\n static async restDelete(url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {\n return await RestServiceUtil.callRest(\n 'DELETE',\n url,\n params,\n confirmTitleKey,\n confirmMsgKey,\n successCallback,\n failureCallback\n )\n }\n\n /**\n * @description REST 서비스 호출\n *********************************************\n * @param {String} method 메소드\n * @param {String} url 서비스 URL\n * @param {Object} params 파라미터\n * @param {String} confirmTitleKey 확인 타이틀 용어 키\n * @param {String} confirmMsgKey 확인 메시지 용어 키\n * @param {Function} successCallback 성공 콜백\n * @param {Function} failureCallback 실패 콜백\n * @return {Object}\n */\n static async callRest(method, url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {\n let confirm = confirmMsgKey\n ? await UiUtil.showAlertPopup(confirmTitleKey, confirmMsgKey, 'question', 'confirm', 'cancel')\n : true\n\n if (confirm) {\n // 서비스 호출 결과\n let res = null\n\n if (method == 'POST') {\n res = await restCallPost(url, params, false)\n } else if (method == 'PUT') {\n res = await restCallPut(url, params, false)\n } else if (method == 'DELETE') {\n res = await restCallDelete(url, params, false)\n }\n\n if (res && res.status && res.status < 400) {\n UiUtil.showToast('info', TermsUtil.tText('Success to Process'))\n if (successCallback) successCallback()\n return res.json ? await res.json() : res\n } else {\n if (failureCallback) failureCallback()\n }\n }\n\n return null\n }\n\n /**\n * @description REST 서버에 GET 방식 호출, response 리턴\n *******************************************************\n * @param {String} url\n * @param {*} params\n * @param {Boolean} responseJson\n * @returns response 리턴\n */\n static async callRestGet(url, params, responseJson) {\n try {\n increaseActiveRequestCounter()\n \n if (params == null || typeof params == undefined) {\n } else if (typeof params == 'string') {\n url = `${url}?${params}`\n } else if (Array.isArray(params)) {\n url += '?'\n params.forEach((item, index, array) => {\n url += `${item['name']}=${item['value']}&`\n })\n } else if (Object.keys(params).length > 0) {\n url += '?'\n for (let param in params) {\n url += `${param}=${params[param]}&`\n }\n }\n const res = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-type': 'application/json',\n Accept: 'application/json',\n 'x-locale': currentLocale()\n }\n })\n \n const resJson = responseJson ? responseJson : false\n return await checkResponse(res, resJson)\n } finally {\n decreaseActiveRequestCounter()\n }\n }\n\n /**\n * @description REST 서버에 POST 방식 호출, 서버 response 자체를 리턴\n *****************************************************************\n * @param {*} url\n * @param {*} bodyObj\n * @param {Boolean} responseJson 응답 JSON을 받을 지 여부\n * @returns response 리턴\n */\n static async callRestPost(url, bodyObj, responseJson) {\n const bodyStr = typeof bodyObj === 'string' ? bodyObj : JSON.stringify(bodyObj)\n\n try {\n increaseActiveRequestCounter()\n\n const res = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-type': 'application/json',\n Accept: 'application/json',\n 'x-locale': currentLocale()\n },\n body: bodyStr\n })\n\n const resJson = responseJson ? responseJson : false\n return await checkResponse(res, resJson)\n } finally {\n decreaseActiveRequestCounter()\n }\n }\n\n /**\n * @description REST 서버에 PUT 방식 호출, 서버 Response 자체를 리턴\n ****************************************************************\n * @param {String} url\n * @param {Object} bodyObj\n * @param {Boolean} responseJson 응답 JSON을 받을 지 여부\n * @returns 서버 response 리턴\n */\n static async callRestPut(url, bodyObj, responseJson) {\n try {\n increaseActiveRequestCounter()\n \n const bodyStr = typeof bodyObj === 'string' ? bodyObj : JSON.stringify(bodyObj)\n const res = await fetch(url, {\n method: 'PUT',\n credentials: 'include',\n headers: {\n 'Content-type': 'application/json',\n Accept: 'application/json',\n 'x-locale': currentLocale()\n },\n body: bodyStr\n })\n\n const resJson = responseJson ? responseJson : false\n return await checkResponse(res, resJson)\n } finally {\n decreaseActiveRequestCounter()\n }\n }\n\n /**\n * @description REST 서버에 DELETE 방식 호출 후 서버 response를 리턴\n ****************************************************************\n * @param {String} url\n * @param {Object} bodyObj\n * @param {Boolean} responseJson 응답 JSON을 받을 지 여부\n * @returns response 리턴\n */\n static async restCallDelete(url, bodyObj, responseJson) {\n try {\n increaseActiveRequestCounter()\n\n const bodyStr = typeof bodyObj === 'string' ? bodyObj : JSON.stringify(bodyObj)\n const res = await fetch(url, {\n method: 'DELETE',\n headers: {\n 'Content-type': 'application/json',\n Accept: 'application/json',\n 'x-locale': currentLocale()\n },\n body: bodyStr\n })\n\n const resJson = responseJson ? responseJson : false\n return await checkResponse(res, resJson)\n } finally {\n decreaseActiveRequestCounter()\n }\n }\n\n /**\n * @description response 상태 체크 후 에러이면 에러 메시지 표시\n *******************************************************\n * @param {Object} res\n * @param {Boolean} responseJson\n */\n static async checkResponse(res, responseJson) {\n if (res && res.status && res.status >= 400) {\n try {\n let isJson = await res.json ? true : false;\n let errData = isJson ? await res.json() : await res.text();\n let errMsg = (typeof errData == 'string') ? \n errData : \n (errData.code && errData.msg ? `${errData.code} - ${errData.msg}` : TermsUtil.tText('unexpected_server_error'))\n\n await UiUtil.showAlertPopup('title.error', errMsg, 'error', 'confirm')\n return errData;\n } catch (err) {\n console.log(err)\n }\n } else {\n return responseJson === true && res.json ? await res.json() : res\n }\n }\n}"]}
@@ -5,23 +5,6 @@
5
5
  * @description 용어 처리 유틸리티
6
6
  */
7
7
  export class TermsUtil {
8
- /**
9
- * 용어 : 용어 키 - 용어 표현 값
10
- */
11
- static META_TERMS: null;
12
- /**
13
- * @description 서버에 현재 로케일에 맞는 용어를 모두 조회
14
- ***********************************************
15
- * @param {String} locale
16
- */
17
- static downloadTerminologies(locale: string): Promise<void>;
18
- /**
19
- * @description locale 정보로 용어 모두 조회
20
- *********************************************
21
- * @param {String} locale
22
- * @returns {Array} 용어 리스트
23
- */
24
- static fetchTerminologies(locale: string): any[];
25
8
  /**
26
9
  * @description 라벨 (필드) labelName을 다국어 변환하여 리턴
27
10
  ***********************************************
@@ -29,7 +12,7 @@ export class TermsUtil {
29
12
  * @param {Object} params
30
13
  * @returns 번역된 라벨 (필드) 명
31
14
  */
32
- static tLabel(labelName: string, params: any): string;
15
+ static tLabel(labelName: string, params: any): import("i18next").TFunctionDetailedResult<object>;
33
16
  /**
34
17
  * @description 필드 fieldName을 다국어 변환하여 리턴
35
18
  ***********************************************
@@ -37,14 +20,14 @@ export class TermsUtil {
37
20
  * @param {Object} params
38
21
  * @returns 번역된 필드 명
39
22
  */
40
- static tField(fieldName: string, params: any): string;
23
+ static tField(fieldName: string, params: any): import("i18next").TFunctionDetailedResult<object>;
41
24
  /**
42
25
  * @description 버튼 buttonName을 다국어 변환하여 리턴
43
26
  ***********************************************
44
27
  * @param {String} buttonName
45
28
  * @returns 번역된 버튼 명
46
29
  */
47
- static tButton(buttonName: string): string;
30
+ static tButton(buttonName: string): import("i18next").TFunctionDetailedResult<object>;
48
31
  /**
49
32
  * @description 타이틀 titleName을 다국어 변환하여 리턴
50
33
  ***********************************************
@@ -52,14 +35,14 @@ export class TermsUtil {
52
35
  * @param {Object} params
53
36
  * @returns 번역된 타이틀 명
54
37
  */
55
- static tTitle(titleName: string, params: any): string;
38
+ static tTitle(titleName: string, params: any): import("i18next").TFunctionDetailedResult<object>;
56
39
  /**
57
40
  * @description 메뉴 menuName을 다국어 변환하여 리턴
58
41
  ***********************************************
59
42
  * @param {String} menuName
60
43
  * @returns 번역된 메뉴 명
61
44
  */
62
- static tMenu(menuName: string): string;
45
+ static tMenu(menuName: string): import("i18next").TFunctionDetailedResult<object>;
63
46
  /**
64
47
  * @description 텍스트 textName을 다국어 변환하여 리턴
65
48
  ***********************************************
@@ -67,7 +50,7 @@ export class TermsUtil {
67
50
  * @param {Object} params
68
51
  * @returns 번역된 텍스트 값
69
52
  */
70
- static tText(textName: string, params: any): string;
53
+ static tText(textName: string, params: any): import("i18next").TFunctionDetailedResult<object>;
71
54
  /**
72
55
  * @description 에러 errorName을 다국어 변환하여 리턴
73
56
  ***********************************************
@@ -75,7 +58,7 @@ export class TermsUtil {
75
58
  * @param {Object} params
76
59
  * @returns 번역된 에러 메시지
77
60
  */
78
- static tError(errorName: string, params: any): string;
61
+ static tError(errorName: string, params: any): import("i18next").TFunctionDetailedResult<object>;
79
62
  /**
80
63
  * @description termKey로 다국어 변환하여 parameters로 파라미터 처리하여 리턴, 변환값이 없다면 defaultValue 리턴, defaultValue가 없다면 null 리턴
81
64
  ***********************************************
@@ -85,14 +68,5 @@ export class TermsUtil {
85
68
  * @param {String} defaultValue
86
69
  * @returns termKey 다국어 변환 값
87
70
  */
88
- static translate(termCategory: string, termName: string, parameters: any, defaultValue: string): string;
89
- /**
90
- * @description termKey로 다국어 변환하여 parameters로 파라미터 처리하여 리턴, 변환값이 없다면 defaultValue 리턴, defaultValue가 없다면 null 리턴
91
- ***********************************************
92
- * @param {String} termKey 용어 키 : {용어 카테고리}'.'{용어 이름}
93
- * @param {Object} parameters 용어 이름에 파라미터가 있는 경우 파라미터 치환 처리할 오브젝트 데이터 {key1 : value1, key2 : value2} 형식 ...
94
- * @param {String} defaultValue
95
- * @returns termKey 다국어 변환 값
96
- */
97
- static t(termKey: string, parameters: any, defaultValue: string): string;
71
+ static translate(termCategory: string, termName: string, parameters: any, defaultValue: string): import("i18next").TFunctionDetailedResult<object>;
98
72
  }
@@ -1,5 +1,3 @@
1
- import gql from 'graphql-tag';
2
- import { client } from '@operato/graphql';
3
1
  import { i18next } from '@operato/i18n';
4
2
  /**
5
3
  * @license
@@ -8,57 +6,6 @@ import { i18next } from '@operato/i18n';
8
6
  * @description 용어 처리 유틸리티
9
7
  */
10
8
  export class TermsUtil {
11
- /**
12
- * @description 서버에 현재 로케일에 맞는 용어를 모두 조회
13
- ***********************************************
14
- * @param {String} locale
15
- */
16
- static async downloadTerminologies(locale) {
17
- let res = await TermsUtil.fetchTerminologies(locale);
18
- let records = res.records;
19
- if (records && records.length > 0) {
20
- TermsUtil.META_TERMS = {};
21
- records.forEach(r => {
22
- let name = `${r.category}.${r.name}`;
23
- TermsUtil.META_TERMS[name] = r.display;
24
- });
25
- }
26
- }
27
- /**
28
- * @description locale 정보로 용어 모두 조회
29
- *********************************************
30
- * @param {String} locale
31
- * @returns {Array} 용어 리스트
32
- */
33
- static async fetchTerminologies(locale) {
34
- let filters = [{ name: 'locale', operator: 'eq', value: locale }];
35
- let sortings = [{ name: 'category' }, { name: 'name' }];
36
- let page = 0;
37
- let limit = 0;
38
- const response = await client.query({
39
- query: gql `
40
- query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
41
- terminologies(filters: $filters, pagination: $pagination, sortings: $sortings) {
42
- items {
43
- name
44
- locale
45
- category
46
- display
47
- }
48
-
49
- total
50
- }
51
- }
52
- `,
53
- variables: { filters, sortings, pagination: { page, limit } }
54
- });
55
- if (!response.errors) {
56
- return {
57
- records: response.data.terminologies.items || [],
58
- total: response.data.terminologies.total || 0
59
- };
60
- }
61
- }
62
9
  /**
63
10
  * @description 라벨 (필드) labelName을 다국어 변환하여 리턴
64
11
  ***********************************************
@@ -141,37 +88,7 @@ export class TermsUtil {
141
88
  * @returns termKey 다국어 변환 값
142
89
  */
143
90
  static translate(termCategory, termName, parameters, defaultValue) {
144
- let termKey = termCategory + '.' + termName;
145
- return TermsUtil.t(termKey, parameters, defaultValue);
146
- }
147
- /**
148
- * @description termKey로 다국어 변환하여 parameters로 파라미터 처리하여 리턴, 변환값이 없다면 defaultValue 리턴, defaultValue가 없다면 null 리턴
149
- ***********************************************
150
- * @param {String} termKey 용어 키 : {용어 카테고리}'.'{용어 이름}
151
- * @param {Object} parameters 용어 이름에 파라미터가 있는 경우 파라미터 치환 처리할 오브젝트 데이터 {key1 : value1, key2 : value2} 형식 ...
152
- * @param {String} defaultValue
153
- * @returns termKey 다국어 변환 값
154
- */
155
- static t(termKey, parameters, defaultValue) {
156
- let translated = TermsUtil.META_TERMS ? TermsUtil.META_TERMS[termKey] : null;
157
- translated = translated ? translated : i18next.t(termKey);
158
- if (translated && termKey != translated) {
159
- if (parameters) {
160
- Object.keys(parameters).forEach(function (param) {
161
- var bracedData = '\\' + '{' + param.replace(/\$/, '\\$') + '\\' + '}';
162
- var regEx = new RegExp(bracedData, 'gi');
163
- translated = translated.replace(regEx, parameters[param]);
164
- });
165
- }
166
- return translated;
167
- }
168
- else {
169
- return defaultValue;
170
- }
91
+ return i18next.t(`${termCategory}.${termName}`, Object.assign(Object.assign({}, parameters), { defaultValue: defaultValue || termName }));
171
92
  }
172
93
  }
173
- /**
174
- * 용어 : 용어 키 - 용어 표현 값
175
- */
176
- TermsUtil.META_TERMS = null;
177
94
  //# sourceMappingURL=terms-util.js.map