From 342ef4e9eb7c7fb501bcd9b48215a47f9a4feb41 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 29 Jul 2025 16:57:06 +1000 Subject: [PATCH] Complete smoke test of DFC data sharing Working within a shadow root of the web component isn't well supported by Capybara and I needed to find some workarounds. It's not pretty but it works (on my machine). *fingers crossed* --- .../can_share_data_with_another_platform.yml | 4662 ++++++++--------- .../admin/enterprises/dfc_permissions_spec.rb | 41 +- 2 files changed, 2290 insertions(+), 2413 deletions(-) diff --git a/spec/fixtures/vcr_cassettes/DFC_Permissions/can_share_data_with_another_platform.yml b/spec/fixtures/vcr_cassettes/DFC_Permissions/can_share_data_with_another_platform.yml index 31eeb8ce0e..074a041360 100644 --- a/spec/fixtures/vcr_cassettes/DFC_Permissions/can_share_data_with_another_platform.yml +++ b/spec/fixtures/vcr_cassettes/DFC_Permissions/can_share_data_with_another_platform.yml @@ -10,11 +10,11 @@ http_interactions: Connection: - close Origin: - - http://127.0.0.1:37737 + - http://127.0.0.1:34777 Sec-Ch-Ua-Platform: - '"Linux"' User-Agent: - - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/138.0.0.0 + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Sec-Ch-Ua: - '"Not)A;Brand";v="8", "Chromium";v="138"' @@ -29,7 +29,7 @@ http_interactions: Sec-Fetch-Dest: - script Referer: - - http://127.0.0.1:37737/ + - http://127.0.0.1:34777/ Accept-Encoding: - '' Accept-Language: @@ -39,16 +39,10 @@ http_interactions: code: 200 message: OK headers: - Date: - - Tue, 29 Jul 2025 04:39:23 GMT - Content-Type: - - application/javascript; charset=utf-8 - Transfer-Encoding: - - chunked Connection: - close - Cf-Ray: - - 9669eea4a8a1ca17-MEL + Content-Length: + - '58988' Access-Control-Allow-Origin: - "*" Access-Control-Expose-Headers: @@ -63,30 +57,28 @@ http_interactions: - nosniff Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload + Content-Type: + - application/javascript; charset=utf-8 X-Jsd-Version: - 3.2.2 X-Jsd-Version-Type: - version Etag: - W/"e66c-aEp9ZysNY7uIOkRFiyu/1NxBypM" + Accept-Ranges: + - bytes + Date: + - Tue, 29 Jul 2025 06:27:11 GMT + Age: + - '9553' X-Served-By: - - cache-fra-eddf8230119-FRA, cache-lga21941-LGA + - cache-fra-eddf8230119-FRA, cache-mel11235-MEL X-Cache: - - HIT, MISS + - HIT, HIT Vary: - Accept-Encoding Alt-Svc: - - h3=":443"; ma=86400 - Cf-Cache-Status: - - HIT - Age: - - '7599' - Report-To: - - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=0g0Pzpgi7hqlcZ%2B9bDw7Ogpr9Y2khGiZd6lI%2BlLaM4WsEKx04x7birCnmPguAKVLXrwe88bGKbNdXTUfPs7JwA1RYjGlyaoBgRrzc0GvdBv80tpyqnxyh5LGyXoqcQ0LJMo%3D"}],"group":"cf-nel","max_age":604800}' - Nel: - - '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}' - Server: - - cloudflare + - h3=":443";ma=86400,h3-29=":443";ma=86400,h3-27=":443";ma=86400 body: encoding: UTF-8 string: "/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: @@ -833,7 +825,7 @@ http_interactions: async (e) => ns.get(e)\n});\nwindow.getLocale = window.getLocale ? window.getLocale.push(jt) : [jt];\nwindow.setLocale = window.setLocale ? window.setLocale.push(Ot) : [Ot];\n" - recorded_at: Tue, 29 Jul 2025 04:39:23 GMT + recorded_at: Tue, 29 Jul 2025 06:27:11 GMT - request: method: get uri: https://cdn.jsdelivr.net/npm/@startinblox/core@latest/dist/index.js @@ -844,11 +836,11 @@ http_interactions: Connection: - close Origin: - - http://127.0.0.1:37737 + - http://127.0.0.1:34777 Sec-Ch-Ua-Platform: - '"Linux"' User-Agent: - - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/138.0.0.0 + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Sec-Ch-Ua: - '"Not)A;Brand";v="8", "Chromium";v="138"' @@ -863,7 +855,7 @@ http_interactions: Sec-Fetch-Dest: - script Referer: - - http://127.0.0.1:37737/ + - http://127.0.0.1:34777/ Accept-Encoding: - '' Accept-Language: @@ -873,14 +865,10 @@ http_interactions: code: 200 message: OK headers: - Date: - - Tue, 29 Jul 2025 04:39:23 GMT - Content-Type: - - application/javascript; charset=utf-8 - Transfer-Encoding: - - chunked Connection: - close + Content-Length: + - '3766416' Access-Control-Allow-Origin: - "*" Access-Control-Expose-Headers: @@ -895,32 +883,28 @@ http_interactions: - nosniff Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload + Content-Type: + - application/javascript; charset=utf-8 X-Jsd-Version: - 2.0.1 X-Jsd-Version-Type: - version Etag: - W/"397890-uVG/t1TLgZ04SMdVcWXhG0nuuJQ" + Accept-Ranges: + - bytes + Date: + - Tue, 29 Jul 2025 06:27:11 GMT + Age: + - '9552' X-Served-By: - - cache-fra-eddf8230128-FRA, cache-lga21956-LGA + - cache-fra-eddf8230128-FRA, cache-mel11268-MEL X-Cache: - - MISS, MISS + - HIT, HIT Vary: - Accept-Encoding Alt-Svc: - - h3=":443"; ma=86400 - Cf-Cache-Status: - - HIT - Age: - - '7600' - Report-To: - - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=YFJpxqm%2Byc49OvcQ1aJBo5XLGg1sOHS6SjQDws3yU4LaNGdIOBaYXxyyL5m9CkclmwlFKZHJWxkb0rsOAtIf4V8%2FKMJWoAWWGXGfVd8Zuqn2hXrPLtVYLUfY3EQKAgcO2Zo%3D"}],"group":"cf-nel","max_age":604800}' - Nel: - - '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}' - Server: - - cloudflare - Cf-Ray: - - 9669eea4ad5be697-MEL + - h3=":443";ma=86400,h3-29=":443";ma=86400,h3-27=":443";ma=86400 body: encoding: UTF-8 string: "var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, @@ -47337,10 +47321,10 @@ http_interactions: \ ValidationMixin,\n WidgetMixin,\n base_context as baseContext,\n x as html,\n o$2 as ifDefined,\n newWidgetFactory,\n B as render,\n store,\n \ o$1 as unsafeHTML,\n m as until,\n widgetFactory\n};\n" - recorded_at: Tue, 29 Jul 2025 04:39:26 GMT + recorded_at: Tue, 29 Jul 2025 06:27:13 GMT - request: method: get - uri: https://cdn.jsdelivr.net/npm/@startinblox/core@latest/dist/store-1t_BHzwg.js + uri: https://cdn.jsdelivr.net/npm/@startinblox/core@latest/dist/helpers-4GFJ8HI8.js body: encoding: UTF-8 string: '' @@ -47348,11 +47332,11 @@ http_interactions: Connection: - close Origin: - - http://127.0.0.1:37737 + - http://127.0.0.1:34777 Sec-Ch-Ua-Platform: - '"Linux"' User-Agent: - - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/138.0.0.0 + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Sec-Ch-Ua: - '"Not)A;Brand";v="8", "Chromium";v="138"' @@ -47377,14 +47361,10 @@ http_interactions: code: 200 message: OK headers: - Date: - - Tue, 29 Jul 2025 04:39:27 GMT - Content-Type: - - application/javascript; charset=utf-8 - Transfer-Encoding: - - chunked Connection: - close + Content-Length: + - '89667' Access-Control-Allow-Origin: - "*" Access-Control-Expose-Headers: @@ -47399,32 +47379,2217 @@ http_interactions: - nosniff Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload + Content-Type: + - application/javascript; charset=utf-8 + X-Jsd-Version: + - 2.0.0 + X-Jsd-Version-Type: + - version + Etag: + - W/"15e43-WgeU3/rOTachL5EAwu/6EzDk130" + Accept-Ranges: + - bytes + Date: + - Tue, 29 Jul 2025 06:27:14 GMT + Age: + - '9554' + X-Served-By: + - cache-fra-etou8220177-FRA, cache-mel11274-MEL + X-Cache: + - HIT, HIT + Vary: + - Accept-Encoding + Alt-Svc: + - h3=":443";ma=86400,h3-29=":443";ma=86400,h3-27=":443";ma=86400 + body: + encoding: UTF-8 + string: | + var __defProp = Object.defineProperty; + var __typeError = (msg) => { + throw TypeError(msg); + }; + var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; + var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); + var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); + var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)); + var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); + var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); + var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method); + var _values, _resolve, _AsyncIterableBuilder_instances, createIterable_fn, next_fn, nextPromise_fn; + var jsonldContextParser = {}; + var ContextParser = {}; + var relativeToAbsoluteIri = {}; + var Resolve = {}; + var hasRequiredResolve; + function requireResolve() { + if (hasRequiredResolve) return Resolve; + hasRequiredResolve = 1; + Object.defineProperty(Resolve, "__esModule", { value: true }); + Resolve.removeDotSegmentsOfPath = Resolve.removeDotSegments = Resolve.resolve = void 0; + function resolve(relativeIRI, baseIRI) { + baseIRI = baseIRI || ""; + const baseFragmentPos = baseIRI.indexOf("#"); + if (baseFragmentPos > 0) { + baseIRI = baseIRI.substr(0, baseFragmentPos); + } + if (!relativeIRI.length) { + if (baseIRI.indexOf(":") < 0) { + throw new Error(`Found invalid baseIRI '${baseIRI}' for value '${relativeIRI}'`); + } + return baseIRI; + } + if (relativeIRI.startsWith("?")) { + const baseQueryPos = baseIRI.indexOf("?"); + if (baseQueryPos > 0) { + baseIRI = baseIRI.substr(0, baseQueryPos); + } + return baseIRI + relativeIRI; + } + if (relativeIRI.startsWith("#")) { + return baseIRI + relativeIRI; + } + if (!baseIRI.length) { + const relativeColonPos = relativeIRI.indexOf(":"); + if (relativeColonPos < 0) { + throw new Error(`Found invalid relative IRI '${relativeIRI}' for a missing baseIRI`); + } + return removeDotSegmentsOfPath(relativeIRI, relativeColonPos); + } + const valueColonPos = relativeIRI.indexOf(":"); + if (valueColonPos >= 0) { + return removeDotSegmentsOfPath(relativeIRI, valueColonPos); + } + const baseColonPos = baseIRI.indexOf(":"); + if (baseColonPos < 0) { + throw new Error(`Found invalid baseIRI '${baseIRI}' for value '${relativeIRI}'`); + } + const baseIRIScheme = baseIRI.substr(0, baseColonPos + 1); + if (relativeIRI.indexOf("//") === 0) { + return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos); + } + let baseSlashAfterColonPos; + if (baseIRI.indexOf("//", baseColonPos) === baseColonPos + 1) { + baseSlashAfterColonPos = baseIRI.indexOf("/", baseColonPos + 3); + if (baseSlashAfterColonPos < 0) { + if (baseIRI.length > baseColonPos + 3) { + return baseIRI + "/" + removeDotSegmentsOfPath(relativeIRI, valueColonPos); + } else { + return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos); + } + } + } else { + baseSlashAfterColonPos = baseIRI.indexOf("/", baseColonPos + 1); + if (baseSlashAfterColonPos < 0) { + return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos); + } + } + if (relativeIRI.indexOf("/") === 0) { + return baseIRI.substr(0, baseSlashAfterColonPos) + removeDotSegments(relativeIRI); + } + let baseIRIPath = baseIRI.substr(baseSlashAfterColonPos); + const baseIRILastSlashPos = baseIRIPath.lastIndexOf("/"); + if (baseIRILastSlashPos >= 0 && baseIRILastSlashPos < baseIRIPath.length - 1) { + baseIRIPath = baseIRIPath.substr(0, baseIRILastSlashPos + 1); + if (relativeIRI[0] === "." && relativeIRI[1] !== "." && relativeIRI[1] !== "/" && relativeIRI[2]) { + relativeIRI = relativeIRI.substr(1); + } + } + relativeIRI = baseIRIPath + relativeIRI; + relativeIRI = removeDotSegments(relativeIRI); + return baseIRI.substr(0, baseSlashAfterColonPos) + relativeIRI; + } + Resolve.resolve = resolve; + function removeDotSegments(path) { + const segmentBuffers = []; + let i = 0; + while (i < path.length) { + switch (path[i]) { + case "/": + if (path[i + 1] === ".") { + if (path[i + 2] === ".") { + if (!isCharacterAllowedAfterRelativePathSegment(path[i + 3])) { + segmentBuffers.push([]); + i++; + break; + } + segmentBuffers.pop(); + if (!path[i + 3]) { + segmentBuffers.push([]); + } + i += 3; + } else { + if (!isCharacterAllowedAfterRelativePathSegment(path[i + 2])) { + segmentBuffers.push([]); + i++; + break; + } + if (!path[i + 2]) { + segmentBuffers.push([]); + } + i += 2; + } + } else { + segmentBuffers.push([]); + i++; + } + break; + case "#": + case "?": + if (!segmentBuffers.length) { + segmentBuffers.push([]); + } + segmentBuffers[segmentBuffers.length - 1].push(path.substr(i)); + i = path.length; + break; + default: + if (!segmentBuffers.length) { + segmentBuffers.push([]); + } + segmentBuffers[segmentBuffers.length - 1].push(path[i]); + i++; + break; + } + } + return "/" + segmentBuffers.map((buffer) => buffer.join("")).join("/"); + } + Resolve.removeDotSegments = removeDotSegments; + function removeDotSegmentsOfPath(iri, colonPosition) { + let searchOffset = colonPosition + 1; + if (colonPosition >= 0) { + if (iri[colonPosition + 1] === "/" && iri[colonPosition + 2] === "/") { + searchOffset = colonPosition + 3; + } + } else { + if (iri[0] === "/" && iri[1] === "/") { + searchOffset = 2; + } + } + const pathSeparator = iri.indexOf("/", searchOffset); + if (pathSeparator < 0) { + return iri; + } + const base = iri.substr(0, pathSeparator); + const path = iri.substr(pathSeparator); + return base + removeDotSegments(path); + } + Resolve.removeDotSegmentsOfPath = removeDotSegmentsOfPath; + function isCharacterAllowedAfterRelativePathSegment(character) { + return !character || character === "#" || character === "?" || character === "/"; + } + return Resolve; + } + var hasRequiredRelativeToAbsoluteIri; + function requireRelativeToAbsoluteIri() { + if (hasRequiredRelativeToAbsoluteIri) return relativeToAbsoluteIri; + hasRequiredRelativeToAbsoluteIri = 1; + (function(exports) { + var __createBinding = relativeToAbsoluteIri && relativeToAbsoluteIri.__createBinding || (Object.create ? function(o, m, k, k2) { + if (k2 === void 0) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { + return m[k]; + } }); + } : function(o, m, k, k2) { + if (k2 === void 0) k2 = k; + o[k2] = m[k]; + }); + var __exportStar = relativeToAbsoluteIri && relativeToAbsoluteIri.__exportStar || function(m, exports2) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + __exportStar(requireResolve(), exports); + })(relativeToAbsoluteIri); + return relativeToAbsoluteIri; + } + var ErrorCoded = {}; + var hasRequiredErrorCoded; + function requireErrorCoded() { + if (hasRequiredErrorCoded) return ErrorCoded; + hasRequiredErrorCoded = 1; + (function(exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.ERROR_CODES = exports.ErrorCoded = void 0; + class ErrorCoded2 extends Error { + /* istanbul ignore next */ + constructor(message, code) { + super(message); + this.code = code; + } + } + exports.ErrorCoded = ErrorCoded2; + (function(ERROR_CODES) { + ERROR_CODES["COLLIDING_KEYWORDS"] = "colliding keywords"; + ERROR_CODES["CONFLICTING_INDEXES"] = "conflicting indexes"; + ERROR_CODES["CYCLIC_IRI_MAPPING"] = "cyclic IRI mapping"; + ERROR_CODES["INVALID_ID_VALUE"] = "invalid @id value"; + ERROR_CODES["INVALID_INDEX_VALUE"] = "invalid @index value"; + ERROR_CODES["INVALID_NEST_VALUE"] = "invalid @nest value"; + ERROR_CODES["INVALID_PREFIX_VALUE"] = "invalid @prefix value"; + ERROR_CODES["INVALID_PROPAGATE_VALUE"] = "invalid @propagate value"; + ERROR_CODES["INVALID_REVERSE_VALUE"] = "invalid @reverse value"; + ERROR_CODES["INVALID_IMPORT_VALUE"] = "invalid @import value"; + ERROR_CODES["INVALID_VERSION_VALUE"] = "invalid @version value"; + ERROR_CODES["INVALID_BASE_IRI"] = "invalid base IRI"; + ERROR_CODES["INVALID_CONTAINER_MAPPING"] = "invalid container mapping"; + ERROR_CODES["INVALID_CONTEXT_ENTRY"] = "invalid context entry"; + ERROR_CODES["INVALID_CONTEXT_NULLIFICATION"] = "invalid context nullification"; + ERROR_CODES["INVALID_DEFAULT_LANGUAGE"] = "invalid default language"; + ERROR_CODES["INVALID_INCLUDED_VALUE"] = "invalid @included value"; + ERROR_CODES["INVALID_IRI_MAPPING"] = "invalid IRI mapping"; + ERROR_CODES["INVALID_JSON_LITERAL"] = "invalid JSON literal"; + ERROR_CODES["INVALID_KEYWORD_ALIAS"] = "invalid keyword alias"; + ERROR_CODES["INVALID_LANGUAGE_MAP_VALUE"] = "invalid language map value"; + ERROR_CODES["INVALID_LANGUAGE_MAPPING"] = "invalid language mapping"; + ERROR_CODES["INVALID_LANGUAGE_TAGGED_STRING"] = "invalid language-tagged string"; + ERROR_CODES["INVALID_LANGUAGE_TAGGED_VALUE"] = "invalid language-tagged value"; + ERROR_CODES["INVALID_LOCAL_CONTEXT"] = "invalid local context"; + ERROR_CODES["INVALID_REMOTE_CONTEXT"] = "invalid remote context"; + ERROR_CODES["INVALID_REVERSE_PROPERTY"] = "invalid reverse property"; + ERROR_CODES["INVALID_REVERSE_PROPERTY_MAP"] = "invalid reverse property map"; + ERROR_CODES["INVALID_REVERSE_PROPERTY_VALUE"] = "invalid reverse property value"; + ERROR_CODES["INVALID_SCOPED_CONTEXT"] = "invalid scoped context"; + ERROR_CODES["INVALID_SCRIPT_ELEMENT"] = "invalid script element"; + ERROR_CODES["INVALID_SET_OR_LIST_OBJECT"] = "invalid set or list object"; + ERROR_CODES["INVALID_TERM_DEFINITION"] = "invalid term definition"; + ERROR_CODES["INVALID_TYPE_MAPPING"] = "invalid type mapping"; + ERROR_CODES["INVALID_TYPE_VALUE"] = "invalid type value"; + ERROR_CODES["INVALID_TYPED_VALUE"] = "invalid typed value"; + ERROR_CODES["INVALID_VALUE_OBJECT"] = "invalid value object"; + ERROR_CODES["INVALID_VALUE_OBJECT_VALUE"] = "invalid value object value"; + ERROR_CODES["INVALID_VOCAB_MAPPING"] = "invalid vocab mapping"; + ERROR_CODES["IRI_CONFUSED_WITH_PREFIX"] = "IRI confused with prefix"; + ERROR_CODES["KEYWORD_REDEFINITION"] = "keyword redefinition"; + ERROR_CODES["LOADING_DOCUMENT_FAILED"] = "loading document failed"; + ERROR_CODES["LOADING_REMOTE_CONTEXT_FAILED"] = "loading remote context failed"; + ERROR_CODES["MULTIPLE_CONTEXT_LINK_HEADERS"] = "multiple context link headers"; + ERROR_CODES["PROCESSING_MODE_CONFLICT"] = "processing mode conflict"; + ERROR_CODES["PROTECTED_TERM_REDEFINITION"] = "protected term redefinition"; + ERROR_CODES["CONTEXT_OVERFLOW"] = "context overflow"; + ERROR_CODES["INVALID_BASE_DIRECTION"] = "invalid base direction"; + ERROR_CODES["RECURSIVE_CONTEXT_INCLUSION"] = "recursive context inclusion"; + ERROR_CODES["INVALID_STREAMING_KEY_ORDER"] = "invalid streaming key order"; + ERROR_CODES["INVALID_EMBEDDED_NODE"] = "invalid embedded node"; + ERROR_CODES["INVALID_ANNOTATION"] = "invalid annotation"; + })(exports.ERROR_CODES || (exports.ERROR_CODES = {})); + })(ErrorCoded); + return ErrorCoded; + } + var FetchDocumentLoader = {}; + var link; + var hasRequiredLink; + function requireLink() { + if (hasRequiredLink) return link; + hasRequiredLink = 1; + var COMPATIBLE_ENCODING_PATTERN = /^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i; + var WS_TRIM_PATTERN = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; + var WS_CHAR_PATTERN = /\s|\uFEFF|\xA0/; + var WS_FOLD_PATTERN = /\r?\n[\x20\x09]+/g; + var DELIMITER_PATTERN = /[;,"]/; + var WS_DELIMITER_PATTERN = /[;,"]|\s/; + var TOKEN_PATTERN = /^[!#$%&'*+\-\.^_`|~\da-zA-Z]+$/; + var STATE = { + IDLE: 1 << 0, + URI: 1 << 1, + ATTR: 1 << 2 + }; + function trim(value) { + return value.replace(WS_TRIM_PATTERN, ""); + } + function hasWhitespace(value) { + return WS_CHAR_PATTERN.test(value); + } + function skipWhitespace(value, offset) { + while (hasWhitespace(value[offset])) { + offset++; + } + return offset; + } + function needsQuotes(value) { + return WS_DELIMITER_PATTERN.test(value) || !TOKEN_PATTERN.test(value); + } + function shallowCompareObjects(object1, object2) { + return Object.keys(object1).length === Object.keys(object2).length && Object.keys(object1).every( + (key) => key in object2 && object1[key] === object2[key] + ); + } + class Link { + /** + * Link + * @constructor + * @param {String} [value] + * @returns {Link} + */ + constructor(value) { + this.refs = []; + if (value) { + this.parse(value); + } + } + /** + * Get refs with given relation type + * @param {String} value + * @returns {Array} + */ + rel(value) { + var links = []; + var type = value.toLowerCase(); + for (var i = 0; i < this.refs.length; i++) { + if (typeof this.refs[i].rel === "string" && this.refs[i].rel.toLowerCase() === type) { + links.push(this.refs[i]); + } + } + return links; + } + /** + * Get refs where given attribute has a given value + * @param {String} attr + * @param {String} value + * @returns {Array} + */ + get(attr, value) { + attr = attr.toLowerCase(); + value = value.toLowerCase(); + var links = []; + for (var i = 0; i < this.refs.length; i++) { + if (typeof this.refs[i][attr] === "string" && this.refs[i][attr].toLowerCase() === value) { + links.push(this.refs[i]); + } + } + return links; + } + /** Sets a reference. */ + set(link2) { + this.refs.push(link2); + return this; + } + /** + * Sets a reference if a reference with similar properties isn’t already set. + */ + setUnique(link2) { + if (!this.refs.some((ref) => shallowCompareObjects(ref, link2))) { + this.refs.push(link2); + } + return this; + } + has(attr, value) { + attr = attr.toLowerCase(); + value = value.toLowerCase(); + for (var i = 0; i < this.refs.length; i++) { + if (typeof this.refs[i][attr] === "string" && this.refs[i][attr].toLowerCase() === value) { + return true; + } + } + return false; + } + parse(value, offset) { + offset = offset || 0; + value = offset ? value.slice(offset) : value; + value = trim(value).replace(WS_FOLD_PATTERN, ""); + var state = STATE.IDLE; + var length = value.length; + var offset = 0; + var ref = null; + while (offset < length) { + if (state === STATE.IDLE) { + if (hasWhitespace(value[offset])) { + offset++; + continue; + } else if (value[offset] === "<") { + if (ref != null) { + ref.rel != null ? this.refs.push(...Link.expandRelations(ref)) : this.refs.push(ref); + } + var end = value.indexOf(">", offset); + if (end === -1) throw new Error("Expected end of URI delimiter at offset " + offset); + ref = { uri: value.slice(offset + 1, end) }; + offset = end; + state = STATE.URI; + } else { + throw new Error('Unexpected character "' + value[offset] + '" at offset ' + offset); + } + offset++; + } else if (state === STATE.URI) { + if (hasWhitespace(value[offset])) { + offset++; + continue; + } else if (value[offset] === ";") { + state = STATE.ATTR; + offset++; + } else if (value[offset] === ",") { + state = STATE.IDLE; + offset++; + } else { + throw new Error('Unexpected character "' + value[offset] + '" at offset ' + offset); + } + } else if (state === STATE.ATTR) { + if (value[offset] === ";" || hasWhitespace(value[offset])) { + offset++; + continue; + } + var end = value.indexOf("=", offset); + if (end === -1) end = value.indexOf(";", offset); + if (end === -1) end = value.length; + var attr = trim(value.slice(offset, end)).toLowerCase(); + var attrValue = ""; + offset = end + 1; + offset = skipWhitespace(value, offset); + if (value[offset] === '"') { + offset++; + while (offset < length) { + if (value[offset] === '"') { + offset++; + break; + } + if (value[offset] === "\\") { + offset++; + } + attrValue += value[offset]; + offset++; + } + } else { + var end = offset + 1; + while (!DELIMITER_PATTERN.test(value[end]) && end < length) { + end++; + } + attrValue = value.slice(offset, end); + offset = end; + } + if (ref[attr] && Link.isSingleOccurenceAttr(attr)) ; + else if (attr[attr.length - 1] === "*") { + ref[attr] = Link.parseExtendedValue(attrValue); + } else { + attrValue = attr === "type" ? attrValue.toLowerCase() : attrValue; + if (ref[attr] != null) { + if (Array.isArray(ref[attr])) { + ref[attr].push(attrValue); + } else { + ref[attr] = [ref[attr], attrValue]; + } + } else { + ref[attr] = attrValue; + } + } + switch (value[offset]) { + case ",": + state = STATE.IDLE; + break; + case ";": + state = STATE.ATTR; + break; + } + offset++; + } else { + throw new Error('Unknown parser state "' + state + '"'); + } + } + if (ref != null) { + ref.rel != null ? this.refs.push(...Link.expandRelations(ref)) : this.refs.push(ref); + } + ref = null; + return this; + } + toString() { + var refs = []; + var link2 = ""; + var ref = null; + for (var i = 0; i < this.refs.length; i++) { + ref = this.refs[i]; + link2 = Object.keys(this.refs[i]).reduce(function(link3, attr) { + if (attr === "uri") return link3; + return link3 + "; " + Link.formatAttribute(attr, ref[attr]); + }, "<" + ref.uri + ">"); + refs.push(link2); + } + return refs.join(", "); + } + } + Link.isCompatibleEncoding = function(value) { + return COMPATIBLE_ENCODING_PATTERN.test(value); + }; + Link.parse = function(value, offset) { + return new Link().parse(value, offset); + }; + Link.isSingleOccurenceAttr = function(attr) { + return attr === "rel" || attr === "type" || attr === "media" || attr === "title" || attr === "title*"; + }; + Link.isTokenAttr = function(attr) { + return attr === "rel" || attr === "type" || attr === "anchor"; + }; + Link.escapeQuotes = function(value) { + return value.replace(/"/g, '\\"'); + }; + Link.expandRelations = function(ref) { + var rels = ref.rel.split(" "); + return rels.map(function(rel) { + var value = Object.assign({}, ref); + value.rel = rel; + return value; + }); + }; + Link.parseExtendedValue = function(value) { + var parts = /([^']+)?(?:'([^']*)')?(.+)/.exec(value); + return { + language: parts[2].toLowerCase(), + encoding: Link.isCompatibleEncoding(parts[1]) ? null : parts[1].toLowerCase(), + value: Link.isCompatibleEncoding(parts[1]) ? decodeURIComponent(parts[3]) : parts[3] + }; + }; + Link.formatExtendedAttribute = function(attr, data) { + var encoding = (data.encoding || "utf-8").toUpperCase(); + var language = data.language || "en"; + var encodedValue = ""; + if (Buffer.isBuffer(data.value) && Link.isCompatibleEncoding(encoding)) { + encodedValue = data.value.toString(encoding); + } else if (Buffer.isBuffer(data.value)) { + encodedValue = data.value.toString("hex").replace(/[0-9a-f]{2}/gi, "%$1"); + } else { + encodedValue = encodeURIComponent(data.value); + } + return attr + "=" + encoding + "'" + language + "'" + encodedValue; + }; + Link.formatAttribute = function(attr, value) { + if (Array.isArray(value)) { + return value.map((item) => { + return Link.formatAttribute(attr, item); + }).join("; "); + } + if (attr[attr.length - 1] === "*" || typeof value !== "string") { + return Link.formatExtendedAttribute(attr, value); + } + if (Link.isTokenAttr(attr)) { + value = needsQuotes(value) ? '"' + Link.escapeQuotes(value) + '"' : Link.escapeQuotes(value); + } else if (needsQuotes(value)) { + value = encodeURIComponent(value); + value = value.replace(/%20/g, " ").replace(/%2C/g, ",").replace(/%3B/g, ";"); + value = '"' + value + '"'; + } + return attr + "=" + value; + }; + link = Link; + return link; + } + var hasRequiredFetchDocumentLoader; + function requireFetchDocumentLoader() { + if (hasRequiredFetchDocumentLoader) return FetchDocumentLoader; + hasRequiredFetchDocumentLoader = 1; + Object.defineProperty(FetchDocumentLoader, "__esModule", { value: true }); + FetchDocumentLoader.FetchDocumentLoader = void 0; + const ErrorCoded_1 = /* @__PURE__ */ requireErrorCoded(); + const http_link_header_1 = requireLink(); + const relative_to_absolute_iri_1 = requireRelativeToAbsoluteIri(); + let FetchDocumentLoader$1 = class FetchDocumentLoader { + constructor(fetcher) { + this.fetcher = fetcher; + } + async load(url) { + const response = await (this.fetcher || fetch)(url, { headers: new Headers({ accept: "application/ld+json" }) }); + if (response.ok && response.headers) { + let mediaType = response.headers.get("Content-Type"); + if (mediaType) { + const colonPos = mediaType.indexOf(";"); + if (colonPos > 0) { + mediaType = mediaType.substr(0, colonPos); + } + } + if (mediaType === "application/ld+json") { + return await response.json(); + } else { + if (response.headers.has("Link")) { + let alternateUrl; + response.headers.forEach((value, key) => { + if (key === "link") { + const linkHeader = (0, http_link_header_1.parse)(value); + for (const link2 of linkHeader.get("type", "application/ld+json")) { + if (link2.rel === "alternate") { + if (alternateUrl) { + throw new Error("Multiple JSON-LD alternate links were found on " + url); + } + alternateUrl = (0, relative_to_absolute_iri_1.resolve)(link2.uri, url); + } + } + } + }); + if (alternateUrl) { + return this.load(alternateUrl); + } + } + throw new ErrorCoded_1.ErrorCoded(`Unsupported JSON-LD media type ${mediaType}`, ErrorCoded_1.ERROR_CODES.LOADING_DOCUMENT_FAILED); + } + } else { + throw new Error(response.statusText || `Status code: ${response.status}`); + } + } + }; + FetchDocumentLoader.FetchDocumentLoader = FetchDocumentLoader$1; + return FetchDocumentLoader; + } + var JsonLdContextNormalized = {}; + var Util = {}; + var hasRequiredUtil; + function requireUtil() { + if (hasRequiredUtil) return Util; + hasRequiredUtil = 1; + Object.defineProperty(Util, "__esModule", { value: true }); + Util.Util = void 0; + let Util$1 = class Util2 { + /** + * Check if the given term is a valid compact IRI. + * Otherwise, it may be an IRI. + * @param {string} term A term. + * @return {boolean} If it is a compact IRI. + */ + static isCompactIri(term) { + return term.indexOf(":") > 0 && !(term && term[0] === "#"); + } + /** + * Get the prefix from the given term. + * @see https://json-ld.org/spec/latest/json-ld/#compact-iris + * @param {string} term A term that is an URL or a prefixed URL. + * @param {IJsonLdContextNormalizedRaw} context A context. + * @return {string} The prefix or null. + */ + static getPrefix(term, context) { + if (term && term[0] === "#") { + return null; + } + const separatorPos = term.indexOf(":"); + if (separatorPos >= 0) { + if (term.length > separatorPos + 1 && term.charAt(separatorPos + 1) === "/" && term.charAt(separatorPos + 2) === "/") { + return null; + } + const prefix = term.substr(0, separatorPos); + if (prefix === "_") { + return null; + } + if (context[prefix]) { + return prefix; + } + } + return null; + } + /** + * From a given context entry value, get the string value, or the @id field. + * @param contextValue A value for a term in a context. + * @return {string} The id value, or null. + */ + static getContextValueId(contextValue) { + if (contextValue === null || typeof contextValue === "string") { + return contextValue; + } + const id = contextValue["@id"]; + return id ? id : null; + } + /** + * Check if the given simple term definition (string-based value of a context term) + * should be considered a prefix. + * @param value A simple term definition value. + * @param options Options that define the way how expansion must be done. + */ + static isSimpleTermDefinitionPrefix(value, options) { + return !Util2.isPotentialKeyword(value) && (options.allowPrefixNonGenDelims || typeof value === "string" && (value[0] === "_" || Util2.isPrefixIriEndingWithGenDelim(value))); + } + /** + * Check if the given keyword is of the keyword format "@"1*ALPHA. + * @param {string} keyword A potential keyword. + * @return {boolean} If the given keyword is of the keyword format. + */ + static isPotentialKeyword(keyword) { + return typeof keyword === "string" && Util2.KEYWORD_REGEX.test(keyword); + } + /** + * Check if the given prefix ends with a gen-delim character. + * @param {string} prefixIri A prefix IRI. + * @return {boolean} If the given prefix IRI is valid. + */ + static isPrefixIriEndingWithGenDelim(prefixIri) { + return Util2.ENDS_WITH_GEN_DELIM.test(prefixIri); + } + /** + * Check if the given context value can be a prefix value. + * @param value A context value. + * @return {boolean} If it can be a prefix value. + */ + static isPrefixValue(value) { + return value && (typeof value === "string" || value && typeof value === "object"); + } + /** + * Check if the given IRI is valid. + * @param {string} iri A potential IRI. + * @return {boolean} If the given IRI is valid. + */ + static isValidIri(iri) { + return Boolean(iri && Util2.IRI_REGEX.test(iri)); + } + /** + * Check if the given IRI is valid, this includes the possibility of being a relative IRI. + * @param {string} iri A potential IRI. + * @return {boolean} If the given IRI is valid. + */ + static isValidIriWeak(iri) { + return !!iri && iri[0] !== ":" && Util2.IRI_REGEX_WEAK.test(iri); + } + /** + * Check if the given keyword is a defined according to the JSON-LD specification. + * @param {string} keyword A potential keyword. + * @return {boolean} If the given keyword is valid. + */ + static isValidKeyword(keyword) { + return Util2.VALID_KEYWORDS[keyword]; + } + /** + * Check if the given term is protected in the context. + * @param {IJsonLdContextNormalizedRaw} context A context. + * @param {string} key A context term. + * @return {boolean} If the given term has an @protected flag. + */ + static isTermProtected(context, key) { + const value = context[key]; + return !(typeof value === "string") && value && value["@protected"]; + } + /** + * Check if the given context has at least one protected term. + * @param context A context. + * @return If the context has a protected term. + */ + static hasProtectedTerms(context) { + for (const key of Object.keys(context)) { + if (Util2.isTermProtected(context, key)) { + return true; + } + } + return false; + } + /** + * Check if the given key is an internal reserved keyword. + * @param key A context key. + */ + static isReservedInternalKeyword(key) { + return key.startsWith("@__"); + } + /** + * Check if two objects are deepEqual to on another. + * @param object1 The first object to test. + * @param object2 The second object to test. + */ + static deepEqual(object1, object2) { + const objKeys1 = Object.keys(object1); + const objKeys2 = Object.keys(object2); + if (objKeys1.length !== objKeys2.length) + return false; + return objKeys1.every((key) => { + const value1 = object1[key]; + const value2 = object2[key]; + return value1 === value2 || value1 !== null && value2 !== null && typeof value1 === "object" && typeof value2 === "object" && this.deepEqual(value1, value2); + }); + } + }; + Util$1.IRI_REGEX = /^([A-Za-z][A-Za-z0-9+-.]*|_):[^ "<>{}|\\\[\]`#]*(#[^#]*)?$/; + Util$1.IRI_REGEX_WEAK = /(?::[^:])|\//; + Util$1.KEYWORD_REGEX = /^@[a-z]+$/i; + Util$1.ENDS_WITH_GEN_DELIM = /[:/?#\[\]@]$/; + Util$1.REGEX_LANGUAGE_TAG = /^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/; + Util$1.REGEX_DIRECTION_TAG = /^(ltr)|(rtl)$/; + Util$1.VALID_KEYWORDS = { + "@annotation": true, + "@base": true, + "@container": true, + "@context": true, + "@direction": true, + "@graph": true, + "@id": true, + "@import": true, + "@included": true, + "@index": true, + "@json": true, + "@language": true, + "@list": true, + "@nest": true, + "@none": true, + "@prefix": true, + "@propagate": true, + "@protected": true, + "@reverse": true, + "@set": true, + "@type": true, + "@value": true, + "@version": true, + "@vocab": true + }; + Util$1.EXPAND_KEYS_BLACKLIST = [ + "@base", + "@vocab", + "@language", + "@version", + "@direction" + ]; + Util$1.ALIAS_DOMAIN_BLACKLIST = [ + "@container", + "@graph", + "@id", + "@index", + "@list", + "@nest", + "@none", + "@prefix", + "@reverse", + "@set", + "@type", + "@value", + "@version" + ]; + Util$1.ALIAS_RANGE_BLACKLIST = [ + "@context", + "@preserve" + ]; + Util$1.CONTAINERS = [ + "@list", + "@set", + "@index", + "@language", + "@graph", + "@id", + "@type" + ]; + Util$1.CONTAINERS_1_0 = [ + "@list", + "@set", + "@index" + ]; + Util.Util = Util$1; + return Util; + } + var hasRequiredJsonLdContextNormalized; + function requireJsonLdContextNormalized() { + if (hasRequiredJsonLdContextNormalized) return JsonLdContextNormalized; + hasRequiredJsonLdContextNormalized = 1; + (function(exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.defaultExpandOptions = exports.JsonLdContextNormalized = void 0; + const relative_to_absolute_iri_1 = requireRelativeToAbsoluteIri(); + const ErrorCoded_1 = /* @__PURE__ */ requireErrorCoded(); + const Util_1 = /* @__PURE__ */ requireUtil(); + class JsonLdContextNormalized2 { + constructor(contextRaw) { + this.contextRaw = contextRaw; + } + /** + * @return The raw inner context. + */ + getContextRaw() { + return this.contextRaw; + } + /** + * Expand the term or prefix of the given term if it has one, + * otherwise return the term as-is. + * + * This will try to expand the IRI as much as possible. + * + * Iff in vocab-mode, then other references to other terms in the context can be used, + * such as to `myTerm`: + * ``` + * { + * "myTerm": "http://example.org/myLongTerm" + * } + * ``` + * + * @param {string} term A term that is an URL or a prefixed URL. + * @param {boolean} expandVocab If the term is a predicate or type and should be expanded based on @vocab, + * otherwise it is considered a regular term that is expanded based on @base. + * @param {IExpandOptions} options Options that define the way how expansion must be done. + * @return {string} The expanded term, the term as-is, or null if it was explicitly disabled in the context. + * @throws If the term is aliased to an invalid value (not a string, IRI or keyword). + */ + expandTerm(term, expandVocab, options = exports.defaultExpandOptions) { + const contextValue = this.contextRaw[term]; + if (contextValue === null || contextValue && contextValue["@id"] === null) { + return null; + } + let validIriMapping = true; + if (contextValue && expandVocab) { + const value = Util_1.Util.getContextValueId(contextValue); + if (value && value !== term) { + if (typeof value !== "string" || !Util_1.Util.isValidIri(value) && !Util_1.Util.isValidKeyword(value)) { + if (!Util_1.Util.isPotentialKeyword(value)) { + validIriMapping = false; + } + } else { + return value; + } + } + } + const prefix = Util_1.Util.getPrefix(term, this.contextRaw); + const vocab = this.contextRaw["@vocab"]; + const vocabRelative = (!!vocab || vocab === "") && vocab.indexOf(":") < 0; + const base = this.contextRaw["@base"]; + const potentialKeyword = Util_1.Util.isPotentialKeyword(term); + if (prefix) { + const contextPrefixValue = this.contextRaw[prefix]; + const value = Util_1.Util.getContextValueId(contextPrefixValue); + if (value) { + if (typeof contextPrefixValue === "string" || !options.allowPrefixForcing) { + if (!Util_1.Util.isSimpleTermDefinitionPrefix(value, options)) { + return term; + } + } else { + if (value[0] !== "_" && !potentialKeyword && !contextPrefixValue["@prefix"] && !(term in this.contextRaw)) { + return term; + } + } + return value + term.substr(prefix.length + 1); + } + } else if (expandVocab && (vocab || vocab === "" || options.allowVocabRelativeToBase && (base && vocabRelative)) && !potentialKeyword && !Util_1.Util.isCompactIri(term)) { + if (vocabRelative) { + if (options.allowVocabRelativeToBase) { + return (vocab || base ? (0, relative_to_absolute_iri_1.resolve)(vocab, base) : "") + term; + } else { + throw new ErrorCoded_1.ErrorCoded(`Relative vocab expansion for term '${term}' with vocab '${vocab}' is not allowed.`, ErrorCoded_1.ERROR_CODES.INVALID_VOCAB_MAPPING); + } + } else { + return vocab + term; + } + } else if (!expandVocab && base && !potentialKeyword && !Util_1.Util.isCompactIri(term)) { + return (0, relative_to_absolute_iri_1.resolve)(term, base); + } + if (validIriMapping) { + return term; + } else { + throw new ErrorCoded_1.ErrorCoded(`Invalid IRI mapping found for context entry '${term}': '${JSON.stringify(contextValue)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); + } + } + /** + * Compact the given term using @base, @vocab, an aliased term, or a prefixed term. + * + * This will try to compact the IRI as much as possible. + * + * @param {string} iri An IRI to compact. + * @param {boolean} vocab If the term is a predicate or type and should be compacted based on @vocab, + * otherwise it is considered a regular term that is compacted based on @base. + * @return {string} The compacted term or the IRI as-is. + */ + compactIri(iri, vocab) { + if (vocab && this.contextRaw["@vocab"] && iri.startsWith(this.contextRaw["@vocab"])) { + return iri.substr(this.contextRaw["@vocab"].length); + } + if (!vocab && this.contextRaw["@base"] && iri.startsWith(this.contextRaw["@base"])) { + return iri.substr(this.contextRaw["@base"].length); + } + const shortestPrefixing = { prefix: "", suffix: iri }; + for (const key in this.contextRaw) { + const value = this.contextRaw[key]; + if (value && !Util_1.Util.isPotentialKeyword(key)) { + const contextIri = Util_1.Util.getContextValueId(value); + if (iri.startsWith(contextIri)) { + const suffix = iri.substr(contextIri.length); + if (!suffix) { + if (vocab) { + return key; + } + } else if (suffix.length < shortestPrefixing.suffix.length) { + shortestPrefixing.prefix = key; + shortestPrefixing.suffix = suffix; + } + } + } + } + if (shortestPrefixing.prefix) { + return shortestPrefixing.prefix + ":" + shortestPrefixing.suffix; + } + return iri; + } + } + exports.JsonLdContextNormalized = JsonLdContextNormalized2; + exports.defaultExpandOptions = { + allowPrefixForcing: true, + allowPrefixNonGenDelims: false, + allowVocabRelativeToBase: true + }; + })(JsonLdContextNormalized); + return JsonLdContextNormalized; + } + var hasRequiredContextParser; + function requireContextParser() { + if (hasRequiredContextParser) return ContextParser; + hasRequiredContextParser = 1; + Object.defineProperty(ContextParser, "__esModule", { value: true }); + ContextParser.ContextParser = void 0; + const relative_to_absolute_iri_1 = requireRelativeToAbsoluteIri(); + const ErrorCoded_1 = /* @__PURE__ */ requireErrorCoded(); + const FetchDocumentLoader_1 = /* @__PURE__ */ requireFetchDocumentLoader(); + const JsonLdContextNormalized_1 = /* @__PURE__ */ requireJsonLdContextNormalized(); + const Util_1 = /* @__PURE__ */ requireUtil(); + let ContextParser$1 = class ContextParser2 { + constructor(options) { + options = options || {}; + this.documentLoader = options.documentLoader || new FetchDocumentLoader_1.FetchDocumentLoader(); + this.documentCache = {}; + this.validateContext = !options.skipValidation; + this.expandContentTypeToBase = !!options.expandContentTypeToBase; + this.remoteContextsDepthLimit = options.remoteContextsDepthLimit || 32; + this.redirectSchemaOrgHttps = "redirectSchemaOrgHttps" in options ? !!options.redirectSchemaOrgHttps : true; + } + /** + * Validate the given @language value. + * An error will be thrown if it is invalid. + * @param value An @language value. + * @param {boolean} strictRange If the string value should be strictly checked against a regex. + * @param {string} errorCode The error code to emit on errors. + * @return {boolean} If validation passed. + * Can only be false if strictRange is false and the string value did not pass the regex. + */ + static validateLanguage(value, strictRange, errorCode) { + if (typeof value !== "string") { + throw new ErrorCoded_1.ErrorCoded(`The value of an '@language' must be a string, got '${JSON.stringify(value)}'`, errorCode); + } + if (!Util_1.Util.REGEX_LANGUAGE_TAG.test(value)) { + if (strictRange) { + throw new ErrorCoded_1.ErrorCoded(`The value of an '@language' must be a valid language tag, got '${JSON.stringify(value)}'`, errorCode); + } else { + return false; + } + } + return true; + } + /** + * Validate the given @direction value. + * An error will be thrown if it is invalid. + * @param value An @direction value. + * @param {boolean} strictValues If the string value should be strictly checked against a regex. + * @return {boolean} If validation passed. + * Can only be false if strictRange is false and the string value did not pass the regex. + */ + static validateDirection(value, strictValues) { + if (typeof value !== "string") { + throw new ErrorCoded_1.ErrorCoded(`The value of an '@direction' must be a string, got '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_BASE_DIRECTION); + } + if (!Util_1.Util.REGEX_DIRECTION_TAG.test(value)) { + if (strictValues) { + throw new ErrorCoded_1.ErrorCoded(`The value of an '@direction' must be 'ltr' or 'rtl', got '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_BASE_DIRECTION); + } else { + return false; + } + } + return true; + } + /** + * Add an @id term for all @reverse terms. + * @param {IJsonLdContextNormalizedRaw} context A context. + * @return {IJsonLdContextNormalizedRaw} The mutated input context. + */ + idifyReverseTerms(context) { + for (const key of Object.keys(context)) { + let value = context[key]; + if (value && typeof value === "object") { + if (value["@reverse"] && !value["@id"]) { + if (typeof value["@reverse"] !== "string" || Util_1.Util.isValidKeyword(value["@reverse"])) { + throw new ErrorCoded_1.ErrorCoded(`Invalid @reverse value, must be absolute IRI or blank node: '${value["@reverse"]}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); + } + value = context[key] = Object.assign(Object.assign({}, value), { "@id": value["@reverse"] }); + value["@id"] = value["@reverse"]; + if (Util_1.Util.isPotentialKeyword(value["@reverse"])) { + delete value["@reverse"]; + } else { + value["@reverse"] = true; + } + } + } + } + return context; + } + /** + * Expand all prefixed terms in the given context. + * @param {IJsonLdContextNormalizedRaw} context A context. + * @param {boolean} expandContentTypeToBase If @type inside the context may be expanded + * via @base if @vocab is set to null. + * @param {string[]} keys Optional set of keys from the context to expand. If left undefined, all + * keys in the context will be expanded. + */ + expandPrefixedTerms(context, expandContentTypeToBase, keys) { + const contextRaw = context.getContextRaw(); + for (const key of keys || Object.keys(contextRaw)) { + if (Util_1.Util.EXPAND_KEYS_BLACKLIST.indexOf(key) < 0 && !Util_1.Util.isReservedInternalKeyword(key)) { + const keyValue = contextRaw[key]; + if (Util_1.Util.isPotentialKeyword(key) && Util_1.Util.ALIAS_DOMAIN_BLACKLIST.indexOf(key) >= 0) { + if (key !== "@type" || typeof contextRaw[key] === "object" && !(contextRaw[key]["@protected"] || contextRaw[key]["@container"] === "@set")) { + throw new ErrorCoded_1.ErrorCoded(`Keywords can not be aliased to something else. + Tried mapping ${key} to ${JSON.stringify(keyValue)}`, ErrorCoded_1.ERROR_CODES.KEYWORD_REDEFINITION); + } + } + if (Util_1.Util.ALIAS_RANGE_BLACKLIST.indexOf(Util_1.Util.getContextValueId(keyValue)) >= 0) { + throw new ErrorCoded_1.ErrorCoded(`Aliasing to certain keywords is not allowed. + Tried mapping ${key} to ${JSON.stringify(keyValue)}`, ErrorCoded_1.ERROR_CODES.INVALID_KEYWORD_ALIAS); + } + if (keyValue && Util_1.Util.isPotentialKeyword(Util_1.Util.getContextValueId(keyValue)) && keyValue["@prefix"] === true) { + throw new ErrorCoded_1.ErrorCoded(`Tried to use keyword aliases as prefix: '${key}': '${JSON.stringify(keyValue)}'`, ErrorCoded_1.ERROR_CODES.INVALID_TERM_DEFINITION); + } + while (Util_1.Util.isPrefixValue(contextRaw[key])) { + const value = contextRaw[key]; + let changed = false; + if (typeof value === "string") { + contextRaw[key] = context.expandTerm(value, true); + changed = changed || value !== contextRaw[key]; + } else { + const id = value["@id"]; + const type = value["@type"]; + const canAddIdEntry = !("@prefix" in value) || Util_1.Util.isValidIri(key); + if ("@id" in value) { + if (id !== void 0 && id !== null && typeof id === "string") { + contextRaw[key] = Object.assign(Object.assign({}, contextRaw[key]), { "@id": context.expandTerm(id, true) }); + changed = changed || id !== contextRaw[key]["@id"]; + } + } else if (!Util_1.Util.isPotentialKeyword(key) && canAddIdEntry) { + const newId = context.expandTerm(key, true); + if (newId !== key) { + contextRaw[key] = Object.assign(Object.assign({}, contextRaw[key]), { "@id": newId }); + changed = true; + } + } + if (type && typeof type === "string" && type !== "@vocab" && (!value["@container"] || !value["@container"]["@type"]) && canAddIdEntry) { + let expandedType = context.expandTerm(type, true); + if (expandContentTypeToBase && type === expandedType) { + expandedType = context.expandTerm(type, false); + } + if (expandedType !== type) { + changed = true; + contextRaw[key] = Object.assign(Object.assign({}, contextRaw[key]), { "@type": expandedType }); + } + } + } + if (!changed) { + break; + } + } + } + } + } + /** + * Normalize the @language entries in the given context to lowercase. + * @param {IJsonLdContextNormalizedRaw} context A context. + * @param {IParseOptions} parseOptions The parsing options. + */ + normalize(context, { processingMode, normalizeLanguageTags }) { + if (normalizeLanguageTags || processingMode === 1) { + for (const key of Object.keys(context)) { + if (key === "@language" && typeof context[key] === "string") { + context[key] = context[key].toLowerCase(); + } else { + const value = context[key]; + if (value && typeof value === "object") { + if (typeof value["@language"] === "string") { + const lowercase = value["@language"].toLowerCase(); + if (lowercase !== value["@language"]) { + context[key] = Object.assign(Object.assign({}, value), { "@language": lowercase }); + } + } + } + } + } + } + } + /** + * Convert all @container strings and array values to hash-based values. + * @param {IJsonLdContextNormalizedRaw} context A context. + */ + containersToHash(context) { + for (const key of Object.keys(context)) { + const value = context[key]; + if (value && typeof value === "object") { + if (typeof value["@container"] === "string") { + context[key] = Object.assign(Object.assign({}, value), { "@container": { [value["@container"]]: true } }); + } else if (Array.isArray(value["@container"])) { + const newValue = {}; + for (const containerValue of value["@container"]) { + newValue[containerValue] = true; + } + context[key] = Object.assign(Object.assign({}, value), { "@container": newValue }); + } + } + } + } + /** + * Normalize and apply context-level @protected terms onto each term separately. + * @param {IJsonLdContextNormalizedRaw} context A context. + * @param {number} processingMode The processing mode. + */ + applyScopedProtected(context, { processingMode }, expandOptions) { + if (processingMode && processingMode >= 1.1) { + if (context["@protected"]) { + for (const key of Object.keys(context)) { + if (Util_1.Util.isReservedInternalKeyword(key)) { + continue; + } + if (!Util_1.Util.isPotentialKeyword(key) && !Util_1.Util.isTermProtected(context, key)) { + const value = context[key]; + if (value && typeof value === "object") { + if (!("@protected" in context[key])) { + context[key] = Object.assign(Object.assign({}, context[key]), { "@protected": true }); + } + } else { + context[key] = { + "@id": value, + "@protected": true + }; + if (Util_1.Util.isSimpleTermDefinitionPrefix(value, expandOptions)) { + context[key] = Object.assign(Object.assign({}, context[key]), { "@prefix": true }); + } + } + } + } + delete context["@protected"]; + } + } + } + /** + * Check if the given context inheritance does not contain any overrides of protected terms. + * @param {IJsonLdContextNormalizedRaw} contextBefore The context that may contain some protected terms. + * @param {IJsonLdContextNormalizedRaw} contextAfter A new context that is being applied on the first one. + * @param {IExpandOptions} expandOptions Options that are needed for any expansions during this validation. + * @param {string[]} keys Optional set of keys from the context to validate. If left undefined, all + * keys defined in contextAfter will be checked. + */ + validateKeywordRedefinitions(contextBefore, contextAfter, expandOptions, keys) { + for (const key of keys !== null && keys !== void 0 ? keys : Object.keys(contextAfter)) { + if (Util_1.Util.isTermProtected(contextBefore, key)) { + if (typeof contextAfter[key] === "string") { + contextAfter[key] = { "@id": contextAfter[key], "@protected": true }; + } else { + contextAfter[key] = Object.assign(Object.assign({}, contextAfter[key]), { "@protected": true }); + } + if (!Util_1.Util.deepEqual(contextBefore[key], contextAfter[key])) { + throw new ErrorCoded_1.ErrorCoded(`Attempted to override the protected keyword ${key} from ${JSON.stringify(Util_1.Util.getContextValueId(contextBefore[key]))} to ${JSON.stringify(Util_1.Util.getContextValueId(contextAfter[key]))}`, ErrorCoded_1.ERROR_CODES.PROTECTED_TERM_REDEFINITION); + } + } + } + } + /** + * Validate the entries of the given context. + * @param {IJsonLdContextNormalizedRaw} context A context. + * @param {IParseOptions} options The parse options. + */ + validate(context, { processingMode }) { + for (const key of Object.keys(context)) { + if (Util_1.Util.isReservedInternalKeyword(key)) { + continue; + } + if (key === "") { + throw new ErrorCoded_1.ErrorCoded(`The empty term is not allowed, got: '${key}': '${JSON.stringify(context[key])}'`, ErrorCoded_1.ERROR_CODES.INVALID_TERM_DEFINITION); + } + const value = context[key]; + const valueType = typeof value; + if (Util_1.Util.isPotentialKeyword(key)) { + switch (key.substr(1)) { + case "vocab": + if (value !== null && valueType !== "string") { + throw new ErrorCoded_1.ErrorCoded(`Found an invalid @vocab IRI: ${value}`, ErrorCoded_1.ERROR_CODES.INVALID_VOCAB_MAPPING); + } + break; + case "base": + if (value !== null && valueType !== "string") { + throw new ErrorCoded_1.ErrorCoded(`Found an invalid @base IRI: ${context[key]}`, ErrorCoded_1.ERROR_CODES.INVALID_BASE_IRI); + } + break; + case "language": + if (value !== null) { + ContextParser2.validateLanguage(value, true, ErrorCoded_1.ERROR_CODES.INVALID_DEFAULT_LANGUAGE); + } + break; + case "version": + if (value !== null && valueType !== "number") { + throw new ErrorCoded_1.ErrorCoded(`Found an invalid @version number: ${value}`, ErrorCoded_1.ERROR_CODES.INVALID_VERSION_VALUE); + } + break; + case "direction": + if (value !== null) { + ContextParser2.validateDirection(value, true); + } + break; + case "propagate": + if (processingMode === 1) { + throw new ErrorCoded_1.ErrorCoded(`Found an illegal @propagate keyword: ${value}`, ErrorCoded_1.ERROR_CODES.INVALID_CONTEXT_ENTRY); + } + if (value !== null && valueType !== "boolean") { + throw new ErrorCoded_1.ErrorCoded(`Found an invalid @propagate value: ${value}`, ErrorCoded_1.ERROR_CODES.INVALID_PROPAGATE_VALUE); + } + break; + } + if (Util_1.Util.isValidKeyword(key) && Util_1.Util.isValidKeyword(Util_1.Util.getContextValueId(value))) { + throw new ErrorCoded_1.ErrorCoded(`Illegal keyword alias in term value, found: '${key}': '${Util_1.Util.getContextValueId(value)}'`, ErrorCoded_1.ERROR_CODES.KEYWORD_REDEFINITION); + } + continue; + } + if (value !== null) { + switch (valueType) { + case "string": + if (Util_1.Util.getPrefix(value, context) === key) { + throw new ErrorCoded_1.ErrorCoded(`Detected cyclical IRI mapping in context entry: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.CYCLIC_IRI_MAPPING); + } + if (Util_1.Util.isValidIriWeak(key)) { + if (value === "@type") { + throw new ErrorCoded_1.ErrorCoded(`IRIs can not be mapped to @type, found: '${key}': '${value}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); + } else if (Util_1.Util.isValidIri(value) && value !== new JsonLdContextNormalized_1.JsonLdContextNormalized(context).expandTerm(key)) { + throw new ErrorCoded_1.ErrorCoded(`IRIs can not be mapped to other IRIs, found: '${key}': '${value}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); + } + } + break; + case "object": + if (!Util_1.Util.isCompactIri(key) && !("@id" in value) && (value["@type"] === "@id" ? !context["@base"] : !context["@vocab"])) { + throw new ErrorCoded_1.ErrorCoded(`Missing @id in context entry: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); + } + for (const objectKey of Object.keys(value)) { + const objectValue = value[objectKey]; + if (!objectValue) { + continue; + } + switch (objectKey) { + case "@id": + if (Util_1.Util.isValidKeyword(objectValue) && objectValue !== "@type" && objectValue !== "@id" && objectValue !== "@graph" && objectValue !== "@nest") { + throw new ErrorCoded_1.ErrorCoded(`Illegal keyword alias in term value, found: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); + } + if (Util_1.Util.isValidIriWeak(key)) { + if (objectValue === "@type") { + throw new ErrorCoded_1.ErrorCoded(`IRIs can not be mapped to @type, found: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); + } else if (Util_1.Util.isValidIri(objectValue) && objectValue !== new JsonLdContextNormalized_1.JsonLdContextNormalized(context).expandTerm(key)) { + throw new ErrorCoded_1.ErrorCoded(`IRIs can not be mapped to other IRIs, found: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); + } + } + if (typeof objectValue !== "string") { + throw new ErrorCoded_1.ErrorCoded(`Detected non-string @id in context entry: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); + } + if (Util_1.Util.getPrefix(objectValue, context) === key) { + throw new ErrorCoded_1.ErrorCoded(`Detected cyclical IRI mapping in context entry: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.CYCLIC_IRI_MAPPING); + } + break; + case "@type": + if (value["@container"] === "@type" && objectValue !== "@id" && objectValue !== "@vocab") { + throw new ErrorCoded_1.ErrorCoded(`@container: @type only allows @type: @id or @vocab, but got: '${key}': '${objectValue}'`, ErrorCoded_1.ERROR_CODES.INVALID_TYPE_MAPPING); + } + if (typeof objectValue !== "string") { + throw new ErrorCoded_1.ErrorCoded(`The value of an '@type' must be a string, got '${JSON.stringify(valueType)}'`, ErrorCoded_1.ERROR_CODES.INVALID_TYPE_MAPPING); + } + if (objectValue !== "@id" && objectValue !== "@vocab" && (processingMode === 1 || objectValue !== "@json") && (processingMode === 1 || objectValue !== "@none") && (objectValue[0] === "_" || !Util_1.Util.isValidIri(objectValue))) { + throw new ErrorCoded_1.ErrorCoded(`A context @type must be an absolute IRI, found: '${key}': '${objectValue}'`, ErrorCoded_1.ERROR_CODES.INVALID_TYPE_MAPPING); + } + break; + case "@reverse": + if (typeof objectValue === "string" && value["@id"] && value["@id"] !== objectValue) { + throw new ErrorCoded_1.ErrorCoded(`Found non-matching @id and @reverse term values in '${key}':'${objectValue}' and '${value["@id"]}'`, ErrorCoded_1.ERROR_CODES.INVALID_REVERSE_PROPERTY); + } + if ("@nest" in value) { + throw new ErrorCoded_1.ErrorCoded(`@nest is not allowed in the reverse property '${key}'`, ErrorCoded_1.ERROR_CODES.INVALID_REVERSE_PROPERTY); + } + break; + case "@container": + if (processingMode === 1) { + if (Object.keys(objectValue).length > 1 || Util_1.Util.CONTAINERS_1_0.indexOf(Object.keys(objectValue)[0]) < 0) { + throw new ErrorCoded_1.ErrorCoded(`Invalid term @container for '${key}' ('${Object.keys(objectValue)}') in 1.0, must be only one of ${Util_1.Util.CONTAINERS_1_0.join(", ")}`, ErrorCoded_1.ERROR_CODES.INVALID_CONTAINER_MAPPING); + } + } + for (const containerValue of Object.keys(objectValue)) { + if (containerValue === "@list" && value["@reverse"]) { + throw new ErrorCoded_1.ErrorCoded(`Term value can not be @container: @list and @reverse at the same time on '${key}'`, ErrorCoded_1.ERROR_CODES.INVALID_REVERSE_PROPERTY); + } + if (Util_1.Util.CONTAINERS.indexOf(containerValue) < 0) { + throw new ErrorCoded_1.ErrorCoded(`Invalid term @container for '${key}' ('${containerValue}'), must be one of ${Util_1.Util.CONTAINERS.join(", ")}`, ErrorCoded_1.ERROR_CODES.INVALID_CONTAINER_MAPPING); + } + } + break; + case "@language": + ContextParser2.validateLanguage(objectValue, true, ErrorCoded_1.ERROR_CODES.INVALID_LANGUAGE_MAPPING); + break; + case "@direction": + ContextParser2.validateDirection(objectValue, true); + break; + case "@prefix": + if (objectValue !== null && typeof objectValue !== "boolean") { + throw new ErrorCoded_1.ErrorCoded(`Found an invalid term @prefix boolean in: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_PREFIX_VALUE); + } + if (!("@id" in value) && !Util_1.Util.isValidIri(key)) { + throw new ErrorCoded_1.ErrorCoded(`Invalid @prefix definition for '${key}' ('${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_TERM_DEFINITION); + } + break; + case "@index": + if (processingMode === 1 || !value["@container"] || !value["@container"]["@index"]) { + throw new ErrorCoded_1.ErrorCoded(`Attempt to add illegal key to value object: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_TERM_DEFINITION); + } + break; + case "@nest": + if (Util_1.Util.isPotentialKeyword(objectValue) && objectValue !== "@nest") { + throw new ErrorCoded_1.ErrorCoded(`Found an invalid term @nest value in: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_NEST_VALUE); + } + } + } + break; + default: + throw new ErrorCoded_1.ErrorCoded(`Found an invalid term value: '${key}': '${value}'`, ErrorCoded_1.ERROR_CODES.INVALID_TERM_DEFINITION); + } + } + } + } + /** + * Apply the @base context entry to the given context under certain circumstances. + * @param context A context. + * @param options Parsing options. + * @param inheritFromParent If the @base value from the parent context can be inherited. + * @return The given context. + */ + applyBaseEntry(context, options, inheritFromParent) { + if (typeof context === "string") { + return context; + } + if (inheritFromParent && !("@base" in context) && options.parentContext && typeof options.parentContext === "object" && "@base" in options.parentContext) { + context["@base"] = options.parentContext["@base"]; + if (options.parentContext["@__baseDocument"]) { + context["@__baseDocument"] = true; + } + } + if (options.baseIRI && !options.external) { + if (!("@base" in context)) { + context["@base"] = options.baseIRI; + context["@__baseDocument"] = true; + } else if (context["@base"] !== null && typeof context["@base"] === "string" && !Util_1.Util.isValidIri(context["@base"])) { + context["@base"] = (0, relative_to_absolute_iri_1.resolve)(context["@base"], options.parentContext && options.parentContext["@base"] || options.baseIRI); + } + } + return context; + } + /** + * Resolve relative context IRIs, or return full IRIs as-is. + * @param {string} contextIri A context IRI. + * @param {string} baseIRI A base IRI. + * @return {string} The normalized context IRI. + */ + normalizeContextIri(contextIri, baseIRI) { + if (!Util_1.Util.isValidIri(contextIri)) { + try { + contextIri = (0, relative_to_absolute_iri_1.resolve)(contextIri, baseIRI); + } catch (_a) { + throw new Error(`Invalid context IRI: ${contextIri}`); + } + } + if (this.redirectSchemaOrgHttps && contextIri.startsWith("http://schema.org")) { + contextIri = "https://schema.org/"; + } + return contextIri; + } + /** + * Parse scoped contexts in the given context. + * @param {IJsonLdContextNormalizedRaw} context A context. + * @param {IParseOptions} options Parsing options. + * @return {IJsonLdContextNormalizedRaw} The mutated input context. + * @param {string[]} keys Optional set of keys from the context to parseInnerContexts of. If left undefined, all + * keys in the context will be iterated over. + */ + async parseInnerContexts(context, options, keys) { + for (const key of keys !== null && keys !== void 0 ? keys : Object.keys(context)) { + const value = context[key]; + if (value && typeof value === "object") { + if ("@context" in value && value["@context"] !== null && !options.ignoreScopedContexts) { + if (this.validateContext) { + try { + const parentContext = Object.assign(Object.assign({}, context), { [key]: Object.assign({}, context[key]) }); + delete parentContext[key]["@context"]; + await this.parse(value["@context"], Object.assign(Object.assign({}, options), { external: false, parentContext, ignoreProtection: true, ignoreRemoteScopedContexts: true, ignoreScopedContexts: true })); + } catch (e) { + throw new ErrorCoded_1.ErrorCoded(e.message, ErrorCoded_1.ERROR_CODES.INVALID_SCOPED_CONTEXT); + } + } + context[key] = Object.assign(Object.assign({}, value), { "@context": (await this.parse(value["@context"], Object.assign(Object.assign({}, options), { external: false, minimalProcessing: true, ignoreRemoteScopedContexts: true, parentContext: context }))).getContextRaw() }); + } + } + } + return context; + } + async parse(context, options = {}, internalOptions = {}) { + const { baseIRI, parentContext, external, processingMode = ContextParser2.DEFAULT_PROCESSING_MODE, normalizeLanguageTags, ignoreProtection, minimalProcessing } = options; + const remoteContexts = options.remoteContexts || {}; + if (Object.keys(remoteContexts).length >= this.remoteContextsDepthLimit) { + throw new ErrorCoded_1.ErrorCoded("Detected an overflow in remote context inclusions: " + Object.keys(remoteContexts), ErrorCoded_1.ERROR_CODES.CONTEXT_OVERFLOW); + } + if (context === null || context === void 0) { + if (!ignoreProtection && parentContext && Util_1.Util.hasProtectedTerms(parentContext)) { + throw new ErrorCoded_1.ErrorCoded("Illegal context nullification when terms are protected", ErrorCoded_1.ERROR_CODES.INVALID_CONTEXT_NULLIFICATION); + } + return new JsonLdContextNormalized_1.JsonLdContextNormalized(this.applyBaseEntry({}, options, false)); + } else if (typeof context === "string") { + const contextIri = this.normalizeContextIri(context, baseIRI); + const overriddenLoad = this.getOverriddenLoad(contextIri, options); + if (overriddenLoad) { + return new JsonLdContextNormalized_1.JsonLdContextNormalized(overriddenLoad); + } + const parsedStringContext = await this.parse(await this.load(contextIri), Object.assign(Object.assign({}, options), { baseIRI: contextIri, external: true, remoteContexts: Object.assign(Object.assign({}, remoteContexts), { [contextIri]: true }) })); + this.applyBaseEntry(parsedStringContext.getContextRaw(), options, true); + return parsedStringContext; + } else if (Array.isArray(context)) { + const contextIris = []; + const contexts = await Promise.all(context.map((subContext, i) => { + if (typeof subContext === "string") { + const contextIri = this.normalizeContextIri(subContext, baseIRI); + contextIris[i] = contextIri; + const overriddenLoad = this.getOverriddenLoad(contextIri, options); + if (overriddenLoad) { + return overriddenLoad; + } + return this.load(contextIri); + } else { + return subContext; + } + })); + if (minimalProcessing) { + return new JsonLdContextNormalized_1.JsonLdContextNormalized(contexts); + } + const reducedContexts = await contexts.reduce((accContextPromise, contextEntry, i) => accContextPromise.then((accContext) => this.parse( + contextEntry, + Object.assign(Object.assign({}, options), { baseIRI: contextIris[i] || options.baseIRI, external: !!contextIris[i] || options.external, parentContext: accContext.getContextRaw(), remoteContexts: contextIris[i] ? Object.assign(Object.assign({}, remoteContexts), { [contextIris[i]]: true }) : remoteContexts }), + // @ts-expect-error: This third argument causes a type error because we have hidden it from consumers + { + skipValidation: i < contexts.length - 1 + } + )), Promise.resolve(new JsonLdContextNormalized_1.JsonLdContextNormalized(parentContext || {}))); + this.applyBaseEntry(reducedContexts.getContextRaw(), options, true); + return reducedContexts; + } else if (typeof context === "object") { + if ("@context" in context) { + return await this.parse(context["@context"], options); + } + context = Object.assign({}, context); + if (external) { + delete context["@base"]; + } + this.applyBaseEntry(context, options, true); + this.containersToHash(context); + if (minimalProcessing) { + return new JsonLdContextNormalized_1.JsonLdContextNormalized(context); + } + let importContext = {}; + if ("@import" in context) { + if (processingMode >= 1.1) { + if (typeof context["@import"] !== "string") { + throw new ErrorCoded_1.ErrorCoded("An @import value must be a string, but got " + typeof context["@import"], ErrorCoded_1.ERROR_CODES.INVALID_IMPORT_VALUE); + } + importContext = await this.loadImportContext(this.normalizeContextIri(context["@import"], baseIRI)); + delete context["@import"]; + } else { + throw new ErrorCoded_1.ErrorCoded("Context importing is not supported in JSON-LD 1.0", ErrorCoded_1.ERROR_CODES.INVALID_CONTEXT_ENTRY); + } + } + this.applyScopedProtected(importContext, { processingMode }, JsonLdContextNormalized_1.defaultExpandOptions); + const newContext = Object.assign(importContext, context); + this.idifyReverseTerms(newContext); + this.normalize(newContext, { processingMode, normalizeLanguageTags }); + this.applyScopedProtected(newContext, { processingMode }, JsonLdContextNormalized_1.defaultExpandOptions); + const keys = Object.keys(newContext); + const overlappingKeys = []; + if (typeof parentContext === "object") { + for (const key in parentContext) { + if (key in newContext) { + overlappingKeys.push(key); + } else { + newContext[key] = parentContext[key]; + } + } + } + await this.parseInnerContexts(newContext, options, keys); + const newContextWrapped = new JsonLdContextNormalized_1.JsonLdContextNormalized(newContext); + if ((newContext && newContext["@version"] || ContextParser2.DEFAULT_PROCESSING_MODE) >= 1.1 && (context["@vocab"] && typeof context["@vocab"] === "string" || context["@vocab"] === "")) { + if (parentContext && "@vocab" in parentContext && context["@vocab"].indexOf(":") < 0) { + newContext["@vocab"] = parentContext["@vocab"] + context["@vocab"]; + } else if (Util_1.Util.isCompactIri(context["@vocab"]) || context["@vocab"] in newContext) { + newContext["@vocab"] = newContextWrapped.expandTerm(context["@vocab"], true); + } + } + this.expandPrefixedTerms(newContextWrapped, this.expandContentTypeToBase, keys); + if (!ignoreProtection && parentContext && processingMode >= 1.1) { + this.validateKeywordRedefinitions(parentContext, newContext, JsonLdContextNormalized_1.defaultExpandOptions, overlappingKeys); + } + if (this.validateContext && !internalOptions.skipValidation) { + this.validate(newContext, { processingMode }); + } + return newContextWrapped; + } else { + throw new ErrorCoded_1.ErrorCoded(`Tried parsing a context that is not a string, array or object, but got ${context}`, ErrorCoded_1.ERROR_CODES.INVALID_LOCAL_CONTEXT); + } + } + /** + * Fetch the given URL as a raw JSON-LD context. + * @param url An URL. + * @return A promise resolving to a raw JSON-LD context. + */ + async load(url) { + const cached = this.documentCache[url]; + if (cached) { + return cached; + } + let document2; + try { + document2 = await this.documentLoader.load(url); + } catch (e) { + throw new ErrorCoded_1.ErrorCoded(`Failed to load remote context ${url}: ${e.message}`, ErrorCoded_1.ERROR_CODES.LOADING_REMOTE_CONTEXT_FAILED); + } + if (!("@context" in document2)) { + throw new ErrorCoded_1.ErrorCoded(`Missing @context in remote context at ${url}`, ErrorCoded_1.ERROR_CODES.INVALID_REMOTE_CONTEXT); + } + return this.documentCache[url] = document2["@context"]; + } + /** + * Override the given context that may be loaded. + * + * This will check whether or not the url is recursively being loaded. + * @param url An URL. + * @param options Parsing options. + * @return An overridden context, or null. + * Optionally an error can be thrown if a cyclic context is detected. + */ + getOverriddenLoad(url, options) { + if (url in (options.remoteContexts || {})) { + if (options.ignoreRemoteScopedContexts) { + return url; + } else { + throw new ErrorCoded_1.ErrorCoded("Detected a cyclic context inclusion of " + url, ErrorCoded_1.ERROR_CODES.RECURSIVE_CONTEXT_INCLUSION); + } + } + return null; + } + /** + * Load an @import'ed context. + * @param importContextIri The full URI of an @import value. + */ + async loadImportContext(importContextIri) { + let importContext = await this.load(importContextIri); + if (typeof importContext !== "object" || Array.isArray(importContext)) { + throw new ErrorCoded_1.ErrorCoded("An imported context must be a single object: " + importContextIri, ErrorCoded_1.ERROR_CODES.INVALID_REMOTE_CONTEXT); + } + if ("@import" in importContext) { + throw new ErrorCoded_1.ErrorCoded("An imported context can not import another context: " + importContextIri, ErrorCoded_1.ERROR_CODES.INVALID_CONTEXT_ENTRY); + } + importContext = Object.assign({}, importContext); + this.containersToHash(importContext); + return importContext; + } + }; + ContextParser$1.DEFAULT_PROCESSING_MODE = 1.1; + ContextParser.ContextParser = ContextParser$1; + return ContextParser; + } + var IDocumentLoader = {}; + var hasRequiredIDocumentLoader; + function requireIDocumentLoader() { + if (hasRequiredIDocumentLoader) return IDocumentLoader; + hasRequiredIDocumentLoader = 1; + Object.defineProperty(IDocumentLoader, "__esModule", { value: true }); + return IDocumentLoader; + } + var JsonLdContext = {}; + var hasRequiredJsonLdContext; + function requireJsonLdContext() { + if (hasRequiredJsonLdContext) return JsonLdContext; + hasRequiredJsonLdContext = 1; + Object.defineProperty(JsonLdContext, "__esModule", { value: true }); + return JsonLdContext; + } + var hasRequiredJsonldContextParser; + function requireJsonldContextParser() { + if (hasRequiredJsonldContextParser) return jsonldContextParser; + hasRequiredJsonldContextParser = 1; + (function(exports) { + var __createBinding = jsonldContextParser && jsonldContextParser.__createBinding || (Object.create ? function(o, m, k, k2) { + if (k2 === void 0) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { + return m[k]; + } }; + } + Object.defineProperty(o, k2, desc); + } : function(o, m, k, k2) { + if (k2 === void 0) k2 = k; + o[k2] = m[k]; + }); + var __exportStar = jsonldContextParser && jsonldContextParser.__exportStar || function(m, exports2) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + __exportStar(/* @__PURE__ */ requireContextParser(), exports); + __exportStar(/* @__PURE__ */ requireErrorCoded(), exports); + __exportStar(/* @__PURE__ */ requireFetchDocumentLoader(), exports); + __exportStar(/* @__PURE__ */ requireIDocumentLoader(), exports); + __exportStar(/* @__PURE__ */ requireJsonLdContext(), exports); + __exportStar(/* @__PURE__ */ requireJsonLdContextNormalized(), exports); + __exportStar(/* @__PURE__ */ requireUtil(), exports); + })(jsonldContextParser); + return jsonldContextParser; + } + var jsonldContextParserExports = /* @__PURE__ */ requireJsonldContextParser(); + function uniqID() { + return `_${(Math.random() * 36 ** 20).toString(36).slice(0, 10)}`; + } + function stringToDom(html) { + const template = document.createElement("template"); + template.innerHTML = html; + return template.content; + } + const AsyncFunction = Object.getPrototypeOf(async () => { + }).constructor; + async function evalTemplateString(str, variables = {}) { + const keys = Object.keys(variables); + const values = keys.map((key) => variables[key]); + try { + const func = AsyncFunction.call(null, ...keys, `return \`${str}\``); + return await func(...values); + } catch (e) { + console.log(e); + throw new SyntaxError(`\`${str}\``); + } + } + function importCSS(...stylesheets) { + const linksElements = []; + for (let url of stylesheets) { + url = relativeSource(url); + let link2 = Array.from(document.head.querySelectorAll("link")).find( + (link22) => link22.href === url + ); + if (link2) return link2; + link2 = document.createElement("link"); + link2.rel = "stylesheet"; + link2.href = url; + document.head.appendChild(link2); + linksElements.push(link2); + } + return linksElements; + } + function importInlineCSS(id, importer) { + id = `sib-inline-css-${id}`; + let style = document.head.querySelector(`style#${id}`); + if (style) return style; + style = document.createElement("style"); + style.id = id; + document.head.appendChild(style); + (async () => { + let textContent; + if (typeof importer === "string") textContent = importer; + else { + const imported = await importer(); + if (typeof imported === "string") textContent = imported; + else textContent = imported.default || ""; + } + style.textContent = textContent; + })(); + return style; + } + function importJS(...plugins) { + return plugins.map((url) => { + url = new URL(url, document.baseURI).href; + let script = Array.from(document.querySelectorAll("script")).find( + (script2) => script2.src === url + ); + if (script) return script; + script = document.createElement("script"); + script.src = url; + document.head.appendChild(script); + return script; + }); + } + function relativeSource(source) { + if (!source.match(/^\..?\//)) return new URL(source, document.baseURI).href; + const e = new Error(); + if (!e.stack) return source; + const f2 = e.stack.split("\n").filter((l) => l.includes(":"))[2]; + const line = f2.match(/[a-z]+:.*$/); + if (!line) return source; + const calledFile = line[0].replace(/(\:[0-9]+){2}\)?$/, ""); + source = new URL(source, calledFile).href; + return source; + } + function loadScript(source) { + source = relativeSource(source); + return new Promise((resolve) => { + const script = document.createElement("script"); + const head = document.querySelector("head"); + script.async = true; + script.onload = () => setTimeout(resolve, 0); + script.src = source; + if (head) head.appendChild(script); + }); + } + function domIsReady() { + return new Promise((resolve) => { + if (document.readyState === "complete") { + resolve(); + } else { + document.addEventListener("DOMContentLoaded", () => resolve()); + } + }); + } + function setDeepProperty(obj, path, value) { + const name = path.shift(); + if (name) { + if (!(name in obj)) obj[name] = {}; + if (path.length > 0) setDeepProperty(obj[name], path, value); + else obj[name] = value; + } + } + function parseFieldsString(fields) { + if (!fields) return []; + while (fields.indexOf("(") > 0) { + const firstBracket = fields.indexOf("("); + const noset = fields.substring( + firstBracket, + findClosingBracketMatchIndex(fields, firstBracket) + 1 + ); + fields = fields.replace(noset, ""); + } + const re = /((^\s*|,)\s*)(("(\\"|[^"])*")|('(\\'|[^'])*')|[^,]*)/gm; + const fieldsArray = fields.match(re) || []; + if (!fieldsArray) return []; + return fieldsArray.map((a) => a.replace(/^[\s,]+/, "")); + } + function findClosingBracketMatchIndex(str, pos) { + if (str[pos] !== "(") throw new Error(`No '(' at index ${pos}`); + let depth = 1; + for (let i = pos + 1; i < str.length; i++) { + switch (str[i]) { + case "(": + depth++; + break; + case ")": + if (--depth === 0) return i; + break; + } + } + return -1; + } + function defineComponent(tagName, componentClass) { + if (!customElements.get(tagName)) { + customElements.define(tagName, componentClass); + } else { + console.warn( + `Warning: the component "${tagName}" has already been loaded in another version of sib-core.` + ); + } + } + function fuzzyCompare(subject, search) { + return compareTransform(subject).includes(compareTransform(String(search))); + } + function compareTransform(str) { + return str.normalize("NFD").replaceAll(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase().replaceAll("œ", "oe").replaceAll("æ", "ae").replaceAll(/[ ,.!?;:-`"]+/g, " ").trim(); + } + const compare = { + string(subject, query) { + if (typeof subject !== "string" || typeof query !== "string") + throw new TypeError("not a string"); + if (query === "") return true; + return fuzzyCompare(subject, String(query)); + }, + boolean(subject, query) { + if (!query) return true; + return subject; + }, + number(subject, query) { + return subject === query; + }, + list(subject, list) { + return list.includes(subject); + }, + range(subject, range) { + return (range[0] == null || range[0] === "" || subject >= range[0]) && (range[1] == null || range[1] === "" || subject <= range[1]); + }, + resource(subject, query) { + if (query === "") return true; + if (!query["@id"]) return false; + const ret = subject["@id"] === query["@id"]; + return ret; + } + }; + function generalComparator(a, b, order = "asc") { + if (order === "desc") return generalComparator(b, a); + if (a == null && b == null) return 0; + if (a === b || Object.is(a, b)) return 0; + if (typeof a === "boolean" && typeof b === "boolean") { + return a === b ? 0 : a ? 1 : -1; + } + if (!Number.isNaN(Number(a)) && !Number.isNaN(Number(b))) { + return Number(a) - Number(b); + } + if (Array.isArray(a) && Array.isArray(b)) { + return a.length - b.length; + } + const dateA = Date.parse(String(a)); + const dateB = Date.parse(String(b)); + if (!Number.isNaN(dateA) && !Number.isNaN(dateB)) { + return dateA - dateB; + } + if (a && b && typeof a === "object" && typeof b === "object") { + const aKeys = Object.keys(a); + const bKeys = Object.keys(b); + return aKeys.length - bKeys.length; + } + if (a == null) return -1; + if (b == null) return 1; + return String(a).localeCompare(String(b)); + } + function transformArrayToContainer(resource) { + const newValue = { ...resource }; + for (const predicate of Object.keys(newValue)) { + const predicateValue = newValue[predicate]; + if (!predicateValue || typeof predicateValue !== "object") continue; + if (["permissions", "@context"].includes(predicate)) continue; + if (!Array.isArray(predicateValue) && predicateValue["@id"]) { + newValue[predicate] = transformArrayToContainer(resource[predicate]); + } + if (Array.isArray(predicateValue) && predicateValue["@id"]) { + newValue[predicate] = { + "@id": predicateValue["@id"], + "ldp:contains": [...predicateValue] + // ???? why only ldp:contains? + }; + newValue[predicate]["ldp:contains"].forEach( + (childPredicate, index) => { + newValue[predicate]["ldp:contains"][index] = transformArrayToContainer(childPredicate); + } + ); + } + } + return newValue; + } + function doesResourceContainList(resource) { + const predicates = ["ldp:contains", "dcat:dataset"]; + return predicates.some( + (predicate) => typeof resource === "object" ? predicate in resource : typeof resource === "string" && resource.includes(predicate) + ); + } + class AsyncIterableBuilder { + constructor() { + __privateAdd(this, _AsyncIterableBuilder_instances); + __privateAdd(this, _values, []); + __privateAdd(this, _resolve); + __publicField(this, "iterable"); + __publicField(this, "next"); + __privateMethod(this, _AsyncIterableBuilder_instances, nextPromise_fn).call(this); + this.iterable = __privateMethod(this, _AsyncIterableBuilder_instances, createIterable_fn).call(this); + this.next = __privateMethod(this, _AsyncIterableBuilder_instances, next_fn).bind(this); + } + } + _values = new WeakMap(); + _resolve = new WeakMap(); + _AsyncIterableBuilder_instances = new WeakSet(); + createIterable_fn = async function* () { + for (let index = 0; ; index++) { + const { value, done } = await __privateGet(this, _values)[index]; + delete __privateGet(this, _values)[index]; + yield value; + if (done) return; + } + }; + next_fn = function(value, done = false) { + __privateGet(this, _resolve).call(this, { value, done }); + __privateMethod(this, _AsyncIterableBuilder_instances, nextPromise_fn).call(this); + }; + nextPromise_fn = function() { + __privateGet(this, _values).push( + new Promise((resolve) => { + __privateSet(this, _resolve, resolve); + }) + ); + }; + const asyncQuerySelector = (selector, parent = document) => new Promise((resolve) => { + const element = parent.querySelector(selector); + if (element) return resolve(element); + const observer = new MutationObserver(() => { + const element2 = parent.querySelector(selector); + if (!element2) return; + observer.disconnect(); + return resolve(element2); + }); + observer.observe(parent, { + subtree: true, + childList: true, + attributes: true + }); + }); + function isUrlOrRelativePath(value) { + if (typeof value !== "string") return false; + if (value.startsWith("_:")) return false; + if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(value)) return true; + if (value.startsWith("/")) return true; + return false; + } + const asyncQuerySelectorAll = (selector, parent = document) => { + const delivered = /* @__PURE__ */ new WeakSet(); + const { next, iterable } = new AsyncIterableBuilder(); + function checkNewElement() { + for (const element of parent.querySelectorAll(selector)) { + if (delivered.has(element)) continue; + delivered.add(element); + next(element); + } + } + checkNewElement(); + const observer = new MutationObserver(checkNewElement); + observer.observe(parent, { + subtree: true, + childList: true, + attributes: true + }); + return iterable; + }; + const mergeContexts = (client, server) => ({ + ...getRawContext(client), + ...getRawContext(server) + }); + const normalizeContext = (ctx, fallbackCtx = null) => { + if (ctx && !(ctx instanceof jsonldContextParserExports.JsonLdContextNormalized)) { + return new jsonldContextParserExports.JsonLdContextNormalized(ctx); + } + if (!ctx && fallbackCtx) { + return normalizeContext(fallbackCtx); + } + return ctx; + }; + const getRawContext = (ctx) => { + if (!ctx) return ctx; + if (ctx instanceof jsonldContextParserExports.JsonLdContextNormalized) { + return ctx.getContextRaw(); + } + if (Array.isArray(ctx)) { + return ctx.map(getRawContext); + } + if (ctx && typeof ctx === "object" && "contextRaw" in ctx) { + return ctx.contextRaw; + } + return ctx; + }; + const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + AsyncIterableBuilder, + asyncQuerySelector, + asyncQuerySelectorAll, + compare, + default: AsyncIterableBuilder, + defineComponent, + doesResourceContainList, + domIsReady, + evalTemplateString, + findClosingBracketMatchIndex, + fuzzyCompare, + generalComparator, + getRawContext, + importCSS, + importInlineCSS, + importJS, + isUrlOrRelativePath, + loadScript, + mergeContexts, + normalizeContext, + parseFieldsString, + setDeepProperty, + stringToDom, + transformArrayToContainer, + uniqID + }, Symbol.toStringTag, { value: "Module" })); + export { + AsyncIterableBuilder as A, + doesResourceContainList as a, + fuzzyCompare as b, + compare as c, + defineComponent as d, + evalTemplateString as e, + findClosingBracketMatchIndex as f, + generalComparator as g, + asyncQuerySelector as h, + importInlineCSS as i, + importCSS as j, + helpers as k, + getRawContext as l, + mergeContexts as m, + normalizeContext as n, + isUrlOrRelativePath as o, + parseFieldsString as p, + jsonldContextParserExports as q, + stringToDom as r, + setDeepProperty as s, + transformArrayToContainer as t, + uniqID as u, + importJS as v, + loadScript as w, + domIsReady as x, + asyncQuerySelectorAll as y + }; + recorded_at: Tue, 29 Jul 2025 06:27:14 GMT +- request: + method: get + uri: https://cdn.jsdelivr.net/npm/@startinblox/core@latest/dist/store-1t_BHzwg.js + body: + encoding: UTF-8 + string: '' + headers: + Connection: + - close + Origin: + - http://127.0.0.1:34777 + Sec-Ch-Ua-Platform: + - '"Linux"' + User-Agent: + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 + Safari/537.36 + Sec-Ch-Ua: + - '"Not)A;Brand";v="8", "Chromium";v="138"' + Sec-Ch-Ua-Mobile: + - "?0" + Accept: + - "*/*" + Sec-Fetch-Site: + - cross-site + Sec-Fetch-Mode: + - cors + Sec-Fetch-Dest: + - script + Referer: + - https://cdn.jsdelivr.net/npm/@startinblox/core@latest/dist/index.js + Accept-Encoding: + - '' + Accept-Language: + - en-US,en;q=0.9 + response: + status: + code: 200 + message: OK + headers: + Connection: + - close + Content-Length: + - '321569' + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - "*" + Timing-Allow-Origin: + - "*" + Cache-Control: + - public, max-age=604800, s-maxage=43200 + Cross-Origin-Resource-Policy: + - cross-origin + X-Content-Type-Options: + - nosniff + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Content-Type: + - application/javascript; charset=utf-8 X-Jsd-Version: - 2.0.1 X-Jsd-Version-Type: - version Etag: - W/"4e821-Wo0eXFslANPU2cEPypsqG0W8lDU" + Accept-Ranges: + - bytes + Date: + - Tue, 29 Jul 2025 06:27:14 GMT + Age: + - '9554' X-Served-By: - - cache-fra-etou8220051-FRA, cache-lga21952-LGA + - cache-fra-etou8220051-FRA, cache-mel11229-MEL X-Cache: - HIT, HIT Vary: - Accept-Encoding Alt-Svc: - - h3=":443"; ma=86400 - Cf-Cache-Status: - - HIT - Age: - - '7602' - Report-To: - - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=kOyd6WEEbnF4GG8Wh7ONK5lhT7GTJqPbrGJccTs%2F2UUwaFWvV%2B3BkB6hgI8lMC10PGw93o3mhoaGWnli6QLLJ9GI0dyT6ojBRHW%2BlHC5e2vA%2BrqEUWpGnfF%2B%2FHlf5iGxN0k%3D"}],"group":"cf-nel","max_age":604800}' - Nel: - - '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}' - Server: - - cloudflare - Cf-Ray: - - 9669eebaabdd7c19-MEL + - h3=":443";ma=86400,h3-29=":443";ma=86400,h3-27=":443";ma=86400 body: encoding: UTF-8 string: "var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, @@ -51533,2324 +53698,7 @@ http_interactions: as a,\n base_context as b,\n commonjsGlobal as c,\n formatAttributesToServerPaginationOptions as f,\n getDefaultExportFromCjs as g,\n mergeServerSearchOptions as m,\n \ store as s\n};\n" - recorded_at: Tue, 29 Jul 2025 04:39:27 GMT -- request: - method: get - uri: https://cdn.jsdelivr.net/npm/@startinblox/core@latest/dist/helpers-4GFJ8HI8.js - body: - encoding: UTF-8 - string: '' - headers: - Connection: - - close - Origin: - - http://127.0.0.1:37737 - Sec-Ch-Ua-Platform: - - '"Linux"' - User-Agent: - - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/138.0.0.0 - Safari/537.36 - Sec-Ch-Ua: - - '"Not)A;Brand";v="8", "Chromium";v="138"' - Sec-Ch-Ua-Mobile: - - "?0" - Accept: - - "*/*" - Sec-Fetch-Site: - - cross-site - Sec-Fetch-Mode: - - cors - Sec-Fetch-Dest: - - script - Referer: - - https://cdn.jsdelivr.net/npm/@startinblox/core@latest/dist/index.js - Accept-Encoding: - - '' - Accept-Language: - - en-US,en;q=0.9 - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 29 Jul 2025 04:39:27 GMT - Content-Type: - - application/javascript; charset=utf-8 - Transfer-Encoding: - - chunked - Connection: - - close - Access-Control-Allow-Origin: - - "*" - Access-Control-Expose-Headers: - - "*" - Timing-Allow-Origin: - - "*" - Cache-Control: - - public, max-age=604800, s-maxage=43200 - Cross-Origin-Resource-Policy: - - cross-origin - X-Content-Type-Options: - - nosniff - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload - X-Jsd-Version: - - 2.0.0 - X-Jsd-Version-Type: - - version - Etag: - - W/"15e43-WgeU3/rOTachL5EAwu/6EzDk130" - X-Served-By: - - cache-fra-etou8220177-FRA, cache-lga21967-LGA - X-Cache: - - HIT, HIT - Vary: - - Accept-Encoding - Alt-Svc: - - h3=":443"; ma=86400 - Cf-Cache-Status: - - HIT - Age: - - '7602' - Report-To: - - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=64PLfniLefKg%2Boatfz0tulN5Nt3cSAn9%2F85lZBl4VeEJD7OuGiwyGbIF9a6BMBO%2FuRlfOOiTVAJKtKlbmfc2je2uSWBysEQmbuCP3myiA8FvheKes9P%2F0NXPZUNdcrGVrQE%3D"}],"group":"cf-nel","max_age":604800}' - Nel: - - '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}' - Server: - - cloudflare - Cf-Ray: - - 9669eebaab9877db-MEL - body: - encoding: UTF-8 - string: | - var __defProp = Object.defineProperty; - var __typeError = (msg) => { - throw TypeError(msg); - }; - var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; - var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); - var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); - var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)); - var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); - var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); - var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method); - var _values, _resolve, _AsyncIterableBuilder_instances, createIterable_fn, next_fn, nextPromise_fn; - var jsonldContextParser = {}; - var ContextParser = {}; - var relativeToAbsoluteIri = {}; - var Resolve = {}; - var hasRequiredResolve; - function requireResolve() { - if (hasRequiredResolve) return Resolve; - hasRequiredResolve = 1; - Object.defineProperty(Resolve, "__esModule", { value: true }); - Resolve.removeDotSegmentsOfPath = Resolve.removeDotSegments = Resolve.resolve = void 0; - function resolve(relativeIRI, baseIRI) { - baseIRI = baseIRI || ""; - const baseFragmentPos = baseIRI.indexOf("#"); - if (baseFragmentPos > 0) { - baseIRI = baseIRI.substr(0, baseFragmentPos); - } - if (!relativeIRI.length) { - if (baseIRI.indexOf(":") < 0) { - throw new Error(`Found invalid baseIRI '${baseIRI}' for value '${relativeIRI}'`); - } - return baseIRI; - } - if (relativeIRI.startsWith("?")) { - const baseQueryPos = baseIRI.indexOf("?"); - if (baseQueryPos > 0) { - baseIRI = baseIRI.substr(0, baseQueryPos); - } - return baseIRI + relativeIRI; - } - if (relativeIRI.startsWith("#")) { - return baseIRI + relativeIRI; - } - if (!baseIRI.length) { - const relativeColonPos = relativeIRI.indexOf(":"); - if (relativeColonPos < 0) { - throw new Error(`Found invalid relative IRI '${relativeIRI}' for a missing baseIRI`); - } - return removeDotSegmentsOfPath(relativeIRI, relativeColonPos); - } - const valueColonPos = relativeIRI.indexOf(":"); - if (valueColonPos >= 0) { - return removeDotSegmentsOfPath(relativeIRI, valueColonPos); - } - const baseColonPos = baseIRI.indexOf(":"); - if (baseColonPos < 0) { - throw new Error(`Found invalid baseIRI '${baseIRI}' for value '${relativeIRI}'`); - } - const baseIRIScheme = baseIRI.substr(0, baseColonPos + 1); - if (relativeIRI.indexOf("//") === 0) { - return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos); - } - let baseSlashAfterColonPos; - if (baseIRI.indexOf("//", baseColonPos) === baseColonPos + 1) { - baseSlashAfterColonPos = baseIRI.indexOf("/", baseColonPos + 3); - if (baseSlashAfterColonPos < 0) { - if (baseIRI.length > baseColonPos + 3) { - return baseIRI + "/" + removeDotSegmentsOfPath(relativeIRI, valueColonPos); - } else { - return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos); - } - } - } else { - baseSlashAfterColonPos = baseIRI.indexOf("/", baseColonPos + 1); - if (baseSlashAfterColonPos < 0) { - return baseIRIScheme + removeDotSegmentsOfPath(relativeIRI, valueColonPos); - } - } - if (relativeIRI.indexOf("/") === 0) { - return baseIRI.substr(0, baseSlashAfterColonPos) + removeDotSegments(relativeIRI); - } - let baseIRIPath = baseIRI.substr(baseSlashAfterColonPos); - const baseIRILastSlashPos = baseIRIPath.lastIndexOf("/"); - if (baseIRILastSlashPos >= 0 && baseIRILastSlashPos < baseIRIPath.length - 1) { - baseIRIPath = baseIRIPath.substr(0, baseIRILastSlashPos + 1); - if (relativeIRI[0] === "." && relativeIRI[1] !== "." && relativeIRI[1] !== "/" && relativeIRI[2]) { - relativeIRI = relativeIRI.substr(1); - } - } - relativeIRI = baseIRIPath + relativeIRI; - relativeIRI = removeDotSegments(relativeIRI); - return baseIRI.substr(0, baseSlashAfterColonPos) + relativeIRI; - } - Resolve.resolve = resolve; - function removeDotSegments(path) { - const segmentBuffers = []; - let i = 0; - while (i < path.length) { - switch (path[i]) { - case "/": - if (path[i + 1] === ".") { - if (path[i + 2] === ".") { - if (!isCharacterAllowedAfterRelativePathSegment(path[i + 3])) { - segmentBuffers.push([]); - i++; - break; - } - segmentBuffers.pop(); - if (!path[i + 3]) { - segmentBuffers.push([]); - } - i += 3; - } else { - if (!isCharacterAllowedAfterRelativePathSegment(path[i + 2])) { - segmentBuffers.push([]); - i++; - break; - } - if (!path[i + 2]) { - segmentBuffers.push([]); - } - i += 2; - } - } else { - segmentBuffers.push([]); - i++; - } - break; - case "#": - case "?": - if (!segmentBuffers.length) { - segmentBuffers.push([]); - } - segmentBuffers[segmentBuffers.length - 1].push(path.substr(i)); - i = path.length; - break; - default: - if (!segmentBuffers.length) { - segmentBuffers.push([]); - } - segmentBuffers[segmentBuffers.length - 1].push(path[i]); - i++; - break; - } - } - return "/" + segmentBuffers.map((buffer) => buffer.join("")).join("/"); - } - Resolve.removeDotSegments = removeDotSegments; - function removeDotSegmentsOfPath(iri, colonPosition) { - let searchOffset = colonPosition + 1; - if (colonPosition >= 0) { - if (iri[colonPosition + 1] === "/" && iri[colonPosition + 2] === "/") { - searchOffset = colonPosition + 3; - } - } else { - if (iri[0] === "/" && iri[1] === "/") { - searchOffset = 2; - } - } - const pathSeparator = iri.indexOf("/", searchOffset); - if (pathSeparator < 0) { - return iri; - } - const base = iri.substr(0, pathSeparator); - const path = iri.substr(pathSeparator); - return base + removeDotSegments(path); - } - Resolve.removeDotSegmentsOfPath = removeDotSegmentsOfPath; - function isCharacterAllowedAfterRelativePathSegment(character) { - return !character || character === "#" || character === "?" || character === "/"; - } - return Resolve; - } - var hasRequiredRelativeToAbsoluteIri; - function requireRelativeToAbsoluteIri() { - if (hasRequiredRelativeToAbsoluteIri) return relativeToAbsoluteIri; - hasRequiredRelativeToAbsoluteIri = 1; - (function(exports) { - var __createBinding = relativeToAbsoluteIri && relativeToAbsoluteIri.__createBinding || (Object.create ? function(o, m, k, k2) { - if (k2 === void 0) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { - return m[k]; - } }); - } : function(o, m, k, k2) { - if (k2 === void 0) k2 = k; - o[k2] = m[k]; - }); - var __exportStar = relativeToAbsoluteIri && relativeToAbsoluteIri.__exportStar || function(m, exports2) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - __exportStar(requireResolve(), exports); - })(relativeToAbsoluteIri); - return relativeToAbsoluteIri; - } - var ErrorCoded = {}; - var hasRequiredErrorCoded; - function requireErrorCoded() { - if (hasRequiredErrorCoded) return ErrorCoded; - hasRequiredErrorCoded = 1; - (function(exports) { - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ERROR_CODES = exports.ErrorCoded = void 0; - class ErrorCoded2 extends Error { - /* istanbul ignore next */ - constructor(message, code) { - super(message); - this.code = code; - } - } - exports.ErrorCoded = ErrorCoded2; - (function(ERROR_CODES) { - ERROR_CODES["COLLIDING_KEYWORDS"] = "colliding keywords"; - ERROR_CODES["CONFLICTING_INDEXES"] = "conflicting indexes"; - ERROR_CODES["CYCLIC_IRI_MAPPING"] = "cyclic IRI mapping"; - ERROR_CODES["INVALID_ID_VALUE"] = "invalid @id value"; - ERROR_CODES["INVALID_INDEX_VALUE"] = "invalid @index value"; - ERROR_CODES["INVALID_NEST_VALUE"] = "invalid @nest value"; - ERROR_CODES["INVALID_PREFIX_VALUE"] = "invalid @prefix value"; - ERROR_CODES["INVALID_PROPAGATE_VALUE"] = "invalid @propagate value"; - ERROR_CODES["INVALID_REVERSE_VALUE"] = "invalid @reverse value"; - ERROR_CODES["INVALID_IMPORT_VALUE"] = "invalid @import value"; - ERROR_CODES["INVALID_VERSION_VALUE"] = "invalid @version value"; - ERROR_CODES["INVALID_BASE_IRI"] = "invalid base IRI"; - ERROR_CODES["INVALID_CONTAINER_MAPPING"] = "invalid container mapping"; - ERROR_CODES["INVALID_CONTEXT_ENTRY"] = "invalid context entry"; - ERROR_CODES["INVALID_CONTEXT_NULLIFICATION"] = "invalid context nullification"; - ERROR_CODES["INVALID_DEFAULT_LANGUAGE"] = "invalid default language"; - ERROR_CODES["INVALID_INCLUDED_VALUE"] = "invalid @included value"; - ERROR_CODES["INVALID_IRI_MAPPING"] = "invalid IRI mapping"; - ERROR_CODES["INVALID_JSON_LITERAL"] = "invalid JSON literal"; - ERROR_CODES["INVALID_KEYWORD_ALIAS"] = "invalid keyword alias"; - ERROR_CODES["INVALID_LANGUAGE_MAP_VALUE"] = "invalid language map value"; - ERROR_CODES["INVALID_LANGUAGE_MAPPING"] = "invalid language mapping"; - ERROR_CODES["INVALID_LANGUAGE_TAGGED_STRING"] = "invalid language-tagged string"; - ERROR_CODES["INVALID_LANGUAGE_TAGGED_VALUE"] = "invalid language-tagged value"; - ERROR_CODES["INVALID_LOCAL_CONTEXT"] = "invalid local context"; - ERROR_CODES["INVALID_REMOTE_CONTEXT"] = "invalid remote context"; - ERROR_CODES["INVALID_REVERSE_PROPERTY"] = "invalid reverse property"; - ERROR_CODES["INVALID_REVERSE_PROPERTY_MAP"] = "invalid reverse property map"; - ERROR_CODES["INVALID_REVERSE_PROPERTY_VALUE"] = "invalid reverse property value"; - ERROR_CODES["INVALID_SCOPED_CONTEXT"] = "invalid scoped context"; - ERROR_CODES["INVALID_SCRIPT_ELEMENT"] = "invalid script element"; - ERROR_CODES["INVALID_SET_OR_LIST_OBJECT"] = "invalid set or list object"; - ERROR_CODES["INVALID_TERM_DEFINITION"] = "invalid term definition"; - ERROR_CODES["INVALID_TYPE_MAPPING"] = "invalid type mapping"; - ERROR_CODES["INVALID_TYPE_VALUE"] = "invalid type value"; - ERROR_CODES["INVALID_TYPED_VALUE"] = "invalid typed value"; - ERROR_CODES["INVALID_VALUE_OBJECT"] = "invalid value object"; - ERROR_CODES["INVALID_VALUE_OBJECT_VALUE"] = "invalid value object value"; - ERROR_CODES["INVALID_VOCAB_MAPPING"] = "invalid vocab mapping"; - ERROR_CODES["IRI_CONFUSED_WITH_PREFIX"] = "IRI confused with prefix"; - ERROR_CODES["KEYWORD_REDEFINITION"] = "keyword redefinition"; - ERROR_CODES["LOADING_DOCUMENT_FAILED"] = "loading document failed"; - ERROR_CODES["LOADING_REMOTE_CONTEXT_FAILED"] = "loading remote context failed"; - ERROR_CODES["MULTIPLE_CONTEXT_LINK_HEADERS"] = "multiple context link headers"; - ERROR_CODES["PROCESSING_MODE_CONFLICT"] = "processing mode conflict"; - ERROR_CODES["PROTECTED_TERM_REDEFINITION"] = "protected term redefinition"; - ERROR_CODES["CONTEXT_OVERFLOW"] = "context overflow"; - ERROR_CODES["INVALID_BASE_DIRECTION"] = "invalid base direction"; - ERROR_CODES["RECURSIVE_CONTEXT_INCLUSION"] = "recursive context inclusion"; - ERROR_CODES["INVALID_STREAMING_KEY_ORDER"] = "invalid streaming key order"; - ERROR_CODES["INVALID_EMBEDDED_NODE"] = "invalid embedded node"; - ERROR_CODES["INVALID_ANNOTATION"] = "invalid annotation"; - })(exports.ERROR_CODES || (exports.ERROR_CODES = {})); - })(ErrorCoded); - return ErrorCoded; - } - var FetchDocumentLoader = {}; - var link; - var hasRequiredLink; - function requireLink() { - if (hasRequiredLink) return link; - hasRequiredLink = 1; - var COMPATIBLE_ENCODING_PATTERN = /^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i; - var WS_TRIM_PATTERN = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; - var WS_CHAR_PATTERN = /\s|\uFEFF|\xA0/; - var WS_FOLD_PATTERN = /\r?\n[\x20\x09]+/g; - var DELIMITER_PATTERN = /[;,"]/; - var WS_DELIMITER_PATTERN = /[;,"]|\s/; - var TOKEN_PATTERN = /^[!#$%&'*+\-\.^_`|~\da-zA-Z]+$/; - var STATE = { - IDLE: 1 << 0, - URI: 1 << 1, - ATTR: 1 << 2 - }; - function trim(value) { - return value.replace(WS_TRIM_PATTERN, ""); - } - function hasWhitespace(value) { - return WS_CHAR_PATTERN.test(value); - } - function skipWhitespace(value, offset) { - while (hasWhitespace(value[offset])) { - offset++; - } - return offset; - } - function needsQuotes(value) { - return WS_DELIMITER_PATTERN.test(value) || !TOKEN_PATTERN.test(value); - } - function shallowCompareObjects(object1, object2) { - return Object.keys(object1).length === Object.keys(object2).length && Object.keys(object1).every( - (key) => key in object2 && object1[key] === object2[key] - ); - } - class Link { - /** - * Link - * @constructor - * @param {String} [value] - * @returns {Link} - */ - constructor(value) { - this.refs = []; - if (value) { - this.parse(value); - } - } - /** - * Get refs with given relation type - * @param {String} value - * @returns {Array} - */ - rel(value) { - var links = []; - var type = value.toLowerCase(); - for (var i = 0; i < this.refs.length; i++) { - if (typeof this.refs[i].rel === "string" && this.refs[i].rel.toLowerCase() === type) { - links.push(this.refs[i]); - } - } - return links; - } - /** - * Get refs where given attribute has a given value - * @param {String} attr - * @param {String} value - * @returns {Array} - */ - get(attr, value) { - attr = attr.toLowerCase(); - value = value.toLowerCase(); - var links = []; - for (var i = 0; i < this.refs.length; i++) { - if (typeof this.refs[i][attr] === "string" && this.refs[i][attr].toLowerCase() === value) { - links.push(this.refs[i]); - } - } - return links; - } - /** Sets a reference. */ - set(link2) { - this.refs.push(link2); - return this; - } - /** - * Sets a reference if a reference with similar properties isn’t already set. - */ - setUnique(link2) { - if (!this.refs.some((ref) => shallowCompareObjects(ref, link2))) { - this.refs.push(link2); - } - return this; - } - has(attr, value) { - attr = attr.toLowerCase(); - value = value.toLowerCase(); - for (var i = 0; i < this.refs.length; i++) { - if (typeof this.refs[i][attr] === "string" && this.refs[i][attr].toLowerCase() === value) { - return true; - } - } - return false; - } - parse(value, offset) { - offset = offset || 0; - value = offset ? value.slice(offset) : value; - value = trim(value).replace(WS_FOLD_PATTERN, ""); - var state = STATE.IDLE; - var length = value.length; - var offset = 0; - var ref = null; - while (offset < length) { - if (state === STATE.IDLE) { - if (hasWhitespace(value[offset])) { - offset++; - continue; - } else if (value[offset] === "<") { - if (ref != null) { - ref.rel != null ? this.refs.push(...Link.expandRelations(ref)) : this.refs.push(ref); - } - var end = value.indexOf(">", offset); - if (end === -1) throw new Error("Expected end of URI delimiter at offset " + offset); - ref = { uri: value.slice(offset + 1, end) }; - offset = end; - state = STATE.URI; - } else { - throw new Error('Unexpected character "' + value[offset] + '" at offset ' + offset); - } - offset++; - } else if (state === STATE.URI) { - if (hasWhitespace(value[offset])) { - offset++; - continue; - } else if (value[offset] === ";") { - state = STATE.ATTR; - offset++; - } else if (value[offset] === ",") { - state = STATE.IDLE; - offset++; - } else { - throw new Error('Unexpected character "' + value[offset] + '" at offset ' + offset); - } - } else if (state === STATE.ATTR) { - if (value[offset] === ";" || hasWhitespace(value[offset])) { - offset++; - continue; - } - var end = value.indexOf("=", offset); - if (end === -1) end = value.indexOf(";", offset); - if (end === -1) end = value.length; - var attr = trim(value.slice(offset, end)).toLowerCase(); - var attrValue = ""; - offset = end + 1; - offset = skipWhitespace(value, offset); - if (value[offset] === '"') { - offset++; - while (offset < length) { - if (value[offset] === '"') { - offset++; - break; - } - if (value[offset] === "\\") { - offset++; - } - attrValue += value[offset]; - offset++; - } - } else { - var end = offset + 1; - while (!DELIMITER_PATTERN.test(value[end]) && end < length) { - end++; - } - attrValue = value.slice(offset, end); - offset = end; - } - if (ref[attr] && Link.isSingleOccurenceAttr(attr)) ; - else if (attr[attr.length - 1] === "*") { - ref[attr] = Link.parseExtendedValue(attrValue); - } else { - attrValue = attr === "type" ? attrValue.toLowerCase() : attrValue; - if (ref[attr] != null) { - if (Array.isArray(ref[attr])) { - ref[attr].push(attrValue); - } else { - ref[attr] = [ref[attr], attrValue]; - } - } else { - ref[attr] = attrValue; - } - } - switch (value[offset]) { - case ",": - state = STATE.IDLE; - break; - case ";": - state = STATE.ATTR; - break; - } - offset++; - } else { - throw new Error('Unknown parser state "' + state + '"'); - } - } - if (ref != null) { - ref.rel != null ? this.refs.push(...Link.expandRelations(ref)) : this.refs.push(ref); - } - ref = null; - return this; - } - toString() { - var refs = []; - var link2 = ""; - var ref = null; - for (var i = 0; i < this.refs.length; i++) { - ref = this.refs[i]; - link2 = Object.keys(this.refs[i]).reduce(function(link3, attr) { - if (attr === "uri") return link3; - return link3 + "; " + Link.formatAttribute(attr, ref[attr]); - }, "<" + ref.uri + ">"); - refs.push(link2); - } - return refs.join(", "); - } - } - Link.isCompatibleEncoding = function(value) { - return COMPATIBLE_ENCODING_PATTERN.test(value); - }; - Link.parse = function(value, offset) { - return new Link().parse(value, offset); - }; - Link.isSingleOccurenceAttr = function(attr) { - return attr === "rel" || attr === "type" || attr === "media" || attr === "title" || attr === "title*"; - }; - Link.isTokenAttr = function(attr) { - return attr === "rel" || attr === "type" || attr === "anchor"; - }; - Link.escapeQuotes = function(value) { - return value.replace(/"/g, '\\"'); - }; - Link.expandRelations = function(ref) { - var rels = ref.rel.split(" "); - return rels.map(function(rel) { - var value = Object.assign({}, ref); - value.rel = rel; - return value; - }); - }; - Link.parseExtendedValue = function(value) { - var parts = /([^']+)?(?:'([^']*)')?(.+)/.exec(value); - return { - language: parts[2].toLowerCase(), - encoding: Link.isCompatibleEncoding(parts[1]) ? null : parts[1].toLowerCase(), - value: Link.isCompatibleEncoding(parts[1]) ? decodeURIComponent(parts[3]) : parts[3] - }; - }; - Link.formatExtendedAttribute = function(attr, data) { - var encoding = (data.encoding || "utf-8").toUpperCase(); - var language = data.language || "en"; - var encodedValue = ""; - if (Buffer.isBuffer(data.value) && Link.isCompatibleEncoding(encoding)) { - encodedValue = data.value.toString(encoding); - } else if (Buffer.isBuffer(data.value)) { - encodedValue = data.value.toString("hex").replace(/[0-9a-f]{2}/gi, "%$1"); - } else { - encodedValue = encodeURIComponent(data.value); - } - return attr + "=" + encoding + "'" + language + "'" + encodedValue; - }; - Link.formatAttribute = function(attr, value) { - if (Array.isArray(value)) { - return value.map((item) => { - return Link.formatAttribute(attr, item); - }).join("; "); - } - if (attr[attr.length - 1] === "*" || typeof value !== "string") { - return Link.formatExtendedAttribute(attr, value); - } - if (Link.isTokenAttr(attr)) { - value = needsQuotes(value) ? '"' + Link.escapeQuotes(value) + '"' : Link.escapeQuotes(value); - } else if (needsQuotes(value)) { - value = encodeURIComponent(value); - value = value.replace(/%20/g, " ").replace(/%2C/g, ",").replace(/%3B/g, ";"); - value = '"' + value + '"'; - } - return attr + "=" + value; - }; - link = Link; - return link; - } - var hasRequiredFetchDocumentLoader; - function requireFetchDocumentLoader() { - if (hasRequiredFetchDocumentLoader) return FetchDocumentLoader; - hasRequiredFetchDocumentLoader = 1; - Object.defineProperty(FetchDocumentLoader, "__esModule", { value: true }); - FetchDocumentLoader.FetchDocumentLoader = void 0; - const ErrorCoded_1 = /* @__PURE__ */ requireErrorCoded(); - const http_link_header_1 = requireLink(); - const relative_to_absolute_iri_1 = requireRelativeToAbsoluteIri(); - let FetchDocumentLoader$1 = class FetchDocumentLoader { - constructor(fetcher) { - this.fetcher = fetcher; - } - async load(url) { - const response = await (this.fetcher || fetch)(url, { headers: new Headers({ accept: "application/ld+json" }) }); - if (response.ok && response.headers) { - let mediaType = response.headers.get("Content-Type"); - if (mediaType) { - const colonPos = mediaType.indexOf(";"); - if (colonPos > 0) { - mediaType = mediaType.substr(0, colonPos); - } - } - if (mediaType === "application/ld+json") { - return await response.json(); - } else { - if (response.headers.has("Link")) { - let alternateUrl; - response.headers.forEach((value, key) => { - if (key === "link") { - const linkHeader = (0, http_link_header_1.parse)(value); - for (const link2 of linkHeader.get("type", "application/ld+json")) { - if (link2.rel === "alternate") { - if (alternateUrl) { - throw new Error("Multiple JSON-LD alternate links were found on " + url); - } - alternateUrl = (0, relative_to_absolute_iri_1.resolve)(link2.uri, url); - } - } - } - }); - if (alternateUrl) { - return this.load(alternateUrl); - } - } - throw new ErrorCoded_1.ErrorCoded(`Unsupported JSON-LD media type ${mediaType}`, ErrorCoded_1.ERROR_CODES.LOADING_DOCUMENT_FAILED); - } - } else { - throw new Error(response.statusText || `Status code: ${response.status}`); - } - } - }; - FetchDocumentLoader.FetchDocumentLoader = FetchDocumentLoader$1; - return FetchDocumentLoader; - } - var JsonLdContextNormalized = {}; - var Util = {}; - var hasRequiredUtil; - function requireUtil() { - if (hasRequiredUtil) return Util; - hasRequiredUtil = 1; - Object.defineProperty(Util, "__esModule", { value: true }); - Util.Util = void 0; - let Util$1 = class Util2 { - /** - * Check if the given term is a valid compact IRI. - * Otherwise, it may be an IRI. - * @param {string} term A term. - * @return {boolean} If it is a compact IRI. - */ - static isCompactIri(term) { - return term.indexOf(":") > 0 && !(term && term[0] === "#"); - } - /** - * Get the prefix from the given term. - * @see https://json-ld.org/spec/latest/json-ld/#compact-iris - * @param {string} term A term that is an URL or a prefixed URL. - * @param {IJsonLdContextNormalizedRaw} context A context. - * @return {string} The prefix or null. - */ - static getPrefix(term, context) { - if (term && term[0] === "#") { - return null; - } - const separatorPos = term.indexOf(":"); - if (separatorPos >= 0) { - if (term.length > separatorPos + 1 && term.charAt(separatorPos + 1) === "/" && term.charAt(separatorPos + 2) === "/") { - return null; - } - const prefix = term.substr(0, separatorPos); - if (prefix === "_") { - return null; - } - if (context[prefix]) { - return prefix; - } - } - return null; - } - /** - * From a given context entry value, get the string value, or the @id field. - * @param contextValue A value for a term in a context. - * @return {string} The id value, or null. - */ - static getContextValueId(contextValue) { - if (contextValue === null || typeof contextValue === "string") { - return contextValue; - } - const id = contextValue["@id"]; - return id ? id : null; - } - /** - * Check if the given simple term definition (string-based value of a context term) - * should be considered a prefix. - * @param value A simple term definition value. - * @param options Options that define the way how expansion must be done. - */ - static isSimpleTermDefinitionPrefix(value, options) { - return !Util2.isPotentialKeyword(value) && (options.allowPrefixNonGenDelims || typeof value === "string" && (value[0] === "_" || Util2.isPrefixIriEndingWithGenDelim(value))); - } - /** - * Check if the given keyword is of the keyword format "@"1*ALPHA. - * @param {string} keyword A potential keyword. - * @return {boolean} If the given keyword is of the keyword format. - */ - static isPotentialKeyword(keyword) { - return typeof keyword === "string" && Util2.KEYWORD_REGEX.test(keyword); - } - /** - * Check if the given prefix ends with a gen-delim character. - * @param {string} prefixIri A prefix IRI. - * @return {boolean} If the given prefix IRI is valid. - */ - static isPrefixIriEndingWithGenDelim(prefixIri) { - return Util2.ENDS_WITH_GEN_DELIM.test(prefixIri); - } - /** - * Check if the given context value can be a prefix value. - * @param value A context value. - * @return {boolean} If it can be a prefix value. - */ - static isPrefixValue(value) { - return value && (typeof value === "string" || value && typeof value === "object"); - } - /** - * Check if the given IRI is valid. - * @param {string} iri A potential IRI. - * @return {boolean} If the given IRI is valid. - */ - static isValidIri(iri) { - return Boolean(iri && Util2.IRI_REGEX.test(iri)); - } - /** - * Check if the given IRI is valid, this includes the possibility of being a relative IRI. - * @param {string} iri A potential IRI. - * @return {boolean} If the given IRI is valid. - */ - static isValidIriWeak(iri) { - return !!iri && iri[0] !== ":" && Util2.IRI_REGEX_WEAK.test(iri); - } - /** - * Check if the given keyword is a defined according to the JSON-LD specification. - * @param {string} keyword A potential keyword. - * @return {boolean} If the given keyword is valid. - */ - static isValidKeyword(keyword) { - return Util2.VALID_KEYWORDS[keyword]; - } - /** - * Check if the given term is protected in the context. - * @param {IJsonLdContextNormalizedRaw} context A context. - * @param {string} key A context term. - * @return {boolean} If the given term has an @protected flag. - */ - static isTermProtected(context, key) { - const value = context[key]; - return !(typeof value === "string") && value && value["@protected"]; - } - /** - * Check if the given context has at least one protected term. - * @param context A context. - * @return If the context has a protected term. - */ - static hasProtectedTerms(context) { - for (const key of Object.keys(context)) { - if (Util2.isTermProtected(context, key)) { - return true; - } - } - return false; - } - /** - * Check if the given key is an internal reserved keyword. - * @param key A context key. - */ - static isReservedInternalKeyword(key) { - return key.startsWith("@__"); - } - /** - * Check if two objects are deepEqual to on another. - * @param object1 The first object to test. - * @param object2 The second object to test. - */ - static deepEqual(object1, object2) { - const objKeys1 = Object.keys(object1); - const objKeys2 = Object.keys(object2); - if (objKeys1.length !== objKeys2.length) - return false; - return objKeys1.every((key) => { - const value1 = object1[key]; - const value2 = object2[key]; - return value1 === value2 || value1 !== null && value2 !== null && typeof value1 === "object" && typeof value2 === "object" && this.deepEqual(value1, value2); - }); - } - }; - Util$1.IRI_REGEX = /^([A-Za-z][A-Za-z0-9+-.]*|_):[^ "<>{}|\\\[\]`#]*(#[^#]*)?$/; - Util$1.IRI_REGEX_WEAK = /(?::[^:])|\//; - Util$1.KEYWORD_REGEX = /^@[a-z]+$/i; - Util$1.ENDS_WITH_GEN_DELIM = /[:/?#\[\]@]$/; - Util$1.REGEX_LANGUAGE_TAG = /^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/; - Util$1.REGEX_DIRECTION_TAG = /^(ltr)|(rtl)$/; - Util$1.VALID_KEYWORDS = { - "@annotation": true, - "@base": true, - "@container": true, - "@context": true, - "@direction": true, - "@graph": true, - "@id": true, - "@import": true, - "@included": true, - "@index": true, - "@json": true, - "@language": true, - "@list": true, - "@nest": true, - "@none": true, - "@prefix": true, - "@propagate": true, - "@protected": true, - "@reverse": true, - "@set": true, - "@type": true, - "@value": true, - "@version": true, - "@vocab": true - }; - Util$1.EXPAND_KEYS_BLACKLIST = [ - "@base", - "@vocab", - "@language", - "@version", - "@direction" - ]; - Util$1.ALIAS_DOMAIN_BLACKLIST = [ - "@container", - "@graph", - "@id", - "@index", - "@list", - "@nest", - "@none", - "@prefix", - "@reverse", - "@set", - "@type", - "@value", - "@version" - ]; - Util$1.ALIAS_RANGE_BLACKLIST = [ - "@context", - "@preserve" - ]; - Util$1.CONTAINERS = [ - "@list", - "@set", - "@index", - "@language", - "@graph", - "@id", - "@type" - ]; - Util$1.CONTAINERS_1_0 = [ - "@list", - "@set", - "@index" - ]; - Util.Util = Util$1; - return Util; - } - var hasRequiredJsonLdContextNormalized; - function requireJsonLdContextNormalized() { - if (hasRequiredJsonLdContextNormalized) return JsonLdContextNormalized; - hasRequiredJsonLdContextNormalized = 1; - (function(exports) { - Object.defineProperty(exports, "__esModule", { value: true }); - exports.defaultExpandOptions = exports.JsonLdContextNormalized = void 0; - const relative_to_absolute_iri_1 = requireRelativeToAbsoluteIri(); - const ErrorCoded_1 = /* @__PURE__ */ requireErrorCoded(); - const Util_1 = /* @__PURE__ */ requireUtil(); - class JsonLdContextNormalized2 { - constructor(contextRaw) { - this.contextRaw = contextRaw; - } - /** - * @return The raw inner context. - */ - getContextRaw() { - return this.contextRaw; - } - /** - * Expand the term or prefix of the given term if it has one, - * otherwise return the term as-is. - * - * This will try to expand the IRI as much as possible. - * - * Iff in vocab-mode, then other references to other terms in the context can be used, - * such as to `myTerm`: - * ``` - * { - * "myTerm": "http://example.org/myLongTerm" - * } - * ``` - * - * @param {string} term A term that is an URL or a prefixed URL. - * @param {boolean} expandVocab If the term is a predicate or type and should be expanded based on @vocab, - * otherwise it is considered a regular term that is expanded based on @base. - * @param {IExpandOptions} options Options that define the way how expansion must be done. - * @return {string} The expanded term, the term as-is, or null if it was explicitly disabled in the context. - * @throws If the term is aliased to an invalid value (not a string, IRI or keyword). - */ - expandTerm(term, expandVocab, options = exports.defaultExpandOptions) { - const contextValue = this.contextRaw[term]; - if (contextValue === null || contextValue && contextValue["@id"] === null) { - return null; - } - let validIriMapping = true; - if (contextValue && expandVocab) { - const value = Util_1.Util.getContextValueId(contextValue); - if (value && value !== term) { - if (typeof value !== "string" || !Util_1.Util.isValidIri(value) && !Util_1.Util.isValidKeyword(value)) { - if (!Util_1.Util.isPotentialKeyword(value)) { - validIriMapping = false; - } - } else { - return value; - } - } - } - const prefix = Util_1.Util.getPrefix(term, this.contextRaw); - const vocab = this.contextRaw["@vocab"]; - const vocabRelative = (!!vocab || vocab === "") && vocab.indexOf(":") < 0; - const base = this.contextRaw["@base"]; - const potentialKeyword = Util_1.Util.isPotentialKeyword(term); - if (prefix) { - const contextPrefixValue = this.contextRaw[prefix]; - const value = Util_1.Util.getContextValueId(contextPrefixValue); - if (value) { - if (typeof contextPrefixValue === "string" || !options.allowPrefixForcing) { - if (!Util_1.Util.isSimpleTermDefinitionPrefix(value, options)) { - return term; - } - } else { - if (value[0] !== "_" && !potentialKeyword && !contextPrefixValue["@prefix"] && !(term in this.contextRaw)) { - return term; - } - } - return value + term.substr(prefix.length + 1); - } - } else if (expandVocab && (vocab || vocab === "" || options.allowVocabRelativeToBase && (base && vocabRelative)) && !potentialKeyword && !Util_1.Util.isCompactIri(term)) { - if (vocabRelative) { - if (options.allowVocabRelativeToBase) { - return (vocab || base ? (0, relative_to_absolute_iri_1.resolve)(vocab, base) : "") + term; - } else { - throw new ErrorCoded_1.ErrorCoded(`Relative vocab expansion for term '${term}' with vocab '${vocab}' is not allowed.`, ErrorCoded_1.ERROR_CODES.INVALID_VOCAB_MAPPING); - } - } else { - return vocab + term; - } - } else if (!expandVocab && base && !potentialKeyword && !Util_1.Util.isCompactIri(term)) { - return (0, relative_to_absolute_iri_1.resolve)(term, base); - } - if (validIriMapping) { - return term; - } else { - throw new ErrorCoded_1.ErrorCoded(`Invalid IRI mapping found for context entry '${term}': '${JSON.stringify(contextValue)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); - } - } - /** - * Compact the given term using @base, @vocab, an aliased term, or a prefixed term. - * - * This will try to compact the IRI as much as possible. - * - * @param {string} iri An IRI to compact. - * @param {boolean} vocab If the term is a predicate or type and should be compacted based on @vocab, - * otherwise it is considered a regular term that is compacted based on @base. - * @return {string} The compacted term or the IRI as-is. - */ - compactIri(iri, vocab) { - if (vocab && this.contextRaw["@vocab"] && iri.startsWith(this.contextRaw["@vocab"])) { - return iri.substr(this.contextRaw["@vocab"].length); - } - if (!vocab && this.contextRaw["@base"] && iri.startsWith(this.contextRaw["@base"])) { - return iri.substr(this.contextRaw["@base"].length); - } - const shortestPrefixing = { prefix: "", suffix: iri }; - for (const key in this.contextRaw) { - const value = this.contextRaw[key]; - if (value && !Util_1.Util.isPotentialKeyword(key)) { - const contextIri = Util_1.Util.getContextValueId(value); - if (iri.startsWith(contextIri)) { - const suffix = iri.substr(contextIri.length); - if (!suffix) { - if (vocab) { - return key; - } - } else if (suffix.length < shortestPrefixing.suffix.length) { - shortestPrefixing.prefix = key; - shortestPrefixing.suffix = suffix; - } - } - } - } - if (shortestPrefixing.prefix) { - return shortestPrefixing.prefix + ":" + shortestPrefixing.suffix; - } - return iri; - } - } - exports.JsonLdContextNormalized = JsonLdContextNormalized2; - exports.defaultExpandOptions = { - allowPrefixForcing: true, - allowPrefixNonGenDelims: false, - allowVocabRelativeToBase: true - }; - })(JsonLdContextNormalized); - return JsonLdContextNormalized; - } - var hasRequiredContextParser; - function requireContextParser() { - if (hasRequiredContextParser) return ContextParser; - hasRequiredContextParser = 1; - Object.defineProperty(ContextParser, "__esModule", { value: true }); - ContextParser.ContextParser = void 0; - const relative_to_absolute_iri_1 = requireRelativeToAbsoluteIri(); - const ErrorCoded_1 = /* @__PURE__ */ requireErrorCoded(); - const FetchDocumentLoader_1 = /* @__PURE__ */ requireFetchDocumentLoader(); - const JsonLdContextNormalized_1 = /* @__PURE__ */ requireJsonLdContextNormalized(); - const Util_1 = /* @__PURE__ */ requireUtil(); - let ContextParser$1 = class ContextParser2 { - constructor(options) { - options = options || {}; - this.documentLoader = options.documentLoader || new FetchDocumentLoader_1.FetchDocumentLoader(); - this.documentCache = {}; - this.validateContext = !options.skipValidation; - this.expandContentTypeToBase = !!options.expandContentTypeToBase; - this.remoteContextsDepthLimit = options.remoteContextsDepthLimit || 32; - this.redirectSchemaOrgHttps = "redirectSchemaOrgHttps" in options ? !!options.redirectSchemaOrgHttps : true; - } - /** - * Validate the given @language value. - * An error will be thrown if it is invalid. - * @param value An @language value. - * @param {boolean} strictRange If the string value should be strictly checked against a regex. - * @param {string} errorCode The error code to emit on errors. - * @return {boolean} If validation passed. - * Can only be false if strictRange is false and the string value did not pass the regex. - */ - static validateLanguage(value, strictRange, errorCode) { - if (typeof value !== "string") { - throw new ErrorCoded_1.ErrorCoded(`The value of an '@language' must be a string, got '${JSON.stringify(value)}'`, errorCode); - } - if (!Util_1.Util.REGEX_LANGUAGE_TAG.test(value)) { - if (strictRange) { - throw new ErrorCoded_1.ErrorCoded(`The value of an '@language' must be a valid language tag, got '${JSON.stringify(value)}'`, errorCode); - } else { - return false; - } - } - return true; - } - /** - * Validate the given @direction value. - * An error will be thrown if it is invalid. - * @param value An @direction value. - * @param {boolean} strictValues If the string value should be strictly checked against a regex. - * @return {boolean} If validation passed. - * Can only be false if strictRange is false and the string value did not pass the regex. - */ - static validateDirection(value, strictValues) { - if (typeof value !== "string") { - throw new ErrorCoded_1.ErrorCoded(`The value of an '@direction' must be a string, got '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_BASE_DIRECTION); - } - if (!Util_1.Util.REGEX_DIRECTION_TAG.test(value)) { - if (strictValues) { - throw new ErrorCoded_1.ErrorCoded(`The value of an '@direction' must be 'ltr' or 'rtl', got '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_BASE_DIRECTION); - } else { - return false; - } - } - return true; - } - /** - * Add an @id term for all @reverse terms. - * @param {IJsonLdContextNormalizedRaw} context A context. - * @return {IJsonLdContextNormalizedRaw} The mutated input context. - */ - idifyReverseTerms(context) { - for (const key of Object.keys(context)) { - let value = context[key]; - if (value && typeof value === "object") { - if (value["@reverse"] && !value["@id"]) { - if (typeof value["@reverse"] !== "string" || Util_1.Util.isValidKeyword(value["@reverse"])) { - throw new ErrorCoded_1.ErrorCoded(`Invalid @reverse value, must be absolute IRI or blank node: '${value["@reverse"]}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); - } - value = context[key] = Object.assign(Object.assign({}, value), { "@id": value["@reverse"] }); - value["@id"] = value["@reverse"]; - if (Util_1.Util.isPotentialKeyword(value["@reverse"])) { - delete value["@reverse"]; - } else { - value["@reverse"] = true; - } - } - } - } - return context; - } - /** - * Expand all prefixed terms in the given context. - * @param {IJsonLdContextNormalizedRaw} context A context. - * @param {boolean} expandContentTypeToBase If @type inside the context may be expanded - * via @base if @vocab is set to null. - * @param {string[]} keys Optional set of keys from the context to expand. If left undefined, all - * keys in the context will be expanded. - */ - expandPrefixedTerms(context, expandContentTypeToBase, keys) { - const contextRaw = context.getContextRaw(); - for (const key of keys || Object.keys(contextRaw)) { - if (Util_1.Util.EXPAND_KEYS_BLACKLIST.indexOf(key) < 0 && !Util_1.Util.isReservedInternalKeyword(key)) { - const keyValue = contextRaw[key]; - if (Util_1.Util.isPotentialKeyword(key) && Util_1.Util.ALIAS_DOMAIN_BLACKLIST.indexOf(key) >= 0) { - if (key !== "@type" || typeof contextRaw[key] === "object" && !(contextRaw[key]["@protected"] || contextRaw[key]["@container"] === "@set")) { - throw new ErrorCoded_1.ErrorCoded(`Keywords can not be aliased to something else. - Tried mapping ${key} to ${JSON.stringify(keyValue)}`, ErrorCoded_1.ERROR_CODES.KEYWORD_REDEFINITION); - } - } - if (Util_1.Util.ALIAS_RANGE_BLACKLIST.indexOf(Util_1.Util.getContextValueId(keyValue)) >= 0) { - throw new ErrorCoded_1.ErrorCoded(`Aliasing to certain keywords is not allowed. - Tried mapping ${key} to ${JSON.stringify(keyValue)}`, ErrorCoded_1.ERROR_CODES.INVALID_KEYWORD_ALIAS); - } - if (keyValue && Util_1.Util.isPotentialKeyword(Util_1.Util.getContextValueId(keyValue)) && keyValue["@prefix"] === true) { - throw new ErrorCoded_1.ErrorCoded(`Tried to use keyword aliases as prefix: '${key}': '${JSON.stringify(keyValue)}'`, ErrorCoded_1.ERROR_CODES.INVALID_TERM_DEFINITION); - } - while (Util_1.Util.isPrefixValue(contextRaw[key])) { - const value = contextRaw[key]; - let changed = false; - if (typeof value === "string") { - contextRaw[key] = context.expandTerm(value, true); - changed = changed || value !== contextRaw[key]; - } else { - const id = value["@id"]; - const type = value["@type"]; - const canAddIdEntry = !("@prefix" in value) || Util_1.Util.isValidIri(key); - if ("@id" in value) { - if (id !== void 0 && id !== null && typeof id === "string") { - contextRaw[key] = Object.assign(Object.assign({}, contextRaw[key]), { "@id": context.expandTerm(id, true) }); - changed = changed || id !== contextRaw[key]["@id"]; - } - } else if (!Util_1.Util.isPotentialKeyword(key) && canAddIdEntry) { - const newId = context.expandTerm(key, true); - if (newId !== key) { - contextRaw[key] = Object.assign(Object.assign({}, contextRaw[key]), { "@id": newId }); - changed = true; - } - } - if (type && typeof type === "string" && type !== "@vocab" && (!value["@container"] || !value["@container"]["@type"]) && canAddIdEntry) { - let expandedType = context.expandTerm(type, true); - if (expandContentTypeToBase && type === expandedType) { - expandedType = context.expandTerm(type, false); - } - if (expandedType !== type) { - changed = true; - contextRaw[key] = Object.assign(Object.assign({}, contextRaw[key]), { "@type": expandedType }); - } - } - } - if (!changed) { - break; - } - } - } - } - } - /** - * Normalize the @language entries in the given context to lowercase. - * @param {IJsonLdContextNormalizedRaw} context A context. - * @param {IParseOptions} parseOptions The parsing options. - */ - normalize(context, { processingMode, normalizeLanguageTags }) { - if (normalizeLanguageTags || processingMode === 1) { - for (const key of Object.keys(context)) { - if (key === "@language" && typeof context[key] === "string") { - context[key] = context[key].toLowerCase(); - } else { - const value = context[key]; - if (value && typeof value === "object") { - if (typeof value["@language"] === "string") { - const lowercase = value["@language"].toLowerCase(); - if (lowercase !== value["@language"]) { - context[key] = Object.assign(Object.assign({}, value), { "@language": lowercase }); - } - } - } - } - } - } - } - /** - * Convert all @container strings and array values to hash-based values. - * @param {IJsonLdContextNormalizedRaw} context A context. - */ - containersToHash(context) { - for (const key of Object.keys(context)) { - const value = context[key]; - if (value && typeof value === "object") { - if (typeof value["@container"] === "string") { - context[key] = Object.assign(Object.assign({}, value), { "@container": { [value["@container"]]: true } }); - } else if (Array.isArray(value["@container"])) { - const newValue = {}; - for (const containerValue of value["@container"]) { - newValue[containerValue] = true; - } - context[key] = Object.assign(Object.assign({}, value), { "@container": newValue }); - } - } - } - } - /** - * Normalize and apply context-level @protected terms onto each term separately. - * @param {IJsonLdContextNormalizedRaw} context A context. - * @param {number} processingMode The processing mode. - */ - applyScopedProtected(context, { processingMode }, expandOptions) { - if (processingMode && processingMode >= 1.1) { - if (context["@protected"]) { - for (const key of Object.keys(context)) { - if (Util_1.Util.isReservedInternalKeyword(key)) { - continue; - } - if (!Util_1.Util.isPotentialKeyword(key) && !Util_1.Util.isTermProtected(context, key)) { - const value = context[key]; - if (value && typeof value === "object") { - if (!("@protected" in context[key])) { - context[key] = Object.assign(Object.assign({}, context[key]), { "@protected": true }); - } - } else { - context[key] = { - "@id": value, - "@protected": true - }; - if (Util_1.Util.isSimpleTermDefinitionPrefix(value, expandOptions)) { - context[key] = Object.assign(Object.assign({}, context[key]), { "@prefix": true }); - } - } - } - } - delete context["@protected"]; - } - } - } - /** - * Check if the given context inheritance does not contain any overrides of protected terms. - * @param {IJsonLdContextNormalizedRaw} contextBefore The context that may contain some protected terms. - * @param {IJsonLdContextNormalizedRaw} contextAfter A new context that is being applied on the first one. - * @param {IExpandOptions} expandOptions Options that are needed for any expansions during this validation. - * @param {string[]} keys Optional set of keys from the context to validate. If left undefined, all - * keys defined in contextAfter will be checked. - */ - validateKeywordRedefinitions(contextBefore, contextAfter, expandOptions, keys) { - for (const key of keys !== null && keys !== void 0 ? keys : Object.keys(contextAfter)) { - if (Util_1.Util.isTermProtected(contextBefore, key)) { - if (typeof contextAfter[key] === "string") { - contextAfter[key] = { "@id": contextAfter[key], "@protected": true }; - } else { - contextAfter[key] = Object.assign(Object.assign({}, contextAfter[key]), { "@protected": true }); - } - if (!Util_1.Util.deepEqual(contextBefore[key], contextAfter[key])) { - throw new ErrorCoded_1.ErrorCoded(`Attempted to override the protected keyword ${key} from ${JSON.stringify(Util_1.Util.getContextValueId(contextBefore[key]))} to ${JSON.stringify(Util_1.Util.getContextValueId(contextAfter[key]))}`, ErrorCoded_1.ERROR_CODES.PROTECTED_TERM_REDEFINITION); - } - } - } - } - /** - * Validate the entries of the given context. - * @param {IJsonLdContextNormalizedRaw} context A context. - * @param {IParseOptions} options The parse options. - */ - validate(context, { processingMode }) { - for (const key of Object.keys(context)) { - if (Util_1.Util.isReservedInternalKeyword(key)) { - continue; - } - if (key === "") { - throw new ErrorCoded_1.ErrorCoded(`The empty term is not allowed, got: '${key}': '${JSON.stringify(context[key])}'`, ErrorCoded_1.ERROR_CODES.INVALID_TERM_DEFINITION); - } - const value = context[key]; - const valueType = typeof value; - if (Util_1.Util.isPotentialKeyword(key)) { - switch (key.substr(1)) { - case "vocab": - if (value !== null && valueType !== "string") { - throw new ErrorCoded_1.ErrorCoded(`Found an invalid @vocab IRI: ${value}`, ErrorCoded_1.ERROR_CODES.INVALID_VOCAB_MAPPING); - } - break; - case "base": - if (value !== null && valueType !== "string") { - throw new ErrorCoded_1.ErrorCoded(`Found an invalid @base IRI: ${context[key]}`, ErrorCoded_1.ERROR_CODES.INVALID_BASE_IRI); - } - break; - case "language": - if (value !== null) { - ContextParser2.validateLanguage(value, true, ErrorCoded_1.ERROR_CODES.INVALID_DEFAULT_LANGUAGE); - } - break; - case "version": - if (value !== null && valueType !== "number") { - throw new ErrorCoded_1.ErrorCoded(`Found an invalid @version number: ${value}`, ErrorCoded_1.ERROR_CODES.INVALID_VERSION_VALUE); - } - break; - case "direction": - if (value !== null) { - ContextParser2.validateDirection(value, true); - } - break; - case "propagate": - if (processingMode === 1) { - throw new ErrorCoded_1.ErrorCoded(`Found an illegal @propagate keyword: ${value}`, ErrorCoded_1.ERROR_CODES.INVALID_CONTEXT_ENTRY); - } - if (value !== null && valueType !== "boolean") { - throw new ErrorCoded_1.ErrorCoded(`Found an invalid @propagate value: ${value}`, ErrorCoded_1.ERROR_CODES.INVALID_PROPAGATE_VALUE); - } - break; - } - if (Util_1.Util.isValidKeyword(key) && Util_1.Util.isValidKeyword(Util_1.Util.getContextValueId(value))) { - throw new ErrorCoded_1.ErrorCoded(`Illegal keyword alias in term value, found: '${key}': '${Util_1.Util.getContextValueId(value)}'`, ErrorCoded_1.ERROR_CODES.KEYWORD_REDEFINITION); - } - continue; - } - if (value !== null) { - switch (valueType) { - case "string": - if (Util_1.Util.getPrefix(value, context) === key) { - throw new ErrorCoded_1.ErrorCoded(`Detected cyclical IRI mapping in context entry: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.CYCLIC_IRI_MAPPING); - } - if (Util_1.Util.isValidIriWeak(key)) { - if (value === "@type") { - throw new ErrorCoded_1.ErrorCoded(`IRIs can not be mapped to @type, found: '${key}': '${value}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); - } else if (Util_1.Util.isValidIri(value) && value !== new JsonLdContextNormalized_1.JsonLdContextNormalized(context).expandTerm(key)) { - throw new ErrorCoded_1.ErrorCoded(`IRIs can not be mapped to other IRIs, found: '${key}': '${value}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); - } - } - break; - case "object": - if (!Util_1.Util.isCompactIri(key) && !("@id" in value) && (value["@type"] === "@id" ? !context["@base"] : !context["@vocab"])) { - throw new ErrorCoded_1.ErrorCoded(`Missing @id in context entry: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); - } - for (const objectKey of Object.keys(value)) { - const objectValue = value[objectKey]; - if (!objectValue) { - continue; - } - switch (objectKey) { - case "@id": - if (Util_1.Util.isValidKeyword(objectValue) && objectValue !== "@type" && objectValue !== "@id" && objectValue !== "@graph" && objectValue !== "@nest") { - throw new ErrorCoded_1.ErrorCoded(`Illegal keyword alias in term value, found: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); - } - if (Util_1.Util.isValidIriWeak(key)) { - if (objectValue === "@type") { - throw new ErrorCoded_1.ErrorCoded(`IRIs can not be mapped to @type, found: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); - } else if (Util_1.Util.isValidIri(objectValue) && objectValue !== new JsonLdContextNormalized_1.JsonLdContextNormalized(context).expandTerm(key)) { - throw new ErrorCoded_1.ErrorCoded(`IRIs can not be mapped to other IRIs, found: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); - } - } - if (typeof objectValue !== "string") { - throw new ErrorCoded_1.ErrorCoded(`Detected non-string @id in context entry: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_IRI_MAPPING); - } - if (Util_1.Util.getPrefix(objectValue, context) === key) { - throw new ErrorCoded_1.ErrorCoded(`Detected cyclical IRI mapping in context entry: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.CYCLIC_IRI_MAPPING); - } - break; - case "@type": - if (value["@container"] === "@type" && objectValue !== "@id" && objectValue !== "@vocab") { - throw new ErrorCoded_1.ErrorCoded(`@container: @type only allows @type: @id or @vocab, but got: '${key}': '${objectValue}'`, ErrorCoded_1.ERROR_CODES.INVALID_TYPE_MAPPING); - } - if (typeof objectValue !== "string") { - throw new ErrorCoded_1.ErrorCoded(`The value of an '@type' must be a string, got '${JSON.stringify(valueType)}'`, ErrorCoded_1.ERROR_CODES.INVALID_TYPE_MAPPING); - } - if (objectValue !== "@id" && objectValue !== "@vocab" && (processingMode === 1 || objectValue !== "@json") && (processingMode === 1 || objectValue !== "@none") && (objectValue[0] === "_" || !Util_1.Util.isValidIri(objectValue))) { - throw new ErrorCoded_1.ErrorCoded(`A context @type must be an absolute IRI, found: '${key}': '${objectValue}'`, ErrorCoded_1.ERROR_CODES.INVALID_TYPE_MAPPING); - } - break; - case "@reverse": - if (typeof objectValue === "string" && value["@id"] && value["@id"] !== objectValue) { - throw new ErrorCoded_1.ErrorCoded(`Found non-matching @id and @reverse term values in '${key}':'${objectValue}' and '${value["@id"]}'`, ErrorCoded_1.ERROR_CODES.INVALID_REVERSE_PROPERTY); - } - if ("@nest" in value) { - throw new ErrorCoded_1.ErrorCoded(`@nest is not allowed in the reverse property '${key}'`, ErrorCoded_1.ERROR_CODES.INVALID_REVERSE_PROPERTY); - } - break; - case "@container": - if (processingMode === 1) { - if (Object.keys(objectValue).length > 1 || Util_1.Util.CONTAINERS_1_0.indexOf(Object.keys(objectValue)[0]) < 0) { - throw new ErrorCoded_1.ErrorCoded(`Invalid term @container for '${key}' ('${Object.keys(objectValue)}') in 1.0, must be only one of ${Util_1.Util.CONTAINERS_1_0.join(", ")}`, ErrorCoded_1.ERROR_CODES.INVALID_CONTAINER_MAPPING); - } - } - for (const containerValue of Object.keys(objectValue)) { - if (containerValue === "@list" && value["@reverse"]) { - throw new ErrorCoded_1.ErrorCoded(`Term value can not be @container: @list and @reverse at the same time on '${key}'`, ErrorCoded_1.ERROR_CODES.INVALID_REVERSE_PROPERTY); - } - if (Util_1.Util.CONTAINERS.indexOf(containerValue) < 0) { - throw new ErrorCoded_1.ErrorCoded(`Invalid term @container for '${key}' ('${containerValue}'), must be one of ${Util_1.Util.CONTAINERS.join(", ")}`, ErrorCoded_1.ERROR_CODES.INVALID_CONTAINER_MAPPING); - } - } - break; - case "@language": - ContextParser2.validateLanguage(objectValue, true, ErrorCoded_1.ERROR_CODES.INVALID_LANGUAGE_MAPPING); - break; - case "@direction": - ContextParser2.validateDirection(objectValue, true); - break; - case "@prefix": - if (objectValue !== null && typeof objectValue !== "boolean") { - throw new ErrorCoded_1.ErrorCoded(`Found an invalid term @prefix boolean in: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_PREFIX_VALUE); - } - if (!("@id" in value) && !Util_1.Util.isValidIri(key)) { - throw new ErrorCoded_1.ErrorCoded(`Invalid @prefix definition for '${key}' ('${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_TERM_DEFINITION); - } - break; - case "@index": - if (processingMode === 1 || !value["@container"] || !value["@container"]["@index"]) { - throw new ErrorCoded_1.ErrorCoded(`Attempt to add illegal key to value object: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_TERM_DEFINITION); - } - break; - case "@nest": - if (Util_1.Util.isPotentialKeyword(objectValue) && objectValue !== "@nest") { - throw new ErrorCoded_1.ErrorCoded(`Found an invalid term @nest value in: '${key}': '${JSON.stringify(value)}'`, ErrorCoded_1.ERROR_CODES.INVALID_NEST_VALUE); - } - } - } - break; - default: - throw new ErrorCoded_1.ErrorCoded(`Found an invalid term value: '${key}': '${value}'`, ErrorCoded_1.ERROR_CODES.INVALID_TERM_DEFINITION); - } - } - } - } - /** - * Apply the @base context entry to the given context under certain circumstances. - * @param context A context. - * @param options Parsing options. - * @param inheritFromParent If the @base value from the parent context can be inherited. - * @return The given context. - */ - applyBaseEntry(context, options, inheritFromParent) { - if (typeof context === "string") { - return context; - } - if (inheritFromParent && !("@base" in context) && options.parentContext && typeof options.parentContext === "object" && "@base" in options.parentContext) { - context["@base"] = options.parentContext["@base"]; - if (options.parentContext["@__baseDocument"]) { - context["@__baseDocument"] = true; - } - } - if (options.baseIRI && !options.external) { - if (!("@base" in context)) { - context["@base"] = options.baseIRI; - context["@__baseDocument"] = true; - } else if (context["@base"] !== null && typeof context["@base"] === "string" && !Util_1.Util.isValidIri(context["@base"])) { - context["@base"] = (0, relative_to_absolute_iri_1.resolve)(context["@base"], options.parentContext && options.parentContext["@base"] || options.baseIRI); - } - } - return context; - } - /** - * Resolve relative context IRIs, or return full IRIs as-is. - * @param {string} contextIri A context IRI. - * @param {string} baseIRI A base IRI. - * @return {string} The normalized context IRI. - */ - normalizeContextIri(contextIri, baseIRI) { - if (!Util_1.Util.isValidIri(contextIri)) { - try { - contextIri = (0, relative_to_absolute_iri_1.resolve)(contextIri, baseIRI); - } catch (_a) { - throw new Error(`Invalid context IRI: ${contextIri}`); - } - } - if (this.redirectSchemaOrgHttps && contextIri.startsWith("http://schema.org")) { - contextIri = "https://schema.org/"; - } - return contextIri; - } - /** - * Parse scoped contexts in the given context. - * @param {IJsonLdContextNormalizedRaw} context A context. - * @param {IParseOptions} options Parsing options. - * @return {IJsonLdContextNormalizedRaw} The mutated input context. - * @param {string[]} keys Optional set of keys from the context to parseInnerContexts of. If left undefined, all - * keys in the context will be iterated over. - */ - async parseInnerContexts(context, options, keys) { - for (const key of keys !== null && keys !== void 0 ? keys : Object.keys(context)) { - const value = context[key]; - if (value && typeof value === "object") { - if ("@context" in value && value["@context"] !== null && !options.ignoreScopedContexts) { - if (this.validateContext) { - try { - const parentContext = Object.assign(Object.assign({}, context), { [key]: Object.assign({}, context[key]) }); - delete parentContext[key]["@context"]; - await this.parse(value["@context"], Object.assign(Object.assign({}, options), { external: false, parentContext, ignoreProtection: true, ignoreRemoteScopedContexts: true, ignoreScopedContexts: true })); - } catch (e) { - throw new ErrorCoded_1.ErrorCoded(e.message, ErrorCoded_1.ERROR_CODES.INVALID_SCOPED_CONTEXT); - } - } - context[key] = Object.assign(Object.assign({}, value), { "@context": (await this.parse(value["@context"], Object.assign(Object.assign({}, options), { external: false, minimalProcessing: true, ignoreRemoteScopedContexts: true, parentContext: context }))).getContextRaw() }); - } - } - } - return context; - } - async parse(context, options = {}, internalOptions = {}) { - const { baseIRI, parentContext, external, processingMode = ContextParser2.DEFAULT_PROCESSING_MODE, normalizeLanguageTags, ignoreProtection, minimalProcessing } = options; - const remoteContexts = options.remoteContexts || {}; - if (Object.keys(remoteContexts).length >= this.remoteContextsDepthLimit) { - throw new ErrorCoded_1.ErrorCoded("Detected an overflow in remote context inclusions: " + Object.keys(remoteContexts), ErrorCoded_1.ERROR_CODES.CONTEXT_OVERFLOW); - } - if (context === null || context === void 0) { - if (!ignoreProtection && parentContext && Util_1.Util.hasProtectedTerms(parentContext)) { - throw new ErrorCoded_1.ErrorCoded("Illegal context nullification when terms are protected", ErrorCoded_1.ERROR_CODES.INVALID_CONTEXT_NULLIFICATION); - } - return new JsonLdContextNormalized_1.JsonLdContextNormalized(this.applyBaseEntry({}, options, false)); - } else if (typeof context === "string") { - const contextIri = this.normalizeContextIri(context, baseIRI); - const overriddenLoad = this.getOverriddenLoad(contextIri, options); - if (overriddenLoad) { - return new JsonLdContextNormalized_1.JsonLdContextNormalized(overriddenLoad); - } - const parsedStringContext = await this.parse(await this.load(contextIri), Object.assign(Object.assign({}, options), { baseIRI: contextIri, external: true, remoteContexts: Object.assign(Object.assign({}, remoteContexts), { [contextIri]: true }) })); - this.applyBaseEntry(parsedStringContext.getContextRaw(), options, true); - return parsedStringContext; - } else if (Array.isArray(context)) { - const contextIris = []; - const contexts = await Promise.all(context.map((subContext, i) => { - if (typeof subContext === "string") { - const contextIri = this.normalizeContextIri(subContext, baseIRI); - contextIris[i] = contextIri; - const overriddenLoad = this.getOverriddenLoad(contextIri, options); - if (overriddenLoad) { - return overriddenLoad; - } - return this.load(contextIri); - } else { - return subContext; - } - })); - if (minimalProcessing) { - return new JsonLdContextNormalized_1.JsonLdContextNormalized(contexts); - } - const reducedContexts = await contexts.reduce((accContextPromise, contextEntry, i) => accContextPromise.then((accContext) => this.parse( - contextEntry, - Object.assign(Object.assign({}, options), { baseIRI: contextIris[i] || options.baseIRI, external: !!contextIris[i] || options.external, parentContext: accContext.getContextRaw(), remoteContexts: contextIris[i] ? Object.assign(Object.assign({}, remoteContexts), { [contextIris[i]]: true }) : remoteContexts }), - // @ts-expect-error: This third argument causes a type error because we have hidden it from consumers - { - skipValidation: i < contexts.length - 1 - } - )), Promise.resolve(new JsonLdContextNormalized_1.JsonLdContextNormalized(parentContext || {}))); - this.applyBaseEntry(reducedContexts.getContextRaw(), options, true); - return reducedContexts; - } else if (typeof context === "object") { - if ("@context" in context) { - return await this.parse(context["@context"], options); - } - context = Object.assign({}, context); - if (external) { - delete context["@base"]; - } - this.applyBaseEntry(context, options, true); - this.containersToHash(context); - if (minimalProcessing) { - return new JsonLdContextNormalized_1.JsonLdContextNormalized(context); - } - let importContext = {}; - if ("@import" in context) { - if (processingMode >= 1.1) { - if (typeof context["@import"] !== "string") { - throw new ErrorCoded_1.ErrorCoded("An @import value must be a string, but got " + typeof context["@import"], ErrorCoded_1.ERROR_CODES.INVALID_IMPORT_VALUE); - } - importContext = await this.loadImportContext(this.normalizeContextIri(context["@import"], baseIRI)); - delete context["@import"]; - } else { - throw new ErrorCoded_1.ErrorCoded("Context importing is not supported in JSON-LD 1.0", ErrorCoded_1.ERROR_CODES.INVALID_CONTEXT_ENTRY); - } - } - this.applyScopedProtected(importContext, { processingMode }, JsonLdContextNormalized_1.defaultExpandOptions); - const newContext = Object.assign(importContext, context); - this.idifyReverseTerms(newContext); - this.normalize(newContext, { processingMode, normalizeLanguageTags }); - this.applyScopedProtected(newContext, { processingMode }, JsonLdContextNormalized_1.defaultExpandOptions); - const keys = Object.keys(newContext); - const overlappingKeys = []; - if (typeof parentContext === "object") { - for (const key in parentContext) { - if (key in newContext) { - overlappingKeys.push(key); - } else { - newContext[key] = parentContext[key]; - } - } - } - await this.parseInnerContexts(newContext, options, keys); - const newContextWrapped = new JsonLdContextNormalized_1.JsonLdContextNormalized(newContext); - if ((newContext && newContext["@version"] || ContextParser2.DEFAULT_PROCESSING_MODE) >= 1.1 && (context["@vocab"] && typeof context["@vocab"] === "string" || context["@vocab"] === "")) { - if (parentContext && "@vocab" in parentContext && context["@vocab"].indexOf(":") < 0) { - newContext["@vocab"] = parentContext["@vocab"] + context["@vocab"]; - } else if (Util_1.Util.isCompactIri(context["@vocab"]) || context["@vocab"] in newContext) { - newContext["@vocab"] = newContextWrapped.expandTerm(context["@vocab"], true); - } - } - this.expandPrefixedTerms(newContextWrapped, this.expandContentTypeToBase, keys); - if (!ignoreProtection && parentContext && processingMode >= 1.1) { - this.validateKeywordRedefinitions(parentContext, newContext, JsonLdContextNormalized_1.defaultExpandOptions, overlappingKeys); - } - if (this.validateContext && !internalOptions.skipValidation) { - this.validate(newContext, { processingMode }); - } - return newContextWrapped; - } else { - throw new ErrorCoded_1.ErrorCoded(`Tried parsing a context that is not a string, array or object, but got ${context}`, ErrorCoded_1.ERROR_CODES.INVALID_LOCAL_CONTEXT); - } - } - /** - * Fetch the given URL as a raw JSON-LD context. - * @param url An URL. - * @return A promise resolving to a raw JSON-LD context. - */ - async load(url) { - const cached = this.documentCache[url]; - if (cached) { - return cached; - } - let document2; - try { - document2 = await this.documentLoader.load(url); - } catch (e) { - throw new ErrorCoded_1.ErrorCoded(`Failed to load remote context ${url}: ${e.message}`, ErrorCoded_1.ERROR_CODES.LOADING_REMOTE_CONTEXT_FAILED); - } - if (!("@context" in document2)) { - throw new ErrorCoded_1.ErrorCoded(`Missing @context in remote context at ${url}`, ErrorCoded_1.ERROR_CODES.INVALID_REMOTE_CONTEXT); - } - return this.documentCache[url] = document2["@context"]; - } - /** - * Override the given context that may be loaded. - * - * This will check whether or not the url is recursively being loaded. - * @param url An URL. - * @param options Parsing options. - * @return An overridden context, or null. - * Optionally an error can be thrown if a cyclic context is detected. - */ - getOverriddenLoad(url, options) { - if (url in (options.remoteContexts || {})) { - if (options.ignoreRemoteScopedContexts) { - return url; - } else { - throw new ErrorCoded_1.ErrorCoded("Detected a cyclic context inclusion of " + url, ErrorCoded_1.ERROR_CODES.RECURSIVE_CONTEXT_INCLUSION); - } - } - return null; - } - /** - * Load an @import'ed context. - * @param importContextIri The full URI of an @import value. - */ - async loadImportContext(importContextIri) { - let importContext = await this.load(importContextIri); - if (typeof importContext !== "object" || Array.isArray(importContext)) { - throw new ErrorCoded_1.ErrorCoded("An imported context must be a single object: " + importContextIri, ErrorCoded_1.ERROR_CODES.INVALID_REMOTE_CONTEXT); - } - if ("@import" in importContext) { - throw new ErrorCoded_1.ErrorCoded("An imported context can not import another context: " + importContextIri, ErrorCoded_1.ERROR_CODES.INVALID_CONTEXT_ENTRY); - } - importContext = Object.assign({}, importContext); - this.containersToHash(importContext); - return importContext; - } - }; - ContextParser$1.DEFAULT_PROCESSING_MODE = 1.1; - ContextParser.ContextParser = ContextParser$1; - return ContextParser; - } - var IDocumentLoader = {}; - var hasRequiredIDocumentLoader; - function requireIDocumentLoader() { - if (hasRequiredIDocumentLoader) return IDocumentLoader; - hasRequiredIDocumentLoader = 1; - Object.defineProperty(IDocumentLoader, "__esModule", { value: true }); - return IDocumentLoader; - } - var JsonLdContext = {}; - var hasRequiredJsonLdContext; - function requireJsonLdContext() { - if (hasRequiredJsonLdContext) return JsonLdContext; - hasRequiredJsonLdContext = 1; - Object.defineProperty(JsonLdContext, "__esModule", { value: true }); - return JsonLdContext; - } - var hasRequiredJsonldContextParser; - function requireJsonldContextParser() { - if (hasRequiredJsonldContextParser) return jsonldContextParser; - hasRequiredJsonldContextParser = 1; - (function(exports) { - var __createBinding = jsonldContextParser && jsonldContextParser.__createBinding || (Object.create ? function(o, m, k, k2) { - if (k2 === void 0) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { - return m[k]; - } }; - } - Object.defineProperty(o, k2, desc); - } : function(o, m, k, k2) { - if (k2 === void 0) k2 = k; - o[k2] = m[k]; - }); - var __exportStar = jsonldContextParser && jsonldContextParser.__exportStar || function(m, exports2) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - __exportStar(/* @__PURE__ */ requireContextParser(), exports); - __exportStar(/* @__PURE__ */ requireErrorCoded(), exports); - __exportStar(/* @__PURE__ */ requireFetchDocumentLoader(), exports); - __exportStar(/* @__PURE__ */ requireIDocumentLoader(), exports); - __exportStar(/* @__PURE__ */ requireJsonLdContext(), exports); - __exportStar(/* @__PURE__ */ requireJsonLdContextNormalized(), exports); - __exportStar(/* @__PURE__ */ requireUtil(), exports); - })(jsonldContextParser); - return jsonldContextParser; - } - var jsonldContextParserExports = /* @__PURE__ */ requireJsonldContextParser(); - function uniqID() { - return `_${(Math.random() * 36 ** 20).toString(36).slice(0, 10)}`; - } - function stringToDom(html) { - const template = document.createElement("template"); - template.innerHTML = html; - return template.content; - } - const AsyncFunction = Object.getPrototypeOf(async () => { - }).constructor; - async function evalTemplateString(str, variables = {}) { - const keys = Object.keys(variables); - const values = keys.map((key) => variables[key]); - try { - const func = AsyncFunction.call(null, ...keys, `return \`${str}\``); - return await func(...values); - } catch (e) { - console.log(e); - throw new SyntaxError(`\`${str}\``); - } - } - function importCSS(...stylesheets) { - const linksElements = []; - for (let url of stylesheets) { - url = relativeSource(url); - let link2 = Array.from(document.head.querySelectorAll("link")).find( - (link22) => link22.href === url - ); - if (link2) return link2; - link2 = document.createElement("link"); - link2.rel = "stylesheet"; - link2.href = url; - document.head.appendChild(link2); - linksElements.push(link2); - } - return linksElements; - } - function importInlineCSS(id, importer) { - id = `sib-inline-css-${id}`; - let style = document.head.querySelector(`style#${id}`); - if (style) return style; - style = document.createElement("style"); - style.id = id; - document.head.appendChild(style); - (async () => { - let textContent; - if (typeof importer === "string") textContent = importer; - else { - const imported = await importer(); - if (typeof imported === "string") textContent = imported; - else textContent = imported.default || ""; - } - style.textContent = textContent; - })(); - return style; - } - function importJS(...plugins) { - return plugins.map((url) => { - url = new URL(url, document.baseURI).href; - let script = Array.from(document.querySelectorAll("script")).find( - (script2) => script2.src === url - ); - if (script) return script; - script = document.createElement("script"); - script.src = url; - document.head.appendChild(script); - return script; - }); - } - function relativeSource(source) { - if (!source.match(/^\..?\//)) return new URL(source, document.baseURI).href; - const e = new Error(); - if (!e.stack) return source; - const f2 = e.stack.split("\n").filter((l) => l.includes(":"))[2]; - const line = f2.match(/[a-z]+:.*$/); - if (!line) return source; - const calledFile = line[0].replace(/(\:[0-9]+){2}\)?$/, ""); - source = new URL(source, calledFile).href; - return source; - } - function loadScript(source) { - source = relativeSource(source); - return new Promise((resolve) => { - const script = document.createElement("script"); - const head = document.querySelector("head"); - script.async = true; - script.onload = () => setTimeout(resolve, 0); - script.src = source; - if (head) head.appendChild(script); - }); - } - function domIsReady() { - return new Promise((resolve) => { - if (document.readyState === "complete") { - resolve(); - } else { - document.addEventListener("DOMContentLoaded", () => resolve()); - } - }); - } - function setDeepProperty(obj, path, value) { - const name = path.shift(); - if (name) { - if (!(name in obj)) obj[name] = {}; - if (path.length > 0) setDeepProperty(obj[name], path, value); - else obj[name] = value; - } - } - function parseFieldsString(fields) { - if (!fields) return []; - while (fields.indexOf("(") > 0) { - const firstBracket = fields.indexOf("("); - const noset = fields.substring( - firstBracket, - findClosingBracketMatchIndex(fields, firstBracket) + 1 - ); - fields = fields.replace(noset, ""); - } - const re = /((^\s*|,)\s*)(("(\\"|[^"])*")|('(\\'|[^'])*')|[^,]*)/gm; - const fieldsArray = fields.match(re) || []; - if (!fieldsArray) return []; - return fieldsArray.map((a) => a.replace(/^[\s,]+/, "")); - } - function findClosingBracketMatchIndex(str, pos) { - if (str[pos] !== "(") throw new Error(`No '(' at index ${pos}`); - let depth = 1; - for (let i = pos + 1; i < str.length; i++) { - switch (str[i]) { - case "(": - depth++; - break; - case ")": - if (--depth === 0) return i; - break; - } - } - return -1; - } - function defineComponent(tagName, componentClass) { - if (!customElements.get(tagName)) { - customElements.define(tagName, componentClass); - } else { - console.warn( - `Warning: the component "${tagName}" has already been loaded in another version of sib-core.` - ); - } - } - function fuzzyCompare(subject, search) { - return compareTransform(subject).includes(compareTransform(String(search))); - } - function compareTransform(str) { - return str.normalize("NFD").replaceAll(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase().replaceAll("œ", "oe").replaceAll("æ", "ae").replaceAll(/[ ,.!?;:-`"]+/g, " ").trim(); - } - const compare = { - string(subject, query) { - if (typeof subject !== "string" || typeof query !== "string") - throw new TypeError("not a string"); - if (query === "") return true; - return fuzzyCompare(subject, String(query)); - }, - boolean(subject, query) { - if (!query) return true; - return subject; - }, - number(subject, query) { - return subject === query; - }, - list(subject, list) { - return list.includes(subject); - }, - range(subject, range) { - return (range[0] == null || range[0] === "" || subject >= range[0]) && (range[1] == null || range[1] === "" || subject <= range[1]); - }, - resource(subject, query) { - if (query === "") return true; - if (!query["@id"]) return false; - const ret = subject["@id"] === query["@id"]; - return ret; - } - }; - function generalComparator(a, b, order = "asc") { - if (order === "desc") return generalComparator(b, a); - if (a == null && b == null) return 0; - if (a === b || Object.is(a, b)) return 0; - if (typeof a === "boolean" && typeof b === "boolean") { - return a === b ? 0 : a ? 1 : -1; - } - if (!Number.isNaN(Number(a)) && !Number.isNaN(Number(b))) { - return Number(a) - Number(b); - } - if (Array.isArray(a) && Array.isArray(b)) { - return a.length - b.length; - } - const dateA = Date.parse(String(a)); - const dateB = Date.parse(String(b)); - if (!Number.isNaN(dateA) && !Number.isNaN(dateB)) { - return dateA - dateB; - } - if (a && b && typeof a === "object" && typeof b === "object") { - const aKeys = Object.keys(a); - const bKeys = Object.keys(b); - return aKeys.length - bKeys.length; - } - if (a == null) return -1; - if (b == null) return 1; - return String(a).localeCompare(String(b)); - } - function transformArrayToContainer(resource) { - const newValue = { ...resource }; - for (const predicate of Object.keys(newValue)) { - const predicateValue = newValue[predicate]; - if (!predicateValue || typeof predicateValue !== "object") continue; - if (["permissions", "@context"].includes(predicate)) continue; - if (!Array.isArray(predicateValue) && predicateValue["@id"]) { - newValue[predicate] = transformArrayToContainer(resource[predicate]); - } - if (Array.isArray(predicateValue) && predicateValue["@id"]) { - newValue[predicate] = { - "@id": predicateValue["@id"], - "ldp:contains": [...predicateValue] - // ???? why only ldp:contains? - }; - newValue[predicate]["ldp:contains"].forEach( - (childPredicate, index) => { - newValue[predicate]["ldp:contains"][index] = transformArrayToContainer(childPredicate); - } - ); - } - } - return newValue; - } - function doesResourceContainList(resource) { - const predicates = ["ldp:contains", "dcat:dataset"]; - return predicates.some( - (predicate) => typeof resource === "object" ? predicate in resource : typeof resource === "string" && resource.includes(predicate) - ); - } - class AsyncIterableBuilder { - constructor() { - __privateAdd(this, _AsyncIterableBuilder_instances); - __privateAdd(this, _values, []); - __privateAdd(this, _resolve); - __publicField(this, "iterable"); - __publicField(this, "next"); - __privateMethod(this, _AsyncIterableBuilder_instances, nextPromise_fn).call(this); - this.iterable = __privateMethod(this, _AsyncIterableBuilder_instances, createIterable_fn).call(this); - this.next = __privateMethod(this, _AsyncIterableBuilder_instances, next_fn).bind(this); - } - } - _values = new WeakMap(); - _resolve = new WeakMap(); - _AsyncIterableBuilder_instances = new WeakSet(); - createIterable_fn = async function* () { - for (let index = 0; ; index++) { - const { value, done } = await __privateGet(this, _values)[index]; - delete __privateGet(this, _values)[index]; - yield value; - if (done) return; - } - }; - next_fn = function(value, done = false) { - __privateGet(this, _resolve).call(this, { value, done }); - __privateMethod(this, _AsyncIterableBuilder_instances, nextPromise_fn).call(this); - }; - nextPromise_fn = function() { - __privateGet(this, _values).push( - new Promise((resolve) => { - __privateSet(this, _resolve, resolve); - }) - ); - }; - const asyncQuerySelector = (selector, parent = document) => new Promise((resolve) => { - const element = parent.querySelector(selector); - if (element) return resolve(element); - const observer = new MutationObserver(() => { - const element2 = parent.querySelector(selector); - if (!element2) return; - observer.disconnect(); - return resolve(element2); - }); - observer.observe(parent, { - subtree: true, - childList: true, - attributes: true - }); - }); - function isUrlOrRelativePath(value) { - if (typeof value !== "string") return false; - if (value.startsWith("_:")) return false; - if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(value)) return true; - if (value.startsWith("/")) return true; - return false; - } - const asyncQuerySelectorAll = (selector, parent = document) => { - const delivered = /* @__PURE__ */ new WeakSet(); - const { next, iterable } = new AsyncIterableBuilder(); - function checkNewElement() { - for (const element of parent.querySelectorAll(selector)) { - if (delivered.has(element)) continue; - delivered.add(element); - next(element); - } - } - checkNewElement(); - const observer = new MutationObserver(checkNewElement); - observer.observe(parent, { - subtree: true, - childList: true, - attributes: true - }); - return iterable; - }; - const mergeContexts = (client, server) => ({ - ...getRawContext(client), - ...getRawContext(server) - }); - const normalizeContext = (ctx, fallbackCtx = null) => { - if (ctx && !(ctx instanceof jsonldContextParserExports.JsonLdContextNormalized)) { - return new jsonldContextParserExports.JsonLdContextNormalized(ctx); - } - if (!ctx && fallbackCtx) { - return normalizeContext(fallbackCtx); - } - return ctx; - }; - const getRawContext = (ctx) => { - if (!ctx) return ctx; - if (ctx instanceof jsonldContextParserExports.JsonLdContextNormalized) { - return ctx.getContextRaw(); - } - if (Array.isArray(ctx)) { - return ctx.map(getRawContext); - } - if (ctx && typeof ctx === "object" && "contextRaw" in ctx) { - return ctx.contextRaw; - } - return ctx; - }; - const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - AsyncIterableBuilder, - asyncQuerySelector, - asyncQuerySelectorAll, - compare, - default: AsyncIterableBuilder, - defineComponent, - doesResourceContainList, - domIsReady, - evalTemplateString, - findClosingBracketMatchIndex, - fuzzyCompare, - generalComparator, - getRawContext, - importCSS, - importInlineCSS, - importJS, - isUrlOrRelativePath, - loadScript, - mergeContexts, - normalizeContext, - parseFieldsString, - setDeepProperty, - stringToDom, - transformArrayToContainer, - uniqID - }, Symbol.toStringTag, { value: "Module" })); - export { - AsyncIterableBuilder as A, - doesResourceContainList as a, - fuzzyCompare as b, - compare as c, - defineComponent as d, - evalTemplateString as e, - findClosingBracketMatchIndex as f, - generalComparator as g, - asyncQuerySelector as h, - importInlineCSS as i, - importCSS as j, - helpers as k, - getRawContext as l, - mergeContexts as m, - normalizeContext as n, - isUrlOrRelativePath as o, - parseFieldsString as p, - jsonldContextParserExports as q, - stringToDom as r, - setDeepProperty as s, - transformArrayToContainer as t, - uniqID as u, - importJS as v, - loadScript as w, - domIsReady as x, - asyncQuerySelectorAll as y - }; - recorded_at: Tue, 29 Jul 2025 04:39:27 GMT -- request: - method: get - uri: https://content-autofill.googleapis.com/v1/pages/ChVDaHJvbWUvMTM4LjAuNzIwNC4xNTcSGQkBf12-dAqR-hIFDXhvEhkh9Jq4APEXZIkShQMJBH9NUZQD-MASBQ2u9qxaEgUNPT5pAhIFDSX7wvgSBQ2yVPL5EgUNLKVwVRIFDch-ywESBQ1Bfj98EgUNkWGVThIFDZFhlU4SBQ3XllV7EgUNkWGVThIFDZFhlU4SBQ3e6Gg1EgUNLqq_DRIFDajtMcsSBQ0yrTf-EgUNe5N7CBIFDXDA9xYSBQ3EoeCZEgUNsPDnLxIFDcSeswcSBQ2PJz14EgUNyO_X4xIFDYJIAmgSBQ2-Z2cREgUNhkVdERIFDWdnUPcSBQ0EW3WGEgUNzgbu9hIFDbkOr5ISBQ0KuEGqEgUNodcIKRIFDdOH988SBQ0cCw7hEgUNkWGVThIFDZFhlU4SBQ3K_D-VEgUNkWGVThIFDZFhlU4SBQ0Xve78EgUN8axL0RIFDZFhlU4SBQ2CLRWjEgUNGAd-1xIFDb5nZxESBQ2-Z2cREgUNsiC4wBIFDak9-pkSBQ1D2gBQEgUNvmdnERIFDQScNYcSBQ2RYZVOEgUN_-YqSiEOL_1xzbylaxIuCdjgNVi8VVA6EgUN3j-TvhIFDZFhlU4SBQ0P34RuEgUNbwH-bSFxUzFFIBoV3w==?alt=proto - body: - encoding: UTF-8 - string: '' - headers: - Connection: - - close - X-Goog-Encode-Response-If-Executable: - - base64 - X-Goog-Api-Key: - - AIzaSyCkfPOPZXDKNn8hhgu3JrA62wIgC93d44k - Sec-Fetch-Site: - - none - Sec-Fetch-Mode: - - no-cors - Sec-Fetch-Dest: - - empty - User-Agent: - - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/138.0.0.0 - Safari/537.36 - Accept-Encoding: - - '' - Accept-Language: - - en-US,en;q=0.9 - response: - status: - code: 403 - message: Forbidden - headers: - Vary: - - Origin,Accept-Encoding - - Referer - - X-Origin - Content-Type: - - application/x-protobuf - Date: - - Tue, 29 Jul 2025 04:39:30 GMT - Server: - - ESF - X-Xss-Protection: - - '0' - X-Frame-Options: - - SAMEORIGIN - X-Content-Type-Options: - - nosniff - Alt-Svc: - - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 - Accept-Ranges: - - none - Connection: - - close - Transfer-Encoding: - - chunked - body: - encoding: ASCII-8BIT - string: !binary |- - CAcSwgJBdXRvZmlsbCBBUEkgaGFzIG5vdCBiZWVuIHVzZWQgaW4gcHJvamVjdCA4MTE1NzQ4OTE0NjcgYmVmb3JlIG9yIGl0IGlzIGRpc2FibGVkLiBFbmFibGUgaXQgYnkgdmlzaXRpbmcgaHR0cHM6Ly9jb25zb2xlLmRldmVsb3BlcnMuZ29vZ2xlLmNvbS9hcGlzL2FwaS9hdXRvZmlsbC5nb29nbGVhcGlzLmNvbS9vdmVydmlldz9wcm9qZWN0PTgxMTU3NDg5MTQ2NyB0aGVuIHJldHJ5LiBJZiB5b3UgZW5hYmxlZCB0aGlzIEFQSSByZWNlbnRseSwgd2FpdCBhIGZldyBtaW51dGVzIGZvciB0aGUgYWN0aW9uIHRvIHByb3BhZ2F0ZSB0byBvdXIgc3lzdGVtcyBhbmQgcmV0cnkuGsoCCih0eXBlLmdvb2dsZWFwaXMuY29tL2dvb2dsZS5ycGMuRXJyb3JJbmZvEp0CChBTRVJWSUNFX0RJU0FCTEVEEg5nb29nbGVhcGlzLmNvbRodCg1jb250YWluZXJJbmZvEgw4MTE1NzQ4OTE0NjcadQoNYWN0aXZhdGlvblVybBJkaHR0cHM6Ly9jb25zb2xlLmRldmVsb3BlcnMuZ29vZ2xlLmNvbS9hcGlzL2FwaS9hdXRvZmlsbC5nb29nbGVhcGlzLmNvbS9vdmVydmlldz9wcm9qZWN0PTgxMTU3NDg5MTQ2NxocCgxzZXJ2aWNlVGl0bGUSDEF1dG9maWxsIEFQSRoiCgdzZXJ2aWNlEhdhdXRvZmlsbC5nb29nbGVhcGlzLmNvbRohCghjb25zdW1lchIVcHJvamVjdHMvODExNTc0ODkxNDY3GoADCi90eXBlLmdvb2dsZWFwaXMuY29tL2dvb2dsZS5ycGMuTG9jYWxpemVkTWVzc2FnZRLMAgoFZW4tVVMSwgJBdXRvZmlsbCBBUEkgaGFzIG5vdCBiZWVuIHVzZWQgaW4gcHJvamVjdCA4MTE1NzQ4OTE0NjcgYmVmb3JlIG9yIGl0IGlzIGRpc2FibGVkLiBFbmFibGUgaXQgYnkgdmlzaXRpbmcgaHR0cHM6Ly9jb25zb2xlLmRldmVsb3BlcnMuZ29vZ2xlLmNvbS9hcGlzL2FwaS9hdXRvZmlsbC5nb29nbGVhcGlzLmNvbS9vdmVydmlldz9wcm9qZWN0PTgxMTU3NDg5MTQ2NyB0aGVuIHJldHJ5LiBJZiB5b3UgZW5hYmxlZCB0aGlzIEFQSSByZWNlbnRseSwgd2FpdCBhIGZldyBtaW51dGVzIGZvciB0aGUgYWN0aW9uIHRvIHByb3BhZ2F0ZSB0byBvdXIgc3lzdGVtcyBhbmQgcmV0cnkuGrsBCiN0eXBlLmdvb2dsZWFwaXMuY29tL2dvb2dsZS5ycGMuSGVscBKTAQqQAQooR29vZ2xlIGRldmVsb3BlcnMgY29uc29sZSBBUEkgYWN0aXZhdGlvbhJkaHR0cHM6Ly9jb25zb2xlLmRldmVsb3BlcnMuZ29vZ2xlLmNvbS9hcGlzL2FwaS9hdXRvZmlsbC5nb29nbGVhcGlzLmNvbS9vdmVydmlldz9wcm9qZWN0PTgxMTU3NDg5MTQ2Nw== - recorded_at: Tue, 29 Jul 2025 04:39:30 GMT -- request: - method: get - uri: https://content-autofill.googleapis.com/v1/pages/ChVDaHJvbWUvMTM4LjAuNzIwNC4xNTcSrwMJg_Rd1UHqGWgSBQ2u9qxaEgUNPT5pAhIFDSX7wvgSBQ2yVPL5EgUNLKVwVRIFDch-ywESBQ1Bfj98EgUNkWGVThIFDZFhlU4SBQ3XllV7EgUNkWGVThIFDZFhlU4SBQ3e6Gg1EgUNLqq_DRIFDajtMcsSBQ0yrTf-EgUNe5N7CBIFDXDA9xYSBQ3EoeCZEgUNsPDnLxIFDcSeswcSBQ2PJz14EgUNyO_X4xIFDYJIAmgSBQ2-Z2cREgUNhkVdERIFDWdnUPcSBQ0EW3WGEgUNzgbu9hIFDbkOr5ISBQ0KuEGqEgUNodcIKRIFDdOH988SBQ0cCw7hEgUNkWGVThIFDZFhlU4SBQ3K_D-VEgUNkWGVThIFDZFhlU4SBQ0Xve78EgUN8axL0RIFDZFhlU4SBQ2CLRWjEgUNGAd-1xIFDb5nZxESBQ2-Z2cREgUNvFNSMRIFDbIguMASBQ3On7MLEgUNqT36mRIFDUPaAFASBQ2-Z2cREgUN42vQ2BIFDZFhlU4SBQ0EnDWHEgUNkWGVThIFDf_mKkoSBQ26p7UiEgUNkWGVTiGtfghJdQCcIRI8CWz8-a81byNkEgUN3j-TvhIFDZFhlU4SBQ0P34RuEgUNqtu3jBIFDZFhlU4SBQ1vAf5tIYt3SZqRj8nf?alt=proto - body: - encoding: UTF-8 - string: '' - headers: - Connection: - - close - X-Goog-Encode-Response-If-Executable: - - base64 - X-Goog-Api-Key: - - AIzaSyCkfPOPZXDKNn8hhgu3JrA62wIgC93d44k - Sec-Fetch-Site: - - none - Sec-Fetch-Mode: - - no-cors - Sec-Fetch-Dest: - - empty - User-Agent: - - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/138.0.0.0 - Safari/537.36 - Accept-Encoding: - - '' - Accept-Language: - - en-US,en;q=0.9 - response: - status: - code: 403 - message: Forbidden - headers: - Vary: - - Origin,Accept-Encoding - - Referer - - X-Origin - Content-Type: - - application/x-protobuf - Date: - - Tue, 29 Jul 2025 04:39:30 GMT - Server: - - ESF - X-Xss-Protection: - - '0' - X-Frame-Options: - - SAMEORIGIN - X-Content-Type-Options: - - nosniff - Alt-Svc: - - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 - Accept-Ranges: - - none - Connection: - - close - Transfer-Encoding: - - chunked - body: - encoding: ASCII-8BIT - string: !binary |- - CAcSwgJBdXRvZmlsbCBBUEkgaGFzIG5vdCBiZWVuIHVzZWQgaW4gcHJvamVjdCA4MTE1NzQ4OTE0NjcgYmVmb3JlIG9yIGl0IGlzIGRpc2FibGVkLiBFbmFibGUgaXQgYnkgdmlzaXRpbmcgaHR0cHM6Ly9jb25zb2xlLmRldmVsb3BlcnMuZ29vZ2xlLmNvbS9hcGlzL2FwaS9hdXRvZmlsbC5nb29nbGVhcGlzLmNvbS9vdmVydmlldz9wcm9qZWN0PTgxMTU3NDg5MTQ2NyB0aGVuIHJldHJ5LiBJZiB5b3UgZW5hYmxlZCB0aGlzIEFQSSByZWNlbnRseSwgd2FpdCBhIGZldyBtaW51dGVzIGZvciB0aGUgYWN0aW9uIHRvIHByb3BhZ2F0ZSB0byBvdXIgc3lzdGVtcyBhbmQgcmV0cnkuGsoCCih0eXBlLmdvb2dsZWFwaXMuY29tL2dvb2dsZS5ycGMuRXJyb3JJbmZvEp0CChBTRVJWSUNFX0RJU0FCTEVEEg5nb29nbGVhcGlzLmNvbRocCgxzZXJ2aWNlVGl0bGUSDEF1dG9maWxsIEFQSRoiCgdzZXJ2aWNlEhdhdXRvZmlsbC5nb29nbGVhcGlzLmNvbRohCghjb25zdW1lchIVcHJvamVjdHMvODExNTc0ODkxNDY3Gh0KDWNvbnRhaW5lckluZm8SDDgxMTU3NDg5MTQ2Nxp1Cg1hY3RpdmF0aW9uVXJsEmRodHRwczovL2NvbnNvbGUuZGV2ZWxvcGVycy5nb29nbGUuY29tL2FwaXMvYXBpL2F1dG9maWxsLmdvb2dsZWFwaXMuY29tL292ZXJ2aWV3P3Byb2plY3Q9ODExNTc0ODkxNDY3GoADCi90eXBlLmdvb2dsZWFwaXMuY29tL2dvb2dsZS5ycGMuTG9jYWxpemVkTWVzc2FnZRLMAgoFZW4tVVMSwgJBdXRvZmlsbCBBUEkgaGFzIG5vdCBiZWVuIHVzZWQgaW4gcHJvamVjdCA4MTE1NzQ4OTE0NjcgYmVmb3JlIG9yIGl0IGlzIGRpc2FibGVkLiBFbmFibGUgaXQgYnkgdmlzaXRpbmcgaHR0cHM6Ly9jb25zb2xlLmRldmVsb3BlcnMuZ29vZ2xlLmNvbS9hcGlzL2FwaS9hdXRvZmlsbC5nb29nbGVhcGlzLmNvbS9vdmVydmlldz9wcm9qZWN0PTgxMTU3NDg5MTQ2NyB0aGVuIHJldHJ5LiBJZiB5b3UgZW5hYmxlZCB0aGlzIEFQSSByZWNlbnRseSwgd2FpdCBhIGZldyBtaW51dGVzIGZvciB0aGUgYWN0aW9uIHRvIHByb3BhZ2F0ZSB0byBvdXIgc3lzdGVtcyBhbmQgcmV0cnkuGrsBCiN0eXBlLmdvb2dsZWFwaXMuY29tL2dvb2dsZS5ycGMuSGVscBKTAQqQAQooR29vZ2xlIGRldmVsb3BlcnMgY29uc29sZSBBUEkgYWN0aXZhdGlvbhJkaHR0cHM6Ly9jb25zb2xlLmRldmVsb3BlcnMuZ29vZ2xlLmNvbS9hcGlzL2FwaS9hdXRvZmlsbC5nb29nbGVhcGlzLmNvbS9vdmVydmlldz9wcm9qZWN0PTgxMTU3NDg5MTQ2Nw== - recorded_at: Tue, 29 Jul 2025 04:39:30 GMT + recorded_at: Tue, 29 Jul 2025 06:27:14 GMT - request: method: get uri: https://cdn.startinblox.com/owl/context-bis.jsonld @@ -53863,7 +53711,7 @@ http_interactions: Sec-Ch-Ua-Platform: - '"Linux"' User-Agent: - - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/138.0.0.0 + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Accept: - application/ld+json @@ -53878,7 +53726,7 @@ http_interactions: Sec-Fetch-Dest: - empty Referer: - - http://127.0.0.1:37737/ + - http://127.0.0.1:34777/ Accept-Encoding: - '' Accept-Language: @@ -53893,7 +53741,7 @@ http_interactions: Content-Length: - '1809' Date: - - Tue, 29 Jul 2025 04:39:31 GMT + - Tue, 29 Jul 2025 06:27:17 GMT Server: - Apache Access-Control-Allow-Origin: @@ -53963,7 +53811,7 @@ http_interactions: "control": "acl:Control" } } - recorded_at: Tue, 29 Jul 2025 04:39:31 GMT + recorded_at: Tue, 29 Jul 2025 06:27:17 GMT - request: method: get uri: https://cdn.startinblox.com/owl/dfc/taxonomies/scopes.jsonld @@ -53976,7 +53824,7 @@ http_interactions: Sec-Ch-Ua-Platform: - '"Linux"' User-Agent: - - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/138.0.0.0 + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Sec-Ch-Ua: - '"Not)A;Brand";v="8", "Chromium";v="138"' @@ -53991,7 +53839,7 @@ http_interactions: Sec-Fetch-Dest: - empty Referer: - - http://127.0.0.1:37737/ + - http://127.0.0.1:34777/ Accept-Encoding: - '' Accept-Language: @@ -54006,7 +53854,7 @@ http_interactions: Content-Length: - '7082' Date: - - Tue, 29 Jul 2025 04:39:32 GMT + - Tue, 29 Jul 2025 06:27:19 GMT Server: - Apache Access-Control-Allow-Origin: @@ -54031,7 +53879,7 @@ http_interactions: encoding: ASCII-8BIT string: !binary |- WwogIHsKICAgICJAaWQiOiAiaHR0cHM6Ly9naXRodWIuY29tL2RhdGFmb29kY29uc29ydGl1bS90YXhvbm9taWVzL3JlbGVhc2VzL2xhdGVzdC9kb3dubG9hZC9zY29wZXMucmRmI1JlYWRQcm9kdWN0cyIsCiAgICAiQHR5cGUiOiBbCiAgICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNDb25jZXB0IgogICAgXSwKICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNkZWZpbml0aW9uIjogWwogICAgICB7CiAgICAgICAgIkBsYW5ndWFnZSI6ICJlbiIsCiAgICAgICAgIkB2YWx1ZSI6ICJUaGlzIHNjb3BlIGFsbG93cyBwb3J0YWxzIHRvIGFjY2VzcyB0aGUgYXNzb2NpYXRlZCBwcm9kdWNlcidzIHByb2R1Y3RzIgogICAgICB9LAogICAgICB7CiAgICAgICAgIkBsYW5ndWFnZSI6ICJmciIsCiAgICAgICAgIkB2YWx1ZSI6ICJDZSBww6lyaW3DqHRyZSBwZXJtZXQgYXV4IHBvcnRhaWxzIGQnYWNjw6lkZXIgYXV4IHByb2R1aXRzIGR1IHByb2R1Y3RldXIgYXNzb2Npw6kiCiAgICAgIH0KICAgIF0sCiAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjaW5TY2hlbWUiOiBbCiAgICAgIHsKICAgICAgICAiQGlkIjogImh0dHBzOi8vZ2l0aHViLmNvbS9kYXRhZm9vZGNvbnNvcnRpdW0vdGF4b25vbWllcy9yZWxlYXNlcy9sYXRlc3QvZG93bmxvYWQvc2NvcGVzLnJkZiIKICAgICAgfQogICAgXSwKICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNub3RhdGlvbiI6IFsKICAgICAgewogICAgICAgICJAdmFsdWUiOiAiUmVhZFByb2R1Y3RzIgogICAgICB9CiAgICBdLAogICAgImh0dHA6Ly93d3cudzMub3JnLzIwMDQvMDIvc2tvcy9jb3JlI3ByZWZMYWJlbCI6IFsKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZW4iLAogICAgICAgICJAdmFsdWUiOiAiQWNjZXNzIHRvIHlvdXIgcHJvZHVjdCBsaXN0aW5nLCBpbmNsdWRpbmcgcHJpY2luZyAocmVhZC1vbmx5KSIKICAgICAgfSwKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZnIiLAogICAgICAgICJAdmFsdWUiOiAiQWNjw6lkZXIgw6Agdm9zIHByb2R1aXRzLCB5IGNvbXByaXMgbGVzIHByaXggKGxlY3R1cmUgc2V1bGUpIgogICAgICB9CiAgICBdCiAgfSwKICB7CiAgICAiQGlkIjogImh0dHBzOi8vZ2l0aHViLmNvbS9kYXRhZm9vZGNvbnNvcnRpdW0vdGF4b25vbWllcy9yZWxlYXNlcy9sYXRlc3QvZG93bmxvYWQvc2NvcGVzLnJkZiIsCiAgICAiQHR5cGUiOiBbCiAgICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNDb25jZXB0U2NoZW1lIgogICAgXSwKICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNwcmVmTGFiZWwiOiBbCiAgICAgIHsKICAgICAgICAiQGxhbmd1YWdlIjogImVuIiwKICAgICAgICAiQHZhbHVlIjogIkF1dGhvcml6YXRpb24gc2NvcGVzIgogICAgICB9LAogICAgICB7CiAgICAgICAgIkBsYW5ndWFnZSI6ICJmciIsCiAgICAgICAgIkB2YWx1ZSI6ICJQw6lyaW3DqHRyZXMgZCdhdXRvcmlzYXRpb24iCiAgICAgIH0KICAgIF0KICB9LAogIHsKICAgICJAaWQiOiAiaHR0cHM6Ly9naXRodWIuY29tL2RhdGFmb29kY29uc29ydGl1bS90YXhvbm9taWVzL3JlbGVhc2VzL2xhdGVzdC9kb3dubG9hZC9zY29wZXMucmRmI1dyaXRlUHJvZHVjdHMiLAogICAgIkB0eXBlIjogWwogICAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjQ29uY2VwdCIKICAgIF0sCiAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjZGVmaW5pdGlvbiI6IFsKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZW4iLAogICAgICAgICJAdmFsdWUiOiAiVGhpcyBzY29wZSBhbGxvd3MgcG9ydGFscyB0byBtb2RpZnkgdGhlIGFzc29jaWF0ZWQgcHJvZHVjZXIncyBwcm9kdWN0cyIKICAgICAgfSwKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZnIiLAogICAgICAgICJAdmFsdWUiOiAiQ2UgcMOpcmltw6h0cmUgcGVybWV0IGF1eCBwb3J0YWlscyBkZSBtb2RpZmllciBsZXMgcHJvZHVpdHMgZHUgcHJvZHVjdGV1ciBhc3NvY2nDqSIKICAgICAgfQogICAgXSwKICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNpblNjaGVtZSI6IFsKICAgICAgewogICAgICAgICJAaWQiOiAiaHR0cHM6Ly9naXRodWIuY29tL2RhdGFmb29kY29uc29ydGl1bS90YXhvbm9taWVzL3JlbGVhc2VzL2xhdGVzdC9kb3dubG9hZC9zY29wZXMucmRmIgogICAgICB9CiAgICBdLAogICAgImh0dHA6Ly93d3cudzMub3JnLzIwMDQvMDIvc2tvcy9jb3JlI25vdGF0aW9uIjogWwogICAgICB7CiAgICAgICAgIkB2YWx1ZSI6ICJXcml0ZVByb2R1Y3RzIgogICAgICB9CiAgICBdLAogICAgImh0dHA6Ly93d3cudzMub3JnLzIwMDQvMDIvc2tvcy9jb3JlI3ByZWZMYWJlbCI6IFsKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZW4iLAogICAgICAgICJAdmFsdWUiOiAiQ3JlYXRlIG9yIGVkaXQgcHJvZHVjdHMiCiAgICAgIH0sCiAgICAgIHsKICAgICAgICAiQGxhbmd1YWdlIjogImZyIiwKICAgICAgICAiQHZhbHVlIjogIkFqb3V0ZXIgb3UgbW9kaWZpZXIgZGVzIHByb2R1aXRzIgogICAgICB9CiAgICBdCiAgfSwKICB7CiAgICAiQGlkIjogImh0dHBzOi8vZ2l0aHViLmNvbS9kYXRhZm9vZGNvbnNvcnRpdW0vdGF4b25vbWllcy9yZWxlYXNlcy9sYXRlc3QvZG93bmxvYWQvc2NvcGVzLnJkZiNSZWFkT3JkZXJzIiwKICAgICJAdHlwZSI6IFsKICAgICAgImh0dHA6Ly93d3cudzMub3JnLzIwMDQvMDIvc2tvcy9jb3JlI0NvbmNlcHQiCiAgICBdLAogICAgImh0dHA6Ly93d3cudzMub3JnLzIwMDQvMDIvc2tvcy9jb3JlI2RlZmluaXRpb24iOiBbCiAgICAgIHsKICAgICAgICAiQGxhbmd1YWdlIjogImVuIiwKICAgICAgICAiQHZhbHVlIjogIlRoaXMgc2NvcGUgYWxsb3dzIHBvcnRhbHMgdG8gcmVhZCB0aGUgYXNzb2NpYXRlZCBwcm9kdWNlcidzIG9yZGVycyIKICAgICAgfSwKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZnIiLAogICAgICAgICJAdmFsdWUiOiAiQ2UgcMOpcmltw6h0cmUgcGVybWV0IGF1eCBwb3J0YWlscyBkZSBsaXJlIGxlcyBjb21tYW5kZXMgZHUgcHJvZHVjdGV1ciBhc3NvY2nDqSIKICAgICAgfQogICAgXSwKICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNpblNjaGVtZSI6IFsKICAgICAgewogICAgICAgICJAaWQiOiAiaHR0cHM6Ly9naXRodWIuY29tL2RhdGFmb29kY29uc29ydGl1bS90YXhvbm9taWVzL3JlbGVhc2VzL2xhdGVzdC9kb3dubG9hZC9zY29wZXMucmRmIgogICAgICB9CiAgICBdLAogICAgImh0dHA6Ly93d3cudzMub3JnLzIwMDQvMDIvc2tvcy9jb3JlI25vdGF0aW9uIjogWwogICAgICB7CiAgICAgICAgIkB2YWx1ZSI6ICJSZWFkT3JkZXJzIgogICAgICB9CiAgICBdLAogICAgImh0dHA6Ly93d3cudzMub3JnLzIwMDQvMDIvc2tvcy9jb3JlI3ByZWZMYWJlbCI6IFsKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZW4iLAogICAgICAgICJAdmFsdWUiOiAiQWNjZXNzIHRvIHlvdXIgb3JkZXJzIChyZWFkLW9ubHkpIgogICAgICB9LAogICAgICB7CiAgICAgICAgIkBsYW5ndWFnZSI6ICJmciIsCiAgICAgICAgIkB2YWx1ZSI6ICJBY2PDqWRlciDDoCB2b3MgY29tbWFuZGVzIChsZWN0dXJlIHNldWxlKSIKICAgICAgfQogICAgXQogIH0sCiAgewogICAgIkBpZCI6ICJodHRwczovL2dpdGh1Yi5jb20vZGF0YWZvb2Rjb25zb3J0aXVtL3RheG9ub21pZXMvcmVsZWFzZXMvbGF0ZXN0L2Rvd25sb2FkL3Njb3Blcy5yZGYjUmVhZEVudGVycHJpc2UiLAogICAgIkB0eXBlIjogWwogICAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjQ29uY2VwdCIKICAgIF0sCiAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjZGVmaW5pdGlvbiI6IFsKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZW4iLAogICAgICAgICJAdmFsdWUiOiAiVGhpcyBzY29wZSBhbGxvd3MgcG9ydGFscyB0byBhY2Nlc3MgdGhlIGFzc29jaWF0ZWQgcHJvZHVjZXIncyBlbnRlcnByaXNlIGRhdGEiCiAgICAgIH0sCiAgICAgIHsKICAgICAgICAiQGxhbmd1YWdlIjogImZyIiwKICAgICAgICAiQHZhbHVlIjogIkNlIHDDqXJpbcOodHJlIHBlcm1ldCBhdXggcG9ydGFpbHMgZCdhY2PDqWRlciBhdXggZG9ubsOpZXMgZGUgbCdlbnRyZXByaXNlIGR1IHByb2R1Y3RldXIgYXNzb2Npw6kiCiAgICAgIH0KICAgIF0sCiAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjaW5TY2hlbWUiOiBbCiAgICAgIHsKICAgICAgICAiQGlkIjogImh0dHBzOi8vZ2l0aHViLmNvbS9kYXRhZm9vZGNvbnNvcnRpdW0vdGF4b25vbWllcy9yZWxlYXNlcy9sYXRlc3QvZG93bmxvYWQvc2NvcGVzLnJkZiIKICAgICAgfQogICAgXSwKICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNub3RhdGlvbiI6IFsKICAgICAgewogICAgICAgICJAdmFsdWUiOiAiUmVhZEVudGVycHJpc2UiCiAgICAgIH0KICAgIF0sCiAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjcHJlZkxhYmVsIjogWwogICAgICB7CiAgICAgICAgIkBsYW5ndWFnZSI6ICJlbiIsCiAgICAgICAgIkB2YWx1ZSI6ICJBY2Nlc3MgdG8geW91ciBlbnRlcnByaXNlIHByb2ZpbGUgZGF0YSAocmVhZC1vbmx5KSIKICAgICAgfSwKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZnIiLAogICAgICAgICJAdmFsdWUiOiAiQWNjw6lkZXIgYXV4IGRvbm7DqWVzIGRlIHZvdHJlIHByb2ZpbCBlbnRlcnByaXNlIChsZWN0dXJlIHNldWxlKSIKICAgICAgfQogICAgXQogIH0sCiAgewogICAgIkBpZCI6ICJodHRwczovL2dpdGh1Yi5jb20vZGF0YWZvb2Rjb25zb3J0aXVtL3RheG9ub21pZXMvcmVsZWFzZXMvbGF0ZXN0L2Rvd25sb2FkL3Njb3Blcy5yZGYjV3JpdGVPcmRlcnMiLAogICAgIkB0eXBlIjogWwogICAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjQ29uY2VwdCIKICAgIF0sCiAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjZGVmaW5pdGlvbiI6IFsKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZW4iLAogICAgICAgICJAdmFsdWUiOiAiVGhpcyBzY29wZSBhbGxvd3MgcG9ydGFscyB0byBtb2RpZnkgdGhlIGFzc29jaWF0ZWQgcHJvZHVjZXIncyBvcmRlcnMiCiAgICAgIH0sCiAgICAgIHsKICAgICAgICAiQGxhbmd1YWdlIjogImZyIiwKICAgICAgICAiQHZhbHVlIjogIkNlIHDDqXJpbcOodHJlIHBlcm1ldCBhdXggcG9ydGFpbHMgZGUgbW9kaWZpZXIgbGVzIGNvbW1hbmRlcyBkdSBwcm9kdWN0ZXVyIGFzc29jacOpIgogICAgICB9CiAgICBdLAogICAgImh0dHA6Ly93d3cudzMub3JnLzIwMDQvMDIvc2tvcy9jb3JlI2luU2NoZW1lIjogWwogICAgICB7CiAgICAgICAgIkBpZCI6ICJodHRwczovL2dpdGh1Yi5jb20vZGF0YWZvb2Rjb25zb3J0aXVtL3RheG9ub21pZXMvcmVsZWFzZXMvbGF0ZXN0L2Rvd25sb2FkL3Njb3Blcy5yZGYiCiAgICAgIH0KICAgIF0sCiAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjbm90YXRpb24iOiBbCiAgICAgIHsKICAgICAgICAiQHZhbHVlIjogIldyaXRlT3JkZXJzIgogICAgICB9CiAgICBdLAogICAgImh0dHA6Ly93d3cudzMub3JnLzIwMDQvMDIvc2tvcy9jb3JlI3ByZWZMYWJlbCI6IFsKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZW4iLAogICAgICAgICJAdmFsdWUiOiAiQ3JlYXRlIG9yIGVkaXQgb3JkZXJzIgogICAgICB9LAogICAgICB7CiAgICAgICAgIkBsYW5ndWFnZSI6ICJmciIsCiAgICAgICAgIkB2YWx1ZSI6ICJBam91dGVyIG91IG1vZGlmaWVyIGRlcyBjb21tYW5kZXMiCiAgICAgIH0KICAgIF0KICB9LAogIHsKICAgICJAaWQiOiAiaHR0cHM6Ly9naXRodWIuY29tL2RhdGFmb29kY29uc29ydGl1bS90YXhvbm9taWVzL3JlbGVhc2VzL2xhdGVzdC9kb3dubG9hZC9zY29wZXMucmRmI1dyaXRlRW50ZXJwcmlzZSIsCiAgICAiQHR5cGUiOiBbCiAgICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNDb25jZXB0IgogICAgXSwKICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNkZWZpbml0aW9uIjogWwogICAgICB7CiAgICAgICAgIkBsYW5ndWFnZSI6ICJlbiIsCiAgICAgICAgIkB2YWx1ZSI6ICJUaGlzIHNjb3BlIGFsbG93cyBwb3J0YWxzIHRvIG1vZGlmeSB0aGUgYXNzb2NpYXRlZCBwcm9kdWNlcidzIGVudGVycHJpc2UgZGF0YSIKICAgICAgfSwKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZnIiLAogICAgICAgICJAdmFsdWUiOiAiQ2UgcMOpcmltw6h0cmUgcGVybWV0IGF1eCBwb3J0YWlscyBkZSBtb2RpZmllciBsZXMgZG9ubsOpZXMgZGUgbCdlbnRyZXByaXNlIGR1IHByb2R1Y3RldXIgYXNzb2Npw6kiCiAgICAgIH0KICAgIF0sCiAgICAiaHR0cDovL3d3dy53My5vcmcvMjAwNC8wMi9za29zL2NvcmUjaW5TY2hlbWUiOiBbCiAgICAgIHsKICAgICAgICAiQGlkIjogImh0dHBzOi8vZ2l0aHViLmNvbS9kYXRhZm9vZGNvbnNvcnRpdW0vdGF4b25vbWllcy9yZWxlYXNlcy9sYXRlc3QvZG93bmxvYWQvc2NvcGVzLnJkZiIKICAgICAgfQogICAgXSwKICAgICJodHRwOi8vd3d3LnczLm9yZy8yMDA0LzAyL3Nrb3MvY29yZSNub3RhdGlvbiI6IFsKICAgICAgewogICAgICAgICJAdmFsdWUiOiAiV3JpdGVFbnRlcnByaXNlIgogICAgICB9CiAgICBdLAogICAgImh0dHA6Ly93d3cudzMub3JnLzIwMDQvMDIvc2tvcy9jb3JlI3ByZWZMYWJlbCI6IFsKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZW4iLAogICAgICAgICJAdmFsdWUiOiAiQ3JlYXRlIG9yIGVkaXQgeW91ciBlbnRlcnByaXNlIHByb2ZpbGUgZGF0YSIKICAgICAgfSwKICAgICAgewogICAgICAgICJAbGFuZ3VhZ2UiOiAiZnIiLAogICAgICAgICJAdmFsdWUiOiAiQWpvdXRlciBvdSBtb2RpZmllciB2b3RyZSBwcm9maWwgZW50cmVwcmlzZSIKICAgICAgfQogICAgXQogIH0KXQo= - recorded_at: Tue, 29 Jul 2025 04:39:33 GMT + recorded_at: Tue, 29 Jul 2025 06:27:19 GMT - request: method: get uri: https://api.proxy-dev.cqcm.startinblox.com/profile @@ -54052,7 +53900,7 @@ http_interactions: Sec-Ch-Ua-Mobile: - "?0" User-Agent: - - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/138.0.0.0 + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Accept: - application/ld+json @@ -54067,7 +53915,7 @@ http_interactions: Sec-Fetch-Storage-Access: - none Referer: - - http://127.0.0.1:37737/ + - http://127.0.0.1:34777/ Accept-Encoding: - '' response: @@ -54109,12 +53957,12 @@ http_interactions: Via: - 1.1 alproxy Date: - - Tue, 29 Jul 2025 04:39:36 GMT + - Tue, 29 Jul 2025 06:27:21 GMT body: encoding: UTF-8 string: '{"@context":["https://cdn.startinblox.com/owl/dfc.jsonld","https://cdn.startinblox.com/owl/dfc.jsonld"],"@graph":[{"@id":"https://api.proxy-dev.cqcm.startinblox.com/profile","@type":"foaf:PersonalProfileDocument","foaf:primaryTopic":"https://api.proxy-dev.cqcm.startinblox.com/profile#me"},{"@id":"https://api.proxy-dev.cqcm.startinblox.com/profile#me","@type":["sib:HublApplication","solid:Application","foaf:Agent"],"dcterms:title":"Proxy Dev Portal","dcterms:description":"This is the first test portal for the DPM","dcterms:license":"https://proxy-dev.cqcm.startinblox.com/terms-and-conditions","solid:publicTypeIndex":"https://api.proxy-dev.cqcm.startinblox.com/profile/publicTypeIndex"}]}' - recorded_at: Tue, 29 Jul 2025 04:39:36 GMT + recorded_at: Tue, 29 Jul 2025 06:27:21 GMT - request: method: get uri: https://cdn.startinblox.com/owl/dfc.jsonld @@ -54127,7 +53975,7 @@ http_interactions: Sec-Ch-Ua-Platform: - '"Linux"' User-Agent: - - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/138.0.0.0 + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Accept: - application/ld+json @@ -54142,7 +53990,7 @@ http_interactions: Sec-Fetch-Dest: - empty Referer: - - http://127.0.0.1:37737/ + - http://127.0.0.1:34777/ Accept-Encoding: - '' Accept-Language: @@ -54157,7 +54005,7 @@ http_interactions: Content-Length: - '7025' Date: - - Tue, 29 Jul 2025 04:39:37 GMT + - Tue, 29 Jul 2025 06:27:22 GMT Server: - Apache Access-Control-Allow-Origin: @@ -54279,5 +54127,5 @@ http_interactions: \"@id\"\n\t\t},\n\t\t\"dfc-t:hasPivot\": {\n\t\t\t\"@type\": \"@id\"\n\t\t},\n\t\t\"dfc-t:hostedBy\": {\n\t\t\t\"@type\": \"@id\"\n\t\t},\n\t\t\"dfc:owner\": {\n\t\t\t\"@type\": \"@id\"\n\t\t},\n\t\t\"ofn:hasCertificationStatus\": {\n\t\t\t\"@type\": \"@id\"\n\t\t}\n\t}\n}\n\n" - recorded_at: Tue, 29 Jul 2025 04:39:38 GMT + recorded_at: Tue, 29 Jul 2025 06:27:23 GMT recorded_with: VCR 6.2.0 diff --git a/spec/system/admin/enterprises/dfc_permissions_spec.rb b/spec/system/admin/enterprises/dfc_permissions_spec.rb index 2f3c4f4c79..a69bbf9d1e 100644 --- a/spec/system/admin/enterprises/dfc_permissions_spec.rb +++ b/spec/system/admin/enterprises/dfc_permissions_spec.rb @@ -21,14 +21,43 @@ RSpec.describe "DFC Permissions", feature: "cqcm-dev", vcr: true do scroll_to :bottom click_link "Connected apps" - within(page.find('solid-permissioning').shadow_root) do - expect(page).to have_content "APPROVED PLATFORMS" + # The component displays something and then replaces it with the real + # list. That leads to a race condition and we have to just wait until + # the component is loaded. :-( + sleep 10 + + within(platform_list("without-permissions")) do + expect(page).to have_content "Proxy Dev Portal" + + # NotSupportedError: Failed to execute 'evaluate' on 'Document': + # The node provided is '#document-fragment', which is not a valid context node type. + # + # click_on "Agree and share" + + # This hack works + find("button", text: "Agree and share").native.trigger("click") end - # expect(page).to have_content "Proxy Dev Portal" - # expect(page).to have_selector "svg.unchecked" # permission not granted + sleep 5 + within(platform_list("approved")) do + expect(page).to have_content "Proxy Dev Portal" + find("button", text: "Stop sharing").native.trigger("click") + end - # click_on "Agree and share" - # expect(page).to have_selector "svg.checked" # permission granted + sleep 5 + within(platform_list("without-permissions")) do + expect(page).to have_content "Proxy Dev Portal" + find("button", text: "Agree and share").native.trigger("click") + end + + sleep 5 + within(platform_list("approved")) do + expect(page).to have_content "Proxy Dev Portal" + end + end + + def platform_list(variant) + page.find('solid-permissioning').shadow_root + .find("platform-block[variant='#{variant}']").shadow_root end end