@pdg/api 1.0.21 → 1.0.22
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 +1 -1
- package/dist/index.esm.js +52 -2
- package/dist/index.js +54 -4
- package/package.json +10 -13
package/README.md
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios from'axios'
|
|
1
|
+
import axios from'axios';/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -229,4 +229,54 @@ var Api = /** @class */ (function () {
|
|
|
229
229
|
return this.run('delete', path, data, option);
|
|
230
230
|
};
|
|
231
231
|
return Api;
|
|
232
|
-
}());
|
|
232
|
+
}());
|
|
233
|
+
/********************************************************************************************************************
|
|
234
|
+
* empty
|
|
235
|
+
* ******************************************************************************************************************/
|
|
236
|
+
function empty(v) {
|
|
237
|
+
var result = false;
|
|
238
|
+
if (v == null) {
|
|
239
|
+
result = true;
|
|
240
|
+
}
|
|
241
|
+
else if (typeof v === 'string') {
|
|
242
|
+
result = v === '';
|
|
243
|
+
}
|
|
244
|
+
else if (typeof v === 'object') {
|
|
245
|
+
if (Array.isArray(v)) {
|
|
246
|
+
result = v.length === 0;
|
|
247
|
+
}
|
|
248
|
+
else if (!(v instanceof Date)) {
|
|
249
|
+
result = Object.entries(v).length === 0;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
/********************************************************************************************************************
|
|
255
|
+
* notEmpty
|
|
256
|
+
* ******************************************************************************************************************/
|
|
257
|
+
function notEmpty(v) {
|
|
258
|
+
return !empty(v);
|
|
259
|
+
}
|
|
260
|
+
/********************************************************************************************************************
|
|
261
|
+
* urlJoin
|
|
262
|
+
* ******************************************************************************************************************/
|
|
263
|
+
function urlJoin() {
|
|
264
|
+
var parts = [];
|
|
265
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
266
|
+
parts[_i] = arguments[_i];
|
|
267
|
+
}
|
|
268
|
+
return parts.reduce(function (acc, part) {
|
|
269
|
+
if (acc === '') {
|
|
270
|
+
return part;
|
|
271
|
+
}
|
|
272
|
+
else if (part.startsWith('?')) {
|
|
273
|
+
return "".concat(acc).concat(part);
|
|
274
|
+
}
|
|
275
|
+
else if (acc.endsWith('/')) {
|
|
276
|
+
return "".concat(acc).concat(part.startsWith('/') ? part.substring(1) : part);
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
return "".concat(acc).concat(part.startsWith('/') ? part : "/".concat(part));
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}export{Api,ApiError};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var axios=require('axios')
|
|
1
|
+
'use strict';var axios=require('axios');/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -122,10 +122,10 @@ var Api = /** @class */ (function () {
|
|
|
122
122
|
if (option === null || option === void 0 ? void 0 : option.raw) {
|
|
123
123
|
requestConfig.responseType = (option === null || option === void 0 ? void 0 : option.rawResponseType) || 'arraybuffer';
|
|
124
124
|
}
|
|
125
|
-
requestConfig.url =
|
|
125
|
+
requestConfig.url = urlJoin(_this.option.baseUrl, path.replace(/\./g, '/'));
|
|
126
126
|
if (data) {
|
|
127
127
|
if (method === 'get') {
|
|
128
|
-
if (
|
|
128
|
+
if (notEmpty(data)) {
|
|
129
129
|
var finalData = {};
|
|
130
130
|
finalData[_this.option.timeParamName] = new Date().getTime();
|
|
131
131
|
for (var key in data) {
|
|
@@ -229,4 +229,54 @@ var Api = /** @class */ (function () {
|
|
|
229
229
|
return this.run('delete', path, data, option);
|
|
230
230
|
};
|
|
231
231
|
return Api;
|
|
232
|
-
}());
|
|
232
|
+
}());
|
|
233
|
+
/********************************************************************************************************************
|
|
234
|
+
* empty
|
|
235
|
+
* ******************************************************************************************************************/
|
|
236
|
+
function empty(v) {
|
|
237
|
+
var result = false;
|
|
238
|
+
if (v == null) {
|
|
239
|
+
result = true;
|
|
240
|
+
}
|
|
241
|
+
else if (typeof v === 'string') {
|
|
242
|
+
result = v === '';
|
|
243
|
+
}
|
|
244
|
+
else if (typeof v === 'object') {
|
|
245
|
+
if (Array.isArray(v)) {
|
|
246
|
+
result = v.length === 0;
|
|
247
|
+
}
|
|
248
|
+
else if (!(v instanceof Date)) {
|
|
249
|
+
result = Object.entries(v).length === 0;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
/********************************************************************************************************************
|
|
255
|
+
* notEmpty
|
|
256
|
+
* ******************************************************************************************************************/
|
|
257
|
+
function notEmpty(v) {
|
|
258
|
+
return !empty(v);
|
|
259
|
+
}
|
|
260
|
+
/********************************************************************************************************************
|
|
261
|
+
* urlJoin
|
|
262
|
+
* ******************************************************************************************************************/
|
|
263
|
+
function urlJoin() {
|
|
264
|
+
var parts = [];
|
|
265
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
266
|
+
parts[_i] = arguments[_i];
|
|
267
|
+
}
|
|
268
|
+
return parts.reduce(function (acc, part) {
|
|
269
|
+
if (acc === '') {
|
|
270
|
+
return part;
|
|
271
|
+
}
|
|
272
|
+
else if (part.startsWith('?')) {
|
|
273
|
+
return "".concat(acc).concat(part);
|
|
274
|
+
}
|
|
275
|
+
else if (acc.endsWith('/')) {
|
|
276
|
+
return "".concat(acc).concat(part.startsWith('/') ? part.substring(1) : part);
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
return "".concat(acc).concat(part.startsWith('/') ? part : "/".concat(part));
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}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.22",
|
|
5
5
|
"description": "API Module",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -36,24 +36,21 @@
|
|
|
36
36
|
"javascript"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"
|
|
40
|
-
"axios": "^1.9.0"
|
|
39
|
+
"axios": "^1.3.0"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
|
-
"@eslint/js": "^9.
|
|
42
|
+
"@eslint/js": "^9.28.0",
|
|
44
43
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
45
44
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
46
|
-
"@types/node": "^22.
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
48
|
-
"@typescript-eslint/parser": "^8.
|
|
49
|
-
"eslint": "9.
|
|
50
|
-
"eslint-config-prettier": "^10.1.
|
|
45
|
+
"@types/node": "^22.15.29",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^8.33.0",
|
|
47
|
+
"@typescript-eslint/parser": "^8.33.0",
|
|
48
|
+
"eslint": "9.28.0",
|
|
49
|
+
"eslint-config-prettier": "^10.1.5",
|
|
51
50
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
52
|
-
"eslint-plugin-prettier": "^5.
|
|
53
|
-
"i": "^0.3.7",
|
|
54
|
-
"npm": "^11.3.0",
|
|
51
|
+
"eslint-plugin-prettier": "^5.4.1",
|
|
55
52
|
"prettier": "^3.5.3",
|
|
56
|
-
"rollup": "^4.
|
|
53
|
+
"rollup": "^4.41.1",
|
|
57
54
|
"rollup-plugin-delete": "^2.2.0",
|
|
58
55
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
59
56
|
"rollup-plugin-typescript2": "^0.36.0",
|