@syncbridge/common 0.9.0 → 0.9.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/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = '0.9.0';
1
+ export const version = '0.9.1';
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');
@@ -10,6 +10,7 @@ export declare class ElementComponentMetadataRecord {
10
10
  */
11
11
  export declare class ElementComponentMetadata {
12
12
  propertyKey?: string;
13
+ abstract?: boolean;
13
14
  uri: string;
14
15
  description?: string;
15
16
  required?: boolean;
@@ -19,6 +19,14 @@ export { ElementComponentMetadataRecord };
19
19
  let ElementComponentMetadata = class ElementComponentMetadata {
20
20
  propertyKey;
21
21
  };
22
+ __decorate([
23
+ ApiField({
24
+ label: 'Abstract',
25
+ description: 'Determines if the component uri is set in profile or it not. If set true an explicit uri is required.',
26
+ examples: ['@syncbridge/net:TcpClient', '@syncbridge/sqb:SqbClient'],
27
+ }),
28
+ __metadata("design:type", Boolean)
29
+ ], ElementComponentMetadata.prototype, "abstract", void 0);
22
30
  __decorate([
23
31
  ApiField({
24
32
  label: 'Class URI',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncbridge/common",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "SyncBridge Common utilities",
5
5
  "author": "Panates Inc",
6
6
  "license": "MIT",
@@ -59,35 +59,42 @@ function _materializeComponents(stackExecutor, srcMetadata, profile) {
59
59
  for (const [componentName, metadataComponent,] of Object.entries(srcMetadata)) {
60
60
  stackExecutor.execute(componentName, () => {
61
61
  /** Check if component defined in profile */
62
+ let materializedComponent;
62
63
  const profileComponent = profile?.components?.[componentName];
63
64
  if (!profileComponent) {
64
- if (metadataComponent.required)
65
- throw new SbValidationError(`Component "${componentName}" should be configured`);
66
- return;
65
+ materializedComponent = {
66
+ abstract: true,
67
+ uri: metadataComponent.uri,
68
+ description: metadataComponent.description,
69
+ required: metadataComponent.required,
70
+ };
71
+ out[componentName] = materializedComponent;
67
72
  }
68
- /** istanbul ignore next */
69
- if (!profileComponent.uri)
70
- throw new SbValidationError(`"uri" property required`);
71
- const reg = ExtensionRegistry.getComponent(profileComponent.uri);
72
- if (!(profileComponent.uri === metadataComponent.uri ||
73
- reg.metadata.interfaces?.includes(metadataComponent.uri)))
74
- throw new SbValidationError(`Selected component "${profileComponent.uri}" do not implement ${metadataComponent.uri}.`);
75
- const materializedComponent = {
76
- uri: profileComponent.uri,
77
- ...omit(metadataComponent, ['uri', 'variables']),
78
- };
79
- out[componentName] = materializedComponent;
80
- materializedComponent.variables = merge({}, [reg.metadata.variables || {}, metadataComponent.variables || {}], { deep: 'full' });
81
- materializedComponent.variables = sortVariables(materializedComponent.variables);
82
- /** Remove ignored variables */
83
- for (const [k, variable] of Object.entries(materializedComponent.variables)) {
84
- if (variable.ignored)
85
- delete materializedComponent.variables[k];
86
- }
87
- if (reg.metadata.components) {
88
- stackExecutor.execute('components', () => {
89
- materializedComponent.components = _materializeComponents(stackExecutor, reg.metadata.components, profileComponent);
90
- });
73
+ else {
74
+ /** istanbul ignore next */
75
+ if (!profileComponent.uri)
76
+ throw new SbValidationError(`"uri" property required`);
77
+ const reg = ExtensionRegistry.getComponent(profileComponent.uri);
78
+ if (!(profileComponent.uri === metadataComponent.uri ||
79
+ reg.metadata.interfaces?.includes(metadataComponent.uri)))
80
+ throw new SbValidationError(`Selected component "${profileComponent.uri}" do not implement ${metadataComponent.uri}.`);
81
+ materializedComponent = {
82
+ uri: profileComponent.uri,
83
+ ...omit(metadataComponent, ['uri', 'variables']),
84
+ };
85
+ materializedComponent.variables = merge({}, [reg.metadata.variables || {}, metadataComponent.variables || {}], { deep: 'full' });
86
+ materializedComponent.variables = sortVariables(materializedComponent.variables);
87
+ out[componentName] = materializedComponent;
88
+ /** Remove ignored variables */
89
+ for (const [k, variable] of Object.entries(materializedComponent.variables)) {
90
+ if (variable.ignored)
91
+ delete materializedComponent.variables[k];
92
+ }
93
+ if (reg.metadata.components) {
94
+ stackExecutor.execute('components', () => {
95
+ materializedComponent.components = _materializeComponents(stackExecutor, reg.metadata.components, profileComponent);
96
+ });
97
+ }
91
98
  }
92
99
  });
93
100
  }