@semapps/semantic-data-provider 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +350 -218
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.ts +2380 -0
- package/dist/index.d.ts +175 -188
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +345 -213
- package/dist/index.es.js.map +1 -1
- package/dist/index.es.tsx +2439 -0
- package/package.json +14 -8
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import {createConnectedLdoDataset as $fj9kP$createConnectedLdoDataset} from "@ldo/connected";
|
|
2
|
+
import {solidConnectedPlugin as $fj9kP$solidConnectedPlugin} from "@ldo/connected-solid";
|
|
1
3
|
import $fj9kP$speakingurl from "speakingurl";
|
|
2
4
|
import $fj9kP$jsonld from "jsonld";
|
|
3
|
-
import $fj9kP$rdfjsdatamodel
|
|
5
|
+
import $fj9kP$rdfjsdatamodel from "@rdfjs/data-model";
|
|
4
6
|
import {Generator as $fj9kP$Generator} from "sparqljs";
|
|
5
7
|
import $fj9kP$cryptojsmd5 from "crypto-js/md5";
|
|
6
8
|
import {fetchUtils as $fj9kP$fetchUtils, useDataProvider as $fj9kP$useDataProvider, DataProviderContext as $fj9kP$DataProviderContext, useRecordContext as $fj9kP$useRecordContext, useGetList as $fj9kP$useGetList, ArrayInput as $fj9kP$ArrayInput, SimpleFormIterator as $fj9kP$SimpleFormIterator, TextInput as $fj9kP$TextInput} from "react-admin";
|
|
@@ -10,14 +12,13 @@ import $fj9kP$httplinkheader from "http-link-header";
|
|
|
10
12
|
import {capitalCase as $fj9kP$capitalCase} from "change-case";
|
|
11
13
|
import $fj9kP$react, {useState as $fj9kP$useState, useEffect as $fj9kP$useEffect, useMemo as $fj9kP$useMemo, useCallback as $fj9kP$useCallback, useContext as $fj9kP$useContext} from "react";
|
|
12
14
|
import {jsx as $fj9kP$jsx, Fragment as $fj9kP$Fragment, jsxs as $fj9kP$jsxs} from "react/jsx-runtime";
|
|
13
|
-
import $fj9kP$
|
|
15
|
+
import {makeStyles as $fj9kP$makeStyles} from "tss-react/mui";
|
|
14
16
|
|
|
15
|
-
var $11242e90250f263e$exports = {};
|
|
16
|
-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
const $eadae1e342076a7b$var$fetchResource = async (resourceUri, config)=>{
|
|
21
22
|
const { httpClient: httpClient, jsonContext: jsonContext } = config;
|
|
22
23
|
let { json: data } = await httpClient(resourceUri);
|
|
23
24
|
if (!data) throw new Error(`Not a valid JSON: ${resourceUri}`);
|
|
@@ -27,14 +28,14 @@ const $336b7edf722fe53e$var$fetchResource = async (resourceUri, config)=>{
|
|
|
27
28
|
if (data['@context'] !== jsonContext) data = await (0, $fj9kP$jsonld).compact(data, jsonContext);
|
|
28
29
|
return data;
|
|
29
30
|
};
|
|
30
|
-
var $
|
|
31
|
+
var $eadae1e342076a7b$export$2e2bcd8739ae039 = $eadae1e342076a7b$var$fetchResource;
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
const $
|
|
34
|
+
const $4861cda99f97e87d$var$getOneMethod = (config)=>async (resourceId, params)=>{
|
|
34
35
|
const { resources: resources } = config;
|
|
35
36
|
const dataModel = resources[resourceId];
|
|
36
37
|
if (!dataModel) throw new Error(`Resource ${resourceId} is not mapped in resources file`);
|
|
37
|
-
const data = await (0, $
|
|
38
|
+
const data = await (0, $eadae1e342076a7b$export$2e2bcd8739ae039)(params.id, config);
|
|
38
39
|
// Transform single value into array if forceArray is set
|
|
39
40
|
if (dataModel.list?.forceArray) {
|
|
40
41
|
for (const forceArrayItem of dataModel.list?.forceArray || [])if (data[forceArrayItem] && !Array.isArray(data[forceArrayItem])) data[forceArrayItem] = [
|
|
@@ -63,7 +64,7 @@ const $ed447224dd38ce82$var$getOneMethod = (config)=>async (resourceId, params)=
|
|
|
63
64
|
data: data
|
|
64
65
|
};
|
|
65
66
|
};
|
|
66
|
-
var $
|
|
67
|
+
var $4861cda99f97e87d$export$2e2bcd8739ae039 = $4861cda99f97e87d$var$getOneMethod;
|
|
67
68
|
|
|
68
69
|
|
|
69
70
|
const $c35ffbda15247c32$var$getUploadsContainerUri = (config, serverKey)=>{
|
|
@@ -114,22 +115,22 @@ var $b17c43e3301545ca$export$2e2bcd8739ae039 = {
|
|
|
114
115
|
};
|
|
115
116
|
|
|
116
117
|
|
|
117
|
-
const $
|
|
118
|
+
const $aed10b8332b5d58a$var$getServerKeyFromType = (type, dataServers)=>{
|
|
118
119
|
return dataServers && Object.keys(dataServers).find((key)=>{
|
|
119
120
|
return dataServers[key][type];
|
|
120
121
|
});
|
|
121
122
|
};
|
|
122
|
-
var $
|
|
123
|
+
var $aed10b8332b5d58a$export$2e2bcd8739ae039 = $aed10b8332b5d58a$var$getServerKeyFromType;
|
|
123
124
|
|
|
124
125
|
|
|
125
126
|
const $99cc2e4a2a3c100b$var$parseServerKey = (serverKey, dataServers)=>{
|
|
126
127
|
switch(serverKey){
|
|
127
128
|
case '@default':
|
|
128
|
-
return (0, $
|
|
129
|
+
return (0, $aed10b8332b5d58a$export$2e2bcd8739ae039)('default', dataServers);
|
|
129
130
|
case '@pod':
|
|
130
|
-
return (0, $
|
|
131
|
+
return (0, $aed10b8332b5d58a$export$2e2bcd8739ae039)('pod', dataServers);
|
|
131
132
|
case '@authServer':
|
|
132
|
-
return (0, $
|
|
133
|
+
return (0, $aed10b8332b5d58a$export$2e2bcd8739ae039)('authServer', dataServers);
|
|
133
134
|
default:
|
|
134
135
|
return serverKey;
|
|
135
136
|
}
|
|
@@ -143,7 +144,7 @@ const $99cc2e4a2a3c100b$var$parseServerKeys = (serverKeys, dataServers)=>{
|
|
|
143
144
|
} else if (typeof serverKeys === 'string') {
|
|
144
145
|
if (serverKeys === '@all') return Object.keys(dataServers);
|
|
145
146
|
else if (serverKeys === '@remote') {
|
|
146
|
-
const defaultServerKey = (0, $
|
|
147
|
+
const defaultServerKey = (0, $aed10b8332b5d58a$export$2e2bcd8739ae039)('default', dataServers);
|
|
147
148
|
return Object.keys(dataServers).filter((serverKey)=>serverKey !== defaultServerKey);
|
|
148
149
|
} else return [
|
|
149
150
|
$99cc2e4a2a3c100b$var$parseServerKey(serverKeys, dataServers)
|
|
@@ -180,7 +181,7 @@ const $7c772a9c0c25a69d$var$findContainersWithURIs = (containersUris, dataServer
|
|
|
180
181
|
var $7c772a9c0c25a69d$export$2e2bcd8739ae039 = $7c772a9c0c25a69d$var$findContainersWithURIs;
|
|
181
182
|
|
|
182
183
|
|
|
183
|
-
const $
|
|
184
|
+
const $d12d4cfb47175317$var$createMethod = (config)=>async (resourceId, params)=>{
|
|
184
185
|
const { dataServers: dataServers, resources: resources, httpClient: httpClient, jsonContext: jsonContext } = config;
|
|
185
186
|
const dataModel = resources[resourceId];
|
|
186
187
|
if (!dataModel) Error(`Resource ${resourceId} is not mapped in resources file`);
|
|
@@ -223,7 +224,7 @@ const $5a7a2f7583392866$var$createMethod = (config)=>async (resourceId, params)=
|
|
|
223
224
|
});
|
|
224
225
|
// Retrieve newly-created resource
|
|
225
226
|
const resourceUri = responseHeaders.get('Location');
|
|
226
|
-
return await (0, $
|
|
227
|
+
return await (0, $4861cda99f97e87d$export$2e2bcd8739ae039)(config)(resourceId, {
|
|
227
228
|
id: resourceUri
|
|
228
229
|
});
|
|
229
230
|
}
|
|
@@ -238,12 +239,12 @@ const $5a7a2f7583392866$var$createMethod = (config)=>async (resourceId, params)=
|
|
|
238
239
|
`
|
|
239
240
|
});
|
|
240
241
|
// Create must return the new data, so get them from the remote URI
|
|
241
|
-
return await (0, $
|
|
242
|
+
return await (0, $4861cda99f97e87d$export$2e2bcd8739ae039)(config)(resourceId, {
|
|
242
243
|
id: params.id
|
|
243
244
|
});
|
|
244
245
|
}
|
|
245
246
|
};
|
|
246
|
-
var $
|
|
247
|
+
var $d12d4cfb47175317$export$2e2bcd8739ae039 = $d12d4cfb47175317$var$createMethod;
|
|
247
248
|
|
|
248
249
|
|
|
249
250
|
const $9510970b8e7eb9e2$var$deleteMethod = (config)=>async (resourceId, params)=>{
|
|
@@ -260,7 +261,7 @@ const $9510970b8e7eb9e2$var$deleteMethod = (config)=>async (resourceId, params)=
|
|
|
260
261
|
var $9510970b8e7eb9e2$export$2e2bcd8739ae039 = $9510970b8e7eb9e2$var$deleteMethod;
|
|
261
262
|
|
|
262
263
|
|
|
263
|
-
const $
|
|
264
|
+
const $9b978ac85d859b57$var$deleteManyMethod = (config)=>async (resourceId, params)=>{
|
|
264
265
|
const { httpClient: httpClient } = config;
|
|
265
266
|
const ids = [];
|
|
266
267
|
for (const id of params.ids)try {
|
|
@@ -275,19 +276,19 @@ const $298dd1ae21173ea0$var$deleteManyMethod = (config)=>async (resourceId, para
|
|
|
275
276
|
data: ids
|
|
276
277
|
};
|
|
277
278
|
};
|
|
278
|
-
var $
|
|
279
|
+
var $9b978ac85d859b57$export$2e2bcd8739ae039 = $9b978ac85d859b57$var$deleteManyMethod;
|
|
279
280
|
|
|
280
281
|
|
|
281
|
-
const $
|
|
282
|
+
const $294fdd580f2e7246$var$getDataServers = (config)=>()=>{
|
|
282
283
|
return config.dataServers;
|
|
283
284
|
};
|
|
284
|
-
var $
|
|
285
|
+
var $294fdd580f2e7246$export$2e2bcd8739ae039 = $294fdd580f2e7246$var$getDataServers;
|
|
285
286
|
|
|
286
287
|
|
|
287
|
-
const $
|
|
288
|
+
const $52333268224773ef$var$getDataModels = (config)=>()=>{
|
|
288
289
|
return config.resources;
|
|
289
290
|
};
|
|
290
|
-
var $
|
|
291
|
+
var $52333268224773ef$export$2e2bcd8739ae039 = $52333268224773ef$var$getDataModels;
|
|
291
292
|
|
|
292
293
|
|
|
293
294
|
|
|
@@ -305,6 +306,19 @@ const $cc8adac4b83414eb$var$arrayOf = (value)=>{
|
|
|
305
306
|
var $cc8adac4b83414eb$export$2e2bcd8739ae039 = $cc8adac4b83414eb$var$arrayOf;
|
|
306
307
|
|
|
307
308
|
|
|
309
|
+
|
|
310
|
+
// Fetch the selected resources of the provided containers
|
|
311
|
+
// Filter out resources that are provided (can avoid loading a resource twice)
|
|
312
|
+
const $c83d324c3b433284$var$fetchSelectedResources = async (containers, excludedResourcesUris, config)=>{
|
|
313
|
+
let selectedResourcesUris = containers.filter((c)=>c.selectedResources).map((c)=>c.selectedResources).flat();
|
|
314
|
+
// Filter out resources which are already included in the SPARQL query results
|
|
315
|
+
selectedResourcesUris = selectedResourcesUris.filter((uri)=>!excludedResourcesUris.includes(uri));
|
|
316
|
+
const selectedResources = await Promise.all(selectedResourcesUris.map((resourceUri)=>(0, $eadae1e342076a7b$export$2e2bcd8739ae039)(resourceUri, config)));
|
|
317
|
+
return selectedResources;
|
|
318
|
+
};
|
|
319
|
+
var $c83d324c3b433284$export$2e2bcd8739ae039 = $c83d324c3b433284$var$fetchSelectedResources;
|
|
320
|
+
|
|
321
|
+
|
|
308
322
|
const $aba124ea15ea8bc6$var$isValidLDPContainer = (container)=>{
|
|
309
323
|
const resourceType = container.type || container['@type'];
|
|
310
324
|
return Array.isArray(resourceType) ? resourceType.includes('ldp:Container') : resourceType === 'ldp:Container';
|
|
@@ -312,23 +326,24 @@ const $aba124ea15ea8bc6$var$isValidLDPContainer = (container)=>{
|
|
|
312
326
|
const $aba124ea15ea8bc6$var$isObject = (val)=>{
|
|
313
327
|
return val != null && typeof val === 'object' && !Array.isArray(val);
|
|
314
328
|
};
|
|
315
|
-
const $aba124ea15ea8bc6$var$fetchContainers = async (containers, params,
|
|
316
|
-
const
|
|
317
|
-
const jsonResponse = json;
|
|
318
|
-
// If container's context is different, compact it to have an uniform result
|
|
319
|
-
// TODO deep compare if the context is an object
|
|
320
|
-
if (jsonResponse['@context'] !== jsonContext) return (0, $fj9kP$jsonld).compact(jsonResponse, jsonContext);
|
|
321
|
-
return jsonResponse;
|
|
322
|
-
}).then((json)=>{
|
|
323
|
-
if (!$aba124ea15ea8bc6$var$isValidLDPContainer(json)) throw new Error(`${container.uri} is not a LDP container`);
|
|
324
|
-
return (0, $cc8adac4b83414eb$export$2e2bcd8739ae039)(json['ldp:contains']).map((resource)=>({
|
|
325
|
-
'@context': json['@context'],
|
|
326
|
-
...resource
|
|
327
|
-
}));
|
|
328
|
-
}));
|
|
329
|
+
const $aba124ea15ea8bc6$var$fetchContainers = async (containers, params, config)=>{
|
|
330
|
+
const { httpClient: httpClient, jsonContext: jsonContext } = config;
|
|
329
331
|
// Fetch simultaneously all containers
|
|
330
|
-
const results = await Promise.all(
|
|
332
|
+
const results = await Promise.all(containers.filter((c)=>!c.selectedResources).map(async (container)=>{
|
|
333
|
+
let { json: json } = await httpClient(container.uri);
|
|
334
|
+
// If container's context is different, compact it to have an uniform result
|
|
335
|
+
// TODO deep compare if the context is an object
|
|
336
|
+
if (json['@context'] !== jsonContext) json = await (0, $fj9kP$jsonld).compact(json, jsonContext);
|
|
337
|
+
if (!$aba124ea15ea8bc6$var$isValidLDPContainer(json)) throw new Error(`${container.uri} is not a LDP container`);
|
|
338
|
+
return (0, $cc8adac4b83414eb$export$2e2bcd8739ae039)(json['ldp:contains']).map((resource)=>({
|
|
339
|
+
'@context': json['@context'],
|
|
340
|
+
...resource
|
|
341
|
+
}));
|
|
342
|
+
}));
|
|
331
343
|
let resources = results.flat();
|
|
344
|
+
// Append selected resources (if any)
|
|
345
|
+
const selectedResources = await (0, $c83d324c3b433284$export$2e2bcd8739ae039)(containers, resources.map((r)=>r.id), config);
|
|
346
|
+
resources = resources.concat(selectedResources);
|
|
332
347
|
resources = resources.map((resource)=>{
|
|
333
348
|
resource.id = resource.id || resource['@id'];
|
|
334
349
|
return resource;
|
|
@@ -390,7 +405,10 @@ const $aba124ea15ea8bc6$var$fetchContainers = async (containers, params, { httpC
|
|
|
390
405
|
});
|
|
391
406
|
// Sorting
|
|
392
407
|
if (params.sort) resources = resources.sort((a, b)=>{
|
|
393
|
-
|
|
408
|
+
// @ts-expect-error TS(2532): Object is possibly 'undefined'.
|
|
409
|
+
if (params.sort.order === 'ASC') // @ts-expect-error TS(2532): Object is possibly 'undefined'.
|
|
410
|
+
return (a[params.sort.field] ?? '').localeCompare(b[params.sort.field] ?? '');
|
|
411
|
+
// @ts-expect-error TS(2532): Object is possibly 'undefined'.
|
|
394
412
|
return (b[params.sort.field] ?? '').localeCompare(a[params.sort.field] ?? '');
|
|
395
413
|
});
|
|
396
414
|
// Pagination
|
|
@@ -405,7 +423,7 @@ var $aba124ea15ea8bc6$export$2e2bcd8739ae039 = $aba124ea15ea8bc6$var$fetchContai
|
|
|
405
423
|
|
|
406
424
|
|
|
407
425
|
|
|
408
|
-
const $
|
|
426
|
+
const $30358023049c31e9$var$getEmbedFrame = (blankNodes)=>{
|
|
409
427
|
let embedFrame = {};
|
|
410
428
|
let predicates;
|
|
411
429
|
if (blankNodes) {
|
|
@@ -416,7 +434,8 @@ const $3007d5479dd82d51$var$getEmbedFrame = (blankNodes)=>{
|
|
|
416
434
|
];
|
|
417
435
|
embedFrame = {
|
|
418
436
|
...embedFrame,
|
|
419
|
-
...predicates.reduce((accumulator
|
|
437
|
+
...predicates.reduce(// @ts-expect-error TS(7006): Parameter 'accumulator' implicitly has an 'any' ty... Remove this comment to see the full error message
|
|
438
|
+
(accumulator, predicate)=>({
|
|
420
439
|
[predicate]: {
|
|
421
440
|
'@embed': '@last',
|
|
422
441
|
...accumulator
|
|
@@ -427,7 +446,7 @@ const $3007d5479dd82d51$var$getEmbedFrame = (blankNodes)=>{
|
|
|
427
446
|
return embedFrame;
|
|
428
447
|
}
|
|
429
448
|
};
|
|
430
|
-
var $
|
|
449
|
+
var $30358023049c31e9$export$2e2bcd8739ae039 = $30358023049c31e9$var$getEmbedFrame;
|
|
431
450
|
|
|
432
451
|
|
|
433
452
|
|
|
@@ -448,22 +467,22 @@ const $4872a1c30c1fc60e$var$getUriFromPrefix = (item, ontologies)=>{
|
|
|
448
467
|
var $4872a1c30c1fc60e$export$2e2bcd8739ae039 = $4872a1c30c1fc60e$var$getUriFromPrefix;
|
|
449
468
|
|
|
450
469
|
|
|
451
|
-
const $
|
|
470
|
+
const $4e30f9af2d448bb4$var$defaultToArray = (value)=>!value ? [] : Array.isArray(value) ? value : [
|
|
452
471
|
value
|
|
453
472
|
];
|
|
454
473
|
// We need to always include the type or React-Admin will not work properly
|
|
455
|
-
const $
|
|
456
|
-
const $
|
|
474
|
+
const $4e30f9af2d448bb4$var$typeQuery = (0, $fj9kP$rdfjsdatamodel).quad((0, $fj9kP$rdfjsdatamodel).variable('s1'), (0, $fj9kP$rdfjsdatamodel).namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), (0, $fj9kP$rdfjsdatamodel).variable('type'));
|
|
475
|
+
const $4e30f9af2d448bb4$var$buildBaseQuery = (predicates, ontologies)=>{
|
|
457
476
|
let baseTriples;
|
|
458
477
|
if (predicates) {
|
|
459
|
-
baseTriples = $
|
|
478
|
+
baseTriples = $4e30f9af2d448bb4$var$defaultToArray(predicates).map((predicate, i)=>(0, $fj9kP$rdfjsdatamodel).quad((0, $fj9kP$rdfjsdatamodel).variable('s1'), (0, $fj9kP$rdfjsdatamodel).namedNode((0, $4872a1c30c1fc60e$export$2e2bcd8739ae039)(predicate, ontologies)), (0, $fj9kP$rdfjsdatamodel).variable(`o${i + 1}`)));
|
|
460
479
|
return {
|
|
461
480
|
construct: [
|
|
462
|
-
$
|
|
481
|
+
$4e30f9af2d448bb4$var$typeQuery,
|
|
463
482
|
...baseTriples
|
|
464
483
|
],
|
|
465
484
|
where: [
|
|
466
|
-
$
|
|
485
|
+
$4e30f9af2d448bb4$var$typeQuery,
|
|
467
486
|
...baseTriples.map((triple)=>({
|
|
468
487
|
type: 'optional',
|
|
469
488
|
patterns: [
|
|
@@ -474,21 +493,22 @@ const $47d734d7812e6861$var$buildBaseQuery = (predicates, ontologies)=>{
|
|
|
474
493
|
};
|
|
475
494
|
}
|
|
476
495
|
baseTriples = [
|
|
477
|
-
(0, $fj9kP$
|
|
496
|
+
(0, $fj9kP$rdfjsdatamodel).quad((0, $fj9kP$rdfjsdatamodel).variable('s1'), (0, $fj9kP$rdfjsdatamodel).variable('p1'), (0, $fj9kP$rdfjsdatamodel).variable('o1'))
|
|
478
497
|
];
|
|
479
498
|
return {
|
|
480
499
|
construct: baseTriples,
|
|
481
500
|
where: baseTriples
|
|
482
501
|
};
|
|
483
502
|
};
|
|
484
|
-
var $
|
|
503
|
+
var $4e30f9af2d448bb4$export$2e2bcd8739ae039 = $4e30f9af2d448bb4$var$buildBaseQuery;
|
|
485
504
|
|
|
486
505
|
|
|
506
|
+
// @ts-expect-error TS(7016): Could not find a declaration file for module 'cryp... Remove this comment to see the full error message
|
|
487
507
|
|
|
488
508
|
|
|
489
509
|
|
|
490
510
|
// Transform ['ont:predicate1/ont:predicate2'] to ['ont:predicate1', 'ont:predicate1/ont:predicate2']
|
|
491
|
-
const $
|
|
511
|
+
const $8ad7b5ebbca2bb3e$var$extractNodes = (blankNodes)=>{
|
|
492
512
|
const nodes = [];
|
|
493
513
|
if (blankNodes) {
|
|
494
514
|
for (const predicate of blankNodes)if (predicate.includes('/')) {
|
|
@@ -498,10 +518,10 @@ const $865f630cc944e818$var$extractNodes = (blankNodes)=>{
|
|
|
498
518
|
}
|
|
499
519
|
return nodes;
|
|
500
520
|
};
|
|
501
|
-
const $
|
|
502
|
-
const $
|
|
503
|
-
const $
|
|
504
|
-
const $
|
|
521
|
+
const $8ad7b5ebbca2bb3e$var$generateSparqlVarName = (node)=>(0, $fj9kP$cryptojsmd5)(node);
|
|
522
|
+
const $8ad7b5ebbca2bb3e$var$getParentNode = (node)=>node.includes('/') && node.split('/')[0];
|
|
523
|
+
const $8ad7b5ebbca2bb3e$var$getPredicate = (node)=>node.includes('/') ? node.split('/')[1] : node;
|
|
524
|
+
const $8ad7b5ebbca2bb3e$var$buildUnionQuery = (queries)=>queries.map((q)=>{
|
|
505
525
|
let triples = q.query;
|
|
506
526
|
const firstTriple = queries.find((q2)=>q.parentNode === q2.node);
|
|
507
527
|
if (firstTriple !== undefined) triples = triples.concat(firstTriple.query[0]);
|
|
@@ -510,18 +530,18 @@ const $865f630cc944e818$var$buildUnionQuery = (queries)=>queries.map((q)=>{
|
|
|
510
530
|
triples: triples
|
|
511
531
|
};
|
|
512
532
|
});
|
|
513
|
-
const $
|
|
533
|
+
const $8ad7b5ebbca2bb3e$var$buildBlankNodesQuery = (blankNodes, baseQuery, ontologies)=>{
|
|
514
534
|
const queries = [];
|
|
515
|
-
const nodes = $
|
|
535
|
+
const nodes = $8ad7b5ebbca2bb3e$var$extractNodes(blankNodes);
|
|
516
536
|
if (nodes && ontologies && ontologies.length > 0) {
|
|
517
537
|
for (const node of nodes){
|
|
518
|
-
const parentNode = $
|
|
519
|
-
const predicate = $
|
|
520
|
-
const varName = $
|
|
521
|
-
const parentVarName = parentNode ? $
|
|
538
|
+
const parentNode = $8ad7b5ebbca2bb3e$var$getParentNode(node);
|
|
539
|
+
const predicate = $8ad7b5ebbca2bb3e$var$getPredicate(node);
|
|
540
|
+
const varName = $8ad7b5ebbca2bb3e$var$generateSparqlVarName(node);
|
|
541
|
+
const parentVarName = parentNode ? $8ad7b5ebbca2bb3e$var$generateSparqlVarName(parentNode) : '1';
|
|
522
542
|
const query = [
|
|
523
|
-
(0, $fj9kP$
|
|
524
|
-
(0, $fj9kP$
|
|
543
|
+
(0, $fj9kP$rdfjsdatamodel).quad((0, $fj9kP$rdfjsdatamodel).variable(`s${parentVarName}`), (0, $fj9kP$rdfjsdatamodel).namedNode((0, $4872a1c30c1fc60e$export$2e2bcd8739ae039)(predicate, ontologies)), (0, $fj9kP$rdfjsdatamodel).variable(`s${varName}`)),
|
|
544
|
+
(0, $fj9kP$rdfjsdatamodel).quad((0, $fj9kP$rdfjsdatamodel).variable(`s${varName}`), (0, $fj9kP$rdfjsdatamodel).variable(`p${varName}`), (0, $fj9kP$rdfjsdatamodel).variable(`o${varName}`))
|
|
525
545
|
];
|
|
526
546
|
queries.push({
|
|
527
547
|
node: node,
|
|
@@ -536,7 +556,7 @@ const $865f630cc944e818$var$buildBlankNodesQuery = (blankNodes, baseQuery, ontol
|
|
|
536
556
|
type: 'union',
|
|
537
557
|
patterns: [
|
|
538
558
|
baseQuery.where,
|
|
539
|
-
...$
|
|
559
|
+
...$8ad7b5ebbca2bb3e$var$buildUnionQuery(queries)
|
|
540
560
|
]
|
|
541
561
|
}
|
|
542
562
|
};
|
|
@@ -546,11 +566,11 @@ const $865f630cc944e818$var$buildBlankNodesQuery = (blankNodes, baseQuery, ontol
|
|
|
546
566
|
where: ''
|
|
547
567
|
};
|
|
548
568
|
};
|
|
549
|
-
var $
|
|
569
|
+
var $8ad7b5ebbca2bb3e$export$2e2bcd8739ae039 = $8ad7b5ebbca2bb3e$var$buildBlankNodesQuery;
|
|
550
570
|
|
|
551
571
|
|
|
552
572
|
|
|
553
|
-
const $
|
|
573
|
+
const $6aa919fd3fcf3e9c$var$buildAutoDetectBlankNodesQuery = (depth, baseQuery)=>{
|
|
554
574
|
const construct = [
|
|
555
575
|
...baseQuery.construct
|
|
556
576
|
];
|
|
@@ -561,7 +581,7 @@ const $efbe3fa6f1479c06$var$buildAutoDetectBlankNodesQuery = (depth, baseQuery)=
|
|
|
561
581
|
baseQuery.where
|
|
562
582
|
]);
|
|
563
583
|
for(let i = 1; i <= depth; i++){
|
|
564
|
-
construct.push((0, $fj9kP$
|
|
584
|
+
construct.push((0, $fj9kP$rdfjsdatamodel).quad((0, $fj9kP$rdfjsdatamodel).variable(`o${i}`), (0, $fj9kP$rdfjsdatamodel).variable(`p${i + 1}`), (0, $fj9kP$rdfjsdatamodel).variable(`o${i + 1}`)));
|
|
565
585
|
whereQueries.push([
|
|
566
586
|
...whereQueries[whereQueries.length - 1],
|
|
567
587
|
{
|
|
@@ -570,11 +590,11 @@ const $efbe3fa6f1479c06$var$buildAutoDetectBlankNodesQuery = (depth, baseQuery)=
|
|
|
570
590
|
type: 'operation',
|
|
571
591
|
operator: 'isblank',
|
|
572
592
|
args: [
|
|
573
|
-
(0, $fj9kP$variable
|
|
593
|
+
(0, $fj9kP$rdfjsdatamodel).variable(`o${i}`)
|
|
574
594
|
]
|
|
575
595
|
}
|
|
576
596
|
},
|
|
577
|
-
(0, $fj9kP$
|
|
597
|
+
(0, $fj9kP$rdfjsdatamodel).quad((0, $fj9kP$rdfjsdatamodel).variable(`o${i}`), (0, $fj9kP$rdfjsdatamodel).variable(`p${i + 1}`), (0, $fj9kP$rdfjsdatamodel).variable(`o${i + 1}`))
|
|
578
598
|
]);
|
|
579
599
|
}
|
|
580
600
|
where = {
|
|
@@ -588,16 +608,15 @@ const $efbe3fa6f1479c06$var$buildAutoDetectBlankNodesQuery = (depth, baseQuery)=
|
|
|
588
608
|
where: where
|
|
589
609
|
};
|
|
590
610
|
};
|
|
591
|
-
var $
|
|
611
|
+
var $6aa919fd3fcf3e9c$export$2e2bcd8739ae039 = $6aa919fd3fcf3e9c$var$buildAutoDetectBlankNodesQuery;
|
|
592
612
|
|
|
593
613
|
|
|
594
614
|
|
|
595
615
|
|
|
596
|
-
var $
|
|
597
|
-
const
|
|
598
|
-
const $6cde9a8fbbde3ffb$var$generator = new $6cde9a8fbbde3ffb$require$SparqlGenerator({
|
|
616
|
+
var $dcde11998342d30d$require$SparqlGenerator = $fj9kP$Generator;
|
|
617
|
+
const $dcde11998342d30d$var$generator = new $dcde11998342d30d$require$SparqlGenerator({
|
|
599
618
|
});
|
|
600
|
-
const $
|
|
619
|
+
const $dcde11998342d30d$var$reservedFilterKeys = [
|
|
601
620
|
'q',
|
|
602
621
|
'sparqlWhere',
|
|
603
622
|
'blankNodes',
|
|
@@ -605,7 +624,7 @@ const $6cde9a8fbbde3ffb$var$reservedFilterKeys = [
|
|
|
605
624
|
'_servers',
|
|
606
625
|
'_predicates'
|
|
607
626
|
];
|
|
608
|
-
const $
|
|
627
|
+
const $dcde11998342d30d$var$buildSparqlQuery = ({ containersUris: containersUris, params: params, dataModel: dataModel, ontologies: ontologies })=>{
|
|
609
628
|
const blankNodes = params.filter?.blankNodes || dataModel.list?.blankNodes;
|
|
610
629
|
const predicates = params.filter?._predicates || dataModel.list?.predicates;
|
|
611
630
|
const blankNodesDepth = params.filter?.blankNodesDepth ?? dataModel.list?.blankNodesDepth ?? 2;
|
|
@@ -613,7 +632,7 @@ const $6cde9a8fbbde3ffb$var$buildSparqlQuery = ({ containersUris: containersUris
|
|
|
613
632
|
...dataModel.list?.filter,
|
|
614
633
|
...params.filter
|
|
615
634
|
};
|
|
616
|
-
const baseQuery = (0, $
|
|
635
|
+
const baseQuery = (0, $4e30f9af2d448bb4$export$2e2bcd8739ae039)(predicates, ontologies);
|
|
617
636
|
const sparqlJsParams = {
|
|
618
637
|
queryType: 'CONSTRUCT',
|
|
619
638
|
template: baseQuery.construct,
|
|
@@ -625,17 +644,17 @@ const $6cde9a8fbbde3ffb$var$buildSparqlQuery = ({ containersUris: containersUris
|
|
|
625
644
|
{
|
|
626
645
|
type: 'values',
|
|
627
646
|
values: containersUris.map((containerUri)=>({
|
|
628
|
-
'?containerUri': $
|
|
647
|
+
'?containerUri': (0, $fj9kP$rdfjsdatamodel).namedNode(containerUri)
|
|
629
648
|
}))
|
|
630
649
|
},
|
|
631
|
-
$
|
|
650
|
+
(0, $fj9kP$rdfjsdatamodel).quad((0, $fj9kP$rdfjsdatamodel).variable('containerUri'), (0, $fj9kP$rdfjsdatamodel).namedNode('http://www.w3.org/ns/ldp#contains'), (0, $fj9kP$rdfjsdatamodel).variable('s1')),
|
|
632
651
|
{
|
|
633
652
|
type: 'filter',
|
|
634
653
|
expression: {
|
|
635
654
|
type: 'operation',
|
|
636
655
|
operator: 'isiri',
|
|
637
656
|
args: [
|
|
638
|
-
$
|
|
657
|
+
(0, $fj9kP$rdfjsdatamodel).variable('s1')
|
|
639
658
|
]
|
|
640
659
|
}
|
|
641
660
|
}
|
|
@@ -647,10 +666,10 @@ const $6cde9a8fbbde3ffb$var$buildSparqlQuery = ({ containersUris: containersUris
|
|
|
647
666
|
{
|
|
648
667
|
"sparqlWhere": {
|
|
649
668
|
"type": "bgp",
|
|
650
|
-
"
|
|
651
|
-
"subject": {"termType": "
|
|
669
|
+
"rdf.quads": [{
|
|
670
|
+
"subject": {"termType": "rdf.variable", "value": "s1"},
|
|
652
671
|
"predicate": {"termType": "NameNode", "value": "http://virtual-assembly.org/ontologies/pair#label"},
|
|
653
|
-
"object": {"termType": "
|
|
672
|
+
"object": {"termType": "rdf.literal", "value": "My Organization"}
|
|
654
673
|
}]
|
|
655
674
|
}
|
|
656
675
|
}
|
|
@@ -667,17 +686,17 @@ const $6cde9a8fbbde3ffb$var$buildSparqlQuery = ({ containersUris: containersUris
|
|
|
667
686
|
{
|
|
668
687
|
queryType: 'SELECT',
|
|
669
688
|
variables: [
|
|
670
|
-
$
|
|
689
|
+
(0, $fj9kP$rdfjsdatamodel).variable('s1')
|
|
671
690
|
],
|
|
672
691
|
where: [
|
|
673
|
-
$
|
|
692
|
+
(0, $fj9kP$rdfjsdatamodel).quad((0, $fj9kP$rdfjsdatamodel).variable('s1'), (0, $fj9kP$rdfjsdatamodel).variable('p1'), (0, $fj9kP$rdfjsdatamodel).variable('o1')),
|
|
674
693
|
{
|
|
675
694
|
type: 'filter',
|
|
676
695
|
expression: {
|
|
677
696
|
type: 'operation',
|
|
678
697
|
operator: 'isliteral',
|
|
679
698
|
args: [
|
|
680
|
-
$
|
|
699
|
+
(0, $fj9kP$rdfjsdatamodel).variable('o1')
|
|
681
700
|
]
|
|
682
701
|
}
|
|
683
702
|
},
|
|
@@ -695,12 +714,13 @@ const $6cde9a8fbbde3ffb$var$buildSparqlQuery = ({ containersUris: containersUris
|
|
|
695
714
|
type: 'operation',
|
|
696
715
|
operator: 'str',
|
|
697
716
|
args: [
|
|
698
|
-
$
|
|
717
|
+
(0, $fj9kP$rdfjsdatamodel).variable('o1')
|
|
699
718
|
]
|
|
700
719
|
}
|
|
701
720
|
]
|
|
702
721
|
},
|
|
703
|
-
|
|
722
|
+
// @ts-expect-error TS(2554): Expected 1-2 arguments, but got 3.
|
|
723
|
+
(0, $fj9kP$rdfjsdatamodel).literal(filter.q.toLowerCase(), '', (0, $fj9kP$rdfjsdatamodel).namedNode('http://www.w3.org/2001/XMLSchema#string'))
|
|
704
724
|
]
|
|
705
725
|
}
|
|
706
726
|
}
|
|
@@ -713,22 +733,27 @@ const $6cde9a8fbbde3ffb$var$buildSparqlQuery = ({ containersUris: containersUris
|
|
|
713
733
|
// SPARQL keyword a = filter based on the class of a resource (example => 'a': 'pair:OrganizationType')
|
|
714
734
|
// Other filters are based on a value (example => 'petr:hasAudience': 'http://localhost:3000/audiences/tout-public')
|
|
715
735
|
Object.entries(filter).forEach(([predicate, object])=>{
|
|
716
|
-
if (!$
|
|
736
|
+
if (!$dcde11998342d30d$var$reservedFilterKeys.includes(predicate)) resourceWhere.unshift((0, $fj9kP$rdfjsdatamodel).quad((0, $fj9kP$rdfjsdatamodel).variable('s1'), (0, $fj9kP$rdfjsdatamodel).namedNode((0, $4872a1c30c1fc60e$export$2e2bcd8739ae039)(predicate, ontologies)), // @ts-expect-error TS(2345): Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
|
|
737
|
+
(0, $fj9kP$rdfjsdatamodel).namedNode((0, $4872a1c30c1fc60e$export$2e2bcd8739ae039)(object, ontologies))));
|
|
717
738
|
});
|
|
718
739
|
}
|
|
719
740
|
// Blank nodes
|
|
720
|
-
const blankNodesQuery = blankNodes ? (0, $
|
|
741
|
+
const blankNodesQuery = blankNodes ? (0, $8ad7b5ebbca2bb3e$export$2e2bcd8739ae039)(blankNodes, baseQuery, ontologies) : (0, $6aa919fd3fcf3e9c$export$2e2bcd8739ae039)(blankNodesDepth, baseQuery);
|
|
721
742
|
if (blankNodesQuery && blankNodesQuery.construct) {
|
|
743
|
+
// @ts-expect-error TS(2769): No overload matches this call.
|
|
722
744
|
resourceWhere = resourceWhere.concat(blankNodesQuery.where);
|
|
745
|
+
// @ts-expect-error TS(2769): No overload matches this call.
|
|
723
746
|
sparqlJsParams.template = sparqlJsParams.template.concat(blankNodesQuery.construct);
|
|
724
747
|
} else resourceWhere.push(baseQuery.where);
|
|
748
|
+
// @ts-expect-error TS(2345): Argument of type '(uad | { type: string; values: ... Remove this comment to see the full error message
|
|
725
749
|
sparqlJsParams.where.push(containerWhere, resourceWhere);
|
|
726
|
-
return $
|
|
750
|
+
return $dcde11998342d30d$var$generator.stringify(sparqlJsParams);
|
|
727
751
|
};
|
|
728
|
-
var $
|
|
752
|
+
var $dcde11998342d30d$export$2e2bcd8739ae039 = $dcde11998342d30d$var$buildSparqlQuery;
|
|
729
753
|
|
|
730
754
|
|
|
731
|
-
|
|
755
|
+
|
|
756
|
+
const $4aa3fb2e83f6c3a3$var$compare = (a, b)=>{
|
|
732
757
|
switch(typeof a){
|
|
733
758
|
case 'string':
|
|
734
759
|
return a.localeCompare(b);
|
|
@@ -738,17 +763,20 @@ const $05a1b4063d50f1b7$var$compare = (a, b)=>{
|
|
|
738
763
|
return 0;
|
|
739
764
|
}
|
|
740
765
|
};
|
|
741
|
-
const $
|
|
742
|
-
const { dataServers: dataServers,
|
|
743
|
-
const dataModel = resources[resourceId];
|
|
744
|
-
|
|
766
|
+
const $4aa3fb2e83f6c3a3$var$fetchSparqlEndpoints = async (containers, resourceId, params, config)=>{
|
|
767
|
+
const { dataServers: dataServers, httpClient: httpClient, jsonContext: jsonContext, ontologies: ontologies } = config;
|
|
768
|
+
const dataModel = config.resources[resourceId];
|
|
769
|
+
// Find servers to query with SPARQL
|
|
770
|
+
// (Ignore containers with selected resources, they will be fetched below)
|
|
771
|
+
const serversToQuery = containers.filter((c)=>!c.selectedResources).reduce((acc, cur)=>{
|
|
745
772
|
if (!acc.includes(cur.server)) acc.push(cur.server);
|
|
746
773
|
return acc;
|
|
747
774
|
}, []);
|
|
748
|
-
|
|
775
|
+
// Run simultaneous SPARQL queries
|
|
776
|
+
const results = await Promise.all(serversToQuery.map((serverKey)=>new Promise((resolve, reject)=>{
|
|
749
777
|
const blankNodes = params.filter?.blankNodes || dataModel.list?.blankNodes;
|
|
750
|
-
const sparqlQuery = (0, $
|
|
751
|
-
containersUris: containers.filter((c)=>c.server === serverKey).map((c)=>c.uri),
|
|
778
|
+
const sparqlQuery = (0, $dcde11998342d30d$export$2e2bcd8739ae039)({
|
|
779
|
+
containersUris: containers.filter((c)=>c.server === serverKey && !c.selectedResources).map((c)=>c.uri),
|
|
752
780
|
params: params,
|
|
753
781
|
dataModel: dataModel,
|
|
754
782
|
ontologies: ontologies
|
|
@@ -764,7 +792,7 @@ const $05a1b4063d50f1b7$var$fetchSparqlEndpoints = async (containers, resourceId
|
|
|
764
792
|
'@context': jsonContext,
|
|
765
793
|
'@type': dataModel.types,
|
|
766
794
|
'@embed': '@never',
|
|
767
|
-
...(0, $
|
|
795
|
+
...(0, $30358023049c31e9$export$2e2bcd8739ae039)(blankNodes)
|
|
768
796
|
} : {
|
|
769
797
|
'@context': jsonContext,
|
|
770
798
|
'@type': dataModel.types
|
|
@@ -788,25 +816,26 @@ const $05a1b4063d50f1b7$var$fetchSparqlEndpoints = async (containers, resourceId
|
|
|
788
816
|
...resource
|
|
789
817
|
})) || []);
|
|
790
818
|
}).catch((e)=>reject(e));
|
|
791
|
-
}));
|
|
792
|
-
//
|
|
793
|
-
let
|
|
794
|
-
|
|
819
|
+
})));
|
|
820
|
+
// Merge results from all SPARQL servers
|
|
821
|
+
let resources = results.flat();
|
|
822
|
+
// Append selected resources to SPARQL query results
|
|
823
|
+
const selectedResources = await (0, $c83d324c3b433284$export$2e2bcd8739ae039)(containers, resources.map((r)=>r.id), config);
|
|
824
|
+
resources = resources.concat(selectedResources);
|
|
825
|
+
if (resources.length === 0) return {
|
|
795
826
|
data: [],
|
|
796
827
|
total: 0
|
|
797
828
|
};
|
|
798
|
-
// Merge all results in one array
|
|
799
|
-
results = [].concat(...results);
|
|
800
829
|
// Add id in addition to @id, as this is what React-Admin expects
|
|
801
|
-
let returnData =
|
|
830
|
+
let returnData = resources.map((item)=>{
|
|
802
831
|
item.id = item.id || item['@id'];
|
|
803
832
|
return item;
|
|
804
833
|
});
|
|
805
834
|
// TODO sort and paginate the results in the SPARQL query to improve performances
|
|
806
835
|
if (params.sort) returnData = returnData.sort((a, b)=>{
|
|
807
836
|
if (a[params.sort.field] !== undefined && b[params.sort.field] !== undefined) {
|
|
808
|
-
if (params.sort.order === 'ASC') return $
|
|
809
|
-
return $
|
|
837
|
+
if (params.sort.order === 'ASC') return $4aa3fb2e83f6c3a3$var$compare(a[params.sort.field], b[params.sort.field]);
|
|
838
|
+
return $4aa3fb2e83f6c3a3$var$compare(b[params.sort.field], a[params.sort.field]);
|
|
810
839
|
}
|
|
811
840
|
return 0;
|
|
812
841
|
});
|
|
@@ -816,7 +845,7 @@ const $05a1b4063d50f1b7$var$fetchSparqlEndpoints = async (containers, resourceId
|
|
|
816
845
|
total: results.length
|
|
817
846
|
};
|
|
818
847
|
};
|
|
819
|
-
var $
|
|
848
|
+
var $4aa3fb2e83f6c3a3$export$2e2bcd8739ae039 = $4aa3fb2e83f6c3a3$var$fetchSparqlEndpoints;
|
|
820
849
|
|
|
821
850
|
|
|
822
851
|
|
|
@@ -850,15 +879,15 @@ const $1caf729dc3ce856d$var$getListMethod = (config)=>async (resourceId, params)
|
|
|
850
879
|
else // Otherwise find the container URIs on the given servers (either in the filter or the data model)
|
|
851
880
|
containers = (0, $15b841e67a1ba752$export$2e2bcd8739ae039)((0, $cc8adac4b83414eb$export$2e2bcd8739ae039)(dataModel.types), params?.filter?._servers || dataModel.list?.servers, dataServers);
|
|
852
881
|
if (dataModel.list?.fetchContainer) return (0, $aba124ea15ea8bc6$export$2e2bcd8739ae039)(containers, params, config);
|
|
853
|
-
else return (0, $
|
|
882
|
+
else return (0, $4aa3fb2e83f6c3a3$export$2e2bcd8739ae039)(containers, resourceId, params, config);
|
|
854
883
|
};
|
|
855
884
|
var $1caf729dc3ce856d$export$2e2bcd8739ae039 = $1caf729dc3ce856d$var$getListMethod;
|
|
856
885
|
|
|
857
886
|
|
|
858
887
|
|
|
859
|
-
const $
|
|
888
|
+
const $4704ee0f6c5ac80d$var$getManyMethod = (config)=>async (resourceId, params)=>{
|
|
860
889
|
const { returnFailedResources: returnFailedResources } = config;
|
|
861
|
-
let returnData = await Promise.all(params.ids.map((id)=>(0, $
|
|
890
|
+
let returnData = await Promise.all(params.ids.map((id)=>(0, $4861cda99f97e87d$export$2e2bcd8739ae039)(config)(resourceId, {
|
|
862
891
|
id: typeof id === 'object' ? id['@id'] : id
|
|
863
892
|
}).then(({ data: data })=>data).catch(()=>{
|
|
864
893
|
// Catch if one resource fails to load
|
|
@@ -876,19 +905,20 @@ const $f1e05270f9a21255$var$getManyMethod = (config)=>async (resourceId, params)
|
|
|
876
905
|
data: returnData
|
|
877
906
|
};
|
|
878
907
|
};
|
|
879
|
-
var $
|
|
908
|
+
var $4704ee0f6c5ac80d$export$2e2bcd8739ae039 = $4704ee0f6c5ac80d$var$getManyMethod;
|
|
880
909
|
|
|
881
910
|
|
|
882
911
|
|
|
883
|
-
const $
|
|
912
|
+
const $ca9c98aad8d79793$var$getManyReferenceMethod = (config)=>async (resourceId, params)=>{
|
|
884
913
|
params.filter = {
|
|
885
914
|
...params.filter,
|
|
886
915
|
[params.target]: params.id
|
|
887
916
|
};
|
|
917
|
+
// @ts-expect-error ts(2790): The operand of a 'delete' operator must be optional.
|
|
888
918
|
delete params.target;
|
|
889
919
|
return await (0, $1caf729dc3ce856d$export$2e2bcd8739ae039)(config)(resourceId, params);
|
|
890
920
|
};
|
|
891
|
-
var $
|
|
921
|
+
var $ca9c98aad8d79793$export$2e2bcd8739ae039 = $ca9c98aad8d79793$var$getManyReferenceMethod;
|
|
892
922
|
|
|
893
923
|
|
|
894
924
|
|
|
@@ -932,7 +962,7 @@ var $cdfdce6efa87baab$export$2e2bcd8739ae039 = $cdfdce6efa87baab$var$patchMethod
|
|
|
932
962
|
|
|
933
963
|
|
|
934
964
|
// Return the first server matching with the baseUrl
|
|
935
|
-
const $
|
|
965
|
+
const $2ae722513e522d60$var$getServerKeyFromUri = (uri, dataServers)=>{
|
|
936
966
|
if (!uri) throw Error(`No URI provided to getServerKeyFromUri`);
|
|
937
967
|
return dataServers && Object.keys(dataServers).find((key)=>{
|
|
938
968
|
if (dataServers[key].pod) // The baseUrl ends with /data so remove this part to match with the webId and webId-related URLs (/inbox, /outbox...)
|
|
@@ -940,12 +970,12 @@ const $47e21ee81eed09a6$var$getServerKeyFromUri = (uri, dataServers)=>{
|
|
|
940
970
|
return uri.startsWith(dataServers[key].baseUrl);
|
|
941
971
|
});
|
|
942
972
|
};
|
|
943
|
-
var $
|
|
973
|
+
var $2ae722513e522d60$export$2e2bcd8739ae039 = $2ae722513e522d60$var$getServerKeyFromUri;
|
|
944
974
|
|
|
945
975
|
|
|
946
976
|
const $c5031381f4dfc62d$var$updateMethod = (config)=>async (resourceId, params)=>{
|
|
947
977
|
const { httpClient: httpClient, jsonContext: jsonContext, dataServers: dataServers } = config;
|
|
948
|
-
const serverKey = (0, $
|
|
978
|
+
const serverKey = (0, $2ae722513e522d60$export$2e2bcd8739ae039)(params.id, dataServers);
|
|
949
979
|
// Upload files, if there are any
|
|
950
980
|
const { updatedRecord: updatedRecord } = await (0, $b17c43e3301545ca$export$2e2bcd8739ae039).upload(params.data, config, serverKey);
|
|
951
981
|
params.data = updatedRecord;
|
|
@@ -966,40 +996,43 @@ var $c5031381f4dfc62d$export$2e2bcd8739ae039 = $c5031381f4dfc62d$var$updateMetho
|
|
|
966
996
|
|
|
967
997
|
|
|
968
998
|
|
|
969
|
-
|
|
970
|
-
*
|
|
971
|
-
*
|
|
972
|
-
|
|
999
|
+
/**
|
|
1000
|
+
*
|
|
1001
|
+
* @param dataServers Data servers configuration
|
|
1002
|
+
* @param fetchFn The fetch function to use for the actual fetch call, e.g. `fetchUtils.fetchJson` or `fetch`
|
|
1003
|
+
* @returns
|
|
1004
|
+
*/ const $00b6445d7042c29d$var$fetchBase = (dataServers, fetchFn)=>(url, options = {})=>{
|
|
973
1005
|
if (!url) throw new Error(`No URL provided on httpClient call`);
|
|
974
|
-
const authServerKey = (0, $
|
|
975
|
-
const serverKey = (0, $
|
|
976
|
-
const useProxy = serverKey !== authServerKey &&
|
|
977
|
-
|
|
1006
|
+
const authServerKey = (0, $aed10b8332b5d58a$export$2e2bcd8739ae039)('authServer', dataServers);
|
|
1007
|
+
const serverKey = (0, $2ae722513e522d60$export$2e2bcd8739ae039)(url, dataServers);
|
|
1008
|
+
const useProxy = serverKey !== authServerKey && // The server is different from the auth server.
|
|
1009
|
+
!!dataServers[authServerKey]?.proxyUrl && // A proxy URL is configured on the auth server.
|
|
1010
|
+
dataServers[serverKey]?.noProxy !== true; // The server does not explicitly disable the proxy.
|
|
1011
|
+
const headers = new Headers(options.headers);
|
|
978
1012
|
switch(options.method){
|
|
979
1013
|
case 'POST':
|
|
980
1014
|
case 'PATCH':
|
|
981
1015
|
case 'PUT':
|
|
982
|
-
if (!
|
|
983
|
-
if (!
|
|
1016
|
+
if (!headers.has('Accept')) headers.set('Accept', 'application/ld+json');
|
|
1017
|
+
if (!headers.has('Content-Type')) headers.set('Content-Type', 'application/ld+json');
|
|
984
1018
|
break;
|
|
985
1019
|
case 'DELETE':
|
|
986
1020
|
break;
|
|
987
1021
|
case 'GET':
|
|
988
1022
|
default:
|
|
989
|
-
if (!
|
|
1023
|
+
if (!headers.has('Accept')) headers.set('Accept', 'application/ld+json');
|
|
990
1024
|
break;
|
|
991
1025
|
}
|
|
992
1026
|
if (useProxy) {
|
|
1027
|
+
// To the proxy endpoint, we post the URL, method, headers and body (if any) as multipart/form-data.
|
|
993
1028
|
const formData = new FormData();
|
|
994
1029
|
formData.append('id', url);
|
|
995
1030
|
formData.append('method', options.method || 'GET');
|
|
996
|
-
formData.append('headers', JSON.stringify(Object.fromEntries(
|
|
997
|
-
if (options.body)
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
// Post to proxy endpoint with multipart/form-data format
|
|
1002
|
-
return (0, $fj9kP$fetchUtils).fetchJson(dataServers[authServerKey].proxyUrl, {
|
|
1031
|
+
formData.append('headers', JSON.stringify(Object.fromEntries(headers.entries())));
|
|
1032
|
+
if (options.body instanceof File) formData.append('body', options.body, options.body.name);
|
|
1033
|
+
else if (options.body instanceof Blob || typeof options.body === 'string') formData.append('body', options.body);
|
|
1034
|
+
// POST request to proxy endpoint.
|
|
1035
|
+
return fetchFn(dataServers[authServerKey].proxyUrl, {
|
|
1003
1036
|
method: 'POST',
|
|
1004
1037
|
headers: new Headers({
|
|
1005
1038
|
Authorization: `Bearer ${localStorage.getItem('token')}`
|
|
@@ -1007,14 +1040,39 @@ var $c5031381f4dfc62d$export$2e2bcd8739ae039 = $c5031381f4dfc62d$var$updateMetho
|
|
|
1007
1040
|
body: formData
|
|
1008
1041
|
});
|
|
1009
1042
|
}
|
|
1010
|
-
// Add token if the server is the same as the auth server
|
|
1043
|
+
// Add token if the server is the same as the auth server.
|
|
1011
1044
|
if (serverKey === authServerKey) {
|
|
1012
1045
|
const token = localStorage.getItem('token');
|
|
1013
|
-
if (token)
|
|
1046
|
+
if (token) headers.set('Authorization', `Bearer ${token}`);
|
|
1014
1047
|
}
|
|
1015
|
-
|
|
1048
|
+
options.headers = headers;
|
|
1049
|
+
return fetchFn(url, options);
|
|
1016
1050
|
};
|
|
1017
|
-
|
|
1051
|
+
/**
|
|
1052
|
+
* Creates a fetch function that can be used to make calls to the data servers and which returns data formatted as JSON.
|
|
1053
|
+
* It will use the proxy endpoint if available and if the server is different from the auth server.
|
|
1054
|
+
* It will also set the Accept and Content-Type headers to `application/ld+json` for `POST`, `PATCH`, `PUT` and `GET` requests.
|
|
1055
|
+
* @param dataServers Data servers configuration
|
|
1056
|
+
* @returns A function with react-admin's fetchJson signature that can be used to make calls to the data servers.
|
|
1057
|
+
*
|
|
1058
|
+
*/ const $00b6445d7042c29d$export$5ff1805767bd358a = (dataServers)=>{
|
|
1059
|
+
const fetchBaseFn = $00b6445d7042c29d$var$fetchBase(dataServers, (0, $fj9kP$fetchUtils).fetchJson);
|
|
1060
|
+
return (url, options)=>{
|
|
1061
|
+
return fetchBaseFn(url, options);
|
|
1062
|
+
};
|
|
1063
|
+
};
|
|
1064
|
+
/**
|
|
1065
|
+
* Creates an authenticated fetch function that can be used to make calls to the data servers.
|
|
1066
|
+
* It will use the proxy endpoint if available and if the server is different from the auth server.
|
|
1067
|
+
* @param dataServers Data servers configuration
|
|
1068
|
+
* @returns A function that can be used to make authenticated fetch calls.
|
|
1069
|
+
*/ const $00b6445d7042c29d$export$1ac69e0fa5b5498b = (dataServers)=>{
|
|
1070
|
+
const fetchBaseFn = $00b6445d7042c29d$var$fetchBase(dataServers, fetch);
|
|
1071
|
+
const fetchFunction = (url, options)=>{
|
|
1072
|
+
return fetchBaseFn(url, options);
|
|
1073
|
+
};
|
|
1074
|
+
return fetchFunction;
|
|
1075
|
+
};
|
|
1018
1076
|
|
|
1019
1077
|
|
|
1020
1078
|
|
|
@@ -1080,7 +1138,10 @@ const $ab7d38fd091ff1b6$var$getTypesFromShapeTree = async (shapeTreeUri)=>{
|
|
|
1080
1138
|
var $ab7d38fd091ff1b6$export$2e2bcd8739ae039 = $ab7d38fd091ff1b6$var$getTypesFromShapeTree;
|
|
1081
1139
|
|
|
1082
1140
|
|
|
1083
|
-
|
|
1141
|
+
/**
|
|
1142
|
+
* For data server containers, expands types and adds `uri` and `server` properties.
|
|
1143
|
+
* For resources, expands types (if applicable from shape tree information).
|
|
1144
|
+
*/ const $33bf2a661b5c0cbd$var$normalizeConfig = async (config)=>{
|
|
1084
1145
|
const newConfig = {
|
|
1085
1146
|
...config
|
|
1086
1147
|
};
|
|
@@ -1132,64 +1193,89 @@ const $143de1c1f21344e7$var$getOntologiesFromContext = async (context)=>{
|
|
|
1132
1193
|
var $143de1c1f21344e7$export$2e2bcd8739ae039 = $143de1c1f21344e7$var$getOntologiesFromContext;
|
|
1133
1194
|
|
|
1134
1195
|
|
|
1135
|
-
|
|
1196
|
+
const $9808be090468fc68$var$dataProvider = (originalConfig)=>{
|
|
1136
1197
|
// Keep in memory for refresh
|
|
1137
|
-
let config
|
|
1138
|
-
...originalConfig
|
|
1139
|
-
};
|
|
1198
|
+
let config;
|
|
1140
1199
|
const prepareConfig = async ()=>{
|
|
1200
|
+
const fetchJson = (0, $00b6445d7042c29d$export$5ff1805767bd358a)(originalConfig.dataServers);
|
|
1201
|
+
const authFetchFn = (0, $00b6445d7042c29d$export$1ac69e0fa5b5498b)(originalConfig.dataServers);
|
|
1202
|
+
const dataset = (0, $fj9kP$createConnectedLdoDataset)([
|
|
1203
|
+
(0, $fj9kP$solidConnectedPlugin)
|
|
1204
|
+
]);
|
|
1205
|
+
dataset.setContext('solid', {
|
|
1206
|
+
fetch: authFetchFn
|
|
1207
|
+
});
|
|
1208
|
+
config = {
|
|
1209
|
+
...originalConfig,
|
|
1210
|
+
httpClient: fetchJson,
|
|
1211
|
+
authFetch: authFetchFn,
|
|
1212
|
+
dataset: dataset
|
|
1213
|
+
};
|
|
1141
1214
|
config.dataServers ??= {};
|
|
1142
|
-
//
|
|
1143
|
-
|
|
1144
|
-
|
|
1215
|
+
// Load plugins.
|
|
1216
|
+
for (const plugin of config.plugins){
|
|
1217
|
+
if (plugin.transformConfig) try {
|
|
1218
|
+
config = await plugin.transformConfig(config);
|
|
1219
|
+
} catch (error) {
|
|
1220
|
+
console.error('Error setting up data provider plugin', plugin.name, error);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
// Configure httpClient & authFetch again with possibly updated data servers
|
|
1224
|
+
config.httpClient = (0, $00b6445d7042c29d$export$5ff1805767bd358a)(config.dataServers);
|
|
1225
|
+
config.authFetch = (0, $00b6445d7042c29d$export$1ac69e0fa5b5498b)(config.dataServers);
|
|
1226
|
+
dataset.setContext('solid', {
|
|
1227
|
+
fetch: config.authFetch
|
|
1228
|
+
});
|
|
1229
|
+
// Create the LDO dataset with the solidConnectedPlugin. It will be used to manage the RDF data.
|
|
1230
|
+
config.dataset = dataset;
|
|
1231
|
+
// Useful for debugging: Attach httpClient & authFetch to global document.
|
|
1232
|
+
// @ts-expect-error TS(2339)
|
|
1145
1233
|
document.httpClient = config.httpClient;
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
config.httpClient = (0, $22b4895a4ca7d626$export$2e2bcd8739ae039)(config.dataServers);
|
|
1234
|
+
// @ts-expect-error TS(2339)
|
|
1235
|
+
document.authFetch = authFetchFn;
|
|
1149
1236
|
if (!config.ontologies && config.jsonContext) config.ontologies = await (0, $143de1c1f21344e7$export$2e2bcd8739ae039)(config.jsonContext);
|
|
1150
1237
|
else if (!config.jsonContext && config.ontologies) config.jsonContext = config.ontologies;
|
|
1151
1238
|
else if (!config.jsonContext && !config.ontologies) throw new Error(`Either the JSON context or the ontologies must be set`);
|
|
1152
1239
|
if (!config.returnFailedResources) config.returnFailedResources = false;
|
|
1153
1240
|
config = await (0, $33bf2a661b5c0cbd$export$2e2bcd8739ae039)(config);
|
|
1154
|
-
console.
|
|
1241
|
+
console.debug('Config after plugins', config);
|
|
1155
1242
|
};
|
|
1156
1243
|
// Immediately call the preload plugins
|
|
1157
1244
|
const prepareConfigPromise = prepareConfig();
|
|
1158
|
-
const waitForPrepareConfig = (method)=>async (...
|
|
1245
|
+
const waitForPrepareConfig = (method)=>async (...args)=>{
|
|
1159
1246
|
await prepareConfigPromise; // Return immediately if plugins have already been loaded
|
|
1160
|
-
return method(config)(...
|
|
1247
|
+
return method(config)(...args);
|
|
1161
1248
|
};
|
|
1162
1249
|
return {
|
|
1163
1250
|
getList: waitForPrepareConfig((0, $1caf729dc3ce856d$export$2e2bcd8739ae039)),
|
|
1164
|
-
getMany: waitForPrepareConfig((0, $
|
|
1165
|
-
getManyReference: waitForPrepareConfig((0, $
|
|
1166
|
-
getOne: waitForPrepareConfig((0, $
|
|
1167
|
-
create: waitForPrepareConfig((0, $
|
|
1251
|
+
getMany: waitForPrepareConfig((0, $4704ee0f6c5ac80d$export$2e2bcd8739ae039)),
|
|
1252
|
+
getManyReference: waitForPrepareConfig((0, $ca9c98aad8d79793$export$2e2bcd8739ae039)),
|
|
1253
|
+
getOne: waitForPrepareConfig((0, $4861cda99f97e87d$export$2e2bcd8739ae039)),
|
|
1254
|
+
create: waitForPrepareConfig((0, $d12d4cfb47175317$export$2e2bcd8739ae039)),
|
|
1168
1255
|
update: waitForPrepareConfig((0, $c5031381f4dfc62d$export$2e2bcd8739ae039)),
|
|
1169
1256
|
updateMany: ()=>{
|
|
1170
1257
|
throw new Error('updateMany is not implemented yet');
|
|
1171
1258
|
},
|
|
1172
1259
|
delete: waitForPrepareConfig((0, $9510970b8e7eb9e2$export$2e2bcd8739ae039)),
|
|
1173
|
-
deleteMany: waitForPrepareConfig((0, $
|
|
1260
|
+
deleteMany: waitForPrepareConfig((0, $9b978ac85d859b57$export$2e2bcd8739ae039)),
|
|
1174
1261
|
// Custom methods
|
|
1175
1262
|
patch: waitForPrepareConfig((0, $cdfdce6efa87baab$export$2e2bcd8739ae039)),
|
|
1176
|
-
getDataModels: waitForPrepareConfig((0, $
|
|
1177
|
-
getDataServers: waitForPrepareConfig((0, $
|
|
1178
|
-
getLocalDataServers: (0, $
|
|
1179
|
-
fetch: waitForPrepareConfig((c)=>(0, $
|
|
1263
|
+
getDataModels: waitForPrepareConfig((0, $52333268224773ef$export$2e2bcd8739ae039)),
|
|
1264
|
+
getDataServers: waitForPrepareConfig((0, $294fdd580f2e7246$export$2e2bcd8739ae039)),
|
|
1265
|
+
getLocalDataServers: (0, $294fdd580f2e7246$export$2e2bcd8739ae039)(originalConfig),
|
|
1266
|
+
fetch: waitForPrepareConfig((c)=>(0, $00b6445d7042c29d$export$5ff1805767bd358a)(c.dataServers)),
|
|
1267
|
+
authFetch: waitForPrepareConfig((c)=>(0, $00b6445d7042c29d$export$1ac69e0fa5b5498b)(c.dataServers)),
|
|
1268
|
+
getDataset: waitForPrepareConfig((c)=>()=>c.dataset),
|
|
1180
1269
|
uploadFile: waitForPrepareConfig((c)=>(rawFile)=>(0, $b17c43e3301545ca$export$a5575dbeeffdad98)(rawFile, c)),
|
|
1181
1270
|
expandTypes: waitForPrepareConfig((c)=>(types)=>(0, $36aa010ec46eaf45$export$2e2bcd8739ae039)(types, c.jsonContext)),
|
|
1182
1271
|
getConfig: waitForPrepareConfig((c)=>()=>c),
|
|
1183
1272
|
refreshConfig: async ()=>{
|
|
1184
|
-
config = {
|
|
1185
|
-
...originalConfig
|
|
1186
|
-
};
|
|
1187
1273
|
await prepareConfig();
|
|
1188
1274
|
return config;
|
|
1189
1275
|
}
|
|
1190
1276
|
};
|
|
1191
1277
|
};
|
|
1192
|
-
var $
|
|
1278
|
+
var $9808be090468fc68$export$2e2bcd8739ae039 = $9808be090468fc68$var$dataProvider;
|
|
1193
1279
|
|
|
1194
1280
|
|
|
1195
1281
|
|
|
@@ -1206,7 +1292,10 @@ var $861da9be2c0e62eb$export$2e2bcd8739ae039 = $861da9be2c0e62eb$var$getPrefixFr
|
|
|
1206
1292
|
|
|
1207
1293
|
|
|
1208
1294
|
|
|
1209
|
-
|
|
1295
|
+
/**
|
|
1296
|
+
* Adds `dataServers.user` properties to configuration (baseUrl, sparqlEndpoint, proxyUrl, ...).
|
|
1297
|
+
*/ const $cdd3c71a628eeefe$var$configureUserStorage = ()=>({
|
|
1298
|
+
name: 'configureUserStorage',
|
|
1210
1299
|
transformConfig: async (config)=>{
|
|
1211
1300
|
const token = localStorage.getItem('token');
|
|
1212
1301
|
// If the user is logged in
|
|
@@ -1218,7 +1307,7 @@ const $cdd3c71a628eeefe$var$configureUserStorage = ()=>({
|
|
|
1218
1307
|
const newConfig = {
|
|
1219
1308
|
...config
|
|
1220
1309
|
};
|
|
1221
|
-
newConfig.dataServers
|
|
1310
|
+
newConfig.dataServers[webId] = {
|
|
1222
1311
|
pod: true,
|
|
1223
1312
|
default: true,
|
|
1224
1313
|
authServer: true,
|
|
@@ -1246,6 +1335,7 @@ var $cdd3c71a628eeefe$export$2e2bcd8739ae039 = $cdd3c71a628eeefe$var$configureUs
|
|
|
1246
1335
|
|
|
1247
1336
|
|
|
1248
1337
|
|
|
1338
|
+
|
|
1249
1339
|
const $d7a7484a035f15cd$var$getContainerFromDataRegistration = async (dataRegistrationUri, config)=>{
|
|
1250
1340
|
const { json: dataRegistration } = await config.httpClient(dataRegistrationUri, {
|
|
1251
1341
|
headers: new Headers({
|
|
@@ -1279,7 +1369,8 @@ const $d7a7484a035f15cd$var$getContainerFromDataRegistration = async (dataRegist
|
|
|
1279
1369
|
'@container': '@language'
|
|
1280
1370
|
}
|
|
1281
1371
|
});
|
|
1282
|
-
const
|
|
1372
|
+
const userStorage = (0, $aed10b8332b5d58a$export$2e2bcd8739ae039)('default', config.dataServers);
|
|
1373
|
+
const { baseUrl: baseUrl } = config.dataServers[userStorage];
|
|
1283
1374
|
const containerPath = dataRegistration.id.replace(baseUrl, '');
|
|
1284
1375
|
const container = {
|
|
1285
1376
|
path: containerPath,
|
|
@@ -1305,7 +1396,10 @@ var $d7a7484a035f15cd$export$2e2bcd8739ae039 = $d7a7484a035f15cd$var$getContaine
|
|
|
1305
1396
|
* Return a function that look if an app (clientId) is registered with an user (webId)
|
|
1306
1397
|
* If not, it redirects to the endpoint provided by the user's authorization agent
|
|
1307
1398
|
* See https://solid.github.io/data-interoperability-panel/specification/#authorization-agent
|
|
1308
|
-
*/ const $2c257b4237cb14ca$var$fetchAppRegistration = ()=>
|
|
1399
|
+
*/ const $2c257b4237cb14ca$var$fetchAppRegistration = (pluginConfig = {})=>{
|
|
1400
|
+
const { includeSelectedResources: includeSelectedResources = true } = pluginConfig;
|
|
1401
|
+
return {
|
|
1402
|
+
name: 'fetchAppRegistration',
|
|
1309
1403
|
transformConfig: async (config)=>{
|
|
1310
1404
|
const token = localStorage.getItem('token');
|
|
1311
1405
|
// If the user is logged in
|
|
@@ -1327,15 +1421,27 @@ var $d7a7484a035f15cd$export$2e2bcd8739ae039 = $d7a7484a035f15cd$var$getContaine
|
|
|
1327
1421
|
const newConfig = {
|
|
1328
1422
|
...config
|
|
1329
1423
|
};
|
|
1330
|
-
// Load
|
|
1424
|
+
// Load access grants concurrently to improve performances
|
|
1331
1425
|
const results = await Promise.all((0, $cc8adac4b83414eb$export$2e2bcd8739ae039)(appRegistration['interop:hasAccessGrant']).map(async (accessGrantUri)=>{
|
|
1332
1426
|
const { json: accessGrant } = await config.httpClient(accessGrantUri);
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1427
|
+
const container = await (0, $d7a7484a035f15cd$export$2e2bcd8739ae039)(accessGrant['interop:hasDataRegistration'], config);
|
|
1428
|
+
container.server = accessGrant['interop:dataOwner'];
|
|
1429
|
+
if (accessGrant['interop:scopeOfGrant'] === 'interop:AllFromRegistry') return container;
|
|
1430
|
+
else if (accessGrant['interop:scopeOfGrant'] === 'interop:SelectedFromRegistry') {
|
|
1431
|
+
if (!includeSelectedResources) return undefined;
|
|
1432
|
+
container.selectedResources = (0, $cc8adac4b83414eb$export$2e2bcd8739ae039)(accessGrant['interop:hasDataInstance']);
|
|
1433
|
+
return container;
|
|
1434
|
+
}
|
|
1337
1435
|
}));
|
|
1338
|
-
|
|
1436
|
+
// Put data shared by other users in other servers (storages)
|
|
1437
|
+
for (const container of results.flat().filter((i)=>i !== undefined))if (!newConfig.dataServers[container.server]) newConfig.dataServers[container.server] = {
|
|
1438
|
+
pod: true,
|
|
1439
|
+
baseUrl: `${container.server}/data`,
|
|
1440
|
+
containers: [
|
|
1441
|
+
container
|
|
1442
|
+
]
|
|
1443
|
+
};
|
|
1444
|
+
else newConfig.dataServers[container.server].containers.push(container);
|
|
1339
1445
|
return newConfig;
|
|
1340
1446
|
}
|
|
1341
1447
|
}
|
|
@@ -1343,22 +1449,32 @@ var $d7a7484a035f15cd$export$2e2bcd8739ae039 = $d7a7484a035f15cd$var$getContaine
|
|
|
1343
1449
|
}
|
|
1344
1450
|
return config;
|
|
1345
1451
|
}
|
|
1346
|
-
}
|
|
1452
|
+
};
|
|
1453
|
+
};
|
|
1347
1454
|
var $2c257b4237cb14ca$export$2e2bcd8739ae039 = $2c257b4237cb14ca$var$fetchAppRegistration;
|
|
1348
1455
|
|
|
1349
1456
|
|
|
1350
1457
|
|
|
1351
1458
|
|
|
1352
|
-
|
|
1459
|
+
/**
|
|
1460
|
+
* Plugin to add data registrations to the user containers, by fetching the registry set.
|
|
1461
|
+
*
|
|
1462
|
+
* Requires the `configureUserStorage` plugin.
|
|
1463
|
+
*
|
|
1464
|
+
* @returns {Configuration} The configuration with the data registrations added to `dataServers.user.containers`
|
|
1465
|
+
*/ const $91255e144bb55afc$var$fetchDataRegistry = ()=>({
|
|
1466
|
+
name: 'fetchDataRegistry',
|
|
1353
1467
|
transformConfig: async (config)=>{
|
|
1354
1468
|
const token = localStorage.getItem('token');
|
|
1355
1469
|
// If the user is logged in
|
|
1356
1470
|
if (token) {
|
|
1357
|
-
if (!config.dataServers.user) throw new Error(`You must configure the user storage first with the configureUserStorage plugin`);
|
|
1358
1471
|
const payload = (0, $fj9kP$jwtdecode)(token);
|
|
1359
1472
|
const webId = payload.webId || payload.webid; // Currently we must deal with both formats
|
|
1473
|
+
if (!config.dataServers[webId]) throw new Error(`You must configure the user storage first with the configureUserStorage plugin`);
|
|
1360
1474
|
const { json: user } = await config.httpClient(webId);
|
|
1475
|
+
if (!user['interop:hasRegistrySet']) throw new Error(`User ${webId} is missing interop:hasRegistrySet`);
|
|
1361
1476
|
const { json: registrySet } = await config.httpClient(user['interop:hasRegistrySet']);
|
|
1477
|
+
if (!registrySet['interop:hasDataRegistry']) throw new Error(`User ${webId} is missing interop:hasDataRegistry`);
|
|
1362
1478
|
const { json: dataRegistry } = await config.httpClient(registrySet['interop:hasDataRegistry']);
|
|
1363
1479
|
if (dataRegistry['interop:hasDataRegistration']) {
|
|
1364
1480
|
const results = await Promise.all(dataRegistry['interop:hasDataRegistration'].map((dataRegistrationUri)=>{
|
|
@@ -1367,7 +1483,7 @@ const $91255e144bb55afc$var$fetchDataRegistry = ()=>({
|
|
|
1367
1483
|
const newConfig = {
|
|
1368
1484
|
...config
|
|
1369
1485
|
};
|
|
1370
|
-
newConfig.dataServers.
|
|
1486
|
+
newConfig.dataServers[webId].containers?.push(...results.flat());
|
|
1371
1487
|
return newConfig;
|
|
1372
1488
|
}
|
|
1373
1489
|
}
|
|
@@ -1382,14 +1498,21 @@ var $91255e144bb55afc$export$2e2bcd8739ae039 = $91255e144bb55afc$var$fetchDataRe
|
|
|
1382
1498
|
|
|
1383
1499
|
|
|
1384
1500
|
|
|
1385
|
-
|
|
1501
|
+
/**
|
|
1502
|
+
* Plugin to add type indexes to the user containers, by fetching the them.
|
|
1503
|
+
*
|
|
1504
|
+
* Requires the `configureUserStorage` plugin.
|
|
1505
|
+
*
|
|
1506
|
+
* @returns {Configuration} The configuration with the data registrations added to `dataServers.user.containers`
|
|
1507
|
+
*/ const $2d5f75df63129ebc$var$fetchTypeIndexes = ()=>({
|
|
1508
|
+
name: 'fetchTypeIndexes',
|
|
1386
1509
|
transformConfig: async (config)=>{
|
|
1387
1510
|
const token = localStorage.getItem('token');
|
|
1388
1511
|
// If the user is logged in
|
|
1389
1512
|
if (token) {
|
|
1390
|
-
if (!config.dataServers.user) throw new Error(`You must configure the user storage first with the configureUserStorage plugin`);
|
|
1391
1513
|
const payload = (0, $fj9kP$jwtdecode)(token);
|
|
1392
1514
|
const webId = payload.webId || payload.webid; // Currently we must deal with both formats
|
|
1515
|
+
if (!config.dataServers[webId]) throw new Error(`You must configure the user storage first with the configureUserStorage plugin`);
|
|
1393
1516
|
const { json: user } = await config.httpClient(webId);
|
|
1394
1517
|
const typeRegistrations = {
|
|
1395
1518
|
public: [],
|
|
@@ -1418,17 +1541,17 @@ const $2d5f75df63129ebc$var$fetchTypeIndexes = ()=>({
|
|
|
1418
1541
|
separateNumbers: true
|
|
1419
1542
|
})
|
|
1420
1543
|
},
|
|
1421
|
-
path: typeRegistration['solid:instanceContainer'].replace(newConfig.dataServers.
|
|
1544
|
+
path: typeRegistration['solid:instanceContainer'].replace(newConfig.dataServers[webId].baseUrl, ''),
|
|
1422
1545
|
types: await (0, $36aa010ec46eaf45$export$2e2bcd8739ae039)(types, user['@context']),
|
|
1423
1546
|
private: mode === 'private'
|
|
1424
1547
|
};
|
|
1425
|
-
const containerIndex = newConfig.dataServers.
|
|
1548
|
+
const containerIndex = newConfig.dataServers[webId].containers.findIndex((c)=>c.path === container.path);
|
|
1426
1549
|
if (containerIndex !== -1) // If a container with this URI already exist, add type registration information if they are not set
|
|
1427
|
-
newConfig.dataServers.
|
|
1550
|
+
newConfig.dataServers[webId].containers[containerIndex] = {
|
|
1428
1551
|
...container,
|
|
1429
|
-
...newConfig.dataServers.
|
|
1552
|
+
...newConfig.dataServers[webId].containers[containerIndex]
|
|
1430
1553
|
};
|
|
1431
|
-
else newConfig.dataServers.
|
|
1554
|
+
else newConfig.dataServers[webId].containers.push(container);
|
|
1432
1555
|
}
|
|
1433
1556
|
return newConfig;
|
|
1434
1557
|
}
|
|
@@ -1442,6 +1565,7 @@ var $2d5f75df63129ebc$export$2e2bcd8739ae039 = $2d5f75df63129ebc$var$fetchTypeIn
|
|
|
1442
1565
|
|
|
1443
1566
|
|
|
1444
1567
|
const $a87fd63d8fca0380$var$fetchVoidEndpoints = ()=>({
|
|
1568
|
+
name: 'fetchVoidEndpoints',
|
|
1445
1569
|
transformConfig: async (config)=>{
|
|
1446
1570
|
let results = [];
|
|
1447
1571
|
try {
|
|
@@ -1670,12 +1794,12 @@ const $8dbb0c8c3814e663$var$useGetCreateContainerUri = ()=>{
|
|
|
1670
1794
|
const dataModels = (0, $3a9656756670cb78$export$2e2bcd8739ae039)();
|
|
1671
1795
|
const dataServers = (0, $4daf4cf698ee4eed$export$2e2bcd8739ae039)();
|
|
1672
1796
|
const getCreateContainerUri = (0, $fj9kP$useCallback)((resourceId)=>{
|
|
1673
|
-
if (!dataModels || !dataServers || !dataModels[resourceId]) return undefined;
|
|
1797
|
+
if (!resourceId || !dataModels || !dataServers || !dataModels[resourceId]) return undefined;
|
|
1674
1798
|
const dataModel = dataModels[resourceId];
|
|
1675
1799
|
if (dataModel.create?.container) return dataModel.create.container;
|
|
1676
1800
|
else if (dataModel.create?.server) return (0, $7d9911a250866af6$export$2e2bcd8739ae039)(dataModel.types, dataModel.create.server, dataServers);
|
|
1677
1801
|
else {
|
|
1678
|
-
const defaultServerKey = (0, $
|
|
1802
|
+
const defaultServerKey = (0, $aed10b8332b5d58a$export$2e2bcd8739ae039)('default', dataServers);
|
|
1679
1803
|
if (!defaultServerKey) throw new Error(`No default dataServer found. You can set explicitly one setting the "default" attribute to true`);
|
|
1680
1804
|
return (0, $7d9911a250866af6$export$2e2bcd8739ae039)(dataModel.types, defaultServerKey, dataServers);
|
|
1681
1805
|
}
|
|
@@ -1713,16 +1837,19 @@ var $e5a0eacd756fd1d5$export$2e2bcd8739ae039 = $e5a0eacd756fd1d5$var$useDataMode
|
|
|
1713
1837
|
|
|
1714
1838
|
|
|
1715
1839
|
|
|
1716
|
-
const $
|
|
1717
|
-
const $
|
|
1718
|
-
const $
|
|
1840
|
+
const $0c5cccc31d3b196d$var$compute = (externalLinks, record)=>typeof externalLinks === 'function' ? externalLinks(record) : externalLinks;
|
|
1841
|
+
const $0c5cccc31d3b196d$var$isURL = (url)=>typeof url === 'string' && url.startsWith('http');
|
|
1842
|
+
const $0c5cccc31d3b196d$var$useGetExternalLink = (componentExternalLinks)=>{
|
|
1719
1843
|
// Since the externalLinks config is defined only locally, we don't need to wait for VOID endpoints fetching
|
|
1720
1844
|
const dataProvider = (0, $fj9kP$useContext)((0, $fj9kP$DataProviderContext));
|
|
1845
|
+
// @ts-expect-error TS(2531): Object is possibly 'null'.
|
|
1721
1846
|
const dataServers = dataProvider.getLocalDataServers();
|
|
1722
1847
|
const serversExternalLinks = (0, $fj9kP$useMemo)(()=>{
|
|
1723
1848
|
if (dataServers) return Object.fromEntries(Object.values(dataServers).map((server)=>{
|
|
1724
1849
|
// If externalLinks is not defined in the data server, use external links for non-default servers
|
|
1850
|
+
// @ts-expect-error TS(2571): Object is of type 'unknown'.
|
|
1725
1851
|
const externalLinks = server.externalLinks !== undefined ? server.externalLinks : !server.default;
|
|
1852
|
+
// @ts-expect-error TS(2571): Object is of type 'unknown'.
|
|
1726
1853
|
return [
|
|
1727
1854
|
server.baseUrl,
|
|
1728
1855
|
externalLinks
|
|
@@ -1732,25 +1859,25 @@ const $87656edf926c0f1f$var$useGetExternalLink = (componentExternalLinks)=>{
|
|
|
1732
1859
|
dataServers
|
|
1733
1860
|
]);
|
|
1734
1861
|
return (0, $fj9kP$useCallback)((record)=>{
|
|
1735
|
-
const computedComponentExternalLinks = $
|
|
1862
|
+
const computedComponentExternalLinks = $0c5cccc31d3b196d$var$compute(componentExternalLinks, record);
|
|
1736
1863
|
// If the component explicitly asks not to display as external links, use an internal link
|
|
1737
1864
|
if (computedComponentExternalLinks === false) return false;
|
|
1738
1865
|
if (!record?.id) return false;
|
|
1739
1866
|
const serverBaseUrl = Object.keys(serversExternalLinks).find((baseUrl)=>record?.id.startsWith(baseUrl));
|
|
1740
1867
|
// If no matching data servers could be found, assume we have an internal link
|
|
1741
1868
|
if (!serverBaseUrl) return false;
|
|
1742
|
-
const computedServerExternalLinks = $
|
|
1869
|
+
const computedServerExternalLinks = $0c5cccc31d3b196d$var$compute(serversExternalLinks[serverBaseUrl], record);
|
|
1743
1870
|
// If the data server explicitly asks not to display as external links, use an internal link
|
|
1744
1871
|
if (computedServerExternalLinks === false) return false;
|
|
1745
|
-
if ($
|
|
1746
|
-
if ($
|
|
1872
|
+
if ($0c5cccc31d3b196d$var$isURL(computedComponentExternalLinks)) return computedComponentExternalLinks;
|
|
1873
|
+
if ($0c5cccc31d3b196d$var$isURL(computedServerExternalLinks)) return computedServerExternalLinks;
|
|
1747
1874
|
return record.id;
|
|
1748
1875
|
}, [
|
|
1749
1876
|
serversExternalLinks,
|
|
1750
1877
|
componentExternalLinks
|
|
1751
1878
|
]);
|
|
1752
1879
|
};
|
|
1753
|
-
var $
|
|
1880
|
+
var $0c5cccc31d3b196d$export$2e2bcd8739ae039 = $0c5cccc31d3b196d$var$useGetExternalLink;
|
|
1754
1881
|
|
|
1755
1882
|
|
|
1756
1883
|
|
|
@@ -1780,7 +1907,7 @@ var $487567a146508c4e$export$2e2bcd8739ae039 = $487567a146508c4e$var$useGetPrefi
|
|
|
1780
1907
|
* </SingleFieldList>
|
|
1781
1908
|
* </FilterHandler>
|
|
1782
1909
|
* </Show>
|
|
1783
|
-
*/ const $
|
|
1910
|
+
*/ const $d8039fd362ad4925$var$FilterHandler = ({ children: children, record: record, filter: filter, source: source, ...otherProps })=>{
|
|
1784
1911
|
const [filtered, setFiltered] = (0, $fj9kP$useState)();
|
|
1785
1912
|
(0, $fj9kP$useEffect)(()=>{
|
|
1786
1913
|
if (record && source && Array.isArray(record?.[source])) {
|
|
@@ -1816,7 +1943,7 @@ var $487567a146508c4e$export$2e2bcd8739ae039 = $487567a146508c4e$var$useGetPrefi
|
|
|
1816
1943
|
})
|
|
1817
1944
|
});
|
|
1818
1945
|
};
|
|
1819
|
-
var $
|
|
1946
|
+
var $d8039fd362ad4925$export$2e2bcd8739ae039 = $d8039fd362ad4925$var$FilterHandler;
|
|
1820
1947
|
|
|
1821
1948
|
|
|
1822
1949
|
|
|
@@ -1883,12 +2010,13 @@ var $406574efa35ec6f1$export$2e2bcd8739ae039 = $406574efa35ec6f1$var$FilterHandl
|
|
|
1883
2010
|
* </GroupedReferenceHandler>
|
|
1884
2011
|
*
|
|
1885
2012
|
*
|
|
1886
|
-
*/ const $
|
|
2013
|
+
*/ const $207a50667fa8cffa$var$GroupedReferenceHandler = ({ children: children, groupReference: groupReference, groupLabel: groupLabel, groupHeader: groupHeader, filterProperty: filterProperty, ...otherProps })=>{
|
|
1887
2014
|
const record = (0, $fj9kP$useRecordContext)();
|
|
1888
2015
|
const { data: data } = (0, $fj9kP$useGetList)(groupReference);
|
|
1889
2016
|
return /*#__PURE__*/ (0, $fj9kP$jsx)((0, $fj9kP$Fragment), {
|
|
1890
2017
|
children: data?.map((data, index)=>{
|
|
1891
2018
|
const filter = {};
|
|
2019
|
+
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
1892
2020
|
filter[filterProperty] = data.id;
|
|
1893
2021
|
return /*#__PURE__*/ (0, $fj9kP$jsxs)((0, $fj9kP$Fragment), {
|
|
1894
2022
|
children: [
|
|
@@ -1896,7 +2024,7 @@ var $406574efa35ec6f1$export$2e2bcd8739ae039 = $406574efa35ec6f1$var$FilterHandl
|
|
|
1896
2024
|
...otherProps,
|
|
1897
2025
|
group: data
|
|
1898
2026
|
}),
|
|
1899
|
-
/*#__PURE__*/ (0, $fj9kP$jsx)((0, $
|
|
2027
|
+
/*#__PURE__*/ (0, $fj9kP$jsx)((0, $d8039fd362ad4925$export$2e2bcd8739ae039), {
|
|
1900
2028
|
...otherProps,
|
|
1901
2029
|
record: record,
|
|
1902
2030
|
filter: filter,
|
|
@@ -1908,14 +2036,14 @@ var $406574efa35ec6f1$export$2e2bcd8739ae039 = $406574efa35ec6f1$var$FilterHandl
|
|
|
1908
2036
|
})
|
|
1909
2037
|
});
|
|
1910
2038
|
};
|
|
1911
|
-
var $
|
|
2039
|
+
var $207a50667fa8cffa$export$2e2bcd8739ae039 = $207a50667fa8cffa$var$GroupedReferenceHandler;
|
|
1912
2040
|
|
|
1913
2041
|
|
|
1914
2042
|
|
|
1915
2043
|
|
|
1916
2044
|
|
|
1917
2045
|
|
|
1918
|
-
const $
|
|
2046
|
+
const $1a24ef5e038900c4$var$useReferenceInputStyles = (0, $fj9kP$makeStyles)()({
|
|
1919
2047
|
form: {
|
|
1920
2048
|
display: 'flex'
|
|
1921
2049
|
},
|
|
@@ -1923,18 +2051,19 @@ const $6844bbce0ad66151$var$useReferenceInputStyles = (0, $fj9kP$muistylesmakeSt
|
|
|
1923
2051
|
paddingRight: '20px'
|
|
1924
2052
|
}
|
|
1925
2053
|
});
|
|
1926
|
-
const $
|
|
2054
|
+
const $1a24ef5e038900c4$var$useHideInputStyles = (0, $fj9kP$makeStyles)()({
|
|
1927
2055
|
root: {
|
|
1928
2056
|
display: 'none'
|
|
1929
2057
|
}
|
|
1930
2058
|
});
|
|
1931
|
-
const $
|
|
2059
|
+
const $1a24ef5e038900c4$var$ReificationArrayInput = (props)=>{
|
|
1932
2060
|
const { reificationClass: reificationClass, children: children, ...otherProps } = props;
|
|
1933
|
-
const flexFormClasses = $
|
|
1934
|
-
const hideInputStyles = $
|
|
2061
|
+
const { classes: flexFormClasses } = $1a24ef5e038900c4$var$useReferenceInputStyles();
|
|
2062
|
+
const { classes: hideInputStyles } = $1a24ef5e038900c4$var$useHideInputStyles();
|
|
1935
2063
|
return /*#__PURE__*/ (0, $fj9kP$jsx)((0, $fj9kP$ArrayInput), {
|
|
1936
2064
|
...otherProps,
|
|
1937
2065
|
children: /*#__PURE__*/ (0, $fj9kP$jsxs)((0, $fj9kP$SimpleFormIterator), {
|
|
2066
|
+
// @ts-expect-error TS(2322): Type '{ children: any[]; classes: { form: any; }; ... Remove this comment to see the full error message
|
|
1938
2067
|
classes: {
|
|
1939
2068
|
form: flexFormClasses.form
|
|
1940
2069
|
},
|
|
@@ -1947,13 +2076,14 @@ const $6844bbce0ad66151$var$ReificationArrayInput = (props)=>{
|
|
|
1947
2076
|
/*#__PURE__*/ (0, $fj9kP$jsx)((0, $fj9kP$TextInput), {
|
|
1948
2077
|
className: hideInputStyles.root,
|
|
1949
2078
|
source: "type",
|
|
2079
|
+
// @ts-expect-error TS(2322): Type '{ className: any; source: string; initialVal... Remove this comment to see the full error message
|
|
1950
2080
|
initialValue: reificationClass
|
|
1951
2081
|
})
|
|
1952
2082
|
]
|
|
1953
2083
|
})
|
|
1954
2084
|
});
|
|
1955
2085
|
};
|
|
1956
|
-
var $
|
|
2086
|
+
var $1a24ef5e038900c4$export$2e2bcd8739ae039 = $1a24ef5e038900c4$var$ReificationArrayInput;
|
|
1957
2087
|
|
|
1958
2088
|
|
|
1959
2089
|
|
|
@@ -2057,8 +2187,10 @@ const $03d52e691e8dc945$var$registeredWebSockets = new Map();
|
|
|
2057
2187
|
};
|
|
2058
2188
|
|
|
2059
2189
|
|
|
2190
|
+
var $11242e90250f263e$exports = {};
|
|
2191
|
+
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
2060
2192
|
|
|
2061
2193
|
|
|
2062
2194
|
|
|
2063
|
-
export {$
|
|
2195
|
+
export {$9808be090468fc68$export$2e2bcd8739ae039 as dataProvider, $dcde11998342d30d$export$2e2bcd8739ae039 as buildSparqlQuery, $8ad7b5ebbca2bb3e$export$2e2bcd8739ae039 as buildBlankNodesQuery, $4872a1c30c1fc60e$export$2e2bcd8739ae039 as getUriFromPrefix, $861da9be2c0e62eb$export$2e2bcd8739ae039 as getPrefixFromUri, $cdd3c71a628eeefe$export$2e2bcd8739ae039 as configureUserStorage, $2c257b4237cb14ca$export$2e2bcd8739ae039 as fetchAppRegistration, $91255e144bb55afc$export$2e2bcd8739ae039 as fetchDataRegistry, $2d5f75df63129ebc$export$2e2bcd8739ae039 as fetchTypeIndexes, $a87fd63d8fca0380$export$2e2bcd8739ae039 as fetchVoidEndpoints, $72db0904d77f0f1e$export$2e2bcd8739ae039 as useCompactPredicate, $586fa0ea9d02fa12$export$2e2bcd8739ae039 as useContainers, $9d2c669bd52faa31$export$2e2bcd8739ae039 as useContainersByTypes, $43097d0b613bd4db$export$2e2bcd8739ae039 as useContainerByUri, $35f3e75c86e51f35$export$2e2bcd8739ae039 as useCreateContainerUri, $e5a0eacd756fd1d5$export$2e2bcd8739ae039 as useDataModel, $3a9656756670cb78$export$2e2bcd8739ae039 as useDataModels, $3677b4de74c3d10d$export$2e2bcd8739ae039 as useDataProviderConfig, $4daf4cf698ee4eed$export$2e2bcd8739ae039 as useDataServers, $8dbb0c8c3814e663$export$2e2bcd8739ae039 as useGetCreateContainerUri, $0c5cccc31d3b196d$export$2e2bcd8739ae039 as useGetExternalLink, $487567a146508c4e$export$2e2bcd8739ae039 as useGetPrefixFromUri, $d8039fd362ad4925$export$2e2bcd8739ae039 as FilterHandler, $207a50667fa8cffa$export$2e2bcd8739ae039 as GroupedReferenceHandler, $1a24ef5e038900c4$export$2e2bcd8739ae039 as ReificationArrayInput, $03d52e691e8dc945$export$28772ab4c256e709 as createWsChannel, $03d52e691e8dc945$export$8d60734939c59ced as getOrCreateWsChannel, $03d52e691e8dc945$export$3edfe18db119b920 as createSolidNotificationChannel};
|
|
2064
2196
|
//# sourceMappingURL=index.es.js.map
|