componentsjs 5.0.0-beta.1 → 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 +53 -0
- package/README.md +51 -0
- package/components/context.jsonld +36 -0
- package/lib/ComponentsManager.js +3 -5
- package/lib/construction/ConfigConstructorPool.js +1 -1
- package/lib/construction/strategy/ConstructionStrategyCommonJs.d.ts +3 -1
- package/lib/construction/strategy/ConstructionStrategyCommonJs.js +8 -10
- package/lib/construction/strategy/ConstructionStrategyCommonJsString.js +6 -8
- package/lib/loading/ComponentRegistryFinalizer.js +7 -1
- package/lib/loading/ComponentsManagerBuilder.d.ts +6 -0
- package/lib/loading/ComponentsManagerBuilder.js +4 -1
- package/lib/preprocess/ConfigPreprocessorComponent.js +9 -13
- package/lib/preprocess/GenericsContext.d.ts +49 -5
- package/lib/preprocess/GenericsContext.js +278 -15
- package/lib/preprocess/ParameterHandler.d.ts +3 -0
- package/lib/preprocess/ParameterHandler.js +2 -2
- package/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.d.ts +32 -11
- package/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js +381 -108
- package/lib/rdf/Iris.d.ts +1 -1
- package/lib/rdf/Iris.js +1 -1
- package/lib/rdf/RdfStreamIncluder.js +2 -2
- package/lib/util/ErrorResourcesContext.d.ts +11 -14
- package/lib/util/ErrorResourcesContext.js +44 -22
- package/package.json +2 -2
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Resource } from 'rdf-object';
|
|
2
|
+
import type { IParamValueConflict } from '../preprocess/parameterproperty/ParameterPropertyHandlerRange';
|
|
2
3
|
/**
|
|
3
4
|
* An error that can include a context containing resources for display.
|
|
4
5
|
*/
|
|
5
6
|
export declare class ErrorResourcesContext extends Error {
|
|
6
|
-
readonly context:
|
|
7
|
-
constructor(message: string, context:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
* @param resource A resource.
|
|
17
|
-
*/
|
|
18
|
-
static resourceToString(resource: Resource): string;
|
|
7
|
+
readonly context: IErrorContext;
|
|
8
|
+
constructor(message: string, context: IErrorContext);
|
|
9
|
+
exportContext(): any;
|
|
10
|
+
static contextToJson(context: IErrorContext): any;
|
|
11
|
+
static resourceToJson(resource: Resource | undefined): any;
|
|
12
|
+
static conflictToJson(conflict: IParamValueConflict): any;
|
|
13
|
+
}
|
|
14
|
+
export interface IErrorContext {
|
|
15
|
+
[key: string]: Resource | Resource[] | string | undefined | IErrorContext | IParamValueConflict;
|
|
19
16
|
}
|
|
@@ -1,37 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ErrorResourcesContext = void 0;
|
|
4
|
-
const
|
|
4
|
+
const rdf_object_1 = require("rdf-object");
|
|
5
5
|
/**
|
|
6
6
|
* An error that can include a context containing resources for display.
|
|
7
7
|
*/
|
|
8
8
|
class ErrorResourcesContext extends Error {
|
|
9
9
|
constructor(message, context) {
|
|
10
|
-
super(
|
|
10
|
+
super(message);
|
|
11
11
|
this.name = 'ErrorResourcesContext';
|
|
12
12
|
this.context = context;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
.map(([key, value]) => `${key}: ${typeof value === 'string' ?
|
|
17
|
-
value :
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-extra-parens
|
|
19
|
-
(Array.isArray(value) ?
|
|
20
|
-
value.map(valueSub => ErrorResourcesContext.resourceToString(valueSub)) :
|
|
21
|
-
ErrorResourcesContext.resourceToString(value))}`)
|
|
22
|
-
.join('\n');
|
|
14
|
+
exportContext() {
|
|
15
|
+
return ErrorResourcesContext.contextToJson(this.context);
|
|
23
16
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
static contextToJson(context) {
|
|
18
|
+
return Object.fromEntries(Object.entries(context)
|
|
19
|
+
.map(([key, value]) => {
|
|
20
|
+
let mapped;
|
|
21
|
+
if (typeof value === 'string') {
|
|
22
|
+
mapped = value;
|
|
23
|
+
}
|
|
24
|
+
else if (Array.isArray(value)) {
|
|
25
|
+
mapped = value.map(valueSub => ErrorResourcesContext.resourceToJson(valueSub));
|
|
26
|
+
}
|
|
27
|
+
else if (value instanceof rdf_object_1.Resource || value === undefined) {
|
|
28
|
+
mapped = ErrorResourcesContext.resourceToJson(value);
|
|
29
|
+
}
|
|
30
|
+
else if ('description' in value) {
|
|
31
|
+
mapped = ErrorResourcesContext.conflictToJson(value);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
mapped = ErrorResourcesContext.contextToJson(value);
|
|
35
|
+
}
|
|
36
|
+
return [key, mapped];
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
static resourceToJson(resource) {
|
|
40
|
+
if (resource) {
|
|
41
|
+
return resource.toJSON(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
static conflictToJson(conflict) {
|
|
45
|
+
const data = { description: conflict.description };
|
|
46
|
+
if (conflict.causes) {
|
|
47
|
+
data.causes = [];
|
|
48
|
+
// Only pick the first 2 conflicts for visualization
|
|
49
|
+
for (const subConflict of conflict.causes.slice(0, 1)) {
|
|
50
|
+
data.causes.push(ErrorResourcesContext.conflictToJson(subConflict));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
data.context = ErrorResourcesContext.contextToJson(conflict.context);
|
|
55
|
+
}
|
|
56
|
+
return data;
|
|
35
57
|
}
|
|
36
58
|
}
|
|
37
59
|
exports.ErrorResourcesContext = ErrorResourcesContext;
|
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"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"jsonld-context-parser": "^2.1.1",
|
|
41
41
|
"minimist": "^1.2.0",
|
|
42
42
|
"rdf-data-factory": "^1.1.0",
|
|
43
|
-
"rdf-object": "^1.
|
|
43
|
+
"rdf-object": "^1.13.0",
|
|
44
44
|
"rdf-parse": "^1.9.1",
|
|
45
45
|
"rdf-quad": "^1.5.0",
|
|
46
46
|
"rdf-terms": "^1.7.0",
|