namirasoft-core 1.3.47 → 1.3.48
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/ConsoleColor.d.ts +9 -0
- package/dist/ConsoleColor.js +38 -0
- package/dist/ConsoleColor.js.map +10 -0
- package/dist/ConsoleColorService.d.ts +9 -0
- package/dist/ConsoleColorService.js +41 -0
- package/dist/ConsoleColorService.js.map +10 -0
- package/dist/RegexTemplate.js +1 -1
- package/dist/RegexTemplate.js.map +1 -1
- package/package.json +1 -1
- package/src/BaseDatabaseRow.ts +6 -6
- package/src/BaseServer.ts +83 -83
- package/src/ConsoleOperation.ts +68 -68
- package/src/ConvertService.ts +100 -100
- package/src/Countries.ts +486 -486
- package/src/Country.ts +21 -21
- package/src/CountryOperation.ts +98 -98
- package/src/EncodingOperation.ts +10 -10
- package/src/EncryptionOperation.ts +40 -40
- package/src/ErrorOperation.ts +13 -13
- package/src/FileOperation.ts +57 -57
- package/src/FilterItem.ts +74 -74
- package/src/FilterItemColumnType.ts +6 -6
- package/src/FilterItemOperator.ts +49 -49
- package/src/GeoOperation.ts +18 -18
- package/src/HTTPError.ts +8 -8
- package/src/HTTPMethod.ts +6 -6
- package/src/HashOperation.ts +24 -24
- package/src/IStorage.ts +5 -5
- package/src/IStorageCookie.ts +52 -52
- package/src/IStorageLocal.ts +16 -16
- package/src/IStorageMemory.ts +17 -17
- package/src/NamingConvention.ts +107 -107
- package/src/ObjectService.ts +23 -23
- package/src/PackageService.ts +76 -76
- package/src/PhoneOperation.ts +8 -8
- package/src/RegexTemplate.ts +7 -7
- package/src/StringOperation.ts +18 -18
- package/src/TimeOperation.ts +262 -262
- package/src/URLOperation.ts +54 -54
- package/src/VersionOperation.ts +46 -46
- package/src/index.ts +31 -31
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class ConsoleOperation
|
|
2
|
+
{
|
|
3
|
+
private static colors;
|
|
4
|
+
static log(message: string): string;
|
|
5
|
+
static info(message: string): string;
|
|
6
|
+
static success(message: string): string;
|
|
7
|
+
static warning(message: string): string;
|
|
8
|
+
static error(message: string): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsoleOperation = void 0;
|
|
4
|
+
class ConsoleOperation
|
|
5
|
+
{
|
|
6
|
+
static log(message)
|
|
7
|
+
{
|
|
8
|
+
return (this.colors.white + message + this.colors.reset);
|
|
9
|
+
}
|
|
10
|
+
static info(message)
|
|
11
|
+
{
|
|
12
|
+
return (this.colors.cyan + message + this.colors.reset);
|
|
13
|
+
}
|
|
14
|
+
static success(message)
|
|
15
|
+
{
|
|
16
|
+
return (this.colors.green + message + this.colors.reset);
|
|
17
|
+
}
|
|
18
|
+
static warning(message)
|
|
19
|
+
{
|
|
20
|
+
return (this.colors.yellow + message + this.colors.reset);
|
|
21
|
+
}
|
|
22
|
+
static error(message)
|
|
23
|
+
{
|
|
24
|
+
return (this.colors.red + message + this.colors.reset);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ConsoleOperation = ConsoleOperation;
|
|
28
|
+
ConsoleOperation.colors = {
|
|
29
|
+
reset: '\x1b[0m',
|
|
30
|
+
red: '\x1b[31m',
|
|
31
|
+
green: '\x1b[32m',
|
|
32
|
+
yellow: '\x1b[33m',
|
|
33
|
+
blue: '\x1b[34m',
|
|
34
|
+
magenta: '\x1b[35m',
|
|
35
|
+
cyan: '\x1b[36m',
|
|
36
|
+
white: '\x1b[37m',
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=ConsoleOperation.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "ConsoleOperation.js",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../src/ConsoleOperation.ts"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": ";;;AAAA,MAAa,YAAY;IAYrB,MAAM,CAAC,GAAG,CAAC,OAAe;QAEtB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,OAAe;QAEvB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,OAAe;QAE1B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,OAAe;QAE1B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,OAAe;QAExB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;;AA/BL,oCAgCC;AA9BkB,mBAAM,GAAG;IACpB,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;CACpB,CAAC"
|
|
10
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsoleOperationService = void 0;
|
|
4
|
+
class ConsoleOperationService
|
|
5
|
+
{
|
|
6
|
+
constructor()
|
|
7
|
+
{
|
|
8
|
+
this.colors = {
|
|
9
|
+
reset: '\x1b[0m',
|
|
10
|
+
red: '\x1b[31m',
|
|
11
|
+
green: '\x1b[32m',
|
|
12
|
+
yellow: '\x1b[33m',
|
|
13
|
+
blue: '\x1b[34m',
|
|
14
|
+
magenta: '\x1b[35m',
|
|
15
|
+
cyan: '\x1b[36m',
|
|
16
|
+
white: '\x1b[37m',
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
log(message)
|
|
20
|
+
{
|
|
21
|
+
return (this.colors.white + message + this.colors.reset);
|
|
22
|
+
}
|
|
23
|
+
info(message)
|
|
24
|
+
{
|
|
25
|
+
return (this.colors.cyan + message + this.colors.reset);
|
|
26
|
+
}
|
|
27
|
+
success(message)
|
|
28
|
+
{
|
|
29
|
+
return (this.colors.green + message + this.colors.reset);
|
|
30
|
+
}
|
|
31
|
+
warning(message)
|
|
32
|
+
{
|
|
33
|
+
return (this.colors.yellow + message + this.colors.reset);
|
|
34
|
+
}
|
|
35
|
+
error(message)
|
|
36
|
+
{
|
|
37
|
+
return (this.colors.red + message + this.colors.reset);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.ConsoleOperationService = ConsoleOperationService;
|
|
41
|
+
//# sourceMappingURL=ConsoleOperationService.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "ConsoleOperationService.js",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../src/ConsoleOperationService.ts"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": ";;;AAAA,MAAa,mBAAmB;IAAhC;QAEY,WAAM,GAAG;YACb,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,UAAU;YACjB,MAAM,EAAE,UAAU;YAClB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,UAAU;YACnB,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,UAAU;SACpB,CAAC;IAqBN,CAAC;IApBG,GAAG,CAAC,OAAe;QAEf,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,CAAC,OAAe;QAEhB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,CAAC,OAAe;QAEnB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,CAAC,OAAe;QAEnB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;IACD,KAAK,CAAC,OAAe;QAEjB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;CACJ;AAhCD,kDAgCC"
|
|
10
|
+
}
|
package/dist/RegexTemplate.js
CHANGED
|
@@ -7,6 +7,6 @@ exports.RegexTemplate = RegexTemplate;
|
|
|
7
7
|
RegexTemplate.Date = /^(?!0000)[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$/gm;
|
|
8
8
|
RegexTemplate.Time = /^([01]\d|2[0-3]):([0-5]\d)$/gm;
|
|
9
9
|
RegexTemplate.Duration = /^(\d+d\s)?([01]\d|2[0-3]):([0-5]\d)$/gm;
|
|
10
|
-
RegexTemplate.Email = /^[\w]+@([\w]+\.)+\w{2,}$/gm;
|
|
10
|
+
RegexTemplate.Email = /^[\w\._-]+@([\w]+\.)+\w{2,}$/gm;
|
|
11
11
|
RegexTemplate.IP = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/gm;
|
|
12
12
|
//# sourceMappingURL=RegexTemplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegexTemplate.js","sourceRoot":"","sources":["../src/RegexTemplate.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;;AAA1B,sCAOC;AALU,kBAAI,GAAW,mEAAmE,CAAC;AACnF,kBAAI,GAAW,+BAA+B,CAAC;AAC/C,sBAAQ,GAAW,wCAAwC,CAAC;AAC5D,mBAAK,GAAW,
|
|
1
|
+
{"version":3,"file":"RegexTemplate.js","sourceRoot":"","sources":["../src/RegexTemplate.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;;AAA1B,sCAOC;AALU,kBAAI,GAAW,mEAAmE,CAAC;AACnF,kBAAI,GAAW,+BAA+B,CAAC;AAC/C,sBAAQ,GAAW,wCAAwC,CAAC;AAC5D,mBAAK,GAAW,gCAAgC,CAAC;AACjD,gBAAE,GAAW,oKAAoK,CAAC"}
|
package/package.json
CHANGED
package/src/BaseDatabaseRow.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type BaseDatabaseRow<ID> =
|
|
2
|
-
{
|
|
3
|
-
id: ID;
|
|
4
|
-
createdAt: string;
|
|
5
|
-
updatedAt: string;
|
|
6
|
-
deletedAt: string;
|
|
1
|
+
export type BaseDatabaseRow<ID> =
|
|
2
|
+
{
|
|
3
|
+
id: ID;
|
|
4
|
+
createdAt: string;
|
|
5
|
+
updatedAt: string;
|
|
6
|
+
deletedAt: string;
|
|
7
7
|
}
|
package/src/BaseServer.ts
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
2
|
-
import { HashOperation } from "./HashOperation";
|
|
3
|
-
import { URLOperation } from "./URLOperation";
|
|
4
|
-
import { ErrorOperation } from "./ErrorOperation";
|
|
5
|
-
import { ParsedNameValue } from "./ParsedNameValue";
|
|
6
|
-
import { ConsoleOperation } from "./ConsoleOperation";
|
|
7
|
-
|
|
8
|
-
export abstract class BaseServer
|
|
9
|
-
{
|
|
10
|
-
protected domain: string;
|
|
11
|
-
public suppressErrors: boolean = false;
|
|
12
|
-
constructor(domain: string)
|
|
13
|
-
{
|
|
14
|
-
this.domain = domain;
|
|
15
|
-
}
|
|
16
|
-
protected abstract onBeforeRequest<ReqData = any>(url: string, config?: AxiosRequestConfig<ReqData>): void;
|
|
17
|
-
protected abstract onAfterRequest<ResData = any>(url: string, response: AxiosResponse<ResData>): void;
|
|
18
|
-
protected abstract onError(error: Error): void;
|
|
19
|
-
private async _request<ResData = any, ReqData = any>(onRequest: (url: string, data?: any, config?: AxiosRequestConfig<ReqData>) => Promise<AxiosResponse<ResData>>, sub: string, query?: { [name: string]: ParsedNameValue }, data?: ReqData, config?: AxiosRequestConfig<ReqData>, sign_header?: string, sign_key?: string): Promise<{ response: AxiosResponse<ResData>, data: ResData }>
|
|
20
|
-
{
|
|
21
|
-
let url: string = URLOperation.getLink(this.domain, sub, query);
|
|
22
|
-
if (!config)
|
|
23
|
-
config = { headers: {} };
|
|
24
|
-
if (sign_header)
|
|
25
|
-
if (sign_key)
|
|
26
|
-
if (data)
|
|
27
|
-
if (config?.headers)
|
|
28
|
-
config.headers[sign_header] = HashOperation.SHA256Secret(sign_key, data);
|
|
29
|
-
try
|
|
30
|
-
{
|
|
31
|
-
this.onBeforeRequest(url, config);
|
|
32
|
-
let response: AxiosResponse<ResData> = await onRequest(url, data, config);
|
|
33
|
-
this.onAfterRequest(url, response);
|
|
34
|
-
return { response, data: response.data };
|
|
35
|
-
} catch (error)
|
|
36
|
-
{
|
|
37
|
-
if (error instanceof Error)
|
|
38
|
-
{
|
|
39
|
-
if (this.onError)
|
|
40
|
-
this.onError(error);
|
|
41
|
-
else
|
|
42
|
-
{
|
|
43
|
-
ConsoleOperation.warning("onError function has not been properly set.");
|
|
44
|
-
ConsoleOperation.error(error?.message);
|
|
45
|
-
}
|
|
46
|
-
if (axios.isAxiosError(error))
|
|
47
|
-
if (error?.response?.data)
|
|
48
|
-
if (!this.suppressErrors)
|
|
49
|
-
ErrorOperation.throwHTTP(error.response.status, error.response.data);
|
|
50
|
-
}
|
|
51
|
-
if (!this.suppressErrors)
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
return {} as any;
|
|
55
|
-
}
|
|
56
|
-
protected async _get<ResData = any, ReqData = any>(sub: string, query?: { [name: string]: ParsedNameValue }, config?: AxiosRequestConfig<ReqData>): Promise<{ response: AxiosResponse<ResData>, data: ResData }>
|
|
57
|
-
{
|
|
58
|
-
return await this._request(async (url: string, _?: any, config?: AxiosRequestConfig<ReqData>) =>
|
|
59
|
-
{
|
|
60
|
-
return await axios.get(url, config);
|
|
61
|
-
}, sub, query, undefined, config);
|
|
62
|
-
}
|
|
63
|
-
protected async _post<ResData = any, ReqData = any>(sub: string, query?: { [name: string]: ParsedNameValue }, data?: ReqData, config?: AxiosRequestConfig<ReqData>, sign_header?: string, sign_key?: string): Promise<{ response: AxiosResponse<ResData>, data: ResData }>
|
|
64
|
-
{
|
|
65
|
-
return await this._request(async (url: string, data: ReqData, config?: AxiosRequestConfig<ReqData>) =>
|
|
66
|
-
{
|
|
67
|
-
return await axios.post(url, data, config);
|
|
68
|
-
}, sub, query, data, config, sign_header, sign_key);
|
|
69
|
-
}
|
|
70
|
-
protected async _put<ResData = any, ReqData = any>(sub: string, query?: { [name: string]: ParsedNameValue }, data?: ReqData, config?: AxiosRequestConfig<ReqData>, sign_header?: string, sign_key?: string): Promise<{ response: AxiosResponse<ResData>, data: ResData }>
|
|
71
|
-
{
|
|
72
|
-
return await this._request(async (url: string, data: ReqData, config?: AxiosRequestConfig<ReqData>) =>
|
|
73
|
-
{
|
|
74
|
-
return await axios.put(url, data, config);
|
|
75
|
-
}, sub, query, data, config, sign_header, sign_key);
|
|
76
|
-
}
|
|
77
|
-
protected async _delete<ResData = any, ReqData = any>(sub: string, query?: { [name: string]: ParsedNameValue }, config?: AxiosRequestConfig<ReqData>, sign_header?: string, sign_key?: string): Promise<{ response: AxiosResponse<ResData>, data: ResData }>
|
|
78
|
-
{
|
|
79
|
-
return await this._request(async (url: string, _?: any, config?: AxiosRequestConfig<ReqData>) =>
|
|
80
|
-
{
|
|
81
|
-
return await axios.delete(url, config);
|
|
82
|
-
}, sub, query, undefined, config, sign_header, sign_key);
|
|
83
|
-
}
|
|
1
|
+
import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
2
|
+
import { HashOperation } from "./HashOperation";
|
|
3
|
+
import { URLOperation } from "./URLOperation";
|
|
4
|
+
import { ErrorOperation } from "./ErrorOperation";
|
|
5
|
+
import { ParsedNameValue } from "./ParsedNameValue";
|
|
6
|
+
import { ConsoleOperation } from "./ConsoleOperation";
|
|
7
|
+
|
|
8
|
+
export abstract class BaseServer
|
|
9
|
+
{
|
|
10
|
+
protected domain: string;
|
|
11
|
+
public suppressErrors: boolean = false;
|
|
12
|
+
constructor(domain: string)
|
|
13
|
+
{
|
|
14
|
+
this.domain = domain;
|
|
15
|
+
}
|
|
16
|
+
protected abstract onBeforeRequest<ReqData = any>(url: string, config?: AxiosRequestConfig<ReqData>): void;
|
|
17
|
+
protected abstract onAfterRequest<ResData = any>(url: string, response: AxiosResponse<ResData>): void;
|
|
18
|
+
protected abstract onError(error: Error): void;
|
|
19
|
+
private async _request<ResData = any, ReqData = any>(onRequest: (url: string, data?: any, config?: AxiosRequestConfig<ReqData>) => Promise<AxiosResponse<ResData>>, sub: string, query?: { [name: string]: ParsedNameValue }, data?: ReqData, config?: AxiosRequestConfig<ReqData>, sign_header?: string, sign_key?: string): Promise<{ response: AxiosResponse<ResData>, data: ResData }>
|
|
20
|
+
{
|
|
21
|
+
let url: string = URLOperation.getLink(this.domain, sub, query);
|
|
22
|
+
if (!config)
|
|
23
|
+
config = { headers: {} };
|
|
24
|
+
if (sign_header)
|
|
25
|
+
if (sign_key)
|
|
26
|
+
if (data)
|
|
27
|
+
if (config?.headers)
|
|
28
|
+
config.headers[sign_header] = HashOperation.SHA256Secret(sign_key, data);
|
|
29
|
+
try
|
|
30
|
+
{
|
|
31
|
+
this.onBeforeRequest(url, config);
|
|
32
|
+
let response: AxiosResponse<ResData> = await onRequest(url, data, config);
|
|
33
|
+
this.onAfterRequest(url, response);
|
|
34
|
+
return { response, data: response.data };
|
|
35
|
+
} catch (error)
|
|
36
|
+
{
|
|
37
|
+
if (error instanceof Error)
|
|
38
|
+
{
|
|
39
|
+
if (this.onError)
|
|
40
|
+
this.onError(error);
|
|
41
|
+
else
|
|
42
|
+
{
|
|
43
|
+
ConsoleOperation.warning("onError function has not been properly set.");
|
|
44
|
+
ConsoleOperation.error(error?.message);
|
|
45
|
+
}
|
|
46
|
+
if (axios.isAxiosError(error))
|
|
47
|
+
if (error?.response?.data)
|
|
48
|
+
if (!this.suppressErrors)
|
|
49
|
+
ErrorOperation.throwHTTP(error.response.status, error.response.data);
|
|
50
|
+
}
|
|
51
|
+
if (!this.suppressErrors)
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
return {} as any;
|
|
55
|
+
}
|
|
56
|
+
protected async _get<ResData = any, ReqData = any>(sub: string, query?: { [name: string]: ParsedNameValue }, config?: AxiosRequestConfig<ReqData>): Promise<{ response: AxiosResponse<ResData>, data: ResData }>
|
|
57
|
+
{
|
|
58
|
+
return await this._request(async (url: string, _?: any, config?: AxiosRequestConfig<ReqData>) =>
|
|
59
|
+
{
|
|
60
|
+
return await axios.get(url, config);
|
|
61
|
+
}, sub, query, undefined, config);
|
|
62
|
+
}
|
|
63
|
+
protected async _post<ResData = any, ReqData = any>(sub: string, query?: { [name: string]: ParsedNameValue }, data?: ReqData, config?: AxiosRequestConfig<ReqData>, sign_header?: string, sign_key?: string): Promise<{ response: AxiosResponse<ResData>, data: ResData }>
|
|
64
|
+
{
|
|
65
|
+
return await this._request(async (url: string, data: ReqData, config?: AxiosRequestConfig<ReqData>) =>
|
|
66
|
+
{
|
|
67
|
+
return await axios.post(url, data, config);
|
|
68
|
+
}, sub, query, data, config, sign_header, sign_key);
|
|
69
|
+
}
|
|
70
|
+
protected async _put<ResData = any, ReqData = any>(sub: string, query?: { [name: string]: ParsedNameValue }, data?: ReqData, config?: AxiosRequestConfig<ReqData>, sign_header?: string, sign_key?: string): Promise<{ response: AxiosResponse<ResData>, data: ResData }>
|
|
71
|
+
{
|
|
72
|
+
return await this._request(async (url: string, data: ReqData, config?: AxiosRequestConfig<ReqData>) =>
|
|
73
|
+
{
|
|
74
|
+
return await axios.put(url, data, config);
|
|
75
|
+
}, sub, query, data, config, sign_header, sign_key);
|
|
76
|
+
}
|
|
77
|
+
protected async _delete<ResData = any, ReqData = any>(sub: string, query?: { [name: string]: ParsedNameValue }, config?: AxiosRequestConfig<ReqData>, sign_header?: string, sign_key?: string): Promise<{ response: AxiosResponse<ResData>, data: ResData }>
|
|
78
|
+
{
|
|
79
|
+
return await this._request(async (url: string, _?: any, config?: AxiosRequestConfig<ReqData>) =>
|
|
80
|
+
{
|
|
81
|
+
return await axios.delete(url, config);
|
|
82
|
+
}, sub, query, undefined, config, sign_header, sign_key);
|
|
83
|
+
}
|
|
84
84
|
}
|
package/src/ConsoleOperation.ts
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
export class ConsoleOperation
|
|
2
|
-
{
|
|
3
|
-
public static colors = {
|
|
4
|
-
reset: '\x1b[0m',
|
|
5
|
-
red: '\x1b[31m',
|
|
6
|
-
green: '\x1b[32m',
|
|
7
|
-
yellow: '\x1b[33m',
|
|
8
|
-
blue: '\x1b[34m',
|
|
9
|
-
magenta: '\x1b[35m',
|
|
10
|
-
cyan: '\x1b[36m',
|
|
11
|
-
white: '\x1b[37m',
|
|
12
|
-
};
|
|
13
|
-
static formatLogColor(message: string)
|
|
14
|
-
{
|
|
15
|
-
return (ConsoleOperation.colors.white + message + ConsoleOperation.colors.reset);
|
|
16
|
-
}
|
|
17
|
-
static formatInfoColor(message: string)
|
|
18
|
-
{
|
|
19
|
-
return (ConsoleOperation.colors.cyan + message + ConsoleOperation.colors.reset);
|
|
20
|
-
}
|
|
21
|
-
static formatTraceColor(message: string)
|
|
22
|
-
{
|
|
23
|
-
return (ConsoleOperation.colors.blue + message + ConsoleOperation.colors.reset);
|
|
24
|
-
}
|
|
25
|
-
static formatDebugColor(message: string)
|
|
26
|
-
{
|
|
27
|
-
return (ConsoleOperation.colors.magenta + message + ConsoleOperation.colors.reset);
|
|
28
|
-
}
|
|
29
|
-
static formatSuccessColor(message: string)
|
|
30
|
-
{
|
|
31
|
-
return (ConsoleOperation.colors.green + message + ConsoleOperation.colors.reset);
|
|
32
|
-
}
|
|
33
|
-
static formatWarningColor(message: string)
|
|
34
|
-
{
|
|
35
|
-
return (ConsoleOperation.colors.yellow + message + ConsoleOperation.colors.reset);
|
|
36
|
-
}
|
|
37
|
-
static formatErrorColor(message: string)
|
|
38
|
-
{
|
|
39
|
-
return (ConsoleOperation.colors.red + message + ConsoleOperation.colors.reset);
|
|
40
|
-
}
|
|
41
|
-
static log(message: string)
|
|
42
|
-
{
|
|
43
|
-
console.log(ConsoleOperation.formatLogColor(message));
|
|
44
|
-
}
|
|
45
|
-
static info(message: string)
|
|
46
|
-
{
|
|
47
|
-
console.info(ConsoleOperation.formatInfoColor(message));
|
|
48
|
-
}
|
|
49
|
-
static trace(message: string)
|
|
50
|
-
{
|
|
51
|
-
console.trace(ConsoleOperation.formatTraceColor(message));
|
|
52
|
-
}
|
|
53
|
-
static debug(message: string)
|
|
54
|
-
{
|
|
55
|
-
console.debug(ConsoleOperation.formatDebugColor(message));
|
|
56
|
-
}
|
|
57
|
-
static success(message: string)
|
|
58
|
-
{
|
|
59
|
-
console.info(ConsoleOperation.formatSuccessColor(message));
|
|
60
|
-
}
|
|
61
|
-
static warning(message: string)
|
|
62
|
-
{
|
|
63
|
-
console.warn(ConsoleOperation.formatWarningColor(message));
|
|
64
|
-
}
|
|
65
|
-
static error(message: string)
|
|
66
|
-
{
|
|
67
|
-
console.error(ConsoleOperation.formatErrorColor(message));
|
|
68
|
-
}
|
|
1
|
+
export class ConsoleOperation
|
|
2
|
+
{
|
|
3
|
+
public static colors = {
|
|
4
|
+
reset: '\x1b[0m',
|
|
5
|
+
red: '\x1b[31m',
|
|
6
|
+
green: '\x1b[32m',
|
|
7
|
+
yellow: '\x1b[33m',
|
|
8
|
+
blue: '\x1b[34m',
|
|
9
|
+
magenta: '\x1b[35m',
|
|
10
|
+
cyan: '\x1b[36m',
|
|
11
|
+
white: '\x1b[37m',
|
|
12
|
+
};
|
|
13
|
+
static formatLogColor(message: string)
|
|
14
|
+
{
|
|
15
|
+
return (ConsoleOperation.colors.white + message + ConsoleOperation.colors.reset);
|
|
16
|
+
}
|
|
17
|
+
static formatInfoColor(message: string)
|
|
18
|
+
{
|
|
19
|
+
return (ConsoleOperation.colors.cyan + message + ConsoleOperation.colors.reset);
|
|
20
|
+
}
|
|
21
|
+
static formatTraceColor(message: string)
|
|
22
|
+
{
|
|
23
|
+
return (ConsoleOperation.colors.blue + message + ConsoleOperation.colors.reset);
|
|
24
|
+
}
|
|
25
|
+
static formatDebugColor(message: string)
|
|
26
|
+
{
|
|
27
|
+
return (ConsoleOperation.colors.magenta + message + ConsoleOperation.colors.reset);
|
|
28
|
+
}
|
|
29
|
+
static formatSuccessColor(message: string)
|
|
30
|
+
{
|
|
31
|
+
return (ConsoleOperation.colors.green + message + ConsoleOperation.colors.reset);
|
|
32
|
+
}
|
|
33
|
+
static formatWarningColor(message: string)
|
|
34
|
+
{
|
|
35
|
+
return (ConsoleOperation.colors.yellow + message + ConsoleOperation.colors.reset);
|
|
36
|
+
}
|
|
37
|
+
static formatErrorColor(message: string)
|
|
38
|
+
{
|
|
39
|
+
return (ConsoleOperation.colors.red + message + ConsoleOperation.colors.reset);
|
|
40
|
+
}
|
|
41
|
+
static log(message: string)
|
|
42
|
+
{
|
|
43
|
+
console.log(ConsoleOperation.formatLogColor(message));
|
|
44
|
+
}
|
|
45
|
+
static info(message: string)
|
|
46
|
+
{
|
|
47
|
+
console.info(ConsoleOperation.formatInfoColor(message));
|
|
48
|
+
}
|
|
49
|
+
static trace(message: string)
|
|
50
|
+
{
|
|
51
|
+
console.trace(ConsoleOperation.formatTraceColor(message));
|
|
52
|
+
}
|
|
53
|
+
static debug(message: string)
|
|
54
|
+
{
|
|
55
|
+
console.debug(ConsoleOperation.formatDebugColor(message));
|
|
56
|
+
}
|
|
57
|
+
static success(message: string)
|
|
58
|
+
{
|
|
59
|
+
console.info(ConsoleOperation.formatSuccessColor(message));
|
|
60
|
+
}
|
|
61
|
+
static warning(message: string)
|
|
62
|
+
{
|
|
63
|
+
console.warn(ConsoleOperation.formatWarningColor(message));
|
|
64
|
+
}
|
|
65
|
+
static error(message: string)
|
|
66
|
+
{
|
|
67
|
+
console.error(ConsoleOperation.formatErrorColor(message));
|
|
68
|
+
}
|
|
69
69
|
}
|