@startinblox/core 2.0.0-beta.14 → 2.0.0-beta.16

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.
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { l as isUrlOrRelativePath, a as doesResourceContainList } from "./helpers-D3zLqB4z.js";
4
+ import { m as mergeContexts, n as normalizeContext, l as isUrlOrRelativePath, o as jsonldContextParserExports, q as getRawContext, a as doesResourceContainList } from "./helpers-DEGtolur.js";
5
5
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
6
6
  function getDefaultExportFromCjs(x) {
7
7
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -30,1244 +30,6 @@ function getAugmentedNamespace(n) {
30
30
  });
31
31
  return a;
32
32
  }
33
- var jsonldContextParser = {};
34
- var ContextParser$2 = {};
35
- var g = typeof globalThis !== "undefined" && globalThis || typeof self !== "undefined" && self || // eslint-disable-next-line no-undef
36
- typeof global !== "undefined" && global || {};
37
- var support = {
38
- searchParams: "URLSearchParams" in g,
39
- iterable: "Symbol" in g && "iterator" in Symbol,
40
- blob: "FileReader" in g && "Blob" in g && function() {
41
- try {
42
- new Blob();
43
- return true;
44
- } catch (e) {
45
- return false;
46
- }
47
- }(),
48
- formData: "FormData" in g,
49
- arrayBuffer: "ArrayBuffer" in g
50
- };
51
- function isDataView(obj) {
52
- return obj && DataView.prototype.isPrototypeOf(obj);
53
- }
54
- if (support.arrayBuffer) {
55
- var viewClasses = [
56
- "[object Int8Array]",
57
- "[object Uint8Array]",
58
- "[object Uint8ClampedArray]",
59
- "[object Int16Array]",
60
- "[object Uint16Array]",
61
- "[object Int32Array]",
62
- "[object Uint32Array]",
63
- "[object Float32Array]",
64
- "[object Float64Array]"
65
- ];
66
- var isArrayBufferView = ArrayBuffer.isView || function(obj) {
67
- return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
68
- };
69
- }
70
- function normalizeName(name) {
71
- if (typeof name !== "string") {
72
- name = String(name);
73
- }
74
- if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
75
- throw new TypeError('Invalid character in header field name: "' + name + '"');
76
- }
77
- return name.toLowerCase();
78
- }
79
- function normalizeValue(value) {
80
- if (typeof value !== "string") {
81
- value = String(value);
82
- }
83
- return value;
84
- }
85
- function iteratorFor(items) {
86
- var iterator2 = {
87
- next: function() {
88
- var value = items.shift();
89
- return { done: value === void 0, value };
90
- }
91
- };
92
- if (support.iterable) {
93
- iterator2[Symbol.iterator] = function() {
94
- return iterator2;
95
- };
96
- }
97
- return iterator2;
98
- }
99
- function Headers$1(headers) {
100
- this.map = {};
101
- if (headers instanceof Headers$1) {
102
- headers.forEach(function(value, name) {
103
- this.append(name, value);
104
- }, this);
105
- } else if (Array.isArray(headers)) {
106
- headers.forEach(function(header) {
107
- if (header.length != 2) {
108
- throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + header.length);
109
- }
110
- this.append(header[0], header[1]);
111
- }, this);
112
- } else if (headers) {
113
- Object.getOwnPropertyNames(headers).forEach(function(name) {
114
- this.append(name, headers[name]);
115
- }, this);
116
- }
117
- }
118
- Headers$1.prototype.append = function(name, value) {
119
- name = normalizeName(name);
120
- value = normalizeValue(value);
121
- var oldValue = this.map[name];
122
- this.map[name] = oldValue ? oldValue + ", " + value : value;
123
- };
124
- Headers$1.prototype["delete"] = function(name) {
125
- delete this.map[normalizeName(name)];
126
- };
127
- Headers$1.prototype.get = function(name) {
128
- name = normalizeName(name);
129
- return this.has(name) ? this.map[name] : null;
130
- };
131
- Headers$1.prototype.has = function(name) {
132
- return this.map.hasOwnProperty(normalizeName(name));
133
- };
134
- Headers$1.prototype.set = function(name, value) {
135
- this.map[normalizeName(name)] = normalizeValue(value);
136
- };
137
- Headers$1.prototype.forEach = function(callback, thisArg) {
138
- for (var name in this.map) {
139
- if (this.map.hasOwnProperty(name)) {
140
- callback.call(thisArg, this.map[name], name, this);
141
- }
142
- }
143
- };
144
- Headers$1.prototype.keys = function() {
145
- var items = [];
146
- this.forEach(function(value, name) {
147
- items.push(name);
148
- });
149
- return iteratorFor(items);
150
- };
151
- Headers$1.prototype.values = function() {
152
- var items = [];
153
- this.forEach(function(value) {
154
- items.push(value);
155
- });
156
- return iteratorFor(items);
157
- };
158
- Headers$1.prototype.entries = function() {
159
- var items = [];
160
- this.forEach(function(value, name) {
161
- items.push([name, value]);
162
- });
163
- return iteratorFor(items);
164
- };
165
- if (support.iterable) {
166
- Headers$1.prototype[Symbol.iterator] = Headers$1.prototype.entries;
167
- }
168
- function consumed(body) {
169
- if (body._noBody) return;
170
- if (body.bodyUsed) {
171
- return Promise.reject(new TypeError("Already read"));
172
- }
173
- body.bodyUsed = true;
174
- }
175
- function fileReaderReady(reader) {
176
- return new Promise(function(resolve, reject) {
177
- reader.onload = function() {
178
- resolve(reader.result);
179
- };
180
- reader.onerror = function() {
181
- reject(reader.error);
182
- };
183
- });
184
- }
185
- function readBlobAsArrayBuffer(blob) {
186
- var reader = new FileReader();
187
- var promise = fileReaderReady(reader);
188
- reader.readAsArrayBuffer(blob);
189
- return promise;
190
- }
191
- function readBlobAsText(blob) {
192
- var reader = new FileReader();
193
- var promise = fileReaderReady(reader);
194
- var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
195
- var encoding = match ? match[1] : "utf-8";
196
- reader.readAsText(blob, encoding);
197
- return promise;
198
- }
199
- function readArrayBufferAsText(buf) {
200
- var view = new Uint8Array(buf);
201
- var chars = new Array(view.length);
202
- for (var i = 0; i < view.length; i++) {
203
- chars[i] = String.fromCharCode(view[i]);
204
- }
205
- return chars.join("");
206
- }
207
- function bufferClone(buf) {
208
- if (buf.slice) {
209
- return buf.slice(0);
210
- } else {
211
- var view = new Uint8Array(buf.byteLength);
212
- view.set(new Uint8Array(buf));
213
- return view.buffer;
214
- }
215
- }
216
- function Body() {
217
- this.bodyUsed = false;
218
- this._initBody = function(body) {
219
- this.bodyUsed = this.bodyUsed;
220
- this._bodyInit = body;
221
- if (!body) {
222
- this._noBody = true;
223
- this._bodyText = "";
224
- } else if (typeof body === "string") {
225
- this._bodyText = body;
226
- } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
227
- this._bodyBlob = body;
228
- } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
229
- this._bodyFormData = body;
230
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
231
- this._bodyText = body.toString();
232
- } else if (support.arrayBuffer && support.blob && isDataView(body)) {
233
- this._bodyArrayBuffer = bufferClone(body.buffer);
234
- this._bodyInit = new Blob([this._bodyArrayBuffer]);
235
- } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
236
- this._bodyArrayBuffer = bufferClone(body);
237
- } else {
238
- this._bodyText = body = Object.prototype.toString.call(body);
239
- }
240
- if (!this.headers.get("content-type")) {
241
- if (typeof body === "string") {
242
- this.headers.set("content-type", "text/plain;charset=UTF-8");
243
- } else if (this._bodyBlob && this._bodyBlob.type) {
244
- this.headers.set("content-type", this._bodyBlob.type);
245
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
246
- this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
247
- }
248
- }
249
- };
250
- if (support.blob) {
251
- this.blob = function() {
252
- var rejected = consumed(this);
253
- if (rejected) {
254
- return rejected;
255
- }
256
- if (this._bodyBlob) {
257
- return Promise.resolve(this._bodyBlob);
258
- } else if (this._bodyArrayBuffer) {
259
- return Promise.resolve(new Blob([this._bodyArrayBuffer]));
260
- } else if (this._bodyFormData) {
261
- throw new Error("could not read FormData body as blob");
262
- } else {
263
- return Promise.resolve(new Blob([this._bodyText]));
264
- }
265
- };
266
- }
267
- this.arrayBuffer = function() {
268
- if (this._bodyArrayBuffer) {
269
- var isConsumed = consumed(this);
270
- if (isConsumed) {
271
- return isConsumed;
272
- } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
273
- return Promise.resolve(
274
- this._bodyArrayBuffer.buffer.slice(
275
- this._bodyArrayBuffer.byteOffset,
276
- this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
277
- )
278
- );
279
- } else {
280
- return Promise.resolve(this._bodyArrayBuffer);
281
- }
282
- } else if (support.blob) {
283
- return this.blob().then(readBlobAsArrayBuffer);
284
- } else {
285
- throw new Error("could not read as ArrayBuffer");
286
- }
287
- };
288
- this.text = function() {
289
- var rejected = consumed(this);
290
- if (rejected) {
291
- return rejected;
292
- }
293
- if (this._bodyBlob) {
294
- return readBlobAsText(this._bodyBlob);
295
- } else if (this._bodyArrayBuffer) {
296
- return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
297
- } else if (this._bodyFormData) {
298
- throw new Error("could not read FormData body as text");
299
- } else {
300
- return Promise.resolve(this._bodyText);
301
- }
302
- };
303
- if (support.formData) {
304
- this.formData = function() {
305
- return this.text().then(decode);
306
- };
307
- }
308
- this.json = function() {
309
- return this.text().then(JSON.parse);
310
- };
311
- return this;
312
- }
313
- var methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
314
- function normalizeMethod(method) {
315
- var upcased = method.toUpperCase();
316
- return methods.indexOf(upcased) > -1 ? upcased : method;
317
- }
318
- function Request(input, options) {
319
- if (!(this instanceof Request)) {
320
- throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
321
- }
322
- options = options || {};
323
- var body = options.body;
324
- if (input instanceof Request) {
325
- if (input.bodyUsed) {
326
- throw new TypeError("Already read");
327
- }
328
- this.url = input.url;
329
- this.credentials = input.credentials;
330
- if (!options.headers) {
331
- this.headers = new Headers$1(input.headers);
332
- }
333
- this.method = input.method;
334
- this.mode = input.mode;
335
- this.signal = input.signal;
336
- if (!body && input._bodyInit != null) {
337
- body = input._bodyInit;
338
- input.bodyUsed = true;
339
- }
340
- } else {
341
- this.url = String(input);
342
- }
343
- this.credentials = options.credentials || this.credentials || "same-origin";
344
- if (options.headers || !this.headers) {
345
- this.headers = new Headers$1(options.headers);
346
- }
347
- this.method = normalizeMethod(options.method || this.method || "GET");
348
- this.mode = options.mode || this.mode || null;
349
- this.signal = options.signal || this.signal || function() {
350
- if ("AbortController" in g) {
351
- var ctrl = new AbortController();
352
- return ctrl.signal;
353
- }
354
- }();
355
- this.referrer = null;
356
- if ((this.method === "GET" || this.method === "HEAD") && body) {
357
- throw new TypeError("Body not allowed for GET or HEAD requests");
358
- }
359
- this._initBody(body);
360
- if (this.method === "GET" || this.method === "HEAD") {
361
- if (options.cache === "no-store" || options.cache === "no-cache") {
362
- var reParamSearch = /([?&])_=[^&]*/;
363
- if (reParamSearch.test(this.url)) {
364
- this.url = this.url.replace(reParamSearch, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
365
- } else {
366
- var reQueryString = /\?/;
367
- this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
368
- }
369
- }
370
- }
371
- }
372
- Request.prototype.clone = function() {
373
- return new Request(this, { body: this._bodyInit });
374
- };
375
- function decode(body) {
376
- var form = new FormData();
377
- body.trim().split("&").forEach(function(bytes) {
378
- if (bytes) {
379
- var split = bytes.split("=");
380
- var name = split.shift().replace(/\+/g, " ");
381
- var value = split.join("=").replace(/\+/g, " ");
382
- form.append(decodeURIComponent(name), decodeURIComponent(value));
383
- }
384
- });
385
- return form;
386
- }
387
- function parseHeaders(rawHeaders) {
388
- var headers = new Headers$1();
389
- var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
390
- preProcessedHeaders.split("\r").map(function(header) {
391
- return header.indexOf("\n") === 0 ? header.substr(1, header.length) : header;
392
- }).forEach(function(line) {
393
- var parts = line.split(":");
394
- var key = parts.shift().trim();
395
- if (key) {
396
- var value = parts.join(":").trim();
397
- try {
398
- headers.append(key, value);
399
- } catch (error) {
400
- console.warn("Response " + error.message);
401
- }
402
- }
403
- });
404
- return headers;
405
- }
406
- Body.call(Request.prototype);
407
- function Response(bodyInit, options) {
408
- if (!(this instanceof Response)) {
409
- throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
410
- }
411
- if (!options) {
412
- options = {};
413
- }
414
- this.type = "default";
415
- this.status = options.status === void 0 ? 200 : options.status;
416
- if (this.status < 200 || this.status > 599) {
417
- throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
418
- }
419
- this.ok = this.status >= 200 && this.status < 300;
420
- this.statusText = options.statusText === void 0 ? "" : "" + options.statusText;
421
- this.headers = new Headers$1(options.headers);
422
- this.url = options.url || "";
423
- this._initBody(bodyInit);
424
- }
425
- Body.call(Response.prototype);
426
- Response.prototype.clone = function() {
427
- return new Response(this._bodyInit, {
428
- status: this.status,
429
- statusText: this.statusText,
430
- headers: new Headers$1(this.headers),
431
- url: this.url
432
- });
433
- };
434
- Response.error = function() {
435
- var response = new Response(null, { status: 200, statusText: "" });
436
- response.status = 0;
437
- response.type = "error";
438
- return response;
439
- };
440
- var redirectStatuses = [301, 302, 303, 307, 308];
441
- Response.redirect = function(url2, status) {
442
- if (redirectStatuses.indexOf(status) === -1) {
443
- throw new RangeError("Invalid status code");
444
- }
445
- return new Response(null, { status, headers: { location: url2 } });
446
- };
447
- var DOMException = g.DOMException;
448
- try {
449
- new DOMException();
450
- } catch (err) {
451
- DOMException = function(message, name) {
452
- this.message = message;
453
- this.name = name;
454
- var error = Error(message);
455
- this.stack = error.stack;
456
- };
457
- DOMException.prototype = Object.create(Error.prototype);
458
- DOMException.prototype.constructor = DOMException;
459
- }
460
- function fetch$1(input, init) {
461
- return new Promise(function(resolve, reject) {
462
- var request = new Request(input, init);
463
- if (request.signal && request.signal.aborted) {
464
- return reject(new DOMException("Aborted", "AbortError"));
465
- }
466
- var xhr2 = new XMLHttpRequest();
467
- function abortXhr() {
468
- xhr2.abort();
469
- }
470
- xhr2.onload = function() {
471
- var options = {
472
- status: xhr2.status,
473
- statusText: xhr2.statusText,
474
- headers: parseHeaders(xhr2.getAllResponseHeaders() || "")
475
- };
476
- options.url = "responseURL" in xhr2 ? xhr2.responseURL : options.headers.get("X-Request-URL");
477
- var body = "response" in xhr2 ? xhr2.response : xhr2.responseText;
478
- setTimeout(function() {
479
- resolve(new Response(body, options));
480
- }, 0);
481
- };
482
- xhr2.onerror = function() {
483
- setTimeout(function() {
484
- reject(new TypeError("Network request failed"));
485
- }, 0);
486
- };
487
- xhr2.ontimeout = function() {
488
- setTimeout(function() {
489
- reject(new TypeError("Network request failed"));
490
- }, 0);
491
- };
492
- xhr2.onabort = function() {
493
- setTimeout(function() {
494
- reject(new DOMException("Aborted", "AbortError"));
495
- }, 0);
496
- };
497
- function fixUrl(url2) {
498
- try {
499
- return url2 === "" && g.location.href ? g.location.href : url2;
500
- } catch (e) {
501
- return url2;
502
- }
503
- }
504
- xhr2.open(request.method, fixUrl(request.url), true);
505
- if (request.credentials === "include") {
506
- xhr2.withCredentials = true;
507
- } else if (request.credentials === "omit") {
508
- xhr2.withCredentials = false;
509
- }
510
- if ("responseType" in xhr2) {
511
- if (support.blob) {
512
- xhr2.responseType = "blob";
513
- } else if (support.arrayBuffer) {
514
- xhr2.responseType = "arraybuffer";
515
- }
516
- }
517
- if (init && typeof init.headers === "object" && !(init.headers instanceof Headers$1 || g.Headers && init.headers instanceof g.Headers)) {
518
- var names = [];
519
- Object.getOwnPropertyNames(init.headers).forEach(function(name) {
520
- names.push(normalizeName(name));
521
- xhr2.setRequestHeader(name, normalizeValue(init.headers[name]));
522
- });
523
- request.headers.forEach(function(value, name) {
524
- if (names.indexOf(name) === -1) {
525
- xhr2.setRequestHeader(name, value);
526
- }
527
- });
528
- } else {
529
- request.headers.forEach(function(value, name) {
530
- xhr2.setRequestHeader(name, value);
531
- });
532
- }
533
- if (request.signal) {
534
- request.signal.addEventListener("abort", abortXhr);
535
- xhr2.onreadystatechange = function() {
536
- if (xhr2.readyState === 4) {
537
- request.signal.removeEventListener("abort", abortXhr);
538
- }
539
- };
540
- }
541
- xhr2.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit);
542
- });
543
- }
544
- fetch$1.polyfill = true;
545
- if (!g.fetch) {
546
- g.fetch = fetch$1;
547
- g.Headers = Headers$1;
548
- g.Request = Request;
549
- g.Response = Response;
550
- }
551
- var fetchNpmBrowserify;
552
- var hasRequiredFetchNpmBrowserify;
553
- function requireFetchNpmBrowserify() {
554
- if (hasRequiredFetchNpmBrowserify) return fetchNpmBrowserify;
555
- hasRequiredFetchNpmBrowserify = 1;
556
- fetchNpmBrowserify = self.fetch.bind(self);
557
- return fetchNpmBrowserify;
558
- }
559
- var relativeToAbsoluteIri = {};
560
- var Resolve = {};
561
- var hasRequiredResolve;
562
- function requireResolve() {
563
- if (hasRequiredResolve) return Resolve;
564
- hasRequiredResolve = 1;
565
- Object.defineProperty(Resolve, "__esModule", { value: true });
566
- Resolve.removeDotSegmentsOfPath = Resolve.removeDotSegments = Resolve.resolve = void 0;
567
- function resolve(relativeIRI, baseIRI) {
568
- baseIRI = baseIRI || "";
569
- const baseFragmentPos = baseIRI.indexOf("#");
570
- if (baseFragmentPos > 0) {
571
- baseIRI = baseIRI.substr(0, baseFragmentPos);
572
- }
573
- if (!relativeIRI.length) {
574
- if (baseIRI.indexOf(":") < 0) {
575
- throw new Error(`Found invalid baseIRI '${baseIRI}' for value '${relativeIRI}'`);
576
- }
577
- return baseIRI;
578
- }
579
- if (relativeIRI.startsWith("?")) {
580
- const baseQueryPos = baseIRI.indexOf("?");
581
- if (baseQueryPos > 0) {
582
- baseIRI = baseIRI.substr(0, baseQueryPos);
583
- }
584
- return baseIRI + relativeIRI;
585
- }
586
- if (relativeIRI.startsWith("#")) {
587
- return baseIRI + relativeIRI;
588
- }
589
- if (!baseIRI.length) {
590
- const relativeColonPos = relativeIRI.indexOf(":");
591
- if (relativeColonPos < 0) {
592
- throw new Error(`Found invalid relative IRI '${relativeIRI}' for a missing baseIRI`);
593
- }
594
- return removeDotSegmentsOfPath(relativeIRI, relativeColonPos);
595
- }
596
- const valueColonPos = relativeIRI.indexOf(":");
597
- if (valueColonPos >= 0) {
598
- return removeDotSegmentsOfPath(relativeIRI, valueColonPos);
599
- }
600
- const baseColonPos = baseIRI.indexOf(":");
601
- if (baseColonPos < 0) {
602
- throw new Error(`Found invalid baseIRI '${baseIRI}' for value '${relativeIRI}'`);
603
- }
604
- const baseIRIScheme = baseIRI.substr(0, baseColonPos + 1);
605
- if (relativeIRI.indexOf("//") === 0) {
606
- return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
607
- }
608
- let baseSlashAfterColonPos;
609
- if (baseIRI.indexOf("//", baseColonPos) === baseColonPos + 1) {
610
- baseSlashAfterColonPos = baseIRI.indexOf("/", baseColonPos + 3);
611
- if (baseSlashAfterColonPos < 0) {
612
- if (baseIRI.length > baseColonPos + 3) {
613
- return baseIRI + "/" + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
614
- } else {
615
- return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
616
- }
617
- }
618
- } else {
619
- baseSlashAfterColonPos = baseIRI.indexOf("/", baseColonPos + 1);
620
- if (baseSlashAfterColonPos < 0) {
621
- return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos);
622
- }
623
- }
624
- if (relativeIRI.indexOf("/") === 0) {
625
- return baseIRI.substr(0, baseSlashAfterColonPos) + removeDotSegments(relativeIRI);
626
- }
627
- let baseIRIPath = baseIRI.substr(baseSlashAfterColonPos);
628
- const baseIRILastSlashPos = baseIRIPath.lastIndexOf("/");
629
- if (baseIRILastSlashPos >= 0 && baseIRILastSlashPos < baseIRIPath.length - 1) {
630
- baseIRIPath = baseIRIPath.substr(0, baseIRILastSlashPos + 1);
631
- if (relativeIRI[0] === "." && relativeIRI[1] !== "." && relativeIRI[1] !== "/" && relativeIRI[2]) {
632
- relativeIRI = relativeIRI.substr(1);
633
- }
634
- }
635
- relativeIRI = baseIRIPath + relativeIRI;
636
- relativeIRI = removeDotSegments(relativeIRI);
637
- return baseIRI.substr(0, baseSlashAfterColonPos) + relativeIRI;
638
- }
639
- Resolve.resolve = resolve;
640
- function removeDotSegments(path) {
641
- const segmentBuffers = [];
642
- let i = 0;
643
- while (i < path.length) {
644
- switch (path[i]) {
645
- case "/":
646
- if (path[i + 1] === ".") {
647
- if (path[i + 2] === ".") {
648
- if (!isCharacterAllowedAfterRelativePathSegment(path[i + 3])) {
649
- segmentBuffers.push([]);
650
- i++;
651
- break;
652
- }
653
- segmentBuffers.pop();
654
- if (!path[i + 3]) {
655
- segmentBuffers.push([]);
656
- }
657
- i += 3;
658
- } else {
659
- if (!isCharacterAllowedAfterRelativePathSegment(path[i + 2])) {
660
- segmentBuffers.push([]);
661
- i++;
662
- break;
663
- }
664
- if (!path[i + 2]) {
665
- segmentBuffers.push([]);
666
- }
667
- i += 2;
668
- }
669
- } else {
670
- segmentBuffers.push([]);
671
- i++;
672
- }
673
- break;
674
- case "#":
675
- case "?":
676
- if (!segmentBuffers.length) {
677
- segmentBuffers.push([]);
678
- }
679
- segmentBuffers[segmentBuffers.length - 1].push(path.substr(i));
680
- i = path.length;
681
- break;
682
- default:
683
- if (!segmentBuffers.length) {
684
- segmentBuffers.push([]);
685
- }
686
- segmentBuffers[segmentBuffers.length - 1].push(path[i]);
687
- i++;
688
- break;
689
- }
690
- }
691
- return "/" + segmentBuffers.map((buffer) => buffer.join("")).join("/");
692
- }
693
- Resolve.removeDotSegments = removeDotSegments;
694
- function removeDotSegmentsOfPath(iri, colonPosition) {
695
- let searchOffset = colonPosition + 1;
696
- if (colonPosition >= 0) {
697
- if (iri[colonPosition + 1] === "/" && iri[colonPosition + 2] === "/") {
698
- searchOffset = colonPosition + 3;
699
- }
700
- } else {
701
- if (iri[0] === "/" && iri[1] === "/") {
702
- searchOffset = 2;
703
- }
704
- }
705
- const pathSeparator = iri.indexOf("/", searchOffset);
706
- if (pathSeparator < 0) {
707
- return iri;
708
- }
709
- const base = iri.substr(0, pathSeparator);
710
- const path = iri.substr(pathSeparator);
711
- return base + removeDotSegments(path);
712
- }
713
- Resolve.removeDotSegmentsOfPath = removeDotSegmentsOfPath;
714
- function isCharacterAllowedAfterRelativePathSegment(character) {
715
- return !character || character === "#" || character === "?" || character === "/";
716
- }
717
- return Resolve;
718
- }
719
- var hasRequiredRelativeToAbsoluteIri;
720
- function requireRelativeToAbsoluteIri() {
721
- if (hasRequiredRelativeToAbsoluteIri) return relativeToAbsoluteIri;
722
- hasRequiredRelativeToAbsoluteIri = 1;
723
- (function(exports) {
724
- var __createBinding = relativeToAbsoluteIri && relativeToAbsoluteIri.__createBinding || (Object.create ? function(o, m, k, k2) {
725
- if (k2 === void 0) k2 = k;
726
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
727
- return m[k];
728
- } });
729
- } : function(o, m, k, k2) {
730
- if (k2 === void 0) k2 = k;
731
- o[k2] = m[k];
732
- });
733
- var __exportStar = relativeToAbsoluteIri && relativeToAbsoluteIri.__exportStar || function(m, exports2) {
734
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
735
- };
736
- Object.defineProperty(exports, "__esModule", { value: true });
737
- __exportStar(requireResolve(), exports);
738
- })(relativeToAbsoluteIri);
739
- return relativeToAbsoluteIri;
740
- }
741
- var FetchDocumentLoader = {};
742
- var hasRequiredFetchDocumentLoader;
743
- function requireFetchDocumentLoader() {
744
- if (hasRequiredFetchDocumentLoader) return FetchDocumentLoader;
745
- hasRequiredFetchDocumentLoader = 1;
746
- var __awaiter = FetchDocumentLoader && FetchDocumentLoader.__awaiter || function(thisArg, _arguments, P, generator) {
747
- return new (P || (P = Promise))(function(resolve, reject) {
748
- function fulfilled(value) {
749
- try {
750
- step(generator.next(value));
751
- } catch (e) {
752
- reject(e);
753
- }
754
- }
755
- function rejected(value) {
756
- try {
757
- step(generator["throw"](value));
758
- } catch (e) {
759
- reject(e);
760
- }
761
- }
762
- function step(result) {
763
- result.done ? resolve(result.value) : new P(function(resolve2) {
764
- resolve2(result.value);
765
- }).then(fulfilled, rejected);
766
- }
767
- step((generator = generator.apply(thisArg, _arguments || [])).next());
768
- });
769
- };
770
- Object.defineProperty(FetchDocumentLoader, "__esModule", { value: true });
771
- requireFetchNpmBrowserify();
772
- let FetchDocumentLoader$1 = class FetchDocumentLoader {
773
- load(url2) {
774
- return __awaiter(this, void 0, void 0, function* () {
775
- const response = yield fetch(url2, { headers: { accept: "application/ld+json" } });
776
- if (response.ok) {
777
- return yield response.json();
778
- } else {
779
- throw new Error(`No valid context was found at ${url2}: ${response.statusText}`);
780
- }
781
- });
782
- }
783
- };
784
- FetchDocumentLoader.FetchDocumentLoader = FetchDocumentLoader$1;
785
- return FetchDocumentLoader;
786
- }
787
- var hasRequiredContextParser;
788
- function requireContextParser() {
789
- if (hasRequiredContextParser) return ContextParser$2;
790
- hasRequiredContextParser = 1;
791
- var __awaiter = ContextParser$2 && ContextParser$2.__awaiter || function(thisArg, _arguments, P, generator) {
792
- return new (P || (P = Promise))(function(resolve, reject) {
793
- function fulfilled(value) {
794
- try {
795
- step(generator.next(value));
796
- } catch (e) {
797
- reject(e);
798
- }
799
- }
800
- function rejected(value) {
801
- try {
802
- step(generator["throw"](value));
803
- } catch (e) {
804
- reject(e);
805
- }
806
- }
807
- function step(result) {
808
- result.done ? resolve(result.value) : new P(function(resolve2) {
809
- resolve2(result.value);
810
- }).then(fulfilled, rejected);
811
- }
812
- step((generator = generator.apply(thisArg, _arguments || [])).next());
813
- });
814
- };
815
- Object.defineProperty(ContextParser$2, "__esModule", { value: true });
816
- requireFetchNpmBrowserify();
817
- const relative_to_absolute_iri_1 = requireRelativeToAbsoluteIri();
818
- const FetchDocumentLoader_1 = requireFetchDocumentLoader();
819
- class ContextParser2 {
820
- constructor(options) {
821
- options = options || {};
822
- this.documentLoader = options.documentLoader || new FetchDocumentLoader_1.FetchDocumentLoader();
823
- this.documentCache = {};
824
- this.validate = !options.skipValidation;
825
- this.expandContentTypeToBase = options.expandContentTypeToBase;
826
- }
827
- /**
828
- * Check if the given term is a valid compact IRI.
829
- * Otherwise, it may be an IRI.
830
- * @param {string} term A term.
831
- * @return {boolean} If it is a compact IRI.
832
- */
833
- static isCompactIri(term) {
834
- return term.indexOf(":") >= 0 && !(term && term[0] === "#");
835
- }
836
- /**
837
- * Get the prefix from the given term.
838
- * @see https://json-ld.org/spec/latest/json-ld/#compact-iris
839
- * @param {string} term A term that is an URL or a prefixed URL.
840
- * @param {IJsonLdContextNormalized} context A context.
841
- * @return {string} The prefix or null.
842
- */
843
- static getPrefix(term, context2) {
844
- if (term && term[0] === "#") {
845
- return null;
846
- }
847
- const separatorPos = term.indexOf(":");
848
- if (separatorPos >= 0) {
849
- if (term.length > separatorPos + 1 && term.charAt(separatorPos + 1) === "/" && term.charAt(separatorPos + 2) === "/") {
850
- return null;
851
- }
852
- const prefix = term.substr(0, separatorPos);
853
- if (prefix === "_") {
854
- return null;
855
- }
856
- if (context2[prefix]) {
857
- return prefix;
858
- }
859
- }
860
- return null;
861
- }
862
- /**
863
- * From a given context entry value, get the string value, or the @id field.
864
- * @param contextValue A value for a term in a context.
865
- * @return {string} The id value, or null.
866
- */
867
- static getContextValueId(contextValue) {
868
- if (contextValue === null || typeof contextValue === "string") {
869
- return contextValue;
870
- }
871
- const id = contextValue["@id"];
872
- return id ? id : null;
873
- }
874
- /**
875
- * Expand the term or prefix of the given term if it has one,
876
- * otherwise return the term as-is.
877
- *
878
- * This will try to expand the IRI as much as possible.
879
- *
880
- * Iff in vocab-mode, then other references to other terms in the context can be used,
881
- * such as to `myTerm`:
882
- * ```
883
- * {
884
- * "myTerm": "http://example.org/myLongTerm"
885
- * }
886
- * ```
887
- *
888
- * @param {string} term A term that is an URL or a prefixed URL.
889
- * @param {IJsonLdContextNormalized} context A context.
890
- * @param {boolean} vocab If the term is a predicate or type and should be expanded based on @vocab,
891
- * otherwise it is considered a regular term that is expanded based on @base.
892
- * @return {string} The expanded term, the term as-is, or null if it was explicitly disabled in the context.
893
- */
894
- static expandTerm(term, context2, vocab) {
895
- ContextParser2.assertNormalized(context2);
896
- const contextValue = context2[term];
897
- if (contextValue === null || contextValue && contextValue["@id"] === null) {
898
- return null;
899
- }
900
- if (contextValue && vocab) {
901
- const value = this.getContextValueId(contextValue);
902
- if (value && value !== term) {
903
- return value;
904
- }
905
- }
906
- const prefix = ContextParser2.getPrefix(term, context2);
907
- if (prefix) {
908
- const value = this.getContextValueId(context2[prefix]);
909
- if (value) {
910
- return value + term.substr(prefix.length + 1);
911
- }
912
- } else if (vocab && context2["@vocab"] && term.charAt(0) !== "@" && !ContextParser2.isCompactIri(term)) {
913
- return context2["@vocab"] + term;
914
- } else if (!vocab && context2["@base"] && term.charAt(0) !== "@" && !ContextParser2.isCompactIri(term)) {
915
- return relative_to_absolute_iri_1.resolve(term, context2["@base"]);
916
- }
917
- return term;
918
- }
919
- /**
920
- * Compact the given term using @base, @vocab, an aliased term, or a prefixed term.
921
- *
922
- * This will try to compact the IRI as much as possible.
923
- *
924
- * @param {string} iri An IRI to compact.
925
- * @param {IJsonLdContextNormalized} context The context to compact with.
926
- * @param {boolean} vocab If the term is a predicate or type and should be compacted based on @vocab,
927
- * otherwise it is considered a regular term that is compacted based on @base.
928
- * @return {string} The compacted term or the IRI as-is.
929
- */
930
- static compactIri(iri, context2, vocab) {
931
- ContextParser2.assertNormalized(context2);
932
- if (vocab && context2["@vocab"] && iri.startsWith(context2["@vocab"])) {
933
- return iri.substr(context2["@vocab"].length);
934
- }
935
- if (!vocab && context2["@base"] && iri.startsWith(context2["@base"])) {
936
- return iri.substr(context2["@base"].length);
937
- }
938
- const shortestPrefixing = { prefix: "", suffix: iri };
939
- for (const key in context2) {
940
- const value = context2[key];
941
- if (value && !key.startsWith("@")) {
942
- const contextIri = this.getContextValueId(value);
943
- if (iri.startsWith(contextIri)) {
944
- const suffix = iri.substr(contextIri.length);
945
- if (!suffix) {
946
- if (vocab) {
947
- return key;
948
- }
949
- } else if (suffix.length < shortestPrefixing.suffix.length) {
950
- shortestPrefixing.prefix = key;
951
- shortestPrefixing.suffix = suffix;
952
- }
953
- }
954
- }
955
- }
956
- if (shortestPrefixing.prefix) {
957
- return shortestPrefixing.prefix + ":" + shortestPrefixing.suffix;
958
- }
959
- return iri;
960
- }
961
- /**
962
- * An an assert to check if the given context has been normalized.
963
- * An error will be thrown otherwise.
964
- * @param {JsonLdContext} context A context.
965
- */
966
- static assertNormalized(context2) {
967
- if (typeof context2 === "string" || Array.isArray(context2) || context2["@context"]) {
968
- throw new Error("The given context is not normalized. Make sure to call ContextParser.parse() first.");
969
- }
970
- }
971
- /**
972
- * Check if the given context value can be a prefix value.
973
- * @param value A context value.
974
- * @return {boolean} If it can be a prefix value.
975
- */
976
- static isPrefixValue(value) {
977
- return value && (typeof value === "string" || value["@id"] || value["@type"]);
978
- }
979
- /**
980
- * Check if the given IRI is valid.
981
- * @param {string} iri A potential IRI.
982
- * @return {boolean} If the given IRI is valid.
983
- */
984
- static isValidIri(iri) {
985
- return ContextParser2.IRI_REGEX.test(iri);
986
- }
987
- /**
988
- * Add an @id term for all @reverse terms.
989
- * @param {IJsonLdContextNormalized} context A context.
990
- * @return {IJsonLdContextNormalized} The mutated input context.
991
- */
992
- static idifyReverseTerms(context2) {
993
- for (const key of Object.keys(context2)) {
994
- const value = context2[key];
995
- if (value && typeof value === "object") {
996
- if (value["@reverse"] && !value["@id"]) {
997
- if (typeof value["@reverse"] !== "string") {
998
- throw new Error(`Invalid @reverse value: '${value["@reverse"]}'`);
999
- }
1000
- value["@id"] = value["@reverse"];
1001
- value["@reverse"] = true;
1002
- }
1003
- }
1004
- }
1005
- return context2;
1006
- }
1007
- /**
1008
- * Expand all prefixed terms in the given context.
1009
- * @param {IJsonLdContextNormalized} context A context.
1010
- * @param {boolean} expandContentTypeToBase If @type inside the context may be expanded
1011
- * via @base if @vocab is set to null.
1012
- * @return {IJsonLdContextNormalized} The mutated input context.
1013
- */
1014
- static expandPrefixedTerms(context2, expandContentTypeToBase) {
1015
- for (const key of Object.keys(context2)) {
1016
- if (ContextParser2.EXPAND_KEYS_BLACKLIST.indexOf(key) < 0) {
1017
- if (key[0] === "@" && ContextParser2.ALIAS_KEYS_BLACKLIST.indexOf(key) >= 0) {
1018
- throw new Error(`Keywords can not be aliased to something else.
1019
- Tried mapping ${key} to ${context2[key]}`);
1020
- }
1021
- while (ContextParser2.isPrefixValue(context2[key])) {
1022
- const value = context2[key];
1023
- let changed = false;
1024
- if (typeof value === "string") {
1025
- context2[key] = ContextParser2.expandTerm(value, context2, true);
1026
- changed = changed || value !== context2[key];
1027
- } else {
1028
- const id = value["@id"];
1029
- const type = value["@type"];
1030
- if (id) {
1031
- context2[key]["@id"] = ContextParser2.expandTerm(id, context2, true);
1032
- changed = changed || id !== context2[key]["@id"];
1033
- }
1034
- if (type && type !== "@vocab") {
1035
- context2[key]["@type"] = ContextParser2.expandTerm(type, context2, true);
1036
- if (expandContentTypeToBase && type === context2[key]["@type"]) {
1037
- context2[key]["@type"] = ContextParser2.expandTerm(type, context2, false);
1038
- }
1039
- changed = changed || type !== context2[key]["@type"];
1040
- }
1041
- }
1042
- if (!changed) {
1043
- break;
1044
- }
1045
- }
1046
- }
1047
- }
1048
- return context2;
1049
- }
1050
- /**
1051
- * Normalize the @language entries in the given context to lowercase.
1052
- * @param {IJsonLdContextNormalized} context A context.
1053
- * @return {IJsonLdContextNormalized} The mutated input context.
1054
- */
1055
- static normalize(context2) {
1056
- for (const key of Object.keys(context2)) {
1057
- if (key === "@language" && typeof context2[key] === "string") {
1058
- context2[key] = context2[key].toLowerCase();
1059
- } else {
1060
- const value = context2[key];
1061
- if (value && typeof value === "object") {
1062
- if (typeof value["@language"] === "string") {
1063
- value["@language"] = value["@language"].toLowerCase();
1064
- }
1065
- }
1066
- }
1067
- }
1068
- return context2;
1069
- }
1070
- /**
1071
- * Validate the entries of the given context.
1072
- * @param {IJsonLdContextNormalized} context A context.
1073
- */
1074
- static validate(context2) {
1075
- for (const key of Object.keys(context2)) {
1076
- const value = context2[key];
1077
- const valueType = typeof value;
1078
- if (key[0] === "@") {
1079
- switch (key.substr(1)) {
1080
- case "vocab":
1081
- if (value !== null && valueType !== "string") {
1082
- throw new Error(`Found an invalid @vocab IRI: ${value}`);
1083
- }
1084
- break;
1085
- case "base":
1086
- if (value !== null && valueType !== "string") {
1087
- throw new Error(`Found an invalid @base IRI: ${context2[key]}`);
1088
- }
1089
- break;
1090
- case "language":
1091
- if (value !== null && valueType !== "string") {
1092
- throw new Error(`Found an invalid @language string: ${value}`);
1093
- }
1094
- break;
1095
- }
1096
- }
1097
- if (value !== null) {
1098
- switch (valueType) {
1099
- case "string":
1100
- break;
1101
- case "object":
1102
- if (!ContextParser2.isCompactIri(key) && !("@id" in value) && (value["@type"] === "@id" ? !context2["@base"] : !context2["@vocab"])) {
1103
- throw new Error(`Missing @id in context entry: '${key}': '${JSON.stringify(value)}'`);
1104
- }
1105
- for (const objectKey of Object.keys(value)) {
1106
- const objectValue = value[objectKey];
1107
- if (!objectValue) {
1108
- continue;
1109
- }
1110
- switch (objectKey) {
1111
- case "@id":
1112
- if (objectValue[0] === "@" && objectValue !== "@type" && objectValue !== "@id") {
1113
- throw new Error(`Illegal keyword alias in term value, found: '${key}': '${JSON.stringify(value)}'`);
1114
- }
1115
- break;
1116
- case "@type":
1117
- if (objectValue !== "@id" && objectValue !== "@vocab" && (objectValue[0] === "_" || !ContextParser2.isValidIri(objectValue))) {
1118
- throw new Error(`A context @type must be an absolute IRI, found: '${key}': '${objectValue}'`);
1119
- }
1120
- break;
1121
- case "@reverse":
1122
- if (typeof objectValue === "string" && value["@id"] && value["@id"] !== objectValue) {
1123
- throw new Error(`Found non-matching @id and @reverse term values in '${key}':'${objectValue}' and '${value["@id"]}'`);
1124
- }
1125
- break;
1126
- case "@container":
1127
- if (objectValue === "@list" && value["@reverse"]) {
1128
- throw new Error(`Term value can not be @container: @list and @reverse at the same time on '${key}'`);
1129
- }
1130
- if (ContextParser2.CONTAINERS.indexOf(objectValue) < 0) {
1131
- throw new Error(`Invalid term @container for '${key}' ('${objectValue}'), must be one of ${ContextParser2.CONTAINERS.join(", ")}`);
1132
- }
1133
- break;
1134
- case "@language":
1135
- if (objectValue !== null && typeof objectValue !== "string") {
1136
- throw new Error(`Found an invalid term @language string in: '${key}': '${JSON.stringify(value)}'`);
1137
- }
1138
- break;
1139
- }
1140
- }
1141
- break;
1142
- default:
1143
- throw new Error(`Found an invalid term value: '${key}': '${value}'`);
1144
- }
1145
- }
1146
- }
1147
- }
1148
- /**
1149
- * Resolve relative context IRIs, or return full IRIs as-is.
1150
- * @param {string} contextIri A context IRI.
1151
- * @param {string} baseIri A base IRI.
1152
- * @return {string} The normalized context IRI.
1153
- */
1154
- static normalizeContextIri(contextIri, baseIri) {
1155
- if (!ContextParser2.isValidIri(contextIri)) {
1156
- contextIri = relative_to_absolute_iri_1.resolve(contextIri, baseIri);
1157
- if (!ContextParser2.isValidIri(contextIri)) {
1158
- throw new Error(`Invalid context IRI: ${contextIri}`);
1159
- }
1160
- }
1161
- return contextIri;
1162
- }
1163
- /**
1164
- * Parse a JSON-LD context in any form.
1165
- * @param {JsonLdContext} context A context, URL to a context, or an array of contexts/URLs.
1166
- * @param {IParseOptions} options Optional parsing options.
1167
- * @return {Promise<IJsonLdContextNormalized>} A promise resolving to the context.
1168
- */
1169
- parse(context2, { baseIri, parentContext, external } = {}) {
1170
- return __awaiter(this, void 0, void 0, function* () {
1171
- if (context2 === null || context2 === void 0) {
1172
- return baseIri ? { "@base": baseIri } : {};
1173
- } else if (typeof context2 === "string") {
1174
- return this.parse(yield this.load(ContextParser2.normalizeContextIri(context2, baseIri)), { baseIri, parentContext, external: true });
1175
- } else if (Array.isArray(context2)) {
1176
- const contexts = yield Promise.all(context2.map((subContext) => {
1177
- if (typeof subContext === "string") {
1178
- return this.load(ContextParser2.normalizeContextIri(subContext, baseIri));
1179
- } else {
1180
- return subContext;
1181
- }
1182
- }));
1183
- return contexts.reduce((accContextPromise, contextEntry) => accContextPromise.then((accContext) => this.parse(contextEntry, {
1184
- baseIri: accContext && accContext["@base"] || baseIri,
1185
- external,
1186
- parentContext: accContext
1187
- })), Promise.resolve(parentContext));
1188
- } else if (typeof context2 === "object") {
1189
- if (context2["@context"]) {
1190
- return yield this.parse(context2["@context"], { baseIri, parentContext, external });
1191
- }
1192
- context2 = JSON.parse(JSON.stringify(context2));
1193
- let newContext = {};
1194
- if (external) {
1195
- delete context2["@base"];
1196
- }
1197
- if (baseIri) {
1198
- if (!("@base" in context2)) {
1199
- context2["@base"] = baseIri;
1200
- } else if (context2["@base"] !== null && !ContextParser2.isValidIri(context2["@base"])) {
1201
- context2["@base"] = relative_to_absolute_iri_1.resolve(context2["@base"], baseIri);
1202
- }
1203
- }
1204
- newContext = Object.assign({}, newContext, parentContext, context2);
1205
- ContextParser2.idifyReverseTerms(newContext);
1206
- ContextParser2.expandPrefixedTerms(newContext, this.expandContentTypeToBase);
1207
- ContextParser2.normalize(newContext);
1208
- if (this.validate) {
1209
- ContextParser2.validate(newContext);
1210
- }
1211
- return newContext;
1212
- } else {
1213
- throw new Error(`Tried parsing a context that is not a string, array or object, but got ${context2}`);
1214
- }
1215
- });
1216
- }
1217
- load(url2) {
1218
- return __awaiter(this, void 0, void 0, function* () {
1219
- const cached = this.documentCache[url2];
1220
- if (cached) {
1221
- return Array.isArray(cached) ? cached.slice() : Object.assign({}, cached);
1222
- }
1223
- return this.documentCache[url2] = (yield this.documentLoader.load(url2))["@context"];
1224
- });
1225
- }
1226
- }
1227
- ContextParser2.IRI_REGEX = /^([A-Za-z][A-Za-z0-9+-.]*|_):[^ "<>{}|\\\[\]`]*$/;
1228
- ContextParser2.EXPAND_KEYS_BLACKLIST = [
1229
- "@base",
1230
- "@vocab",
1231
- "@language"
1232
- ];
1233
- ContextParser2.ALIAS_KEYS_BLACKLIST = [
1234
- "@container",
1235
- "@graph",
1236
- "@id",
1237
- "@index",
1238
- "@list",
1239
- "@nest",
1240
- "@none",
1241
- "@prefix",
1242
- "@reverse",
1243
- "@set",
1244
- "@type",
1245
- "@value"
1246
- ];
1247
- ContextParser2.CONTAINERS = [
1248
- "@list",
1249
- "@set",
1250
- "@index",
1251
- "@language"
1252
- ];
1253
- ContextParser$2.ContextParser = ContextParser2;
1254
- return ContextParser$2;
1255
- }
1256
- var hasRequiredJsonldContextParser;
1257
- function requireJsonldContextParser() {
1258
- if (hasRequiredJsonldContextParser) return jsonldContextParser;
1259
- hasRequiredJsonldContextParser = 1;
1260
- (function(exports) {
1261
- function __export(m) {
1262
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
1263
- }
1264
- Object.defineProperty(exports, "__esModule", { value: true });
1265
- __export(requireContextParser());
1266
- __export(requireFetchDocumentLoader());
1267
- })(jsonldContextParser);
1268
- return jsonldContextParser;
1269
- }
1270
- var jsonldContextParserExports = requireJsonldContextParser();
1271
33
  function formatAttributesToServerPaginationOptions(elementAttributes) {
1272
34
  const attributes = new Map(
1273
35
  Array.from(elementAttributes).map(({ name, value }) => [name, value])
@@ -2003,7 +765,7 @@ function requireNQuads$1() {
2003
765
  *
2004
766
  * @return {string} the N-Quad.
2005
767
  */
2006
- static serializeQuadComponents(s, p, o, g2) {
768
+ static serializeQuadComponents(s, p, o, g) {
2007
769
  let nquad = "";
2008
770
  if (s.termType === TYPE_NAMED_NODE) {
2009
771
  nquad += `<${s.value}>`;
@@ -2025,10 +787,10 @@ function requireNQuads$1() {
2025
787
  nquad += `^^<${o.datatype.value}>`;
2026
788
  }
2027
789
  }
2028
- if (g2.termType === TYPE_NAMED_NODE) {
2029
- nquad += ` <${g2.value}>`;
2030
- } else if (g2.termType === TYPE_BLANK_NODE) {
2031
- nquad += ` ${g2.value}`;
790
+ if (g.termType === TYPE_NAMED_NODE) {
791
+ nquad += ` <${g.value}>`;
792
+ } else if (g.termType === TYPE_BLANK_NODE) {
793
+ nquad += ` ${g.value}`;
2032
794
  }
2033
795
  nquad += " .\n";
2034
796
  return nquad;
@@ -10043,7 +8805,6 @@ function requireJsonld() {
10043
8805
  }
10044
8806
  var jsonldExports = requireJsonld();
10045
8807
  const jsonld = /* @__PURE__ */ getDefaultExportFromCjs(jsonldExports);
10046
- const ContextParser$1 = jsonldContextParserExports.ContextParser;
10047
8808
  class CustomGetter {
10048
8809
  // search attributes to give to server
10049
8810
  constructor(resourceId, resource, clientContext, serverContext, parentId = "", serverPagination = {}, serverSearch = {}) {
@@ -10075,7 +8836,7 @@ class CustomGetter {
10075
8836
  this.getExpandedPredicate("ldp:DirectContainer"),
10076
8837
  this.getExpandedPredicate("ldp:IndirectContainer"),
10077
8838
  this.getExpandedPredicate("sib:federatedContainer")
10078
- ];
8839
+ ].filter(Boolean);
10079
8840
  }
10080
8841
  /**
10081
8842
  * Get the property of a resource for a given path
@@ -10131,14 +8892,14 @@ class CustomGetter {
10131
8892
  if (!value || !value["@id"]) return this.getLiteralValue(value);
10132
8893
  return await this.getResource(
10133
8894
  value["@id"],
10134
- { ...this.clientContext, ...this.serverContext },
8895
+ mergeContexts(this.clientContext, this.serverContext),
10135
8896
  this.parentId || this.resourceId
10136
8897
  );
10137
8898
  }
10138
8899
  if (!value || !value["@id"]) return void 0;
10139
8900
  const resource = await this.getResource(
10140
8901
  value["@id"],
10141
- { ...this.clientContext, ...this.serverContext },
8902
+ mergeContexts(this.clientContext, this.serverContext),
10142
8903
  this.parentId || this.resourceId
10143
8904
  );
10144
8905
  store.subscribeResourceTo(this.resourceId, value["@id"]);
@@ -10221,7 +8982,10 @@ class CustomGetter {
10221
8982
  getList(predicateName) {
10222
8983
  let value = this.resource[predicateName];
10223
8984
  if (!value) {
10224
- value = this.resource[this.getExpandedPredicate(predicateName)];
8985
+ const index = this.getExpandedPredicate(predicateName);
8986
+ if (index) {
8987
+ value = this.resource[index];
8988
+ }
10225
8989
  }
10226
8990
  if (value === void 0 || value === null) {
10227
8991
  return [];
@@ -10320,24 +9084,22 @@ class CustomGetter {
10320
9084
  store.clearCache(this.resourceId);
10321
9085
  }
10322
9086
  getExpandedPredicate(property) {
10323
- return ContextParser$1.expandTerm(
10324
- property,
10325
- { ...this.clientContext, ...this.serverContext },
10326
- true
9087
+ const context2 = normalizeContext(
9088
+ mergeContexts(this.clientContext, this.serverContext)
10327
9089
  );
9090
+ return context2.expandTerm(property, true);
10328
9091
  }
10329
9092
  getCompactedPredicate(property) {
10330
- return ContextParser$1.compactIri(
10331
- property,
10332
- { ...this.clientContext, ...this.serverContext },
10333
- true
9093
+ const context2 = normalizeContext(
9094
+ mergeContexts(this.clientContext, this.serverContext)
10334
9095
  );
9096
+ return context2.compactIri(property, true);
10335
9097
  }
10336
9098
  getCompactedIri(id) {
10337
- return ContextParser$1.compactIri(id, {
10338
- ...this.clientContext,
10339
- ...this.serverContext
10340
- });
9099
+ const context2 = normalizeContext(
9100
+ mergeContexts(this.clientContext, this.serverContext)
9101
+ );
9102
+ return context2.compactIri(id);
10341
9103
  }
10342
9104
  toString() {
10343
9105
  return this.getCompactedIri(this.resource["@id"]);
@@ -10521,8 +9283,6 @@ class CacheManager {
10521
9283
  return false;
10522
9284
  }
10523
9285
  }
10524
- const ContextParser = jsonldContextParserExports.ContextParser;
10525
- const myParser = new ContextParser();
10526
9286
  const base_context = {
10527
9287
  "@vocab": "https://cdn.startinblox.com/owl#",
10528
9288
  foaf: "http://xmlns.com/foaf/0.1/",
@@ -10535,7 +9295,7 @@ const base_context = {
10535
9295
  acl: "http://www.w3.org/ns/auth/acl#",
10536
9296
  hd: "http://cdn.startinblox.com/owl/ttl/vocab.ttl#",
10537
9297
  sib: "http://cdn.startinblox.com/owl/ttl/vocab.ttl#",
10538
- dcat: "https://www.w3.org/ns/dcat#",
9298
+ dcat: "https://www.w3.org/ns/dcat3.jsonld#",
10539
9299
  name: "rdfs:label",
10540
9300
  deadline: "xsd:dateTime",
10541
9301
  lat: "geo:lat",
@@ -10560,6 +9320,7 @@ class Store {
10560
9320
  __publicField(this, "headers");
10561
9321
  __publicField(this, "fetch");
10562
9322
  __publicField(this, "session");
9323
+ __publicField(this, "contextParser");
10563
9324
  __publicField(this, "resolveResource", (id, resolve) => {
10564
9325
  const handler = (event) => {
10565
9326
  if (event.detail.id === id) {
@@ -10585,6 +9346,7 @@ class Store {
10585
9346
  };
10586
9347
  this.fetch = this.storeOptions.fetchMethod;
10587
9348
  this.session = this.storeOptions.session;
9349
+ this.contextParser = new jsonldContextParserExports.ContextParser();
10588
9350
  }
10589
9351
  /**
10590
9352
  * Fetch data and cache it
@@ -10601,7 +9363,7 @@ class Store {
10601
9363
  *
10602
9364
  * @async
10603
9365
  */
10604
- async getData(id, context2 = {}, parentId = "", localData, forceFetch = false, serverPagination, serverSearch) {
9366
+ async getData(id, context2 = [], parentId = "", localData, forceFetch = false, serverPagination, serverSearch) {
10605
9367
  var _a;
10606
9368
  let key = id;
10607
9369
  if (serverPagination) {
@@ -10621,7 +9383,9 @@ class Store {
10621
9383
  );
10622
9384
  if (this.loadingList.has(key)) return;
10623
9385
  this.loadingList.add(key);
10624
- const clientContext = await myParser.parse(context2);
9386
+ const clientContext = await this.contextParser.parse(
9387
+ getRawContext(context2)
9388
+ );
10625
9389
  let resource = null;
10626
9390
  if (this._isLocalId(id)) {
10627
9391
  if (localData == null) localData = {};
@@ -10648,7 +9412,7 @@ class Store {
10648
9412
  );
10649
9413
  return;
10650
9414
  }
10651
- const serverContext = await myParser.parse([
9415
+ const serverContext = await this.contextParser.parse([
10652
9416
  resource["@context"] || base_context
10653
9417
  ]);
10654
9418
  await this.cacheGraph(
@@ -10690,7 +9454,7 @@ class Store {
10690
9454
  * @param serverSearch - Server search query params
10691
9455
  * @returns data in json
10692
9456
  */
10693
- async fetchData(id, context2 = {}, parentId = "", serverPagination, serverSearch) {
9457
+ async fetchData(id, context2 = null, parentId = "", serverPagination, serverSearch) {
10694
9458
  let iri = this._getAbsoluteIri(id, context2, parentId);
10695
9459
  if (serverPagination)
10696
9460
  iri = appendServerPaginationToIri(iri, serverPagination);
@@ -10785,7 +9549,7 @@ class Store {
10785
9549
  credentials: "include"
10786
9550
  });
10787
9551
  const resourceProxy = store.get(id);
10788
- const clientContext = resourceProxy ? { ...resourceProxy.clientContext, ...resource["@context"] } : resource["@context"];
9552
+ const clientContext = resourceProxy ? mergeContexts(resourceProxy.clientContext, resource["@context"]) : resource["@context"];
10789
9553
  this.clearCache(id);
10790
9554
  await this.getData(id, clientContext, "", resource);
10791
9555
  return { ok: true };
@@ -10811,8 +9575,11 @@ class Store {
10811
9575
  async _updateResource(method, resource, id) {
10812
9576
  if (!["POST", "PUT", "PATCH", "_LOCAL"].includes(method))
10813
9577
  throw new Error("Error: method not allowed");
10814
- const context2 = await myParser.parse([resource["@context"] || {}]);
9578
+ const context2 = await this.contextParser.parse([
9579
+ resource["@context"] || {}
9580
+ ]);
10815
9581
  const expandedId = this._getExpandedId(id, context2);
9582
+ if (!expandedId) return null;
10816
9583
  return this._fetch(method, resource, id).then(async (response) => {
10817
9584
  var _a;
10818
9585
  if (response.ok) {
@@ -10968,8 +9735,9 @@ class Store {
10968
9735
  *
10969
9736
  * @returns id of the deleted resource
10970
9737
  */
10971
- async delete(id, context2 = {}) {
9738
+ async delete(id, context2 = null) {
10972
9739
  const expandedId = this._getExpandedId(id, context2);
9740
+ if (!expandedId) return null;
10973
9741
  const deleted = await this.fetchAuthn(expandedId, {
10974
9742
  method: "DELETE",
10975
9743
  headers: this.headers,
@@ -10995,7 +9763,8 @@ class Store {
10995
9763
  return headers;
10996
9764
  }
10997
9765
  _getExpandedId(id, context2) {
10998
- return context2 && Object.keys(context2) ? ContextParser.expandTerm(id, context2) : id;
9766
+ if (!context2 || Object.keys(context2).length === 0) return id;
9767
+ return normalizeContext(context2).expandTerm(id);
10999
9768
  }
11000
9769
  /**
11001
9770
  * Returns the expanded predicate based on provided context or the base one.
@@ -11004,8 +9773,7 @@ class Store {
11004
9773
  * @returns The fully expanded term
11005
9774
  */
11006
9775
  getExpandedPredicate(property, context2) {
11007
- if (!context2) return ContextParser.expandTerm(property, base_context, true);
11008
- return ContextParser.expandTerm(property, context2, true);
9776
+ return normalizeContext(context2, base_context).expandTerm(property, true);
11009
9777
  }
11010
9778
  /**
11011
9779
  * Returns the compacted IRI based on provided context or the base one.
@@ -11014,8 +9782,7 @@ class Store {
11014
9782
  * @returns The compacted term
11015
9783
  */
11016
9784
  getCompactedIri(property, context2) {
11017
- if (!context2) return ContextParser.compactIri(property, base_context, true);
11018
- return ContextParser.compactIri(property, context2, true);
9785
+ return normalizeContext(context2, base_context).compactIri(property, true);
11019
9786
  }
11020
9787
  /**
11021
9788
  * Check if the id is a local id
@@ -11054,7 +9821,8 @@ class Store {
11054
9821
  * @param parentId
11055
9822
  */
11056
9823
  _getAbsoluteIri(id, context2, parentId) {
11057
- let iri = ContextParser.expandTerm(id, context2);
9824
+ let iri = normalizeContext(context2, base_context).expandTerm(id);
9825
+ if (!iri) return "";
11058
9826
  if (parentId && !parentId.startsWith("store://local")) {
11059
9827
  const parentIri = new URL(parentId, document.location.href).href;
11060
9828
  iri = new URL(iri, parentIri).href;
@@ -11105,7 +9873,6 @@ export {
11105
9873
  commonjsGlobal as c,
11106
9874
  formatAttributesToServerPaginationOptions as f,
11107
9875
  getDefaultExportFromCjs as g,
11108
- jsonldContextParserExports as j,
11109
9876
  mergeServerSearchOptions as m,
11110
9877
  store as s
11111
9878
  };