sales-frontend-utils 0.0.37 → 0.0.39

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.d.cts CHANGED
@@ -340,4 +340,68 @@ declare const initASTX2: ({ initSuccess, initFailure, checkServerSuccess, checkS
340
340
  */
341
341
  declare function getE2EDataIDs(ids: string[], onSuccess: (astx_data: any) => void, onFailure?: () => void): void;
342
342
 
343
- export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspApiBasePathFromEnvironment, getDspExecutionEnvironment, getDudApiBasePathFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getNlcHostFromEnvironment, getOSName, getOSVersion, getOrCreateDeviceId, getServicePath, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle };
343
+ /**
344
+ *
345
+ * @param year
346
+ * @param month
347
+ * @returns
348
+ */
349
+ declare function getLastDay(year: number, month: number): 29 | 28 | 30 | 31;
350
+ /**
351
+ * 한달뒤 날짜를 포맷형태로 리턴
352
+ * @param 20200101 or 2020.01.01
353
+ * @param 'YYYY.MM.DD'
354
+ * @returns
355
+ */
356
+ declare const getOneMonthLater: (value?: string, format?: string) => string;
357
+ /**
358
+ * 날짜 차이를 구한다. 포맷에 맞지 않으면 Not a Number 리턴
359
+ * @param date1 (yyyymmdd or yyyy.mm.dd or yyyy-mm-dd)
360
+ * @param date2 (yyyymmdd or yyyy.mm.dd or yyyy-mm-dd)
361
+ * @returns date1 - date2
362
+ */
363
+ declare const getDateDiff: (date1: string, date2: string) => number;
364
+ /**
365
+ * 입력되어진 생년월일 값이 당일 기준으로 미래시점인 경우 false를 반환합니다. (회원체계 기준 9, 0 일 경우 오류)
366
+ * @param front 주민등록번호 앞 6자리
367
+ * @param back 주민등록번호 뒤 첫자리
368
+ * @returns boolean
369
+ */
370
+ declare const validateBirthdate: (front: string, back: string) => boolean;
371
+ /**
372
+ * 목표 날짜가 비교 날짜 이후 인지 확인하는 함수 (YYYYMMDD 형식)
373
+ * @param targetDate
374
+ * @param compareDate
375
+ * @returns boolean
376
+ */
377
+ declare function isDateAfter(targetDate: string, compareDate: string): boolean;
378
+ /**
379
+ * 날짜를 포맷형태로 리턴
380
+ * @param 20200101 string
381
+ * @param 'YYYY.MM.DD
382
+ * @returns 포맷화된 날짜
383
+ */
384
+ declare const convertDateFormat: (value?: string, format?: string) => string;
385
+ /**
386
+ * 주어진 날짜가 오늘 날짜 이후인지 확인합니다.
387
+ *
388
+ * @param {string} dateString - 확인할 날짜 문자열입니다.
389
+ * @param {dayjs.OptionType} [format] - 날짜 문자열의 형식입니다.
390
+ * @returns {boolean} - 주어진 날짜가 오늘 이후라면 true를 반환합니다.
391
+ */
392
+ declare const isFutureDate: (dateString?: string, format?: string) => boolean;
393
+ /**
394
+ * 날짜 유효성 검사
395
+ *
396
+ * @param {string} dateString - 검사할 날짜 문자열.
397
+ * @param {dayjs.OptionType} [format] - 날짜 문자열의 형식입니다.
398
+ * @returns {boolean} - 유효한 날짜이면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
399
+ */
400
+ declare const isValidDate: (dateString?: string, format?: string) => boolean;
401
+ type PeriodType = 'thisWeek' | 'lastWeek' | 'last7Days' | 'thisMonth' | 'lastMonth' | 'last365Days';
402
+ declare const getPeriodDate: (periodType: PeriodType) => {
403
+ startDate: Date;
404
+ endDate: Date;
405
+ };
406
+
407
+ 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 };
package/dist/index.d.ts CHANGED
@@ -340,4 +340,68 @@ declare const initASTX2: ({ initSuccess, initFailure, checkServerSuccess, checkS
340
340
  */
341
341
  declare function getE2EDataIDs(ids: string[], onSuccess: (astx_data: any) => void, onFailure?: () => void): void;
342
342
 
343
- export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspApiBasePathFromEnvironment, getDspExecutionEnvironment, getDudApiBasePathFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getNlcHostFromEnvironment, getOSName, getOSVersion, getOrCreateDeviceId, getServicePath, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle };
343
+ /**
344
+ *
345
+ * @param year
346
+ * @param month
347
+ * @returns
348
+ */
349
+ declare function getLastDay(year: number, month: number): 29 | 28 | 30 | 31;
350
+ /**
351
+ * 한달뒤 날짜를 포맷형태로 리턴
352
+ * @param 20200101 or 2020.01.01
353
+ * @param 'YYYY.MM.DD'
354
+ * @returns
355
+ */
356
+ declare const getOneMonthLater: (value?: string, format?: string) => string;
357
+ /**
358
+ * 날짜 차이를 구한다. 포맷에 맞지 않으면 Not a Number 리턴
359
+ * @param date1 (yyyymmdd or yyyy.mm.dd or yyyy-mm-dd)
360
+ * @param date2 (yyyymmdd or yyyy.mm.dd or yyyy-mm-dd)
361
+ * @returns date1 - date2
362
+ */
363
+ declare const getDateDiff: (date1: string, date2: string) => number;
364
+ /**
365
+ * 입력되어진 생년월일 값이 당일 기준으로 미래시점인 경우 false를 반환합니다. (회원체계 기준 9, 0 일 경우 오류)
366
+ * @param front 주민등록번호 앞 6자리
367
+ * @param back 주민등록번호 뒤 첫자리
368
+ * @returns boolean
369
+ */
370
+ declare const validateBirthdate: (front: string, back: string) => boolean;
371
+ /**
372
+ * 목표 날짜가 비교 날짜 이후 인지 확인하는 함수 (YYYYMMDD 형식)
373
+ * @param targetDate
374
+ * @param compareDate
375
+ * @returns boolean
376
+ */
377
+ declare function isDateAfter(targetDate: string, compareDate: string): boolean;
378
+ /**
379
+ * 날짜를 포맷형태로 리턴
380
+ * @param 20200101 string
381
+ * @param 'YYYY.MM.DD
382
+ * @returns 포맷화된 날짜
383
+ */
384
+ declare const convertDateFormat: (value?: string, format?: string) => string;
385
+ /**
386
+ * 주어진 날짜가 오늘 날짜 이후인지 확인합니다.
387
+ *
388
+ * @param {string} dateString - 확인할 날짜 문자열입니다.
389
+ * @param {dayjs.OptionType} [format] - 날짜 문자열의 형식입니다.
390
+ * @returns {boolean} - 주어진 날짜가 오늘 이후라면 true를 반환합니다.
391
+ */
392
+ declare const isFutureDate: (dateString?: string, format?: string) => boolean;
393
+ /**
394
+ * 날짜 유효성 검사
395
+ *
396
+ * @param {string} dateString - 검사할 날짜 문자열.
397
+ * @param {dayjs.OptionType} [format] - 날짜 문자열의 형식입니다.
398
+ * @returns {boolean} - 유효한 날짜이면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
399
+ */
400
+ declare const isValidDate: (dateString?: string, format?: string) => boolean;
401
+ type PeriodType = 'thisWeek' | 'lastWeek' | 'last7Days' | 'thisMonth' | 'lastMonth' | 'last365Days';
402
+ declare const getPeriodDate: (periodType: PeriodType) => {
403
+ startDate: Date;
404
+ endDate: Date;
405
+ };
406
+
407
+ 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 };
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import dayjs from 'dayjs';
2
+ import customParseFormat from 'dayjs/plugin/customParseFormat.js';
3
+
1
4
  var __defProp = Object.defineProperty;
