@pdg/api 1.0.9 → 1.0.11
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/@util/compare.d.ts +3 -3
- package/dist/@util/index.d.ts +2 -2
- package/dist/@util/url.d.ts +1 -1
- package/dist/Api/Api.d.ts +12 -12
- package/dist/Api/Api.types.d.ts +34 -34
- package/dist/Api/index.d.ts +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +180 -240
- package/dist/index.js +180 -240
- package/package.json +16 -16
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/@util/compare.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const empty: (v: any) => boolean;
|
|
2
|
-
declare const notEmpty: (v: any) => boolean;
|
|
3
|
-
export { empty, notEmpty };
|
|
1
|
+
declare const empty: (v: any) => boolean;
|
|
2
|
+
declare const notEmpty: (v: any) => boolean;
|
|
3
|
+
export { empty, notEmpty };
|
package/dist/@util/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './compare';
|
|
2
|
-
export * from './url';
|
|
1
|
+
export * from './compare';
|
|
2
|
+
export * from './url';
|
package/dist/@util/url.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function joinUrl(...
|
|
1
|
+
export declare function joinUrl(...parts: string[]): string;
|
package/dist/Api/Api.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Method } from 'axios';
|
|
2
|
-
import { ApiRequestData, ApiOption, ApiRequestOption } from './Api.types';
|
|
3
|
-
declare class Api<T = any> {
|
|
4
|
-
option: ApiOption;
|
|
5
|
-
constructor(option: ApiOption<T>);
|
|
6
|
-
get(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T>;
|
|
7
|
-
post(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T>;
|
|
8
|
-
patch(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T>;
|
|
9
|
-
delete(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T>;
|
|
10
|
-
run: (method: Method, path: string, data?: ApiRequestData, option?: ApiRequestOption) => Promise<T>;
|
|
11
|
-
}
|
|
12
|
-
export default Api;
|
|
1
|
+
import { Method } from 'axios';
|
|
2
|
+
import { ApiRequestData, ApiOption, ApiRequestOption } from './Api.types';
|
|
3
|
+
declare class Api<T = any> {
|
|
4
|
+
option: ApiOption;
|
|
5
|
+
constructor(option: ApiOption<T>);
|
|
6
|
+
get(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T>;
|
|
7
|
+
post(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T>;
|
|
8
|
+
patch(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T>;
|
|
9
|
+
delete(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T>;
|
|
10
|
+
run: (method: Method, path: string, data?: ApiRequestData, option?: ApiRequestOption) => Promise<T>;
|
|
11
|
+
}
|
|
12
|
+
export default Api;
|
package/dist/Api/Api.types.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig, ResponseType } from 'axios';
|
|
2
|
-
export interface ApiRequestData {
|
|
3
|
-
[key: string]: any;
|
|
4
|
-
}
|
|
5
|
-
export interface ApiRequestOption {
|
|
6
|
-
raw?: boolean;
|
|
7
|
-
rawResponseType?: ResponseType;
|
|
8
|
-
silent?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface ApiRequestConfig extends AxiosRequestConfig {
|
|
11
|
-
silent?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare class ApiError<T = any> extends Error {
|
|
14
|
-
code?: string;
|
|
15
|
-
config?: ApiRequestConfig;
|
|
16
|
-
baseUrl?: string;
|
|
17
|
-
path?: string;
|
|
18
|
-
requestData?: ApiRequestData;
|
|
19
|
-
requestOption?: ApiRequestOption;
|
|
20
|
-
response?: AxiosResponse<T>;
|
|
21
|
-
status?: number;
|
|
22
|
-
isAxiosError: boolean;
|
|
23
|
-
constructor(message?: string, code?: string);
|
|
24
|
-
}
|
|
25
|
-
export interface ApiOption<T = any> {
|
|
26
|
-
baseUrl: string;
|
|
27
|
-
timeParamName: string;
|
|
28
|
-
withCredentials?: boolean;
|
|
29
|
-
headers?: AxiosRequestConfig['headers'];
|
|
30
|
-
onRequest?(config: InternalAxiosRequestConfig, baseUrl: string, path: string, requestData?: ApiRequestData, requestOption?: ApiRequestOption): Promise<InternalAxiosRequestConfig>;
|
|
31
|
-
onResponse?(response: AxiosResponse<T>, config: AxiosRequestConfig, baseUrl: string, path: string, requestData?: ApiRequestData, requestOption?: ApiRequestOption): Promise<T>;
|
|
32
|
-
onError?(err: ApiError): void;
|
|
33
|
-
dataKeysToLowerCase?: boolean;
|
|
34
|
-
}
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig, ResponseType } from 'axios';
|
|
2
|
+
export interface ApiRequestData {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export interface ApiRequestOption {
|
|
6
|
+
raw?: boolean;
|
|
7
|
+
rawResponseType?: ResponseType;
|
|
8
|
+
silent?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ApiRequestConfig extends AxiosRequestConfig {
|
|
11
|
+
silent?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class ApiError<T = any> extends Error {
|
|
14
|
+
code?: string;
|
|
15
|
+
config?: ApiRequestConfig;
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
path?: string;
|
|
18
|
+
requestData?: ApiRequestData;
|
|
19
|
+
requestOption?: ApiRequestOption;
|
|
20
|
+
response?: AxiosResponse<T>;
|
|
21
|
+
status?: number;
|
|
22
|
+
isAxiosError: boolean;
|
|
23
|
+
constructor(message?: string, code?: string);
|
|
24
|
+
}
|
|
25
|
+
export interface ApiOption<T = any> {
|
|
26
|
+
baseUrl: string;
|
|
27
|
+
timeParamName: string;
|
|
28
|
+
withCredentials?: boolean;
|
|
29
|
+
headers?: AxiosRequestConfig['headers'];
|
|
30
|
+
onRequest?(config: InternalAxiosRequestConfig, baseUrl: string, path: string, requestData?: ApiRequestData, requestOption?: ApiRequestOption): Promise<InternalAxiosRequestConfig>;
|
|
31
|
+
onResponse?(response: AxiosResponse<T>, config: AxiosRequestConfig, baseUrl: string, path: string, requestData?: ApiRequestData, requestOption?: ApiRequestOption): Promise<T>;
|
|
32
|
+
onError?(err: ApiError): void;
|
|
33
|
+
dataKeysToLowerCase?: boolean;
|
|
34
|
+
}
|
package/dist/Api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Api from './Api';
|
|
2
|
-
export default Api;
|
|
3
|
-
export { Api };
|
|
4
|
-
export * from './Api.types';
|
|
1
|
+
import Api from './Api';
|
|
2
|
+
export default Api;
|
|
3
|
+
export { Api };
|
|
4
|
+
export * from './Api.types';
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Api';
|
|
1
|
+
export * from './Api';
|
package/dist/index.esm.js
CHANGED
|
@@ -81,246 +81,186 @@ function __generator(thisArg, body) {
|
|
|
81
81
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
82
82
|
var e = new Error(message);
|
|
83
83
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
84
|
-
};//--------------------------------------------------------------------------------------------------------------------
|
|
85
|
-
var ApiError = /** @class */ (function (_super) {
|
|
86
|
-
__extends(ApiError, _super);
|
|
87
|
-
function ApiError(message, code) {
|
|
88
|
-
var _this = _super.call(this, message) || this;
|
|
89
|
-
_this.isAxiosError = false;
|
|
90
|
-
_this.code = code;
|
|
91
|
-
return _this;
|
|
92
|
-
}
|
|
93
|
-
return ApiError;
|
|
94
|
-
}(Error));var empty = function (v) {
|
|
95
|
-
var result = false;
|
|
96
|
-
if (v == null) {
|
|
97
|
-
result = true;
|
|
98
|
-
}
|
|
99
|
-
else if (typeof v === 'string') {
|
|
100
|
-
result = v === '';
|
|
101
|
-
}
|
|
102
|
-
else if (typeof v === 'object') {
|
|
103
|
-
if (Array.isArray(v)) {
|
|
104
|
-
result = v.length === 0;
|
|
105
|
-
}
|
|
106
|
-
else if (!(v instanceof Date)) {
|
|
107
|
-
result = Object.entries(v).length === 0;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
};
|
|
112
|
-
var notEmpty = function (v) {
|
|
113
|
-
return !empty(v);
|
|
114
|
-
};function normalize (strArray) {
|
|
115
|
-
var resultArray = [];
|
|
116
|
-
if (strArray.length === 0) { return ''; }
|
|
117
|
-
|
|
118
|
-
if (typeof strArray[0] !== 'string') {
|
|
119
|
-
throw new TypeError('Url must be a string. Received ' + strArray[0]);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// If the first part is a plain protocol, we combine it with the next part.
|
|
123
|
-
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
|
|
124
|
-
var first = strArray.shift();
|
|
125
|
-
strArray[0] = first + strArray[0];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// There must be two or three slashes in the file protocol, two slashes in anything else.
|
|
129
|
-
if (strArray[0].match(/^file:\/\/\//)) {
|
|
130
|
-
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///');
|
|
131
|
-
} else {
|
|
132
|
-
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
for (var i = 0; i < strArray.length; i++) {
|
|
136
|
-
var component = strArray[i];
|
|
137
|
-
|
|
138
|
-
if (typeof component !== 'string') {
|
|
139
|
-
throw new TypeError('Url must be a string. Received ' + component);
|
|
84
|
+
};//--------------------------------------------------------------------------------------------------------------------
|
|
85
|
+
var ApiError = /** @class */ (function (_super) {
|
|
86
|
+
__extends(ApiError, _super);
|
|
87
|
+
function ApiError(message, code) {
|
|
88
|
+
var _this = _super.call(this, message) || this;
|
|
89
|
+
_this.isAxiosError = false;
|
|
90
|
+
_this.code = code;
|
|
91
|
+
return _this;
|
|
140
92
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
component = component.replace(/^[\/]+/, '');
|
|
93
|
+
return ApiError;
|
|
94
|
+
}(Error));var empty = function (v) {
|
|
95
|
+
var result = false;
|
|
96
|
+
if (v == null) {
|
|
97
|
+
result = true;
|
|
147
98
|
}
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
component = component.replace(/[\/]+$/, '');
|
|
151
|
-
} else {
|
|
152
|
-
// For the last component we will combine multiple slashes to a single one.
|
|
153
|
-
component = component.replace(/[\/]+$/, '/');
|
|
99
|
+
else if (typeof v === 'string') {
|
|
100
|
+
result = v === '';
|
|
154
101
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
err
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
apiError.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return this.run('patch', path, data, option);
|
|
321
|
-
};
|
|
322
|
-
Api.prototype.delete = function (path, data, option) {
|
|
323
|
-
return this.run('delete', path, data, option);
|
|
324
|
-
};
|
|
325
|
-
return Api;
|
|
326
|
-
}());export{Api,ApiError};//# sourceMappingURL=index.esm.js.map
|
|
102
|
+
else if (typeof v === 'object') {
|
|
103
|
+
if (Array.isArray(v)) {
|
|
104
|
+
result = v.length === 0;
|
|
105
|
+
}
|
|
106
|
+
else if (!(v instanceof Date)) {
|
|
107
|
+
result = Object.entries(v).length === 0;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
};
|
|
112
|
+
var notEmpty = function (v) {
|
|
113
|
+
return !empty(v);
|
|
114
|
+
};function joinUrl() {
|
|
115
|
+
var parts = [];
|
|
116
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
117
|
+
parts[_i] = arguments[_i];
|
|
118
|
+
}
|
|
119
|
+
return parts.reduce(function (acc, part) {
|
|
120
|
+
if (acc === '') {
|
|
121
|
+
return part;
|
|
122
|
+
}
|
|
123
|
+
else if (part.startsWith('?')) {
|
|
124
|
+
return "".concat(acc).concat(part);
|
|
125
|
+
}
|
|
126
|
+
else if (acc.endsWith('/')) {
|
|
127
|
+
return "".concat(acc).concat(part.startsWith('/') ? part.substring(1) : part);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return "".concat(acc).concat(part.startsWith('/') ? part : "/".concat(part));
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}var _a;
|
|
134
|
+
var AxiosCreate = axios.create ? axios.create : (_a = require('axios').default) === null || _a === void 0 ? void 0 : _a.create;
|
|
135
|
+
var Api = /** @class */ (function () {
|
|
136
|
+
// constructor -------------------------------------------------------------------------------------------------------
|
|
137
|
+
function Api(option) {
|
|
138
|
+
var _this = this;
|
|
139
|
+
// Run ---------------------------------------------------------------------------------------------------------------
|
|
140
|
+
this.run = function (method, path, data, option) {
|
|
141
|
+
return new Promise(function (resolve, reject) {
|
|
142
|
+
var _a;
|
|
143
|
+
var headers = __assign({}, _this.option.headers);
|
|
144
|
+
if (typeof window !== 'undefined') {
|
|
145
|
+
if ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href) {
|
|
146
|
+
headers['X-Referer'] = window.location.href;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
var requestConfig = {
|
|
150
|
+
method: method,
|
|
151
|
+
withCredentials: _this.option.withCredentials,
|
|
152
|
+
headers: headers,
|
|
153
|
+
silent: !!(option === null || option === void 0 ? void 0 : option.silent),
|
|
154
|
+
};
|
|
155
|
+
if (option === null || option === void 0 ? void 0 : option.raw) {
|
|
156
|
+
requestConfig.responseType = (option === null || option === void 0 ? void 0 : option.rawResponseType) || 'arraybuffer';
|
|
157
|
+
}
|
|
158
|
+
requestConfig.url = joinUrl(_this.option.baseUrl, path.replace(/\./g, '/'));
|
|
159
|
+
if (data) {
|
|
160
|
+
if (method === 'get') {
|
|
161
|
+
if (notEmpty(data)) {
|
|
162
|
+
var finalData = {};
|
|
163
|
+
finalData[_this.option.timeParamName] = new Date().getTime();
|
|
164
|
+
for (var key in data) {
|
|
165
|
+
if (data[key] != null) {
|
|
166
|
+
finalData[key] = data[key];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
requestConfig.url += "?".concat(new URLSearchParams(finalData).toString());
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
if (data instanceof FormData) {
|
|
174
|
+
data.append(_this.option.timeParamName, "".concat(new Date().getTime()));
|
|
175
|
+
requestConfig.data = data;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
var finalData = __assign({}, data);
|
|
179
|
+
finalData[_this.option.timeParamName] = new Date().getTime();
|
|
180
|
+
requestConfig.data = finalData;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
var setErrorInfo = function (err, status, response) {
|
|
185
|
+
err.config = requestConfig;
|
|
186
|
+
err.baseUrl = _this.option.baseUrl;
|
|
187
|
+
err.path = path;
|
|
188
|
+
err.requestData = data;
|
|
189
|
+
err.requestOption = option;
|
|
190
|
+
err.response = response;
|
|
191
|
+
err.status = status;
|
|
192
|
+
};
|
|
193
|
+
var fireError = function (err) {
|
|
194
|
+
var apiError = new ApiError();
|
|
195
|
+
if (typeof err === 'object') {
|
|
196
|
+
apiError.message = err.message;
|
|
197
|
+
apiError.code = err.code;
|
|
198
|
+
setErrorInfo(apiError, err.status, err.response);
|
|
199
|
+
}
|
|
200
|
+
else if (typeof err === 'string') {
|
|
201
|
+
apiError.message = err;
|
|
202
|
+
}
|
|
203
|
+
else if (err) {
|
|
204
|
+
apiError.message = err.toString();
|
|
205
|
+
}
|
|
206
|
+
if (_this.option.onError)
|
|
207
|
+
_this.option.onError(apiError);
|
|
208
|
+
reject(apiError);
|
|
209
|
+
};
|
|
210
|
+
var instance = AxiosCreate();
|
|
211
|
+
var requestInterceptor;
|
|
212
|
+
if (_this.option.onRequest) {
|
|
213
|
+
requestInterceptor = instance.interceptors.request.use(function (config) { return __awaiter(_this, void 0, void 0, function () {
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
if (this.option.onRequest) {
|
|
216
|
+
return [2 /*return*/, this.option.onRequest(config, this.option.baseUrl, path, data, option)];
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return [2 /*return*/, config];
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}); });
|
|
223
|
+
}
|
|
224
|
+
instance
|
|
225
|
+
.request(requestConfig)
|
|
226
|
+
.then(function (res) {
|
|
227
|
+
var resData = res.data;
|
|
228
|
+
if (_this.option.onResponse) {
|
|
229
|
+
_this.option
|
|
230
|
+
.onResponse(res, requestConfig, _this.option.baseUrl, path, data, option)
|
|
231
|
+
.then(function (finalResData) {
|
|
232
|
+
resolve(finalResData);
|
|
233
|
+
})
|
|
234
|
+
.catch(function (err) {
|
|
235
|
+
setErrorInfo(err, res.status, res);
|
|
236
|
+
fireError(err);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
resolve(resData);
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
.catch(fireError)
|
|
244
|
+
.finally(function () {
|
|
245
|
+
if (requestInterceptor) {
|
|
246
|
+
instance.interceptors.request.eject(requestInterceptor);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
this.option = option;
|
|
252
|
+
}
|
|
253
|
+
Api.prototype.get = function (path, data, option) {
|
|
254
|
+
return this.run('get', path, data, option);
|
|
255
|
+
};
|
|
256
|
+
Api.prototype.post = function (path, data, option) {
|
|
257
|
+
return this.run('post', path, data, option);
|
|
258
|
+
};
|
|
259
|
+
Api.prototype.patch = function (path, data, option) {
|
|
260
|
+
return this.run('patch', path, data, option);
|
|
261
|
+
};
|
|
262
|
+
Api.prototype.delete = function (path, data, option) {
|
|
263
|
+
return this.run('delete', path, data, option);
|
|
264
|
+
};
|
|
265
|
+
return Api;
|
|
266
|
+
}());export{Api,ApiError};
|
package/dist/index.js
CHANGED
|
@@ -81,246 +81,186 @@ function __generator(thisArg, body) {
|
|
|
81
81
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
82
82
|
var e = new Error(message);
|
|
83
83
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
84
|
-
};//--------------------------------------------------------------------------------------------------------------------
|
|
85
|
-
var ApiError = /** @class */ (function (_super) {
|
|
86
|
-
__extends(ApiError, _super);
|
|
87
|
-
function ApiError(message, code) {
|
|
88
|
-
var _this = _super.call(this, message) || this;
|
|
89
|
-
_this.isAxiosError = false;
|
|
90
|
-
_this.code = code;
|
|
91
|
-
return _this;
|
|
92
|
-
}
|
|
93
|
-
return ApiError;
|
|
94
|
-
}(Error));var empty = function (v) {
|
|
95
|
-
var result = false;
|
|
96
|
-
if (v == null) {
|
|
97
|
-
result = true;
|
|
98
|
-
}
|
|
99
|
-
else if (typeof v === 'string') {
|
|
100
|
-
result = v === '';
|
|
101
|
-
}
|
|
102
|
-
else if (typeof v === 'object') {
|
|
103
|
-
if (Array.isArray(v)) {
|
|
104
|
-
result = v.length === 0;
|
|
105
|
-
}
|
|
106
|
-
else if (!(v instanceof Date)) {
|
|
107
|
-
result = Object.entries(v).length === 0;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
};
|
|
112
|
-
var notEmpty = function (v) {
|
|
113
|
-
return !empty(v);
|
|
114
|
-
};function normalize (strArray) {
|
|
115
|
-
var resultArray = [];
|
|
116
|
-
if (strArray.length === 0) { return ''; }
|
|
117
|
-
|
|
118
|
-
if (typeof strArray[0] !== 'string') {
|
|
119
|
-
throw new TypeError('Url must be a string. Received ' + strArray[0]);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// If the first part is a plain protocol, we combine it with the next part.
|
|
123
|
-
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
|
|
124
|
-
var first = strArray.shift();
|
|
125
|
-
strArray[0] = first + strArray[0];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// There must be two or three slashes in the file protocol, two slashes in anything else.
|
|
129
|
-
if (strArray[0].match(/^file:\/\/\//)) {
|
|
130
|
-
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///');
|
|
131
|
-
} else {
|
|
132
|
-
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
for (var i = 0; i < strArray.length; i++) {
|
|
136
|
-
var component = strArray[i];
|
|
137
|
-
|
|
138
|
-
if (typeof component !== 'string') {
|
|
139
|
-
throw new TypeError('Url must be a string. Received ' + component);
|
|
84
|
+
};//--------------------------------------------------------------------------------------------------------------------
|
|
85
|
+
var ApiError = /** @class */ (function (_super) {
|
|
86
|
+
__extends(ApiError, _super);
|
|
87
|
+
function ApiError(message, code) {
|
|
88
|
+
var _this = _super.call(this, message) || this;
|
|
89
|
+
_this.isAxiosError = false;
|
|
90
|
+
_this.code = code;
|
|
91
|
+
return _this;
|
|
140
92
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
component = component.replace(/^[\/]+/, '');
|
|
93
|
+
return ApiError;
|
|
94
|
+
}(Error));var empty = function (v) {
|
|
95
|
+
var result = false;
|
|
96
|
+
if (v == null) {
|
|
97
|
+
result = true;
|
|
147
98
|
}
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
component = component.replace(/[\/]+$/, '');
|
|
151
|
-
} else {
|
|
152
|
-
// For the last component we will combine multiple slashes to a single one.
|
|
153
|
-
component = component.replace(/[\/]+$/, '/');
|
|
99
|
+
else if (typeof v === 'string') {
|
|
100
|
+
result = v === '';
|
|
154
101
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
err
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
apiError.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return this.run('patch', path, data, option);
|
|
321
|
-
};
|
|
322
|
-
Api.prototype.delete = function (path, data, option) {
|
|
323
|
-
return this.run('delete', path, data, option);
|
|
324
|
-
};
|
|
325
|
-
return Api;
|
|
326
|
-
}());exports.Api=Api;exports.ApiError=ApiError;//# sourceMappingURL=index.js.map
|
|
102
|
+
else if (typeof v === 'object') {
|
|
103
|
+
if (Array.isArray(v)) {
|
|
104
|
+
result = v.length === 0;
|
|
105
|
+
}
|
|
106
|
+
else if (!(v instanceof Date)) {
|
|
107
|
+
result = Object.entries(v).length === 0;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
};
|
|
112
|
+
var notEmpty = function (v) {
|
|
113
|
+
return !empty(v);
|
|
114
|
+
};function joinUrl() {
|
|
115
|
+
var parts = [];
|
|
116
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
117
|
+
parts[_i] = arguments[_i];
|
|
118
|
+
}
|
|
119
|
+
return parts.reduce(function (acc, part) {
|
|
120
|
+
if (acc === '') {
|
|
121
|
+
return part;
|
|
122
|
+
}
|
|
123
|
+
else if (part.startsWith('?')) {
|
|
124
|
+
return "".concat(acc).concat(part);
|
|
125
|
+
}
|
|
126
|
+
else if (acc.endsWith('/')) {
|
|
127
|
+
return "".concat(acc).concat(part.startsWith('/') ? part.substring(1) : part);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return "".concat(acc).concat(part.startsWith('/') ? part : "/".concat(part));
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}var _a;
|
|
134
|
+
var AxiosCreate = axios.create ? axios.create : (_a = require('axios').default) === null || _a === void 0 ? void 0 : _a.create;
|
|
135
|
+
var Api = /** @class */ (function () {
|
|
136
|
+
// constructor -------------------------------------------------------------------------------------------------------
|
|
137
|
+
function Api(option) {
|
|
138
|
+
var _this = this;
|
|
139
|
+
// Run ---------------------------------------------------------------------------------------------------------------
|
|
140
|
+
this.run = function (method, path, data, option) {
|
|
141
|
+
return new Promise(function (resolve, reject) {
|
|
142
|
+
var _a;
|
|
143
|
+
var headers = __assign({}, _this.option.headers);
|
|
144
|
+
if (typeof window !== 'undefined') {
|
|
145
|
+
if ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href) {
|
|
146
|
+
headers['X-Referer'] = window.location.href;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
var requestConfig = {
|
|
150
|
+
method: method,
|
|
151
|
+
withCredentials: _this.option.withCredentials,
|
|
152
|
+
headers: headers,
|
|
153
|
+
silent: !!(option === null || option === void 0 ? void 0 : option.silent),
|
|
154
|
+
};
|
|
155
|
+
if (option === null || option === void 0 ? void 0 : option.raw) {
|
|
156
|
+
requestConfig.responseType = (option === null || option === void 0 ? void 0 : option.rawResponseType) || 'arraybuffer';
|
|
157
|
+
}
|
|
158
|
+
requestConfig.url = joinUrl(_this.option.baseUrl, path.replace(/\./g, '/'));
|
|
159
|
+
if (data) {
|
|
160
|
+
if (method === 'get') {
|
|
161
|
+
if (notEmpty(data)) {
|
|
162
|
+
var finalData = {};
|
|
163
|
+
finalData[_this.option.timeParamName] = new Date().getTime();
|
|
164
|
+
for (var key in data) {
|
|
165
|
+
if (data[key] != null) {
|
|
166
|
+
finalData[key] = data[key];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
requestConfig.url += "?".concat(new URLSearchParams(finalData).toString());
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
if (data instanceof FormData) {
|
|
174
|
+
data.append(_this.option.timeParamName, "".concat(new Date().getTime()));
|
|
175
|
+
requestConfig.data = data;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
var finalData = __assign({}, data);
|
|
179
|
+
finalData[_this.option.timeParamName] = new Date().getTime();
|
|
180
|
+
requestConfig.data = finalData;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
var setErrorInfo = function (err, status, response) {
|
|
185
|
+
err.config = requestConfig;
|
|
186
|
+
err.baseUrl = _this.option.baseUrl;
|
|
187
|
+
err.path = path;
|
|
188
|
+
err.requestData = data;
|
|
189
|
+
err.requestOption = option;
|
|
190
|
+
err.response = response;
|
|
191
|
+
err.status = status;
|
|
192
|
+
};
|
|
193
|
+
var fireError = function (err) {
|
|
194
|
+
var apiError = new ApiError();
|
|
195
|
+
if (typeof err === 'object') {
|
|
196
|
+
apiError.message = err.message;
|
|
197
|
+
apiError.code = err.code;
|
|
198
|
+
setErrorInfo(apiError, err.status, err.response);
|
|
199
|
+
}
|
|
200
|
+
else if (typeof err === 'string') {
|
|
201
|
+
apiError.message = err;
|
|
202
|
+
}
|
|
203
|
+
else if (err) {
|
|
204
|
+
apiError.message = err.toString();
|
|
205
|
+
}
|
|
206
|
+
if (_this.option.onError)
|
|
207
|
+
_this.option.onError(apiError);
|
|
208
|
+
reject(apiError);
|
|
209
|
+
};
|
|
210
|
+
var instance = AxiosCreate();
|
|
211
|
+
var requestInterceptor;
|
|
212
|
+
if (_this.option.onRequest) {
|
|
213
|
+
requestInterceptor = instance.interceptors.request.use(function (config) { return __awaiter(_this, void 0, void 0, function () {
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
if (this.option.onRequest) {
|
|
216
|
+
return [2 /*return*/, this.option.onRequest(config, this.option.baseUrl, path, data, option)];
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return [2 /*return*/, config];
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}); });
|
|
223
|
+
}
|
|
224
|
+
instance
|
|
225
|
+
.request(requestConfig)
|
|
226
|
+
.then(function (res) {
|
|
227
|
+
var resData = res.data;
|
|
228
|
+
if (_this.option.onResponse) {
|
|
229
|
+
_this.option
|
|
230
|
+
.onResponse(res, requestConfig, _this.option.baseUrl, path, data, option)
|
|
231
|
+
.then(function (finalResData) {
|
|
232
|
+
resolve(finalResData);
|
|
233
|
+
})
|
|
234
|
+
.catch(function (err) {
|
|
235
|
+
setErrorInfo(err, res.status, res);
|
|
236
|
+
fireError(err);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
resolve(resData);
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
.catch(fireError)
|
|
244
|
+
.finally(function () {
|
|
245
|
+
if (requestInterceptor) {
|
|
246
|
+
instance.interceptors.request.eject(requestInterceptor);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
this.option = option;
|
|
252
|
+
}
|
|
253
|
+
Api.prototype.get = function (path, data, option) {
|
|
254
|
+
return this.run('get', path, data, option);
|
|
255
|
+
};
|
|
256
|
+
Api.prototype.post = function (path, data, option) {
|
|
257
|
+
return this.run('post', path, data, option);
|
|
258
|
+
};
|
|
259
|
+
Api.prototype.patch = function (path, data, option) {
|
|
260
|
+
return this.run('patch', path, data, option);
|
|
261
|
+
};
|
|
262
|
+
Api.prototype.delete = function (path, data, option) {
|
|
263
|
+
return this.run('delete', path, data, option);
|
|
264
|
+
};
|
|
265
|
+
return Api;
|
|
266
|
+
}());exports.Api=Api;exports.ApiError=ApiError;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdg/api",
|
|
3
3
|
"title": "API Module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.11",
|
|
5
5
|
"description": "API Module",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"test:get": "cd examples && npm run test:get",
|
|
25
25
|
"build": "rollup -c --bundleConfigAsCjs",
|
|
26
26
|
"publish": "npm publish --access=public",
|
|
27
|
-
"lint": "eslint './src/**/*.ts'"
|
|
27
|
+
"lint": "eslint './src/**/*.ts'",
|
|
28
|
+
"reinstall-module": "rm -rf node_modules && rm -f package-lock.json && npm i"
|
|
28
29
|
},
|
|
29
30
|
"author": "YOUNG CHUL PARK",
|
|
30
31
|
"license": "MIT",
|
|
@@ -38,22 +39,21 @@
|
|
|
38
39
|
"axios": "^1.0.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
42
|
-
"@rollup/plugin-eslint": "^9.0.
|
|
43
|
-
"@rollup/plugin-node-resolve": "^15.2.
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
45
|
-
"@typescript-eslint/parser": "^
|
|
46
|
-
"eslint": "8.
|
|
47
|
-
"eslint-config-prettier": "^9.
|
|
48
|
-
"eslint-plugin-jsx-a11y": "^6.
|
|
49
|
-
"eslint-plugin-prettier": "^5.
|
|
50
|
-
"prettier": "^3.
|
|
51
|
-
"rollup": "^
|
|
42
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
43
|
+
"@rollup/plugin-eslint": "^9.0.5",
|
|
44
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
46
|
+
"@typescript-eslint/parser": "^7.2.0",
|
|
47
|
+
"eslint": "8.57.0",
|
|
48
|
+
"eslint-config-prettier": "^9.1.0",
|
|
49
|
+
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
50
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
51
|
+
"prettier": "^3.2.5",
|
|
52
|
+
"rollup": "^4.13.0",
|
|
52
53
|
"rollup-plugin-delete": "^2.0.0",
|
|
53
54
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
54
55
|
"rollup-plugin-postcss": "^4.0.2",
|
|
55
|
-
"rollup-plugin-typescript2": "^0.
|
|
56
|
-
"typescript": "^4.
|
|
57
|
-
"url-join": "^5.0.0"
|
|
56
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
57
|
+
"typescript": "^5.4.2"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/dist/index.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/Api/Api.types.ts","../src/@util/compare.ts","../node_modules/url-join/lib/url-join.js","../src/@util/url.ts","../src/Api/Api.ts"],"sourcesContent":["import { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig, ResponseType } from 'axios';\n\nexport interface ApiRequestData {\n [key: string]: any;\n}\n\nexport interface ApiRequestOption {\n raw?: boolean;\n rawResponseType?: ResponseType;\n silent?: boolean;\n}\n\nexport interface ApiRequestConfig extends AxiosRequestConfig {\n silent?: boolean;\n}\n\n//--------------------------------------------------------------------------------------------------------------------\n\nexport class ApiError<T = any> extends Error {\n code?: string;\n config?: ApiRequestConfig;\n baseUrl?: string;\n path?: string;\n requestData?: ApiRequestData;\n requestOption?: ApiRequestOption;\n response?: AxiosResponse<T>;\n status?: number;\n isAxiosError = false;\n\n constructor(message?: string, code?: string) {\n super(message);\n\n this.code = code;\n }\n}\n\n//--------------------------------------------------------------------------------------------------------------------\n\nexport interface ApiOption<T = any> {\n baseUrl: string;\n timeParamName: string;\n withCredentials?: boolean;\n headers?: AxiosRequestConfig['headers'];\n onRequest?(\n config: InternalAxiosRequestConfig,\n baseUrl: string,\n path: string,\n requestData?: ApiRequestData,\n requestOption?: ApiRequestOption\n ): Promise<InternalAxiosRequestConfig>;\n onResponse?(\n response: AxiosResponse<T>,\n config: AxiosRequestConfig,\n baseUrl: string,\n path: string,\n requestData?: ApiRequestData,\n requestOption?: ApiRequestOption\n ): Promise<T>;\n onError?(err: ApiError): void;\n dataKeysToLowerCase?: boolean;\n}\n","const empty = function (v: any) {\n let result = false;\n if (v == null) {\n result = true;\n } else if (typeof v === 'string') {\n result = v === '';\n } else if (typeof v === 'object') {\n if (Array.isArray(v)) {\n result = v.length === 0;\n } else if (!(v instanceof Date)) {\n result = Object.entries(v).length === 0;\n }\n }\n return result;\n};\n\nconst notEmpty = function (v: any) {\n return !empty(v);\n};\n\nexport { empty, notEmpty };\n","function normalize (strArray) {\n var resultArray = [];\n if (strArray.length === 0) { return ''; }\n\n if (typeof strArray[0] !== 'string') {\n throw new TypeError('Url must be a string. Received ' + strArray[0]);\n }\n\n // If the first part is a plain protocol, we combine it with the next part.\n if (strArray[0].match(/^[^/:]+:\\/*$/) && strArray.length > 1) {\n var first = strArray.shift();\n strArray[0] = first + strArray[0];\n }\n\n // There must be two or three slashes in the file protocol, two slashes in anything else.\n if (strArray[0].match(/^file:\\/\\/\\//)) {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, '$1:///');\n } else {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, '$1://');\n }\n\n for (var i = 0; i < strArray.length; i++) {\n var component = strArray[i];\n\n if (typeof component !== 'string') {\n throw new TypeError('Url must be a string. Received ' + component);\n }\n\n if (component === '') { continue; }\n\n if (i > 0) {\n // Removing the starting slashes for each component but the first.\n component = component.replace(/^[\\/]+/, '');\n }\n if (i < strArray.length - 1) {\n // Removing the ending slashes for each component but the last.\n component = component.replace(/[\\/]+$/, '');\n } else {\n // For the last component we will combine multiple slashes to a single one.\n component = component.replace(/[\\/]+$/, '/');\n }\n\n resultArray.push(component);\n\n }\n\n var str = resultArray.join('/');\n // Each input component is now separated by a single slash except the possible first plain protocol part.\n\n // remove trailing slash before parameters or hash\n str = str.replace(/\\/(\\?|&|#[^!])/g, '$1');\n\n // replace ? in parameters with &\n var parts = str.split('?');\n str = parts.shift() + (parts.length > 0 ? '?': '') + parts.join('&');\n\n return str;\n}\n\nexport default function urlJoin() {\n var input;\n\n if (typeof arguments[0] === 'object') {\n input = arguments[0];\n } else {\n input = [].slice.call(arguments);\n }\n\n return normalize(input);\n}\n","import urlJoin from 'url-join';\n\nexport function joinUrl(...paths: string[]): string {\n let url = urlJoin(...paths);\n while (url.indexOf('//') > -1) {\n url = url.replace(/\\/\\//g, '/');\n }\n return url;\n}\n","import axios, { AxiosInstance, AxiosResponse, InternalAxiosRequestConfig, Method } from 'axios';\nimport { ApiError, ApiRequestData, ApiOption, ApiRequestOption, ApiRequestConfig } from './Api.types';\nimport { notEmpty, joinUrl } from '../@util';\n\nconst AxiosCreate = axios.create ? axios.create : require('axios').default?.create;\n\nclass Api<T = any> {\n option: ApiOption;\n\n // constructor -------------------------------------------------------------------------------------------------------\n\n constructor(option: ApiOption<T>) {\n this.option = option;\n }\n\n get(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T> {\n return this.run('get', path, data, option);\n }\n\n post(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T> {\n return this.run('post', path, data, option);\n }\n\n patch(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T> {\n return this.run('patch', path, data, option);\n }\n\n delete(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T> {\n return this.run('delete', path, data, option);\n }\n\n // Run ---------------------------------------------------------------------------------------------------------------\n\n run = (method: Method, path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T> => {\n return new Promise<T>((resolve, reject) => {\n const headers: ApiRequestConfig['headers'] = { ...this.option.headers };\n\n if (typeof window !== 'undefined') {\n if (window?.location?.href) {\n headers['X-Referer'] = window.location.href;\n }\n }\n\n const requestConfig: ApiRequestConfig = {\n method,\n withCredentials: this.option.withCredentials,\n headers,\n silent: !!option?.silent,\n };\n if (option?.raw) {\n requestConfig.responseType = option?.rawResponseType || 'arraybuffer';\n }\n\n requestConfig.url = joinUrl(this.option.baseUrl, path.replace(/\\./g, '/'));\n\n if (data) {\n if (method === 'get') {\n if (notEmpty(data)) {\n const finalData: ApiRequestData = {};\n finalData[this.option.timeParamName] = new Date().getTime();\n for (const key in data) {\n if (data[key] != null) {\n finalData[key] = data[key];\n }\n }\n requestConfig.url += `?${new URLSearchParams(finalData).toString()}`;\n }\n } else {\n if (data instanceof FormData) {\n data.append(this.option.timeParamName, `${new Date().getTime()}`);\n requestConfig.data = data;\n } else {\n const finalData: ApiRequestData = { ...data };\n finalData[this.option.timeParamName] = new Date().getTime();\n requestConfig.data = finalData;\n }\n }\n }\n\n const setErrorInfo = (err: ApiError, status?: number, response?: AxiosResponse) => {\n err.config = requestConfig;\n err.baseUrl = this.option.baseUrl;\n err.path = path;\n err.requestData = data;\n err.requestOption = option;\n err.response = response;\n err.status = status;\n };\n\n const fireError = (err: any): void => {\n const apiError: ApiError = new ApiError();\n\n if (typeof err === 'object') {\n apiError.message = err.message;\n apiError.code = err.code;\n setErrorInfo(apiError, err.status, err.response);\n } else if (typeof err === 'string') {\n apiError.message = err;\n } else if (err) {\n apiError.message = err.toString();\n }\n\n if (this.option.onError) this.option.onError(apiError);\n\n reject(apiError);\n };\n\n const instance: AxiosInstance = AxiosCreate();\n let requestInterceptor: number;\n if (this.option.onRequest) {\n requestInterceptor = instance.interceptors.request.use(async (config: InternalAxiosRequestConfig) => {\n if (this.option.onRequest) {\n return this.option.onRequest(config, this.option.baseUrl, path, data, option);\n } else {\n return config;\n }\n });\n }\n\n instance\n .request<T>(requestConfig)\n .then((res) => {\n const { data: resData } = res;\n if (this.option.onResponse) {\n this.option\n .onResponse(res, requestConfig, this.option.baseUrl, path, data, option)\n .then((finalResData) => {\n resolve(finalResData);\n })\n .catch((err: ApiError) => {\n setErrorInfo(err, res.status, res);\n fireError(err);\n });\n } else {\n resolve(resData);\n }\n })\n .catch(fireError)\n .finally(() => {\n if (requestInterceptor) {\n instance.interceptors.request.eject(requestInterceptor);\n }\n });\n });\n };\n}\n\nexport default Api;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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tB,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;AACzD,qBAAA;AACH,iBAAC,CAAC,CAAC;AACP,aAAC,CAAC,CAAC;AACL,SAAC,CAAC;AApIA,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;KACtB;AAED,IAAA,GAAA,CAAA,SAAA,CAAA,GAAG,GAAH,UAAI,IAAY,EAAE,IAAqB,EAAE,MAAyB,EAAA;AAChE,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;KAC5C,CAAA;AAED,IAAA,GAAA,CAAA,SAAA,CAAA,IAAI,GAAJ,UAAK,IAAY,EAAE,IAAqB,EAAE,MAAyB,EAAA;AACjE,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;KAC7C,CAAA;AAED,IAAA,GAAA,CAAA,SAAA,CAAA,KAAK,GAAL,UAAM,IAAY,EAAE,IAAqB,EAAE,MAAyB,EAAA;AAClE,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;KAC9C,CAAA;AAED,IAAA,GAAA,CAAA,SAAA,CAAA,MAAM,GAAN,UAAO,IAAY,EAAE,IAAqB,EAAE,MAAyB,EAAA;AACnE,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;KAC/C,CAAA;IAoHH,OAAC,GAAA,CAAA;AAAD,CAAC,EAAA","x_google_ignoreList":[2]}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/Api/Api.types.ts","../src/@util/compare.ts","../node_modules/url-join/lib/url-join.js","../src/@util/url.ts","../src/Api/Api.ts"],"sourcesContent":["import { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig, ResponseType } from 'axios';\n\nexport interface ApiRequestData {\n [key: string]: any;\n}\n\nexport interface ApiRequestOption {\n raw?: boolean;\n rawResponseType?: ResponseType;\n silent?: boolean;\n}\n\nexport interface ApiRequestConfig extends AxiosRequestConfig {\n silent?: boolean;\n}\n\n//--------------------------------------------------------------------------------------------------------------------\n\nexport class ApiError<T = any> extends Error {\n code?: string;\n config?: ApiRequestConfig;\n baseUrl?: string;\n path?: string;\n requestData?: ApiRequestData;\n requestOption?: ApiRequestOption;\n response?: AxiosResponse<T>;\n status?: number;\n isAxiosError = false;\n\n constructor(message?: string, code?: string) {\n super(message);\n\n this.code = code;\n }\n}\n\n//--------------------------------------------------------------------------------------------------------------------\n\nexport interface ApiOption<T = any> {\n baseUrl: string;\n timeParamName: string;\n withCredentials?: boolean;\n headers?: AxiosRequestConfig['headers'];\n onRequest?(\n config: InternalAxiosRequestConfig,\n baseUrl: string,\n path: string,\n requestData?: ApiRequestData,\n requestOption?: ApiRequestOption\n ): Promise<InternalAxiosRequestConfig>;\n onResponse?(\n response: AxiosResponse<T>,\n config: AxiosRequestConfig,\n baseUrl: string,\n path: string,\n requestData?: ApiRequestData,\n requestOption?: ApiRequestOption\n ): Promise<T>;\n onError?(err: ApiError): void;\n dataKeysToLowerCase?: boolean;\n}\n","const empty = function (v: any) {\n let result = false;\n if (v == null) {\n result = true;\n } else if (typeof v === 'string') {\n result = v === '';\n } else if (typeof v === 'object') {\n if (Array.isArray(v)) {\n result = v.length === 0;\n } else if (!(v instanceof Date)) {\n result = Object.entries(v).length === 0;\n }\n }\n return result;\n};\n\nconst notEmpty = function (v: any) {\n return !empty(v);\n};\n\nexport { empty, notEmpty };\n","function normalize (strArray) {\n var resultArray = [];\n if (strArray.length === 0) { return ''; }\n\n if (typeof strArray[0] !== 'string') {\n throw new TypeError('Url must be a string. Received ' + strArray[0]);\n }\n\n // If the first part is a plain protocol, we combine it with the next part.\n if (strArray[0].match(/^[^/:]+:\\/*$/) && strArray.length > 1) {\n var first = strArray.shift();\n strArray[0] = first + strArray[0];\n }\n\n // There must be two or three slashes in the file protocol, two slashes in anything else.\n if (strArray[0].match(/^file:\\/\\/\\//)) {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, '$1:///');\n } else {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, '$1://');\n }\n\n for (var i = 0; i < strArray.length; i++) {\n var component = strArray[i];\n\n if (typeof component !== 'string') {\n throw new TypeError('Url must be a string. Received ' + component);\n }\n\n if (component === '') { continue; }\n\n if (i > 0) {\n // Removing the starting slashes for each component but the first.\n component = component.replace(/^[\\/]+/, '');\n }\n if (i < strArray.length - 1) {\n // Removing the ending slashes for each component but the last.\n component = component.replace(/[\\/]+$/, '');\n } else {\n // For the last component we will combine multiple slashes to a single one.\n component = component.replace(/[\\/]+$/, '/');\n }\n\n resultArray.push(component);\n\n }\n\n var str = resultArray.join('/');\n // Each input component is now separated by a single slash except the possible first plain protocol part.\n\n // remove trailing slash before parameters or hash\n str = str.replace(/\\/(\\?|&|#[^!])/g, '$1');\n\n // replace ? in parameters with &\n var parts = str.split('?');\n str = parts.shift() + (parts.length > 0 ? '?': '') + parts.join('&');\n\n return str;\n}\n\nexport default function urlJoin() {\n var input;\n\n if (typeof arguments[0] === 'object') {\n input = arguments[0];\n } else {\n input = [].slice.call(arguments);\n }\n\n return normalize(input);\n}\n","import urlJoin from 'url-join';\n\nexport function joinUrl(...paths: string[]): string {\n let url = urlJoin(...paths);\n while (url.indexOf('//') > -1) {\n url = url.replace(/\\/\\//g, '/');\n }\n return url;\n}\n","import axios, { AxiosInstance, AxiosResponse, InternalAxiosRequestConfig, Method } from 'axios';\nimport { ApiError, ApiRequestData, ApiOption, ApiRequestOption, ApiRequestConfig } from './Api.types';\nimport { notEmpty, joinUrl } from '../@util';\n\nconst AxiosCreate = axios.create ? axios.create : require('axios').default?.create;\n\nclass Api<T = any> {\n option: ApiOption;\n\n // constructor -------------------------------------------------------------------------------------------------------\n\n constructor(option: ApiOption<T>) {\n this.option = option;\n }\n\n get(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T> {\n return this.run('get', path, data, option);\n }\n\n post(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T> {\n return this.run('post', path, data, option);\n }\n\n patch(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T> {\n return this.run('patch', path, data, option);\n }\n\n delete(path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T> {\n return this.run('delete', path, data, option);\n }\n\n // Run ---------------------------------------------------------------------------------------------------------------\n\n run = (method: Method, path: string, data?: ApiRequestData, option?: ApiRequestOption): Promise<T> => {\n return new Promise<T>((resolve, reject) => {\n const headers: ApiRequestConfig['headers'] = { ...this.option.headers };\n\n if (typeof window !== 'undefined') {\n if (window?.location?.href) {\n headers['X-Referer'] = window.location.href;\n }\n }\n\n const requestConfig: ApiRequestConfig = {\n method,\n withCredentials: this.option.withCredentials,\n headers,\n silent: !!option?.silent,\n };\n if (option?.raw) {\n requestConfig.responseType = option?.rawResponseType || 'arraybuffer';\n }\n\n requestConfig.url = joinUrl(this.option.baseUrl, path.replace(/\\./g, '/'));\n\n if (data) {\n if (method === 'get') {\n if (notEmpty(data)) {\n const finalData: ApiRequestData = {};\n finalData[this.option.timeParamName] = new Date().getTime();\n for (const key in data) {\n if (data[key] != null) {\n finalData[key] = data[key];\n }\n }\n requestConfig.url += `?${new URLSearchParams(finalData).toString()}`;\n }\n } else {\n if (data instanceof FormData) {\n data.append(this.option.timeParamName, `${new Date().getTime()}`);\n requestConfig.data = data;\n } else {\n const finalData: ApiRequestData = { ...data };\n finalData[this.option.timeParamName] = new Date().getTime();\n requestConfig.data = finalData;\n }\n }\n }\n\n const setErrorInfo = (err: ApiError, status?: number, response?: AxiosResponse) => {\n err.config = requestConfig;\n err.baseUrl = this.option.baseUrl;\n err.path = path;\n err.requestData = data;\n err.requestOption = option;\n err.response = response;\n err.status = status;\n };\n\n const fireError = (err: any): void => {\n const apiError: ApiError = new ApiError();\n\n if (typeof err === 'object') {\n apiError.message = err.message;\n apiError.code = err.code;\n setErrorInfo(apiError, err.status, err.response);\n } else if (typeof err === 'string') {\n apiError.message = err;\n } else if (err) {\n apiError.message = err.toString();\n }\n\n if (this.option.onError) this.option.onError(apiError);\n\n reject(apiError);\n };\n\n const instance: AxiosInstance = AxiosCreate();\n let requestInterceptor: number;\n if (this.option.onRequest) {\n requestInterceptor = instance.interceptors.request.use(async (config: InternalAxiosRequestConfig) => {\n if (this.option.onRequest) {\n return this.option.onRequest(config, this.option.baseUrl, path, data, option);\n } else {\n return config;\n }\n });\n }\n\n instance\n .request<T>(requestConfig)\n .then((res) => {\n const { data: resData } = res;\n if (this.option.onResponse) {\n this.option\n .onResponse(res, requestConfig, this.option.baseUrl, path, data, option)\n .then((finalResData) => {\n resolve(finalResData);\n })\n .catch((err: ApiError) => {\n setErrorInfo(err, res.status, res);\n fireError(err);\n });\n } else {\n resolve(resData);\n }\n })\n .catch(fireError)\n .finally(() => {\n if (requestInterceptor) {\n instance.interceptors.request.eject(requestInterceptor);\n }\n });\n });\n };\n}\n\nexport default Api;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBA;AAEA,IAAA,QAAA,kBAAA,UAAA,MAAA,EAAA;IAAuC,SAAK,CAAA,QAAA,EAAA,MAAA,CAAA,CAAA;IAW1C,SAAY,QAAA,CAAA,OAAgB,EAAE,IAAa,EAAA;QAA3C,IACE,KAAA,GAAA,MAAA,CAAA,IAAA,CAAA,IAAA,EAAM,OAAO,CAAC,IAGf,IAAA,CAAA;QAND,KAAY,CAAA,YAAA,GAAG,KAAK,CAAC;AAKnB,QAAA,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;KAClB;IACH,OAAC,QAAA,CAAA;AAAD,CAhBA,C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