@_linked/core 2.12.0 → 2.13.0-next.20260706164859

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.
Files changed (246) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/esm/queries/IRPipeline.d.ts +7 -1
  3. package/lib/esm/queries/IRPipeline.js +20 -6
  4. package/lib/esm/queries/IRPipeline.js.map +1 -1
  5. package/lib/esm/queries/queryDispatch.js +12 -2
  6. package/lib/esm/queries/queryDispatch.js.map +1 -1
  7. package/package.json +10 -13
  8. package/lib/cjs/collections/CoreSet.d.ts +0 -47
  9. package/lib/cjs/collections/CoreSet.js +0 -136
  10. package/lib/cjs/collections/CoreSet.js.map +0 -1
  11. package/lib/cjs/collections/ShapeSet.d.ts +0 -6
  12. package/lib/cjs/collections/ShapeSet.js +0 -20
  13. package/lib/cjs/collections/ShapeSet.js.map +0 -1
  14. package/lib/cjs/expressions/Expr.d.ts +0 -29
  15. package/lib/cjs/expressions/Expr.js +0 -80
  16. package/lib/cjs/expressions/Expr.js.map +0 -1
  17. package/lib/cjs/expressions/ExpressionMethods.d.ts +0 -85
  18. package/lib/cjs/expressions/ExpressionMethods.js +0 -3
  19. package/lib/cjs/expressions/ExpressionMethods.js.map +0 -1
  20. package/lib/cjs/expressions/ExpressionNode.d.ts +0 -144
  21. package/lib/cjs/expressions/ExpressionNode.js +0 -432
  22. package/lib/cjs/expressions/ExpressionNode.js.map +0 -1
  23. package/lib/cjs/index.d.ts +0 -29
  24. package/lib/cjs/index.js +0 -65
  25. package/lib/cjs/index.js.map +0 -1
  26. package/lib/cjs/interfaces/ICoreIterable.d.ts +0 -14
  27. package/lib/cjs/interfaces/ICoreIterable.js +0 -3
  28. package/lib/cjs/interfaces/ICoreIterable.js.map +0 -1
  29. package/lib/cjs/interfaces/IDataset.d.ts +0 -26
  30. package/lib/cjs/interfaces/IDataset.js +0 -3
  31. package/lib/cjs/interfaces/IDataset.js.map +0 -1
  32. package/lib/cjs/interfaces/IFileStore.d.ts +0 -16
  33. package/lib/cjs/interfaces/IFileStore.js +0 -3
  34. package/lib/cjs/interfaces/IFileStore.js.map +0 -1
  35. package/lib/cjs/ontologies/linked-core.d.ts +0 -15
  36. package/lib/cjs/ontologies/linked-core.js +0 -38
  37. package/lib/cjs/ontologies/linked-core.js.map +0 -1
  38. package/lib/cjs/ontologies/npm.d.ts +0 -6
  39. package/lib/cjs/ontologies/npm.js +0 -15
  40. package/lib/cjs/ontologies/npm.js.map +0 -1
  41. package/lib/cjs/ontologies/owl.d.ts +0 -14
  42. package/lib/cjs/ontologies/owl.js +0 -21
  43. package/lib/cjs/ontologies/owl.js.map +0 -1
  44. package/lib/cjs/ontologies/rdf.d.ts +0 -13
  45. package/lib/cjs/ontologies/rdf.js +0 -27
  46. package/lib/cjs/ontologies/rdf.js.map +0 -1
  47. package/lib/cjs/ontologies/rdfs.d.ts +0 -16
  48. package/lib/cjs/ontologies/rdfs.js +0 -33
  49. package/lib/cjs/ontologies/rdfs.js.map +0 -1
  50. package/lib/cjs/ontologies/shacl.d.ts +0 -103
  51. package/lib/cjs/ontologies/shacl.js +0 -152
  52. package/lib/cjs/ontologies/shacl.js.map +0 -1
  53. package/lib/cjs/ontologies/xsd.d.ts +0 -19
  54. package/lib/cjs/ontologies/xsd.js +0 -41
  55. package/lib/cjs/ontologies/xsd.js.map +0 -1
  56. package/lib/cjs/package.d.ts +0 -4
  57. package/lib/cjs/package.js +0 -6
  58. package/lib/cjs/package.js.map +0 -1
  59. package/lib/cjs/package.json +0 -9
  60. package/lib/cjs/paths/PropertyPathExpr.d.ts +0 -38
  61. package/lib/cjs/paths/PropertyPathExpr.js +0 -221
  62. package/lib/cjs/paths/PropertyPathExpr.js.map +0 -1
  63. package/lib/cjs/paths/normalizePropertyPath.d.ts +0 -23
  64. package/lib/cjs/paths/normalizePropertyPath.js +0 -75
  65. package/lib/cjs/paths/normalizePropertyPath.js.map +0 -1
  66. package/lib/cjs/paths/pathExprToSparql.d.ts +0 -14
  67. package/lib/cjs/paths/pathExprToSparql.js +0 -136
  68. package/lib/cjs/paths/pathExprToSparql.js.map +0 -1
  69. package/lib/cjs/queries/ContextRef.d.ts +0 -32
  70. package/lib/cjs/queries/ContextRef.js +0 -69
  71. package/lib/cjs/queries/ContextRef.js.map +0 -1
  72. package/lib/cjs/queries/CreateBuilder.d.ts +0 -59
  73. package/lib/cjs/queries/CreateBuilder.js +0 -138
  74. package/lib/cjs/queries/CreateBuilder.js.map +0 -1
  75. package/lib/cjs/queries/CreateQuery.d.ts +0 -20
  76. package/lib/cjs/queries/CreateQuery.js +0 -3
  77. package/lib/cjs/queries/CreateQuery.js.map +0 -1
  78. package/lib/cjs/queries/DeleteBuilder.d.ts +0 -56
  79. package/lib/cjs/queries/DeleteBuilder.js +0 -172
  80. package/lib/cjs/queries/DeleteBuilder.js.map +0 -1
  81. package/lib/cjs/queries/DeleteQuery.d.ts +0 -37
  82. package/lib/cjs/queries/DeleteQuery.js +0 -3
  83. package/lib/cjs/queries/DeleteQuery.js.map +0 -1
  84. package/lib/cjs/queries/DslJsonExpression.d.ts +0 -68
  85. package/lib/cjs/queries/DslJsonExpression.js +0 -427
  86. package/lib/cjs/queries/DslJsonExpression.js.map +0 -1
  87. package/lib/cjs/queries/FieldSet.d.ts +0 -310
  88. package/lib/cjs/queries/FieldSet.js +0 -802
  89. package/lib/cjs/queries/FieldSet.js.map +0 -1
  90. package/lib/cjs/queries/IRAliasScope.d.ts +0 -20
  91. package/lib/cjs/queries/IRAliasScope.js +0 -52
  92. package/lib/cjs/queries/IRAliasScope.js.map +0 -1
  93. package/lib/cjs/queries/IRCanonicalize.d.ts +0 -19
  94. package/lib/cjs/queries/IRCanonicalize.js +0 -19
  95. package/lib/cjs/queries/IRCanonicalize.js.map +0 -1
  96. package/lib/cjs/queries/IRDesugar.d.ts +0 -123
  97. package/lib/cjs/queries/IRDesugar.js +0 -261
  98. package/lib/cjs/queries/IRDesugar.js.map +0 -1
  99. package/lib/cjs/queries/IRLower.d.ts +0 -25
  100. package/lib/cjs/queries/IRLower.js +0 -398
  101. package/lib/cjs/queries/IRLower.js.map +0 -1
  102. package/lib/cjs/queries/IRMutation.d.ts +0 -53
  103. package/lib/cjs/queries/IRMutation.js +0 -130
  104. package/lib/cjs/queries/IRMutation.js.map +0 -1
  105. package/lib/cjs/queries/IRPipeline.d.ts +0 -8
  106. package/lib/cjs/queries/IRPipeline.js +0 -25
  107. package/lib/cjs/queries/IRPipeline.js.map +0 -1
  108. package/lib/cjs/queries/IRProjection.d.ts +0 -39
  109. package/lib/cjs/queries/IRProjection.js +0 -105
  110. package/lib/cjs/queries/IRProjection.js.map +0 -1
  111. package/lib/cjs/queries/IntermediateRepresentation.d.ts +0 -282
  112. package/lib/cjs/queries/IntermediateRepresentation.js +0 -3
  113. package/lib/cjs/queries/IntermediateRepresentation.js.map +0 -1
  114. package/lib/cjs/queries/MutationQuery.d.ts +0 -50
  115. package/lib/cjs/queries/MutationQuery.js +0 -334
  116. package/lib/cjs/queries/MutationQuery.js.map +0 -1
  117. package/lib/cjs/queries/MutationSerialization.d.ts +0 -102
  118. package/lib/cjs/queries/MutationSerialization.js +0 -207
  119. package/lib/cjs/queries/MutationSerialization.js.map +0 -1
  120. package/lib/cjs/queries/MutationThenable.d.ts +0 -18
  121. package/lib/cjs/queries/MutationThenable.js +0 -32
  122. package/lib/cjs/queries/MutationThenable.js.map +0 -1
  123. package/lib/cjs/queries/PropertyPath.d.ts +0 -38
  124. package/lib/cjs/queries/PropertyPath.js +0 -82
  125. package/lib/cjs/queries/PropertyPath.js.map +0 -1
  126. package/lib/cjs/queries/ProxiedPathBuilder.d.ts +0 -14
  127. package/lib/cjs/queries/ProxiedPathBuilder.js +0 -29
  128. package/lib/cjs/queries/ProxiedPathBuilder.js.map +0 -1
  129. package/lib/cjs/queries/QueryBuilder.d.ts +0 -193
  130. package/lib/cjs/queries/QueryBuilder.js +0 -519
  131. package/lib/cjs/queries/QueryBuilder.js.map +0 -1
  132. package/lib/cjs/queries/QueryBuilderSerialization.d.ts +0 -31
  133. package/lib/cjs/queries/QueryBuilderSerialization.js +0 -68
  134. package/lib/cjs/queries/QueryBuilderSerialization.js.map +0 -1
  135. package/lib/cjs/queries/QueryContext.d.ts +0 -50
  136. package/lib/cjs/queries/QueryContext.js +0 -147
  137. package/lib/cjs/queries/QueryContext.js.map +0 -1
  138. package/lib/cjs/queries/QueryFactory.d.ts +0 -80
  139. package/lib/cjs/queries/QueryFactory.js +0 -21
  140. package/lib/cjs/queries/QueryFactory.js.map +0 -1
  141. package/lib/cjs/queries/SelectQuery.d.ts +0 -302
  142. package/lib/cjs/queries/SelectQuery.js +0 -761
  143. package/lib/cjs/queries/SelectQuery.js.map +0 -1
  144. package/lib/cjs/queries/UpdateBuilder.d.ts +0 -69
  145. package/lib/cjs/queries/UpdateBuilder.js +0 -199
  146. package/lib/cjs/queries/UpdateBuilder.js.map +0 -1
  147. package/lib/cjs/queries/UpdateQuery.d.ts +0 -18
  148. package/lib/cjs/queries/UpdateQuery.js +0 -3
  149. package/lib/cjs/queries/UpdateQuery.js.map +0 -1
  150. package/lib/cjs/queries/fromJSON.d.ts +0 -16
  151. package/lib/cjs/queries/fromJSON.js +0 -41
  152. package/lib/cjs/queries/fromJSON.js.map +0 -1
  153. package/lib/cjs/queries/lower.d.ts +0 -28
  154. package/lib/cjs/queries/lower.js +0 -114
  155. package/lib/cjs/queries/lower.js.map +0 -1
  156. package/lib/cjs/queries/lowerMutationJSON.d.ts +0 -25
  157. package/lib/cjs/queries/lowerMutationJSON.js +0 -173
  158. package/lib/cjs/queries/lowerMutationJSON.js.map +0 -1
  159. package/lib/cjs/queries/mutationLowerSpec.d.ts +0 -32
  160. package/lib/cjs/queries/mutationLowerSpec.js +0 -8
  161. package/lib/cjs/queries/mutationLowerSpec.js.map +0 -1
  162. package/lib/cjs/queries/queryDispatch.d.ts +0 -33
  163. package/lib/cjs/queries/queryDispatch.js +0 -33
  164. package/lib/cjs/queries/queryDispatch.js.map +0 -1
  165. package/lib/cjs/queries/resolveShape.d.ts +0 -10
  166. package/lib/cjs/queries/resolveShape.js +0 -23
  167. package/lib/cjs/queries/resolveShape.js.map +0 -1
  168. package/lib/cjs/queries/wireVersion.d.ts +0 -7
  169. package/lib/cjs/queries/wireVersion.js +0 -25
  170. package/lib/cjs/queries/wireVersion.js.map +0 -1
  171. package/lib/cjs/shapes/List.d.ts +0 -35
  172. package/lib/cjs/shapes/List.js +0 -72
  173. package/lib/cjs/shapes/List.js.map +0 -1
  174. package/lib/cjs/shapes/PathNode.d.ts +0 -20
  175. package/lib/cjs/shapes/PathNode.js +0 -68
  176. package/lib/cjs/shapes/PathNode.js.map +0 -1
  177. package/lib/cjs/shapes/SHACL.d.ts +0 -300
  178. package/lib/cjs/shapes/SHACL.js +0 -612
  179. package/lib/cjs/shapes/SHACL.js.map +0 -1
  180. package/lib/cjs/shapes/Shape.d.ts +0 -74
  181. package/lib/cjs/shapes/Shape.js +0 -124
  182. package/lib/cjs/shapes/Shape.js.map +0 -1
  183. package/lib/cjs/shapes/serializePathToNodeData.d.ts +0 -24
  184. package/lib/cjs/shapes/serializePathToNodeData.js +0 -67
  185. package/lib/cjs/shapes/serializePathToNodeData.js.map +0 -1
  186. package/lib/cjs/shapes/syncShapes.d.ts +0 -38
  187. package/lib/cjs/shapes/syncShapes.js +0 -214
  188. package/lib/cjs/shapes/syncShapes.js.map +0 -1
  189. package/lib/cjs/sparql/SparqlAlgebra.d.ts +0 -190
  190. package/lib/cjs/sparql/SparqlAlgebra.js +0 -4
  191. package/lib/cjs/sparql/SparqlAlgebra.js.map +0 -1
  192. package/lib/cjs/sparql/SparqlDataset.d.ts +0 -60
  193. package/lib/cjs/sparql/SparqlDataset.js +0 -117
  194. package/lib/cjs/sparql/SparqlDataset.js.map +0 -1
  195. package/lib/cjs/sparql/algebraToString.d.ts +0 -13
  196. package/lib/cjs/sparql/algebraToString.js +0 -385
  197. package/lib/cjs/sparql/algebraToString.js.map +0 -1
  198. package/lib/cjs/sparql/index.d.ts +0 -9
  199. package/lib/cjs/sparql/index.js +0 -41
  200. package/lib/cjs/sparql/index.js.map +0 -1
  201. package/lib/cjs/sparql/irToAlgebra.d.ts +0 -79
  202. package/lib/cjs/sparql/irToAlgebra.js +0 -2042
  203. package/lib/cjs/sparql/irToAlgebra.js.map +0 -1
  204. package/lib/cjs/sparql/resultMapping.d.ts +0 -36
  205. package/lib/cjs/sparql/resultMapping.js +0 -563
  206. package/lib/cjs/sparql/resultMapping.js.map +0 -1
  207. package/lib/cjs/sparql/sparqlUtils.d.ts +0 -53
  208. package/lib/cjs/sparql/sparqlUtils.js +0 -154
  209. package/lib/cjs/sparql/sparqlUtils.js.map +0 -1
  210. package/lib/cjs/utils/LinkedErrorLogging.d.ts +0 -13
  211. package/lib/cjs/utils/LinkedErrorLogging.js +0 -22
  212. package/lib/cjs/utils/LinkedErrorLogging.js.map +0 -1
  213. package/lib/cjs/utils/LinkedFileStorage.d.ts +0 -23
  214. package/lib/cjs/utils/LinkedFileStorage.js +0 -62
  215. package/lib/cjs/utils/LinkedFileStorage.js.map +0 -1
  216. package/lib/cjs/utils/LinkedStorage.d.ts +0 -40
  217. package/lib/cjs/utils/LinkedStorage.js +0 -148
  218. package/lib/cjs/utils/LinkedStorage.js.map +0 -1
  219. package/lib/cjs/utils/NameSpace.d.ts +0 -2
  220. package/lib/cjs/utils/NameSpace.js +0 -8
  221. package/lib/cjs/utils/NameSpace.js.map +0 -1
  222. package/lib/cjs/utils/NodeReference.d.ts +0 -30
  223. package/lib/cjs/utils/NodeReference.js +0 -54
  224. package/lib/cjs/utils/NodeReference.js.map +0 -1
  225. package/lib/cjs/utils/Package.d.ts +0 -153
  226. package/lib/cjs/utils/Package.js +0 -419
  227. package/lib/cjs/utils/Package.js.map +0 -1
  228. package/lib/cjs/utils/Prefix.d.ts +0 -22
  229. package/lib/cjs/utils/Prefix.js +0 -104
  230. package/lib/cjs/utils/Prefix.js.map +0 -1
  231. package/lib/cjs/utils/ShapeClass.d.ts +0 -30
  232. package/lib/cjs/utils/ShapeClass.js +0 -180
  233. package/lib/cjs/utils/ShapeClass.js.map +0 -1
  234. package/lib/cjs/utils/URI.d.ts +0 -18
  235. package/lib/cjs/utils/URI.js +0 -42
  236. package/lib/cjs/utils/URI.js.map +0 -1
  237. package/lib/cjs/utils/cached.d.ts +0 -14
  238. package/lib/cjs/utils/cached.js +0 -71
  239. package/lib/cjs/utils/cached.js.map +0 -1
  240. package/lib/cjs/utils/loadStores.d.ts +0 -34
  241. package/lib/cjs/utils/loadStores.js +0 -105
  242. package/lib/cjs/utils/loadStores.js.map +0 -1
  243. package/lib/cjs/utils/parseDatasetsConfig.d.ts +0 -49
  244. package/lib/cjs/utils/parseDatasetsConfig.js +0 -110
  245. package/lib/cjs/utils/parseDatasetsConfig.js.map +0 -1
  246. package/lib/esm/package.json +0 -9
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Prefix = void 0;
4
- /*
5
- * This Source Code Form is subject to the terms of the Mozilla Public
6
- * License, v. 2.0. If a copy of the MPL was not distributed with this
7
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
- */
9
- class Prefix {
10
- static getUriToPrefixMap() {
11
- return this.uriToPrefix;
12
- }
13
- static getPrefixToUriMap() {
14
- return this.prefixToUri;
15
- }
16
- static add(prefix, fullURI) {
17
- this.uriToPrefix.set(fullURI, prefix);
18
- this.prefixToUri.set(prefix, fullURI);
19
- }
20
- static delete(prefix) {
21
- if (this.prefixToUri.has(prefix)) {
22
- let fullURI = this.getFullURI(prefix);
23
- this.uriToPrefix.delete(fullURI);
24
- this.prefixToUri.delete(prefix);
25
- }
26
- }
27
- static clear() {
28
- this.uriToPrefix = new Map();
29
- this.prefixToUri = new Map();
30
- }
31
- static getPrefix(fullURI) {
32
- if (this.uriToPrefix.has(fullURI)) {
33
- return this.uriToPrefix.get(fullURI);
34
- }
35
- let match = this.findMatch(fullURI);
36
- if (match.length > 0)
37
- return match[1];
38
- }
39
- static getFullURI(prefix) {
40
- return this.prefixToUri.get(prefix);
41
- }
42
- static findMatch(fullURI) {
43
- for (let [ontologyURI, prefix] of this.uriToPrefix.entries()) {
44
- if (fullURI.substring(0, ontologyURI.length) == ontologyURI) {
45
- return [ontologyURI, prefix, fullURI.substring(ontologyURI.length)];
46
- }
47
- }
48
- return [];
49
- }
50
- static toPrefixed(fullURI) {
51
- let match = this.findMatch(fullURI);
52
- if (match.length > 0) {
53
- const postFix = fullURI.substring(match[0].length);
54
- if (!postFix.includes('/')) {
55
- return match[1] + ':' + postFix;
56
- }
57
- }
58
- }
59
- static toPrefixedIfPossible(fullURI) {
60
- return this.toPrefixed(fullURI) || fullURI;
61
- }
62
- static toFullIfPossible(fullURI) {
63
- let res = this._toFull(fullURI);
64
- if (res) {
65
- return res;
66
- }
67
- return fullURI;
68
- }
69
- /**
70
- * Converts a prefixed URI back to its full URI
71
- * Will return the prefixed URI if no prefix was found
72
- * @param uri
73
- */
74
- static toFull(uri) {
75
- let res = this._toFull(uri);
76
- if (res) {
77
- return res;
78
- }
79
- const colon = uri.indexOf(':');
80
- const prefix = colon === -1 ? uri : uri.slice(0, colon);
81
- throw new Error('Unknown prefix ' +
82
- prefix +
83
- '. Could not convert ' +
84
- uri +
85
- ' to a full URI');
86
- }
87
- static _toFull(uri) {
88
- // Split on the FIRST colon only: the local name may itself contain colons
89
- // (e.g. `ex:foo:bar`), which `split(':')` would truncate.
90
- const colon = uri.indexOf(':');
91
- if (colon === -1)
92
- return undefined;
93
- const prefix = uri.slice(0, colon);
94
- const rest = uri.slice(colon + 1);
95
- let ontologyURI = this.getFullURI(prefix);
96
- if (ontologyURI) {
97
- return ontologyURI + rest;
98
- }
99
- }
100
- }
101
- exports.Prefix = Prefix;
102
- Prefix.uriToPrefix = new Map();
103
- Prefix.prefixToUri = new Map();
104
- //# sourceMappingURL=Prefix.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Prefix.js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eShape, PropertyShape } from '../shapes/SHACL.js';
3
- import type { ICoreIterable } from '../interfaces/ICoreIterable.js';
4
- import type { NodeReferenceValue } from './NodeReference.js';
5
- export declare function addNodeShapeToShapeClass(nodeShape: NodeShape, shapeClass: typeof Shape): void;
6
- export declare function getShapeClass(nodeShape: NodeReferenceValue | {
7
- id: string;
8
- } | string): ShapeConstructor | undefined;
9
- /**
10
- * Returns all registered shape classes (keyed by NodeShape URI).
11
- */
12
- export declare function getAllShapeClasses(): Map<string, typeof Shape>;
13
- /**
14
- * Returns all the sub shapes of the given shape
15
- * That is all the shapes that extend this shape
16
- * @param shape
17
- */
18
- export declare function getSubShapesClasses(shape: typeof Shape | (typeof Shape)[], _internalKey?: string): (typeof Shape)[];
19
- /**
20
- * Returns all the superclasses of the given shape
21
- * That is all the shapes that it extends.
22
- * Results are sorted from most specific to least specific
23
- * @param shape
24
- */
25
- export declare function getSuperShapesClasses(shape: typeof Shape | (typeof Shape)[]): (typeof Shape)[];
26
- export declare function getPropertyShapeByLabel(shapeClass: typeof Shape, label: string): PropertyShape;
27
- export declare function hasSuperClass(a: Function, b: Function): boolean;
28
- export declare function hasSubClass(a: Function, b: Function): boolean;
29
- export declare function getLeastSpecificShapeClasses(shapes: ICoreIterable<Shape>): any;
30
- export declare function getMostSpecificSubShapes(shape: typeof Shape | (typeof Shape)[]): (typeof Shape)[];
@@ -1,180 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addNodeShapeToShapeClass = addNodeShapeToShapeClass;
4
- exports.getShapeClass = getShapeClass;
5
- exports.getAllShapeClasses = getAllShapeClasses;
6
- exports.getSubShapesClasses = getSubShapesClasses;
7
- exports.getSuperShapesClasses = getSuperShapesClasses;
8
- exports.getPropertyShapeByLabel = getPropertyShapeByLabel;
9
- exports.hasSuperClass = hasSuperClass;
10
- exports.hasSubClass = hasSubClass;
11
- exports.getLeastSpecificShapeClasses = getLeastSpecificShapeClasses;
12
- exports.getMostSpecificSubShapes = getMostSpecificSubShapes;
13
- const resolveTargetClassId = (targetClass) => {
14
- var _a;
15
- if (!targetClass)
16
- return null;
17
- return (_a = targetClass.id) !== null && _a !== void 0 ? _a : null;
18
- };
19
- let subShapesCache = new Map();
20
- let mostSpecificSubShapesCache = new Map();
21
- let nodeShapeToShapeClass = new Map();
22
- let shouldResetCache = false;
23
- function addNodeShapeToShapeClass(nodeShape, shapeClass) {
24
- if (!(nodeShape === null || nodeShape === void 0 ? void 0 : nodeShape.id)) {
25
- return;
26
- }
27
- nodeShapeToShapeClass.set(nodeShape.id, shapeClass);
28
- //make sure that the cache is reset after the next event loop
29
- if (!shouldResetCache) {
30
- shouldResetCache = true;
31
- setTimeout(() => {
32
- subShapesCache.clear();
33
- mostSpecificSubShapesCache.clear();
34
- shouldResetCache = false;
35
- }, 0);
36
- }
37
- }
38
- function getShapeClass(nodeShape) {
39
- const id = typeof nodeShape === 'string' ? nodeShape : nodeShape === null || nodeShape === void 0 ? void 0 : nodeShape.id;
40
- if (!id) {
41
- return undefined;
42
- }
43
- // SAFETY: The map stores `typeof Shape` (abstract), but registered shapes are always
44
- // concrete subclasses with a constructor and static .shape — i.e. ShapeConstructor.
45
- return nodeShapeToShapeClass.get(id);
46
- }
47
- /**
48
- * Returns all registered shape classes (keyed by NodeShape URI).
49
- */
50
- function getAllShapeClasses() {
51
- return nodeShapeToShapeClass;
52
- }
53
- /**
54
- * Returns all the sub shapes of the given shape
55
- * That is all the shapes that extend this shape
56
- * @param shape
57
- */
58
- function getSubShapesClasses(shape, _internalKey) {
59
- let key = _internalKey || getKey(shape);
60
- if (!subShapesCache.has(key)) {
61
- //apply the hasSuperclass function to the shape
62
- let filterFunction = applyFnToShapeOrArray(shape, hasSubClass);
63
- //filter and then sort the results based on their inheritance (most specific classes first, so we use hasSuperClass for the sorting)
64
- subShapesCache.set(key, filterShapeClasses(filterFunction).sort((a, b) => {
65
- return hasSubClass(a, b) ? 1 : -1;
66
- }));
67
- }
68
- //return a copy of the array to prevent it from being modified
69
- return [...subShapesCache.get(key)];
70
- }
71
- /**
72
- * Returns all the superclasses of the given shape
73
- * That is all the shapes that it extends.
74
- * Results are sorted from most specific to least specific
75
- * @param shape
76
- */
77
- function getSuperShapesClasses(shape) {
78
- //apply the hasSuperclass function to the shape
79
- let filterFunction = applyFnToShapeOrArray(shape, hasSuperClass);
80
- //filter and then sort the results based on their inheritance
81
- return filterShapeClasses(filterFunction).sort((a, b) => {
82
- return hasSubClass(a, b) ? 1 : -1;
83
- });
84
- }
85
- function getPropertyShapeByLabel(shapeClass, label) {
86
- //get all the shapes that this shape extends
87
- let shapeChain = getSuperShapesClasses(shapeClass);
88
- //include the shape itself as the first shape in the array
89
- shapeChain.unshift(shapeClass);
90
- let propertyShape;
91
- for (let sClass of shapeChain) {
92
- propertyShape = sClass.shape
93
- .getPropertyShapes()
94
- .find((propertyShape) => propertyShape.label === label);
95
- if (propertyShape) {
96
- break;
97
- }
98
- }
99
- return propertyShape;
100
- }
101
- function hasSuperClass(a, b) {
102
- return a.prototype instanceof b;
103
- }
104
- function hasSubClass(a, b) {
105
- return b.prototype instanceof a;
106
- }
107
- function applyFnToShapeOrArray(shape, filterFn) {
108
- if (Array.isArray(shape)) {
109
- return (shapeClass) => {
110
- //returns true if one of the given shapes extends the shapeClass passed as argument
111
- return shape.some((s) => filterFn(s, shapeClass));
112
- };
113
- }
114
- else {
115
- //first argument will be the given shape class, second argument will be each stored shape class in the map
116
- //will filter down where the given shape extends the stored shape
117
- return filterFn.bind(null, shape);
118
- }
119
- }
120
- function filterShapeClasses(filterFn) {
121
- let result = [];
122
- nodeShapeToShapeClass.forEach((shapeClass) => {
123
- if (filterFn(shapeClass)) {
124
- result.push(shapeClass);
125
- }
126
- });
127
- return result;
128
- }
129
- function getLeastSpecificShapeClasses(shapes) {
130
- let shapeClasses = shapes.map((shape) => getShapeClass(shape.nodeShape.id));
131
- return filterShapesToLeastSpecific(shapeClasses);
132
- }
133
- function getMostSpecificSubShapes(shape) {
134
- if (!Array.isArray(shape)) {
135
- shape = [shape];
136
- }
137
- //get the subshapes of the given shapes
138
- let key = shape.map((s) => s.name).join(',');
139
- if (!mostSpecificSubShapesCache.has(key)) {
140
- //get the subshapes of the given shapes
141
- let subShapes = getSubShapesClasses(shape, key);
142
- //filter them down to the most specific ones (that are not extended by any other shape)
143
- mostSpecificSubShapesCache.set(key, filterShapesToMostSpecific(subShapes));
144
- }
145
- return mostSpecificSubShapesCache.get(key);
146
- }
147
- /**
148
- * Filters out all shapes that are extended by any other shape in the given set/array
149
- * @param subShapes
150
- */
151
- function filterShapesToMostSpecific(subShapes) {
152
- return subShapes.filter((subShape) => {
153
- return !subShapes.some((otherSubShape) => {
154
- return otherSubShape.prototype instanceof subShape;
155
- });
156
- });
157
- }
158
- /**
159
- * Filters out all shapes that extend any other shape in the given set/array
160
- * @param shapeClasses
161
- */
162
- function filterShapesToLeastSpecific(shapeClasses) {
163
- return shapeClasses.filter((shapeClass) => {
164
- return !shapeClasses.some((otherShapeClass) => {
165
- return (otherShapeClass !== shapeClass &&
166
- shapeClass.prototype instanceof otherShapeClass);
167
- });
168
- });
169
- }
170
- function getKey(shape) {
171
- return Array.isArray(shape)
172
- ? shape.map((s) => getShapeKey(s)).join(',')
173
- : getShapeKey(shape);
174
- }
175
- function getShapeKey(shape) {
176
- //return a unique string for each shape
177
- return (resolveTargetClassId(shape.targetClass) ||
178
- shape.name + shape.prototype.constructor.toString().substring(0, 80));
179
- }
180
- //# sourceMappingURL=ShapeClass.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ShapeClass.js","sourceRoot":"","sources":["../../../src/utils/ShapeClass.ts"],"names":[],"mappings":";;AAiBA,4DAiBC;AAED,sCAUC;AAKD,gDAEC;AAQD,kDAkBC;AAQD,sDASC;AAED,0DAqBC;AAED,sCAEC;AAED,kCAEC;AAyBD,oEAKC;AAED,4DAeC;AAzKD,MAAM,oBAAoB,GAAG,CAC3B,WAAuC,EACxB,EAAE;;IACjB,IAAI,C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OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;QACxC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE;YAC5C,OAAO,CACL,eAAe,KAAK,UAAU;gBAC9B,UAAU,CAAC,SAAS,YAAY,eAAe,CAChD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,MAAM,CAAC,KAAsC;IACpD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5C,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,WAAW,CAAC,KAAmB;IACtC,uCAAuC;IACvC,OAAO,CACL,oBAAoB,CAAC,KAAK,CAAC,WAAW,CAAC;QACvC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CACrE,CAAC;AACJ,CAAC"}
@@ -1,18 +0,0 @@
1
- export declare class URI {
2
- /**
3
- * Function: sanitize
4
- * Returns a sanitized string, typically for URLs.
5
- *
6
- * Parameters:
7
- * $string - The string to sanitize.
8
- * $force_lowercase - Force the string to lowercase?
9
- */
10
- static sanitize(string: any): any;
11
- static isURI(uri: string): boolean;
12
- /**
13
- * Generate a new URI based on the given URI components (labels / identifiers).
14
- * This URI will start with the DATA_ROOT environment variable
15
- * @param uriComponents
16
- */
17
- static generate(...uriComponents: string[]): string;
18
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.URI = void 0;
4
- /*
5
- * This Source Code Form is subject to the terms of the Mozilla Public
6
- * License, v. 2.0. If a copy of the MPL was not distributed with this
7
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
- */
9
- class URI {
10
- /**
11
- * Function: sanitize
12
- * Returns a sanitized string, typically for URLs.
13
- *
14
- * Parameters:
15
- * $string - The string to sanitize.
16
- * $force_lowercase - Force the string to lowercase?
17
- */
18
- static sanitize(string) {
19
- if (!string)
20
- return string;
21
- //\u200B is the ZERO WIDTH SPACE, often introduced by WYSIWYG editors. This causes a hyphen (-) at the end of a string sometimes, so we filter it out first
22
- return string
23
- .replace(/\u200B/g, '')
24
- .replace(/[^\w]+/g, '-')
25
- .toLowerCase();
26
- }
27
- static isURI(uri) {
28
- //must have a scheme followed by ://
29
- return /([A-Za-z][A-Za-z0-9+\-.]*)\:\/\//.test(uri);
30
- }
31
- /**
32
- * Generate a new URI based on the given URI components (labels / identifiers).
33
- * This URI will start with the DATA_ROOT environment variable
34
- * @param uriComponents
35
- */
36
- static generate(...uriComponents) {
37
- return (process.env.DATA_ROOT +
38
- uriComponents.filter(Boolean).map(encodeURIComponent).join('/'));
39
- }
40
- }
41
- exports.URI = URI;
42
- //# sourceMappingURL=URI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"URI.js","sourceRoot":"","sources":["../../../src/utils/URI.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,GAAG;IACd;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM;QACpB,IAAI,CAAC,MAAM;YAAE,OAAO,MAAM,CAAC;QAC3B,2JAA2J;QAC3J,OAAO,MAAM;aACV,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;aACtB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;aACvB,WAAW,EAAE,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,GAAW;QACtB,oCAAoC;QACpC,OAAO,kCAAkC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,GAAG,aAAuB;QACxC,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,SAAS;YACrB,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAChE,CAAC;IACJ,CAAC;CACF;AAlCD,kBAkCC"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Caches the result of a function call based on its arguments for a specified time.
3
- * Arguments are converted to strings for comparison.
4
- * Use cacheTimeMs = 0 to disable caching.
5
- * Use cacheTimeMs = Infinity to never expire the cache.
6
- * When `alsoCacheErrors` is set, a thrown error is remembered for the window so
7
- * the function is not re-invoked — but it is re-thrown to the caller, never
8
- * returned as if it were a value.
9
- * @param fn
10
- * @param args
11
- * @param cacheTimeMs
12
- * @param alsoCacheErrors
13
- */
14
- export declare function cached(fn: () => any, args: any[], cacheTimeMs?: number, alsoCacheErrors?: boolean): any;
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cached = cached;
4
- const Shape_js_1 = require("../shapes/Shape.js");
5
- // Per-function caches. Keying by the function identity (WeakMap) instead of a
6
- // single global string map means two different functions with identical args no
7
- // longer collide, and a function's cache is reclaimed once the function itself
8
- // is unreferenced (bounding growth).
9
- const _cache = new WeakMap();
10
- /**
11
- * Caches the result of a function call based on its arguments for a specified time.
12
- * Arguments are converted to strings for comparison.
13
- * Use cacheTimeMs = 0 to disable caching.
14
- * Use cacheTimeMs = Infinity to never expire the cache.
15
- * When `alsoCacheErrors` is set, a thrown error is remembered for the window so
16
- * the function is not re-invoked — but it is re-thrown to the caller, never
17
- * returned as if it were a value.
18
- * @param fn
19
- * @param args
20
- * @param cacheTimeMs
21
- * @param alsoCacheErrors
22
- */
23
- function cached(fn, args, cacheTimeMs, alsoCacheErrors) {
24
- if (cacheTimeMs !== 0) {
25
- const now = Date.now();
26
- const keyArgs = args.map((a) => {
27
- var _a;
28
- if (a instanceof Shape_js_1.Shape) {
29
- return (_a = a.id) !== null && _a !== void 0 ? _a : a.uri;
30
- }
31
- else if (a && typeof a === 'object' && 'id' in a) {
32
- return a.id;
33
- }
34
- else {
35
- return a === null || a === void 0 ? void 0 : a.toString();
36
- }
37
- });
38
- const key = JSON.stringify(keyArgs);
39
- let fnCache = _cache.get(fn);
40
- if (!fnCache) {
41
- fnCache = new Map();
42
- _cache.set(fn, fnCache);
43
- }
44
- let entry = fnCache.get(key);
45
- if (entry && entry.timeout < now) {
46
- fnCache.delete(key);
47
- entry = undefined;
48
- }
49
- if (!entry) {
50
- try {
51
- entry = { timeout: now + cacheTimeMs, value: fn(), isError: false };
52
- }
53
- catch (e) {
54
- if (alsoCacheErrors) {
55
- entry = { timeout: now + cacheTimeMs, value: e, isError: true };
56
- }
57
- else {
58
- throw e;
59
- }
60
- }
61
- fnCache.set(key, entry);
62
- }
63
- if (entry.isError)
64
- throw entry.value;
65
- return entry.value;
66
- }
67
- else {
68
- return fn();
69
- }
70
- }
71
- //# sourceMappingURL=cached.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cached.js","sourceRoot":"","sources":["../../../src/utils/cached.ts"],"names":[],"mappings":";;AAuBA,wBAwCC;AA/DD,iDAAyC;AAIzC,8EAA8E;AAC9E,gFAAgF;AAChF,+EAA+E;AAC/E,qCAAqC;AACrC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAsC,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,SAAgB,MAAM,CAAC,EAAa,EAAE,IAAW,EAAE,WAAoB,EAAC,eAAyB;IAC/F,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;;YAC7B,IAAI,CAAC,YAAY,gBAAK,EAAE,CAAC;gBACvB,OAAO,MAAA,CAAC,CAAC,EAAE,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CAAC;YACD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC;QACD,IAAI,KAAK,CAAC,OAAO;YAAE,MAAM,KAAK,CAAC,KAAK,CAAC;QACrC,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,34 +0,0 @@
1
- import type { DatasetsConfig } from './parseDatasetsConfig.js';
2
- /**
3
- * Dynamically imports each alias's `store` (an npm specifier) and
4
- * instantiates the resolved class with the entry's `config` verbatim —
5
- * `new StoreClass(entry.config)`. Returns alias → store.
6
- *
7
- * Convention: the last segment of the `store` path is the named export
8
- * to use (e.g. `@_linked/fuseki/shapes/FusekiStore` → `FusekiStore`).
9
- * Falls back to the module's `default` export if the named export is
10
- * absent. Each store class must accept a single config-object argument.
11
- *
12
- * Async + uses runtime dynamic import; works in Node where the module
13
- * specifier can be resolved at runtime. Frontends should instead
14
- * import each store class explicitly in their storage-config file and
15
- * instantiate per alias by hand (webpack can't bundle
16
- * `import(variableString)`).
17
- *
18
- * @example
19
- * ```ts
20
- * import rawConfig from './linked.backend.datasets.json' assert { type: 'json' };
21
- * import { parseDatasetsConfig } from '@_linked/core/utils/parseDatasetsConfig';
22
- * import { loadStores } from '@_linked/core/utils/loadStores';
23
- * import { LinkedStorage } from '@_linked/core/utils/LinkedStorage';
24
- *
25
- * const config = parseDatasetsConfig(rawConfig, process.env);
26
- * const stores = await loadStores(config);
27
- * LinkedStorage.setDefaultDataset(stores.appData);
28
- * ```
29
- *
30
- * @param config Parsed config from {@link parseDatasetsConfig}.
31
- * @returns Map of alias → constructed store instance.
32
- * @throws If a `store` path can't be resolved to a class export.
33
- */
34
- export declare function loadStores<T = unknown>(config: DatasetsConfig): Promise<Record<string, T>>;
@@ -1,105 +0,0 @@
1
- "use strict";
2
- // Backend-side store loader. Lives in its own file so that frontend
3
- // bundlers (webpack) consuming parseDatasetsConfig don't pull in the
4
- // dynamic-import code below — webpack flags `import(variableString)` as
5
- // a critical dependency when it can't analyse the target statically.
6
- //
7
- // Backends import this directly; frontends never do.
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
- Object.defineProperty(o, "default", { enumerable: true, value: v });
21
- }) : function(o, v) {
22
- o["default"] = v;
23
- });
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
42
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
43
- return new (P || (P = Promise))(function (resolve, reject) {
44
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
45
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
46
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47
- step((generator = generator.apply(thisArg, _arguments || [])).next());
48
- });
49
- };
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.loadStores = loadStores;
52
- /**
53
- * Dynamically imports each alias's `store` (an npm specifier) and
54
- * instantiates the resolved class with the entry's `config` verbatim —
55
- * `new StoreClass(entry.config)`. Returns alias → store.
56
- *
57
- * Convention: the last segment of the `store` path is the named export
58
- * to use (e.g. `@_linked/fuseki/shapes/FusekiStore` → `FusekiStore`).
59
- * Falls back to the module's `default` export if the named export is
60
- * absent. Each store class must accept a single config-object argument.
61
- *
62
- * Async + uses runtime dynamic import; works in Node where the module
63
- * specifier can be resolved at runtime. Frontends should instead
64
- * import each store class explicitly in their storage-config file and
65
- * instantiate per alias by hand (webpack can't bundle
66
- * `import(variableString)`).
67
- *
68
- * @example
69
- * ```ts
70
- * import rawConfig from './linked.backend.datasets.json' assert { type: 'json' };
71
- * import { parseDatasetsConfig } from '@_linked/core/utils/parseDatasetsConfig';
72
- * import { loadStores } from '@_linked/core/utils/loadStores';
73
- * import { LinkedStorage } from '@_linked/core/utils/LinkedStorage';
74
- *
75
- * const config = parseDatasetsConfig(rawConfig, process.env);
76
- * const stores = await loadStores(config);
77
- * LinkedStorage.setDefaultDataset(stores.appData);
78
- * ```
79
- *
80
- * @param config Parsed config from {@link parseDatasetsConfig}.
81
- * @returns Map of alias → constructed store instance.
82
- * @throws If a `store` path can't be resolved to a class export.
83
- */
84
- function loadStores(config) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- var _a;
87
- const stores = {};
88
- for (const [alias, entry] of Object.entries(config.datasets)) {
89
- // SECURITY: `entry.store` is a module specifier loaded and executed here.
90
- // It must come from a trusted developer artifact (datasets.json) and must
91
- // NEVER be attacker-influenced — an arbitrary specifier is arbitrary code
92
- // execution. Do not source this from request/user input.
93
- const mod = yield Promise.resolve(`${entry.store}`).then(s => __importStar(require(s)));
94
- const exportName = entry.store.split('/').pop();
95
- const StoreClass = (_a = (mod && mod[exportName])) !== null && _a !== void 0 ? _a : (mod && mod.default);
96
- if (typeof StoreClass !== 'function') {
97
- throw new Error(`loadStores: could not resolve a class export from "${entry.store}" for alias "${alias}". ` +
98
- `Expected a named export "${exportName}" or a default export that is a class.`);
99
- }
100
- stores[alias] = new StoreClass(entry.config);
101
- }
102
- return stores;
103
- });
104
- }
105
- //# sourceMappingURL=loadStores.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadStores.js","sourceRoot":"","sources":["../../../src/utils/loadStores.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,qEAAqE;AACrE,wEAAwE;AACxE,qEAAqE;AACrE,EAAE;AACF,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCrD,gCAuBC;AAvDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAsB,UAAU,CAC9B,MAAsB;;;QAEtB,MAAM,MAAM,GAAsB,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7D,0EAA0E;YAC1E,0EAA0E;YAC1E,0EAA0E;YAC1E,yDAAyD;YACzD,MAAM,GAAG,GAAG,yBAAa,KAAK,CAAC,KAAK,uCAAC,CAAC;YACtC,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAG,CAAC;YACjD,MAAM,UAAU,GACd,MAAA,CAAC,GAAG,IAAK,GAA+B,CAAC,UAAU,CAAC,CAAC,mCACrD,CAAC,GAAG,IAAK,GAA2B,CAAC,OAAO,CAAC,CAAC;YAChD,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CACb,sDAAsD,KAAK,CAAC,KAAK,gBAAgB,KAAK,KAAK;oBACzF,4BAA4B,UAAU,wCAAwC,CACjF,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAK,UAAsC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA"}