componentsjs 5.0.0-beta.2 → 5.0.0-beta.6

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/CHANGELOG.md CHANGED
@@ -1,6 +1,59 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ <a name="v5.0.0-beta.6"></a>
5
+ ## [v5.0.0-beta.6](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.5...v5.0.0-beta.6) - 2022-02-09
6
+
7
+ ### Fixed
8
+ * [Fix generic errors still throwing during ignored type checking](https://github.com/LinkedSoftwareDependencies/Components.js/commit/c14adcf4757e5194db22c0f0285407bd03bf5635)
9
+
10
+ <a name="v5.0.0-beta.5"></a>
11
+ ## [v5.0.0-beta.5](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.4...v5.0.0-beta.5) - 2022-02-08
12
+
13
+ ### Added
14
+ * [Allow type-checking to be disabled via typeChecking](https://github.com/LinkedSoftwareDependencies/Components.js/commit/a55331085e4c5621832e6b23bc52b00068e8256a)
15
+
16
+ ### Changed
17
+ * [Throw error on circular dependencies, Closes #53](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e7a28d1cf87d96d5b58bb6d1f19ce41d6e55aab6)
18
+
19
+ ### Fixed
20
+ * [Fix seeAlso links not handling encoded URI components, Closes #43](https://github.com/LinkedSoftwareDependencies/Components.js/commit/2b72914d2720b2982d4570af55f9b5d7dc196c27)
21
+
22
+ <a name="v5.0.0-beta.4"></a>
23
+ ## [v5.0.0-beta.4](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.3...v5.0.0-beta.4) - 2022-01-29
24
+
25
+ ### Added
26
+ * [Support ParameterRangeIndexed for fixed literals](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0d97782a4a8dcca9fc5bbb3389a4213eca5a5205)
27
+
28
+ ### Changed
29
+ * [Propagate original error messages to require calls, Closes #65](https://github.com/LinkedSoftwareDependencies/Components.js/commit/8934ec9b784def601730b3d3f2e60c4ff0b8776e)
30
+ * [Include config id in invalid param error message](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e724f44e2222eb9917da3b227e2ce0dc9cde15f9)
31
+ * [Update memberKeys to memberFields](https://github.com/LinkedSoftwareDependencies/Components.js/commit/2c7437e1519c1813fb1a29f50d7c20bdbdf7f06e)
32
+
33
+ <a name="v5.0.0-beta.3"></a>
34
+ ## [v5.0.0-beta.3](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.2...v5.0.0-beta.3) - 2022-01-17
35
+
36
+ ### Added
37
+ * [Add support for wildcard parameter ranges](https://github.com/LinkedSoftwareDependencies/Components.js/commit/83238a9fa08877f29326be562d7d3d5fff860c69)
38
+ * Improve error reporting:
39
+ * [Add causes for param check failures in error messages](https://github.com/LinkedSoftwareDependencies/Components.js/commit/9be1fd0899ffb8a77ea99e5fb86e661526ef6d1a)
40
+ * [Improve error message on invalid generic type instantiations](https://github.com/LinkedSoftwareDependencies/Components.js/commit/6ecb9798eeb84f09fece68b3a47454fa8c857ba4)
41
+ * [Move error context to error state file](https://github.com/LinkedSoftwareDependencies/Components.js/commit/dbf26e072bdc63168814ef4d503777efaf4745eb)
42
+
43
+ ### Fixed
44
+ * Resolve several issues related to generics:
45
+ * [Throw error on invalid ParameterRangeGenericComponent](https://github.com/LinkedSoftwareDependencies/Components.js/commit/c692ab6175ce466fb32fbe38b973644e2601b2e6)
46
+ * [Fix generic components not accepting specific types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/c7739182fddcb92d46a86fe3e33d6e29fd1134b6)
47
+ * [Support generic type instantiation during component extension](https://github.com/LinkedSoftwareDependencies/Components.js/commit/98f70e350cc3f9bf8a4ea632db546f74624ddda7)
48
+ * [Support generic components in params with fixed generics](https://github.com/LinkedSoftwareDependencies/Components.js/commit/d8b30972e1306e9fe9db391d4693aa6000917e60)
49
+ * [Use GenericComponentExtension to refer to wrapped generic comp extensions](https://github.com/LinkedSoftwareDependencies/Components.js/commit/239895accfdb7f09a7ac8454928bd3e0be5e5f15)
50
+ * [Fix invalid range display with multiple generics](https://github.com/LinkedSoftwareDependencies/Components.js/commit/b98baf0bcf4546b60299ae548f929693345292bc)
51
+ * [Handle range merging if left or right is union](https://github.com/LinkedSoftwareDependencies/Components.js/commit/637e140106691b95f0f546cf88eb39f3f80dc61d)
52
+ * [Handle sub-types when merging param ranges](https://github.com/LinkedSoftwareDependencies/Components.js/commit/43290525b2e244f5fbb6d5f344760b863329c31b)
53
+ * [Allow merging of generic component param types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/ee8de7d9b8d18bf6968a17078e493946e5fca8cd)
54
+ * [Allow param range merging with generic components](https://github.com/LinkedSoftwareDependencies/Components.js/commit/bcea7dcff288ce7068ee244c49c12134208c89da)
55
+ * [Fix generics crash when doing repeated param type checking](https://github.com/LinkedSoftwareDependencies/Components.js/commit/237572cb8a9c546b098582041ccd7a457b41aecd)
56
+
4
57
  <a name="v5.0.0-beta.2"></a>
5
58
  ## [v5.0.0-beta.2](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.1...v5.0.0-beta.2) - 2021-12-09
6
59
 
package/README.md CHANGED
@@ -202,6 +202,57 @@ const myInstance = await manager.instantiate('http://example.org/myInstance');
202
202
  [RDF]: https://www.w3.org/RDF/
203
203
  [JSON-LD]: https://json-ld.org/
204
204
 
205
+ ## Advanced usage
206
+
207
+ The `ComponentsManager` can be customized with the following options:
208
+
209
+ ```javascript
210
+ const manager = await ComponentsManager.build({
211
+ // Absolute path to the package root from which module resolution should start.
212
+ mainModulePath: __dirname,
213
+ // Callback for registering components and modules
214
+ // Defaults to an invocation of {@link ComponentRegistry.registerAvailableModules}.
215
+ moduleLoader: (registry) => {},
216
+ // Callback for registering configurations.
217
+ // Defaults to no config registrations.
218
+ configLoader: (registry) => {},
219
+ // A strategy for constructing instances.
220
+ // Defaults to {@link ConstructionStrategyCommonJs}.
221
+ constructionStrategy: new ConstructionStrategyCommonJs(),
222
+ // If the error state should be dumped into `componentsjs-error-state.json` after failed instantiations.
223
+ // Defaults to `true`.
224
+ dumpErrorState: true,
225
+ // The logging level.
226
+ // Defaults to `'warn'`.
227
+ logLevel: 'warn',
228
+ // The module state.
229
+ // Defaults to a newly created instance on the {@link mainModulePath}.
230
+ moduleState: {},
231
+ // If JSON-LD context validation should be skipped.
232
+ // Defaults to `true`.
233
+ skipContextValidation: true,
234
+ // If values for parameters should be type-checked.
235
+ // Defaults to `true`.
236
+ typeChecking: true,
237
+ });
238
+ ```
239
+
240
+ ## Cite
241
+
242
+ If you are using or extending Components.js as part of a scientific publication,
243
+ we would appreciate a citation of our [article](https://linkedsoftwaredependencies.github.io/Article-System-Components/).
244
+
245
+ ```bibtex
246
+ @article{taelman_swj_componentsjs_2022,
247
+ author = {Taelman, Ruben and Van Herwegen, Joachim and Vander Sande, Miel and Verborgh, Ruben},
248
+ title = {Components.js: Semantic Dependency Injection},
249
+ journal = {Semantic Web Journal},
250
+ year = {2022},
251
+ month = jan,
252
+ url = {https://linkedsoftwaredependencies.github.io/Article-System-Components/}
253
+ }
254
+ ```
255
+
205
256
  ## License
206
257
  Components.js is written by [Ruben Taelman](http://www.rubensworks.net/).
207
258
 
@@ -2,6 +2,9 @@
2
2
  "@context": {
3
3
  "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
4
4
  "xsd": "http://www.w3.org/2001/XMLSchema#",
5
+ "type": {
6
+ "@id": "rdf:type"
7
+ },
5
8
  "types": {
6
9
  "@id": "rdf:type"
7
10
  },
@@ -29,8 +32,11 @@
29
32
  "parameters": {
30
33
  "@id": "oo:parameter"
31
34
  },
32
- "memberKeys": {
33
- "@id": "oo:memberKey"
35
+ "memberFields": {
36
+ "@id": "oo:memberFields"
37
+ },
38
+ "memberFieldName": {
39
+ "@id": "oo:memberFieldName"
34
40
  },
35
41
  "genericTypeParameters": {
36
42
  "@id": "oo:genericTypeParameter"
@@ -77,6 +83,9 @@
77
83
  "ParameterRangeUndefined": {
78
84
  "@id": "oo:ParameterRangeUndefined"
79
85
  },
86
+ "ParameterRangeWildcard": {
87
+ "@id": "oo:ParameterRangeWildcard"
88
+ },
80
89
  "ParameterRangeArray": {
81
90
  "@id": "oo:ParameterRangeArray"
82
91
  },
@@ -116,6 +125,10 @@
116
125
  "ParameterRangeGenericComponent": {
117
126
  "@id": "oo:ParameterRangeGenericComponent"
118
127
  },
128
+ "genericTypeInstancesComponentScope": {
129
+ "@id": "oo:genericTypeInstancesComponentScope",
130
+ "@type": "@id"
131
+ },
119
132
  "genericTypeInstances": {
120
133
  "@id": "oo:genericTypeInstance",
121
134
  "@type": "@id"
@@ -131,6 +144,20 @@
131
144
  "@id": "oo:parameterRangeGenericBindings",
132
145
  "@type": "@id"
133
146
  },
147
+ "GenericComponentExtension": {
148
+ "@id": "oo:GenericComponentExtension"
149
+ },
150
+ "ParameterRangeIndexed": {
151
+ "@id": "oo:ParameterRangeIndexed"
152
+ },
153
+ "parameterRangeIndexedObject": {
154
+ "@id": "oo:parameterRangeIndexedObject",
155
+ "@type": "@id"
156
+ },
157
+ "parameterRangeIndexedIndex": {
158
+ "@id": "oo:parameterRangeIndexedIndex",
159
+ "@type": "@id"
160
+ },
134
161
 
135
162
  "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
136
163
  "comment": {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComponentsManager = void 0;
4
4
  const fs = require("fs");
5
5
  const ComponentsManagerBuilder_1 = require("./loading/ComponentsManagerBuilder");
6
+ const ErrorResourcesContext_1 = require("./util/ErrorResourcesContext");
6
7
  /**
7
8
  * A components manager can instantiate components.
8
9
  * This manager should be created using {@link ComponentsManager.build}.
@@ -51,17 +52,14 @@ class ComponentsManager {
51
52
  */
52
53
  generateErrorLog(error) {
53
54
  if (this.dumpErrorState) {
54
- const contents = JSON.stringify({
55
- componentTypes: Object.keys(this.componentResources),
56
- moduleState: {
55
+ const contents = JSON.stringify(Object.assign(Object.assign({}, error instanceof ErrorResourcesContext_1.ErrorResourcesContext ? error.exportContext() : {}), { componentTypes: Object.keys(this.componentResources), moduleState: {
57
56
  mainModulePath: this.moduleState.mainModulePath,
58
57
  componentModules: this.moduleState.componentModules,
59
58
  importPaths: this.moduleState.importPaths,
60
59
  contexts: this.moduleState.contexts,
61
60
  nodeModuleImportPaths: this.moduleState.nodeModuleImportPaths,
62
61
  nodeModulePaths: this.moduleState.nodeModulePaths,
63
- },
64
- }, null, ' ');
62
+ } }), null, ' ');
65
63
  fs.writeFileSync('componentsjs-error-state.json', contents, 'utf8');
66
64
  this.logger.error(`Detected fatal error. Generated 'componentsjs-error-state.json' with more information.`);
67
65
  }
@@ -28,7 +28,7 @@ class ConfigConstructorPool {
28
28
  // if so, return a dummy value, to avoid infinite recursion.
29
29
  const resourceBlacklist = settings.resourceBlacklist || {};
30
30
  if (resourceBlacklist[configResource.value]) {
31
- return Promise.resolve(this.constructionStrategy.createUndefined());
31
+ return Promise.reject(new ErrorResourcesContext_1.ErrorResourcesContext(`Circular dependency was detected on ${configResource.value}`, { config: configResource }));
32
32
  }
33
33
  // Before instantiating, first check if the resource is a variable
34
34
  if (configResource.isA('Variable')) {
@@ -16,7 +16,9 @@ export declare class ConstructionStrategyCommonJs implements IConstructionStrate
16
16
  * @param requireName The module name that should be required.
17
17
  * @returns {any} The require() result
18
18
  */
19
- requireCurrentRunningModuleIfCurrent(moduleState: IModuleState, requireName: string): void;
19
+ requireCurrentRunningModuleIfCurrent(moduleState: IModuleState, requireName: string): {
20
+ value: any;
21
+ } | false;
20
22
  createHash(options: ICreationStrategyHashOptions<any>): any;
21
23
  createArray(options: ICreationStrategyArrayOptions<any>): any;
22
24
  createLazySupplier(options: ICreationStrategySupplierOptions<any>): Promise<any>;
@@ -14,16 +14,14 @@ class ConstructionStrategyCommonJs {
14
14
  createInstance(options) {
15
15
  // Call require()
16
16
  options.requireName = this.overrideRequireNames[options.requireName] || options.requireName;
17
+ // First try requiring current module, and fallback to a plain require
17
18
  let object;
18
- try {
19
- object = this.requireCurrentRunningModuleIfCurrent(options.moduleState, options.requireName);
20
- }
21
- catch (_a) {
22
- // Always require relative from main module, because Components.js will in most cases just be dependency.
23
- object = this.req(options.requireName.startsWith('.') ?
19
+ const currentResult = this.requireCurrentRunningModuleIfCurrent(options.moduleState, options.requireName);
20
+ object = currentResult !== false ?
21
+ currentResult.value :
22
+ this.req(options.requireName.startsWith('.') ?
24
23
  Path.join(process.cwd(), options.requireName) :
25
24
  this.req.resolve(options.requireName, { paths: [options.moduleState.mainModulePath] }));
26
- }
27
25
  // Determine the child of the require'd element
28
26
  let subObject;
29
27
  if (options.requireElement) {
@@ -31,7 +29,7 @@ class ConstructionStrategyCommonJs {
31
29
  try {
32
30
  subObject = requireElementPath.reduce((acc, subRequireElement) => acc[subRequireElement], object);
33
31
  }
34
- catch (_b) {
32
+ catch (_a) {
35
33
  throw new Error(`Failed to get module element ${options.requireElement} from module ${options.requireName}`);
36
34
  }
37
35
  }
@@ -65,11 +63,11 @@ class ConstructionStrategyCommonJs {
65
63
  const mainPath = Path.posix.join(moduleState.mainModulePath, pckg.main);
66
64
  const required = this.req(mainPath);
67
65
  if (required) {
68
- return required;
66
+ return { value: required };
69
67
  }
70
68
  }
71
69
  }
72
- throw new Error('Component is not the main module');
70
+ return false;
73
71
  }
74
72
  createHash(options) {
75
73
  return options.entries.reduce((data, entry) => {
@@ -30,14 +30,12 @@ class ConstructionStrategyCommonJsString {
30
30
  createInstance(options) {
31
31
  // Call require()
32
32
  options.requireName = this.overrideRequireNames[options.requireName] || options.requireName;
33
- let resultingRequirePath;
34
- try {
35
- this.strategyCommonJs.requireCurrentRunningModuleIfCurrent(options.moduleState, options.requireName);
36
- resultingRequirePath = `.${Path.sep}${Path.relative(options.moduleState.mainModulePath, this.getCurrentRunningModuleMain(options.moduleState))}`;
37
- }
38
- catch (_a) {
39
- resultingRequirePath = options.requireName;
40
- }
33
+ // First try requiring current module, and fallback to a plain require
34
+ const currentResult = this.strategyCommonJs
35
+ .requireCurrentRunningModuleIfCurrent(options.moduleState, options.requireName);
36
+ const resultingRequirePath = currentResult !== false ?
37
+ `.${Path.sep}${Path.relative(options.moduleState.mainModulePath, this.getCurrentRunningModuleMain(options.moduleState))}` :
38
+ options.requireName;
41
39
  let serialization = `require('${resultingRequirePath.replace(/\\/gu, '/')}')`;
42
40
  // Determine the child of the require'd element
43
41
  if (options.requireElement) {
@@ -41,7 +41,13 @@ class ComponentRegistryFinalizer {
41
41
  * @param superComponents The components to inherit from.
42
42
  */
43
43
  inheritParameters(component, superComponents) {
44
- for (const superComponent of superComponents) {
44
+ var _a;
45
+ for (let superComponent of superComponents) {
46
+ // Check if the super component is wrapped in a generic component instantiation
47
+ if (((_a = superComponent.property.type) === null || _a === void 0 ? void 0 : _a.value) === this.objectLoader.contextResolved
48
+ .expandTerm('oo:GenericComponentExtension')) {
49
+ superComponent = superComponent.property.component;
50
+ }
45
51
  this.componentRegistry.requireValidComponent(superComponent, component);
46
52
  for (const parameter of superComponent.properties.parameters) {
47
53
  if (!component.properties.parameters.includes(parameter)) {
@@ -18,6 +18,7 @@ export declare class ComponentsManagerBuilder<Instance = any> {
18
18
  private readonly logger;
19
19
  private readonly moduleState?;
20
20
  private readonly skipContextValidation;
21
+ private readonly typeChecking;
21
22
  constructor(options: IComponentsManagerBuilderOptions<Instance>);
22
23
  static createLogger(logLevel?: LogLevel): Logger;
23
24
  static createObjectLoader(): RdfObjectLoader;
@@ -69,4 +70,9 @@ export interface IComponentsManagerBuilderOptions<Instance> {
69
70
  * Defaults to `true`.
70
71
  */
71
72
  skipContextValidation?: boolean;
73
+ /**
74
+ * If values for parameters should be type-checked.
75
+ * Defaults to `true`.
76
+ */
77
+ typeChecking?: boolean;
72
78
  }
@@ -31,6 +31,9 @@ class ComponentsManagerBuilder {
31
31
  this.skipContextValidation = options.skipContextValidation === undefined ?
32
32
  true :
33
33
  Boolean(options.skipContextValidation);
34
+ this.typeChecking = options.typeChecking === undefined ?
35
+ true :
36
+ Boolean(options.typeChecking);
34
37
  }
35
38
  static createLogger(logLevel = 'warn') {
36
39
  return (0, winston_1.createLogger)({
@@ -92,7 +95,7 @@ class ComponentsManagerBuilder {
92
95
  this.logger.info(`Loaded configs`);
93
96
  // Build constructor pool
94
97
  const runTypeConfigs = {};
95
- const parameterHandler = new ParameterHandler_1.ParameterHandler({ objectLoader });
98
+ const parameterHandler = new ParameterHandler_1.ParameterHandler({ objectLoader, typeChecking: this.typeChecking });
96
99
  const configConstructorPool = new ConfigConstructorPool_1.ConfigConstructorPool({
97
100
  objectLoader,
98
101
  configPreprocessors: [
@@ -89,20 +89,19 @@ class ConfigPreprocessorComponent {
89
89
  return configRaw;
90
90
  }
91
91
  createGenericsContext(handleResponse, config) {
92
+ // Create a new generics context for the component's generic type parameters
92
93
  const genericsContext = new GenericsContext_1.GenericsContext(this.objectLoader, handleResponse.component.properties.genericTypeParameters);
93
- // Populate with manually defined generic type bindings
94
- const genericTypesInner = handleResponse.component.properties.genericTypeParameters;
95
- if (genericTypesInner.length < config.properties.genericTypeInstances.length) {
96
- throw new ErrorResourcesContext_1.ErrorResourcesContext(`Invalid generic type instantiations: more generic types are passed than are defined on the component.`, {
97
- config,
98
- component: handleResponse.component,
99
- });
100
- }
101
- for (const [i, genericTypeInstance] of config.properties.genericTypeInstances.entries()) {
102
- // Remap generic type IRI to inner generic type IRI
103
- const genericTypeIdInner = genericTypesInner[i].value;
104
- genericsContext.bindings[genericTypeIdInner] = genericTypeInstance.properties.parameterRangeGenericBindings;
105
- genericsContext.genericTypeIds[genericTypeIdInner] = true;
94
+ // If the config has a genericTypeInstancesComponentScope, it will also have genericTypeInstances.
95
+ // In that case, we bind these instances to the component's generic type parameters within the context.
96
+ // (these values may have been set during generic param type-checking in
97
+ // ParameterPropertyHandlerRange#hasParamValueValidType)
98
+ if (config.property.genericTypeInstancesComponentScope &&
99
+ handleResponse.component.value === config.property.genericTypeInstancesComponentScope.value) {
100
+ const conflict = genericsContext.bindComponentGenericTypes(handleResponse.component, config.properties.genericTypeInstances, { config }, (subType, superType) => this.parameterHandler.parameterPropertyHandlerRange
101
+ .hasType(subType, superType, genericsContext, config.property.genericTypeInstancesComponentScope, config.properties.genericTypeInstances, { config }));
102
+ if (conflict) {
103
+ throw new ErrorResourcesContext_1.ErrorResourcesContext(conflict.description, conflict.context);
104
+ }
106
105
  }
107
106
  return genericsContext;
108
107
  }
@@ -1,30 +1,74 @@
1
+ import type * as RDF from '@rdfjs/types';
1
2
  import type { Resource, RdfObjectLoader } from 'rdf-object';
3
+ import type { IParamValueConflict } from './parameterproperty/ParameterPropertyHandlerRange';
2
4
  /**
3
5
  * Context for binding generic types to a concrete range value.
4
6
  */
5
7
  export declare class GenericsContext {
8
+ private static readonly XSD_INHERITANCE_TABLE;
6
9
  private readonly objectLoader;
7
10
  /**
8
11
  * Set of generic type ids.
9
12
  * @private
10
13
  */
11
- readonly genericTypeIds: Record<string, boolean>;
14
+ genericTypeIds: Record<string, boolean>;
12
15
  /**
13
16
  * Mapping of generic type id to the resolved range.
14
17
  * @private
15
18
  */
16
- readonly bindings: Record<string, Resource[]>;
19
+ bindings: Record<string, Resource>;
17
20
  constructor(objectLoader: RdfObjectLoader, genericTypeParameters: Resource[]);
18
21
  /**
19
22
  * Try to to bind the given value to the given generic.
20
23
  * @param genericTypeId IRI of the generic to bind.
21
24
  * @param value The value to bind to.
22
- * @param typeValidator Callback for validating values against types.
25
+ * @param valueTypeValidator Callback for validating values against types.
26
+ * @param typeTypeValidator Callback for validating sub-types against super-types.
27
+ * @return boolean True if the binding was valid and took place.
23
28
  */
24
- bindGenericTypeToValue(genericTypeId: string, value: Resource | undefined, typeValidator: (subValue: Resource | undefined, subType: Resource) => boolean): boolean;
29
+ bindGenericTypeToValue(genericTypeId: string, value: Resource | undefined, valueTypeValidator: (subValue: Resource | undefined, subType: Resource) => IParamValueConflict | undefined, typeTypeValidator: (subValue: Resource, subType: Resource) => IParamValueConflict | undefined): IParamValueConflict | undefined;
30
+ /**
31
+ * Try to bind the given range to the given generic.
32
+ * @param genericTypeId IRI of the generic to bind.
33
+ * @param range The range to bind to.
34
+ * @param typeTypeValidator Callback for validating sub-types against super-types.
35
+ * @return boolean True if the binding was valid and took place.
36
+ */
37
+ bindGenericTypeToRange(genericTypeId: string, range: Resource, typeTypeValidator: (subType: Resource, superType: Resource) => IParamValueConflict | undefined): IParamValueConflict | undefined;
25
38
  /**
26
39
  * Infer the parameter range of the given value.
27
40
  * @param value A value.
28
41
  */
29
- inferValueRange(value: Resource | undefined): Resource[];
42
+ inferValueRange(value: Resource | undefined): Resource | undefined;
43
+ /**
44
+ * Merge the given ranges into a new range.
45
+ * This will return undefined in the ranges are incompatible.
46
+ *
47
+ * If one type is more specific than the other, it will return the narrowest type.
48
+ *
49
+ * @param rangeA A first range.
50
+ * @param rangeB A second range.
51
+ * @param typeTypeValidator Callback for validating sub-types against super-types.
52
+ */
53
+ mergeRanges(rangeA: Resource, rangeB: Resource, typeTypeValidator: (subType: Resource, superType: Resource) => IParamValueConflict | undefined): Resource | undefined;
54
+ protected mergeUnion(rangeUnion: Resource, rangeOther: Resource, typeValidator: (subType: Resource, superType: Resource) => IParamValueConflict | undefined): Resource | undefined;
55
+ /**
56
+ * Check if the given type is a subtype of the given super type.
57
+ * @param type A type node.
58
+ * @param potentialSuperType A potential super type node.
59
+ */
60
+ isXsdSubType(type: RDF.Term, potentialSuperType: RDF.Term): boolean;
61
+ /**
62
+ * Apply the give generic type instances for the given component's generic type parameters.
63
+ *
64
+ * This will throw if the number of passed instances does not match with
65
+ * the number of generic type parameters on the component.
66
+ *
67
+ * @param component The component
68
+ * @param genericTypeInstances The generic type instances to apply.
69
+ * @param errorContext The context for error reporting.
70
+ * @param typeTypeValidator Callback for validating sub-types against super-types.
71
+ * @return boolean False if the application failed due to a binding error. True otherwise
72
+ */
73
+ bindComponentGenericTypes(component: Resource, genericTypeInstances: Resource[], errorContext: Record<string, Resource | Resource[] | string>, typeTypeValidator: (subValue: Resource, subType: Resource) => IParamValueConflict | undefined): IParamValueConflict | undefined;
30
74
  }