@syncbridge/common 0.9.5 → 0.9.7
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/classes/console-logger.d.ts +13 -0
- package/classes/console-logger.js +37 -0
- package/constants.js +1 -1
- package/decorators/component.decorator.js +6 -9
- package/decorators/decorator-helpers.d.ts +1 -4
- package/decorators/decorator-helpers.js +7 -9
- package/decorators/processor-events.decorator.js +4 -10
- package/decorators/processor.decorator.js +5 -8
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ILogger } from '../interfaces/index.js';
|
|
2
|
+
export declare class ConsoleLogger implements ILogger {
|
|
3
|
+
level: string;
|
|
4
|
+
critical(...args: any[]): ILogger;
|
|
5
|
+
debug(...args: any[]): ILogger;
|
|
6
|
+
error(...args: any[]): ILogger;
|
|
7
|
+
fatal(...args: any[]): ILogger;
|
|
8
|
+
info(...args: any[]): ILogger;
|
|
9
|
+
trace(...args: any[]): ILogger;
|
|
10
|
+
warn(...args: any[]): ILogger;
|
|
11
|
+
child(): ILogger;
|
|
12
|
+
close(): void | Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class ConsoleLogger {
|
|
2
|
+
level = 'info';
|
|
3
|
+
critical(...args) {
|
|
4
|
+
console.warn(...args);
|
|
5
|
+
return this;
|
|
6
|
+
}
|
|
7
|
+
debug(...args) {
|
|
8
|
+
console.debug(...args);
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
error(...args) {
|
|
12
|
+
console.error(...args);
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
fatal(...args) {
|
|
16
|
+
console.error(...args);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
info(...args) {
|
|
20
|
+
console.info(...args);
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
trace(...args) {
|
|
24
|
+
console.trace(...args);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
warn(...args) {
|
|
28
|
+
console.warn(...args);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
child() {
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
close() {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
package/constants.js
CHANGED
|
@@ -34,15 +34,12 @@ export function Component(options) {
|
|
|
34
34
|
const packageName = pkgjson.syncbridge?.name || pkgjson.name;
|
|
35
35
|
const uri = packageName + ':' + className;
|
|
36
36
|
const metadata = defineOwnMetadata(target, CLASS_METADATA, {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
author: parseNpmAuthor(pkgjson.author),
|
|
44
|
-
...omit(options, ['uri']),
|
|
45
|
-
},
|
|
37
|
+
uri,
|
|
38
|
+
displayName: className,
|
|
39
|
+
version: pkgjson.version,
|
|
40
|
+
abstract: !!options.abstract,
|
|
41
|
+
author: parseNpmAuthor(pkgjson.author),
|
|
42
|
+
...omit(options, ['uri']),
|
|
46
43
|
});
|
|
47
44
|
const base = Object.getPrototypeOf(target);
|
|
48
45
|
const baseMetadata = Reflect.getMetadata(CLASS_METADATA, base);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { AuthorMetadata } from '../models/index.js';
|
|
3
|
-
export declare function defineOwnMetadata(target: any, metadataKey: string | symbol,
|
|
4
|
-
overwrite?: any;
|
|
5
|
-
mergeBase?: boolean;
|
|
6
|
-
}): any;
|
|
3
|
+
export declare function defineOwnMetadata(target: any, metadataKey: string | symbol, overwrite?: any): any;
|
|
7
4
|
export declare function parseNpmAuthor(value: any): AuthorMetadata | undefined;
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { merge } from '@jsopen/objects';
|
|
3
3
|
import { AuthorMetadata } from '../models/index.js';
|
|
4
|
-
export function defineOwnMetadata(target, metadataKey,
|
|
4
|
+
export function defineOwnMetadata(target, metadataKey, overwrite) {
|
|
5
5
|
let metadata = Reflect.getOwnMetadata(metadataKey, target);
|
|
6
6
|
const sources = [];
|
|
7
7
|
if (!metadata) {
|
|
8
8
|
metadata = {};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
sources.push(baseMetadata);
|
|
14
|
-
}
|
|
9
|
+
const base = Object.getPrototypeOf(target);
|
|
10
|
+
const baseMetadata = Reflect.getMetadata(metadataKey, base);
|
|
11
|
+
if (baseMetadata)
|
|
12
|
+
sources.push(baseMetadata);
|
|
15
13
|
}
|
|
16
|
-
if (
|
|
17
|
-
sources.push(
|
|
14
|
+
if (overwrite)
|
|
15
|
+
sources.push(overwrite);
|
|
18
16
|
if (sources.length)
|
|
19
17
|
merge(metadata, sources, {
|
|
20
18
|
deep: 'full',
|
|
@@ -4,11 +4,8 @@ import { defineOwnMetadata } from './decorator-helpers.js';
|
|
|
4
4
|
export function OnCreateProfile() {
|
|
5
5
|
return function (target, propertyKey) {
|
|
6
6
|
defineOwnMetadata(target, CLASS_METADATA, {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
staticEvents: {
|
|
10
|
-
onCreateProfile: propertyKey,
|
|
11
|
-
},
|
|
7
|
+
staticEvents: {
|
|
8
|
+
onCreateProfile: propertyKey,
|
|
12
9
|
},
|
|
13
10
|
});
|
|
14
11
|
};
|
|
@@ -16,11 +13,8 @@ export function OnCreateProfile() {
|
|
|
16
13
|
export function OnUpdateProfile() {
|
|
17
14
|
return function (target, propertyKey) {
|
|
18
15
|
defineOwnMetadata(target, CLASS_METADATA, {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
staticEvents: {
|
|
22
|
-
onUpdateProfile: propertyKey,
|
|
23
|
-
},
|
|
16
|
+
staticEvents: {
|
|
17
|
+
onUpdateProfile: propertyKey,
|
|
24
18
|
},
|
|
25
19
|
});
|
|
26
20
|
};
|
|
@@ -35,14 +35,11 @@ export function Processor(options) {
|
|
|
35
35
|
const packageName = pkgjson.syncbridge?.name || pkgjson.name;
|
|
36
36
|
const uri = packageName + ':' + className;
|
|
37
37
|
defineOwnMetadata(target, CLASS_METADATA, {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
abstract: !!options.abstract,
|
|
44
|
-
...omit(options, ['uri']),
|
|
45
|
-
},
|
|
38
|
+
uri,
|
|
39
|
+
displayName: className,
|
|
40
|
+
version: pkgjson.version,
|
|
41
|
+
abstract: !!options.abstract,
|
|
42
|
+
...omit(options, ['uri']),
|
|
46
43
|
});
|
|
47
44
|
target.uri = uri;
|
|
48
45
|
target.packageName = packageName;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED