From d8aec075e945275a47fdeb8db0460c4f633b8fb0 Mon Sep 17 00:00:00 2001 From: Paul Weidner Date: Mon, 7 Oct 2024 15:58:32 -0700 Subject: [PATCH 1/3] Add @graph to unknown rdf fields --- web-marketplace/src/lib/rdf/rdf.unknown-fields.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-marketplace/src/lib/rdf/rdf.unknown-fields.ts b/web-marketplace/src/lib/rdf/rdf.unknown-fields.ts index 533e896c3f..5cd7b9d127 100644 --- a/web-marketplace/src/lib/rdf/rdf.unknown-fields.ts +++ b/web-marketplace/src/lib/rdf/rdf.unknown-fields.ts @@ -8,7 +8,7 @@ import { function getUnknowFields(data: object, knownFields: string[]) { return Object.entries(data).filter( - ([key]) => !['@context', '@type', '@id', ...knownFields].includes(key), + ([key]) => !['@context', '@graph', '@type', '@id', ...knownFields].includes(key), ); } From f2c67d9f3120d198ba7409db21689bdb8d181705 Mon Sep 17 00:00:00 2001 From: Paul Weidner Date: Fri, 18 Oct 2024 16:09:06 -0700 Subject: [PATCH 2/3] Support field labels that do not have a prefix It's possible that the jsonld context fully defines a field label so that it doesn't contain a "regen:" prefix --- web-marketplace/src/lib/rdf/rdf.unknown-fields.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web-marketplace/src/lib/rdf/rdf.unknown-fields.ts b/web-marketplace/src/lib/rdf/rdf.unknown-fields.ts index 5cd7b9d127..dd3b89b1d9 100644 --- a/web-marketplace/src/lib/rdf/rdf.unknown-fields.ts +++ b/web-marketplace/src/lib/rdf/rdf.unknown-fields.ts @@ -92,7 +92,8 @@ export function getBatchUnknownFields< } export function getFieldLabel(fieldName: string) { - return fieldName.split(':')[1].replace(/([A-Z])/g, ' $1'); + // Remove the field prefix and add space before capital letters. + return fieldName.replace(/[^:]*\:/, '').replace(/([A-Z])/g, ' $1'); } export function getFieldType(fieldName: string, context?: ContextDefinition) { From 3c45bc87bcaddd9c0d84c4ce635bf076021d6f14 Mon Sep 17 00:00:00 2001 From: Paul Weidner Date: Fri, 18 Oct 2024 16:21:58 -0700 Subject: [PATCH 3/3] Add comment for @graph --- web-marketplace/src/lib/rdf/rdf.compact.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/web-marketplace/src/lib/rdf/rdf.compact.ts b/web-marketplace/src/lib/rdf/rdf.compact.ts index 58740a2076..2f27f5ee2d 100644 --- a/web-marketplace/src/lib/rdf/rdf.compact.ts +++ b/web-marketplace/src/lib/rdf/rdf.compact.ts @@ -3,6 +3,7 @@ import { ContextDefinition, JsonLdDocument, NodeObject } from 'jsonld'; import { COMPACTED_CONTEXT } from './rdf.constants'; +// TODO: Support documents with @graph export const jsonLdCompact = async ( data: JsonLdDocument, context?: object,