Skip to content

Commit

Permalink
Defaultgraph to TS linkeddata#355
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Oct 22, 2019
1 parent e7f423e commit 21ad8ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/default-graph.js → src/default-graph.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict'
import Node from './node-internal'
import { RDFJSDefaultGraph } from './types';

export default class DefaultGraph extends Node implements RDFJSDefaultGraph {
value: ''

export default class DefaultGraph extends Node {
constructor () {
super()
this.termType = 'DefaultGraph'
Expand Down
16 changes: 13 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Variable from './variable';
import BlankNode from './blank-node';
import Collection from './collection';
import Literal from './literal';
import DefaultGraph from './default-graph';
import NamedNode from './named-node';

/**
Expand All @@ -14,13 +13,15 @@ export type BlankNodeTermType = "BlankNode" | TermType.BlankNode
export type LiteralTermType = "Literal" | TermType.Literal
export type VariableTermType = "Variable" | TermType.Variable
export type CollectionTermType = "Collection" | TermType.Collection
export type DefaultGraphTermType = "DefaultGraph" | TermType.DefaultGraph

export enum TermType {
NamedNode = "NamedNode",
BlankNode = "BlankNode",
Literal = "Literal",
Variable = "Variable",
Collection = "Collection",
DefaultGraph = "DefaultGraph",
}

export type SomeTerm = RDFJSNamedNode | RDFJSBlankNode | RDFJSLiteral
Expand Down Expand Up @@ -60,7 +61,7 @@ export interface RDFJSBlankNode extends Term {
* @link https://rdf.js.org/data-model-spec/#quad-interface
*/
export interface RDFJSQuad<
S extends Term = Term,
S extends RDFJSNamedNode | RDFJSBlankNode = RDFJSNamedNode | RDFJSBlankNode,
P extends RDFJSNamedNode = RDFJSNamedNode,
O extends Term = SomeTerm,
G extends RDFJSNamedNode | DefaultGraph = RDFJSNamedNode | DefaultGraph
Expand Down Expand Up @@ -107,6 +108,15 @@ export interface RDFJSVariable extends Term {
equals(other: Term): boolean
};

/**
* An instance of DefaultGraph represents the default graph. It's only allowed to assign a DefaultGraph to the graph property of a Quad.
*/
export interface RDFJSDefaultGraph extends Term {
termType: string;
value: '';
equals(other: Term): boolean
};

/**
* A type for values that serves as inputs
*/
Expand All @@ -116,7 +126,7 @@ export interface Bindings {
[id: string]: Node;
}

export type SubjectType = NamedNode | RDFJSNamedNode | Variable | BlankNode
export type SubjectType = NamedNode | RDFJSNamedNode | Variable | RDFJSBlankNode
export type PredicateType = NamedNode | RDFJSNamedNode | Variable
export type ObjectType = NamedNode | RDFJSNamedNode | Literal | Collection | BlankNode | Variable
export type GraphType = NamedNode | RDFJSNamedNode | DefaultGraph | Variable

0 comments on commit 21ad8ce

Please sign in to comment.