@twin.org/data-json-ld 0.0.3-next.20 → 0.0.3-next.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -116,9 +116,11 @@ export class JsonLdHelper {
|
|
|
116
116
|
if (Is.arrayValue(expandedProps)) {
|
|
117
117
|
for (const expandedProp of expandedProps) {
|
|
118
118
|
const arr = ArrayHelper.fromObjectOrArray(expandedProp);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
if (Is.arrayValue(arr)) {
|
|
120
|
+
for (const arrValue of arr) {
|
|
121
|
+
if (Is.stringValue(arrValue)) {
|
|
122
|
+
types.add(arrValue);
|
|
123
|
+
}
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
126
|
}
|
|
@@ -142,9 +144,11 @@ export class JsonLdHelper {
|
|
|
142
144
|
if (Is.arrayValue(expandedProps)) {
|
|
143
145
|
for (const expandedProp of expandedProps) {
|
|
144
146
|
const arr = ArrayHelper.fromObjectOrArray(expandedProp);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
if (Is.arrayValue(arr)) {
|
|
148
|
+
for (const arrValue of arr) {
|
|
149
|
+
if (Is.stringValue(arrValue)) {
|
|
150
|
+
return arrValue;
|
|
151
|
+
}
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonLdHelper.js","sourceRoot":"","sources":["../../../src/utils/jsonLdHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAA2B,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAuB,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD;;GAEG;AACH,MAAM,OAAO,YAAY;IACxB;;;OAGG;IACI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AAI,UAAU,EAAE,CAAC;YAC9B,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YAC9B,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,gBAAgB,GAAG,CAAC,EAAE,CAAC;gBAC3F,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAC3D,IAAI,qBAAqB,IAAI,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC/D,kBAAkB,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;gBACzC,CAAC;qBAAM,CAAC;oBACP,kBAAkB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACjC,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,kBAAkB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACjC,CAAC;QACF,CAAC;QAED,OAAO,kBAAkB,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACK,MAAM,CAAC,KAAK,CAAC,mBAAmB,CACvC,kBAAyD;QAEzD,IAAI,EAAE,CAAC,KAAK,CAAoB,kBAAkB,CAAC,EAAE,CAAC;YACrD,MAAM,CAAC,KAAK,CACX,YAAY,CAAC,UAAU,wBAEvB,kBAAkB,CAClB,CAAC;YAEF,OAAO,kBAAkB,CAAC;QAC3B,CAAC;QAED,MAAM,CAAC,MAAM,CACZ,YAAY,CAAC,UAAU,wBAEvB,kBAAkB,CAClB,CAAC;QAEF,OAAO,eAAe,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACnD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ArrayHelper, Guards, Is, type IValidationFailure } from \"@twin.org/core\";\nimport { DataTypeHelper, type ValidationMode } from \"@twin.org/data-core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { JsonLdProcessor } from \"./jsonLdProcessor.js\";\nimport type { IJsonLdDocument } from \"../models/IJsonLdDocument.js\";\nimport type { IJsonLdNodeObject } from \"../models/IJsonLdNodeObject.js\";\nimport type { IJsonLdNodePrimitive } from \"../models/IJsonLdNodePrimitive.js\";\n\n/**\n * Class to help with JSON LD.\n */\nexport class JsonLdHelper {\n\t/**\n\t * The class name.\n\t * @internal\n\t */\n\tpublic static readonly CLASS_NAME = nameof<JsonLdHelper>();\n\n\t/**\n\t * Validate a JSON-LD document.\n\t * @param document The JSON-LD document to validate.\n\t * @param validationFailures The list of validation failures to add to.\n\t * @param options Optional options for validation.\n\t * @param options.failOnMissingType If true, will fail validation if the data type is missing, defaults to false.\n\t * @param options.validationMode The validation mode to use, defaults to either.\n\t * @returns True if the document was valid.\n\t */\n\tpublic static async validate<T extends IJsonLdDocument = IJsonLdDocument>(\n\t\tdocument: T,\n\t\tvalidationFailures: IValidationFailure[],\n\t\toptions?: {\n\t\t\tvalidationMode?: ValidationMode;\n\t\t\tfailOnMissingType?: boolean;\n\t\t}\n\t): Promise<boolean> {\n\t\tif (Is.array<IJsonLdNodeObject>(document)) {\n\t\t\t// If the document is an array of nodes, validate each node\n\t\t\tfor (const node of document) {\n\t\t\t\tawait JsonLdHelper.validate(node, validationFailures, options);\n\t\t\t}\n\t\t} else if (Is.array<IJsonLdNodeObject>(document[\"@graph\"])) {\n\t\t\t// If the graph is an array of nodes, validate each node\n\t\t\tfor (const node of document[\"@graph\"]) {\n\t\t\t\tawait JsonLdHelper.validate(node, validationFailures, options);\n\t\t\t}\n\t\t} else if (Is.object<IJsonLdNodeObject>(document)) {\n\t\t\t// Expand the document to ensure we have the full context for types\n\t\t\t// As the data types in the factories are always fully qualified\n\t\t\tconst expandedDocs = await JsonLdProcessor.expand(document);\n\t\t\tif (Is.arrayValue(expandedDocs)) {\n\t\t\t\tfor (const expandedDoc of expandedDocs) {\n\t\t\t\t\tconst expandedDataTypes = ArrayHelper.fromObjectOrArray(expandedDoc[\"@type\"]);\n\t\t\t\t\tif (Is.arrayValue(expandedDataTypes)) {\n\t\t\t\t\t\tfor (const expandedDataType of expandedDataTypes) {\n\t\t\t\t\t\t\tawait DataTypeHelper.validate(\n\t\t\t\t\t\t\t\t\"document\",\n\t\t\t\t\t\t\t\texpandedDataType,\n\t\t\t\t\t\t\t\tdocument,\n\t\t\t\t\t\t\t\tvalidationFailures,\n\t\t\t\t\t\t\t\toptions\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn validationFailures.length === 0;\n\t}\n\n\t/**\n\t * Convert an object to a JSON-LD node object.\n\t * @param object The object to convert.\n\t * @returns The JSON-LD node object.\n\t */\n\tpublic static toNodeObject<T = unknown>(object: T): T & IJsonLdNodeObject {\n\t\tGuards.object<T>(JsonLdHelper.CLASS_NAME, nameof(object), object);\n\t\treturn object as T & IJsonLdNodeObject;\n\t}\n\n\t/**\n\t * Convert the JSON-LD node object to a structured object.\n\t * @param nodeObject The JSON-LD node object to convert.\n\t * @returns The structured object.\n\t */\n\tpublic static toStructuredObject<T = unknown>(nodeObject: IJsonLdNodeObject): T {\n\t\tGuards.object<IJsonLdNodeObject>(JsonLdHelper.CLASS_NAME, nameof(nodeObject), nodeObject);\n\t\treturn nodeObject as unknown as T;\n\t}\n\n\t/**\n\t * Expand the JSON-LD document.\n\t * @param document The JSON-LD document to expand.\n\t * @returns The expanded JSON-LD document.\n\t */\n\tpublic static async expand(document: IJsonLdDocument): Promise<IJsonLdNodeObject[]> {\n\t\tGuards.object<IJsonLdDocument>(JsonLdHelper.CLASS_NAME, nameof(document), document);\n\t\treturn JsonLdProcessor.expand(document);\n\t}\n\n\t/**\n\t * Expand the JSON-LD document and check if it is of a specific type.\n\t * @param documentOrExpanded The JSON-LD document to check or already expanded document.\n\t * @param type The type to check for.\n\t * @returns True if the document is of the specified type.\n\t */\n\tpublic static async isType(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[],\n\t\ttype: string[]\n\t): Promise<boolean> {\n\t\tconst expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);\n\t\tGuards.arrayValue(JsonLdHelper.CLASS_NAME, nameof(type), type);\n\n\t\tif (Is.arrayValue(expanded)) {\n\t\t\tfor (const item of expanded) {\n\t\t\t\tconst types = ArrayHelper.fromObjectOrArray(item[\"@type\"]);\n\t\t\t\tif (Is.arrayValue(types)) {\n\t\t\t\t\t// All required types must be present in this item's @type array\n\t\t\t\t\tconst itemTypes = new Set(types);\n\t\t\t\t\tif (type.every(t => itemTypes.has(t))) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Get the types from the document.\n\t * @param documentOrExpanded The JSON-LD document to check or already expanded document.\n\t * @returns The type(s) extracted from the document.\n\t */\n\tpublic static async getType(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[]\n\t): Promise<string[]> {\n\t\tconst expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);\n\n\t\tconst types: Set<string> = new Set<string>();\n\t\tconst props = [\"@type\", \"type\"];\n\n\t\tfor (const expandedDoc of expanded) {\n\t\t\tfor (const prop of props) {\n\t\t\t\tconst expandedProps = ArrayHelper.fromObjectOrArray(expandedDoc[prop]);\n\t\t\t\tif (Is.arrayValue(expandedProps)) {\n\t\t\t\t\tfor (const expandedProp of expandedProps) {\n\t\t\t\t\t\tconst arr = ArrayHelper.fromObjectOrArray(expandedProp);\n\t\t\t\t\t\tfor (const arrValue of arr) {\n\t\t\t\t\t\t\tif (Is.stringValue(arrValue)) {\n\t\t\t\t\t\t\t\ttypes.add(arrValue);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn Array.from(types);\n\t}\n\n\t/**\n\t * Get the id from the document.\n\t * @param documentOrExpanded The JSON-LD document to get the id from or already expanded document.\n\t * @param additionalIdProperties Optional additional properties to check for the id, in addition to \"@id\" and \"id\".\n\t * @returns The id extracted from the document.\n\t */\n\tpublic static async getId(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[],\n\t\tadditionalIdProperties?: string[]\n\t): Promise<string | undefined> {\n\t\tconst expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);\n\n\t\tconst props = [\"@id\", \"id\", ...(additionalIdProperties ?? [])];\n\n\t\tfor (const expandedDoc of expanded) {\n\t\t\tfor (const prop of props) {\n\t\t\t\tconst expandedProps = ArrayHelper.fromObjectOrArray(expandedDoc[prop]);\n\t\t\t\tif (Is.arrayValue(expandedProps)) {\n\t\t\t\t\tfor (const expandedProp of expandedProps) {\n\t\t\t\t\t\tconst arr = ArrayHelper.fromObjectOrArray(expandedProp);\n\t\t\t\t\t\tfor (const arrValue of arr) {\n\t\t\t\t\t\t\tif (Is.stringValue(arrValue)) {\n\t\t\t\t\t\t\t\treturn arrValue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get property values by a single full expanded property name.\n\t * @param documentOrExpanded The JSON-LD document to get the property from or already expanded document.\n\t * @param propertyFullName The full expanded property name.\n\t * @param language Optional filter values by their language property.\n\t * @returns Matching property values for the input property.\n\t */\n\tpublic static async getPropertyValue(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[],\n\t\tpropertyFullName: string,\n\t\tlanguage?: string\n\t): Promise<IJsonLdNodePrimitive[] | undefined> {\n\t\tconst results = await JsonLdHelper.getPropertyValues(\n\t\t\tdocumentOrExpanded,\n\t\t\t[propertyFullName],\n\t\t\tlanguage\n\t\t);\n\n\t\treturn results[0];\n\t}\n\n\t/**\n\t * Get property values by their full expanded property names.\n\t * @param documentOrExpanded The JSON-LD document to get the property from or already expanded document.\n\t * @param propertyFullNames The full expanded property names.\n\t * @param language Optional filter values by their language property.\n\t * @returns Matching property values for each input property, in the same index order.\n\t */\n\tpublic static async getPropertyValues(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[],\n\t\tpropertyFullNames: string[],\n\t\tlanguage?: string\n\t): Promise<(IJsonLdNodePrimitive[] | undefined)[]> {\n\t\tconst expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);\n\n\t\tGuards.arrayValue(JsonLdHelper.CLASS_NAME, nameof(propertyFullNames), propertyFullNames);\n\t\tif (Is.stringValue(language)) {\n\t\t\tGuards.stringValue(JsonLdHelper.CLASS_NAME, nameof(language), language);\n\t\t}\n\t\tconst languageLower = Is.stringValue(language) ? language.toLowerCase() : undefined;\n\t\tconst result: (IJsonLdNodePrimitive[] | undefined)[] = [];\n\n\t\tfor (const propertyFullName of propertyFullNames) {\n\t\t\tGuards.stringValue(JsonLdHelper.CLASS_NAME, nameof(propertyFullName), propertyFullName);\n\t\t\tconst values: IJsonLdNodePrimitive[] = [];\n\n\t\t\tfor (const expandedDoc of expanded) {\n\t\t\t\tconst propValue = expandedDoc[propertyFullName];\n\t\t\t\tif (!Is.empty(propValue)) {\n\t\t\t\t\tconst expandedProps = ArrayHelper.fromObjectOrArray(propValue);\n\t\t\t\t\tif (Is.arrayValue(expandedProps)) {\n\t\t\t\t\t\tfor (const expandedProp of expandedProps) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tIs.object<{ \"@value\"?: IJsonLdNodePrimitive; \"@language\"?: string }>(expandedProp)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tif (!Is.empty(expandedProp[\"@value\"])) {\n\t\t\t\t\t\t\t\t\tlet shouldAdd = true;\n\t\t\t\t\t\t\t\t\tif (Is.stringValue(languageLower)) {\n\t\t\t\t\t\t\t\t\t\tconst itemLanguage = Is.stringValue(expandedProp[\"@language\"])\n\t\t\t\t\t\t\t\t\t\t\t? expandedProp[\"@language\"].toLowerCase()\n\t\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\t\t\tshouldAdd = itemLanguage === languageLower;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (shouldAdd) {\n\t\t\t\t\t\t\t\t\t\tvalues.push(expandedProp[\"@value\"]);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else if (!Is.stringValue(languageLower)) {\n\t\t\t\t\t\t\t\t\tvalues.push(expandedProp);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tIs.stringValue(expandedProp) ||\n\t\t\t\t\t\t\t\tIs.boolean(expandedProp) ||\n\t\t\t\t\t\t\t\tIs.number(expandedProp)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tif (!Is.stringValue(languageLower)) {\n\t\t\t\t\t\t\t\t\tvalues.push(expandedProp);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresult.push(values.length > 0 ? values : undefined);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Prefix all properties in the document with the provided prefix, except for JSON-LD properties.\n\t * This is useful for ensuring that all properties are fully qualified with a namespace.\n\t * For example, if the prefix is \"ex\" and the document has a property \"name\", it will be transformed to \"ex:name\".\n\t * @param nodeObject The JSON-LD node object to prefix properties on.\n\t * @param prefix The prefix to add to the properties.\n\t * @param properties Optional list of properties to prefix. If not provided, all properties except for JSON-LD properties.\n\t * @returns A new JSON-LD node object with the properties prefixed.\n\t */\n\tpublic static prefixProperties<T extends IJsonLdNodeObject>(\n\t\tnodeObject: T,\n\t\tprefix: string,\n\t\tproperties?: string[]\n\t): IJsonLdNodeObject {\n\t\tGuards.object<IJsonLdNodeObject>(JsonLdHelper.CLASS_NAME, nameof(nodeObject), nodeObject);\n\t\tGuards.stringValue(JsonLdHelper.CLASS_NAME, nameof(prefix), prefix);\n\t\tconst normalizedPrefix = prefix.endsWith(\":\") ? prefix.slice(0, -1) : prefix;\n\t\tconst hasNoPropertiesFilter = !Is.arrayValue(properties);\n\n\t\tconst prefixedNodeObject: IJsonLdNodeObject = {};\n\n\t\tfor (const key in nodeObject) {\n\t\t\tconst value = nodeObject[key];\n\t\t\tif (\n\t\t\t\tIs.stringValue(key) &&\n\t\t\t\t!key.startsWith(\"@\") &&\n\t\t\t\t(hasNoPropertiesFilter || properties.includes(key))\n\t\t\t) {\n\t\t\t\tprefixedNodeObject[`${normalizedPrefix}:${key}`] = value;\n\t\t\t} else {\n\t\t\t\tprefixedNodeObject[key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn prefixedNodeObject;\n\t}\n\n\t/**\n\t * Strip a prefix from properties in the document, except for JSON-LD properties.\n\t * This is useful for converting fully qualified namespaced properties back to local names.\n\t * For example, if the prefix is \"ex\" and the document has a property \"ex:name\", it will be transformed to \"name\".\n\t * @param nodeObject The JSON-LD node object to strip prefixed properties from.\n\t * @param prefix The prefix to remove from the properties.\n\t * @param properties Optional list of unprefixed properties to strip. If not provided, all matching prefixed properties.\n\t * @returns A new JSON-LD node object with the prefix stripped from matching properties.\n\t */\n\tpublic static stripPrefixProperties<T extends IJsonLdNodeObject>(\n\t\tnodeObject: T,\n\t\tprefix: string,\n\t\tproperties?: string[]\n\t): IJsonLdNodeObject {\n\t\tGuards.object<IJsonLdNodeObject>(JsonLdHelper.CLASS_NAME, nameof(nodeObject), nodeObject);\n\t\tGuards.stringValue(JsonLdHelper.CLASS_NAME, nameof(prefix), prefix);\n\t\tconst normalizedPrefix = prefix.endsWith(\":\") ? prefix.slice(0, -1) : prefix;\n\t\tconst hasNoPropertiesFilter = !Is.arrayValue(properties);\n\n\t\tconst strippedNodeObject: IJsonLdNodeObject = {};\n\n\t\tfor (const key in nodeObject) {\n\t\t\tconst value = nodeObject[key];\n\t\t\tif (Is.stringValue(key) && !key.startsWith(\"@\") && key.startsWith(`${normalizedPrefix}:`)) {\n\t\t\t\tconst strippedKey = key.slice(normalizedPrefix.length + 1);\n\t\t\t\tif (hasNoPropertiesFilter || properties.includes(strippedKey)) {\n\t\t\t\t\tstrippedNodeObject[strippedKey] = value;\n\t\t\t\t} else {\n\t\t\t\t\tstrippedNodeObject[key] = value;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstrippedNodeObject[key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn strippedNodeObject;\n\t}\n\n\t/**\n\t * Get an expanded JSON-LD document from either compact or expanded input.\n\t * @param documentOrExpanded The JSON-LD document or expanded document.\n\t * @returns The expanded JSON-LD document.\n\t * @internal\n\t */\n\tprivate static async getExpandedDocument(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[]\n\t): Promise<IJsonLdNodeObject[]> {\n\t\tif (Is.array<IJsonLdNodeObject>(documentOrExpanded)) {\n\t\t\tGuards.array<IJsonLdNodeObject>(\n\t\t\t\tJsonLdHelper.CLASS_NAME,\n\t\t\t\tnameof(documentOrExpanded),\n\t\t\t\tdocumentOrExpanded\n\t\t\t);\n\n\t\t\treturn documentOrExpanded;\n\t\t}\n\n\t\tGuards.object<IJsonLdDocument>(\n\t\t\tJsonLdHelper.CLASS_NAME,\n\t\t\tnameof(documentOrExpanded),\n\t\t\tdocumentOrExpanded\n\t\t);\n\n\t\treturn JsonLdProcessor.expand(documentOrExpanded);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"jsonLdHelper.js","sourceRoot":"","sources":["../../../src/utils/jsonLdHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAA2B,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAuB,MAAM,qBAAqB,CAAC;AAE1E,OAAO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,wBAEvB,kBAAkB,CAClB,CAAC;QAEF,OAAO,eAAe,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACnD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ArrayHelper, Guards, Is, type IValidationFailure } from \"@twin.org/core\";\nimport { DataTypeHelper, type ValidationMode } from \"@twin.org/data-core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { JsonLdProcessor } from \"./jsonLdProcessor.js\";\nimport type { IJsonLdDocument } from \"../models/IJsonLdDocument.js\";\nimport type { IJsonLdNodeObject } from \"../models/IJsonLdNodeObject.js\";\nimport type { IJsonLdNodePrimitive } from \"../models/IJsonLdNodePrimitive.js\";\n\n/**\n * Class to help with JSON LD.\n */\nexport class JsonLdHelper {\n\t/**\n\t * The class name.\n\t * @internal\n\t */\n\tpublic static readonly CLASS_NAME = nameof<JsonLdHelper>();\n\n\t/**\n\t * Validate a JSON-LD document.\n\t * @param document The JSON-LD document to validate.\n\t * @param validationFailures The list of validation failures to add to.\n\t * @param options Optional options for validation.\n\t * @param options.failOnMissingType If true, will fail validation if the data type is missing, defaults to false.\n\t * @param options.validationMode The validation mode to use, defaults to either.\n\t * @returns True if the document was valid.\n\t */\n\tpublic static async validate<T extends IJsonLdDocument = IJsonLdDocument>(\n\t\tdocument: T,\n\t\tvalidationFailures: IValidationFailure[],\n\t\toptions?: {\n\t\t\tvalidationMode?: ValidationMode;\n\t\t\tfailOnMissingType?: boolean;\n\t\t}\n\t): Promise<boolean> {\n\t\tif (Is.array<IJsonLdNodeObject>(document)) {\n\t\t\t// If the document is an array of nodes, validate each node\n\t\t\tfor (const node of document) {\n\t\t\t\tawait JsonLdHelper.validate(node, validationFailures, options);\n\t\t\t}\n\t\t} else if (Is.array<IJsonLdNodeObject>(document[\"@graph\"])) {\n\t\t\t// If the graph is an array of nodes, validate each node\n\t\t\tfor (const node of document[\"@graph\"]) {\n\t\t\t\tawait JsonLdHelper.validate(node, validationFailures, options);\n\t\t\t}\n\t\t} else if (Is.object<IJsonLdNodeObject>(document)) {\n\t\t\t// Expand the document to ensure we have the full context for types\n\t\t\t// As the data types in the factories are always fully qualified\n\t\t\tconst expandedDocs = await JsonLdProcessor.expand(document);\n\t\t\tif (Is.arrayValue(expandedDocs)) {\n\t\t\t\tfor (const expandedDoc of expandedDocs) {\n\t\t\t\t\tconst expandedDataTypes = ArrayHelper.fromObjectOrArray(expandedDoc[\"@type\"]);\n\t\t\t\t\tif (Is.arrayValue(expandedDataTypes)) {\n\t\t\t\t\t\tfor (const expandedDataType of expandedDataTypes) {\n\t\t\t\t\t\t\tawait DataTypeHelper.validate(\n\t\t\t\t\t\t\t\t\"document\",\n\t\t\t\t\t\t\t\texpandedDataType,\n\t\t\t\t\t\t\t\tdocument,\n\t\t\t\t\t\t\t\tvalidationFailures,\n\t\t\t\t\t\t\t\toptions\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn validationFailures.length === 0;\n\t}\n\n\t/**\n\t * Convert an object to a JSON-LD node object.\n\t * @param object The object to convert.\n\t * @returns The JSON-LD node object.\n\t */\n\tpublic static toNodeObject<T = unknown>(object: T): T & IJsonLdNodeObject {\n\t\tGuards.object<T>(JsonLdHelper.CLASS_NAME, nameof(object), object);\n\t\treturn object as T & IJsonLdNodeObject;\n\t}\n\n\t/**\n\t * Convert the JSON-LD node object to a structured object.\n\t * @param nodeObject The JSON-LD node object to convert.\n\t * @returns The structured object.\n\t */\n\tpublic static toStructuredObject<T = unknown>(nodeObject: IJsonLdNodeObject): T {\n\t\tGuards.object<IJsonLdNodeObject>(JsonLdHelper.CLASS_NAME, nameof(nodeObject), nodeObject);\n\t\treturn nodeObject as unknown as T;\n\t}\n\n\t/**\n\t * Expand the JSON-LD document.\n\t * @param document The JSON-LD document to expand.\n\t * @returns The expanded JSON-LD document.\n\t */\n\tpublic static async expand(document: IJsonLdDocument): Promise<IJsonLdNodeObject[]> {\n\t\tGuards.object<IJsonLdDocument>(JsonLdHelper.CLASS_NAME, nameof(document), document);\n\t\treturn JsonLdProcessor.expand(document);\n\t}\n\n\t/**\n\t * Expand the JSON-LD document and check if it is of a specific type.\n\t * @param documentOrExpanded The JSON-LD document to check or already expanded document.\n\t * @param type The type to check for.\n\t * @returns True if the document is of the specified type.\n\t */\n\tpublic static async isType(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[],\n\t\ttype: string[]\n\t): Promise<boolean> {\n\t\tconst expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);\n\t\tGuards.arrayValue(JsonLdHelper.CLASS_NAME, nameof(type), type);\n\n\t\tif (Is.arrayValue(expanded)) {\n\t\t\tfor (const item of expanded) {\n\t\t\t\tconst types = ArrayHelper.fromObjectOrArray(item[\"@type\"]);\n\t\t\t\tif (Is.arrayValue(types)) {\n\t\t\t\t\t// All required types must be present in this item's @type array\n\t\t\t\t\tconst itemTypes = new Set(types);\n\t\t\t\t\tif (type.every(t => itemTypes.has(t))) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Get the types from the document.\n\t * @param documentOrExpanded The JSON-LD document to check or already expanded document.\n\t * @returns The type(s) extracted from the document.\n\t */\n\tpublic static async getType(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[]\n\t): Promise<string[]> {\n\t\tconst expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);\n\n\t\tconst types: Set<string> = new Set<string>();\n\t\tconst props = [\"@type\", \"type\"];\n\n\t\tfor (const expandedDoc of expanded) {\n\t\t\tfor (const prop of props) {\n\t\t\t\tconst expandedProps = ArrayHelper.fromObjectOrArray(expandedDoc[prop]);\n\t\t\t\tif (Is.arrayValue(expandedProps)) {\n\t\t\t\t\tfor (const expandedProp of expandedProps) {\n\t\t\t\t\t\tconst arr = ArrayHelper.fromObjectOrArray(expandedProp);\n\t\t\t\t\t\tif (Is.arrayValue(arr)) {\n\t\t\t\t\t\t\tfor (const arrValue of arr) {\n\t\t\t\t\t\t\t\tif (Is.stringValue(arrValue)) {\n\t\t\t\t\t\t\t\t\ttypes.add(arrValue);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn Array.from(types);\n\t}\n\n\t/**\n\t * Get the id from the document.\n\t * @param documentOrExpanded The JSON-LD document to get the id from or already expanded document.\n\t * @param additionalIdProperties Optional additional properties to check for the id, in addition to \"@id\" and \"id\".\n\t * @returns The id extracted from the document.\n\t */\n\tpublic static async getId(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[],\n\t\tadditionalIdProperties?: string[]\n\t): Promise<string | undefined> {\n\t\tconst expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);\n\n\t\tconst props = [\"@id\", \"id\", ...(additionalIdProperties ?? [])];\n\n\t\tfor (const expandedDoc of expanded) {\n\t\t\tfor (const prop of props) {\n\t\t\t\tconst expandedProps = ArrayHelper.fromObjectOrArray(expandedDoc[prop]);\n\t\t\t\tif (Is.arrayValue(expandedProps)) {\n\t\t\t\t\tfor (const expandedProp of expandedProps) {\n\t\t\t\t\t\tconst arr = ArrayHelper.fromObjectOrArray(expandedProp);\n\t\t\t\t\t\tif (Is.arrayValue(arr)) {\n\t\t\t\t\t\t\tfor (const arrValue of arr) {\n\t\t\t\t\t\t\t\tif (Is.stringValue(arrValue)) {\n\t\t\t\t\t\t\t\t\treturn arrValue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get property values by a single full expanded property name.\n\t * @param documentOrExpanded The JSON-LD document to get the property from or already expanded document.\n\t * @param propertyFullName The full expanded property name.\n\t * @param language Optional filter values by their language property.\n\t * @returns Matching property values for the input property.\n\t */\n\tpublic static async getPropertyValue(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[],\n\t\tpropertyFullName: string,\n\t\tlanguage?: string\n\t): Promise<IJsonLdNodePrimitive[] | undefined> {\n\t\tconst results = await JsonLdHelper.getPropertyValues(\n\t\t\tdocumentOrExpanded,\n\t\t\t[propertyFullName],\n\t\t\tlanguage\n\t\t);\n\n\t\treturn results[0];\n\t}\n\n\t/**\n\t * Get property values by their full expanded property names.\n\t * @param documentOrExpanded The JSON-LD document to get the property from or already expanded document.\n\t * @param propertyFullNames The full expanded property names.\n\t * @param language Optional filter values by their language property.\n\t * @returns Matching property values for each input property, in the same index order.\n\t */\n\tpublic static async getPropertyValues(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[],\n\t\tpropertyFullNames: string[],\n\t\tlanguage?: string\n\t): Promise<(IJsonLdNodePrimitive[] | undefined)[]> {\n\t\tconst expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);\n\n\t\tGuards.arrayValue(JsonLdHelper.CLASS_NAME, nameof(propertyFullNames), propertyFullNames);\n\t\tif (Is.stringValue(language)) {\n\t\t\tGuards.stringValue(JsonLdHelper.CLASS_NAME, nameof(language), language);\n\t\t}\n\t\tconst languageLower = Is.stringValue(language) ? language.toLowerCase() : undefined;\n\t\tconst result: (IJsonLdNodePrimitive[] | undefined)[] = [];\n\n\t\tfor (const propertyFullName of propertyFullNames) {\n\t\t\tGuards.stringValue(JsonLdHelper.CLASS_NAME, nameof(propertyFullName), propertyFullName);\n\t\t\tconst values: IJsonLdNodePrimitive[] = [];\n\n\t\t\tfor (const expandedDoc of expanded) {\n\t\t\t\tconst propValue = expandedDoc[propertyFullName];\n\t\t\t\tif (!Is.empty(propValue)) {\n\t\t\t\t\tconst expandedProps = ArrayHelper.fromObjectOrArray(propValue);\n\t\t\t\t\tif (Is.arrayValue(expandedProps)) {\n\t\t\t\t\t\tfor (const expandedProp of expandedProps) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tIs.object<{ \"@value\"?: IJsonLdNodePrimitive; \"@language\"?: string }>(expandedProp)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tif (!Is.empty(expandedProp[\"@value\"])) {\n\t\t\t\t\t\t\t\t\tlet shouldAdd = true;\n\t\t\t\t\t\t\t\t\tif (Is.stringValue(languageLower)) {\n\t\t\t\t\t\t\t\t\t\tconst itemLanguage = Is.stringValue(expandedProp[\"@language\"])\n\t\t\t\t\t\t\t\t\t\t\t? expandedProp[\"@language\"].toLowerCase()\n\t\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\t\t\tshouldAdd = itemLanguage === languageLower;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (shouldAdd) {\n\t\t\t\t\t\t\t\t\t\tvalues.push(expandedProp[\"@value\"]);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else if (!Is.stringValue(languageLower)) {\n\t\t\t\t\t\t\t\t\tvalues.push(expandedProp);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tIs.stringValue(expandedProp) ||\n\t\t\t\t\t\t\t\tIs.boolean(expandedProp) ||\n\t\t\t\t\t\t\t\tIs.number(expandedProp)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tif (!Is.stringValue(languageLower)) {\n\t\t\t\t\t\t\t\t\tvalues.push(expandedProp);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresult.push(values.length > 0 ? values : undefined);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Prefix all properties in the document with the provided prefix, except for JSON-LD properties.\n\t * This is useful for ensuring that all properties are fully qualified with a namespace.\n\t * For example, if the prefix is \"ex\" and the document has a property \"name\", it will be transformed to \"ex:name\".\n\t * @param nodeObject The JSON-LD node object to prefix properties on.\n\t * @param prefix The prefix to add to the properties.\n\t * @param properties Optional list of properties to prefix. If not provided, all properties except for JSON-LD properties.\n\t * @returns A new JSON-LD node object with the properties prefixed.\n\t */\n\tpublic static prefixProperties<T extends IJsonLdNodeObject>(\n\t\tnodeObject: T,\n\t\tprefix: string,\n\t\tproperties?: string[]\n\t): IJsonLdNodeObject {\n\t\tGuards.object<IJsonLdNodeObject>(JsonLdHelper.CLASS_NAME, nameof(nodeObject), nodeObject);\n\t\tGuards.stringValue(JsonLdHelper.CLASS_NAME, nameof(prefix), prefix);\n\t\tconst normalizedPrefix = prefix.endsWith(\":\") ? prefix.slice(0, -1) : prefix;\n\t\tconst hasNoPropertiesFilter = !Is.arrayValue(properties);\n\n\t\tconst prefixedNodeObject: IJsonLdNodeObject = {};\n\n\t\tfor (const key in nodeObject) {\n\t\t\tconst value = nodeObject[key];\n\t\t\tif (\n\t\t\t\tIs.stringValue(key) &&\n\t\t\t\t!key.startsWith(\"@\") &&\n\t\t\t\t(hasNoPropertiesFilter || properties.includes(key))\n\t\t\t) {\n\t\t\t\tprefixedNodeObject[`${normalizedPrefix}:${key}`] = value;\n\t\t\t} else {\n\t\t\t\tprefixedNodeObject[key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn prefixedNodeObject;\n\t}\n\n\t/**\n\t * Strip a prefix from properties in the document, except for JSON-LD properties.\n\t * This is useful for converting fully qualified namespaced properties back to local names.\n\t * For example, if the prefix is \"ex\" and the document has a property \"ex:name\", it will be transformed to \"name\".\n\t * @param nodeObject The JSON-LD node object to strip prefixed properties from.\n\t * @param prefix The prefix to remove from the properties.\n\t * @param properties Optional list of unprefixed properties to strip. If not provided, all matching prefixed properties.\n\t * @returns A new JSON-LD node object with the prefix stripped from matching properties.\n\t */\n\tpublic static stripPrefixProperties<T extends IJsonLdNodeObject>(\n\t\tnodeObject: T,\n\t\tprefix: string,\n\t\tproperties?: string[]\n\t): IJsonLdNodeObject {\n\t\tGuards.object<IJsonLdNodeObject>(JsonLdHelper.CLASS_NAME, nameof(nodeObject), nodeObject);\n\t\tGuards.stringValue(JsonLdHelper.CLASS_NAME, nameof(prefix), prefix);\n\t\tconst normalizedPrefix = prefix.endsWith(\":\") ? prefix.slice(0, -1) : prefix;\n\t\tconst hasNoPropertiesFilter = !Is.arrayValue(properties);\n\n\t\tconst strippedNodeObject: IJsonLdNodeObject = {};\n\n\t\tfor (const key in nodeObject) {\n\t\t\tconst value = nodeObject[key];\n\t\t\tif (Is.stringValue(key) && !key.startsWith(\"@\") && key.startsWith(`${normalizedPrefix}:`)) {\n\t\t\t\tconst strippedKey = key.slice(normalizedPrefix.length + 1);\n\t\t\t\tif (hasNoPropertiesFilter || properties.includes(strippedKey)) {\n\t\t\t\t\tstrippedNodeObject[strippedKey] = value;\n\t\t\t\t} else {\n\t\t\t\t\tstrippedNodeObject[key] = value;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstrippedNodeObject[key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn strippedNodeObject;\n\t}\n\n\t/**\n\t * Get an expanded JSON-LD document from either compact or expanded input.\n\t * @param documentOrExpanded The JSON-LD document or expanded document.\n\t * @returns The expanded JSON-LD document.\n\t * @internal\n\t */\n\tprivate static async getExpandedDocument(\n\t\tdocumentOrExpanded: IJsonLdDocument | IJsonLdNodeObject[]\n\t): Promise<IJsonLdNodeObject[]> {\n\t\tif (Is.array<IJsonLdNodeObject>(documentOrExpanded)) {\n\t\t\tGuards.array<IJsonLdNodeObject>(\n\t\t\t\tJsonLdHelper.CLASS_NAME,\n\t\t\t\tnameof(documentOrExpanded),\n\t\t\t\tdocumentOrExpanded\n\t\t\t);\n\n\t\t\treturn documentOrExpanded;\n\t\t}\n\n\t\tGuards.object<IJsonLdDocument>(\n\t\t\tJsonLdHelper.CLASS_NAME,\n\t\t\tnameof(documentOrExpanded),\n\t\t\tdocumentOrExpanded\n\t\t);\n\n\t\treturn JsonLdProcessor.expand(documentOrExpanded);\n\t}\n}\n"]}
|
|
@@ -130,7 +130,9 @@ export class JsonLdProcessor {
|
|
|
130
130
|
});
|
|
131
131
|
if (!Is.empty(overrideContext)) {
|
|
132
132
|
// Remove the override context from the compacted document
|
|
133
|
-
compacted["@context"] = JsonLdProcessor.removeContexts(compacted["@context"], [
|
|
133
|
+
compacted["@context"] = JsonLdProcessor.removeContexts(compacted["@context"], [
|
|
134
|
+
overrideContext
|
|
135
|
+
]);
|
|
134
136
|
}
|
|
135
137
|
return compacted;
|
|
136
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonLdProcessor.js","sourceRoot":"","sources":["../../../src/utils/jsonLdProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAExF,OAAO,EACN,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,UAAU,EACV,cAAc,EACd,SAAS,EACT,MAAM,eAAe,CAAC;AACvB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAO5B;;GAEG;AACH,MAAM,OAAO,eAAe;IAC3B;;;OAGG;IACI,MAAM,CAAU,UAAU,qBAA6B;IAE9D;;;OAGG;IACK,MAAM,CAAU,yBAAyB,GAAG,CAAC,CAAC;IAEtD;;;OAGG;IACI,MAAM,CAAC,iBAAiB,CAAC,cAAqD;QACpF,WAAW,CAAC,GAAG,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,iBAAiB;QAC9B,IAAI,cAAc,GACjB,WAAW,CAAC,GAAG,CAAwC,sBAAsB,CAAC,CAAC;QAChF,IAAI,CAAC,EAAE,CAAC,QAA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C,CAAC;QAC5F,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, GeneralError, Is, ObjectHelper, SharedStore } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tFetchHelper,\n\tHeaderHelper,\n\tHeaderTypes,\n\tHttpLinkRelType,\n\tHttpMethod,\n\tHttpStatusCode,\n\tMimeTypes\n} from \"@twin.org/web\";\nimport jsonLd from \"jsonld\";\nimport type { JsonLd, RemoteDocument, Url } from \"jsonld/jsonld-spec.js\";\nimport type { IJsonLdContextDefinition } from \"../models/IJsonLdContextDefinition.js\";\nimport type { IJsonLdContextDefinitionElement } from \"../models/IJsonLdContextDefinitionElement.js\";\nimport type { IJsonLdContextDefinitionRoot } from \"../models/IJsonLdContextDefinitionRoot.js\";\nimport type { IJsonLdNodeObject } from \"../models/IJsonLdNodeObject.js\";\n\n/**\n * JSON-LD Processor.\n */\nexport class JsonLdProcessor {\n\t/**\n\t * The class name.\n\t * @internal\n\t */\n\tpublic static readonly CLASS_NAME = nameof<JsonLdProcessor>();\n\n\t/**\n\t * Maximum number of HTTP Link-header discovery hops (namespace URL → context document).\n\t * @internal\n\t */\n\tprivate static readonly _MAX_LINK_DISCOVERY_DEPTH = 1;\n\n\t/**\n\t * The document loader to use.\n\t * @param documentLoader The document loader to use.\n\t */\n\tpublic static setDocumentLoader(documentLoader: (url: Url) => Promise<RemoteDocument>): void {\n\t\tSharedStore.set(\"jsonLdDocumentLoader\", documentLoader);\n\t}\n\n\t/**\n\t * The document loader to use for retrieving JSON-LD documents.\n\t * @returns The document loader.\n\t */\n\tpublic static getDocumentLoader(): (url: Url) => Promise<RemoteDocument> {\n\t\tlet documentLoader =\n\t\t\tSharedStore.get<(url: Url) => Promise<RemoteDocument>>(\"jsonLdDocumentLoader\");\n\t\tif (!Is.function(documentLoader)) {\n\t\t\tdocumentLoader = async (url: string) => JsonLdProcessor.documentLoader(url);\n\t\t}\n\t\treturn documentLoader;\n\t}\n\n\t/**\n\t * Set the cache time limit for documents.\n\t * @param cacheLimitMs The cache limit in milliseconds.\n\t */\n\tpublic static setCacheLimit(cacheLimitMs: number): void {\n\t\tSharedStore.set(\"jsonLdDocumentCacheLimit\", cacheLimitMs);\n\t}\n\n\t/**\n\t * Get the cache limit for documents.\n\t * @returns The document loader.\n\t */\n\tpublic static getCacheLimit(): number {\n\t\tlet cacheLimitMs = SharedStore.get<number>(\"jsonLdDocumentCacheLimit\");\n\t\tif (Is.empty(cacheLimitMs)) {\n\t\t\tcacheLimitMs = 3600000;\n\t\t\tSharedStore.set(\"jsonLdDocumentCacheLimit\", cacheLimitMs);\n\t\t}\n\t\treturn cacheLimitMs;\n\t}\n\n\t/**\n\t * Replace the global redirect list (use {@link JsonLdProcessor.addRedirect} to append without replacing).\n\t * Redirects run before any HTTP GET or `Link` discovery; use them for stable overrides, tests, or hosts that do not expose a suitable `Link` header.\n\t * @param redirects The redirects to use.\n\t */\n\tpublic static setRedirects(\n\t\tredirects: {\n\t\t\tfrom: RegExp;\n\t\t\tto: string;\n\t\t}[]\n\t): void {\n\t\tSharedStore.set(\"jsonLdRedirects\", redirects);\n\t}\n\n\t/**\n\t * Get the global redirects for JSON-LD.\n\t * @returns The registered redirects.\n\t */\n\tpublic static getRedirects(): {\n\t\tfrom: RegExp;\n\t\tto: string;\n\t}[] {\n\t\tlet redirects = SharedStore.get<\n\t\t\t{\n\t\t\t\tfrom: RegExp;\n\t\t\t\tto: string;\n\t\t\t}[]\n\t\t>(\"jsonLdRedirects\");\n\t\tif (Is.empty(redirects)) {\n\t\t\tredirects = [];\n\t\t\tSharedStore.set(\"jsonLdRedirects\", redirects);\n\t\t}\n\t\treturn redirects;\n\t}\n\n\t/**\n\t * Append a redirect rule (ignored if the same `RegExp.source` is already registered).\n\t * Optional when the vocabulary URL supports HTTP `Link` discovery (`rel` includes `alternate`, `type` is `application/ld+json`) via the default document loader.\n\t * Standards packages often expose `registerRedirects()` helpers that call this method; those are optional for the same reason.\n\t * @param from The URL to redirect from.\n\t * @param to The URL to redirect to.\n\t */\n\tpublic static addRedirect(from: RegExp, to: string): void {\n\t\tconst redirects = JsonLdProcessor.getRedirects();\n\t\tif (!redirects.some(r => r.from.source === from.source)) {\n\t\t\tredirects.push({ from, to });\n\t\t}\n\t}\n\n\t/**\n\t * Compact a document according to a particular context.\n\t * @param document The JSON-LD document to compact.\n\t * @param context The context to compact the document to, if not provided will use the one in the document.\n\t * @param options The options for compacting the document.\n\t * @param options.itemListOverride Whether to override the itemListElement context with a set, defaults to true.\n\t * @returns The compacted JSON-LD document.\n\t */\n\tpublic static async compact<T>(\n\t\tdocument: T,\n\t\tcontext?: IJsonLdContextDefinitionRoot,\n\t\toptions?: { itemListOverride: boolean }\n\t): Promise<T> {\n\t\ttry {\n\t\t\tif (Is.object<IJsonLdNodeObject>(document)) {\n\t\t\t\t// If the user didn't provide a context, use the one from the document\n\t\t\t\tif (Is.empty(context) && !Is.empty(document[\"@context\"])) {\n\t\t\t\t\tcontext = document[\"@context\"];\n\t\t\t\t}\n\n\t\t\t\tconst overrideListElementOption = options?.itemListOverride ?? true;\n\t\t\t\tlet overrideContext: IJsonLdContextDefinitionElement | undefined;\n\n\t\t\t\tif (overrideListElementOption) {\n\t\t\t\t\t// The compactArrays flag doesn't work with the current version of jsonld.js\n\t\t\t\t\t// For list results we standardise on ItemList and itemListElement\n\t\t\t\t\t// so we modify the schema.org type for itemListElement to be a set which bypasses the issue\n\t\t\t\t\t// https://github.com/digitalbazaar/jsonld.js/issues/247\n\t\t\t\t\toverrideContext = {\n\t\t\t\t\t\titemListElement: {\n\t\t\t\t\t\t\t\"@id\": \"http://schema.org/itemListElement\",\n\t\t\t\t\t\t\t\"@container\": \"@set\",\n\t\t\t\t\t\t\t\"@protected\": true\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tif (Is.object(context) && \"@context\" in context) {\n\t\t\t\t\t\t// If the context is an object, we need to merge it with the override context\n\t\t\t\t\t\tcontext = JsonLdProcessor.combineContexts(\n\t\t\t\t\t\t\tcontext[\"@context\"] as IJsonLdContextDefinitionRoot,\n\t\t\t\t\t\t\toverrideContext\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the context is a string or an array, we need to merge it with the override context\n\t\t\t\t\t\tcontext = JsonLdProcessor.combineContexts(context, overrideContext);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst compacted = await jsonLd.compact(\n\t\t\t\t\tObjectHelper.removeEmptyProperties(document),\n\t\t\t\t\tcontext as IJsonLdContextDefinition,\n\t\t\t\t\t{\n\t\t\t\t\t\tdocumentLoader: JsonLdProcessor.getDocumentLoader()\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif (!Is.empty(overrideContext)) {\n\t\t\t\t\t// Remove the override context from the compacted document\n\t\t\t\t\tcompacted[\"@context\"] = JsonLdProcessor.removeContexts(\n\t\t\t\t\t\tcompacted[\"@context\"] as IJsonLdContextDefinitionRoot,\n\t\t\t\t\t\t[overrideContext]\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn compacted as T;\n\t\t\t}\n\t\t\treturn document;\n\t\t} catch (err) {\n\t\t\tJsonLdProcessor.handleCommonErrors(err);\n\n\t\t\tthrow new GeneralError(JsonLdProcessor.CLASS_NAME, \"compact\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Expand a document, removing its context.\n\t * @param compacted The compacted JSON-LD document to expand.\n\t * @returns The expanded JSON-LD document.\n\t */\n\tpublic static async expand<T>(compacted: T): Promise<IJsonLdNodeObject[]> {\n\t\ttry {\n\t\t\tif (Is.object<IJsonLdNodeObject>(compacted)) {\n\t\t\t\tconst expanded = await jsonLd.expand(ObjectHelper.removeEmptyProperties(compacted), {\n\t\t\t\t\tdocumentLoader: JsonLdProcessor.getDocumentLoader()\n\t\t\t\t});\n\t\t\t\treturn expanded;\n\t\t\t}\n\t\t\treturn [];\n\t\t} catch (err) {\n\t\t\tJsonLdProcessor.handleCommonErrors(err);\n\n\t\t\tthrow new GeneralError(JsonLdProcessor.CLASS_NAME, \"expand\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Canonize a document.\n\t * @param document The document to canonize.\n\t * @param options The options for canonization.\n\t * @param options.algorithm The algorithm to use for canonization, defaults to URDNA2015.\n\t * @returns The canonized document.\n\t */\n\tpublic static async canonize<T extends IJsonLdNodeObject>(\n\t\tdocument: T,\n\t\toptions?: {\n\t\t\talgorithm?: \"URDNA2015\" | \"URGNA2012\" | undefined;\n\t\t}\n\t): Promise<string> {\n\t\ttry {\n\t\t\tconst normalized = await jsonLd.canonize(ObjectHelper.removeEmptyProperties(document), {\n\t\t\t\talgorithm: options?.algorithm ?? \"URDNA2015\",\n\t\t\t\tformat: \"application/n-quads\",\n\t\t\t\tdocumentLoader: JsonLdProcessor.getDocumentLoader()\n\t\t\t});\n\t\t\treturn normalized;\n\t\t} catch (err) {\n\t\t\tJsonLdProcessor.handleCommonErrors(err);\n\n\t\t\tthrow new GeneralError(JsonLdProcessor.CLASS_NAME, \"canonize\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Combine contexts.\n\t * @param context1 The first JSON-LD context to combine.\n\t * @param context2 The second JSON-LD context to combine.\n\t * @returns The combined context.\n\t */\n\tpublic static combineContexts(\n\t\tcontext1: IJsonLdContextDefinitionRoot | undefined,\n\t\tcontext2: IJsonLdContextDefinitionRoot | undefined\n\t): IJsonLdContextDefinitionRoot | undefined {\n\t\tconst combinedContext: IJsonLdContextDefinitionRoot = [];\n\n\t\tif (Is.string(context1)) {\n\t\t\tif (!combinedContext.includes(context1)) {\n\t\t\t\tcombinedContext.push(context1);\n\t\t\t}\n\t\t} else if (Is.array(context1)) {\n\t\t\tfor (const context of context1) {\n\t\t\t\tconst hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context));\n\t\t\t\tif (!hasMatch) {\n\t\t\t\t\tcombinedContext.push(context);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.object(context1)) {\n\t\t\tconst hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context1));\n\t\t\tif (!hasMatch) {\n\t\t\t\tcombinedContext.push(context1);\n\t\t\t}\n\t\t}\n\n\t\tif (Is.string(context2)) {\n\t\t\tif (!combinedContext.includes(context2)) {\n\t\t\t\tcombinedContext.push(context2);\n\t\t\t}\n\t\t} else if (Is.array(context2)) {\n\t\t\tfor (const context of context2) {\n\t\t\t\tconst hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context));\n\t\t\t\tif (!hasMatch) {\n\t\t\t\t\tcombinedContext.push(context);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.object(context2)) {\n\t\t\tconst hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context2));\n\t\t\tif (!hasMatch) {\n\t\t\t\tcombinedContext.push(context2);\n\t\t\t}\n\t\t}\n\n\t\tif (combinedContext.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (combinedContext.length === 1) {\n\t\t\treturn combinedContext[0];\n\t\t}\n\n\t\treturn combinedContext;\n\t}\n\n\t/**\n\t * Gather all the contexts from the element and it's children.\n\t * @param element The element to gather the contexts from.\n\t * @param initial The initial context.\n\t * @returns The combined contexts.\n\t */\n\tpublic static gatherContexts<T>(\n\t\telement: T,\n\t\tinitial?: IJsonLdContextDefinitionRoot\n\t): IJsonLdContextDefinitionRoot | undefined {\n\t\tlet combinedContexts: IJsonLdContextDefinitionRoot | undefined = initial;\n\n\t\tif (Is.object<IJsonLdNodeObject>(element)) {\n\t\t\tif (!Is.empty(element[\"@context\"])) {\n\t\t\t\tcombinedContexts = JsonLdProcessor.combineContexts(\n\t\t\t\t\tinitial,\n\t\t\t\t\telement[\"@context\"] as IJsonLdContextDefinitionRoot\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfor (const prop of Object.keys(element)) {\n\t\t\t\tconst value = element[prop];\n\t\t\t\tif (Is.object(value)) {\n\t\t\t\t\tcombinedContexts = JsonLdProcessor.gatherContexts(\n\t\t\t\t\t\tvalue as IJsonLdNodeObject,\n\t\t\t\t\t\tcombinedContexts\n\t\t\t\t\t);\n\t\t\t\t} else if (Is.array(value)) {\n\t\t\t\t\tfor (const item of value) {\n\t\t\t\t\t\tif (Is.object(item)) {\n\t\t\t\t\t\t\tcombinedContexts = JsonLdProcessor.gatherContexts(\n\t\t\t\t\t\t\t\titem as IJsonLdNodeObject,\n\t\t\t\t\t\t\t\tcombinedContexts\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn combinedContexts;\n\t}\n\n\t/**\n\t * Remove all the contexts that match the pattern.\n\t * @param context The context to remove the entries from.\n\t * @param match The element to try and match.\n\t * @returns The updated contexts.\n\t */\n\tpublic static removeContexts(\n\t\tcontext: IJsonLdContextDefinitionRoot | undefined,\n\t\tmatch?: IJsonLdContextDefinitionElement[]\n\t): IJsonLdContextDefinitionRoot | undefined {\n\t\tif (!Is.arrayValue(match)) {\n\t\t\treturn context;\n\t\t}\n\n\t\tlet finalContext: IJsonLdContextDefinitionRoot | undefined;\n\t\tif (Is.string(context)) {\n\t\t\tfor (const m of match) {\n\t\t\t\tif (context === m) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.array(context)) {\n\t\t\tfor (const item of context) {\n\t\t\t\tconst hasMatch = match.some(m => ObjectHelper.equal(m, item));\n\t\t\t\tif (!hasMatch) {\n\t\t\t\t\tfinalContext ??= [];\n\t\t\t\t\tif (Is.array(finalContext)) {\n\t\t\t\t\t\tfinalContext.push(item);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.object(context)) {\n\t\t\tconst hasMatch = match.some(m => ObjectHelper.equal(m, context));\n\t\t\tif (!hasMatch) {\n\t\t\t\tfinalContext = context;\n\t\t\t}\n\t\t}\n\n\t\treturn Is.arrayValue(finalContext) && finalContext.length === 1\n\t\t\t? finalContext[0]\n\t\t\t: finalContext;\n\t}\n\n\t/**\n\t * Add a context directly to the document loader cache.\n\t * @param url The url the ld context is for.\n\t * @param ldContext The context to add.\n\t * @returns Nothing.\n\t */\n\tpublic static async documentCacheAdd(url: string, ldContext: unknown): Promise<void> {\n\t\tawait FetchHelper.setCacheEntry(url, ldContext);\n\t}\n\n\t/**\n\t * Remove a context from the document loader cache.\n\t * @param url The url the ld context is for.\n\t * @returns Nothing.\n\t */\n\tpublic static async documentCacheRemove(url: string): Promise<void> {\n\t\tFetchHelper.removeCacheEntry(url);\n\t}\n\n\t/**\n\t * Document loader which uses a caching mechanism.\n\t * @param url The document url to load.\n\t * @returns The document.\n\t * @internal\n\t */\n\tprivate static async documentLoader(url: Url): Promise<RemoteDocument> {\n\t\tconst redirects = JsonLdProcessor.getRedirects();\n\t\tfor (const redirect of redirects) {\n\t\t\tif (redirect.from.test(url)) {\n\t\t\t\turl = redirect.to;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn JsonLdProcessor.fetchRemoteJsonLdDocument(url, 0);\n\t}\n\n\t/**\n\t * True when FetchHelper failed to decode JSON from the response (e.g. HTML or plain text).\n\t * @param err The error from fetchJson.\n\t * @internal\n\t */\n\tprivate static isFetchJsonDecodeFailure(err: unknown): boolean {\n\t\t// Raw JSON.parse / response.json() failures (FetchHelper may rethrow as FetchError with cause,\n\t\t// or propagate SyntaxError when error-response body is not JSON).\n\t\tconst error = BaseError.fromError(err);\n\t\tif (error.name === \"SyntaxError\" || error.cause?.name === \"SyntaxError\") {\n\t\t\treturn true;\n\t\t}\n\t\treturn error.message.includes(\"decodingJSON\") || error.message.includes(\"is not valid JSON\");\n\t}\n\n\t/**\n\t * Use HTTP Link (rel=alternate, type=application/ld+json) to discover a JSON-LD context URL.\n\t * @param sourceUrl URL that did not yield JSON (e.g. vocabulary namespace HTML page).\n\t * @returns Absolute context document URL, or undefined.\n\t * @internal\n\t */\n\tprivate static async tryDiscoverAlternateJsonLdContextUrl(\n\t\tsourceUrl: string\n\t): Promise<string | undefined> {\n\t\tconst fetchOpts = {\n\t\t\ttimeoutMs: 30_000,\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Accept]: `${MimeTypes.JsonLd},${MimeTypes.Json};q=0.9,*/*;q=0.8`\n\t\t\t}\n\t\t};\n\n\t\tlet response = await FetchHelper.fetch(\n\t\t\tJsonLdProcessor.CLASS_NAME,\n\t\t\tsourceUrl,\n\t\t\tHttpMethod.HEAD,\n\t\t\tundefined,\n\t\t\tfetchOpts\n\t\t);\n\n\t\tif (\n\t\t\tresponse.status === HttpStatusCode.methodNotAllowed ||\n\t\t\tresponse.status === HttpStatusCode.notImplemented\n\t\t) {\n\t\t\tresponse = await FetchHelper.fetch(\n\t\t\t\tJsonLdProcessor.CLASS_NAME,\n\t\t\t\tsourceUrl,\n\t\t\t\tHttpMethod.GET,\n\t\t\t\tundefined,\n\t\t\t\tfetchOpts\n\t\t\t);\n\t\t\tawait response.arrayBuffer();\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst linkHeader = response.headers.get(HeaderTypes.Link);\n\t\tif (Is.empty(linkHeader)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// response.url is \"\" for many mocked/synthetic Responses; Is.empty(\"\") is false, but\n\t\t// new URL(absoluteHref, \"\") throws — use a non-empty resolved URL as base only.\n\t\tconst baseUrl = Is.stringValue(response.url) ? response.url : sourceUrl;\n\n\t\tconst alternateLinkHeaders = HeaderHelper.extractLinkHeaderRelations(\n\t\t\tlinkHeader,\n\t\t\tHttpLinkRelType.alternate\n\t\t);\n\n\t\tif (Is.arrayValue(alternateLinkHeaders)) {\n\t\t\tfor (const alternateLinkHeader of alternateLinkHeaders) {\n\t\t\t\tif (alternateLinkHeader.params?.type === MimeTypes.JsonLd) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn new URL(alternateLinkHeader.url, baseUrl).href;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Malformed URL for this segment; try the next Link segment.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Fetch a remote JSON-LD document, with Accept fallbacks and optional Link-header discovery.\n\t * @param url Resolved document URL.\n\t * @param linkDiscoveryDepth Current discovery recursion depth.\n\t * @internal\n\t */\n\tprivate static async fetchRemoteJsonLdDocument(\n\t\turl: string,\n\t\tlinkDiscoveryDepth: number\n\t): Promise<RemoteDocument> {\n\t\tconst cacheTtlMs = JsonLdProcessor.getCacheLimit();\n\t\tconst fetchJsonLdOptions = {\n\t\t\tcacheTtlMs,\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t}\n\t\t};\n\t\tconst fetchJsonOptions = {\n\t\t\tcacheTtlMs,\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Accept]: MimeTypes.Json\n\t\t\t}\n\t\t};\n\n\t\ttry {\n\t\t\tconst document = await FetchHelper.fetchJson<never, JsonLd>(\n\t\t\t\tJsonLdProcessor.CLASS_NAME,\n\t\t\t\turl,\n\t\t\t\tHttpMethod.GET,\n\t\t\t\tundefined,\n\t\t\t\tfetchJsonLdOptions\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tdocumentUrl: url,\n\t\t\t\tdocument\n\t\t\t};\n\t\t} catch (errLd) {\n\t\t\tif (JsonLdProcessor.isFetchJsonDecodeFailure(errLd)) {\n\t\t\t\ttry {\n\t\t\t\t\tconst document = await FetchHelper.fetchJson<never, JsonLd>(\n\t\t\t\t\t\tJsonLdProcessor.CLASS_NAME,\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tHttpMethod.GET,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tfetchJsonOptions\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdocumentUrl: url,\n\t\t\t\t\t\tdocument\n\t\t\t\t\t};\n\t\t\t\t} catch (errJson) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tlinkDiscoveryDepth < JsonLdProcessor._MAX_LINK_DISCOVERY_DEPTH &&\n\t\t\t\t\t\tJsonLdProcessor.isFetchJsonDecodeFailure(errJson)\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst discovered = await JsonLdProcessor.tryDiscoverAlternateJsonLdContextUrl(url);\n\t\t\t\t\t\tif (Is.stringValue(discovered) && discovered !== url) {\n\t\t\t\t\t\t\treturn JsonLdProcessor.fetchRemoteJsonLdDocument(discovered, linkDiscoveryDepth + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow errJson;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow errLd;\n\t\t}\n\t}\n\n\t/**\n\t * Handle common errors.\n\t * @param err The error to handle.\n\t * @internal\n\t */\n\tprivate static handleCommonErrors(err: unknown): void {\n\t\tif (\n\t\t\tIs.object<{ name: string; details?: { url?: string } }>(err) &&\n\t\t\terr.name === \"jsonld.InvalidUrl\"\n\t\t) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tJsonLdProcessor.CLASS_NAME,\n\t\t\t\t\"invalidUrl\",\n\t\t\t\t{ url: err.details?.url },\n\t\t\t\terr\n\t\t\t);\n\t\t} else if (\n\t\t\tIs.object<{ name: string; details?: { code: string } & { [id: string]: unknown } }>(err) &&\n\t\t\terr.name.startsWith(\"jsonld.\")\n\t\t) {\n\t\t\tconst { code, ...other } = err.details ?? {};\n\t\t\tthrow new GeneralError(JsonLdProcessor.CLASS_NAME, \"jsonLdError\", { code, ...other }, err);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"jsonLdProcessor.js","sourceRoot":"","sources":["../../../src/utils/jsonLdProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY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,CAAC,kBAAkB,CAAC,GAAY;QAC7C,IACC,EAAE,CAAC,MAAM,CAA+C,GAAG,CAAC;YAC5D,GAAG,CAAC,IAAI,KAAK,mBAAmB,EAC/B,CAAC;YACF,MAAM,IAAI,YAAY,CACrB,eAAe,CAAC,UAAU,EAC1B,YAAY,EACZ,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,EACzB,GAAG,CACH,CAAC;QACH,CAAC;aAAM,IACN,EAAE,CAAC,MAAM,CAA2E,GAAG,CAAC;YACxF,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAC7B,CAAC;YACF,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,GAAG,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;YAC7C,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC;QAC5F,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, GeneralError, Is, ObjectHelper, SharedStore } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tFetchHelper,\n\tHeaderHelper,\n\tHeaderTypes,\n\tHttpLinkRelType,\n\tHttpMethod,\n\tHttpStatusCode,\n\tMimeTypes\n} from \"@twin.org/web\";\nimport jsonLd from \"jsonld\";\nimport type { JsonLd, RemoteDocument, Url } from \"jsonld/jsonld-spec.js\";\nimport type { IJsonLdContextDefinition } from \"../models/IJsonLdContextDefinition.js\";\nimport type { IJsonLdContextDefinitionElement } from \"../models/IJsonLdContextDefinitionElement.js\";\nimport type { IJsonLdContextDefinitionRoot } from \"../models/IJsonLdContextDefinitionRoot.js\";\nimport type { IJsonLdNodeObject } from \"../models/IJsonLdNodeObject.js\";\n\n/**\n * JSON-LD Processor.\n */\nexport class JsonLdProcessor {\n\t/**\n\t * The class name.\n\t * @internal\n\t */\n\tpublic static readonly CLASS_NAME = nameof<JsonLdProcessor>();\n\n\t/**\n\t * Maximum number of HTTP Link-header discovery hops (namespace URL → context document).\n\t * @internal\n\t */\n\tprivate static readonly _MAX_LINK_DISCOVERY_DEPTH = 1;\n\n\t/**\n\t * The document loader to use.\n\t * @param documentLoader The document loader to use.\n\t */\n\tpublic static setDocumentLoader(documentLoader: (url: Url) => Promise<RemoteDocument>): void {\n\t\tSharedStore.set(\"jsonLdDocumentLoader\", documentLoader);\n\t}\n\n\t/**\n\t * The document loader to use for retrieving JSON-LD documents.\n\t * @returns The document loader.\n\t */\n\tpublic static getDocumentLoader(): (url: Url) => Promise<RemoteDocument> {\n\t\tlet documentLoader =\n\t\t\tSharedStore.get<(url: Url) => Promise<RemoteDocument>>(\"jsonLdDocumentLoader\");\n\t\tif (!Is.function(documentLoader)) {\n\t\t\tdocumentLoader = async (url: string) => JsonLdProcessor.documentLoader(url);\n\t\t}\n\t\treturn documentLoader;\n\t}\n\n\t/**\n\t * Set the cache time limit for documents.\n\t * @param cacheLimitMs The cache limit in milliseconds.\n\t */\n\tpublic static setCacheLimit(cacheLimitMs: number): void {\n\t\tSharedStore.set(\"jsonLdDocumentCacheLimit\", cacheLimitMs);\n\t}\n\n\t/**\n\t * Get the cache limit for documents.\n\t * @returns The document loader.\n\t */\n\tpublic static getCacheLimit(): number {\n\t\tlet cacheLimitMs = SharedStore.get<number>(\"jsonLdDocumentCacheLimit\");\n\t\tif (Is.empty(cacheLimitMs)) {\n\t\t\tcacheLimitMs = 3600000;\n\t\t\tSharedStore.set(\"jsonLdDocumentCacheLimit\", cacheLimitMs);\n\t\t}\n\t\treturn cacheLimitMs;\n\t}\n\n\t/**\n\t * Replace the global redirect list (use {@link JsonLdProcessor.addRedirect} to append without replacing).\n\t * Redirects run before any HTTP GET or `Link` discovery; use them for stable overrides, tests, or hosts that do not expose a suitable `Link` header.\n\t * @param redirects The redirects to use.\n\t */\n\tpublic static setRedirects(\n\t\tredirects: {\n\t\t\tfrom: RegExp;\n\t\t\tto: string;\n\t\t}[]\n\t): void {\n\t\tSharedStore.set(\"jsonLdRedirects\", redirects);\n\t}\n\n\t/**\n\t * Get the global redirects for JSON-LD.\n\t * @returns The registered redirects.\n\t */\n\tpublic static getRedirects(): {\n\t\tfrom: RegExp;\n\t\tto: string;\n\t}[] {\n\t\tlet redirects = SharedStore.get<\n\t\t\t{\n\t\t\t\tfrom: RegExp;\n\t\t\t\tto: string;\n\t\t\t}[]\n\t\t>(\"jsonLdRedirects\");\n\t\tif (Is.empty(redirects)) {\n\t\t\tredirects = [];\n\t\t\tSharedStore.set(\"jsonLdRedirects\", redirects);\n\t\t}\n\t\treturn redirects;\n\t}\n\n\t/**\n\t * Append a redirect rule (ignored if the same `RegExp.source` is already registered).\n\t * Optional when the vocabulary URL supports HTTP `Link` discovery (`rel` includes `alternate`, `type` is `application/ld+json`) via the default document loader.\n\t * Standards packages often expose `registerRedirects()` helpers that call this method; those are optional for the same reason.\n\t * @param from The URL to redirect from.\n\t * @param to The URL to redirect to.\n\t */\n\tpublic static addRedirect(from: RegExp, to: string): void {\n\t\tconst redirects = JsonLdProcessor.getRedirects();\n\t\tif (!redirects.some(r => r.from.source === from.source)) {\n\t\t\tredirects.push({ from, to });\n\t\t}\n\t}\n\n\t/**\n\t * Compact a document according to a particular context.\n\t * @param document The JSON-LD document to compact.\n\t * @param context The context to compact the document to, if not provided will use the one in the document.\n\t * @param options The options for compacting the document.\n\t * @param options.itemListOverride Whether to override the itemListElement context with a set, defaults to true.\n\t * @returns The compacted JSON-LD document.\n\t */\n\tpublic static async compact<T>(\n\t\tdocument: T,\n\t\tcontext?: IJsonLdContextDefinitionRoot,\n\t\toptions?: { itemListOverride: boolean }\n\t): Promise<T> {\n\t\ttry {\n\t\t\tif (Is.object<IJsonLdNodeObject>(document)) {\n\t\t\t\t// If the user didn't provide a context, use the one from the document\n\t\t\t\tif (Is.empty(context) && !Is.empty(document[\"@context\"])) {\n\t\t\t\t\tcontext = document[\"@context\"];\n\t\t\t\t}\n\n\t\t\t\tconst overrideListElementOption = options?.itemListOverride ?? true;\n\t\t\t\tlet overrideContext: IJsonLdContextDefinitionElement | undefined;\n\n\t\t\t\tif (overrideListElementOption) {\n\t\t\t\t\t// The compactArrays flag doesn't work with the current version of jsonld.js\n\t\t\t\t\t// For list results we standardise on ItemList and itemListElement\n\t\t\t\t\t// so we modify the schema.org type for itemListElement to be a set which bypasses the issue\n\t\t\t\t\t// https://github.com/digitalbazaar/jsonld.js/issues/247\n\t\t\t\t\toverrideContext = {\n\t\t\t\t\t\titemListElement: {\n\t\t\t\t\t\t\t\"@id\": \"http://schema.org/itemListElement\",\n\t\t\t\t\t\t\t\"@container\": \"@set\",\n\t\t\t\t\t\t\t\"@protected\": true\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tif (Is.object(context) && \"@context\" in context) {\n\t\t\t\t\t\t// If the context is an object, we need to merge it with the override context\n\t\t\t\t\t\tcontext = JsonLdProcessor.combineContexts(\n\t\t\t\t\t\t\tcontext[\"@context\"] as IJsonLdContextDefinitionRoot,\n\t\t\t\t\t\t\toverrideContext\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the context is a string or an array, we need to merge it with the override context\n\t\t\t\t\t\tcontext = JsonLdProcessor.combineContexts(context, overrideContext);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst compacted = await jsonLd.compact(\n\t\t\t\t\tObjectHelper.removeEmptyProperties(document),\n\t\t\t\t\tcontext as IJsonLdContextDefinition,\n\t\t\t\t\t{\n\t\t\t\t\t\tdocumentLoader: JsonLdProcessor.getDocumentLoader()\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif (!Is.empty(overrideContext)) {\n\t\t\t\t\t// Remove the override context from the compacted document\n\t\t\t\t\tcompacted[\"@context\"] = JsonLdProcessor.removeContexts(compacted[\"@context\"], [\n\t\t\t\t\t\toverrideContext\n\t\t\t\t\t]);\n\t\t\t\t}\n\n\t\t\t\treturn compacted as T;\n\t\t\t}\n\t\t\treturn document;\n\t\t} catch (err) {\n\t\t\tJsonLdProcessor.handleCommonErrors(err);\n\n\t\t\tthrow new GeneralError(JsonLdProcessor.CLASS_NAME, \"compact\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Expand a document, removing its context.\n\t * @param compacted The compacted JSON-LD document to expand.\n\t * @returns The expanded JSON-LD document.\n\t */\n\tpublic static async expand<T>(compacted: T): Promise<IJsonLdNodeObject[]> {\n\t\ttry {\n\t\t\tif (Is.object<IJsonLdNodeObject>(compacted)) {\n\t\t\t\tconst expanded = await jsonLd.expand(ObjectHelper.removeEmptyProperties(compacted), {\n\t\t\t\t\tdocumentLoader: JsonLdProcessor.getDocumentLoader()\n\t\t\t\t});\n\t\t\t\treturn expanded;\n\t\t\t}\n\t\t\treturn [];\n\t\t} catch (err) {\n\t\t\tJsonLdProcessor.handleCommonErrors(err);\n\n\t\t\tthrow new GeneralError(JsonLdProcessor.CLASS_NAME, \"expand\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Canonize a document.\n\t * @param document The document to canonize.\n\t * @param options The options for canonization.\n\t * @param options.algorithm The algorithm to use for canonization, defaults to URDNA2015.\n\t * @returns The canonized document.\n\t */\n\tpublic static async canonize<T extends IJsonLdNodeObject>(\n\t\tdocument: T,\n\t\toptions?: {\n\t\t\talgorithm?: \"URDNA2015\" | \"URGNA2012\" | undefined;\n\t\t}\n\t): Promise<string> {\n\t\ttry {\n\t\t\tconst normalized = await jsonLd.canonize(ObjectHelper.removeEmptyProperties(document), {\n\t\t\t\talgorithm: options?.algorithm ?? \"URDNA2015\",\n\t\t\t\tformat: \"application/n-quads\",\n\t\t\t\tdocumentLoader: JsonLdProcessor.getDocumentLoader()\n\t\t\t});\n\t\t\treturn normalized;\n\t\t} catch (err) {\n\t\t\tJsonLdProcessor.handleCommonErrors(err);\n\n\t\t\tthrow new GeneralError(JsonLdProcessor.CLASS_NAME, \"canonize\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Combine contexts.\n\t * @param context1 The first JSON-LD context to combine.\n\t * @param context2 The second JSON-LD context to combine.\n\t * @returns The combined context.\n\t */\n\tpublic static combineContexts(\n\t\tcontext1: IJsonLdContextDefinitionRoot | undefined,\n\t\tcontext2: IJsonLdContextDefinitionRoot | undefined\n\t): IJsonLdContextDefinitionRoot | undefined {\n\t\tconst combinedContext: IJsonLdContextDefinitionRoot = [];\n\n\t\tif (Is.string(context1)) {\n\t\t\tif (!combinedContext.includes(context1)) {\n\t\t\t\tcombinedContext.push(context1);\n\t\t\t}\n\t\t} else if (Is.array(context1)) {\n\t\t\tfor (const context of context1) {\n\t\t\t\tconst hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context));\n\t\t\t\tif (!hasMatch) {\n\t\t\t\t\tcombinedContext.push(context);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.object(context1)) {\n\t\t\tconst hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context1));\n\t\t\tif (!hasMatch) {\n\t\t\t\tcombinedContext.push(context1);\n\t\t\t}\n\t\t}\n\n\t\tif (Is.string(context2)) {\n\t\t\tif (!combinedContext.includes(context2)) {\n\t\t\t\tcombinedContext.push(context2);\n\t\t\t}\n\t\t} else if (Is.array(context2)) {\n\t\t\tfor (const context of context2) {\n\t\t\t\tconst hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context));\n\t\t\t\tif (!hasMatch) {\n\t\t\t\t\tcombinedContext.push(context);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.object(context2)) {\n\t\t\tconst hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context2));\n\t\t\tif (!hasMatch) {\n\t\t\t\tcombinedContext.push(context2);\n\t\t\t}\n\t\t}\n\n\t\tif (combinedContext.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (combinedContext.length === 1) {\n\t\t\treturn combinedContext[0];\n\t\t}\n\n\t\treturn combinedContext;\n\t}\n\n\t/**\n\t * Gather all the contexts from the element and it's children.\n\t * @param element The element to gather the contexts from.\n\t * @param initial The initial context.\n\t * @returns The combined contexts.\n\t */\n\tpublic static gatherContexts<T>(\n\t\telement: T,\n\t\tinitial?: IJsonLdContextDefinitionRoot\n\t): IJsonLdContextDefinitionRoot | undefined {\n\t\tlet combinedContexts: IJsonLdContextDefinitionRoot | undefined = initial;\n\n\t\tif (Is.object<IJsonLdNodeObject>(element)) {\n\t\t\tif (!Is.empty(element[\"@context\"])) {\n\t\t\t\tcombinedContexts = JsonLdProcessor.combineContexts(initial, element[\"@context\"]);\n\t\t\t}\n\n\t\t\tfor (const prop of Object.keys(element)) {\n\t\t\t\tconst value = element[prop];\n\t\t\t\tif (Is.object(value)) {\n\t\t\t\t\tcombinedContexts = JsonLdProcessor.gatherContexts(\n\t\t\t\t\t\tvalue as IJsonLdNodeObject,\n\t\t\t\t\t\tcombinedContexts\n\t\t\t\t\t);\n\t\t\t\t} else if (Is.array(value)) {\n\t\t\t\t\tfor (const item of value) {\n\t\t\t\t\t\tif (Is.object(item)) {\n\t\t\t\t\t\t\tcombinedContexts = JsonLdProcessor.gatherContexts(\n\t\t\t\t\t\t\t\titem as IJsonLdNodeObject,\n\t\t\t\t\t\t\t\tcombinedContexts\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn combinedContexts;\n\t}\n\n\t/**\n\t * Remove all the contexts that match the pattern.\n\t * @param context The context to remove the entries from.\n\t * @param match The element to try and match.\n\t * @returns The updated contexts.\n\t */\n\tpublic static removeContexts(\n\t\tcontext: IJsonLdContextDefinitionRoot | undefined,\n\t\tmatch?: IJsonLdContextDefinitionElement[]\n\t): IJsonLdContextDefinitionRoot | undefined {\n\t\tif (!Is.arrayValue(match)) {\n\t\t\treturn context;\n\t\t}\n\n\t\tlet finalContext: IJsonLdContextDefinitionRoot | undefined;\n\t\tif (Is.string(context)) {\n\t\t\tfor (const m of match) {\n\t\t\t\tif (context === m) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.array(context)) {\n\t\t\tfor (const item of context) {\n\t\t\t\tconst hasMatch = match.some(m => ObjectHelper.equal(m, item));\n\t\t\t\tif (!hasMatch) {\n\t\t\t\t\tfinalContext ??= [];\n\t\t\t\t\tif (Is.array(finalContext)) {\n\t\t\t\t\t\tfinalContext.push(item);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.object(context)) {\n\t\t\tconst hasMatch = match.some(m => ObjectHelper.equal(m, context));\n\t\t\tif (!hasMatch) {\n\t\t\t\tfinalContext = context;\n\t\t\t}\n\t\t}\n\n\t\treturn Is.arrayValue(finalContext) && finalContext.length === 1\n\t\t\t? finalContext[0]\n\t\t\t: finalContext;\n\t}\n\n\t/**\n\t * Add a context directly to the document loader cache.\n\t * @param url The url the ld context is for.\n\t * @param ldContext The context to add.\n\t * @returns Nothing.\n\t */\n\tpublic static async documentCacheAdd(url: string, ldContext: unknown): Promise<void> {\n\t\tawait FetchHelper.setCacheEntry(url, ldContext);\n\t}\n\n\t/**\n\t * Remove a context from the document loader cache.\n\t * @param url The url the ld context is for.\n\t * @returns Nothing.\n\t */\n\tpublic static async documentCacheRemove(url: string): Promise<void> {\n\t\tFetchHelper.removeCacheEntry(url);\n\t}\n\n\t/**\n\t * Document loader which uses a caching mechanism.\n\t * @param url The document url to load.\n\t * @returns The document.\n\t * @internal\n\t */\n\tprivate static async documentLoader(url: Url): Promise<RemoteDocument> {\n\t\tconst redirects = JsonLdProcessor.getRedirects();\n\t\tfor (const redirect of redirects) {\n\t\t\tif (redirect.from.test(url)) {\n\t\t\t\turl = redirect.to;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn JsonLdProcessor.fetchRemoteJsonLdDocument(url, 0);\n\t}\n\n\t/**\n\t * True when FetchHelper failed to decode JSON from the response (e.g. HTML or plain text).\n\t * @param err The error from fetchJson.\n\t * @internal\n\t */\n\tprivate static isFetchJsonDecodeFailure(err: unknown): boolean {\n\t\t// Raw JSON.parse / response.json() failures (FetchHelper may rethrow as FetchError with cause,\n\t\t// or propagate SyntaxError when error-response body is not JSON).\n\t\tconst error = BaseError.fromError(err);\n\t\tif (error.name === \"SyntaxError\" || error.cause?.name === \"SyntaxError\") {\n\t\t\treturn true;\n\t\t}\n\t\treturn error.message.includes(\"decodingJSON\") || error.message.includes(\"is not valid JSON\");\n\t}\n\n\t/**\n\t * Use HTTP Link (rel=alternate, type=application/ld+json) to discover a JSON-LD context URL.\n\t * @param sourceUrl URL that did not yield JSON (e.g. vocabulary namespace HTML page).\n\t * @returns Absolute context document URL, or undefined.\n\t * @internal\n\t */\n\tprivate static async tryDiscoverAlternateJsonLdContextUrl(\n\t\tsourceUrl: string\n\t): Promise<string | undefined> {\n\t\tconst fetchOpts = {\n\t\t\ttimeoutMs: 30_000,\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Accept]: `${MimeTypes.JsonLd},${MimeTypes.Json};q=0.9,*/*;q=0.8`\n\t\t\t}\n\t\t};\n\n\t\tlet response = await FetchHelper.fetch(\n\t\t\tJsonLdProcessor.CLASS_NAME,\n\t\t\tsourceUrl,\n\t\t\tHttpMethod.HEAD,\n\t\t\tundefined,\n\t\t\tfetchOpts\n\t\t);\n\n\t\tif (\n\t\t\tresponse.status === HttpStatusCode.methodNotAllowed ||\n\t\t\tresponse.status === HttpStatusCode.notImplemented\n\t\t) {\n\t\t\tresponse = await FetchHelper.fetch(\n\t\t\t\tJsonLdProcessor.CLASS_NAME,\n\t\t\t\tsourceUrl,\n\t\t\t\tHttpMethod.GET,\n\t\t\t\tundefined,\n\t\t\t\tfetchOpts\n\t\t\t);\n\t\t\tawait response.arrayBuffer();\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst linkHeader = response.headers.get(HeaderTypes.Link);\n\t\tif (Is.empty(linkHeader)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// response.url is \"\" for many mocked/synthetic Responses; Is.empty(\"\") is false, but\n\t\t// new URL(absoluteHref, \"\") throws — use a non-empty resolved URL as base only.\n\t\tconst baseUrl = Is.stringValue(response.url) ? response.url : sourceUrl;\n\n\t\tconst alternateLinkHeaders = HeaderHelper.extractLinkHeaderRelations(\n\t\t\tlinkHeader,\n\t\t\tHttpLinkRelType.alternate\n\t\t);\n\n\t\tif (Is.arrayValue(alternateLinkHeaders)) {\n\t\t\tfor (const alternateLinkHeader of alternateLinkHeaders) {\n\t\t\t\tif (alternateLinkHeader.params?.type === MimeTypes.JsonLd) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn new URL(alternateLinkHeader.url, baseUrl).href;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Malformed URL for this segment; try the next Link segment.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Fetch a remote JSON-LD document, with Accept fallbacks and optional Link-header discovery.\n\t * @param url Resolved document URL.\n\t * @param linkDiscoveryDepth Current discovery recursion depth.\n\t * @internal\n\t */\n\tprivate static async fetchRemoteJsonLdDocument(\n\t\turl: string,\n\t\tlinkDiscoveryDepth: number\n\t): Promise<RemoteDocument> {\n\t\tconst cacheTtlMs = JsonLdProcessor.getCacheLimit();\n\t\tconst fetchJsonLdOptions = {\n\t\t\tcacheTtlMs,\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t}\n\t\t};\n\t\tconst fetchJsonOptions = {\n\t\t\tcacheTtlMs,\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Accept]: MimeTypes.Json\n\t\t\t}\n\t\t};\n\n\t\ttry {\n\t\t\tconst document = await FetchHelper.fetchJson<never, JsonLd>(\n\t\t\t\tJsonLdProcessor.CLASS_NAME,\n\t\t\t\turl,\n\t\t\t\tHttpMethod.GET,\n\t\t\t\tundefined,\n\t\t\t\tfetchJsonLdOptions\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tdocumentUrl: url,\n\t\t\t\tdocument\n\t\t\t};\n\t\t} catch (errLd) {\n\t\t\tif (JsonLdProcessor.isFetchJsonDecodeFailure(errLd)) {\n\t\t\t\ttry {\n\t\t\t\t\tconst document = await FetchHelper.fetchJson<never, JsonLd>(\n\t\t\t\t\t\tJsonLdProcessor.CLASS_NAME,\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tHttpMethod.GET,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tfetchJsonOptions\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdocumentUrl: url,\n\t\t\t\t\t\tdocument\n\t\t\t\t\t};\n\t\t\t\t} catch (errJson) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tlinkDiscoveryDepth < JsonLdProcessor._MAX_LINK_DISCOVERY_DEPTH &&\n\t\t\t\t\t\tJsonLdProcessor.isFetchJsonDecodeFailure(errJson)\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst discovered = await JsonLdProcessor.tryDiscoverAlternateJsonLdContextUrl(url);\n\t\t\t\t\t\tif (Is.stringValue(discovered) && discovered !== url) {\n\t\t\t\t\t\t\treturn JsonLdProcessor.fetchRemoteJsonLdDocument(discovered, linkDiscoveryDepth + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow errJson;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow errLd;\n\t\t}\n\t}\n\n\t/**\n\t * Handle common errors.\n\t * @param err The error to handle.\n\t * @internal\n\t */\n\tprivate static handleCommonErrors(err: unknown): void {\n\t\tif (\n\t\t\tIs.object<{ name: string; details?: { url?: string } }>(err) &&\n\t\t\terr.name === \"jsonld.InvalidUrl\"\n\t\t) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tJsonLdProcessor.CLASS_NAME,\n\t\t\t\t\"invalidUrl\",\n\t\t\t\t{ url: err.details?.url },\n\t\t\t\terr\n\t\t\t);\n\t\t} else if (\n\t\t\tIs.object<{ name: string; details?: { code: string } & { [id: string]: unknown } }>(err) &&\n\t\t\terr.name.startsWith(\"jsonld.\")\n\t\t) {\n\t\t\tconst { code, ...other } = err.details ?? {};\n\t\t\tthrow new GeneralError(JsonLdProcessor.CLASS_NAME, \"jsonLdError\", { code, ...other }, err);\n\t\t}\n\t}\n}\n"]}
|
package/docs/changelog.md
CHANGED
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.0.3-next.
|
|
3
|
+
## [0.0.3-next.22](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.21...data-json-ld-v0.0.3-next.22) (2026-05-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* handle possible undefined array ([094d188](https://github.com/iotaledger/twin-data/commit/094d1887b9f280ffa035d6a1f811a943184f4655))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/data-core bumped from 0.0.3-next.21 to 0.0.3-next.22
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.21](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.20...data-json-ld-v0.0.3-next.21) (2026-05-11)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* typescript 6 update ([44cbfe8](https://github.com/iotaledger/twin-data/commit/44cbfe87256282b9928134b2bbed1d3c6ee15acb))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/data-core bumped from 0.0.3-next.20 to 0.0.3-next.21
|
|
30
|
+
|
|
31
|
+
## [0.0.3-next.20](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.19...data-json-ld-v0.0.3-next.20) (2026-03-24)
|
|
4
32
|
|
|
5
33
|
|
|
6
34
|
### Features
|
|
7
35
|
|
|
8
|
-
* discover JSON-LD context via HTTP Link ([#62](https://github.com/
|
|
36
|
+
* discover JSON-LD context via HTTP Link ([#62](https://github.com/iotaledger/twin-data/issues/62)) ([5545864](https://github.com/iotaledger/twin-data/commit/5545864c08e8c42fb93844f552907648a1130b64))
|
|
9
37
|
|
|
10
38
|
|
|
11
39
|
### Dependencies
|
|
@@ -14,7 +42,7 @@
|
|
|
14
42
|
* dependencies
|
|
15
43
|
* @twin.org/data-core bumped from 0.0.3-next.19 to 0.0.3-next.20
|
|
16
44
|
|
|
17
|
-
## [0.0.3-next.20](https://github.com/
|
|
45
|
+
## [0.0.3-next.20](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.19...data-json-ld-v0.0.3-next.20) (2026-03-23)
|
|
18
46
|
|
|
19
47
|
|
|
20
48
|
### Features
|
|
@@ -34,12 +62,12 @@
|
|
|
34
62
|
* Share schema.org fixture document-cache seeding via `tests/helpers/schemaOrgDocumentCache.ts` (`jsonLdProcessor` / `jsonLdHelper` specs).
|
|
35
63
|
|
|
36
64
|
|
|
37
|
-
## [0.0.3-next.19](https://github.com/
|
|
65
|
+
## [0.0.3-next.19](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.18...data-json-ld-v0.0.3-next.19) (2026-03-20)
|
|
38
66
|
|
|
39
67
|
|
|
40
68
|
### Features
|
|
41
69
|
|
|
42
|
-
* use local LD context fixture in tests instead of remotes ([#60](https://github.com/
|
|
70
|
+
* use local LD context fixture in tests instead of remotes ([#60](https://github.com/iotaledger/twin-data/issues/60)) ([df18303](https://github.com/iotaledger/twin-data/commit/df18303301f031a5032850c900eea24b094a99a5))
|
|
43
71
|
|
|
44
72
|
|
|
45
73
|
### Dependencies
|
|
@@ -48,7 +76,7 @@
|
|
|
48
76
|
* dependencies
|
|
49
77
|
* @twin.org/data-core bumped from 0.0.3-next.18 to 0.0.3-next.19
|
|
50
78
|
|
|
51
|
-
## [0.0.3-next.18](https://github.com/
|
|
79
|
+
## [0.0.3-next.18](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.17...data-json-ld-v0.0.3-next.18) (2026-03-16)
|
|
52
80
|
|
|
53
81
|
|
|
54
82
|
### Miscellaneous Chores
|
|
@@ -62,7 +90,7 @@
|
|
|
62
90
|
* dependencies
|
|
63
91
|
* @twin.org/data-core bumped from 0.0.3-next.17 to 0.0.3-next.18
|
|
64
92
|
|
|
65
|
-
## [0.0.3-next.17](https://github.com/
|
|
93
|
+
## [0.0.3-next.17](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.16...data-json-ld-v0.0.3-next.17) (2026-03-12)
|
|
66
94
|
|
|
67
95
|
|
|
68
96
|
### Miscellaneous Chores
|
|
@@ -76,12 +104,12 @@
|
|
|
76
104
|
* dependencies
|
|
77
105
|
* @twin.org/data-core bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
78
106
|
|
|
79
|
-
## [0.0.3-next.16](https://github.com/
|
|
107
|
+
## [0.0.3-next.16](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.15...data-json-ld-v0.0.3-next.16) (2026-03-06)
|
|
80
108
|
|
|
81
109
|
|
|
82
110
|
### Features
|
|
83
111
|
|
|
84
|
-
* additional JSON-LD helper types ([575627c](https://github.com/
|
|
112
|
+
* additional JSON-LD helper types ([575627c](https://github.com/iotaledger/twin-data/commit/575627c707e691086e07163dac44ba1396ac322e))
|
|
85
113
|
|
|
86
114
|
|
|
87
115
|
### Dependencies
|
|
@@ -90,12 +118,12 @@
|
|
|
90
118
|
* dependencies
|
|
91
119
|
* @twin.org/data-core bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
92
120
|
|
|
93
|
-
## [0.0.3-next.15](https://github.com/
|
|
121
|
+
## [0.0.3-next.15](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.14...data-json-ld-v0.0.3-next.15) (2026-02-27)
|
|
94
122
|
|
|
95
123
|
|
|
96
124
|
### Features
|
|
97
125
|
|
|
98
|
-
* additional json-ld helpers ([c74cbd6](https://github.com/
|
|
126
|
+
* additional json-ld helpers ([c74cbd6](https://github.com/iotaledger/twin-data/commit/c74cbd60e423c5f780243da9868723e9d54d068a))
|
|
99
127
|
|
|
100
128
|
|
|
101
129
|
### Dependencies
|
|
@@ -104,12 +132,12 @@
|
|
|
104
132
|
* dependencies
|
|
105
133
|
* @twin.org/data-core bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
106
134
|
|
|
107
|
-
## [0.0.3-next.14](https://github.com/
|
|
135
|
+
## [0.0.3-next.14](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.13...data-json-ld-v0.0.3-next.14) (2026-02-25)
|
|
108
136
|
|
|
109
137
|
|
|
110
138
|
### Features
|
|
111
139
|
|
|
112
|
-
* update schemas ([c30159c](https://github.com/
|
|
140
|
+
* update schemas ([c30159c](https://github.com/iotaledger/twin-data/commit/c30159cd24e5f60f9124752738dd1c0312ee17dd))
|
|
113
141
|
|
|
114
142
|
|
|
115
143
|
### Dependencies
|
|
@@ -118,12 +146,12 @@
|
|
|
118
146
|
* dependencies
|
|
119
147
|
* @twin.org/data-core bumped from 0.0.3-next.13 to 0.0.3-next.14
|
|
120
148
|
|
|
121
|
-
## [0.0.3-next.13](https://github.com/
|
|
149
|
+
## [0.0.3-next.13](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.12...data-json-ld-v0.0.3-next.13) (2026-02-25)
|
|
122
150
|
|
|
123
151
|
|
|
124
152
|
### Features
|
|
125
153
|
|
|
126
|
-
* publish npm await ([7bdf0cd](https://github.com/
|
|
154
|
+
* publish npm await ([7bdf0cd](https://github.com/iotaledger/twin-data/commit/7bdf0cd5d9417e7f8811f295ccf3ab3403ae3753))
|
|
127
155
|
|
|
128
156
|
|
|
129
157
|
### Dependencies
|
|
@@ -132,12 +160,12 @@
|
|
|
132
160
|
* dependencies
|
|
133
161
|
* @twin.org/data-core bumped from 0.0.3-next.12 to 0.0.3-next.13
|
|
134
162
|
|
|
135
|
-
## [0.0.3-next.12](https://github.com/
|
|
163
|
+
## [0.0.3-next.12](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.11...data-json-ld-v0.0.3-next.12) (2026-02-25)
|
|
136
164
|
|
|
137
165
|
|
|
138
166
|
### Features
|
|
139
167
|
|
|
140
|
-
* add toStructuredObject ([58354e0](https://github.com/
|
|
168
|
+
* add toStructuredObject ([58354e0](https://github.com/iotaledger/twin-data/commit/58354e0096c917f2e2e64214107d68326c79260d))
|
|
141
169
|
|
|
142
170
|
|
|
143
171
|
### Dependencies
|
|
@@ -146,12 +174,12 @@
|
|
|
146
174
|
* dependencies
|
|
147
175
|
* @twin.org/data-core bumped from 0.0.3-next.11 to 0.0.3-next.12
|
|
148
176
|
|
|
149
|
-
## [0.0.3-next.11](https://github.com/
|
|
177
|
+
## [0.0.3-next.11](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.10...data-json-ld-v0.0.3-next.11) (2026-02-25)
|
|
150
178
|
|
|
151
179
|
|
|
152
180
|
### Features
|
|
153
181
|
|
|
154
|
-
* expand JsonLdHelper.getId with custom properties names ([8ec4dcf](https://github.com/
|
|
182
|
+
* expand JsonLdHelper.getId with custom properties names ([8ec4dcf](https://github.com/iotaledger/twin-data/commit/8ec4dcf807a6dc416b2df2a77749f841a60be05f))
|
|
155
183
|
|
|
156
184
|
|
|
157
185
|
### Dependencies
|
|
@@ -160,12 +188,12 @@
|
|
|
160
188
|
* dependencies
|
|
161
189
|
* @twin.org/data-core bumped from 0.0.3-next.10 to 0.0.3-next.11
|
|
162
190
|
|
|
163
|
-
## [0.0.3-next.10](https://github.com/
|
|
191
|
+
## [0.0.3-next.10](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.9...data-json-ld-v0.0.3-next.10) (2026-02-24)
|
|
164
192
|
|
|
165
193
|
|
|
166
194
|
### Features
|
|
167
195
|
|
|
168
|
-
* add json ld helper types ([#46](https://github.com/
|
|
196
|
+
* add json ld helper types ([#46](https://github.com/iotaledger/twin-data/issues/46)) ([22e998e](https://github.com/iotaledger/twin-data/commit/22e998e29e7eadc9202026ee9743d64ed98035df))
|
|
169
197
|
|
|
170
198
|
|
|
171
199
|
### Dependencies
|
|
@@ -174,12 +202,12 @@
|
|
|
174
202
|
* dependencies
|
|
175
203
|
* @twin.org/data-core bumped from 0.0.3-next.9 to 0.0.3-next.10
|
|
176
204
|
|
|
177
|
-
## [0.0.3-next.9](https://github.com/
|
|
205
|
+
## [0.0.3-next.9](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.8...data-json-ld-v0.0.3-next.9) (2026-02-23)
|
|
178
206
|
|
|
179
207
|
|
|
180
208
|
### Features
|
|
181
209
|
|
|
182
|
-
* additional JsonLdHelper methods ([#44](https://github.com/
|
|
210
|
+
* additional JsonLdHelper methods ([#44](https://github.com/iotaledger/twin-data/issues/44)) ([ebe2cf5](https://github.com/iotaledger/twin-data/commit/ebe2cf50d1a7fbe0474f0a556d49f43eb7767a2f))
|
|
183
211
|
|
|
184
212
|
|
|
185
213
|
### Dependencies
|
|
@@ -188,7 +216,7 @@
|
|
|
188
216
|
* dependencies
|
|
189
217
|
* @twin.org/data-core bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
190
218
|
|
|
191
|
-
## [0.0.3-next.8](https://github.com/
|
|
219
|
+
## [0.0.3-next.8](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.7...data-json-ld-v0.0.3-next.8) (2026-02-02)
|
|
192
220
|
|
|
193
221
|
|
|
194
222
|
### Miscellaneous Chores
|
|
@@ -202,12 +230,12 @@
|
|
|
202
230
|
* dependencies
|
|
203
231
|
* @twin.org/data-core bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
204
232
|
|
|
205
|
-
## [0.0.3-next.7](https://github.com/
|
|
233
|
+
## [0.0.3-next.7](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.6...data-json-ld-v0.0.3-next.7) (2026-01-21)
|
|
206
234
|
|
|
207
235
|
|
|
208
236
|
### Features
|
|
209
237
|
|
|
210
|
-
* update context naming ([#37](https://github.com/
|
|
238
|
+
* update context naming ([#37](https://github.com/iotaledger/twin-data/issues/37)) ([9d99360](https://github.com/iotaledger/twin-data/commit/9d993605aa51f27a09722729057c6ee921617c2d))
|
|
211
239
|
|
|
212
240
|
|
|
213
241
|
### Dependencies
|
|
@@ -216,7 +244,7 @@
|
|
|
216
244
|
* dependencies
|
|
217
245
|
* @twin.org/data-core bumped from 0.0.3-next.6 to 0.0.3-next.7
|
|
218
246
|
|
|
219
|
-
## [0.0.3-next.6](https://github.com/
|
|
247
|
+
## [0.0.3-next.6](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.5...data-json-ld-v0.0.3-next.6) (2026-01-14)
|
|
220
248
|
|
|
221
249
|
|
|
222
250
|
### Miscellaneous Chores
|
|
@@ -230,12 +258,12 @@
|
|
|
230
258
|
* dependencies
|
|
231
259
|
* @twin.org/data-core bumped from 0.0.3-next.5 to 0.0.3-next.6
|
|
232
260
|
|
|
233
|
-
## [0.0.3-next.5](https://github.com/
|
|
261
|
+
## [0.0.3-next.5](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.4...data-json-ld-v0.0.3-next.5) (2026-01-14)
|
|
234
262
|
|
|
235
263
|
|
|
236
264
|
### Features
|
|
237
265
|
|
|
238
|
-
* improve data type registration ([#34](https://github.com/
|
|
266
|
+
* improve data type registration ([#34](https://github.com/iotaledger/twin-data/issues/34)) ([855d110](https://github.com/iotaledger/twin-data/commit/855d11046a4d85317b77a5c4e0f4a7b1b6d1a767))
|
|
239
267
|
|
|
240
268
|
|
|
241
269
|
### Dependencies
|
|
@@ -244,7 +272,7 @@
|
|
|
244
272
|
* dependencies
|
|
245
273
|
* @twin.org/data-core bumped from 0.0.3-next.4 to 0.0.3-next.5
|
|
246
274
|
|
|
247
|
-
## [0.0.3-next.4](https://github.com/
|
|
275
|
+
## [0.0.3-next.4](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.3...data-json-ld-v0.0.3-next.4) (2026-01-06)
|
|
248
276
|
|
|
249
277
|
|
|
250
278
|
### Miscellaneous Chores
|
|
@@ -258,12 +286,12 @@
|
|
|
258
286
|
* dependencies
|
|
259
287
|
* @twin.org/data-core bumped from 0.0.3-next.3 to 0.0.3-next.4
|
|
260
288
|
|
|
261
|
-
## [0.0.3-next.3](https://github.com/
|
|
289
|
+
## [0.0.3-next.3](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.2...data-json-ld-v0.0.3-next.3) (2026-01-05)
|
|
262
290
|
|
|
263
291
|
|
|
264
292
|
### Features
|
|
265
293
|
|
|
266
|
-
* add JsonLdHelper.toNodeObject method ([93f2add](https://github.com/
|
|
294
|
+
* add JsonLdHelper.toNodeObject method ([93f2add](https://github.com/iotaledger/twin-data/commit/93f2add1948f168d7a21223929cf6c65a8115f6f))
|
|
267
295
|
|
|
268
296
|
|
|
269
297
|
### Dependencies
|
|
@@ -272,17 +300,17 @@
|
|
|
272
300
|
* dependencies
|
|
273
301
|
* @twin.org/data-core bumped from 0.0.3-next.2 to 0.0.3-next.3
|
|
274
302
|
|
|
275
|
-
## [0.0.3-next.2](https://github.com/
|
|
303
|
+
## [0.0.3-next.2](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.1...data-json-ld-v0.0.3-next.2) (2025-11-24)
|
|
276
304
|
|
|
277
305
|
|
|
278
306
|
### Features
|
|
279
307
|
|
|
280
|
-
* add JsonLdHelper getId and getType ([4b43e41](https://github.com/
|
|
308
|
+
* add JsonLdHelper getId and getType ([4b43e41](https://github.com/iotaledger/twin-data/commit/4b43e41fa47a16a19d2c759f5e40a1fb51e0a128))
|
|
281
309
|
|
|
282
310
|
|
|
283
311
|
### Bug Fixes
|
|
284
312
|
|
|
285
|
-
* add redirect remove duplicates ([49709e0](https://github.com/
|
|
313
|
+
* add redirect remove duplicates ([49709e0](https://github.com/iotaledger/twin-data/commit/49709e04cf087e216f4c9e36a9f35daceeae98fd))
|
|
286
314
|
|
|
287
315
|
|
|
288
316
|
### Dependencies
|
|
@@ -291,29 +319,29 @@
|
|
|
291
319
|
* dependencies
|
|
292
320
|
* @twin.org/data-core bumped from 0.0.3-next.1 to 0.0.3-next.2
|
|
293
321
|
|
|
294
|
-
## [0.0.3-next.1](https://github.com/
|
|
322
|
+
## [0.0.3-next.1](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.0...data-json-ld-v0.0.3-next.1) (2025-11-10)
|
|
295
323
|
|
|
296
324
|
|
|
297
325
|
### Features
|
|
298
326
|
|
|
299
|
-
* add context id features ([#25](https://github.com/
|
|
300
|
-
* add document cache access methods ([dbf1e36](https://github.com/
|
|
301
|
-
* add fail on missing type option and both mode ([e8b9702](https://github.com/
|
|
302
|
-
* add validate-locales ([cf9b761](https://github.com/
|
|
303
|
-
* eslint migration to flat config ([b0db6e6](https://github.com/
|
|
304
|
-
* expand Json LD Keyword ([70632d1](https://github.com/
|
|
305
|
-
* support multiple type JSON-LD ([8f0d530](https://github.com/
|
|
306
|
-
* update framework core ([c077b8c](https://github.com/
|
|
307
|
-
* update ts-to-schema ([8c3cd91](https://github.com/
|
|
308
|
-
* use fully qualified names for data type lookups ([b7b5c74](https://github.com/
|
|
309
|
-
* use shared store mechanism ([#3](https://github.com/
|
|
310
|
-
* use updated Is.function ([46a4715](https://github.com/
|
|
311
|
-
* use updated JSON schema specs ([465223a](https://github.com/
|
|
327
|
+
* add context id features ([#25](https://github.com/iotaledger/twin-data/issues/25)) ([6592f2e](https://github.com/iotaledger/twin-data/commit/6592f2e4e59021cc42a079a4f46242758a54313d))
|
|
328
|
+
* add document cache access methods ([dbf1e36](https://github.com/iotaledger/twin-data/commit/dbf1e36d176c5f428f8c52628fb5a1ff7a6a174a))
|
|
329
|
+
* add fail on missing type option and both mode ([e8b9702](https://github.com/iotaledger/twin-data/commit/e8b97029a04b646497ff0e55b9610291e58ae92a))
|
|
330
|
+
* add validate-locales ([cf9b761](https://github.com/iotaledger/twin-data/commit/cf9b76160820fe0b13b4fe56ed241c1d5511b7c1))
|
|
331
|
+
* eslint migration to flat config ([b0db6e6](https://github.com/iotaledger/twin-data/commit/b0db6e69a90046fc60d29e4273fcdfee13c16088))
|
|
332
|
+
* expand Json LD Keyword ([70632d1](https://github.com/iotaledger/twin-data/commit/70632d1e11ad85cf3c57e118476b125a673f1681))
|
|
333
|
+
* support multiple type JSON-LD ([8f0d530](https://github.com/iotaledger/twin-data/commit/8f0d530f66302ab19413ecf968f170f97456e31e))
|
|
334
|
+
* update framework core ([c077b8c](https://github.com/iotaledger/twin-data/commit/c077b8c07e7ee66b5482254eab6f2a52cd911270))
|
|
335
|
+
* update ts-to-schema ([8c3cd91](https://github.com/iotaledger/twin-data/commit/8c3cd9131113f2d609f6e709562402e5c7766c1a))
|
|
336
|
+
* use fully qualified names for data type lookups ([b7b5c74](https://github.com/iotaledger/twin-data/commit/b7b5c746b0180a87baa976f6a7a76cedd53d8ff7))
|
|
337
|
+
* use shared store mechanism ([#3](https://github.com/iotaledger/twin-data/issues/3)) ([33eb221](https://github.com/iotaledger/twin-data/commit/33eb221ccec2b4a79549c06e9a04225009b93a46))
|
|
338
|
+
* use updated Is.function ([46a4715](https://github.com/iotaledger/twin-data/commit/46a4715f995aea34f2011138662fe003c9727d07))
|
|
339
|
+
* use updated JSON schema specs ([465223a](https://github.com/iotaledger/twin-data/commit/465223a9e9c24af546480ef084327a78fa366eaa))
|
|
312
340
|
|
|
313
341
|
|
|
314
342
|
### Bug Fixes
|
|
315
343
|
|
|
316
|
-
* itemListElement compaction override ([d908a10](https://github.com/
|
|
344
|
+
* itemListElement compaction override ([d908a10](https://github.com/iotaledger/twin-data/commit/d908a1043d7792e31b3101221d17850757b6c2a6))
|
|
317
345
|
|
|
318
346
|
|
|
319
347
|
### Dependencies
|
|
@@ -322,12 +350,12 @@
|
|
|
322
350
|
* dependencies
|
|
323
351
|
* @twin.org/data-core bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
324
352
|
|
|
325
|
-
## [0.0.2-next.4](https://github.com/
|
|
353
|
+
## [0.0.2-next.4](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.2-next.3...data-json-ld-v0.0.2-next.4) (2025-10-09)
|
|
326
354
|
|
|
327
355
|
|
|
328
356
|
### Features
|
|
329
357
|
|
|
330
|
-
* add validate-locales ([cf9b761](https://github.com/
|
|
358
|
+
* add validate-locales ([cf9b761](https://github.com/iotaledger/twin-data/commit/cf9b76160820fe0b13b4fe56ed241c1d5511b7c1))
|
|
331
359
|
|
|
332
360
|
|
|
333
361
|
### Dependencies
|
|
@@ -336,12 +364,12 @@
|
|
|
336
364
|
* dependencies
|
|
337
365
|
* @twin.org/data-core bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
338
366
|
|
|
339
|
-
## [0.0.2-next.3](https://github.com/
|
|
367
|
+
## [0.0.2-next.3](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.2-next.2...data-json-ld-v0.0.2-next.3) (2025-09-29)
|
|
340
368
|
|
|
341
369
|
|
|
342
370
|
### Features
|
|
343
371
|
|
|
344
|
-
* use updated Is.function ([46a4715](https://github.com/
|
|
372
|
+
* use updated Is.function ([46a4715](https://github.com/iotaledger/twin-data/commit/46a4715f995aea34f2011138662fe003c9727d07))
|
|
345
373
|
|
|
346
374
|
|
|
347
375
|
### Dependencies
|
|
@@ -350,12 +378,12 @@
|
|
|
350
378
|
* dependencies
|
|
351
379
|
* @twin.org/data-core bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
352
380
|
|
|
353
|
-
## [0.0.2-next.2](https://github.com/
|
|
381
|
+
## [0.0.2-next.2](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.2-next.1...data-json-ld-v0.0.2-next.2) (2025-08-29)
|
|
354
382
|
|
|
355
383
|
|
|
356
384
|
### Features
|
|
357
385
|
|
|
358
|
-
* eslint migration to flat config ([b0db6e6](https://github.com/
|
|
386
|
+
* eslint migration to flat config ([b0db6e6](https://github.com/iotaledger/twin-data/commit/b0db6e69a90046fc60d29e4273fcdfee13c16088))
|
|
359
387
|
|
|
360
388
|
|
|
361
389
|
### Dependencies
|
|
@@ -364,25 +392,25 @@
|
|
|
364
392
|
* dependencies
|
|
365
393
|
* @twin.org/data-core bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
366
394
|
|
|
367
|
-
## [0.0.2-next.1](https://github.com/
|
|
395
|
+
## [0.0.2-next.1](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.2-next.0...data-json-ld-v0.0.2-next.1) (2025-08-19)
|
|
368
396
|
|
|
369
397
|
|
|
370
398
|
### Features
|
|
371
399
|
|
|
372
|
-
* add document cache access methods ([dbf1e36](https://github.com/
|
|
373
|
-
* add fail on missing type option and both mode ([e8b9702](https://github.com/
|
|
374
|
-
* expand Json LD Keyword ([70632d1](https://github.com/
|
|
375
|
-
* support multiple type JSON-LD ([8f0d530](https://github.com/
|
|
376
|
-
* update framework core ([c077b8c](https://github.com/
|
|
377
|
-
* update ts-to-schema ([8c3cd91](https://github.com/
|
|
378
|
-
* use fully qualified names for data type lookups ([b7b5c74](https://github.com/
|
|
379
|
-
* use shared store mechanism ([#3](https://github.com/
|
|
380
|
-
* use updated JSON schema specs ([465223a](https://github.com/
|
|
400
|
+
* add document cache access methods ([dbf1e36](https://github.com/iotaledger/twin-data/commit/dbf1e36d176c5f428f8c52628fb5a1ff7a6a174a))
|
|
401
|
+
* add fail on missing type option and both mode ([e8b9702](https://github.com/iotaledger/twin-data/commit/e8b97029a04b646497ff0e55b9610291e58ae92a))
|
|
402
|
+
* expand Json LD Keyword ([70632d1](https://github.com/iotaledger/twin-data/commit/70632d1e11ad85cf3c57e118476b125a673f1681))
|
|
403
|
+
* support multiple type JSON-LD ([8f0d530](https://github.com/iotaledger/twin-data/commit/8f0d530f66302ab19413ecf968f170f97456e31e))
|
|
404
|
+
* update framework core ([c077b8c](https://github.com/iotaledger/twin-data/commit/c077b8c07e7ee66b5482254eab6f2a52cd911270))
|
|
405
|
+
* update ts-to-schema ([8c3cd91](https://github.com/iotaledger/twin-data/commit/8c3cd9131113f2d609f6e709562402e5c7766c1a))
|
|
406
|
+
* use fully qualified names for data type lookups ([b7b5c74](https://github.com/iotaledger/twin-data/commit/b7b5c746b0180a87baa976f6a7a76cedd53d8ff7))
|
|
407
|
+
* use shared store mechanism ([#3](https://github.com/iotaledger/twin-data/issues/3)) ([33eb221](https://github.com/iotaledger/twin-data/commit/33eb221ccec2b4a79549c06e9a04225009b93a46))
|
|
408
|
+
* use updated JSON schema specs ([465223a](https://github.com/iotaledger/twin-data/commit/465223a9e9c24af546480ef084327a78fa366eaa))
|
|
381
409
|
|
|
382
410
|
|
|
383
411
|
### Bug Fixes
|
|
384
412
|
|
|
385
|
-
* itemListElement compaction override ([d908a10](https://github.com/
|
|
413
|
+
* itemListElement compaction override ([d908a10](https://github.com/iotaledger/twin-data/commit/d908a1043d7792e31b3101221d17850757b6c2a6))
|
|
386
414
|
|
|
387
415
|
|
|
388
416
|
### Dependencies
|
|
@@ -396,26 +424,26 @@
|
|
|
396
424
|
|
|
397
425
|
### Features
|
|
398
426
|
|
|
399
|
-
* add document cache access methods ([dbf1e36](https://github.com/
|
|
400
|
-
* add fail on missing type option and both mode ([e8b9702](https://github.com/
|
|
401
|
-
* expand Json LD Keyword ([70632d1](https://github.com/
|
|
402
|
-
* support multiple type JSON-LD ([8f0d530](https://github.com/
|
|
403
|
-
* update ts-to-schema ([8c3cd91](https://github.com/
|
|
404
|
-
* use fully qualified names for data type lookups ([b7b5c74](https://github.com/
|
|
405
|
-
* use shared store mechanism ([#3](https://github.com/
|
|
406
|
-
* use updated JSON schema specs ([465223a](https://github.com/
|
|
427
|
+
* add document cache access methods ([dbf1e36](https://github.com/iotaledger/twin-data/commit/dbf1e36d176c5f428f8c52628fb5a1ff7a6a174a))
|
|
428
|
+
* add fail on missing type option and both mode ([e8b9702](https://github.com/iotaledger/twin-data/commit/e8b97029a04b646497ff0e55b9610291e58ae92a))
|
|
429
|
+
* expand Json LD Keyword ([70632d1](https://github.com/iotaledger/twin-data/commit/70632d1e11ad85cf3c57e118476b125a673f1681))
|
|
430
|
+
* support multiple type JSON-LD ([8f0d530](https://github.com/iotaledger/twin-data/commit/8f0d530f66302ab19413ecf968f170f97456e31e))
|
|
431
|
+
* update ts-to-schema ([8c3cd91](https://github.com/iotaledger/twin-data/commit/8c3cd9131113f2d609f6e709562402e5c7766c1a))
|
|
432
|
+
* use fully qualified names for data type lookups ([b7b5c74](https://github.com/iotaledger/twin-data/commit/b7b5c746b0180a87baa976f6a7a76cedd53d8ff7))
|
|
433
|
+
* use shared store mechanism ([#3](https://github.com/iotaledger/twin-data/issues/3)) ([33eb221](https://github.com/iotaledger/twin-data/commit/33eb221ccec2b4a79549c06e9a04225009b93a46))
|
|
434
|
+
* use updated JSON schema specs ([465223a](https://github.com/iotaledger/twin-data/commit/465223a9e9c24af546480ef084327a78fa366eaa))
|
|
407
435
|
|
|
408
436
|
|
|
409
437
|
### Bug Fixes
|
|
410
438
|
|
|
411
|
-
* itemListElement compaction override ([d908a10](https://github.com/
|
|
439
|
+
* itemListElement compaction override ([d908a10](https://github.com/iotaledger/twin-data/commit/d908a1043d7792e31b3101221d17850757b6c2a6))
|
|
412
440
|
|
|
413
|
-
## [0.0.1-next.37](https://github.com/
|
|
441
|
+
## [0.0.1-next.37](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.1-next.36...data-json-ld-v0.0.1-next.37) (2025-06-11)
|
|
414
442
|
|
|
415
443
|
|
|
416
444
|
### Features
|
|
417
445
|
|
|
418
|
-
* use updated JSON schema specs ([465223a](https://github.com/
|
|
446
|
+
* use updated JSON schema specs ([465223a](https://github.com/iotaledger/twin-data/commit/465223a9e9c24af546480ef084327a78fa366eaa))
|
|
419
447
|
|
|
420
448
|
|
|
421
449
|
### Dependencies
|
|
@@ -424,12 +452,12 @@
|
|
|
424
452
|
* dependencies
|
|
425
453
|
* @twin.org/data-core bumped from 0.0.1-next.36 to 0.0.1-next.37
|
|
426
454
|
|
|
427
|
-
## [0.0.1-next.36](https://github.com/
|
|
455
|
+
## [0.0.1-next.36](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.1-next.35...data-json-ld-v0.0.1-next.36) (2025-06-10)
|
|
428
456
|
|
|
429
457
|
|
|
430
458
|
### Features
|
|
431
459
|
|
|
432
|
-
* expand Json LD Keyword ([70632d1](https://github.com/
|
|
460
|
+
* expand Json LD Keyword ([70632d1](https://github.com/iotaledger/twin-data/commit/70632d1e11ad85cf3c57e118476b125a673f1681))
|
|
433
461
|
|
|
434
462
|
|
|
435
463
|
### Dependencies
|
|
@@ -438,12 +466,12 @@
|
|
|
438
466
|
* dependencies
|
|
439
467
|
* @twin.org/data-core bumped from 0.0.1-next.35 to 0.0.1-next.36
|
|
440
468
|
|
|
441
|
-
## [0.0.1-next.35](https://github.com/
|
|
469
|
+
## [0.0.1-next.35](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.1-next.34...data-json-ld-v0.0.1-next.35) (2025-06-03)
|
|
442
470
|
|
|
443
471
|
|
|
444
472
|
### Features
|
|
445
473
|
|
|
446
|
-
* update ts-to-schema ([8c3cd91](https://github.com/
|
|
474
|
+
* update ts-to-schema ([8c3cd91](https://github.com/iotaledger/twin-data/commit/8c3cd9131113f2d609f6e709562402e5c7766c1a))
|
|
447
475
|
|
|
448
476
|
|
|
449
477
|
### Dependencies
|
|
@@ -452,12 +480,12 @@
|
|
|
452
480
|
* dependencies
|
|
453
481
|
* @twin.org/data-core bumped from 0.0.1-next.34 to 0.0.1-next.35
|
|
454
482
|
|
|
455
|
-
## [0.0.1-next.34](https://github.com/
|
|
483
|
+
## [0.0.1-next.34](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.1-next.33...data-json-ld-v0.0.1-next.34) (2025-06-02)
|
|
456
484
|
|
|
457
485
|
|
|
458
486
|
### Features
|
|
459
487
|
|
|
460
|
-
* support multiple type JSON-LD ([8f0d530](https://github.com/
|
|
488
|
+
* support multiple type JSON-LD ([8f0d530](https://github.com/iotaledger/twin-data/commit/8f0d530f66302ab19413ecf968f170f97456e31e))
|
|
461
489
|
|
|
462
490
|
|
|
463
491
|
### Dependencies
|
|
@@ -466,12 +494,12 @@
|
|
|
466
494
|
* dependencies
|
|
467
495
|
* @twin.org/data-core bumped from 0.0.1-next.33 to 0.0.1-next.34
|
|
468
496
|
|
|
469
|
-
## [0.0.1-next.33](https://github.com/
|
|
497
|
+
## [0.0.1-next.33](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.1-next.32...data-json-ld-v0.0.1-next.33) (2025-06-02)
|
|
470
498
|
|
|
471
499
|
|
|
472
500
|
### Features
|
|
473
501
|
|
|
474
|
-
* add fail on missing type option and both mode ([e8b9702](https://github.com/
|
|
502
|
+
* add fail on missing type option and both mode ([e8b9702](https://github.com/iotaledger/twin-data/commit/e8b97029a04b646497ff0e55b9610291e58ae92a))
|
|
475
503
|
|
|
476
504
|
|
|
477
505
|
### Dependencies
|
|
@@ -480,12 +508,12 @@
|
|
|
480
508
|
* dependencies
|
|
481
509
|
* @twin.org/data-core bumped from 0.0.1-next.32 to 0.0.1-next.33
|
|
482
510
|
|
|
483
|
-
## [0.0.1-next.32](https://github.com/
|
|
511
|
+
## [0.0.1-next.32](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.1-next.31...data-json-ld-v0.0.1-next.32) (2025-05-28)
|
|
484
512
|
|
|
485
513
|
|
|
486
514
|
### Features
|
|
487
515
|
|
|
488
|
-
* use fully qualified names for data type lookups ([b7b5c74](https://github.com/
|
|
516
|
+
* use fully qualified names for data type lookups ([b7b5c74](https://github.com/iotaledger/twin-data/commit/b7b5c746b0180a87baa976f6a7a76cedd53d8ff7))
|
|
489
517
|
|
|
490
518
|
|
|
491
519
|
### Dependencies
|
|
@@ -494,12 +522,12 @@
|
|
|
494
522
|
* dependencies
|
|
495
523
|
* @twin.org/data-core bumped from 0.0.1-next.31 to 0.0.1-next.32
|
|
496
524
|
|
|
497
|
-
## [0.0.1-next.31](https://github.com/
|
|
525
|
+
## [0.0.1-next.31](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.1-next.30...data-json-ld-v0.0.1-next.31) (2025-05-08)
|
|
498
526
|
|
|
499
527
|
|
|
500
528
|
### Bug Fixes
|
|
501
529
|
|
|
502
|
-
* itemListElement compaction override ([d908a10](https://github.com/
|
|
530
|
+
* itemListElement compaction override ([d908a10](https://github.com/iotaledger/twin-data/commit/d908a1043d7792e31b3101221d17850757b6c2a6))
|
|
503
531
|
|
|
504
532
|
|
|
505
533
|
### Dependencies
|
|
@@ -508,12 +536,12 @@
|
|
|
508
536
|
* dependencies
|
|
509
537
|
* @twin.org/data-core bumped from 0.0.1-next.30 to 0.0.1-next.31
|
|
510
538
|
|
|
511
|
-
## [0.0.1-next.30](https://github.com/
|
|
539
|
+
## [0.0.1-next.30](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.1-next.29...data-json-ld-v0.0.1-next.30) (2025-04-17)
|
|
512
540
|
|
|
513
541
|
|
|
514
542
|
### Features
|
|
515
543
|
|
|
516
|
-
* use shared store mechanism ([#3](https://github.com/
|
|
544
|
+
* use shared store mechanism ([#3](https://github.com/iotaledger/twin-data/issues/3)) ([33eb221](https://github.com/iotaledger/twin-data/commit/33eb221ccec2b4a79549c06e9a04225009b93a46))
|
|
517
545
|
|
|
518
546
|
|
|
519
547
|
### Dependencies
|
|
@@ -522,12 +550,12 @@
|
|
|
522
550
|
* dependencies
|
|
523
551
|
* @twin.org/data-core bumped from 0.0.1-next.29 to 0.0.1-next.30
|
|
524
552
|
|
|
525
|
-
## [0.0.1-next.29](https://github.com/
|
|
553
|
+
## [0.0.1-next.29](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.1-next.28...data-json-ld-v0.0.1-next.29) (2025-03-28)
|
|
526
554
|
|
|
527
555
|
|
|
528
556
|
### Features
|
|
529
557
|
|
|
530
|
-
* add document cache access methods ([dbf1e36](https://github.com/
|
|
558
|
+
* add document cache access methods ([dbf1e36](https://github.com/iotaledger/twin-data/commit/dbf1e36d176c5f428f8c52628fb5a1ff7a6a174a))
|
|
531
559
|
|
|
532
560
|
|
|
533
561
|
### Dependencies
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/data-json-ld",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.22",
|
|
4
4
|
"description": "JSON-LD data models and helpers for working with linked data documents.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/iotaledger/data.git",
|
|
8
8
|
"directory": "packages/data-json-ld"
|
|
9
9
|
},
|
|
10
10
|
"author": "martyn.janes@iota.org",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
|
-
"@twin.org/data-core": "0.0.3-next.
|
|
18
|
+
"@twin.org/data-core": "0.0.3-next.22",
|
|
19
19
|
"@twin.org/entity": "next",
|
|
20
20
|
"@twin.org/nameof": "next",
|
|
21
21
|
"@twin.org/web": "next",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"data"
|
|
48
48
|
],
|
|
49
49
|
"bugs": {
|
|
50
|
-
"url": "git+https://github.com/
|
|
50
|
+
"url": "git+https://github.com/iotaledger/data/issues"
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://twindev.org"
|
|
53
53
|
}
|