@syncbridge/common 0.12.6 → 0.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/constants.js +1 -1
- package/decorators/component.decorator.d.ts +1 -1
- package/decorators/component.decorator.js +11 -3
- package/decorators/decorator-helpers.d.ts +0 -2
- package/decorators/decorator-helpers.js +0 -22
- package/decorators/processor.decorator.d.ts +1 -1
- package/decorators/processor.decorator.js +10 -1
- package/models/index.d.ts +0 -1
- package/models/index.js +0 -1
- package/models/metadata/component-metadata.d.ts +1 -0
- package/models/metadata/component-metadata.js +8 -0
- package/models/metadata/element-metadata.d.ts +2 -4
- package/models/metadata/element-metadata.js +5 -12
- package/models/metadata/processor-metadata.d.ts +1 -0
- package/models/metadata/processor-metadata.js +9 -1
- package/package.json +1 -1
- package/registry/extension-package.d.ts +0 -2
- package/registry/extension-package.js +2 -8
- package/utils/materialize-metadata.js +2 -2
- package/utils/normalize-metadata.js +10 -6
- package/models/metadata/author-metadata.d.ts +0 -8
- package/models/metadata/author-metadata.js +0 -48
package/constants.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ComponentMetadata } from '../models/index.js';
|
|
|
5
5
|
import { UseComponent as _UseComponent } from './use-component.decorator.js';
|
|
6
6
|
export declare function Component<T extends ComponentBase>(options: Component.Options): (target: Type<T>) => void;
|
|
7
7
|
export declare namespace Component {
|
|
8
|
-
type Options = DeepPartial<StrictOmit<ComponentMetadata, '
|
|
8
|
+
type Options = DeepPartial<StrictOmit<ComponentMetadata, 'classType' | 'className' | 'components' | 'variables' | 'version'>> & {
|
|
9
9
|
className?: string;
|
|
10
10
|
};
|
|
11
11
|
function UseVariables<T extends ComponentBase>(variablesClass?: Type): (target: T, propertyKey: "values") => void;
|
|
@@ -6,7 +6,7 @@ import { ComponentBase } from '../classes/component-base.js';
|
|
|
6
6
|
import { CLASS_METADATA, CLASS_TYPE } from '../constants.js';
|
|
7
7
|
import { ComponentMetadata } from '../models/index.js';
|
|
8
8
|
import { resolvePackageJson } from '../utils/locate-package-json.js';
|
|
9
|
-
import { defineOwnMetadata
|
|
9
|
+
import { defineOwnMetadata } from './decorator-helpers.js';
|
|
10
10
|
import { UseComponent as _UseComponent } from './use-component.decorator.js';
|
|
11
11
|
import { UseVariables as _UseVariables } from './use-variables.decorator.js';
|
|
12
12
|
const NAME_PATTERN = /^([A-Z][A-Za-z0-9_]*?)(Component)?$/;
|
|
@@ -36,12 +36,20 @@ export function Component(options) {
|
|
|
36
36
|
const packageName = pkgjson.syncbridge?.name || pkgjson.name;
|
|
37
37
|
const uri = packageName + ':' + className;
|
|
38
38
|
const metadata = defineOwnMetadata(target, CLASS_METADATA, {
|
|
39
|
+
classType: 'component',
|
|
39
40
|
uri,
|
|
41
|
+
className,
|
|
40
42
|
displayName: className,
|
|
41
43
|
version: pkgjson.version,
|
|
42
44
|
abstract: !!options.abstract,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
...omit(options, [
|
|
46
|
+
'uri',
|
|
47
|
+
'classType',
|
|
48
|
+
'className',
|
|
49
|
+
'components',
|
|
50
|
+
'variables',
|
|
51
|
+
'version',
|
|
52
|
+
]),
|
|
45
53
|
});
|
|
46
54
|
const base = Object.getPrototypeOf(target);
|
|
47
55
|
const baseMetadata = Reflect.getMetadata(CLASS_METADATA, base);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { merge } from '@jsopen/objects';
|
|
3
|
-
import { AuthorMetadata } from '../models/index.js';
|
|
4
3
|
export function defineOwnMetadata(target, metadataKey, overwrite) {
|
|
5
4
|
let metadata = Reflect.getOwnMetadata(metadataKey, target);
|
|
6
5
|
const sources = [];
|
|
@@ -23,24 +22,3 @@ export function defineOwnMetadata(target, metadataKey, overwrite) {
|
|
|
23
22
|
Reflect.defineMetadata(metadataKey, metadata, target);
|
|
24
23
|
return metadata;
|
|
25
24
|
}
|
|
26
|
-
const AUTHOR_PATTERN = /^\s*([^<(]+?)\s*(?:<([^>]+)>)?\s*(?:\(([^)]+)\))?\s*$/;
|
|
27
|
-
export function parseNpmAuthor(value) {
|
|
28
|
-
if (!value)
|
|
29
|
-
return;
|
|
30
|
-
if (typeof value === 'string') {
|
|
31
|
-
const m = AUTHOR_PATTERN.exec(value);
|
|
32
|
-
if (m)
|
|
33
|
-
return new AuthorMetadata({
|
|
34
|
-
name: m[1],
|
|
35
|
-
email: m[2],
|
|
36
|
-
url: m[3],
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
else if (typeof value === 'object') {
|
|
40
|
-
return new AuthorMetadata({
|
|
41
|
-
name: value.name,
|
|
42
|
-
email: value.email,
|
|
43
|
-
url: value.url,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -23,7 +23,7 @@ export declare namespace Processor {
|
|
|
23
23
|
function OnUpdateProfile<T extends ProcessorBase>(): (target: Type<T>, propertyKey: string | symbol) => void;
|
|
24
24
|
}
|
|
25
25
|
export declare namespace Processor {
|
|
26
|
-
type Options = DeepPartial<StrictOmit<ProcessorMetadata, '
|
|
26
|
+
type Options = DeepPartial<StrictOmit<ProcessorMetadata, 'classType' | 'className' | 'components' | 'variables' | 'version'>> & {
|
|
27
27
|
className?: string;
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -36,11 +36,20 @@ export function Processor(options) {
|
|
|
36
36
|
const packageName = pkgjson.syncbridge?.name || pkgjson.name;
|
|
37
37
|
const uri = packageName + ':' + className;
|
|
38
38
|
defineOwnMetadata(target, CLASS_METADATA, {
|
|
39
|
+
classType: 'processor',
|
|
39
40
|
uri,
|
|
41
|
+
className,
|
|
40
42
|
displayName: className,
|
|
41
43
|
version: pkgjson.version,
|
|
42
44
|
abstract: !!options?.abstract,
|
|
43
|
-
...omit(options, [
|
|
45
|
+
...omit(options, [
|
|
46
|
+
'uri',
|
|
47
|
+
'classType',
|
|
48
|
+
'className',
|
|
49
|
+
'components',
|
|
50
|
+
'variables',
|
|
51
|
+
'version',
|
|
52
|
+
]),
|
|
44
53
|
});
|
|
45
54
|
target.uri = uri;
|
|
46
55
|
target.packageName = packageName;
|
package/models/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export * from './enums/log-level.js';
|
|
|
2
2
|
export * from './enums/service-status.js';
|
|
3
3
|
export * from './enums/variable-format.enum.js';
|
|
4
4
|
export * from './enums/variable-type.enum.js';
|
|
5
|
-
export * from './metadata/author-metadata.js';
|
|
6
5
|
export * from './metadata/component-metadata.js';
|
|
7
6
|
export * from './metadata/element-component-metadata.js';
|
|
8
7
|
export * from './metadata/element-metadata.js';
|
package/models/index.js
CHANGED
|
@@ -2,7 +2,6 @@ export * from './enums/log-level.js';
|
|
|
2
2
|
export * from './enums/service-status.js';
|
|
3
3
|
export * from './enums/variable-format.enum.js';
|
|
4
4
|
export * from './enums/variable-type.enum.js';
|
|
5
|
-
export * from './metadata/author-metadata.js';
|
|
6
5
|
export * from './metadata/component-metadata.js';
|
|
7
6
|
export * from './metadata/element-component-metadata.js';
|
|
8
7
|
export * from './metadata/element-metadata.js';
|
|
@@ -9,6 +9,14 @@ let ComponentMetadata = class ComponentMetadata extends ElementMetadata {
|
|
|
9
9
|
super(init);
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
+
__decorate([
|
|
13
|
+
ApiField({
|
|
14
|
+
label: 'Class Type',
|
|
15
|
+
description: 'Determines the type of the class',
|
|
16
|
+
fixed: 'component',
|
|
17
|
+
}),
|
|
18
|
+
__metadata("design:type", String)
|
|
19
|
+
], ComponentMetadata.prototype, "classType", void 0);
|
|
12
20
|
__decorate([
|
|
13
21
|
ApiField({
|
|
14
22
|
label: 'Interfaces',
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AuthorMetadata } from './author-metadata.js';
|
|
2
1
|
import type { ElementComponentMetadataRecord } from './element-component-metadata.js';
|
|
3
2
|
import { VariableMetadataRecord } from './variable-metadata.js';
|
|
4
3
|
/**
|
|
@@ -7,12 +6,11 @@ import { VariableMetadataRecord } from './variable-metadata.js';
|
|
|
7
6
|
export declare class ElementMetadata {
|
|
8
7
|
constructor(init?: Partial<ElementMetadata>);
|
|
9
8
|
abstract?: boolean;
|
|
10
|
-
|
|
11
|
-
version
|
|
9
|
+
className: string;
|
|
10
|
+
version: string;
|
|
12
11
|
displayName: string;
|
|
13
12
|
iconUrl?: string;
|
|
14
13
|
description?: string;
|
|
15
|
-
author: AuthorMetadata;
|
|
16
14
|
variables?: VariableMetadataRecord;
|
|
17
15
|
components?: ElementComponentMetadataRecord;
|
|
18
16
|
tags: string[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { ApiField, ArrayType, ComplexType } from '@opra/common';
|
|
3
|
-
import { AuthorMetadata } from './author-metadata.js';
|
|
4
3
|
import { VariableMetadataRecord } from './variable-metadata.js';
|
|
5
4
|
/**
|
|
6
5
|
*
|
|
@@ -14,17 +13,18 @@ let ElementMetadata = class ElementMetadata {
|
|
|
14
13
|
};
|
|
15
14
|
__decorate([
|
|
16
15
|
ApiField({
|
|
17
|
-
label: 'Class
|
|
18
|
-
description: '
|
|
19
|
-
|
|
16
|
+
label: 'Class Name',
|
|
17
|
+
description: 'Computer friendly class name',
|
|
18
|
+
required: true,
|
|
20
19
|
}),
|
|
21
20
|
__metadata("design:type", String)
|
|
22
|
-
], ElementMetadata.prototype, "
|
|
21
|
+
], ElementMetadata.prototype, "className", void 0);
|
|
23
22
|
__decorate([
|
|
24
23
|
ApiField({
|
|
25
24
|
label: 'Version',
|
|
26
25
|
description: 'Version of the class',
|
|
27
26
|
examples: ['0.2.1', '2.1.5', '1.18.1-alpha.1'],
|
|
27
|
+
required: true,
|
|
28
28
|
}),
|
|
29
29
|
__metadata("design:type", String)
|
|
30
30
|
], ElementMetadata.prototype, "version", void 0);
|
|
@@ -50,13 +50,6 @@ __decorate([
|
|
|
50
50
|
}),
|
|
51
51
|
__metadata("design:type", String)
|
|
52
52
|
], ElementMetadata.prototype, "description", void 0);
|
|
53
|
-
__decorate([
|
|
54
|
-
ApiField({
|
|
55
|
-
label: 'Author',
|
|
56
|
-
description: 'Author',
|
|
57
|
-
}),
|
|
58
|
-
__metadata("design:type", AuthorMetadata)
|
|
59
|
-
], ElementMetadata.prototype, "author", void 0);
|
|
60
53
|
__decorate([
|
|
61
54
|
ApiField({
|
|
62
55
|
label: 'Variables',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { ComplexType } from '@opra/common';
|
|
2
|
+
import { ApiField, ComplexType } from '@opra/common';
|
|
3
3
|
import { ElementMetadata } from './element-metadata.js';
|
|
4
4
|
let ProcessorMetadata = class ProcessorMetadata extends ElementMetadata {
|
|
5
5
|
constructor(init) {
|
|
@@ -7,6 +7,14 @@ let ProcessorMetadata = class ProcessorMetadata extends ElementMetadata {
|
|
|
7
7
|
}
|
|
8
8
|
staticEvents;
|
|
9
9
|
};
|
|
10
|
+
__decorate([
|
|
11
|
+
ApiField({
|
|
12
|
+
label: 'Class Type',
|
|
13
|
+
description: 'Determines the type of the class',
|
|
14
|
+
fixed: 'processor',
|
|
15
|
+
}),
|
|
16
|
+
__metadata("design:type", String)
|
|
17
|
+
], ProcessorMetadata.prototype, "classType", void 0);
|
|
10
18
|
ProcessorMetadata = __decorate([
|
|
11
19
|
ComplexType(),
|
|
12
20
|
__metadata("design:paramtypes", [Object])
|
package/package.json
CHANGED
|
@@ -26,8 +26,6 @@ export declare abstract class ExtensionBase {
|
|
|
26
26
|
readonly pkg: ExtensionPackage;
|
|
27
27
|
readonly exportName: string;
|
|
28
28
|
readonly metadata: ElementMetadata;
|
|
29
|
-
readonly organization: string;
|
|
30
|
-
readonly packageName: string;
|
|
31
29
|
readonly className: string;
|
|
32
30
|
protected constructor(pkg: ExtensionPackage, exportName: string, metadata: ElementMetadata, ctor?: Type<BaseElement>);
|
|
33
31
|
get uri(): string;
|
|
@@ -21,22 +21,16 @@ export class ExtensionBase {
|
|
|
21
21
|
pkg;
|
|
22
22
|
exportName;
|
|
23
23
|
metadata;
|
|
24
|
-
organization;
|
|
25
|
-
packageName;
|
|
26
24
|
className;
|
|
27
25
|
constructor(pkg, exportName, metadata, ctor) {
|
|
28
26
|
this.pkg = pkg;
|
|
29
27
|
this.exportName = exportName;
|
|
30
28
|
this.metadata = metadata;
|
|
31
29
|
this._ctor = ctor;
|
|
32
|
-
|
|
33
|
-
const [organization, packageName] = pn.split('/');
|
|
34
|
-
this.className = className;
|
|
35
|
-
this.organization = (organization || '').replace('@', '');
|
|
36
|
-
this.packageName = packageName;
|
|
30
|
+
this.className = metadata.className;
|
|
37
31
|
}
|
|
38
32
|
get uri() {
|
|
39
|
-
return this.metadata.
|
|
33
|
+
return this.pkg.name + ':' + this.metadata.className;
|
|
40
34
|
}
|
|
41
35
|
get displayName() {
|
|
42
36
|
return this.metadata.displayName;
|
|
@@ -31,12 +31,12 @@ export function materializeMetadataSilent(profile, options) {
|
|
|
31
31
|
const stackExecutor = new StackExecutor();
|
|
32
32
|
const processorRec = ExtensionRegistry.getProcessor(profile.processorUri);
|
|
33
33
|
const metadata = omitUndefined(clone({
|
|
34
|
-
|
|
34
|
+
classType: processorRec.metadata.classType,
|
|
35
|
+
className: processorRec.metadata.className,
|
|
35
36
|
version: processorRec.version,
|
|
36
37
|
displayName: processorRec.metadata.displayName,
|
|
37
38
|
description: processorRec.metadata.description,
|
|
38
39
|
iconUrl: processorRec.metadata.iconUrl,
|
|
39
|
-
author: processorRec.metadata.author,
|
|
40
40
|
tags: processorRec.metadata.tags,
|
|
41
41
|
variables: processorRec.metadata.variables,
|
|
42
42
|
components: processorRec.metadata.components,
|
|
@@ -24,11 +24,11 @@ export async function normalizeProcessorMetadata(metadata) {
|
|
|
24
24
|
export async function normalizeProcessorMetadataSilent(metadata) {
|
|
25
25
|
const decoder = await getProcMetadataTypeDecoder();
|
|
26
26
|
let cloned = deepClone({
|
|
27
|
-
|
|
27
|
+
classType: 'processor',
|
|
28
|
+
className: metadata.className,
|
|
28
29
|
displayName: metadata.displayName,
|
|
29
30
|
description: metadata.description,
|
|
30
31
|
iconUrl: metadata.iconUrl,
|
|
31
|
-
author: metadata.author,
|
|
32
32
|
tags: metadata.tags,
|
|
33
33
|
abstract: metadata.abstract,
|
|
34
34
|
variables: metadata.variables,
|
|
@@ -44,8 +44,10 @@ export async function normalizeProcessorMetadataSilent(metadata) {
|
|
|
44
44
|
return {
|
|
45
45
|
metadata: value || cloned,
|
|
46
46
|
issues: errors?.map(x => ({
|
|
47
|
-
|
|
47
|
+
message: x.message,
|
|
48
48
|
severity: 'error',
|
|
49
|
+
location: x.location,
|
|
50
|
+
code: 'validation-error:' + x.rule,
|
|
49
51
|
})),
|
|
50
52
|
};
|
|
51
53
|
}
|
|
@@ -69,11 +71,11 @@ export async function normalizeComponentMetadata(metadata) {
|
|
|
69
71
|
export async function normalizeComponentMetadataSilent(metadata) {
|
|
70
72
|
const decoder = await getCompMetadataTypeDecoder();
|
|
71
73
|
let cloned = deepClone({
|
|
72
|
-
|
|
74
|
+
classType: 'component',
|
|
75
|
+
className: metadata.className,
|
|
73
76
|
displayName: metadata.displayName,
|
|
74
77
|
description: metadata.description,
|
|
75
78
|
iconUrl: metadata.iconUrl,
|
|
76
|
-
author: metadata.author,
|
|
77
79
|
interfaces: metadata.interfaces,
|
|
78
80
|
tags: metadata.tags,
|
|
79
81
|
abstract: metadata.abstract,
|
|
@@ -90,8 +92,10 @@ export async function normalizeComponentMetadataSilent(metadata) {
|
|
|
90
92
|
return {
|
|
91
93
|
metadata: value || cloned,
|
|
92
94
|
issues: errors?.map(x => ({
|
|
93
|
-
|
|
95
|
+
message: x.message,
|
|
94
96
|
severity: 'error',
|
|
97
|
+
location: x.location,
|
|
98
|
+
code: 'validation-error:' + x.rule,
|
|
95
99
|
})),
|
|
96
100
|
};
|
|
97
101
|
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { ApiField, ComplexType } from '@opra/common';
|
|
3
|
-
let AuthorMetadata = class AuthorMetadata {
|
|
4
|
-
constructor(init) {
|
|
5
|
-
if (init)
|
|
6
|
-
Object.assign(this, init);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
__decorate([
|
|
10
|
-
ApiField({
|
|
11
|
-
label: 'Name',
|
|
12
|
-
description: 'Name of the author. This is used to identify the author. ',
|
|
13
|
-
}),
|
|
14
|
-
__metadata("design:type", String)
|
|
15
|
-
], AuthorMetadata.prototype, "name", void 0);
|
|
16
|
-
__decorate([
|
|
17
|
-
ApiField({
|
|
18
|
-
label: 'Email',
|
|
19
|
-
description: 'Email of the author',
|
|
20
|
-
}),
|
|
21
|
-
__metadata("design:type", String)
|
|
22
|
-
], AuthorMetadata.prototype, "email", void 0);
|
|
23
|
-
__decorate([
|
|
24
|
-
ApiField({
|
|
25
|
-
label: 'Url',
|
|
26
|
-
description: 'Url of the author',
|
|
27
|
-
}),
|
|
28
|
-
__metadata("design:type", String)
|
|
29
|
-
], AuthorMetadata.prototype, "url", void 0);
|
|
30
|
-
__decorate([
|
|
31
|
-
ApiField({
|
|
32
|
-
label: 'Logo Url',
|
|
33
|
-
description: 'Url of the author logo. Dimensions should be 800x600, 400x300',
|
|
34
|
-
}),
|
|
35
|
-
__metadata("design:type", String)
|
|
36
|
-
], AuthorMetadata.prototype, "logoUrl", void 0);
|
|
37
|
-
__decorate([
|
|
38
|
-
ApiField({
|
|
39
|
-
label: 'Logomark Url',
|
|
40
|
-
description: 'Url of the author logomark. Dimensions should be square',
|
|
41
|
-
}),
|
|
42
|
-
__metadata("design:type", String)
|
|
43
|
-
], AuthorMetadata.prototype, "iconUrl", void 0);
|
|
44
|
-
AuthorMetadata = __decorate([
|
|
45
|
-
ComplexType(),
|
|
46
|
-
__metadata("design:paramtypes", [Object])
|
|
47
|
-
], AuthorMetadata);
|
|
48
|
-
export { AuthorMetadata };
|