@semapps/semantic-data-provider 1.1.0 → 1.1.2
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/dist/index.cjs.js +23 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +23 -19
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -3
package/dist/index.cjs.js
CHANGED
|
@@ -920,7 +920,7 @@ const $95cbc03f25caf72a$var$getListMethod = (config)=>async (resourceId, params)
|
|
|
920
920
|
if (!dataModel) throw new Error(`Resource ${resourceId} is not mapped in resources file`);
|
|
921
921
|
let containers = [];
|
|
922
922
|
if (!params.filter?._servers && dataModel.list?.containers) {
|
|
923
|
-
if (Array.isArray(dataModel.list?.containers)) throw new Error(`The list.containers property of ${resourceId} dataModel must be of type
|
|
923
|
+
if (!Array.isArray(dataModel.list?.containers)) throw new Error(`The list.containers property of ${resourceId} dataModel must be of type array`);
|
|
924
924
|
// If containers are set explicitly, use them
|
|
925
925
|
containers = (0, $37c161736d0d7276$export$2e2bcd8739ae039)(dataModel.list.containers, dataServers);
|
|
926
926
|
} else if (dataModel.shapeTreeUri) containers = (0, $1d94774735aa9ea2$export$2e2bcd8739ae039)(dataModel.shapeTreeUri, params?.filter?._servers || dataModel.list?.servers, dataServers);
|
|
@@ -1101,16 +1101,16 @@ var $341dff85fe619d85$export$2e2bcd8739ae039 = $341dff85fe619d85$var$httpClient;
|
|
|
1101
1101
|
|
|
1102
1102
|
|
|
1103
1103
|
|
|
1104
|
-
const $9ab033d1ec46b5da$var$
|
|
1104
|
+
const $9ab033d1ec46b5da$var$isURI = (value)=>(typeof value === 'string' || value instanceof String) && (value.startsWith('http') || value.startsWith('urn:'));
|
|
1105
1105
|
const $9ab033d1ec46b5da$var$expandTypes = async (types, context)=>{
|
|
1106
1106
|
// If types are already full URIs, return them immediately
|
|
1107
|
-
if (types.every((type)=>$9ab033d1ec46b5da$var$
|
|
1107
|
+
if (types.every((type)=>$9ab033d1ec46b5da$var$isURI(type))) return types;
|
|
1108
1108
|
const result = await (0, ($parcel$interopDefault($bkNnK$jsonld))).expand({
|
|
1109
1109
|
'@context': context,
|
|
1110
1110
|
'@type': types
|
|
1111
1111
|
});
|
|
1112
1112
|
const expandedTypes = (0, $e6fbab1f303bdb93$export$2e2bcd8739ae039)(result[0]['@type']);
|
|
1113
|
-
if (!expandedTypes.every((type)=>$9ab033d1ec46b5da$var$
|
|
1113
|
+
if (!expandedTypes.every((type)=>$9ab033d1ec46b5da$var$isURI(type))) throw new Error(`
|
|
1114
1114
|
Could not expand all types (${expandedTypes.join(', ')}).
|
|
1115
1115
|
Is an ontology missing or not registered yet on the local context ?
|
|
1116
1116
|
`);
|
|
@@ -1220,6 +1220,8 @@ var $fcf4eee3b18e8350$export$2e2bcd8739ae039 = $fcf4eee3b18e8350$var$getOntologi
|
|
|
1220
1220
|
config.dataServers ??= {};
|
|
1221
1221
|
// Configure httpClient with initial data servers, so that plugins may use it
|
|
1222
1222
|
config.httpClient = (0, $341dff85fe619d85$export$2e2bcd8739ae039)(config.dataServers);
|
|
1223
|
+
// Useful for debugging.
|
|
1224
|
+
document.httpClient = config.httpClient;
|
|
1223
1225
|
for (const plugin of config.plugins)if (plugin.transformConfig) config = await plugin.transformConfig(config);
|
|
1224
1226
|
// Configure again httpClient with possibly updated data servers
|
|
1225
1227
|
config.httpClient = (0, $341dff85fe619d85$export$2e2bcd8739ae039)(config.dataServers);
|
|
@@ -1553,16 +1555,22 @@ const $1395e306228d41f2$var$fetchVoidEndpoints = ()=>({
|
|
|
1553
1555
|
const expandedTypes = await (0, $9ab033d1ec46b5da$export$2e2bcd8739ae039)([
|
|
1554
1556
|
type
|
|
1555
1557
|
], result.context);
|
|
1556
|
-
const containerIndex = newConfig.dataServers[result.key].containers.findIndex((c)=>c.
|
|
1557
|
-
if (containerIndex
|
|
1558
|
-
|
|
1559
|
-
|
|
1558
|
+
const containerIndex = newConfig.dataServers[result.key].containers.findIndex((c)=>c.path === path);
|
|
1559
|
+
if (containerIndex !== -1) {
|
|
1560
|
+
// If a container with this path already exist, merge types
|
|
1561
|
+
const mergedTypes = [
|
|
1562
|
+
...newConfig.dataServers[result.key].containers[containerIndex].types,
|
|
1563
|
+
...expandedTypes
|
|
1564
|
+
].filter((v, i, a)=>a.indexOf(v) === i);
|
|
1565
|
+
newConfig.dataServers[result.key].containers[containerIndex] = {
|
|
1566
|
+
...newConfig.dataServers[result.key].containers[containerIndex],
|
|
1567
|
+
types: mergedTypes,
|
|
1568
|
+
binaryResources: mergedTypes.includes('http://semapps.org/ns/core#File')
|
|
1569
|
+
};
|
|
1570
|
+
} else newConfig.dataServers[result.key].containers.push({
|
|
1560
1571
|
path: path,
|
|
1561
|
-
types: expandedTypes
|
|
1562
|
-
|
|
1563
|
-
else newConfig.dataServers[result.key].containers.push({
|
|
1564
|
-
path: path,
|
|
1565
|
-
types: expandedTypes
|
|
1572
|
+
types: expandedTypes,
|
|
1573
|
+
binaryResources: expandedTypes.includes('http://semapps.org/ns/core#File')
|
|
1566
1574
|
});
|
|
1567
1575
|
}
|
|
1568
1576
|
}
|
|
@@ -1725,7 +1733,6 @@ var $d3746ce11bc56f3b$export$2e2bcd8739ae039 = $d3746ce11bc56f3b$var$useContaine
|
|
|
1725
1733
|
|
|
1726
1734
|
|
|
1727
1735
|
|
|
1728
|
-
|
|
1729
1736
|
const $ff3623bf1421ebcc$var$findCreateContainerWithTypes = (types, createServerKey, dataServers)=>{
|
|
1730
1737
|
if (!dataServers[createServerKey].containers) throw new Error(`Data server ${createServerKey} has no declared containers`);
|
|
1731
1738
|
const matchingContainers = dataServers[createServerKey].containers.filter((container)=>container.types?.some((t)=>types.includes(t)));
|
|
@@ -1744,11 +1751,8 @@ const $32d32215b4e4729f$var$useGetCreateContainerUri = ()=>{
|
|
|
1744
1751
|
const getCreateContainerUri = (0, $bkNnK$react.useCallback)((resourceId)=>{
|
|
1745
1752
|
if (!dataModels || !dataServers || !dataModels[resourceId]) return undefined;
|
|
1746
1753
|
const dataModel = dataModels[resourceId];
|
|
1747
|
-
if (dataModel.create?.container)
|
|
1748
|
-
|
|
1749
|
-
if (!serverKey || !dataServers[serverKey]) throw new Error(`Wrong key for the dataModel.create.container config of resource ${resourceId}`);
|
|
1750
|
-
return (0, ($parcel$interopDefault($bkNnK$urljoin)))(dataServers[serverKey].baseUrl, path);
|
|
1751
|
-
} else if (dataModel.create?.server) return (0, $ff3623bf1421ebcc$export$2e2bcd8739ae039)(dataModel.types, dataModel.create?.server, dataServers);
|
|
1754
|
+
if (dataModel.create?.container) return dataModel.create.container;
|
|
1755
|
+
else if (dataModel.create?.server) return (0, $ff3623bf1421ebcc$export$2e2bcd8739ae039)(dataModel.types, dataModel.create.server, dataServers);
|
|
1752
1756
|
else {
|
|
1753
1757
|
const defaultServerKey = (0, $8f44b7c15b8b8e1d$export$2e2bcd8739ae039)('default', dataServers);
|
|
1754
1758
|
if (!defaultServerKey) throw new Error(`No default dataServer found. You can set explicitly one setting the "default" attribute to true`);
|