@lde/dataset 0.7.5 → 0.7.7
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/skolem.d.ts +28 -0
- package/dist/skolem.d.ts.map +1 -0
- package/dist/skolem.js +32 -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/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/skolem.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mint a deterministic IRI for an otherwise-anonymous structural node — a PROV
|
|
3
|
+
* `Activity`/`Usage`, a DQV measurement, a `void:Linkset`, a `void:subset` or a
|
|
4
|
+
* `void:*Partition` — by extending a `base` IRI that is already unique within
|
|
5
|
+
* the dataset's graph (typically the dataset IRI or one of its subsets) with
|
|
6
|
+
* `-`-joined `suffixes`.
|
|
7
|
+
*
|
|
8
|
+
* Use this instead of a blank node for any such node. A dataset's graph is
|
|
9
|
+
* assembled from the output of several independent pipeline stages, and
|
|
10
|
+
* blank-node labels are not preserved across separately serialised documents:
|
|
11
|
+
* two stages' `_:b0` collapse into one node when the documents are merged into
|
|
12
|
+
* one graph, silently fusing unrelated provenance, measurements and linksets
|
|
13
|
+
* (see dataset-knowledge-graph issue #352). IRIs are never relabelled, so
|
|
14
|
+
* deriving every structural node from a unique base keeps distinct nodes
|
|
15
|
+
* distinct across stages and makes a re-run idempotent rather than additive —
|
|
16
|
+
* and lets a later stage address (and extend) a subset or partition another
|
|
17
|
+
* stage emitted.
|
|
18
|
+
*
|
|
19
|
+
* Pass opaque, possibly non-IRI-safe `suffixes` (e.g. a URL) through
|
|
20
|
+
* {@link hashSuffix} first.
|
|
21
|
+
*/
|
|
22
|
+
export declare function skolemIri(base: string, ...suffixes: string[]): string;
|
|
23
|
+
/**
|
|
24
|
+
* An md5 hex digest, for embedding an opaque value (e.g. a URL) as a stable,
|
|
25
|
+
* IRI-safe segment in a {@link skolemIri}.
|
|
26
|
+
*/
|
|
27
|
+
export declare function hashSuffix(value: string): string;
|
|
28
|
+
//# sourceMappingURL=skolem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skolem.d.ts","sourceRoot":"","sources":["../src/skolem.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAErE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
package/dist/skolem.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Mint a deterministic IRI for an otherwise-anonymous structural node — a PROV
|
|
4
|
+
* `Activity`/`Usage`, a DQV measurement, a `void:Linkset`, a `void:subset` or a
|
|
5
|
+
* `void:*Partition` — by extending a `base` IRI that is already unique within
|
|
6
|
+
* the dataset's graph (typically the dataset IRI or one of its subsets) with
|
|
7
|
+
* `-`-joined `suffixes`.
|
|
8
|
+
*
|
|
9
|
+
* Use this instead of a blank node for any such node. A dataset's graph is
|
|
10
|
+
* assembled from the output of several independent pipeline stages, and
|
|
11
|
+
* blank-node labels are not preserved across separately serialised documents:
|
|
12
|
+
* two stages' `_:b0` collapse into one node when the documents are merged into
|
|
13
|
+
* one graph, silently fusing unrelated provenance, measurements and linksets
|
|
14
|
+
* (see dataset-knowledge-graph issue #352). IRIs are never relabelled, so
|
|
15
|
+
* deriving every structural node from a unique base keeps distinct nodes
|
|
16
|
+
* distinct across stages and makes a re-run idempotent rather than additive —
|
|
17
|
+
* and lets a later stage address (and extend) a subset or partition another
|
|
18
|
+
* stage emitted.
|
|
19
|
+
*
|
|
20
|
+
* Pass opaque, possibly non-IRI-safe `suffixes` (e.g. a URL) through
|
|
21
|
+
* {@link hashSuffix} first.
|
|
22
|
+
*/
|
|
23
|
+
export function skolemIri(base, ...suffixes) {
|
|
24
|
+
return [base, ...suffixes].join('-');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* An md5 hex digest, for embedding an opaque value (e.g. a URL) as a stable,
|
|
28
|
+
* IRI-safe segment in a {@link skolemIri}.
|
|
29
|
+
*/
|
|
30
|
+
export function hashSuffix(value) {
|
|
31
|
+
return createHash('md5').update(value).digest('hex');
|
|
32
|
+
}
|