rdflib 2.3.1 → 2.3.2-2bc27df4
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/dist/515.rdflib.min.js +1 -1
- package/dist/515.rdflib.min.js.LICENSE.txt +6 -2
- package/dist/515.rdflib.min.js.map +1 -1
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +0 -9
- package/dist/rdflib.min.js.map +1 -1
- package/esm/factories/rdflib-data-factory.js +1 -3
- package/esm/fetcher.js +9 -15
- package/esm/formula.js +2 -11
- package/esm/parse.js +1 -3
- package/esm/serializer.js +7 -9
- package/esm/store.js +1 -2
- package/esm/update-manager.js +5 -10
- package/esm/utils.js +1 -2
- package/esm/variable.js +1 -2
- package/esm/xsd.js +1 -2
- package/lib/collection.d.ts +1 -1
- package/lib/factories/rdflib-data-factory.js +1 -3
- package/lib/fetcher.js +9 -15
- package/lib/formula.js +2 -11
- package/lib/index.d.ts +1 -1
- package/lib/parse.js +1 -3
- package/lib/rdfaparser.d.ts +9 -9
- package/lib/rdfxmlparser.d.ts +1 -1
- package/lib/serializer.d.ts +10 -11
- package/lib/serializer.js +7 -9
- package/lib/store.js +1 -2
- package/lib/update-manager.js +5 -10
- package/lib/utils.js +1 -2
- package/lib/variable.js +1 -2
- package/lib/xsd-internal.d.ts +7 -7
- package/lib/xsd.d.ts +7 -7
- package/lib/xsd.js +1 -2
- package/package.json +41 -36
- package/src/jsonldparser.js +2 -2
- package/src/n3parser.js +669 -669
- package/src/serializer.js +19 -20
- package/src/xsd-internal.js +1 -1
- package/src/xsd.js +4 -4
- package/dist/789.rdflib.min.js +0 -1
|
@@ -15,9 +15,7 @@ const RDFlibDataFactory = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Creates a new graph (store)
|
|
17
17
|
*/
|
|
18
|
-
graph() {
|
|
19
|
-
let features = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
|
|
20
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
18
|
+
graph(features = undefined, opts = undefined) {
|
|
21
19
|
return new IndexedFormula(features, opts || {
|
|
22
20
|
rdfFactory: ExtendedTermFactory
|
|
23
21
|
});
|
package/esm/fetcher.js
CHANGED
|
@@ -435,8 +435,7 @@ function isXMLNS(responseText) {
|
|
|
435
435
|
* and put back the data to the web.
|
|
436
436
|
*/
|
|
437
437
|
export default class Fetcher {
|
|
438
|
-
constructor(store) {
|
|
439
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
438
|
+
constructor(store, options = {}) {
|
|
440
439
|
_defineProperty(this, "store", void 0);
|
|
441
440
|
_defineProperty(this, "timeout", void 0);
|
|
442
441
|
_defineProperty(this, "_fetch", void 0);
|
|
@@ -589,8 +588,7 @@ export default class Fetcher {
|
|
|
589
588
|
* @param requestedURI
|
|
590
589
|
* @param options
|
|
591
590
|
*/
|
|
592
|
-
static setCredentials(requestedURI) {
|
|
593
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
591
|
+
static setCredentials(requestedURI, options = {}) {
|
|
594
592
|
// 2014 CORS problem:
|
|
595
593
|
// XMLHttpRequest cannot load http://www.w3.org/People/Berners-Lee/card.
|
|
596
594
|
// A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin'
|
|
@@ -653,8 +651,7 @@ export default class Fetcher {
|
|
|
653
651
|
*
|
|
654
652
|
* @returns {Promise<Result>}
|
|
655
653
|
*/
|
|
656
|
-
load(uri) {
|
|
657
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
654
|
+
load(uri, options = {}) {
|
|
658
655
|
options = Object.assign({}, options); // Take a copy as we add stuff to the options!!
|
|
659
656
|
if (uri instanceof Array) {
|
|
660
657
|
return Promise.all(uri.map(x => {
|
|
@@ -872,8 +869,7 @@ export default class Fetcher {
|
|
|
872
869
|
* response The fetch Response object (was: XHR) if there was was one
|
|
873
870
|
* includes response.status as the HTTP status if any.
|
|
874
871
|
*/
|
|
875
|
-
nowOrWhenFetched(uriIn, p2, userCallback) {
|
|
876
|
-
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
872
|
+
nowOrWhenFetched(uriIn, p2, userCallback, options = {}) {
|
|
877
873
|
const uri = termValue(uriIn);
|
|
878
874
|
if (typeof p2 === 'function') {
|
|
879
875
|
// nowOrWhenFetched (uri, userCallback)
|
|
@@ -1055,8 +1051,7 @@ export default class Fetcher {
|
|
|
1055
1051
|
/**
|
|
1056
1052
|
* Writes back to the web what we have in the store for this uri
|
|
1057
1053
|
*/
|
|
1058
|
-
putBack(uri) {
|
|
1059
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1054
|
+
putBack(uri, options = {}) {
|
|
1060
1055
|
const uriSting = termValue(uri);
|
|
1061
1056
|
let doc = new RDFlibNamedNode(uriSting).doc(); // strip off #
|
|
1062
1057
|
options.contentType = options["content-type"] || options["Content-Type"] || options.contentType || TurtleContentType;
|
|
@@ -1100,9 +1095,7 @@ export default class Fetcher {
|
|
|
1100
1095
|
* as otherwise existing could be deleted.
|
|
1101
1096
|
* @param doc - The resource
|
|
1102
1097
|
*/
|
|
1103
|
-
async createIfNotExists(doc) {
|
|
1104
|
-
let contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TurtleContentType;
|
|
1105
|
-
let data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
1098
|
+
async createIfNotExists(doc, contentType = TurtleContentType, data = '') {
|
|
1106
1099
|
const fetcher = this;
|
|
1107
1100
|
try {
|
|
1108
1101
|
var response = await fetcher.load(doc);
|
|
@@ -1187,8 +1180,9 @@ export default class Fetcher {
|
|
|
1187
1180
|
* Returns promise of Response
|
|
1188
1181
|
* If data is returned, copies it to response.responseText before returning
|
|
1189
1182
|
*/
|
|
1190
|
-
webOperation(method, uriIn
|
|
1191
|
-
|
|
1183
|
+
webOperation(method, uriIn,
|
|
1184
|
+
// Not sure about this type. Maybe this Options is different?
|
|
1185
|
+
options = {}) {
|
|
1192
1186
|
const uri = termValue(uriIn);
|
|
1193
1187
|
options.method = method;
|
|
1194
1188
|
options.body = options.data || options.body;
|
package/esm/formula.js
CHANGED
|
@@ -25,15 +25,8 @@ export default class Formula extends Node {
|
|
|
25
25
|
* @param opts
|
|
26
26
|
* @param opts.rdfFactory - The rdf factory that should be used by the store
|
|
27
27
|
*/
|
|
28
|
-
constructor() {
|
|
29
|
-
var _this;
|
|
30
|
-
let statements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
31
|
-
let constraints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
32
|
-
let initBindings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
33
|
-
let optional = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
34
|
-
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
28
|
+
constructor(statements = [], constraints = [], initBindings = [], optional = [], opts = {}) {
|
|
35
29
|
super('');
|
|
36
|
-
_this = this;
|
|
37
30
|
this.statements = statements;
|
|
38
31
|
this.constraints = constraints;
|
|
39
32
|
this.initBindings = initBindings;
|
|
@@ -57,9 +50,7 @@ export default class Formula extends Node {
|
|
|
57
50
|
this.rdfFactory = opts && opts.rdfFactory || CanonicalDataFactory;
|
|
58
51
|
// Enable default factory methods on this while preserving factory context.
|
|
59
52
|
for (const factoryMethod of appliedFactoryMethods) {
|
|
60
|
-
this[factoryMethod] =
|
|
61
|
-
return _this.rdfFactory[factoryMethod](...arguments);
|
|
62
|
-
};
|
|
53
|
+
this[factoryMethod] = (...args) => this.rdfFactory[factoryMethod](...args);
|
|
63
54
|
}
|
|
64
55
|
}
|
|
65
56
|
|
package/esm/parse.js
CHANGED
|
@@ -19,9 +19,7 @@ import { TurtleContentType, N3ContentType, RDFXMLContentType, XHTMLContentType,
|
|
|
19
19
|
* @param contentType - The MIME content type string for the input - defaults to text/turtle
|
|
20
20
|
* @param [callback] - The callback to call when the data has been loaded
|
|
21
21
|
*/
|
|
22
|
-
export default function parse(str, kb, base) {
|
|
23
|
-
let contentType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'text/turtle';
|
|
24
|
-
let callback = arguments.length > 4 ? arguments[4] : undefined;
|
|
22
|
+
export default function parse(str, kb, base, contentType = 'text/turtle', callback) {
|
|
25
23
|
contentType = contentType || TurtleContentType;
|
|
26
24
|
contentType = contentType.split(';')[0];
|
|
27
25
|
try {
|
package/esm/serializer.js
CHANGED
|
@@ -6,14 +6,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
6
6
|
** This is or was https://github.com/linkeddata/rdflib.js/blob/main/src/serializer.js
|
|
7
7
|
** Licence: MIT
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import * as ttl2jsonld from '@frogcat/ttl2jsonld';
|
|
10
|
+
import solidNs from 'solid-namespace';
|
|
11
|
+
import CanonicalDataFactory from './factories/canonical-data-factory';
|
|
11
12
|
import * as Uri from './uri';
|
|
12
13
|
import * as Util from './utils-js';
|
|
13
|
-
import CanonicalDataFactory from './factories/canonical-data-factory';
|
|
14
14
|
import { createXSD } from './xsd';
|
|
15
|
-
import solidNs from 'solid-namespace';
|
|
16
|
-
import * as ttl2jsonld from '@frogcat/ttl2jsonld';
|
|
17
15
|
export default function createSerializer(store) {
|
|
18
16
|
return new Serializer(store);
|
|
19
17
|
}
|
|
@@ -43,7 +41,7 @@ export class Serializer {
|
|
|
43
41
|
|
|
44
42
|
this.namespacesUsed = []; // Count actually used and so needed in @prefixes
|
|
45
43
|
this.keywords = ['a']; // The only one we generate at the moment
|
|
46
|
-
this.prefixchars = '
|
|
44
|
+
this.prefixchars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
47
45
|
this.incoming = null; // Array not calculated yet
|
|
48
46
|
this.formulas = []; // remembering original formulae from hashes
|
|
49
47
|
this.store = store;
|
|
@@ -170,7 +168,7 @@ export class Serializer {
|
|
|
170
168
|
if (slash >= 0) p = p.slice(slash + 1);
|
|
171
169
|
var i = 0;
|
|
172
170
|
while (i < p.length) {
|
|
173
|
-
if (this.prefixchars.indexOf(p[i])) {
|
|
171
|
+
if (this.prefixchars.indexOf(p[i]) >= 0) {
|
|
174
172
|
i++;
|
|
175
173
|
} else {
|
|
176
174
|
break;
|
|
@@ -876,7 +874,7 @@ export class Serializer {
|
|
|
876
874
|
results = results.concat(['<' + t + ' rdf:resource="' + relURI(st.object) + '"/>']);
|
|
877
875
|
break;
|
|
878
876
|
case 'Literal':
|
|
879
|
-
results = results.concat(['<' + t + (st.object.
|
|
877
|
+
results = results.concat(['<' + t + (st.object.language ? ' xml:lang="' + st.object.language + '"' : st.object.datatype.equals(this.xsd.string) ? '' : ' rdf:datatype="' + escapeForXML(st.object.datatype.uri) + '"') + '>' + escapeForXML(st.object.value) + '</' + t + '>']);
|
|
880
878
|
break;
|
|
881
879
|
case 'Collection':
|
|
882
880
|
results = results.concat(['<' + t + ' rdf:parseType="Collection">', collectionXMLTree(st.object, stats), '</' + t + '>']);
|
|
@@ -927,7 +925,7 @@ export class Serializer {
|
|
|
927
925
|
results = results.concat(['<' + qname(st.predicate) + ' rdf:resource="' + relURI(st.object) + '"/>']);
|
|
928
926
|
break;
|
|
929
927
|
case 'Literal':
|
|
930
|
-
results = results.concat(['<' + qname(st.predicate) + (st.object.
|
|
928
|
+
results = results.concat(['<' + qname(st.predicate) + (st.object.language ? ' xml:lang="' + st.object.language + '"' : st.object.datatype.equals(this.xsd.string) ? '' : ' rdf:datatype="' + escapeForXML(st.object.datatype.value) + '"') + '>' + escapeForXML(st.object.value) + '</' + qname(st.predicate) + '>']);
|
|
931
929
|
break;
|
|
932
930
|
case 'Collection':
|
|
933
931
|
results = results.concat(['<' + qname(st.predicate) + ' rdf:parseType="Collection">', collectionXMLTree(st.object, stats), '</' + qname(st.predicate) + '>']);
|
package/esm/store.js
CHANGED
|
@@ -92,8 +92,7 @@ export default class IndexedFormula extends Formula {
|
|
|
92
92
|
* @param [opts.rdfArrayRemove] - Function which removes statements from the store
|
|
93
93
|
* @param [opts.dataCallback] - Callback when a statement is added to the store, will not trigger when adding duplicates
|
|
94
94
|
*/
|
|
95
|
-
constructor(features) {
|
|
96
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
95
|
+
constructor(features, opts = {}) {
|
|
97
96
|
super(undefined, undefined, undefined, undefined, opts);
|
|
98
97
|
// IN future - allow pass array of statements to constructor
|
|
99
98
|
/**
|
package/esm/update-manager.js
CHANGED
|
@@ -378,8 +378,7 @@ export default class UpdateManager {
|
|
|
378
378
|
/**
|
|
379
379
|
* @private
|
|
380
380
|
*/
|
|
381
|
-
fire(uri, query, callbackFunction) {
|
|
382
|
-
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
381
|
+
fire(uri, query, callbackFunction, options = {}) {
|
|
383
382
|
return Promise.resolve().then(() => {
|
|
384
383
|
if (!uri) {
|
|
385
384
|
throw new Error('No URI given for remote editing operation: ' + query);
|
|
@@ -667,8 +666,7 @@ export default class UpdateManager {
|
|
|
667
666
|
* @param insertions - Statement or statements to be inserted.
|
|
668
667
|
* @returns a promise
|
|
669
668
|
*/
|
|
670
|
-
updateMany(deletions) {
|
|
671
|
-
let insertions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
669
|
+
updateMany(deletions, insertions = []) {
|
|
672
670
|
const docs = deletions.concat(insertions).map(st => st.why);
|
|
673
671
|
const thisUpdater = this;
|
|
674
672
|
const uniqueDocs = [];
|
|
@@ -781,8 +779,7 @@ _:patch
|
|
|
781
779
|
* OR returns a promise
|
|
782
780
|
* @param options - Options for the fetch call
|
|
783
781
|
*/
|
|
784
|
-
update(deletions, insertions, callback, secondTry) {
|
|
785
|
-
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
782
|
+
update(deletions, insertions, callback, secondTry, options = {}) {
|
|
786
783
|
if (!callback) {
|
|
787
784
|
var thisUpdater = this;
|
|
788
785
|
return new Promise(function (resolve, reject) {
|
|
@@ -925,8 +922,7 @@ _:patch
|
|
|
925
922
|
callback(undefined, false, 'Exception in update: ' + e + '\n' + Util.stackString(e));
|
|
926
923
|
}
|
|
927
924
|
}
|
|
928
|
-
updateDav(doc, ds, is, callbackFunction) {
|
|
929
|
-
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
925
|
+
updateDav(doc, ds, is, callbackFunction, options = {}) {
|
|
930
926
|
let kb = this.store;
|
|
931
927
|
// The code below is derived from Kenny's UpdateCenter.js
|
|
932
928
|
var request = kb.any(doc, this.ns.link('request'));
|
|
@@ -983,8 +979,7 @@ _:patch
|
|
|
983
979
|
* @param callbackFunction
|
|
984
980
|
* @param options
|
|
985
981
|
*/
|
|
986
|
-
updateLocalFile(doc, ds, is, callbackFunction) {
|
|
987
|
-
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
982
|
+
updateLocalFile(doc, ds, is, callbackFunction, options = {}) {
|
|
988
983
|
const kb = this.store;
|
|
989
984
|
// console.log('Writing back to local file\n')
|
|
990
985
|
|
package/esm/utils.js
CHANGED
|
@@ -79,8 +79,7 @@ export function arrayToStatements(rdfFactory, subject, data) {
|
|
|
79
79
|
}, subject);
|
|
80
80
|
return statements;
|
|
81
81
|
}
|
|
82
|
-
export function ArrayIndexOf(arr, item) {
|
|
83
|
-
let i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
82
|
+
export function ArrayIndexOf(arr, item, i = 0) {
|
|
84
83
|
var length = arr.length;
|
|
85
84
|
if (i < 0) i = length + i;
|
|
86
85
|
for (; i < length; i++) {
|
package/esm/variable.js
CHANGED
|
@@ -15,8 +15,7 @@ export default class Variable extends Node {
|
|
|
15
15
|
* Initializes this variable
|
|
16
16
|
* @param name The variable's name
|
|
17
17
|
*/
|
|
18
|
-
constructor() {
|
|
19
|
-
let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
18
|
+
constructor(name = '') {
|
|
20
19
|
super(name);
|
|
21
20
|
_defineProperty(this, "termType", VariableTermType);
|
|
22
21
|
/** The base string for a variable's name */
|
package/esm/xsd.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import CanonicalDataFactory from "./factories/canonical-data-factory";
|
|
2
|
-
export function createXSD() {
|
|
3
|
-
let localFactory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CanonicalDataFactory;
|
|
2
|
+
export function createXSD(localFactory = CanonicalDataFactory) {
|
|
4
3
|
return {
|
|
5
4
|
boolean: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#boolean"),
|
|
6
5
|
dateTime: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#dateTime"),
|
package/lib/collection.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export default class Collection<T extends Node = Node | RdflibBlankNode | Collec
|
|
|
49
49
|
* Creates a new Collection with the substituting bindings applied
|
|
50
50
|
* @param bindings - The bindings to substitute
|
|
51
51
|
*/
|
|
52
|
-
substitute(bindings: Bindings): any
|
|
52
|
+
substitute(bindings: Bindings): Collection<Node | Collection<any> | Literal | Variable>;
|
|
53
53
|
toNT(): string;
|
|
54
54
|
static toNT(collection: any): string;
|
|
55
55
|
/**
|
|
@@ -22,9 +22,7 @@ const RDFlibDataFactory = {
|
|
|
22
22
|
/**
|
|
23
23
|
* Creates a new graph (store)
|
|
24
24
|
*/
|
|
25
|
-
graph() {
|
|
26
|
-
let features = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
|
|
27
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
25
|
+
graph(features = undefined, opts = undefined) {
|
|
28
26
|
return new _store.default(features, opts || {
|
|
29
27
|
rdfFactory: _extendedTermFactory.default
|
|
30
28
|
});
|
package/lib/fetcher.js
CHANGED
|
@@ -444,8 +444,7 @@ function isXMLNS(responseText) {
|
|
|
444
444
|
* and put back the data to the web.
|
|
445
445
|
*/
|
|
446
446
|
class Fetcher {
|
|
447
|
-
constructor(store) {
|
|
448
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
447
|
+
constructor(store, options = {}) {
|
|
449
448
|
(0, _defineProperty2.default)(this, "store", void 0);
|
|
450
449
|
(0, _defineProperty2.default)(this, "timeout", void 0);
|
|
451
450
|
(0, _defineProperty2.default)(this, "_fetch", void 0);
|
|
@@ -598,8 +597,7 @@ class Fetcher {
|
|
|
598
597
|
* @param requestedURI
|
|
599
598
|
* @param options
|
|
600
599
|
*/
|
|
601
|
-
static setCredentials(requestedURI) {
|
|
602
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
600
|
+
static setCredentials(requestedURI, options = {}) {
|
|
603
601
|
// 2014 CORS problem:
|
|
604
602
|
// XMLHttpRequest cannot load http://www.w3.org/People/Berners-Lee/card.
|
|
605
603
|
// A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin'
|
|
@@ -662,8 +660,7 @@ class Fetcher {
|
|
|
662
660
|
*
|
|
663
661
|
* @returns {Promise<Result>}
|
|
664
662
|
*/
|
|
665
|
-
load(uri) {
|
|
666
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
663
|
+
load(uri, options = {}) {
|
|
667
664
|
options = Object.assign({}, options); // Take a copy as we add stuff to the options!!
|
|
668
665
|
if (uri instanceof Array) {
|
|
669
666
|
return Promise.all(uri.map(x => {
|
|
@@ -881,8 +878,7 @@ class Fetcher {
|
|
|
881
878
|
* response The fetch Response object (was: XHR) if there was was one
|
|
882
879
|
* includes response.status as the HTTP status if any.
|
|
883
880
|
*/
|
|
884
|
-
nowOrWhenFetched(uriIn, p2, userCallback) {
|
|
885
|
-
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
881
|
+
nowOrWhenFetched(uriIn, p2, userCallback, options = {}) {
|
|
886
882
|
const uri = (0, _termValue.termValue)(uriIn);
|
|
887
883
|
if (typeof p2 === 'function') {
|
|
888
884
|
// nowOrWhenFetched (uri, userCallback)
|
|
@@ -1064,8 +1060,7 @@ class Fetcher {
|
|
|
1064
1060
|
/**
|
|
1065
1061
|
* Writes back to the web what we have in the store for this uri
|
|
1066
1062
|
*/
|
|
1067
|
-
putBack(uri) {
|
|
1068
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1063
|
+
putBack(uri, options = {}) {
|
|
1069
1064
|
const uriSting = (0, _termValue.termValue)(uri);
|
|
1070
1065
|
let doc = new _namedNode.default(uriSting).doc(); // strip off #
|
|
1071
1066
|
options.contentType = options["content-type"] || options["Content-Type"] || options.contentType || _types.TurtleContentType;
|
|
@@ -1109,9 +1104,7 @@ class Fetcher {
|
|
|
1109
1104
|
* as otherwise existing could be deleted.
|
|
1110
1105
|
* @param doc - The resource
|
|
1111
1106
|
*/
|
|
1112
|
-
async createIfNotExists(doc) {
|
|
1113
|
-
let contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _types.TurtleContentType;
|
|
1114
|
-
let data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
1107
|
+
async createIfNotExists(doc, contentType = _types.TurtleContentType, data = '') {
|
|
1115
1108
|
const fetcher = this;
|
|
1116
1109
|
try {
|
|
1117
1110
|
var response = await fetcher.load(doc);
|
|
@@ -1196,8 +1189,9 @@ class Fetcher {
|
|
|
1196
1189
|
* Returns promise of Response
|
|
1197
1190
|
* If data is returned, copies it to response.responseText before returning
|
|
1198
1191
|
*/
|
|
1199
|
-
webOperation(method, uriIn
|
|
1200
|
-
|
|
1192
|
+
webOperation(method, uriIn,
|
|
1193
|
+
// Not sure about this type. Maybe this Options is different?
|
|
1194
|
+
options = {}) {
|
|
1201
1195
|
const uri = (0, _termValue.termValue)(uriIn);
|
|
1202
1196
|
options.method = method;
|
|
1203
1197
|
options.body = options.data || options.body;
|
package/lib/formula.js
CHANGED
|
@@ -32,15 +32,8 @@ class Formula extends _nodeInternal.default {
|
|
|
32
32
|
* @param opts
|
|
33
33
|
* @param opts.rdfFactory - The rdf factory that should be used by the store
|
|
34
34
|
*/
|
|
35
|
-
constructor() {
|
|
36
|
-
var _this;
|
|
37
|
-
let statements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
38
|
-
let constraints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
39
|
-
let initBindings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
40
|
-
let optional = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
41
|
-
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
35
|
+
constructor(statements = [], constraints = [], initBindings = [], optional = [], opts = {}) {
|
|
42
36
|
super('');
|
|
43
|
-
_this = this;
|
|
44
37
|
this.statements = statements;
|
|
45
38
|
this.constraints = constraints;
|
|
46
39
|
this.initBindings = initBindings;
|
|
@@ -64,9 +57,7 @@ class Formula extends _nodeInternal.default {
|
|
|
64
57
|
this.rdfFactory = opts && opts.rdfFactory || _canonicalDataFactory.default;
|
|
65
58
|
// Enable default factory methods on this while preserving factory context.
|
|
66
59
|
for (const factoryMethod of _utils.appliedFactoryMethods) {
|
|
67
|
-
this[factoryMethod] =
|
|
68
|
-
return _this.rdfFactory[factoryMethod](...arguments);
|
|
69
|
-
};
|
|
60
|
+
this[factoryMethod] = (...args) => this.rdfFactory[factoryMethod](...args);
|
|
70
61
|
}
|
|
71
62
|
}
|
|
72
63
|
|
package/lib/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ import * as uri from './uri';
|
|
|
28
28
|
import * as Util from './utils-js';
|
|
29
29
|
import Variable from './variable';
|
|
30
30
|
import DataFactory from './factories/rdflib-data-factory';
|
|
31
|
-
declare const fetcher: (store: Store, options: any) => Fetcher, graph: (features?: any, opts?: any) => Store, lit: (val: string, lang?: string
|
|
31
|
+
declare const fetcher: (store: Store, options: any) => Fetcher, graph: (features?: any, opts?: any) => Store, lit: (val: string, lang?: string, dt?: import("./tf-types").NamedNode) => Literal, st: (subject: import("./tf-types").Quad_Subject, predicate: import("./tf-types").Quad_Predicate, object: import("./tf-types").Quad_Object, graph?: import("./tf-types").Quad_Graph) => Statement, namedNode: (value: string) => NamedNode, variable: (value: string) => Variable, blankNode: (value?: string) => BlankNode, defaultGraph: () => import("./default-graph").default, literal: (value: string, languageOrDatatype?: string | import("./tf-types").NamedNode) => Literal, quad: (subject: import("./tf-types").Term, predicate: import("./tf-types").Term, object: import("./tf-types").Term, graph?: import("./tf-types").Term) => Statement, triple: (subject: import("./tf-types").Term, predicate: import("./tf-types").Term, object: import("./tf-types").Term, graph?: import("./tf-types").Term) => import("./tf-types").Quad<any, any, any, any>;
|
|
32
32
|
declare const fromNT: (str: any) => any;
|
|
33
33
|
declare const term: <T extends import("./types").FromValueReturns>(value: import("./types").ValueType) => T;
|
|
34
34
|
declare const NextId: number;
|
package/lib/parse.js
CHANGED
|
@@ -29,9 +29,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
29
29
|
* @param contentType - The MIME content type string for the input - defaults to text/turtle
|
|
30
30
|
* @param [callback] - The callback to call when the data has been loaded
|
|
31
31
|
*/
|
|
32
|
-
function parse(str, kb, base) {
|
|
33
|
-
let contentType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'text/turtle';
|
|
34
|
-
let callback = arguments.length > 4 ? arguments[4] : undefined;
|
|
32
|
+
function parse(str, kb, base, contentType = 'text/turtle', callback) {
|
|
35
33
|
contentType = contentType || _types.TurtleContentType;
|
|
36
34
|
contentType = contentType.split(';')[0];
|
|
37
35
|
try {
|
package/lib/rdfaparser.d.ts
CHANGED
|
@@ -61,15 +61,15 @@ declare class RDFaProcessor {
|
|
|
61
61
|
trim(str: any): any;
|
|
62
62
|
}
|
|
63
63
|
declare namespace RDFaProcessor {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
let XMLLiteralURI: string;
|
|
65
|
+
let HTMLLiteralURI: string;
|
|
66
|
+
let PlainLiteralURI: string;
|
|
67
|
+
let objectURI: string;
|
|
68
|
+
let typeURI: string;
|
|
69
|
+
let nameChar: string;
|
|
70
|
+
let nameStartChar: string;
|
|
71
|
+
let NCNAME: RegExp;
|
|
72
|
+
let dateTimeTypes: {
|
|
73
73
|
pattern: RegExp;
|
|
74
74
|
type: string;
|
|
75
75
|
}[];
|
package/lib/rdfxmlparser.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export default class RDFParser {
|
|
|
25
25
|
};
|
|
26
26
|
constructor(store: any);
|
|
27
27
|
/** Our triple store reference @private */
|
|
28
|
-
store
|
|
28
|
+
private store; /** Our identified blank nodes @private */
|
|
29
29
|
bnodes: {}; /** A context for context-aware stores @private */
|
|
30
30
|
why: any; /** Reification flag */
|
|
31
31
|
reify: boolean;
|
package/lib/serializer.d.ts
CHANGED
|
@@ -13,22 +13,22 @@ export class Serializer {
|
|
|
13
13
|
store: any;
|
|
14
14
|
rdfFactory: any;
|
|
15
15
|
xsd: {
|
|
16
|
-
boolean:
|
|
17
|
-
dateTime:
|
|
18
|
-
decimal:
|
|
19
|
-
double:
|
|
20
|
-
integer:
|
|
21
|
-
langString:
|
|
22
|
-
string:
|
|
16
|
+
boolean: import("./named-node").default;
|
|
17
|
+
dateTime: import("./named-node").default;
|
|
18
|
+
decimal: import("./named-node").default;
|
|
19
|
+
double: import("./named-node").default;
|
|
20
|
+
integer: import("./named-node").default;
|
|
21
|
+
langString: import("./named-node").default;
|
|
22
|
+
string: import("./named-node").default;
|
|
23
23
|
};
|
|
24
|
-
setBase(base: any):
|
|
24
|
+
setBase(base: any): this;
|
|
25
25
|
/**
|
|
26
26
|
* Set serializer behavior flags. Letters can be combined with spaces.
|
|
27
27
|
* Examples: 'si', 'deinprstux', 'si dr', 'o'.
|
|
28
28
|
* Notable flags:
|
|
29
29
|
* - 'o': do not abbreviate to a prefixed name when the local part contains a dot
|
|
30
30
|
*/
|
|
31
|
-
setFlags(flags: any):
|
|
31
|
+
setFlags(flags: any): this;
|
|
32
32
|
toStr(x: any): any;
|
|
33
33
|
fromStr(s: any): any;
|
|
34
34
|
/**
|
|
@@ -45,7 +45,7 @@ export class Serializer {
|
|
|
45
45
|
*/
|
|
46
46
|
setPrefix(prefix: any, uri: any): void;
|
|
47
47
|
suggestPrefix(prefix: any, uri: any): void;
|
|
48
|
-
suggestNamespaces(namespaces: any):
|
|
48
|
+
suggestNamespaces(namespaces: any): this;
|
|
49
49
|
checkIntegrity(): void;
|
|
50
50
|
makeUpPrefix(uri: any): any;
|
|
51
51
|
rootSubjects(sts: any): {
|
|
@@ -72,4 +72,3 @@ export class Serializer {
|
|
|
72
72
|
statementsToXML(sts: any): string;
|
|
73
73
|
statementsToJsonld(sts: any): string;
|
|
74
74
|
}
|
|
75
|
-
import NamedNode from './named-node';
|
package/lib/serializer.js
CHANGED
|
@@ -7,14 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.Serializer = void 0;
|
|
8
8
|
exports.default = createSerializer;
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var ttl2jsonld = _interopRequireWildcard(require("@frogcat/ttl2jsonld"));
|
|
11
|
+
var _solidNamespace = _interopRequireDefault(require("solid-namespace"));
|
|
12
|
+
var _canonicalDataFactory = _interopRequireDefault(require("./factories/canonical-data-factory"));
|
|
12
13
|
var Uri = _interopRequireWildcard(require("./uri"));
|
|
13
14
|
var Util = _interopRequireWildcard(require("./utils-js"));
|
|
14
|
-
var _canonicalDataFactory = _interopRequireDefault(require("./factories/canonical-data-factory"));
|
|
15
15
|
var _xsd = require("./xsd");
|
|
16
|
-
var _solidNamespace = _interopRequireDefault(require("solid-namespace"));
|
|
17
|
-
var ttl2jsonld = _interopRequireWildcard(require("@frogcat/ttl2jsonld"));
|
|
18
16
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
17
|
/* Serialization of RDF Graphs
|
|
20
18
|
**
|
|
@@ -53,7 +51,7 @@ class Serializer {
|
|
|
53
51
|
|
|
54
52
|
this.namespacesUsed = []; // Count actually used and so needed in @prefixes
|
|
55
53
|
this.keywords = ['a']; // The only one we generate at the moment
|
|
56
|
-
this.prefixchars = '
|
|
54
|
+
this.prefixchars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
57
55
|
this.incoming = null; // Array not calculated yet
|
|
58
56
|
this.formulas = []; // remembering original formulae from hashes
|
|
59
57
|
this.store = store;
|
|
@@ -180,7 +178,7 @@ class Serializer {
|
|
|
180
178
|
if (slash >= 0) p = p.slice(slash + 1);
|
|
181
179
|
var i = 0;
|
|
182
180
|
while (i < p.length) {
|
|
183
|
-
if (this.prefixchars.indexOf(p[i])) {
|
|
181
|
+
if (this.prefixchars.indexOf(p[i]) >= 0) {
|
|
184
182
|
i++;
|
|
185
183
|
} else {
|
|
186
184
|
break;
|
|
@@ -886,7 +884,7 @@ class Serializer {
|
|
|
886
884
|
results = results.concat(['<' + t + ' rdf:resource="' + relURI(st.object) + '"/>']);
|
|
887
885
|
break;
|
|
888
886
|
case 'Literal':
|
|
889
|
-
results = results.concat(['<' + t + (st.object.
|
|
887
|
+
results = results.concat(['<' + t + (st.object.language ? ' xml:lang="' + st.object.language + '"' : st.object.datatype.equals(this.xsd.string) ? '' : ' rdf:datatype="' + escapeForXML(st.object.datatype.uri) + '"') + '>' + escapeForXML(st.object.value) + '</' + t + '>']);
|
|
890
888
|
break;
|
|
891
889
|
case 'Collection':
|
|
892
890
|
results = results.concat(['<' + t + ' rdf:parseType="Collection">', collectionXMLTree(st.object, stats), '</' + t + '>']);
|
|
@@ -937,7 +935,7 @@ class Serializer {
|
|
|
937
935
|
results = results.concat(['<' + qname(st.predicate) + ' rdf:resource="' + relURI(st.object) + '"/>']);
|
|
938
936
|
break;
|
|
939
937
|
case 'Literal':
|
|
940
|
-
results = results.concat(['<' + qname(st.predicate) + (st.object.
|
|
938
|
+
results = results.concat(['<' + qname(st.predicate) + (st.object.language ? ' xml:lang="' + st.object.language + '"' : st.object.datatype.equals(this.xsd.string) ? '' : ' rdf:datatype="' + escapeForXML(st.object.datatype.value) + '"') + '>' + escapeForXML(st.object.value) + '</' + qname(st.predicate) + '>']);
|
|
941
939
|
break;
|
|
942
940
|
case 'Collection':
|
|
943
941
|
results = results.concat(['<' + qname(st.predicate) + ' rdf:parseType="Collection">', collectionXMLTree(st.object, stats), '</' + qname(st.predicate) + '>']);
|
package/lib/store.js
CHANGED
|
@@ -100,8 +100,7 @@ class IndexedFormula extends _formula.default {
|
|
|
100
100
|
* @param [opts.rdfArrayRemove] - Function which removes statements from the store
|
|
101
101
|
* @param [opts.dataCallback] - Callback when a statement is added to the store, will not trigger when adding duplicates
|
|
102
102
|
*/
|
|
103
|
-
constructor(features) {
|
|
104
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
103
|
+
constructor(features, opts = {}) {
|
|
105
104
|
super(undefined, undefined, undefined, undefined, opts);
|
|
106
105
|
// IN future - allow pass array of statements to constructor
|
|
107
106
|
/**
|
package/lib/update-manager.js
CHANGED
|
@@ -387,8 +387,7 @@ class UpdateManager {
|
|
|
387
387
|
/**
|
|
388
388
|
* @private
|
|
389
389
|
*/
|
|
390
|
-
fire(uri, query, callbackFunction) {
|
|
391
|
-
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
390
|
+
fire(uri, query, callbackFunction, options = {}) {
|
|
392
391
|
return Promise.resolve().then(() => {
|
|
393
392
|
if (!uri) {
|
|
394
393
|
throw new Error('No URI given for remote editing operation: ' + query);
|
|
@@ -676,8 +675,7 @@ class UpdateManager {
|
|
|
676
675
|
* @param insertions - Statement or statements to be inserted.
|
|
677
676
|
* @returns a promise
|
|
678
677
|
*/
|
|
679
|
-
updateMany(deletions) {
|
|
680
|
-
let insertions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
678
|
+
updateMany(deletions, insertions = []) {
|
|
681
679
|
const docs = deletions.concat(insertions).map(st => st.why);
|
|
682
680
|
const thisUpdater = this;
|
|
683
681
|
const uniqueDocs = [];
|
|
@@ -790,8 +788,7 @@ _:patch
|
|
|
790
788
|
* OR returns a promise
|
|
791
789
|
* @param options - Options for the fetch call
|
|
792
790
|
*/
|
|
793
|
-
update(deletions, insertions, callback, secondTry) {
|
|
794
|
-
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
791
|
+
update(deletions, insertions, callback, secondTry, options = {}) {
|
|
795
792
|
if (!callback) {
|
|
796
793
|
var thisUpdater = this;
|
|
797
794
|
return new Promise(function (resolve, reject) {
|
|
@@ -934,8 +931,7 @@ _:patch
|
|
|
934
931
|
callback(undefined, false, 'Exception in update: ' + e + '\n' + Util.stackString(e));
|
|
935
932
|
}
|
|
936
933
|
}
|
|
937
|
-
updateDav(doc, ds, is, callbackFunction) {
|
|
938
|
-
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
934
|
+
updateDav(doc, ds, is, callbackFunction, options = {}) {
|
|
939
935
|
let kb = this.store;
|
|
940
936
|
// The code below is derived from Kenny's UpdateCenter.js
|
|
941
937
|
var request = kb.any(doc, this.ns.link('request'));
|
|
@@ -992,8 +988,7 @@ _:patch
|
|
|
992
988
|
* @param callbackFunction
|
|
993
989
|
* @param options
|
|
994
990
|
*/
|
|
995
|
-
updateLocalFile(doc, ds, is, callbackFunction) {
|
|
996
|
-
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
991
|
+
updateLocalFile(doc, ds, is, callbackFunction, options = {}) {
|
|
997
992
|
const kb = this.store;
|
|
998
993
|
// console.log('Writing back to local file\n')
|
|
999
994
|
|
package/lib/utils.js
CHANGED
|
@@ -89,8 +89,7 @@ function arrayToStatements(rdfFactory, subject, data) {
|
|
|
89
89
|
}, subject);
|
|
90
90
|
return statements;
|
|
91
91
|
}
|
|
92
|
-
function ArrayIndexOf(arr, item) {
|
|
93
|
-
let i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
92
|
+
function ArrayIndexOf(arr, item, i = 0) {
|
|
94
93
|
var length = arr.length;
|
|
95
94
|
if (i < 0) i = length + i;
|
|
96
95
|
for (; i < length; i++) {
|