@twin.org/data-json-ld 0.0.1-next.10 → 0.0.1-next.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.cjs
CHANGED
|
@@ -1581,23 +1581,6 @@ class JsonLdProcessor {
|
|
|
1581
1581
|
this._redirects.push({ from, to });
|
|
1582
1582
|
}
|
|
1583
1583
|
}
|
|
1584
|
-
/**
|
|
1585
|
-
* Extract a property from the JSON-LD.
|
|
1586
|
-
* @param nodeObject The JSON-LD node object to extract from.
|
|
1587
|
-
* @param propertyNames The possible names for the property.
|
|
1588
|
-
* @param deleteProperty Delete the property from the object, defaults to true.
|
|
1589
|
-
* @returns The properties if available.
|
|
1590
|
-
*/
|
|
1591
|
-
static extractProperty(nodeObject, propertyNames, deleteProperty = true) {
|
|
1592
|
-
let retVal;
|
|
1593
|
-
for (const prop of propertyNames) {
|
|
1594
|
-
retVal ??= nodeObject[prop];
|
|
1595
|
-
if (deleteProperty) {
|
|
1596
|
-
delete nodeObject[prop];
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
return retVal;
|
|
1600
|
-
}
|
|
1601
1584
|
/**
|
|
1602
1585
|
* Combine contexts.
|
|
1603
1586
|
* @param context1 The first JSON-LD context to combine.
|
|
@@ -1734,7 +1717,7 @@ class JsonLdProcessor {
|
|
|
1734
1717
|
const response = await web.FetchHelper.fetchJson(JsonLdProcessor._CLASS_NAME, url, web.HttpMethod.GET, undefined, {
|
|
1735
1718
|
cacheTtlMs: 3600000,
|
|
1736
1719
|
headers: {
|
|
1737
|
-
Accept: `${web.MimeTypes.JsonLd},${web.MimeTypes.Json}`
|
|
1720
|
+
[web.HeaderTypes.Accept]: `${web.MimeTypes.JsonLd},${web.MimeTypes.Json}`
|
|
1738
1721
|
}
|
|
1739
1722
|
});
|
|
1740
1723
|
return {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataTypeHandlerFactory, DataTypeHelper } from '@twin.org/data-core';
|
|
2
2
|
import { Is, GeneralError, ObjectHelper } from '@twin.org/core';
|
|
3
|
-
import { FetchHelper, HttpMethod, MimeTypes } from '@twin.org/web';
|
|
3
|
+
import { FetchHelper, HttpMethod, HeaderTypes, MimeTypes } from '@twin.org/web';
|
|
4
4
|
import jsonLd from 'jsonld';
|
|
5
5
|
|
|
6
6
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -1579,23 +1579,6 @@ class JsonLdProcessor {
|
|
|
1579
1579
|
this._redirects.push({ from, to });
|
|
1580
1580
|
}
|
|
1581
1581
|
}
|
|
1582
|
-
/**
|
|
1583
|
-
* Extract a property from the JSON-LD.
|
|
1584
|
-
* @param nodeObject The JSON-LD node object to extract from.
|
|
1585
|
-
* @param propertyNames The possible names for the property.
|
|
1586
|
-
* @param deleteProperty Delete the property from the object, defaults to true.
|
|
1587
|
-
* @returns The properties if available.
|
|
1588
|
-
*/
|
|
1589
|
-
static extractProperty(nodeObject, propertyNames, deleteProperty = true) {
|
|
1590
|
-
let retVal;
|
|
1591
|
-
for (const prop of propertyNames) {
|
|
1592
|
-
retVal ??= nodeObject[prop];
|
|
1593
|
-
if (deleteProperty) {
|
|
1594
|
-
delete nodeObject[prop];
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
return retVal;
|
|
1598
|
-
}
|
|
1599
1582
|
/**
|
|
1600
1583
|
* Combine contexts.
|
|
1601
1584
|
* @param context1 The first JSON-LD context to combine.
|
|
@@ -1732,7 +1715,7 @@ class JsonLdProcessor {
|
|
|
1732
1715
|
const response = await FetchHelper.fetchJson(JsonLdProcessor._CLASS_NAME, url, HttpMethod.GET, undefined, {
|
|
1733
1716
|
cacheTtlMs: 3600000,
|
|
1734
1717
|
headers: {
|
|
1735
|
-
Accept: `${MimeTypes.JsonLd},${MimeTypes.Json}`
|
|
1718
|
+
[HeaderTypes.Accept]: `${MimeTypes.JsonLd},${MimeTypes.Json}`
|
|
1736
1719
|
}
|
|
1737
1720
|
});
|
|
1738
1721
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RemoteDocument, Url } from "jsonld/jsonld-spec";
|
|
2
|
-
import type { IJsonLdContextDefinitionElement, IJsonLdContextDefinitionRoot, IJsonLdDocument
|
|
2
|
+
import type { IJsonLdContextDefinitionElement, IJsonLdContextDefinitionRoot, IJsonLdDocument } from "../models/IJsonLdDocument";
|
|
3
3
|
/**
|
|
4
4
|
* JSON-LD Processor.
|
|
5
5
|
*/
|
|
@@ -31,14 +31,6 @@ export declare class JsonLdProcessor {
|
|
|
31
31
|
* @param to The URL to redirect to.
|
|
32
32
|
*/
|
|
33
33
|
static addRedirect(from: RegExp, to: string): void;
|
|
34
|
-
/**
|
|
35
|
-
* Extract a property from the JSON-LD.
|
|
36
|
-
* @param nodeObject The JSON-LD node object to extract from.
|
|
37
|
-
* @param propertyNames The possible names for the property.
|
|
38
|
-
* @param deleteProperty Delete the property from the object, defaults to true.
|
|
39
|
-
* @returns The properties if available.
|
|
40
|
-
*/
|
|
41
|
-
static extractProperty<T>(nodeObject: IJsonLdNodeObject, propertyNames: string[], deleteProperty?: boolean): T | undefined;
|
|
42
34
|
/**
|
|
43
35
|
* Combine contexts.
|
|
44
36
|
* @param context1 The first JSON-LD context to combine.
|
package/docs/changelog.md
CHANGED
|
@@ -96,38 +96,6 @@ The URL to redirect to.
|
|
|
96
96
|
|
|
97
97
|
***
|
|
98
98
|
|
|
99
|
-
### extractProperty()
|
|
100
|
-
|
|
101
|
-
> `static` **extractProperty**\<`T`\>(`nodeObject`, `propertyNames`, `deleteProperty`): `undefined` \| `T`
|
|
102
|
-
|
|
103
|
-
Extract a property from the JSON-LD.
|
|
104
|
-
|
|
105
|
-
#### Type Parameters
|
|
106
|
-
|
|
107
|
-
• **T**
|
|
108
|
-
|
|
109
|
-
#### Parameters
|
|
110
|
-
|
|
111
|
-
• **nodeObject**: [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
|
|
112
|
-
|
|
113
|
-
The JSON-LD node object to extract from.
|
|
114
|
-
|
|
115
|
-
• **propertyNames**: `string`[]
|
|
116
|
-
|
|
117
|
-
The possible names for the property.
|
|
118
|
-
|
|
119
|
-
• **deleteProperty**: `boolean` = `true`
|
|
120
|
-
|
|
121
|
-
Delete the property from the object, defaults to true.
|
|
122
|
-
|
|
123
|
-
#### Returns
|
|
124
|
-
|
|
125
|
-
`undefined` \| `T`
|
|
126
|
-
|
|
127
|
-
The properties if available.
|
|
128
|
-
|
|
129
|
-
***
|
|
130
|
-
|
|
131
99
|
### combineContexts()
|
|
132
100
|
|
|
133
101
|
> `static` **combineContexts**(`context1`, `context2`): `undefined` \| [`IJsonLdContextDefinitionRoot`](../type-aliases/IJsonLdContextDefinitionRoot.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/data-json-ld",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.12",
|
|
4
4
|
"description": "Models which define the structure of JSON LD",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
|
-
"@twin.org/data-core": "0.0.1-next.
|
|
18
|
+
"@twin.org/data-core": "0.0.1-next.12",
|
|
19
19
|
"@twin.org/entity": "next",
|
|
20
20
|
"@twin.org/nameof": "next",
|
|
21
21
|
"@twin.org/web": "next",
|