componentsjs 5.0.0-beta.4 → 5.0.0-beta.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/CHANGELOG.md +12 -0
- package/README.md +35 -0
- package/lib/construction/ConfigConstructorPool.js +1 -1
- package/lib/loading/ComponentsManagerBuilder.d.ts +6 -0
- package/lib/loading/ComponentsManagerBuilder.js +4 -1
- package/lib/preprocess/ParameterHandler.d.ts +1 -0
- package/lib/preprocess/ParameterHandler.js +1 -1
- package/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.d.ts +2 -1
- package/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js +3 -2
- package/lib/rdf/Iris.d.ts +1 -1
- package/lib/rdf/Iris.js +1 -1
- package/lib/rdf/RdfStreamIncluder.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
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.5"></a>
|
|
5
|
+
## [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
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
* [Allow type-checking to be disabled via typeChecking](https://github.com/LinkedSoftwareDependencies/Components.js/commit/a55331085e4c5621832e6b23bc52b00068e8256a)
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
* [Throw error on circular dependencies, Closes #53](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e7a28d1cf87d96d5b58bb6d1f19ce41d6e55aab6)
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
* [Fix seeAlso links not handling encoded URI components, Closes #43](https://github.com/LinkedSoftwareDependencies/Components.js/commit/2b72914d2720b2982d4570af55f9b5d7dc196c27)
|
|
15
|
+
|
|
4
16
|
<a name="v5.0.0-beta.4"></a>
|
|
5
17
|
## [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
|
|
6
18
|
|
package/README.md
CHANGED
|
@@ -202,6 +202,41 @@ 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
|
+
|
|
205
240
|
## Cite
|
|
206
241
|
|
|
207
242
|
If you are using or extending Components.js as part of a scientific publication,
|
|
@@ -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.
|
|
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')) {
|
|
@@ -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: [
|
|
@@ -17,7 +17,7 @@ class ParameterHandler {
|
|
|
17
17
|
new ParameterPropertyHandlerDefaultScoped_1.ParameterPropertyHandlerDefaultScoped(this.objectLoader),
|
|
18
18
|
new ParameterPropertyHandlerDefault_1.ParameterPropertyHandlerDefault(this.objectLoader),
|
|
19
19
|
new ParameterPropertyHandlerFixed_1.ParameterPropertyHandlerFixed(this.objectLoader),
|
|
20
|
-
this.parameterPropertyHandlerRange = new ParameterPropertyHandlerRange_1.ParameterPropertyHandlerRange(this.objectLoader),
|
|
20
|
+
this.parameterPropertyHandlerRange = new ParameterPropertyHandlerRange_1.ParameterPropertyHandlerRange(this.objectLoader, options.typeChecking),
|
|
21
21
|
new ParameterPropertyHandlerLazy_1.ParameterPropertyHandlerLazy(),
|
|
22
22
|
];
|
|
23
23
|
}
|
|
@@ -7,7 +7,8 @@ import type { IParameterPropertyHandler } from './IParameterPropertyHandler';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class ParameterPropertyHandlerRange implements IParameterPropertyHandler {
|
|
9
9
|
private readonly objectLoader;
|
|
10
|
-
|
|
10
|
+
private readonly typeChecking;
|
|
11
|
+
constructor(objectLoader: RdfObjectLoader, typeChecking: boolean);
|
|
11
12
|
canHandle(value: Resource | undefined, configRoot: Resource, parameter: Resource): boolean;
|
|
12
13
|
handle(value: Resource | undefined, configRoot: Resource, parameter: Resource, configElement: Resource, genericsContext: GenericsContext): Resource | undefined;
|
|
13
14
|
/**
|
|
@@ -8,8 +8,9 @@ const GenericsContext_1 = require("../GenericsContext");
|
|
|
8
8
|
* If a param range is defined, apply the type and validate the range.
|
|
9
9
|
*/
|
|
10
10
|
class ParameterPropertyHandlerRange {
|
|
11
|
-
constructor(objectLoader) {
|
|
11
|
+
constructor(objectLoader, typeChecking) {
|
|
12
12
|
this.objectLoader = objectLoader;
|
|
13
|
+
this.typeChecking = typeChecking;
|
|
13
14
|
}
|
|
14
15
|
canHandle(value, configRoot, parameter) {
|
|
15
16
|
return Boolean(parameter.property.range);
|
|
@@ -30,7 +31,7 @@ class ParameterPropertyHandlerRange {
|
|
|
30
31
|
captureType(value, param, genericsContext) {
|
|
31
32
|
const errorContext = { param };
|
|
32
33
|
const conflict = this.hasValueType(value, param.property.range, errorContext, genericsContext);
|
|
33
|
-
if (!conflict) {
|
|
34
|
+
if (!conflict || !this.typeChecking) {
|
|
34
35
|
return value;
|
|
35
36
|
}
|
|
36
37
|
ParameterPropertyHandlerRange.throwIncorrectTypeError(value, param, genericsContext, conflict);
|
package/lib/rdf/Iris.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const IRIS_RDF: {
|
|
|
18
18
|
};
|
|
19
19
|
export declare const PREFIX_RDFS: (suffix: string) => string;
|
|
20
20
|
export declare const IRIS_RDFS: {
|
|
21
|
-
|
|
21
|
+
seeAlso: string;
|
|
22
22
|
};
|
|
23
23
|
export declare const PREFIX_XSD: (suffix: string) => string;
|
|
24
24
|
export declare const IRIS_XSD: {
|
package/lib/rdf/Iris.js
CHANGED
|
@@ -22,7 +22,7 @@ exports.IRIS_RDF = {
|
|
|
22
22
|
};
|
|
23
23
|
exports.PREFIX_RDFS = definePrefix('http://www.w3.org/2000/01/rdf-schema#');
|
|
24
24
|
exports.IRIS_RDFS = {
|
|
25
|
-
|
|
25
|
+
seeAlso: (0, exports.PREFIX_RDFS)('seeAlso'),
|
|
26
26
|
};
|
|
27
27
|
exports.PREFIX_XSD = definePrefix('http://www.w3.org/2001/XMLSchema#');
|
|
28
28
|
exports.IRIS_XSD = {
|
|
@@ -36,9 +36,9 @@ class RdfStreamIncluder extends stream_1.Transform {
|
|
|
36
36
|
* @param quad A quad.
|
|
37
37
|
*/
|
|
38
38
|
handleImports(quad) {
|
|
39
|
-
if (!this.parserOptions.ignoreImports && quad.predicate.value === Iris_1.IRIS_RDFS.
|
|
39
|
+
if (!this.parserOptions.ignoreImports && quad.predicate.value === Iris_1.IRIS_RDFS.seeAlso) {
|
|
40
40
|
this.runningImporters++;
|
|
41
|
-
let relativeFilePath = quad.object.value;
|
|
41
|
+
let relativeFilePath = decodeURI(quad.object.value);
|
|
42
42
|
// Try overriding path using defined import paths
|
|
43
43
|
if (this.parserOptions.importPaths) {
|
|
44
44
|
for (const prefix of Object.keys(this.parserOptions.importPaths)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "componentsjs",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.5",
|
|
4
4
|
"description": "A semantic dependency injection framework",
|
|
5
5
|
"lsd:contexts": {
|
|
6
6
|
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^3.0.0/components/context.jsonld": "components/context.jsonld"
|