@uniai-fe/util-functions 0.0.1 → 0.1.0
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/LICENSE +27 -0
- package/README.md +15 -0
- package/dist/api/index.cjs +235 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/index.d.cts +55 -0
- package/dist/api/index.d.ts +55 -0
- package/dist/api/index.mjs +231 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/convert/index.cjs +118 -0
- package/dist/convert/index.cjs.map +1 -0
- package/dist/convert/index.d.cts +93 -0
- package/dist/convert/index.d.ts +93 -0
- package/dist/convert/index.mjs +105 -0
- package/dist/convert/index.mjs.map +1 -0
- package/dist/date/index.cjs +260 -0
- package/dist/date/index.cjs.map +1 -0
- package/dist/date/index.d.cts +142 -0
- package/dist/date/index.d.ts +142 -0
- package/dist/date/index.mjs +244 -0
- package/dist/date/index.mjs.map +1 -0
- package/dist/form/checkbox/index.cjs +20 -0
- package/dist/form/checkbox/index.cjs.map +1 -0
- package/dist/form/checkbox/index.d.cts +21 -0
- package/dist/form/checkbox/index.d.ts +21 -0
- package/dist/form/checkbox/index.mjs +17 -0
- package/dist/form/checkbox/index.mjs.map +1 -0
- package/dist/format/index.cjs +193 -0
- package/dist/format/index.cjs.map +1 -0
- package/dist/format/index.d.cts +94 -0
- package/dist/format/index.d.ts +94 -0
- package/dist/format/index.mjs +183 -0
- package/dist/format/index.mjs.map +1 -0
- package/dist/index.cjs +873 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +799 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mask/index.cjs +76 -0
- package/dist/mask/index.cjs.map +1 -0
- package/dist/mask/index.d.cts +59 -0
- package/dist/mask/index.d.ts +59 -0
- package/dist/mask/index.mjs +70 -0
- package/dist/mask/index.mjs.map +1 -0
- package/dist/reg-exp/index.cjs +17 -0
- package/dist/reg-exp/index.cjs.map +1 -0
- package/dist/reg-exp/index.d.cts +18 -0
- package/dist/reg-exp/index.d.ts +18 -0
- package/dist/reg-exp/index.mjs +14 -0
- package/dist/reg-exp/index.mjs.map +1 -0
- package/dist/route/index.cjs +27 -0
- package/dist/route/index.cjs.map +1 -0
- package/dist/route/index.d.cts +27 -0
- package/dist/route/index.d.ts +27 -0
- package/dist/route/index.mjs +24 -0
- package/dist/route/index.mjs.map +1 -0
- package/dist/sort/index.cjs +42 -0
- package/dist/sort/index.cjs.map +1 -0
- package/dist/sort/index.d.cts +34 -0
- package/dist/sort/index.d.ts +34 -0
- package/dist/sort/index.mjs +37 -0
- package/dist/sort/index.mjs.map +1 -0
- package/dist/style/size/index.cjs +41 -0
- package/dist/style/size/index.cjs.map +1 -0
- package/{src/style/size.ts → dist/style/size/index.d.cts} +17 -58
- package/dist/style/size/index.d.ts +87 -0
- package/dist/style/size/index.mjs +33 -0
- package/dist/style/size/index.mjs.map +1 -0
- package/dist/type-CNV_n0-w.d.cts +22 -0
- package/dist/type-CNV_n0-w.d.ts +22 -0
- package/dist/validation/index.cjs +52 -0
- package/dist/validation/index.cjs.map +1 -0
- package/dist/validation/index.d.cts +104 -0
- package/dist/validation/index.d.ts +104 -0
- package/dist/validation/index.mjs +39 -0
- package/dist/validation/index.mjs.map +1 -0
- package/package.json +101 -44
- package/src/form/checkbox.ts +0 -41
- package/src/functions/api.server.ts +0 -114
- package/src/functions/api.ts +0 -515
- package/src/functions/chart.ts +0 -304
- package/src/functions/convert.ts +0 -229
- package/src/functions/crypto.ts +0 -44
- package/src/functions/date.ts +0 -386
- package/src/functions/file.ts +0 -57
- package/src/functions/format.ts +0 -318
- package/src/functions/log.ts +0 -9
- package/src/functions/mask.ts +0 -175
- package/src/functions/reg-exp.ts +0 -26
- package/src/functions/route.ts +0 -46
- package/src/functions/sort.ts +0 -71
- package/src/functions/validation.ts +0 -155
- package/src/index.tsx +0 -20
- package/src/react/convert.tsx +0 -129
- package/src/react/match.tsx +0 -41
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,873 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/reg-exp/module.ts
|
|
4
|
+
var escapeSymbol = (text) => {
|
|
5
|
+
const specialCharPattern = /([.*+?^${}()|[\]\\])/g;
|
|
6
|
+
const escapedText = text.replace(specialCharPattern, "\\$1");
|
|
7
|
+
return escapedText;
|
|
8
|
+
};
|
|
9
|
+
var escapeQuotes = (text) => {
|
|
10
|
+
const quotesPattern = /["']/g;
|
|
11
|
+
return text.replace(quotesPattern, "");
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// src/validation/module.ts
|
|
15
|
+
var isValidIdx = (idxValue) => typeof idxValue !== "undefined" && idxValue !== "" && !isNaN(Number(idxValue)) && Number(idxValue) > 0;
|
|
16
|
+
var isValidArray = (array) => typeof array !== "undefined" && Array.isArray(array);
|
|
17
|
+
var isValidBusinessCode = (businessCode) => {
|
|
18
|
+
if (!businessCode) return false;
|
|
19
|
+
if (String(businessCode).length === 10) return !isNaN(Number(businessCode));
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
22
|
+
var isValidDateNumber = (dateNumber) => {
|
|
23
|
+
const DATE_MIN = 16724988e5;
|
|
24
|
+
const DATE_MAX = 48281724e5;
|
|
25
|
+
return DATE_MIN < dateNumber && dateNumber < DATE_MAX;
|
|
26
|
+
};
|
|
27
|
+
var isValidDateType = (date) => {
|
|
28
|
+
if (!date) return false;
|
|
29
|
+
if (typeof date === "string" || typeof date === "number" && isValidDateNumber(date) || date instanceof Date)
|
|
30
|
+
return new Date(date) instanceof Date && !isNaN(new Date(date).valueOf());
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
var isValidUuidx = (uuidx) => typeof uuidx !== "undefined" && uuidx !== "";
|
|
34
|
+
var isValidBuildingNo = (buildingNo) => typeof buildingNo !== "undefined" && buildingNo !== "" && !isNaN(Number(buildingNo)) && Number(buildingNo) > 0;
|
|
35
|
+
var isValidBuildingNoList = (buildingNoList) => typeof buildingNoList === "string" && buildingNoList !== "" && buildingNoList.split(",").length > 0;
|
|
36
|
+
var isValidNumber = (value) => typeof value !== "undefined" && !isNaN(Number(value)) && value !== "";
|
|
37
|
+
var isValidFirmCategory = (categoryName) => typeof categoryName === "string" && /[농장|정부기관|유통사|수의사|병성기관|부화장|도계장|사료|약품|유니아이]/.test(
|
|
38
|
+
categoryName
|
|
39
|
+
);
|
|
40
|
+
var isValidFeedMedicineCategory = (categoryName) => typeof categoryName === "string" && /[약품|사료]/.test(categoryName);
|
|
41
|
+
var isValidTimeStringFormat = (time) => {
|
|
42
|
+
const hms = time.split(":");
|
|
43
|
+
if (hms.length !== 3 || hms.some((t) => isNaN(Number(t)))) return false;
|
|
44
|
+
if (Number(hms[0]) < 0 || Number(hms[0]) > 24) return false;
|
|
45
|
+
if (Number(hms[1]) < 0 || Number(hms[1]) > 59) return false;
|
|
46
|
+
if (Number(hms[2]) < 0 || Number(hms[2]) > 59) return false;
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/mask/module.ts
|
|
51
|
+
function maskPhone(value) {
|
|
52
|
+
const originValue = String(value).replace(/[^0-9]/g, "");
|
|
53
|
+
if (isNaN(Number(originValue))) return originValue;
|
|
54
|
+
const v = originValue.length > 11 ? originValue.slice(0, 11) : originValue;
|
|
55
|
+
let maskValue = v;
|
|
56
|
+
if (3 < v.length && v.length <= 7) {
|
|
57
|
+
maskValue = `${v.slice(0, 3)}-${v.slice(3)}`;
|
|
58
|
+
} else if (v.length === 8) {
|
|
59
|
+
maskValue = `${v.slice(0, 4)}-${v.slice(4)}`;
|
|
60
|
+
} else if (v.length === 9) {
|
|
61
|
+
maskValue = `${v.slice(0, 2)}-${v.slice(2, 5)}-${v.slice(5)}`;
|
|
62
|
+
} else if (v.length === 10) {
|
|
63
|
+
const firstDigits = v.startsWith("02") ? 2 : 3;
|
|
64
|
+
if (firstDigits === 2) {
|
|
65
|
+
maskValue = `${v.slice(0, 2)}-${v.slice(2, 6)}-${v.slice(6)}`;
|
|
66
|
+
} else {
|
|
67
|
+
maskValue = `${v.slice(0, 3)}-${v.slice(3, 6)}-${v.slice(6)}`;
|
|
68
|
+
}
|
|
69
|
+
} else if (v.length > 10) {
|
|
70
|
+
maskValue = `${v.slice(0, 3)}-${v.slice(3, 7)}-${v.slice(7)}`;
|
|
71
|
+
}
|
|
72
|
+
return maskValue;
|
|
73
|
+
}
|
|
74
|
+
function maskResidentCode(value) {
|
|
75
|
+
const originValue = String(value).replace(/[^0-9]/g, "");
|
|
76
|
+
if (isNaN(Number(originValue))) return originValue;
|
|
77
|
+
const v = originValue.length > 6 ? originValue.slice(0, 6) : originValue;
|
|
78
|
+
return v.length > 6 ? v.slice(0, 6) : v;
|
|
79
|
+
}
|
|
80
|
+
function maskBusinessCode(value) {
|
|
81
|
+
const originValue = String(value).replace(/[^0-9]/g, "");
|
|
82
|
+
if (isNaN(Number(originValue))) return originValue;
|
|
83
|
+
const v = originValue.length > 10 ? originValue.slice(0, 10) : originValue;
|
|
84
|
+
let maskValue = v;
|
|
85
|
+
if (3 < v.length && v.length < 6) {
|
|
86
|
+
maskValue = `${v.slice(0, 3)}-${v.slice(3)}`;
|
|
87
|
+
} else if (6 <= v.length) {
|
|
88
|
+
maskValue = `${v.slice(0, 3)}-${v.slice(3, 5)}-${v.slice(5)}`;
|
|
89
|
+
}
|
|
90
|
+
return maskValue;
|
|
91
|
+
}
|
|
92
|
+
function maskDecimalSeparator(value, options) {
|
|
93
|
+
const pureNumberValue = String(value).replace(/[^0-9.-]/g, "");
|
|
94
|
+
if (isNaN(Number(pureNumberValue))) return pureNumberValue;
|
|
95
|
+
const originValue = String(value).replace(/[^0-9,.-]/g, "");
|
|
96
|
+
const isPoint = originValue !== "" && originValue.indexOf(".") === originValue.length - 1;
|
|
97
|
+
const v = String(value).replace(/[^0-9.-]/g, "");
|
|
98
|
+
if (isNaN(Number(v))) return String(originValue);
|
|
99
|
+
return v === "" ? "" : `${new Intl.NumberFormat("en-US", {
|
|
100
|
+
style: "decimal",
|
|
101
|
+
...options
|
|
102
|
+
}).format(Number(v))}${isPoint ? "." : ""}`;
|
|
103
|
+
}
|
|
104
|
+
function maskDate(value) {
|
|
105
|
+
const originValue = String(value).replace(/[^0-9]/g, "");
|
|
106
|
+
if (isNaN(Number(originValue))) return originValue;
|
|
107
|
+
const v = originValue.length > 8 ? originValue.slice(0, 8) : originValue;
|
|
108
|
+
let maskValue = v;
|
|
109
|
+
if (4 < v.length && v.length < 7) {
|
|
110
|
+
maskValue = `${v.slice(0, 4)}-${v.slice(4)}`;
|
|
111
|
+
} else if (7 <= v.length) {
|
|
112
|
+
maskValue = `${v.slice(0, 4)}-${v.slice(4, 6)}-${v.slice(6)}`;
|
|
113
|
+
}
|
|
114
|
+
return maskValue;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/format/module.ts
|
|
118
|
+
var getNumberReplaceComma = (value, isString) => {
|
|
119
|
+
if (!["number", "string"].includes(typeof value) || value === null || value === "")
|
|
120
|
+
return "";
|
|
121
|
+
if (typeof value === "number") return value;
|
|
122
|
+
const v = Number(String(value).replace(/[^0-9.-]/g, ""));
|
|
123
|
+
if (isNaN(Number(v))) return isString ? "" : 0;
|
|
124
|
+
return isString ? String(v) : v;
|
|
125
|
+
};
|
|
126
|
+
var lengthFormat = (value, digit) => {
|
|
127
|
+
if (!["number", "string"].includes(typeof value) || value === null || value === "")
|
|
128
|
+
return "-";
|
|
129
|
+
if (isNaN(Number(getNumberReplaceComma(value)))) return String(value);
|
|
130
|
+
const digitOptions = typeof digit === "number" ? { minimumFractionDigits: digit, maximumFractionDigits: digit } : {};
|
|
131
|
+
return new Intl.NumberFormat("en-US", digitOptions).format(Number(value));
|
|
132
|
+
};
|
|
133
|
+
var DATE_FULL_OPTION = {
|
|
134
|
+
year: "numeric",
|
|
135
|
+
month: "2-digit",
|
|
136
|
+
day: "2-digit"
|
|
137
|
+
};
|
|
138
|
+
var NO_DATE_OPTION = {
|
|
139
|
+
year: void 0,
|
|
140
|
+
month: void 0,
|
|
141
|
+
day: void 0
|
|
142
|
+
};
|
|
143
|
+
var TIME_FULL_OPTION = {
|
|
144
|
+
hour12: false,
|
|
145
|
+
hour: "2-digit",
|
|
146
|
+
minute: "2-digit",
|
|
147
|
+
second: "2-digit"
|
|
148
|
+
};
|
|
149
|
+
var NO_TIME_OPTION = {
|
|
150
|
+
hour: void 0,
|
|
151
|
+
minute: void 0,
|
|
152
|
+
second: void 0
|
|
153
|
+
};
|
|
154
|
+
var correctTimezone = (date) => {
|
|
155
|
+
const utc = new Date(date).getTime() + new Date(date).getTimezoneOffset() * 6e4;
|
|
156
|
+
return new Date(utc + 9 * 60 * 6e4);
|
|
157
|
+
};
|
|
158
|
+
var dateFormat = (date, options) => {
|
|
159
|
+
if (isValidDateType(date)) {
|
|
160
|
+
const d = new Date(date);
|
|
161
|
+
const corrDate = correctTimezone(d);
|
|
162
|
+
const defaultDateFormat = options?.isCorrection ? `${corrDate.getFullYear()}-${convert2Digit(corrDate.getMonth() + 1)}-${convert2Digit(corrDate.getDate())}` : `${d.getFullYear()}-${convert2Digit(d.getMonth() + 1)}-${convert2Digit(d.getDate())}`;
|
|
163
|
+
if (options?.isISOString) return defaultDateFormat;
|
|
164
|
+
const onlyDate = defaultDateFormat || "";
|
|
165
|
+
if (options?.isKorean) {
|
|
166
|
+
const [y, m, d2] = onlyDate.split("-");
|
|
167
|
+
if (options.isKorean === true) return `${y}\uB144 ${m}\uC6D4 ${d2}\uC77C`;
|
|
168
|
+
const __ymd = options.isKorean.map((apply, index) => {
|
|
169
|
+
switch (index) {
|
|
170
|
+
case 0:
|
|
171
|
+
return apply ? `${y}\uB144` : "";
|
|
172
|
+
case 1:
|
|
173
|
+
return apply ? `${m}\uC6D4` : "";
|
|
174
|
+
case 2:
|
|
175
|
+
return apply ? `${d2}\uC77C` : "";
|
|
176
|
+
default:
|
|
177
|
+
return "";
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return __ymd.join(" ");
|
|
181
|
+
}
|
|
182
|
+
if (typeof options?.formatOptions !== "undefined")
|
|
183
|
+
return new Intl.DateTimeFormat(
|
|
184
|
+
options?.formatTimezone ? options.formatTimezone : "ko-KR",
|
|
185
|
+
{ ...DATE_FULL_OPTION, ...options.formatOptions, ...NO_TIME_OPTION }
|
|
186
|
+
).format(d);
|
|
187
|
+
return onlyDate;
|
|
188
|
+
}
|
|
189
|
+
return String(date);
|
|
190
|
+
};
|
|
191
|
+
var timeFormat = (date, options) => {
|
|
192
|
+
if (isValidDateType(date)) {
|
|
193
|
+
const d = new Date(date);
|
|
194
|
+
if (options?.isKST) {
|
|
195
|
+
const utc = d.getTime() + 60 * 60 * 1e3 * 9;
|
|
196
|
+
d.setTime(utc);
|
|
197
|
+
}
|
|
198
|
+
const defaultDateFormat = options?.isCorrection ? correctTimezone(d).toISOString().split("T")[1].split(".")[0] : new Intl.DateTimeFormat("en-US", {
|
|
199
|
+
...TIME_FULL_OPTION,
|
|
200
|
+
...NO_DATE_OPTION
|
|
201
|
+
}).format(d);
|
|
202
|
+
if (options?.isISOString) return defaultDateFormat;
|
|
203
|
+
const onlyDate = defaultDateFormat || "";
|
|
204
|
+
if (options?.isKorean) {
|
|
205
|
+
const [hr, min, sec] = onlyDate.split(":");
|
|
206
|
+
if (options.isKorean === true) return `${hr}\uC2DC\uAC04 ${min}\uBD84 ${sec}\uCD08`;
|
|
207
|
+
const __hms = options.isKorean.map((apply, index) => {
|
|
208
|
+
switch (index) {
|
|
209
|
+
case 0:
|
|
210
|
+
return apply ? `${hr}\uC2DC\uAC04` : "";
|
|
211
|
+
case 1:
|
|
212
|
+
return apply ? `${min}\uBD84` : "";
|
|
213
|
+
case 2:
|
|
214
|
+
return apply ? `${d}\uCD08` : "";
|
|
215
|
+
default:
|
|
216
|
+
return "";
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
return __hms.join(" ");
|
|
220
|
+
}
|
|
221
|
+
if (typeof options?.formatOptions !== "undefined") {
|
|
222
|
+
const res = new Intl.DateTimeFormat(
|
|
223
|
+
options?.formatTimezone ? options.formatTimezone : "ko-KR",
|
|
224
|
+
{ ...TIME_FULL_OPTION, ...options.formatOptions, ...NO_DATE_OPTION }
|
|
225
|
+
).format(d);
|
|
226
|
+
return res;
|
|
227
|
+
}
|
|
228
|
+
return onlyDate;
|
|
229
|
+
}
|
|
230
|
+
return String(date);
|
|
231
|
+
};
|
|
232
|
+
var durationFormat = (duration, options) => {
|
|
233
|
+
if (duration === null) return String(duration);
|
|
234
|
+
const hours = options?.hours === false ? null : Math.floor(duration / (60 * 60));
|
|
235
|
+
const minutes = options?.minutes === false ? null : Math.floor(duration % (60 * 60) / 60);
|
|
236
|
+
const seconds = options?.seconds === false ? null : duration % 60;
|
|
237
|
+
const HH = hours !== null ? `${hours}\uC2DC\uAC04 ` : "";
|
|
238
|
+
const MM = minutes !== null ? `${minutes}\uBD84 ` : "";
|
|
239
|
+
const SS = seconds !== null ? `${seconds}\uCD08` : "";
|
|
240
|
+
return `${HH}${MM}${SS}`.trim();
|
|
241
|
+
};
|
|
242
|
+
var phoneNumberFormat = maskPhone;
|
|
243
|
+
var deltaFormat = (value, digit = 0, isMaskLength = true) => {
|
|
244
|
+
if (typeof value === "undefined" || value === null || isNaN(Number(value)))
|
|
245
|
+
return "-";
|
|
246
|
+
const v = Number(value);
|
|
247
|
+
if (v > 0) return isMaskLength ? `+${lengthFormat(v, digit)}` : `+${v}`;
|
|
248
|
+
return lengthFormat(v, digit);
|
|
249
|
+
};
|
|
250
|
+
var distanceFormat = (distance, isUseUnit = true) => {
|
|
251
|
+
if (distance === null) return "-";
|
|
252
|
+
if (distance < 1e3) return `${distance}${isUseUnit ? "m" : ""}`;
|
|
253
|
+
return `${Math.floor(distance / 1e3)}${isUseUnit ? "km" : ""}`;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// src/convert/module.ts
|
|
257
|
+
var isKeyChainRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && typeof value !== "function";
|
|
258
|
+
var string = (value) => {
|
|
259
|
+
if (typeof value === "string") return value;
|
|
260
|
+
return JSON.stringify(value);
|
|
261
|
+
};
|
|
262
|
+
var parseData = (data) => {
|
|
263
|
+
if (/^(\{|\[)/.test(data)) return JSON.parse(data);
|
|
264
|
+
else if (!isNaN(Number(data))) return Number(data);
|
|
265
|
+
else if (data === "true" || data === "false") return JSON.parse(data);
|
|
266
|
+
else if (data === "undefined") return void 0;
|
|
267
|
+
return data;
|
|
268
|
+
};
|
|
269
|
+
var getValueByKeyChain = (data, keyChain) => {
|
|
270
|
+
if (isKeyChainRecord(data)) {
|
|
271
|
+
const firstChainIndex = keyChain.indexOf(".");
|
|
272
|
+
if (firstChainIndex === -1)
|
|
273
|
+
return data[keyChain];
|
|
274
|
+
const currentKey = keyChain.slice(0, firstChainIndex);
|
|
275
|
+
const remainKeyChain = keyChain.slice(firstChainIndex + 1);
|
|
276
|
+
const foundData = data[currentKey];
|
|
277
|
+
return isKeyChainRecord(foundData) ? getValueByKeyChain(foundData, remainKeyChain) : void 0;
|
|
278
|
+
}
|
|
279
|
+
return data;
|
|
280
|
+
};
|
|
281
|
+
var convertObjectToSearchParams = (data) => {
|
|
282
|
+
if (!data) {
|
|
283
|
+
console.log("[convertObjectToSearchParams] \uB370\uC774\uD130\uAC00 \uC720\uD6A8\uD558\uC9C0 \uC54A\uC74C", {
|
|
284
|
+
data
|
|
285
|
+
});
|
|
286
|
+
return new URLSearchParams();
|
|
287
|
+
}
|
|
288
|
+
if (data instanceof URLSearchParams) {
|
|
289
|
+
return data;
|
|
290
|
+
}
|
|
291
|
+
if (isKeyChainRecord(data) && Object.keys(data).length > 0) {
|
|
292
|
+
const d = Object.fromEntries(
|
|
293
|
+
Object.entries(data).map(([key, value]) => [
|
|
294
|
+
key,
|
|
295
|
+
string(value)
|
|
296
|
+
])
|
|
297
|
+
);
|
|
298
|
+
return new URLSearchParams(d);
|
|
299
|
+
}
|
|
300
|
+
console.log("[convertObjectToSearchParams] \uB370\uC774\uD130\uAC00 \uAC1D\uCCB4\uAC00 \uC544\uB2D8", {
|
|
301
|
+
data,
|
|
302
|
+
type: typeof data,
|
|
303
|
+
key: isKeyChainRecord(data) ? Object.keys(data) : [],
|
|
304
|
+
array: Array.isArray(data)
|
|
305
|
+
});
|
|
306
|
+
return new URLSearchParams();
|
|
307
|
+
};
|
|
308
|
+
var capitalize = (value) => {
|
|
309
|
+
const first = value.charAt(0).toUpperCase();
|
|
310
|
+
const others = value.slice(1);
|
|
311
|
+
return `${first}${others}`;
|
|
312
|
+
};
|
|
313
|
+
var covertGram = (kg) => Number(kg) * 1e3;
|
|
314
|
+
var covertKilogram = (gram) => Number(gram) / 1e3;
|
|
315
|
+
var convertLiter = (ml) => Number(ml) / 1e3;
|
|
316
|
+
var convertMilliliter = (liter) => Number(liter) * 1e3;
|
|
317
|
+
function extractCoreValue(value) {
|
|
318
|
+
if (isValidDateType(value)) return dateFormat(value);
|
|
319
|
+
if (typeof value === "string")
|
|
320
|
+
return value.replace(/[\s\n\t]+/g, "");
|
|
321
|
+
return value;
|
|
322
|
+
}
|
|
323
|
+
function convertDigit(v, digitLength = 2) {
|
|
324
|
+
const valueLength = String(Math.floor(v)).length;
|
|
325
|
+
const restLength = digitLength - valueLength;
|
|
326
|
+
const fill = Array(restLength).fill(0).join("");
|
|
327
|
+
return `${fill}${v}`;
|
|
328
|
+
}
|
|
329
|
+
var convert2Digit = (date_time) => date_time < 10 ? `0${date_time}` : String(date_time);
|
|
330
|
+
|
|
331
|
+
// src/date/module.ts
|
|
332
|
+
var getToday = (time) => `${dateFormat(/* @__PURE__ */ new Date())}${time && isValidTimeStringFormat(time) ? `T${time}` : ""}`;
|
|
333
|
+
function getPrevDay(date, weeks, days) {
|
|
334
|
+
if (!isValidDateType(date)) return void 0;
|
|
335
|
+
const standardDate = new Date(date);
|
|
336
|
+
const prevWeekDay = typeof weeks === "undefined" ? 0 : 7 * weeks;
|
|
337
|
+
const prevDays = typeof days === "undefined" ? 1 : days;
|
|
338
|
+
const prevDayAmount = prevWeekDay !== 0 ? prevWeekDay : prevDays;
|
|
339
|
+
standardDate.setDate(standardDate.getDate() - prevDayAmount);
|
|
340
|
+
return new Date(standardDate);
|
|
341
|
+
}
|
|
342
|
+
function getNextDay(date, weeks, days) {
|
|
343
|
+
if (!isValidDateType(date)) return void 0;
|
|
344
|
+
const standardDate = new Date(date);
|
|
345
|
+
const nextWeekDay = typeof weeks === "undefined" ? 0 : 7 * weeks;
|
|
346
|
+
const nextDays = typeof days === "undefined" ? 1 : days;
|
|
347
|
+
const nextDayAmount = nextWeekDay !== 0 ? nextWeekDay : nextDays;
|
|
348
|
+
standardDate.setDate(standardDate.getDate() + nextDayAmount);
|
|
349
|
+
return new Date(standardDate);
|
|
350
|
+
}
|
|
351
|
+
function getLastWeeks(date, weeks = 1) {
|
|
352
|
+
if (!isValidDateType(date)) return [];
|
|
353
|
+
const lastWeeks = [];
|
|
354
|
+
for (let d = 1; d <= 7 * weeks; d++) {
|
|
355
|
+
const prevDate = new Date(date);
|
|
356
|
+
lastWeeks.unshift(new Date(prevDate.setDate(prevDate.getDate() - d)));
|
|
357
|
+
}
|
|
358
|
+
return lastWeeks;
|
|
359
|
+
}
|
|
360
|
+
function getNextWeeks(date, weeks = 1) {
|
|
361
|
+
if (!isValidDateType(date)) return [];
|
|
362
|
+
const startDate = new Date(date);
|
|
363
|
+
return new Array(weeks * 7).fill(startDate).map((date2, index) => {
|
|
364
|
+
const nextDate = new Date(date2);
|
|
365
|
+
return new Date(nextDate.setDate(nextDate.getDate() + index));
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
function getDateArray(startDate, endDate, isFormat) {
|
|
369
|
+
if (!isValidDateType(startDate) || !isValidDateType(endDate)) return [];
|
|
370
|
+
const dayUnit = 1e3 * 60 * 60 * 24;
|
|
371
|
+
const start = new Date(dateFormat(startDate));
|
|
372
|
+
const end = new Date(dateFormat(endDate));
|
|
373
|
+
const array = [];
|
|
374
|
+
for (let day = start.getTime(); day <= end.getTime(); day += dayUnit) {
|
|
375
|
+
const d = isFormat ? dateFormat(new Date(day)) : new Date(day);
|
|
376
|
+
array.push(d);
|
|
377
|
+
}
|
|
378
|
+
return array;
|
|
379
|
+
}
|
|
380
|
+
function checkDateMoment(date) {
|
|
381
|
+
const res = {
|
|
382
|
+
isToday: false,
|
|
383
|
+
isPast: false,
|
|
384
|
+
isFuture: false,
|
|
385
|
+
moment: ""
|
|
386
|
+
};
|
|
387
|
+
if (!isValidDateType(date)) return res;
|
|
388
|
+
const standardDate = dateFormat(date);
|
|
389
|
+
const standardTime = new Date(standardDate).getTime();
|
|
390
|
+
const today = getToday();
|
|
391
|
+
const todayTime = new Date(today).getTime();
|
|
392
|
+
if (standardDate === today) {
|
|
393
|
+
res.isToday = true;
|
|
394
|
+
res.moment = "today";
|
|
395
|
+
} else if (standardTime < todayTime) {
|
|
396
|
+
res.isPast = true;
|
|
397
|
+
res.moment = "past";
|
|
398
|
+
} else if (standardTime > todayTime) {
|
|
399
|
+
res.isFuture = true;
|
|
400
|
+
res.moment = "future";
|
|
401
|
+
}
|
|
402
|
+
return res;
|
|
403
|
+
}
|
|
404
|
+
function weekOrderIndex(date) {
|
|
405
|
+
if (date && new Date(date) instanceof Date) {
|
|
406
|
+
const standardDate = new Date(date).getDate();
|
|
407
|
+
const firstWeekday = new Date(new Date(date).setDate(1)).getDay();
|
|
408
|
+
return Math.ceil((standardDate + firstWeekday) / 7);
|
|
409
|
+
}
|
|
410
|
+
return 0;
|
|
411
|
+
}
|
|
412
|
+
function getRepeatCycleUnit(FREQ) {
|
|
413
|
+
switch (FREQ) {
|
|
414
|
+
case "DAILY":
|
|
415
|
+
return "\uC77C";
|
|
416
|
+
case "WEEKLY":
|
|
417
|
+
return "\uC8FC";
|
|
418
|
+
case "MONTHLY":
|
|
419
|
+
return "\uAC1C\uC6D4";
|
|
420
|
+
case "YEARLY":
|
|
421
|
+
return "\uB144";
|
|
422
|
+
default:
|
|
423
|
+
return "\uC8FC\uAE30";
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function weekOrderKo(weekIndex) {
|
|
427
|
+
if (typeof weekIndex === "undefined") return "";
|
|
428
|
+
switch (String(weekIndex)) {
|
|
429
|
+
case "1":
|
|
430
|
+
return "\uCCAB\uBC88\uC9F8";
|
|
431
|
+
case "2":
|
|
432
|
+
return "\uB450\uBC88\uC9F8";
|
|
433
|
+
case "3":
|
|
434
|
+
return "\uC138\uBC88\uC9F8";
|
|
435
|
+
case "4":
|
|
436
|
+
return "\uB124\uBC88\uC9F8";
|
|
437
|
+
case "5":
|
|
438
|
+
return "\uB2E4\uC12F\uBC88\uC9F8";
|
|
439
|
+
case "6":
|
|
440
|
+
return "\uC5EC\uC12F\uBC88\uC9F8";
|
|
441
|
+
default:
|
|
442
|
+
return "";
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
function weekdayCodeByWeekdayIndex(weekdayIndex) {
|
|
446
|
+
if (typeof weekdayIndex === "undefined") return "";
|
|
447
|
+
switch (String(weekdayIndex)) {
|
|
448
|
+
case "0":
|
|
449
|
+
return "SU";
|
|
450
|
+
case "1":
|
|
451
|
+
return "MO";
|
|
452
|
+
case "2":
|
|
453
|
+
return "TU";
|
|
454
|
+
case "3":
|
|
455
|
+
return "WE";
|
|
456
|
+
case "4":
|
|
457
|
+
return "TH";
|
|
458
|
+
case "5":
|
|
459
|
+
return "FR";
|
|
460
|
+
case "6":
|
|
461
|
+
return "SA";
|
|
462
|
+
default:
|
|
463
|
+
return "";
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function weekdayByDayCode(dayCode, isFull) {
|
|
467
|
+
if (typeof dayCode === "undefined") return "";
|
|
468
|
+
const fullName = isFull ? "\uC694\uC77C" : "";
|
|
469
|
+
const code = String(dayCode);
|
|
470
|
+
if (code === "0" || code.includes("SU")) return `\uC77C${fullName}`;
|
|
471
|
+
else if (code === "1" || code.includes("MO")) return `\uC6D4${fullName}`;
|
|
472
|
+
else if (code === "2" || code.includes("TU")) return `\uD654${fullName}`;
|
|
473
|
+
else if (code === "3" || code.includes("WE")) return `\uC218${fullName}`;
|
|
474
|
+
else if (code === "4" || code.includes("TH")) return `\uBAA9${fullName}`;
|
|
475
|
+
else if (code === "5" || code.includes("FR")) return `\uAE08${fullName}`;
|
|
476
|
+
else if (code === "6" || code.includes("SA")) return `\uD1A0${fullName}`;
|
|
477
|
+
return ``;
|
|
478
|
+
}
|
|
479
|
+
function generateRepeatCycleDate(cycleDateString) {
|
|
480
|
+
const isRepeatDate = cycleDateString?.startsWith("date,") || false;
|
|
481
|
+
const isRepeatWeek = cycleDateString?.startsWith("weekday,") || false;
|
|
482
|
+
if (cycleDateString === "" || !(isRepeatDate || isRepeatWeek))
|
|
483
|
+
return void 0;
|
|
484
|
+
const selected = cycleDateString.split(",");
|
|
485
|
+
const repeatCycleDate = {
|
|
486
|
+
cycleDateUnit: selected[0]
|
|
487
|
+
};
|
|
488
|
+
if (selected[0] === "date") {
|
|
489
|
+
const repeatDay = selected[1]?.split("_")?.[1] || "";
|
|
490
|
+
Object.assign(repeatCycleDate, { repeatDay });
|
|
491
|
+
if (selected[2] !== "" && selected[2]?.startsWith("month_")) {
|
|
492
|
+
const repeatMonth = selected[2].split("_")?.[1] || "";
|
|
493
|
+
Object.assign(repeatCycleDate, { repeatMonth });
|
|
494
|
+
}
|
|
495
|
+
} else if (selected[0] === "weekday") {
|
|
496
|
+
const repeatWeekOrder = selected[1]?.split("_")?.[1] || "";
|
|
497
|
+
const repeatWeekDayIndex = selected[2]?.split("_")?.[1] || "";
|
|
498
|
+
Object.assign(repeatCycleDate, { repeatWeekOrder, repeatWeekDayIndex });
|
|
499
|
+
}
|
|
500
|
+
return repeatCycleDate;
|
|
501
|
+
}
|
|
502
|
+
function repeatCycleDateKo(repeatCycleDate) {
|
|
503
|
+
if (typeof repeatCycleDate === "undefined" || repeatCycleDate === "")
|
|
504
|
+
return "";
|
|
505
|
+
const option = generateRepeatCycleDate(repeatCycleDate);
|
|
506
|
+
if (option === void 0) return "";
|
|
507
|
+
if (option.cycleDateUnit === "date") {
|
|
508
|
+
const repeatMonthKo = option.repeatMonth ? `${option.repeatMonth}\uC6D4 ` : "";
|
|
509
|
+
const repeatDayKo = option.repeatDay ? `${option.repeatDay}\uC77C` : "";
|
|
510
|
+
return `${repeatMonthKo}${repeatDayKo}`;
|
|
511
|
+
} else if (option.cycleDateUnit === "weekday") {
|
|
512
|
+
const repeatWeekOrderKo = weekOrderKo(option.repeatWeekOrder);
|
|
513
|
+
const repeatWeekDayKo = weekdayByDayCode(option.repeatWeekDayIndex, true);
|
|
514
|
+
return `${repeatWeekOrderKo} ${repeatWeekDayKo}`;
|
|
515
|
+
}
|
|
516
|
+
return "";
|
|
517
|
+
}
|
|
518
|
+
function convertSelectedRepeatInfo(repeatUnit, repeatCycle, repeatCycleDate, repeatWeekly) {
|
|
519
|
+
const weekdayKorean = repeatUnit === "WEEKLY" && typeof repeatWeekly !== "undefined" && repeatWeekly !== "" ? String(repeatWeekly).split(",").map((dayIndex) => weekdayByDayCode(dayIndex, true)).join(",") : "";
|
|
520
|
+
switch (repeatUnit) {
|
|
521
|
+
case "DAILY":
|
|
522
|
+
return `${repeatCycle}\uC77C\uB9C8\uB2E4`;
|
|
523
|
+
case "WEEKLY":
|
|
524
|
+
return `\uB9E4\uC8FC ${weekdayKorean}`;
|
|
525
|
+
case "MONTHLY":
|
|
526
|
+
return `${repeatCycle}\uAC1C\uC6D4\uB9C8\uB2E4 ${repeatCycleDateKo(repeatCycleDate)}`;
|
|
527
|
+
case "YEARLY":
|
|
528
|
+
return `${repeatCycle}\uB144\uB9C8\uB2E4 ${repeatCycleDateKo(repeatCycleDate)}`;
|
|
529
|
+
default:
|
|
530
|
+
return "--";
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// src/route/module.ts
|
|
535
|
+
var getClosestRoute = (routes, currentPath) => {
|
|
536
|
+
let deepestMatch = null;
|
|
537
|
+
for (const route of routes) {
|
|
538
|
+
if (currentPath.startsWith(route.path)) {
|
|
539
|
+
if (!deepestMatch || route.path.length > deepestMatch.path.length) {
|
|
540
|
+
deepestMatch = route;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return deepestMatch;
|
|
545
|
+
};
|
|
546
|
+
var getMatchRoute = (routes, currentPath) => {
|
|
547
|
+
const res = { category: null, depth: null };
|
|
548
|
+
res.category = getClosestRoute(routes, currentPath);
|
|
549
|
+
if (res.category && res.category.depth) {
|
|
550
|
+
res.depth = getClosestRoute(res.category.depth, currentPath);
|
|
551
|
+
}
|
|
552
|
+
return res;
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
// src/sort/module.ts
|
|
556
|
+
var sortAsc = (a, b) => {
|
|
557
|
+
if (a === null || b === null) {
|
|
558
|
+
if (a === null && b !== null) return 1;
|
|
559
|
+
if (a !== null && b === null) return -1;
|
|
560
|
+
return 0;
|
|
561
|
+
}
|
|
562
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
563
|
+
};
|
|
564
|
+
var sortDesc = (a, b) => {
|
|
565
|
+
if (a === null || b === null) {
|
|
566
|
+
if (a === null && b !== null) return 1;
|
|
567
|
+
if (a !== null && b === null) return -1;
|
|
568
|
+
return 0;
|
|
569
|
+
}
|
|
570
|
+
return a > b ? -1 : a < b ? 1 : 0;
|
|
571
|
+
};
|
|
572
|
+
var sortDateAsc = (a, b) => {
|
|
573
|
+
if (a === null || b === null) {
|
|
574
|
+
if (a === null && b !== null) return 1;
|
|
575
|
+
if (a !== null && b === null) return -1;
|
|
576
|
+
return 0;
|
|
577
|
+
}
|
|
578
|
+
return sortAsc(new Date(a).getTime(), new Date(b).getTime());
|
|
579
|
+
};
|
|
580
|
+
var sortDateDesc = (a, b) => {
|
|
581
|
+
if (a === null || b === null) {
|
|
582
|
+
if (a === null && b !== null) return 1;
|
|
583
|
+
if (a !== null && b === null) return -1;
|
|
584
|
+
return 0;
|
|
585
|
+
}
|
|
586
|
+
return sortDesc(new Date(a).getTime(), new Date(b).getTime());
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
// src/api/module.ts
|
|
590
|
+
var defaultLogger = (method, routeUrl, queryUrl, ...messages) => {
|
|
591
|
+
if (process.env.NODE_ENV === "production") return;
|
|
592
|
+
const DATE = dateFormat(/* @__PURE__ */ new Date());
|
|
593
|
+
const TIME = new Intl.DateTimeFormat("en-US", {
|
|
594
|
+
hour: "numeric",
|
|
595
|
+
minute: "numeric",
|
|
596
|
+
second: "numeric",
|
|
597
|
+
hour12: false
|
|
598
|
+
}).format(/* @__PURE__ */ new Date()) + "." + (/* @__PURE__ */ new Date()).getMilliseconds();
|
|
599
|
+
const REQUEST_METHOD = method.split("-")[0]?.toUpperCase() || "-";
|
|
600
|
+
const RESPONSE_METHOD = method.split("-")[1] ? method.split("-")[1]?.toUpperCase() || "-" : REQUEST_METHOD;
|
|
601
|
+
return console.log(
|
|
602
|
+
`
|
|
603
|
+
`,
|
|
604
|
+
`[Backend API] \u23F1 ${DATE} ( ${TIME} )`,
|
|
605
|
+
`
|
|
606
|
+
\u03BB [${REQUEST_METHOD}] FE route`,
|
|
607
|
+
`
|
|
608
|
+
${routeUrl}`,
|
|
609
|
+
...queryUrl ? [`
|
|
610
|
+
\u2550\u23F5 \u03A9 [${RESPONSE_METHOD}] BE url`, `
|
|
611
|
+
${queryUrl}`, `
|
|
612
|
+
`] : [],
|
|
613
|
+
...messages?.[0] ? [` \u25C7-`, ...messages] : [],
|
|
614
|
+
`
|
|
615
|
+
`
|
|
616
|
+
);
|
|
617
|
+
};
|
|
618
|
+
var getFetchOptions = ({
|
|
619
|
+
method,
|
|
620
|
+
headers,
|
|
621
|
+
body
|
|
622
|
+
}) => {
|
|
623
|
+
const option = { method };
|
|
624
|
+
if (typeof headers !== "undefined") Object.assign(option, { headers });
|
|
625
|
+
if (typeof body !== "undefined") Object.assign(option, { body });
|
|
626
|
+
return option;
|
|
627
|
+
};
|
|
628
|
+
var getQueryString = (searchParams) => {
|
|
629
|
+
if (typeof searchParams === "undefined" || convertObjectToSearchParams(searchParams).toString() === "")
|
|
630
|
+
return "";
|
|
631
|
+
return `?${convertObjectToSearchParams(searchParams).toString()}`;
|
|
632
|
+
};
|
|
633
|
+
var resolveDomain = (infra, explicitDomain, resolver) => {
|
|
634
|
+
if (typeof explicitDomain === "string" && explicitDomain)
|
|
635
|
+
return explicitDomain;
|
|
636
|
+
if (typeof infra === "undefined") {
|
|
637
|
+
throw new Error(
|
|
638
|
+
"[createBackendApiClient] infra \uAC00 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC544 \uB3C4\uBA54\uC778\uC744 \uD574\uC11D\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
const domain = resolver(infra);
|
|
642
|
+
if (!domain) {
|
|
643
|
+
throw new Error(
|
|
644
|
+
`[createBackendApiClient] \uB3C4\uBA54\uC778\uC744 \uD574\uC11D\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. (infra: ${infra})`
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
return domain;
|
|
648
|
+
};
|
|
649
|
+
var createBackendApiClient = (config) => {
|
|
650
|
+
const baseLogger = config.logger ?? defaultLogger;
|
|
651
|
+
const generateBackendQueryUrl_GET = ({
|
|
652
|
+
infra,
|
|
653
|
+
domain,
|
|
654
|
+
routeUrl,
|
|
655
|
+
queryUrl,
|
|
656
|
+
searchParams,
|
|
657
|
+
log,
|
|
658
|
+
logDisabled,
|
|
659
|
+
logger
|
|
660
|
+
}) => {
|
|
661
|
+
const resolvedDomain = resolveDomain(infra, domain, config.resolveDomain);
|
|
662
|
+
const url = `${resolvedDomain}${queryUrl}${getQueryString(searchParams)}`;
|
|
663
|
+
const logFn = logger ?? baseLogger;
|
|
664
|
+
if (!logDisabled)
|
|
665
|
+
logFn("get", routeUrl, url, {
|
|
666
|
+
...log,
|
|
667
|
+
...searchParams ? searchParams : {}
|
|
668
|
+
});
|
|
669
|
+
return url;
|
|
670
|
+
};
|
|
671
|
+
const fetchBackendQuery = async ({
|
|
672
|
+
infra,
|
|
673
|
+
domain,
|
|
674
|
+
routeUrl,
|
|
675
|
+
queryUrl,
|
|
676
|
+
method,
|
|
677
|
+
headers,
|
|
678
|
+
body,
|
|
679
|
+
bodyOriginData,
|
|
680
|
+
queryStringData,
|
|
681
|
+
log,
|
|
682
|
+
logDisabled,
|
|
683
|
+
fetchDisabled,
|
|
684
|
+
logger
|
|
685
|
+
}) => {
|
|
686
|
+
const resolvedDomain = resolveDomain(infra, domain, config.resolveDomain);
|
|
687
|
+
const url = `${resolvedDomain}${queryUrl}${getQueryString(queryStringData)}`;
|
|
688
|
+
const errRes = {
|
|
689
|
+
is_ok: false,
|
|
690
|
+
idx: "",
|
|
691
|
+
error: ""
|
|
692
|
+
};
|
|
693
|
+
const bodyData = convertObjectToSearchParams(bodyOriginData);
|
|
694
|
+
if (typeof bodyOriginData !== "undefined" && bodyData.toString() === "") {
|
|
695
|
+
if (!logDisabled) {
|
|
696
|
+
(logger ?? baseLogger)(method.toLowerCase(), routeUrl, url, {
|
|
697
|
+
state: "ERROR (BODY - ORIGIN DATA)",
|
|
698
|
+
error: "\uB370\uC774\uD130\uAC00 \uC720\uD6A8\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.",
|
|
699
|
+
bodyOriginData,
|
|
700
|
+
...log
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
errRes.error = "\uB370\uC774\uD130\uAC00 \uC720\uD6A8\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.";
|
|
704
|
+
return errRes;
|
|
705
|
+
}
|
|
706
|
+
const option = getFetchOptions({
|
|
707
|
+
method,
|
|
708
|
+
headers,
|
|
709
|
+
body
|
|
710
|
+
});
|
|
711
|
+
if (!body && typeof bodyOriginData !== "undefined")
|
|
712
|
+
Object.assign(option, { body: bodyData });
|
|
713
|
+
const logFn = logger ?? baseLogger;
|
|
714
|
+
if (!logDisabled) {
|
|
715
|
+
logFn(method.toLowerCase(), routeUrl, url, {
|
|
716
|
+
state: "READY",
|
|
717
|
+
...option,
|
|
718
|
+
...log
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
if (fetchDisabled) {
|
|
722
|
+
errRes.error = "API \uC694\uCCAD\uC81C\uD55C \uD65C\uC131\uD654\uB428.";
|
|
723
|
+
return errRes;
|
|
724
|
+
}
|
|
725
|
+
try {
|
|
726
|
+
const res = await (await fetch(url, option)).json();
|
|
727
|
+
if (!logDisabled) {
|
|
728
|
+
const isSuccess = "is_ok" in res && typeof res?.is_ok === "boolean" && res.is_ok === true;
|
|
729
|
+
logFn(method.toLowerCase(), routeUrl, url, {
|
|
730
|
+
state: isSuccess ? "SUCCESS" : "FAIL",
|
|
731
|
+
...res
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
return res;
|
|
735
|
+
} catch (error) {
|
|
736
|
+
errRes.error = error instanceof Error ? error.message || "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD558\uC600\uC2B5\uB2C8\uB2E4." : String(error);
|
|
737
|
+
if (!logDisabled) {
|
|
738
|
+
logFn(method.toLowerCase(), routeUrl, url, {
|
|
739
|
+
state: "ERROR (RESPONSE)",
|
|
740
|
+
error,
|
|
741
|
+
...log
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
return errRes;
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
return {
|
|
748
|
+
getQueryString,
|
|
749
|
+
generateBackendQueryUrl_GET,
|
|
750
|
+
fetchBackendQuery,
|
|
751
|
+
logger: baseLogger
|
|
752
|
+
};
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
// src/form/checkbox/module.ts
|
|
756
|
+
var syncAllToEach = (checkStateObject, allCheckState) => Object.fromEntries(
|
|
757
|
+
Object.entries(checkStateObject).map(([key]) => [key, allCheckState])
|
|
758
|
+
);
|
|
759
|
+
var syncEachToAll = (checkStateObject, eachKey, eachChecked) => {
|
|
760
|
+
const res = { ...checkStateObject, [eachKey]: eachChecked };
|
|
761
|
+
const exceptStateAll = Object.entries(res).filter(([key]) => key !== "all").map(([, checked]) => checked);
|
|
762
|
+
const isAllEachChecked = Object.values(exceptStateAll).every(
|
|
763
|
+
(checked) => checked
|
|
764
|
+
);
|
|
765
|
+
res.all = isAllEachChecked;
|
|
766
|
+
return res;
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
// src/style/size/module.ts
|
|
770
|
+
var styleRemAmount = 10;
|
|
771
|
+
var styleRem = (v) => `${v / styleRemAmount}rem`;
|
|
772
|
+
var styleBaseSize = (unit, v, alt) => {
|
|
773
|
+
if (!["number", "string"].includes(typeof v) && typeof alt === "undefined")
|
|
774
|
+
return "auto";
|
|
775
|
+
if (typeof v === "number")
|
|
776
|
+
return unit === "rem" ? styleRem(v) : `${v}${unit}`;
|
|
777
|
+
if (typeof v === "string" && v) return v;
|
|
778
|
+
if (typeof alt === "number")
|
|
779
|
+
return unit === "rem" ? styleRem(alt) : `${alt}${unit}`;
|
|
780
|
+
else if (typeof alt === "string" && alt) return alt;
|
|
781
|
+
return String(v);
|
|
782
|
+
};
|
|
783
|
+
var styleSpacingArray = (unit, v) => v.map((space) => styleBaseSize(unit, space)).join(" ");
|
|
784
|
+
var styleSpacingSize = (unit, spacing, alt) => {
|
|
785
|
+
if (typeof spacing === "undefined") {
|
|
786
|
+
if (typeof alt === "undefined") return "0";
|
|
787
|
+
if (Array.isArray(alt)) return styleSpacingArray(unit, alt);
|
|
788
|
+
else if (["number", "string"].includes(typeof alt) && alt !== "")
|
|
789
|
+
return styleBaseSize(unit, alt);
|
|
790
|
+
}
|
|
791
|
+
if (["number", "string"].includes(typeof spacing) && spacing !== "")
|
|
792
|
+
return styleBaseSize(unit, spacing);
|
|
793
|
+
if (Array.isArray(spacing)) return styleSpacingArray(unit, spacing);
|
|
794
|
+
return String(spacing);
|
|
795
|
+
};
|
|
796
|
+
var stylePaddingSize = styleSpacingSize;
|
|
797
|
+
var styleMarginSize = styleSpacingSize;
|
|
798
|
+
|
|
799
|
+
exports.capitalize = capitalize;
|
|
800
|
+
exports.checkDateMoment = checkDateMoment;
|
|
801
|
+
exports.convert2Digit = convert2Digit;
|
|
802
|
+
exports.convertDigit = convertDigit;
|
|
803
|
+
exports.convertLiter = convertLiter;
|
|
804
|
+
exports.convertMilliliter = convertMilliliter;
|
|
805
|
+
exports.convertObjectToSearchParams = convertObjectToSearchParams;
|
|
806
|
+
exports.convertSelectedRepeatInfo = convertSelectedRepeatInfo;
|
|
807
|
+
exports.correctTimezone = correctTimezone;
|
|
808
|
+
exports.covertGram = covertGram;
|
|
809
|
+
exports.covertKilogram = covertKilogram;
|
|
810
|
+
exports.createBackendApiClient = createBackendApiClient;
|
|
811
|
+
exports.dateFormat = dateFormat;
|
|
812
|
+
exports.defaultApiLogger = defaultLogger;
|
|
813
|
+
exports.deltaFormat = deltaFormat;
|
|
814
|
+
exports.distanceFormat = distanceFormat;
|
|
815
|
+
exports.durationFormat = durationFormat;
|
|
816
|
+
exports.escapeQuotes = escapeQuotes;
|
|
817
|
+
exports.escapeSymbol = escapeSymbol;
|
|
818
|
+
exports.extractCoreValue = extractCoreValue;
|
|
819
|
+
exports.generateRepeatCycleDate = generateRepeatCycleDate;
|
|
820
|
+
exports.getClosestRoute = getClosestRoute;
|
|
821
|
+
exports.getDateArray = getDateArray;
|
|
822
|
+
exports.getLastWeeks = getLastWeeks;
|
|
823
|
+
exports.getMatchRoute = getMatchRoute;
|
|
824
|
+
exports.getNextDay = getNextDay;
|
|
825
|
+
exports.getNextWeeks = getNextWeeks;
|
|
826
|
+
exports.getNumberReplaceComma = getNumberReplaceComma;
|
|
827
|
+
exports.getPrevDay = getPrevDay;
|
|
828
|
+
exports.getQueryString = getQueryString;
|
|
829
|
+
exports.getRepeatCycleUnit = getRepeatCycleUnit;
|
|
830
|
+
exports.getToday = getToday;
|
|
831
|
+
exports.getValueByKeyChain = getValueByKeyChain;
|
|
832
|
+
exports.isValidArray = isValidArray;
|
|
833
|
+
exports.isValidBuildingNo = isValidBuildingNo;
|
|
834
|
+
exports.isValidBuildingNoList = isValidBuildingNoList;
|
|
835
|
+
exports.isValidBusinessCode = isValidBusinessCode;
|
|
836
|
+
exports.isValidDateNumber = isValidDateNumber;
|
|
837
|
+
exports.isValidDateType = isValidDateType;
|
|
838
|
+
exports.isValidFeedMedicineCategory = isValidFeedMedicineCategory;
|
|
839
|
+
exports.isValidFirmCategory = isValidFirmCategory;
|
|
840
|
+
exports.isValidIdx = isValidIdx;
|
|
841
|
+
exports.isValidNumber = isValidNumber;
|
|
842
|
+
exports.isValidTimeStringFormat = isValidTimeStringFormat;
|
|
843
|
+
exports.isValidUuidx = isValidUuidx;
|
|
844
|
+
exports.lengthFormat = lengthFormat;
|
|
845
|
+
exports.maskBusinessCode = maskBusinessCode;
|
|
846
|
+
exports.maskDate = maskDate;
|
|
847
|
+
exports.maskDecimalSeparator = maskDecimalSeparator;
|
|
848
|
+
exports.maskPhone = maskPhone;
|
|
849
|
+
exports.maskResidentCode = maskResidentCode;
|
|
850
|
+
exports.parseData = parseData;
|
|
851
|
+
exports.phoneNumberFormat = phoneNumberFormat;
|
|
852
|
+
exports.repeatCycleDateKo = repeatCycleDateKo;
|
|
853
|
+
exports.sortAsc = sortAsc;
|
|
854
|
+
exports.sortDateAsc = sortDateAsc;
|
|
855
|
+
exports.sortDateDesc = sortDateDesc;
|
|
856
|
+
exports.sortDesc = sortDesc;
|
|
857
|
+
exports.string = string;
|
|
858
|
+
exports.styleBaseSize = styleBaseSize;
|
|
859
|
+
exports.styleMarginSize = styleMarginSize;
|
|
860
|
+
exports.stylePaddingSize = stylePaddingSize;
|
|
861
|
+
exports.styleRem = styleRem;
|
|
862
|
+
exports.styleRemAmount = styleRemAmount;
|
|
863
|
+
exports.styleSpacingArray = styleSpacingArray;
|
|
864
|
+
exports.styleSpacingSize = styleSpacingSize;
|
|
865
|
+
exports.syncAllToEach = syncAllToEach;
|
|
866
|
+
exports.syncEachToAll = syncEachToAll;
|
|
867
|
+
exports.timeFormat = timeFormat;
|
|
868
|
+
exports.weekOrderIndex = weekOrderIndex;
|
|
869
|
+
exports.weekOrderKo = weekOrderKo;
|
|
870
|
+
exports.weekdayByDayCode = weekdayByDayCode;
|
|
871
|
+
exports.weekdayCodeByWeekdayIndex = weekdayCodeByWeekdayIndex;
|
|
872
|
+
//# sourceMappingURL=index.cjs.map
|
|
873
|
+
//# sourceMappingURL=index.cjs.map
|