@semapps/semantic-data-provider 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +26 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +26 -16
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1056,7 +1056,7 @@ const $3cfb23eead135e3f$var$fetchUserConfig = async (config)=>{
|
|
|
1056
1056
|
// Fill the config provided to the data provider
|
|
1057
1057
|
// We must modify the config object directly
|
|
1058
1058
|
config.dataServers[podKey].name = "My Pod";
|
|
1059
|
-
config.dataServers[podKey].baseUrl = (0, ($parcel$interopDefault($bkNnK$urljoin)))(webId, "data");
|
|
1059
|
+
config.dataServers[podKey].baseUrl = userData["pim:storage"] || (0, ($parcel$interopDefault($bkNnK$urljoin)))(webId, "data");
|
|
1060
1060
|
config.dataServers[podKey].sparqlEndpoint = userData.endpoints?.["void:sparqlEndpoint"] || (0, ($parcel$interopDefault($bkNnK$urljoin)))(webId, "sparql");
|
|
1061
1061
|
}
|
|
1062
1062
|
if (authServerKey) // Fill the config provided to the data provider
|
|
@@ -1626,32 +1626,42 @@ var $030f1232f6810456$export$2e2bcd8739ae039 = $030f1232f6810456$var$Reification
|
|
|
1626
1626
|
|
|
1627
1627
|
/**
|
|
1628
1628
|
* Find the solid notification description resource for a given resource URI.
|
|
1629
|
-
*/ const $84ab912646919f8c$var$findDescriptionResource = async (
|
|
1630
|
-
const { headers: headers } = await
|
|
1629
|
+
*/ const $84ab912646919f8c$var$findDescriptionResource = async (authenticatedFetch, resourceUri)=>{
|
|
1630
|
+
const { headers: headers } = await authenticatedFetch(resourceUri, {
|
|
1631
1631
|
method: "HEAD"
|
|
1632
1632
|
});
|
|
1633
1633
|
const linkHeader = headers.get("Link");
|
|
1634
1634
|
const matches = linkHeader?.match(/<([^>]+)>;\s*rel="(?:describedby|http:\/\/www\.w3\.org\/ns\/solid\/terms#storageDescription)"/);
|
|
1635
1635
|
if (!matches?.[1]) return undefined;
|
|
1636
|
-
|
|
1637
|
-
|
|
1636
|
+
// Don't use authenticatedFetch to get this endpoint
|
|
1637
|
+
const response = await fetch(matches[1], {
|
|
1638
|
+
headers: new Headers({
|
|
1639
|
+
Accept: "application/ld+json"
|
|
1640
|
+
})
|
|
1641
|
+
});
|
|
1642
|
+
return await response.json();
|
|
1638
1643
|
};
|
|
1639
|
-
const $84ab912646919f8c$export$3edfe18db119b920 = async (
|
|
1644
|
+
const $84ab912646919f8c$export$3edfe18db119b920 = async (authenticatedFetch, resourceUri, options = {
|
|
1640
1645
|
type: "WebSocketChannel2023"
|
|
1641
1646
|
})=>{
|
|
1642
1647
|
const { type: type, closeAfter: closeAfter, startIn: startIn, rate: rate } = options;
|
|
1643
1648
|
let { startAt: startAt, endAt: endAt } = options;
|
|
1644
1649
|
if (startIn && !startAt) startAt = new Date(Date.now() + startIn).toISOString();
|
|
1645
1650
|
if (closeAfter && !endAt) endAt = new Date(Date.now() + closeAfter).toISOString();
|
|
1646
|
-
const descriptionResource = await $84ab912646919f8c$var$findDescriptionResource(
|
|
1651
|
+
const descriptionResource = await $84ab912646919f8c$var$findDescriptionResource(authenticatedFetch, resourceUri);
|
|
1647
1652
|
// TODO: use a json-ld parser / ldo in the future for this...
|
|
1648
1653
|
// Get solid notification subscription service for the given type.
|
|
1649
1654
|
const subscriptionService = (await Promise.all(// Get the subscription service resources (that describe a channel type).
|
|
1650
1655
|
(0, $e6fbab1f303bdb93$export$2e2bcd8739ae039)(descriptionResource.subscription || descriptionResource["notify:subscription"]).map(async (subscriptionServiceOrUri)=>{
|
|
1651
1656
|
// They might not be resolved...
|
|
1652
1657
|
if (typeof subscriptionServiceOrUri === "string") {
|
|
1653
|
-
|
|
1654
|
-
|
|
1658
|
+
// Don't use authenticatedFetch to get this endpoint
|
|
1659
|
+
const response = await fetch(subscriptionServiceOrUri, {
|
|
1660
|
+
headers: new Headers({
|
|
1661
|
+
Accept: "application/ld+json"
|
|
1662
|
+
})
|
|
1663
|
+
});
|
|
1664
|
+
return await response.json();
|
|
1655
1665
|
}
|
|
1656
1666
|
return subscriptionServiceOrUri;
|
|
1657
1667
|
}))).find((service)=>{
|
|
@@ -1661,10 +1671,10 @@ const $84ab912646919f8c$export$3edfe18db119b920 = async (fetch, resourceUri, opt
|
|
|
1661
1671
|
});
|
|
1662
1672
|
if (!subscriptionService) throw new Error(`No solid notification subscription service found for type ${type}`);
|
|
1663
1673
|
// Create a new channel.
|
|
1664
|
-
const { json: channel } = await
|
|
1674
|
+
const { json: channel } = await authenticatedFetch(subscriptionService.id || subscriptionService["@id"], {
|
|
1665
1675
|
method: "POST",
|
|
1666
1676
|
body: JSON.stringify({
|
|
1667
|
-
"@context": "https://www.w3.org/ns/solid/
|
|
1677
|
+
"@context": "https://www.w3.org/ns/solid/notifications-context/v1",
|
|
1668
1678
|
type: "WebSocketChannel2023",
|
|
1669
1679
|
topic: resourceUri,
|
|
1670
1680
|
startAt: startAt,
|
|
@@ -1674,18 +1684,18 @@ const $84ab912646919f8c$export$3edfe18db119b920 = async (fetch, resourceUri, opt
|
|
|
1674
1684
|
});
|
|
1675
1685
|
return channel;
|
|
1676
1686
|
};
|
|
1677
|
-
const $84ab912646919f8c$export$28772ab4c256e709 = async (
|
|
1678
|
-
const channel = await $84ab912646919f8c$export$3edfe18db119b920(
|
|
1687
|
+
const $84ab912646919f8c$export$28772ab4c256e709 = async (authenticatedFetch, resourceUri, options)=>{
|
|
1688
|
+
const channel = await $84ab912646919f8c$export$3edfe18db119b920(authenticatedFetch, resourceUri, options);
|
|
1679
1689
|
const receiveFrom = channel.receiveFrom || channel["notify:receiveFrom"];
|
|
1680
1690
|
return new WebSocket(receiveFrom);
|
|
1681
1691
|
};
|
|
1682
1692
|
const $84ab912646919f8c$var$registeredWebSockets = new Map();
|
|
1683
1693
|
/**
|
|
1684
|
-
* @param
|
|
1694
|
+
* @param authenticatedFetch A react admin fetch function.
|
|
1685
1695
|
* @param resourceUri The resource to subscribe to
|
|
1686
1696
|
* @param options Options to pass to @see createSolidNotificationChannel, if the channel does not exist yet.
|
|
1687
1697
|
* @returns {WebSocket} A new or existing web socket that subscribed to the given resource.
|
|
1688
|
-
*/ const $84ab912646919f8c$export$8d60734939c59ced = async (
|
|
1698
|
+
*/ const $84ab912646919f8c$export$8d60734939c59ced = async (authenticatedFetch, resourceUri, options = {
|
|
1689
1699
|
type: "WebSocketChannel2023",
|
|
1690
1700
|
closeAfter: 3600000
|
|
1691
1701
|
})=>{
|
|
@@ -1694,7 +1704,7 @@ const $84ab912646919f8c$var$registeredWebSockets = new Map();
|
|
|
1694
1704
|
return socket;
|
|
1695
1705
|
// Create a promise, to return immediately and set the sockets cache.
|
|
1696
1706
|
// This prevents racing conditions that create multiple channels.
|
|
1697
|
-
const wsPromise = $84ab912646919f8c$export$28772ab4c256e709(
|
|
1707
|
+
const wsPromise = $84ab912646919f8c$export$28772ab4c256e709(authenticatedFetch, resourceUri, {
|
|
1698
1708
|
...options,
|
|
1699
1709
|
type: "WebSocketChannel2023"
|
|
1700
1710
|
}).then((ws)=>{
|