@ancon/wildcat-utils 1.12.0 → 1.13.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/index.js +1 -1
- package/index.mjs +30 -28
- package/logger/Logger.d.ts +10 -8
- package/logger/Logger.js +1 -1
- package/logger/Logger.mjs +14 -7
- package/logger/index.d.ts +3 -2
- package/logger/index.js +1 -1
- package/logger/index.mjs +5 -3
- package/logger/sanitizeAsStringDict.d.ts +2 -0
- package/logger/sanitizeAsStringDict.js +1 -0
- package/logger/sanitizeAsStringDict.mjs +19 -0
- package/logger/types.d.ts +11 -2
- package/package.json +6 -1
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/enums.js"),r=require("./shared/isWithinFlag.js"),i=require("./shared/generateId.js"),t=require("./outlet/getListOutletOpeningHoursTable.js"),n=require("./versioning/isVersionALessThanB.js"),s=require("./versioning/cleanVersionString.js"),o=require("./api/getUrlAndParams.js"),g=require("./api/getEndpointWithVersion.js"),l=require("./string/slugify.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/enums.js"),r=require("./shared/isWithinFlag.js"),i=require("./shared/generateId.js"),t=require("./outlet/getListOutletOpeningHoursTable.js"),n=require("./versioning/isVersionALessThanB.js"),s=require("./versioning/cleanVersionString.js"),o=require("./api/getUrlAndParams.js"),g=require("./api/getEndpointWithVersion.js"),l=require("./string/slugify.js"),a=require("./color/lighten.js"),u=require("./color/brighten.js"),c=require("./color/darken.js"),d=require("./user/getFullName.js"),q=require("./user/getFullAddressString.js"),_=require("./logger/Logger.js"),p=require("./logger/types.js"),h=require("./logger/sanitizeAsStringDict.js"),S=require("./printing/isValidPrinter.js"),V=require("./printing/isValidNetworkPrinter.js"),y=require("./printing/isValidStarCloudPrinter.js"),P=require("./printing/getPrinterType.js");require("moment");require("@ancon/wildcat-types");require("compare-versions");require("tinycolor2");require("@ancon/wildcat-printing");exports.DayOfWeek=e.DayOfWeek;exports.IntervalState=e.IntervalState;exports.IntervalType=e.IntervalType;exports.OrderFormat=e.OrderFormat;exports.isWithinFlag=r;exports.generateId=i;exports.getListOutletOpeningHoursTable=t;exports.isVersionALessThanB=n;exports.cleanVersionString=s;exports.getUrlAndParams=o;exports.getEndpointWithVersion=g;exports.slugify=l;exports.lighten=a;exports.brighten=u;exports.darken=c;exports.getFullName=d;exports.getFullAddressString=q;exports.Logger=_;exports.LogLevel=p.LogLevel;exports.sanitizeAsStringDict=h;exports.isValidPrinter=S;exports.isValidNetworkPrinter=V;exports.isValidStarCloudPrinter=y;exports.getPrinterType=P;
|
package/index.mjs
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { DayOfWeek as s, IntervalState as i, IntervalType as d, OrderFormat as p } from "./shared/enums.mjs";
|
|
2
|
-
import { default as
|
|
2
|
+
import { default as n } from "./shared/isWithinFlag.mjs";
|
|
3
3
|
import { default as x } from "./shared/generateId.mjs";
|
|
4
4
|
import { default as V } from "./outlet/getListOutletOpeningHoursTable.mjs";
|
|
5
5
|
import { default as L } from "./versioning/isVersionALessThanB.mjs";
|
|
6
|
-
import { default as
|
|
7
|
-
import { default as
|
|
8
|
-
import { default as
|
|
9
|
-
import { default as
|
|
6
|
+
import { default as S } from "./versioning/cleanVersionString.mjs";
|
|
7
|
+
import { default as A } from "./api/getUrlAndParams.mjs";
|
|
8
|
+
import { default as O } from "./api/getEndpointWithVersion.mjs";
|
|
9
|
+
import { default as k } from "./string/slugify.mjs";
|
|
10
10
|
import { default as I } from "./color/lighten.mjs";
|
|
11
11
|
import { default as b } from "./color/brighten.mjs";
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { LogLevel as
|
|
17
|
-
import { default as
|
|
18
|
-
import { default as J } from "./printing/
|
|
19
|
-
import { default as M } from "./printing/
|
|
20
|
-
import { default as R } from "./printing/
|
|
12
|
+
import { default as D } from "./color/darken.mjs";
|
|
13
|
+
import { default as w } from "./user/getFullName.mjs";
|
|
14
|
+
import { default as B } from "./user/getFullAddressString.mjs";
|
|
15
|
+
import { default as E } from "./logger/Logger.mjs";
|
|
16
|
+
import { LogLevel as U } from "./logger/types.mjs";
|
|
17
|
+
import { default as q } from "./logger/sanitizeAsStringDict.mjs";
|
|
18
|
+
import { default as J } from "./printing/isValidPrinter.mjs";
|
|
19
|
+
import { default as M } from "./printing/isValidNetworkPrinter.mjs";
|
|
20
|
+
import { default as R } from "./printing/isValidStarCloudPrinter.mjs";
|
|
21
|
+
import { default as Y } from "./printing/getPrinterType.mjs";
|
|
21
22
|
import "moment";
|
|
22
23
|
import "@ancon/wildcat-types";
|
|
23
24
|
import "compare-versions";
|
|
@@ -27,24 +28,25 @@ export {
|
|
|
27
28
|
s as DayOfWeek,
|
|
28
29
|
i as IntervalState,
|
|
29
30
|
d as IntervalType,
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
U as LogLevel,
|
|
32
|
+
E as Logger,
|
|
32
33
|
p as OrderFormat,
|
|
33
34
|
b as brighten,
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
S as cleanVersionString,
|
|
36
|
+
D as darken,
|
|
36
37
|
x as generateId,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
O as getEndpointWithVersion,
|
|
39
|
+
B as getFullAddressString,
|
|
40
|
+
w as getFullName,
|
|
40
41
|
V as getListOutletOpeningHoursTable,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
Y as getPrinterType,
|
|
43
|
+
A as getUrlAndParams,
|
|
44
|
+
M as isValidNetworkPrinter,
|
|
45
|
+
J as isValidPrinter,
|
|
46
|
+
R as isValidStarCloudPrinter,
|
|
46
47
|
L as isVersionALessThanB,
|
|
47
|
-
|
|
48
|
+
n as isWithinFlag,
|
|
48
49
|
I as lighten,
|
|
49
|
-
|
|
50
|
+
q as sanitizeAsStringDict,
|
|
51
|
+
k as slugify
|
|
50
52
|
};
|
package/logger/Logger.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { LogStrategy } from './types';
|
|
2
|
+
declare class Logger {
|
|
3
3
|
private logStrategy;
|
|
4
4
|
constructor(logStrategy: LogStrategy);
|
|
5
|
+
private sanitize;
|
|
5
6
|
setLogStrategy(logStrategy: LogStrategy): void;
|
|
6
|
-
verbose(message: string,
|
|
7
|
-
debug(message: string,
|
|
8
|
-
info(message: string,
|
|
9
|
-
warn(message: string,
|
|
10
|
-
error(message: string,
|
|
11
|
-
fatal(message: string,
|
|
7
|
+
verbose<T = unknown>(message: string, data?: T): void;
|
|
8
|
+
debug<T = unknown>(message: string, data?: T): void;
|
|
9
|
+
info<T = unknown>(message: string, data?: T): void;
|
|
10
|
+
warn<T = unknown>(message: string, data?: T): void;
|
|
11
|
+
error<T = unknown>(message: string, data?: T): void;
|
|
12
|
+
fatal<T = unknown>(message: string, data?: T): void;
|
|
12
13
|
}
|
|
14
|
+
export default Logger;
|
package/logger/Logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const i=require("./types.js");class s{constructor(e){this.logStrategy=e}sanitize(e){return this.logStrategy.sanitize?this.logStrategy.sanitize(e):e}setLogStrategy(e){this.logStrategy=e}verbose(e,t){this.logStrategy.execute(i.LogLevel.Verbose,e,this.sanitize(t))}debug(e,t){this.logStrategy.execute(i.LogLevel.Debug,e,this.sanitize(t))}info(e,t){this.logStrategy.execute(i.LogLevel.Information,e,this.sanitize(t))}warn(e,t){this.logStrategy.execute(i.LogLevel.Warning,e,this.sanitize(t))}error(e,t){this.logStrategy.execute(i.LogLevel.Error,e,this.sanitize(t))}fatal(e,t){this.logStrategy.execute(i.LogLevel.Fatal,e,this.sanitize(t))}}module.exports=s;
|
package/logger/Logger.mjs
CHANGED
|
@@ -1,28 +1,35 @@
|
|
|
1
|
-
import { LogLevel as
|
|
1
|
+
import { LogLevel as i } from "./types.mjs";
|
|
2
2
|
class a {
|
|
3
3
|
constructor(t) {
|
|
4
4
|
this.logStrategy = t;
|
|
5
5
|
}
|
|
6
|
+
sanitize(t) {
|
|
7
|
+
return this.logStrategy.sanitize ? this.logStrategy.sanitize(t) : t;
|
|
8
|
+
}
|
|
6
9
|
setLogStrategy(t) {
|
|
7
10
|
this.logStrategy = t;
|
|
8
11
|
}
|
|
9
12
|
verbose(t, e) {
|
|
10
|
-
this.logStrategy.execute(
|
|
13
|
+
this.logStrategy.execute(i.Verbose, t, this.sanitize(e));
|
|
11
14
|
}
|
|
12
15
|
debug(t, e) {
|
|
13
|
-
this.logStrategy.execute(
|
|
16
|
+
this.logStrategy.execute(i.Debug, t, this.sanitize(e));
|
|
14
17
|
}
|
|
15
18
|
info(t, e) {
|
|
16
|
-
this.logStrategy.execute(
|
|
19
|
+
this.logStrategy.execute(
|
|
20
|
+
i.Information,
|
|
21
|
+
t,
|
|
22
|
+
this.sanitize(e)
|
|
23
|
+
);
|
|
17
24
|
}
|
|
18
25
|
warn(t, e) {
|
|
19
|
-
this.logStrategy.execute(
|
|
26
|
+
this.logStrategy.execute(i.Warning, t, this.sanitize(e));
|
|
20
27
|
}
|
|
21
28
|
error(t, e) {
|
|
22
|
-
this.logStrategy.execute(
|
|
29
|
+
this.logStrategy.execute(i.Error, t, this.sanitize(e));
|
|
23
30
|
}
|
|
24
31
|
fatal(t, e) {
|
|
25
|
-
this.logStrategy.execute(
|
|
32
|
+
this.logStrategy.execute(i.Fatal, t, this.sanitize(e));
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
export {
|
package/logger/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Logger from './Logger';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LogStrategy } from './types';
|
|
3
3
|
import { LogLevel } from './types';
|
|
4
|
-
|
|
4
|
+
import sanitizeAsStringDict from './sanitizeAsStringDict';
|
|
5
|
+
export { Logger, LogLevel, LogStrategy, sanitizeAsStringDict };
|
package/logger/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Logger.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Logger.js"),r=require("./types.js"),g=require("./sanitizeAsStringDict.js");exports.Logger=e;exports.LogLevel=r.LogLevel;exports.sanitizeAsStringDict=g;
|
package/logger/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { default as r } from "./Logger.mjs";
|
|
2
|
-
import { LogLevel as
|
|
2
|
+
import { LogLevel as a } from "./types.mjs";
|
|
3
|
+
import { default as g } from "./sanitizeAsStringDict.mjs";
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
-
r as Logger
|
|
5
|
+
a as LogLevel,
|
|
6
|
+
r as Logger,
|
|
7
|
+
g as sanitizeAsStringDict
|
|
6
8
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function s(n,t){return t?`${t}.${n}`:n}function o(n,t,u){return Object.entries(n).reduce((e,[i,r])=>{const f=s(i,u);return t[f]!==void 0?e:typeof r=="string"?(t[f]=r,e):typeof r=="number"?(t[f]=r.toString(),e):typeof r=="object"&&r?o(r,e,i):(t[f]=String(r),t)},t)}function b(n){if(n)return o(n,{})}module.exports=b;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function s(n, t) {
|
|
2
|
+
return t ? `${t}.${n}` : n;
|
|
3
|
+
}
|
|
4
|
+
function o(n, t, u) {
|
|
5
|
+
return Object.entries(n).reduce(
|
|
6
|
+
(e, [i, r]) => {
|
|
7
|
+
const f = s(i, u);
|
|
8
|
+
return t[f] !== void 0 ? e : typeof r == "string" ? (t[f] = r, e) : typeof r == "number" ? (t[f] = r.toString(), e) : typeof r == "object" && r ? o(r, e, i) : (t[f] = String(r), t);
|
|
9
|
+
},
|
|
10
|
+
t
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
function d(n) {
|
|
14
|
+
if (n)
|
|
15
|
+
return o(n, {});
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
d as default
|
|
19
|
+
};
|
package/logger/types.d.ts
CHANGED
|
@@ -6,7 +6,16 @@ export declare enum LogLevel {
|
|
|
6
6
|
Error = 4,
|
|
7
7
|
Fatal = 5
|
|
8
8
|
}
|
|
9
|
-
export declare type LogProperties = Record<string, unknown>;
|
|
10
9
|
export interface LogStrategy {
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Method which should return a sanitized version of `data`.
|
|
12
|
+
* @param data Additional data from `execute()`
|
|
13
|
+
*/
|
|
14
|
+
sanitize?(data?: unknown): unknown;
|
|
15
|
+
/**
|
|
16
|
+
* @param logLevel `LogLevel`
|
|
17
|
+
* @param message Message string
|
|
18
|
+
* @param data Any additional data to log. Sanitized if `sanitize()` method is implemented.
|
|
19
|
+
*/
|
|
20
|
+
execute(logLevel: LogLevel, message: string, data?: unknown): void;
|
|
12
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancon/wildcat-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "index.cjs",
|
|
6
6
|
"module": "index.js",
|
|
@@ -56,6 +56,11 @@
|
|
|
56
56
|
"require": "./logger/index.cjs",
|
|
57
57
|
"types": "./logger/index.d.ts"
|
|
58
58
|
},
|
|
59
|
+
"./logger/sanitizeAsStringDict": {
|
|
60
|
+
"import": "./logger/sanitizeAsStringDict.js",
|
|
61
|
+
"require": "./logger/sanitizeAsStringDict.cjs",
|
|
62
|
+
"types": "./logger/sanitizeAsStringDict.d.ts"
|
|
63
|
+
},
|
|
59
64
|
"./logger/types": {
|
|
60
65
|
"import": "./logger/types.js",
|
|
61
66
|
"require": "./logger/types.cjs",
|