Comparing version 8.1.1 to 8.2.0
@@ -550,4 +550,4 @@ /* | ||
if(container.includes('@language')) { | ||
// if container is a language map, simplify compacted value to | ||
// a simple string | ||
// if container is a language map, simplify compacted value to | ||
// a simple string | ||
if(_isValue(compactedItem)) { | ||
@@ -554,0 +554,0 @@ compactedItem = compactedItem['@value']; |
@@ -375,39 +375,9 @@ /* | ||
!options.keepFreeFloatingNodes && !insideList && | ||
(activeProperty === null || expandedActiveProperty === '@graph')) { | ||
(activeProperty === null || | ||
expandedActiveProperty === '@graph' || | ||
(_getContextValue(activeCtx, activeProperty, '@container') || []) | ||
.includes('@graph') | ||
)) { | ||
// drop empty object, top-level @value/@list, or object with only @id | ||
if(count === 0 || '@value' in rval || '@list' in rval || | ||
(count === 1 && '@id' in rval)) { | ||
// FIXME | ||
if(options.eventHandler) { | ||
// FIXME: one event or diff event for empty, @v/@l, {@id}? | ||
let code; | ||
let message; | ||
if(count === 0) { | ||
code = 'empty object'; | ||
message = 'Dropping empty object.'; | ||
} else if('@value' in rval) { | ||
code = 'object with only @value'; | ||
message = 'Dropping object with only @value.'; | ||
} else if('@list' in rval) { | ||
code = 'object with only @list'; | ||
message = 'Dropping object with only @list.'; | ||
} else if(count === 1 && '@id' in rval) { | ||
code = 'object with only @id'; | ||
message = 'Dropping object with only @id.'; | ||
} | ||
_handleEvent({ | ||
event: { | ||
type: ['JsonLdEvent'], | ||
code, | ||
level: 'warning', | ||
message, | ||
details: { | ||
value: rval | ||
} | ||
}, | ||
options | ||
}); | ||
} | ||
rval = null; | ||
} | ||
rval = _dropUnsafeObject({value: rval, count, options}); | ||
} | ||
@@ -419,2 +389,48 @@ | ||
/** | ||
* Drop empty object, top-level @value/@list, or object with only @id | ||
*/ | ||
function _dropUnsafeObject({ | ||
value, | ||
count, | ||
options | ||
}) { | ||
if(count === 0 || '@value' in value || '@list' in value || | ||
(count === 1 && '@id' in value)) { | ||
// FIXME | ||
if(options.eventHandler) { | ||
// FIXME: one event or diff event for empty, @v/@l, {@id}? | ||
let code; | ||
let message; | ||
if(count === 0) { | ||
code = 'empty object'; | ||
message = 'Dropping empty object.'; | ||
} else if('@value' in value) { | ||
code = 'object with only @value'; | ||
message = 'Dropping object with only @value.'; | ||
} else if('@list' in value) { | ||
code = 'object with only @list'; | ||
message = 'Dropping object with only @list.'; | ||
} else if(count === 1 && '@id' in value) { | ||
code = 'object with only @id'; | ||
message = 'Dropping object with only @id.'; | ||
} | ||
_handleEvent({ | ||
event: { | ||
type: ['JsonLdEvent'], | ||
code, | ||
level: 'warning', | ||
message, | ||
details: { | ||
value | ||
} | ||
}, | ||
options | ||
}); | ||
} | ||
return null; | ||
} | ||
return value; | ||
} | ||
/** | ||
* Expand each key and value of element adding to result | ||
@@ -639,3 +655,3 @@ * | ||
}), | ||
{propertyIsArray: options.isFrame}); | ||
{propertyIsArray: !!options.isFrame}); | ||
continue; | ||
@@ -781,4 +797,3 @@ } | ||
activeCtx, | ||
activeProperty: | ||
'@reverse', | ||
activeProperty: '@reverse', | ||
element: value, | ||
@@ -888,3 +903,3 @@ options | ||
// recurse into @list or @set | ||
const isList = (expandedProperty === '@list'); | ||
const isList = expandedProperty === '@list'; | ||
if(isList || expandedProperty === '@set') { | ||
@@ -942,4 +957,14 @@ let nextActiveProperty = activeProperty; | ||
// ensure expanded values are arrays | ||
expandedValue = _asArray(expandedValue) | ||
.map(v => ({'@graph': _asArray(v)})); | ||
// ensure an array | ||
expandedValue = _asArray(expandedValue); | ||
// check if needs to be dropped | ||
const count = Object.keys(expandedValue[0]).length; | ||
if(!options.isFrame && _dropUnsafeObject({ | ||
value: expandedValue[0], count, options | ||
}) === null) { | ||
// skip adding and continue | ||
continue; | ||
} | ||
// convert to graph | ||
expandedValue = expandedValue.map(v => ({'@graph': _asArray(v)})); | ||
} | ||
@@ -946,0 +971,0 @@ |
@@ -467,4 +467,5 @@ /* | ||
for(const type of util.asArray(frame[0]['@type'])) { | ||
// @id must be wildcard or an IRI | ||
if(!(types.isObject(type) || url.isAbsolute(type)) || | ||
// @type must be wildcard, IRI, or @json | ||
if(!(types.isObject(type) || url.isAbsolute(type) || | ||
(type === '@json')) || | ||
(types.isString(type) && type.indexOf('_:') === 0)) { | ||
@@ -471,0 +472,0 @@ throw new JsonLdError( |
{ | ||
"name": "jsonld", | ||
"version": "8.1.1", | ||
"version": "8.2.0", | ||
"description": "A JSON-LD Processor and API implementation in JavaScript.", | ||
@@ -32,34 +32,34 @@ "homepage": "https://github.com/digitalbazaar/jsonld.js", | ||
"dependencies": { | ||
"@digitalbazaar/http-client": "^3.2.0", | ||
"@digitalbazaar/http-client": "^3.4.1", | ||
"canonicalize": "^1.0.1", | ||
"lru-cache": "^6.0.0", | ||
"rdf-canonize": "^3.0.0" | ||
"rdf-canonize": "^3.4.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.13.14", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.13.8", | ||
"@babel/plugin-transform-modules-commonjs": "^7.13.8", | ||
"@babel/plugin-transform-runtime": "^7.13.10", | ||
"@babel/preset-env": "^7.13.12", | ||
"@babel/runtime": "^7.13.10", | ||
"@babel/core": "^7.21.8", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.20.7", | ||
"@babel/plugin-transform-modules-commonjs": "^7.21.5", | ||
"@babel/plugin-transform-runtime": "^7.21.4", | ||
"@babel/preset-env": "^7.21.5", | ||
"@babel/runtime": "^7.21.5", | ||
"babel-loader": "^8.2.2", | ||
"benchmark": "^2.1.4", | ||
"browserify": "^17.0.0", | ||
"chai": "^4.3.4", | ||
"core-js": "^3.10.0", | ||
"cors": "^2.7.1", | ||
"chai": "^4.3.7", | ||
"core-js": "^3.30.2", | ||
"cors": "^2.8.5", | ||
"cross-env": "^7.0.3", | ||
"envify": "^4.1.0", | ||
"eslint": "^8.17.0", | ||
"eslint": "^8.41.0", | ||
"eslint-config-digitalbazaar": "^3.0.0", | ||
"esmify": "^2.1.1", | ||
"express": "^4.16.4", | ||
"express": "^4.18.2", | ||
"fs-extra": "^9.1.0", | ||
"join-path-js": "0.0.0", | ||
"karma": "^5.2.3", | ||
"karma-babel-preprocessor": "^8.0.1", | ||
"karma-browserify": "^8.0.0", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-babel-preprocessor": "^8.0.2", | ||
"karma-browserify": "^8.1.0", | ||
"karma-chrome-launcher": "^3.2.0", | ||
"karma-edge-launcher": "^0.4.2", | ||
"karma-firefox-launcher": "^2.1.0", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-ie-launcher": "^1.0.0", | ||
@@ -69,6 +69,7 @@ "karma-mocha": "^2.0.1", | ||
"karma-safari-launcher": "^1.0.0", | ||
"karma-server-side": "^1.7.0", | ||
"karma-server-side": "^1.8.0", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-tap-reporter": "0.0.6", | ||
"karma-webpack": "^4.0.2", | ||
"klona": "^2.0.6", | ||
"mocha": "^8.3.2", | ||
@@ -80,3 +81,3 @@ "mocha-lcov-reporter": "^1.3.0", | ||
"webpack-cli": "^4.5.0", | ||
"webpack-merge": "^5.7.3" | ||
"webpack-merge": "^5.8.0" | ||
}, | ||
@@ -98,3 +99,3 @@ "engines": { | ||
"build-webpack": "webpack", | ||
"fetch-test-suites": "npm run fetch-json-ld-wg-test-suite && npm run fetch-json-ld-org-test-suite && npm run fetch-normalization-test-suite", | ||
"fetch-test-suites": "npm run fetch-json-ld-wg-test-suite && npm run fetch-json-ld-org-test-suite && npm run fetch-rdf-canon-test-suite", | ||
"fetch-json-ld-wg-test-suite": "npm run fetch-json-ld-api-test-suite && npm run fetch-json-ld-framing-test-suite", | ||
@@ -104,5 +105,5 @@ "fetch-json-ld-api-test-suite": "if [ ! -e test-suites/json-wg-api ]; then git clone --depth 1 https://github.com/w3c/json-ld-api.git test-suites/json-ld-api; fi", | ||
"fetch-json-ld-org-test-suite": "if [ ! -e test-suites/json-ld.org ]; then git clone --depth 1 https://github.com/json-ld/json-ld.org.git test-suites/json-ld.org; fi", | ||
"fetch-normalization-test-suite": "if [ ! -e test-suites/normalization ]; then git clone --depth 1 https://github.com/json-ld/normalization.git test-suites/normalization; fi", | ||
"fetch-rdf-canon-test-suite": "if [ ! -e test-suites/rdf-canon ]; then git clone --depth 1 https://github.com/w3c/rdf-canon.git test-suites/rdf-canon; fi", | ||
"test": "npm run test-node", | ||
"test-node": "cross-env NODE_ENV=test mocha --delay -t 30000 -A -R ${REPORTER:-spec} tests/test.js", | ||
"test-node": "cross-env NODE_ENV=test mocha --delay -t 30000 -A -R ${REPORTER:-spec} tests/test-node.js", | ||
"test-karma": "cross-env NODE_ENV=test karma start", | ||
@@ -109,0 +110,0 @@ "coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm test", |
jsonld.js | ||
========= | ||
[![Build status](https://img.shields.io/github/workflow/status/digitalbazaar/jsonld.js/Node.js%20CI)](https://github.com/digitalbazaar/jsonld.js/actions?query=workflow%3A%22Node.js+CI%22) | ||
[![Build status](https://img.shields.io/github/actions/workflow/status/digitalbazaar/jsonld.js/main.yml)](https://github.com/digitalbazaar/jsonld.js/actions/workflows/main.yml) | ||
[![Coverage status](https://img.shields.io/codecov/c/github/digitalbazaar/jsonld.js)](https://codecov.io/gh/digitalbazaar/jsonld.js) | ||
[![Dependency Status](https://img.shields.io/david/digitalbazaar/jsonld.js.svg)](https://david-dm.org/digitalbazaar/jsonld.js) | ||
[![npm](https://img.shields.io/npm/v/jsonld)](https://npm.im/jsonld) | ||
@@ -209,3 +209,3 @@ Introduction | ||
### [compact](http://json-ld.org/spec/latest/json-ld/#compacted-document-form) | ||
### [compact](https://json-ld.org/spec/latest/json-ld/#compacted-document-form) | ||
@@ -230,3 +230,3 @@ ```js | ||
### [expand](http://json-ld.org/spec/latest/json-ld/#expanded-document-form) | ||
### [expand](https://json-ld.org/spec/latest/json-ld/#expanded-document-form) | ||
@@ -248,3 +248,3 @@ ```js | ||
### [flatten](http://json-ld.org/spec/latest/json-ld/#flattened-document-form) | ||
### [flatten](https://json-ld.org/spec/latest/json-ld/#flattened-document-form) | ||
@@ -257,3 +257,3 @@ ```js | ||
### [frame](http://json-ld.org/spec/latest/json-ld-framing/#introduction) | ||
### [frame](https://json-ld.org/spec/latest/json-ld-framing/#introduction) | ||
@@ -266,7 +266,7 @@ ```js | ||
### <a name="canonize"></a>[canonize](http://json-ld.github.io/normalization/spec/) (normalize) | ||
### <a name="canonize"></a>[canonize](https://w3c.github.io/rdf-canon/spec/) (normalize) | ||
```js | ||
// canonize (normalize) a document using the RDF Dataset Normalization Algorithm | ||
// (URDNA2015), see: | ||
// canonize (normalize) a document using the RDF Dataset Canonicalization Algorithm | ||
// (URDNA2015): | ||
const canonized = await jsonld.canonize(doc, { | ||
@@ -372,24 +372,2 @@ algorithm: 'URDNA2015', | ||
Related Modules | ||
--------------- | ||
* [jsonld-cli][]: A command line interface tool called `jsonld` that exposes | ||
most of the basic jsonld.js API. | ||
* [jsonld-request][]: A module that can read data from stdin, URLs, and files | ||
and in various formats and return JSON-LD. | ||
Commercial Support | ||
------------------ | ||
Commercial support for this library is available upon request from | ||
[Digital Bazaar][]: support@digitalbazaar.com | ||
Source | ||
------ | ||
The source code for the JavaScript implementation of the JSON-LD API | ||
is available at: | ||
http://github.com/digitalbazaar/jsonld.js | ||
Tests | ||
@@ -407,3 +385,3 @@ ----- | ||
https://github.com/json-ld/json-ld.org | ||
https://github.com/json-ld/normalization | ||
https://github.com/w3c/rdf-canon | ||
@@ -421,9 +399,9 @@ They should be sibling directories of the jsonld.js directory or in a | ||
If you installed the test suites elsewhere, or wish to run other tests, use | ||
the `JSONLD_TESTS` environment var: | ||
the `TESTS` environment var: | ||
JSONLD_TESTS="/tmp/org/test-suites /tmp/norm/tests" npm test | ||
TESTS="/tmp/org/test-suites /tmp/norm/tests" npm test | ||
This feature can be used to run the older json-ld.org test suite: | ||
JSONLD_TESTS=/tmp/json-ld.org/test-suite npm test | ||
TESTS=/tmp/json-ld.org/test-suite npm test | ||
@@ -452,3 +430,3 @@ Browser testing can be done with Karma: | ||
JSONLD_TESTS=`pwd`/tests npm test | ||
TESTS=`pwd`/tests npm test | ||
@@ -466,3 +444,3 @@ To generate EARL reports: | ||
JSONLD_TESTS="`pwd`/../json-ld-api/tests `pwd`/../json-ld-framing/tests" EARL="jsonld-js-earl.jsonld" npm test | ||
TESTS="`pwd`/../json-ld-api/tests `pwd`/../json-ld-framing/tests" EARL="jsonld-js-earl.jsonld" npm test | ||
@@ -484,3 +462,3 @@ The EARL `.jsonld` output can be converted to `.ttl` using the [rdf][] tool: | ||
JSONLD_TESTS=/tmp/benchmark-manifest.jsonld JSONLD_BENCHMARK=1 npm test | ||
TESTS=/tmp/benchmark-manifest.jsonld BENCHMARK=1 npm test | ||
@@ -490,5 +468,5 @@ EARL reports with benchmark data can be generated with an optional environment | ||
JSONLD_TESTS=`pwd`/../json-ld.org/benchmarks/b001-manifiest.jsonld JSONLD_BENCHMARK=1 EARL=earl-test.jsonld TEST_ENV=1 npm test | ||
TESTS=`pwd`/../json-ld.org/benchmarks/b001-manifiest.jsonld BENCHMARK=1 EARL=earl-test.jsonld TEST_ENV=1 npm test | ||
See `tests/test.js` for more `TEST_ENV` control and options. | ||
See `tests/test.js` for more `TEST_ENV` and `BENCHMARK` control and options. | ||
@@ -498,2 +476,24 @@ These reports can be compared with the `benchmarks/compare/` tool and at the | ||
Related Modules | ||
--------------- | ||
* [jsonld-cli][]: A command line interface tool called `jsonld` that exposes | ||
most of the basic jsonld.js API. | ||
* [jsonld-request][]: A module that can read data from stdin, URLs, and files | ||
and in various formats and return JSON-LD. | ||
Source | ||
------ | ||
The source code for the JavaScript implementation of the JSON-LD API | ||
is available at: | ||
https://github.com/digitalbazaar/jsonld.js | ||
Commercial Support | ||
------------------ | ||
Commercial support for this library is available upon request from | ||
[Digital Bazaar][]: support@digitalbazaar.com | ||
[Digital Bazaar]: https://digitalbazaar.com/ | ||
@@ -534,2 +534,3 @@ | ||
[jsonld-request]: https://github.com/digitalbazaar/jsonld-request | ||
[rdf]: https://rubygems.org/gems/rdf | ||
[rdf-canonize-native]: https://github.com/digitalbazaar/rdf-canonize-native | ||
@@ -536,0 +537,0 @@ [test runner]: https://github.com/digitalbazaar/jsonld.js/blob/master/tests/test-common.js |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2809038
21176
526
42
Updatedrdf-canonize@^3.4.0