Skip to content

Commit

Permalink
feat: Create multiple configs supporting different store backends
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimvh committed Nov 4, 2020
1 parent fe870f0 commit 892b5f5
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 40 deletions.
5 changes: 3 additions & 2 deletions config/config-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"files-scs:config/presets/ldp/permissions-extractor.json",
"files-scs:config/presets/ldp/request-parser.json",
"files-scs:config/presets/logging.json",
"files-scs:config/presets/representation-conversion.json",
"files-scs:config/presets/setup.json",
"files-scs:config/presets/storage.json",
"files-scs:config/presets/storage_wrapper.json",
"files-scs:config/presets/storage-backend/storage-memory.json",
"files-scs:config/presets/storage-wrapper.json",
"files-scs:config/presets/cli-params.json"
]
}
19 changes: 19 additions & 0 deletions config/config-file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld",
"import": [
"files-scs:config/presets/acl.json",
"files-scs:config/presets/http.json",
"files-scs:config/presets/ldp.json",
"files-scs:config/presets/ldp/credentials-extractor.json",
"files-scs:config/presets/ldp/metadata-handler.json",
"files-scs:config/presets/ldp/operation-handler.json",
"files-scs:config/presets/ldp/permissions-extractor.json",
"files-scs:config/presets/ldp/request-parser.json",
"files-scs:config/presets/logging.json",
"files-scs:config/presets/representation-conversion.json",
"files-scs:config/presets/setup.json",
"files-scs:config/presets/storage-backend/storage-filesystem.json",
"files-scs:config/presets/storage-wrapper.json",
"files-scs:config/presets/cli-params.json"
]
}
19 changes: 19 additions & 0 deletions config/config-sparql-endpoint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld",
"import": [
"files-scs:config/presets/acl.json",
"files-scs:config/presets/http.json",
"files-scs:config/presets/ldp.json",
"files-scs:config/presets/ldp/credentials-extractor.json",
"files-scs:config/presets/ldp/metadata-handler.json",
"files-scs:config/presets/ldp/operation-handler.json",
"files-scs:config/presets/ldp/permissions-extractor.json",
"files-scs:config/presets/ldp/request-parser.json",
"files-scs:config/presets/logging.json",
"files-scs:config/presets/representation-conversion.json",
"files-scs:config/presets/setup.json",
"files-scs:config/presets/storage-backend/storage-sparql-endpoint.json",
"files-scs:config/presets/storage-wrapper.json",
"files-scs:config/presets/cli-params.json"
]
}
4 changes: 4 additions & 0 deletions config/presets/cli-params.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"@id": "urn:solid-server:default:variable:rootFilePath",
"@type": "Variable"
},
{
"@id": "urn:solid-server:default:variable:sparqlEndpoint",
"@type": "Variable"
},
{
"@id": "urn:solid-server:default:variable:loggingLevel",
"@type": "Variable"
Expand Down
43 changes: 43 additions & 0 deletions config/presets/representation-conversion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld",
"@graph": [
{
"@id": "urn:solid-server:default:RdfToQuadConverter",
"@type": "RdfToQuadConverter"
},

{
"@id": "urn:solid-server:default:QuadToRdfConverter",
"@type": "QuadToRdfConverter"
},

{
"@id": "urn:solid-server:default:RdfRepresentationConverter",
"@type": "ChainedConverter",
"ChainedConverter:_converters": [
{
"@id": "urn:solid-server:default:RdfToQuadConverter"
},
{
"@id": "urn:solid-server:default:QuadToRdfConverter"
}
]
},

{
"@id": "urn:solid-server:default:RepresentationConverter",
"@type": "CompositeAsyncHandler",
"CompositeAsyncHandler:_handlers": [
{
"@id": "urn:solid-server:default:RdfToQuadConverter"
},
{
"@id": "urn:solid-server:default:QuadToRdfConverter"
},
{
"@id": "urn:solid-server:default:RdfRepresentationConverter"
}
]
}
]
}
47 changes: 47 additions & 0 deletions config/presets/storage-backend/storage-filesystem.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld",
"@graph": [
{
"@id": "urn:solid-server:default:MetadataController",
"@type": "MetadataController"
},
{
"@id": "urn:solid-server:default:FileIdentifierMapper",
"@type": "ExtensionBasedMapper",
"ExtensionBasedMapper:_base": {
"@id": "urn:solid-server:default:variable:base"
},
"ExtensionBasedMapper:_rootFilepath": {
"@id": "urn:solid-server:default:variable:rootFilePath"
},
"ExtensionBasedMapper:_acl": "text/turtle",
"ExtensionBasedMapper:_meta": "text/turtle"
},
{
"@id": "urn:solid-server:default:DataAccessor",
"@type": "FileDataAccessor",
"FileDataAccessor:_resourceMapper": {
"@id": "urn:solid-server:default:FileIdentifierMapper"
},
"FileDataAccessor:_metadataController": {
"@id": "urn:solid-server:default:MetadataController"
}
},
{
"@id": "urn:solid-server:default:ResourceStore",
"@type": "DataAccessorBasedStore",
"DataAccessorBasedStore:_accessor": {
"@id": "urn:solid-server:default:DataAccessor"
},
"DataAccessorBasedStore:_base": {
"@id": "urn:solid-server:default:variable:base"
},
"DataAccessorBasedStore:_metadataController": {
"@id": "urn:solid-server:default:MetadataController"
},
"DataAccessorBasedStore:_containerManager": {
"@id": "urn:solid-server:default:UrlContainerManager"
}
}
]
}
File renamed without changes.
55 changes: 55 additions & 0 deletions config/presets/storage-backend/storage-sparql-endpoint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld",
"@graph": [
{
"@id": "urn:solid-server:default:MetadataController",
"@type": "MetadataController"
},

{
"@id": "urn:solid-server:default:DataAccessor",
"@type": "SparqlDataAccessor",
"SparqlDataAccessor:_endpoint": {
"@id": "urn:solid-server:default:variable:sparqlEndpoint"
},
"SparqlDataAccessor:_base": {
"@id": "urn:solid-server:default:variable:base"
},
"SparqlDataAccessor:_containerManager": {
"@id": "urn:solid-server:default:UrlContainerManager"
},
"SparqlDataAccessor:_metadataController": {
"@id": "urn:solid-server:default:MetadataController"
}
},

{
"@id": "urn:solid-server:default:DataAccessorBasedStore",
"@type": "DataAccessorBasedStore",
"DataAccessorBasedStore:_accessor": {
"@id": "urn:solid-server:default:DataAccessor"
},
"DataAccessorBasedStore:_base": {
"@id": "urn:solid-server:default:variable:base"
},
"DataAccessorBasedStore:_metadataController": {
"@id": "urn:solid-server:default:MetadataController"
},
"DataAccessorBasedStore:_containerManager": {
"@id": "urn:solid-server:default:UrlContainerManager"
}
},

{
"@id": "urn:solid-server:default:ResourceStore",
"@type": "RepresentationConvertingStore",
"RepresentationConvertingStore:_source": {
"@id": "urn:solid-server:default:DataAccessorBasedStore"
},
"RepresentationConvertingStore:_inConverter": {
"@id": "urn:solid-server:default:RepresentationConverter"
},
"RepresentationConvertingStore:_inType": "internal/quads"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@id": "urn:solid-server:default:PatchHandler",
"@type": "SparqlUpdatePatchHandler",
"SparqlUpdatePatchHandler:_source": {
"@id": "urn:solid-server:default:ResourceStore_Converting"
"@id": "urn:solid-server:default:ResourceStore_ToTurtle"
},
"SparqlUpdatePatchHandler:_locker": {
"@id": "urn:solid-server:default:ResourceLocker"
Expand All @@ -25,26 +25,18 @@
},

{
"@id": "urn:solid-server:default:ResourceStore_Converting_RdfToQuad",
"@type": "RdfToQuadConverter"
},

{
"@id": "urn:solid-server:default:ResourceStore_Converting_QuadToRdf",
"@type": "QuadToRdfConverter"
},

{
"@id": "urn:solid-server:default:ResourceStore_Converting_Chained",
"@type": "ChainedConverter",
"ChainedConverter:_converters": [
{
"@id": "urn:solid-server:default:ResourceStore_Converting_RdfToQuad"
},
{
"@id": "urn:solid-server:default:ResourceStore_Converting_QuadToRdf"
}
]
"@id": "urn:solid-server:default:ResourceStore_ToTurtle",
"@type": "RepresentationConvertingStore",
"RepresentationConvertingStore:_source": {
"@id": "urn:solid-server:default:ResourceStore"
},
"RepresentationConvertingStore:_outConverter": {
"@id": "urn:solid-server:default:RepresentationConverter"
},
"RepresentationConvertingStore:_inConverter": {
"@id": "urn:solid-server:default:RepresentationConverter"
},
"RepresentationConvertingStore:_inType": "text/turtle"
},

{
Expand All @@ -53,19 +45,8 @@
"RepresentationConvertingStore:_source": {
"@id": "urn:solid-server:default:ResourceStore"
},
"RepresentationConvertingStore:_converter": {
"@type": "CompositeAsyncHandler",
"CompositeAsyncHandler:_handlers": [
{
"@id": "urn:solid-server:default:ResourceStore_Converting_RdfToQuad"
},
{
"@id": "urn:solid-server:default:ResourceStore_Converting_QuadToRdf"
},
{
"@id": "urn:solid-server:default:ResourceStore_Converting_Chained"
}
]
"RepresentationConvertingStore:_outConverter": {
"@id": "urn:solid-server:default:RepresentationConverter"
}
},

Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
"globals": {
"ts-jest": {
"tsConfig": "tsconfig.json"
"tsconfig": "tsconfig.json"
}
},
"transform": {
Expand Down
5 changes: 4 additions & 1 deletion src/init/CliRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export const runCustom = function(
.options({
port: { type: 'number', alias: 'p', default: 3000 },
config: { type: 'string', alias: 'c' },
rootFilePath: { type: 'string', alias: 'f' },
sparqlEndpoint: { type: 'string', alias: 's' },
level: { type: 'string', alias: 'l', default: 'info' },
})
.help();
Expand All @@ -46,7 +48,8 @@ export const runCustom = function(
variables: {
'urn:solid-server:default:variable:port': argv.port,
'urn:solid-server:default:variable:base': `http://localhost:${argv.port}/`,
'urn:solid-server:default:variable:rootFilePath': process.cwd(),
'urn:solid-server:default:variable:rootFilePath': argv.rootFilePath ?? process.cwd(),
'urn:solid-server:default:variable:sparqlEndpoint': argv.sparqlEndpoint,
'urn:solid-server:default:variable:loggingLevel': argv.level,
},
}) as Setup;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/init/CliRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jest.mock('yargs', (): any => ({
return this;
},
help(): any {
// Return once with and once without config value so that both branches are tested.
// Return once with and once without values so that both branches are tested.
if (throwError) {
return {
argv: { config: 'value' },
argv: { config: 'value', rootFilePath: 'root' },
};
}
return {
Expand Down

0 comments on commit 892b5f5

Please sign in to comment.