Skip to content

Custom components.js serialization #97

Open
@jeswr

Description

@jeswr

Issue type:

  • ➕ Feature request

Description:

Building on this comment I thought I should share my thoughts on a javascriptish serialization for components.js files. It should be fairly quick to throw together an MVP for this in a day or so (using https://github.com/dsherret/ts-morph to parse the file and then traversing the AST to generate quads) which I'm happy to do in my own time in a couple of weeks.

To give this by example consider the following CSS config. My proposal is that this would roughly become

default.components.ts

// @context https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^4.0.0/components/context.jsonld

import * from "files-scs:config/ldp/handler/components/authorizer.json";
import * from "files-scs:config/ldp/handler/components/error-handler.json";
import * from "files-scs:config/ldp/handler/components/operation-handler.json";
import * from "files-scs:config/ldp/handler/components/operation-metadata.json";
import * from "files-scs:config/ldp/handler/components/request-parser.json";
import * from "files-scs:config/ldp/handler/components/response-writer.json";

const serverLink = text => link(`urn:solid-server:default:${text}`)

export {
  /**
  * The main entry point into the main Solid behaviour.
  */
  "urn:solid-server:default:LdpHandler": new ParsingHttpHandler({args: {
    requestParser: serverLink("RequestParser"),
    metadataCollector: serverLink("OperationMetadataCollector"),
    errorHandler: serverLink("ErrorHandler"),
    responseWriter: serverLink("ResponseWriter"),
    operationHandler: new AuthorizingHttpHandler({
      credentialsExtractor: serverLink("CredentialsExtractor"),
        modesExtractor: serverLink("ModesExtractor"),
        permissionReader: serverLink("PermissionReader"),
        authorizer: serverLink("Authorizer"),
        perationHandler: serverLink("OperationHandler")
    }})
}

or equivalently

// @context https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^4.0.0/components/context.jsonld

import * from "files-scs:config/ldp/handler/components/authorizer.json";
import * from "files-scs:config/ldp/handler/components/error-handler.json";
import * from "files-scs:config/ldp/handler/components/operation-handler.json";
import * from "files-scs:config/ldp/handler/components/operation-metadata.json";
import * from "files-scs:config/ldp/handler/components/request-parser.json";
import * from "files-scs:config/ldp/handler/components/response-writer.json";

const serverLink = text => link(`urn:solid-server:default:${text}`)

const operationHandler = new AuthorizingHttpHandler({ args: {
      credentialsExtractor: serverLink("CredentialsExtractor"),
        modesExtractor: serverLink("ModesExtractor"),
        permissionReader: serverLink("PermissionReader"),
        authorizer: serverLink("Authorizer"),
        operationHandler: serverLink("OperationHandler")
    }})

export {
  /**
  * The main entry point into the main Solid behaviour.
  */
  "urn:solid-server:default:LdpHandler": new ParsingHttpHandler({args: {
    requestParser: serverLink("RequestParser"),
    metadataCollector: serverLink("OperationMetadataCollector"),
    errorHandler: serverLink("ErrorHandler"),
    responseWriter: serverLink("ResponseWriter"),
    operationHandler,
  }})
}

Rather than having the @context comment at the top it may make sense to have

const link = context("https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^4.0.0/components/context.jsonld")

There are plenty of possible refinements here but just wanted to get my initial ideas down

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions