@syncbridge/common 0.9.1 → 0.9.2
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
CHANGED
package/package.json
CHANGED
|
@@ -3,11 +3,11 @@ import { ProcessorMetadata, Profile } from '../models/index.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Materializes metadata from profile.
|
|
5
5
|
*/
|
|
6
|
-
export declare function materializeMetadata(profile: Profile): ProcessorMetadata;
|
|
6
|
+
export declare function materializeMetadata(profile: Profile, returnUndefinedComponentsAsAbstract?: boolean): ProcessorMetadata;
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
export declare function materializeMetadataSilent(profile: Profile): {
|
|
10
|
+
export declare function materializeMetadataSilent(profile: Profile, returnUndefinedComponentsAsAbstract?: boolean): {
|
|
11
11
|
metadata: ProcessorMetadata;
|
|
12
12
|
issues?: StackExecutor.Issue[];
|
|
13
13
|
};
|
|
@@ -6,8 +6,8 @@ import { ExtensionRegistry } from '../registry/extension-registry.js';
|
|
|
6
6
|
/**
|
|
7
7
|
* Materializes metadata from profile.
|
|
8
8
|
*/
|
|
9
|
-
export function materializeMetadata(profile) {
|
|
10
|
-
const { metadata, issues } = materializeMetadataSilent(profile);
|
|
9
|
+
export function materializeMetadata(profile, returnUndefinedComponentsAsAbstract) {
|
|
10
|
+
const { metadata, issues } = materializeMetadataSilent(profile, returnUndefinedComponentsAsAbstract);
|
|
11
11
|
if (issues?.length) {
|
|
12
12
|
const msg = 'Worker profile validation error.\n ' +
|
|
13
13
|
issues
|
|
@@ -27,7 +27,7 @@ export function materializeMetadata(profile) {
|
|
|
27
27
|
/**
|
|
28
28
|
*
|
|
29
29
|
*/
|
|
30
|
-
export function materializeMetadataSilent(profile) {
|
|
30
|
+
export function materializeMetadataSilent(profile, returnUndefinedComponentsAsAbstract) {
|
|
31
31
|
const stackExecutor = new StackExecutor();
|
|
32
32
|
const processorRec = ExtensionRegistry.getProcessor(profile.processorUri);
|
|
33
33
|
const metadata = omitUndefined(clone({
|
|
@@ -43,7 +43,7 @@ export function materializeMetadataSilent(profile) {
|
|
|
43
43
|
}, { deep: 'full' }));
|
|
44
44
|
if (metadata.components) {
|
|
45
45
|
stackExecutor.execute('components', () => {
|
|
46
|
-
metadata.components = _materializeComponents(stackExecutor, metadata.components, profile);
|
|
46
|
+
metadata.components = _materializeComponents(stackExecutor, metadata.components, profile, returnUndefinedComponentsAsAbstract);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
if (stackExecutor.issues?.length)
|
|
@@ -54,7 +54,7 @@ export function materializeMetadataSilent(profile) {
|
|
|
54
54
|
*
|
|
55
55
|
* @private
|
|
56
56
|
*/
|
|
57
|
-
function _materializeComponents(stackExecutor, srcMetadata, profile) {
|
|
57
|
+
function _materializeComponents(stackExecutor, srcMetadata, profile, returnUndefinedComponentsAsAbstract) {
|
|
58
58
|
const out = {};
|
|
59
59
|
for (const [componentName, metadataComponent,] of Object.entries(srcMetadata)) {
|
|
60
60
|
stackExecutor.execute(componentName, () => {
|
|
@@ -62,6 +62,11 @@ function _materializeComponents(stackExecutor, srcMetadata, profile) {
|
|
|
62
62
|
let materializedComponent;
|
|
63
63
|
const profileComponent = profile?.components?.[componentName];
|
|
64
64
|
if (!profileComponent) {
|
|
65
|
+
if (!returnUndefinedComponentsAsAbstract) {
|
|
66
|
+
if (metadataComponent.required)
|
|
67
|
+
throw new SbValidationError(`Component "${componentName}" should be configured`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
65
70
|
materializedComponent = {
|
|
66
71
|
abstract: true,
|
|
67
72
|
uri: metadataComponent.uri,
|
|
@@ -92,7 +97,7 @@ function _materializeComponents(stackExecutor, srcMetadata, profile) {
|
|
|
92
97
|
}
|
|
93
98
|
if (reg.metadata.components) {
|
|
94
99
|
stackExecutor.execute('components', () => {
|
|
95
|
-
materializedComponent.components = _materializeComponents(stackExecutor, reg.metadata.components, profileComponent);
|
|
100
|
+
materializedComponent.components = _materializeComponents(stackExecutor, reg.metadata.components, profileComponent, returnUndefinedComponentsAsAbstract);
|
|
96
101
|
});
|
|
97
102
|
}
|
|
98
103
|
}
|