@lde/distribution-probe 0.1.2 → 0.1.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/probe.d.ts.map +1 -1
- package/dist/probe.js +11 -8
- package/package.json +2 -2
package/dist/probe.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../src/probe.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../src/probe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,YAAY,EAAE,MAAM,cAAc,CAAC;AAGnE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD;;GAEG;AACH,qBAAa,YAAY;aAEL,GAAG,EAAE,MAAM;aACX,OAAO,EAAE,MAAM;aACf,cAAc,EAAE,MAAM;gBAFtB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM;CAEzC;AAED;;GAEG;AACH,uBAAe,WAAW;aAUN,GAAG,EAAE,MAAM;IAT7B,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,YAAY,EAAE,IAAI,GAAG,IAAI,CAAQ;IACjD,SAAgB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,SAAgB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,SAAgB,QAAQ,EAAE,MAAM,EAAE,CAAM;IACxC,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAGrB,GAAG,EAAE,MAAM,EAC3B,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,MAAM,EACtB,aAAa,GAAE,MAAM,GAAG,IAAW;IAa9B,SAAS,IAAI,OAAO;CAO5B;AAKD;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,SAAgB,mBAAmB,EAAE,MAAM,CAAC;gBAG1C,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,MAAM,EACtB,mBAAmB,EAAE,MAAM,EAC3B,aAAa,GAAE,MAAM,GAAG,IAAW;IAM5B,SAAS,IAAI,OAAO;CAM9B;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,SAAgB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;gBAGhD,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,MAAM,EACtB,aAAa,GAAE,MAAM,GAAG,IAAW;CAQtC;AAED,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,mBAAmB,GACnB,YAAY,CAAC;AAIjB;;;;;;;;GAQG;AACH,wBAAsB,KAAK,CACzB,YAAY,EAAE,YAAY,EAC1B,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,eAAe,CAAC,CAkC1B"}
|
package/dist/probe.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { compressionMediaTypes } from '@lde/dataset';
|
|
1
2
|
import { Parser } from 'n3';
|
|
2
3
|
const DEFAULT_SPARQL_QUERY = 'SELECT * { ?s ?p ?o } LIMIT 1';
|
|
3
4
|
const DEFAULT_TIMEOUT_MS = 5000;
|
|
@@ -201,8 +202,16 @@ async function validateSparqlResponse(response, queryType) {
|
|
|
201
202
|
return null;
|
|
202
203
|
}
|
|
203
204
|
async function probeDataDump(url, distribution, options, authHeaders, start) {
|
|
205
|
+
// Express a preference for the declared media type, but accept anything as a
|
|
206
|
+
// fallback. Servers that implement RFC 9110 §12.5.1 content negotiation will
|
|
207
|
+
// pick the declared type (preserving our ability to detect real Content-Type
|
|
208
|
+
// mismatches). Servers that reject any non-*/* Accept with 406 — notably
|
|
209
|
+
// Dataverse's /api/access/datafile/ endpoint (IQSS/dataverse#12410) — fall
|
|
210
|
+
// back to */* and return the file unchanged.
|
|
204
211
|
const headers = new Headers({
|
|
205
|
-
Accept: distribution.mimeType
|
|
212
|
+
Accept: distribution.mimeType
|
|
213
|
+
? `${distribution.mimeType}, */*;q=0.5`
|
|
214
|
+
: '*/*',
|
|
206
215
|
'Accept-Encoding': 'identity',
|
|
207
216
|
});
|
|
208
217
|
for (const [key, value] of authHeaders) {
|
|
@@ -263,12 +272,6 @@ function validateBody(body, contentType) {
|
|
|
263
272
|
}
|
|
264
273
|
return null;
|
|
265
274
|
}
|
|
266
|
-
/** Content types that indicate compression, not the RDF serialization format. */
|
|
267
|
-
const compressionTypes = new Set([
|
|
268
|
-
'application/gzip',
|
|
269
|
-
'application/x-gzip',
|
|
270
|
-
'application/octet-stream',
|
|
271
|
-
]);
|
|
272
275
|
/**
|
|
273
276
|
* Compare the declared MIME type from the dataset registry against the
|
|
274
277
|
* server's Content-Type header. Adds a warning when they disagree.
|
|
@@ -277,7 +280,7 @@ function checkContentTypeMismatch(result, declaredMimeType) {
|
|
|
277
280
|
if (!result.isSuccess() || !declaredMimeType || !result.contentType)
|
|
278
281
|
return;
|
|
279
282
|
const actual = result.contentType.split(';')[0].trim();
|
|
280
|
-
if (
|
|
283
|
+
if (compressionMediaTypes.has(actual))
|
|
281
284
|
return;
|
|
282
285
|
if (actual !== declaredMimeType) {
|
|
283
286
|
result.warnings.push(`Server Content-Type ${actual} does not match declared media type ${declaredMimeType}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/distribution-probe",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/ldelements/lde.git",
|
|
6
6
|
"directory": "packages/distribution-probe"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"!**/*.tsbuildinfo"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@lde/dataset": "0.7.
|
|
27
|
+
"@lde/dataset": "0.7.4",
|
|
28
28
|
"n3": "^2.0.1",
|
|
29
29
|
"tslib": "^2.3.0"
|
|
30
30
|
}
|