rdflib 2.3.0 → 2.3.1-07daeac2
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/README.md +30 -0
- 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/n3parser.js +45 -9
- package/esm/parse.js +1 -3
- package/esm/serialize.js +4 -2
- package/esm/serializer.js +49 -19
- 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/factories/rdflib-data-factory.js +1 -3
- package/lib/fetcher.js +9 -15
- package/lib/formula.js +2 -11
- package/lib/n3parser.js +45 -9
- package/lib/parse.js +1 -3
- package/lib/serialize.js +4 -2
- package/lib/serializer.d.ts +14 -8
- package/lib/serializer.js +49 -19
- 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.js +1 -2
- package/package.json +30 -27
- package/src/n3parser.js +46 -17
- package/src/serialize.ts +4 -2
- package/src/serializer.js +54 -24
- 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/n3parser.js
CHANGED
|
@@ -183,9 +183,19 @@ var ws = new RegExp("^[ \\t]*", 'g');
|
|
|
183
183
|
var signed_integer = new RegExp("^[-+]?[0-9]+", 'g');
|
|
184
184
|
var number_syntax = new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?([eE][-+]?[0-9]+)?", 'g');
|
|
185
185
|
var datetime_syntax = new RegExp('^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](T[0-9][0-9]:[0-9][0-9](:[0-9][0-9](\\.[0-9]*)?)?)?Z?');
|
|
186
|
+
|
|
187
|
+
// Reused in tight loops to detect whitespace or comment after a dot
|
|
188
|
+
var wsOrHash = new RegExp("[\\s#]");
|
|
186
189
|
var digitstring = new RegExp("^[0-9]+", 'g');
|
|
187
190
|
var interesting = new RegExp("[\\\\\\r\\n\\\"]", 'g');
|
|
188
191
|
var langcode = new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*", 'g');
|
|
192
|
+
|
|
193
|
+
// Returns true when a dot at position i should terminate a name,
|
|
194
|
+
// i.e., when the next character is whitespace, a comment start, or EOF
|
|
195
|
+
function dotTerminatesName(str, i) {
|
|
196
|
+
var next = str.charAt(i + 1);
|
|
197
|
+
return next === '' || wsOrHash.test(next);
|
|
198
|
+
}
|
|
189
199
|
function createSinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) {
|
|
190
200
|
return new SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why);
|
|
191
201
|
}
|
|
@@ -674,6 +684,16 @@ export class SinkParser {
|
|
|
674
684
|
if (j < 0) {
|
|
675
685
|
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when ']' expected after [ <propertyList>");
|
|
676
686
|
}
|
|
687
|
+
if (str.slice(j, j + 1) == ".") {
|
|
688
|
+
// If a dot is found after a blank node, treat it as a statement terminator.
|
|
689
|
+
// Do NOT consume the '.' here: statement terminators are handled centrally by
|
|
690
|
+
// checkDot() (called by directiveOrStatement after statement()). Consuming the dot
|
|
691
|
+
// locally would bypass that unified logic and could cause inconsistencies.
|
|
692
|
+
// We do consume ']' below because it is a structural closer of the blank node,
|
|
693
|
+
// not a statement terminator.
|
|
694
|
+
res.push(subj);
|
|
695
|
+
return j; // leave '.' for checkDot()
|
|
696
|
+
}
|
|
677
697
|
if (str.slice(j, j + 1) != "]") {
|
|
678
698
|
throw BadSyntax(this._thisDoc, this.lines, str, j, "']' expected");
|
|
679
699
|
}
|
|
@@ -1122,7 +1142,17 @@ export class SinkParser {
|
|
|
1122
1142
|
return -1;
|
|
1123
1143
|
}
|
|
1124
1144
|
var i = j;
|
|
1125
|
-
while (i < pyjslib_len(str)
|
|
1145
|
+
while (i < pyjslib_len(str)) {
|
|
1146
|
+
var c = str.charAt(i);
|
|
1147
|
+
if (c === '.') {
|
|
1148
|
+
if (dotTerminatesName(str, i)) {
|
|
1149
|
+
break; // treat as statement terminator, not part of name
|
|
1150
|
+
}
|
|
1151
|
+
// else: accept '.' as part of name
|
|
1152
|
+
} else if (_notNameChars.indexOf(c) >= 0) {
|
|
1153
|
+
// Other invalid characters terminate the name
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1126
1156
|
var i = i + 1;
|
|
1127
1157
|
}
|
|
1128
1158
|
res.push(str.slice(j, i));
|
|
@@ -1148,12 +1178,15 @@ export class SinkParser {
|
|
|
1148
1178
|
var i = i + 1;
|
|
1149
1179
|
while (i < pyjslib_len(str)) {
|
|
1150
1180
|
var c = str.charAt(i);
|
|
1151
|
-
if (
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1181
|
+
if (c === '.') {
|
|
1182
|
+
if (dotTerminatesName(str, i)) {
|
|
1183
|
+
break; // dot ends the name here
|
|
1184
|
+
}
|
|
1185
|
+
} else if (_notNameChars.indexOf(c) >= 0) {
|
|
1155
1186
|
break;
|
|
1156
1187
|
}
|
|
1188
|
+
var ln = ln + c;
|
|
1189
|
+
var i = i + 1;
|
|
1157
1190
|
}
|
|
1158
1191
|
} else {
|
|
1159
1192
|
var ln = "";
|
|
@@ -1164,12 +1197,15 @@ export class SinkParser {
|
|
|
1164
1197
|
var ln = "";
|
|
1165
1198
|
while (i < pyjslib_len(str)) {
|
|
1166
1199
|
var c = str.charAt(i);
|
|
1167
|
-
if (
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1200
|
+
if (c === '.') {
|
|
1201
|
+
if (dotTerminatesName(str, i)) {
|
|
1202
|
+
break; // dot ends the name here
|
|
1203
|
+
}
|
|
1204
|
+
} else if (_notNameChars.indexOf(c) >= 0) {
|
|
1171
1205
|
break;
|
|
1172
1206
|
}
|
|
1207
|
+
var ln = ln + c;
|
|
1208
|
+
var i = i + 1;
|
|
1173
1209
|
}
|
|
1174
1210
|
res.push(new pyjslib_Tuple([pfx, ln]));
|
|
1175
1211
|
return i;
|
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/serialize.js
CHANGED
|
@@ -40,7 +40,8 @@ contentType, callback, options) {
|
|
|
40
40
|
return executeCallback(null, documentString);
|
|
41
41
|
case TurtleContentType:
|
|
42
42
|
case TurtleLegacyContentType:
|
|
43
|
-
|
|
43
|
+
// Suppress = for sameAs and => for implies; preserve any user-specified flags (e.g., 'o')
|
|
44
|
+
sz.setFlags('si' + (opts.flags ? ' ' + opts.flags : ''));
|
|
44
45
|
documentString = sz.statementsToN3(newSts);
|
|
45
46
|
return executeCallback(null, documentString);
|
|
46
47
|
case NTriplesContentType:
|
|
@@ -48,7 +49,8 @@ contentType, callback, options) {
|
|
|
48
49
|
documentString = sz.statementsToNTriples(newSts);
|
|
49
50
|
return executeCallback(null, documentString);
|
|
50
51
|
case JSONLDContentType:
|
|
51
|
-
|
|
52
|
+
// turtle + dr (means no default, no relative prefix); preserve user flags
|
|
53
|
+
sz.setFlags('si dr' + (opts.flags ? ' ' + opts.flags : ''));
|
|
52
54
|
documentString = sz.statementsToJsonld(newSts); // convert via turtle
|
|
53
55
|
return executeCallback(null, documentString);
|
|
54
56
|
case NQuadsContentType:
|
package/esm/serializer.js
CHANGED
|
@@ -6,21 +6,20 @@ 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
|
}
|
|
20
18
|
;
|
|
21
19
|
export class Serializer {
|
|
22
20
|
constructor(store) {
|
|
23
|
-
_defineProperty(this, "_notQNameChars", '\t\r\n !"#$%&\'()
|
|
21
|
+
_defineProperty(this, "_notQNameChars", '\t\r\n !"#$%&\'()*,+/;<=>?@[\\]^`{|}~');
|
|
22
|
+
// issue#228
|
|
24
23
|
_defineProperty(this, "_notNameChars", this._notQNameChars + ':');
|
|
25
24
|
// stringToN3: String escaping for N3
|
|
26
25
|
_defineProperty(this, "validPrefix", new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/));
|
|
@@ -42,7 +41,7 @@ export class Serializer {
|
|
|
42
41
|
|
|
43
42
|
this.namespacesUsed = []; // Count actually used and so needed in @prefixes
|
|
44
43
|
this.keywords = ['a']; // The only one we generate at the moment
|
|
45
|
-
this.prefixchars = '
|
|
44
|
+
this.prefixchars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
46
45
|
this.incoming = null; // Array not calculated yet
|
|
47
46
|
this.formulas = []; // remembering original formulae from hashes
|
|
48
47
|
this.store = store;
|
|
@@ -53,6 +52,13 @@ export class Serializer {
|
|
|
53
52
|
this.base = base;
|
|
54
53
|
return this;
|
|
55
54
|
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Set serializer behavior flags. Letters can be combined with spaces.
|
|
58
|
+
* Examples: 'si', 'deinprstux', 'si dr', 'o'.
|
|
59
|
+
* Notable flags:
|
|
60
|
+
* - 'o': do not abbreviate to a prefixed name when the local part contains a dot
|
|
61
|
+
*/
|
|
56
62
|
setFlags(flags) {
|
|
57
63
|
this.flags = flags || '';
|
|
58
64
|
return this;
|
|
@@ -162,7 +168,7 @@ export class Serializer {
|
|
|
162
168
|
if (slash >= 0) p = p.slice(slash + 1);
|
|
163
169
|
var i = 0;
|
|
164
170
|
while (i < p.length) {
|
|
165
|
-
if (this.prefixchars.indexOf(p[i])) {
|
|
171
|
+
if (this.prefixchars.indexOf(p[i]) >= 0) {
|
|
166
172
|
i++;
|
|
167
173
|
} else {
|
|
168
174
|
break;
|
|
@@ -243,6 +249,28 @@ export class Serializer {
|
|
|
243
249
|
toN3(f) {
|
|
244
250
|
return this.statementsToN3(f.statements);
|
|
245
251
|
}
|
|
252
|
+
// Validate if a string is a valid PN_LOCAL per Turtle 1.1 spec
|
|
253
|
+
// Allows dots inside the local name but not as trailing character
|
|
254
|
+
// Also allows empty local names (for URIs ending in / or #)
|
|
255
|
+
isValidPNLocal(local) {
|
|
256
|
+
// Empty local name is valid (e.g., ex: for http://example.com/)
|
|
257
|
+
if (local.length === 0) return true;
|
|
258
|
+
|
|
259
|
+
// Cannot end with a dot
|
|
260
|
+
if (local[local.length - 1] === '.') return false;
|
|
261
|
+
|
|
262
|
+
// Check each character (allow dots mid-string)
|
|
263
|
+
for (var i = 0; i < local.length; i++) {
|
|
264
|
+
var ch = local[i];
|
|
265
|
+
// Dot is allowed unless it's the last character (checked above)
|
|
266
|
+
if (ch === '.') continue;
|
|
267
|
+
// Other characters must not be in the blacklist
|
|
268
|
+
if (this._notNameChars.indexOf(ch) >= 0) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
246
274
|
explicitURI(uri) {
|
|
247
275
|
if (this.flags.indexOf('r') < 0 && this.base) {
|
|
248
276
|
uri = Uri.refTo(this.base, uri);
|
|
@@ -605,13 +633,17 @@ export class Serializer {
|
|
|
605
633
|
if (j >= 0 && this.flags.indexOf('p') < 0 && (
|
|
606
634
|
// Can split at namespace but only if http[s]: URI or file: or ws[s] (why not others?)
|
|
607
635
|
uri.indexOf('http') === 0 || uri.indexOf('ws') === 0 || uri.indexOf('file') === 0)) {
|
|
608
|
-
var
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
636
|
+
var localid = uri.slice(j + 1);
|
|
637
|
+
var namesp = uri.slice(0, j + 1);
|
|
638
|
+
// Don't split if namespace is just the protocol (e.g., https://)
|
|
639
|
+
// A valid namespace should have content after the protocol
|
|
640
|
+
var minNamespaceLength = uri.indexOf('://') + 4; // e.g., "http://x" minimum
|
|
641
|
+
// Also don't split if namespace is the base directory (would serialize as relative URI)
|
|
642
|
+
var baseDir = this.base ? this.base.slice(0, Math.max(this.base.lastIndexOf('/'), this.base.lastIndexOf('#')) + 1) : null;
|
|
643
|
+
var namespaceIsBaseDir = baseDir && namesp === baseDir;
|
|
644
|
+
// If flag 'o' is present, forbid dots in local part when abbreviating
|
|
645
|
+
var forbidDotLocal = this.flags.indexOf('o') >= 0 && localid.indexOf('.') >= 0;
|
|
646
|
+
var canSplit = !namespaceIsBaseDir && !forbidDotLocal && namesp.length > minNamespaceLength && this.isValidPNLocal(localid);
|
|
615
647
|
/*
|
|
616
648
|
if (uri.slice(0, j + 1) === this.base + '#') { // base-relative
|
|
617
649
|
if (canSplit) {
|
|
@@ -622,8 +654,6 @@ export class Serializer {
|
|
|
622
654
|
}
|
|
623
655
|
*/
|
|
624
656
|
if (canSplit) {
|
|
625
|
-
var localid = uri.slice(j + 1);
|
|
626
|
-
var namesp = uri.slice(0, j + 1);
|
|
627
657
|
if (this.defaultNamespace && this.defaultNamespace === namesp && this.flags.indexOf('d') < 0) {
|
|
628
658
|
// d -> suppress default
|
|
629
659
|
if (this.flags.indexOf('k') >= 0 && this.keyords.indexOf(localid) < 0) {
|
|
@@ -844,7 +874,7 @@ export class Serializer {
|
|
|
844
874
|
results = results.concat(['<' + t + ' rdf:resource="' + relURI(st.object) + '"/>']);
|
|
845
875
|
break;
|
|
846
876
|
case 'Literal':
|
|
847
|
-
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 + '>']);
|
|
848
878
|
break;
|
|
849
879
|
case 'Collection':
|
|
850
880
|
results = results.concat(['<' + t + ' rdf:parseType="Collection">', collectionXMLTree(st.object, stats), '</' + t + '>']);
|
|
@@ -895,7 +925,7 @@ export class Serializer {
|
|
|
895
925
|
results = results.concat(['<' + qname(st.predicate) + ' rdf:resource="' + relURI(st.object) + '"/>']);
|
|
896
926
|
break;
|
|
897
927
|
case 'Literal':
|
|
898
|
-
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) + '>']);
|
|
899
929
|
break;
|
|
900
930
|
case 'Collection':
|
|
901
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"),
|
|
@@ -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
|
|