sales-frontend-utils 0.0.40 → 0.0.41
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 +24 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -4
- package/dist/index.d.ts +37 -4
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -392,6 +392,25 @@ declare const convertDateFormat: (value?: string | number | dayjs.Dayjs | Date,
|
|
|
392
392
|
* @returns {boolean} - 주어진 날짜가 오늘 이후라면 true를 반환합니다.
|
|
393
393
|
*/
|
|
394
394
|
declare const isFutureDate: (dateString?: string | number | dayjs.Dayjs | Date, format?: dayjs.OptionType) => boolean;
|
|
395
|
+
/**
|
|
396
|
+
* 자주 사용하는 타입들 추가해두었습니다. 필요하신 형태 있으면 추가해주세요.
|
|
397
|
+
*/
|
|
398
|
+
type DateFormat = 'YYYY-MM-DD' | 'YYYY.MM.DD' | 'YYYY-MM' | 'YYYY-MM-DD HH:mm:ss' | 'YYYY.MM.DD HH:mm:ss' | 'YYYY-MM-DD HH:mm' | 'YYYYMMDD' | 'YYYY.M.D' | 'YYYY.M' | 'YYYY.MM.DD(dd) HH:mm:ss' | 'HH:mm:ss' | 'YYYY.M.D(dd)' | 'HH:mm';
|
|
399
|
+
interface Props {
|
|
400
|
+
/** 날짜 문자열 */
|
|
401
|
+
dateString: string | number | Date | dayjs.Dayjs;
|
|
402
|
+
/** 현재 날짜 포맷 */
|
|
403
|
+
fromFormat?: string;
|
|
404
|
+
/** 컨버팅할 날짜 포맷 */
|
|
405
|
+
toFormat: string;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* date string 을 입력받고 패턴에 맞게 포맷팅을 변경하는 유틸 함수
|
|
409
|
+
* fromFormat 현재 날짜 포맷
|
|
410
|
+
* toFormat 리턴 날짜 포맷
|
|
411
|
+
*/
|
|
412
|
+
declare const convertDateString: ({ dateString, fromFormat, toFormat }: Props) => string;
|
|
413
|
+
declare const isDate: (value: unknown) => boolean;
|
|
395
414
|
/**
|
|
396
415
|
* 날짜 유효성 검사
|
|
397
416
|
*
|
|
@@ -400,10 +419,24 @@ declare const isFutureDate: (dateString?: string | number | dayjs.Dayjs | Date,
|
|
|
400
419
|
* @returns {boolean} - 유효한 날짜이면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
|
|
401
420
|
*/
|
|
402
421
|
declare const isValidDate: (dateString?: string | number | dayjs.Dayjs | Date, format?: dayjs.OptionType) => boolean;
|
|
403
|
-
type PeriodType = 'thisWeek' | 'lastWeek' | 'last7Days' | 'thisMonth' | 'lastMonth' | 'last365Days';
|
|
404
|
-
|
|
422
|
+
type PeriodType = 'thisWeek' | 'lastWeek' | 'last7Days' | 'thisMonth' | 'lastMonth' | 'last365Days' | 'week' | 'month' | 'today';
|
|
423
|
+
/**
|
|
424
|
+
* @description
|
|
425
|
+
* today 당일
|
|
426
|
+
* week 7일: 오늘 기준 7일 전
|
|
427
|
+
* month 30: 오늘 기준 30일 전
|
|
428
|
+
* thisWeek 이번 주 (일요일 ~ 토요일)
|
|
429
|
+
* lastWeek 지난 주 (일요일 ~ 토요일)
|
|
430
|
+
* last7Days 최근 7일 (오늘 포함)
|
|
431
|
+
* thisMonth 이번 달 (1일 ~ 말일)
|
|
432
|
+
* lastMonth 지난 달 (1일 ~ 말일)
|
|
433
|
+
* last365Days 최근 365일 (오늘 포함)
|
|
434
|
+
* @param periodType
|
|
435
|
+
* @returns
|
|
436
|
+
*/
|
|
437
|
+
declare const getPeriodDate: (periodType: PeriodType | "today") => {
|
|
405
438
|
startDate: Date;
|
|
406
439
|
endDate: Date;
|
|
407
|
-
};
|
|
440
|
+
} | null;
|
|
408
441
|
|
|
409
|
-
export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, type PeriodType, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertDateFormat, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDateDiff, getDeviceModel, getDspApiBasePathFromEnvironment, getDspExecutionEnvironment, getDudApiBasePathFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getLastDay, getNlcHostFromEnvironment, getOSName, getOSVersion, getOneMonthLater, getOrCreateDeviceId, getPeriodDate, getServicePath, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDateAfter, isDspApp, isFpPlannerApp, isFutureDate, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, isValidDate, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle, validateBirthdate };
|
|
442
|
+
export { type BrowserName, type DateFormat, type ExecutionEnvironment, MessageEventManager, type OSName, type PeriodType, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertDateFormat, convertDateString, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDateDiff, getDeviceModel, getDspApiBasePathFromEnvironment, getDspExecutionEnvironment, getDudApiBasePathFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getLastDay, getNlcHostFromEnvironment, getOSName, getOSVersion, getOneMonthLater, getOrCreateDeviceId, getPeriodDate, getServicePath, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDate, isDateAfter, isDspApp, isFpPlannerApp, isFutureDate, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, isValidDate, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle, validateBirthdate };
|
package/dist/index.d.ts
CHANGED
|
@@ -392,6 +392,25 @@ declare const convertDateFormat: (value?: string | number | dayjs.Dayjs | Date,
|
|
|
392
392
|
* @returns {boolean} - 주어진 날짜가 오늘 이후라면 true를 반환합니다.
|
|
393
393
|
*/
|
|
394
394
|
declare const isFutureDate: (dateString?: string | number | dayjs.Dayjs | Date, format?: dayjs.OptionType) => boolean;
|
|
395
|
+
/**
|
|
396
|
+
* 자주 사용하는 타입들 추가해두었습니다. 필요하신 형태 있으면 추가해주세요.
|
|
397
|
+
*/
|
|
398
|
+
type DateFormat = 'YYYY-MM-DD' | 'YYYY.MM.DD' | 'YYYY-MM' | 'YYYY-MM-DD HH:mm:ss' | 'YYYY.MM.DD HH:mm:ss' | 'YYYY-MM-DD HH:mm' | 'YYYYMMDD' | 'YYYY.M.D' | 'YYYY.M' | 'YYYY.MM.DD(dd) HH:mm:ss' | 'HH:mm:ss' | 'YYYY.M.D(dd)' | 'HH:mm';
|
|
399
|
+
interface Props {
|
|
400
|
+
/** 날짜 문자열 */
|
|
401
|
+
dateString: string | number | Date | dayjs.Dayjs;
|
|
402
|
+
/** 현재 날짜 포맷 */
|
|
403
|
+
fromFormat?: string;
|
|
404
|
+
/** 컨버팅할 날짜 포맷 */
|
|
405
|
+
toFormat: string;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* date string 을 입력받고 패턴에 맞게 포맷팅을 변경하는 유틸 함수
|
|
409
|
+
* fromFormat 현재 날짜 포맷
|
|
410
|
+
* toFormat 리턴 날짜 포맷
|
|
411
|
+
*/
|
|
412
|
+
declare const convertDateString: ({ dateString, fromFormat, toFormat }: Props) => string;
|
|
413
|
+
declare const isDate: (value: unknown) => boolean;
|
|
395
414
|
/**
|
|
396
415
|
* 날짜 유효성 검사
|
|
397
416
|
*
|
|
@@ -400,10 +419,24 @@ declare const isFutureDate: (dateString?: string | number | dayjs.Dayjs | Date,
|
|
|
400
419
|
* @returns {boolean} - 유효한 날짜이면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
|
|
401
420
|
*/
|
|
402
421
|
declare const isValidDate: (dateString?: string | number | dayjs.Dayjs | Date, format?: dayjs.OptionType) => boolean;
|
|
403
|
-
type PeriodType = 'thisWeek' | 'lastWeek' | 'last7Days' | 'thisMonth' | 'lastMonth' | 'last365Days';
|
|
404
|
-
|
|
422
|
+
type PeriodType = 'thisWeek' | 'lastWeek' | 'last7Days' | 'thisMonth' | 'lastMonth' | 'last365Days' | 'week' | 'month' | 'today';
|
|
423
|
+
/**
|
|
424
|
+
* @description
|
|
425
|
+
* today 당일
|
|
426
|
+
* week 7일: 오늘 기준 7일 전
|
|
427
|
+
* month 30: 오늘 기준 30일 전
|
|
428
|
+
* thisWeek 이번 주 (일요일 ~ 토요일)
|
|
429
|
+
* lastWeek 지난 주 (일요일 ~ 토요일)
|
|
430
|
+
* last7Days 최근 7일 (오늘 포함)
|
|
431
|
+
* thisMonth 이번 달 (1일 ~ 말일)
|
|
432
|
+
* lastMonth 지난 달 (1일 ~ 말일)
|
|
433
|
+
* last365Days 최근 365일 (오늘 포함)
|
|
434
|
+
* @param periodType
|
|
435
|
+
* @returns
|
|
436
|
+
*/
|
|
437
|
+
declare const getPeriodDate: (periodType: PeriodType | "today") => {
|
|
405
438
|
startDate: Date;
|
|
406
439
|
endDate: Date;
|
|
407
|
-
};
|
|
440
|
+
} | null;
|
|
408
441
|
|
|
409
|
-
export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, type PeriodType, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertDateFormat, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDateDiff, getDeviceModel, getDspApiBasePathFromEnvironment, getDspExecutionEnvironment, getDudApiBasePathFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getLastDay, getNlcHostFromEnvironment, getOSName, getOSVersion, getOneMonthLater, getOrCreateDeviceId, getPeriodDate, getServicePath, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDateAfter, isDspApp, isFpPlannerApp, isFutureDate, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, isValidDate, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle, validateBirthdate };
|
|
442
|
+
export { type BrowserName, type DateFormat, type ExecutionEnvironment, MessageEventManager, type OSName, type PeriodType, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertDateFormat, convertDateString, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDateDiff, getDeviceModel, getDspApiBasePathFromEnvironment, getDspExecutionEnvironment, getDudApiBasePathFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getLastDay, getNlcHostFromEnvironment, getOSName, getOSVersion, getOneMonthLater, getOrCreateDeviceId, getPeriodDate, getServicePath, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDate, isDateAfter, isDspApp, isFpPlannerApp, isFutureDate, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, isValidDate, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle, validateBirthdate };
|
package/dist/index.js
CHANGED
|
@@ -919,6 +919,12 @@ var isFutureDate = (dateString, format) => {
|
|
|
919
919
|
const date = dayjs(dateString, format || "YYYYMMDD", true);
|
|
920
920
|
return date.isValid() && date.isAfter(today);
|
|
921
921
|
};
|
|
922
|
+
var convertDateString = ({ dateString, fromFormat, toFormat }) => {
|
|
923
|
+
return dayjs(dateString, fromFormat).format(toFormat);
|
|
924
|
+
};
|
|
925
|
+
var isDate = (value) => {
|
|
926
|
+
return value instanceof Date && !isNaN(+value);
|
|
927
|
+
};
|
|
922
928
|
var isValidDate = (dateString, format) => {
|
|
923
929
|
if (!dateString) {
|
|
924
930
|
return false;
|
|
@@ -928,7 +934,22 @@ var isValidDate = (dateString, format) => {
|
|
|
928
934
|
};
|
|
929
935
|
var getPeriodDate = (periodType) => {
|
|
930
936
|
const lastMonth = dayjs().subtract(1, "M");
|
|
937
|
+
const today = /* @__PURE__ */ new Date();
|
|
938
|
+
today.setHours(0, 0, 0, 0);
|
|
939
|
+
const endDate = new Date(today);
|
|
940
|
+
let startDate;
|
|
931
941
|
switch (periodType) {
|
|
942
|
+
case "today":
|
|
943
|
+
startDate = new Date(today);
|
|
944
|
+
return { startDate, endDate };
|
|
945
|
+
case "week":
|
|
946
|
+
startDate = new Date(today);
|
|
947
|
+
startDate.setDate(startDate.getDate() - 6);
|
|
948
|
+
return { startDate, endDate };
|
|
949
|
+
case "month":
|
|
950
|
+
startDate = new Date(today);
|
|
951
|
+
startDate.setDate(startDate.getDate() - 29);
|
|
952
|
+
return { startDate, endDate };
|
|
932
953
|
case "thisWeek":
|
|
933
954
|
return { startDate: dayjs().day(0).toDate(), endDate: dayjs().day(6).toDate() };
|
|
934
955
|
case "lastWeek":
|
|
@@ -951,10 +972,10 @@ var getPeriodDate = (periodType) => {
|
|
|
951
972
|
case "last365Days":
|
|
952
973
|
return { startDate: dayjs().subtract(365, "d").toDate(), endDate: dayjs().toDate() };
|
|
953
974
|
default:
|
|
954
|
-
return
|
|
975
|
+
return null;
|
|
955
976
|
}
|
|
956
977
|
};
|
|
957
978
|
|
|
958
|
-
export { MessageEventManager, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertDateFormat, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDateDiff, getDeviceModel, getDspApiBasePathFromEnvironment, getDspExecutionEnvironment, getDudApiBasePathFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getLastDay, getNlcHostFromEnvironment, getOSName, getOSVersion, getOneMonthLater, getOrCreateDeviceId, getPeriodDate, getServicePath, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDateAfter, isDspApp, isFpPlannerApp, isFutureDate, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, isValidDate, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle, validateBirthdate };
|
|
979
|
+
export { MessageEventManager, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertDateFormat, convertDateString, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDateDiff, getDeviceModel, getDspApiBasePathFromEnvironment, getDspExecutionEnvironment, getDudApiBasePathFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getLastDay, getNlcHostFromEnvironment, getOSName, getOSVersion, getOneMonthLater, getOrCreateDeviceId, getPeriodDate, getServicePath, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDate, isDateAfter, isDspApp, isFpPlannerApp, isFutureDate, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, isValidDate, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle, validateBirthdate };
|
|
959
980
|
//# sourceMappingURL=index.js.map
|
|
960
981
|
//# sourceMappingURL=index.js.map
|