diff --git a/data-model.d.ts b/data-model.d.ts index 6fff406..c2ac4a3 100644 --- a/data-model.d.ts +++ b/data-model.d.ts @@ -10,7 +10,7 @@ * @see DefaultGraph * @see BaseQuad */ -export type Term = NamedNode | BlankNode | Literal | Variable | DefaultGraph | BaseQuad; +export type Term = NamedNode | BlankNode | Literal | Variable | DefaultGraph | BaseQuad | BaseTriple; /** * Contains an IRI. @@ -128,12 +128,12 @@ export interface DefaultGraph { } /** - * The subject, which is a NamedNode, BlankNode or Variable. + * The subject, which is a NamedNode, BlankNode, Variable, or a quoted triple. * @see NamedNode * @see BlankNode * @see Variable */ -export type Quad_Subject = NamedNode | BlankNode | Quad | Variable; +export type Quad_Subject = NamedNode | BlankNode | Triple | Variable; /** * The predicate, which is a NamedNode or Variable. @@ -143,13 +143,13 @@ export type Quad_Subject = NamedNode | BlankNode | Quad | Variable; export type Quad_Predicate = NamedNode | Variable; /** - * The object, which is a NamedNode, Literal, BlankNode or Variable. + * The object, which is a NamedNode, Literal, BlankNode, Variable, or a quoted triple. * @see NamedNode * @see Literal * @see BlankNode * @see Variable */ -export type Quad_Object = NamedNode | Literal | BlankNode | Quad | Variable; +export type Quad_Object = NamedNode | Literal | BlankNode | Triple | Variable; /** * The named graph, which is a DefaultGraph, NamedNode, BlankNode or Variable. @@ -233,6 +233,13 @@ export interface Quad extends BaseQuad { equals(other: Term | null | undefined): boolean; } +export interface BaseTriple extends Omit { + termType: 'QuotedTriple'; +} +export interface Triple extends Omit { + termType: 'QuotedTriple'; +} + /** * A factory for instantiating RDF terms and quads. */ @@ -286,5 +293,5 @@ export interface DataFactory {}; + let term2: Term | undefined + switch (term.termType) { + case 'Quad': + term2 = term; + break; + case 'QuotedTriple': + term2 = term; + break; + case 'NamedNode': + term2 = term; + break; + case 'Literal': + term2 = term; + break; + case 'BlankNode': + term2 = term; + break; + case 'Variable': + term2 = term; + break; + case 'DefaultGraph': + term2 = term; + break; + } } function test_quads() { @@ -113,11 +139,15 @@ function test_datafactory_star() { ); // Decompose the triple - if (quadBobAgeCertainty.subject.termType === 'Quad') { - const quadBobAge2: Quad = quadBobAgeCertainty.subject; + if (quadBobAgeCertainty.subject.termType === 'QuotedTriple') { + const quadBobAge2: Triple = quadBobAgeCertainty.subject; const equalToSelf: boolean = quadBobAge2.equals(quadBobAge); const notEqualToOtherType: boolean = quadBobAge2.equals(dataFactory.namedNode('ex:something:else')); + + const dataset: DatasetCore = {}; + // @ts-expect-error: triple is not assignable to quad. It has no graph property + dataset.add(quadBobAge2); } } @@ -137,11 +167,15 @@ function test_datafactory_star_basequad() { ); // Decompose the triple - if (quadBobAgeCertainty.subject.termType === 'Quad') { - const quadBobAge2: BaseQuad = quadBobAgeCertainty.subject; + if (quadBobAgeCertainty.subject.termType === 'QuotedTriple') { + const quadBobAge2: BaseTriple = quadBobAgeCertainty.subject; const equalToSelf: boolean = quadBobAge2.equals(quadBobAge); const notEqualToOtherType: boolean = quadBobAge2.equals(dataFactory.namedNode('ex:something:else')); + + const dataset: DatasetCore = {}; + // @ts-expect-error: triple is not assignable to quad. It has no graph property + dataset.add(quadBobAge2); } }