sales-frontend-api 0.0.19 → 0.0.21

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/server.d.cts CHANGED
@@ -1,6 +1,5 @@
1
- import { H as HttpClientAxios, C as CustomError, c as customConfig, E as ErrorHandler, e as errorHandler, A as AbstractHttpClient } from './error-handler-DCenPKx5.cjs';
2
- import { customConfigFetch, interceptors, customResponse, fulfilled, rejected } from './common.cjs';
3
- import 'axios';
1
+ import { a as GetterAsync, b as SetterAsync } from './header.types-duHbFvO0.cjs';
2
+ export { A as AT, G as GetterSync, S as SetterSync, c as customHeaderNames } from './header.types-duHbFvO0.cjs';
4
3
 
5
4
  declare class AuthServer {
6
5
  /**
@@ -18,92 +17,141 @@ declare class AuthServer {
18
17
  refreshToken(): Promise<string>;
19
18
  }
20
19
 
21
- declare class SsrHttpClientAxios extends HttpClientAxios<CustomError> {
22
- static query: string;
23
- private ssrErrorHandler;
24
- constructor(config?: customConfig);
25
- setSsrErrorHandler(ssrErrorHandler: ErrorHandler): void;
20
+ /**
21
+ * 서버사이드용 쿠키함수
22
+ */
23
+ declare const cookieServer: {
24
+ getCookie(name: string): Promise<string>;
25
+ setCookie(name: string, value: string, options?: any): Promise<void>;
26
+ deleteCookie(name: string): Promise<void>;
27
+ };
28
+
29
+ declare class HeaderManagerAsync {
30
+ private getter;
31
+ private setter;
32
+ constructor(getter: GetterAsync, setter: SetterAsync);
26
33
  /**
27
- * API 연동 실패시, 에러핸들러 셋팅 (특정페이지에서만 동작하는 개별 핸들러)
28
- * @param handler ssrErrorHandler
34
+ * 커스텀 헤더를 비동기적으로 설정합니다.
29
35
  */
30
- setLocalErrorHandler(handler: errorHandler, global?: boolean): void;
31
- }
32
-
33
- declare class FetchInstance {
36
+ setCustomHeaders(): Promise<void>;
34
37
  /**
35
- * fetch 인스턴스 생성시 기본설정값 및 기타 필요한 정보들을 추가 가능
38
+ * 인증 토큰을 비동기적으로 설정합니다.
36
39
  */
37
- protected config: customConfigFetch;
38
- protected interceptors: interceptors<customConfigFetch, customResponse>;
39
- constructor(config: customConfigFetch);
40
- doFetch<dataType>(config: customConfigFetch): Promise<dataType>;
41
- private getUrlWithParams;
42
- get<dataType = any>(url: string, config?: customConfigFetch): Promise<dataType>;
43
- post<dataType = any>(url: string, data?: any, config?: customConfigFetch): Promise<dataType>;
44
- put<dataType = any>(url: string, data?: any, config?: customConfigFetch): Promise<dataType>;
45
- delete<dataType = any>(url: string, data?: any, config?: customConfigFetch): Promise<dataType>;
46
- addRequestInterceptor(onFulfilled: fulfilled<customConfigFetch>, onRejected?: rejected): void;
47
- addResponseInterceptor(onFulfilled: fulfilled<customResponse>, onRejected?: rejected): void;
48
- private getValue;
49
- handleRequest(config: customConfigFetch): Promise<customConfigFetch>;
50
- handleResponse(customResponse: customResponse): Promise<customResponse>;
51
- handleResponseError(e: CustomError): Promise<void>;
40
+ setAuthToken(): Promise<void>;
41
+ /**
42
+ * 모든 헤더를 비동기적으로 설정합니다.
43
+ */
44
+ setAllHeaders(): Promise<void>;
52
45
  }
46
+ declare const HeaderFunc: {
47
+ getHeader(name: string): Promise<string | null>;
48
+ setHeader(name: string, value: string): Promise<void>;
49
+ };
53
50
 
54
- declare class HttpClientFetch extends AbstractHttpClient<customConfigFetch, FetchInstance, CustomError> {
55
- protected errorHandler: null | ((e: CustomError) => void);
51
+ /**
52
+ * HTTP 요청에 대한 설정을 나타냅니다.
53
+ * 표준 `RequestInit` 타입의 하위 집합이며, `params`와 `data`가 추가되었습니다.
54
+ * body를 제거하고 axios와 유사한 형태로 data로 작성.
55
+ * json변환 자동화 및 개발편의성.
56
+ */
57
+ interface RequestConfig extends Omit<RequestInit, 'body'> {
58
+ url?: string;
59
+ params?: Record<string, any>;
60
+ data?: any;
61
+ }
62
+ /**
63
+ * HttpClient 인스턴스에 대한 설정입니다.
64
+ */
65
+ interface HttpClientConfig {
66
+ baseURL?: string;
67
+ headers?: Record<string, string>;
68
+ }
69
+ /**
70
+ * 선택적인 성공 및 실패 핸들러를 포함하는 인터셉터의 구조
71
+ */
72
+ interface Interceptor<V> {
73
+ onFulfilled?: (value: V) => V | Promise<V>;
74
+ onRejected?: (error: any) => any;
75
+ }
76
+
77
+ /**
78
+ * HTTP 오류를 위한 사용자 정의 오류
79
+ * 응답 객체를 포함
80
+ * @todo CustomeError > 다이렉트 에러 참고하여 수정 필요
81
+ */
82
+ declare class HttpError extends Error {
83
+ response: Response;
84
+ data: any;
85
+ constructor(response: Response, data: any);
86
+ }
87
+ /**
88
+ * Axios와 유사하게 인터셉터 컬렉션을 관리합니다.
89
+ */
90
+ declare class InterceptorManager<V> {
91
+ private handlers;
56
92
  /**
57
- * HttpClientFetch request interceptor 동작시, 헤더에 주입될 헤더의 key,value
93
+ * 체인에 인터셉터를 추가
94
+ * @param onFulfilled - 프로미스가 이행되었을 때 호출할 함수
95
+ * @param onRejected - 프로미스가 거부되었을 때 호출할 함수
96
+ * @returns 인터셉터의 ID이며, 나중에 제거하는 데 사용
58
97
  */
59
- protected headers: Record<string, string>;
98
+ use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
60
99
  /**
61
- * fetch 인스턴스 생성시 기본설정값 및 기타 필요한 정보들을 추가 가능
100
+ * ID를 사용하여 체인에서 인터셉터를 제거합니다.
101
+ * @param id - 제거할 인터셉터의 ID입니다.
62
102
  */
63
- protected config: customConfigFetch;
103
+ eject(id: number): void;
64
104
  /**
65
- * api연동을 수행할 실제 객체(axios, fetch 등의 다른 라이브러리로 교체가능한 영역)
66
- * 현재 버전에서는 axios를 사용하여 구현됨.
105
+ * 주어진 프로미스에 대해 인터셉터 체인을 실행합니다.
106
+ * @param promise - 체인을 시작할 초기 프로미스입니다.
107
+ * @returns 전체 체인이 실행된 후 확인되는 새 프로미스입니다.
67
108
  */
68
- api: FetchInstance;
69
- constructor(config?: customConfigFetch);
70
- put<dataType = any>(url: string, data?: any, config?: customConfigFetch): Promise<dataType>;
71
- get<dataType = any>(url: string, config?: customConfigFetch): Promise<dataType>;
72
- delete<dataType = any>(url: string, config?: customConfigFetch): Promise<dataType>;
73
- post<dataType = any>(url: string, data?: any, config?: customConfigFetch): Promise<dataType>;
74
- setHeader(key: string, value: string): void;
109
+ executeChain(promise: Promise<V>): Promise<V>;
75
110
  }
76
-
77
- type errorHandlerFethType = (response: CustomError, config: customConfigFetch) => void;
78
- declare abstract class ErrorHandlerFetch {
79
- protected localThrow?: errorHandlerFethType;
80
- /** 개별처리 + 글로벌처리 모두 사용할경우 : true , 개별처리만 사용할 경우 : false */
81
- protected globalCheck: boolean;
82
- constructor();
83
- setGlobalCheck(global: boolean): void;
84
- /**
85
- * 에러코드에 맞는 Error에러 객체를 throw 및 Sentry 리포팅 영역
86
- */
87
- private globalThrow;
88
- setLocalHandler(func: errorHandlerFethType): void;
89
- do(error: CustomError, config: customConfigFetch): void;
111
+ /**
112
+ * @description middleware.ts에서 사용하기 위한 용도로 작성
113
+ */
114
+ declare class FetchInstance {
115
+ private defaults;
116
+ interceptors: {
117
+ request: InterceptorManager<RequestConfig>;
118
+ response: InterceptorManager<Response>;
119
+ };
120
+ constructor(config?: HttpClientConfig);
90
121
  /**
91
- * 발생한 CustomError 설정값에 따른 에러 처리 추가영역
92
- * 상속한 server/client 에서 에러 핸들링
122
+ * 인터셉터를 적용하고 실제 fetch 호출을 수행
123
+ * @param config - 요청 설정
93
124
  */
94
- abstract errorHandler(e: CustomError): void;
125
+ request<T = any>(config: RequestConfig): Promise<{
126
+ data: T;
127
+ response: Response;
128
+ }>;
129
+ get<T = any>(url: string, config?: Omit<RequestConfig, 'method'>): Promise<{
130
+ data: T;
131
+ response: Response;
132
+ }>;
133
+ post<T = any>(url: string, data: any, config?: Omit<RequestConfig, 'method' | 'data'>): Promise<{
134
+ data: T;
135
+ response: Response;
136
+ }>;
137
+ put<T = any>(url: string, data: any, config?: Omit<RequestConfig, 'method' | 'data'>): Promise<{
138
+ data: T;
139
+ response: Response;
140
+ }>;
141
+ delete<T = any>(url: string, config?: Omit<RequestConfig, 'method'>): Promise<{
142
+ data: T;
143
+ response: Response;
144
+ }>;
95
145
  }
96
146
 
97
- declare class SsrHttpClientFetch extends HttpClientFetch {
98
- static query: string;
99
- private ssrErrorHandlerFetch;
100
- constructor(config?: customConfigFetch);
101
- setSsrErrorFetchHandler(ssrErrorHandlerFetch: ErrorHandlerFetch): void;
102
- /**
103
- * API 연동 실패시, 에러핸들러 셋팅 (특정페이지에서만 동작하는 개별 핸들러)
104
- * @param handler ssrErrorHandler
105
- */
106
- setLocalErrorHandler(handler: errorHandlerFethType): void;
147
+ /**
148
+ * @description middleware에서 사용하는 용도.
149
+ * 인증토큰 처리외에 용도는 없음.
150
+ */
151
+ declare class HttpClientFetch extends FetchInstance {
152
+ headerManager: HeaderManagerAsync;
153
+ headers: Record<string, string>;
154
+ constructor(config?: HttpClientConfig);
107
155
  }
108
156
 
109
- export { AuthServer, ErrorHandlerFetch, SsrHttpClientAxios, SsrHttpClientFetch, type errorHandlerFethType };
157
+ export { AuthServer, FetchInstance, GetterAsync, HeaderFunc, HeaderManagerAsync, type HttpClientConfig, HttpClientFetch, HttpError, type Interceptor, type RequestConfig, SetterAsync, cookieServer };
package/dist/server.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { H as HttpClientAxios, C as CustomError, c as customConfig, E as ErrorHandler, e as errorHandler, A as AbstractHttpClient } from './error-handler-DCenPKx5.js';
2
- import { customConfigFetch, interceptors, customResponse, fulfilled, rejected } from './common.js';
3
- import 'axios';
1
+ import { a as GetterAsync, b as SetterAsync } from './header.types-duHbFvO0.js';
2
+ export { A as AT, G as GetterSync, S as SetterSync, c as customHeaderNames } from './header.types-duHbFvO0.js';
4
3
 
5
4
  declare class AuthServer {
6
5
  /**
@@ -18,92 +17,141 @@ declare class AuthServer {
18
17
  refreshToken(): Promise<string>;
19
18
  }
20
19
 
21
- declare class SsrHttpClientAxios extends HttpClientAxios<CustomError> {
22
- static query: string;
23
- private ssrErrorHandler;
24
- constructor(config?: customConfig);
25
- setSsrErrorHandler(ssrErrorHandler: ErrorHandler): void;
20
+ /**
21
+ * 서버사이드용 쿠키함수
22
+ */
23
+ declare const cookieServer: {
24
+ getCookie(name: string): Promise<string>;
25
+ setCookie(name: string, value: string, options?: any): Promise<void>;
26
+ deleteCookie(name: string): Promise<void>;
27
+ };
28
+
29
+ declare class HeaderManagerAsync {
30
+ private getter;
31
+ private setter;
32
+ constructor(getter: GetterAsync, setter: SetterAsync);
26
33
  /**
27
- * API 연동 실패시, 에러핸들러 셋팅 (특정페이지에서만 동작하는 개별 핸들러)
28
- * @param handler ssrErrorHandler
34
+ * 커스텀 헤더를 비동기적으로 설정합니다.
29
35
  */
30
- setLocalErrorHandler(handler: errorHandler, global?: boolean): void;
31
- }
32
-
33
- declare class FetchInstance {
36
+ setCustomHeaders(): Promise<void>;
34
37
  /**
35
- * fetch 인스턴스 생성시 기본설정값 및 기타 필요한 정보들을 추가 가능
38
+ * 인증 토큰을 비동기적으로 설정합니다.
36
39
  */
37
- protected config: customConfigFetch;
38
- protected interceptors: interceptors<customConfigFetch, customResponse>;
39
- constructor(config: customConfigFetch);
40
- doFetch<dataType>(config: customConfigFetch): Promise<dataType>;
41
- private getUrlWithParams;
42
- get<dataType = any>(url: string, config?: customConfigFetch): Promise<dataType>;
43
- post<dataType = any>(url: string, data?: any, config?: customConfigFetch): Promise<dataType>;
44
- put<dataType = any>(url: string, data?: any, config?: customConfigFetch): Promise<dataType>;
45
- delete<dataType = any>(url: string, data?: any, config?: customConfigFetch): Promise<dataType>;
46
- addRequestInterceptor(onFulfilled: fulfilled<customConfigFetch>, onRejected?: rejected): void;
47
- addResponseInterceptor(onFulfilled: fulfilled<customResponse>, onRejected?: rejected): void;
48
- private getValue;
49
- handleRequest(config: customConfigFetch): Promise<customConfigFetch>;
50
- handleResponse(customResponse: customResponse): Promise<customResponse>;
51
- handleResponseError(e: CustomError): Promise<void>;
40
+ setAuthToken(): Promise<void>;
41
+ /**
42
+ * 모든 헤더를 비동기적으로 설정합니다.
43
+ */
44
+ setAllHeaders(): Promise<void>;
52
45
  }
46
+ declare const HeaderFunc: {
47
+ getHeader(name: string): Promise<string | null>;
48
+ setHeader(name: string, value: string): Promise<void>;
49
+ };
53
50
 
54
- declare class HttpClientFetch extends AbstractHttpClient<customConfigFetch, FetchInstance, CustomError> {
55
- protected errorHandler: null | ((e: CustomError) => void);
51
+ /**
52
+ * HTTP 요청에 대한 설정을 나타냅니다.
53
+ * 표준 `RequestInit` 타입의 하위 집합이며, `params`와 `data`가 추가되었습니다.
54
+ * body를 제거하고 axios와 유사한 형태로 data로 작성.
55
+ * json변환 자동화 및 개발편의성.
56
+ */
57
+ interface RequestConfig extends Omit<RequestInit, 'body'> {
58
+ url?: string;
59
+ params?: Record<string, any>;
60
+ data?: any;
61
+ }
62
+ /**
63
+ * HttpClient 인스턴스에 대한 설정입니다.
64
+ */
65
+ interface HttpClientConfig {
66
+ baseURL?: string;
67
+ headers?: Record<string, string>;
68
+ }
69
+ /**
70
+ * 선택적인 성공 및 실패 핸들러를 포함하는 인터셉터의 구조
71
+ */
72
+ interface Interceptor<V> {
73
+ onFulfilled?: (value: V) => V | Promise<V>;
74
+ onRejected?: (error: any) => any;
75
+ }
76
+
77
+ /**
78
+ * HTTP 오류를 위한 사용자 정의 오류
79
+ * 응답 객체를 포함
80
+ * @todo CustomeError > 다이렉트 에러 참고하여 수정 필요
81
+ */
82
+ declare class HttpError extends Error {
83
+ response: Response;
84
+ data: any;
85
+ constructor(response: Response, data: any);
86
+ }
87
+ /**
88
+ * Axios와 유사하게 인터셉터 컬렉션을 관리합니다.
89
+ */
90
+ declare class InterceptorManager<V> {
91
+ private handlers;
56
92
  /**
57
- * HttpClientFetch request interceptor 동작시, 헤더에 주입될 헤더의 key,value
93
+ * 체인에 인터셉터를 추가
94
+ * @param onFulfilled - 프로미스가 이행되었을 때 호출할 함수
95
+ * @param onRejected - 프로미스가 거부되었을 때 호출할 함수
96
+ * @returns 인터셉터의 ID이며, 나중에 제거하는 데 사용
58
97
  */
59
- protected headers: Record<string, string>;
98
+ use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
60
99
  /**
61
- * fetch 인스턴스 생성시 기본설정값 및 기타 필요한 정보들을 추가 가능
100
+ * ID를 사용하여 체인에서 인터셉터를 제거합니다.
101
+ * @param id - 제거할 인터셉터의 ID입니다.
62
102
  */
63
- protected config: customConfigFetch;
103
+ eject(id: number): void;
64
104
  /**
65
- * api연동을 수행할 실제 객체(axios, fetch 등의 다른 라이브러리로 교체가능한 영역)
66
- * 현재 버전에서는 axios를 사용하여 구현됨.
105
+ * 주어진 프로미스에 대해 인터셉터 체인을 실행합니다.
106
+ * @param promise - 체인을 시작할 초기 프로미스입니다.
107
+ * @returns 전체 체인이 실행된 후 확인되는 새 프로미스입니다.
67
108
  */
68
- api: FetchInstance;
69
- constructor(config?: customConfigFetch);
70
- put<dataType = any>(url: string, data?: any, config?: customConfigFetch): Promise<dataType>;
71
- get<dataType = any>(url: string, config?: customConfigFetch): Promise<dataType>;
72
- delete<dataType = any>(url: string, config?: customConfigFetch): Promise<dataType>;
73
- post<dataType = any>(url: string, data?: any, config?: customConfigFetch): Promise<dataType>;
74
- setHeader(key: string, value: string): void;
109
+ executeChain(promise: Promise<V>): Promise<V>;
75
110
  }
76
-
77
- type errorHandlerFethType = (response: CustomError, config: customConfigFetch) => void;
78
- declare abstract class ErrorHandlerFetch {
79
- protected localThrow?: errorHandlerFethType;
80
- /** 개별처리 + 글로벌처리 모두 사용할경우 : true , 개별처리만 사용할 경우 : false */
81
- protected globalCheck: boolean;
82
- constructor();
83
- setGlobalCheck(global: boolean): void;
84
- /**
85
- * 에러코드에 맞는 Error에러 객체를 throw 및 Sentry 리포팅 영역
86
- */
87
- private globalThrow;
88
- setLocalHandler(func: errorHandlerFethType): void;
89
- do(error: CustomError, config: customConfigFetch): void;
111
+ /**
112
+ * @description middleware.ts에서 사용하기 위한 용도로 작성
113
+ */
114
+ declare class FetchInstance {
115
+ private defaults;
116
+ interceptors: {
117
+ request: InterceptorManager<RequestConfig>;
118
+ response: InterceptorManager<Response>;
119
+ };
120
+ constructor(config?: HttpClientConfig);
90
121
  /**
91
- * 발생한 CustomError 설정값에 따른 에러 처리 추가영역
92
- * 상속한 server/client 에서 에러 핸들링
122
+ * 인터셉터를 적용하고 실제 fetch 호출을 수행
123
+ * @param config - 요청 설정
93
124
  */
94
- abstract errorHandler(e: CustomError): void;
125
+ request<T = any>(config: RequestConfig): Promise<{
126
+ data: T;
127
+ response: Response;
128
+ }>;
129
+ get<T = any>(url: string, config?: Omit<RequestConfig, 'method'>): Promise<{
130
+ data: T;
131
+ response: Response;
132
+ }>;
133
+ post<T = any>(url: string, data: any, config?: Omit<RequestConfig, 'method' | 'data'>): Promise<{
134
+ data: T;
135
+ response: Response;
136
+ }>;
137
+ put<T = any>(url: string, data: any, config?: Omit<RequestConfig, 'method' | 'data'>): Promise<{
138
+ data: T;
139
+ response: Response;
140
+ }>;
141
+ delete<T = any>(url: string, config?: Omit<RequestConfig, 'method'>): Promise<{
142
+ data: T;
143
+ response: Response;
144
+ }>;
95
145
  }
96
146
 
97
- declare class SsrHttpClientFetch extends HttpClientFetch {
98
- static query: string;
99
- private ssrErrorHandlerFetch;
100
- constructor(config?: customConfigFetch);
101
- setSsrErrorFetchHandler(ssrErrorHandlerFetch: ErrorHandlerFetch): void;
102
- /**
103
- * API 연동 실패시, 에러핸들러 셋팅 (특정페이지에서만 동작하는 개별 핸들러)
104
- * @param handler ssrErrorHandler
105
- */
106
- setLocalErrorHandler(handler: errorHandlerFethType): void;
147
+ /**
148
+ * @description middleware에서 사용하는 용도.
149
+ * 인증토큰 처리외에 용도는 없음.
150
+ */
151
+ declare class HttpClientFetch extends FetchInstance {
152
+ headerManager: HeaderManagerAsync;
153
+ headers: Record<string, string>;
154
+ constructor(config?: HttpClientConfig);
107
155
  }
108
156
 
109
- export { AuthServer, ErrorHandlerFetch, SsrHttpClientAxios, SsrHttpClientFetch, type errorHandlerFethType };
157
+ export { AuthServer, FetchInstance, GetterAsync, HeaderFunc, HeaderManagerAsync, type HttpClientConfig, HttpClientFetch, HttpError, type Interceptor, type RequestConfig, SetterAsync, cookieServer };