@twin.org/data-json-ld 0.0.2-next.3 → 0.0.2-next.4
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 +11 -10
- package/dist/esm/index.mjs +11 -10
- package/docs/changelog.md +14 -0
- package/locales/.validate-ignore +1 -0
- package/package.json +15 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -1602,7 +1602,7 @@ class JsonLdProcessor {
|
|
|
1602
1602
|
* The class name.
|
|
1603
1603
|
* @internal
|
|
1604
1604
|
*/
|
|
1605
|
-
static
|
|
1605
|
+
static CLASS_NAME = "JsonLdProcessor";
|
|
1606
1606
|
/**
|
|
1607
1607
|
* The document loader to use.
|
|
1608
1608
|
* @param documentLoader The document loader to use.
|
|
@@ -1710,7 +1710,7 @@ class JsonLdProcessor {
|
|
|
1710
1710
|
}
|
|
1711
1711
|
catch (err) {
|
|
1712
1712
|
JsonLdProcessor.handleCommonErrors(err);
|
|
1713
|
-
throw new core.GeneralError(JsonLdProcessor.
|
|
1713
|
+
throw new core.GeneralError(JsonLdProcessor.CLASS_NAME, "compact", undefined, err);
|
|
1714
1714
|
}
|
|
1715
1715
|
}
|
|
1716
1716
|
/**
|
|
@@ -1730,7 +1730,7 @@ class JsonLdProcessor {
|
|
|
1730
1730
|
}
|
|
1731
1731
|
catch (err) {
|
|
1732
1732
|
JsonLdProcessor.handleCommonErrors(err);
|
|
1733
|
-
throw new core.GeneralError(JsonLdProcessor.
|
|
1733
|
+
throw new core.GeneralError(JsonLdProcessor.CLASS_NAME, "expand", undefined, err);
|
|
1734
1734
|
}
|
|
1735
1735
|
}
|
|
1736
1736
|
/**
|
|
@@ -1751,7 +1751,7 @@ class JsonLdProcessor {
|
|
|
1751
1751
|
}
|
|
1752
1752
|
catch (err) {
|
|
1753
1753
|
JsonLdProcessor.handleCommonErrors(err);
|
|
1754
|
-
throw new core.GeneralError(JsonLdProcessor.
|
|
1754
|
+
throw new core.GeneralError(JsonLdProcessor.CLASS_NAME, "canonize", undefined, err);
|
|
1755
1755
|
}
|
|
1756
1756
|
}
|
|
1757
1757
|
/**
|
|
@@ -1834,12 +1834,12 @@ class JsonLdProcessor {
|
|
|
1834
1834
|
for (const prop of Object.keys(element)) {
|
|
1835
1835
|
const value = element[prop];
|
|
1836
1836
|
if (core.Is.object(value)) {
|
|
1837
|
-
combinedContexts =
|
|
1837
|
+
combinedContexts = JsonLdProcessor.gatherContexts(value, combinedContexts);
|
|
1838
1838
|
}
|
|
1839
1839
|
else if (core.Is.array(value)) {
|
|
1840
1840
|
for (const item of value) {
|
|
1841
1841
|
if (core.Is.object(item)) {
|
|
1842
|
-
combinedContexts =
|
|
1842
|
+
combinedContexts = JsonLdProcessor.gatherContexts(item, combinedContexts);
|
|
1843
1843
|
}
|
|
1844
1844
|
}
|
|
1845
1845
|
}
|
|
@@ -1918,7 +1918,7 @@ class JsonLdProcessor {
|
|
|
1918
1918
|
}
|
|
1919
1919
|
}
|
|
1920
1920
|
try {
|
|
1921
|
-
const response = await web.FetchHelper.fetchJson(JsonLdProcessor.
|
|
1921
|
+
const response = await web.FetchHelper.fetchJson(JsonLdProcessor.CLASS_NAME, url, web.HttpMethod.GET, undefined, {
|
|
1922
1922
|
cacheTtlMs: JsonLdProcessor.getCacheLimit(),
|
|
1923
1923
|
headers: {
|
|
1924
1924
|
[web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
|
|
@@ -1932,7 +1932,7 @@ class JsonLdProcessor {
|
|
|
1932
1932
|
catch (err) {
|
|
1933
1933
|
const error = core.BaseError.fromError(err);
|
|
1934
1934
|
if (error.message.includes("is not valid JSON")) {
|
|
1935
|
-
const response = await web.FetchHelper.fetchJson(JsonLdProcessor.
|
|
1935
|
+
const response = await web.FetchHelper.fetchJson(JsonLdProcessor.CLASS_NAME, url, web.HttpMethod.GET, undefined, {
|
|
1936
1936
|
cacheTtlMs: JsonLdProcessor.getCacheLimit(),
|
|
1937
1937
|
headers: {
|
|
1938
1938
|
[web.HeaderTypes.Accept]: web.MimeTypes.Json
|
|
@@ -1954,11 +1954,12 @@ class JsonLdProcessor {
|
|
|
1954
1954
|
static handleCommonErrors(err) {
|
|
1955
1955
|
if (core.Is.object(err) &&
|
|
1956
1956
|
err.name === "jsonld.InvalidUrl") {
|
|
1957
|
-
throw new core.GeneralError(JsonLdProcessor.
|
|
1957
|
+
throw new core.GeneralError(JsonLdProcessor.CLASS_NAME, "invalidUrl", { url: err.details?.url }, err);
|
|
1958
1958
|
}
|
|
1959
1959
|
else if (core.Is.object(err) &&
|
|
1960
1960
|
err.name.startsWith("jsonld.")) {
|
|
1961
|
-
|
|
1961
|
+
const { code, ...other } = err.details ?? {};
|
|
1962
|
+
throw new core.GeneralError(JsonLdProcessor.CLASS_NAME, "jsonLdError", { code, ...other }, err);
|
|
1962
1963
|
}
|
|
1963
1964
|
}
|
|
1964
1965
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1600,7 +1600,7 @@ class JsonLdProcessor {
|
|
|
1600
1600
|
* The class name.
|
|
1601
1601
|
* @internal
|
|
1602
1602
|
*/
|
|
1603
|
-
static
|
|
1603
|
+
static CLASS_NAME = "JsonLdProcessor";
|
|
1604
1604
|
/**
|
|
1605
1605
|
* The document loader to use.
|
|
1606
1606
|
* @param documentLoader The document loader to use.
|
|
@@ -1708,7 +1708,7 @@ class JsonLdProcessor {
|
|
|
1708
1708
|
}
|
|
1709
1709
|
catch (err) {
|
|
1710
1710
|
JsonLdProcessor.handleCommonErrors(err);
|
|
1711
|
-
throw new GeneralError(JsonLdProcessor.
|
|
1711
|
+
throw new GeneralError(JsonLdProcessor.CLASS_NAME, "compact", undefined, err);
|
|
1712
1712
|
}
|
|
1713
1713
|
}
|
|
1714
1714
|
/**
|
|
@@ -1728,7 +1728,7 @@ class JsonLdProcessor {
|
|
|
1728
1728
|
}
|
|
1729
1729
|
catch (err) {
|
|
1730
1730
|
JsonLdProcessor.handleCommonErrors(err);
|
|
1731
|
-
throw new GeneralError(JsonLdProcessor.
|
|
1731
|
+
throw new GeneralError(JsonLdProcessor.CLASS_NAME, "expand", undefined, err);
|
|
1732
1732
|
}
|
|
1733
1733
|
}
|
|
1734
1734
|
/**
|
|
@@ -1749,7 +1749,7 @@ class JsonLdProcessor {
|
|
|
1749
1749
|
}
|
|
1750
1750
|
catch (err) {
|
|
1751
1751
|
JsonLdProcessor.handleCommonErrors(err);
|
|
1752
|
-
throw new GeneralError(JsonLdProcessor.
|
|
1752
|
+
throw new GeneralError(JsonLdProcessor.CLASS_NAME, "canonize", undefined, err);
|
|
1753
1753
|
}
|
|
1754
1754
|
}
|
|
1755
1755
|
/**
|
|
@@ -1832,12 +1832,12 @@ class JsonLdProcessor {
|
|
|
1832
1832
|
for (const prop of Object.keys(element)) {
|
|
1833
1833
|
const value = element[prop];
|
|
1834
1834
|
if (Is.object(value)) {
|
|
1835
|
-
combinedContexts =
|
|
1835
|
+
combinedContexts = JsonLdProcessor.gatherContexts(value, combinedContexts);
|
|
1836
1836
|
}
|
|
1837
1837
|
else if (Is.array(value)) {
|
|
1838
1838
|
for (const item of value) {
|
|
1839
1839
|
if (Is.object(item)) {
|
|
1840
|
-
combinedContexts =
|
|
1840
|
+
combinedContexts = JsonLdProcessor.gatherContexts(item, combinedContexts);
|
|
1841
1841
|
}
|
|
1842
1842
|
}
|
|
1843
1843
|
}
|
|
@@ -1916,7 +1916,7 @@ class JsonLdProcessor {
|
|
|
1916
1916
|
}
|
|
1917
1917
|
}
|
|
1918
1918
|
try {
|
|
1919
|
-
const response = await FetchHelper.fetchJson(JsonLdProcessor.
|
|
1919
|
+
const response = await FetchHelper.fetchJson(JsonLdProcessor.CLASS_NAME, url, HttpMethod.GET, undefined, {
|
|
1920
1920
|
cacheTtlMs: JsonLdProcessor.getCacheLimit(),
|
|
1921
1921
|
headers: {
|
|
1922
1922
|
[HeaderTypes.Accept]: MimeTypes.JsonLd
|
|
@@ -1930,7 +1930,7 @@ class JsonLdProcessor {
|
|
|
1930
1930
|
catch (err) {
|
|
1931
1931
|
const error = BaseError.fromError(err);
|
|
1932
1932
|
if (error.message.includes("is not valid JSON")) {
|
|
1933
|
-
const response = await FetchHelper.fetchJson(JsonLdProcessor.
|
|
1933
|
+
const response = await FetchHelper.fetchJson(JsonLdProcessor.CLASS_NAME, url, HttpMethod.GET, undefined, {
|
|
1934
1934
|
cacheTtlMs: JsonLdProcessor.getCacheLimit(),
|
|
1935
1935
|
headers: {
|
|
1936
1936
|
[HeaderTypes.Accept]: MimeTypes.Json
|
|
@@ -1952,11 +1952,12 @@ class JsonLdProcessor {
|
|
|
1952
1952
|
static handleCommonErrors(err) {
|
|
1953
1953
|
if (Is.object(err) &&
|
|
1954
1954
|
err.name === "jsonld.InvalidUrl") {
|
|
1955
|
-
throw new GeneralError(JsonLdProcessor.
|
|
1955
|
+
throw new GeneralError(JsonLdProcessor.CLASS_NAME, "invalidUrl", { url: err.details?.url }, err);
|
|
1956
1956
|
}
|
|
1957
1957
|
else if (Is.object(err) &&
|
|
1958
1958
|
err.name.startsWith("jsonld.")) {
|
|
1959
|
-
|
|
1959
|
+
const { code, ...other } = err.details ?? {};
|
|
1960
|
+
throw new GeneralError(JsonLdProcessor.CLASS_NAME, "jsonLdError", { code, ...other }, err);
|
|
1960
1961
|
}
|
|
1961
1962
|
}
|
|
1962
1963
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @twin.org/data-json-ld - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.4](https://github.com/twinfoundation/data/compare/data-json-ld-v0.0.2-next.3...data-json-ld-v0.0.2-next.4) (2025-10-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add validate-locales ([cf9b761](https://github.com/twinfoundation/data/commit/cf9b76160820fe0b13b4fe56ed241c1d5511b7c1))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/data-core bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
16
|
+
|
|
3
17
|
## [0.0.2-next.3](https://github.com/twinfoundation/data/compare/data-json-ld-v0.0.2-next.2...data-json-ld-v0.0.2-next.3) (2025-09-29)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
^jsonld.InvalidUrl$
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/data-json-ld",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.4",
|
|
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.2-next.
|
|
18
|
+
"@twin.org/data-core": "0.0.2-next.4",
|
|
19
19
|
"@twin.org/entity": "next",
|
|
20
20
|
"@twin.org/nameof": "next",
|
|
21
21
|
"@twin.org/web": "next",
|
|
@@ -39,5 +39,17 @@
|
|
|
39
39
|
"dist/types",
|
|
40
40
|
"locales",
|
|
41
41
|
"docs"
|
|
42
|
-
]
|
|
42
|
+
],
|
|
43
|
+
"keywords": [
|
|
44
|
+
"twin",
|
|
45
|
+
"trade",
|
|
46
|
+
"iota",
|
|
47
|
+
"framework",
|
|
48
|
+
"blockchain",
|
|
49
|
+
"data"
|
|
50
|
+
],
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "git+https://github.com/twinfoundation/data/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://twindev.org"
|
|
43
55
|
}
|