xjs-common 10.1.2 → 11.0.0-alpha.1
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/index.js +1 -32
- package/dist/types.d.ts +285 -0
- package/package.json +10 -7
- package/dist/const/ccy.d.ts +0 -18
- package/dist/const/ccy.js +0 -20
- package/dist/const/gender.d.ts +0 -4
- package/dist/const/gender.js +0 -8
- package/dist/const/http-method.d.ts +0 -8
- package/dist/const/http-method.js +0 -12
- package/dist/const/time-unit.d.ts +0 -9
- package/dist/const/time-unit.js +0 -13
- package/dist/const/types.d.ts +0 -24
- package/dist/const/types.js +0 -14
- package/dist/func/decorator/d-type.d.ts +0 -24
- package/dist/func/decorator/d-type.js +0 -71
- package/dist/func/decorator/d-validate.d.ts +0 -20
- package/dist/func/decorator/d-validate.js +0 -64
- package/dist/func/decorator/transaction.d.ts +0 -7
- package/dist/func/decorator/transaction.js +0 -36
- package/dist/func/u-array.d.ts +0 -40
- package/dist/func/u-array.js +0 -70
- package/dist/func/u-file.d.ts +0 -51
- package/dist/func/u-file.js +0 -171
- package/dist/func/u-http.d.ts +0 -9
- package/dist/func/u-http.js +0 -32
- package/dist/func/u-obj.d.ts +0 -18
- package/dist/func/u-obj.js +0 -44
- package/dist/func/u-string.d.ts +0 -27
- package/dist/func/u-string.js +0 -120
- package/dist/func/u-type.d.ts +0 -25
- package/dist/func/u-type.js +0 -58
- package/dist/func/u.d.ts +0 -24
- package/dist/func/u.js +0 -76
- package/dist/index.d.ts +0 -14
- package/dist/obj/type-exp.d.ts +0 -8
- package/dist/obj/type-exp.js +0 -23
- package/dist/obj/xjs-err.d.ts +0 -5
- package/dist/obj/xjs-err.js +0 -13
- package/dist/prcs/http/http-resolver-context.d.ts +0 -64
- package/dist/prcs/http/http-resolver-context.js +0 -343
- package/dist/prcs/http/http-resolver.d.ts +0 -36
- package/dist/prcs/http/http-resolver.js +0 -53
- package/dist/prcs/http/i-http-client.d.ts +0 -63
- package/dist/prcs/http/i-http-client.js +0 -2
- package/dist/prcs/http-resolver.d.ts +0 -53
- package/dist/prcs/http-resolver.js +0 -255
package/dist/func/u-string.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UString = void 0;
|
|
4
|
-
const time_unit_1 = require("../const/time-unit");
|
|
5
|
-
const xjs_err_1 = require("../obj/xjs-err");
|
|
6
|
-
const u_1 = require("./u");
|
|
7
|
-
const u_type_1 = require("./u-type");
|
|
8
|
-
const s_errCode = 20;
|
|
9
|
-
var UString;
|
|
10
|
-
(function (UString) {
|
|
11
|
-
function eq(s1, s2) {
|
|
12
|
-
return !u_type_1.UType.isString(s1) || !u_type_1.UType.isString(s2) ? s1 === s2 : s1.trim() === s2.trim();
|
|
13
|
-
}
|
|
14
|
-
UString.eq = eq;
|
|
15
|
-
function repeat(token, mlt) {
|
|
16
|
-
return (0, u_1.int2array)(mlt).map(_ => token).join("");
|
|
17
|
-
}
|
|
18
|
-
UString.repeat = repeat;
|
|
19
|
-
/**
|
|
20
|
-
* generate date time number as fixed length (depends on `unit`) string without separator charactor.
|
|
21
|
-
* For example, `2025-06-08T10:15:06.366Z` is to be `20250608101506366`.
|
|
22
|
-
* @param op.date Date object refered by this. default is `new Date()`.
|
|
23
|
-
* @param op.unit time unit. default is secound.
|
|
24
|
-
*/
|
|
25
|
-
function simpleTime(op) {
|
|
26
|
-
const t = (op?.date ?? new Date()).toISOString().split(".")[0].replace(/[-T:]/g, "");
|
|
27
|
-
if (op?.unit === time_unit_1.TimeUnit.Msec)
|
|
28
|
-
return t;
|
|
29
|
-
return t.substring(0, 14 - (6 - (op?.unit ?? time_unit_1.TimeUnit.Sec)) * 2);
|
|
30
|
-
}
|
|
31
|
-
UString.simpleTime = simpleTime;
|
|
32
|
-
function generateRandomString(len) {
|
|
33
|
-
return (0, u_1.int2array)(len).map(_ => {
|
|
34
|
-
let rnd = Math.floor(62 * Math.random());
|
|
35
|
-
const remain = rnd - 52;
|
|
36
|
-
if (remain >= 0)
|
|
37
|
-
return remain.toString();
|
|
38
|
-
if (rnd > 26)
|
|
39
|
-
rnd += 6;
|
|
40
|
-
return String.fromCharCode(rnd + 65);
|
|
41
|
-
}).join("");
|
|
42
|
-
}
|
|
43
|
-
UString.generateRandomString = generateRandomString;
|
|
44
|
-
function idx2az(idx) {
|
|
45
|
-
let az = "", num = idx;
|
|
46
|
-
while (num >= 0) {
|
|
47
|
-
az = String.fromCharCode(num % 26 + 97) + az;
|
|
48
|
-
num = Math.floor(num / 26) - 1;
|
|
49
|
-
}
|
|
50
|
-
return az.toUpperCase();
|
|
51
|
-
}
|
|
52
|
-
UString.idx2az = idx2az;
|
|
53
|
-
function az2idx(az) {
|
|
54
|
-
if (!az?.match(/^[a-zA-Z]+$/))
|
|
55
|
-
throw new xjs_err_1.XjsErr(s_errCode, "the parameter isn't az(AZ) format.");
|
|
56
|
-
return az.toLowerCase().split("").map(c => c.charCodeAt(0) - 97).reverse()
|
|
57
|
-
.map((idx, i) => (idx + 1) * (26 ** i)).reduce((v1, v2) => v1 + v2) - 1;
|
|
58
|
-
}
|
|
59
|
-
UString.az2idx = az2idx;
|
|
60
|
-
function asAmount(amount, unit) {
|
|
61
|
-
const int2dec = amount.toString().split(".");
|
|
62
|
-
const etni = int2dec[0].split("").reverse().join("");
|
|
63
|
-
let fetni = "";
|
|
64
|
-
const max = Math.ceil(etni.length / 3);
|
|
65
|
-
for (let i = 0; i < max; i++) {
|
|
66
|
-
if (i === max - 1)
|
|
67
|
-
fetni += etni.substring(i * 3);
|
|
68
|
-
else
|
|
69
|
-
fetni += (etni.substring(i * 3, (i + 1) * 3) + ",");
|
|
70
|
-
}
|
|
71
|
-
const finte = unit + fetni.split("").reverse().join("");
|
|
72
|
-
if (int2dec.length === 1)
|
|
73
|
-
return finte;
|
|
74
|
-
else
|
|
75
|
-
return finte + "." + int2dec[1];
|
|
76
|
-
}
|
|
77
|
-
function asJpy(amount) {
|
|
78
|
-
return u_type_1.UType.isEmpty(amount) ? "" : asAmount(Math.floor(amount), "¥");
|
|
79
|
-
}
|
|
80
|
-
UString.asJpy = asJpy;
|
|
81
|
-
function asUsd(amount) {
|
|
82
|
-
return u_type_1.UType.isEmpty(amount) ? "" : asAmount(Number(amount.toFixed(2)), "$");
|
|
83
|
-
}
|
|
84
|
-
UString.asUsd = asUsd;
|
|
85
|
-
function asPercentage(amount) {
|
|
86
|
-
if (u_type_1.UType.isEmpty(amount))
|
|
87
|
-
return "";
|
|
88
|
-
let percent = (amount * 100).toFixed(2);
|
|
89
|
-
while (percent.endsWith("0"))
|
|
90
|
-
percent = percent.substring(0, percent.length - 1);
|
|
91
|
-
if (percent.endsWith("."))
|
|
92
|
-
percent = percent.substring(0, percent.length - 1);
|
|
93
|
-
return percent + "%";
|
|
94
|
-
}
|
|
95
|
-
UString.asPercentage = asPercentage;
|
|
96
|
-
function is_yyyy(v) {
|
|
97
|
-
return !!v?.match(/^[1-9]\d{3}$/);
|
|
98
|
-
}
|
|
99
|
-
UString.is_yyyy = is_yyyy;
|
|
100
|
-
function is_yyyyMM(v) {
|
|
101
|
-
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])$/);
|
|
102
|
-
}
|
|
103
|
-
UString.is_yyyyMM = is_yyyyMM;
|
|
104
|
-
function is_yyyyMMdd(v) {
|
|
105
|
-
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])$/);
|
|
106
|
-
}
|
|
107
|
-
UString.is_yyyyMMdd = is_yyyyMMdd;
|
|
108
|
-
function is_yyyyMMddhh(v) {
|
|
109
|
-
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])([01]\d|2[0-3])$/);
|
|
110
|
-
}
|
|
111
|
-
UString.is_yyyyMMddhh = is_yyyyMMddhh;
|
|
112
|
-
function is_yyyyMMddhhmm(v) {
|
|
113
|
-
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])([01]\d|2[0-3])[0-5]\d$/);
|
|
114
|
-
}
|
|
115
|
-
UString.is_yyyyMMddhhmm = is_yyyyMMddhhmm;
|
|
116
|
-
function is_yyyyMMddhhmmss(v) {
|
|
117
|
-
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])([01]\d|2[0-3])[0-5]\d[0-5]\d$/);
|
|
118
|
-
}
|
|
119
|
-
UString.is_yyyyMMddhhmmss = is_yyyyMMddhhmmss;
|
|
120
|
-
})(UString = exports.UString || (exports.UString = {}));
|
package/dist/func/u-type.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { MaybeArray, Type } from "../const/types";
|
|
2
|
-
export declare namespace UType {
|
|
3
|
-
function isDefined(v: any): boolean;
|
|
4
|
-
function isEmpty(v: any): boolean;
|
|
5
|
-
function isString(v: any): v is string;
|
|
6
|
-
function isNumber(v: any): v is number;
|
|
7
|
-
function isBigint(v: any): v is bigint;
|
|
8
|
-
function isBoolean(v: any): v is boolean;
|
|
9
|
-
function isSymbol(v: any): v is symbol;
|
|
10
|
-
function isObject(v: any): v is object;
|
|
11
|
-
function isArray(v: any, t: Type.string): v is string[];
|
|
12
|
-
function isArray(v: any, t: Type.number): v is number[];
|
|
13
|
-
function isArray(v: any, t: Type.bigint): v is bigint[];
|
|
14
|
-
function isArray(v: any, t: Type.boolean): v is boolean[];
|
|
15
|
-
function isArray(v: any, t: Type.symbol): v is symbol[];
|
|
16
|
-
function isArray(v: any, t: Type.object): v is object[];
|
|
17
|
-
function isArray(v: any): v is any[];
|
|
18
|
-
/**
|
|
19
|
-
* validate properties which attached decorators in {@link DType}.
|
|
20
|
-
* @param o object to be validated.
|
|
21
|
-
* @returns invalid property keys. returns an empty array if `o` is valid.
|
|
22
|
-
*/
|
|
23
|
-
function validate(o: any): string[];
|
|
24
|
-
function takeAsArray<T>(v: MaybeArray<T>): T[];
|
|
25
|
-
}
|
package/dist/func/u-type.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UType = void 0;
|
|
4
|
-
const types_1 = require("../const/types");
|
|
5
|
-
const d_type_1 = require("./decorator/d-type");
|
|
6
|
-
var UType;
|
|
7
|
-
(function (UType) {
|
|
8
|
-
function isDefined(v) {
|
|
9
|
-
return typeof v !== types_1.Type.undefined;
|
|
10
|
-
}
|
|
11
|
-
UType.isDefined = isDefined;
|
|
12
|
-
function isEmpty(v) {
|
|
13
|
-
return v === null || typeof v === types_1.Type.undefined;
|
|
14
|
-
}
|
|
15
|
-
UType.isEmpty = isEmpty;
|
|
16
|
-
function isString(v) { return typeof v === types_1.Type.string; }
|
|
17
|
-
UType.isString = isString;
|
|
18
|
-
function isNumber(v) { return typeof v === types_1.Type.number; }
|
|
19
|
-
UType.isNumber = isNumber;
|
|
20
|
-
function isBigint(v) { return typeof v === types_1.Type.bigint; }
|
|
21
|
-
UType.isBigint = isBigint;
|
|
22
|
-
function isBoolean(v) { return typeof v === types_1.Type.boolean; }
|
|
23
|
-
UType.isBoolean = isBoolean;
|
|
24
|
-
function isSymbol(v) { return typeof v === types_1.Type.symbol; }
|
|
25
|
-
UType.isSymbol = isSymbol;
|
|
26
|
-
function isObject(v) { return typeof v === types_1.Type.object; }
|
|
27
|
-
UType.isObject = isObject;
|
|
28
|
-
function isArray(v, t) {
|
|
29
|
-
return Array.isArray(v) && (!t || v.every(e => typeof e === t));
|
|
30
|
-
}
|
|
31
|
-
UType.isArray = isArray;
|
|
32
|
-
/**
|
|
33
|
-
* validate properties which attached decorators in {@link DType}.
|
|
34
|
-
* @param o object to be validated.
|
|
35
|
-
* @returns invalid property keys. returns an empty array if `o` is valid.
|
|
36
|
-
*/
|
|
37
|
-
function validate(o) {
|
|
38
|
-
if (!o[d_type_1.smbl_tm])
|
|
39
|
-
return [];
|
|
40
|
-
return Object.entries(o[d_type_1.smbl_tm]).flatMap(e => validateProp(e[0], o[e[0]], e[1]));
|
|
41
|
-
}
|
|
42
|
-
UType.validate = validate;
|
|
43
|
-
function validateProp(k, prop, td) {
|
|
44
|
-
if (isEmpty(prop))
|
|
45
|
-
return td.req ? [k] : [];
|
|
46
|
-
if (td.t && typeof prop !== td.t)
|
|
47
|
-
return [k];
|
|
48
|
-
if (td.ary)
|
|
49
|
-
return Array.isArray(prop) ? prop.flatMap(e => validateProp(k, e, td.ary)) : [k];
|
|
50
|
-
if (td.rec)
|
|
51
|
-
return validate(prop).flatMap(k2 => `${k}.${k2}`);
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
function takeAsArray(v) {
|
|
55
|
-
return Array.isArray(v) ? v : [v];
|
|
56
|
-
}
|
|
57
|
-
UType.takeAsArray = takeAsArray;
|
|
58
|
-
})(UType = exports.UType || (exports.UType = {}));
|
package/dist/func/u.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Loggable } from "../const/types";
|
|
2
|
-
export declare function getJSTDate(d?: Date): Date;
|
|
3
|
-
export declare function delay(sec: number): Promise<void>;
|
|
4
|
-
export declare function int2array(size: number): number[];
|
|
5
|
-
export declare function array2map<K, T>(array: T[], keyGen: (e: T) => K): Map<K, T[]>;
|
|
6
|
-
export declare function bitor(...bit: number[]): number;
|
|
7
|
-
export interface RetryOption<T = void | Promise<void>> {
|
|
8
|
-
count?: number;
|
|
9
|
-
logger?: Loggable;
|
|
10
|
-
errorCriterion?: (e: any) => boolean;
|
|
11
|
-
intervalPredicate?: () => T;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* runs callback with customizable retry.
|
|
15
|
-
* @param cb callback to be retried.
|
|
16
|
-
* @param op.count number of retries. default is 1.
|
|
17
|
-
* @param op.logger logger used for exceptions while retrying the process. default is `console` object.
|
|
18
|
-
* @param op.errorCriterion distinguish whether retry is required form exceptions. default is none. (i.e. allways required.)
|
|
19
|
-
* @param op.intervalPredicate predicate that runs between callbacks when retrying.
|
|
20
|
-
*/
|
|
21
|
-
export declare function retry<T>(cb: () => T, op?: RetryOption<void>): T;
|
|
22
|
-
export declare function retry<T>(cb: () => T, op?: RetryOption<Promise<void>>): Promise<T>;
|
|
23
|
-
export declare function retry<T>(cb: () => Promise<T>, op?: RetryOption<void>): Promise<T>;
|
|
24
|
-
export declare function retry<T>(cb: () => Promise<T>, op?: RetryOption<Promise<void>>): Promise<T>;
|
package/dist/func/u.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.retry = exports.bitor = exports.array2map = exports.int2array = exports.delay = exports.getJSTDate = void 0;
|
|
4
|
-
const xjs_err_1 = require("../obj/xjs-err");
|
|
5
|
-
const s_errCode = 10;
|
|
6
|
-
function getJSTDate(d) {
|
|
7
|
-
return new Date((d ? d.getTime() : Date.now()) + 9 * 60 * 60 * 1000);
|
|
8
|
-
}
|
|
9
|
-
exports.getJSTDate = getJSTDate;
|
|
10
|
-
function delay(sec) {
|
|
11
|
-
return new Promise(resolve => setTimeout(resolve, 1000 * sec));
|
|
12
|
-
}
|
|
13
|
-
exports.delay = delay;
|
|
14
|
-
function int2array(size) {
|
|
15
|
-
const s = Number(size);
|
|
16
|
-
if (Number.isNaN(s))
|
|
17
|
-
throw new xjs_err_1.XjsErr(s_errCode, "size of the argument is not number.");
|
|
18
|
-
return Array.from(Array(s).keys());
|
|
19
|
-
}
|
|
20
|
-
exports.int2array = int2array;
|
|
21
|
-
function array2map(array, keyGen) {
|
|
22
|
-
const map = new Map();
|
|
23
|
-
for (const e of array) {
|
|
24
|
-
const k = keyGen(e);
|
|
25
|
-
if (map.has(k))
|
|
26
|
-
map.get(k).push(e);
|
|
27
|
-
else
|
|
28
|
-
map.set(k, [e]);
|
|
29
|
-
}
|
|
30
|
-
return map;
|
|
31
|
-
}
|
|
32
|
-
exports.array2map = array2map;
|
|
33
|
-
function bitor(...bit) {
|
|
34
|
-
return bit.reduce((a, b) => a | b);
|
|
35
|
-
}
|
|
36
|
-
exports.bitor = bitor;
|
|
37
|
-
;
|
|
38
|
-
function retry(cb, op) {
|
|
39
|
-
const l = op?.logger ?? console;
|
|
40
|
-
const initialCount = op?.count ?? 1;
|
|
41
|
-
const handleError = (e) => {
|
|
42
|
-
if (op?.errorCriterion && !op.errorCriterion(e))
|
|
43
|
-
return false;
|
|
44
|
-
l.warn(e);
|
|
45
|
-
return true;
|
|
46
|
-
};
|
|
47
|
-
const prcs = (c) => {
|
|
48
|
-
if (c < 0)
|
|
49
|
-
throw new xjs_err_1.XjsErr(s_errCode, "failure exceeds retryable count.");
|
|
50
|
-
let ret = null;
|
|
51
|
-
const innerPrcs = () => {
|
|
52
|
-
try {
|
|
53
|
-
ret = cb();
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
if (handleError(e))
|
|
57
|
-
ret = prcs(c - 1);
|
|
58
|
-
else
|
|
59
|
-
throw e;
|
|
60
|
-
}
|
|
61
|
-
if (ret instanceof Promise) {
|
|
62
|
-
return new Promise((resolve, reject) => ret.then(resolve).catch((e) => { if (handleError(e))
|
|
63
|
-
resolve(prcs(c - 1));
|
|
64
|
-
else
|
|
65
|
-
reject(e); }));
|
|
66
|
-
}
|
|
67
|
-
else
|
|
68
|
-
return ret;
|
|
69
|
-
};
|
|
70
|
-
if (c < initialCount && op?.intervalPredicate)
|
|
71
|
-
ret = op?.intervalPredicate();
|
|
72
|
-
return ret instanceof Promise ? ret.then(() => innerPrcs()) : innerPrcs();
|
|
73
|
-
};
|
|
74
|
-
return prcs(initialCount);
|
|
75
|
-
}
|
|
76
|
-
exports.retry = retry;
|
package/dist/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from "./const/types";
|
|
2
|
-
export * from "./const/time-unit";
|
|
3
|
-
export * from "./const/gender";
|
|
4
|
-
export * from "./const/http-method";
|
|
5
|
-
export * from "./const/ccy";
|
|
6
|
-
export * from "./func/u";
|
|
7
|
-
export * from "./func/u-obj";
|
|
8
|
-
export * from "./func/u-string";
|
|
9
|
-
export * from "./func/u-array";
|
|
10
|
-
export * from "./func/u-http";
|
|
11
|
-
export * from "./func/u-type";
|
|
12
|
-
export * from "./func/decorator/transaction";
|
|
13
|
-
export { DType } from "./func/decorator/d-type";
|
|
14
|
-
export * from "./obj/xjs-err";
|
package/dist/obj/type-exp.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Type } from "../const/types";
|
|
2
|
-
export declare class TypeExp<T> {
|
|
3
|
-
private t;
|
|
4
|
-
private readonly _m;
|
|
5
|
-
constructor(t: Type.string | Type.number | Type.bigint | Type.null | Type.symbol | Type.undefined);
|
|
6
|
-
constructor(t: Type.object, model: any);
|
|
7
|
-
match(o: any): o is T;
|
|
8
|
-
}
|
package/dist/obj/type-exp.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypeExp = void 0;
|
|
4
|
-
const types_1 = require("../const/types");
|
|
5
|
-
class TypeExp {
|
|
6
|
-
t;
|
|
7
|
-
_m;
|
|
8
|
-
constructor(t, model) {
|
|
9
|
-
this.t = t;
|
|
10
|
-
this._m = model;
|
|
11
|
-
}
|
|
12
|
-
match(o) {
|
|
13
|
-
if (typeof o !== this.t)
|
|
14
|
-
return false;
|
|
15
|
-
if (this.t !== types_1.Type.object)
|
|
16
|
-
return true;
|
|
17
|
-
const isArray = Array.isArray(o);
|
|
18
|
-
if (isArray !== Array.isArray(this._m))
|
|
19
|
-
return false;
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.TypeExp = TypeExp;
|
package/dist/obj/xjs-err.d.ts
DELETED
package/dist/obj/xjs-err.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XjsErr = void 0;
|
|
4
|
-
class XjsErr extends Error {
|
|
5
|
-
code;
|
|
6
|
-
origin;
|
|
7
|
-
constructor(code, msg, origin) {
|
|
8
|
-
super(`[XJS] ${msg}`);
|
|
9
|
-
this.code = code;
|
|
10
|
-
this.origin = origin;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.XjsErr = XjsErr;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { ClientOption, HttpResponse, IHttpClient, RequestOption } from "./i-http-client";
|
|
2
|
-
import { Loggable } from "../../const/types";
|
|
3
|
-
export declare const s_clientMode: {
|
|
4
|
-
nodejs: {
|
|
5
|
-
id: number;
|
|
6
|
-
cipherOrder: any;
|
|
7
|
-
};
|
|
8
|
-
chrome: {
|
|
9
|
-
id: number;
|
|
10
|
-
cipherOrder: number[];
|
|
11
|
-
};
|
|
12
|
-
firefox: {
|
|
13
|
-
id: number;
|
|
14
|
-
cipherOrder: number[];
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export declare class HttpResolverContext implements IHttpClient {
|
|
18
|
-
readonly cmv: number;
|
|
19
|
-
private _l;
|
|
20
|
-
private readonly _als;
|
|
21
|
-
private readonly _mode;
|
|
22
|
-
private readonly _ciphers;
|
|
23
|
-
private readonly _proxyConfig?;
|
|
24
|
-
private readonly _chHeaders;
|
|
25
|
-
private _cookies?;
|
|
26
|
-
get clientMode(): string;
|
|
27
|
-
constructor(cmv: number, op?: ClientOption, _l?: Loggable);
|
|
28
|
-
/**
|
|
29
|
-
* request GET to the url.
|
|
30
|
-
* @param url target url.
|
|
31
|
-
* @param op.headers http headers.
|
|
32
|
-
* @param op.ignoreQuery {@link RequestOption.ignoreQuery}
|
|
33
|
-
* @param op.downloadPath {@link RequestOption.downloadPath}
|
|
34
|
-
* @param op.timeout {@link RequestOption.timeout}
|
|
35
|
-
* @returns string encoded by utf-8 as response payload.
|
|
36
|
-
*/
|
|
37
|
-
get(url: string, op?: RequestOption & {
|
|
38
|
-
outerRedirectCount?: number;
|
|
39
|
-
}): Promise<HttpResponse>;
|
|
40
|
-
/**
|
|
41
|
-
* request POST to the url.
|
|
42
|
-
* @param url target url.
|
|
43
|
-
* @param payload request payload. if this is an object, it is treated as json.
|
|
44
|
-
* @param op.headers http headers.
|
|
45
|
-
* @param op.ignoreQuery {@link RequestOption.ignoreQuery}
|
|
46
|
-
* @param op.downloadPath {@link RequestOption.downloadPath}
|
|
47
|
-
* @param op.timeout {@link RequestOption.timeout}
|
|
48
|
-
* @returns string encoded by utf-8 as response payload.
|
|
49
|
-
*/
|
|
50
|
-
post(url: string, payload: any, op?: RequestOption): Promise<HttpResponse>;
|
|
51
|
-
private createProxyAgent;
|
|
52
|
-
private getIn;
|
|
53
|
-
private postIn;
|
|
54
|
-
private reqHttps;
|
|
55
|
-
private processResponse;
|
|
56
|
-
private resolveDownloadPath;
|
|
57
|
-
private handleRedirect;
|
|
58
|
-
private createCiphers;
|
|
59
|
-
private setCookies;
|
|
60
|
-
private storeCookies;
|
|
61
|
-
private log;
|
|
62
|
-
private warn;
|
|
63
|
-
private error;
|
|
64
|
-
}
|