2
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -839,7 +842,121 @@ function getE2EDataIDs(ids, onSuccess, onFailure = () => {
839
842
  );
840
843
  }
841
844
  }
845
+ dayjs.locale("ko");
846
+ dayjs.extend(customParseFormat);
847
+ function getLastDay(year, month) {
848
+ switch (month) {
849
+ case 2:
850
+ return year % 4 === 0 ? 29 : 28;
851
+ case 4:
852
+ case 6:
853
+ case 9:
854
+ case 11:
855
+ return 30;
856
+ default:
857
+ return 31;
858
+ }
859
+ }
860
+ var getOneMonthLater = (value, format) => {
861
+ const str = value ? value.split(".").join("") : "";
862
+ const date = value ? new Date(Number(str.substring(0, 4)), Number(str.substring(4, 6)) - 1, Number(str.substring(6, 8))) : /* @__PURE__ */ new Date();
863
+ try {
864
+ return dayjs(new Date(date.setMonth(date.getMonth() + 1))).format(format || "YYYY.MM.DD");
865
+ } catch (err) {
866
+ console.warn(err);
867
+ return "";
868
+ }
869
+ };
870
+ var getDateDiff = (date1, date2) => {
871
+ const yyyyMMdd1 = date1.replace(/[.|-]/g, "");
872
+ const yyyyMMdd2 = date2.replace(/[.|-]/g, "");
873
+ const diff1 = dayjs(dayjs(yyyyMMdd1).format("YYYY-MM-DD"));
874
+ const diff2 = dayjs(yyyyMMdd2).format("YYYY-MM-DD");
875
+ return diff1.diff(diff2, "day");
876
+ };
877
+ var validateBirthdate = (front, back) => {
878
+ const year = parseInt(front.slice(0, 2));
879
+ const month = parseInt(front.slice(2, 4));
880
+ const day = parseInt(front.slice(4, 6));
881
+ let birthYear = 0;
882
+ switch (back) {
883
+ case "1":
884
+ case "2":
885
+ case "5":
886
+ case "6":
887
+ birthYear = 1900 + year;
888
+ break;
889
+ case "3":
890
+ case "4":
891
+ case "7":
892
+ case "8":
893
+ birthYear = 2e3 + year;
894
+ break;
895
+ case "9":
896
+ case "0":
897
+ return false;
898
+ default:
899
+ return false;
900
+ }
901
+ const birthdate = new Date(birthYear, month - 1, day);
902
+ const currdate = /* @__PURE__ */ new Date();
903
+ return birthdate < currdate;
904
+ };
905
+ function isDateAfter(targetDate, compareDate) {
906
+ const targetDateTime = new Date(convertDateFormat(targetDate, "YYYY-MM-DD")).getTime();
907
+ const compareDateTime = new Date(convertDateFormat(compareDate, "YYYY-MM-DD")).getTime();
908
+ return targetDateTime > compareDateTime;
909
+ }
910
+ var convertDateFormat = (value, format) => {
911
+ if (!value) {
912
+ return "";
913
+ }
914
+ return dayjs(value).format(format || "YYYY.MM.DD");
915
+ };
916
+ var isFutureDate = (dateString, format) => {
917
+ if (!dateString) {
918
+ return false;
919
+ }
920
+ const today = dayjs().startOf("day");
921
+ const date = dayjs(dateString, format || "YYYYMMDD", true);
922
+ return date.isValid() && date.isAfter(today);
923
+ };
924
+ var isValidDate = (dateString, format) => {
925
+ if (!dateString) {
926
+ return false;
927
+ }
928
+ const date = dayjs(dateString, format || "YYYYMMDD", true);
929
+ return date.isValid();
930
+ };
931
+ var getPeriodDate = (periodType) => {
932
+ const lastMonth = dayjs().subtract(1, "M");
933
+ switch (periodType) {
934
+ case "thisWeek":
935
+ return { startDate: dayjs().day(0).toDate(), endDate: dayjs().day(6).toDate() };
936
+ case "lastWeek":
937
+ return {
938
+ startDate: dayjs().subtract(1, "w").day(0).toDate(),
939
+ endDate: dayjs().subtract(1, "w").day(6).toDate()
940
+ };
941
+ case "last7Days":
942
+ return { startDate: dayjs().subtract(7, "d").toDate(), endDate: dayjs().toDate() };
943
+ case "thisMonth":
944
+ return {
945
+ startDate: dayjs().date(1).toDate(),
946
+ endDate: dayjs().date(dayjs().daysInMonth()).toDate()
947
+ };
948
+ case "lastMonth":
949
+ return {
950
+ startDate: lastMonth.date(1).toDate(),
951
+ endDate: lastMonth.date(lastMonth.daysInMonth()).toDate()
952
+ };
953
+ case "last365Days":
954
+ return { startDate: dayjs().subtract(365, "d").toDate(), endDate: dayjs().toDate() };
955
+ default:
956
+ return { startDate: dayjs().toDate(), endDate: dayjs().toDate() };
957
+ }
958
+ };
842
959
 
843
- export { MessageEventManager, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspApiBasePathFromEnvironment, getDspExecutionEnvironment, getDudApiBasePathFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getNlcHostFromEnvironment, getOSName, getOSVersion, getOrCreateDeviceId, getServicePath, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle };
960
+ 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 };
844
961
  //# sourceMappingURL=index.js.map
845
962
  //# sourceMappingURL=index.js.map