@lde/dataset 0.7.4 → 0.7.6
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/distribution.d.ts +9 -0
- package/dist/distribution.d.ts.map +1 -1
- package/dist/distribution.js +23 -0
- package/dist/mediaType.d.ts.map +1 -1
- package/dist/mediaType.js +1 -0
- package/package.json +1 -1
package/dist/distribution.d.ts
CHANGED
|
@@ -18,6 +18,15 @@ export declare class Distribution {
|
|
|
18
18
|
* Returns `undefined` when no compression format is declared.
|
|
19
19
|
*/
|
|
20
20
|
get compressMimeType(): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The full content type a server is expected to send for the compressed
|
|
23
|
+
* download — {@link mimeType} with the compression suffix derived from
|
|
24
|
+
* {@link compressFormat} appended, e.g. `application/n-quads+gzip`. Returns
|
|
25
|
+
* `undefined` when no media type or no recognised compression format is
|
|
26
|
+
* declared. Lets a format check accept either the bare media type (the server
|
|
27
|
+
* decompressed the body) or the declared compressed form.
|
|
28
|
+
*/
|
|
29
|
+
get compressedMimeType(): string | undefined;
|
|
21
30
|
/**
|
|
22
31
|
* @param accessUrl Distribution access URL.
|
|
23
32
|
* @param mediaType IANA media type URI per DCAT-AP 3.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../src/distribution.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,kDACc,CAAC;
|
|
1
|
+
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../src/distribution.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,kDACc,CAAC;AAYlD,qBAAa,YAAY;aA8CL,SAAS,EAAE,GAAG;aACd,SAAS,CAAC,EAAE,MAAM;aAClB,UAAU,CAAC,EAAE,GAAG;IA/C3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAE9B;;;OAGG;IACH,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElC;;;OAGG;IACH,IAAW,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAKhD;IAED;;;;;;;OAOG;IACH,IAAW,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAIlD;IAED;;;;;;OAMG;gBAEe,SAAS,EAAE,GAAG,EACd,SAAS,CAAC,EAAE,MAAM,YAAA,EAClB,UAAU,CAAC,EAAE,GAAG,YAAA;IAO3B,QAAQ;WASD,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,MAAM;CAUxD;AAED,oBAAY,SAAS;IACnB,WAAW,0BAA0B;IACrC,SAAS,wBAAwB;IACjC,MAAM,gBAAgB;CACvB;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAWrE"}
|
package/dist/distribution.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
const SPARQL_URI = 'https://www.w3.org/TR/sparql11-protocol/';
|
|
2
2
|
export const IANA_MEDIA_TYPE_PREFIX = 'https://www.iana.org/assignments/media-types/';
|
|
3
|
+
// Maps a compression content type to the structured-syntax suffix a server
|
|
4
|
+
// appends to the RDF media type, e.g. `application/gzip` yields the `gzip` in
|
|
5
|
+
// `application/n-quads+gzip`. The inverse of how a registry strips that suffix
|
|
6
|
+
// into a separate compress format on ingest.
|
|
7
|
+
const compressionSuffixesByMimeType = {
|
|
8
|
+
'application/gzip': 'gzip',
|
|
9
|
+
'application/x-gzip': 'gzip',
|
|
10
|
+
'application/zip': 'zip',
|
|
11
|
+
};
|
|
3
12
|
export class Distribution {
|
|
4
13
|
accessUrl;
|
|
5
14
|
mediaType;
|
|
@@ -25,6 +34,20 @@ export class Distribution {
|
|
|
25
34
|
? this.compressFormat.slice(IANA_MEDIA_TYPE_PREFIX.length)
|
|
26
35
|
: this.compressFormat;
|
|
27
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* The full content type a server is expected to send for the compressed
|
|
39
|
+
* download — {@link mimeType} with the compression suffix derived from
|
|
40
|
+
* {@link compressFormat} appended, e.g. `application/n-quads+gzip`. Returns
|
|
41
|
+
* `undefined` when no media type or no recognised compression format is
|
|
42
|
+
* declared. Lets a format check accept either the bare media type (the server
|
|
43
|
+
* decompressed the body) or the declared compressed form.
|
|
44
|
+
*/
|
|
45
|
+
get compressedMimeType() {
|
|
46
|
+
if (this.mimeType === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
const suffix = compressionSuffixesByMimeType[this.compressMimeType ?? ''];
|
|
49
|
+
return suffix === undefined ? undefined : `${this.mimeType}+${suffix}`;
|
|
50
|
+
}
|
|
28
51
|
/**
|
|
29
52
|
* @param accessUrl Distribution access URL.
|
|
30
53
|
* @param mediaType IANA media type URI per DCAT-AP 3.0
|
package/dist/mediaType.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediaType.d.ts","sourceRoot":"","sources":["../src/mediaType.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,UAI5B,CAAC;AAEF,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"mediaType.d.ts","sourceRoot":"","sources":["../src/mediaType.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,UAI5B,CAAC;AAEF,eAAO,MAAM,aAAa,UAMzB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,MAAM,CAKpD,CAAC"}
|
package/dist/mediaType.js
CHANGED