jordy 0.12.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/README.md +11 -0
- package/esm5/adaptive-render/AdaptiveRender.js +14 -0
- package/esm5/adaptive-render/DeviceDetectContext.js +62 -0
- package/esm5/adaptive-render/adaptive-render.type.js +1 -0
- package/esm5/adaptive-render/device.type.js +9 -0
- package/esm5/adaptive-render/index.js +4 -0
- package/esm5/adaptive-render/withAdaptiveRender.js +29 -0
- package/esm5/hooks/index.js +3 -0
- package/esm5/hooks/useDebounce.js +26 -0
- package/esm5/hooks/useQueryParams.js +20 -0
- package/esm5/hooks/useThrottle.js +18 -0
- package/esm5/http-api/httpApi.factory.js +143 -0
- package/esm5/http-api/httpHeader.factory.js +46 -0
- package/esm5/http-api/index.js +3 -0
- package/esm5/http-api/network.type.js +1 -0
- package/esm5/http-api/networkParser.js +73 -0
- package/esm5/index.js +11 -0
- package/esm5/proxies/cache.proxy.js +40 -0
- package/esm5/proxies/index.js +1 -0
- package/esm5/queries/buildMutationCreator.js +87 -0
- package/esm5/queries/buildQueryCreator.js +124 -0
- package/esm5/queries/index.js +2 -0
- package/esm5/queries/useMakeDeps.js +23 -0
- package/esm5/queries/utils/clearCacheByKeyword.js +50 -0
- package/esm5/queries/utils/createCacheKey.js +23 -0
- package/esm5/queries/utils/index.js +2 -0
- package/esm5/route-system/AsyncGuard.js +37 -0
- package/esm5/route-system/index.js +3 -0
- package/esm5/route-system/moduleRoute.model.js +1 -0
- package/esm5/route-system/renderRouteSystem.js +64 -0
- package/esm5/route-system/routeSystem.util.js +23 -0
- package/esm5/storage/CookieStorageAdapter.js +20 -0
- package/esm5/storage/ExpiableStorageAdapter.js +36 -0
- package/esm5/storage/MemorySimpleStorage.js +18 -0
- package/esm5/storage/SimpleStorageAdapter.js +18 -0
- package/esm5/storage/cookie.js +27 -0
- package/esm5/storage/index.js +4 -0
- package/esm5/storage/memoryStorage.js +35 -0
- package/esm5/storage/storage.factory.js +30 -0
- package/esm5/storage/storage.type.js +1 -0
- package/esm5/storage/token-provider.factory.js +23 -0
- package/esm5/types/component.type.js +1 -0
- package/esm5/types/index.js +2 -0
- package/esm5/types/marshalling.type.js +1 -0
- package/esm5/util/collection.js +17 -0
- package/esm5/util/envCheck.js +55 -0
- package/esm5/util/etc.js +12 -0
- package/esm5/util/filter.js +10 -0
- package/esm5/util/format.js +8 -0
- package/esm5/util/index.js +15 -0
- package/esm5/util/josa.js +57 -0
- package/esm5/util/json.js +19 -0
- package/esm5/util/libLoader.js +27 -0
- package/esm5/util/path.js +16 -0
- package/esm5/util/queryString.js +62 -0
- package/esm5/util/redux.js +6 -0
- package/esm5/util/template.js +65 -0
- package/esm5/util/typeCheck.js +33 -0
- package/esm5/validate/fn.js +66 -0
- package/esm5/validate/index.js +7 -0
- package/esm5/validate/mergeValidates.js +22 -0
- package/esm5/validate/validate.js +22 -0
- package/esm5/validate/validate.type.js +1 -0
- package/esm5/validate/validateSubUtils.js +67 -0
- package/libs/adaptive-render/AdaptiveRender.d.ts +25 -0
- package/libs/adaptive-render/DeviceDetectContext.d.ts +16 -0
- package/libs/adaptive-render/adaptive-render.type.d.ts +63 -0
- package/libs/adaptive-render/device.type.d.ts +14 -0
- package/libs/adaptive-render/index.d.ts +4 -0
- package/libs/adaptive-render/withAdaptiveRender.d.ts +35 -0
- package/libs/hooks/index.d.ts +3 -0
- package/libs/hooks/useDebounce.d.ts +29 -0
- package/libs/hooks/useQueryParams.d.ts +19 -0
- package/libs/hooks/useThrottle.d.ts +25 -0
- package/libs/http-api/httpApi.factory.d.ts +9 -0
- package/libs/http-api/httpHeader.factory.d.ts +15 -0
- package/libs/http-api/index.d.ts +3 -0
- package/libs/http-api/network.type.d.ts +109 -0
- package/libs/http-api/networkParser.d.ts +9 -0
- package/libs/index.d.ts +11 -0
- package/libs/proxies/cache.proxy.d.ts +11 -0
- package/libs/proxies/index.d.ts +1 -0
- package/libs/queries/buildMutationCreator.d.ts +37 -0
- package/libs/queries/buildQueryCreator.d.ts +115 -0
- package/libs/queries/index.d.ts +2 -0
- package/libs/queries/useMakeDeps.d.ts +1 -0
- package/libs/queries/utils/clearCacheByKeyword.d.ts +14 -0
- package/libs/queries/utils/createCacheKey.d.ts +1 -0
- package/libs/queries/utils/index.d.ts +2 -0
- package/libs/route-system/AsyncGuard.d.ts +8 -0
- package/libs/route-system/index.d.ts +3 -0
- package/libs/route-system/moduleRoute.model.d.ts +49 -0
- package/libs/route-system/renderRouteSystem.d.ts +5 -0
- package/libs/route-system/routeSystem.util.d.ts +4 -0
- package/libs/storage/CookieStorageAdapter.d.ts +11 -0
- package/libs/storage/ExpiableStorageAdapter.d.ts +11 -0
- package/libs/storage/MemorySimpleStorage.d.ts +10 -0
- package/libs/storage/SimpleStorageAdapter.d.ts +10 -0
- package/libs/storage/cookie.d.ts +2 -0
- package/libs/storage/index.d.ts +4 -0
- package/libs/storage/memoryStorage.d.ts +7 -0
- package/libs/storage/storage.factory.d.ts +31 -0
- package/libs/storage/storage.type.d.ts +96 -0
- package/libs/storage/token-provider.factory.d.ts +9 -0
- package/libs/types/component.type.d.ts +23 -0
- package/libs/types/index.d.ts +2 -0
- package/libs/types/marshalling.type.d.ts +5 -0
- package/libs/util/collection.d.ts +25 -0
- package/libs/util/envCheck.d.ts +56 -0
- package/libs/util/etc.d.ts +11 -0
- package/libs/util/filter.d.ts +2 -0
- package/libs/util/format.d.ts +6 -0
- package/libs/util/index.d.ts +15 -0
- package/libs/util/josa.d.ts +66 -0
- package/libs/util/json.d.ts +14 -0
- package/libs/util/libLoader.d.ts +1 -0
- package/libs/util/path.d.ts +20 -0
- package/libs/util/queryString.d.ts +35 -0
- package/libs/util/redux.d.ts +3 -0
- package/libs/util/template.d.ts +38 -0
- package/libs/util/typeCheck.d.ts +42 -0
- package/libs/validate/fn.d.ts +111 -0
- package/libs/validate/index.d.ts +58 -0
- package/libs/validate/mergeValidates.d.ts +21 -0
- package/libs/validate/validate.d.ts +2 -0
- package/libs/validate/validate.type.d.ts +84 -0
- package/libs/validate/validateSubUtils.d.ts +12 -0
- package/package.json +58 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { FC, ComponentType } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 적응형 함수 설정 시 필요한 모델.
|
|
4
|
+
*/
|
|
5
|
+
export interface AdaptiveSettingModel<T> {
|
|
6
|
+
/**
|
|
7
|
+
* 네이티브 모바일앱 에서만 수행될 기능.
|
|
8
|
+
*
|
|
9
|
+
* 다른 조건들 대비 우선순위가 가장 높다.
|
|
10
|
+
*
|
|
11
|
+
* 미설정 시 앱에서 수행되지 않는다.
|
|
12
|
+
*/
|
|
13
|
+
native?: T;
|
|
14
|
+
/**
|
|
15
|
+
* 모바일 에서만 수행될 기능.
|
|
16
|
+
*
|
|
17
|
+
* 미설정 시 모바일에서 수행되지 않는다.
|
|
18
|
+
*/
|
|
19
|
+
mobile?: T;
|
|
20
|
+
/**
|
|
21
|
+
* 태블릿에서만 수행될 기능.
|
|
22
|
+
*
|
|
23
|
+
* 미설정 시 태블릿에서 수행되지 않는다.
|
|
24
|
+
*/
|
|
25
|
+
tablet?: T;
|
|
26
|
+
/**
|
|
27
|
+
* 데스크탑에서만 수행될 기능.
|
|
28
|
+
*
|
|
29
|
+
* 미설정 desktop 에서 수행되지 않는다.
|
|
30
|
+
*/
|
|
31
|
+
desktop?: T;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 적응형 렌더링에서 쓰이는 설정 모델.
|
|
35
|
+
*/
|
|
36
|
+
export interface AdaptiveRenderSettingModel<T> extends AdaptiveSettingModel<FC<T> | ComponentType<T>> {
|
|
37
|
+
/**
|
|
38
|
+
* 네이티브 모바일앱 에서만 보여질 컴포넌트.
|
|
39
|
+
*
|
|
40
|
+
* 다른 조건들 대비 우선순위가 가장 높다.
|
|
41
|
+
*
|
|
42
|
+
* 미설정 시 앱에서 보여지지 않는다.
|
|
43
|
+
*/
|
|
44
|
+
native?: FC<T> | ComponentType<T>;
|
|
45
|
+
/**
|
|
46
|
+
* 모바일 에서만 보여질 컴포넌트.
|
|
47
|
+
*
|
|
48
|
+
* 미설정 시 모바일에서 보여지지 않는다.
|
|
49
|
+
*/
|
|
50
|
+
mobile?: FC<T> | ComponentType<T>;
|
|
51
|
+
/**
|
|
52
|
+
* 태블릿에서만 보여질 컴포넌트.
|
|
53
|
+
*
|
|
54
|
+
* 미설정 시 태블릿에서 보여지지 않는다.
|
|
55
|
+
*/
|
|
56
|
+
tablet?: FC<T> | ComponentType<T>;
|
|
57
|
+
/**
|
|
58
|
+
* 데스크탑에서만 보여질 컴포넌트.
|
|
59
|
+
*
|
|
60
|
+
* 미설정 desktop 에서 보여지지 않는다.
|
|
61
|
+
*/
|
|
62
|
+
desktop?: FC<T> | ComponentType<T>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 기기별 사이즈를 정의한 것.
|
|
3
|
+
*
|
|
4
|
+
* 사이즈 참고:
|
|
5
|
+
* https://stackoverflow.com/questions/6370690/media-queries-how-to-target-desktop-tablet-and-mobile
|
|
6
|
+
*/
|
|
7
|
+
export declare enum DeviceSizeEnum {
|
|
8
|
+
MOBILE_SM = 320,
|
|
9
|
+
MOBILE = 481,
|
|
10
|
+
TABLET_SM = 768,
|
|
11
|
+
TABLET = 961,
|
|
12
|
+
DESKTOP_SM = 1025,
|
|
13
|
+
DESKTOP = 1120
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AdaptiveRenderSettingModel } from './adaptive-render.type';
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* HOC: 적응형 컴포넌트를 만든다.
|
|
6
|
+
*
|
|
7
|
+
* desktop, tablet 및 mobile 에 맞는 컴포넌트를 인수로 넘겨주면 된다.
|
|
8
|
+
*
|
|
9
|
+
* 각각의 세가지 컴포넌트는 반드시 Props 를 공통으로 사용해야 한다.
|
|
10
|
+
*
|
|
11
|
+
* 그리고 사용 시 반드시 각 컴포넌트가 공통으로 사용하는 Props 타입을 제네릭 선언 해 주어야 한다.
|
|
12
|
+
*
|
|
13
|
+
* 한편, 각 대응되는 device 별 인수를 넣지 않을 경우 그 device 환경이 되면 컴포넌트 렌더링을 하지 않는다.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* interface InputProps {
|
|
17
|
+
* name: string;
|
|
18
|
+
* value: string;
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* // tablet 이 빠져 있으므로 tablet 환경에서는 렌더링 하지 않는다.
|
|
22
|
+
* // 사용 시 반드시 각 컴포넌트가 공통으로 사용하는 Props 타입을 제네릭 선언 해 주어야 한다.
|
|
23
|
+
* const AdaptiveInput = hocAdaptiveRender<InputProps>({
|
|
24
|
+
* desktop: InputDesktop,
|
|
25
|
+
* mobile: InputMobile,
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // 사용 예
|
|
29
|
+
* export const Test: FC = () => (
|
|
30
|
+
* <AdaptiveInput name="title" value="nani?" />
|
|
31
|
+
* );
|
|
32
|
+
*
|
|
33
|
+
* @param settings 적응형으로 설정할 컴포넌트들.
|
|
34
|
+
*/
|
|
35
|
+
export declare function withAdaptiveRender<T>(settings: AdaptiveRenderSettingModel<T>): React.FC<T>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface DebounceHooksResult<T> {
|
|
2
|
+
(args: T): void;
|
|
3
|
+
stop(): void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* 훅: 디바운스를 적용 한다.
|
|
7
|
+
*
|
|
8
|
+
* 적용 시 별도로 함수가 반환되며, 이 함수는 특정시간이 지날 때 까지 재 호출이 없다면 비로소 인수로 주어진 내부 함수를 수행한다.
|
|
9
|
+
*
|
|
10
|
+
* 참고:
|
|
11
|
+
* https://medium.com/@feanar/debounce%EB%9E%80-%EB%AD%98%EA%B9%8C%EC%9A%94-82204c8b953f
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const Example: FC = () => {
|
|
15
|
+
* const handler = (e: KeyboardEvent) => console.log(e.target.value);
|
|
16
|
+
* // 300 미리초가 지날 때 까지 추가적인 입력이 없으면 콘솔에 출력한다.
|
|
17
|
+
* const handleChange = useDebounce(handler, 300);
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <input onChange={handleChange} />
|
|
21
|
+
* );
|
|
22
|
+
* };
|
|
23
|
+
*
|
|
24
|
+
* @param fn 디바운스를 적용 시킬 함수.
|
|
25
|
+
* @param time 시간 조건(ms). 기본 300.
|
|
26
|
+
* @param deps 생성되는 함수가 변경되어야 할 조건들 (dependencies)
|
|
27
|
+
*/
|
|
28
|
+
export declare function useDebounce<T = any>(fn: (args: T) => void, time?: number, deps?: any[]): DebounceHooksResult<T>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 훅: 웹브라우저의 URL 파라미터 및 쿼리 파라미터를 합쳐서 하나의 객체로 만들어준다.
|
|
3
|
+
*
|
|
4
|
+
* 주의1: 쿼리 및 URL 파라미터의 key name 이 중복되지 않는 조건에서 사용해야한다.
|
|
5
|
+
*
|
|
6
|
+
* @see useParams
|
|
7
|
+
* @see qs.parse
|
|
8
|
+
*/
|
|
9
|
+
export declare function useQueryParams<T = unknown>(): T;
|
|
10
|
+
/**
|
|
11
|
+
* 훅: 웹브라우저의 URL 파라미터 및 쿼리 파라미터를 합쳐서 하나의 객체로 만들어준다.
|
|
12
|
+
*
|
|
13
|
+
* 주의1: 쿼리 및 URL 파라미터의 key name 이 중복되지 않는 조건에서 사용해야한다.
|
|
14
|
+
*
|
|
15
|
+
* @param selector 변환된 쿼리 파라미터 객체를 원하는 타입으로 직접 변환하는 셀렉터.
|
|
16
|
+
* @see useParams
|
|
17
|
+
* @see qs.parse
|
|
18
|
+
*/
|
|
19
|
+
export declare function useQueryParams<T>(selector: (params: Record<string, string>) => T): T;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 훅: 쓰로틀을 적용한다.
|
|
3
|
+
*
|
|
4
|
+
* 적용 시 별도로 함수가 반환되며, 이 함수는 처음 수행 후 지정된 시간이 지날 때 까지 재호출이 되어도 다시 수행되지 않는다.
|
|
5
|
+
*
|
|
6
|
+
* 이 후 지정된 시간이 지나면 비로소 인수로 주어진 내부 콜백 함수를 수행한다.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const Example: FC = () => {
|
|
10
|
+
* const handler = (e: MouseEvent) => console.log('클릭이요!');
|
|
11
|
+
* // 첫 클릭 이후로 버튼을 연타 하면 300 미리초가 지날 때만 한번씩 콘솔에 출력된다.
|
|
12
|
+
* const handleClick = useThrottle(handler, 300);
|
|
13
|
+
*
|
|
14
|
+
* return (
|
|
15
|
+
* <button type="button" onClick={handleClick}>
|
|
16
|
+
* 0.3초마다 콘솔 찍히는 버튼!!
|
|
17
|
+
* </button>
|
|
18
|
+
* );
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* @param fn 쓰로틀을 적용시킬 함수.
|
|
22
|
+
* @param time 시간 조건(ms). 기본 300.
|
|
23
|
+
* @param deps 생성되는 함수가 변경되어야 할 조건들 (dependencies)
|
|
24
|
+
*/
|
|
25
|
+
export declare function useThrottle<T = any>(fn: (args: T) => void, time?: number, deps?: any[]): (args: T) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { HttpApi, HttpApiErrorParser } from './network.type';
|
|
3
|
+
/**
|
|
4
|
+
* Backend 에서 API를 호출하는 서비스를 생성한다.
|
|
5
|
+
* @param baseUrl 현재 서비스에서 API 호출 시 필요한 도메인 및 하위 경로를 정의 한다.
|
|
6
|
+
* @param headerProvider 헤더 제공자를 주입한다.
|
|
7
|
+
* @param withCredentials cross-domain 의 cookie 값을 가져올지의 여부 설정. 기본 true.
|
|
8
|
+
*/
|
|
9
|
+
export declare const createHttpApi: (baseUrl: string, parserVisitor: HttpApiErrorParser<AxiosError>, headerProvider?: () => Record<string, string>, withCredentials?: boolean, paramsSerializer?: (params: any) => string) => HttpApi;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TokenProvider } from '../storage';
|
|
2
|
+
export declare const headerPipe: {
|
|
3
|
+
acceptContentType: (headerData: Record<string, string>) => Record<string, string>;
|
|
4
|
+
contentTypeFormPost: (headerData: Record<string, string>) => Record<string, string>;
|
|
5
|
+
contentTypeFormMultipart: (headerData: Record<string, string>) => Record<string, string>;
|
|
6
|
+
contentTypeJson: (headerData: Record<string, string>) => Record<string, string>;
|
|
7
|
+
bearerToken: (headerData: Record<string, string>, token?: string) => Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* HTTP 헤더를 제공한다.
|
|
11
|
+
* tokenProvider 설정 후 pipe 로 필요한 헤더 요소를 함수로 구성하여
|
|
12
|
+
* 다양한 HTTP 헤더를 만들 수 있다.
|
|
13
|
+
* @param tokenProvider 토큰을 보관하는 제공자.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createHttpHeaderProvider: (tokenProvider?: TokenProvider) => (...pipes: ((defHeader: Record<string, string>, token?: string) => Record<string, string>)[]) => Record<string, string>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { MarshallingType } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 업로드 상태를 확인할 수 있는 객체.
|
|
4
|
+
*/
|
|
5
|
+
export interface UploadStateArgs {
|
|
6
|
+
/**
|
|
7
|
+
* 진행도. 0~100 까지의 수치.
|
|
8
|
+
*/
|
|
9
|
+
progress: number;
|
|
10
|
+
/**
|
|
11
|
+
* 업로드된 바이트수.
|
|
12
|
+
*/
|
|
13
|
+
loaded: number;
|
|
14
|
+
/**
|
|
15
|
+
* 업로드 해야 할 총 바이트수.
|
|
16
|
+
*/
|
|
17
|
+
total: number;
|
|
18
|
+
/**
|
|
19
|
+
* 완료여부.
|
|
20
|
+
*/
|
|
21
|
+
completed: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Axios 에서 업로드 상태 전달 콜백에 인자로 들어오는 이벤트 객체.
|
|
25
|
+
*/
|
|
26
|
+
export interface XhrUploadStateArgs {
|
|
27
|
+
/**
|
|
28
|
+
* 업로드 된 바이트 수
|
|
29
|
+
*/
|
|
30
|
+
loaded: number;
|
|
31
|
+
/**
|
|
32
|
+
* 업로드 되어야 할 전체 바이트 수
|
|
33
|
+
*/
|
|
34
|
+
total: number;
|
|
35
|
+
}
|
|
36
|
+
export interface HttpApiErrorParser<T, E extends Error = Error> {
|
|
37
|
+
parse(libErrObj: T): E;
|
|
38
|
+
throwOther<E extends Error>(err: E): never;
|
|
39
|
+
interrupt: <E extends Error>(error: E) => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* HTTP 프로토콜을 이용하여 비동기 통신을 수행한다.
|
|
43
|
+
*/
|
|
44
|
+
export interface HttpApi {
|
|
45
|
+
/**
|
|
46
|
+
* GET 메서드 호출
|
|
47
|
+
* @param url 호출 경로
|
|
48
|
+
* @param params 전달할 파라미터
|
|
49
|
+
* @param timeout 응답 제한시간 설정. 설정한 시간이 넘도록 응답이 없다면 중단하고 throw 를 일으킨다.
|
|
50
|
+
*/
|
|
51
|
+
get<T = MarshallingType, P = Record<string, any> | void>(url: string, params?: P, timeout?: number): Promise<T>;
|
|
52
|
+
/**
|
|
53
|
+
* POST 메서드 호출
|
|
54
|
+
* @param url 호출 경로. 만약 쿼리 파라미터가 포함된다면 이 곳에 추가적으로 명시 해 주어야 한다.
|
|
55
|
+
* @param body 요청으로 보낼 데이터. json 으로 바꿔서 보내게 된다.
|
|
56
|
+
* @param timeout 응답 제한시간 설정. 설정한 시간이 넘도록 응답이 없다면 중단하고 throw 를 일으킨다.
|
|
57
|
+
*/
|
|
58
|
+
post<T = MarshallingType, P = Record<string, any> | void>(url: string, body?: P, timeout?: number): Promise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* PUT 메서드 호출
|
|
61
|
+
* @param url 호출 경로. 만약 쿼리 파라미터가 포함된다면 이 곳에 추가적으로 명시 해 주어야 한다.
|
|
62
|
+
* @param body 요청으로 보낼 데이터. json 으로 바꿔서 보내게 된다.
|
|
63
|
+
* @param timeout 응답 제한시간 설정. 설정한 시간이 넘도록 응답이 없다면 중단하고 throw 를 일으킨다.
|
|
64
|
+
*/
|
|
65
|
+
put<T = MarshallingType, P = Record<string, any> | void>(url: string, body?: P, timeout?: number): Promise<T>;
|
|
66
|
+
/**
|
|
67
|
+
* PATCH 메서드 호출
|
|
68
|
+
* @param url 호출 경로. 만약 쿼리 파라미터가 포함된다면 이 곳에 추가적으로 명시 해 주어야 한다.
|
|
69
|
+
* @param body 요청으로 보낼 데이터. json 으로 바꿔서 보내게 된다.
|
|
70
|
+
* @param timeout 응답 제한시간 설정. 설정한 시간이 넘도록 응답이 없다면 중단하고 throw 를 일으킨다.
|
|
71
|
+
*/
|
|
72
|
+
patch<T = MarshallingType, P = Record<string, any> | void>(url: string, body?: P, timeout?: number): Promise<T>;
|
|
73
|
+
/**
|
|
74
|
+
* DELETE 메서드 호출
|
|
75
|
+
* @param url 호출 경로
|
|
76
|
+
* @param params 전달할 파라미터
|
|
77
|
+
* @param timeout 응답 제한시간 설정. 설정한 시간이 넘도록 응답이 없다면 중단하고 throw 를 일으킨다.
|
|
78
|
+
*/
|
|
79
|
+
delete<T = MarshallingType, P = Record<string, any> | void>(url: string, params?: P, timeout?: number): Promise<T>;
|
|
80
|
+
/**
|
|
81
|
+
* POST 메서드로 업로드 한다.
|
|
82
|
+
* @param url 업로드 경로
|
|
83
|
+
* @param data 업로드에 쓰이는 데이터
|
|
84
|
+
* @param progCallback 업로드 상황을 보내주는 콜백
|
|
85
|
+
* @param timeout 응답 제한시간 설정. 설정한 시간이 넘도록 응답이 없다면 중단하고 throw 를 일으킨다.
|
|
86
|
+
*/
|
|
87
|
+
postUpload<T = void, P extends Record<string, any> = Record<string, string | File | File[]>>(url: string, data: P, progCallback?: (args: UploadStateArgs) => void, timeout?: number): Promise<T>;
|
|
88
|
+
/**
|
|
89
|
+
* PUT 메서드로 업로드 한다.
|
|
90
|
+
* @param url 업로드 경로
|
|
91
|
+
* @param data 업로드에 쓰이는 데이터
|
|
92
|
+
* @param progCallback 업로드 상황을 보내주는 콜백
|
|
93
|
+
* @param timeout 응답 제한시간 설정. 설정한 시간이 넘도록 응답이 없다면 중단하고 throw 를 일으킨다.
|
|
94
|
+
*/
|
|
95
|
+
putUpload<T = void, P extends Record<string, any> = Record<string, string | File | File[]>>(url: string, data: P, progCallback?: (args: UploadStateArgs) => void, timeout?: number): Promise<T>;
|
|
96
|
+
/**
|
|
97
|
+
* GET 메서드로 파일을 비동기로 가져온다.
|
|
98
|
+
* @param url 파일을 가져올 경로
|
|
99
|
+
* @param params 전달할 파라미터
|
|
100
|
+
* @param filename 파일이 받아졌을 때 쓰여질 파일명.
|
|
101
|
+
*/
|
|
102
|
+
getFile<P = Record<string, any> | void>(url: string, params?: P, filename?: string): Promise<File>;
|
|
103
|
+
/**
|
|
104
|
+
* GET 메서드로 blob을 비동기로 가져온다.
|
|
105
|
+
* @param url blob을 가져올 경로
|
|
106
|
+
* @param params 전달할 파라미터
|
|
107
|
+
*/
|
|
108
|
+
getBlob<P = Record<string, any> | void>(url: string, params?: P): Promise<Blob>;
|
|
109
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AxiosError, AxiosResponse, Method } from 'axios';
|
|
2
|
+
import { HttpApiErrorParser, UploadStateArgs } from './network.type';
|
|
3
|
+
export declare const axiosResponseToData: <T>(axiosRes: AxiosResponse<T>) => T;
|
|
4
|
+
export declare function axiosCreateHeader(headerProvider: () => Record<string, string>): {
|
|
5
|
+
common: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
export declare const throwNewErrorForLib: <T>(parserVisitor: HttpApiErrorParser<T, Error>) => (anyError: any) => never;
|
|
8
|
+
export declare const axiosUploadCommon: (baseUrl: string, parserVisitor: HttpApiErrorParser<AxiosError>, headerProvider: () => Record<string, string>, withCredentials?: boolean) => <T>(method: Method, url: string, data: FormData, progCallback?: (args: UploadStateArgs) => void, timeout?: number) => Promise<T>;
|
|
9
|
+
export declare function convertToFormData(data: Record<string, string | File | File[]>): FormData;
|
package/libs/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DeviceDetectProvider, withAdaptiveRender } from './adaptive-render';
|
|
2
|
+
import { createHttpApi, createHttpHeaderProvider, headerPipe, HttpApi, HttpApiErrorParser, UploadStateArgs, XhrUploadStateArgs } from './http-api';
|
|
3
|
+
import { cache } from './proxies';
|
|
4
|
+
import { createGuardDispatch, createGuardSelector, ModuleRouteModel, renderRouteSystem } from './route-system';
|
|
5
|
+
import validate, { mergeValidates, ValidateResultModel, ValidateBulkResultModel, ValidateCheckModel, ValidateBulkOptionType } from './validate';
|
|
6
|
+
export * from './queries';
|
|
7
|
+
export * from './storage';
|
|
8
|
+
export * from './hooks';
|
|
9
|
+
export * from './util';
|
|
10
|
+
export * from './types';
|
|
11
|
+
export { UploadStateArgs, XhrUploadStateArgs, HttpApiErrorParser, HttpApi, ModuleRouteModel, DeviceDetectProvider, withAdaptiveRender, createHttpApi, headerPipe, createHttpHeaderProvider, cache, renderRouteSystem, createGuardDispatch, createGuardSelector, validate, mergeValidates, ValidateResultModel, ValidateBulkResultModel, ValidateCheckModel, ValidateBulkOptionType, };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
declare type CacheProxy = (baseApi: HttpApi) => <T extends string | string[] | Record<string, any>, P = void | Record<string, any>>(url: string, params?: P) => Promise<T>;
|
|
3
|
+
declare type CacheType = 'local' | 'session' | 'memory';
|
|
4
|
+
/**
|
|
5
|
+
* 스토리지를 이용한 API 캐시를 적용한다.
|
|
6
|
+
*
|
|
7
|
+
* @param type local, session, memory 셋 중 하나. 기본 local.
|
|
8
|
+
* @param expiredTime 캐시가 만료되는 시간(seconds). 0 이하면 무제한. 기본 0.
|
|
9
|
+
*/
|
|
10
|
+
export declare function cache(type?: CacheType, expiredTime?: number): CacheProxy;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cache.proxy';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EnhancedStore } from '@reduxjs/toolkit';
|
|
2
|
+
interface MutationHooksCreatorSettingOptionDto<SR, SP, R, P, ReduxRootState> {
|
|
3
|
+
/**
|
|
4
|
+
* Mutation hooks의 고유키이다. auto dispatch 사용 시 반드시 필요하다.
|
|
5
|
+
*
|
|
6
|
+
* ### auto dispatch
|
|
7
|
+
* 매 요청마다 redux store의 dispatch를 수행한다. (devTool에 로그가 출력된다.)
|
|
8
|
+
*/
|
|
9
|
+
key?: string;
|
|
10
|
+
/**
|
|
11
|
+
* 데이터 mutaion를 위한 함수
|
|
12
|
+
*/
|
|
13
|
+
mutator: ((params: SP) => Promise<SR>) | ((params?: SP) => Promise<SR>);
|
|
14
|
+
/**
|
|
15
|
+
* 파라미터 변환기.
|
|
16
|
+
*
|
|
17
|
+
* UI Model로 전달된 파라미터를 Server측 파라미터로 변환한다.
|
|
18
|
+
*/
|
|
19
|
+
parameterConverter?: (params: P, getState: () => ReduxRootState) => SP;
|
|
20
|
+
/**
|
|
21
|
+
* 받아온 결과 데이터에 대한 변환기.
|
|
22
|
+
*
|
|
23
|
+
* Server측 Entity와 response를 UI Model로 변환한다.
|
|
24
|
+
*/
|
|
25
|
+
resultConverter?: (result: SR, getState: () => ReduxRootState) => R;
|
|
26
|
+
}
|
|
27
|
+
interface MutationResultType<R = void, P = void, E extends Error = Error> {
|
|
28
|
+
data: R | null;
|
|
29
|
+
error?: E;
|
|
30
|
+
loading: boolean;
|
|
31
|
+
mutate: (params?: P, throwable?: boolean) => Promise<boolean>;
|
|
32
|
+
}
|
|
33
|
+
interface MutationHooks<R = void, P = void, E extends Error = Error> {
|
|
34
|
+
(params?: R): MutationResultType<R, P, E>;
|
|
35
|
+
}
|
|
36
|
+
export declare function buildMutationCreator<S>(store: EnhancedStore<S>): <SR, SP, R, P, E extends Error>({ key, mutator, parameterConverter, resultConverter, }: MutationHooksCreatorSettingOptionDto<SR, SP, R, P, S>) => MutationHooks<R, P, E>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { EnhancedStore } from '@reduxjs/toolkit';
|
|
2
|
+
import { StorageType } from '../storage';
|
|
3
|
+
/**
|
|
4
|
+
* query hooks가 리턴하는 객체
|
|
5
|
+
*/
|
|
6
|
+
interface QueryHandler<R, P = void, E extends Error = Error> {
|
|
7
|
+
/**
|
|
8
|
+
* 응답(response) 받은 자료가 담겨있다.
|
|
9
|
+
*
|
|
10
|
+
* 원격에서 자료를 받아오기 전까지는 설정된 기본 자료가 담겨있다.
|
|
11
|
+
*/
|
|
12
|
+
data: R;
|
|
13
|
+
/**
|
|
14
|
+
* 오류 내용
|
|
15
|
+
*/
|
|
16
|
+
error?: E;
|
|
17
|
+
/**
|
|
18
|
+
* 응답을 받아오는 중인지 여부
|
|
19
|
+
*/
|
|
20
|
+
loading: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 응답을 위한 요청 수행 함수
|
|
23
|
+
*/
|
|
24
|
+
load: (params?: P) => Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* 현재 쿼리에 담긴 데이터를 초기화하고 기본 자료를 담는다.
|
|
27
|
+
*
|
|
28
|
+
* @param removeCache true (기본) = 캐시와 내부 상태 모두 초기화, false = 내부 상태만 초기화
|
|
29
|
+
*/
|
|
30
|
+
clear: (removeCache?: boolean) => void;
|
|
31
|
+
}
|
|
32
|
+
interface QueryHooksCreatorSettingOptionDto<SR, SP, R, P, ReduxRootState> {
|
|
33
|
+
/**
|
|
34
|
+
* 쿼리 훅스 고유키. 캐시나 auto dispatch 사용 시 반드시 필요하다.
|
|
35
|
+
*
|
|
36
|
+
* ### auto dispatch
|
|
37
|
+
* 매 요청 마다 redux store 의 dispatch 를 수행한다. (redux dev tool 에 해당 로그가 출력됨)
|
|
38
|
+
*/
|
|
39
|
+
key?: string;
|
|
40
|
+
/**
|
|
41
|
+
* 캐시할 때 쓰일 서브키들을 설정한다.
|
|
42
|
+
*
|
|
43
|
+
* 들어오는 파라미터 객체에서 지정된 키만을 이용하여 캐시키를 만든다.
|
|
44
|
+
*
|
|
45
|
+
* **미 설정 시 기본 동작**: 들어오는 파라미터 객체의 _모든 키들을 대상_ 으로 동작된다.
|
|
46
|
+
*
|
|
47
|
+
* #### 해당 옵션이 무시되는 경우
|
|
48
|
+
* - cache 옵션이 'false` 라면 무시된다.
|
|
49
|
+
* - 들어오는 파라미터가 객체가 아니거나 비어있다면 해당 설정은 무시된다.
|
|
50
|
+
*/
|
|
51
|
+
subKeysFromParams?: Array<keyof P>;
|
|
52
|
+
/**
|
|
53
|
+
* 캐시 종류 선택.
|
|
54
|
+
*
|
|
55
|
+
* key 옵션 설정 시 기본값이 자동으로 설정된다.
|
|
56
|
+
*
|
|
57
|
+
* false 를 주면 캐시를 사용하지 않는다.
|
|
58
|
+
*
|
|
59
|
+
* @default 'session'
|
|
60
|
+
*/
|
|
61
|
+
cache?: StorageType | false;
|
|
62
|
+
/**
|
|
63
|
+
* 캐시 유효기간 설정. (seconds)
|
|
64
|
+
*
|
|
65
|
+
* 0 혹은 설정하지 않으면 기한이 없다.
|
|
66
|
+
*
|
|
67
|
+
* @default 0
|
|
68
|
+
*/
|
|
69
|
+
expired?: number;
|
|
70
|
+
/**
|
|
71
|
+
* 게으른 수행(lazy fetch) 여부.
|
|
72
|
+
*
|
|
73
|
+
* true 로 설정 시 별도로 load 를 수행하지 않으면 데이터를 가져오지 않는다.
|
|
74
|
+
*
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
lazy?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* 쿼리 훅스 수행과 동시에 곧바로 로딩으로 둘지의 여부.
|
|
80
|
+
*
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
83
|
+
defaultLoading?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* 데이터 가져오기를 실제 수행 할 함수.
|
|
86
|
+
*/
|
|
87
|
+
fetcher: ((params: SP) => Promise<SR>) | (() => Promise<SR>);
|
|
88
|
+
/**
|
|
89
|
+
* 적용할 기본자료.
|
|
90
|
+
*
|
|
91
|
+
* fetcher 가 자료를 가져오기 전 까지 기본적으로 제공 할 자료로 쓰인다.
|
|
92
|
+
*/
|
|
93
|
+
defaultData: R | (() => R);
|
|
94
|
+
/**
|
|
95
|
+
* 파라미터 변환기.
|
|
96
|
+
*
|
|
97
|
+
* UI Model 로 전달된 파라미터를 Server 측 파라미터로 변환한다.
|
|
98
|
+
*/
|
|
99
|
+
parameterConverter?: (params: P, getState: () => ReduxRootState) => SP;
|
|
100
|
+
/**
|
|
101
|
+
* 받아온 결과 데이터에 대한 변환기.
|
|
102
|
+
*
|
|
103
|
+
* Server 측 Entity 와 응답 자료를 UI Model 로 변환한다.
|
|
104
|
+
*/
|
|
105
|
+
resultConverter?: (result: SR, getState: () => ReduxRootState, params: P) => R;
|
|
106
|
+
}
|
|
107
|
+
interface QueryHooks<R, P = void, E extends Error = Error> {
|
|
108
|
+
(params?: P): QueryHandler<R, P, E>;
|
|
109
|
+
}
|
|
110
|
+
interface CreateRepositoryQuery<S> {
|
|
111
|
+
<SR, SP, R, P, E extends Error = Error>(config: QueryHooksCreatorSettingOptionDto<SR, SP, R, P, S>): QueryHooks<R, P, E>;
|
|
112
|
+
<R, P, E extends Error = Error>(config: QueryHooksCreatorSettingOptionDto<R, P, R, P, S>): QueryHooks<R, P, E>;
|
|
113
|
+
}
|
|
114
|
+
export declare function buildQueryCreator<S>(store: EnhancedStore<S>): CreateRepositoryQuery<S>;
|
|
115
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMakeDeps<T>(args?: T, keys?: string[] | (keyof T)[]): any[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StorageKeyManager, StorageType } from '../../storage';
|
|
2
|
+
declare type LargeStorageType = Exclude<StorageType, 'cookie'>;
|
|
3
|
+
declare function getStorage(type: LargeStorageType): StorageKeyManager;
|
|
4
|
+
/**
|
|
5
|
+
* 캐시를 제거한다.
|
|
6
|
+
*
|
|
7
|
+
* 제공되는 cache 디코레이터로 만들어진 캐시들을 제거하는데 쓰인다.
|
|
8
|
+
*
|
|
9
|
+
* @param type 캐시 타입 (쿠키 제외)
|
|
10
|
+
* @param keyword 삭제 대상이 되는 키워드
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function clearCacheByKeyword(type: LargeStorageType, keyword: string | string[], storageGetter?: typeof getStorage): number;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createCacheKey<P>(key: string, params?: P, subKeys?: Array<keyof P>): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 모듈에서 쓰이는 각종 페이지 컴포넌트의 라우팅 정보를 담은 객체
|
|
4
|
+
*/
|
|
5
|
+
export interface ModuleRouteModel {
|
|
6
|
+
/**
|
|
7
|
+
* 수행 경로
|
|
8
|
+
*/
|
|
9
|
+
path: string;
|
|
10
|
+
/**
|
|
11
|
+
* 정확성 여부. 지정된 path 가 정확히 맞아야만 컴포넌트가 렌더링 된다.
|
|
12
|
+
*/
|
|
13
|
+
exact?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 현재 경로로 왔을 때 곧바로 이동될 다른 경로.
|
|
16
|
+
*
|
|
17
|
+
* 만약 guard 옵션에 설정이 되어있고 그 결과가 true 가 아니라면 설정된 주소를 사용하여 이동될 것이다.
|
|
18
|
+
*/
|
|
19
|
+
redirect?: string;
|
|
20
|
+
/**
|
|
21
|
+
* 해당 페이지에 접근 시 별도 권한이 필요하다면 쓰이는 기능.
|
|
22
|
+
*
|
|
23
|
+
* 동기 혹은 비동기로 true 가 되면 페이지 렌더링이 된다.
|
|
24
|
+
*
|
|
25
|
+
* 만약 설정 되었음에도 true 가 안된다면,
|
|
26
|
+
* 1. failComponent 에 설정된 컴포넌트를 렌더링 한다.
|
|
27
|
+
* 2. failComponent 가 설정 안되어 있다면, redirect 에 설정된 주소로 이동된다.
|
|
28
|
+
* 3. 아무것도 설정되어 있지 않다면 루트(/) 경로로 이동한다.
|
|
29
|
+
*
|
|
30
|
+
* 설정하지 않을 경우 무조건 렌더링 한다.
|
|
31
|
+
*/
|
|
32
|
+
guard?: () => boolean | Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* 설정된 페이지 컴포넌트를 감싸서 함께 렌더링될 상위 컴포넌트
|
|
35
|
+
*/
|
|
36
|
+
wrap?: ComponentType<any>;
|
|
37
|
+
/**
|
|
38
|
+
* 렌더링에 사용될 페이지 컴포넌트.
|
|
39
|
+
*/
|
|
40
|
+
component?: ComponentType<any>;
|
|
41
|
+
/**
|
|
42
|
+
* guard 설정 결과가 false 일 때 렌더링 될 컴포넌트.
|
|
43
|
+
*/
|
|
44
|
+
failComponent?: ComponentType<any>;
|
|
45
|
+
/**
|
|
46
|
+
* 하위 라우팅 설정
|
|
47
|
+
*/
|
|
48
|
+
child?: ModuleRouteModel[];
|
|
49
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { ModuleRouteModel } from './moduleRoute.model';
|
|
3
|
+
declare type GuardFunctionType = () => boolean | Promise<boolean>;
|
|
4
|
+
export declare const renderRouteSystem: (routes: ModuleRouteModel[], withSwitch?: boolean, notFound?: ComponentType<any>, guardList?: GuardFunctionType[]) => JSX.Element | JSX.Element[];
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EnhancedStore, AsyncThunkAction } from '@reduxjs/toolkit';
|
|
2
|
+
import { CombinedState } from 'redux';
|
|
3
|
+
export declare function createGuardDispatch<T>(store: EnhancedStore<CombinedState<T>>): <R>(effectResult: AsyncThunkAction<R, any, any>) => Promise<boolean>;
|
|
4
|
+
export declare function createGuardSelector<T>(store: EnhancedStore<CombinedState<T>>): <R>(selector: (state: CombinedState<T>) => R) => R;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CookieService, SimpleStorage } from './storage.type';
|
|
2
|
+
import { MarshallingType } from '../types';
|
|
3
|
+
export declare class CookieStorageAdapter<T extends MarshallingType> implements SimpleStorage<T> {
|
|
4
|
+
private cookie;
|
|
5
|
+
readonly key: string;
|
|
6
|
+
expiredTime: number;
|
|
7
|
+
constructor(cookie: CookieService, key: string, expiredTime?: number);
|
|
8
|
+
get(): T | null;
|
|
9
|
+
set(value: T): void;
|
|
10
|
+
remove(): void;
|
|
11
|
+
}
|