@pdg/api 1.0.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 +8 -0
- package/dist/@util/compare.d.ts +3 -0
- package/dist/@util/index.d.ts +2 -0
- package/dist/@util/url.d.ts +1 -0
- package/dist/Api/Api.d.ts +12 -0
- package/dist/Api/Api.types.d.ts +32 -0
- package/dist/Api/index.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +252 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +252 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function joinUrl(...paths: string[]): string;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse, 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
|
+
withCredentials?: boolean;
|
|
28
|
+
headers?: AxiosRequestConfig['headers'];
|
|
29
|
+
onResponse?(response: AxiosResponse<T>, config: AxiosRequestConfig, baseUrl: string, path: string, requestData?: ApiRequestData, requestOption?: ApiRequestOption): Promise<T>;
|
|
30
|
+
onError?(err: ApiError): void;
|
|
31
|
+
dataKeysToLowerCase?: boolean;
|
|
32
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Api';
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import axios from'axios';/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
/* global Reflect, Promise */
|
|
16
|
+
|
|
17
|
+
var extendStatics = function(d, b) {
|
|
18
|
+
extendStatics = Object.setPrototypeOf ||
|
|
19
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
20
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
21
|
+
return extendStatics(d, b);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function __extends(d, b) {
|
|
25
|
+
if (typeof b !== "function" && b !== null)
|
|
26
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
27
|
+
extendStatics(d, b);
|
|
28
|
+
function __() { this.constructor = d; }
|
|
29
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var __assign = function() {
|
|
33
|
+
__assign = Object.assign || function __assign(t) {
|
|
34
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
35
|
+
s = arguments[i];
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
37
|
+
}
|
|
38
|
+
return t;
|
|
39
|
+
};
|
|
40
|
+
return __assign.apply(this, arguments);
|
|
41
|
+
};//--------------------------------------------------------------------------------------------------------------------
|
|
42
|
+
var ApiError = /** @class */ (function (_super) {
|
|
43
|
+
__extends(ApiError, _super);
|
|
44
|
+
function ApiError(message, code) {
|
|
45
|
+
var _this = _super.call(this, message) || this;
|
|
46
|
+
_this.isAxiosError = false;
|
|
47
|
+
_this.code = code;
|
|
48
|
+
return _this;
|
|
49
|
+
}
|
|
50
|
+
return ApiError;
|
|
51
|
+
}(Error));var empty = function (v) {
|
|
52
|
+
var result = false;
|
|
53
|
+
if (v == null) {
|
|
54
|
+
result = true;
|
|
55
|
+
}
|
|
56
|
+
else if (typeof v === 'string') {
|
|
57
|
+
result = v === '';
|
|
58
|
+
}
|
|
59
|
+
else if (typeof v === 'object') {
|
|
60
|
+
if (Array.isArray(v)) {
|
|
61
|
+
result = v.length === 0;
|
|
62
|
+
}
|
|
63
|
+
else if (!(v instanceof Date)) {
|
|
64
|
+
result = Object.entries(v).length === 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
var notEmpty = function (v) {
|
|
70
|
+
return !empty(v);
|
|
71
|
+
};function normalize (strArray) {
|
|
72
|
+
var resultArray = [];
|
|
73
|
+
if (strArray.length === 0) { return ''; }
|
|
74
|
+
|
|
75
|
+
if (typeof strArray[0] !== 'string') {
|
|
76
|
+
throw new TypeError('Url must be a string. Received ' + strArray[0]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// If the first part is a plain protocol, we combine it with the next part.
|
|
80
|
+
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
|
|
81
|
+
var first = strArray.shift();
|
|
82
|
+
strArray[0] = first + strArray[0];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// There must be two or three slashes in the file protocol, two slashes in anything else.
|
|
86
|
+
if (strArray[0].match(/^file:\/\/\//)) {
|
|
87
|
+
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///');
|
|
88
|
+
} else {
|
|
89
|
+
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
for (var i = 0; i < strArray.length; i++) {
|
|
93
|
+
var component = strArray[i];
|
|
94
|
+
|
|
95
|
+
if (typeof component !== 'string') {
|
|
96
|
+
throw new TypeError('Url must be a string. Received ' + component);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (component === '') { continue; }
|
|
100
|
+
|
|
101
|
+
if (i > 0) {
|
|
102
|
+
// Removing the starting slashes for each component but the first.
|
|
103
|
+
component = component.replace(/^[\/]+/, '');
|
|
104
|
+
}
|
|
105
|
+
if (i < strArray.length - 1) {
|
|
106
|
+
// Removing the ending slashes for each component but the last.
|
|
107
|
+
component = component.replace(/[\/]+$/, '');
|
|
108
|
+
} else {
|
|
109
|
+
// For the last component we will combine multiple slashes to a single one.
|
|
110
|
+
component = component.replace(/[\/]+$/, '/');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
resultArray.push(component);
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var str = resultArray.join('/');
|
|
118
|
+
// Each input component is now separated by a single slash except the possible first plain protocol part.
|
|
119
|
+
|
|
120
|
+
// remove trailing slash before parameters or hash
|
|
121
|
+
str = str.replace(/\/(\?|&|#[^!])/g, '$1');
|
|
122
|
+
|
|
123
|
+
// replace ? in parameters with &
|
|
124
|
+
var parts = str.split('?');
|
|
125
|
+
str = parts.shift() + (parts.length > 0 ? '?': '') + parts.join('&');
|
|
126
|
+
|
|
127
|
+
return str;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function urlJoin() {
|
|
131
|
+
var input;
|
|
132
|
+
|
|
133
|
+
if (typeof arguments[0] === 'object') {
|
|
134
|
+
input = arguments[0];
|
|
135
|
+
} else {
|
|
136
|
+
input = [].slice.call(arguments);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return normalize(input);
|
|
140
|
+
}function joinUrl() {
|
|
141
|
+
var paths = [];
|
|
142
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
143
|
+
paths[_i] = arguments[_i];
|
|
144
|
+
}
|
|
145
|
+
var url = urlJoin.apply(void 0, paths);
|
|
146
|
+
while (url.indexOf('//') > -1) {
|
|
147
|
+
url = url.replace(/\/\//g, '/');
|
|
148
|
+
}
|
|
149
|
+
return url;
|
|
150
|
+
}var Api = /** @class */ (function () {
|
|
151
|
+
// constructor -------------------------------------------------------------------------------------------------------
|
|
152
|
+
function Api(option) {
|
|
153
|
+
var _this = this;
|
|
154
|
+
// Run ---------------------------------------------------------------------------------------------------------------
|
|
155
|
+
this.run = function (method, path, data, option) {
|
|
156
|
+
return new Promise(function (resolve, reject) {
|
|
157
|
+
var _a;
|
|
158
|
+
var headers = __assign({}, _this.option.headers);
|
|
159
|
+
if (typeof window !== 'undefined') {
|
|
160
|
+
if ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href) {
|
|
161
|
+
headers['X-Referer'] = window.location.href;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
var requestConfig = {
|
|
165
|
+
method: method,
|
|
166
|
+
withCredentials: _this.option.withCredentials,
|
|
167
|
+
headers: headers,
|
|
168
|
+
silent: !!(option === null || option === void 0 ? void 0 : option.silent),
|
|
169
|
+
};
|
|
170
|
+
if (option === null || option === void 0 ? void 0 : option.raw) {
|
|
171
|
+
requestConfig.responseType = (option === null || option === void 0 ? void 0 : option.rawResponseType) || 'arraybuffer';
|
|
172
|
+
}
|
|
173
|
+
requestConfig.url = joinUrl(_this.option.baseUrl, path.replace(/\./g, '/'));
|
|
174
|
+
if (data) {
|
|
175
|
+
if (method === 'get') {
|
|
176
|
+
if (notEmpty(data)) {
|
|
177
|
+
var finalData = {};
|
|
178
|
+
for (var key in data) {
|
|
179
|
+
if (data[key] != null) {
|
|
180
|
+
finalData[key] = data[key];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
requestConfig.url += "?".concat(new URLSearchParams(finalData).toString());
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
requestConfig.data = data;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
var setErrorInfo = function (err, status, response) {
|
|
191
|
+
err.config = requestConfig;
|
|
192
|
+
err.baseUrl = _this.option.baseUrl;
|
|
193
|
+
err.path = path;
|
|
194
|
+
err.requestData = data;
|
|
195
|
+
err.requestOption = option;
|
|
196
|
+
err.response = response;
|
|
197
|
+
err.status = status;
|
|
198
|
+
};
|
|
199
|
+
var fireError = function (err) {
|
|
200
|
+
var apiError = new ApiError();
|
|
201
|
+
if (typeof err === 'object') {
|
|
202
|
+
apiError.message = err.message;
|
|
203
|
+
apiError.code = err.code;
|
|
204
|
+
setErrorInfo(apiError, err.status, err.response);
|
|
205
|
+
}
|
|
206
|
+
else if (typeof err === 'string') {
|
|
207
|
+
apiError.message = err;
|
|
208
|
+
}
|
|
209
|
+
else if (err) {
|
|
210
|
+
apiError.message = err.toString();
|
|
211
|
+
}
|
|
212
|
+
if (_this.option.onError)
|
|
213
|
+
_this.option.onError(apiError);
|
|
214
|
+
reject(apiError);
|
|
215
|
+
};
|
|
216
|
+
axios(requestConfig)
|
|
217
|
+
.then(function (res) {
|
|
218
|
+
var resData = res.data;
|
|
219
|
+
if (_this.option.onResponse) {
|
|
220
|
+
_this.option
|
|
221
|
+
.onResponse(res, requestConfig, _this.option.baseUrl, path, data, option)
|
|
222
|
+
.then(function (finalResData) {
|
|
223
|
+
resolve(finalResData);
|
|
224
|
+
})
|
|
225
|
+
.catch(function (err) {
|
|
226
|
+
setErrorInfo(err, res.status, res);
|
|
227
|
+
fireError(err);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
resolve(resData);
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
.catch(fireError);
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
this.option = option;
|
|
238
|
+
}
|
|
239
|
+
Api.prototype.get = function (path, data, option) {
|
|
240
|
+
return this.run('get', path, data, option);
|
|
241
|
+
};
|
|
242
|
+
Api.prototype.post = function (path, data, option) {
|
|
243
|
+
return this.run('post', path, data, option);
|
|
244
|
+
};
|
|
245
|
+
Api.prototype.patch = function (path, data, option) {
|
|
246
|
+
return this.run('patch', path, data, option);
|
|
247
|
+
};
|
|
248
|
+
Api.prototype.delete = function (path, data, option) {
|
|
249
|
+
return this.run('delete', path, data, option);
|
|
250
|
+
};
|
|
251
|
+
return Api;
|
|
252
|
+
}());export{Api,ApiError};//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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, 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 withCredentials?: boolean;\n headers?: AxiosRequestConfig['headers'];\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, { AxiosResponse, Method } from 'axios';\nimport { ApiError, ApiRequestData, ApiOption, ApiRequestOption, ApiRequestConfig } from './Api.types';\nimport { notEmpty, joinUrl } from '../@util';\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 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 requestConfig.data = data;\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 axios<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 });\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,CAAuC,KAAK,CAgB3C,EClCD,IAAM,KAAK,GAAG,UAAU,CAAM,EAAA;IAC5B,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,CAAC,IAAI,IAAI,EAAE;QACb,MAAM,GAAG,IAAI,CAAC;AACf,KAAA;AAAM,SAAA,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;AAChC,QAAA,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;AACnB,KAAA;AAAM,SAAA,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;AA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,yBAAC,CAAC,CAAC;AACN,qBAAA;AAAM,yBAAA;wBACL,OAAO,CAAC,OAAO,CAAC,CAAC;AAClB,qBAAA;AACH,iBAAC,CAAC;qBACD,KAAK,CAAC,SAAS,CAAC,CAAC;AACtB,aAAC,CAAC,CAAC;AACL,SAAC,CAAC;AA1GA,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;IA0FH,OAAC,GAAA,CAAA;AAAD,CAAC,EAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var axios=require('axios');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var axios__default=/*#__PURE__*/_interopDefaultLegacy(axios);/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
/* global Reflect, Promise */
|
|
16
|
+
|
|
17
|
+
var extendStatics = function(d, b) {
|
|
18
|
+
extendStatics = Object.setPrototypeOf ||
|
|
19
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
20
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
21
|
+
return extendStatics(d, b);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function __extends(d, b) {
|
|
25
|
+
if (typeof b !== "function" && b !== null)
|
|
26
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
27
|
+
extendStatics(d, b);
|
|
28
|
+
function __() { this.constructor = d; }
|
|
29
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var __assign = function() {
|
|
33
|
+
__assign = Object.assign || function __assign(t) {
|
|
34
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
35
|
+
s = arguments[i];
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
37
|
+
}
|
|
38
|
+
return t;
|
|
39
|
+
};
|
|
40
|
+
return __assign.apply(this, arguments);
|
|
41
|
+
};//--------------------------------------------------------------------------------------------------------------------
|
|
42
|
+
var ApiError = /** @class */ (function (_super) {
|
|
43
|
+
__extends(ApiError, _super);
|
|
44
|
+
function ApiError(message, code) {
|
|
45
|
+
var _this = _super.call(this, message) || this;
|
|
46
|
+
_this.isAxiosError = false;
|
|
47
|
+
_this.code = code;
|
|
48
|
+
return _this;
|
|
49
|
+
}
|
|
50
|
+
return ApiError;
|
|
51
|
+
}(Error));var empty = function (v) {
|
|
52
|
+
var result = false;
|
|
53
|
+
if (v == null) {
|
|
54
|
+
result = true;
|
|
55
|
+
}
|
|
56
|
+
else if (typeof v === 'string') {
|
|
57
|
+
result = v === '';
|
|
58
|
+
}
|
|
59
|
+
else if (typeof v === 'object') {
|
|
60
|
+
if (Array.isArray(v)) {
|
|
61
|
+
result = v.length === 0;
|
|
62
|
+
}
|
|
63
|
+
else if (!(v instanceof Date)) {
|
|
64
|
+
result = Object.entries(v).length === 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
var notEmpty = function (v) {
|
|
70
|
+
return !empty(v);
|
|
71
|
+
};function normalize (strArray) {
|
|
72
|
+
var resultArray = [];
|
|
73
|
+
if (strArray.length === 0) { return ''; }
|
|
74
|
+
|
|
75
|
+
if (typeof strArray[0] !== 'string') {
|
|
76
|
+
throw new TypeError('Url must be a string. Received ' + strArray[0]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// If the first part is a plain protocol, we combine it with the next part.
|
|
80
|
+
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
|
|
81
|
+
var first = strArray.shift();
|
|
82
|
+
strArray[0] = first + strArray[0];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// There must be two or three slashes in the file protocol, two slashes in anything else.
|
|
86
|
+
if (strArray[0].match(/^file:\/\/\//)) {
|
|
87
|
+
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///');
|
|
88
|
+
} else {
|
|
89
|
+
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
for (var i = 0; i < strArray.length; i++) {
|
|
93
|
+
var component = strArray[i];
|
|
94
|
+
|
|
95
|
+
if (typeof component !== 'string') {
|
|
96
|
+
throw new TypeError('Url must be a string. Received ' + component);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (component === '') { continue; }
|
|
100
|
+
|
|
101
|
+
if (i > 0) {
|
|
102
|
+
// Removing the starting slashes for each component but the first.
|
|
103
|
+
component = component.replace(/^[\/]+/, '');
|
|
104
|
+
}
|
|
105
|
+
if (i < strArray.length - 1) {
|
|
106
|
+
// Removing the ending slashes for each component but the last.
|
|
107
|
+
component = component.replace(/[\/]+$/, '');
|
|
108
|
+
} else {
|
|
109
|
+
// For the last component we will combine multiple slashes to a single one.
|
|
110
|
+
component = component.replace(/[\/]+$/, '/');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
resultArray.push(component);
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var str = resultArray.join('/');
|
|
118
|
+
// Each input component is now separated by a single slash except the possible first plain protocol part.
|
|
119
|
+
|
|
120
|
+
// remove trailing slash before parameters or hash
|
|
121
|
+
str = str.replace(/\/(\?|&|#[^!])/g, '$1');
|
|
122
|
+
|
|
123
|
+
// replace ? in parameters with &
|
|
124
|
+
var parts = str.split('?');
|
|
125
|
+
str = parts.shift() + (parts.length > 0 ? '?': '') + parts.join('&');
|
|
126
|
+
|
|
127
|
+
return str;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function urlJoin() {
|
|
131
|
+
var input;
|
|
132
|
+
|
|
133
|
+
if (typeof arguments[0] === 'object') {
|
|
134
|
+
input = arguments[0];
|
|
135
|
+
} else {
|
|
136
|
+
input = [].slice.call(arguments);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return normalize(input);
|
|
140
|
+
}function joinUrl() {
|
|
141
|
+
var paths = [];
|
|
142
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
143
|
+
paths[_i] = arguments[_i];
|
|
144
|
+
}
|
|
145
|
+
var url = urlJoin.apply(void 0, paths);
|
|
146
|
+
while (url.indexOf('//') > -1) {
|
|
147
|
+
url = url.replace(/\/\//g, '/');
|
|
148
|
+
}
|
|
149
|
+
return url;
|
|
150
|
+
}var Api = /** @class */ (function () {
|
|
151
|
+
// constructor -------------------------------------------------------------------------------------------------------
|
|
152
|
+
function Api(option) {
|
|
153
|
+
var _this = this;
|
|
154
|
+
// Run ---------------------------------------------------------------------------------------------------------------
|
|
155
|
+
this.run = function (method, path, data, option) {
|
|
156
|
+
return new Promise(function (resolve, reject) {
|
|
157
|
+
var _a;
|
|
158
|
+
var headers = __assign({}, _this.option.headers);
|
|
159
|
+
if (typeof window !== 'undefined') {
|
|
160
|
+
if ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href) {
|
|
161
|
+
headers['X-Referer'] = window.location.href;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
var requestConfig = {
|
|
165
|
+
method: method,
|
|
166
|
+
withCredentials: _this.option.withCredentials,
|
|
167
|
+
headers: headers,
|
|
168
|
+
silent: !!(option === null || option === void 0 ? void 0 : option.silent),
|
|
169
|
+
};
|
|
170
|
+
if (option === null || option === void 0 ? void 0 : option.raw) {
|
|
171
|
+
requestConfig.responseType = (option === null || option === void 0 ? void 0 : option.rawResponseType) || 'arraybuffer';
|
|
172
|
+
}
|
|
173
|
+
requestConfig.url = joinUrl(_this.option.baseUrl, path.replace(/\./g, '/'));
|
|
174
|
+
if (data) {
|
|
175
|
+
if (method === 'get') {
|
|
176
|
+
if (notEmpty(data)) {
|
|
177
|
+
var finalData = {};
|
|
178
|
+
for (var key in data) {
|
|
179
|
+
if (data[key] != null) {
|
|
180
|
+
finalData[key] = data[key];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
requestConfig.url += "?".concat(new URLSearchParams(finalData).toString());
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
requestConfig.data = data;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
var setErrorInfo = function (err, status, response) {
|
|
191
|
+
err.config = requestConfig;
|
|
192
|
+
err.baseUrl = _this.option.baseUrl;
|
|
193
|
+
err.path = path;
|
|
194
|
+
err.requestData = data;
|
|
195
|
+
err.requestOption = option;
|
|
196
|
+
err.response = response;
|
|
197
|
+
err.status = status;
|
|
198
|
+
};
|
|
199
|
+
var fireError = function (err) {
|
|
200
|
+
var apiError = new ApiError();
|
|
201
|
+
if (typeof err === 'object') {
|
|
202
|
+
apiError.message = err.message;
|
|
203
|
+
apiError.code = err.code;
|
|
204
|
+
setErrorInfo(apiError, err.status, err.response);
|
|
205
|
+
}
|
|
206
|
+
else if (typeof err === 'string') {
|
|
207
|
+
apiError.message = err;
|
|
208
|
+
}
|
|
209
|
+
else if (err) {
|
|
210
|
+
apiError.message = err.toString();
|
|
211
|
+
}
|
|
212
|
+
if (_this.option.onError)
|
|
213
|
+
_this.option.onError(apiError);
|
|
214
|
+
reject(apiError);
|
|
215
|
+
};
|
|
216
|
+
axios__default["default"](requestConfig)
|
|
217
|
+
.then(function (res) {
|
|
218
|
+
var resData = res.data;
|
|
219
|
+
if (_this.option.onResponse) {
|
|
220
|
+
_this.option
|
|
221
|
+
.onResponse(res, requestConfig, _this.option.baseUrl, path, data, option)
|
|
222
|
+
.then(function (finalResData) {
|
|
223
|
+
resolve(finalResData);
|
|
224
|
+
})
|
|
225
|
+
.catch(function (err) {
|
|
226
|
+
setErrorInfo(err, res.status, res);
|
|
227
|
+
fireError(err);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
resolve(resData);
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
.catch(fireError);
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
this.option = option;
|
|
238
|
+
}
|
|
239
|
+
Api.prototype.get = function (path, data, option) {
|
|
240
|
+
return this.run('get', path, data, option);
|
|
241
|
+
};
|
|
242
|
+
Api.prototype.post = function (path, data, option) {
|
|
243
|
+
return this.run('post', path, data, option);
|
|
244
|
+
};
|
|
245
|
+
Api.prototype.patch = function (path, data, option) {
|
|
246
|
+
return this.run('patch', path, data, option);
|
|
247
|
+
};
|
|
248
|
+
Api.prototype.delete = function (path, data, option) {
|
|
249
|
+
return this.run('delete', path, data, option);
|
|
250
|
+
};
|
|
251
|
+
return Api;
|
|
252
|
+
}());exports.Api=Api;exports.ApiError=ApiError;//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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, 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 withCredentials?: boolean;\n headers?: AxiosRequestConfig['headers'];\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, { AxiosResponse, Method } from 'axios';\nimport { ApiError, ApiRequestData, ApiOption, ApiRequestOption, ApiRequestConfig } from './Api.types';\nimport { notEmpty, joinUrl } from '../@util';\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 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 requestConfig.data = data;\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 axios<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 });\n };\n}\n\nexport default Api;\n"],"names":["axios"],"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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,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;IA0FH,OAAC,GAAA,CAAA;AAAD,CAAC,EAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pdg/api",
|
|
3
|
+
"title": "API Module",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "API Module",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.esm.js",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/parkdigy/api.git",
|
|
12
|
+
"baseUrl": "https://github.com/parkdigy/api"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/parkdigy/api/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/parkdigy/api#readme",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test:get": "cd examples && npm run test:get",
|
|
24
|
+
"build": "rollup -c",
|
|
25
|
+
"publish": "npm publish --access=public",
|
|
26
|
+
"lint": "eslint './src/**/*.ts'"
|
|
27
|
+
},
|
|
28
|
+
"author": "YOUNG CHUL PARK",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"readmeFilename": "README.md",
|
|
31
|
+
"keywords": [
|
|
32
|
+
"api",
|
|
33
|
+
"typescript",
|
|
34
|
+
"javascript"
|
|
35
|
+
],
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"axios": "^1.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@rollup/plugin-commonjs": "^22.0.2",
|
|
41
|
+
"@rollup/plugin-eslint": "^8.0.2",
|
|
42
|
+
"@rollup/plugin-node-resolve": "^14.1.0",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
|
44
|
+
"@typescript-eslint/parser": "^5.38.1",
|
|
45
|
+
"eslint": "8.22.0",
|
|
46
|
+
"eslint-config-prettier": "^8.5.0",
|
|
47
|
+
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
48
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
49
|
+
"prettier": "^2.7.1",
|
|
50
|
+
"rollup": "^2.79.1",
|
|
51
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
52
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
53
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
54
|
+
"rollup-plugin-typescript2": "^0.34.0",
|
|
55
|
+
"typescript": "^4.8.3",
|
|
56
|
+
"url-join": "^5.0.0"
|
|
57
|
+
}
|
|
58
|
+
}
|