From 0a68c87f9766173fbe318d7030e3581f2fd9b057 Mon Sep 17 00:00:00 2001 From: Laurin-W <59744144+Laurin-W@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:12:23 +0200 Subject: [PATCH] Solid Notification support for useCollection (#1280) --- .../activitypub-components/dist/index.cjs.js | 397 ++++++-- .../dist/index.cjs.js.map | 2 +- .../activitypub-components/dist/index.d.ts | 35 +- .../dist/index.d.ts.map | 2 +- .../activitypub-components/dist/index.es.js | 401 ++++++-- .../dist/index.es.js.map | 2 +- .../activitypub-components/src/constants.js | 2 +- .../src/hooks/useCollection.js | 191 ++-- .../src/hooks/useCollection.ts | 245 +++++ .../activitypub-components/src/utils.js | 16 - .../activitypub-components/src/utils.ts | 28 + .../packages/auth-provider/dist/index.d.ts | 869 ++++++++---------- .../semantic-data-provider/dist/index.cjs.js | 94 ++ .../dist/index.cjs.js.map | 2 +- .../semantic-data-provider/dist/index.d.ts | 19 + .../dist/index.d.ts.map | 2 +- .../semantic-data-provider/dist/index.es.js | 93 +- .../dist/index.es.js.map | 2 +- .../semantic-data-provider/src/index.ts | 6 + .../subscribeToUpdates.ts | 140 +++ .../packages/activitypub/constants.js | 2 +- .../docs/frontend/activitypub-components.md | 27 +- .../frontend/semantic-data-provider/index.md | 33 + 23 files changed, 1892 insertions(+), 718 deletions(-) create mode 100644 src/frontend/packages/activitypub-components/src/hooks/useCollection.ts delete mode 100644 src/frontend/packages/activitypub-components/src/utils.js create mode 100644 src/frontend/packages/activitypub-components/src/utils.ts create mode 100644 src/frontend/packages/semantic-data-provider/src/notificationChannels/subscribeToUpdates.ts diff --git a/src/frontend/packages/activitypub-components/dist/index.cjs.js b/src/frontend/packages/activitypub-components/dist/index.cjs.js index 9bf5beed2..3cc2f9faa 100644 --- a/src/frontend/packages/activitypub-components/dist/index.cjs.js +++ b/src/frontend/packages/activitypub-components/dist/index.cjs.js @@ -27,7 +27,7 @@ function $parcel$interopDefault(a) { $parcel$export(module.exports, "CommentsField", () => $2e5504cc4159ca8d$export$2e2bcd8739ae039); $parcel$export(module.exports, "CollectionList", () => $505d598a33288aad$export$2e2bcd8739ae039); $parcel$export(module.exports, "ReferenceCollectionField", () => $b0c94a9bdea99da5$export$2e2bcd8739ae039); -$parcel$export(module.exports, "useCollection", () => $2b75a2f49c9ef165$export$2e2bcd8739ae039); +$parcel$export(module.exports, "useCollection", () => $5ca5f7e9fc1c3544$export$2e2bcd8739ae039); $parcel$export(module.exports, "useInbox", () => $97664763db3c0a46$export$2e2bcd8739ae039); $parcel$export(module.exports, "useNodeinfo", () => $30fd77858150739b$export$2e2bcd8739ae039); $parcel$export(module.exports, "useOutbox", () => $decfdd34cc00b80e$export$2e2bcd8739ae039); @@ -76,7 +76,7 @@ const $ebea823cebb2f44b$export$1ec8e53e7d982d22 = { REMOVE: "Remove", TENTATIVE_REJECT: "TentativeReject", TENTATIVE_ACCEPT: "TentativeAccept", - TRAVAL: "Travel", + TRAVEL: "Travel", UNDO: "Undo", UPDATE: "Update", VIEW: "View" @@ -546,7 +546,8 @@ var $d68cd57b2d06b6d5$export$2e2bcd8739ae039 = $d68cd57b2d06b6d5$var$CommentsLis -const $3ff23aa25753c478$export$e57ff0f701c44363 = (value)=>{ + +const $03510abb28fd3d8a$export$e57ff0f701c44363 = (value)=>{ // If the field is null-ish, we suppose there are no values. if (value === null || value === undefined) return []; // Return as is. @@ -556,30 +557,88 @@ const $3ff23aa25753c478$export$e57ff0f701c44363 = (value)=>{ value ]; }; -var $3ff23aa25753c478$export$2e2bcd8739ae039 = { - arrayOf: $3ff23aa25753c478$export$e57ff0f701c44363 +var $03510abb28fd3d8a$export$2e2bcd8739ae039 = { + arrayOf: $03510abb28fd3d8a$export$e57ff0f701c44363 +}; +const $03510abb28fd3d8a$export$34aed805e991a647 = (iterable, predicate)=>{ + const seen = new Set(); + return iterable.filter((item)=>{ + const key = predicate(item); + if (seen.has(key)) return false; + seen.add(key); + return true; + }); }; +const $2b75a2f49c9ef165$var$useItemsFromPagesAndNotifications = (pages, notifications, dereferenceItems)=>{ + const dataProvider = (0, $583VT$reactadmin.useDataProvider)(); + // Add all items from pages and process notifications (possibly new and deleted items). + const items = (0, $583VT$react.useMemo)(()=>{ + const addItems = notifications.map((n)=>n.type === "Add").map((n)=>n.object); + const removeItems = notifications.map((n)=>n.type === "Remove").map((n)=>n.object.id || n.object); + const currentItems = !pages ? [] : pages.flatMap((p)=>(0, $03510abb28fd3d8a$export$e57ff0f701c44363)(p.orderedItems || p.items)); + const currentAndNew = currentItems.concat(addItems); + return currentAndNew// Filter out removed items. + .filter((item)=>!removeItems.some((r)=>(r.id ?? r) === (item.id ?? item)))// Filter duplicates. + .filter((item)=>currentAndNew.some((i2)=>(i2.id ?? i2) === (item.id ?? item))); + }, pages, notifications); + if (!dereferenceItems) return { + loadedItems: items, + isLoading: false, + isFetching: false + }; + // Dereference all items, if they are not yet. + const itemQueries = (0, $583VT$reactquery.useQueries)(items.filter((item)=>typeof item === "string").map((itemUri)=>({ + queryKey: [ + "resource", + itemUri + ], + queryFn: async ()=>(await dataProvider.fetch(itemUri)).json, + staleTime: Infinity + }))); + // Put all loaded items together (might be dereferenced already, so concatenate). + const loadedItems = items.filter((item)=>typeof item !== "string").concat(itemQueries.flatMap((itemQuery)=>{ + return itemQuery.isSuccess && itemQuery.data || []; + })); + console.log("loadedItems", loadedItems.length, "total", items.length); + const errors = itemQueries.filter((q)=>q.error); + return { + loadedItems: loadedItems, + isLoading: itemQueries.some((q)=>q.isLoading), + isFetching: itemQueries.some((q)=>q.isFetching), + errors: errors.length > 0 && errors + }; +}; const $2b75a2f49c9ef165$var$useCollection = (predicateOrUrl, options = {})=>{ - const { dereferenceItems: dereferenceItems = false } = options; + const { dereferenceItems: dereferenceItems = false, liveUpdates: liveUpdates = true } = options; const { data: identity } = (0, $583VT$reactadmin.useGetIdentity)(); - const [items, setItems] = (0, $583VT$react.useState)(); const [totalItems, setTotalItems] = (0, $583VT$react.useState)(); + const [notifications, setNotifications] = (0, $583VT$react.useState)([]); + const [hasLiveUpdates, setHasLiveUpdates] = (0, $583VT$react.useState)({ + status: "disconnected", + error: undefined + }); const dataProvider = (0, $583VT$reactadmin.useDataProvider)(); - const queryClient = (0, $583VT$reactquery.useQueryClient)(); + // Get collectionUrl from webId predicate or URL. const collectionUrl = (0, $583VT$react.useMemo)(()=>{ if (predicateOrUrl) { if (predicateOrUrl.startsWith("http")) return predicateOrUrl; if (identity?.webIdData) return identity?.webIdData?.[predicateOrUrl]; } + return undefined; + // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`); }, [ identity, predicateOrUrl ]); + // Fetch page of collection item references (if pageParam provided) + // or default to `collectionUrl` (which should give you the first page). const fetchCollection = (0, $583VT$react.useCallback)(async ({ pageParam: nextPageUrl })=>{ + // Fetch page or first page (collectionUrl) let { json: json } = await dataProvider.fetch(nextPageUrl || collectionUrl); if (json.totalItems) setTotalItems(json.totalItems); + // If first page, handle this here. if ((json.type === "OrderedCollection" || json.type === "Collection") && json.first) { if (json.first?.items) { if (json.first?.items.length === 0 && json.first?.next) // Special case where the first property is an object without items @@ -588,17 +647,6 @@ const $2b75a2f49c9ef165$var$useCollection = (predicateOrUrl, options = {})=>{ } else // Fetch the first page ({ json: json } = await dataProvider.fetch(json.first)); } - // Force dereference of items - if (dereferenceItems) { - const itemPredicate = json.items ? "items" : "orderedItems"; - json[itemPredicate] = json[itemPredicate] && await Promise.all((0, $3ff23aa25753c478$export$e57ff0f701c44363)(json[itemPredicate]).map(async (item)=>{ - if (typeof item === "string") { - const { json: json } = await dataProvider.fetch(item); - return json; - } - return item; - })); - } return json; }, [ dataProvider, @@ -606,8 +654,9 @@ const $2b75a2f49c9ef165$var$useCollection = (predicateOrUrl, options = {})=>{ identity, setTotalItems ]); - const { data: data, error: error, fetchNextPage: fetchNextPage, refetch: refetch, hasNextPage: hasNextPage, isLoading: isLoading, isFetching: isFetching, isFetchingNextPage: isFetchingNextPage, status: status } = (0, $583VT$reactquery.useInfiniteQuery)([ - "Collection", + // Use infiniteQuery to handle pagination, fetching, etc. + const { data: data, error: collectionError, fetchNextPage: fetchNextPage, refetch: refetch, hasNextPage: hasNextPage, isLoading: isLoadingPage, isFetching: isFetchingPage, isFetchingNextPage: isFetchingNextPage } = (0, $583VT$reactquery.useInfiniteQuery)([ + "collection", { collectionUrl: collectionUrl } @@ -616,63 +665,57 @@ const $2b75a2f49c9ef165$var$useCollection = (predicateOrUrl, options = {})=>{ getNextPageParam: (lastPage)=>lastPage.next, getPreviousPageParam: (firstPage)=>firstPage.prev }); + // Put all items together in a list. + const { loadedItems: items, isLoading: isLoadingItems, isFetching: isFetchingItems, errors: itemErrors } = $2b75a2f49c9ef165$var$useItemsFromPagesAndNotifications(data?.pages, notifications, dereferenceItems); + // Notifications have been processed after hook call, so reset. + // useEffect(() => { + // setNotifications([]); + // }, [notifications]) + // Live Updates (0, $583VT$react.useEffect)(()=>{ - if (data?.pages) setItems([].concat(...data.pages.map((p)=>(0, $3ff23aa25753c478$export$e57ff0f701c44363)(p.orderedItems || p.items)))); - }, [ - data, - setItems - ]); - const addItem = (0, $583VT$react.useCallback)((item)=>{ - setItems((oldItems)=>[ - ...oldItems, - item - ]); - // TODO use queryClient.setQueryData to update items directly in react-query cache - setTimeout(()=>queryClient.refetchQueries([ - "Collection", - { - collectionUrl: collectionUrl - } - ], { - active: true, - exact: true - }), 2000); - }, [ - setItems, - queryClient, - collectionUrl - ]); - const removeItem = (0, $583VT$react.useCallback)((itemId)=>{ - setItems((oldItems)=>oldItems.filter((item)=>typeof item === "string" ? item !== itemId : item.id !== itemId)); - // TODO use queryClient.setQueryData to update items directly in react-query cache - setTimeout(()=>queryClient.refetchQueries([ - "Collection", - { - collectionUrl: collectionUrl - } - ], { - active: true, - exact: true - }), 2000); + if (liveUpdates && collectionUrl) // Create ws that listens to collectionUri changes + (0, $583VT$semappssemanticdataprovider.getOrCreateWsChannel)(dataProvider.fetch, collectionUrl).then((webSocket)=>{ + webSocket.addEventListener("message", (e)=>{ + if (e.data && e.data.type === "Add" || e.data.type === "Remove") setNotifications([ + ...notifications, + e.data + ]); + }); + webSocket.addEventListener("error", (e)=>{ + setHasLiveUpdates({ + status: "error", + error: e + }); + // TODO: Retry after a while + }); + webSocket.addEventListener("close", (e)=>{ + setHasLiveUpdates({ + ...hasLiveUpdates, + status: "disconnected" + }); + }); + setHasLiveUpdates({ + status: "connected" + }); + }).catch(()=>{}); // If it fails, we won't receive live updates. But that's okay. }, [ - setItems, - queryClient, - collectionUrl + collectionUrl, + liveUpdates, + dataProvider.fetch ]); + const allErrors = (0, $03510abb28fd3d8a$export$e57ff0f701c44363)(collectionError).concat((0, $03510abb28fd3d8a$export$e57ff0f701c44363)(itemErrors)); return { items: items, totalItems: totalItems, - error: error, + error: allErrors.length > 0 && allErrors, refetch: refetch, fetchNextPage: fetchNextPage, hasNextPage: hasNextPage, - isLoading: isLoading, - isFetching: isFetching, + isLoading: isLoadingPage || isLoadingItems, + isFetching: isFetchingPage || isFetchingItems, isFetchingNextPage: isFetchingNextPage, - status: status, - addItem: addItem, - removeItem: removeItem, - url: collectionUrl + url: collectionUrl, + hasLiveUpdates: hasLiveUpdates }; }; var $2b75a2f49c9ef165$export$2e2bcd8739ae039 = $2b75a2f49c9ef165$var$useCollection; @@ -759,6 +802,224 @@ var $b0c94a9bdea99da5$export$2e2bcd8739ae039 = $b0c94a9bdea99da5$var$ReferenceCo + +const $5ca5f7e9fc1c3544$var$useItemsFromPages = (pages, dereferenceItems)=>{ + const dataProvider = (0, $583VT$reactadmin.useDataProvider)(); + const items = (0, $583VT$react.useMemo)(()=>pages.flatMap((p)=>(0, $03510abb28fd3d8a$export$e57ff0f701c44363)(p.orderedItems || p.items)), [ + pages + ]); + // We will force dereference, if some items are not URI string references. + const shouldDereference = (0, $583VT$react.useMemo)(()=>{ + return dereferenceItems || items.some((item)=>typeof item !== "string"); + }, [ + dereferenceItems, + items + ]); + // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called). + const itemQueries = (0, $583VT$reactquery.useQueries)(!shouldDereference ? [] : items.filter((item)=>typeof item === "string").map((itemUri)=>({ + queryKey: [ + "resource", + itemUri + ], + queryFn: async ()=>(await dataProvider.fetch(itemUri)).json, + staleTime: Infinity + }))); + if (!shouldDereference) return { + loadedItems: items, + isLoading: false, + isFetching: false + }; + // Put all loaded items together (might be dereferenced already, so concatenate). + const loadedItems = items.filter((item)=>typeof item !== "string").concat(itemQueries.flatMap((itemQuery)=>{ + return itemQuery.isSuccess && itemQuery.data || []; + })); + const errors = itemQueries.filter((q)=>q.error); + return { + loadedItems: loadedItems, + isLoading: itemQueries.some((q)=>q.isLoading), + isFetching: itemQueries.some((q)=>q.isFetching), + errors: errors.length > 0 ? errors : undefined + }; +}; +/** + * Subscribe a collection. Supports pagination. + * @param predicateOrUrl The collection URI or the predicate to get the collection URI from the identity (webId). + * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }` + */ const $5ca5f7e9fc1c3544$var$useCollection = (predicateOrUrl, options = {})=>{ + const { dereferenceItems: dereferenceItems = false, liveUpdates: liveUpdates = true } = options; + const { data: identity } = (0, $583VT$reactadmin.useGetIdentity)(); + const [totalItems, setTotalItems] = (0, $583VT$react.useState)(); + const queryClient = (0, $583VT$reactquery.useQueryClient)(); + const [hasLiveUpdates, setHasLiveUpdates] = (0, $583VT$react.useState)({ + status: "connecting" + }); + const dataProvider = (0, $583VT$reactadmin.useDataProvider)(); + // Get collectionUrl from webId predicate or URL. + const collectionUrl = (0, $583VT$react.useMemo)(()=>{ + if (predicateOrUrl) { + if (predicateOrUrl.startsWith("http")) return predicateOrUrl; + if (identity?.webIdData) return identity?.webIdData?.[predicateOrUrl]; + } + return undefined; + // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`); + }, [ + identity, + predicateOrUrl + ]); + // Fetch page of collection item references (if pageParam provided) + // or default to `collectionUrl` (which should give you the first page). + const fetchCollection = (0, $583VT$react.useCallback)(async ({ pageParam: nextPageUrl })=>{ + // Fetch page or first page (collectionUrl) + let { json: json } = await dataProvider.fetch(nextPageUrl || collectionUrl); + if (json.totalItems) setTotalItems(json.totalItems); + // If first page, handle this here. + if ((json.type === "OrderedCollection" || json.type === "Collection") && json.first) { + if (json.first?.items) { + if (json.first?.items.length === 0 && json.first?.next) // Special case where the first property is an object without items + ({ json: json } = await dataProvider.fetch(json.first?.next)); + else json = json.first; + } else // Fetch the first page + ({ json: json } = await dataProvider.fetch(json.first)); + } + return json; + }, [ + dataProvider, + collectionUrl, + identity, + setTotalItems + ]); + // Use infiniteQuery to handle pagination, fetching, etc. + const { data: pageData, error: collectionError, fetchNextPage: fetchNextPage, refetch: refetch, hasNextPage: hasNextPage, isLoading: isLoadingPage, isFetching: isFetchingPage, isFetchingNextPage: isFetchingNextPage } = (0, $583VT$reactquery.useInfiniteQuery)([ + "collection", + { + collectionUrl: collectionUrl + } + ], fetchCollection, { + enabled: !!(collectionUrl && identity?.id), + getNextPageParam: (lastPage)=>lastPage.next, + getPreviousPageParam: (firstPage)=>firstPage.prev + }); + // Put all items together in a list (and dereference, if required). + const { loadedItems: items, isLoading: isLoadingItems, isFetching: isFetchingItems, errors: itemErrors } = $5ca5f7e9fc1c3544$var$useItemsFromPages(pageData?.pages ?? [], dereferenceItems); + const allErrors = (0, $03510abb28fd3d8a$export$e57ff0f701c44363)(collectionError).concat((0, $03510abb28fd3d8a$export$e57ff0f701c44363)(itemErrors)); + const addItem = (0, $583VT$react.useCallback)((item, shouldRefetch = true)=>{ + queryClient.setQueryData([ + "collection", + { + collectionUrl: collectionUrl + } + ], (oldData)=>{ + if (!oldData) return oldData; + setTotalItems(totalItems && totalItems + 1); + // Destructure, so react knows, it needs to re-render the pages. + const pages = [ + ...oldData.pages + ]; + const firstPageItems = pages?.[0]?.orderedItems || pages?.[0]?.items || []; + firstPageItems.unshift(item); + oldData.pages = pages; + return oldData; + }); + if (shouldRefetch) setTimeout(()=>queryClient.refetchQueries([ + "collection", + { + collectionUrl: collectionUrl + } + ], { + active: true, + exact: true + }), typeof shouldRefetch === "number" ? shouldRefetch : 2000); + }, [ + queryClient, + collectionUrl + ]); + const removeItem = (0, $583VT$react.useCallback)((item, shouldRefetch = true)=>{ + queryClient.setQueryData([ + "collection", + { + collectionUrl: collectionUrl + } + ], (oldData)=>{ + if (!oldData) return oldData; + setTotalItems(totalItems && totalItems - 1); + // Destructure, so react knows, it needs to re-render the pages array. + const pages = [ + ...oldData.pages + ]; + // Find the item in all pages and remove the item to be removed (either item.id or just item) + pages.forEach((page)=>{ + if (page.orderedItems) page.orderedItems = page.orderedItems.filter((i)=>(i.id || i) !== (item.id || item)); + else if (page.items) page.items = page.items.filter((i)=>(i.id || i) !== (item?.id || item)); + }); + oldData.pages = pages; + return oldData; + }); + if (shouldRefetch) setTimeout(()=>queryClient.refetchQueries([ + "collection", + { + collectionUrl: collectionUrl + } + ], { + active: true, + exact: true + }), typeof shouldRefetch === "number" ? shouldRefetch : 2000); + }, [ + queryClient, + collectionUrl + ]); + // Live Updates + (0, $583VT$react.useEffect)(()=>{ + if (liveUpdates && collectionUrl) // Create ws that listens to collectionUri changes + (0, $583VT$semappssemanticdataprovider.getOrCreateWsChannel)(dataProvider.fetch, collectionUrl).then((webSocket)=>{ + webSocket.addEventListener("message", (e)=>{ + const data = JSON.parse(e.data); + if (data && data.type === "Add") addItem(data.object, true); + else if (data && data.type === "Remove") removeItem(data.object, true); + }); + webSocket.addEventListener("error", (e)=>{ + setHasLiveUpdates({ + status: "error", + error: e + }); + // TODO: Retry after a while + }); + webSocket.addEventListener("close", (e)=>{ + if (!hasLiveUpdates.error) setHasLiveUpdates({ + ...hasLiveUpdates, + status: "closed" + }); + }); + setHasLiveUpdates({ + status: "connected" + }); + }).catch(()=>{}); // If it fails, we won't receive live updates. But that's okay. + }, [ + collectionUrl, + liveUpdates, + dataProvider + ]); + return { + items: items, + totalItems: totalItems, + error: allErrors.length > 0 && allErrors, + refetch: refetch, + fetchNextPage: fetchNextPage, + addItem: addItem, + removeItem: removeItem, + hasNextPage: hasNextPage, + isLoading: isLoadingPage || isLoadingItems, + isFetching: isFetchingPage || isFetchingItems, + isFetchingNextPage: isFetchingNextPage, + url: collectionUrl, + hasLiveUpdates: hasLiveUpdates + }; +}; +var $5ca5f7e9fc1c3544$export$2e2bcd8739ae039 = $5ca5f7e9fc1c3544$var$useCollection; + + + + + const $97664763db3c0a46$var$useInbox = ()=>{ const { data: identity } = (0, $583VT$reactadmin.useGetIdentity)(); const inboxUrl = (0, $583VT$react.useMemo)(()=>{ diff --git a/src/frontend/packages/activitypub-components/dist/index.cjs.js.map b/src/frontend/packages/activitypub-components/dist/index.cjs.js.map index 03c43aa0c..b01270237 100644 --- a/src/frontend/packages/activitypub-components/dist/index.cjs.js.map +++ b/src/frontend/packages/activitypub-components/dist/index.cjs.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;;;;;;;;;;;;;;AGAN,MAAM,4CAAiB;IAC5B,QAAQ;IACR,KAAK;IACL,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,kBAAkB;IAClB,kBAAkB;IAClB,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,MAAM;AACR;AAEO,MAAM,4CAAc;IACzB,aAAa;IACb,OAAO;IACP,cAAc;IACd,QAAQ;IACR,SAAS;AACX;AAEO,MAAM,4CAAe;IAC1B,SAAS;IACT,OAAO;IACP,UAAU;IACV,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,SAAS;IACT,cAAc;IACd,WAAW;IACX,OAAO;AACT;AAEO,MAAM,4CAAa;;;;;;AClD1B,MAAM,kCAAY;IAChB,MAAM,EAA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E;YACf,OAAO,kBAAkB,MAAM,CAAC,CAAC,SAAE,KAAK,EAAE,GAAK,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,WAAW,KAAK,KAAK,CAAC,GAAG;QAC/G;IAEJ,GAAG;QAAC;KAAkB;IAEtB,OAAO;eACL;QACA,QAAQ,CAAA,GAAA,wCAAa;IACvB;AACF;IAEA,2CAAe;","sources":["packages/activitypub-components/src/index.ts","packages/activitypub-components/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/constants.js","packages/activitypub-components/src/hooks/useOutbox.js","packages/activitypub-components/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/hooks/useCollection.js","packages/activitypub-components/src/utils.js","packages/activitypub-components/src/components/CollectionList.js","packages/activitypub-components/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/hooks/useInbox.js","packages/activitypub-components/src/hooks/useNodeinfo.js","packages/activitypub-components/src/hooks/useWebfinger.js","packages/activitypub-components/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/hooks/useMentions/MentionsList.js"],"sourcesContent":["// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport PostCommentForm from './PostCommentForm';\nimport CommentsList from './CommentsList';\nimport useCollection from '../../hooks/useCollection';\n\nconst CommentsField = ({ source, context, helperText, placeholder, userResource, mentions }) => {\n const record = useRecordContext();\n const { items: comments, loading, addItem, removeItem } = useCollection(record.replies);\n if (!userResource) throw new Error('No userResource defined for CommentsField');\n return (\n <>\n \n \n \n );\n};\n\nCommentsField.defaultProps = {\n label: 'Commentaires',\n placeholder: 'Commencez à taper votre commentaire...',\n source: 'id', // Ensure the field is always displayed\n context: 'id'\n};\n\nexport default CommentsField;\n","import React, { useState, useCallback } from 'react';\nimport { Form, useGetIdentity, useNotify, useRecordContext } from 'react-admin';\nimport { RichTextInput, DefaultEditorOptions } from 'ra-input-rich-text';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { Button, Box, Avatar } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport SendIcon from '@mui/icons-material/Send';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AuthDialog } from '@semapps/auth-provider';\nimport { OBJECT_TYPES, PUBLIC_URI } from '../../constants';\nimport useOutbox from '../../hooks/useOutbox';\nimport CustomMention from './CustomMention';\n\nconst useStyles = makeStyles(theme => ({\n form: {\n marginTop: -12 // Negative margin to keep the form close to the label\n },\n container: {\n paddingLeft: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 16,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n editorContent: {\n '& > div': {\n backgroundColor: 'rgba(0, 0, 0, 0.09)',\n padding: '2px 12px',\n borderWidth: '0px !important',\n borderRadius: 0,\n borderBottom: '1px solid #FFF',\n minHeight: 60,\n outline: 'unset !important'\n },\n '& > div > p': {\n marginTop: 12,\n marginBottom: 12,\n fontFamily: theme.typography.body1.fontFamily,\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n },\n '& > div > p.is-editor-empty:first-child::before': {\n color: 'grey',\n content: 'attr(data-placeholder)',\n float: 'left',\n height: 0,\n pointerEvents: 'none'\n }\n },\n button: {\n marginTop: -10, // To go over helper text block\n marginBottom: 15\n }\n}));\n\nconst EmptyToolbar = () => null;\n\nconst PostCommentForm = ({ context, placeholder, helperText, mentions, userResource, addItem, removeItem }) => {\n const record = useRecordContext();\n const { data: identity, isLoading } = useGetIdentity();\n const userDataModel = useDataModel(userResource);\n const classes = useStyles();\n const notify = useNotify();\n const outbox = useOutbox();\n const [expanded, setExpanded] = useState(false);\n const [openAuth, setOpenAuth] = useState(false);\n\n const onSubmit = useCallback(\n async values => {\n const document = new DOMParser().parseFromString(values.comment, 'text/html');\n const mentions = Array.from(document.body.getElementsByClassName('mention'));\n const mentionedUsersUris = [];\n\n mentions.forEach(node => {\n const userUri = node.attributes['data-mention-id'].value;\n const userLabel = node.attributes['data-mention-label'].value;\n const link = document.createElement('a');\n link.setAttribute(\n 'href',\n `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`\n );\n link.textContent = `@${userLabel}`;\n node.parentNode.replaceChild(link, node);\n mentionedUsersUris.push(userUri);\n });\n\n if (document.body.innerHTML === 'undefined') {\n notify('Votre commentaire est vide', { type: 'error' });\n } else {\n const tempId = Date.now();\n\n const note = {\n type: OBJECT_TYPES.NOTE,\n attributedTo: outbox.owner,\n content: document.body.innerHTML,\n inReplyTo: record[context],\n published: new Date().toISOString()\n };\n\n try {\n addItem({ id: tempId, ...note });\n // TODO reset the form\n setExpanded(false);\n await outbox.post({ ...note, to: [...mentionedUsersUris, PUBLIC_URI] });\n notify('Commentaire posté avec succès', { type: 'success' });\n } catch (e) {\n console.error(e);\n removeItem(tempId);\n notify(e.message, { type: 'error' });\n }\n }\n },\n [outbox, notify, setExpanded, addItem, removeItem]\n );\n\n const openAuthIfDisconnected = useCallback(() => {\n if (!identity?.id) {\n setOpenAuth(true);\n }\n }, [identity, setOpenAuth]);\n\n // Don't init the editor options until mentions and identity are loaded, as they can only be initialized once\n if ((mentions && !mentions.items) || isLoading) return null;\n\n return (\n <>\n
\n \n \n }\n fullWidth\n classes={{ editorContent: classes.editorContent }}\n editorOptions={{\n ...DefaultEditorOptions,\n onFocus() {\n setExpanded(true);\n },\n extensions: [\n ...DefaultEditorOptions.extensions,\n placeholder ? Placeholder.configure({ placeholder }) : null,\n mentions\n ? CustomMention.configure({\n HTMLAttributes: {\n class: 'mention'\n },\n suggestion: mentions\n })\n : null\n ],\n // Disable editor if user is not connected\n editable: !!identity?.id\n }}\n helperText={helperText}\n />\n {expanded && (\n }\n className={classes.button}\n >\n Envoyer\n \n )}\n \n
\n setOpenAuth(false)}\n message=\"Pour poster un commentaire, vous devez être connecté.\"\n />\n \n );\n};\n\nexport default PostCommentForm;\n","export const ACTIVITY_TYPES = {\n ACCEPT: 'Accept',\n ADD: 'Add',\n ANNOUNCE: 'Announce',\n ARRIVE: 'Arrive',\n BLOCK: 'Block',\n CREATE: 'Create',\n DELETE: 'Delete',\n DISLIKE: 'Dislike',\n FLAG: 'Flag',\n FOLLOW: 'Follow',\n IGNORE: 'Ignore',\n INVITE: 'Invite',\n JOIN: 'Join',\n LEAVE: 'Leave',\n LIKE: 'Like',\n LISTEN: 'Listen',\n MOVE: 'Move',\n OFFER: 'Offer',\n QUESTION: 'Question',\n REJECT: 'Reject',\n READ: 'Read',\n REMOVE: 'Remove',\n TENTATIVE_REJECT: 'TentativeReject',\n TENTATIVE_ACCEPT: 'TentativeAccept',\n TRAVAL: 'Travel',\n UNDO: 'Undo',\n UPDATE: 'Update',\n VIEW: 'View'\n};\n\nexport const ACTOR_TYPES = {\n APPLICATION: 'Application',\n GROUP: 'Group',\n ORGANIZATION: 'Organization',\n PERSON: 'Person',\n SERVICE: 'Service'\n};\n\nexport const OBJECT_TYPES = {\n ARTICLE: 'Article',\n AUDIO: 'Audio',\n DOCUMENT: 'Document',\n EVENT: 'Event',\n IMAGE: 'Image',\n NOTE: 'Note',\n PAGE: 'Page',\n PLACE: 'Place',\n PROFILE: 'Profile',\n RELATIONSHIP: 'Relationship',\n TOMBSTONE: 'Tombstone',\n VIDEO: 'Video'\n};\n\nexport const PUBLIC_URI = 'https://www.w3.org/ns/activitystreams#Public';\n","import { useCallback, useMemo } from 'react';\nimport { useGetIdentity, fetchUtils } from 'react-admin';\nimport { buildBlankNodesQuery } from '@semapps/semantic-data-provider';\n\nconst useOutbox = () => {\n const { data: identity } = useGetIdentity();\n\n const outboxUrl = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.outbox;\n }\n }, [identity]);\n\n const sparqlEndpoint = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.endpoints?.['void:sparqlEndpoint'] || `${identity?.id}/sparql`;\n }\n }, [identity]);\n\n // Post an activity to the logged user's outbox and return its URI\n const post = useCallback(\n async activity => {\n if (!outboxUrl)\n throw new Error(\n 'Cannot post to outbox before user identity is loaded. Please use the loaded argument of useOutbox'\n );\n const token = localStorage.getItem('token');\n const { headers } = await fetchUtils.fetchJson(outboxUrl, {\n method: 'POST',\n body: JSON.stringify({\n '@context': 'https://www.w3.org/ns/activitystreams',\n ...activity\n }),\n headers: new Headers({\n 'Content-Type': 'application/ld+json',\n Authorization: `Bearer ${token}`\n })\n });\n return headers.get('Location');\n },\n [outboxUrl]\n );\n\n const fetch = useCallback(async () => {\n if (!sparqlEndpoint || !outboxUrl) return;\n\n const token = localStorage.getItem('token');\n const blankNodesQuery = buildBlankNodesQuery(['as:object']);\n\n const query = `\n PREFIX as: \n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.construct}\n }\n WHERE {\n <${outboxUrl}> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.where}\n }\n `;\n\n const { json } = await fetchUtils.fetchJson(sparqlEndpoint, {\n method: 'POST',\n body: query,\n headers: new Headers({\n Accept: 'application/ld+json',\n Authorization: token ? `Bearer ${token}` : undefined\n })\n });\n\n if (json['@graph']) {\n return json['@graph'];\n }\n return null;\n }, [sparqlEndpoint, outboxUrl]);\n\n return { post, fetch, url: outboxUrl, loaded: !!outboxUrl, owner: identity?.id };\n};\n\nexport default useOutbox;\n","import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\n\n// Fix a bug in the current version of the mention extension\n// (The { id, label } object is located inside the id property)\n// See https://github.com/ueberdosis/tiptap/pull/1322\nconst CustomMention = Mention.extend({\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id.label}`];\n },\n addAttributes() {\n return {\n label: {\n default: null,\n parseHTML: element => {\n return {\n label: element.getAttribute('data-mention-label')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.label) {\n return {};\n }\n return {\n 'data-mention-label': attributes.id.label\n };\n }\n },\n id: {\n default: null,\n parseHTML: element => {\n return {\n id: element.getAttribute('data-mention-id')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.id) {\n return {};\n }\n return {\n 'data-mention-id': attributes.id.id\n };\n }\n }\n };\n }\n});\n\nexport default CustomMention;\n","import React from 'react';\nimport { TextField, RichTextField, DateField } from 'react-admin';\nimport { Box, Typography, CircularProgress } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AvatarWithLabelField, ReferenceField } from '@semapps/field-components';\n\nconst useStyles = makeStyles(() => ({\n container: {\n paddingLeft: 80,\n marginTop: 8,\n minHeight: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n text: {\n paddingTop: 2,\n paddingBottom: 8\n },\n label: {\n fontWeight: 'bold'\n },\n content: {\n '& p': {\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n }\n },\n loading: {\n zIndex: 1000,\n backgroundColor: 'white',\n opacity: 0.5,\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n marginTop: 5\n }\n}));\n\nconst CommentsList = ({ comments, userResource, loading }) => {\n const classes = useStyles();\n const userDataModel = useDataModel(userResource);\n return (\n \n {comments &&\n comments\n .sort((a, b) => new Date(b.published) - new Date(a.published))\n .map(comment => (\n \n \n \n \n \n \n \n \n \n \n \n  • \n \n \n \n \n \n ))}\n {loading && (\n \n \n \n \n \n )}\n \n );\n};\n\nexport default CommentsList;\n","import { useCallback, useMemo, useState, useEffect } from 'react';\nimport { useGetIdentity, useDataProvider } from 'react-admin';\nimport { useInfiniteQuery, useQueryClient } from 'react-query';\nimport { arrayOf } from '../utils';\n\nconst useCollection = (predicateOrUrl, options = {}) => {\n const { dereferenceItems = false } = options;\n const { data: identity } = useGetIdentity();\n const [items, setItems] = useState();\n const [totalItems, setTotalItems] = useState();\n const dataProvider = useDataProvider();\n const queryClient = useQueryClient();\n\n const collectionUrl = useMemo(() => {\n if (predicateOrUrl) {\n if (predicateOrUrl.startsWith('http')) {\n return predicateOrUrl;\n }\n if (identity?.webIdData) {\n return identity?.webIdData?.[predicateOrUrl];\n }\n }\n }, [identity, predicateOrUrl]);\n\n const fetchCollection = useCallback(\n async ({ pageParam: nextPageUrl }) => {\n let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl);\n if (json.totalItems) setTotalItems(json.totalItems);\n\n if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {\n if (json.first?.items) {\n if (json.first?.items.length === 0 && json.first?.next) {\n // Special case where the first property is an object without items\n ({ json } = await dataProvider.fetch(json.first?.next));\n } else {\n json = json.first;\n }\n } else {\n // Fetch the first page\n ({ json } = await dataProvider.fetch(json.first));\n }\n }\n\n // Force dereference of items\n if (dereferenceItems) {\n const itemPredicate = json.items ? 'items' : 'orderedItems';\n json[itemPredicate] =\n json[itemPredicate] &&\n (await Promise.all(\n arrayOf(json[itemPredicate]).map(async item => {\n if (typeof item === 'string') {\n const { json } = await dataProvider.fetch(item);\n return json;\n }\n return item;\n })\n ));\n }\n\n return json;\n },\n [dataProvider, collectionUrl, identity, setTotalItems]\n );\n\n const { data, error, fetchNextPage, refetch, hasNextPage, isLoading, isFetching, isFetchingNextPage, status } =\n useInfiniteQuery(['Collection', { collectionUrl }], fetchCollection, {\n enabled: !!(collectionUrl && identity?.id),\n getNextPageParam: lastPage => lastPage.next,\n getPreviousPageParam: firstPage => firstPage.prev\n });\n\n useEffect(() => {\n if (data?.pages) {\n setItems([].concat(...data.pages.map(p => arrayOf(p.orderedItems || p.items))));\n }\n }, [data, setItems]);\n\n const addItem = useCallback(\n item => {\n setItems(oldItems => [...oldItems, item]);\n // TODO use queryClient.setQueryData to update items directly in react-query cache\n setTimeout(\n () =>\n queryClient.refetchQueries(['Collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n 2000\n );\n },\n [setItems, queryClient, collectionUrl]\n );\n\n const removeItem = useCallback(\n itemId => {\n setItems(oldItems => oldItems.filter(item => (typeof item === 'string' ? item !== itemId : item.id !== itemId)));\n // TODO use queryClient.setQueryData to update items directly in react-query cache\n setTimeout(\n () =>\n queryClient.refetchQueries(['Collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n 2000\n );\n },\n [setItems, queryClient, collectionUrl]\n );\n\n return {\n items,\n totalItems,\n error,\n refetch,\n fetchNextPage,\n hasNextPage,\n isLoading,\n isFetching,\n isFetchingNextPage,\n status,\n addItem,\n removeItem,\n url: collectionUrl\n };\n};\n\nexport default useCollection;\n","export const arrayOf = value => {\n // If the field is null-ish, we suppose there are no values.\n if (value === null || value === undefined) {\n return [];\n }\n // Return as is.\n if (Array.isArray(value)) {\n return value;\n }\n // Single value is made an array.\n return [value];\n};\n\nexport default {\n arrayOf\n};\n","import React from 'react';\nimport { useList, ListContextProvider, useGetMany } from 'react-admin';\nimport useCollection from '../hooks/useCollection';\n\nconst CollectionList = ({ collectionUrl, resource, children }) => {\n if (React.Children.count(children) !== 1) {\n throw new Error(' only accepts a single child');\n }\n\n const { items: actorsUris } = useCollection(collectionUrl);\n\n const { data, isLoading, isFetching } = useGetMany(\n resource,\n { ids: Array.isArray(actorsUris) ? actorsUris : [actorsUris] },\n { enabled: !!actorsUris }\n );\n\n const listContext = useList({ data, isLoading, isFetching });\n\n return {children};\n};\n\nexport default CollectionList;\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport CollectionList from './CollectionList';\n\nconst ReferenceCollectionField = ({ source, reference, children, ...rest }) => {\n const record = useRecordContext();\n\n if (React.Children.count(children) !== 1) {\n throw new Error(' only accepts a single child');\n }\n\n if (!record || !record[source]) return null;\n\n return (\n \n {children}\n \n );\n};\n\nexport default ReferenceCollectionField;\n","import { useCallback, useMemo } from 'react';\nimport { useGetIdentity, fetchUtils } from 'react-admin';\nimport { buildBlankNodesQuery } from '@semapps/semantic-data-provider';\n\nconst useInbox = () => {\n const { data: identity } = useGetIdentity();\n\n const inboxUrl = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.inbox;\n }\n }, [identity]);\n\n const sparqlEndpoint = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.endpoints?.['void:sparqlEndpoint'] || `${identity?.id}/sparql`;\n }\n }, [identity]);\n\n const fetch = useCallback(\n async ({ filters }) => {\n if (!sparqlEndpoint || !inboxUrl) return;\n\n const token = localStorage.getItem('token');\n const blankNodesQuery = buildBlankNodesQuery(['as:object']);\n\n let filtersWhereQuery = '';\n if (filters) {\n Object.keys(filters).forEach(predicate => {\n if (filters[predicate]) {\n const object = filters[predicate].startsWith('http') ? `<${filters[predicate]}>` : filters[predicate];\n filtersWhereQuery += `?s1 ${predicate} ${object} .`;\n }\n });\n }\n\n const query = `\n PREFIX as: \n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.construct}\n }\n WHERE {\n <${inboxUrl}> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n FILTER( (isIRI(?s1)) ) .\n ${filtersWhereQuery}\n ${blankNodesQuery.where}\n }\n `;\n\n const { json } = await fetchUtils.fetchJson(sparqlEndpoint, {\n method: 'POST',\n body: query,\n headers: new Headers({\n Accept: 'application/ld+json',\n Authorization: token ? `Bearer ${token}` : undefined\n })\n });\n\n if (json['@graph']) {\n return json['@graph'];\n }\n return null;\n },\n [sparqlEndpoint, inboxUrl]\n );\n\n return { fetch, url: inboxUrl, owner: identity?.id };\n};\n\nexport default useInbox;\n","import { useEffect, useState } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useNodeinfo = (host, rel = 'http://nodeinfo.diaspora.software/ns/schema/2.1') => {\n const [schema, setSchema] = useState();\n\n useEffect(() => {\n (async () => {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are likely on HTTP\n const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;\n\n try {\n const { json: links } = await fetchUtils.fetchJson(nodeinfoUrl);\n\n // Accept any version of the nodeinfo protocol\n const link = links?.links?.find(l => l.rel === rel);\n\n const { json } = await fetchUtils.fetchJson(link.href);\n\n setSchema(json);\n } catch (e) {\n // Do nothing if nodeinfo can't be fetched\n }\n })();\n }, [host, setSchema, rel]);\n\n return schema;\n};\n\nexport default useNodeinfo;\n","import { useCallback } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useWebfinger = () => {\n // Post an activity to the logged user's outbox and return its URI\n const fetch = useCallback(async id => {\n // eslint-disable-next-line\n const [_, username, host] = id.split('@');\n if (host) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are most likely on localhost\n const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;\n\n try {\n const { json } = await fetchUtils.fetchJson(webfingerUrl);\n\n const link = json.links.find(l => l.type === 'application/activity+json');\n\n return link ? link.href : null;\n } catch (e) {\n return null;\n }\n } else {\n return null;\n }\n }, []);\n\n return { fetch };\n};\n\nexport default useWebfinger;\n","import { useMemo } from 'react';\nimport { useGetList } from 'react-admin';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport renderMentions from './renderMentions';\n\nconst useMentions = userResource => {\n const userDataModel = useDataModel(userResource);\n\n const { data } = useGetList(\n userResource,\n {\n filter: {\n _predicates: [userDataModel?.fieldsMapping?.title],\n blankNodes: []\n }\n },\n {\n enabled: !!userDataModel?.fieldsMapping?.title\n }\n );\n\n const availableMentions = useMemo(() => {\n if (data) {\n return data.map(item => ({ id: item.id, label: item[userDataModel?.fieldsMapping?.title] }));\n }\n }, [data]);\n\n const items = useMemo(() => {\n if (availableMentions) {\n return ({ query }) => {\n return availableMentions.filter(({ label }) => label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5);\n };\n }\n }, [availableMentions]);\n\n return {\n items,\n render: renderMentions\n };\n};\n\nexport default useMentions;\n","import { ReactRenderer } from '@tiptap/react';\nimport tippy from 'tippy.js';\nimport MentionsList from './MentionsList';\n\nconst renderMentions = () => {\n let component;\n let popup;\n\n return {\n onStart: props => {\n component = new ReactRenderer(MentionsList, {\n props,\n editor: props.editor\n });\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: 'manual',\n placement: 'bottom-start'\n });\n },\n\n onUpdate(props) {\n component.updateProps(props);\n\n popup[0].setProps({\n getReferenceClientRect: props.clientRect\n });\n },\n\n onKeyDown(props) {\n if (props.event.key === 'Escape') {\n popup[0].hide();\n\n return true;\n }\n\n return component.ref?.onKeyDown(props);\n },\n\n onExit() {\n popup[0].destroy();\n component.destroy();\n }\n };\n};\n\nexport default renderMentions;\n","import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport makeStyles from '@mui/styles/makeStyles';\n\nconst useStyles = makeStyles(theme => ({\n items: {\n background: '#fff',\n borderRadius: '0.5rem',\n boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)',\n color: 'rgba(0, 0, 0, 0.8)',\n fontSize: '0.9rem',\n overflow: 'hidden',\n padding: '0.2rem',\n position: 'relative'\n },\n item: {\n background: 'transparent',\n border: '1px solid transparent',\n borderRadius: '0.4rem',\n display: 'block',\n margin: 0,\n padding: '0.2rem 0.4rem',\n textAlign: 'left',\n width: '100%',\n '&.selected': {\n borderColor: '#000'\n }\n }\n}));\n\nexport default forwardRef((props, ref) => {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const classes = useStyles();\n\n const selectItem = index => {\n const item = props.items[index];\n\n if (item) {\n props.command({ id: item });\n }\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + props.items.length - 1) % props.items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % props.items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n useEffect(() => setSelectedIndex(0), [props.items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === 'ArrowUp') {\n upHandler();\n return true;\n }\n\n if (event.key === 'ArrowDown') {\n downHandler();\n return true;\n }\n\n if (event.key === 'Enter') {\n enterHandler();\n return true;\n }\n\n return false;\n }\n }));\n\n return (\n
\n {props.items.length ? (\n props.items.map((item, index) => (\n selectItem(index)}\n >\n {item.label}\n \n ))\n ) : (\n
Aucun résultat
\n )}\n
\n );\n});\n"],"names":[],"version":3,"file":"index.cjs.js.map"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;;;;;;;;;;;;;;AGAN,MAAM,4CAAiB;IAC5B,QAAQ;IACR,KAAK;IACL,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,kBAAkB;IAClB,kBAAkB;IAClB,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,MAAM;AACR;AAEO,MAAM,4CAAc;IACzB,aAAa;IACb,OAAO;IACP,cAAc;IACd,QAAQ;IACR,SAAS;A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E;QAChB;IACF,GACA;QACE,SAAS,CAAC,CAAC,eAAe,eAAe;IAC3C;IAGF,MAAM,oBAAoB,CAAA,GAAA,oBAAM,EAAE;QAChC,IAAI,MACF,OAAO,KAAK,GAAG,CAAC,CAAA,OAAS,CAAA;gBAAE,IAAI,KAAK,EAAE;gBAAE,OAAO,IAAI,CAAC,eAAe,eAAe,MAAM;YAAC,CAAA;IAE7F,GAAG;QAAC;KAAK;IAET,MAAM,QAAQ,CAAA,GAAA,oBAAM,EAAE;QACpB,IAAI,mBACF,OAAO,CAAC,SAAE,KAAK,EAAE;YACf,OAAO,kBAAkB,MAAM,CAAC,CAAC,SAAE,KAAK,EAAE,GAAK,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,WAAW,KAAK,KAAK,CAAC,GAAG;QAC/G;IAEJ,GAAG;QAAC;KAAkB;IAEtB,OAAO;eACL;QACA,QAAQ,CAAA,GAAA,wCAAa;IACvB;AACF;IAEA,2CAAe;","sources":["packages/activitypub-components/src/index.ts","packages/activitypub-components/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/constants.js","packages/activitypub-components/src/hooks/useOutbox.js","packages/activitypub-components/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/hooks/useCollection.js","packages/activitypub-components/src/utils.ts","packages/activitypub-components/src/components/CollectionList.js","packages/activitypub-components/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/hooks/useCollection.ts","packages/activitypub-components/src/hooks/useInbox.js","packages/activitypub-components/src/hooks/useNodeinfo.js","packages/activitypub-components/src/hooks/useWebfinger.js","packages/activitypub-components/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/hooks/useMentions/MentionsList.js"],"sourcesContent":["// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport PostCommentForm from './PostCommentForm';\nimport CommentsList from './CommentsList';\nimport useCollection from '../../hooks/useCollection';\n\nconst CommentsField = ({ source, context, helperText, placeholder, userResource, mentions }) => {\n const record = useRecordContext();\n const { items: comments, loading, addItem, removeItem } = useCollection(record.replies);\n if (!userResource) throw new Error('No userResource defined for CommentsField');\n return (\n <>\n \n \n \n );\n};\n\nCommentsField.defaultProps = {\n label: 'Commentaires',\n placeholder: 'Commencez à taper votre commentaire...',\n source: 'id', // Ensure the field is always displayed\n context: 'id'\n};\n\nexport default CommentsField;\n","import React, { useState, useCallback } from 'react';\nimport { Form, useGetIdentity, useNotify, useRecordContext } from 'react-admin';\nimport { RichTextInput, DefaultEditorOptions } from 'ra-input-rich-text';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { Button, Box, Avatar } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport SendIcon from '@mui/icons-material/Send';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AuthDialog } from '@semapps/auth-provider';\nimport { OBJECT_TYPES, PUBLIC_URI } from '../../constants';\nimport useOutbox from '../../hooks/useOutbox';\nimport CustomMention from './CustomMention';\n\nconst useStyles = makeStyles(theme => ({\n form: {\n marginTop: -12 // Negative margin to keep the form close to the label\n },\n container: {\n paddingLeft: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 16,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n editorContent: {\n '& > div': {\n backgroundColor: 'rgba(0, 0, 0, 0.09)',\n padding: '2px 12px',\n borderWidth: '0px !important',\n borderRadius: 0,\n borderBottom: '1px solid #FFF',\n minHeight: 60,\n outline: 'unset !important'\n },\n '& > div > p': {\n marginTop: 12,\n marginBottom: 12,\n fontFamily: theme.typography.body1.fontFamily,\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n },\n '& > div > p.is-editor-empty:first-child::before': {\n color: 'grey',\n content: 'attr(data-placeholder)',\n float: 'left',\n height: 0,\n pointerEvents: 'none'\n }\n },\n button: {\n marginTop: -10, // To go over helper text block\n marginBottom: 15\n }\n}));\n\nconst EmptyToolbar = () => null;\n\nconst PostCommentForm = ({ context, placeholder, helperText, mentions, userResource, addItem, removeItem }) => {\n const record = useRecordContext();\n const { data: identity, isLoading } = useGetIdentity();\n const userDataModel = useDataModel(userResource);\n const classes = useStyles();\n const notify = useNotify();\n const outbox = useOutbox();\n const [expanded, setExpanded] = useState(false);\n const [openAuth, setOpenAuth] = useState(false);\n\n const onSubmit = useCallback(\n async values => {\n const document = new DOMParser().parseFromString(values.comment, 'text/html');\n const mentions = Array.from(document.body.getElementsByClassName('mention'));\n const mentionedUsersUris = [];\n\n mentions.forEach(node => {\n const userUri = node.attributes['data-mention-id'].value;\n const userLabel = node.attributes['data-mention-label'].value;\n const link = document.createElement('a');\n link.setAttribute(\n 'href',\n `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`\n );\n link.textContent = `@${userLabel}`;\n node.parentNode.replaceChild(link, node);\n mentionedUsersUris.push(userUri);\n });\n\n if (document.body.innerHTML === 'undefined') {\n notify('Votre commentaire est vide', { type: 'error' });\n } else {\n const tempId = Date.now();\n\n const note = {\n type: OBJECT_TYPES.NOTE,\n attributedTo: outbox.owner,\n content: document.body.innerHTML,\n inReplyTo: record[context],\n published: new Date().toISOString()\n };\n\n try {\n addItem({ id: tempId, ...note });\n // TODO reset the form\n setExpanded(false);\n await outbox.post({ ...note, to: [...mentionedUsersUris, PUBLIC_URI] });\n notify('Commentaire posté avec succès', { type: 'success' });\n } catch (e) {\n console.error(e);\n removeItem(tempId);\n notify(e.message, { type: 'error' });\n }\n }\n },\n [outbox, notify, setExpanded, addItem, removeItem]\n );\n\n const openAuthIfDisconnected = useCallback(() => {\n if (!identity?.id) {\n setOpenAuth(true);\n }\n }, [identity, setOpenAuth]);\n\n // Don't init the editor options until mentions and identity are loaded, as they can only be initialized once\n if ((mentions && !mentions.items) || isLoading) return null;\n\n return (\n <>\n
\n \n \n }\n fullWidth\n classes={{ editorContent: classes.editorContent }}\n editorOptions={{\n ...DefaultEditorOptions,\n onFocus() {\n setExpanded(true);\n },\n extensions: [\n ...DefaultEditorOptions.extensions,\n placeholder ? Placeholder.configure({ placeholder }) : null,\n mentions\n ? CustomMention.configure({\n HTMLAttributes: {\n class: 'mention'\n },\n suggestion: mentions\n })\n : null\n ],\n // Disable editor if user is not connected\n editable: !!identity?.id\n }}\n helperText={helperText}\n />\n {expanded && (\n }\n className={classes.button}\n >\n Envoyer\n \n )}\n \n
\n setOpenAuth(false)}\n message=\"Pour poster un commentaire, vous devez être connecté.\"\n />\n \n );\n};\n\nexport default PostCommentForm;\n","export const ACTIVITY_TYPES = {\n ACCEPT: 'Accept',\n ADD: 'Add',\n ANNOUNCE: 'Announce',\n ARRIVE: 'Arrive',\n BLOCK: 'Block',\n CREATE: 'Create',\n DELETE: 'Delete',\n DISLIKE: 'Dislike',\n FLAG: 'Flag',\n FOLLOW: 'Follow',\n IGNORE: 'Ignore',\n INVITE: 'Invite',\n JOIN: 'Join',\n LEAVE: 'Leave',\n LIKE: 'Like',\n LISTEN: 'Listen',\n MOVE: 'Move',\n OFFER: 'Offer',\n QUESTION: 'Question',\n REJECT: 'Reject',\n READ: 'Read',\n REMOVE: 'Remove',\n TENTATIVE_REJECT: 'TentativeReject',\n TENTATIVE_ACCEPT: 'TentativeAccept',\n TRAVEL: 'Travel',\n UNDO: 'Undo',\n UPDATE: 'Update',\n VIEW: 'View'\n};\n\nexport const ACTOR_TYPES = {\n APPLICATION: 'Application',\n GROUP: 'Group',\n ORGANIZATION: 'Organization',\n PERSON: 'Person',\n SERVICE: 'Service'\n};\n\nexport const OBJECT_TYPES = {\n ARTICLE: 'Article',\n AUDIO: 'Audio',\n DOCUMENT: 'Document',\n EVENT: 'Event',\n IMAGE: 'Image',\n NOTE: 'Note',\n PAGE: 'Page',\n PLACE: 'Place',\n PROFILE: 'Profile',\n RELATIONSHIP: 'Relationship',\n TOMBSTONE: 'Tombstone',\n VIDEO: 'Video'\n};\n\nexport const PUBLIC_URI = 'https://www.w3.org/ns/activitystreams#Public';\n","import { useCallback, useMemo } from 'react';\nimport { useGetIdentity, fetchUtils } from 'react-admin';\nimport { buildBlankNodesQuery } from '@semapps/semantic-data-provider';\n\nconst useOutbox = () => {\n const { data: identity } = useGetIdentity();\n\n const outboxUrl = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.outbox;\n }\n }, [identity]);\n\n const sparqlEndpoint = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.endpoints?.['void:sparqlEndpoint'] || `${identity?.id}/sparql`;\n }\n }, [identity]);\n\n // Post an activity to the logged user's outbox and return its URI\n const post = useCallback(\n async activity => {\n if (!outboxUrl)\n throw new Error(\n 'Cannot post to outbox before user identity is loaded. Please use the loaded argument of useOutbox'\n );\n const token = localStorage.getItem('token');\n const { headers } = await fetchUtils.fetchJson(outboxUrl, {\n method: 'POST',\n body: JSON.stringify({\n '@context': 'https://www.w3.org/ns/activitystreams',\n ...activity\n }),\n headers: new Headers({\n 'Content-Type': 'application/ld+json',\n Authorization: `Bearer ${token}`\n })\n });\n return headers.get('Location');\n },\n [outboxUrl]\n );\n\n const fetch = useCallback(async () => {\n if (!sparqlEndpoint || !outboxUrl) return;\n\n const token = localStorage.getItem('token');\n const blankNodesQuery = buildBlankNodesQuery(['as:object']);\n\n const query = `\n PREFIX as: \n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.construct}\n }\n WHERE {\n <${outboxUrl}> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.where}\n }\n `;\n\n const { json } = await fetchUtils.fetchJson(sparqlEndpoint, {\n method: 'POST',\n body: query,\n headers: new Headers({\n Accept: 'application/ld+json',\n Authorization: token ? `Bearer ${token}` : undefined\n })\n });\n\n if (json['@graph']) {\n return json['@graph'];\n }\n return null;\n }, [sparqlEndpoint, outboxUrl]);\n\n return { post, fetch, url: outboxUrl, loaded: !!outboxUrl, owner: identity?.id };\n};\n\nexport default useOutbox;\n","import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\n\n// Fix a bug in the current version of the mention extension\n// (The { id, label } object is located inside the id property)\n// See https://github.com/ueberdosis/tiptap/pull/1322\nconst CustomMention = Mention.extend({\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id.label}`];\n },\n addAttributes() {\n return {\n label: {\n default: null,\n parseHTML: element => {\n return {\n label: element.getAttribute('data-mention-label')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.label) {\n return {};\n }\n return {\n 'data-mention-label': attributes.id.label\n };\n }\n },\n id: {\n default: null,\n parseHTML: element => {\n return {\n id: element.getAttribute('data-mention-id')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.id) {\n return {};\n }\n return {\n 'data-mention-id': attributes.id.id\n };\n }\n }\n };\n }\n});\n\nexport default CustomMention;\n","import React from 'react';\nimport { TextField, RichTextField, DateField } from 'react-admin';\nimport { Box, Typography, CircularProgress } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AvatarWithLabelField, ReferenceField } from '@semapps/field-components';\n\nconst useStyles = makeStyles(() => ({\n container: {\n paddingLeft: 80,\n marginTop: 8,\n minHeight: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n text: {\n paddingTop: 2,\n paddingBottom: 8\n },\n label: {\n fontWeight: 'bold'\n },\n content: {\n '& p': {\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n }\n },\n loading: {\n zIndex: 1000,\n backgroundColor: 'white',\n opacity: 0.5,\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n marginTop: 5\n }\n}));\n\nconst CommentsList = ({ comments, userResource, loading }) => {\n const classes = useStyles();\n const userDataModel = useDataModel(userResource);\n return (\n \n {comments &&\n comments\n .sort((a, b) => new Date(b.published) - new Date(a.published))\n .map(comment => (\n \n \n \n \n \n \n \n \n \n \n \n  • \n \n \n \n \n \n ))}\n {loading && (\n \n \n \n \n \n )}\n \n );\n};\n\nexport default CommentsList;\n","import { useCallback, useMemo, useState, useEffect } from 'react';\nimport { useGetIdentity, useDataProvider } from 'react-admin';\nimport { useInfiniteQuery, useQueries } from 'react-query';\nimport { getOrCreateWsChannel } from '@semapps/semantic-data-provider';\nimport { arrayOf } from '../utils';\n\nconst useItemsFromPagesAndNotifications = (pages, notifications, dereferenceItems) => {\n const dataProvider = useDataProvider();\n\n // Add all items from pages and process notifications (possibly new and deleted items).\n const items = useMemo(\n () => {\n const addItems = notifications.map(n => n.type === 'Add').map(n => n.object);\n const removeItems = notifications.map(n => n.type === 'Remove').map(n => n.object.id || n.object);\n const currentItems = !pages ? [] : pages.flatMap(p => arrayOf(p.orderedItems || p.items));\n const currentAndNew = currentItems.concat(addItems);\n\n return (\n currentAndNew\n // Filter out removed items.\n .filter(item => !removeItems.some(r => (r.id ?? r) === (item.id ?? item)))\n // Filter duplicates.\n .filter(item => currentAndNew.some(i2 => (i2.id ?? i2) === (item.id ?? item)))\n );\n },\n pages,\n notifications\n );\n\n if (!dereferenceItems) {\n return { loadedItems: items, isLoading: false, isFetching: false };\n }\n\n // Dereference all items, if they are not yet.\n const itemQueries = useQueries(\n items\n .filter(item => typeof item === 'string')\n .map(itemUri => ({\n queryKey: ['resource', itemUri],\n queryFn: async () => (await dataProvider.fetch(itemUri)).json,\n staleTime: Infinity\n }))\n );\n\n // Put all loaded items together (might be dereferenced already, so concatenate).\n const loadedItems = items\n .filter(item => typeof item !== 'string')\n .concat(\n itemQueries.flatMap(itemQuery => {\n return (itemQuery.isSuccess && itemQuery.data) || [];\n })\n );\n\n console.log('loadedItems', loadedItems.length, 'total', items.length);\n\n const errors = itemQueries.filter(q => q.error);\n return {\n loadedItems,\n isLoading: itemQueries.some(q => q.isLoading),\n isFetching: itemQueries.some(q => q.isFetching),\n errors: errors.length > 0 && errors\n };\n};\n\nconst useCollection = (predicateOrUrl, options = {}) => {\n const { dereferenceItems = false, liveUpdates = true } = options;\n const { data: identity } = useGetIdentity();\n const [totalItems, setTotalItems] = useState();\n const [notifications, setNotifications] = useState([]);\n const [hasLiveUpdates, setHasLiveUpdates] = useState({ status: 'disconnected', error: undefined });\n const dataProvider = useDataProvider();\n\n // Get collectionUrl from webId predicate or URL.\n const collectionUrl = useMemo(() => {\n if (predicateOrUrl) {\n if (predicateOrUrl.startsWith('http')) {\n return predicateOrUrl;\n }\n if (identity?.webIdData) {\n return identity?.webIdData?.[predicateOrUrl];\n }\n }\n return undefined;\n // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`);\n }, [identity, predicateOrUrl]);\n\n // Fetch page of collection item references (if pageParam provided)\n // or default to `collectionUrl` (which should give you the first page).\n const fetchCollection = useCallback(\n async ({ pageParam: nextPageUrl }) => {\n // Fetch page or first page (collectionUrl)\n let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl);\n if (json.totalItems) setTotalItems(json.totalItems);\n\n // If first page, handle this here.\n if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {\n if (json.first?.items) {\n if (json.first?.items.length === 0 && json.first?.next) {\n // Special case where the first property is an object without items\n ({ json } = await dataProvider.fetch(json.first?.next));\n } else {\n json = json.first;\n }\n } else {\n // Fetch the first page\n ({ json } = await dataProvider.fetch(json.first));\n }\n }\n\n return json;\n },\n [dataProvider, collectionUrl, identity, setTotalItems]\n );\n\n // Use infiniteQuery to handle pagination, fetching, etc.\n const {\n data,\n error: collectionError,\n fetchNextPage,\n refetch,\n hasNextPage,\n isLoading: isLoadingPage,\n isFetching: isFetchingPage,\n isFetchingNextPage\n } = useInfiniteQuery(['collection', { collectionUrl }], fetchCollection, {\n enabled: !!(collectionUrl && identity?.id),\n getNextPageParam: lastPage => lastPage.next,\n getPreviousPageParam: firstPage => firstPage.prev\n });\n\n // Put all items together in a list.\n const {\n loadedItems: items,\n isLoading: isLoadingItems,\n isFetching: isFetchingItems,\n errors: itemErrors\n } = useItemsFromPagesAndNotifications(data?.pages, notifications, dereferenceItems);\n // Notifications have been processed after hook call, so reset.\n // useEffect(() => {\n // setNotifications([]);\n // }, [notifications])\n\n // Live Updates\n useEffect(() => {\n if (liveUpdates && collectionUrl) {\n // Create ws that listens to collectionUri changes\n getOrCreateWsChannel(dataProvider.fetch, collectionUrl)\n .then(webSocket => {\n webSocket.addEventListener('message', e => {\n if ((e.data && e.data.type === 'Add') || e.data.type === 'Remove') {\n setNotifications([...notifications, e.data]);\n }\n });\n webSocket.addEventListener('error', e => {\n setHasLiveUpdates({ status: 'error', error: e });\n // TODO: Retry after a while\n });\n webSocket.addEventListener('close', e => {\n setHasLiveUpdates({ ...hasLiveUpdates, status: 'disconnected' });\n });\n setHasLiveUpdates({ status: 'connected' });\n })\n .catch(() => {}); // If it fails, we won't receive live updates. But that's okay.\n }\n }, [collectionUrl, liveUpdates, dataProvider.fetch]);\n\n const allErrors = arrayOf(collectionError).concat(arrayOf(itemErrors));\n\n return {\n items,\n totalItems,\n error: allErrors.length > 0 && allErrors,\n refetch,\n fetchNextPage,\n hasNextPage,\n isLoading: isLoadingPage || isLoadingItems,\n isFetching: isFetchingPage || isFetchingItems,\n isFetchingNextPage,\n url: collectionUrl,\n hasLiveUpdates\n };\n};\n\nexport default useCollection;\n","export const arrayOf = (value: T | T[]) => {\n // If the field is null-ish, we suppose there are no values.\n if (value === null || value === undefined) {\n return [];\n }\n // Return as is.\n if (Array.isArray(value)) {\n return value;\n }\n // Single value is made an array.\n return [value];\n};\n\nexport default {\n arrayOf\n};\n\nexport const filterDuplicates = (iterable: T[], predicate: (item: T) => string) => {\n const seen = new Set();\n return iterable.filter(item => {\n const key = predicate(item);\n if (seen.has(key)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n};\n","import React from 'react';\nimport { useList, ListContextProvider, useGetMany } from 'react-admin';\nimport useCollection from '../hooks/useCollection';\n\nconst CollectionList = ({ collectionUrl, resource, children }) => {\n if (React.Children.count(children) !== 1) {\n throw new Error(' only accepts a single child');\n }\n\n const { items: actorsUris } = useCollection(collectionUrl);\n\n const { data, isLoading, isFetching } = useGetMany(\n resource,\n { ids: Array.isArray(actorsUris) ? actorsUris : [actorsUris] },\n { enabled: !!actorsUris }\n );\n\n const listContext = useList({ data, isLoading, isFetching });\n\n return {children};\n};\n\nexport default CollectionList;\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport CollectionList from './CollectionList';\n\nconst ReferenceCollectionField = ({ source, reference, children, ...rest }) => {\n const record = useRecordContext();\n\n if (React.Children.count(children) !== 1) {\n throw new Error(' only accepts a single child');\n }\n\n if (!record || !record[source]) return null;\n\n return (\n \n {children}\n \n );\n};\n\nexport default ReferenceCollectionField;\n","import { useCallback, useMemo, useState, useEffect } from 'react';\nimport { useGetIdentity, useDataProvider } from 'react-admin';\nimport { QueryFunction, useInfiniteQuery, useQueries, useQueryClient } from 'react-query';\nimport { getOrCreateWsChannel } from '@semapps/semantic-data-provider';\nimport { arrayOf } from '../utils';\n\nconst useItemsFromPages = (pages: any[], dereferenceItems: boolean) => {\n const dataProvider = useDataProvider();\n const items = useMemo(() => pages.flatMap(p => arrayOf(p.orderedItems || p.items)), [pages]);\n\n // We will force dereference, if some items are not URI string references.\n const shouldDereference = useMemo(() => {\n return dereferenceItems || items.some(item => typeof item !== 'string');\n }, [dereferenceItems, items]);\n\n // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called).\n const itemQueries = useQueries(\n !shouldDereference\n ? []\n : items\n .filter(item => typeof item === 'string')\n .map(itemUri => ({\n queryKey: ['resource', itemUri],\n queryFn: async () => (await dataProvider.fetch(itemUri)).json,\n staleTime: Infinity\n }))\n );\n\n if (!shouldDereference) {\n return { loadedItems: items, isLoading: false, isFetching: false };\n }\n\n // Put all loaded items together (might be dereferenced already, so concatenate).\n const loadedItems = items\n .filter(item => typeof item !== 'string')\n .concat(\n itemQueries.flatMap(itemQuery => {\n return (itemQuery.isSuccess && itemQuery.data) || [];\n })\n );\n\n const errors = itemQueries.filter(q => q.error);\n return {\n loadedItems,\n isLoading: itemQueries.some(q => q.isLoading),\n isFetching: itemQueries.some(q => q.isFetching),\n errors: errors.length > 0 ? errors : undefined\n };\n};\n\ninterface UseCollectionOptions {\n dereferenceItems?: boolean;\n liveUpdates?: boolean;\n}\n\n/**\n * Subscribe a collection. Supports pagination.\n * @param predicateOrUrl The collection URI or the predicate to get the collection URI from the identity (webId).\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useCollection = (predicateOrUrl: string, options: UseCollectionOptions = {}) => {\n const { dereferenceItems = false, liveUpdates = true } = options;\n const { data: identity } = useGetIdentity();\n const [totalItems, setTotalItems] = useState();\n const queryClient = useQueryClient();\n const [hasLiveUpdates, setHasLiveUpdates] = useState<{ status: string; error?: any }>({ status: 'connecting' });\n const dataProvider = useDataProvider();\n\n // Get collectionUrl from webId predicate or URL.\n const collectionUrl = useMemo(() => {\n if (predicateOrUrl) {\n if (predicateOrUrl.startsWith('http')) {\n return predicateOrUrl;\n }\n if (identity?.webIdData) {\n return identity?.webIdData?.[predicateOrUrl];\n }\n }\n return undefined;\n // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`);\n }, [identity, predicateOrUrl]);\n\n // Fetch page of collection item references (if pageParam provided)\n // or default to `collectionUrl` (which should give you the first page).\n const fetchCollection: QueryFunction = useCallback(\n async ({ pageParam: nextPageUrl }) => {\n // Fetch page or first page (collectionUrl)\n let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl);\n if (json.totalItems) setTotalItems(json.totalItems);\n\n // If first page, handle this here.\n if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {\n if (json.first?.items) {\n if (json.first?.items.length === 0 && json.first?.next) {\n // Special case where the first property is an object without items\n ({ json } = await dataProvider.fetch(json.first?.next));\n } else {\n json = json.first;\n }\n } else {\n // Fetch the first page\n ({ json } = await dataProvider.fetch(json.first));\n }\n }\n\n return json;\n },\n [dataProvider, collectionUrl, identity, setTotalItems]\n );\n\n // Use infiniteQuery to handle pagination, fetching, etc.\n const {\n data: pageData,\n error: collectionError,\n fetchNextPage,\n refetch,\n hasNextPage,\n isLoading: isLoadingPage,\n isFetching: isFetchingPage,\n isFetchingNextPage\n } = useInfiniteQuery(['collection', { collectionUrl }], fetchCollection, {\n enabled: !!(collectionUrl && identity?.id),\n getNextPageParam: (lastPage: any) => lastPage.next,\n getPreviousPageParam: (firstPage: any) => firstPage.prev\n });\n\n // Put all items together in a list (and dereference, if required).\n const {\n loadedItems: items,\n isLoading: isLoadingItems,\n isFetching: isFetchingItems,\n errors: itemErrors\n } = useItemsFromPages(pageData?.pages ?? [], dereferenceItems);\n\n const allErrors = arrayOf(collectionError).concat(arrayOf(itemErrors));\n\n const addItem = useCallback(\n (item: string | any, shouldRefetch: boolean | number = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems + 1);\n\n // Destructure, so react knows, it needs to re-render the pages.\n const pages = [...oldData.pages];\n const firstPageItems: any[] = pages?.[0]?.orderedItems || pages?.[0]?.items || [];\n firstPageItems.unshift(item);\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n const removeItem = useCallback(\n (item: string | any, shouldRefetch: boolean = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems - 1);\n\n // Destructure, so react knows, it needs to re-render the pages array.\n const pages = [...oldData.pages];\n // Find the item in all pages and remove the item to be removed (either item.id or just item)\n pages.forEach(page => {\n if (page.orderedItems) {\n page.orderedItems = page.orderedItems.filter((i: any) => (i.id || i) !== (item.id || item));\n } else if (page.items) {\n page.items = page.items.filter((i: any) => (i.id || i) !== (item?.id || item));\n }\n });\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n // Live Updates\n useEffect(() => {\n if (liveUpdates && collectionUrl) {\n // Create ws that listens to collectionUri changes\n getOrCreateWsChannel(dataProvider.fetch, collectionUrl)\n .then(webSocket => {\n webSocket.addEventListener('message', e => {\n const data = JSON.parse(e.data);\n if (data && data.type === 'Add') {\n addItem(data.object, true);\n } else if (data && data.type === 'Remove') {\n removeItem(data.object, true);\n }\n });\n webSocket.addEventListener('error', e => {\n setHasLiveUpdates({ status: 'error', error: e });\n // TODO: Retry after a while\n });\n webSocket.addEventListener('close', e => {\n if (!hasLiveUpdates.error) {\n setHasLiveUpdates({ ...hasLiveUpdates, status: 'closed' });\n }\n });\n setHasLiveUpdates({ status: 'connected' });\n })\n .catch(() => {}); // If it fails, we won't receive live updates. But that's okay.\n }\n }, [collectionUrl, liveUpdates, dataProvider]);\n\n return {\n items,\n totalItems,\n error: allErrors.length > 0 && allErrors,\n refetch,\n fetchNextPage,\n addItem,\n removeItem,\n hasNextPage,\n isLoading: isLoadingPage || isLoadingItems,\n isFetching: isFetchingPage || isFetchingItems,\n isFetchingNextPage,\n url: collectionUrl,\n hasLiveUpdates\n };\n};\n\nexport default useCollection;\n","import { useCallback, useMemo } from 'react';\nimport { useGetIdentity, fetchUtils } from 'react-admin';\nimport { buildBlankNodesQuery } from '@semapps/semantic-data-provider';\n\nconst useInbox = () => {\n const { data: identity } = useGetIdentity();\n\n const inboxUrl = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.inbox;\n }\n }, [identity]);\n\n const sparqlEndpoint = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.endpoints?.['void:sparqlEndpoint'] || `${identity?.id}/sparql`;\n }\n }, [identity]);\n\n const fetch = useCallback(\n async ({ filters }) => {\n if (!sparqlEndpoint || !inboxUrl) return;\n\n const token = localStorage.getItem('token');\n const blankNodesQuery = buildBlankNodesQuery(['as:object']);\n\n let filtersWhereQuery = '';\n if (filters) {\n Object.keys(filters).forEach(predicate => {\n if (filters[predicate]) {\n const object = filters[predicate].startsWith('http') ? `<${filters[predicate]}>` : filters[predicate];\n filtersWhereQuery += `?s1 ${predicate} ${object} .`;\n }\n });\n }\n\n const query = `\n PREFIX as: \n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.construct}\n }\n WHERE {\n <${inboxUrl}> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n FILTER( (isIRI(?s1)) ) .\n ${filtersWhereQuery}\n ${blankNodesQuery.where}\n }\n `;\n\n const { json } = await fetchUtils.fetchJson(sparqlEndpoint, {\n method: 'POST',\n body: query,\n headers: new Headers({\n Accept: 'application/ld+json',\n Authorization: token ? `Bearer ${token}` : undefined\n })\n });\n\n if (json['@graph']) {\n return json['@graph'];\n }\n return null;\n },\n [sparqlEndpoint, inboxUrl]\n );\n\n return { fetch, url: inboxUrl, owner: identity?.id };\n};\n\nexport default useInbox;\n","import { useEffect, useState } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useNodeinfo = (host, rel = 'http://nodeinfo.diaspora.software/ns/schema/2.1') => {\n const [schema, setSchema] = useState();\n\n useEffect(() => {\n (async () => {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are likely on HTTP\n const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;\n\n try {\n const { json: links } = await fetchUtils.fetchJson(nodeinfoUrl);\n\n // Accept any version of the nodeinfo protocol\n const link = links?.links?.find(l => l.rel === rel);\n\n const { json } = await fetchUtils.fetchJson(link.href);\n\n setSchema(json);\n } catch (e) {\n // Do nothing if nodeinfo can't be fetched\n }\n })();\n }, [host, setSchema, rel]);\n\n return schema;\n};\n\nexport default useNodeinfo;\n","import { useCallback } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useWebfinger = () => {\n // Post an activity to the logged user's outbox and return its URI\n const fetch = useCallback(async id => {\n // eslint-disable-next-line\n const [_, username, host] = id.split('@');\n if (host) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are most likely on localhost\n const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;\n\n try {\n const { json } = await fetchUtils.fetchJson(webfingerUrl);\n\n const link = json.links.find(l => l.type === 'application/activity+json');\n\n return link ? link.href : null;\n } catch (e) {\n return null;\n }\n } else {\n return null;\n }\n }, []);\n\n return { fetch };\n};\n\nexport default useWebfinger;\n","import { useMemo } from 'react';\nimport { useGetList } from 'react-admin';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport renderMentions from './renderMentions';\n\nconst useMentions = userResource => {\n const userDataModel = useDataModel(userResource);\n\n const { data } = useGetList(\n userResource,\n {\n filter: {\n _predicates: [userDataModel?.fieldsMapping?.title],\n blankNodes: []\n }\n },\n {\n enabled: !!userDataModel?.fieldsMapping?.title\n }\n );\n\n const availableMentions = useMemo(() => {\n if (data) {\n return data.map(item => ({ id: item.id, label: item[userDataModel?.fieldsMapping?.title] }));\n }\n }, [data]);\n\n const items = useMemo(() => {\n if (availableMentions) {\n return ({ query }) => {\n return availableMentions.filter(({ label }) => label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5);\n };\n }\n }, [availableMentions]);\n\n return {\n items,\n render: renderMentions\n };\n};\n\nexport default useMentions;\n","import { ReactRenderer } from '@tiptap/react';\nimport tippy from 'tippy.js';\nimport MentionsList from './MentionsList';\n\nconst renderMentions = () => {\n let component;\n let popup;\n\n return {\n onStart: props => {\n component = new ReactRenderer(MentionsList, {\n props,\n editor: props.editor\n });\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: 'manual',\n placement: 'bottom-start'\n });\n },\n\n onUpdate(props) {\n component.updateProps(props);\n\n popup[0].setProps({\n getReferenceClientRect: props.clientRect\n });\n },\n\n onKeyDown(props) {\n if (props.event.key === 'Escape') {\n popup[0].hide();\n\n return true;\n }\n\n return component.ref?.onKeyDown(props);\n },\n\n onExit() {\n popup[0].destroy();\n component.destroy();\n }\n };\n};\n\nexport default renderMentions;\n","import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport makeStyles from '@mui/styles/makeStyles';\n\nconst useStyles = makeStyles(theme => ({\n items: {\n background: '#fff',\n borderRadius: '0.5rem',\n boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)',\n color: 'rgba(0, 0, 0, 0.8)',\n fontSize: '0.9rem',\n overflow: 'hidden',\n padding: '0.2rem',\n position: 'relative'\n },\n item: {\n background: 'transparent',\n border: '1px solid transparent',\n borderRadius: '0.4rem',\n display: 'block',\n margin: 0,\n padding: '0.2rem 0.4rem',\n textAlign: 'left',\n width: '100%',\n '&.selected': {\n borderColor: '#000'\n }\n }\n}));\n\nexport default forwardRef((props, ref) => {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const classes = useStyles();\n\n const selectItem = index => {\n const item = props.items[index];\n\n if (item) {\n props.command({ id: item });\n }\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + props.items.length - 1) % props.items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % props.items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n useEffect(() => setSelectedIndex(0), [props.items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === 'ArrowUp') {\n upHandler();\n return true;\n }\n\n if (event.key === 'ArrowDown') {\n downHandler();\n return true;\n }\n\n if (event.key === 'Enter') {\n enterHandler();\n return true;\n }\n\n return false;\n }\n }));\n\n return (\n
\n {props.items.length ? (\n props.items.map((item, index) => (\n selectItem(index)}\n >\n {item.label}\n \n ))\n ) : (\n
Aucun résultat
\n )}\n
\n );\n});\n"],"names":[],"version":3,"file":"index.cjs.js.map"} \ No newline at end of file diff --git a/src/frontend/packages/activitypub-components/dist/index.d.ts b/src/frontend/packages/activitypub-components/dist/index.d.ts index e3fa11ff6..baec2400d 100644 --- a/src/frontend/packages/activitypub-components/dist/index.d.ts +++ b/src/frontend/packages/activitypub-components/dist/index.d.ts @@ -23,7 +23,7 @@ export declare namespace ACTIVITY_TYPES { let REMOVE: string; let TENTATIVE_REJECT: string; let TENTATIVE_ACCEPT: string; - let TRAVAL: string; + let TRAVEL: string; let UNDO: string; let UPDATE: string; let VIEW: string; @@ -57,30 +57,39 @@ export function useOutbox(): { loaded: boolean; owner: import('react-admin').Identifier | undefined; }; -declare namespace _default { - export { arrayOf }; +interface UseCollectionOptions { + dereferenceItems?: boolean; + liveUpdates?: boolean; } -export function useCollection( - predicateOrUrl: any, - options?: {} -): { - items: undefined; - totalItems: undefined; - error: unknown; +/** + * Subscribe a collection. Supports pagination. + * @param predicateOrUrl The collection URI or the predicate to get the collection URI from the identity (webId). + * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }` + */ +export const useCollection: ( + predicateOrUrl: string, + options?: UseCollectionOptions +) => { + items: any[]; + totalItems: number | undefined; + error: false | unknown[]; refetch: ( options?: (import('react-query').RefetchOptions & import('react-query').RefetchQueryFilters) | undefined ) => Promise, unknown>>; fetchNextPage: ( options?: import('react-query').FetchNextPageOptions | undefined ) => Promise>; + addItem: (item: string | any, shouldRefetch?: boolean | number) => void; + removeItem: (item: string | any, shouldRefetch?: boolean) => void; hasNextPage: boolean | undefined; isLoading: boolean; isFetching: boolean; isFetchingNextPage: boolean; - status: 'success' | 'error' | 'loading' | 'idle'; - addItem: (item: any) => void; - removeItem: (itemId: any) => void; url: any; + hasLiveUpdates: { + status: string; + error?: any; + }; }; export function CommentsField({ source, diff --git a/src/frontend/packages/activitypub-components/dist/index.d.ts.map b/src/frontend/packages/activitypub-components/dist/index.d.ts.map index 57761a40b..088508b1f 100644 --- a/src/frontend/packages/activitypub-components/dist/index.d.ts.map +++ b/src/frontend/packages/activitypub-components/dist/index.d.ts.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,wEAAyE;AClDzE;;;;;;EA0EC;;;;AKzED;;;;;;;;;;;;;;EAuHC;ACtHD;;;;;;;4CAkBC;;;;;;;;;ACpBD;;;;4CAgBC;AChBD;;;;;mDAcC;ACdD;;;;;;EAiEC;AClED,gEAwBC;ACxBD;;EAwBC;AGtBD;;;;;;;;;;;;;EAkCC","sources":["packages/activitypub-components/src/src/constants.js","packages/activitypub-components/src/src/hooks/useOutbox.js","packages/activitypub-components/src/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/src/utils.js","packages/activitypub-components/src/src/hooks/useCollection.js","packages/activitypub-components/src/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/src/components/CollectionList.js","packages/activitypub-components/src/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/src/hooks/useInbox.js","packages/activitypub-components/src/src/hooks/useNodeinfo.js","packages/activitypub-components/src/src/hooks/useWebfinger.js","packages/activitypub-components/src/src/hooks/useMentions/MentionsList.js","packages/activitypub-components/src/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/src/index.ts","packages/activitypub-components/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n"],"names":[],"version":3,"file":"index.d.ts.map"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,wEAAyE;AClDzE;;;;;;EA0EC;AK5BD;IACE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,OAAA,MAAM,gCAAiC,MAAM,YAAW,oBAAoB;;;;;;oBA6EjE,MAAM,GAAG,GAAG,kBAAiB,OAAO,GAAG,MAAM;uBA4B7C,MAAM,GAAG,GAAG,kBAAiB,OAAO;;;;;;;gBApGkB,MAAM;gBAAU,GAAG;;CAiLnF,CAAC;AC5OF;;;;;;;4CAkBC;;;;;;;;;ACpBD;;;;4CAgBC;AChBD;;;;;mDAcC;ACdD;;;;;;EAiEC;AClED,gEAwBC;ACxBD;;EAwBC;AGtBD;;;;;;;;;;;;;EAkCC","sources":["packages/activitypub-components/src/src/constants.js","packages/activitypub-components/src/src/hooks/useOutbox.js","packages/activitypub-components/src/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/src/utils.ts","packages/activitypub-components/src/src/hooks/useCollection.ts","packages/activitypub-components/src/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/src/components/CollectionList.js","packages/activitypub-components/src/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/src/hooks/useInbox.js","packages/activitypub-components/src/src/hooks/useNodeinfo.js","packages/activitypub-components/src/src/hooks/useWebfinger.js","packages/activitypub-components/src/src/hooks/useMentions/MentionsList.js","packages/activitypub-components/src/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/src/index.ts","packages/activitypub-components/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n"],"names":[],"version":3,"file":"index.d.ts.map"} \ No newline at end of file diff --git a/src/frontend/packages/activitypub-components/dist/index.es.js b/src/frontend/packages/activitypub-components/dist/index.es.js index 4774e2cda..08391a2dd 100644 --- a/src/frontend/packages/activitypub-components/dist/index.es.js +++ b/src/frontend/packages/activitypub-components/dist/index.es.js @@ -6,12 +6,12 @@ import $85cNH$tiptapextensionplaceholder from "@tiptap/extension-placeholder"; import {Box as $85cNH$Box, Avatar as $85cNH$Avatar, Button as $85cNH$Button, Typography as $85cNH$Typography, CircularProgress as $85cNH$CircularProgress} from "@mui/material"; import $85cNH$muistylesmakeStyles from "@mui/styles/makeStyles"; import $85cNH$muiiconsmaterialSend from "@mui/icons-material/Send"; -import {useDataModel as $85cNH$useDataModel, buildBlankNodesQuery as $85cNH$buildBlankNodesQuery} from "@semapps/semantic-data-provider"; +import {useDataModel as $85cNH$useDataModel, buildBlankNodesQuery as $85cNH$buildBlankNodesQuery, getOrCreateWsChannel as $85cNH$getOrCreateWsChannel} from "@semapps/semantic-data-provider"; import {AuthDialog as $85cNH$AuthDialog} from "@semapps/auth-provider"; import {mergeAttributes as $85cNH$mergeAttributes} from "@tiptap/core"; import $85cNH$tiptapextensionmention from "@tiptap/extension-mention"; import {ReferenceField as $85cNH$ReferenceField, AvatarWithLabelField as $85cNH$AvatarWithLabelField} from "@semapps/field-components"; -import {useQueryClient as $85cNH$useQueryClient, useInfiniteQuery as $85cNH$useInfiniteQuery} from "react-query"; +import {useQueries as $85cNH$useQueries, useInfiniteQuery as $85cNH$useInfiniteQuery, useQueryClient as $85cNH$useQueryClient} from "react-query"; import {ReactRenderer as $85cNH$ReactRenderer} from "@tiptap/react"; import $85cNH$tippyjs from "tippy.js"; @@ -54,7 +54,7 @@ const $338f387df48a40d7$export$1ec8e53e7d982d22 = { REMOVE: "Remove", TENTATIVE_REJECT: "TentativeReject", TENTATIVE_ACCEPT: "TentativeAccept", - TRAVAL: "Travel", + TRAVEL: "Travel", UNDO: "Undo", UPDATE: "Update", VIEW: "View" @@ -524,7 +524,8 @@ var $be88b298220210d1$export$2e2bcd8739ae039 = $be88b298220210d1$var$CommentsLis -const $e4e1b14e0441184d$export$e57ff0f701c44363 = (value)=>{ + +const $577f4953dfa5de4f$export$e57ff0f701c44363 = (value)=>{ // If the field is null-ish, we suppose there are no values. if (value === null || value === undefined) return []; // Return as is. @@ -534,30 +535,88 @@ const $e4e1b14e0441184d$export$e57ff0f701c44363 = (value)=>{ value ]; }; -var $e4e1b14e0441184d$export$2e2bcd8739ae039 = { - arrayOf: $e4e1b14e0441184d$export$e57ff0f701c44363 +var $577f4953dfa5de4f$export$2e2bcd8739ae039 = { + arrayOf: $577f4953dfa5de4f$export$e57ff0f701c44363 +}; +const $577f4953dfa5de4f$export$34aed805e991a647 = (iterable, predicate)=>{ + const seen = new Set(); + return iterable.filter((item)=>{ + const key = predicate(item); + if (seen.has(key)) return false; + seen.add(key); + return true; + }); }; +const $c1e897431d8c5742$var$useItemsFromPagesAndNotifications = (pages, notifications, dereferenceItems)=>{ + const dataProvider = (0, $85cNH$useDataProvider)(); + // Add all items from pages and process notifications (possibly new and deleted items). + const items = (0, $85cNH$useMemo)(()=>{ + const addItems = notifications.map((n)=>n.type === "Add").map((n)=>n.object); + const removeItems = notifications.map((n)=>n.type === "Remove").map((n)=>n.object.id || n.object); + const currentItems = !pages ? [] : pages.flatMap((p)=>(0, $577f4953dfa5de4f$export$e57ff0f701c44363)(p.orderedItems || p.items)); + const currentAndNew = currentItems.concat(addItems); + return currentAndNew// Filter out removed items. + .filter((item)=>!removeItems.some((r)=>(r.id ?? r) === (item.id ?? item)))// Filter duplicates. + .filter((item)=>currentAndNew.some((i2)=>(i2.id ?? i2) === (item.id ?? item))); + }, pages, notifications); + if (!dereferenceItems) return { + loadedItems: items, + isLoading: false, + isFetching: false + }; + // Dereference all items, if they are not yet. + const itemQueries = (0, $85cNH$useQueries)(items.filter((item)=>typeof item === "string").map((itemUri)=>({ + queryKey: [ + "resource", + itemUri + ], + queryFn: async ()=>(await dataProvider.fetch(itemUri)).json, + staleTime: Infinity + }))); + // Put all loaded items together (might be dereferenced already, so concatenate). + const loadedItems = items.filter((item)=>typeof item !== "string").concat(itemQueries.flatMap((itemQuery)=>{ + return itemQuery.isSuccess && itemQuery.data || []; + })); + console.log("loadedItems", loadedItems.length, "total", items.length); + const errors = itemQueries.filter((q)=>q.error); + return { + loadedItems: loadedItems, + isLoading: itemQueries.some((q)=>q.isLoading), + isFetching: itemQueries.some((q)=>q.isFetching), + errors: errors.length > 0 && errors + }; +}; const $c1e897431d8c5742$var$useCollection = (predicateOrUrl, options = {})=>{ - const { dereferenceItems: dereferenceItems = false } = options; + const { dereferenceItems: dereferenceItems = false, liveUpdates: liveUpdates = true } = options; const { data: identity } = (0, $85cNH$useGetIdentity)(); - const [items, setItems] = (0, $85cNH$useState)(); const [totalItems, setTotalItems] = (0, $85cNH$useState)(); + const [notifications, setNotifications] = (0, $85cNH$useState)([]); + const [hasLiveUpdates, setHasLiveUpdates] = (0, $85cNH$useState)({ + status: "disconnected", + error: undefined + }); const dataProvider = (0, $85cNH$useDataProvider)(); - const queryClient = (0, $85cNH$useQueryClient)(); + // Get collectionUrl from webId predicate or URL. const collectionUrl = (0, $85cNH$useMemo)(()=>{ if (predicateOrUrl) { if (predicateOrUrl.startsWith("http")) return predicateOrUrl; if (identity?.webIdData) return identity?.webIdData?.[predicateOrUrl]; } + return undefined; + // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`); }, [ identity, predicateOrUrl ]); + // Fetch page of collection item references (if pageParam provided) + // or default to `collectionUrl` (which should give you the first page). const fetchCollection = (0, $85cNH$useCallback)(async ({ pageParam: nextPageUrl })=>{ + // Fetch page or first page (collectionUrl) let { json: json } = await dataProvider.fetch(nextPageUrl || collectionUrl); if (json.totalItems) setTotalItems(json.totalItems); + // If first page, handle this here. if ((json.type === "OrderedCollection" || json.type === "Collection") && json.first) { if (json.first?.items) { if (json.first?.items.length === 0 && json.first?.next) // Special case where the first property is an object without items @@ -566,17 +625,6 @@ const $c1e897431d8c5742$var$useCollection = (predicateOrUrl, options = {})=>{ } else // Fetch the first page ({ json: json } = await dataProvider.fetch(json.first)); } - // Force dereference of items - if (dereferenceItems) { - const itemPredicate = json.items ? "items" : "orderedItems"; - json[itemPredicate] = json[itemPredicate] && await Promise.all((0, $e4e1b14e0441184d$export$e57ff0f701c44363)(json[itemPredicate]).map(async (item)=>{ - if (typeof item === "string") { - const { json: json } = await dataProvider.fetch(item); - return json; - } - return item; - })); - } return json; }, [ dataProvider, @@ -584,8 +632,9 @@ const $c1e897431d8c5742$var$useCollection = (predicateOrUrl, options = {})=>{ identity, setTotalItems ]); - const { data: data, error: error, fetchNextPage: fetchNextPage, refetch: refetch, hasNextPage: hasNextPage, isLoading: isLoading, isFetching: isFetching, isFetchingNextPage: isFetchingNextPage, status: status } = (0, $85cNH$useInfiniteQuery)([ - "Collection", + // Use infiniteQuery to handle pagination, fetching, etc. + const { data: data, error: collectionError, fetchNextPage: fetchNextPage, refetch: refetch, hasNextPage: hasNextPage, isLoading: isLoadingPage, isFetching: isFetchingPage, isFetchingNextPage: isFetchingNextPage } = (0, $85cNH$useInfiniteQuery)([ + "collection", { collectionUrl: collectionUrl } @@ -594,63 +643,57 @@ const $c1e897431d8c5742$var$useCollection = (predicateOrUrl, options = {})=>{ getNextPageParam: (lastPage)=>lastPage.next, getPreviousPageParam: (firstPage)=>firstPage.prev }); + // Put all items together in a list. + const { loadedItems: items, isLoading: isLoadingItems, isFetching: isFetchingItems, errors: itemErrors } = $c1e897431d8c5742$var$useItemsFromPagesAndNotifications(data?.pages, notifications, dereferenceItems); + // Notifications have been processed after hook call, so reset. + // useEffect(() => { + // setNotifications([]); + // }, [notifications]) + // Live Updates (0, $85cNH$useEffect)(()=>{ - if (data?.pages) setItems([].concat(...data.pages.map((p)=>(0, $e4e1b14e0441184d$export$e57ff0f701c44363)(p.orderedItems || p.items)))); - }, [ - data, - setItems - ]); - const addItem = (0, $85cNH$useCallback)((item)=>{ - setItems((oldItems)=>[ - ...oldItems, - item - ]); - // TODO use queryClient.setQueryData to update items directly in react-query cache - setTimeout(()=>queryClient.refetchQueries([ - "Collection", - { - collectionUrl: collectionUrl - } - ], { - active: true, - exact: true - }), 2000); - }, [ - setItems, - queryClient, - collectionUrl - ]); - const removeItem = (0, $85cNH$useCallback)((itemId)=>{ - setItems((oldItems)=>oldItems.filter((item)=>typeof item === "string" ? item !== itemId : item.id !== itemId)); - // TODO use queryClient.setQueryData to update items directly in react-query cache - setTimeout(()=>queryClient.refetchQueries([ - "Collection", - { - collectionUrl: collectionUrl - } - ], { - active: true, - exact: true - }), 2000); + if (liveUpdates && collectionUrl) // Create ws that listens to collectionUri changes + (0, $85cNH$getOrCreateWsChannel)(dataProvider.fetch, collectionUrl).then((webSocket)=>{ + webSocket.addEventListener("message", (e)=>{ + if (e.data && e.data.type === "Add" || e.data.type === "Remove") setNotifications([ + ...notifications, + e.data + ]); + }); + webSocket.addEventListener("error", (e)=>{ + setHasLiveUpdates({ + status: "error", + error: e + }); + // TODO: Retry after a while + }); + webSocket.addEventListener("close", (e)=>{ + setHasLiveUpdates({ + ...hasLiveUpdates, + status: "disconnected" + }); + }); + setHasLiveUpdates({ + status: "connected" + }); + }).catch(()=>{}); // If it fails, we won't receive live updates. But that's okay. }, [ - setItems, - queryClient, - collectionUrl + collectionUrl, + liveUpdates, + dataProvider.fetch ]); + const allErrors = (0, $577f4953dfa5de4f$export$e57ff0f701c44363)(collectionError).concat((0, $577f4953dfa5de4f$export$e57ff0f701c44363)(itemErrors)); return { items: items, totalItems: totalItems, - error: error, + error: allErrors.length > 0 && allErrors, refetch: refetch, fetchNextPage: fetchNextPage, hasNextPage: hasNextPage, - isLoading: isLoading, - isFetching: isFetching, + isLoading: isLoadingPage || isLoadingItems, + isFetching: isFetchingPage || isFetchingItems, isFetchingNextPage: isFetchingNextPage, - status: status, - addItem: addItem, - removeItem: removeItem, - url: collectionUrl + url: collectionUrl, + hasLiveUpdates: hasLiveUpdates }; }; var $c1e897431d8c5742$export$2e2bcd8739ae039 = $c1e897431d8c5742$var$useCollection; @@ -737,6 +780,224 @@ var $ea214512ab1a2e8f$export$2e2bcd8739ae039 = $ea214512ab1a2e8f$var$ReferenceCo + +const $8281f3ce3b9d6123$var$useItemsFromPages = (pages, dereferenceItems)=>{ + const dataProvider = (0, $85cNH$useDataProvider)(); + const items = (0, $85cNH$useMemo)(()=>pages.flatMap((p)=>(0, $577f4953dfa5de4f$export$e57ff0f701c44363)(p.orderedItems || p.items)), [ + pages + ]); + // We will force dereference, if some items are not URI string references. + const shouldDereference = (0, $85cNH$useMemo)(()=>{ + return dereferenceItems || items.some((item)=>typeof item !== "string"); + }, [ + dereferenceItems, + items + ]); + // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called). + const itemQueries = (0, $85cNH$useQueries)(!shouldDereference ? [] : items.filter((item)=>typeof item === "string").map((itemUri)=>({ + queryKey: [ + "resource", + itemUri + ], + queryFn: async ()=>(await dataProvider.fetch(itemUri)).json, + staleTime: Infinity + }))); + if (!shouldDereference) return { + loadedItems: items, + isLoading: false, + isFetching: false + }; + // Put all loaded items together (might be dereferenced already, so concatenate). + const loadedItems = items.filter((item)=>typeof item !== "string").concat(itemQueries.flatMap((itemQuery)=>{ + return itemQuery.isSuccess && itemQuery.data || []; + })); + const errors = itemQueries.filter((q)=>q.error); + return { + loadedItems: loadedItems, + isLoading: itemQueries.some((q)=>q.isLoading), + isFetching: itemQueries.some((q)=>q.isFetching), + errors: errors.length > 0 ? errors : undefined + }; +}; +/** + * Subscribe a collection. Supports pagination. + * @param predicateOrUrl The collection URI or the predicate to get the collection URI from the identity (webId). + * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }` + */ const $8281f3ce3b9d6123$var$useCollection = (predicateOrUrl, options = {})=>{ + const { dereferenceItems: dereferenceItems = false, liveUpdates: liveUpdates = true } = options; + const { data: identity } = (0, $85cNH$useGetIdentity)(); + const [totalItems, setTotalItems] = (0, $85cNH$useState)(); + const queryClient = (0, $85cNH$useQueryClient)(); + const [hasLiveUpdates, setHasLiveUpdates] = (0, $85cNH$useState)({ + status: "connecting" + }); + const dataProvider = (0, $85cNH$useDataProvider)(); + // Get collectionUrl from webId predicate or URL. + const collectionUrl = (0, $85cNH$useMemo)(()=>{ + if (predicateOrUrl) { + if (predicateOrUrl.startsWith("http")) return predicateOrUrl; + if (identity?.webIdData) return identity?.webIdData?.[predicateOrUrl]; + } + return undefined; + // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`); + }, [ + identity, + predicateOrUrl + ]); + // Fetch page of collection item references (if pageParam provided) + // or default to `collectionUrl` (which should give you the first page). + const fetchCollection = (0, $85cNH$useCallback)(async ({ pageParam: nextPageUrl })=>{ + // Fetch page or first page (collectionUrl) + let { json: json } = await dataProvider.fetch(nextPageUrl || collectionUrl); + if (json.totalItems) setTotalItems(json.totalItems); + // If first page, handle this here. + if ((json.type === "OrderedCollection" || json.type === "Collection") && json.first) { + if (json.first?.items) { + if (json.first?.items.length === 0 && json.first?.next) // Special case where the first property is an object without items + ({ json: json } = await dataProvider.fetch(json.first?.next)); + else json = json.first; + } else // Fetch the first page + ({ json: json } = await dataProvider.fetch(json.first)); + } + return json; + }, [ + dataProvider, + collectionUrl, + identity, + setTotalItems + ]); + // Use infiniteQuery to handle pagination, fetching, etc. + const { data: pageData, error: collectionError, fetchNextPage: fetchNextPage, refetch: refetch, hasNextPage: hasNextPage, isLoading: isLoadingPage, isFetching: isFetchingPage, isFetchingNextPage: isFetchingNextPage } = (0, $85cNH$useInfiniteQuery)([ + "collection", + { + collectionUrl: collectionUrl + } + ], fetchCollection, { + enabled: !!(collectionUrl && identity?.id), + getNextPageParam: (lastPage)=>lastPage.next, + getPreviousPageParam: (firstPage)=>firstPage.prev + }); + // Put all items together in a list (and dereference, if required). + const { loadedItems: items, isLoading: isLoadingItems, isFetching: isFetchingItems, errors: itemErrors } = $8281f3ce3b9d6123$var$useItemsFromPages(pageData?.pages ?? [], dereferenceItems); + const allErrors = (0, $577f4953dfa5de4f$export$e57ff0f701c44363)(collectionError).concat((0, $577f4953dfa5de4f$export$e57ff0f701c44363)(itemErrors)); + const addItem = (0, $85cNH$useCallback)((item, shouldRefetch = true)=>{ + queryClient.setQueryData([ + "collection", + { + collectionUrl: collectionUrl + } + ], (oldData)=>{ + if (!oldData) return oldData; + setTotalItems(totalItems && totalItems + 1); + // Destructure, so react knows, it needs to re-render the pages. + const pages = [ + ...oldData.pages + ]; + const firstPageItems = pages?.[0]?.orderedItems || pages?.[0]?.items || []; + firstPageItems.unshift(item); + oldData.pages = pages; + return oldData; + }); + if (shouldRefetch) setTimeout(()=>queryClient.refetchQueries([ + "collection", + { + collectionUrl: collectionUrl + } + ], { + active: true, + exact: true + }), typeof shouldRefetch === "number" ? shouldRefetch : 2000); + }, [ + queryClient, + collectionUrl + ]); + const removeItem = (0, $85cNH$useCallback)((item, shouldRefetch = true)=>{ + queryClient.setQueryData([ + "collection", + { + collectionUrl: collectionUrl + } + ], (oldData)=>{ + if (!oldData) return oldData; + setTotalItems(totalItems && totalItems - 1); + // Destructure, so react knows, it needs to re-render the pages array. + const pages = [ + ...oldData.pages + ]; + // Find the item in all pages and remove the item to be removed (either item.id or just item) + pages.forEach((page)=>{ + if (page.orderedItems) page.orderedItems = page.orderedItems.filter((i)=>(i.id || i) !== (item.id || item)); + else if (page.items) page.items = page.items.filter((i)=>(i.id || i) !== (item?.id || item)); + }); + oldData.pages = pages; + return oldData; + }); + if (shouldRefetch) setTimeout(()=>queryClient.refetchQueries([ + "collection", + { + collectionUrl: collectionUrl + } + ], { + active: true, + exact: true + }), typeof shouldRefetch === "number" ? shouldRefetch : 2000); + }, [ + queryClient, + collectionUrl + ]); + // Live Updates + (0, $85cNH$useEffect)(()=>{ + if (liveUpdates && collectionUrl) // Create ws that listens to collectionUri changes + (0, $85cNH$getOrCreateWsChannel)(dataProvider.fetch, collectionUrl).then((webSocket)=>{ + webSocket.addEventListener("message", (e)=>{ + const data = JSON.parse(e.data); + if (data && data.type === "Add") addItem(data.object, true); + else if (data && data.type === "Remove") removeItem(data.object, true); + }); + webSocket.addEventListener("error", (e)=>{ + setHasLiveUpdates({ + status: "error", + error: e + }); + // TODO: Retry after a while + }); + webSocket.addEventListener("close", (e)=>{ + if (!hasLiveUpdates.error) setHasLiveUpdates({ + ...hasLiveUpdates, + status: "closed" + }); + }); + setHasLiveUpdates({ + status: "connected" + }); + }).catch(()=>{}); // If it fails, we won't receive live updates. But that's okay. + }, [ + collectionUrl, + liveUpdates, + dataProvider + ]); + return { + items: items, + totalItems: totalItems, + error: allErrors.length > 0 && allErrors, + refetch: refetch, + fetchNextPage: fetchNextPage, + addItem: addItem, + removeItem: removeItem, + hasNextPage: hasNextPage, + isLoading: isLoadingPage || isLoadingItems, + isFetching: isFetchingPage || isFetchingItems, + isFetchingNextPage: isFetchingNextPage, + url: collectionUrl, + hasLiveUpdates: hasLiveUpdates + }; +}; +var $8281f3ce3b9d6123$export$2e2bcd8739ae039 = $8281f3ce3b9d6123$var$useCollection; + + + + + const $542b37cc25b8ccca$var$useInbox = ()=>{ const { data: identity } = (0, $85cNH$useGetIdentity)(); const inboxUrl = (0, $85cNH$useMemo)(()=>{ @@ -1018,5 +1279,5 @@ var $51cccd331ea8b13d$export$2e2bcd8739ae039 = $51cccd331ea8b13d$var$useMentions -export {$7ce737d4a1c88e63$export$2e2bcd8739ae039 as CommentsField, $d3be168cd1e7aaae$export$2e2bcd8739ae039 as CollectionList, $ea214512ab1a2e8f$export$2e2bcd8739ae039 as ReferenceCollectionField, $c1e897431d8c5742$export$2e2bcd8739ae039 as useCollection, $542b37cc25b8ccca$export$2e2bcd8739ae039 as useInbox, $641e93142bcf5435$export$2e2bcd8739ae039 as useNodeinfo, $712f7f004b5f345e$export$2e2bcd8739ae039 as useOutbox, $2514c63dc8f4867c$export$2e2bcd8739ae039 as useWebfinger, $51cccd331ea8b13d$export$2e2bcd8739ae039 as useMentions, $338f387df48a40d7$export$1ec8e53e7d982d22 as ACTIVITY_TYPES, $338f387df48a40d7$export$9649665d7ccb0dc2 as ACTOR_TYPES, $338f387df48a40d7$export$c49cfb2681596b20 as OBJECT_TYPES, $338f387df48a40d7$export$4d8d554031975581 as PUBLIC_URI}; +export {$7ce737d4a1c88e63$export$2e2bcd8739ae039 as CommentsField, $d3be168cd1e7aaae$export$2e2bcd8739ae039 as CollectionList, $ea214512ab1a2e8f$export$2e2bcd8739ae039 as ReferenceCollectionField, $8281f3ce3b9d6123$export$2e2bcd8739ae039 as useCollection, $542b37cc25b8ccca$export$2e2bcd8739ae039 as useInbox, $641e93142bcf5435$export$2e2bcd8739ae039 as useNodeinfo, $712f7f004b5f345e$export$2e2bcd8739ae039 as useOutbox, $2514c63dc8f4867c$export$2e2bcd8739ae039 as useWebfinger, $51cccd331ea8b13d$export$2e2bcd8739ae039 as useMentions, $338f387df48a40d7$export$1ec8e53e7d982d22 as ACTIVITY_TYPES, $338f387df48a40d7$export$9649665d7ccb0dc2 as ACTOR_TYPES, $338f387df48a40d7$export$c49cfb2681596b20 as OBJECT_TYPES, $338f387df48a40d7$export$4d8d554031975581 as PUBLIC_URI}; //# sourceMappingURL=index.es.js.map diff --git a/src/frontend/packages/activitypub-components/dist/index.es.js.map b/src/frontend/packages/activitypub-components/dist/index.es.js.map index 780b51c47..1aa9e0465 100644 --- a/src/frontend/packages/activitypub-components/dist/index.es.js.map +++ b/src/frontend/packages/activitypub-components/dist/index.es.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;AAAA,aAAa;;;;;;;;;;;;;;AGAN,MAAM,4CAAiB;IAC5B,QAAQ;IACR,KAAK;IACL,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,kBAAkB;IAClB,kBAAkB;IAClB,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,MAAM;AACR;AAEO,MAAM,4CAAc;IACzB,aAAa;IACb,OAAO;IACP,c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CAAC,CAAA,OAAS,CAAA;gBAAE,IAAI,KAAK,EAAE;gBAAE,OAAO,IAAI,CAAC,eAAe,eAAe,MAAM;YAAC,CAAA;IAE7F,GAAG;QAAC;KAAK;IAET,MAAM,QAAQ,CAAA,GAAA,cAAM,EAAE;QACpB,IAAI,mBACF,OAAO,CAAC,SAAE,KAAK,EAAE;YACf,OAAO,kBAAkB,MAAM,CAAC,CAAC,SAAE,KAAK,EAAE,GAAK,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,WAAW,KAAK,KAAK,CAAC,GAAG;QAC/G;IAEJ,GAAG;QAAC;KAAkB;IAEtB,OAAO;eACL;QACA,QAAQ,CAAA,GAAA,wCAAa;IACvB;AACF;IAEA,2CAAe;","sources":["packages/activitypub-components/src/index.ts","packages/activitypub-components/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/constants.js","packages/activitypub-components/src/hooks/useOutbox.js","packages/activitypub-components/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/hooks/useCollection.js","packages/activitypub-components/src/utils.js","packages/activitypub-components/src/components/CollectionList.js","packages/activitypub-components/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/hooks/useInbox.js","packages/activitypub-components/src/hooks/useNodeinfo.js","packages/activitypub-components/src/hooks/useWebfinger.js","packages/activitypub-components/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/hooks/useMentions/MentionsList.js"],"sourcesContent":["// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport PostCommentForm from './PostCommentForm';\nimport CommentsList from './CommentsList';\nimport useCollection from '../../hooks/useCollection';\n\nconst CommentsField = ({ source, context, helperText, placeholder, userResource, mentions }) => {\n const record = useRecordContext();\n const { items: comments, loading, addItem, removeItem } = useCollection(record.replies);\n if (!userResource) throw new Error('No userResource defined for CommentsField');\n return (\n <>\n \n \n \n );\n};\n\nCommentsField.defaultProps = {\n label: 'Commentaires',\n placeholder: 'Commencez à taper votre commentaire...',\n source: 'id', // Ensure the field is always displayed\n context: 'id'\n};\n\nexport default CommentsField;\n","import React, { useState, useCallback } from 'react';\nimport { Form, useGetIdentity, useNotify, useRecordContext } from 'react-admin';\nimport { RichTextInput, DefaultEditorOptions } from 'ra-input-rich-text';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { Button, Box, Avatar } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport SendIcon from '@mui/icons-material/Send';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AuthDialog } from '@semapps/auth-provider';\nimport { OBJECT_TYPES, PUBLIC_URI } from '../../constants';\nimport useOutbox from '../../hooks/useOutbox';\nimport CustomMention from './CustomMention';\n\nconst useStyles = makeStyles(theme => ({\n form: {\n marginTop: -12 // Negative margin to keep the form close to the label\n },\n container: {\n paddingLeft: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 16,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n editorContent: {\n '& > div': {\n backgroundColor: 'rgba(0, 0, 0, 0.09)',\n padding: '2px 12px',\n borderWidth: '0px !important',\n borderRadius: 0,\n borderBottom: '1px solid #FFF',\n minHeight: 60,\n outline: 'unset !important'\n },\n '& > div > p': {\n marginTop: 12,\n marginBottom: 12,\n fontFamily: theme.typography.body1.fontFamily,\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n },\n '& > div > p.is-editor-empty:first-child::before': {\n color: 'grey',\n content: 'attr(data-placeholder)',\n float: 'left',\n height: 0,\n pointerEvents: 'none'\n }\n },\n button: {\n marginTop: -10, // To go over helper text block\n marginBottom: 15\n }\n}));\n\nconst EmptyToolbar = () => null;\n\nconst PostCommentForm = ({ context, placeholder, helperText, mentions, userResource, addItem, removeItem }) => {\n const record = useRecordContext();\n const { data: identity, isLoading } = useGetIdentity();\n const userDataModel = useDataModel(userResource);\n const classes = useStyles();\n const notify = useNotify();\n const outbox = useOutbox();\n const [expanded, setExpanded] = useState(false);\n const [openAuth, setOpenAuth] = useState(false);\n\n const onSubmit = useCallback(\n async values => {\n const document = new DOMParser().parseFromString(values.comment, 'text/html');\n const mentions = Array.from(document.body.getElementsByClassName('mention'));\n const mentionedUsersUris = [];\n\n mentions.forEach(node => {\n const userUri = node.attributes['data-mention-id'].value;\n const userLabel = node.attributes['data-mention-label'].value;\n const link = document.createElement('a');\n link.setAttribute(\n 'href',\n `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`\n );\n link.textContent = `@${userLabel}`;\n node.parentNode.replaceChild(link, node);\n mentionedUsersUris.push(userUri);\n });\n\n if (document.body.innerHTML === 'undefined') {\n notify('Votre commentaire est vide', { type: 'error' });\n } else {\n const tempId = Date.now();\n\n const note = {\n type: OBJECT_TYPES.NOTE,\n attributedTo: outbox.owner,\n content: document.body.innerHTML,\n inReplyTo: record[context],\n published: new Date().toISOString()\n };\n\n try {\n addItem({ id: tempId, ...note });\n // TODO reset the form\n setExpanded(false);\n await outbox.post({ ...note, to: [...mentionedUsersUris, PUBLIC_URI] });\n notify('Commentaire posté avec succès', { type: 'success' });\n } catch (e) {\n console.error(e);\n removeItem(tempId);\n notify(e.message, { type: 'error' });\n }\n }\n },\n [outbox, notify, setExpanded, addItem, removeItem]\n );\n\n const openAuthIfDisconnected = useCallback(() => {\n if (!identity?.id) {\n setOpenAuth(true);\n }\n }, [identity, setOpenAuth]);\n\n // Don't init the editor options until mentions and identity are loaded, as they can only be initialized once\n if ((mentions && !mentions.items) || isLoading) return null;\n\n return (\n <>\n
\n \n \n }\n fullWidth\n classes={{ editorContent: classes.editorContent }}\n editorOptions={{\n ...DefaultEditorOptions,\n onFocus() {\n setExpanded(true);\n },\n extensions: [\n ...DefaultEditorOptions.extensions,\n placeholder ? Placeholder.configure({ placeholder }) : null,\n mentions\n ? CustomMention.configure({\n HTMLAttributes: {\n class: 'mention'\n },\n suggestion: mentions\n })\n : null\n ],\n // Disable editor if user is not connected\n editable: !!identity?.id\n }}\n helperText={helperText}\n />\n {expanded && (\n }\n className={classes.button}\n >\n Envoyer\n \n )}\n \n
\n setOpenAuth(false)}\n message=\"Pour poster un commentaire, vous devez être connecté.\"\n />\n \n );\n};\n\nexport default PostCommentForm;\n","export const ACTIVITY_TYPES = {\n ACCEPT: 'Accept',\n ADD: 'Add',\n ANNOUNCE: 'Announce',\n ARRIVE: 'Arrive',\n BLOCK: 'Block',\n CREATE: 'Create',\n DELETE: 'Delete',\n DISLIKE: 'Dislike',\n FLAG: 'Flag',\n FOLLOW: 'Follow',\n IGNORE: 'Ignore',\n INVITE: 'Invite',\n JOIN: 'Join',\n LEAVE: 'Leave',\n LIKE: 'Like',\n LISTEN: 'Listen',\n MOVE: 'Move',\n OFFER: 'Offer',\n QUESTION: 'Question',\n REJECT: 'Reject',\n READ: 'Read',\n REMOVE: 'Remove',\n TENTATIVE_REJECT: 'TentativeReject',\n TENTATIVE_ACCEPT: 'TentativeAccept',\n TRAVAL: 'Travel',\n UNDO: 'Undo',\n UPDATE: 'Update',\n VIEW: 'View'\n};\n\nexport const ACTOR_TYPES = {\n APPLICATION: 'Application',\n GROUP: 'Group',\n ORGANIZATION: 'Organization',\n PERSON: 'Person',\n SERVICE: 'Service'\n};\n\nexport const OBJECT_TYPES = {\n ARTICLE: 'Article',\n AUDIO: 'Audio',\n DOCUMENT: 'Document',\n EVENT: 'Event',\n IMAGE: 'Image',\n NOTE: 'Note',\n PAGE: 'Page',\n PLACE: 'Place',\n PROFILE: 'Profile',\n RELATIONSHIP: 'Relationship',\n TOMBSTONE: 'Tombstone',\n VIDEO: 'Video'\n};\n\nexport const PUBLIC_URI = 'https://www.w3.org/ns/activitystreams#Public';\n","import { useCallback, useMemo } from 'react';\nimport { useGetIdentity, fetchUtils } from 'react-admin';\nimport { buildBlankNodesQuery } from '@semapps/semantic-data-provider';\n\nconst useOutbox = () => {\n const { data: identity } = useGetIdentity();\n\n const outboxUrl = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.outbox;\n }\n }, [identity]);\n\n const sparqlEndpoint = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.endpoints?.['void:sparqlEndpoint'] || `${identity?.id}/sparql`;\n }\n }, [identity]);\n\n // Post an activity to the logged user's outbox and return its URI\n const post = useCallback(\n async activity => {\n if (!outboxUrl)\n throw new Error(\n 'Cannot post to outbox before user identity is loaded. Please use the loaded argument of useOutbox'\n );\n const token = localStorage.getItem('token');\n const { headers } = await fetchUtils.fetchJson(outboxUrl, {\n method: 'POST',\n body: JSON.stringify({\n '@context': 'https://www.w3.org/ns/activitystreams',\n ...activity\n }),\n headers: new Headers({\n 'Content-Type': 'application/ld+json',\n Authorization: `Bearer ${token}`\n })\n });\n return headers.get('Location');\n },\n [outboxUrl]\n );\n\n const fetch = useCallback(async () => {\n if (!sparqlEndpoint || !outboxUrl) return;\n\n const token = localStorage.getItem('token');\n const blankNodesQuery = buildBlankNodesQuery(['as:object']);\n\n const query = `\n PREFIX as: \n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.construct}\n }\n WHERE {\n <${outboxUrl}> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.where}\n }\n `;\n\n const { json } = await fetchUtils.fetchJson(sparqlEndpoint, {\n method: 'POST',\n body: query,\n headers: new Headers({\n Accept: 'application/ld+json',\n Authorization: token ? `Bearer ${token}` : undefined\n })\n });\n\n if (json['@graph']) {\n return json['@graph'];\n }\n return null;\n }, [sparqlEndpoint, outboxUrl]);\n\n return { post, fetch, url: outboxUrl, loaded: !!outboxUrl, owner: identity?.id };\n};\n\nexport default useOutbox;\n","import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\n\n// Fix a bug in the current version of the mention extension\n// (The { id, label } object is located inside the id property)\n// See https://github.com/ueberdosis/tiptap/pull/1322\nconst CustomMention = Mention.extend({\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id.label}`];\n },\n addAttributes() {\n return {\n label: {\n default: null,\n parseHTML: element => {\n return {\n label: element.getAttribute('data-mention-label')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.label) {\n return {};\n }\n return {\n 'data-mention-label': attributes.id.label\n };\n }\n },\n id: {\n default: null,\n parseHTML: element => {\n return {\n id: element.getAttribute('data-mention-id')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.id) {\n return {};\n }\n return {\n 'data-mention-id': attributes.id.id\n };\n }\n }\n };\n }\n});\n\nexport default CustomMention;\n","import React from 'react';\nimport { TextField, RichTextField, DateField } from 'react-admin';\nimport { Box, Typography, CircularProgress } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AvatarWithLabelField, ReferenceField } from '@semapps/field-components';\n\nconst useStyles = makeStyles(() => ({\n container: {\n paddingLeft: 80,\n marginTop: 8,\n minHeight: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n text: {\n paddingTop: 2,\n paddingBottom: 8\n },\n label: {\n fontWeight: 'bold'\n },\n content: {\n '& p': {\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n }\n },\n loading: {\n zIndex: 1000,\n backgroundColor: 'white',\n opacity: 0.5,\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n marginTop: 5\n }\n}));\n\nconst CommentsList = ({ comments, userResource, loading }) => {\n const classes = useStyles();\n const userDataModel = useDataModel(userResource);\n return (\n \n {comments &&\n comments\n .sort((a, b) => new Date(b.published) - new Date(a.published))\n .map(comment => (\n \n \n \n \n \n \n \n \n \n \n \n  • \n \n \n \n \n \n ))}\n {loading && (\n \n \n \n \n \n )}\n \n );\n};\n\nexport default CommentsList;\n","import { useCallback, useMemo, useState, useEffect } from 'react';\nimport { useGetIdentity, useDataProvider } from 'react-admin';\nimport { useInfiniteQuery, useQueryClient } from 'react-query';\nimport { arrayOf } from '../utils';\n\nconst useCollection = (predicateOrUrl, options = {}) => {\n const { dereferenceItems = false } = options;\n const { data: identity } = useGetIdentity();\n const [items, setItems] = useState();\n const [totalItems, setTotalItems] = useState();\n const dataProvider = useDataProvider();\n const queryClient = useQueryClient();\n\n const collectionUrl = useMemo(() => {\n if (predicateOrUrl) {\n if (predicateOrUrl.startsWith('http')) {\n return predicateOrUrl;\n }\n if (identity?.webIdData) {\n return identity?.webIdData?.[predicateOrUrl];\n }\n }\n }, [identity, predicateOrUrl]);\n\n const fetchCollection = useCallback(\n async ({ pageParam: nextPageUrl }) => {\n let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl);\n if (json.totalItems) setTotalItems(json.totalItems);\n\n if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {\n if (json.first?.items) {\n if (json.first?.items.length === 0 && json.first?.next) {\n // Special case where the first property is an object without items\n ({ json } = await dataProvider.fetch(json.first?.next));\n } else {\n json = json.first;\n }\n } else {\n // Fetch the first page\n ({ json } = await dataProvider.fetch(json.first));\n }\n }\n\n // Force dereference of items\n if (dereferenceItems) {\n const itemPredicate = json.items ? 'items' : 'orderedItems';\n json[itemPredicate] =\n json[itemPredicate] &&\n (await Promise.all(\n arrayOf(json[itemPredicate]).map(async item => {\n if (typeof item === 'string') {\n const { json } = await dataProvider.fetch(item);\n return json;\n }\n return item;\n })\n ));\n }\n\n return json;\n },\n [dataProvider, collectionUrl, identity, setTotalItems]\n );\n\n const { data, error, fetchNextPage, refetch, hasNextPage, isLoading, isFetching, isFetchingNextPage, status } =\n useInfiniteQuery(['Collection', { collectionUrl }], fetchCollection, {\n enabled: !!(collectionUrl && identity?.id),\n getNextPageParam: lastPage => lastPage.next,\n getPreviousPageParam: firstPage => firstPage.prev\n });\n\n useEffect(() => {\n if (data?.pages) {\n setItems([].concat(...data.pages.map(p => arrayOf(p.orderedItems || p.items))));\n }\n }, [data, setItems]);\n\n const addItem = useCallback(\n item => {\n setItems(oldItems => [...oldItems, item]);\n // TODO use queryClient.setQueryData to update items directly in react-query cache\n setTimeout(\n () =>\n queryClient.refetchQueries(['Collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n 2000\n );\n },\n [setItems, queryClient, collectionUrl]\n );\n\n const removeItem = useCallback(\n itemId => {\n setItems(oldItems => oldItems.filter(item => (typeof item === 'string' ? item !== itemId : item.id !== itemId)));\n // TODO use queryClient.setQueryData to update items directly in react-query cache\n setTimeout(\n () =>\n queryClient.refetchQueries(['Collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n 2000\n );\n },\n [setItems, queryClient, collectionUrl]\n );\n\n return {\n items,\n totalItems,\n error,\n refetch,\n fetchNextPage,\n hasNextPage,\n isLoading,\n isFetching,\n isFetchingNextPage,\n status,\n addItem,\n removeItem,\n url: collectionUrl\n };\n};\n\nexport default useCollection;\n","export const arrayOf = value => {\n // If the field is null-ish, we suppose there are no values.\n if (value === null || value === undefined) {\n return [];\n }\n // Return as is.\n if (Array.isArray(value)) {\n return value;\n }\n // Single value is made an array.\n return [value];\n};\n\nexport default {\n arrayOf\n};\n","import React from 'react';\nimport { useList, ListContextProvider, useGetMany } from 'react-admin';\nimport useCollection from '../hooks/useCollection';\n\nconst CollectionList = ({ collectionUrl, resource, children }) => {\n if (React.Children.count(children) !== 1) {\n throw new Error(' only accepts a single child');\n }\n\n const { items: actorsUris } = useCollection(collectionUrl);\n\n const { data, isLoading, isFetching } = useGetMany(\n resource,\n { ids: Array.isArray(actorsUris) ? actorsUris : [actorsUris] },\n { enabled: !!actorsUris }\n );\n\n const listContext = useList({ data, isLoading, isFetching });\n\n return {children};\n};\n\nexport default CollectionList;\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport CollectionList from './CollectionList';\n\nconst ReferenceCollectionField = ({ source, reference, children, ...rest }) => {\n const record = useRecordContext();\n\n if (React.Children.count(children) !== 1) {\n throw new Error(' only accepts a single child');\n }\n\n if (!record || !record[source]) return null;\n\n return (\n \n {children}\n \n );\n};\n\nexport default ReferenceCollectionField;\n","import { useCallback, useMemo } from 'react';\nimport { useGetIdentity, fetchUtils } from 'react-admin';\nimport { buildBlankNodesQuery } from '@semapps/semantic-data-provider';\n\nconst useInbox = () => {\n const { data: identity } = useGetIdentity();\n\n const inboxUrl = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.inbox;\n }\n }, [identity]);\n\n const sparqlEndpoint = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.endpoints?.['void:sparqlEndpoint'] || `${identity?.id}/sparql`;\n }\n }, [identity]);\n\n const fetch = useCallback(\n async ({ filters }) => {\n if (!sparqlEndpoint || !inboxUrl) return;\n\n const token = localStorage.getItem('token');\n const blankNodesQuery = buildBlankNodesQuery(['as:object']);\n\n let filtersWhereQuery = '';\n if (filters) {\n Object.keys(filters).forEach(predicate => {\n if (filters[predicate]) {\n const object = filters[predicate].startsWith('http') ? `<${filters[predicate]}>` : filters[predicate];\n filtersWhereQuery += `?s1 ${predicate} ${object} .`;\n }\n });\n }\n\n const query = `\n PREFIX as: \n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.construct}\n }\n WHERE {\n <${inboxUrl}> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n FILTER( (isIRI(?s1)) ) .\n ${filtersWhereQuery}\n ${blankNodesQuery.where}\n }\n `;\n\n const { json } = await fetchUtils.fetchJson(sparqlEndpoint, {\n method: 'POST',\n body: query,\n headers: new Headers({\n Accept: 'application/ld+json',\n Authorization: token ? `Bearer ${token}` : undefined\n })\n });\n\n if (json['@graph']) {\n return json['@graph'];\n }\n return null;\n },\n [sparqlEndpoint, inboxUrl]\n );\n\n return { fetch, url: inboxUrl, owner: identity?.id };\n};\n\nexport default useInbox;\n","import { useEffect, useState } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useNodeinfo = (host, rel = 'http://nodeinfo.diaspora.software/ns/schema/2.1') => {\n const [schema, setSchema] = useState();\n\n useEffect(() => {\n (async () => {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are likely on HTTP\n const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;\n\n try {\n const { json: links } = await fetchUtils.fetchJson(nodeinfoUrl);\n\n // Accept any version of the nodeinfo protocol\n const link = links?.links?.find(l => l.rel === rel);\n\n const { json } = await fetchUtils.fetchJson(link.href);\n\n setSchema(json);\n } catch (e) {\n // Do nothing if nodeinfo can't be fetched\n }\n })();\n }, [host, setSchema, rel]);\n\n return schema;\n};\n\nexport default useNodeinfo;\n","import { useCallback } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useWebfinger = () => {\n // Post an activity to the logged user's outbox and return its URI\n const fetch = useCallback(async id => {\n // eslint-disable-next-line\n const [_, username, host] = id.split('@');\n if (host) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are most likely on localhost\n const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;\n\n try {\n const { json } = await fetchUtils.fetchJson(webfingerUrl);\n\n const link = json.links.find(l => l.type === 'application/activity+json');\n\n return link ? link.href : null;\n } catch (e) {\n return null;\n }\n } else {\n return null;\n }\n }, []);\n\n return { fetch };\n};\n\nexport default useWebfinger;\n","import { useMemo } from 'react';\nimport { useGetList } from 'react-admin';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport renderMentions from './renderMentions';\n\nconst useMentions = userResource => {\n const userDataModel = useDataModel(userResource);\n\n const { data } = useGetList(\n userResource,\n {\n filter: {\n _predicates: [userDataModel?.fieldsMapping?.title],\n blankNodes: []\n }\n },\n {\n enabled: !!userDataModel?.fieldsMapping?.title\n }\n );\n\n const availableMentions = useMemo(() => {\n if (data) {\n return data.map(item => ({ id: item.id, label: item[userDataModel?.fieldsMapping?.title] }));\n }\n }, [data]);\n\n const items = useMemo(() => {\n if (availableMentions) {\n return ({ query }) => {\n return availableMentions.filter(({ label }) => label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5);\n };\n }\n }, [availableMentions]);\n\n return {\n items,\n render: renderMentions\n };\n};\n\nexport default useMentions;\n","import { ReactRenderer } from '@tiptap/react';\nimport tippy from 'tippy.js';\nimport MentionsList from './MentionsList';\n\nconst renderMentions = () => {\n let component;\n let popup;\n\n return {\n onStart: props => {\n component = new ReactRenderer(MentionsList, {\n props,\n editor: props.editor\n });\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: 'manual',\n placement: 'bottom-start'\n });\n },\n\n onUpdate(props) {\n component.updateProps(props);\n\n popup[0].setProps({\n getReferenceClientRect: props.clientRect\n });\n },\n\n onKeyDown(props) {\n if (props.event.key === 'Escape') {\n popup[0].hide();\n\n return true;\n }\n\n return component.ref?.onKeyDown(props);\n },\n\n onExit() {\n popup[0].destroy();\n component.destroy();\n }\n };\n};\n\nexport default renderMentions;\n","import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport makeStyles from '@mui/styles/makeStyles';\n\nconst useStyles = makeStyles(theme => ({\n items: {\n background: '#fff',\n borderRadius: '0.5rem',\n boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)',\n color: 'rgba(0, 0, 0, 0.8)',\n fontSize: '0.9rem',\n overflow: 'hidden',\n padding: '0.2rem',\n position: 'relative'\n },\n item: {\n background: 'transparent',\n border: '1px solid transparent',\n borderRadius: '0.4rem',\n display: 'block',\n margin: 0,\n padding: '0.2rem 0.4rem',\n textAlign: 'left',\n width: '100%',\n '&.selected': {\n borderColor: '#000'\n }\n }\n}));\n\nexport default forwardRef((props, ref) => {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const classes = useStyles();\n\n const selectItem = index => {\n const item = props.items[index];\n\n if (item) {\n props.command({ id: item });\n }\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + props.items.length - 1) % props.items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % props.items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n useEffect(() => setSelectedIndex(0), [props.items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === 'ArrowUp') {\n upHandler();\n return true;\n }\n\n if (event.key === 'ArrowDown') {\n downHandler();\n return true;\n }\n\n if (event.key === 'Enter') {\n enterHandler();\n return true;\n }\n\n return false;\n }\n }));\n\n return (\n
\n {props.items.length ? (\n props.items.map((item, index) => (\n selectItem(index)}\n >\n {item.label}\n \n ))\n ) : (\n
Aucun résultat
\n )}\n
\n );\n});\n"],"names":[],"version":3,"file":"index.es.js.map"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;AAAA,aAAa;;;;;;;;;;;;;;AGAN,MAAM,4CAAiB;IAC5B,QAAQ;IACR,KAAK;IACL,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,UAAU;IAC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GAAA,mBAAW,EAAE;IAEnC,MAAM,QAAE,IAAI,EAAE,GAAG,CAAA,GAAA,iBAAS,EACxB,cACA;QACE,QAAQ;YACN,aAAa;gBAAC,eAAe,eAAe;aAAM;YAClD,YAAY,EAAE;QAChB;IACF,GACA;QACE,SAAS,CAAC,CAAC,eAAe,eAAe;IAC3C;IAGF,MAAM,oBAAoB,CAAA,GAAA,cAAM,EAAE;QAChC,IAAI,MACF,OAAO,KAAK,GAAG,CAAC,CAAA,OAAS,CAAA;gBAAE,IAAI,KAAK,EAAE;gBAAE,OAAO,IAAI,CAAC,eAAe,eAAe,MAAM;YAAC,CAAA;IAE7F,GAAG;QAAC;KAAK;IAET,MAAM,QAAQ,CAAA,GAAA,cAAM,EAAE;QACpB,IAAI,mBACF,OAAO,CAAC,SAAE,KAAK,EAAE;YACf,OAAO,kBAAkB,MAAM,CAAC,CAAC,SAAE,KAAK,EAAE,GAAK,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,WAAW,KAAK,KAAK,CAAC,GAAG;QAC/G;IAEJ,GAAG;QAAC;KAAkB;IAEtB,OAAO;eACL;QACA,QAAQ,CAAA,GAAA,wCAAa;IACvB;AACF;IAEA,2CAAe;","sources":["packages/activitypub-components/src/index.ts","packages/activitypub-components/src/components/CommentsField/CommentsField.js","packages/activitypub-components/src/components/CommentsField/PostCommentForm.js","packages/activitypub-components/src/constants.js","packages/activitypub-components/src/hooks/useOutbox.js","packages/activitypub-components/src/components/CommentsField/CustomMention.js","packages/activitypub-components/src/components/CommentsField/CommentsList.js","packages/activitypub-components/src/hooks/useCollection.js","packages/activitypub-components/src/utils.ts","packages/activitypub-components/src/components/CollectionList.js","packages/activitypub-components/src/components/ReferenceCollectionField.js","packages/activitypub-components/src/hooks/useCollection.ts","packages/activitypub-components/src/hooks/useInbox.js","packages/activitypub-components/src/hooks/useNodeinfo.js","packages/activitypub-components/src/hooks/useWebfinger.js","packages/activitypub-components/src/hooks/useMentions/useMentions.js","packages/activitypub-components/src/hooks/useMentions/renderMentions.js","packages/activitypub-components/src/hooks/useMentions/MentionsList.js"],"sourcesContent":["// Components\nexport { default as CommentsField } from './components/CommentsField/CommentsField';\nexport { default as CollectionList } from './components/CollectionList';\nexport { default as ReferenceCollectionField } from './components/ReferenceCollectionField';\n\n// Hooks\nexport { default as useCollection } from './hooks/useCollection';\nexport { default as useInbox } from './hooks/useInbox';\nexport { default as useNodeinfo } from './hooks/useNodeinfo';\nexport { default as useOutbox } from './hooks/useOutbox';\nexport { default as useWebfinger } from './hooks/useWebfinger';\nexport { default as useMentions } from './hooks/useMentions/useMentions';\n\n// Constants\nexport { ACTIVITY_TYPES, ACTOR_TYPES, OBJECT_TYPES, PUBLIC_URI } from './constants';\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport PostCommentForm from './PostCommentForm';\nimport CommentsList from './CommentsList';\nimport useCollection from '../../hooks/useCollection';\n\nconst CommentsField = ({ source, context, helperText, placeholder, userResource, mentions }) => {\n const record = useRecordContext();\n const { items: comments, loading, addItem, removeItem } = useCollection(record.replies);\n if (!userResource) throw new Error('No userResource defined for CommentsField');\n return (\n <>\n \n \n \n );\n};\n\nCommentsField.defaultProps = {\n label: 'Commentaires',\n placeholder: 'Commencez à taper votre commentaire...',\n source: 'id', // Ensure the field is always displayed\n context: 'id'\n};\n\nexport default CommentsField;\n","import React, { useState, useCallback } from 'react';\nimport { Form, useGetIdentity, useNotify, useRecordContext } from 'react-admin';\nimport { RichTextInput, DefaultEditorOptions } from 'ra-input-rich-text';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { Button, Box, Avatar } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport SendIcon from '@mui/icons-material/Send';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AuthDialog } from '@semapps/auth-provider';\nimport { OBJECT_TYPES, PUBLIC_URI } from '../../constants';\nimport useOutbox from '../../hooks/useOutbox';\nimport CustomMention from './CustomMention';\n\nconst useStyles = makeStyles(theme => ({\n form: {\n marginTop: -12 // Negative margin to keep the form close to the label\n },\n container: {\n paddingLeft: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 16,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n editorContent: {\n '& > div': {\n backgroundColor: 'rgba(0, 0, 0, 0.09)',\n padding: '2px 12px',\n borderWidth: '0px !important',\n borderRadius: 0,\n borderBottom: '1px solid #FFF',\n minHeight: 60,\n outline: 'unset !important'\n },\n '& > div > p': {\n marginTop: 12,\n marginBottom: 12,\n fontFamily: theme.typography.body1.fontFamily,\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n },\n '& > div > p.is-editor-empty:first-child::before': {\n color: 'grey',\n content: 'attr(data-placeholder)',\n float: 'left',\n height: 0,\n pointerEvents: 'none'\n }\n },\n button: {\n marginTop: -10, // To go over helper text block\n marginBottom: 15\n }\n}));\n\nconst EmptyToolbar = () => null;\n\nconst PostCommentForm = ({ context, placeholder, helperText, mentions, userResource, addItem, removeItem }) => {\n const record = useRecordContext();\n const { data: identity, isLoading } = useGetIdentity();\n const userDataModel = useDataModel(userResource);\n const classes = useStyles();\n const notify = useNotify();\n const outbox = useOutbox();\n const [expanded, setExpanded] = useState(false);\n const [openAuth, setOpenAuth] = useState(false);\n\n const onSubmit = useCallback(\n async values => {\n const document = new DOMParser().parseFromString(values.comment, 'text/html');\n const mentions = Array.from(document.body.getElementsByClassName('mention'));\n const mentionedUsersUris = [];\n\n mentions.forEach(node => {\n const userUri = node.attributes['data-mention-id'].value;\n const userLabel = node.attributes['data-mention-label'].value;\n const link = document.createElement('a');\n link.setAttribute(\n 'href',\n `${new URL(window.location.href).origin}/${userResource}/${encodeURIComponent(userUri)}/show`\n );\n link.textContent = `@${userLabel}`;\n node.parentNode.replaceChild(link, node);\n mentionedUsersUris.push(userUri);\n });\n\n if (document.body.innerHTML === 'undefined') {\n notify('Votre commentaire est vide', { type: 'error' });\n } else {\n const tempId = Date.now();\n\n const note = {\n type: OBJECT_TYPES.NOTE,\n attributedTo: outbox.owner,\n content: document.body.innerHTML,\n inReplyTo: record[context],\n published: new Date().toISOString()\n };\n\n try {\n addItem({ id: tempId, ...note });\n // TODO reset the form\n setExpanded(false);\n await outbox.post({ ...note, to: [...mentionedUsersUris, PUBLIC_URI] });\n notify('Commentaire posté avec succès', { type: 'success' });\n } catch (e) {\n console.error(e);\n removeItem(tempId);\n notify(e.message, { type: 'error' });\n }\n }\n },\n [outbox, notify, setExpanded, addItem, removeItem]\n );\n\n const openAuthIfDisconnected = useCallback(() => {\n if (!identity?.id) {\n setOpenAuth(true);\n }\n }, [identity, setOpenAuth]);\n\n // Don't init the editor options until mentions and identity are loaded, as they can only be initialized once\n if ((mentions && !mentions.items) || isLoading) return null;\n\n return (\n <>\n
\n \n \n }\n fullWidth\n classes={{ editorContent: classes.editorContent }}\n editorOptions={{\n ...DefaultEditorOptions,\n onFocus() {\n setExpanded(true);\n },\n extensions: [\n ...DefaultEditorOptions.extensions,\n placeholder ? Placeholder.configure({ placeholder }) : null,\n mentions\n ? CustomMention.configure({\n HTMLAttributes: {\n class: 'mention'\n },\n suggestion: mentions\n })\n : null\n ],\n // Disable editor if user is not connected\n editable: !!identity?.id\n }}\n helperText={helperText}\n />\n {expanded && (\n }\n className={classes.button}\n >\n Envoyer\n \n )}\n \n
\n setOpenAuth(false)}\n message=\"Pour poster un commentaire, vous devez être connecté.\"\n />\n \n );\n};\n\nexport default PostCommentForm;\n","export const ACTIVITY_TYPES = {\n ACCEPT: 'Accept',\n ADD: 'Add',\n ANNOUNCE: 'Announce',\n ARRIVE: 'Arrive',\n BLOCK: 'Block',\n CREATE: 'Create',\n DELETE: 'Delete',\n DISLIKE: 'Dislike',\n FLAG: 'Flag',\n FOLLOW: 'Follow',\n IGNORE: 'Ignore',\n INVITE: 'Invite',\n JOIN: 'Join',\n LEAVE: 'Leave',\n LIKE: 'Like',\n LISTEN: 'Listen',\n MOVE: 'Move',\n OFFER: 'Offer',\n QUESTION: 'Question',\n REJECT: 'Reject',\n READ: 'Read',\n REMOVE: 'Remove',\n TENTATIVE_REJECT: 'TentativeReject',\n TENTATIVE_ACCEPT: 'TentativeAccept',\n TRAVEL: 'Travel',\n UNDO: 'Undo',\n UPDATE: 'Update',\n VIEW: 'View'\n};\n\nexport const ACTOR_TYPES = {\n APPLICATION: 'Application',\n GROUP: 'Group',\n ORGANIZATION: 'Organization',\n PERSON: 'Person',\n SERVICE: 'Service'\n};\n\nexport const OBJECT_TYPES = {\n ARTICLE: 'Article',\n AUDIO: 'Audio',\n DOCUMENT: 'Document',\n EVENT: 'Event',\n IMAGE: 'Image',\n NOTE: 'Note',\n PAGE: 'Page',\n PLACE: 'Place',\n PROFILE: 'Profile',\n RELATIONSHIP: 'Relationship',\n TOMBSTONE: 'Tombstone',\n VIDEO: 'Video'\n};\n\nexport const PUBLIC_URI = 'https://www.w3.org/ns/activitystreams#Public';\n","import { useCallback, useMemo } from 'react';\nimport { useGetIdentity, fetchUtils } from 'react-admin';\nimport { buildBlankNodesQuery } from '@semapps/semantic-data-provider';\n\nconst useOutbox = () => {\n const { data: identity } = useGetIdentity();\n\n const outboxUrl = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.outbox;\n }\n }, [identity]);\n\n const sparqlEndpoint = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.endpoints?.['void:sparqlEndpoint'] || `${identity?.id}/sparql`;\n }\n }, [identity]);\n\n // Post an activity to the logged user's outbox and return its URI\n const post = useCallback(\n async activity => {\n if (!outboxUrl)\n throw new Error(\n 'Cannot post to outbox before user identity is loaded. Please use the loaded argument of useOutbox'\n );\n const token = localStorage.getItem('token');\n const { headers } = await fetchUtils.fetchJson(outboxUrl, {\n method: 'POST',\n body: JSON.stringify({\n '@context': 'https://www.w3.org/ns/activitystreams',\n ...activity\n }),\n headers: new Headers({\n 'Content-Type': 'application/ld+json',\n Authorization: `Bearer ${token}`\n })\n });\n return headers.get('Location');\n },\n [outboxUrl]\n );\n\n const fetch = useCallback(async () => {\n if (!sparqlEndpoint || !outboxUrl) return;\n\n const token = localStorage.getItem('token');\n const blankNodesQuery = buildBlankNodesQuery(['as:object']);\n\n const query = `\n PREFIX as: \n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.construct}\n }\n WHERE {\n <${outboxUrl}> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.where}\n }\n `;\n\n const { json } = await fetchUtils.fetchJson(sparqlEndpoint, {\n method: 'POST',\n body: query,\n headers: new Headers({\n Accept: 'application/ld+json',\n Authorization: token ? `Bearer ${token}` : undefined\n })\n });\n\n if (json['@graph']) {\n return json['@graph'];\n }\n return null;\n }, [sparqlEndpoint, outboxUrl]);\n\n return { post, fetch, url: outboxUrl, loaded: !!outboxUrl, owner: identity?.id };\n};\n\nexport default useOutbox;\n","import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\n\n// Fix a bug in the current version of the mention extension\n// (The { id, label } object is located inside the id property)\n// See https://github.com/ueberdosis/tiptap/pull/1322\nconst CustomMention = Mention.extend({\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id.label}`];\n },\n addAttributes() {\n return {\n label: {\n default: null,\n parseHTML: element => {\n return {\n label: element.getAttribute('data-mention-label')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.label) {\n return {};\n }\n return {\n 'data-mention-label': attributes.id.label\n };\n }\n },\n id: {\n default: null,\n parseHTML: element => {\n return {\n id: element.getAttribute('data-mention-id')\n };\n },\n renderHTML: attributes => {\n if (!attributes.id.id) {\n return {};\n }\n return {\n 'data-mention-id': attributes.id.id\n };\n }\n }\n };\n }\n});\n\nexport default CustomMention;\n","import React from 'react';\nimport { TextField, RichTextField, DateField } from 'react-admin';\nimport { Box, Typography, CircularProgress } from '@mui/material';\nimport makeStyles from '@mui/styles/makeStyles';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport { AvatarWithLabelField, ReferenceField } from '@semapps/field-components';\n\nconst useStyles = makeStyles(() => ({\n container: {\n paddingLeft: 80,\n marginTop: 8,\n minHeight: 80,\n position: 'relative'\n },\n avatar: {\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n width: 64,\n height: 64\n },\n text: {\n paddingTop: 2,\n paddingBottom: 8\n },\n label: {\n fontWeight: 'bold'\n },\n content: {\n '& p': {\n marginBlockStart: '0.5em',\n marginBlockEnd: '0.5em'\n }\n },\n loading: {\n zIndex: 1000,\n backgroundColor: 'white',\n opacity: 0.5,\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n marginTop: 5\n }\n}));\n\nconst CommentsList = ({ comments, userResource, loading }) => {\n const classes = useStyles();\n const userDataModel = useDataModel(userResource);\n return (\n \n {comments &&\n comments\n .sort((a, b) => new Date(b.published) - new Date(a.published))\n .map(comment => (\n \n \n \n \n \n \n \n \n \n \n \n  • \n \n \n \n \n \n ))}\n {loading && (\n \n \n \n \n \n )}\n \n );\n};\n\nexport default CommentsList;\n","import { useCallback, useMemo, useState, useEffect } from 'react';\nimport { useGetIdentity, useDataProvider } from 'react-admin';\nimport { useInfiniteQuery, useQueries } from 'react-query';\nimport { getOrCreateWsChannel } from '@semapps/semantic-data-provider';\nimport { arrayOf } from '../utils';\n\nconst useItemsFromPagesAndNotifications = (pages, notifications, dereferenceItems) => {\n const dataProvider = useDataProvider();\n\n // Add all items from pages and process notifications (possibly new and deleted items).\n const items = useMemo(\n () => {\n const addItems = notifications.map(n => n.type === 'Add').map(n => n.object);\n const removeItems = notifications.map(n => n.type === 'Remove').map(n => n.object.id || n.object);\n const currentItems = !pages ? [] : pages.flatMap(p => arrayOf(p.orderedItems || p.items));\n const currentAndNew = currentItems.concat(addItems);\n\n return (\n currentAndNew\n // Filter out removed items.\n .filter(item => !removeItems.some(r => (r.id ?? r) === (item.id ?? item)))\n // Filter duplicates.\n .filter(item => currentAndNew.some(i2 => (i2.id ?? i2) === (item.id ?? item)))\n );\n },\n pages,\n notifications\n );\n\n if (!dereferenceItems) {\n return { loadedItems: items, isLoading: false, isFetching: false };\n }\n\n // Dereference all items, if they are not yet.\n const itemQueries = useQueries(\n items\n .filter(item => typeof item === 'string')\n .map(itemUri => ({\n queryKey: ['resource', itemUri],\n queryFn: async () => (await dataProvider.fetch(itemUri)).json,\n staleTime: Infinity\n }))\n );\n\n // Put all loaded items together (might be dereferenced already, so concatenate).\n const loadedItems = items\n .filter(item => typeof item !== 'string')\n .concat(\n itemQueries.flatMap(itemQuery => {\n return (itemQuery.isSuccess && itemQuery.data) || [];\n })\n );\n\n console.log('loadedItems', loadedItems.length, 'total', items.length);\n\n const errors = itemQueries.filter(q => q.error);\n return {\n loadedItems,\n isLoading: itemQueries.some(q => q.isLoading),\n isFetching: itemQueries.some(q => q.isFetching),\n errors: errors.length > 0 && errors\n };\n};\n\nconst useCollection = (predicateOrUrl, options = {}) => {\n const { dereferenceItems = false, liveUpdates = true } = options;\n const { data: identity } = useGetIdentity();\n const [totalItems, setTotalItems] = useState();\n const [notifications, setNotifications] = useState([]);\n const [hasLiveUpdates, setHasLiveUpdates] = useState({ status: 'disconnected', error: undefined });\n const dataProvider = useDataProvider();\n\n // Get collectionUrl from webId predicate or URL.\n const collectionUrl = useMemo(() => {\n if (predicateOrUrl) {\n if (predicateOrUrl.startsWith('http')) {\n return predicateOrUrl;\n }\n if (identity?.webIdData) {\n return identity?.webIdData?.[predicateOrUrl];\n }\n }\n return undefined;\n // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`);\n }, [identity, predicateOrUrl]);\n\n // Fetch page of collection item references (if pageParam provided)\n // or default to `collectionUrl` (which should give you the first page).\n const fetchCollection = useCallback(\n async ({ pageParam: nextPageUrl }) => {\n // Fetch page or first page (collectionUrl)\n let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl);\n if (json.totalItems) setTotalItems(json.totalItems);\n\n // If first page, handle this here.\n if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {\n if (json.first?.items) {\n if (json.first?.items.length === 0 && json.first?.next) {\n // Special case where the first property is an object without items\n ({ json } = await dataProvider.fetch(json.first?.next));\n } else {\n json = json.first;\n }\n } else {\n // Fetch the first page\n ({ json } = await dataProvider.fetch(json.first));\n }\n }\n\n return json;\n },\n [dataProvider, collectionUrl, identity, setTotalItems]\n );\n\n // Use infiniteQuery to handle pagination, fetching, etc.\n const {\n data,\n error: collectionError,\n fetchNextPage,\n refetch,\n hasNextPage,\n isLoading: isLoadingPage,\n isFetching: isFetchingPage,\n isFetchingNextPage\n } = useInfiniteQuery(['collection', { collectionUrl }], fetchCollection, {\n enabled: !!(collectionUrl && identity?.id),\n getNextPageParam: lastPage => lastPage.next,\n getPreviousPageParam: firstPage => firstPage.prev\n });\n\n // Put all items together in a list.\n const {\n loadedItems: items,\n isLoading: isLoadingItems,\n isFetching: isFetchingItems,\n errors: itemErrors\n } = useItemsFromPagesAndNotifications(data?.pages, notifications, dereferenceItems);\n // Notifications have been processed after hook call, so reset.\n // useEffect(() => {\n // setNotifications([]);\n // }, [notifications])\n\n // Live Updates\n useEffect(() => {\n if (liveUpdates && collectionUrl) {\n // Create ws that listens to collectionUri changes\n getOrCreateWsChannel(dataProvider.fetch, collectionUrl)\n .then(webSocket => {\n webSocket.addEventListener('message', e => {\n if ((e.data && e.data.type === 'Add') || e.data.type === 'Remove') {\n setNotifications([...notifications, e.data]);\n }\n });\n webSocket.addEventListener('error', e => {\n setHasLiveUpdates({ status: 'error', error: e });\n // TODO: Retry after a while\n });\n webSocket.addEventListener('close', e => {\n setHasLiveUpdates({ ...hasLiveUpdates, status: 'disconnected' });\n });\n setHasLiveUpdates({ status: 'connected' });\n })\n .catch(() => {}); // If it fails, we won't receive live updates. But that's okay.\n }\n }, [collectionUrl, liveUpdates, dataProvider.fetch]);\n\n const allErrors = arrayOf(collectionError).concat(arrayOf(itemErrors));\n\n return {\n items,\n totalItems,\n error: allErrors.length > 0 && allErrors,\n refetch,\n fetchNextPage,\n hasNextPage,\n isLoading: isLoadingPage || isLoadingItems,\n isFetching: isFetchingPage || isFetchingItems,\n isFetchingNextPage,\n url: collectionUrl,\n hasLiveUpdates\n };\n};\n\nexport default useCollection;\n","export const arrayOf = (value: T | T[]) => {\n // If the field is null-ish, we suppose there are no values.\n if (value === null || value === undefined) {\n return [];\n }\n // Return as is.\n if (Array.isArray(value)) {\n return value;\n }\n // Single value is made an array.\n return [value];\n};\n\nexport default {\n arrayOf\n};\n\nexport const filterDuplicates = (iterable: T[], predicate: (item: T) => string) => {\n const seen = new Set();\n return iterable.filter(item => {\n const key = predicate(item);\n if (seen.has(key)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n};\n","import React from 'react';\nimport { useList, ListContextProvider, useGetMany } from 'react-admin';\nimport useCollection from '../hooks/useCollection';\n\nconst CollectionList = ({ collectionUrl, resource, children }) => {\n if (React.Children.count(children) !== 1) {\n throw new Error(' only accepts a single child');\n }\n\n const { items: actorsUris } = useCollection(collectionUrl);\n\n const { data, isLoading, isFetching } = useGetMany(\n resource,\n { ids: Array.isArray(actorsUris) ? actorsUris : [actorsUris] },\n { enabled: !!actorsUris }\n );\n\n const listContext = useList({ data, isLoading, isFetching });\n\n return {children};\n};\n\nexport default CollectionList;\n","import React from 'react';\nimport { useRecordContext } from 'react-admin';\nimport CollectionList from './CollectionList';\n\nconst ReferenceCollectionField = ({ source, reference, children, ...rest }) => {\n const record = useRecordContext();\n\n if (React.Children.count(children) !== 1) {\n throw new Error(' only accepts a single child');\n }\n\n if (!record || !record[source]) return null;\n\n return (\n \n {children}\n \n );\n};\n\nexport default ReferenceCollectionField;\n","import { useCallback, useMemo, useState, useEffect } from 'react';\nimport { useGetIdentity, useDataProvider } from 'react-admin';\nimport { QueryFunction, useInfiniteQuery, useQueries, useQueryClient } from 'react-query';\nimport { getOrCreateWsChannel } from '@semapps/semantic-data-provider';\nimport { arrayOf } from '../utils';\n\nconst useItemsFromPages = (pages: any[], dereferenceItems: boolean) => {\n const dataProvider = useDataProvider();\n const items = useMemo(() => pages.flatMap(p => arrayOf(p.orderedItems || p.items)), [pages]);\n\n // We will force dereference, if some items are not URI string references.\n const shouldDereference = useMemo(() => {\n return dereferenceItems || items.some(item => typeof item !== 'string');\n }, [dereferenceItems, items]);\n\n // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called).\n const itemQueries = useQueries(\n !shouldDereference\n ? []\n : items\n .filter(item => typeof item === 'string')\n .map(itemUri => ({\n queryKey: ['resource', itemUri],\n queryFn: async () => (await dataProvider.fetch(itemUri)).json,\n staleTime: Infinity\n }))\n );\n\n if (!shouldDereference) {\n return { loadedItems: items, isLoading: false, isFetching: false };\n }\n\n // Put all loaded items together (might be dereferenced already, so concatenate).\n const loadedItems = items\n .filter(item => typeof item !== 'string')\n .concat(\n itemQueries.flatMap(itemQuery => {\n return (itemQuery.isSuccess && itemQuery.data) || [];\n })\n );\n\n const errors = itemQueries.filter(q => q.error);\n return {\n loadedItems,\n isLoading: itemQueries.some(q => q.isLoading),\n isFetching: itemQueries.some(q => q.isFetching),\n errors: errors.length > 0 ? errors : undefined\n };\n};\n\ninterface UseCollectionOptions {\n dereferenceItems?: boolean;\n liveUpdates?: boolean;\n}\n\n/**\n * Subscribe a collection. Supports pagination.\n * @param predicateOrUrl The collection URI or the predicate to get the collection URI from the identity (webId).\n * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }`\n */\nconst useCollection = (predicateOrUrl: string, options: UseCollectionOptions = {}) => {\n const { dereferenceItems = false, liveUpdates = true } = options;\n const { data: identity } = useGetIdentity();\n const [totalItems, setTotalItems] = useState();\n const queryClient = useQueryClient();\n const [hasLiveUpdates, setHasLiveUpdates] = useState<{ status: string; error?: any }>({ status: 'connecting' });\n const dataProvider = useDataProvider();\n\n // Get collectionUrl from webId predicate or URL.\n const collectionUrl = useMemo(() => {\n if (predicateOrUrl) {\n if (predicateOrUrl.startsWith('http')) {\n return predicateOrUrl;\n }\n if (identity?.webIdData) {\n return identity?.webIdData?.[predicateOrUrl];\n }\n }\n return undefined;\n // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`);\n }, [identity, predicateOrUrl]);\n\n // Fetch page of collection item references (if pageParam provided)\n // or default to `collectionUrl` (which should give you the first page).\n const fetchCollection: QueryFunction = useCallback(\n async ({ pageParam: nextPageUrl }) => {\n // Fetch page or first page (collectionUrl)\n let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl);\n if (json.totalItems) setTotalItems(json.totalItems);\n\n // If first page, handle this here.\n if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) {\n if (json.first?.items) {\n if (json.first?.items.length === 0 && json.first?.next) {\n // Special case where the first property is an object without items\n ({ json } = await dataProvider.fetch(json.first?.next));\n } else {\n json = json.first;\n }\n } else {\n // Fetch the first page\n ({ json } = await dataProvider.fetch(json.first));\n }\n }\n\n return json;\n },\n [dataProvider, collectionUrl, identity, setTotalItems]\n );\n\n // Use infiniteQuery to handle pagination, fetching, etc.\n const {\n data: pageData,\n error: collectionError,\n fetchNextPage,\n refetch,\n hasNextPage,\n isLoading: isLoadingPage,\n isFetching: isFetchingPage,\n isFetchingNextPage\n } = useInfiniteQuery(['collection', { collectionUrl }], fetchCollection, {\n enabled: !!(collectionUrl && identity?.id),\n getNextPageParam: (lastPage: any) => lastPage.next,\n getPreviousPageParam: (firstPage: any) => firstPage.prev\n });\n\n // Put all items together in a list (and dereference, if required).\n const {\n loadedItems: items,\n isLoading: isLoadingItems,\n isFetching: isFetchingItems,\n errors: itemErrors\n } = useItemsFromPages(pageData?.pages ?? [], dereferenceItems);\n\n const allErrors = arrayOf(collectionError).concat(arrayOf(itemErrors));\n\n const addItem = useCallback(\n (item: string | any, shouldRefetch: boolean | number = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems + 1);\n\n // Destructure, so react knows, it needs to re-render the pages.\n const pages = [...oldData.pages];\n const firstPageItems: any[] = pages?.[0]?.orderedItems || pages?.[0]?.items || [];\n firstPageItems.unshift(item);\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n const removeItem = useCallback(\n (item: string | any, shouldRefetch: boolean = true) => {\n queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => {\n if (!oldData) return oldData;\n setTotalItems(totalItems && totalItems - 1);\n\n // Destructure, so react knows, it needs to re-render the pages array.\n const pages = [...oldData.pages];\n // Find the item in all pages and remove the item to be removed (either item.id or just item)\n pages.forEach(page => {\n if (page.orderedItems) {\n page.orderedItems = page.orderedItems.filter((i: any) => (i.id || i) !== (item.id || item));\n } else if (page.items) {\n page.items = page.items.filter((i: any) => (i.id || i) !== (item?.id || item));\n }\n });\n\n oldData.pages = pages;\n return oldData;\n });\n if (shouldRefetch) {\n setTimeout(\n () =>\n queryClient.refetchQueries(['collection', { collectionUrl }], {\n active: true,\n exact: true\n }),\n typeof shouldRefetch === 'number' ? shouldRefetch : 2000\n );\n }\n },\n [queryClient, collectionUrl]\n );\n\n // Live Updates\n useEffect(() => {\n if (liveUpdates && collectionUrl) {\n // Create ws that listens to collectionUri changes\n getOrCreateWsChannel(dataProvider.fetch, collectionUrl)\n .then(webSocket => {\n webSocket.addEventListener('message', e => {\n const data = JSON.parse(e.data);\n if (data && data.type === 'Add') {\n addItem(data.object, true);\n } else if (data && data.type === 'Remove') {\n removeItem(data.object, true);\n }\n });\n webSocket.addEventListener('error', e => {\n setHasLiveUpdates({ status: 'error', error: e });\n // TODO: Retry after a while\n });\n webSocket.addEventListener('close', e => {\n if (!hasLiveUpdates.error) {\n setHasLiveUpdates({ ...hasLiveUpdates, status: 'closed' });\n }\n });\n setHasLiveUpdates({ status: 'connected' });\n })\n .catch(() => {}); // If it fails, we won't receive live updates. But that's okay.\n }\n }, [collectionUrl, liveUpdates, dataProvider]);\n\n return {\n items,\n totalItems,\n error: allErrors.length > 0 && allErrors,\n refetch,\n fetchNextPage,\n addItem,\n removeItem,\n hasNextPage,\n isLoading: isLoadingPage || isLoadingItems,\n isFetching: isFetchingPage || isFetchingItems,\n isFetchingNextPage,\n url: collectionUrl,\n hasLiveUpdates\n };\n};\n\nexport default useCollection;\n","import { useCallback, useMemo } from 'react';\nimport { useGetIdentity, fetchUtils } from 'react-admin';\nimport { buildBlankNodesQuery } from '@semapps/semantic-data-provider';\n\nconst useInbox = () => {\n const { data: identity } = useGetIdentity();\n\n const inboxUrl = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.inbox;\n }\n }, [identity]);\n\n const sparqlEndpoint = useMemo(() => {\n if (identity?.webIdData) {\n return identity?.webIdData?.endpoints?.['void:sparqlEndpoint'] || `${identity?.id}/sparql`;\n }\n }, [identity]);\n\n const fetch = useCallback(\n async ({ filters }) => {\n if (!sparqlEndpoint || !inboxUrl) return;\n\n const token = localStorage.getItem('token');\n const blankNodesQuery = buildBlankNodesQuery(['as:object']);\n\n let filtersWhereQuery = '';\n if (filters) {\n Object.keys(filters).forEach(predicate => {\n if (filters[predicate]) {\n const object = filters[predicate].startsWith('http') ? `<${filters[predicate]}>` : filters[predicate];\n filtersWhereQuery += `?s1 ${predicate} ${object} .`;\n }\n });\n }\n\n const query = `\n PREFIX as: \n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ${blankNodesQuery.construct}\n }\n WHERE {\n <${inboxUrl}> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n FILTER( (isIRI(?s1)) ) .\n ${filtersWhereQuery}\n ${blankNodesQuery.where}\n }\n `;\n\n const { json } = await fetchUtils.fetchJson(sparqlEndpoint, {\n method: 'POST',\n body: query,\n headers: new Headers({\n Accept: 'application/ld+json',\n Authorization: token ? `Bearer ${token}` : undefined\n })\n });\n\n if (json['@graph']) {\n return json['@graph'];\n }\n return null;\n },\n [sparqlEndpoint, inboxUrl]\n );\n\n return { fetch, url: inboxUrl, owner: identity?.id };\n};\n\nexport default useInbox;\n","import { useEffect, useState } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useNodeinfo = (host, rel = 'http://nodeinfo.diaspora.software/ns/schema/2.1') => {\n const [schema, setSchema] = useState();\n\n useEffect(() => {\n (async () => {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are likely on HTTP\n const nodeinfoUrl = `${protocol}://${host}/.well-known/nodeinfo`;\n\n try {\n const { json: links } = await fetchUtils.fetchJson(nodeinfoUrl);\n\n // Accept any version of the nodeinfo protocol\n const link = links?.links?.find(l => l.rel === rel);\n\n const { json } = await fetchUtils.fetchJson(link.href);\n\n setSchema(json);\n } catch (e) {\n // Do nothing if nodeinfo can't be fetched\n }\n })();\n }, [host, setSchema, rel]);\n\n return schema;\n};\n\nexport default useNodeinfo;\n","import { useCallback } from 'react';\nimport { fetchUtils } from 'react-admin';\n\nconst useWebfinger = () => {\n // Post an activity to the logged user's outbox and return its URI\n const fetch = useCallback(async id => {\n // eslint-disable-next-line\n const [_, username, host] = id.split('@');\n if (host) {\n const protocol = host.includes(':') ? 'http' : 'https'; // If the host has a port, we are most likely on localhost\n const webfingerUrl = `${protocol}://${host}/.well-known/webfinger?resource=acct:${username}@${host}`;\n\n try {\n const { json } = await fetchUtils.fetchJson(webfingerUrl);\n\n const link = json.links.find(l => l.type === 'application/activity+json');\n\n return link ? link.href : null;\n } catch (e) {\n return null;\n }\n } else {\n return null;\n }\n }, []);\n\n return { fetch };\n};\n\nexport default useWebfinger;\n","import { useMemo } from 'react';\nimport { useGetList } from 'react-admin';\nimport { useDataModel } from '@semapps/semantic-data-provider';\nimport renderMentions from './renderMentions';\n\nconst useMentions = userResource => {\n const userDataModel = useDataModel(userResource);\n\n const { data } = useGetList(\n userResource,\n {\n filter: {\n _predicates: [userDataModel?.fieldsMapping?.title],\n blankNodes: []\n }\n },\n {\n enabled: !!userDataModel?.fieldsMapping?.title\n }\n );\n\n const availableMentions = useMemo(() => {\n if (data) {\n return data.map(item => ({ id: item.id, label: item[userDataModel?.fieldsMapping?.title] }));\n }\n }, [data]);\n\n const items = useMemo(() => {\n if (availableMentions) {\n return ({ query }) => {\n return availableMentions.filter(({ label }) => label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5);\n };\n }\n }, [availableMentions]);\n\n return {\n items,\n render: renderMentions\n };\n};\n\nexport default useMentions;\n","import { ReactRenderer } from '@tiptap/react';\nimport tippy from 'tippy.js';\nimport MentionsList from './MentionsList';\n\nconst renderMentions = () => {\n let component;\n let popup;\n\n return {\n onStart: props => {\n component = new ReactRenderer(MentionsList, {\n props,\n editor: props.editor\n });\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: 'manual',\n placement: 'bottom-start'\n });\n },\n\n onUpdate(props) {\n component.updateProps(props);\n\n popup[0].setProps({\n getReferenceClientRect: props.clientRect\n });\n },\n\n onKeyDown(props) {\n if (props.event.key === 'Escape') {\n popup[0].hide();\n\n return true;\n }\n\n return component.ref?.onKeyDown(props);\n },\n\n onExit() {\n popup[0].destroy();\n component.destroy();\n }\n };\n};\n\nexport default renderMentions;\n","import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport makeStyles from '@mui/styles/makeStyles';\n\nconst useStyles = makeStyles(theme => ({\n items: {\n background: '#fff',\n borderRadius: '0.5rem',\n boxShadow: '0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)',\n color: 'rgba(0, 0, 0, 0.8)',\n fontSize: '0.9rem',\n overflow: 'hidden',\n padding: '0.2rem',\n position: 'relative'\n },\n item: {\n background: 'transparent',\n border: '1px solid transparent',\n borderRadius: '0.4rem',\n display: 'block',\n margin: 0,\n padding: '0.2rem 0.4rem',\n textAlign: 'left',\n width: '100%',\n '&.selected': {\n borderColor: '#000'\n }\n }\n}));\n\nexport default forwardRef((props, ref) => {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const classes = useStyles();\n\n const selectItem = index => {\n const item = props.items[index];\n\n if (item) {\n props.command({ id: item });\n }\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + props.items.length - 1) % props.items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % props.items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n useEffect(() => setSelectedIndex(0), [props.items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === 'ArrowUp') {\n upHandler();\n return true;\n }\n\n if (event.key === 'ArrowDown') {\n downHandler();\n return true;\n }\n\n if (event.key === 'Enter') {\n enterHandler();\n return true;\n }\n\n return false;\n }\n }));\n\n return (\n
\n {props.items.length ? (\n props.items.map((item, index) => (\n selectItem(index)}\n >\n {item.label}\n \n ))\n ) : (\n
Aucun résultat
\n )}\n
\n );\n});\n"],"names":[],"version":3,"file":"index.es.js.map"} \ No newline at end of file diff --git a/src/frontend/packages/activitypub-components/src/constants.js b/src/frontend/packages/activitypub-components/src/constants.js index 84680d410..da0e73512 100644 --- a/src/frontend/packages/activitypub-components/src/constants.js +++ b/src/frontend/packages/activitypub-components/src/constants.js @@ -23,7 +23,7 @@ export const ACTIVITY_TYPES = { REMOVE: 'Remove', TENTATIVE_REJECT: 'TentativeReject', TENTATIVE_ACCEPT: 'TentativeAccept', - TRAVAL: 'Travel', + TRAVEL: 'Travel', UNDO: 'Undo', UPDATE: 'Update', VIEW: 'View' diff --git a/src/frontend/packages/activitypub-components/src/hooks/useCollection.js b/src/frontend/packages/activitypub-components/src/hooks/useCollection.js index ba123a466..c77871172 100644 --- a/src/frontend/packages/activitypub-components/src/hooks/useCollection.js +++ b/src/frontend/packages/activitypub-components/src/hooks/useCollection.js @@ -1,16 +1,76 @@ import { useCallback, useMemo, useState, useEffect } from 'react'; import { useGetIdentity, useDataProvider } from 'react-admin'; -import { useInfiniteQuery, useQueryClient } from 'react-query'; +import { useInfiniteQuery, useQueries } from 'react-query'; +import { getOrCreateWsChannel } from '@semapps/semantic-data-provider'; import { arrayOf } from '../utils'; +const useItemsFromPagesAndNotifications = (pages, notifications, dereferenceItems) => { + const dataProvider = useDataProvider(); + + // Add all items from pages and process notifications (possibly new and deleted items). + const items = useMemo( + () => { + const addItems = notifications.map(n => n.type === 'Add').map(n => n.object); + const removeItems = notifications.map(n => n.type === 'Remove').map(n => n.object.id || n.object); + const currentItems = !pages ? [] : pages.flatMap(p => arrayOf(p.orderedItems || p.items)); + const currentAndNew = currentItems.concat(addItems); + + return ( + currentAndNew + // Filter out removed items. + .filter(item => !removeItems.some(r => (r.id ?? r) === (item.id ?? item))) + // Filter duplicates. + .filter(item => currentAndNew.some(i2 => (i2.id ?? i2) === (item.id ?? item))) + ); + }, + pages, + notifications + ); + + if (!dereferenceItems) { + return { loadedItems: items, isLoading: false, isFetching: false }; + } + + // Dereference all items, if they are not yet. + const itemQueries = useQueries( + items + .filter(item => typeof item === 'string') + .map(itemUri => ({ + queryKey: ['resource', itemUri], + queryFn: async () => (await dataProvider.fetch(itemUri)).json, + staleTime: Infinity + })) + ); + + // Put all loaded items together (might be dereferenced already, so concatenate). + const loadedItems = items + .filter(item => typeof item !== 'string') + .concat( + itemQueries.flatMap(itemQuery => { + return (itemQuery.isSuccess && itemQuery.data) || []; + }) + ); + + console.log('loadedItems', loadedItems.length, 'total', items.length); + + const errors = itemQueries.filter(q => q.error); + return { + loadedItems, + isLoading: itemQueries.some(q => q.isLoading), + isFetching: itemQueries.some(q => q.isFetching), + errors: errors.length > 0 && errors + }; +}; + const useCollection = (predicateOrUrl, options = {}) => { - const { dereferenceItems = false } = options; + const { dereferenceItems = false, liveUpdates = true } = options; const { data: identity } = useGetIdentity(); - const [items, setItems] = useState(); const [totalItems, setTotalItems] = useState(); + const [notifications, setNotifications] = useState([]); + const [hasLiveUpdates, setHasLiveUpdates] = useState({ status: 'disconnected', error: undefined }); const dataProvider = useDataProvider(); - const queryClient = useQueryClient(); + // Get collectionUrl from webId predicate or URL. const collectionUrl = useMemo(() => { if (predicateOrUrl) { if (predicateOrUrl.startsWith('http')) { @@ -20,13 +80,19 @@ const useCollection = (predicateOrUrl, options = {}) => { return identity?.webIdData?.[predicateOrUrl]; } } + return undefined; + // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`); }, [identity, predicateOrUrl]); + // Fetch page of collection item references (if pageParam provided) + // or default to `collectionUrl` (which should give you the first page). const fetchCollection = useCallback( async ({ pageParam: nextPageUrl }) => { + // Fetch page or first page (collectionUrl) let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl); if (json.totalItems) setTotalItems(json.totalItems); + // If first page, handle this here. if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) { if (json.first?.items) { if (json.first?.items.length === 0 && json.first?.next) { @@ -41,86 +107,77 @@ const useCollection = (predicateOrUrl, options = {}) => { } } - // Force dereference of items - if (dereferenceItems) { - const itemPredicate = json.items ? 'items' : 'orderedItems'; - json[itemPredicate] = - json[itemPredicate] && - (await Promise.all( - arrayOf(json[itemPredicate]).map(async item => { - if (typeof item === 'string') { - const { json } = await dataProvider.fetch(item); - return json; - } - return item; - }) - )); - } - return json; }, [dataProvider, collectionUrl, identity, setTotalItems] ); - const { data, error, fetchNextPage, refetch, hasNextPage, isLoading, isFetching, isFetchingNextPage, status } = - useInfiniteQuery(['Collection', { collectionUrl }], fetchCollection, { - enabled: !!(collectionUrl && identity?.id), - getNextPageParam: lastPage => lastPage.next, - getPreviousPageParam: firstPage => firstPage.prev - }); + // Use infiniteQuery to handle pagination, fetching, etc. + const { + data, + error: collectionError, + fetchNextPage, + refetch, + hasNextPage, + isLoading: isLoadingPage, + isFetching: isFetchingPage, + isFetchingNextPage + } = useInfiniteQuery(['collection', { collectionUrl }], fetchCollection, { + enabled: !!(collectionUrl && identity?.id), + getNextPageParam: lastPage => lastPage.next, + getPreviousPageParam: firstPage => firstPage.prev + }); + + // Put all items together in a list. + const { + loadedItems: items, + isLoading: isLoadingItems, + isFetching: isFetchingItems, + errors: itemErrors + } = useItemsFromPagesAndNotifications(data?.pages, notifications, dereferenceItems); + // Notifications have been processed after hook call, so reset. + // useEffect(() => { + // setNotifications([]); + // }, [notifications]) + // Live Updates useEffect(() => { - if (data?.pages) { - setItems([].concat(...data.pages.map(p => arrayOf(p.orderedItems || p.items)))); + if (liveUpdates && collectionUrl) { + // Create ws that listens to collectionUri changes + getOrCreateWsChannel(dataProvider.fetch, collectionUrl) + .then(webSocket => { + webSocket.addEventListener('message', e => { + if ((e.data && e.data.type === 'Add') || e.data.type === 'Remove') { + setNotifications([...notifications, e.data]); + } + }); + webSocket.addEventListener('error', e => { + setHasLiveUpdates({ status: 'error', error: e }); + // TODO: Retry after a while + }); + webSocket.addEventListener('close', e => { + setHasLiveUpdates({ ...hasLiveUpdates, status: 'disconnected' }); + }); + setHasLiveUpdates({ status: 'connected' }); + }) + .catch(() => {}); // If it fails, we won't receive live updates. But that's okay. } - }, [data, setItems]); - - const addItem = useCallback( - item => { - setItems(oldItems => [...oldItems, item]); - // TODO use queryClient.setQueryData to update items directly in react-query cache - setTimeout( - () => - queryClient.refetchQueries(['Collection', { collectionUrl }], { - active: true, - exact: true - }), - 2000 - ); - }, - [setItems, queryClient, collectionUrl] - ); + }, [collectionUrl, liveUpdates, dataProvider.fetch]); - const removeItem = useCallback( - itemId => { - setItems(oldItems => oldItems.filter(item => (typeof item === 'string' ? item !== itemId : item.id !== itemId))); - // TODO use queryClient.setQueryData to update items directly in react-query cache - setTimeout( - () => - queryClient.refetchQueries(['Collection', { collectionUrl }], { - active: true, - exact: true - }), - 2000 - ); - }, - [setItems, queryClient, collectionUrl] - ); + const allErrors = arrayOf(collectionError).concat(arrayOf(itemErrors)); return { items, totalItems, - error, + error: allErrors.length > 0 && allErrors, refetch, fetchNextPage, hasNextPage, - isLoading, - isFetching, + isLoading: isLoadingPage || isLoadingItems, + isFetching: isFetchingPage || isFetchingItems, isFetchingNextPage, - status, - addItem, - removeItem, - url: collectionUrl + url: collectionUrl, + hasLiveUpdates }; }; diff --git a/src/frontend/packages/activitypub-components/src/hooks/useCollection.ts b/src/frontend/packages/activitypub-components/src/hooks/useCollection.ts new file mode 100644 index 000000000..65f9bbcd0 --- /dev/null +++ b/src/frontend/packages/activitypub-components/src/hooks/useCollection.ts @@ -0,0 +1,245 @@ +import { useCallback, useMemo, useState, useEffect } from 'react'; +import { useGetIdentity, useDataProvider } from 'react-admin'; +import { QueryFunction, useInfiniteQuery, useQueries, useQueryClient } from 'react-query'; +import { getOrCreateWsChannel } from '@semapps/semantic-data-provider'; +import { arrayOf } from '../utils'; + +const useItemsFromPages = (pages: any[], dereferenceItems: boolean) => { + const dataProvider = useDataProvider(); + const items = useMemo(() => pages.flatMap(p => arrayOf(p.orderedItems || p.items)), [pages]); + + // We will force dereference, if some items are not URI string references. + const shouldDereference = useMemo(() => { + return dereferenceItems || items.some(item => typeof item !== 'string'); + }, [dereferenceItems, items]); + + // Dereference all items, if necessary (even if shouldDereference is false, the hook needs to be called). + const itemQueries = useQueries( + !shouldDereference + ? [] + : items + .filter(item => typeof item === 'string') + .map(itemUri => ({ + queryKey: ['resource', itemUri], + queryFn: async () => (await dataProvider.fetch(itemUri)).json, + staleTime: Infinity + })) + ); + + if (!shouldDereference) { + return { loadedItems: items, isLoading: false, isFetching: false }; + } + + // Put all loaded items together (might be dereferenced already, so concatenate). + const loadedItems = items + .filter(item => typeof item !== 'string') + .concat( + itemQueries.flatMap(itemQuery => { + return (itemQuery.isSuccess && itemQuery.data) || []; + }) + ); + + const errors = itemQueries.filter(q => q.error); + return { + loadedItems, + isLoading: itemQueries.some(q => q.isLoading), + isFetching: itemQueries.some(q => q.isFetching), + errors: errors.length > 0 ? errors : undefined + }; +}; + +interface UseCollectionOptions { + dereferenceItems?: boolean; + liveUpdates?: boolean; +} + +/** + * Subscribe a collection. Supports pagination. + * @param predicateOrUrl The collection URI or the predicate to get the collection URI from the identity (webId). + * @param {UseCollectionOptions} options Defaults to `{ dereferenceItems: false, liveUpdates: true }` + */ +const useCollection = (predicateOrUrl: string, options: UseCollectionOptions = {}) => { + const { dereferenceItems = false, liveUpdates = true } = options; + const { data: identity } = useGetIdentity(); + const [totalItems, setTotalItems] = useState(); + const queryClient = useQueryClient(); + const [hasLiveUpdates, setHasLiveUpdates] = useState<{ status: string; error?: any }>({ status: 'connecting' }); + const dataProvider = useDataProvider(); + + // Get collectionUrl from webId predicate or URL. + const collectionUrl = useMemo(() => { + if (predicateOrUrl) { + if (predicateOrUrl.startsWith('http')) { + return predicateOrUrl; + } + if (identity?.webIdData) { + return identity?.webIdData?.[predicateOrUrl]; + } + } + return undefined; + // throw new Error(`No URL available for useCollection: ${predicateOrUrl}.`); + }, [identity, predicateOrUrl]); + + // Fetch page of collection item references (if pageParam provided) + // or default to `collectionUrl` (which should give you the first page). + const fetchCollection: QueryFunction = useCallback( + async ({ pageParam: nextPageUrl }) => { + // Fetch page or first page (collectionUrl) + let { json } = await dataProvider.fetch(nextPageUrl || collectionUrl); + if (json.totalItems) setTotalItems(json.totalItems); + + // If first page, handle this here. + if ((json.type === 'OrderedCollection' || json.type === 'Collection') && json.first) { + if (json.first?.items) { + if (json.first?.items.length === 0 && json.first?.next) { + // Special case where the first property is an object without items + ({ json } = await dataProvider.fetch(json.first?.next)); + } else { + json = json.first; + } + } else { + // Fetch the first page + ({ json } = await dataProvider.fetch(json.first)); + } + } + + return json; + }, + [dataProvider, collectionUrl, identity, setTotalItems] + ); + + // Use infiniteQuery to handle pagination, fetching, etc. + const { + data: pageData, + error: collectionError, + fetchNextPage, + refetch, + hasNextPage, + isLoading: isLoadingPage, + isFetching: isFetchingPage, + isFetchingNextPage + } = useInfiniteQuery(['collection', { collectionUrl }], fetchCollection, { + enabled: !!(collectionUrl && identity?.id), + getNextPageParam: (lastPage: any) => lastPage.next, + getPreviousPageParam: (firstPage: any) => firstPage.prev + }); + + // Put all items together in a list (and dereference, if required). + const { + loadedItems: items, + isLoading: isLoadingItems, + isFetching: isFetchingItems, + errors: itemErrors + } = useItemsFromPages(pageData?.pages ?? [], dereferenceItems); + + const allErrors = arrayOf(collectionError).concat(arrayOf(itemErrors)); + + const addItem = useCallback( + (item: string | any, shouldRefetch: boolean | number = true) => { + queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => { + if (!oldData) return oldData; + setTotalItems(totalItems && totalItems + 1); + + // Destructure, so react knows, it needs to re-render the pages. + const pages = [...oldData.pages]; + const firstPageItems: any[] = pages?.[0]?.orderedItems || pages?.[0]?.items || []; + firstPageItems.unshift(item); + + oldData.pages = pages; + return oldData; + }); + if (shouldRefetch) { + setTimeout( + () => + queryClient.refetchQueries(['collection', { collectionUrl }], { + active: true, + exact: true + }), + typeof shouldRefetch === 'number' ? shouldRefetch : 2000 + ); + } + }, + [queryClient, collectionUrl] + ); + + const removeItem = useCallback( + (item: string | any, shouldRefetch: boolean = true) => { + queryClient.setQueryData(['collection', { collectionUrl }], (oldData: any) => { + if (!oldData) return oldData; + setTotalItems(totalItems && totalItems - 1); + + // Destructure, so react knows, it needs to re-render the pages array. + const pages = [...oldData.pages]; + // Find the item in all pages and remove the item to be removed (either item.id or just item) + pages.forEach(page => { + if (page.orderedItems) { + page.orderedItems = page.orderedItems.filter((i: any) => (i.id || i) !== (item.id || item)); + } else if (page.items) { + page.items = page.items.filter((i: any) => (i.id || i) !== (item?.id || item)); + } + }); + + oldData.pages = pages; + return oldData; + }); + if (shouldRefetch) { + setTimeout( + () => + queryClient.refetchQueries(['collection', { collectionUrl }], { + active: true, + exact: true + }), + typeof shouldRefetch === 'number' ? shouldRefetch : 2000 + ); + } + }, + [queryClient, collectionUrl] + ); + + // Live Updates + useEffect(() => { + if (liveUpdates && collectionUrl) { + // Create ws that listens to collectionUri changes + getOrCreateWsChannel(dataProvider.fetch, collectionUrl) + .then(webSocket => { + webSocket.addEventListener('message', e => { + const data = JSON.parse(e.data); + if (data && data.type === 'Add') { + addItem(data.object, true); + } else if (data && data.type === 'Remove') { + removeItem(data.object, true); + } + }); + webSocket.addEventListener('error', e => { + setHasLiveUpdates({ status: 'error', error: e }); + // TODO: Retry after a while + }); + webSocket.addEventListener('close', e => { + if (!hasLiveUpdates.error) { + setHasLiveUpdates({ ...hasLiveUpdates, status: 'closed' }); + } + }); + setHasLiveUpdates({ status: 'connected' }); + }) + .catch(() => {}); // If it fails, we won't receive live updates. But that's okay. + } + }, [collectionUrl, liveUpdates, dataProvider]); + + return { + items, + totalItems, + error: allErrors.length > 0 && allErrors, + refetch, + fetchNextPage, + addItem, + removeItem, + hasNextPage, + isLoading: isLoadingPage || isLoadingItems, + isFetching: isFetchingPage || isFetchingItems, + isFetchingNextPage, + url: collectionUrl, + hasLiveUpdates + }; +}; + +export default useCollection; diff --git a/src/frontend/packages/activitypub-components/src/utils.js b/src/frontend/packages/activitypub-components/src/utils.js deleted file mode 100644 index 7b78cfd03..000000000 --- a/src/frontend/packages/activitypub-components/src/utils.js +++ /dev/null @@ -1,16 +0,0 @@ -export const arrayOf = value => { - // If the field is null-ish, we suppose there are no values. - if (value === null || value === undefined) { - return []; - } - // Return as is. - if (Array.isArray(value)) { - return value; - } - // Single value is made an array. - return [value]; -}; - -export default { - arrayOf -}; diff --git a/src/frontend/packages/activitypub-components/src/utils.ts b/src/frontend/packages/activitypub-components/src/utils.ts new file mode 100644 index 000000000..122e9c97a --- /dev/null +++ b/src/frontend/packages/activitypub-components/src/utils.ts @@ -0,0 +1,28 @@ +export const arrayOf = (value: T | T[]) => { + // If the field is null-ish, we suppose there are no values. + if (value === null || value === undefined) { + return []; + } + // Return as is. + if (Array.isArray(value)) { + return value; + } + // Single value is made an array. + return [value]; +}; + +export default { + arrayOf +}; + +export const filterDuplicates = (iterable: T[], predicate: (item: T) => string) => { + const seen = new Set(); + return iterable.filter(item => { + const key = predicate(item); + if (seen.has(key)) { + return false; + } + seen.add(key); + return true; + }); +}; diff --git a/src/frontend/packages/auth-provider/dist/index.d.ts b/src/frontend/packages/auth-provider/dist/index.d.ts index 2a80c21c7..689986e51 100644 --- a/src/frontend/packages/auth-provider/dist/index.d.ts +++ b/src/frontend/packages/auth-provider/dist/index.d.ts @@ -1,208 +1,167 @@ -import React from 'react'; -import { ToolbarProps } from 'react-admin'; -export function authProvider({ - dataProvider, - authType, - allowAnonymous, - checkUser, - checkPermissions, - clientId -}: { - dataProvider: any; - authType: any; - allowAnonymous?: boolean | undefined; - checkUser: any; - checkPermissions?: boolean | undefined; - clientId: any; +import React from "react"; +import { ToolbarProps } from "react-admin"; +export function authProvider({ dataProvider, authType, allowAnonymous, checkUser, checkPermissions, clientId }: { + dataProvider: any; + authType: any; + allowAnonymous?: boolean | undefined; + checkUser: any; + checkPermissions?: boolean | undefined; + clientId: any; }): { - login: (params: any) => Promise; - handleCallback: () => Promise; - signup: (params: any) => Promise; - logout: () => Promise; - checkAuth: () => Promise; - checkUser: (userData: any) => any; - checkError: (error: any) => Promise; - getPermissions: (uri: any) => Promise; - addPermission: (uri: any, agentId: any, predicate: any, mode: any) => Promise; - removePermission: (uri: any, agentId: any, predicate: any, mode: any) => Promise; - getIdentity: () => Promise< - | { + login: (params: any) => Promise; + handleCallback: () => Promise; + signup: (params: any) => Promise; + logout: () => Promise; + checkAuth: () => Promise; + checkUser: (userData: any) => any; + checkError: (error: any) => Promise; + getPermissions: (uri: any) => Promise; + addPermission: (uri: any, agentId: any, predicate: any, mode: any) => Promise; + removePermission: (uri: any, agentId: any, predicate: any, mode: any) => Promise; + getIdentity: () => Promise<{ id: any; fullName: any; profileData: any; webIdData: any; - } - | undefined - >; - resetPassword: (params: any) => Promise; - setNewPassword: (params: any) => Promise; - getAccountSettings: (params: any) => Promise; - updateAccountSettings: (params: any) => Promise; - /** - * Inform the OIDC server that the login interaction has been completed. - * This is necessary, otherwise the OIDC server will keep on redirecting to the login form. - * We call the endpoint with the token as a proof of login, otherwise it could be abused. - */ - loginCompleted: (interactionId: any, webId: any) => Promise; + } | undefined>; + resetPassword: (params: any) => Promise; + setNewPassword: (params: any) => Promise; + getAccountSettings: (params: any) => Promise; + updateAccountSettings: (params: any) => Promise; + /** + * Inform the OIDC server that the login interaction has been completed. + * This is necessary, otherwise the OIDC server will keep on redirecting to the login form. + * We call the endpoint with the token as a proof of login, otherwise it could be abused. + */ + loginCompleted: (interactionId: any, webId: any) => Promise; }; type AclMode = 'acl:Read' | 'acl:Append' | 'acl:Write' | 'acl:Control'; /** foaf:Agent = anonymous, acl:AuthenticatedAgent = logged */ type AclClass = 'foaf:Agent' | 'acl:AuthenticatedAgent'; type BasePermission = { - /** '#Control' | '#Read' | '#Write' | custom string */ - '@id': string; - '@type': 'acl:Authorization'; - 'acl:mode': AclMode; -} & ( - | { - /** Related resource URI */ - 'acl:accessTo'?: string; - } - | { - /** Parent resource URI */ - 'acl:default': string; - } -); + /** '#Control' | '#Read' | '#Write' | custom string */ + '@id': string; + '@type': 'acl:Authorization'; + 'acl:mode': AclMode; +} & ({ + /** Related resource URI */ + 'acl:accessTo'?: string; +} | { + /** Parent resource URI */ + 'acl:default': string; +}); type UserPermission = BasePermission & { - /** User resource URI */ - 'acl:agent': string; + /** User resource URI */ + 'acl:agent': string; }; type GroupPermission = BasePermission & { - /** ACL Group resource URI */ - 'acl:agentGroup': string; + /** ACL Group resource URI */ + 'acl:agentGroup': string; }; type ClassPermission = BasePermission & { - 'acl:agentClass': AclClass | AclClass[]; + 'acl:agentClass': AclClass | AclClass[]; }; type Permission = UserPermission | GroupPermission | ClassPermission; type Permissions = Permission[]; declare const rights: { - show: AclMode[]; - list: AclMode[]; - create: AclMode[]; - edit: AclMode[]; - delete: AclMode[]; - control: AclMode[]; + show: AclMode[]; + list: AclMode[]; + create: AclMode[]; + edit: AclMode[]; + delete: AclMode[]; + control: AclMode[]; }; -export const useCheckPermissions: ( - uri: string, - mode: keyof typeof rights, - redirectUrl?: string -) => Permissions | undefined; -export function CreateWithPermissions(props: any): import('react/jsx-runtime').JSX.Element; +export const useCheckPermissions: (uri: string, mode: keyof typeof rights, redirectUrl?: string) => Permissions | undefined; +export function CreateWithPermissions(props: any): import("react/jsx-runtime").JSX.Element; declare namespace CreateWithPermissions { - namespace defaultProps { - let actions: import('react/jsx-runtime').JSX.Element; - } + namespace defaultProps { + let actions: import("react/jsx-runtime").JSX.Element; + } } export function useAgents(uri: any): { - agents: {}; - addPermission: (agentId: any, predicate: any, mode: any) => void; - removePermission: (agentId: any, predicate: any, mode: any) => void; + agents: {}; + addPermission: (agentId: any, predicate: any, mode: any) => void; + removePermission: (agentId: any, predicate: any, mode: any) => void; }; -export function PermissionsButton({ isContainer }: { isContainer: any }): import('react/jsx-runtime').JSX.Element; +export function PermissionsButton({ isContainer }: { + isContainer: any; +}): import("react/jsx-runtime").JSX.Element; declare namespace PermissionsButton { - namespace defaultProps { - let isContainer: boolean; - } + namespace defaultProps { + let isContainer: boolean; + } } -export const EditActionsWithPermissions: () => import('react/jsx-runtime').JSX.Element; -export function DeleteButtonWithPermissions(props: any): import('react/jsx-runtime').JSX.Element | null; +export const EditActionsWithPermissions: () => import("react/jsx-runtime").JSX.Element; +export function DeleteButtonWithPermissions(props: any): import("react/jsx-runtime").JSX.Element | null; export const EditToolbarWithPermissions: React.FunctionComponent; -export function EditWithPermissions(props: any): import('react/jsx-runtime').JSX.Element; +export function EditWithPermissions(props: any): import("react/jsx-runtime").JSX.Element; declare namespace EditWithPermissions { - namespace defaultProps { - let actions: import('react/jsx-runtime').JSX.Element; - } + namespace defaultProps { + let actions: import("react/jsx-runtime").JSX.Element; + } } -export function EditButtonWithPermissions(props: any): import('react/jsx-runtime').JSX.Element | null; -export function ListActionsWithPermissions({ - bulkActions, - sort, - displayedFilters, - exporter, - filters, - filterValues, - onUnselectItems, - selectedIds, - showFilter, - total -}: { - bulkActions: any; - sort: any; - displayedFilters: any; - exporter: any; - filters: any; - filterValues: any; - onUnselectItems: any; - selectedIds: any; - showFilter: any; - total: any; -}): import('react/jsx-runtime').JSX.Element; -export function ListWithPermissions(props: any): import('react/jsx-runtime').JSX.Element; +export function EditButtonWithPermissions(props: any): import("react/jsx-runtime").JSX.Element | null; +export function ListActionsWithPermissions({ bulkActions, sort, displayedFilters, exporter, filters, filterValues, onUnselectItems, selectedIds, showFilter, total }: { + bulkActions: any; + sort: any; + displayedFilters: any; + exporter: any; + filters: any; + filterValues: any; + onUnselectItems: any; + selectedIds: any; + showFilter: any; + total: any; +}): import("react/jsx-runtime").JSX.Element; +export function ListWithPermissions(props: any): import("react/jsx-runtime").JSX.Element; declare namespace ListWithPermissions { - namespace defaultProps { - let actions: import('react/jsx-runtime').JSX.Element; - } + namespace defaultProps { + let actions: import("react/jsx-runtime").JSX.Element; + } } -export const ShowActionsWithPermissions: () => import('react/jsx-runtime').JSX.Element; -export function ShowWithPermissions(props: any): import('react/jsx-runtime').JSX.Element; +export const ShowActionsWithPermissions: () => import("react/jsx-runtime").JSX.Element; +export function ShowWithPermissions(props: any): import("react/jsx-runtime").JSX.Element; declare namespace ShowWithPermissions { - namespace defaultProps { - let actions: import('react/jsx-runtime').JSX.Element; - } + namespace defaultProps { + let actions: import("react/jsx-runtime").JSX.Element; + } } -export function AuthDialog({ - open, - onClose, - title, - message, - redirect, - ...rest -}: { - [x: string]: any; - open: any; - onClose: any; - title: any; - message: any; - redirect: any; -}): import('react/jsx-runtime').JSX.Element; +export function AuthDialog({ open, onClose, title, message, redirect, ...rest }: { + [x: string]: any; + open: any; + onClose: any; + title: any; + message: any; + redirect: any; +}): import("react/jsx-runtime").JSX.Element; declare namespace AuthDialog { - namespace defaultProps { - let title: string; - let message: string; - } + namespace defaultProps { + let title: string; + let message: string; + } } export declare namespace SsoLoginPageClasses { - export let card: string; - export let avatar: string; - export let icon: string; - let _switch: string; - export { _switch as switch }; + export let card: string; + export let avatar: string; + export let icon: string; + let _switch: string; + export { _switch as switch }; } -export function LoginPage({ - children, - backgroundImage, - buttons, - userResource, - propertiesExist, - text, - ...rest -}: { - [x: string]: any; - children: any; - backgroundImage: any; - buttons: any; - userResource: any; - propertiesExist: any; - text: any; -}): import('react/jsx-runtime').JSX.Element | null; +export function LoginPage({ children, backgroundImage, buttons, userResource, propertiesExist, text, ...rest }: { + [x: string]: any; + children: any; + backgroundImage: any; + buttons: any; + userResource: any; + propertiesExist: any; + text: any; +}): import("react/jsx-runtime").JSX.Element | null; declare namespace SsoLoginPage { - namespace defaultProps { - let propertiesExist: never[]; - let buttons: import('react/jsx-runtime').JSX.Element[]; - let userResource: string; - } + namespace defaultProps { + let propertiesExist: never[]; + let buttons: import("react/jsx-runtime").JSX.Element[]; + let userResource: string; + } } export function useSignup(): (params?: {}) => any; /** @@ -218,84 +177,75 @@ export function useSignup(): (params?: {}) => any; */ /** @type {PasswordStrengthOptions} */ export const defaultPasswordScorerOptions: PasswordStrengthOptions; -export function createPasswordScorer( - options?: PasswordStrengthOptions, - minRequiredScore?: number -): { - scoreFn: (password: any) => number; - minRequiredScore: number; - maxScore: number; +export function createPasswordScorer(options?: PasswordStrengthOptions, minRequiredScore?: number): { + scoreFn: (password: any) => number; + minRequiredScore: number; + maxScore: number; }; export declare namespace defaultScorer { - export function scoreFn(password: any): number; - export { minRequiredScore }; - export let maxScore: number; + export function scoreFn(password: any): number; + export { minRequiredScore }; + export let maxScore: number; } type PasswordStrengthOptions = { - /** - * - Required characters for a very long password (default: 12) - */ - isVeryLongLength: number; - /** - * - Required characters for a long password (default: 6) - */ - isLongLength: number; - /** - * - Score for a very long password (default: 2.5) - */ - isVeryLongScore: number; - /** - * - Score for a long password (default: 1.5) - */ - isLongScore: number; - /** - * - Score for a password with uppercase letters (default: 1) - */ - uppercaseScore: number; - /** - * - Score for a password with lowercase letters (default: 1) - */ - lowercaseScore: number; - /** - * - Score for a password with numbers (default: 1) - */ - numbersScore: number; - /** - * - Score for a password without non-alphanumeric characters (default: 1) - */ - nonAlphanumericsScore: number; + /** + * - Required characters for a very long password (default: 12) + */ + isVeryLongLength: number; + /** + * - Required characters for a long password (default: 6) + */ + isLongLength: number; + /** + * - Score for a very long password (default: 2.5) + */ + isVeryLongScore: number; + /** + * - Score for a long password (default: 1.5) + */ + isLongScore: number; + /** + * - Score for a password with uppercase letters (default: 1) + */ + uppercaseScore: number; + /** + * - Score for a password with lowercase letters (default: 1) + */ + lowercaseScore: number; + /** + * - Score for a password with numbers (default: 1) + */ + numbersScore: number; + /** + * - Score for a password without non-alphanumeric characters (default: 1) + */ + nonAlphanumericsScore: number; }; export function validatePasswordStrength(scorer?: { - scoreFn: (password: any) => number; - minRequiredScore: number; - maxScore: number; -}): (value: any) => 'auth.input.password_too_weak' | undefined; -export function PasswordStrengthIndicator({ - scorer, - password, - ...restProps -}: { - [x: string]: any; - scorer?: - | { + scoreFn: (password: any) => number; + minRequiredScore: number; + maxScore: number; +}): (value: any) => "auth.input.password_too_weak" | undefined; +export function PasswordStrengthIndicator({ scorer, password, ...restProps }: { + [x: string]: any; + scorer?: { scoreFn: (password: any) => number; minRequiredScore: number; maxScore: number; - } - | undefined; - password: any; -}): import('react/jsx-runtime').JSX.Element; + } | undefined; + password: any; +}): import("react/jsx-runtime").JSX.Element; declare namespace SignupForm { - namespace defaultValues { - let redirectTo: string; - let additionalSignupValues: {}; - } + namespace defaultValues { + let redirectTo: string; + let additionalSignupValues: {}; + } } declare namespace LoginForm { - namespace defaultValues { - let redirectTo: string; - let allowUsername: boolean; - } + namespace defaultValues { + let redirectTo: string; + let allowUsername: boolean; + } } /** * @param {object} props Props @@ -309,253 +259,238 @@ declare namespace LoginForm { * passwordStrength's `defaultScorer`. * @returns */ -export function LocalLoginPage({ - hasSignup, - allowUsername, - postSignupRedirect, - postLoginRedirect, - additionalSignupValues, - passwordScorer -}: { - hasSignup: boolean; - allowUsername: boolean; - postSignupRedirect: string; - postLoginRedirect: string; - additionalSignupValues: object; - passwordScorer: object; -}): import('react/jsx-runtime').JSX.Element | null; +export function LocalLoginPage({ hasSignup, allowUsername, postSignupRedirect, postLoginRedirect, additionalSignupValues, passwordScorer }: { + hasSignup: boolean; + allowUsername: boolean; + postSignupRedirect: string; + postLoginRedirect: string; + additionalSignupValues: object; + passwordScorer: object; +}): import("react/jsx-runtime").JSX.Element | null; declare namespace LocalLoginPage { - namespace defaultProps { - let hasSignup: boolean; - let allowUsername: boolean; - let additionalSignupValues: {}; - } + namespace defaultProps { + let hasSignup: boolean; + let allowUsername: boolean; + let additionalSignupValues: {}; + } } -export function ResourceWithPermissions({ - name, - create, - ...rest -}: { - [x: string]: any; - name: any; - create: any; -}): import('react/jsx-runtime').JSX.Element; -export function UserMenu({ - logout, - profileResource, - ...otherProps -}: { - [x: string]: any; - logout: any; - profileResource: any; -}): import('react/jsx-runtime').JSX.Element; +export function ResourceWithPermissions({ name, create, ...rest }: { + [x: string]: any; + name: any; + create: any; +}): import("react/jsx-runtime").JSX.Element; +export function UserMenu({ logout, profileResource, ...otherProps }: { + [x: string]: any; + logout: any; + profileResource: any; +}): import("react/jsx-runtime").JSX.Element; declare namespace UserMenu { - namespace defaultProps { - let logout: import('react/jsx-runtime').JSX.Element; - let profileResource: string; - } + namespace defaultProps { + let logout: import("react/jsx-runtime").JSX.Element; + let profileResource: string; + } } export function useCheckAuthenticated(message: any): { - identity: import('react-admin').UserIdentity | undefined; - isLoading: boolean; + identity: import("react-admin").UserIdentity | undefined; + isLoading: boolean; }; export function usePermissionsWithRefetch(params?: {}): { - refetch: () => Promise; - permissions?: any; + refetch: () => Promise; + permissions?: any; }; declare namespace englishMessages { - namespace auth { - namespace dialog { - let container_permissions: string; - let resource_permissions: string; - let login_required: string; - } - namespace action { - let submit: string; - let permissions: string; - let signup: string; - let reset_password: string; - let set_new_password: string; - let logout: string; - let login: string; - let view_my_profile: string; - let edit_my_profile: string; + namespace auth { + namespace dialog { + let container_permissions: string; + let resource_permissions: string; + let login_required: string; + } + namespace action { + let submit: string; + let permissions: string; + let signup: string; + let reset_password: string; + let set_new_password: string; + let logout: string; + let login: string; + let view_my_profile: string; + let edit_my_profile: string; + } + namespace right { + namespace resource { + let read: string; + let append: string; + let write: string; + let control: string; + } + namespace container { + let read_1: string; + export { read_1 as read }; + let append_1: string; + export { append_1 as append }; + let write_1: string; + export { write_1 as write }; + let control_1: string; + export { control_1 as control }; + } + } + namespace agent { + let anonymous: string; + let authenticated: string; + } + namespace input { + let agent_select: string; + let name: string; + let username: string; + let email: string; + let username_or_email: string; + let current_password: string; + let new_password: string; + let confirm_new_password: string; + let password_strength: string; + let password_too_weak: string; + } + namespace helper { + let login_1: string; + export { login_1 as login }; + let signup_1: string; + export { signup_1 as signup }; + let reset_password_1: string; + export { reset_password_1 as reset_password }; + let set_new_password_1: string; + export { set_new_password_1 as set_new_password }; + } + namespace message { + let resource_show_forbidden: string; + let resource_edit_forbidden: string; + let resource_delete_forbidden: string; + let resource_control_forbidden: string; + let container_create_forbidden: string; + let container_list_forbidden: string; + let unable_to_fetch_user_data: string; + let no_token_returned: string; + let invalid_token_returned: string; + let signup_error: string; + let user_not_allowed_to_login: string; + let user_email_not_found: string; + let user_email_exist: string; + let username_exist: string; + let username_invalid: string; + let new_user_created: string; + let user_connected: string; + let user_disconnected: string; + let bad_request: string; + let account_settings_updated: string; + let login_to_continue: string; + let choose_pod_provider: string; + } + namespace notification { + let reset_password_submitted: string; + let reset_password_error: string; + let password_changed: string; + let new_password_error: string; + let invalid_password: string; + let get_settings_error: string; + let update_settings_error: string; + } } - namespace right { - namespace resource { - let read: string; - let append: string; - let write: string; - let control: string; - } - namespace container { - let read_1: string; - export { read_1 as read }; - let append_1: string; - export { append_1 as append }; - let write_1: string; - export { write_1 as write }; - let control_1: string; - export { control_1 as control }; - } - } - namespace agent { - let anonymous: string; - let authenticated: string; - } - namespace input { - let agent_select: string; - let name: string; - let username: string; - let email: string; - let username_or_email: string; - let current_password: string; - let new_password: string; - let confirm_new_password: string; - let password_strength: string; - let password_too_weak: string; - } - namespace helper { - let login_1: string; - export { login_1 as login }; - let signup_1: string; - export { signup_1 as signup }; - let reset_password_1: string; - export { reset_password_1 as reset_password }; - let set_new_password_1: string; - export { set_new_password_1 as set_new_password }; - } - namespace message { - let resource_show_forbidden: string; - let resource_edit_forbidden: string; - let resource_delete_forbidden: string; - let resource_control_forbidden: string; - let container_create_forbidden: string; - let container_list_forbidden: string; - let unable_to_fetch_user_data: string; - let no_token_returned: string; - let invalid_token_returned: string; - let signup_error: string; - let user_not_allowed_to_login: string; - let user_email_not_found: string; - let user_email_exist: string; - let username_exist: string; - let username_invalid: string; - let new_user_created: string; - let user_connected: string; - let user_disconnected: string; - let bad_request: string; - let account_settings_updated: string; - let login_to_continue: string; - let choose_pod_provider: string; - } - namespace notification { - let reset_password_submitted: string; - let reset_password_error: string; - let password_changed: string; - let new_password_error: string; - let invalid_password: string; - let get_settings_error: string; - let update_settings_error: string; - } - } } declare namespace frenchMessages { - namespace auth { - namespace dialog { - let container_permissions: string; - let resource_permissions: string; - let login_required: string; - } - namespace action { - let submit: string; - let permissions: string; - let signup: string; - let reset_password: string; - let set_new_password: string; - let logout: string; - let login: string; - let view_my_profile: string; - let edit_my_profile: string; - } - namespace right { - namespace resource { - let read: string; - let append: string; - let write: string; - let control: string; - } - namespace container { - let read_1: string; - export { read_1 as read }; - let append_1: string; - export { append_1 as append }; - let write_1: string; - export { write_1 as write }; - let control_1: string; - export { control_1 as control }; - } - } - namespace agent { - let anonymous: string; - let authenticated: string; - } - namespace input { - let agent_select: string; - let name: string; - let username: string; - let email: string; - let username_or_email: string; - let current_password: string; - let new_password: string; - let confirm_new_password: string; - let password_strength: string; - let password_too_weak: string; - } - namespace helper { - let login_1: string; - export { login_1 as login }; - let signup_1: string; - export { signup_1 as signup }; - let reset_password_1: string; - export { reset_password_1 as reset_password }; - let set_new_password_1: string; - export { set_new_password_1 as set_new_password }; - } - namespace message { - let resource_show_forbidden: string; - let resource_edit_forbidden: string; - let resource_delete_forbidden: string; - let resource_control_forbidden: string; - let container_create_forbidden: string; - let container_list_forbidden: string; - let unable_to_fetch_user_data: string; - let no_token_returned: string; - let invalid_token_returned: string; - let signup_error: string; - let user_not_allowed_to_login: string; - let user_email_not_found: string; - let user_email_exist: string; - let username_exist: string; - let username_invalid: string; - let new_user_created: string; - let user_connected: string; - let user_disconnected: string; - let bad_request: string; - let account_settings_updated: string; - let login_to_continue: string; - let choose_pod_provider: string; - } - namespace notification { - let reset_password_submitted: string; - let reset_password_error: string; - let password_changed: string; - let new_password_error: string; - let invalid_password: string; - let get_settings_error: string; - let update_settings_error: string; + namespace auth { + namespace dialog { + let container_permissions: string; + let resource_permissions: string; + let login_required: string; + } + namespace action { + let submit: string; + let permissions: string; + let signup: string; + let reset_password: string; + let set_new_password: string; + let logout: string; + let login: string; + let view_my_profile: string; + let edit_my_profile: string; + } + namespace right { + namespace resource { + let read: string; + let append: string; + let write: string; + let control: string; + } + namespace container { + let read_1: string; + export { read_1 as read }; + let append_1: string; + export { append_1 as append }; + let write_1: string; + export { write_1 as write }; + let control_1: string; + export { control_1 as control }; + } + } + namespace agent { + let anonymous: string; + let authenticated: string; + } + namespace input { + let agent_select: string; + let name: string; + let username: string; + let email: string; + let username_or_email: string; + let current_password: string; + let new_password: string; + let confirm_new_password: string; + let password_strength: string; + let password_too_weak: string; + } + namespace helper { + let login_1: string; + export { login_1 as login }; + let signup_1: string; + export { signup_1 as signup }; + let reset_password_1: string; + export { reset_password_1 as reset_password }; + let set_new_password_1: string; + export { set_new_password_1 as set_new_password }; + } + namespace message { + let resource_show_forbidden: string; + let resource_edit_forbidden: string; + let resource_delete_forbidden: string; + let resource_control_forbidden: string; + let container_create_forbidden: string; + let container_list_forbidden: string; + let unable_to_fetch_user_data: string; + let no_token_returned: string; + let invalid_token_returned: string; + let signup_error: string; + let user_not_allowed_to_login: string; + let user_email_not_found: string; + let user_email_exist: string; + let username_exist: string; + let username_invalid: string; + let new_user_created: string; + let user_connected: string; + let user_disconnected: string; + let bad_request: string; + let account_settings_updated: string; + let login_to_continue: string; + let choose_pod_provider: string; + } + namespace notification { + let reset_password_submitted: string; + let reset_password_error: string; + let password_changed: string; + let new_password_error: string; + let invalid_password: string; + let get_settings_error: string; + let update_settings_error: string; + } } - } } //# sourceMappingURL=index.d.ts.map diff --git a/src/frontend/packages/semantic-data-provider/dist/index.cjs.js b/src/frontend/packages/semantic-data-provider/dist/index.cjs.js index 7e2363444..3c5a55775 100644 --- a/src/frontend/packages/semantic-data-provider/dist/index.cjs.js +++ b/src/frontend/packages/semantic-data-provider/dist/index.cjs.js @@ -31,6 +31,9 @@ $parcel$export(module.exports, "useDataServers", () => $c9933a88e2acc4da$export$ $parcel$export(module.exports, "FilterHandler", () => $f763906f9b20f2d8$export$2e2bcd8739ae039); $parcel$export(module.exports, "GroupedReferenceHandler", () => $b4703fef6d6af456$export$2e2bcd8739ae039); $parcel$export(module.exports, "ReificationArrayInput", () => $030f1232f6810456$export$2e2bcd8739ae039); +$parcel$export(module.exports, "createWsChannel", () => $84ab912646919f8c$export$28772ab4c256e709); +$parcel$export(module.exports, "getOrCreateWsChannel", () => $84ab912646919f8c$export$8d60734939c59ced); +$parcel$export(module.exports, "createSolidNotificationChannel", () => $84ab912646919f8c$export$3edfe18db119b920); const $3db7a4510a668a04$var$fetchResource = async (resourceUri, config)=>{ @@ -1565,5 +1568,96 @@ var $030f1232f6810456$export$2e2bcd8739ae039 = $030f1232f6810456$var$Reification +/** + * Find the solid notification description resource for a given resource URI. + */ const $84ab912646919f8c$var$findDescriptionResource = async (fetch, resourceUri)=>{ + const { headers: headers } = await fetch(resourceUri, { + method: "HEAD" + }); + const linkHeader = headers.get("Link"); + const matches = linkHeader?.match(/<([^>]+)>;\s*rel="(?:describedby|http:\/\/www\.w3\.org\/ns\/solid\/terms#storageDescription)"/); + if (!matches?.[1]) return undefined; + const { json: descriptionResource } = await fetch(matches[1]); + return descriptionResource; +}; +const $84ab912646919f8c$export$3edfe18db119b920 = async (fetch, resourceUri, options = { + type: "WebSocketChannel2023" +})=>{ + const { type: type, closeAfter: closeAfter, startIn: startIn, rate: rate } = options; + let { startAt: startAt, endAt: endAt } = options; + if (startIn && !startAt) startAt = new Date(Date.now() + startIn).toISOString(); + if (closeAfter && !endAt) endAt = new Date(Date.now() + closeAfter).toISOString(); + const descriptionResource = await $84ab912646919f8c$var$findDescriptionResource(fetch, resourceUri); + // TODO: use a json-ld parser / ldo in the future for this... + // Get solid notification subscription service for the given type. + const subscriptionService = (await Promise.all(// Get the subscription service resources (that describe a channel type). + (0, $e6fbab1f303bdb93$export$2e2bcd8739ae039)(descriptionResource.subscription || descriptionResource["notify:subscription"]).map(async (subscriptionServiceOrUri)=>{ + // They might not be resolved... + if (typeof subscriptionServiceOrUri === "string") { + const { json: json } = await fetch(subscriptionServiceOrUri); + return json; + } + return subscriptionServiceOrUri; + }))).find((service)=>{ + // Find for the correct channel type (e.g. web socket). + const channelType = service.channelType ?? service["notify:channelType"]; + return channelType === type || channelType === `notify:${type}`; + }); + if (!subscriptionService) throw new Error(`No solid notification subscription service found for type ${type}`); + // Create a new channel. + const { json: channel } = await fetch(subscriptionService.id || subscriptionService["@id"], { + method: "POST", + body: JSON.stringify({ + "@context": "https://www.w3.org/ns/solid/notification/v1", + type: "WebSocketChannel2023", + topic: resourceUri, + startAt: startAt, + endAt: endAt, + rate: rate + }) + }); + return channel; +}; +const $84ab912646919f8c$export$28772ab4c256e709 = async (fetch, resourceUri, options)=>{ + const channel = await $84ab912646919f8c$export$3edfe18db119b920(fetch, resourceUri, options); + const receiveFrom = channel.receiveFrom || channel["notify:receiveFrom"]; + return new WebSocket(receiveFrom); +}; +const $84ab912646919f8c$var$registeredWebSockets = new Map(); +/** + * @param fetch A react admin fetch function. + * @param resourceUri The resource to subscribe to + * @param options Options to pass to @see createSolidNotificationChannel, if the channel does not exist yet. + * @returns {WebSocket} A new or existing web socket that subscribed to the given resource. + */ const $84ab912646919f8c$export$8d60734939c59ced = async (fetch, resourceUri, options = { + type: "WebSocketChannel2023", + closeAfter: 3600000 +})=>{ + const socket = $84ab912646919f8c$var$registeredWebSockets.get(resourceUri); + if (socket) // Will resolve or is resolved already. + return socket; + // Create a promise, to return immediately and set the sockets cache. + // This prevents racing conditions that create multiple channels. + const wsPromise = $84ab912646919f8c$export$28772ab4c256e709(fetch, resourceUri, { + ...options, + type: "WebSocketChannel2023" + }).then((ws)=>{ + // Remove the promise from the cache, if it closes. + ws.addEventListener("close", (e)=>{ + $84ab912646919f8c$var$registeredWebSockets.delete(resourceUri); + }); + // Close the socket, if the endAt / closeAfter time is reached. + const closeIn = options.closeAfter ?? (options.endAt && new Date(options.endAt).getTime() - Date.now()); + if (closeIn) setTimeout(()=>{ + ws.close(); + }, closeIn); + return ws; + }); + $84ab912646919f8c$var$registeredWebSockets.set(resourceUri, wsPromise); + return wsPromise; +}; + + + //# sourceMappingURL=index.cjs.js.map diff --git a/src/frontend/packages/semantic-data-provider/dist/index.cjs.js.map b/src/frontend/packages/semantic-data-provider/dist/index.cjs.js.map index fa128c5b5..7e4097c7a 100644 --- a/src/frontend/packages/semantic-data-provider/dist/index.cjs.js.map +++ b/src/frontend/packages/semantic-data-provider/dist/index.cjs.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIEA,MAAM,sCAAgB,OAAO,aAAa;IACxC,MAAM,cAAE,UAAU,eAAE,WAAW,EAAE,GAAG;IAEpC,IAAI,EAAE,MAAM,IAAI,EAAE,GAAG,MAAM,WAAW;IAEtC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,CAAC,kBAAkB,EAAE,YAAY,CAAC;IAE7D,KAAK,EAAE,GAAG,KAAK,EAAE,IAAI,IAAI,CAAC,MAAM;IAEhC,sFAAsF;IACtF,gDAAgD;IAChD,IAAI,IAAI,CAAC,WAAW,KAAK,aACvB,OAAO,MAAM,CAAA,GAAA,uCAAK,EAAE,OAAO,CAAC,MAAM;IAGpC,OAAO;AACT;IAEA,2CAAe;;;ADlBf,MAAM,qCAAe,CAAA,SAAU,OA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MAAM,CAAC,eAAe,GAAG,KAAK,EAAE;YAChC,qBACE;;oBACG,eAAe,YAAY;wBAAE,GAAG,UAAU;wBAAE,OAAO;oBAAK;kCACzD,gCAAC,CAAA,GAAA,wCAAY;wBAAG,GAAG,UAAU;wBAAE,QAAQ;wBAAQ,QAAQ;wBAAQ,OAAO,IAAI,CAAC,WAAW;kCACnF;;;;QAIT;;AAGN;IAEA,2CAAe;;;;;;;AC1Ff,MAAM,gDAA0B,CAAA,GAAA,oDAAS,EAAE;IACzC,MAAM;QACJ,SAAS;IACX;IACA,OAAO;QACL,cAAc;IAChB;AACF;AAEA,MAAM,2CAAqB,CAAA,GAAA,oDAAS,EAAE;IACpC,MAAM;QACJ,SAAS;IACX;AACF;AAEA,MAAM,8CAAwB,CAAA;IAC5B,MAAM,oBAAE,gBAAgB,YAAE,QAAQ,EAAE,GAAG,YAAY,GAAG;IACtD,MAAM,kBAAkB;IACxB,MAAM,kBAAkB;IAExB,qBACE,gCAAC,CAAA,GAAA,4BAAS;QAAG,GAAG,UAAU;kBACxB,cAAA,iCAAC,CAAA,GAAA,oCAAiB;YAAE,SAAS;gBAAE,MAAM,gBAAgB,IAAI;YAAC;;gBACvD,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,QAAQ,EAAE,CAAC,OAAO;oBAC1C,qBAAO,CAAA,GAAA,sCAAI,EAAE,YAAY,CAAC,OAAO;wBAC/B,WAAW,gBAAgB,KAAK;oBAClC;gBACF;8BACA,gCAAC,CAAA,GAAA,2BAAQ;oBAAE,WAAW,gBAAgB,IAAI;oBAAE,QAAO;oBAAO,cAAc;;;;;AAIhF;IAEA,2CAAe;;","sources":["packages/semantic-data-provider/src/index.ts","packages/semantic-data-provider/src/dataProvider/dataProvider.js","packages/semantic-data-provider/src/dataProvider/methods/create.js","packages/semantic-data-provider/src/dataProvider/methods/getOne.js","packages/semantic-data-provider/src/dataProvider/utils/fetchResource.js","packages/semantic-data-provider/src/dataProvider/utils/handleFiles.ts","packages/semantic-data-provider/src/dataProvider/utils/findContainersWithTypes.ts","packages/semantic-data-provider/src/dataProvider/utils/parseServerKeys.js","packages/semantic-data-provider/src/dataProvider/utils/getServerKeyFromType.js","packages/semantic-data-provider/src/dataProvider/methods/delete.ts","packages/semantic-data-provider/src/dataProvider/methods/deleteMany.js","packages/semantic-data-provider/src/dataProvider/methods/getDataServers.js","packages/semantic-data-provider/src/dataProvider/methods/getDataModels.js","packages/semantic-data-provider/src/dataProvider/methods/getList.js","packages/semantic-data-provider/src/dataProvider/utils/fetchContainers.ts","packages/semantic-data-provider/src/dataProvider/utils/arrayOf.ts","packages/semantic-data-provider/src/dataProvider/utils/fetchSparqlEndpoints.js","packages/semantic-data-provider/src/dataProvider/utils/getEmbedFrame.js","packages/semantic-data-provider/src/dataProvider/utils/buildSparqlQuery.js","packages/semantic-data-provider/src/dataProvider/utils/buildBaseQuery.js","packages/semantic-data-provider/src/dataProvider/utils/resolvePrefix.js","packages/semantic-data-provider/src/dataProvider/utils/buildBlankNodesQuery.js","packages/semantic-data-provider/src/dataProvider/utils/buildAutoDetectBlankNodesQuery.js","packages/semantic-data-provider/src/dataProvider/utils/findContainersWithPath.js","packages/semantic-data-provider/src/dataProvider/methods/getMany.js","packages/semantic-data-provider/src/dataProvider/methods/getManyReference.js","packages/semantic-data-provider/src/dataProvider/methods/update.ts","packages/semantic-data-provider/src/dataProvider/utils/fetchUserConfig.js","packages/semantic-data-provider/src/dataProvider/utils/fetchVoidEndpoints.js","packages/semantic-data-provider/src/dataProvider/httpClient.js","packages/semantic-data-provider/src/dataProvider/utils/getServerKeyFromUri.js","packages/semantic-data-provider/src/hooks/useGetExternalLink.js","packages/semantic-data-provider/src/hooks/useContainers.ts","packages/semantic-data-provider/src/hooks/useDataModel.ts","packages/semantic-data-provider/src/hooks/useDataServers.ts","packages/semantic-data-provider/src/hooks/useCreateContainer.js","packages/semantic-data-provider/src/dataProvider/utils/findCreateContainerWithTypes.ts","packages/semantic-data-provider/src/hooks/useCreateContainerUri.ts","packages/semantic-data-provider/src/hooks/useDataModels.ts","packages/semantic-data-provider/src/reification/FilterHandler.js","packages/semantic-data-provider/src/reification/GroupedReferenceHandler.js","packages/semantic-data-provider/src/reification/ReificationArrayInput.js"],"sourcesContent":["export { default as dataProvider } from './dataProvider/dataProvider';\n\nexport { default as buildSparqlQuery } from './dataProvider/utils/buildSparqlQuery';\nexport { default as buildBlankNodesQuery } from './dataProvider/utils/buildBlankNodesQuery';\n\nexport { default as useGetExternalLink } from './hooks/useGetExternalLink';\nexport { default as useContainers } from './hooks/useContainers';\nexport { default as useCreateContainer } from './hooks/useCreateContainer';\nexport { default as useCreateContainerUri } from './hooks/useCreateContainerUri';\nexport { default as useDataModel } from './hooks/useDataModel';\nexport { default as useDataModels } from './hooks/useDataModels';\nexport { default as useDataServers } from './hooks/useDataServers';\n\nexport { default as FilterHandler } from './reification/FilterHandler';\nexport { default as GroupedReferenceHandler } from './reification/GroupedReferenceHandler';\nexport { default as ReificationArrayInput } from './reification/ReificationArrayInput';\n","import createMethod from './methods/create';\nimport deleteMethod from './methods/delete';\nimport deleteManyMethod from './methods/deleteMany';\nimport getDataServersMethod from './methods/getDataServers';\nimport getDataModelsMethod from './methods/getDataModels';\nimport getListMethod from './methods/getList';\nimport getManyMethod from './methods/getMany';\nimport getManyReferenceMethod from './methods/getManyReference';\nimport getOneMethod from './methods/getOne';\nimport updateMethod from './methods/update';\nimport fetchUserConfig from './utils/fetchUserConfig';\nimport fetchVoidEndpoints from './utils/fetchVoidEndpoints';\nimport getServerKeyFromType from './utils/getServerKeyFromType';\nimport httpClient from './httpClient';\n\nconst dataProvider = config => {\n // TODO verify all data provider config + data models\n if (!getServerKeyFromType('default', config.dataServers))\n throw new Error('You must define a default server in your dataServers config');\n\n if (!config.jsonContext) config.jsonContext = Object.fromEntries(config.ontologies.map(o => [o.prefix, o.url]));\n if (!config.returnFailedResources) config.returnFailedResources = false;\n\n // Configure httpClient with data servers (this is needed for proxy calls)\n config.httpClient = httpClient(config.dataServers);\n\n // Keep in memory for refresh\n const originalConfig = { ...config };\n\n let fetchUserConfigPromise = fetchUserConfig(config);\n let fetchVoidEndpointsPromise = fetchVoidEndpoints(config);\n\n const waitForConfig =\n method =>\n async (...arg) => {\n await fetchUserConfigPromise;\n await fetchVoidEndpointsPromise; // Return immediately if promise is fulfilled\n return await method(...arg);\n };\n\n return {\n getList: waitForConfig(getListMethod(config)),\n getMany: waitForConfig(getManyMethod(config)),\n getManyReference: waitForConfig(getManyReferenceMethod(config)),\n getOne: waitForConfig(getOneMethod(config)),\n create: waitForConfig(createMethod(config)),\n update: waitForConfig(updateMethod(config)),\n updateMany: () => {\n throw new Error('updateMany is not implemented yet');\n },\n delete: waitForConfig(deleteMethod(config)),\n deleteMany: waitForConfig(deleteManyMethod(config)),\n // Custom methods\n getDataModels: waitForConfig(getDataModelsMethod(config)),\n getDataServers: waitForConfig(getDataServersMethod(config)),\n getLocalDataServers: getDataServersMethod(config),\n fetch: waitForConfig(config.httpClient),\n refreshConfig: async () => {\n config = { ...originalConfig };\n fetchUserConfigPromise = fetchUserConfig(config);\n fetchVoidEndpointsPromise = fetchVoidEndpoints(config);\n await fetchUserConfigPromise;\n await fetchVoidEndpointsPromise;\n return config;\n }\n };\n};\n\nexport default dataProvider;\n","import urlJoin from 'url-join';\nimport getOne from './getOne';\nimport handleFiles from '../utils/handleFiles';\nimport findContainersWithTypes from '../utils/findContainersWithTypes';\n\nconst createMethod = config => async (resourceId, params) => {\n const { dataServers, resources, httpClient, jsonContext } = config;\n const dataModel = resources[resourceId];\n\n if (!dataModel) Error(`Resource ${resourceId} is not mapped in resources file`);\n\n const headers = new Headers();\n\n let containerUri;\n let serverKey;\n if (dataModel.create?.container) {\n serverKey = Object.keys(dataModel.create.container)[0];\n containerUri = urlJoin(dataServers[serverKey].baseUrl, Object.values(dataModel.create.container)[0]);\n } else {\n serverKey = dataModel.create?.server || Object.keys(dataServers).find(key => dataServers[key].default === true);\n if (!serverKey) throw new Error('You must define a server for the creation, or a container, or a default server');\n\n const containers = findContainersWithTypes(dataModel.types, [serverKey], dataServers);\n // Extract the containerUri from the results (and ensure there is only one)\n const serverKeys = Object.keys(containers);\n\n if (!serverKeys || serverKeys.length === 0)\n throw new Error(`No container with types ${JSON.stringify(dataModel.types)} found on server ${serverKey}`);\n if (serverKeys.length > 1 || containers[serverKeys[0]].length > 1)\n throw new Error(\n `More than one container detected with types ${JSON.stringify(dataModel.types)} on server ${serverKey}`\n );\n containerUri = containers[serverKeys[0]][0];\n }\n\n if (params.data) {\n if (dataModel.fieldsMapping?.title) {\n if (Array.isArray(dataModel.fieldsMapping.title)) {\n headers.set('Slug', dataModel.fieldsMapping.title.map(f => params.data[f]).join(' '));\n } else {\n headers.set('Slug', params.data[dataModel.fieldsMapping.title]);\n }\n }\n\n // Upload files, if there are any\n const { updatedRecord } = await handleFiles.upload(params.data, config);\n params.data = updatedRecord;\n\n const { headers: responseHeaders } = await httpClient(containerUri, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n '@context': jsonContext,\n '@type': dataModel.types,\n ...params.data\n })\n });\n\n // Retrieve newly-created resource\n const resourceUri = responseHeaders.get('Location');\n return await getOne(config)(resourceId, { id: resourceUri });\n }\n if (params.id) {\n headers.set('Content-Type', 'application/sparql-update');\n\n await httpClient(containerUri, {\n method: 'PATCH',\n headers,\n body: `\n PREFIX ldp: \n INSERT DATA { <${containerUri}> ldp:contains <${params.id}>. };\n `\n });\n\n // Create must return the new data, so get them from the remote URI\n return await getOne(config)(resourceId, { id: params.id });\n }\n};\n\nexport default createMethod;\n","import fetchResource from '../utils/fetchResource';\n\nconst getOneMethod = config => async (resourceId, params) => {\n const { resources } = config;\n const dataModel = resources[resourceId];\n\n if (!dataModel) throw new Error(`Resource ${resourceId} is not mapped in resources file`);\n\n const data = await fetchResource(params.id, config);\n\n // Transform single value into array if forceArray is set\n if (dataModel.list?.forceArray) {\n for (const forceArrayItem of dataModel.list?.forceArray || []) {\n if (data[forceArrayItem] && !Array.isArray(data[forceArrayItem])) {\n data[forceArrayItem] = [data[forceArrayItem]];\n }\n }\n }\n\n // TODO activate defaultFetchPlan option\n // if (dataModel.list?.defaultFetchPlan) {\n // for (const node of dataModel.list?.defaultFetchPlan) {\n // if (\n // data[node] &&\n // typeof data[node] === 'string' &&\n // data[node].startsWith('http')\n // ) {\n // try {\n // const dataToEmbed = await fetchResource(data[node], config);\n // delete dataToEmbed['@context'];\n // data[node] = dataToEmbed;\n // } catch (e) {\n // // Ignore errors (this may happen if user does not have rights to see the resource)\n // }\n // }\n // }\n // }\n\n return { data };\n};\n\nexport default getOneMethod;\n","import jsonld from 'jsonld';\n\nconst fetchResource = async (resourceUri, config) => {\n const { httpClient, jsonContext } = config;\n\n let { json: data } = await httpClient(resourceUri);\n\n if (!data) throw new Error(`Not a valid JSON: ${resourceUri}`);\n\n data.id = data.id || data['@id'];\n\n // We compact only if the context is different between the frontend and the middleware\n // TODO deep compare if the context is an object\n if (data['@context'] !== jsonContext) {\n data = await jsonld.compact(data, jsonContext);\n }\n\n return data;\n};\n\nexport default fetchResource;\n","import urlJoin from 'url-join';\nimport { RaRecord } from 'react-admin';\nimport { Configuration } from '../types';\n\nconst isFile = (o: any): o is { rawFile: File } => o?.rawFile && o.rawFile instanceof File;\nconst isFileToDelete = (o: any): o is { fileToDelete: string } =>\n o?.fileToDelete !== undefined && o?.fileToDelete !== null;\n\nconst getUploadsContainerUri = (config: Configuration) => {\n const serverKey = Object.keys(config.dataServers).find(key => config.dataServers[key].uploadsContainer);\n if (serverKey && config.dataServers[serverKey].uploadsContainer) {\n return urlJoin(config.dataServers[serverKey].baseUrl, config.dataServers[serverKey].uploadsContainer!);\n }\n return null;\n};\n\nconst uploadFile = async (rawFile: File, config: Configuration) => {\n const uploadsContainerUri = getUploadsContainerUri(config);\n if (!uploadsContainerUri) throw new Error(\"You must define an uploadsContainer in one of the server's configuration\");\n\n const response = await config.httpClient(uploadsContainerUri, {\n method: 'POST',\n body: rawFile,\n headers: new Headers({\n 'Content-Type': rawFile.type\n })\n });\n\n if (response.status === 201) {\n return response.headers.get('Location');\n }\n return null;\n};\n\nconst deleteFiles = async (filesToDelete: string[], config: Configuration) => {\n return Promise.all(\n filesToDelete.map(file =>\n config.httpClient(file, {\n method: 'DELETE'\n })\n )\n );\n};\n\n/*\n * Look for raw files in the record data.\n * If there are any, upload them and replace the file by its URL.\n */\nconst uploadAllFiles = async (record: Partial, config: Configuration) => {\n const filesToDelete: string[] = [];\n const updatedRecord = { ...record };\n\n for (const property of Object.keys(record)) {\n const value = record[property];\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const itemValue = value[i];\n if (isFile(itemValue)) {\n if (isFileToDelete(itemValue)) {\n filesToDelete.push(itemValue.fileToDelete);\n }\n updatedRecord[property][i] = await uploadFile(itemValue.rawFile, config);\n } else if (isFileToDelete(itemValue)) {\n filesToDelete.push(itemValue.fileToDelete);\n updatedRecord[property][i] = null;\n }\n }\n } else if (isFile(value)) {\n if (isFileToDelete(value)) {\n filesToDelete.push(value.fileToDelete);\n }\n updatedRecord[property] = await uploadFile(value.rawFile, config);\n } else if (isFileToDelete(value)) {\n filesToDelete.push(value.fileToDelete);\n updatedRecord[property] = null;\n }\n }\n\n return {\n updatedRecord,\n filesToDelete\n };\n};\n\nexport default {\n upload: uploadAllFiles,\n delete: deleteFiles\n};\n","import urlJoin from 'url-join';\nimport { Configuration, DataServerKey } from '../types';\nimport parseServerKeys from './parseServerKeys';\n\nconst findContainersWithTypes = (\n types: string[],\n serverKeys: string | string[] | undefined,\n dataServers: Configuration['dataServers']\n) => {\n const containers = {} as Record;\n const existingContainers: string[] = [];\n\n const parsedServerKeys = parseServerKeys(serverKeys, dataServers);\n\n Object.keys(dataServers)\n .filter(dataServerKey => dataServers[dataServerKey].containers)\n .forEach(dataServerKey => {\n Object.keys(dataServers[dataServerKey].containers || {}).forEach(containerKey => {\n if (!parsedServerKeys || parsedServerKeys.includes(containerKey)) {\n Object.keys(dataServers[dataServerKey].containers![containerKey]).forEach(type => {\n if (types.includes(type)) {\n dataServers[dataServerKey].containers![containerKey][type].map(path => {\n const containerUri = urlJoin(dataServers[containerKey].baseUrl, path);\n\n // Avoid returning the same container several times\n if (!existingContainers.includes(containerUri)) {\n existingContainers.push(containerUri);\n\n if (!containers[dataServerKey]) containers[dataServerKey] = [];\n containers[dataServerKey].push(containerUri);\n }\n });\n }\n });\n }\n });\n });\n return containers;\n};\n\nexport default findContainersWithTypes;\n","import getServerKeyFromType from './getServerKeyFromType';\n\nconst parseServerKey = (serverKey, dataServers) => {\n switch (serverKey) {\n case '@default':\n return getServerKeyFromType('default', dataServers);\n case '@pod':\n return getServerKeyFromType('pod', dataServers);\n case '@authServer':\n return getServerKeyFromType('authServer', dataServers);\n default:\n return serverKey;\n }\n};\n\n// Return the list of servers keys in an array\n// parsing keywords like @all, @default, @pod and @authServer\nconst parseServerKeys = (serverKeys, dataServers) => {\n if (Array.isArray(serverKeys)) {\n if (serverKeys.includes('@all')) {\n return Object.keys(dataServers);\n }\n return serverKeys.map(serverKey => parseServerKey(serverKey, dataServers));\n }\n if (typeof serverKeys === 'string') {\n if (serverKeys === '@all') {\n return Object.keys(dataServers);\n }\n if (serverKeys === '@remote') {\n const defaultServerKey = getServerKeyFromType('default', dataServers);\n return Object.keys(dataServers).filter(serverKey => serverKey !== defaultServerKey);\n }\n return [parseServerKey(serverKeys, dataServers)];\n }\n // If server key is empty\n return false;\n};\n\nexport default parseServerKeys;\n","const getServerKeyFromType = (type, dataServers) => {\n return Object.keys(dataServers).find(key => {\n return dataServers[key][type];\n });\n};\n\nexport default getServerKeyFromType;\n","import { DeleteParams, RaRecord } from 'react-admin';\nimport { Configuration } from '../types';\nimport handleFiles from '../utils/handleFiles';\n\nconst deleteMethod = (config: Configuration) => async (resourceId: string, params: DeleteParams) => {\n const { httpClient } = config;\n\n await httpClient(`${params.id}`, {\n method: 'DELETE'\n });\n\n if (params.meta?.filesToDelete) {\n await handleFiles.delete(params.meta.filesToDelete, config);\n }\n\n return { data: { id: params.id } };\n};\n\nexport default deleteMethod;\n","const deleteManyMethod = config => async (resourceId, params) => {\n const { httpClient } = config;\n const ids = [];\n\n for (const id of params.ids) {\n try {\n await httpClient(id, {\n method: 'DELETE'\n });\n ids.push(id);\n } catch (e) {\n // Do nothing if we fail to delete a resource\n }\n }\n\n return { data: ids };\n};\n\nexport default deleteManyMethod;\n","const getDataServers = config => () => {\n return config.dataServers;\n};\n\nexport default getDataServers;\n","const getDataModels = config => () => {\n return config.resources;\n};\n\nexport default getDataModels;\n","import findContainersWithTypes from '../utils/findContainersWithTypes';\nimport fetchContainers from '../utils/fetchContainers';\nimport fetchSparqlEndpoints from '../utils/fetchSparqlEndpoints';\nimport findContainersWithPaths from '../utils/findContainersWithPath';\n\nconst getListMethod =\n config =>\n async (resourceId, params = {}) => {\n const { dataServers, resources } = config;\n const dataModel = resources[resourceId];\n\n if (!dataModel) throw new Error(`Resource ${resourceId} is not mapped in resources file`);\n\n let containers;\n if (!params.filter?._servers && dataModel.list?.containers) {\n if (Array.isArray(dataModel.list?.containers))\n throw new Error(\n `The list.containers property of ${resourceId} dataModel must be of type object ({ serverKey: [containerUri] })`\n );\n // If containers are set explicitly, use them\n containers = findContainersWithPaths(dataModel.list.containers, dataServers);\n } else {\n // Otherwise find the container URIs on the given servers (either in the filter or the data model)\n containers = findContainersWithTypes(\n dataModel.types,\n params.filter?._servers || dataModel.list?.servers,\n dataServers\n );\n }\n\n if (dataModel.list?.fetchContainer) {\n return fetchContainers(containers, params, config);\n }\n return fetchSparqlEndpoints(containers, resourceId, params, config);\n };\n\nexport default getListMethod;\n","import jsonld, { ContextDefinition } from 'jsonld';\nimport { GetListParams } from 'react-admin';\nimport arrayOf from './arrayOf';\nimport { Configuration, ContainerURI, DataServerKey } from '../types';\n\ntype LDPContainerType = 'ldp:Container' | 'ldp:BasicContainer';\n\ninterface LDPContainerBase {\n '@context': Configuration['jsonContext'];\n id: string;\n 'ldp:contains': Record[];\n}\n\ninterface LDPContainerWithType extends LDPContainerBase {\n type: LDPContainerType | LDPContainerType[];\n}\n\ninterface LDPContainerWithAtType extends LDPContainerBase {\n '@type': LDPContainerType | LDPContainerType[];\n}\n\ntype LDPContainer = LDPContainerWithType | LDPContainerWithAtType;\n\ntype LDPResource = {\n '@context': Configuration['jsonContext'];\n [key: string]: any;\n};\n\ntype ListFilters = Partial<{\n q: string;\n type: string;\n _predicates: string[];\n _servers: DataServerKey[];\n [attribute: string]: any;\n}>;\n\nconst isValidLDPContainer = (container: LDPContainer) => {\n const resourceType = (container as LDPContainerWithType).type || (container as LDPContainerWithAtType)['@type'];\n return Array.isArray(resourceType) ? resourceType.includes('ldp:Container') : resourceType === 'ldp:Container';\n};\n\nconst isObject = (val: any) => {\n return val != null && typeof val === 'object' && !Array.isArray(val);\n};\n\nconst fetchContainers = async (\n containers: Record,\n params: GetListParams,\n { httpClient, jsonContext }: Configuration\n) => {\n const containersUri = Object.values(containers).flat();\n\n const fetchPromises = containersUri.map(containerUri =>\n httpClient(containerUri)\n .then(async ({ json }) => {\n const jsonResponse: LDPContainer = json;\n\n // If container's context is different, compact it to have an uniform result\n // TODO deep compare if the context is an object\n if (jsonResponse['@context'] !== jsonContext) {\n return jsonld.compact(jsonResponse, jsonContext as ContextDefinition) as unknown as Promise;\n }\n\n return jsonResponse;\n })\n .then((json: LDPContainer) => {\n if (!isValidLDPContainer(json)) {\n throw new Error(`${containerUri} is not a LDP container`);\n }\n\n return arrayOf(json['ldp:contains']).map(resource => ({\n '@context': json['@context'],\n ...resource\n }));\n })\n );\n\n // Fetch simultaneously all containers\n const results = await Promise.all(fetchPromises);\n let resources = results.flat();\n\n resources = resources.map(resource => {\n resource.id = resource.id || resource['@id'];\n return resource;\n });\n\n // Apply filter to results\n const filters: ListFilters = params.filter;\n\n // For SPARQL queries, we use \"a\" to filter types, but in containers it must be \"type\"\n if (filters.a) {\n filters.type = filters.a;\n delete filters.a;\n }\n\n // Filter resources attributes according to _predicates list\n if (filters._predicates && Array.isArray(filters._predicates)) {\n const predicates = filters._predicates;\n const mandatoryAttributes = ['id'];\n\n resources = resources.map(resource => {\n return Object.keys(resource)\n .filter(key => predicates.includes(key) || mandatoryAttributes.includes(key))\n .reduce(\n (filteredResource, key) => {\n filteredResource[key] = resource[key];\n return filteredResource;\n },\n { '@context': [] }\n );\n });\n }\n\n if (Object.keys(filters).filter(f => !['_predicates', '_servers'].includes(f)).length > 0) {\n resources = resources.filter(resource => {\n // Full text filtering\n if (filters.q) {\n return Object.values(resource).some(attributeValue => {\n if (!isObject(attributeValue)) {\n const arrayValues = Array.isArray(attributeValue) ? attributeValue : [attributeValue];\n return arrayValues.some(value => {\n if (typeof value === 'string') {\n return value.toLowerCase().normalize('NFD').includes(filters.q!.toLowerCase().normalize('NFD'));\n }\n return false;\n });\n }\n return false;\n });\n }\n\n // Attribute filtering\n const attributesFilters = Object.keys(filters).filter(f => !['_predicates', '_servers', 'q'].includes(f));\n\n return attributesFilters.every(attribute => {\n if (resource[attribute]) {\n const arrayValues: any[] = Array.isArray(resource[attribute]) ? resource[attribute] : [resource[attribute]];\n return arrayValues.some(\n (value: any) => typeof value === 'string' && value.includes(filters[attribute] as string)\n );\n }\n\n return false;\n });\n });\n }\n\n // Sorting\n if (params.sort) {\n resources = resources.sort((a, b) => {\n if (a[params.sort.field] && b[params.sort.field]) {\n if (params.sort.order === 'ASC') {\n return a[params.sort.field].localeCompare(b[params.sort.field]);\n }\n return b[params.sort.field].localeCompare(a[params.sort.field]);\n }\n return true;\n });\n }\n\n // Pagination\n const total = resources.length;\n\n if (params.pagination) {\n resources = resources.slice(\n (params.pagination.page - 1) * params.pagination.perPage,\n params.pagination.page * params.pagination.perPage\n );\n }\n\n return { data: resources, total };\n};\n\nexport default fetchContainers;\n","const arrayOf = (value: T | T[]) => {\n // If the field is null-ish, we suppose there are no values.\n if (!value) {\n return [];\n }\n // Return as is.\n if (Array.isArray(value)) {\n return value;\n }\n // Single value is made an array.\n return [value];\n};\n\nexport default arrayOf;\n","import jsonld from 'jsonld';\nimport getEmbedFrame from './getEmbedFrame';\nimport buildSparqlQuery from './buildSparqlQuery';\n\nconst compare = (a, b) => {\n switch (typeof a) {\n case 'string':\n return a.localeCompare(b);\n case 'number':\n case 'bigint':\n return a - b;\n default:\n return 0;\n }\n};\n\nconst fetchSparqlEndpoints = async (containers, resourceId, params, config) => {\n const { dataServers, resources, httpClient, jsonContext, ontologies } = config;\n const dataModel = resources[resourceId];\n\n const sparqlQueryPromises = Object.keys(containers).map(\n serverKey =>\n new Promise((resolve, reject) => {\n const blankNodes = params.filter?.blankNodes || dataModel.list?.blankNodes;\n\n // When the SPARQL request comes from the browser's URL, it comes as JSON string which must must be parsed\n if (\n params.filter?.sparqlWhere &&\n (typeof params.filter.sparqlWhere === 'string' || params.filter.sparqlWhere instanceof String)\n ) {\n params.filter.sparqlWhere = JSON.parse(decodeURIComponent(params.filter.sparqlWhere));\n }\n const sparqlQuery = buildSparqlQuery({\n containers: containers[serverKey],\n params,\n dataModel,\n ontologies\n });\n\n httpClient(dataServers[serverKey].sparqlEndpoint, {\n method: 'POST',\n body: sparqlQuery\n })\n .then(({ json }) => {\n // If we declared the blank nodes to dereference, embed only those blank nodes\n // This solve problems which can occur when same-type resources are embedded in other resources\n // To increase performances, you can set explicitEmbedOnFraming to false (make sure the result is still OK)\n const frame =\n blankNodes && dataModel.list?.explicitEmbedOnFraming !== false\n ? {\n '@context': jsonContext,\n '@type': dataModel.types,\n '@embed': '@never',\n ...getEmbedFrame(blankNodes)\n }\n : {\n '@context': jsonContext,\n '@type': dataModel.types\n };\n\n // omitGraph option force results to be in a @graph, even if we have a single result\n return jsonld.frame(json, frame, { omitGraph: false });\n })\n .then(compactJson => {\n if (compactJson['@id']) {\n const { '@context': context, ...rest } = compactJson;\n compactJson = {\n '@context': context,\n '@graph': [rest]\n };\n }\n resolve(\n compactJson['@graph'].map(resource => ({ '@context': compactJson['@context'], ...resource })) || []\n );\n })\n .catch(e => reject(e));\n })\n );\n\n // Run simultaneous SPARQL queries\n let results = await Promise.all(sparqlQueryPromises);\n\n if (results.length === 0) {\n return { data: [], total: 0 };\n }\n // Merge all results in one array\n results = [].concat(...results);\n\n // Add id in addition to @id, as this is what React-Admin expects\n let returnData = results.map(item => {\n item.id = item.id || item['@id'];\n return item;\n });\n\n // TODO sort and paginate the results in the SPARQL query to improve performances\n if (params.sort) {\n returnData = returnData.sort((a, b) => {\n if (a[params.sort.field] !== undefined && b[params.sort.field] !== undefined) {\n if (params.sort.order === 'ASC') {\n return compare(a[params.sort.field], b[params.sort.field]);\n }\n return compare(b[params.sort.field], a[params.sort.field]);\n }\n return 0;\n });\n }\n if (params.pagination) {\n returnData = returnData.slice(\n (params.pagination.page - 1) * params.pagination.perPage,\n params.pagination.page * params.pagination.perPage\n );\n }\n\n return { data: returnData, total: results.length };\n};\n\nexport default fetchSparqlEndpoints;\n","const getEmbedFrame = blankNodes => {\n let embedFrame = {};\n let predicates;\n if (blankNodes) {\n for (const blankNode of blankNodes) {\n if (blankNode.includes('/')) {\n predicates = blankNode.split('/').reverse();\n } else {\n predicates = [blankNode];\n }\n embedFrame = {\n ...embedFrame,\n ...predicates.reduce(\n (accumulator, predicate) => ({\n [predicate]: {\n '@embed': '@last',\n ...accumulator\n }\n }),\n {}\n )\n };\n }\n return embedFrame;\n }\n};\n\nexport default getEmbedFrame;\n","import DataFactory from '@rdfjs/data-model';\nimport buildBaseQuery from './buildBaseQuery';\nimport buildBlankNodesQuery from './buildBlankNodesQuery';\nimport buildAutoDetectBlankNodesQuery from './buildAutoDetectBlankNodesQuery';\nimport resolvePrefix from './resolvePrefix';\n\nconst SparqlGenerator = require('sparqljs').Generator;\n\nconst { literal, namedNode, triple, variable } = DataFactory;\n\nconst generator = new SparqlGenerator({\n /* prefixes, baseIRI, factory, sparqlStar */\n});\n\nconst reservedFilterKeys = ['q', 'sparqlWhere', 'blankNodes', 'blankNodesDepth', '_servers', '_predicates'];\n\nconst buildSparqlQuery = ({ containers, params, dataModel, ontologies }) => {\n const blankNodes = params.filter?.blankNodes || dataModel.list?.blankNodes;\n const predicates = params.filter?._predicates || dataModel.list?.predicates;\n const blankNodesDepth = params.filter?.blankNodesDepth ?? dataModel.list?.blankNodesDepth ?? 2;\n const filter = { ...dataModel.list?.filter, ...params.filter };\n const baseQuery = buildBaseQuery(predicates, ontologies);\n\n const sparqlJsParams = {\n queryType: 'CONSTRUCT',\n template: baseQuery.construct,\n where: [],\n type: 'query',\n prefixes: Object.fromEntries(ontologies.map(ontology => [ontology.prefix, ontology.url]))\n };\n\n const containerWhere = [\n {\n type: 'values',\n values: containers.map(containerUri => ({ '?containerUri': namedNode(containerUri) }))\n },\n triple(variable('containerUri'), namedNode('http://www.w3.org/ns/ldp#contains'), variable('s1')),\n {\n type: 'filter',\n expression: {\n type: 'operation',\n operator: 'isiri',\n args: [variable('s1')]\n }\n }\n ];\n\n let resourceWhere = [];\n\n if (filter && Object.keys(filter).length > 0) {\n const hasSPARQLFilter = filter.sparqlWhere && Object.keys(filter.sparqlWhere).length > 0;\n const hasFullTextSearch = filter.q && filter.q.length > 0;\n\n if (hasSPARQLFilter) {\n /*\n Example of usage :\n {\n \"sparqlWhere\": {\n \"type\": \"bgp\",\n \"triples\": [{\n \"subject\": {\"termType\": \"Variable\", \"value\": \"s1\"},\n \"predicate\": {\"termType\": \"NameNode\", \"value\": \"http://virtual-assembly.org/ontologies/pair#label\"},\n \"object\": {\"termType\": \"Literal\", \"value\": \"My Organization\"}\n }]\n }\n }\n */\n // initialize array in case of single value :\n [].concat(filter.sparqlWhere).forEach(sw => {\n resourceWhere.push(sw);\n });\n }\n\n if (hasFullTextSearch) {\n resourceWhere.push({\n type: 'group',\n patterns: [\n {\n queryType: 'SELECT',\n variables: [variable('s1')],\n where: [\n triple(variable('s1'), variable('p1'), variable('o1')),\n {\n type: 'filter',\n expression: {\n type: 'operation',\n operator: 'isliteral',\n args: [variable('o1')]\n }\n },\n {\n type: 'filter',\n expression: {\n type: 'operation',\n operator: 'regex',\n args: [\n {\n type: 'operation',\n operator: 'lcase',\n args: [\n {\n type: 'operation',\n operator: 'str',\n args: [variable('o1')]\n }\n ]\n },\n literal(filter.q.toLowerCase(), '', namedNode('http://www.w3.org/2001/XMLSchema#string'))\n ]\n }\n }\n ],\n type: 'query'\n }\n ]\n });\n }\n\n // Other filters\n // SPARQL keyword a = filter based on the class of a resource (example => 'a': 'pair:OrganizationType')\n // Other filters are based on a value (example => 'petr:hasAudience': 'http://localhost:3000/audiences/tout-public')\n Object.entries(filter).forEach(([predicate, object]) => {\n if (!reservedFilterKeys.includes(predicate)) {\n resourceWhere.unshift(\n triple(\n variable('s1'),\n namedNode(resolvePrefix(predicate, ontologies)),\n namedNode(resolvePrefix(object, ontologies))\n )\n );\n }\n });\n }\n\n // Blank nodes\n const blankNodesQuery = blankNodes\n ? buildBlankNodesQuery(blankNodes, baseQuery, ontologies)\n : buildAutoDetectBlankNodesQuery(blankNodesDepth, baseQuery);\n\n if (blankNodesQuery && blankNodesQuery.construct) {\n resourceWhere = resourceWhere.concat(blankNodesQuery.where);\n sparqlJsParams.template = sparqlJsParams.template.concat(blankNodesQuery.construct);\n } else {\n resourceWhere.push(baseQuery.where);\n }\n\n sparqlJsParams.where.push(\n {\n type: 'union',\n patterns: [\n containerWhere,\n {\n type: 'graph',\n name: namedNode('http://semapps.org/mirror'),\n patterns: containerWhere\n }\n ]\n },\n {\n type: 'union',\n patterns: [\n resourceWhere,\n {\n type: 'graph',\n name: namedNode('http://semapps.org/mirror'),\n patterns: resourceWhere\n }\n ]\n }\n );\n\n return generator.stringify(sparqlJsParams);\n};\n\nexport default buildSparqlQuery;\n","import { namedNode, triple, variable } from '@rdfjs/data-model';\nimport resolvePrefix from './resolvePrefix';\n\nconst defaultToArray = value => (!value ? [] : Array.isArray(value) ? value : [value]);\n\n// We need to always include the type or React-Admin will not work properly\nconst typeQuery = triple(\n variable('s1'),\n namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),\n variable('type')\n);\n\nconst buildBaseQuery = (predicates, ontologies) => {\n let baseTriples;\n if (predicates) {\n baseTriples = defaultToArray(predicates).map((predicate, i) =>\n triple(variable('s1'), namedNode(resolvePrefix(predicate, ontologies)), variable(`o${i + 1}`))\n );\n return {\n construct: [typeQuery, ...baseTriples],\n where: [typeQuery, ...baseTriples.map(triple => ({ type: 'optional', patterns: [triple] }))]\n };\n }\n baseTriples = [triple(variable('s1'), variable('p1'), variable('o1'))];\n return {\n construct: baseTriples,\n where: baseTriples\n };\n};\n\nexport default buildBaseQuery;\n","const resolvePrefix = (item, ontologies) => {\n if (item.startsWith('http://') || item.startsWith('https://')) {\n // Already resolved, return the URI\n return item;\n }\n if (item === 'a') {\n // Special case\n return 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';\n }\n const [prefix, value] = item.split(':');\n if (value) {\n const ontology = ontologies.find(ontology => ontology.prefix === prefix);\n if (ontology) {\n return ontology.url + value;\n }\n throw new Error(`No ontology found with prefix ${prefix}`);\n } else {\n throw new Error(`The value \"${item}\" is not correct. It must include a prefix or be a full URI.`);\n }\n};\n\nexport default resolvePrefix;\n","import md5 from 'crypto-js/md5';\nimport { namedNode, triple, variable } from '@rdfjs/data-model';\nimport resolvePrefix from './resolvePrefix';\n\n// Transform ['ont:predicate1/ont:predicate2'] to ['ont:predicate1', 'ont:predicate1/ont:predicate2']\nconst extractNodes = blankNodes => {\n const nodes = [];\n if (blankNodes) {\n for (const predicate of blankNodes) {\n if (predicate.includes('/')) {\n const nodeNames = predicate.split('/');\n for (let i = 1; i <= nodeNames.length; i++) {\n nodes.push(nodeNames.slice(0, i).join('/'));\n }\n } else {\n nodes.push(predicate);\n }\n }\n }\n return nodes;\n};\n\nconst generateSparqlVarName = node => md5(node);\n\nconst getParentNode = node => node.includes('/') && node.split('/')[0];\n\nconst getPredicate = node => (node.includes('/') ? node.split('/')[1] : node);\n\nconst buildUnionQuery = queries =>\n queries.map(q => {\n let triples = q.query;\n const firstTriple = queries.find(q2 => q.parentNode === q2.node);\n if (firstTriple !== undefined) {\n triples = triples.concat(firstTriple.query[0]);\n }\n return {\n type: 'bgp',\n triples\n };\n });\n\nconst buildBlankNodesQuery = (blankNodes, baseQuery, ontologies) => {\n const queries = [];\n const nodes = extractNodes(blankNodes);\n\n if (nodes && ontologies && ontologies.length > 0) {\n for (const node of nodes) {\n const parentNode = getParentNode(node);\n const predicate = getPredicate(node);\n const varName = generateSparqlVarName(node);\n const parentVarName = parentNode ? generateSparqlVarName(parentNode) : '1';\n\n const query = [\n triple(variable(`s${parentVarName}`), namedNode(resolvePrefix(predicate, ontologies)), variable(`s${varName}`)),\n triple(variable(`s${varName}`), variable(`p${varName}`), variable(`o${varName}`))\n ];\n\n queries.push({\n node,\n parentNode,\n query,\n filter: '' // `FILTER(isBLANK(?s${varName})) .`\n });\n }\n\n return {\n construct: queries.length > 0 ? queries.map(q => q.query).reduce((pre, cur) => pre.concat(cur)) : null,\n where: {\n type: 'union',\n patterns: [baseQuery.where, ...buildUnionQuery(queries)]\n }\n };\n }\n return {\n construct: '',\n where: ''\n };\n};\n\nexport default buildBlankNodesQuery;\n","import { triple, variable } from '@rdfjs/data-model';\n\nconst buildAutoDetectBlankNodesQuery = (depth, baseQuery) => {\n const construct = [...baseQuery.construct];\n let where = {};\n if (depth > 0) {\n const whereQueries = [];\n whereQueries.push([baseQuery.where]);\n for (let i = 1; i <= depth; i++) {\n construct.push(triple(variable(`o${i}`), variable(`p${i + 1}`), variable(`o${i + 1}`)));\n whereQueries.push([\n ...whereQueries[whereQueries.length - 1],\n {\n type: 'filter',\n expression: {\n type: 'operation',\n operator: 'isblank',\n args: [variable(`o${i}`)]\n }\n },\n triple(variable(`o${i}`), variable(`p${i + 1}`), variable(`o${i + 1}`))\n ]);\n }\n where = {\n type: 'union',\n patterns: whereQueries\n };\n } else if (depth === 0) {\n where = baseQuery.where;\n } else {\n throw new Error('The depth of buildAutoDetectBlankNodesQuery should be 0 or more');\n }\n\n return { construct, where };\n};\n\nexport default buildAutoDetectBlankNodesQuery;\n","import urlJoin from 'url-join';\n\nconst findContainersWithPaths = (paths, dataServers) => {\n const containers = {};\n Object.keys(paths).forEach(serverKey => {\n if (dataServers[serverKey]) {\n containers[serverKey] = [];\n paths[serverKey].forEach(path => {\n containers[serverKey].push(urlJoin(dataServers[serverKey].baseUrl, path));\n });\n } else {\n throw new Error(`No server found with key ${serverKey}`);\n }\n });\n return containers;\n};\n\nexport default findContainersWithPaths;\n","import getOne from './getOne';\n\nconst getManyMethod = config => async (resourceId, params) => {\n const { returnFailedResources } = config;\n\n let returnData = await Promise.all(\n params.ids.map(id =>\n getOne(config)(resourceId, { id: typeof id === 'object' ? id['@id'] : id })\n .then(({ data }) => data)\n .catch(() => {\n // Catch if one resource fails to load\n // Otherwise no references will be show if only one is missing\n // See https://github.com/marmelab/react-admin/issues/5190\n if (returnFailedResources) {\n return { id, _error: true };\n }\n // Returning nothing\n })\n )\n );\n\n // We don't want undefined results to appear in the results as it will break with react-admin\n returnData = returnData.filter(e => e);\n\n return { data: returnData };\n};\n\nexport default getManyMethod;\n","import getList from './getList';\n\nconst getManyReferenceMethod = config => async (resourceId, params) => {\n params.filter = { ...params.filter, [params.target]: params.id };\n delete params.target;\n return await getList(config)(resourceId, params);\n};\n\nexport default getManyReferenceMethod;\n","import { RaRecord, UpdateParams } from 'react-admin';\nimport { Configuration } from '../types';\nimport handleFiles from '../utils/handleFiles';\n\nconst updateMethod = (config: Configuration) => async (resourceId: string, params: UpdateParams) => {\n const { httpClient, jsonContext } = config;\n\n // Upload files, if there are any\n const { updatedRecord, filesToDelete } = await handleFiles.upload(params.data, config);\n params.data = updatedRecord;\n\n await httpClient(`${params.id}`, {\n method: 'PUT',\n body: JSON.stringify({\n '@context': jsonContext,\n ...params.data\n })\n });\n\n // Delete files only if update is successful\n await handleFiles.delete(filesToDelete, config);\n\n return { data: params.data };\n};\n\nexport default updateMethod;\n","import jwtDecode from 'jwt-decode';\nimport urlJoin from 'url-join';\nimport getServerKeyFromType from './getServerKeyFromType';\n\nconst fetchUserConfig = async config => {\n const { dataServers, httpClient } = config;\n const token = localStorage.getItem('token');\n const podKey = getServerKeyFromType('pod', dataServers);\n const authServerKey = getServerKeyFromType('authServer', dataServers);\n\n // If the user is logged in\n if (token) {\n const payload = jwtDecode(token);\n const webId = payload.webId || payload.webid; // Currently we must deal with both formats\n let userData;\n\n try {\n const { json } = await httpClient(webId);\n userData = json;\n } catch (e) {\n console.error(e);\n // If the webId cannot be fetched, assume an invalid token and disconnect the user\n localStorage.clear();\n window.location.reload();\n return;\n }\n\n // If we have a POD server\n if (podKey) {\n // Fill the config provided to the data provider\n // We must modify the config object directly\n config.dataServers[podKey].name = 'My Pod';\n config.dataServers[podKey].baseUrl = urlJoin(webId, 'data'); // TODO find POD URI from user profile\n config.dataServers[podKey].sparqlEndpoint =\n userData.endpoints?.['void:sparqlEndpoint'] || urlJoin(webId, 'sparql');\n }\n\n if (authServerKey) {\n // Fill the config provided to the data provider\n // We must modify the config object directly\n config.dataServers[authServerKey].proxyUrl = userData.endpoints?.proxyUrl;\n }\n } else if (podKey) {\n // If the user is not logged in, ignore the POD server\n delete config.dataServers[podKey];\n }\n};\n\nexport default fetchUserConfig;\n","const defaultToArray = value => (!value ? undefined : Array.isArray(value) ? value : [value]);\n\nconst fetchVoidEndpoints = async config => {\n const fetchPromises = Object.entries(config.dataServers)\n .filter(([key, server]) => server.pod !== true && server.void !== false)\n .map(([key, server]) =>\n config\n .httpClient(new URL('/.well-known/void', server.baseUrl).toString())\n .then(result => ({ key, datasets: result.json['@graph'] }))\n .catch(e => {\n if (e.status === 404 || e.status === 401 || e.status === 500) {\n return { key, error: e };\n }\n throw e;\n })\n );\n\n let results = [];\n\n try {\n results = await Promise.all(fetchPromises);\n } catch (e) {\n // Do not throw error if no endpoint found\n }\n\n for (const result of results) {\n config.dataServers[result.key].containers = config.dataServers[result.key].containers || {};\n config.dataServers[result.key].blankNodes = config.dataServers[result.key].blankNodes || {};\n\n // Ignore unfetchable endpoints\n if (result.datasets) {\n for (const dataset of result.datasets) {\n const datasetServerKey = Object.keys(config.dataServers).find(\n key => dataset['void:uriSpace'] === config.dataServers[key].baseUrl\n );\n\n // If the dataset is not part of a server mapped in the dataServers, ignore it\n if (datasetServerKey) {\n // If this is the local dataset, add the base information\n if (datasetServerKey === result.key) {\n config.dataServers[result.key].name = config.dataServers[result.key].name || dataset['dc:title'];\n config.dataServers[result.key].description =\n config.dataServers[result.key].description || dataset['dc:description'];\n config.dataServers[result.key].sparqlEndpoint =\n config.dataServers[result.key].sparqlEndpoint || dataset['void:sparqlEndpoint'];\n }\n\n config.dataServers[result.key].containers[datasetServerKey] =\n config.dataServers[result.key].containers[datasetServerKey] || {};\n\n for (const partition of defaultToArray(dataset['void:classPartition'])) {\n for (const type of defaultToArray(partition['void:class'])) {\n // Set containers by type\n const path = partition['void:uriSpace'].replace(dataset['void:uriSpace'], '/');\n if (config.dataServers[result.key].containers[datasetServerKey][type]) {\n config.dataServers[result.key].containers[datasetServerKey][type].push(path);\n } else {\n config.dataServers[result.key].containers[datasetServerKey][type] = [path];\n }\n }\n }\n }\n }\n }\n }\n};\n\nexport default fetchVoidEndpoints;\n","import { fetchUtils } from 'react-admin';\nimport getServerKeyFromUri from './utils/getServerKeyFromUri';\nimport getServerKeyFromType from './utils/getServerKeyFromType';\n\n/*\n * HTTP client used by all calls in data provider and auth provider\n * Do proxy calls if a proxy endpoint is available and the server is different from the auth server\n */\nconst httpClient =\n dataServers =>\n (url, options = {}) => {\n const authServerKey = getServerKeyFromType('authServer', dataServers);\n const serverKey = getServerKeyFromUri(url, dataServers);\n const useProxy =\n serverKey !== authServerKey && dataServers[authServerKey]?.proxyUrl && dataServers[serverKey]?.noProxy !== true;\n\n if (!options.headers) options.headers = new Headers();\n\n switch (options.method) {\n case 'POST':\n case 'PATCH':\n case 'PUT':\n if (!options.headers.has('Accept')) options.headers.set('Accept', 'application/ld+json');\n if (!options.headers.has('Content-Type')) options.headers.set('Content-Type', 'application/ld+json');\n break;\n\n case 'DELETE':\n break;\n\n case 'GET':\n default:\n if (!options.headers.has('Accept')) options.headers.set('Accept', 'application/ld+json');\n break;\n }\n\n if (useProxy) {\n const formData = new FormData();\n\n formData.append('id', url);\n formData.append('method', options.method || 'GET');\n formData.append('headers', JSON.stringify(Object.fromEntries(options.headers.entries())));\n\n if (options.body) {\n if (options.body instanceof File) {\n formData.append('body', options.body, options.body.name);\n } else {\n formData.append('body', options.body);\n }\n }\n\n // Post to proxy endpoint with multipart/form-data format\n return fetchUtils.fetchJson(dataServers[authServerKey].proxyUrl, {\n method: 'POST',\n headers: new Headers({\n Authorization: `Bearer ${localStorage.getItem('token')}`\n }),\n body: formData\n });\n }\n // Add token if the server is the same as the auth server\n if (serverKey === authServerKey) {\n const token = localStorage.getItem('token');\n if (token) options.headers.set('Authorization', `Bearer ${token}`);\n }\n return fetchUtils.fetchJson(url, options);\n };\n\nexport default httpClient;\n","// Return the first server matching with the baseUrl\nconst getServerKeyFromUri = (uri, dataServers) => {\n if (!uri) throw Error(`No URI provided to getServerKeyFromUri`);\n return Object.keys(dataServers).find(key => {\n if (dataServers[key].pod) {\n // The baseUrl ends with /data so remove this part to match with the webId and webId-related URLs (/inbox, /outbox...)\n return dataServers[key].baseUrl && uri.startsWith(dataServers[key].baseUrl.replace('/data', ''));\n }\n return uri.startsWith(dataServers[key].baseUrl);\n });\n};\n\nexport default getServerKeyFromUri;\n","import { useCallback, useMemo, useContext } from 'react';\nimport { DataProviderContext } from 'react-admin';\n\nconst compute = (externalLinks, record) =>\n typeof externalLinks === 'function' ? externalLinks(record) : externalLinks;\nconst isURL = url => typeof url === 'string' && url.startsWith('http');\n\nconst useGetExternalLink = componentExternalLinks => {\n // Since the externalLinks config is defined only locally, we don't need to wait for VOID endpoints fetching\n const dataProvider = useContext(DataProviderContext);\n const dataServers = dataProvider.getLocalDataServers();\n\n const serversExternalLinks = useMemo(() => {\n if (dataServers) {\n return Object.fromEntries(\n Object.values(dataServers).map(server => {\n // If externalLinks is not defined in the data server, use external links for non-default servers\n const externalLinks = server.externalLinks !== undefined ? server.externalLinks : !server.default;\n return [server.baseUrl, externalLinks];\n })\n );\n }\n }, [dataServers]);\n\n return useCallback(\n record => {\n const computedComponentExternalLinks = compute(componentExternalLinks, record);\n // If the component explicitly asks not to display as external links, use an internal link\n if (computedComponentExternalLinks === false) return false;\n\n if (!record?.id) return false;\n\n const serverBaseUrl = Object.keys(serversExternalLinks).find(baseUrl => record?.id.startsWith(baseUrl));\n // If no matching data servers could be found, assume we have an internal link\n if (!serverBaseUrl) return false;\n\n const computedServerExternalLinks = compute(serversExternalLinks[serverBaseUrl], record);\n // If the data server explicitly asks not to display as external links, use an internal link\n if (computedServerExternalLinks === false) return false;\n\n if (isURL(computedComponentExternalLinks)) {\n return computedComponentExternalLinks;\n }\n if (isURL(computedServerExternalLinks)) {\n return computedServerExternalLinks;\n }\n return record.id;\n },\n [serversExternalLinks, componentExternalLinks]\n );\n};\n\nexport default useGetExternalLink;\n","import { useState, useEffect } from 'react';\nimport useDataModel from './useDataModel';\nimport useDataServers from './useDataServers';\nimport findContainersWithTypes from '../dataProvider/utils/findContainersWithTypes';\nimport { DataServerKey } from '../dataProvider/types';\n\nconst useContainers = (resourceId: string, serverKeys = '@all') => {\n const dataModel = useDataModel(resourceId);\n const dataServers = useDataServers();\n const [containers, setContainers] = useState>();\n\n useEffect(() => {\n if (dataModel && dataServers) {\n setContainers(findContainersWithTypes(dataModel.types, serverKeys, dataServers));\n }\n }, [dataModel, dataServers, serverKeys]);\n\n return containers;\n};\n\nexport default useContainers;\n","import { useContext, useState, useEffect } from 'react';\nimport { DataProviderContext } from 'react-admin';\n\nconst useDataModel = (resourceId: string) => {\n // Get the raw data provider, since useDataProvider returns a wrapper\n const dataProvider = useContext(DataProviderContext);\n const [dataModel, setDataModel] = useState(undefined); // TODO: Type this object\n\n useEffect(() => {\n dataProvider.getDataModels().then((results: any) => setDataModel(results[resourceId]));\n }, [dataProvider, resourceId, setDataModel]);\n\n return dataModel;\n};\n\nexport default useDataModel;\n","import { useState, useEffect } from 'react';\nimport { useDataProvider } from 'react-admin';\nimport { DataProvider, DataServersConfig } from '../dataProvider/types';\n\nconst useDataServers = () => {\n const dataProvider = useDataProvider();\n const [dataServers, setDataServers] = useState();\n\n useEffect(() => {\n dataProvider.getDataServers().then(results => {\n setDataServers(results);\n });\n }, [dataProvider, setDataServers]);\n\n return dataServers;\n};\n\nexport default useDataServers;\n","import { useState, useEffect } from 'react';\nimport urlJoin from 'url-join';\nimport useDataModel from './useDataModel';\nimport useDataServers from './useDataServers';\nimport findCreateContainerWithTypes from '../dataProvider/utils/findCreateContainerWithTypes';\nimport getServerKeyFromType from '../dataProvider/utils/getServerKeyFromType';\n\n/** @deprecated Use \"useCreateContainerUri\" instead */\nconst useCreateContainer = resourceId => {\n const dataModel = useDataModel(resourceId);\n const dataServers = useDataServers();\n const [createContainer, setCreateContainer] = useState();\n\n useEffect(() => {\n if (dataModel && dataServers) {\n if (dataModel.create?.container) {\n const [serverKey, path] = Object.entries(dataModel.create.container)[0];\n if (!serverKey || !dataServers[serverKey]) {\n throw new Error(`Wrong key for the dataModel.create.container config of resource ${resourceId}`);\n }\n setCreateContainer(urlJoin(dataServers[serverKey].baseUrl, path));\n } else if (dataModel.create?.server) {\n setCreateContainer(findCreateContainerWithTypes(dataModel.types, dataModel.create?.server, dataServers));\n } else {\n const defaultServerKey = getServerKeyFromType('default', dataServers);\n setCreateContainer(findCreateContainerWithTypes(dataModel.types, defaultServerKey, dataServers));\n }\n }\n }, [dataModel, dataServers, setCreateContainer]);\n\n return createContainer;\n};\n\nexport default useCreateContainer;\n","import urlJoin from 'url-join';\nimport { DataModel, DataServerKey, DataServersConfig } from '../types';\n\nconst findCreateContainerWithTypes = (\n types: DataModel['types'],\n createServerKey: DataServerKey,\n dataServers: DataServersConfig\n) => {\n const containers: string[] = [];\n\n Object.keys(dataServers[createServerKey].containers?.[createServerKey] || {}).forEach(type => {\n if (types.includes(type)) {\n dataServers[createServerKey].containers![createServerKey][type].forEach(path => {\n const containerUri = urlJoin(dataServers[createServerKey].baseUrl, path);\n if (!containers.includes(containerUri)) {\n containers.push(containerUri);\n }\n });\n }\n });\n\n if (containers.length === 0) {\n throw new Error(\n `No container found matching with types ${JSON.stringify(\n types\n )}. You can set explicitely the create.container property of the resource.`\n );\n } else if (containers.length > 1) {\n throw new Error(\n `More than one container found matching with types ${JSON.stringify(\n types\n )}. You must set the create.server or create.container property for the resource.`\n );\n }\n\n return containers[0];\n};\n\nexport default findCreateContainerWithTypes;\n","import { useCallback } from 'react';\nimport urlJoin from 'url-join';\nimport useDataServers from './useDataServers';\nimport findCreateContainerWithTypes from '../dataProvider/utils/findCreateContainerWithTypes';\nimport getServerKeyFromType from '../dataProvider/utils/getServerKeyFromType';\nimport useDataModels from './useDataModels';\n\nconst useCreateContainerUri = () => {\n const dataModels = useDataModels();\n const dataServers = useDataServers();\n\n const getContainerUri = useCallback(\n (resourceId: string) => {\n if (!dataModels || !dataServers || !dataModels[resourceId]) {\n return undefined;\n }\n\n const dataModel = dataModels[resourceId];\n\n if (dataModel.create?.container) {\n const [serverKey, path] = Object.entries(dataModel.create.container)[0];\n if (!serverKey || !dataServers[serverKey]) {\n throw new Error(`Wrong key for the dataModel.create.container config of resource ${resourceId}`);\n }\n return urlJoin(dataServers[serverKey].baseUrl, path);\n }\n\n if (dataModel.create?.server) {\n return findCreateContainerWithTypes(dataModel.types, dataModel.create?.server, dataServers);\n }\n\n const defaultServerKey = getServerKeyFromType('default', dataServers);\n\n if (!defaultServerKey) {\n throw new Error(\n `No default dataServer found. You can set explicitly one setting the \"default\" attribute to true`\n );\n }\n\n return findCreateContainerWithTypes(dataModel.types, defaultServerKey, dataServers);\n },\n [dataModels, dataServers]\n );\n\n return getContainerUri;\n};\n\nexport default useCreateContainerUri;\n","import { useState, useEffect } from 'react';\nimport { useDataProvider } from 'react-admin';\nimport { DataModel, DataProvider } from '../dataProvider/types';\n\nconst useDataModels = () => {\n const dataProvider = useDataProvider();\n const [dataModels, setDataModels] = useState>();\n\n useEffect(() => {\n dataProvider.getDataModels().then(results => {\n setDataModels(results);\n });\n }, [dataProvider, setDataModels]);\n\n return dataModels;\n};\n\nexport default useDataModels;\n","import React, { useState, useEffect } from 'react';\n\n/**\n * @example\n * \n * \n * \n * \n * \n * \n */\n\nconst FilterHandler = ({ children, record, filter, source, ...otherProps }) => {\n const [filtered, setFiltered] = useState();\n useEffect(() => {\n if (record && source && Array.isArray(record?.[source])) {\n const filteredData = record?.[source].filter(r => {\n let eq = true;\n for (const key in filter) {\n const value = r[key];\n if (Array.isArray(value)) {\n if (!value.includes(filter[key])) {\n eq = false;\n }\n } else if (value !== filter[key]) {\n eq = false;\n }\n }\n return eq;\n });\n const newRecord = {\n ...record\n };\n // undefined setted if no data to obtain no render in RightLabel or equivalent\n newRecord[source] = filteredData.length > 0 ? filteredData : undefined;\n setFiltered(newRecord);\n }\n }, [record, source, filter]);\n\n return (\n <>\n {React.Children.map(children, (child, i) => {\n return React.cloneElement(child, {\n ...otherProps,\n record: filtered,\n source\n });\n })}\n \n );\n};\nexport default FilterHandler;\n","import React from 'react';\nimport { useGetList, useRecordContext } from 'react-admin';\nimport { default as FilterHandler } from './FilterHandler';\n\n/*\n * @example Label used in examples\n * const Label = ({label, ...otherProps})=>{\n * return

{label}

\n * }\n *\n * @example show header for each group with group property thanks to groupHeader\n * }\n * filterProperty=\"property of source filtered by groupReference\"\n * >\n * // same props as GroupedArrayField source\n * \n * \n * \n * \n *\n * @example call chhildren with label thanks to groupLabel\n * \n *