From 7422fbffe7500780ed01d4cb6f9dea520456657a Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Wed, 5 Oct 2022 15:52:09 +0200 Subject: [PATCH] feat: Take preferences as input in `RepresentationConvertingStore` --- RELEASE_NOTES.md | 1 + config/sparql-file-storage.json | 5 ++++- config/storage/backend/regex.json | 5 ++++- config/storage/backend/sparql.json | 5 ++++- src/storage/RepresentationConvertingStore.ts | 14 ++++++++++---- .../storage/RepresentationConvertingStore.test.ts | 7 +++++-- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d00038945..b6d90d245 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -63,6 +63,7 @@ These changes are relevant if you wrote custom modules for the server that depen - `AgentGroupAccessChecker` no longer accepts any input parameters. - The functions in `Vocabularies.ts` were renamed, the typings have been made more precise and several utility types were added. +- The `RepresentationConvetingStore` `options.inType` was replaced with `options.inPreferences`. - Several changes to support ACP. - `WebAclAuxiliaryReader` was renamed to `AuthAuxiliaryReader`. - `OwnerPermissionReader` input parameter `aclStrategy` was renamed to `authStrategy`. diff --git a/config/sparql-file-storage.json b/config/sparql-file-storage.json index dd60b97b1..f58a9852a 100644 --- a/config/sparql-file-storage.json +++ b/config/sparql-file-storage.json @@ -81,7 +81,10 @@ "@type": "RepresentationConvertingStore", "metadataStrategy":{ "@id": "urn:solid-server:default:MetadataStrategy" }, "options_inConverter": { "@id": "urn:solid-server:default:RepresentationConverter" }, - "options_inType": "internal/quads", + "options_inPreferences_type": { + "RepresentationConvertingStore:_options_inPreferences_type_key": "internal/quads", + "RepresentationConvertingStore:_options_inPreferences_type_value": 1 + }, "source": { "@type": "DataAccessorBasedStore", "identifierStrategy": { "@id": "urn:solid-server:default:IdentifierStrategy" }, diff --git a/config/storage/backend/regex.json b/config/storage/backend/regex.json index fb8fdfadc..81e67fc85 100644 --- a/config/storage/backend/regex.json +++ b/config/storage/backend/regex.json @@ -67,7 +67,10 @@ "@type": "RepresentationConvertingStore", "metadataStrategy":{ "@id": "urn:solid-server:default:MetadataStrategy" }, "options_inConverter": { "@id": "urn:solid-server:default:RepresentationConverter" }, - "options_inType": "internal/quads", + "options_inPreferences_type": { + "RepresentationConvertingStore:_options_inPreferences_type_key": "internal/quads", + "RepresentationConvertingStore:_options_inPreferences_type_value": 1 + }, "source": { "@type": "DataAccessorBasedStore", "identifierStrategy": { "@id": "urn:solid-server:default:IdentifierStrategy" }, diff --git a/config/storage/backend/sparql.json b/config/storage/backend/sparql.json index 3f95f235f..6eb76bbb5 100644 --- a/config/storage/backend/sparql.json +++ b/config/storage/backend/sparql.json @@ -17,7 +17,10 @@ "comment": "This makes it so all incoming data is converted to quad objects.", "@id": "urn:solid-server:default:ResourceStore_Converting", "@type": "RepresentationConvertingStore", - "options_inType": "internal/quads" + "options_inPreferences_type": { + "RepresentationConvertingStore:_options_inPreferences_type_key": "internal/quads", + "RepresentationConvertingStore:_options_inPreferences_type_value": 1 + } } ] } diff --git a/src/storage/RepresentationConvertingStore.ts b/src/storage/RepresentationConvertingStore.ts index 11dafc7a4..3f059b80f 100644 --- a/src/storage/RepresentationConvertingStore.ts +++ b/src/storage/RepresentationConvertingStore.ts @@ -22,19 +22,25 @@ export class RepresentationConvertingStore { const inConverter: RepresentationConverter = { handleSafe: jest.fn().mockResolvedValue(convertedIn) } as any; const outConverter: RepresentationConverter = { handleSafe: jest.fn().mockResolvedValue(convertedOut) } as any; - const inType = 'text/turtle'; + const inPreferences: RepresentationPreferences = { type: { 'text/turtle': 1 }}; const metadataStrategy = new SimpleSuffixStrategy('.meta'); - const store = new RepresentationConvertingStore(source, metadataStrategy, { inType, inConverter, outConverter }); + const store = new RepresentationConvertingStore(source, + metadataStrategy, + { inPreferences, inConverter, outConverter }); beforeEach(async(): Promise => { jest.clearAllMocks();