componentsjs 5.0.0 → 5.2.0
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 +18 -0
- package/README.md +4 -4
- package/index.js +5 -1
- package/lib/ComponentsManager.d.ts +4 -0
- package/lib/ComponentsManager.js +10 -0
- package/lib/construction/ConfigConstructorPool.d.ts +4 -0
- package/lib/construction/ConfigConstructorPool.js +15 -7
- package/lib/construction/IConfigConstructorPool.d.ts +5 -0
- package/lib/loading/ConfigRegistry.d.ts +6 -1
- package/lib/loading/ConfigRegistry.js +8 -0
- package/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.d.ts +15 -0
- package/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js +96 -63
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
<a name="v5.2.0"></a>
|
|
5
|
+
## [v5.2.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.1.0...v5.2.0) - 2022-05-20
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
* [Preserve literal values for params with type unknown](https://github.com/LinkedSoftwareDependencies/Components.js/commit/ad52da8afc2340ddc63e8a45c4d560e11ecb3ceb)
|
|
9
|
+
|
|
10
|
+
<a name="v5.1.0"></a>
|
|
11
|
+
## [v5.1.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0...v5.1.0) - 2022-05-10
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
* [Expose instantiated resources from ComponentsManager](https://github.com/LinkedSoftwareDependencies/Components.js/commit/19c8d669a081dc413091a413d1c42c71b691cfbc)
|
|
15
|
+
|
|
16
|
+
<a name="v5.0.1"></a>
|
|
17
|
+
## [v5.0.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0...v5.0.1) - 2022-03-02
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
* [Bump to rdf-parse 2](https://github.com/LinkedSoftwareDependencies/Components.js/commit/5957c21d9ea0d8e6086be09d67ee99e64f8b2960)
|
|
21
|
+
|
|
4
22
|
<a name="v5.0.0"></a>
|
|
5
23
|
## [v5.0.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.7...v5.0.0) - 2022-03-01
|
|
6
24
|
|
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ $ npm install -D componentsjs-generator
|
|
|
53
53
|
...
|
|
54
54
|
"build": "npm run build:ts && npm run build:components",
|
|
55
55
|
"build:ts": "tsc",
|
|
56
|
-
"build:components": "componentsjs-generator
|
|
56
|
+
"build:components": "componentsjs-generator",
|
|
57
57
|
"prepare": "npm run build",
|
|
58
58
|
...
|
|
59
59
|
}
|
|
@@ -80,7 +80,7 @@ export class MyClass {
|
|
|
80
80
|
```json
|
|
81
81
|
{
|
|
82
82
|
"@context": [
|
|
83
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^
|
|
83
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
|
|
84
84
|
"https://linkedsoftwaredependencies.org/bundles/npm/my-package/^2.0.0/components/context.jsonld"
|
|
85
85
|
],
|
|
86
86
|
"@id": "urn:my-package:myInstance",
|
|
@@ -132,7 +132,7 @@ export class MyClass {
|
|
|
132
132
|
```json
|
|
133
133
|
{
|
|
134
134
|
"@context": [
|
|
135
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^
|
|
135
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
|
|
136
136
|
{ "ex": "http://example.org/" }
|
|
137
137
|
],
|
|
138
138
|
"@id": "ex:MyPackage",
|
|
@@ -164,7 +164,7 @@ The constructor of `MyClass` takes a single `name` argument.
|
|
|
164
164
|
```json
|
|
165
165
|
{
|
|
166
166
|
"@context": [
|
|
167
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^
|
|
167
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
|
|
168
168
|
{
|
|
169
169
|
"ex": "http://example.org/",
|
|
170
170
|
"name": "ex:MyPackage/MyClass#name"
|
package/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -33,6 +33,10 @@ export declare class ComponentsManager<Instance> {
|
|
|
33
33
|
* @param settings Optional settings that may influence instantiation.
|
|
34
34
|
*/
|
|
35
35
|
instantiate<T = Instance>(instanceIri: string, settings?: IConstructionSettings): Promise<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve a list of all instantiated Resources.
|
|
38
|
+
*/
|
|
39
|
+
getInstantiatedResources(): Resource[];
|
|
36
40
|
/**
|
|
37
41
|
* Create an `componentsjs-error-state.json` file to represent the application state in the current working directory.
|
|
38
42
|
* @param error The error that causes this error state to be created.
|
package/lib/ComponentsManager.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ComponentsManager = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
|
+
const rdf_string_1 = require("rdf-string");
|
|
5
6
|
const ComponentsManagerBuilder_1 = require("./loading/ComponentsManagerBuilder");
|
|
6
7
|
const ErrorResourcesContext_1 = require("./util/ErrorResourcesContext");
|
|
7
8
|
/**
|
|
@@ -46,6 +47,15 @@ class ComponentsManager {
|
|
|
46
47
|
throw this.generateErrorLog(error);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Retrieve a list of all instantiated Resources.
|
|
52
|
+
*/
|
|
53
|
+
getInstantiatedResources() {
|
|
54
|
+
const instances = this.configConstructorPool.getInstanceRegistry();
|
|
55
|
+
return Object.keys(instances)
|
|
56
|
+
.map(key => (0, rdf_string_1.stringToTerm)(key))
|
|
57
|
+
.map(term => this.configRegistry.getInstantiatedResource(term));
|
|
58
|
+
}
|
|
49
59
|
/**
|
|
50
60
|
* Create an `componentsjs-error-state.json` file to represent the application state in the current working directory.
|
|
51
61
|
* @param error The error that causes this error state to be created.
|
|
@@ -41,6 +41,10 @@ export declare class ConfigConstructorPool<Instance> implements IConfigConstruct
|
|
|
41
41
|
* @param optional If the field is optional.
|
|
42
42
|
*/
|
|
43
43
|
validateParam(config: Resource, field: string, type: string, optional?: boolean): void;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the instance registry.
|
|
46
|
+
*/
|
|
47
|
+
getInstanceRegistry(): Record<string, Promise<any>>;
|
|
44
48
|
}
|
|
45
49
|
export interface IInstancePoolOptions<Instance> {
|
|
46
50
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConfigConstructorPool = void 0;
|
|
4
|
+
const rdf_string_1 = require("rdf-string");
|
|
4
5
|
const ErrorResourcesContext_1 = require("../util/ErrorResourcesContext");
|
|
5
6
|
const ConfigConstructor_1 = require("./ConfigConstructor");
|
|
6
7
|
/**
|
|
@@ -27,7 +28,8 @@ class ConfigConstructorPool {
|
|
|
27
28
|
// Check if this resource is required as argument in its own chain,
|
|
28
29
|
// if so, return a dummy value, to avoid infinite recursion.
|
|
29
30
|
const resourceBlacklist = settings.resourceBlacklist || {};
|
|
30
|
-
|
|
31
|
+
const configResourceId = (0, rdf_string_1.termToString)(configResource.term);
|
|
32
|
+
if (resourceBlacklist[configResourceId]) {
|
|
31
33
|
return Promise.reject(new ErrorResourcesContext_1.ErrorResourcesContext(`Circular dependency was detected on ${configResource.value}`, { config: configResource }));
|
|
32
34
|
}
|
|
33
35
|
// Before instantiating, first check if the resource is a variable
|
|
@@ -36,24 +38,24 @@ class ConfigConstructorPool {
|
|
|
36
38
|
.getVariableValue({ settings, variableName: configResource.value }));
|
|
37
39
|
}
|
|
38
40
|
// Instantiate only once
|
|
39
|
-
if (!(
|
|
41
|
+
if (!(configResourceId in this.instances)) {
|
|
40
42
|
// The blacklist avoids infinite recursion for self-referencing configs
|
|
41
43
|
const subBlackList = Object.assign({}, resourceBlacklist);
|
|
42
|
-
subBlackList[
|
|
44
|
+
subBlackList[configResourceId] = true;
|
|
43
45
|
// Prepare instance parameters
|
|
44
46
|
let rawConfig;
|
|
45
47
|
try {
|
|
46
48
|
rawConfig = this.getRawConfig(configResource);
|
|
47
49
|
}
|
|
48
50
|
catch (syncError) {
|
|
49
|
-
this.instances[
|
|
50
|
-
return this.instances[
|
|
51
|
+
this.instances[configResourceId] = Promise.reject(syncError);
|
|
52
|
+
return this.instances[configResourceId];
|
|
51
53
|
}
|
|
52
54
|
const subSettings = Object.assign(Object.assign({}, settings), { resourceBlacklist: subBlackList });
|
|
53
55
|
// Invoke instance creation
|
|
54
|
-
this.instances[
|
|
56
|
+
this.instances[configResourceId] = this.configConstructor.createInstance(rawConfig, subSettings);
|
|
55
57
|
}
|
|
56
|
-
return this.instances[
|
|
58
|
+
return this.instances[configResourceId];
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
61
|
* Determine the raw config of the given config.
|
|
@@ -106,6 +108,12 @@ class ConfigConstructorPool {
|
|
|
106
108
|
throw new ErrorResourcesContext_1.ErrorResourcesContext(`Invalid config: ${field} "${config.property[field].value}" must be a ${type}, but got ${config.property[field].type}`, { config });
|
|
107
109
|
}
|
|
108
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns the instance registry.
|
|
113
|
+
*/
|
|
114
|
+
getInstanceRegistry() {
|
|
115
|
+
return this.instances;
|
|
116
|
+
}
|
|
109
117
|
}
|
|
110
118
|
exports.ConfigConstructorPool = ConfigConstructorPool;
|
|
111
119
|
//# sourceMappingURL=ConfigConstructorPool.js.map
|
|
@@ -11,4 +11,9 @@ export interface IConfigConstructorPool<Instance> {
|
|
|
11
11
|
* @returns {any} The run instance.
|
|
12
12
|
*/
|
|
13
13
|
instantiate: (configResource: Resource, settings: IConstructionSettings) => Promise<Instance>;
|
|
14
|
+
/**
|
|
15
|
+
* Return the instance regsitry.
|
|
16
|
+
* This is a hash from registered id to a Promise of the Instance.
|
|
17
|
+
*/
|
|
18
|
+
getInstanceRegistry: () => Record<string, Promise<Instance>>;
|
|
14
19
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Readable } from 'stream';
|
|
3
3
|
import type * as RDF from '@rdfjs/types';
|
|
4
|
-
import type { RdfObjectLoader } from 'rdf-object';
|
|
4
|
+
import type { RdfObjectLoader, Resource } from 'rdf-object';
|
|
5
5
|
import type { Logger } from 'winston';
|
|
6
6
|
import type { IModuleState } from './ModuleStateBuilder';
|
|
7
7
|
/**
|
|
@@ -30,6 +30,11 @@ export declare class ConfigRegistry {
|
|
|
30
30
|
* @param params A dictionary with named parameters.
|
|
31
31
|
*/
|
|
32
32
|
registerCustom(configId: string, componentTypeIri: string, params: Record<string, string>): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the instantiated Resource that was registered to the given term.
|
|
35
|
+
* @param term The term of the Resource that was instantiated
|
|
36
|
+
*/
|
|
37
|
+
getInstantiatedResource(term: RDF.Term): Resource;
|
|
33
38
|
}
|
|
34
39
|
export interface IConfigLoaderRegistryOptions {
|
|
35
40
|
moduleState: IModuleState;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConfigRegistry = void 0;
|
|
4
|
+
const rdf_string_1 = require("rdf-string");
|
|
4
5
|
const RdfParser_1 = require("../rdf/RdfParser");
|
|
5
6
|
/**
|
|
6
7
|
* Accepts registrations for configurations that contain instantiations of components.
|
|
@@ -50,6 +51,13 @@ class ConfigRegistry {
|
|
|
50
51
|
configResource.property[key] = this.objectLoader.createCompactedResource(`"${params[key]}"`);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the instantiated Resource that was registered to the given term.
|
|
56
|
+
* @param term The term of the Resource that was instantiated
|
|
57
|
+
*/
|
|
58
|
+
getInstantiatedResource(term) {
|
|
59
|
+
return this.objectLoader.resources[(0, rdf_string_1.termToString)(term)];
|
|
60
|
+
}
|
|
53
61
|
}
|
|
54
62
|
exports.ConfigRegistry = ConfigRegistry;
|
|
55
63
|
//# sourceMappingURL=ConfigRegistry.js.map
|
|
@@ -33,6 +33,11 @@ export declare class ParameterPropertyHandlerRange implements IParameterProperty
|
|
|
33
33
|
* @return IParamValueConflict A conflict value if there was an error, or undefined if there was no error
|
|
34
34
|
*/
|
|
35
35
|
hasValueType(value: Resource | undefined, type: Resource | undefined, errorContext: IErrorContext, genericsContext: GenericsContext): IParamValueConflict | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Utility function for handling Literals.
|
|
38
|
+
* If the provided value represents a valid Literal, the `valueRaw` field will be set.
|
|
39
|
+
*/
|
|
40
|
+
private interpretValueAsType;
|
|
36
41
|
static throwIncorrectTypeError(value: Resource | undefined, parameter: Resource, genericsContext: GenericsContext, conflict: IParamValueConflict): never;
|
|
37
42
|
/**
|
|
38
43
|
* Check if the given value is of the given type.
|
|
@@ -54,3 +59,13 @@ export interface IParamValueConflict {
|
|
|
54
59
|
context: IErrorContext;
|
|
55
60
|
causes?: IParamValueConflict[];
|
|
56
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Represents the result of an interpretValuesAsType operation.
|
|
64
|
+
*/
|
|
65
|
+
export interface ILiteralAsTypeInterpretationResult {
|
|
66
|
+
/**
|
|
67
|
+
* Value is true if a matching literal type was found.
|
|
68
|
+
*/
|
|
69
|
+
match: boolean;
|
|
70
|
+
value?: IParamValueConflict;
|
|
71
|
+
}
|
|
@@ -53,6 +53,11 @@ class ParameterPropertyHandlerRange {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
if (type.isA('ParameterRangeWildcard')) {
|
|
56
|
+
if (value && value.term.termType === 'Literal') {
|
|
57
|
+
// Get datatype of the configured value
|
|
58
|
+
const configuredDataType = value.term.datatype;
|
|
59
|
+
return this.interpretValueAsType(value, configuredDataType, errorContext, genericsContext).value;
|
|
60
|
+
}
|
|
56
61
|
return;
|
|
57
62
|
}
|
|
58
63
|
if (!value && type.isA('ParameterRangeUndefined')) {
|
|
@@ -64,69 +69,10 @@ class ParameterPropertyHandlerRange {
|
|
|
64
69
|
}
|
|
65
70
|
// Handle literal values
|
|
66
71
|
if (value && value.type === 'Literal') {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
case Iris_1.IRIS_XSD.boolean:
|
|
72
|
-
if (value.value === 'true') {
|
|
73
|
-
value.term.valueRaw = true;
|
|
74
|
-
}
|
|
75
|
-
else if (value.value === 'false') {
|
|
76
|
-
value.term.valueRaw = false;
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
return {
|
|
80
|
-
description: 'value must either be "true" or "false"',
|
|
81
|
-
context: errorContext,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
return;
|
|
85
|
-
case Iris_1.IRIS_XSD.integer:
|
|
86
|
-
case Iris_1.IRIS_XSD.number:
|
|
87
|
-
case Iris_1.IRIS_XSD.int:
|
|
88
|
-
case Iris_1.IRIS_XSD.byte:
|
|
89
|
-
case Iris_1.IRIS_XSD.long:
|
|
90
|
-
parsed = Number.parseInt(value.value, 10);
|
|
91
|
-
if (Number.isNaN(parsed)) {
|
|
92
|
-
return {
|
|
93
|
-
description: `value is not a number`,
|
|
94
|
-
context: errorContext,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
// ParseInt also parses floats to ints!
|
|
98
|
-
if (String(parsed) !== value.value) {
|
|
99
|
-
return {
|
|
100
|
-
description: `value can not be a float`,
|
|
101
|
-
context: errorContext,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
value.term.valueRaw = parsed;
|
|
105
|
-
return;
|
|
106
|
-
case Iris_1.IRIS_XSD.float:
|
|
107
|
-
case Iris_1.IRIS_XSD.decimal:
|
|
108
|
-
case Iris_1.IRIS_XSD.double:
|
|
109
|
-
parsed = Number.parseFloat(value.value);
|
|
110
|
-
if (Number.isNaN(parsed)) {
|
|
111
|
-
return {
|
|
112
|
-
description: `value is not a number`,
|
|
113
|
-
context: errorContext,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
value.term.valueRaw = parsed;
|
|
117
|
-
return;
|
|
118
|
-
case Iris_1.IRIS_RDF.JSON:
|
|
119
|
-
try {
|
|
120
|
-
parsed = JSON.parse(value.value);
|
|
121
|
-
value.term.valueRaw = parsed;
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
return {
|
|
125
|
-
description: `JSON parse exception: ${error.message}`,
|
|
126
|
-
context: errorContext,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
return;
|
|
72
|
+
const result = this.interpretValueAsType(value, type, errorContext, genericsContext);
|
|
73
|
+
if (result.match) {
|
|
74
|
+
// Stop processing and return (with a possible IParamValueConflict) if a match was found.
|
|
75
|
+
return result.value;
|
|
130
76
|
}
|
|
131
77
|
}
|
|
132
78
|
// Allow IRIs to be casted to strings
|
|
@@ -359,6 +305,93 @@ class ParameterPropertyHandlerRange {
|
|
|
359
305
|
}
|
|
360
306
|
return hasTypeConflict || { description: 'unknown parameter type', context: errorContext };
|
|
361
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Utility function for handling Literals.
|
|
310
|
+
* If the provided value represents a valid Literal, the `valueRaw` field will be set.
|
|
311
|
+
*/
|
|
312
|
+
interpretValueAsType(value, type, errorContext, genericsContext) {
|
|
313
|
+
let parsed;
|
|
314
|
+
switch (type.value) {
|
|
315
|
+
case Iris_1.IRIS_XSD.string:
|
|
316
|
+
return { match: true };
|
|
317
|
+
case Iris_1.IRIS_XSD.boolean:
|
|
318
|
+
if (value.value === 'true') {
|
|
319
|
+
value.term.valueRaw = true;
|
|
320
|
+
}
|
|
321
|
+
else if (value.value === 'false') {
|
|
322
|
+
value.term.valueRaw = false;
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
return {
|
|
326
|
+
match: true,
|
|
327
|
+
value: {
|
|
328
|
+
description: 'value must either be "true" or "false"',
|
|
329
|
+
context: errorContext,
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
return { match: true };
|
|
334
|
+
case Iris_1.IRIS_XSD.integer:
|
|
335
|
+
case Iris_1.IRIS_XSD.number:
|
|
336
|
+
case Iris_1.IRIS_XSD.int:
|
|
337
|
+
case Iris_1.IRIS_XSD.byte:
|
|
338
|
+
case Iris_1.IRIS_XSD.long:
|
|
339
|
+
parsed = Number.parseInt(value.value, 10);
|
|
340
|
+
if (Number.isNaN(parsed)) {
|
|
341
|
+
return {
|
|
342
|
+
match: true,
|
|
343
|
+
value: {
|
|
344
|
+
description: `value is not a number`,
|
|
345
|
+
context: errorContext,
|
|
346
|
+
},
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
// ParseInt also parses floats to ints!
|
|
350
|
+
if (String(parsed) !== value.value) {
|
|
351
|
+
return {
|
|
352
|
+
match: true,
|
|
353
|
+
value: {
|
|
354
|
+
description: `value can not be a float`,
|
|
355
|
+
context: errorContext,
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
value.term.valueRaw = parsed;
|
|
360
|
+
return { match: true };
|
|
361
|
+
case Iris_1.IRIS_XSD.float:
|
|
362
|
+
case Iris_1.IRIS_XSD.decimal:
|
|
363
|
+
case Iris_1.IRIS_XSD.double:
|
|
364
|
+
parsed = Number.parseFloat(value.value);
|
|
365
|
+
if (Number.isNaN(parsed)) {
|
|
366
|
+
return {
|
|
367
|
+
match: true,
|
|
368
|
+
value: {
|
|
369
|
+
description: `value is not a number`,
|
|
370
|
+
context: errorContext,
|
|
371
|
+
},
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
value.term.valueRaw = parsed;
|
|
375
|
+
return { match: true };
|
|
376
|
+
case Iris_1.IRIS_RDF.JSON:
|
|
377
|
+
try {
|
|
378
|
+
parsed = JSON.parse(value.value);
|
|
379
|
+
value.term.valueRaw = parsed;
|
|
380
|
+
}
|
|
381
|
+
catch (error) {
|
|
382
|
+
return {
|
|
383
|
+
match: true,
|
|
384
|
+
value: {
|
|
385
|
+
description: `JSON parse exception: ${error.message}`,
|
|
386
|
+
context: errorContext,
|
|
387
|
+
},
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
return { match: true };
|
|
391
|
+
default:
|
|
392
|
+
return { match: false };
|
|
393
|
+
}
|
|
394
|
+
}
|
|
362
395
|
static throwIncorrectTypeError(value, parameter, genericsContext, conflict) {
|
|
363
396
|
const withTypes = value && value.properties.types.length > 0 ? ` with types "${value.properties.types.map(resource => resource.value)}"` : '';
|
|
364
397
|
// eslint-disable-next-line @typescript-eslint/no-extra-parens
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "componentsjs",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "A semantic dependency injection framework",
|
|
5
5
|
"lsd:contexts": {
|
|
6
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^
|
|
6
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld": "components/context.jsonld"
|
|
7
7
|
},
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"bin": {
|
|
@@ -41,17 +41,18 @@
|
|
|
41
41
|
"minimist": "^1.2.0",
|
|
42
42
|
"rdf-data-factory": "^1.1.0",
|
|
43
43
|
"rdf-object": "^1.13.1",
|
|
44
|
-
"rdf-parse": "^
|
|
44
|
+
"rdf-parse": "^2.0.0",
|
|
45
45
|
"rdf-quad": "^1.5.0",
|
|
46
|
+
"rdf-string": "^1.6.0",
|
|
46
47
|
"rdf-terms": "^1.7.0",
|
|
47
48
|
"semver": "^7.3.2",
|
|
48
49
|
"winston": "^3.3.3"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@rubensworks/eslint-config": "^1.0.1",
|
|
53
|
+
"@types/jest": "^27.0.0",
|
|
52
54
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
53
55
|
"@typescript-eslint/parser": "^5.0.0",
|
|
54
|
-
"@types/jest": "^27.0.0",
|
|
55
56
|
"eslint": "^7.12.1",
|
|
56
57
|
"eslint-config-es": "3.25.3",
|
|
57
58
|
"eslint-import-resolver-typescript": "^2.3.0",
|