Revised Roles and Patterns#24
Conversation
|
tpluscode
left a comment
There was a problem hiding this comment.
I'm not stoked about the string approach for roles.
Have you had a chance to see my proposal for defining and interface for Role and exporting roles as matching interfaces?
| */ | ||
| export interface Quad extends BaseQuad { | ||
| export interface Quad< | ||
| RdfMode extends AllowedRdfMode=RdfMode_star, |
There was a problem hiding this comment.
By constraining to AllowedRdfMode you essentially close the path for 3rd party modes, contradicting (?) your comment about "easyRDF"
There was a problem hiding this comment.
I would also be in favor of a mechanism that enables developers to add other modes.
The approach from @tpluscode seems to enable this, so perhaps a combination of both approaches could be applied?
| export type RdfMode_star = 'rdf-star'; | ||
|
|
||
| /* Modes officially supported/allowed by RDFJS */ | ||
| export type AllowedRdfMode = RdfMode_11 | RdfMode_star; |
There was a problem hiding this comment.
Wondering if we want to add generalized RDF here as well?
This was the original motivation for adding the BaseQuad.
| */ | ||
| export interface Quad extends BaseQuad { | ||
| export interface Quad< | ||
| RdfMode extends AllowedRdfMode=RdfMode_star, |
There was a problem hiding this comment.
I would also be in favor of a mechanism that enables developers to add other modes.
The approach from @tpluscode seems to enable this, so perhaps a combination of both approaches could be applied?
|
@tpluscode @rubensworks The point of using a string for RDF mode is two-fold. First, it is open for extensibility ( /**
* `<RdfMode extends AllowedRdfMode=RdfMode_11> => TermTypeKey`
*
* Returns the union of valid .termType string values for Terms that appear in the datatype position for the given `RdfMode`
*/
type DatatypeTypeKey<
RdfMode extends AllowedRdfMode=RdfMode_11,
> = Merge<
{[K in RdfMode_11 | RdfMode_star]: NamedNodeTypeKey},
{[K in RdfMode_easier]: DataTypeKey}
>[RdfMode]; |
|
import { NamedNode, BlankNode, Quad } from 'rdf-js'
type RdfMode_11 = 'rdf-1.1'
type RdfMode_star = 'rdf-star'
type AllowedRdfMode = RdfMode_11 | RdfMode_star
type Subject<
RdfMode extends AllowedRdfMode=RdfMode_star,
> = NamedNode | BlankNode | (RdfMode extends RdfMode_star? Quad: never)
type RdfStarSubject = Subject<'rdf-star'>
type EasyRdfSubject = Subject<'EasyRDF'>You cannot add additional types because the constraint literally allows only |
|
@tpluscode lol, I understand what extends does... see v5 dev here. I think you might have misunderstood the point I am making about extensibility. Forget about |
This PR supersedes parts of #23, namely the support of both RDF 1.1 and RDF-star simultaneously. The revised version of this feature no longer introduces any breaking changes.
Instead, the
RoleandPatternnamespaces expose each term position with an optional generic argument that specifies the mode of RDF to use (and defaults to RDF-star). See code for more details.If the consensus agrees with this direction, I will follow up with the corresponding test cases as well before suggesting PR for merge.