@unchainedshop/utils 3.0.0 → 3.0.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/lib/director/BaseAdapter.d.ts +1 -0
- package/lib/director/BaseAdapter.d.ts.map +1 -1
- package/lib/director/BaseAdapter.js +5 -2
- package/lib/director/BaseAdapter.js.map +1 -1
- package/lib/director/BaseDirector.d.ts.map +1 -1
- package/lib/director/BaseDirector.js +0 -3
- package/lib/director/BaseDirector.js.map +1 -1
- package/package.json +1 -1
- package/src/director/BaseAdapter.ts +7 -2
- package/src/director/BaseDirector.ts +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseAdapter.d.ts","sourceRoot":"","sources":["../../src/director/BaseAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"BaseAdapter.d.ts","sourceRoot":"","sources":["../../src/director/BaseAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEhE,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,GAAG,EAAE,CACH,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,QAAQ,CAAC;QACjB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;KAClB,KACE,IAAI,CAAC;CACX;AAED,eAAO,MAAM,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAQvE,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultLogger, LogLevel } from '@unchainedshop/logger';
|
|
2
2
|
export const BaseAdapter = {
|
|
3
3
|
log(message, { level = LogLevel.Debug, ...options } = {}) {
|
|
4
|
-
|
|
4
|
+
defaultLogger[level](message, options);
|
|
5
|
+
},
|
|
6
|
+
asString() {
|
|
7
|
+
return `${this.key}@${this.version}`;
|
|
5
8
|
},
|
|
6
9
|
};
|
|
7
10
|
//# sourceMappingURL=BaseAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseAdapter.js","sourceRoot":"","sources":["../../src/director/BaseAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"BaseAdapter.js","sourceRoot":"","sources":["../../src/director/BaseAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAgBhE,MAAM,CAAC,MAAM,WAAW,GAAoD;IAC1E,GAAG,CAAC,OAAe,EAAE,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE;QAC9D,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;IACvC,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDirector.d.ts","sourceRoot":"","sources":["../../src/director/BaseDirector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseDirector.d.ts","sourceRoot":"","sources":["../../src/director/BaseDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,YAAY;IACzD,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAA;KAAE,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7F,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACrC,eAAe,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CAC7C;AAED,eAAO,MAAM,YAAY,GAAI,WAAW,SAAS,YAAY,gBAC7C,MAAM,YACV;IACR,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,KACA,aAAa,CAAC,WAAW,CAwB3B,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { log } from '@unchainedshop/logger';
|
|
2
1
|
export const BaseDirector = (directorName, options) => {
|
|
3
2
|
const Adapters = new Map();
|
|
4
3
|
const keyField = options?.adapterKeyField || 'key';
|
|
@@ -13,11 +12,9 @@ export const BaseDirector = (directorName, options) => {
|
|
|
13
12
|
.filter(adapterFilter || (() => true));
|
|
14
13
|
},
|
|
15
14
|
registerAdapter: (Adapter) => {
|
|
16
|
-
log(`${directorName} -> Registered ${keyField !== 'key' ? `${Adapter[keyField]}` : ''} ${Adapter.key} ${Adapter.version} (${Adapter.label})`);
|
|
17
15
|
Adapters.set(Adapter[keyField], Adapter);
|
|
18
16
|
},
|
|
19
17
|
unregisterAdapter: (key) => {
|
|
20
|
-
log(`${directorName} -> Unregistered ${key}`);
|
|
21
18
|
return Adapters.delete(key);
|
|
22
19
|
},
|
|
23
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDirector.js","sourceRoot":"","sources":["../../src/director/BaseDirector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseDirector.js","sourceRoot":"","sources":["../../src/director/BaseDirector.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,YAAoB,EACpB,OAGC,EAC2B,EAAE;IAC9B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;IAChD,MAAM,QAAQ,GAAG,OAAO,EAAE,eAAe,IAAI,KAAK,CAAC;IAEnD,OAAO;QACL,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE;YAClB,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAED,WAAW,EAAE,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,EAAE;YACtC,MAAM,OAAO,GAAG,OAAO,EAAE,cAAc,IAAI,QAAQ,CAAC;YACpD,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;iBACjC,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;iBACzD,MAAM,CAAC,aAAa,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3C,CAAC;QAED,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE;YAC3B,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;QAED,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE;YACzB,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultLogger, LogLevel } from '@unchainedshop/logger';
|
|
2
2
|
|
|
3
3
|
export interface IBaseAdapter {
|
|
4
4
|
key: string;
|
|
5
5
|
label: string;
|
|
6
6
|
version: string;
|
|
7
|
+
asString: () => string;
|
|
7
8
|
log: (
|
|
8
9
|
message: string,
|
|
9
10
|
options?: {
|
|
@@ -15,6 +16,10 @@ export interface IBaseAdapter {
|
|
|
15
16
|
|
|
16
17
|
export const BaseAdapter: Omit<IBaseAdapter, 'key' | 'label' | 'version'> = {
|
|
17
18
|
log(message: string, { level = LogLevel.Debug, ...options } = {}) {
|
|
18
|
-
|
|
19
|
+
defaultLogger[level](message, options);
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
asString() {
|
|
23
|
+
return `${this.key}@${this.version}`;
|
|
19
24
|
},
|
|
20
25
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { log } from '@unchainedshop/logger';
|
|
2
1
|
import { IBaseAdapter } from './BaseAdapter.js';
|
|
3
2
|
|
|
4
3
|
export interface IBaseDirector<Adapter extends IBaseAdapter> {
|
|
@@ -31,16 +30,10 @@ export const BaseDirector = <AdapterType extends IBaseAdapter>(
|
|
|
31
30
|
},
|
|
32
31
|
|
|
33
32
|
registerAdapter: (Adapter) => {
|
|
34
|
-
log(
|
|
35
|
-
`${directorName} -> Registered ${keyField !== 'key' ? `${Adapter[keyField]}` : ''} ${
|
|
36
|
-
Adapter.key
|
|
37
|
-
} ${Adapter.version} (${Adapter.label})`,
|
|
38
|
-
);
|
|
39
33
|
Adapters.set(Adapter[keyField], Adapter);
|
|
40
34
|
},
|
|
41
35
|
|
|
42
36
|
unregisterAdapter: (key) => {
|
|
43
|
-
log(`${directorName} -> Unregistered ${key}`);
|
|
44
37
|
return Adapters.delete(key);
|
|
45
38
|
},
|
|
46
39
|
};
|