digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.66k stars 195 forks source link

Replace request issue 420 #434

Closed aljones15 closed 3 years ago

aljones15 commented 3 years ago

This replaces the deprecated library request with @digitalbazaar/http-client. This was done a way that should ensure this is a minor feature and not a major update. Unfortunately node-fetch requires node >= 10 so this is now a major release. When we do the next major update we pull out the callbacks and such then.

Test: The existing test suite reports no new failures, but does not use the documentLoader when testing. I did manual tests using the compact feature:

no redirects:

jsonld.compact({"http://purl.org/dc/terms/created": new Date().toISOString()}, 'https://w3c-ccg.github.io/did-spec/contexts/did-v1.jsonld').then(console.log)
Promise { <pending> }
> {
  '@context': 'https://w3c-ccg.github.io/did-spec/contexts/did-v1.jsonld',
  'dc:created': '2021-02-18T19:40:57.855Z'
}

302 Found redirect with a header.location:

> jsonld.compact({"http://purl.org/dc/terms/created": new Date().toISOString()}, 'https://w3id.org/did/v1').then(console.log)
Promise { <pending> }
> {
  '@context': 'https://w3id.org/did/v1',
  'dc:created': '2021-02-18T20:00:21.644Z'
}

redirect with a link header containing a context:

 nodeDocumentLoader('https://json-ld.org/test-suite/tests/remote-doc-0010-in.json').then(console.log);
{ contextUrl: 'remote-doc-0010-context.jsonld',
  documentUrl:
   'https://json-ld.org/test-suite/tests/remote-doc-0010-in.json',
  document: '[\n  {\n    "@id": "",\n    "term": "value"\n  }\n]' }

addresses: https://github.com/digitalbazaar/jsonld.js/issues/420

codecov-io commented 3 years ago

Codecov Report

Merging #434 (f4bca4a) into master (13984c7) will increase coverage by 1.49%. The diff coverage is 93.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #434      +/-   ##
==========================================
+ Coverage   91.19%   92.68%   +1.49%     
==========================================
  Files          22       22              
  Lines        2850     2857       +7     
==========================================
+ Hits         2599     2648      +49     
+ Misses        251      209      -42     
Impacted Files Coverage Δ
lib/context.js 91.51% <ø> (ø)
lib/documentLoaders/node.js 95.38% <93.54%> (+68.46%) :arrow_up:
lib/index.js 100.00% <100.00%> (+42.85%) :arrow_up:
lib/jsonld.js 82.59% <100.00%> (+0.31%) :arrow_up:
lib/ContextResolver.js 89.79% <0.00%> (+1.02%) :arrow_up:
lib/util.js 88.48% <0.00%> (+1.21%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 13984c7...f4bca4a. Read the comment docs.