@syncbridge/common 0.9.4 → 0.9.5

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
@@ -1,4 +1,4 @@
1
- export const version = '0.9.4';
1
+ export const version = '0.9.5';
2
2
  export const CLASS_METADATA = Symbol.for('CLASS_METADATA');
3
3
  export const CLASS_TYPE = Symbol.for('CLASS_TYPE');
4
4
  export const VARIABLE_CONTAINER = Symbol.for('VARIABLE_CONTAINER');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncbridge/common",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "SyncBridge Common utilities",
5
5
  "author": "Panates Inc",
6
6
  "license": "MIT",
@@ -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,9 +62,18 @@ function _materializeComponents(stackExecutor, srcMetadata, profile) {
62
62
  let materializedComponent;
63
63
  const profileComponent = profile?.components?.[componentName];
64
64
  if (!profileComponent) {
65
- if (metadataComponent.required)
66
- throw new SbValidationError(`Component "${componentName}" should be configured`);
67
- return;
65
+ if (!returnUndefinedComponentsAsAbstract) {
66
+ if (metadataComponent.required)
67
+ throw new SbValidationError(`Component "${componentName}" should be configured`);
68
+ return;
69
+ }
70
+ materializedComponent = {
71
+ abstract: true,
72
+ uri: metadataComponent.uri,
73
+ description: metadataComponent.description,
74
+ required: metadataComponent.required,
75
+ };
76
+ out[componentName] = materializedComponent;
68
77
  }
69
78
  else {
70
79
  /** istanbul ignore next */
@@ -88,7 +97,7 @@ function _materializeComponents(stackExecutor, srcMetadata, profile) {
88
97
  }
89
98
  if (reg.metadata.components) {
90
99
  stackExecutor.execute('components', () => {
91
- materializedComponent.components = _materializeComponents(stackExecutor, reg.metadata.components, profileComponent);
100
+ materializedComponent.components = _materializeComponents(stackExecutor, reg.metadata.components, profileComponent, returnUndefinedComponentsAsAbstract);
92
101
  });
93
102
  }
94
103
  }