rdfjs-wrapper 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +4 -5
- package/dist/algorithm/getter.d.ts +3 -0
- package/dist/algorithm/getter.js +49 -0
- package/dist/algorithm/getter.js.map +1 -0
- package/dist/algorithm/set_literal.d.ts +2 -0
- package/dist/algorithm/set_literal.js +12 -0
- package/dist/algorithm/set_literal.js.map +1 -0
- package/dist/algorithm/set_node.d.ts +4 -0
- package/dist/algorithm/set_node.js +12 -0
- package/dist/algorithm/set_node.js.map +1 -0
- package/dist/algorithm/wrap.d.ts +3 -0
- package/dist/algorithm/wrap.js +31 -0
- package/dist/algorithm/wrap.js.map +1 -0
- package/dist/class/literal_wrapper.d.ts +6 -0
- package/dist/class/literal_wrapper.js +13 -0
- package/dist/class/literal_wrapper.js.map +1 -0
- package/dist/class/node_wrapper.d.ts +6 -0
- package/dist/class/node_wrapper.js +13 -0
- package/dist/class/node_wrapper.js.map +1 -0
- package/dist/class/wrapper.d.ts +9 -0
- package/dist/class/wrapper.js +18 -0
- package/dist/class/wrapper.js.map +1 -0
- package/dist/class/wrapping_set.d.ts +19 -0
- package/dist/class/{WrappingSet.js → wrapping_set.js} +16 -14
- package/dist/class/wrapping_set.js.map +1 -0
- package/dist/constant/term_type.d.ts +1 -0
- package/dist/constant/term_type.js +12 -0
- package/dist/constant/term_type.js.map +1 -0
- package/dist/error/cardinality_error.d.ts +3 -0
- package/dist/error/cardinality_error.js +10 -0
- package/dist/error/cardinality_error.js.map +1 -0
- package/dist/error/missing_value_error.d.ts +3 -0
- package/dist/error/missing_value_error.js +10 -0
- package/dist/error/missing_value_error.js.map +1 -0
- package/dist/error/term_type_error.d.ts +3 -0
- package/dist/error/term_type_error.js +10 -0
- package/dist/error/term_type_error.js.map +1 -0
- package/dist/error/wrapper_type_error.d.ts +3 -0
- package/dist/error/wrapper_type_error.js +10 -0
- package/dist/error/wrapper_type_error.js.map +1 -0
- package/dist/factory/string_factory.d.ts +2 -0
- package/dist/factory/{stringFactory.js → string_factory.js} +4 -3
- package/dist/factory/string_factory.js.map +1 -0
- package/dist/mod.d.ts +10 -0
- package/dist/mod.js +41 -0
- package/dist/mod.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type/i_literal_wrapper_constructor.d.ts +4 -0
- package/dist/type/i_literal_wrapper_constructor.js +3 -0
- package/dist/type/i_literal_wrapper_constructor.js.map +1 -0
- package/dist/type/i_node_wrapper_constructor.d.ts +4 -0
- package/dist/type/i_node_wrapper_constructor.js +3 -0
- package/dist/type/i_node_wrapper_constructor.js.map +1 -0
- package/dist/type/i_term_type.d.ts +2 -0
- package/dist/type/i_term_type.js +3 -0
- package/dist/type/i_term_type.js.map +1 -0
- package/dist/type/i_wrapper_constructor.d.ts +3 -0
- package/dist/type/i_wrapper_constructor.js +3 -0
- package/dist/type/i_wrapper_constructor.js.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +38 -33
- package/dist/class/Wrapper.d.ts +0 -15
- package/dist/class/Wrapper.js +0 -56
- package/dist/class/Wrapper.js.map +0 -1
- package/dist/class/WrappingSet.d.ts +0 -23
- package/dist/class/WrappingSet.js.map +0 -1
- package/dist/class/index.d.ts +0 -2
- package/dist/class/index.js +0 -15
- package/dist/class/index.js.map +0 -1
- package/dist/factory/index.d.ts +0 -1
- package/dist/factory/index.js +0 -14
- package/dist/factory/index.js.map +0 -1
- package/dist/factory/stringFactory.d.ts +0 -2
- package/dist/factory/stringFactory.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -15
- package/dist/index.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2022 Matthieu Bosquet & Samu Lang
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# RDF/JS Wrapper
|
|
2
2
|
|
|
3
|
-
[](https://github.com/matthieubosquet/rdfjs-wrapper/actions/workflows/test-unit.yml?query=workflow%3AUnit%20Tests+branch%3Amain)
|
|
4
4
|
[](https://www.npmjs.com/package/rdfjs-wrapper)
|
|
5
5
|
|
|
6
6
|
RDF/JS compliant graph wrapping library.
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
## See also
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
- [RDF/JS Types](https://github.com/rdfjs/types)
|
|
11
|
+
- [RDF/JS Data model specification](http://rdf.js.org/data-model-spec/)
|
|
12
|
+
- [RDF/JS Stream interfaces](http://rdf.js.org/stream-spec/)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BlankNode, DataFactory, DatasetCore, NamedNode, Quad_Predicate } from "@rdfjs/types";
|
|
2
|
+
import type { ILiteralWrapperConstructor, INodeWrapperConstructor } from "../types";
|
|
3
|
+
export declare function getter<T>(term: BlankNode | NamedNode, dataset: DatasetCore, factory: DataFactory, property: Quad_Predicate, wrapper: INodeWrapperConstructor<T> | ILiteralWrapperConstructor<T>): T;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getter = void 0;
|
|
4
|
+
const node_wrapper_1 = require("../class/node_wrapper");
|
|
5
|
+
const wrapper_1 = require("../class/wrapper");
|
|
6
|
+
const cardinality_error_1 = require("../error/cardinality_error");
|
|
7
|
+
const missing_value_error_1 = require("../error/missing_value_error");
|
|
8
|
+
const term_type_error_1 = require("../error/term_type_error");
|
|
9
|
+
const wrapper_type_error_1 = require("../error/wrapper_type_error");
|
|
10
|
+
function isINodeWrapperConstructor(x) {
|
|
11
|
+
if (!(x.prototype instanceof node_wrapper_1.NodeWrapper)) {
|
|
12
|
+
throw new Error("Wrong constructor tyep");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function isILiteralWrapperConstructor(x) {
|
|
16
|
+
if (!(x.name === "LiteralWrapper")) {
|
|
17
|
+
throw new Error("Wrong constructor tyep");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function getter(term, dataset, factory, property, wrapper) {
|
|
21
|
+
const triples = dataset.match(term, property);
|
|
22
|
+
const iter = triples[Symbol.iterator]();
|
|
23
|
+
const triple = iter.next();
|
|
24
|
+
if (triple.done) {
|
|
25
|
+
throw new missing_value_error_1.MissingValueError(term.value, property.value);
|
|
26
|
+
}
|
|
27
|
+
if (!iter.next().done) {
|
|
28
|
+
throw new cardinality_error_1.CardinalityError(term.value, property.value, ">1", "1");
|
|
29
|
+
}
|
|
30
|
+
const { object } = triple.value;
|
|
31
|
+
if (object.termType !== "BlankNode" &&
|
|
32
|
+
object.termType !== "NamedNode" &&
|
|
33
|
+
object.termType !== "Literal") {
|
|
34
|
+
throw new term_type_error_1.TermTypeError(object.termType, "BlankNode, NamedNode or Literal");
|
|
35
|
+
}
|
|
36
|
+
if (!(wrapper.prototype instanceof wrapper_1.Wrapper)) {
|
|
37
|
+
throw new wrapper_type_error_1.WrapperTypeError(wrapper.toString());
|
|
38
|
+
}
|
|
39
|
+
if (object.termType === "BlankNode" || object.termType === "NamedNode") {
|
|
40
|
+
isINodeWrapperConstructor(wrapper);
|
|
41
|
+
// eslint-disable-next-line new-cap
|
|
42
|
+
return new wrapper(object, dataset, factory);
|
|
43
|
+
}
|
|
44
|
+
isILiteralWrapperConstructor(wrapper);
|
|
45
|
+
// eslint-disable-next-line new-cap
|
|
46
|
+
return new wrapper(object, dataset, factory);
|
|
47
|
+
}
|
|
48
|
+
exports.getter = getter;
|
|
49
|
+
//# sourceMappingURL=getter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getter.js","sourceRoot":"","sources":["../../src/algorithm/getter.ts"],"names":[],"mappings":";;;AAOA,wDAAoD;AACpD,8CAA2C;AAC3C,kEAA8D;AAC9D,sEAAiE;AACjE,8DAAyD;AACzD,oEAA+D;AAM/D,SAAS,yBAAyB,CAAI,CAErC;IACC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,YAAY,0BAAW,CAAC,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;KAC3C;AACH,CAAC;AAED,SAAS,4BAA4B,CAAI,CAGxC;IACC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;KAC3C;AACH,CAAC;AAED,SAAgB,MAAM,CACpB,IAA2B,EAC3B,OAAoB,EACpB,OAAoB,EACpB,QAAwB,EACxB,OAAmE;IAEnE,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAE3B,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,MAAM,IAAI,uCAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;KACzD;IAED,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE;QACrB,MAAM,IAAI,oCAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;KACnE;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;IAEhC,IACE,MAAM,CAAC,QAAQ,KAAK,WAAW;QAC/B,MAAM,CAAC,QAAQ,KAAK,WAAW;QAC/B,MAAM,CAAC,QAAQ,KAAK,SAAS,EAC7B;QACA,MAAM,IAAI,+BAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;KAC7E;IAED,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,YAAY,iBAAO,CAAC,EAAE;QAC3C,MAAM,IAAI,qCAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;KAChD;IAED,IAAI,MAAM,CAAC,QAAQ,KAAK,WAAW,IAAI,MAAM,CAAC,QAAQ,KAAK,WAAW,EAAE;QACtE,yBAAyB,CAAC,OAAO,CAAC,CAAC;QACnC,mCAAmC;QACnC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;KAC9C;IAED,4BAA4B,CAAC,OAAO,CAAC,CAAC;IACtC,mCAAmC;IACnC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AA1CD,wBA0CC","sourcesContent":["import type {\n BlankNode,\n DataFactory,\n DatasetCore,\n NamedNode,\n Quad_Predicate,\n} from \"@rdfjs/types\";\nimport { NodeWrapper } from \"../class/node_wrapper\";\nimport { Wrapper } from \"../class/wrapper\";\nimport { CardinalityError } from \"../error/cardinality_error\";\nimport { MissingValueError } from \"../error/missing_value_error\";\nimport { TermTypeError } from \"../error/term_type_error\";\nimport { WrapperTypeError } from \"../error/wrapper_type_error\";\nimport type {\n ILiteralWrapperConstructor,\n INodeWrapperConstructor,\n} from \"../types\";\n\nfunction isINodeWrapperConstructor<T>(x: {\n prototype: unknown;\n}): asserts x is INodeWrapperConstructor<T> {\n if (!(x.prototype instanceof NodeWrapper)) {\n throw new Error(\"Wrong constructor tyep\");\n }\n}\n\nfunction isILiteralWrapperConstructor<T>(x: {\n name: string;\n prototype: unknown;\n}): asserts x is ILiteralWrapperConstructor<T> {\n if (!(x.name === \"LiteralWrapper\")) {\n throw new Error(\"Wrong constructor tyep\");\n }\n}\n\nexport function getter<T>(\n term: BlankNode | NamedNode,\n dataset: DatasetCore,\n factory: DataFactory,\n property: Quad_Predicate,\n wrapper: INodeWrapperConstructor<T> | ILiteralWrapperConstructor<T>\n): T {\n const triples = dataset.match(term, property);\n const iter = triples[Symbol.iterator]();\n const triple = iter.next();\n\n if (triple.done) {\n throw new MissingValueError(term.value, property.value);\n }\n\n if (!iter.next().done) {\n throw new CardinalityError(term.value, property.value, \">1\", \"1\");\n }\n\n const { object } = triple.value;\n\n if (\n object.termType !== \"BlankNode\" &&\n object.termType !== \"NamedNode\" &&\n object.termType !== \"Literal\"\n ) {\n throw new TermTypeError(object.termType, \"BlankNode, NamedNode or Literal\");\n }\n\n if (!(wrapper.prototype instanceof Wrapper)) {\n throw new WrapperTypeError(wrapper.toString());\n }\n\n if (object.termType === \"BlankNode\" || object.termType === \"NamedNode\") {\n isINodeWrapperConstructor(wrapper);\n // eslint-disable-next-line new-cap\n return new wrapper(object, dataset, factory);\n }\n\n isILiteralWrapperConstructor(wrapper);\n // eslint-disable-next-line new-cap\n return new wrapper(object, dataset, factory);\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setLiteral = void 0;
|
|
4
|
+
function setLiteral(subject, dataset, factory, property, value) {
|
|
5
|
+
// THIS IS FOR SINGLE PROPERTY
|
|
6
|
+
for (const q of dataset.match(subject, property)) {
|
|
7
|
+
dataset.delete(q);
|
|
8
|
+
}
|
|
9
|
+
dataset.add(factory.quad(subject, property, factory.literal(value)));
|
|
10
|
+
}
|
|
11
|
+
exports.setLiteral = setLiteral;
|
|
12
|
+
//# sourceMappingURL=set_literal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set_literal.js","sourceRoot":"","sources":["../../src/algorithm/set_literal.ts"],"names":[],"mappings":";;;AAQA,SAAgB,UAAU,CACxB,OAA8B,EAC9B,OAAoB,EACpB,OAAoB,EACpB,QAAwB,EACxB,KAAa;IAEb,8BAA8B;IAC9B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;QAChD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACnB;IAED,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC;AAbD,gCAaC","sourcesContent":["import type {\n BlankNode,\n DataFactory,\n DatasetCore,\n NamedNode,\n Quad_Predicate,\n} from \"@rdfjs/types\";\n\nexport function setLiteral(\n subject: BlankNode | NamedNode,\n dataset: DatasetCore,\n factory: DataFactory,\n property: Quad_Predicate,\n value: string\n): void {\n // THIS IS FOR SINGLE PROPERTY\n for (const q of dataset.match(subject, property)) {\n dataset.delete(q);\n }\n\n dataset.add(factory.quad(subject, property, factory.literal(value)));\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BlankNode, DataFactory, DatasetCore, Literal, NamedNode, Quad_Predicate } from "@rdfjs/types";
|
|
2
|
+
export declare function setNode(subject: BlankNode | NamedNode, dataset: DatasetCore, factory: DataFactory, property: Quad_Predicate, value: {
|
|
3
|
+
term: BlankNode | NamedNode | Literal;
|
|
4
|
+
}): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setNode = void 0;
|
|
4
|
+
function setNode(subject, dataset, factory, property, value) {
|
|
5
|
+
// THIS IS FOR SINGLE NODE
|
|
6
|
+
for (const q of dataset.match(subject, property)) {
|
|
7
|
+
dataset.delete(q);
|
|
8
|
+
}
|
|
9
|
+
dataset.add(factory.quad(subject, property, value.term));
|
|
10
|
+
}
|
|
11
|
+
exports.setNode = setNode;
|
|
12
|
+
//# sourceMappingURL=set_node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set_node.js","sourceRoot":"","sources":["../../src/algorithm/set_node.ts"],"names":[],"mappings":";;;AASA,SAAgB,OAAO,CACrB,OAA8B,EAC9B,OAAoB,EACpB,OAAoB,EACpB,QAAwB,EACxB,KAAgD;IAEhD,0BAA0B;IAC1B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;QAChD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACnB;IAED,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC;AAbD,0BAaC","sourcesContent":["import type {\n BlankNode,\n DataFactory,\n DatasetCore,\n Literal,\n NamedNode,\n Quad_Predicate,\n} from \"@rdfjs/types\";\n\nexport function setNode(\n subject: BlankNode | NamedNode,\n dataset: DatasetCore,\n factory: DataFactory,\n property: Quad_Predicate,\n value: { term: BlankNode | NamedNode | Literal }\n): void {\n // THIS IS FOR SINGLE NODE\n for (const q of dataset.match(subject, property)) {\n dataset.delete(q);\n }\n\n dataset.add(factory.quad(subject, property, value.term));\n}\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BlankNode, DataFactory, DatasetCore, Literal, NamedNode } from "@rdfjs/types";
|
|
2
|
+
import type { ILiteralWrapperConstructor, INodeWrapperConstructor } from "../types";
|
|
3
|
+
export declare function wrap<T>(term: BlankNode | NamedNode | Literal, dataset: DatasetCore, factory: DataFactory, wrapper: INodeWrapperConstructor<T> | ILiteralWrapperConstructor<T>): T;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrap = void 0;
|
|
4
|
+
const node_wrapper_1 = require("../class/node_wrapper");
|
|
5
|
+
const wrapper_1 = require("../class/wrapper");
|
|
6
|
+
const wrapper_type_error_1 = require("../error/wrapper_type_error");
|
|
7
|
+
function isINodeWrapperConstructor(x) {
|
|
8
|
+
if (!(x.prototype instanceof node_wrapper_1.NodeWrapper)) {
|
|
9
|
+
throw new Error("Wrong constructor tyep");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function isILiteralWrapperConstructor(x) {
|
|
13
|
+
if (!(x.name === "LiteralWrapper")) {
|
|
14
|
+
throw new Error("Wrong constructor tyep");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function wrap(term, dataset, factory, wrapper) {
|
|
18
|
+
if (!(wrapper.prototype instanceof wrapper_1.Wrapper)) {
|
|
19
|
+
throw new wrapper_type_error_1.WrapperTypeError(wrapper.toString());
|
|
20
|
+
}
|
|
21
|
+
if (term.termType === "BlankNode" || term.termType === "NamedNode") {
|
|
22
|
+
isINodeWrapperConstructor(wrapper);
|
|
23
|
+
// eslint-disable-next-line new-cap
|
|
24
|
+
return new wrapper(term, dataset, factory);
|
|
25
|
+
}
|
|
26
|
+
isILiteralWrapperConstructor(wrapper);
|
|
27
|
+
// eslint-disable-next-line new-cap
|
|
28
|
+
return new wrapper(term, dataset, factory);
|
|
29
|
+
}
|
|
30
|
+
exports.wrap = wrap;
|
|
31
|
+
//# sourceMappingURL=wrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../../src/algorithm/wrap.ts"],"names":[],"mappings":";;;AAOA,wDAAoD;AACpD,8CAA2C;AAC3C,oEAA+D;AAM/D,SAAS,yBAAyB,CAAI,CAErC;IACC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,YAAY,0BAAW,CAAC,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;KAC3C;AACH,CAAC;AAED,SAAS,4BAA4B,CAAI,CAGxC;IACC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;KAC3C;AACH,CAAC;AAED,SAAgB,IAAI,CAClB,IAAqC,EACrC,OAAoB,EACpB,OAAoB,EACpB,OAAmE;IAEnE,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,YAAY,iBAAO,CAAC,EAAE;QAC3C,MAAM,IAAI,qCAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;KAChD;IAED,IAAI,IAAI,CAAC,QAAQ,KAAK,WAAW,IAAI,IAAI,CAAC,QAAQ,KAAK,WAAW,EAAE;QAClE,yBAAyB,CAAC,OAAO,CAAC,CAAC;QACnC,mCAAmC;QACnC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;KAC5C;IAED,4BAA4B,CAAC,OAAO,CAAC,CAAC;IACtC,mCAAmC;IACnC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AAnBD,oBAmBC","sourcesContent":["import type {\n BlankNode,\n DataFactory,\n DatasetCore,\n Literal,\n NamedNode,\n} from \"@rdfjs/types\";\nimport { NodeWrapper } from \"../class/node_wrapper\";\nimport { Wrapper } from \"../class/wrapper\";\nimport { WrapperTypeError } from \"../error/wrapper_type_error\";\nimport type {\n ILiteralWrapperConstructor,\n INodeWrapperConstructor,\n} from \"../types\";\n\nfunction isINodeWrapperConstructor<T>(x: {\n prototype: unknown;\n}): asserts x is INodeWrapperConstructor<T> {\n if (!(x.prototype instanceof NodeWrapper)) {\n throw new Error(\"Wrong constructor tyep\");\n }\n}\n\nfunction isILiteralWrapperConstructor<T>(x: {\n name: string;\n prototype: unknown;\n}): asserts x is ILiteralWrapperConstructor<T> {\n if (!(x.name === \"LiteralWrapper\")) {\n throw new Error(\"Wrong constructor tyep\");\n }\n}\n\nexport function wrap<T>(\n term: BlankNode | NamedNode | Literal,\n dataset: DatasetCore,\n factory: DataFactory,\n wrapper: INodeWrapperConstructor<T> | ILiteralWrapperConstructor<T>\n): T {\n if (!(wrapper.prototype instanceof Wrapper)) {\n throw new WrapperTypeError(wrapper.toString());\n }\n\n if (term.termType === \"BlankNode\" || term.termType === \"NamedNode\") {\n isINodeWrapperConstructor(wrapper);\n // eslint-disable-next-line new-cap\n return new wrapper(term, dataset, factory);\n }\n\n isILiteralWrapperConstructor(wrapper);\n // eslint-disable-next-line new-cap\n return new wrapper(term, dataset, factory);\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiteralWrapper = void 0;
|
|
4
|
+
const wrapper_1 = require("./wrapper");
|
|
5
|
+
class LiteralWrapper extends wrapper_1.Wrapper {
|
|
6
|
+
term;
|
|
7
|
+
constructor(term, dataset, factory) {
|
|
8
|
+
super(term, dataset, factory);
|
|
9
|
+
this.term = term;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.LiteralWrapper = LiteralWrapper;
|
|
13
|
+
//# sourceMappingURL=literal_wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"literal_wrapper.js","sourceRoot":"","sources":["../../src/class/literal_wrapper.ts"],"names":[],"mappings":";;;AACA,uCAAoC;AAEpC,MAAa,cAAe,SAAQ,iBAAgB;IAC3C,IAAI,CAAU;IAErB,YACE,IAAa,EACb,OAAoB,EACpB,OAAoB;QAEpB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAXD,wCAWC","sourcesContent":["import type { DataFactory, DatasetCore, Literal } from \"@rdfjs/types\";\nimport { Wrapper } from \"./wrapper\";\n\nexport class LiteralWrapper extends Wrapper<Literal> {\n public term: Literal;\n\n public constructor(\n term: Literal,\n dataset: DatasetCore,\n factory: DataFactory\n ) {\n super(term, dataset, factory);\n this.term = term;\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BlankNode, DataFactory, DatasetCore, NamedNode } from "@rdfjs/types";
|
|
2
|
+
import { Wrapper } from "./wrapper";
|
|
3
|
+
export declare abstract class NodeWrapper extends Wrapper<BlankNode | NamedNode> {
|
|
4
|
+
term: BlankNode | NamedNode;
|
|
5
|
+
constructor(term: BlankNode | NamedNode, dataset: DatasetCore, factory: DataFactory);
|
|
6
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeWrapper = void 0;
|
|
4
|
+
const wrapper_1 = require("./wrapper");
|
|
5
|
+
class NodeWrapper extends wrapper_1.Wrapper {
|
|
6
|
+
term;
|
|
7
|
+
constructor(term, dataset, factory) {
|
|
8
|
+
super(term, dataset, factory);
|
|
9
|
+
this.term = term;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.NodeWrapper = NodeWrapper;
|
|
13
|
+
//# sourceMappingURL=node_wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node_wrapper.js","sourceRoot":"","sources":["../../src/class/node_wrapper.ts"],"names":[],"mappings":";;;AAMA,uCAAoC;AAEpC,MAAsB,WAAY,SAAQ,iBAA8B;IAC/D,IAAI,CAAwB;IAEnC,YACE,IAA2B,EAC3B,OAAoB,EACpB,OAAoB;QAEpB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAXD,kCAWC","sourcesContent":["import type {\n BlankNode,\n DataFactory,\n DatasetCore,\n NamedNode,\n} from \"@rdfjs/types\";\nimport { Wrapper } from \"./wrapper\";\n\nexport abstract class NodeWrapper extends Wrapper<BlankNode | NamedNode> {\n public term: BlankNode | NamedNode;\n\n public constructor(\n term: BlankNode | NamedNode,\n dataset: DatasetCore,\n factory: DataFactory\n ) {\n super(term, dataset, factory);\n this.term = term;\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BlankNode, DataFactory, DatasetCore, Literal, NamedNode } from "@rdfjs/types";
|
|
2
|
+
export type Resource = Literal | BlankNode | NamedNode;
|
|
3
|
+
export declare abstract class Wrapper<T extends Resource> {
|
|
4
|
+
term: T;
|
|
5
|
+
protected dataset: DatasetCore;
|
|
6
|
+
protected factory: DataFactory;
|
|
7
|
+
constructor(term: T, dataset: DatasetCore, factory: DataFactory);
|
|
8
|
+
get toString(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Wrapper = void 0;
|
|
4
|
+
class Wrapper {
|
|
5
|
+
term;
|
|
6
|
+
dataset;
|
|
7
|
+
factory;
|
|
8
|
+
constructor(term, dataset, factory) {
|
|
9
|
+
this.term = term;
|
|
10
|
+
this.dataset = dataset;
|
|
11
|
+
this.factory = factory;
|
|
12
|
+
}
|
|
13
|
+
get toString() {
|
|
14
|
+
return this.term.value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Wrapper = Wrapper;
|
|
18
|
+
//# sourceMappingURL=wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/class/wrapper.ts"],"names":[],"mappings":";;;AAUA,MAAsB,OAAO;IACpB,IAAI,CAAI;IAEL,OAAO,CAAc;IAErB,OAAO,CAAc;IAE/B,YAAmB,IAAO,EAAE,OAAoB,EAAE,OAAoB;QACpE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB,CAAC;CACF;AAhBD,0BAgBC","sourcesContent":["import type {\n BlankNode,\n DataFactory,\n DatasetCore,\n Literal,\n NamedNode,\n} from \"@rdfjs/types\";\n\nexport type Resource = Literal | BlankNode | NamedNode;\n\nexport abstract class Wrapper<T extends Resource> {\n public term: T;\n\n protected dataset: DatasetCore;\n\n protected factory: DataFactory;\n\n public constructor(term: T, dataset: DatasetCore, factory: DataFactory) {\n this.term = term;\n this.dataset = dataset;\n this.factory = factory;\n }\n\n get toString(): string {\n return this.term.value;\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DataFactory, Quad_Predicate, DatasetCore, Term, BlankNode, NamedNode } from "@rdfjs/types";
|
|
2
|
+
import { NodeWrapper } from "./node_wrapper";
|
|
3
|
+
export declare class WrappingSet<T> extends NodeWrapper implements Set<T> {
|
|
4
|
+
private property;
|
|
5
|
+
private valueFactory;
|
|
6
|
+
constructor(term: BlankNode | NamedNode, dataset: DatasetCore, factory: DataFactory, property: Quad_Predicate, valueFactory: (term: Term, dataset?: DatasetCore) => T);
|
|
7
|
+
add(value: T): this;
|
|
8
|
+
clear(): void;
|
|
9
|
+
delete(value: T): boolean;
|
|
10
|
+
forEach(callbackfn: (item: T, index: T, set: Set<T>) => void, thisArg?: unknown): void;
|
|
11
|
+
has(value: T): boolean;
|
|
12
|
+
get size(): number;
|
|
13
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
14
|
+
entries(): IterableIterator<[T, T]>;
|
|
15
|
+
keys(): IterableIterator<T>;
|
|
16
|
+
values(): IterableIterator<T>;
|
|
17
|
+
get [Symbol.toStringTag](): string;
|
|
18
|
+
private convert;
|
|
19
|
+
}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WrappingSet = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const node_wrapper_1 = require("./node_wrapper");
|
|
5
|
+
class WrappingSet extends node_wrapper_1.NodeWrapper {
|
|
6
|
+
property;
|
|
7
|
+
valueFactory;
|
|
8
|
+
constructor(term, dataset, factory, property,
|
|
9
|
+
// eslint-disable-next-line no-shadow
|
|
10
|
+
valueFactory) {
|
|
11
|
+
super(term, dataset, factory);
|
|
12
|
+
this.property = property;
|
|
10
13
|
this.valueFactory = valueFactory;
|
|
11
14
|
}
|
|
12
15
|
add(value) {
|
|
13
|
-
const q = this.factory.quad(this.
|
|
16
|
+
const q = this.factory.quad(this.term, this.property, this.convert(value));
|
|
14
17
|
this.dataset.add(q);
|
|
15
18
|
return this;
|
|
16
19
|
}
|
|
17
20
|
clear() {
|
|
18
|
-
for (const q of this.dataset.match(this.
|
|
21
|
+
for (const q of this.dataset.match(this.term, this.property)) {
|
|
19
22
|
this.dataset.delete(q);
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -23,7 +26,7 @@ class WrappingSet {
|
|
|
23
26
|
if (!this.has(value)) {
|
|
24
27
|
return false;
|
|
25
28
|
}
|
|
26
|
-
for (const q of this.dataset.match(this.
|
|
29
|
+
for (const q of this.dataset.match(this.term, this.property, this.convert(value))) {
|
|
27
30
|
this.dataset.delete(q);
|
|
28
31
|
}
|
|
29
32
|
return true;
|
|
@@ -34,12 +37,11 @@ class WrappingSet {
|
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
has(value) {
|
|
37
|
-
return this.dataset.has(this.factory.quad(this.
|
|
40
|
+
return this.dataset.has(this.factory.quad(this.term, this.property, this.convert(value)));
|
|
38
41
|
}
|
|
39
42
|
get size() {
|
|
40
43
|
return Array.from(this).length;
|
|
41
44
|
}
|
|
42
|
-
;
|
|
43
45
|
[Symbol.iterator]() {
|
|
44
46
|
return this.values();
|
|
45
47
|
}
|
|
@@ -52,12 +54,12 @@ class WrappingSet {
|
|
|
52
54
|
return this.values();
|
|
53
55
|
}
|
|
54
56
|
*values() {
|
|
55
|
-
for (const q of this.dataset.match(this.
|
|
57
|
+
for (const q of this.dataset.match(this.term, this.property)) {
|
|
56
58
|
yield this.valueFactory(q.object, this.dataset);
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
get [Symbol.toStringTag]() {
|
|
60
|
-
return `collection wrapper for subject ${this.
|
|
62
|
+
return `collection wrapper for subject ${this.term.value} predicate ${this.property.value}`;
|
|
61
63
|
}
|
|
62
64
|
convert(value) {
|
|
63
65
|
switch (typeof value) {
|
|
@@ -71,4 +73,4 @@ class WrappingSet {
|
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
exports.WrappingSet = WrappingSet;
|
|
74
|
-
//# sourceMappingURL=
|
|
76
|
+
//# sourceMappingURL=wrapping_set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapping_set.js","sourceRoot":"","sources":["../../src/class/wrapping_set.ts"],"names":[],"mappings":"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","sourcesContent":["import type {\n DataFactory,\n Quad_Subject,\n Quad_Predicate,\n DatasetCore,\n Term,\n Quad_Object,\n BlankNode,\n NamedNode,\n} from \"@rdfjs/types\";\nimport { NodeWrapper } from \"./node_wrapper\";\n\nexport class WrappingSet<T> extends NodeWrapper implements Set<T> {\n private property: Quad_Predicate;\n\n private valueFactory: (term: Term, dataset?: DatasetCore) => T;\n\n constructor(\n term: BlankNode | NamedNode,\n dataset: DatasetCore,\n factory: DataFactory,\n property: Quad_Predicate,\n // eslint-disable-next-line no-shadow\n valueFactory: (term: Term, dataset?: DatasetCore) => T\n ) {\n super(term, dataset, factory);\n this.property = property;\n this.valueFactory = valueFactory;\n }\n\n public add(value: T): this {\n const q = this.factory.quad(this.term, this.property, this.convert(value));\n this.dataset.add(q);\n return this;\n }\n\n public clear(): void {\n for (const q of this.dataset.match(this.term, this.property)) {\n this.dataset.delete(q);\n }\n }\n\n public delete(value: T): boolean {\n if (!this.has(value)) {\n return false;\n }\n\n for (const q of this.dataset.match(\n this.term,\n this.property,\n this.convert(value)\n )) {\n this.dataset.delete(q);\n }\n return true;\n }\n\n public forEach(\n callbackfn: (item: T, index: T, set: Set<T>) => void,\n thisArg?: unknown\n ): void {\n for (const item of this) {\n callbackfn.call(thisArg, item, item, this);\n }\n }\n\n public has(value: T): boolean {\n return this.dataset.has(\n this.factory.quad(this.term, this.property, this.convert(value))\n );\n }\n\n public get size(): number {\n return Array.from(this).length;\n }\n\n public [Symbol.iterator](): IterableIterator<T> {\n return this.values();\n }\n\n public *entries(): IterableIterator<[T, T]> {\n for (const t of this) {\n yield [t, t];\n }\n }\n\n public keys(): IterableIterator<T> {\n return this.values();\n }\n\n public *values(): IterableIterator<T> {\n for (const q of this.dataset.match(this.term, this.property)) {\n yield this.valueFactory(q.object, this.dataset);\n }\n }\n\n public get [Symbol.toStringTag](): string {\n return `collection wrapper for subject ${this.term.value} predicate ${this.property.value}`;\n }\n\n private convert(value: T): Quad_Object {\n switch (typeof value) {\n case \"string\":\n return this.factory.literal(value);\n\n case \"number\":\n return this.factory.literal(\n value.toString(),\n this.factory.namedNode(\"xsd:int\")\n );\n\n default:\n return (value as { term: Quad_Subject }).term;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TERM_TYPE: Set<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TERM_TYPE = void 0;
|
|
4
|
+
exports.TERM_TYPE = new Set([
|
|
5
|
+
"NamedNode",
|
|
6
|
+
"BlankNode",
|
|
7
|
+
"Literal",
|
|
8
|
+
"Variable",
|
|
9
|
+
"DefaultGraph",
|
|
10
|
+
"BaseQuad",
|
|
11
|
+
]);
|
|
12
|
+
//# sourceMappingURL=term_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"term_type.js","sourceRoot":"","sources":["../../src/constant/term_type.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,IAAI,GAAG,CAAC;IAC/B,WAAW;IACX,WAAW;IACX,SAAS;IACT,UAAU;IACV,cAAc;IACd,UAAU;CACX,CAAC,CAAC","sourcesContent":["export const TERM_TYPE = new Set([\n \"NamedNode\",\n \"BlankNode\",\n \"Literal\",\n \"Variable\",\n \"DefaultGraph\",\n \"BaseQuad\",\n]);\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CardinalityError = void 0;
|
|
4
|
+
class CardinalityError extends Error {
|
|
5
|
+
constructor(subject, property, actual, expected) {
|
|
6
|
+
super(`Wrong cardinality for subject ${subject}, property ${property}.\nActual: ${actual}\nExpected: ${expected}`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.CardinalityError = CardinalityError;
|
|
10
|
+
//# sourceMappingURL=cardinality_error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardinality_error.js","sourceRoot":"","sources":["../../src/error/cardinality_error.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAiB,SAAQ,KAAK;IACzC,YACE,OAAe,EACf,QAAgB,EAChB,MAAc,EACd,QAAgB;QAEhB,KAAK,CACH,iCAAiC,OAAO,cAAc,QAAQ,cAAc,MAAM,eAAe,QAAQ,EAAE,CAC5G,CAAC;IACJ,CAAC;CACF;AAXD,4CAWC","sourcesContent":["export class CardinalityError extends Error {\n constructor(\n subject: string,\n property: string,\n actual: string,\n expected: string\n ) {\n super(\n `Wrong cardinality for subject ${subject}, property ${property}.\\nActual: ${actual}\\nExpected: ${expected}`\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MissingValueError = void 0;
|
|
4
|
+
class MissingValueError extends Error {
|
|
5
|
+
constructor(subject, property) {
|
|
6
|
+
super(`The subject ${subject} has no value for property ${property}.`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.MissingValueError = MissingValueError;
|
|
10
|
+
//# sourceMappingURL=missing_value_error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missing_value_error.js","sourceRoot":"","sources":["../../src/error/missing_value_error.ts"],"names":[],"mappings":";;;AAAA,MAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAe,EAAE,QAAgB;QAC3C,KAAK,CAAC,eAAe,OAAO,8BAA8B,QAAQ,GAAG,CAAC,CAAC;IACzE,CAAC;CACF;AAJD,8CAIC","sourcesContent":["export class MissingValueError extends Error {\n constructor(subject: string, property: string) {\n super(`The subject ${subject} has no value for property ${property}.`);\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TermTypeError = void 0;
|
|
4
|
+
class TermTypeError extends Error {
|
|
5
|
+
constructor(actual, expected) {
|
|
6
|
+
super(`The term is not of the expected type.\nActual: ${actual}\nExpected: ${expected}`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.TermTypeError = TermTypeError;
|
|
10
|
+
//# sourceMappingURL=term_type_error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"term_type_error.js","sourceRoot":"","sources":["../../src/error/term_type_error.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,MAAc,EAAE,QAAgB;QAC1C,KAAK,CACH,kDAAkD,MAAM,eAAe,QAAQ,EAAE,CAClF,CAAC;IACJ,CAAC;CACF;AAND,sCAMC","sourcesContent":["export class TermTypeError extends Error {\n constructor(actual: string, expected: string) {\n super(\n `The term is not of the expected type.\\nActual: ${actual}\\nExpected: ${expected}`\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WrapperTypeError = void 0;
|
|
4
|
+
class WrapperTypeError extends Error {
|
|
5
|
+
constructor(actual) {
|
|
6
|
+
super(`Wrapper should extend Wrapper.\nActual: ${actual}`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.WrapperTypeError = WrapperTypeError;
|
|
10
|
+
//# sourceMappingURL=wrapper_type_error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper_type_error.js","sourceRoot":"","sources":["../../src/error/wrapper_type_error.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,MAAc;QACxB,KAAK,CAAC,2CAA2C,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AAJD,4CAIC","sourcesContent":["export class WrapperTypeError extends Error {\n constructor(actual: string) {\n super(`Wrapper should extend Wrapper.\\nActual: ${actual}`);\n }\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stringFactory = void 0;
|
|
4
|
-
|
|
4
|
+
const term_type_error_1 = require("../error/term_type_error");
|
|
5
|
+
function stringFactory(term) {
|
|
5
6
|
if (term.termType !== "Literal") {
|
|
6
|
-
throw
|
|
7
|
+
throw new term_type_error_1.TermTypeError(term.termType, "Literal");
|
|
7
8
|
}
|
|
8
9
|
return term.value;
|
|
9
10
|
}
|
|
10
11
|
exports.stringFactory = stringFactory;
|
|
11
|
-
//# sourceMappingURL=
|
|
12
|
+
//# sourceMappingURL=string_factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string_factory.js","sourceRoot":"","sources":["../../src/factory/string_factory.ts"],"names":[],"mappings":";;;AACA,8DAAyD;AAEzD,SAAgB,aAAa,CAAC,IAAU;IACtC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;QAC/B,MAAM,IAAI,+BAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;KACnD;IAED,OAAO,IAAI,CAAC,KAAK,CAAC;AACpB,CAAC;AAND,sCAMC","sourcesContent":["import type { Term } from \"@rdfjs/types\";\nimport { TermTypeError } from \"../error/term_type_error\";\n\nexport function stringFactory(term: Term): string {\n if (term.termType !== \"Literal\") {\n throw new TermTypeError(term.termType, \"Literal\");\n }\n\n return term.value;\n}\n"]}
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { LiteralWrapper } from "./class/literal_wrapper";
|
|
2
|
+
export { NodeWrapper } from "./class/node_wrapper";
|
|
3
|
+
export { Wrapper } from "./class/wrapper";
|
|
4
|
+
export { WrappingSet } from "./class/wrapping_set";
|
|
5
|
+
export { getter } from "./algorithm/getter";
|
|
6
|
+
export { setLiteral } from "./algorithm/set_literal";
|
|
7
|
+
export { setNode } from "./algorithm/set_node";
|
|
8
|
+
export { wrap } from "./algorithm/wrap";
|
|
9
|
+
export { stringFactory } from "./factory/string_factory";
|
|
10
|
+
export * from "./types";
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.stringFactory = exports.wrap = exports.setNode = exports.setLiteral = exports.getter = exports.WrappingSet = exports.Wrapper = exports.NodeWrapper = exports.LiteralWrapper = void 0;
|
|
18
|
+
// Classes
|
|
19
|
+
var literal_wrapper_1 = require("./class/literal_wrapper");
|
|
20
|
+
Object.defineProperty(exports, "LiteralWrapper", { enumerable: true, get: function () { return literal_wrapper_1.LiteralWrapper; } });
|
|
21
|
+
var node_wrapper_1 = require("./class/node_wrapper");
|
|
22
|
+
Object.defineProperty(exports, "NodeWrapper", { enumerable: true, get: function () { return node_wrapper_1.NodeWrapper; } });
|
|
23
|
+
var wrapper_1 = require("./class/wrapper");
|
|
24
|
+
Object.defineProperty(exports, "Wrapper", { enumerable: true, get: function () { return wrapper_1.Wrapper; } });
|
|
25
|
+
var wrapping_set_1 = require("./class/wrapping_set");
|
|
26
|
+
Object.defineProperty(exports, "WrappingSet", { enumerable: true, get: function () { return wrapping_set_1.WrappingSet; } });
|
|
27
|
+
// Algorithms
|
|
28
|
+
var getter_1 = require("./algorithm/getter");
|
|
29
|
+
Object.defineProperty(exports, "getter", { enumerable: true, get: function () { return getter_1.getter; } });
|
|
30
|
+
var set_literal_1 = require("./algorithm/set_literal");
|
|
31
|
+
Object.defineProperty(exports, "setLiteral", { enumerable: true, get: function () { return set_literal_1.setLiteral; } });
|
|
32
|
+
var set_node_1 = require("./algorithm/set_node");
|
|
33
|
+
Object.defineProperty(exports, "setNode", { enumerable: true, get: function () { return set_node_1.setNode; } });
|
|
34
|
+
var wrap_1 = require("./algorithm/wrap");
|
|
35
|
+
Object.defineProperty(exports, "wrap", { enumerable: true, get: function () { return wrap_1.wrap; } });
|
|
36
|
+
// Factory
|
|
37
|
+
var string_factory_1 = require("./factory/string_factory");
|
|
38
|
+
Object.defineProperty(exports, "stringFactory", { enumerable: true, get: function () { return string_factory_1.stringFactory; } });
|
|
39
|
+
// Types
|
|
40
|
+
__exportStar(require("./types"), exports);
|
|
41
|
+
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,UAAU;AACV,2DAAyD;AAAhD,iHAAA,cAAc,OAAA;AACvB,qDAAmD;AAA1C,2GAAA,WAAW,OAAA;AACpB,2CAA0C;AAAjC,kGAAA,OAAO,OAAA;AAChB,qDAAmD;AAA1C,2GAAA,WAAW,OAAA;AAEpB,aAAa;AACb,6CAA4C;AAAnC,gGAAA,MAAM,OAAA;AACf,uDAAqD;AAA5C,yGAAA,UAAU,OAAA;AACnB,iDAA+C;AAAtC,mGAAA,OAAO,OAAA;AAChB,yCAAwC;AAA/B,4FAAA,IAAI,OAAA;AAEb,UAAU;AACV,2DAAyD;AAAhD,+GAAA,aAAa,OAAA;AAEtB,QAAQ;AACR,0CAAwB","sourcesContent":["// Classes\nexport { LiteralWrapper } from \"./class/literal_wrapper\";\nexport { NodeWrapper } from \"./class/node_wrapper\";\nexport { Wrapper } from \"./class/wrapper\";\nexport { WrappingSet } from \"./class/wrapping_set\";\n\n// Algorithms\nexport { getter } from \"./algorithm/getter\";\nexport { setLiteral } from \"./algorithm/set_literal\";\nexport { setNode } from \"./algorithm/set_node\";\nexport { wrap } from \"./algorithm/wrap\";\n\n// Factory\nexport { stringFactory } from \"./factory/string_factory\";\n\n// Types\nexport * from \"./types\";\n"]}
|