componentsjs 5.0.0-beta.0 → 5.0.0-beta.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/CHANGELOG.md +231 -0
- package/components/context.jsonld +26 -1
- package/lib/preprocess/ConfigPreprocessorComponent.d.ts +2 -0
- package/lib/preprocess/ConfigPreprocessorComponent.js +22 -1
- package/lib/preprocess/ConfigPreprocessorComponentMapped.d.ts +3 -2
- package/lib/preprocess/ConfigPreprocessorComponentMapped.js +9 -7
- package/lib/preprocess/GenericsContext.d.ts +30 -0
- package/lib/preprocess/GenericsContext.js +63 -0
- package/lib/preprocess/ParameterHandler.d.ts +4 -2
- package/lib/preprocess/ParameterHandler.js +5 -4
- package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerCollectEntries.d.ts +3 -2
- package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerCollectEntries.js +8 -6
- package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerElements.d.ts +2 -1
- package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerElements.js +2 -2
- package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerFields.d.ts +2 -1
- package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerFields.js +3 -2
- package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerKeyValue.d.ts +4 -3
- package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerKeyValue.js +7 -7
- package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerList.d.ts +2 -1
- package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerList.js +5 -3
- package/lib/preprocess/constructorargumentsmapping/IConstructorArgumentsElementMappingHandler.d.ts +5 -2
- package/lib/preprocess/constructorargumentsmapping/IConstructorArgumentsMapper.d.ts +5 -2
- package/lib/preprocess/parameterproperty/IParameterPropertyHandler.d.ts +5 -2
- package/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.d.ts +8 -5
- package/lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.js +55 -22
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
<a name="v5.0.0-beta.1"></a>
|
|
5
|
+
## [v5.0.0-beta.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v5.0.0-beta.0...v5.0.0-beta.1) - 2021-12-07
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
* [Handle generics in nested components](https://github.com/LinkedSoftwareDependencies/Components.js/commit/d33d4c2668974087873943b3d5c66300fa3df65b)
|
|
9
|
+
* [Handle generics in parameter ranges](https://github.com/LinkedSoftwareDependencies/Components.js/commit/d3358b74ab25a3aca13d6dfc97b16cfd836d4ba9)
|
|
10
|
+
* [Add generic vocabulary changes to context](https://github.com/LinkedSoftwareDependencies/Components.js/commit/b8af018bb8f344833c07d1ef795a6b08d414c2ad)
|
|
11
|
+
|
|
12
|
+
<a name="v5.0.0-beta.0"></a>
|
|
13
|
+
## [v5.0.0-beta.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.5.0...v5.0.0-beta.0) - 2021-11-30
|
|
14
|
+
|
|
15
|
+
### BREAKING CHANGES
|
|
16
|
+
* [Remove required and unique param flags in favor of parameter ranges](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0df26318e4803b06660b3458fc75d565c4b60f67):
|
|
17
|
+
This allows more complex ranges to be defined, such as nested arrays, or arrays of union types.
|
|
18
|
+
**Because of this change, arrays now must always be explicitly defined within an RDF list (or @list in JSON-LD).**
|
|
19
|
+
If one param value is provided, it is considered a singular value.
|
|
20
|
+
If the param value contains an RDF list, it is considered an array.
|
|
21
|
+
If multiple param values are provided without RDF list, an error is thrown.
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
* Validate parameter values by type:
|
|
25
|
+
* [Validate param ranges with union and intersection types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/d08ecdb94051d3e88e7e1ea09f0f77518fb0debf)
|
|
26
|
+
* [Validate types of resource-based param values](https://github.com/LinkedSoftwareDependencies/Components.js/commit/2be90ccb416215261ef9c785e89302f3c4ef9264)
|
|
27
|
+
* [Validate param ranges with tuple types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/05d84c4c1d4bde6bcb5a99d53df4e66ca69536bf)
|
|
28
|
+
* [Validate param ranges with literal types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/7373b0fc06bdaf95a8099b9f58b741cd6f4f1b9d)
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
* [Allow IRIs to be casted to string params](https://github.com/LinkedSoftwareDependencies/Components.js/commit/978985684dcba67629d44bfd0e5cf75293c5ea7a)
|
|
32
|
+
* [Allow components to be registered to multiple modules](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e575e64ebd26092a6bb005d837023e35877e9308)
|
|
33
|
+
* [Make relative IRIs make use of importPaths-based URLs if possible](https://github.com/LinkedSoftwareDependencies/Components.js/commit/6a2e18c3bf6a1b95f826b66ee0ef8b154f10c3cc)
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
* [Fix raw JSON values not being serializable to strings](https://github.com/LinkedSoftwareDependencies/Components.js/commit/96fe46eda1e153e87b29689196506ce6fbbdae58)
|
|
37
|
+
|
|
38
|
+
<a name="v4.5.0"></a>
|
|
39
|
+
## [v4.5.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.4.1...v4.5.0) - 2021-08-30
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
* [Migrate to @rdfjs/types](https://github.com/LinkedSoftwareDependencies/Components.js/commit/b2f9f2e0c5512e743b324f48f332d96e4214ec84)
|
|
43
|
+
|
|
44
|
+
<a name="v4.4.1"></a>
|
|
45
|
+
## [v4.4.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.4.0...v4.4.1) - 2021-07-26
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
* [Fix RDF lists not being accepted for all params](https://github.com/LinkedSoftwareDependencies/Components.js/commit/a01e3c80a3a5ce28180f57e8358327c53774b9ba)
|
|
49
|
+
|
|
50
|
+
<a name="v4.4.0"></a>
|
|
51
|
+
## [v4.4.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.2.1...v4.4.0) - 2021-06-30
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
* [Accept RDF lists as argument values, #47](https://github.com/LinkedSoftwareDependencies/Components.js/commit/3501a0fe676d1bc43c2d3ad329fca0adef48c8cd)
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
* [Allow arrays of resources to be passed to ErrorResourcesContext](https://github.com/LinkedSoftwareDependencies/Components.js/commit/aedd53a3e923e030bf0d8433c27f1259183a0a14)
|
|
58
|
+
|
|
59
|
+
<a name="v4.3.0"></a>
|
|
60
|
+
## [v4.3.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.2.1...v4.3.0) - 2021-06-14
|
|
61
|
+
|
|
62
|
+
### Added
|
|
63
|
+
* [Support JSON param ranges via rdf:JSON, Closes #37](https://github.com/LinkedSoftwareDependencies/Components.js/commit/339d2219915bc618991a42adcd8b63a3d6caa9b5)
|
|
64
|
+
|
|
65
|
+
<a name="v4.2.1"></a>
|
|
66
|
+
## [v4.2.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.2.0...v4.2.1) - 2021-05-26
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
* [Allow configs to have multiple identical types, comunica/examples#11](https://github.com/LinkedSoftwareDependencies/Components.js/commit/5285f8e68fefb13d46538c6949238200055a2047)
|
|
70
|
+
|
|
71
|
+
<a name="v4.2.0"></a>
|
|
72
|
+
## [v4.2.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.1.0...v4.2.0) - 2021-05-19
|
|
73
|
+
|
|
74
|
+
### Added
|
|
75
|
+
* [Expose RdfObjectLoader ctor from ComponentsManagerBuilder](https://github.com/LinkedSoftwareDependencies/Components.js/commit/1b1c85adb50855eed5b628788ccea3609aa841ca)
|
|
76
|
+
|
|
77
|
+
<a name="v4.1.0"></a>
|
|
78
|
+
## [v4.1.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.6...v4.1.0) - 2021-04-27
|
|
79
|
+
|
|
80
|
+
### Added
|
|
81
|
+
* [Allow JSON-LD context validation to be skipped](https://github.com/LinkedSoftwareDependencies/Components.js/commit/40931625dc0a577800c60e0cb4aa12393eb26bab)
|
|
82
|
+
|
|
83
|
+
<a name="v4.0.6"></a>
|
|
84
|
+
## [v4.0.6](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.5...v4.0.6) - 2021-01-27
|
|
85
|
+
|
|
86
|
+
### Fixed
|
|
87
|
+
* [Fix undefined root constructor args missing instead of being undefined](https://github.com/LinkedSoftwareDependencies/Components.js/commit/de14c611122ddb031d2973d4e667efa5b13bdf45)
|
|
88
|
+
|
|
89
|
+
<a name="v4.0.5"></a>
|
|
90
|
+
## [v4.0.5](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.4...v4.0.5) - 2021-01-18
|
|
91
|
+
|
|
92
|
+
### Fixed
|
|
93
|
+
* [Allow module discovery in packages without package.json](https://github.com/LinkedSoftwareDependencies/Components.js/commit/a0ac0cb47b2ed07ef7a88619133af15ba71f3577)
|
|
94
|
+
|
|
95
|
+
<a name="v4.0.4"></a>
|
|
96
|
+
## [v4.0.4](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.3...v4.0.4) - 2021-01-15
|
|
97
|
+
|
|
98
|
+
### Changed
|
|
99
|
+
* [Bump rdf-parse with updated components.js context URL](https://github.com/LinkedSoftwareDependencies/Components.js/commit/7525a027c683890f30f4e47402c89dcca7dd89d7)
|
|
100
|
+
|
|
101
|
+
<a name="v4.0.3"></a>
|
|
102
|
+
## [v4.0.3](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.2...v4.0.3) - 2021-01-15
|
|
103
|
+
|
|
104
|
+
### Fixed
|
|
105
|
+
* [Fix broken infinite recursion workaround, #31](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e9f2fdc78eca77f3070663c4dc360e93b1f4c0bb)
|
|
106
|
+
|
|
107
|
+
<a name="v4.0.2"></a>
|
|
108
|
+
## [v4.0.2](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.1...v4.0.2) - 2021-01-15
|
|
109
|
+
|
|
110
|
+
### Fixed
|
|
111
|
+
* [Fix instances being created multiple times, Closes #31](https://github.com/LinkedSoftwareDependencies/Components.js/commit/94ce08874b24bf9c64d7f722beb2d5556aa9c7e9)
|
|
112
|
+
* [Fix value inheritance happening multiple times](https://github.com/LinkedSoftwareDependencies/Components.js/commit/1855178930d2babd2c3a4c6cdad66087c1db79cd)
|
|
113
|
+
|
|
114
|
+
<a name="v4.0.1"></a>
|
|
115
|
+
## [v4.0.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v4.0.0...v4.0.1) - 2021-01-14
|
|
116
|
+
|
|
117
|
+
### Fixed
|
|
118
|
+
* [Fix module resolution failure when outside main module](https://github.com/LinkedSoftwareDependencies/Components.js/commit/2fb4de8abda5d5e91d39942edcc0bafd29acd8ce)
|
|
119
|
+
|
|
120
|
+
<a name="v4.0.0"></a>
|
|
121
|
+
## [v4.0.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.6.0...v4.0.0) - 2021-01-14
|
|
122
|
+
|
|
123
|
+
This release contains breaking changes in the programmatic API,
|
|
124
|
+
but module and configuration files remain backwards-compatible.
|
|
125
|
+
|
|
126
|
+
### Added
|
|
127
|
+
* Developer convenience
|
|
128
|
+
* [Allow `lsd:module` to be set to true in package.json](https://github.com/LinkedSoftwareDependencies/Components.js/commit/afeac8ab11e801376d265d3e42b5df7e113bfce4)
|
|
129
|
+
* [Emit warning when a remote context lookup is being done](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0f3968c26ff5c3d38e3cc8282c6039ff1221b4fd)
|
|
130
|
+
* [Emit warning on potentially invalid parameters in config](https://github.com/LinkedSoftwareDependencies/Components.js/commit/a3ebb95a8d0e18ad062269c47b65cc2d9d1b603a)
|
|
131
|
+
* [Emit warning on potentially invalid IRIs](https://github.com/LinkedSoftwareDependencies/Components.js/commit/18f9f974965d049fd3808ae3a725a36bf264183b)
|
|
132
|
+
* [Generate componentsjs-error-state.json on error](https://github.com/LinkedSoftwareDependencies/Components.js/commit/bd47b17ba3fe82b2486e86bc678d950a9c478d18)
|
|
133
|
+
* [Validate multiple key-value occurences in collectEntries](https://github.com/LinkedSoftwareDependencies/Components.js/commit/ab88b14aa5f2c0c18b34668d6ca1aed8d611de11)
|
|
134
|
+
* [Improve printing of Resources in error reporting](https://github.com/LinkedSoftwareDependencies/Components.js/commit/48d2df7196a1e80e1bb55ac5c6518394b0942d4d)
|
|
135
|
+
* [Rewrite injection of custom JSON-LD document loader](https://github.com/LinkedSoftwareDependencies/Components.js/commit/98ae62f9ddb6589a8651f3a4b9bac6b2bb6642b4)
|
|
136
|
+
* [Migrate RDF loading logic to rdf-object](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e5eb9d27e04a4a333487d5805ce5b0d17cd578a7)
|
|
137
|
+
|
|
138
|
+
### Changed
|
|
139
|
+
* [Use rdfs:seeAlso instead of owl:imports for importing](https://github.com/LinkedSoftwareDependencies/Components.js/commit/4e4227cca2c588e008259440e211af90e6756949)
|
|
140
|
+
* [Handle semver on multiple occurrences of module packages](https://github.com/LinkedSoftwareDependencies/Components.js/commit/c8b2e3377d397179505064e43c4408e19447df6f)
|
|
141
|
+
* [Improve performance of module state loading through parallelization](https://github.com/LinkedSoftwareDependencies/Components.js/commit/4c475b0ee4d7fae31a818dc72fe28223827fd1f1)
|
|
142
|
+
* Refactoring
|
|
143
|
+
* [Accept loading from RDF/JS streams, Closes #1](https://github.com/LinkedSoftwareDependencies/Components.js/commit/749a7e7b5166414f68b5aabd285e5fd747b4dac4)
|
|
144
|
+
* [Add logger](https://github.com/LinkedSoftwareDependencies/Components.js/commit/a5497590d3dabf06c00831f53d95da1554305b10)
|
|
145
|
+
* [Split up Loader into ComponentsManager and loading classes](https://github.com/LinkedSoftwareDependencies/Components.js/commit/687b15c61ea8766b49dadf132fd38b0151f7f6ac)
|
|
146
|
+
* [Split parameter property handling into seperate handlers](https://github.com/LinkedSoftwareDependencies/Components.js/commit/e60a2a8bddc8a89b834cc21db51964bb2f8c3a93)
|
|
147
|
+
* [Create dedicated ParameterHandler component](https://github.com/LinkedSoftwareDependencies/Components.js/commit/408d299f77bc172e61a46d7dfbc4a6c931cecff6)
|
|
148
|
+
* [Reorganize relevant classes into construction package](https://github.com/LinkedSoftwareDependencies/Components.js/commit/aa6b56328fd4442886a82fcad187bd7380c05f27)
|
|
149
|
+
* [Split arguments creation into separate handlers](https://github.com/LinkedSoftwareDependencies/Components.js/commit/f3e995bd603369fb6e21d9be041ce96bec3b475b)
|
|
150
|
+
* [Split constructor args handling into separate handlers](https://github.com/LinkedSoftwareDependencies/Components.js/commit/33f678c5e5df96277243feca893d46882ebdd927)
|
|
151
|
+
* [Refactor component factories as config preprocessors](https://github.com/LinkedSoftwareDependencies/Components.js/commit/181b165f929cfcab206bc6d5ba22032f76d723c8)
|
|
152
|
+
* [Remove Util.PREFIXES in favour if Iris](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0c0c671b18bd8fe2161d56fd39ee8645adc12c63)
|
|
153
|
+
* [Decouple CommonJS instantiation and serialization into strategies](https://github.com/LinkedSoftwareDependencies/Components.js/commit/4756e0ce2f52711d7eb6df7afcc1011da210dbf0)
|
|
154
|
+
* [Decouple instantiation logic from Loader class](https://github.com/LinkedSoftwareDependencies/Components.js/commit/02dd0e64e37c9961be68beba09f03a3b52d0c00f)
|
|
155
|
+
* [Rewrite RdfStreamIncluder as Transform stream](https://github.com/LinkedSoftwareDependencies/Components.js/commit/edf6c61b28f06d2539bcdc8498f10586272a2632)
|
|
156
|
+
* [Delay module registration until finalization phase](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0de3b7940277fd207d7729da4921e62063434e20)
|
|
157
|
+
* [Refactor module loading into ModuleStateBuilder](https://github.com/LinkedSoftwareDependencies/Components.js/commit/6e6e54b498efb3e922466ef9868995926cd20ca8)
|
|
158
|
+
|
|
159
|
+
### Removed
|
|
160
|
+
* [Remove feature to use global modules](https://github.com/LinkedSoftwareDependencies/Components.js/commit/fc0f943ac7e1cda4f84b3a65e2ad05ad1c7c42dc)
|
|
161
|
+
|
|
162
|
+
### Fixed
|
|
163
|
+
* [Fix config compilation using wrong file path](https://github.com/LinkedSoftwareDependencies/Components.js/commit/fd3f806fe9cbb4f74a433e2a31212b5acdddf056)
|
|
164
|
+
* [Fix mapped components only keeping first element of root arrays](https://github.com/LinkedSoftwareDependencies/Components.js/commit/0d33a9d88d473f930ce60c80949d13f5679b0df0)
|
|
165
|
+
|
|
166
|
+
<a name="v3.6.1"></a>
|
|
167
|
+
## [v3.6.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.6.0...v3.6.1) - 2020-11-25
|
|
168
|
+
|
|
169
|
+
### Fixed
|
|
170
|
+
* [Fix Array checks.](https://github.com/LinkedSoftwareDependencies/Components.js/commit/fdd48f6910ce395c72607992056f724953729f32)
|
|
171
|
+
* [Fix function check.](https://github.com/LinkedSoftwareDependencies/Components.js/commit/b685468cfc9de39c74207a1f79cc9efae2bffa4e)
|
|
172
|
+
|
|
173
|
+
<a name="v3.6.0"></a>
|
|
174
|
+
## [v3.6.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.5.0...v3.6.0) - 2020-09-14
|
|
175
|
+
|
|
176
|
+
### Added
|
|
177
|
+
* [Supporting variables in config compilation](https://github.com/LinkedSoftwareDependencies/Components.js/commit/5eb5def9d77b7755d9e121b07c9d23676684a5f1)
|
|
178
|
+
|
|
179
|
+
<a name="v3.5.0"></a>
|
|
180
|
+
## [v3.5.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.4.2...v3.5.0) - 2020-09-11
|
|
181
|
+
|
|
182
|
+
### Added
|
|
183
|
+
* [Accept variables as parameter values, that can be set at init](https://github.com/LinkedSoftwareDependencies/Components.js/commit/cbd6f115cabf2bfcdcc8466f434d5cf52a4c23d5)
|
|
184
|
+
|
|
185
|
+
<a name="v3.4.2"></a>
|
|
186
|
+
## [v3.4.2](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.4.1...v3.4.2) - 2020-08-27
|
|
187
|
+
|
|
188
|
+
### Fixed
|
|
189
|
+
* [Fix empty list class loading failure](https://github.com/LinkedSoftwareDependencies/Components.js/commit/3590171287d2d765417469ea85012b651c88064b)
|
|
190
|
+
|
|
191
|
+
<a name="v3.4.1"></a>
|
|
192
|
+
## [v3.4.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.4.0...v3.4.1) - 2020-07-01
|
|
193
|
+
|
|
194
|
+
### Changed
|
|
195
|
+
* [Make types proper dependencies](https://github.com/LinkedSoftwareDependencies/Components.js/commit/d50005517d606798de130a6cb2a4a4456683574c)
|
|
196
|
+
|
|
197
|
+
<a name="v3.4.0"></a>
|
|
198
|
+
## [v3.4.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.3.0...v3.4.0) - 2020-04-06
|
|
199
|
+
|
|
200
|
+
### Added
|
|
201
|
+
* [Add requireNoConstructor option for raw requireElements](https://github.com/LinkedSoftwareDependencies/Components.js/commit/2d3144b8baad1464d590b691da10b752f7b83342)
|
|
202
|
+
|
|
203
|
+
### Fixed
|
|
204
|
+
* [Fix incorrect error message for invalid dynamic entries](https://github.com/LinkedSoftwareDependencies/Components.js/commit/91b3a543973c06e3a0f3b6f667cc04a49e499103)
|
|
205
|
+
|
|
206
|
+
<a name="v3.3.0"></a>
|
|
207
|
+
## [v3.3.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.2.1...v3.3.0) - 2019-10-21
|
|
208
|
+
|
|
209
|
+
### Added
|
|
210
|
+
* [Allow requireName to be a relative path inside the module](https://github.com/LinkedSoftwareDependencies/Components.js/commit/562470dfbe6d3b1ab50e1202d8319adfafda024c)
|
|
211
|
+
|
|
212
|
+
### Changed
|
|
213
|
+
* [Return error code on failure to compile](https://github.com/LinkedSoftwareDependencies/Components.js/commit/06aa3420911a41963a97586cabbf34ae477084b1)
|
|
214
|
+
|
|
215
|
+
<a name="v3.2.1"></a>
|
|
216
|
+
## [v3.2.1](https://github.com/LinkedSoftwareDependencies/Components.js/compare/v3.2.0...v3.2.1) - 2019-02-21
|
|
217
|
+
|
|
218
|
+
### Fixed
|
|
219
|
+
* [Fix issues where context and component files would conflict](https://github.com/LinkedSoftwareDependencies/Components.js/commit/9e4812b23f6bc70099672172d480fc4855775622)
|
|
220
|
+
* [Fix incorrect comment context entry](https://github.com/LinkedSoftwareDependencies/Components.js/commit/21873b34a0dfc366f02ee1ad7dbd580795254ba5)
|
|
221
|
+
|
|
222
|
+
<a name="v3.2.0"></a>
|
|
223
|
+
## [v3.2.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/2.0.0...v3.2.0) - 2018-11-13
|
|
224
|
+
|
|
225
|
+
### Changed
|
|
226
|
+
* [Prioritize main modules when instantiating](https://github.com/LinkedSoftwareDependencies/Components.js/commit/c97f104d101f8dac96b501def69698615f58385b)
|
|
227
|
+
|
|
228
|
+
<a name="v3.1.0"></a>
|
|
229
|
+
## [v3.1.0](https://github.com/LinkedSoftwareDependencies/Components.js/compare/2.0.0...v3.1.0) - 2018-11-13
|
|
230
|
+
|
|
231
|
+
_Start tracking of changelog_
|
|
@@ -22,9 +22,16 @@
|
|
|
22
22
|
"components": {
|
|
23
23
|
"@id": "oo:component"
|
|
24
24
|
},
|
|
25
|
+
"component": {
|
|
26
|
+
"@id": "oo:component",
|
|
27
|
+
"@type": "@id"
|
|
28
|
+
},
|
|
25
29
|
"parameters": {
|
|
26
30
|
"@id": "oo:parameter"
|
|
27
31
|
},
|
|
32
|
+
"genericTypeParameters": {
|
|
33
|
+
"@id": "oo:genericTypeParameter"
|
|
34
|
+
},
|
|
28
35
|
"constructorArguments": {
|
|
29
36
|
"@id": "oo:constructorArguments",
|
|
30
37
|
"@container": "@list"
|
|
@@ -94,7 +101,25 @@
|
|
|
94
101
|
"@id": "oo:ParameterRangeCollectEntries"
|
|
95
102
|
},
|
|
96
103
|
"parameterRangeCollectEntriesParameters": {
|
|
97
|
-
"@id": "oo:
|
|
104
|
+
"@id": "oo:parameterRangeCollectEntriesParameter",
|
|
105
|
+
"@type": "@id"
|
|
106
|
+
},
|
|
107
|
+
"ParameterRangeGenericComponent": {
|
|
108
|
+
"@id": "oo:ParameterRangeGenericComponent"
|
|
109
|
+
},
|
|
110
|
+
"genericTypeInstances": {
|
|
111
|
+
"@id": "oo:genericTypeInstance",
|
|
112
|
+
"@type": "@id"
|
|
113
|
+
},
|
|
114
|
+
"ParameterRangeGenericTypeReference": {
|
|
115
|
+
"@id": "oo:ParameterRangeGenericTypeReference"
|
|
116
|
+
},
|
|
117
|
+
"parameterRangeGenericType": {
|
|
118
|
+
"@id": "oo:parameterRangeGenericType",
|
|
119
|
+
"@type": "@id"
|
|
120
|
+
},
|
|
121
|
+
"parameterRangeGenericBindings": {
|
|
122
|
+
"@id": "oo:parameterRangeGenericBindings",
|
|
98
123
|
"@type": "@id"
|
|
99
124
|
},
|
|
100
125
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Resource, RdfObjectLoader } from 'rdf-object';
|
|
2
2
|
import type { Logger } from 'winston';
|
|
3
|
+
import { GenericsContext } from './GenericsContext';
|
|
3
4
|
import type { IConfigPreprocessor } from './IConfigPreprocessor';
|
|
4
5
|
import type { ParameterHandler } from './ParameterHandler';
|
|
5
6
|
/**
|
|
@@ -15,6 +16,7 @@ export declare class ConfigPreprocessorComponent implements IConfigPreprocessor<
|
|
|
15
16
|
constructor(options: IComponentConfigPreprocessorOptions);
|
|
16
17
|
canHandle(config: Resource): IComponentConfigPreprocessorHandleResponse | undefined;
|
|
17
18
|
transform(config: Resource, handleResponse: IComponentConfigPreprocessorHandleResponse): Resource;
|
|
19
|
+
protected createGenericsContext(handleResponse: IComponentConfigPreprocessorHandleResponse, config: Resource): GenericsContext;
|
|
18
20
|
/**
|
|
19
21
|
* Determine the constructor arguments of the given config.
|
|
20
22
|
* @param config A config.
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ConfigPreprocessorComponent = void 0;
|
|
4
4
|
const Iris_1 = require("../rdf/Iris");
|
|
5
5
|
const ErrorResourcesContext_1 = require("../util/ErrorResourcesContext");
|
|
6
|
+
const GenericsContext_1 = require("./GenericsContext");
|
|
6
7
|
/**
|
|
7
8
|
* Handles config that refer to a component as type.
|
|
8
9
|
* The component may have parameters that can be applied on the config.
|
|
@@ -87,6 +88,24 @@ class ConfigPreprocessorComponent {
|
|
|
87
88
|
this.validateConfig(config, handleResponse);
|
|
88
89
|
return configRaw;
|
|
89
90
|
}
|
|
91
|
+
createGenericsContext(handleResponse, config) {
|
|
92
|
+
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;
|
|
106
|
+
}
|
|
107
|
+
return genericsContext;
|
|
108
|
+
}
|
|
90
109
|
/**
|
|
91
110
|
* Determine the constructor arguments of the given config.
|
|
92
111
|
* @param config A config.
|
|
@@ -94,10 +113,12 @@ class ConfigPreprocessorComponent {
|
|
|
94
113
|
*/
|
|
95
114
|
transformConstructorArguments(config, handleResponse) {
|
|
96
115
|
const entries = [];
|
|
116
|
+
const genericsContext = this.createGenericsContext(handleResponse, config);
|
|
97
117
|
for (const fieldData of handleResponse.component.properties.parameters) {
|
|
98
118
|
const field = this.objectLoader.createCompactedResource({});
|
|
99
119
|
field.property.key = this.objectLoader.createCompactedResource(`"${fieldData.term.value}"`);
|
|
100
|
-
const value = this.parameterHandler
|
|
120
|
+
const value = this.parameterHandler
|
|
121
|
+
.applyParameterValues(handleResponse.component, fieldData, config, genericsContext);
|
|
101
122
|
if (value) {
|
|
102
123
|
field.property.value = value;
|
|
103
124
|
}
|
|
@@ -2,6 +2,7 @@ import type { Resource } from 'rdf-object';
|
|
|
2
2
|
import type { IComponentConfigPreprocessorHandleResponse } from './ConfigPreprocessorComponent';
|
|
3
3
|
import { ConfigPreprocessorComponent } from './ConfigPreprocessorComponent';
|
|
4
4
|
import type { IConstructorArgumentsMapper } from './constructorargumentsmapping/IConstructorArgumentsMapper';
|
|
5
|
+
import type { GenericsContext } from './GenericsContext';
|
|
5
6
|
/**
|
|
6
7
|
* Handles config that refer to a component as type.
|
|
7
8
|
* The component may have parameters that can be applied on the config.
|
|
@@ -11,6 +12,6 @@ export declare class ConfigPreprocessorComponentMapped extends ConfigPreprocesso
|
|
|
11
12
|
private readonly mappingHandlers;
|
|
12
13
|
canHandle(config: Resource): IComponentConfigPreprocessorHandleResponse | undefined;
|
|
13
14
|
transformConstructorArguments(config: Resource, handleResponse: IComponentConfigPreprocessorHandleResponse): Resource;
|
|
14
|
-
applyConstructorArgumentsParameters(configRoot: Resource, constructorArgs: Resource, configElement: Resource): Resource;
|
|
15
|
-
getParameterValue(configRoot: Resource, parameter: Resource, configElement: Resource, rawValue: boolean): Resource | undefined;
|
|
15
|
+
applyConstructorArgumentsParameters(configRoot: Resource, constructorArgs: Resource, configElement: Resource, genericsContext: GenericsContext): Resource;
|
|
16
|
+
getParameterValue(configRoot: Resource, parameter: Resource, configElement: Resource, rawValue: boolean, genericsContext: GenericsContext): Resource | undefined;
|
|
16
17
|
}
|
|
@@ -33,28 +33,30 @@ class ConfigPreprocessorComponentMapped extends ConfigPreprocessorComponent_1.Co
|
|
|
33
33
|
}
|
|
34
34
|
transformConstructorArguments(config, handleResponse) {
|
|
35
35
|
const constructorArgs = handleResponse.component.property.constructorArguments;
|
|
36
|
-
|
|
36
|
+
const genericsContext = this.createGenericsContext(handleResponse, config);
|
|
37
|
+
return this.applyConstructorArgumentsParameters(config, constructorArgs, config, genericsContext);
|
|
37
38
|
}
|
|
38
|
-
applyConstructorArgumentsParameters(configRoot, constructorArgs, configElement) {
|
|
39
|
+
applyConstructorArgumentsParameters(configRoot, constructorArgs, configElement, genericsContext) {
|
|
39
40
|
// Check if this constructor args resource can be handled by one of the built-in handlers.
|
|
40
41
|
for (const handler of this.mappingHandlers) {
|
|
41
|
-
if (handler.canHandle(configRoot, constructorArgs, configElement, this)) {
|
|
42
|
-
return handler.handle(configRoot, constructorArgs, configElement, this);
|
|
42
|
+
if (handler.canHandle(configRoot, constructorArgs, configElement, this, genericsContext)) {
|
|
43
|
+
return handler.handle(configRoot, constructorArgs, configElement, this, genericsContext);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
// Fallback to original constructor args
|
|
46
47
|
return constructorArgs;
|
|
47
48
|
}
|
|
48
|
-
getParameterValue(configRoot, parameter, configElement, rawValue) {
|
|
49
|
+
getParameterValue(configRoot, parameter, configElement, rawValue, genericsContext) {
|
|
49
50
|
let valueOut;
|
|
50
51
|
if (parameter.type === 'NamedNode' && parameter.value === Iris_1.IRIS_RDF.subject) {
|
|
51
52
|
valueOut = this.objectLoader.createCompactedResource(`"${configElement.value}"`);
|
|
52
53
|
}
|
|
53
54
|
else if (parameter.type === 'NamedNode' && !parameter.property.fields) {
|
|
54
|
-
valueOut = this.parameterHandler
|
|
55
|
+
valueOut = this.parameterHandler
|
|
56
|
+
.applyParameterValues(configRoot, parameter, configElement, genericsContext);
|
|
55
57
|
}
|
|
56
58
|
else {
|
|
57
|
-
valueOut = this.applyConstructorArgumentsParameters(configRoot, parameter, configElement);
|
|
59
|
+
valueOut = this.applyConstructorArgumentsParameters(configRoot, parameter, configElement, genericsContext);
|
|
58
60
|
}
|
|
59
61
|
// If the referenced IRI should become a plain string
|
|
60
62
|
if (rawValue) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Resource, RdfObjectLoader } from 'rdf-object';
|
|
2
|
+
/**
|
|
3
|
+
* Context for binding generic types to a concrete range value.
|
|
4
|
+
*/
|
|
5
|
+
export declare class GenericsContext {
|
|
6
|
+
private readonly objectLoader;
|
|
7
|
+
/**
|
|
8
|
+
* Set of generic type ids.
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
readonly genericTypeIds: Record<string, boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Mapping of generic type id to the resolved range.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
readonly bindings: Record<string, Resource[]>;
|
|
17
|
+
constructor(objectLoader: RdfObjectLoader, genericTypeParameters: Resource[]);
|
|
18
|
+
/**
|
|
19
|
+
* Try to to bind the given value to the given generic.
|
|
20
|
+
* @param genericTypeId IRI of the generic to bind.
|
|
21
|
+
* @param value The value to bind to.
|
|
22
|
+
* @param typeValidator Callback for validating values against types.
|
|
23
|
+
*/
|
|
24
|
+
bindGenericTypeToValue(genericTypeId: string, value: Resource | undefined, typeValidator: (subValue: Resource | undefined, subType: Resource) => boolean): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Infer the parameter range of the given value.
|
|
27
|
+
* @param value A value.
|
|
28
|
+
*/
|
|
29
|
+
inferValueRange(value: Resource | undefined): Resource[];
|
|
30
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GenericsContext = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Context for binding generic types to a concrete range value.
|
|
6
|
+
*/
|
|
7
|
+
class GenericsContext {
|
|
8
|
+
constructor(objectLoader, genericTypeParameters) {
|
|
9
|
+
this.objectLoader = objectLoader;
|
|
10
|
+
this.genericTypeIds = Object.fromEntries(genericTypeParameters
|
|
11
|
+
.map(genericTypeParameter => [genericTypeParameter.value, true]));
|
|
12
|
+
this.bindings = {};
|
|
13
|
+
for (const genericTypeParameter of genericTypeParameters) {
|
|
14
|
+
if (genericTypeParameter.property.range) {
|
|
15
|
+
this.bindings[genericTypeParameter.value] = genericTypeParameter.properties.range;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Try to to bind the given value to the given generic.
|
|
21
|
+
* @param genericTypeId IRI of the generic to bind.
|
|
22
|
+
* @param value The value to bind to.
|
|
23
|
+
* @param typeValidator Callback for validating values against types.
|
|
24
|
+
*/
|
|
25
|
+
bindGenericTypeToValue(genericTypeId, value, typeValidator) {
|
|
26
|
+
// Fail if an unknown generic type is referenced
|
|
27
|
+
if (!(genericTypeId in this.genericTypeIds)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
// If the generic was already bound to a range, validate it
|
|
31
|
+
const existingRange = this.bindings[genericTypeId];
|
|
32
|
+
if (existingRange && existingRange.some(existingRangeElement => !typeValidator(value, existingRangeElement))) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
// Infer type of value
|
|
36
|
+
const valueRange = this.inferValueRange(value);
|
|
37
|
+
if (valueRange.length > 0) {
|
|
38
|
+
// If we already had a range, try to align them
|
|
39
|
+
// TODO: this will be needed for resources with common inheritance hierarchies
|
|
40
|
+
// Save inferred type
|
|
41
|
+
this.bindings[genericTypeId] = valueRange;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Infer the parameter range of the given value.
|
|
47
|
+
* @param value A value.
|
|
48
|
+
*/
|
|
49
|
+
inferValueRange(value) {
|
|
50
|
+
// Value is undefined
|
|
51
|
+
if (!value) {
|
|
52
|
+
return [this.objectLoader.createCompactedResource({ type: 'ParameterRangeUndefined' })];
|
|
53
|
+
}
|
|
54
|
+
// Value is a literal
|
|
55
|
+
if (value.term.termType === 'Literal') {
|
|
56
|
+
return [this.objectLoader.createCompactedResource(value.term.datatype)];
|
|
57
|
+
}
|
|
58
|
+
// Value is a named node
|
|
59
|
+
return value.properties.type;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.GenericsContext = GenericsContext;
|
|
63
|
+
//# sourceMappingURL=GenericsContext.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RdfObjectLoader, Resource } from 'rdf-object';
|
|
2
|
+
import type { GenericsContext } from './GenericsContext';
|
|
2
3
|
/**
|
|
3
4
|
* Handles component parameters in the context of a config.
|
|
4
5
|
*/
|
|
@@ -11,9 +12,10 @@ export declare class ParameterHandler {
|
|
|
11
12
|
* @param configRoot The root config resource that we are working in.
|
|
12
13
|
* @param parameter The parameter resource to get the value for.
|
|
13
14
|
* @param configElement Part of the config resource to look for parameter instantiations as predicates.
|
|
14
|
-
* @
|
|
15
|
+
* @param genericsContext Context for generic types.
|
|
16
|
+
* @return - The parameter value
|
|
15
17
|
*/
|
|
16
|
-
applyParameterValues(configRoot: Resource, parameter: Resource, configElement: Resource): Resource | undefined;
|
|
18
|
+
applyParameterValues(configRoot: Resource, parameter: Resource, configElement: Resource, genericsContext: GenericsContext): Resource | undefined;
|
|
17
19
|
}
|
|
18
20
|
export interface IParameterHandlerOptions {
|
|
19
21
|
objectLoader: RdfObjectLoader;
|
|
@@ -26,9 +26,10 @@ class ParameterHandler {
|
|
|
26
26
|
* @param configRoot The root config resource that we are working in.
|
|
27
27
|
* @param parameter The parameter resource to get the value for.
|
|
28
28
|
* @param configElement Part of the config resource to look for parameter instantiations as predicates.
|
|
29
|
-
* @
|
|
29
|
+
* @param genericsContext Context for generic types.
|
|
30
|
+
* @return - The parameter value
|
|
30
31
|
*/
|
|
31
|
-
applyParameterValues(configRoot, parameter, configElement) {
|
|
32
|
+
applyParameterValues(configRoot, parameter, configElement, genericsContext) {
|
|
32
33
|
// Make sure that we always have a single value with list elements in it.
|
|
33
34
|
const values = configElement.properties[parameter.value];
|
|
34
35
|
let value;
|
|
@@ -47,8 +48,8 @@ class ParameterHandler {
|
|
|
47
48
|
}
|
|
48
49
|
// Run the value through all applicable parameters property handlers.
|
|
49
50
|
for (const handler of this.parameterPropertyHandlers) {
|
|
50
|
-
if (handler.canHandle(value, configRoot, parameter, configElement)) {
|
|
51
|
-
value = handler.handle(value, configRoot, parameter, configElement);
|
|
51
|
+
if (handler.canHandle(value, configRoot, parameter, configElement, genericsContext)) {
|
|
52
|
+
value = handler.handle(value, configRoot, parameter, configElement, genericsContext);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
return value;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Resource } from 'rdf-object';
|
|
2
|
+
import type { GenericsContext } from '../GenericsContext';
|
|
2
3
|
import type { ParameterHandler } from '../ParameterHandler';
|
|
3
4
|
import type { IConstructorArgumentsElementMappingHandler } from './IConstructorArgumentsElementMappingHandler';
|
|
4
5
|
import type { IConstructorArgumentsMapper } from './IConstructorArgumentsMapper';
|
|
@@ -9,6 +10,6 @@ export declare class ConstructorArgumentsElementMappingHandlerCollectEntries imp
|
|
|
9
10
|
private readonly parameterHandler;
|
|
10
11
|
constructor(parameterHandler: ParameterHandler);
|
|
11
12
|
canHandle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): boolean;
|
|
12
|
-
handle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): Resource;
|
|
13
|
-
handleCollectEntry(entryResource: Resource, configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): Resource;
|
|
13
|
+
handle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper, genericsContext: GenericsContext): Resource;
|
|
14
|
+
handleCollectEntry(entryResource: Resource, configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper, genericsContext: GenericsContext): Resource;
|
|
14
15
|
}
|
|
@@ -14,7 +14,7 @@ class ConstructorArgumentsElementMappingHandlerCollectEntries {
|
|
|
14
14
|
return Boolean((constructorArgs.property.value || constructorArgs.property.valueRawReference) &&
|
|
15
15
|
constructorArgs.property.collectEntries);
|
|
16
16
|
}
|
|
17
|
-
handle(configRoot, constructorArgs, configElement, mapper) {
|
|
17
|
+
handle(configRoot, constructorArgs, configElement, mapper, genericsContext) {
|
|
18
18
|
if (constructorArgs.properties.collectEntries.length > 1) {
|
|
19
19
|
throw new ErrorResourcesContext_1.ErrorResourcesContext(`Invalid collectEntries: Only one value can be defined, or an RDF list must be provided`, {
|
|
20
20
|
constructorArgs,
|
|
@@ -31,7 +31,7 @@ class ConstructorArgumentsElementMappingHandlerCollectEntries {
|
|
|
31
31
|
config: configRoot,
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
const value = this.parameterHandler.applyParameterValues(configRoot, entry, configElement);
|
|
34
|
+
const value = this.parameterHandler.applyParameterValues(configRoot, entry, configElement, genericsContext);
|
|
35
35
|
if (value) {
|
|
36
36
|
for (const subValue of value.list || [value]) {
|
|
37
37
|
entryResources.push(subValue);
|
|
@@ -41,10 +41,10 @@ class ConstructorArgumentsElementMappingHandlerCollectEntries {
|
|
|
41
41
|
// Map all entries to values
|
|
42
42
|
return mapper.objectLoader.createCompactedResource({
|
|
43
43
|
list: entryResources.map((entryResource) => this
|
|
44
|
-
.handleCollectEntry(entryResource, configRoot, constructorArgs, configElement, mapper)),
|
|
44
|
+
.handleCollectEntry(entryResource, configRoot, constructorArgs, configElement, mapper, genericsContext)),
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
handleCollectEntry(entryResource, configRoot, constructorArgs, configElement, mapper) {
|
|
47
|
+
handleCollectEntry(entryResource, configRoot, constructorArgs, configElement, mapper, genericsContext) {
|
|
48
48
|
// Determine the (optional) entry key
|
|
49
49
|
let key;
|
|
50
50
|
if (constructorArgs.property.key) {
|
|
@@ -94,13 +94,15 @@ class ConstructorArgumentsElementMappingHandlerCollectEntries {
|
|
|
94
94
|
else if (constructorArgs.property.value.type === 'NamedNode' &&
|
|
95
95
|
constructorArgs.property.value.value === Iris_1.IRIS_RDF.object) {
|
|
96
96
|
// Value is the entry value
|
|
97
|
-
value = mapper
|
|
97
|
+
value = mapper
|
|
98
|
+
.applyConstructorArgumentsParameters(configRoot, entryResource, configElement, genericsContext);
|
|
98
99
|
}
|
|
99
100
|
else if (constructorArgs.property.value &&
|
|
100
101
|
(constructorArgs.property.value.property.fields || constructorArgs.property.value.property.elements)) {
|
|
101
102
|
// Nested mapping should reduce the parameter scope
|
|
102
103
|
// ! at the end of the line, because will always be truthy
|
|
103
|
-
value = mapper
|
|
104
|
+
value = mapper
|
|
105
|
+
.getParameterValue(configRoot, constructorArgs.property.value, entryResource, false, genericsContext);
|
|
104
106
|
}
|
|
105
107
|
else if (entryResource.properties[constructorArgs.property.value.value].length !== 1) {
|
|
106
108
|
throw new ErrorResourcesContext_1.ErrorResourcesContext(`Detected more than one value value in collectEntries`, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Resource } from 'rdf-object';
|
|
2
|
+
import type { GenericsContext } from '../GenericsContext';
|
|
2
3
|
import type { IConstructorArgumentsElementMappingHandler } from './IConstructorArgumentsElementMappingHandler';
|
|
3
4
|
import type { IConstructorArgumentsMapper } from './IConstructorArgumentsMapper';
|
|
4
5
|
/**
|
|
@@ -6,5 +7,5 @@ import type { IConstructorArgumentsMapper } from './IConstructorArgumentsMapper'
|
|
|
6
7
|
*/
|
|
7
8
|
export declare class ConstructorArgumentsElementMappingHandlerElements implements IConstructorArgumentsElementMappingHandler {
|
|
8
9
|
canHandle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): boolean;
|
|
9
|
-
handle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): Resource;
|
|
10
|
+
handle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper, genericsContext: GenericsContext): Resource;
|
|
10
11
|
}
|
|
@@ -9,7 +9,7 @@ class ConstructorArgumentsElementMappingHandlerElements {
|
|
|
9
9
|
canHandle(configRoot, constructorArgs, configElement, mapper) {
|
|
10
10
|
return Boolean(constructorArgs.property.elements);
|
|
11
11
|
}
|
|
12
|
-
handle(configRoot, constructorArgs, configElement, mapper) {
|
|
12
|
+
handle(configRoot, constructorArgs, configElement, mapper, genericsContext) {
|
|
13
13
|
// Elements must have RDF list values.
|
|
14
14
|
if (!constructorArgs.property.elements.list) {
|
|
15
15
|
throw new ErrorResourcesContext_1.ErrorResourcesContext(`Illegal non-RDF-list elements`, {
|
|
@@ -29,7 +29,7 @@ class ConstructorArgumentsElementMappingHandlerElements {
|
|
|
29
29
|
config: configRoot,
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
const value = mapper.getParameterValue(configRoot, element, configElement, Boolean(element.property.valueRawReference));
|
|
32
|
+
const value = mapper.getParameterValue(configRoot, element, configElement, Boolean(element.property.valueRawReference), genericsContext);
|
|
33
33
|
if (value) {
|
|
34
34
|
for (const entry of value.list || [value]) {
|
|
35
35
|
entries.push(entry);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Resource } from 'rdf-object';
|
|
2
|
+
import type { GenericsContext } from '../GenericsContext';
|
|
2
3
|
import type { IConstructorArgumentsElementMappingHandler } from './IConstructorArgumentsElementMappingHandler';
|
|
3
4
|
import type { IConstructorArgumentsMapper } from './IConstructorArgumentsMapper';
|
|
4
5
|
/**
|
|
@@ -6,5 +7,5 @@ import type { IConstructorArgumentsMapper } from './IConstructorArgumentsMapper'
|
|
|
6
7
|
*/
|
|
7
8
|
export declare class ConstructorArgumentsElementMappingHandlerFields implements IConstructorArgumentsElementMappingHandler {
|
|
8
9
|
canHandle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): boolean;
|
|
9
|
-
handle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): Resource;
|
|
10
|
+
handle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper, genericsContext: GenericsContext): Resource;
|
|
10
11
|
}
|
|
@@ -9,7 +9,7 @@ class ConstructorArgumentsElementMappingHandlerFields {
|
|
|
9
9
|
canHandle(configRoot, constructorArgs, configElement, mapper) {
|
|
10
10
|
return Boolean(constructorArgs.property.fields);
|
|
11
11
|
}
|
|
12
|
-
handle(configRoot, constructorArgs, configElement, mapper) {
|
|
12
|
+
handle(configRoot, constructorArgs, configElement, mapper, genericsContext) {
|
|
13
13
|
if (constructorArgs.properties.fields.length > 1) {
|
|
14
14
|
throw new ErrorResourcesContext_1.ErrorResourcesContext(`Invalid fields: Only one value can be defined, or an RDF list must be provided`, {
|
|
15
15
|
constructorArgs,
|
|
@@ -20,7 +20,8 @@ class ConstructorArgumentsElementMappingHandlerFields {
|
|
|
20
20
|
// Recursively handle all field values.
|
|
21
21
|
const entries = [];
|
|
22
22
|
for (const field of fields.list || [fields]) {
|
|
23
|
-
const mapped = mapper
|
|
23
|
+
const mapped = mapper
|
|
24
|
+
.applyConstructorArgumentsParameters(configRoot, field, configElement, genericsContext);
|
|
24
25
|
for (const entry of mapped.list || [mapped]) {
|
|
25
26
|
entries.push(entry);
|
|
26
27
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Resource } from 'rdf-object';
|
|
2
|
+
import type { GenericsContext } from '../GenericsContext';
|
|
2
3
|
import type { IConstructorArgumentsElementMappingHandler } from './IConstructorArgumentsElementMappingHandler';
|
|
3
4
|
import type { IConstructorArgumentsMapper } from './IConstructorArgumentsMapper';
|
|
4
5
|
/**
|
|
@@ -6,7 +7,7 @@ import type { IConstructorArgumentsMapper } from './IConstructorArgumentsMapper'
|
|
|
6
7
|
*/
|
|
7
8
|
export declare class ConstructorArgumentsElementMappingHandlerKeyValue implements IConstructorArgumentsElementMappingHandler {
|
|
8
9
|
canHandle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): boolean;
|
|
9
|
-
handle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): Resource;
|
|
10
|
-
handleKeyValue(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): Resource;
|
|
11
|
-
handleValue(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): Resource;
|
|
10
|
+
handle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper, genericsContext: GenericsContext): Resource;
|
|
11
|
+
handleKeyValue(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper, genericsContext: GenericsContext): Resource;
|
|
12
|
+
handleValue(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper, genericsContext: GenericsContext): Resource;
|
|
12
13
|
}
|
|
@@ -10,7 +10,7 @@ class ConstructorArgumentsElementMappingHandlerKeyValue {
|
|
|
10
10
|
return Boolean((constructorArgs.property.value || constructorArgs.property.valueRawReference) &&
|
|
11
11
|
!constructorArgs.property.collectEntries);
|
|
12
12
|
}
|
|
13
|
-
handle(configRoot, constructorArgs, configElement, mapper) {
|
|
13
|
+
handle(configRoot, constructorArgs, configElement, mapper, genericsContext) {
|
|
14
14
|
if (constructorArgs.property.key) {
|
|
15
15
|
// Throw if our key is not a literal
|
|
16
16
|
if (constructorArgs.property.key.type !== 'Literal') {
|
|
@@ -21,17 +21,17 @@ class ConstructorArgumentsElementMappingHandlerKeyValue {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
// Key-value
|
|
24
|
-
return this.handleKeyValue(configRoot, constructorArgs, configElement, mapper);
|
|
24
|
+
return this.handleKeyValue(configRoot, constructorArgs, configElement, mapper, genericsContext);
|
|
25
25
|
}
|
|
26
26
|
// Only value
|
|
27
|
-
return this.handleValue(configRoot, constructorArgs, configElement, mapper);
|
|
27
|
+
return this.handleValue(configRoot, constructorArgs, configElement, mapper, genericsContext);
|
|
28
28
|
}
|
|
29
|
-
handleKeyValue(configRoot, constructorArgs, configElement, mapper) {
|
|
30
|
-
const value = mapper.getParameterValue(configRoot, constructorArgs.property.value || constructorArgs.property.valueRawReference, configElement, Boolean(constructorArgs.property.valueRawReference));
|
|
29
|
+
handleKeyValue(configRoot, constructorArgs, configElement, mapper, genericsContext) {
|
|
30
|
+
const value = mapper.getParameterValue(configRoot, constructorArgs.property.value || constructorArgs.property.valueRawReference, configElement, Boolean(constructorArgs.property.valueRawReference), genericsContext);
|
|
31
31
|
return mapper.objectLoader.createCompactedResource(Object.assign({ key: constructorArgs.property.key }, value ? { value } : {}));
|
|
32
32
|
}
|
|
33
|
-
handleValue(configRoot, constructorArgs, configElement, mapper) {
|
|
34
|
-
const value = mapper.getParameterValue(configRoot, constructorArgs.property.value || constructorArgs.property.valueRawReference, configElement, Boolean(constructorArgs.property.valueRawReference));
|
|
33
|
+
handleValue(configRoot, constructorArgs, configElement, mapper, genericsContext) {
|
|
34
|
+
const value = mapper.getParameterValue(configRoot, constructorArgs.property.value || constructorArgs.property.valueRawReference, configElement, Boolean(constructorArgs.property.valueRawReference), genericsContext);
|
|
35
35
|
if (!value) {
|
|
36
36
|
return mapper.objectLoader.createCompactedResource({ undefined: true });
|
|
37
37
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Resource } from 'rdf-object';
|
|
2
|
+
import type { GenericsContext } from '../GenericsContext';
|
|
2
3
|
import type { IConstructorArgumentsElementMappingHandler } from './IConstructorArgumentsElementMappingHandler';
|
|
3
4
|
import type { IConstructorArgumentsMapper } from './IConstructorArgumentsMapper';
|
|
4
5
|
/**
|
|
@@ -6,5 +7,5 @@ import type { IConstructorArgumentsMapper } from './IConstructorArgumentsMapper'
|
|
|
6
7
|
*/
|
|
7
8
|
export declare class ConstructorArgumentsElementMappingHandlerList implements IConstructorArgumentsElementMappingHandler {
|
|
8
9
|
canHandle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): boolean;
|
|
9
|
-
handle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper): Resource;
|
|
10
|
+
handle(configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper, genericsContext: GenericsContext): Resource;
|
|
10
11
|
}
|
package/lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerList.js
CHANGED
|
@@ -8,16 +8,18 @@ class ConstructorArgumentsElementMappingHandlerList {
|
|
|
8
8
|
canHandle(configRoot, constructorArgs, configElement, mapper) {
|
|
9
9
|
return Boolean(constructorArgs.list);
|
|
10
10
|
}
|
|
11
|
-
handle(configRoot, constructorArgs, configElement, mapper) {
|
|
11
|
+
handle(configRoot, constructorArgs, configElement, mapper, genericsContext) {
|
|
12
12
|
// Recursively handle all field values.
|
|
13
13
|
const ret = mapper.objectLoader.createCompactedResource({});
|
|
14
14
|
ret.list = [];
|
|
15
15
|
for (const argument of constructorArgs.list) {
|
|
16
16
|
if (argument.property.fields || argument.property.elements) {
|
|
17
|
-
ret.list.push(mapper
|
|
17
|
+
ret.list.push(mapper
|
|
18
|
+
.applyConstructorArgumentsParameters(configRoot, argument, configElement, genericsContext));
|
|
18
19
|
}
|
|
19
20
|
else {
|
|
20
|
-
const value = mapper
|
|
21
|
+
const value = mapper
|
|
22
|
+
.getParameterValue(configRoot, argument, configElement, false, genericsContext);
|
|
21
23
|
if (value) {
|
|
22
24
|
ret.list.push(value);
|
|
23
25
|
}
|
package/lib/preprocess/constructorargumentsmapping/IConstructorArgumentsElementMappingHandler.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Resource } from 'rdf-object';
|
|
2
|
+
import type { GenericsContext } from '../GenericsContext';
|
|
2
3
|
import type { IConstructorArgumentsMapper } from './IConstructorArgumentsMapper';
|
|
3
4
|
/**
|
|
4
5
|
* Handles a specific type of a constructor argument element.
|
|
@@ -10,8 +11,9 @@ export interface IConstructorArgumentsElementMappingHandler {
|
|
|
10
11
|
* @param constructorArgs Object mapping definition inside the constructor arguments.
|
|
11
12
|
* @param configElement Part of the config resource to look for parameter instantiations as predicates.
|
|
12
13
|
* @param mapper Instance of the constructor arguments mapper that can be used to handle recursive args.
|
|
14
|
+
* @param genericsContext Context for generic types.
|
|
13
15
|
*/
|
|
14
|
-
canHandle: (configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper) => boolean;
|
|
16
|
+
canHandle: (configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper, genericsContext: GenericsContext) => boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Map the given config element with param instantiations
|
|
17
19
|
* to a raw config according to the given constructor arguments definition.
|
|
@@ -19,6 +21,7 @@ export interface IConstructorArgumentsElementMappingHandler {
|
|
|
19
21
|
* @param constructorArgs Object mapping definition inside the constructor arguments.
|
|
20
22
|
* @param configElement Part of the config resource to look for parameter instantiations as predicates.
|
|
21
23
|
* @param mapper Instance of the constructor arguments mapper that can be used to handle recursive args.
|
|
24
|
+
* @param genericsContext Context for generic types.
|
|
22
25
|
*/
|
|
23
|
-
handle: (configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper) => Resource;
|
|
26
|
+
handle: (configRoot: Resource, constructorArgs: Resource, configElement: Resource, mapper: IConstructorArgumentsMapper, genericsContext: GenericsContext) => Resource;
|
|
24
27
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RdfObjectLoader, Resource } from 'rdf-object';
|
|
2
|
+
import type { GenericsContext } from '../GenericsContext';
|
|
2
3
|
/**
|
|
3
4
|
* Instances of this interfaces can apply constructor arguments on configs.
|
|
4
5
|
* This is mainly used by {@link IConstructorArgumentsElementMappingHandler}.
|
|
@@ -15,14 +16,16 @@ export interface IConstructorArgumentsMapper {
|
|
|
15
16
|
* @param configRoot The root config resource that we are working in.
|
|
16
17
|
* @param constructorArgs Object mapping definition inside the constructor arguments.
|
|
17
18
|
* @param configElement Part of the config resource to look for parameter instantiations as predicates.
|
|
19
|
+
* @param genericsContext Context for generic types.
|
|
18
20
|
*/
|
|
19
|
-
applyConstructorArgumentsParameters: (configRoot: Resource, constructorArgs: Resource, configElement: Resource) => Resource;
|
|
21
|
+
applyConstructorArgumentsParameters: (configRoot: Resource, constructorArgs: Resource, configElement: Resource, genericsContext: GenericsContext) => Resource;
|
|
20
22
|
/**
|
|
21
23
|
* Obtain the value(s) of the given parameter in the given config.
|
|
22
24
|
* @param configRoot The root config resource that we are working in.
|
|
23
25
|
* @param parameter The parameter resource to get the value for.
|
|
24
26
|
* @param configElement Part of the config resource to look for parameter instantiations as predicates.
|
|
25
27
|
* @param rawValue If the IRI represents a raw string value instead of a parameter reference.
|
|
28
|
+
* @param genericsContext Context for generic types.
|
|
26
29
|
*/
|
|
27
|
-
getParameterValue: (configRoot: Resource, parameter: Resource, configElement: Resource, rawValue: boolean) => Resource | undefined;
|
|
30
|
+
getParameterValue: (configRoot: Resource, parameter: Resource, configElement: Resource, rawValue: boolean, genericsContext: GenericsContext) => Resource | undefined;
|
|
28
31
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Resource } from 'rdf-object';
|
|
2
|
+
import type { GenericsContext } from '../GenericsContext';
|
|
2
3
|
/**
|
|
3
4
|
* Transforms a parameter value based on some kind of parameter property.
|
|
4
5
|
*/
|
|
@@ -10,8 +11,9 @@ export interface IParameterPropertyHandler {
|
|
|
10
11
|
* @param configRoot The root config resource that we are working in.
|
|
11
12
|
* @param parameter The parameter resource to get the value for.
|
|
12
13
|
* @param configElement Part of the config resource to look for parameter instantiations as predicates.
|
|
14
|
+
* @param genericsContext Context for generic types.
|
|
13
15
|
*/
|
|
14
|
-
canHandle: (value: Resource | undefined, configRoot: Resource, parameter: Resource, configElement: Resource) => boolean;
|
|
16
|
+
canHandle: (value: Resource | undefined, configRoot: Resource, parameter: Resource, configElement: Resource, genericsContext: GenericsContext) => boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Transform the given parameter value.
|
|
17
19
|
* @param value The current parameter value obtained from the config.
|
|
@@ -19,6 +21,7 @@ export interface IParameterPropertyHandler {
|
|
|
19
21
|
* @param configRoot The root config resource that we are working in.
|
|
20
22
|
* @param parameter The parameter resource to get the value for.
|
|
21
23
|
* @param configElement Part of the config resource to look for parameter instantiations as predicates.
|
|
24
|
+
* @param genericsContext Context for generic types.
|
|
22
25
|
*/
|
|
23
|
-
handle: (value: Resource | undefined, configRoot: Resource, parameter: Resource, configElement: Resource) => Resource | undefined;
|
|
26
|
+
handle: (value: Resource | undefined, configRoot: Resource, parameter: Resource, configElement: Resource, genericsContext: GenericsContext) => Resource | undefined;
|
|
24
27
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RdfObjectLoader, Resource } from 'rdf-object';
|
|
2
|
+
import type { GenericsContext } from '../GenericsContext';
|
|
2
3
|
import type { IParameterPropertyHandler } from './IParameterPropertyHandler';
|
|
3
4
|
/**
|
|
4
5
|
* If a param range is defined, apply the type and validate the range.
|
|
@@ -7,7 +8,7 @@ export declare class ParameterPropertyHandlerRange implements IParameterProperty
|
|
|
7
8
|
private readonly objectLoader;
|
|
8
9
|
constructor(objectLoader: RdfObjectLoader);
|
|
9
10
|
canHandle(value: Resource | undefined, configRoot: Resource, parameter: Resource): boolean;
|
|
10
|
-
handle(value: Resource | undefined, configRoot: Resource, parameter: Resource, configElement: Resource): Resource | undefined;
|
|
11
|
+
handle(value: Resource | undefined, configRoot: Resource, parameter: Resource, configElement: Resource, genericsContext: GenericsContext): Resource | undefined;
|
|
11
12
|
/**
|
|
12
13
|
* Apply the given datatype to the given literal.
|
|
13
14
|
* Checks if the datatype is correct and casts to the correct js type.
|
|
@@ -15,8 +16,9 @@ export declare class ParameterPropertyHandlerRange implements IParameterProperty
|
|
|
15
16
|
* Will be ignored if the value is not a literal or the type is not recognized.
|
|
16
17
|
* @param value The value.
|
|
17
18
|
* @param param The parameter.
|
|
19
|
+
* @param genericsContext Context for generic types.
|
|
18
20
|
*/
|
|
19
|
-
captureType(value: Resource | undefined, param: Resource): Resource | undefined;
|
|
21
|
+
captureType(value: Resource | undefined, param: Resource, genericsContext: GenericsContext): Resource | undefined;
|
|
20
22
|
/**
|
|
21
23
|
* Apply the given datatype to the given literal.
|
|
22
24
|
* Checks if the datatype is correct and casts to the correct js type.
|
|
@@ -25,8 +27,9 @@ export declare class ParameterPropertyHandlerRange implements IParameterProperty
|
|
|
25
27
|
* @param value The value.
|
|
26
28
|
* @param param The parameter.
|
|
27
29
|
* @param paramRange The parameter's range.
|
|
30
|
+
* @param genericsContext Context for generic types.
|
|
28
31
|
*/
|
|
29
|
-
hasParamValueValidType(value: Resource | undefined, param: Resource, paramRange: Resource): boolean;
|
|
30
|
-
protected throwIncorrectTypeError(value: Resource | undefined, parameter: Resource): never;
|
|
31
|
-
rangeToDisplayString(paramRange: Resource | undefined): string;
|
|
32
|
+
hasParamValueValidType(value: Resource | undefined, param: Resource, paramRange: Resource, genericsContext: GenericsContext): boolean;
|
|
33
|
+
protected throwIncorrectTypeError(value: Resource | undefined, parameter: Resource, genericsContext: GenericsContext): never;
|
|
34
|
+
rangeToDisplayString(paramRange: Resource | undefined, genericsContext: GenericsContext): string;
|
|
32
35
|
}
|
|
@@ -13,8 +13,8 @@ class ParameterPropertyHandlerRange {
|
|
|
13
13
|
canHandle(value, configRoot, parameter) {
|
|
14
14
|
return Boolean(parameter.property.range);
|
|
15
15
|
}
|
|
16
|
-
handle(value, configRoot, parameter, configElement) {
|
|
17
|
-
this.captureType(value, parameter);
|
|
16
|
+
handle(value, configRoot, parameter, configElement, genericsContext) {
|
|
17
|
+
this.captureType(value, parameter, genericsContext);
|
|
18
18
|
return value;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
@@ -24,12 +24,13 @@ class ParameterPropertyHandlerRange {
|
|
|
24
24
|
* Will be ignored if the value is not a literal or the type is not recognized.
|
|
25
25
|
* @param value The value.
|
|
26
26
|
* @param param The parameter.
|
|
27
|
+
* @param genericsContext Context for generic types.
|
|
27
28
|
*/
|
|
28
|
-
captureType(value, param) {
|
|
29
|
-
if (this.hasParamValueValidType(value, param, param.property.range)) {
|
|
29
|
+
captureType(value, param, genericsContext) {
|
|
30
|
+
if (this.hasParamValueValidType(value, param, param.property.range, genericsContext)) {
|
|
30
31
|
return value;
|
|
31
32
|
}
|
|
32
|
-
this.throwIncorrectTypeError(value, param);
|
|
33
|
+
this.throwIncorrectTypeError(value, param, genericsContext);
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Apply the given datatype to the given literal.
|
|
@@ -39,8 +40,9 @@ class ParameterPropertyHandlerRange {
|
|
|
39
40
|
* @param value The value.
|
|
40
41
|
* @param param The parameter.
|
|
41
42
|
* @param paramRange The parameter's range.
|
|
43
|
+
* @param genericsContext Context for generic types.
|
|
42
44
|
*/
|
|
43
|
-
hasParamValueValidType(value, param, paramRange) {
|
|
45
|
+
hasParamValueValidType(value, param, paramRange, genericsContext) {
|
|
44
46
|
if (!paramRange) {
|
|
45
47
|
return true;
|
|
46
48
|
}
|
|
@@ -108,16 +110,16 @@ class ParameterPropertyHandlerRange {
|
|
|
108
110
|
return false;
|
|
109
111
|
}
|
|
110
112
|
return value.list.every(listElement => this
|
|
111
|
-
.hasParamValueValidType(listElement, param, paramRange.property.parameterRangeValue));
|
|
113
|
+
.hasParamValueValidType(listElement, param, paramRange.property.parameterRangeValue, genericsContext));
|
|
112
114
|
}
|
|
113
115
|
// Check if the param type is a composed type
|
|
114
116
|
if (paramRange.isA('ParameterRangeUnion')) {
|
|
115
117
|
return paramRange.properties.parameterRangeElements
|
|
116
|
-
.some(child => this.hasParamValueValidType(value, param, child));
|
|
118
|
+
.some(child => this.hasParamValueValidType(value, param, child, genericsContext));
|
|
117
119
|
}
|
|
118
120
|
if (paramRange.isA('ParameterRangeIntersection')) {
|
|
119
121
|
return paramRange.properties.parameterRangeElements
|
|
120
|
-
.every(child => this.hasParamValueValidType(value, param, child));
|
|
122
|
+
.every(child => this.hasParamValueValidType(value, param, child, genericsContext));
|
|
121
123
|
}
|
|
122
124
|
if (paramRange.isA('ParameterRangeTuple')) {
|
|
123
125
|
if (!value || !value.list) {
|
|
@@ -131,7 +133,7 @@ class ParameterPropertyHandlerRange {
|
|
|
131
133
|
while (listIndex < listElements.length && tupleIndex < tupleTypes.length) {
|
|
132
134
|
if (tupleTypes[tupleIndex].isA('ParameterRangeRest')) {
|
|
133
135
|
// Rest types can match multiple list elements, so only increment index if no match is found.
|
|
134
|
-
if (!this.hasParamValueValidType(listElements[listIndex], param, tupleTypes[tupleIndex].property.parameterRangeValue)) {
|
|
136
|
+
if (!this.hasParamValueValidType(listElements[listIndex], param, tupleTypes[tupleIndex].property.parameterRangeValue, genericsContext)) {
|
|
135
137
|
tupleIndex++;
|
|
136
138
|
}
|
|
137
139
|
else {
|
|
@@ -139,7 +141,7 @@ class ParameterPropertyHandlerRange {
|
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
143
|
else {
|
|
142
|
-
if (!this.hasParamValueValidType(listElements[listIndex], param, tupleTypes[tupleIndex])) {
|
|
144
|
+
if (!this.hasParamValueValidType(listElements[listIndex], param, tupleTypes[tupleIndex], genericsContext)) {
|
|
143
145
|
return false;
|
|
144
146
|
}
|
|
145
147
|
tupleIndex++;
|
|
@@ -153,6 +155,28 @@ class ParameterPropertyHandlerRange {
|
|
|
153
155
|
if (paramRange.isA('ParameterRangeLiteral')) {
|
|
154
156
|
return Boolean(value && value.term.equals(paramRange.property.parameterRangeValue.term));
|
|
155
157
|
}
|
|
158
|
+
// Check if the range refers to a generic type
|
|
159
|
+
if (paramRange.isA('ParameterRangeGenericTypeReference')) {
|
|
160
|
+
return genericsContext.bindGenericTypeToValue(paramRange.property.parameterRangeGenericType.value, value, (subValue, subType) => this.hasParamValueValidType(subValue, param, subType, genericsContext));
|
|
161
|
+
}
|
|
162
|
+
// Check if the range refers to a component with a generic type
|
|
163
|
+
if (paramRange.isA('ParameterRangeGenericComponent')) {
|
|
164
|
+
if (value) {
|
|
165
|
+
if (value.property.genericTypeInstances) {
|
|
166
|
+
// Once we support manual generics setting, we'll need to check here if we can merge with it.
|
|
167
|
+
throw new ErrorResourcesContext_1.ErrorResourcesContext(`Simultaneous manual generic type passing and generic type inference are not supported yet.`, { parameter: param, value });
|
|
168
|
+
}
|
|
169
|
+
// For the defined generic type instances, apply them into the instance so they can be checked later
|
|
170
|
+
value.properties.genericTypeInstances = paramRange.properties.genericTypeInstances
|
|
171
|
+
.map(genericTypeInstance => this.objectLoader.createCompactedResource({
|
|
172
|
+
type: 'ParameterRangeGenericTypeReference',
|
|
173
|
+
parameterRangeGenericType: genericTypeInstance.property.parameterRangeGenericType.value,
|
|
174
|
+
parameterRangeGenericBindings: genericsContext
|
|
175
|
+
.bindings[genericTypeInstance.property.parameterRangeGenericType.value],
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
return this.hasParamValueValidType(value, param, paramRange.property.component, genericsContext);
|
|
179
|
+
}
|
|
156
180
|
// Check if this param defines a field with sub-params
|
|
157
181
|
if (paramRange.isA('ParameterRangeCollectEntries')) {
|
|
158
182
|
// TODO: Add support for type-checking nested fields with collectEntries
|
|
@@ -162,16 +186,17 @@ class ParameterPropertyHandlerRange {
|
|
|
162
186
|
}
|
|
163
187
|
return true;
|
|
164
188
|
}
|
|
165
|
-
throwIncorrectTypeError(value, parameter) {
|
|
189
|
+
throwIncorrectTypeError(value, parameter, genericsContext) {
|
|
166
190
|
const withTypes = value && value.properties.types.length > 0 ? ` with types "${value.properties.types.map(resource => resource.value)}"` : '';
|
|
167
191
|
// eslint-disable-next-line @typescript-eslint/no-extra-parens
|
|
168
192
|
const valueString = value ? (value.list ? `[${value.list.map(subValue => subValue.value).join(', ')}]` : value.value) : 'undefined';
|
|
169
|
-
throw new ErrorResourcesContext_1.ErrorResourcesContext(`The value "${valueString}"${withTypes} for parameter "${parameter.value}" is not of required range type "${this.rangeToDisplayString(parameter.property.range)}"`, {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
193
|
+
throw new ErrorResourcesContext_1.ErrorResourcesContext(`The value "${valueString}"${withTypes} for parameter "${parameter.value}" is not of required range type "${this.rangeToDisplayString(parameter.property.range, genericsContext)}"`, Object.assign(Object.assign({ value: value || 'undefined' }, Object.keys(genericsContext.bindings).length > 0 ?
|
|
194
|
+
{ generics: `[\n ${Object.entries(genericsContext.bindings)
|
|
195
|
+
.map(([id, values]) => `<${id}> => ${values.map(subValue => subValue.value)}`)
|
|
196
|
+
.join(',\n ')}\n]` } :
|
|
197
|
+
{}), { parameter }));
|
|
173
198
|
}
|
|
174
|
-
rangeToDisplayString(paramRange) {
|
|
199
|
+
rangeToDisplayString(paramRange, genericsContext) {
|
|
175
200
|
if (!paramRange) {
|
|
176
201
|
return `any`;
|
|
177
202
|
}
|
|
@@ -179,29 +204,37 @@ class ParameterPropertyHandlerRange {
|
|
|
179
204
|
return `undefined`;
|
|
180
205
|
}
|
|
181
206
|
if (paramRange.isA('ParameterRangeArray')) {
|
|
182
|
-
return `${this.rangeToDisplayString(paramRange.property.parameterRangeValue)}[]`;
|
|
207
|
+
return `${this.rangeToDisplayString(paramRange.property.parameterRangeValue, genericsContext)}[]`;
|
|
183
208
|
}
|
|
184
209
|
if (paramRange.isA('ParameterRangeRest')) {
|
|
185
|
-
return `...${this.rangeToDisplayString(paramRange.property.parameterRangeValue)}`;
|
|
210
|
+
return `...${this.rangeToDisplayString(paramRange.property.parameterRangeValue, genericsContext)}`;
|
|
186
211
|
}
|
|
187
212
|
if (paramRange.isA('ParameterRangeUnion')) {
|
|
188
213
|
return paramRange.properties.parameterRangeElements
|
|
189
|
-
.map(child => this.rangeToDisplayString(child))
|
|
214
|
+
.map(child => this.rangeToDisplayString(child, genericsContext))
|
|
190
215
|
.join(' | ');
|
|
191
216
|
}
|
|
192
217
|
if (paramRange.isA('ParameterRangeIntersection')) {
|
|
193
218
|
return paramRange.properties.parameterRangeElements
|
|
194
|
-
.map(child => this.rangeToDisplayString(child))
|
|
219
|
+
.map(child => this.rangeToDisplayString(child, genericsContext))
|
|
195
220
|
.join(' & ');
|
|
196
221
|
}
|
|
197
222
|
if (paramRange.isA('ParameterRangeTuple')) {
|
|
198
223
|
return `[${paramRange.properties.parameterRangeElements
|
|
199
|
-
.map(child => this.rangeToDisplayString(child))
|
|
224
|
+
.map(child => this.rangeToDisplayString(child, genericsContext))
|
|
200
225
|
.join(', ')}]`;
|
|
201
226
|
}
|
|
202
227
|
if (paramRange.isA('ParameterRangeLiteral')) {
|
|
203
228
|
return paramRange.property.parameterRangeValue.value;
|
|
204
229
|
}
|
|
230
|
+
if (paramRange.isA('ParameterRangeGenericTypeReference')) {
|
|
231
|
+
const valid = paramRange.property.parameterRangeGenericType.value in genericsContext.genericTypeIds;
|
|
232
|
+
return `<${valid ? '' : 'UNKNOWN GENERIC: '}${paramRange.property.parameterRangeGenericType.value}>`;
|
|
233
|
+
}
|
|
234
|
+
if (paramRange.isA('ParameterRangeGenericComponent')) {
|
|
235
|
+
return `(${this.rangeToDisplayString(paramRange.property.component, genericsContext)})${paramRange.properties.genericTypeInstances
|
|
236
|
+
.map(genericTypeInstance => this.rangeToDisplayString(genericTypeInstance, genericsContext)).join('')}`;
|
|
237
|
+
}
|
|
205
238
|
return paramRange.value;
|
|
206
239
|
}
|
|
207
240
|
}
|
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.1",
|
|
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"
|