LinkedSoftwareDependencies / Components-Generator.js

⚙️ Generate Components.js component files from TypeScript
13 stars 7 forks source link

Make alternative short predicates available for options hashes with `@nest` #62

Open RubenVerborgh opened 3 years ago

RubenVerborgh commented 3 years ago

In addition to

{
  "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^0.0.0/components/context.jsonld",
  "@graph": [
    {
      "@id": "urn:solid-server:default:IndexConverter",
      "@type": "ConstantConverter",
      "contentType": "text/html",
      "filePath": "./node_modules/mashlib/dist/databrowser.html",
      "options_container": true,
      "options_minQuality": 1
    }
  ]
}

could we also allow


{
  "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^0.0.0/components/context.jsonld",
  "@graph": [
    {
      "@id": "urn:solid-server:default:IndexConverter",
      "@type": "ConstantConverter",
      "contentType": "text/html",
      "filePath": "./node_modules/mashlib/dist/databrowser.html",
      "container": true,
      "minQuality": 1
    }
  ]
}
rubensworks commented 3 years ago

That might be possible, but then we'll have to take into the account of the possibility of conflicting variable names.

Also, a (perhaps bigger) question is how to enable this functionality, as we may not want to enable this by default due to the possibility on conflicting variable names. A first option could be to add some kind of annotation in the jsdoc of a variable name, which indicates that its Components.js name should be "shortened". A second option could be to configure this across the whole package, as a flag to the generator's CLI tool. Perhaps having both may even make sense.

Another thing I'm also not sure about is the "also allow" part of this functionality, perhaps there may be a need to "instead allow". But this could also be solved via a CLI flag.

RubenVerborgh commented 3 years ago

That might be possible, but then we'll have to take into the account of the possibility of conflicting variable names.

Precedence is fine here for me. (Perhaps the generator doesn't even need to know, and the JSON-LD context just overrides it.)

as we may not want to enable this by default due to the possibility on conflicting variable names.

Default seems fine if there is precedence.

"also allow" part of this functionality

It's just an alias?

rubensworks commented 3 years ago

Alternatively, we could also enable something like this:

{
  "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^0.0.0/components/context.jsonld",
  "@graph": [
    {
      "@id": "urn:solid-server:default:IndexConverter",
      "@type": "ConstantConverter",
      "contentType": "text/html",
      "filePath": "./node_modules/mashlib/dist/databrowser.html",
      "options": {
        "container": true,
        "minQuality": 1
      }
    }
  ]
}

This may be a better reflection of the actual constructor interface, and avoid conflicts completely. This could be done internally using JSON-LD's @nest functionality.

In any case, the alias-based approach is definitely also possible.

RubenVerborgh commented 3 years ago

I love the above.

rubensworks commented 2 years ago

The alias solution will be supported in 3.x. Will leave this issue open for the @nest.