@uniai-fe/util-functions 0.2.5 → 0.2.7
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/api/index.d.cts +111 -1
- package/dist/api/index.d.ts +111 -1
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +13 -1
- package/dist/index.mjs.map +1 -1
- package/dist/route/index.cjs +13 -0
- package/dist/route/index.cjs.map +1 -1
- package/dist/route/index.d.cts +8 -1
- package/dist/route/index.d.ts +8 -1
- package/dist/route/index.mjs +13 -1
- package/dist/route/index.mjs.map +1 -1
- package/dist/runtime-env/index.d.cts +9 -0
- package/dist/runtime-env/index.d.ts +9 -0
- package/package.json +3 -3
package/dist/api/index.d.cts
CHANGED
|
@@ -60,6 +60,116 @@ type FetchBackendQueryOptions<Infra extends InfraKey, FetchRequestType extends o
|
|
|
60
60
|
method: "POST" | "DELETE";
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
/** ---------------------------------------------------------- NEW */
|
|
64
|
+
/**
|
|
65
|
+
* API; Base Params
|
|
66
|
+
* @property {string} domain API 요청 도메인(서버)
|
|
67
|
+
* @property {string} routeUrl Next.js app/api 이하 경로 url
|
|
68
|
+
* @property {string} queryUrl 백엔드 요청 url
|
|
69
|
+
*/
|
|
70
|
+
interface UtilQueryBaseParams {
|
|
71
|
+
/**
|
|
72
|
+
* API 도메인
|
|
73
|
+
*/
|
|
74
|
+
domain: string;
|
|
75
|
+
/**
|
|
76
|
+
* Next.js /app/api 라우트 주소
|
|
77
|
+
*/
|
|
78
|
+
routeUrl: string;
|
|
79
|
+
/**
|
|
80
|
+
* 백엔드 API url
|
|
81
|
+
*/
|
|
82
|
+
queryUrl: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* API; generateBackendQueryUrl_GET Params
|
|
86
|
+
* @property {string} domain API 요청 도메인(서버)
|
|
87
|
+
* @property {string} routeUrl Next.js app/api 이하 경로 url
|
|
88
|
+
* @property {string} queryUrl 백엔드 요청 url
|
|
89
|
+
* @property {URLSearchParams | object} [searchParams] 요청 searchParams
|
|
90
|
+
* @property {object} [log] 디버깅용 서버 로그 데이터 객체
|
|
91
|
+
* @property {boolean} [logDisabled] 로그 비활성화
|
|
92
|
+
*/
|
|
93
|
+
interface GenerateGetQueryUrlParams extends UtilQueryBaseParams {
|
|
94
|
+
/**
|
|
95
|
+
* 쿼리 스트링
|
|
96
|
+
* @desc
|
|
97
|
+
* - URLSearchParams 객체로 가공된 파라미터
|
|
98
|
+
*/
|
|
99
|
+
searchParams?: URLSearchParams | object;
|
|
100
|
+
/**
|
|
101
|
+
* 디버깅용 서버 로그 정보
|
|
102
|
+
*/
|
|
103
|
+
log?: object;
|
|
104
|
+
/**
|
|
105
|
+
* 로그 비활성화
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
logDisabled?: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* API; fetchWithBody Params
|
|
112
|
+
* @property {string} domain API 요청 도메인(서버)
|
|
113
|
+
* @property {string} routeUrl Next.js app/api 이하 경로 url
|
|
114
|
+
* @property {string} queryUrl 백엔드 요청 url
|
|
115
|
+
* @property {string} method fetch method; PUT | POST | DELETE
|
|
116
|
+
* @property {object} alternateResponse 실패 시 대체응답
|
|
117
|
+
* @property {URLSearchParams | object} [searchParams] 요청 searchParams
|
|
118
|
+
* @property {HeadersInit} [headers]
|
|
119
|
+
* @property {BodyInit | null} [body]
|
|
120
|
+
* @property {object} [bodyData]
|
|
121
|
+
* @property {boolean} [isRawResponse]
|
|
122
|
+
* @property {object} [debug]
|
|
123
|
+
* @property {boolean} [disabled]
|
|
124
|
+
* @property {boolean} [disabledLog]
|
|
125
|
+
*/
|
|
126
|
+
interface FetchWithBodyParams<BodyDataType = object> extends UtilQueryBaseParams {
|
|
127
|
+
/**
|
|
128
|
+
* 요청 방식
|
|
129
|
+
* POST, DELETE
|
|
130
|
+
*/
|
|
131
|
+
method: string;
|
|
132
|
+
/**
|
|
133
|
+
* fetch 실패 시 대체 응답
|
|
134
|
+
*/
|
|
135
|
+
alternateResponse: ResponseType;
|
|
136
|
+
/**
|
|
137
|
+
* 쿼리 스트링
|
|
138
|
+
* @desc
|
|
139
|
+
* - URLSearchParams 객체로 가공된 파라미터
|
|
140
|
+
*/
|
|
141
|
+
searchParams?: URLSearchParams | object;
|
|
142
|
+
/**
|
|
143
|
+
* fetch Headers
|
|
144
|
+
*/
|
|
145
|
+
headers?: HeadersInit;
|
|
146
|
+
/**
|
|
147
|
+
* fetch Body
|
|
148
|
+
*/
|
|
149
|
+
body?: BodyInit | null;
|
|
150
|
+
/**
|
|
151
|
+
* fetch Body Data
|
|
152
|
+
*/
|
|
153
|
+
bodyData?: BodyDataType;
|
|
154
|
+
/**
|
|
155
|
+
* 응답값 원본으로 return
|
|
156
|
+
* const responseRaw = await fetch(api);
|
|
157
|
+
*/
|
|
158
|
+
isRawResponse?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* 디버그용 로그 객체
|
|
161
|
+
*/
|
|
162
|
+
debug?: object;
|
|
163
|
+
/**
|
|
164
|
+
* fetch 비활성화
|
|
165
|
+
*/
|
|
166
|
+
disabled?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* 로그 비활성화
|
|
169
|
+
*/
|
|
170
|
+
disabledLog?: boolean;
|
|
171
|
+
}
|
|
172
|
+
|
|
63
173
|
/**
|
|
64
174
|
* API 요청 url 생성; GET 타입
|
|
65
175
|
* @util
|
|
@@ -239,4 +349,4 @@ declare const fetchWithBody: <BodyDataType = object, ResponseType extends object
|
|
|
239
349
|
disabledLog: boolean;
|
|
240
350
|
}>) => Promise<ResponseType>;
|
|
241
351
|
|
|
242
|
-
export { type ApiLogger, type BackendApiConfig, type CommonPostResponseType, type DomainResolver, type EnvDomainMap, type FetchBackendQueryOptions, type GenerateBackendQueryUrlOptions, type InfraKey, fetchBackendQuery, fetchWithBody, generateBackendQueryUrl_GET, getFetchOptions, getQueryString, nextAPILog };
|
|
352
|
+
export { type ApiLogger, type BackendApiConfig, type CommonPostResponseType, type DomainResolver, type EnvDomainMap, type FetchBackendQueryOptions, type FetchWithBodyParams, type GenerateBackendQueryUrlOptions, type GenerateGetQueryUrlParams, type InfraKey, type UtilQueryBaseParams, fetchBackendQuery, fetchWithBody, generateBackendQueryUrl_GET, getFetchOptions, getQueryString, nextAPILog };
|
package/dist/api/index.d.ts
CHANGED
|
@@ -60,6 +60,116 @@ type FetchBackendQueryOptions<Infra extends InfraKey, FetchRequestType extends o
|
|
|
60
60
|
method: "POST" | "DELETE";
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
/** ---------------------------------------------------------- NEW */
|
|
64
|
+
/**
|
|
65
|
+
* API; Base Params
|
|
66
|
+
* @property {string} domain API 요청 도메인(서버)
|
|
67
|
+
* @property {string} routeUrl Next.js app/api 이하 경로 url
|
|
68
|
+
* @property {string} queryUrl 백엔드 요청 url
|
|
69
|
+
*/
|
|
70
|
+
interface UtilQueryBaseParams {
|
|
71
|
+
/**
|
|
72
|
+
* API 도메인
|
|
73
|
+
*/
|
|
74
|
+
domain: string;
|
|
75
|
+
/**
|
|
76
|
+
* Next.js /app/api 라우트 주소
|
|
77
|
+
*/
|
|
78
|
+
routeUrl: string;
|
|
79
|
+
/**
|
|
80
|
+
* 백엔드 API url
|
|
81
|
+
*/
|
|
82
|
+
queryUrl: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* API; generateBackendQueryUrl_GET Params
|
|
86
|
+
* @property {string} domain API 요청 도메인(서버)
|
|
87
|
+
* @property {string} routeUrl Next.js app/api 이하 경로 url
|
|
88
|
+
* @property {string} queryUrl 백엔드 요청 url
|
|
89
|
+
* @property {URLSearchParams | object} [searchParams] 요청 searchParams
|
|
90
|
+
* @property {object} [log] 디버깅용 서버 로그 데이터 객체
|
|
91
|
+
* @property {boolean} [logDisabled] 로그 비활성화
|
|
92
|
+
*/
|
|
93
|
+
interface GenerateGetQueryUrlParams extends UtilQueryBaseParams {
|
|
94
|
+
/**
|
|
95
|
+
* 쿼리 스트링
|
|
96
|
+
* @desc
|
|
97
|
+
* - URLSearchParams 객체로 가공된 파라미터
|
|
98
|
+
*/
|
|
99
|
+
searchParams?: URLSearchParams | object;
|
|
100
|
+
/**
|
|
101
|
+
* 디버깅용 서버 로그 정보
|
|
102
|
+
*/
|
|
103
|
+
log?: object;
|
|
104
|
+
/**
|
|
105
|
+
* 로그 비활성화
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
logDisabled?: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* API; fetchWithBody Params
|
|
112
|
+
* @property {string} domain API 요청 도메인(서버)
|
|
113
|
+
* @property {string} routeUrl Next.js app/api 이하 경로 url
|
|
114
|
+
* @property {string} queryUrl 백엔드 요청 url
|
|
115
|
+
* @property {string} method fetch method; PUT | POST | DELETE
|
|
116
|
+
* @property {object} alternateResponse 실패 시 대체응답
|
|
117
|
+
* @property {URLSearchParams | object} [searchParams] 요청 searchParams
|
|
118
|
+
* @property {HeadersInit} [headers]
|
|
119
|
+
* @property {BodyInit | null} [body]
|
|
120
|
+
* @property {object} [bodyData]
|
|
121
|
+
* @property {boolean} [isRawResponse]
|
|
122
|
+
* @property {object} [debug]
|
|
123
|
+
* @property {boolean} [disabled]
|
|
124
|
+
* @property {boolean} [disabledLog]
|
|
125
|
+
*/
|
|
126
|
+
interface FetchWithBodyParams<BodyDataType = object> extends UtilQueryBaseParams {
|
|
127
|
+
/**
|
|
128
|
+
* 요청 방식
|
|
129
|
+
* POST, DELETE
|
|
130
|
+
*/
|
|
131
|
+
method: string;
|
|
132
|
+
/**
|
|
133
|
+
* fetch 실패 시 대체 응답
|
|
134
|
+
*/
|
|
135
|
+
alternateResponse: ResponseType;
|
|
136
|
+
/**
|
|
137
|
+
* 쿼리 스트링
|
|
138
|
+
* @desc
|
|
139
|
+
* - URLSearchParams 객체로 가공된 파라미터
|
|
140
|
+
*/
|
|
141
|
+
searchParams?: URLSearchParams | object;
|
|
142
|
+
/**
|
|
143
|
+
* fetch Headers
|
|
144
|
+
*/
|
|
145
|
+
headers?: HeadersInit;
|
|
146
|
+
/**
|
|
147
|
+
* fetch Body
|
|
148
|
+
*/
|
|
149
|
+
body?: BodyInit | null;
|
|
150
|
+
/**
|
|
151
|
+
* fetch Body Data
|
|
152
|
+
*/
|
|
153
|
+
bodyData?: BodyDataType;
|
|
154
|
+
/**
|
|
155
|
+
* 응답값 원본으로 return
|
|
156
|
+
* const responseRaw = await fetch(api);
|
|
157
|
+
*/
|
|
158
|
+
isRawResponse?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* 디버그용 로그 객체
|
|
161
|
+
*/
|
|
162
|
+
debug?: object;
|
|
163
|
+
/**
|
|
164
|
+
* fetch 비활성화
|
|
165
|
+
*/
|
|
166
|
+
disabled?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* 로그 비활성화
|
|
169
|
+
*/
|
|
170
|
+
disabledLog?: boolean;
|
|
171
|
+
}
|
|
172
|
+
|
|
63
173
|
/**
|
|
64
174
|
* API 요청 url 생성; GET 타입
|
|
65
175
|
* @util
|
|
@@ -239,4 +349,4 @@ declare const fetchWithBody: <BodyDataType = object, ResponseType extends object
|
|
|
239
349
|
disabledLog: boolean;
|
|
240
350
|
}>) => Promise<ResponseType>;
|
|
241
351
|
|
|
242
|
-
export { type ApiLogger, type BackendApiConfig, type CommonPostResponseType, type DomainResolver, type EnvDomainMap, type FetchBackendQueryOptions, type GenerateBackendQueryUrlOptions, type InfraKey, fetchBackendQuery, fetchWithBody, generateBackendQueryUrl_GET, getFetchOptions, getQueryString, nextAPILog };
|
|
352
|
+
export { type ApiLogger, type BackendApiConfig, type CommonPostResponseType, type DomainResolver, type EnvDomainMap, type FetchBackendQueryOptions, type FetchWithBodyParams, type GenerateBackendQueryUrlOptions, type GenerateGetQueryUrlParams, type InfraKey, type UtilQueryBaseParams, fetchBackendQuery, fetchWithBody, generateBackendQueryUrl_GET, getFetchOptions, getQueryString, nextAPILog };
|
package/dist/index.cjs
CHANGED
|
@@ -550,6 +550,18 @@ var getMatchRoute = (routes, currentPath) => {
|
|
|
550
550
|
}
|
|
551
551
|
return res;
|
|
552
552
|
};
|
|
553
|
+
var getSafePathname = (fallback = "") => {
|
|
554
|
+
if (typeof window !== "undefined" && window.location?.pathname) {
|
|
555
|
+
return window.location.pathname;
|
|
556
|
+
}
|
|
557
|
+
if (typeof globalThis !== "undefined") {
|
|
558
|
+
const globalLocation = globalThis.location;
|
|
559
|
+
if (globalLocation?.pathname) {
|
|
560
|
+
return globalLocation.pathname;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
return fallback;
|
|
564
|
+
};
|
|
553
565
|
|
|
554
566
|
// src/sort/module.ts
|
|
555
567
|
var sortAsc = (a, b) => {
|
|
@@ -962,6 +974,7 @@ exports.getPrevDay = getPrevDay;
|
|
|
962
974
|
exports.getPwaRuntimeInfo = getPwaRuntimeInfo;
|
|
963
975
|
exports.getQueryString = getQueryString;
|
|
964
976
|
exports.getRepeatCycleUnit = getRepeatCycleUnit;
|
|
977
|
+
exports.getSafePathname = getSafePathname;
|
|
965
978
|
exports.getToday = getToday;
|
|
966
979
|
exports.getValueByKeyChain = getValueByKeyChain;
|
|
967
980
|
exports.isValidArray = isValidArray;
|