@rdfx/fs 0.0.49 → 0.0.52
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/CompressedRdfStream.d.ts +2 -2
- package/dist/CompressedRdfStream.js +3 -3
- package/dist/RdfDirectoryGraphStore.d.ts +1 -1
- package/dist/RdfDirectoryGraphStore.js +3 -4
- package/dist/RdfFile.d.ts +2 -2
- package/dist/RdfFile.js +2 -3
- package/dist/RdfFileGraphStore.d.ts +1 -1
- package/dist/RdfFileGraphStore.js +3 -2
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -7
- package/package.json +10 -10
- package/dist/CompressedRdfFormat.d.ts +0 -7
- package/dist/CompressedRdfFormat.js +0 -2
- package/dist/CompressionMethod.d.ts +0 -3
- package/dist/CompressionMethod.js +0 -2
- package/dist/RdfFormat.d.ts +0 -9
- package/dist/RdfFormat.js +0 -48
- package/dist/UncompressedRdfFormat.d.ts +0 -7
- package/dist/UncompressedRdfFormat.js +0 -2
- package/dist/compressionMethods.d.ts +0 -2
- package/dist/compressionMethods.js +0 -6
- package/dist/uncompressedRdfFormats.d.ts +0 -3
- package/dist/uncompressedRdfFormats.js +0 -33
- package/dist/uncompressedRdfFormatsByMimeType.d.ts +0 -3
- package/dist/uncompressedRdfFormatsByMimeType.js +0 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Readable, Writable } from "node:stream";
|
|
2
2
|
import type { Stream } from "@rdfjs/types";
|
|
3
|
-
import
|
|
3
|
+
import { RdfFormat } from "@rdfx/format";
|
|
4
|
+
import serializers from "@rdfx/serializer";
|
|
4
5
|
import { type Either } from "purify-ts";
|
|
5
|
-
import { RdfFormat } from "./RdfFormat.js";
|
|
6
6
|
export declare namespace CompressedRdfStream {
|
|
7
7
|
function parse(format: RdfFormat, input: Readable): Stream;
|
|
8
8
|
function serialize({ destination, format, serializerOptions, source, }: {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { pipeline } from "node:stream/promises";
|
|
2
2
|
import zlib from "node:zlib";
|
|
3
3
|
import dataFactory from "@rdfx/data-factory";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import { RdfFormat } from "@rdfx/format";
|
|
5
|
+
import parsersFactory from "@rdfx/parser";
|
|
6
|
+
import serializers from "@rdfx/serializer";
|
|
6
7
|
import { EitherAsync } from "purify-ts";
|
|
7
8
|
import bz2 from "unbzip2-stream";
|
|
8
|
-
import { RdfFormat } from "./RdfFormat.js";
|
|
9
9
|
const parsers = parsersFactory({ dataFactory });
|
|
10
10
|
export var CompressedRdfStream;
|
|
11
11
|
(function (CompressedRdfStream) {
|
|
@@ -10,7 +10,7 @@ export declare class RdfDirectoryGraphStore implements GraphStore {
|
|
|
10
10
|
readonly path: string;
|
|
11
11
|
private readonly fileSystem;
|
|
12
12
|
private readonly logger;
|
|
13
|
-
static readonly fileFormat: import("
|
|
13
|
+
static readonly fileFormat: import("@rdfx/format").UncompressedRdfFormat;
|
|
14
14
|
constructor(path: string, options?: {
|
|
15
15
|
fileSystem?: FileSystem;
|
|
16
16
|
logger?: Logger;
|
|
@@ -2,15 +2,14 @@ import { Buffer } from "node:buffer";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { datasetFactory } from "@rdfx/collection";
|
|
4
4
|
import dataFactory from "@rdfx/data-factory";
|
|
5
|
+
import { RdfFormat, uncompressedRdfFormatsByMimeType } from "@rdfx/format";
|
|
5
6
|
import { GraphIdentifier } from "@rdfx/graph-store";
|
|
6
|
-
import parsers from "@rdfx/
|
|
7
|
+
import parsers from "@rdfx/parser";
|
|
7
8
|
import { NTriplesTerm } from "@rdfx/string";
|
|
8
9
|
import { Either, EitherAsync, Left, Maybe } from "purify-ts";
|
|
9
10
|
import { dummyLogger } from "ts-log";
|
|
10
11
|
import { NodeFileSystem } from "./NodeFileSystem.js";
|
|
11
12
|
import { RdfDirectory } from "./RdfDirectory.js";
|
|
12
|
-
import { RdfFormat } from "./RdfFormat.js";
|
|
13
|
-
import { uncompressedRdfFormatsByMimeType } from "./uncompressedRdfFormatsByMimeType.js";
|
|
14
13
|
/**
|
|
15
14
|
* A GraphStore implementation backed by files in a directory.
|
|
16
15
|
*/
|
|
@@ -31,7 +30,7 @@ export class RdfDirectoryGraphStore {
|
|
|
31
30
|
continue;
|
|
32
31
|
}
|
|
33
32
|
const direntPath = path.join(dirent.parentPath, dirent.name);
|
|
34
|
-
const formatEither = RdfFormat.
|
|
33
|
+
const formatEither = RdfFormat.fromFileName(direntPath);
|
|
35
34
|
if (formatEither.isLeft()) {
|
|
36
35
|
this.logger.debug("%s is not an RDF file, ignoring", direntPath);
|
|
37
36
|
continue;
|
package/dist/RdfFile.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { DatasetCore, Stream } from "@rdfjs/types";
|
|
2
2
|
import type { PrefixMap } from "@rdfx/collection";
|
|
3
|
-
import
|
|
3
|
+
import { RdfFormat } from "@rdfx/format";
|
|
4
|
+
import type serializers from "@rdfx/serializer";
|
|
4
5
|
import { Either } from "purify-ts";
|
|
5
6
|
import { type Logger } from "ts-log";
|
|
6
7
|
import type { FileSystem } from "./FileSystem.js";
|
|
7
|
-
import { RdfFormat } from "./RdfFormat.js";
|
|
8
8
|
export declare class RdfFile {
|
|
9
9
|
readonly path: string;
|
|
10
10
|
readonly format: RdfFormat;
|
package/dist/RdfFile.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { RdfFormat, uncompressedRdfFormatsByMimeType } from "@rdfx/format";
|
|
1
2
|
import { Either, EitherAsync, Left } from "purify-ts";
|
|
2
3
|
import { dummyLogger } from "ts-log";
|
|
3
4
|
import { CompressedRdfStream } from "./CompressedRdfStream.js";
|
|
4
5
|
import { NodeFileSystem } from "./NodeFileSystem.js";
|
|
5
|
-
import { RdfFormat } from "./RdfFormat.js";
|
|
6
|
-
import { uncompressedRdfFormatsByMimeType } from "./uncompressedRdfFormatsByMimeType.js";
|
|
7
6
|
export class RdfFile {
|
|
8
7
|
path;
|
|
9
8
|
format;
|
|
@@ -18,7 +17,7 @@ export class RdfFile {
|
|
|
18
17
|
this.logger = options?.logger ?? dummyLogger;
|
|
19
18
|
}
|
|
20
19
|
static fromPath(filePath, options) {
|
|
21
|
-
return RdfFormat.
|
|
20
|
+
return RdfFormat.fromFileName(filePath).map((format) => new RdfFile(filePath, {
|
|
22
21
|
fileSystem: options?.fileSystem,
|
|
23
22
|
format,
|
|
24
23
|
logger: options?.logger,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { DatasetCore, Stream } from "@rdfjs/types";
|
|
2
2
|
import { type PrefixMap } from "@rdfx/collection";
|
|
3
|
+
import { RdfFormat } from "@rdfx/format";
|
|
3
4
|
import { type GraphIdentifier, type GraphStore } from "@rdfx/graph-store";
|
|
4
5
|
import { Either, type Maybe } from "purify-ts";
|
|
5
6
|
import { type Logger } from "ts-log";
|
|
6
7
|
import type { FileSystem } from "./FileSystem.js";
|
|
7
|
-
import { RdfFormat } from "./RdfFormat.js";
|
|
8
8
|
/**
|
|
9
9
|
* A GraphStore implementation backed by a single RdfFile.
|
|
10
10
|
*/
|
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { datasetFactory } from "@rdfx/collection";
|
|
8
|
+
import { RdfFormat } from "@rdfx/format";
|
|
8
9
|
import { RdfjsDatasetGraphStore, } from "@rdfx/graph-store";
|
|
9
10
|
import { iterableToStream } from "@rdfx/stream";
|
|
10
11
|
import { Either, EitherAsync, Left } from "purify-ts";
|
|
@@ -13,7 +14,6 @@ import { Memoize } from "typescript-memoize";
|
|
|
13
14
|
import { isErrnoException } from "./ErrnoException.js";
|
|
14
15
|
import { NodeFileSystem } from "./NodeFileSystem.js";
|
|
15
16
|
import { RdfFile } from "./RdfFile.js";
|
|
16
|
-
import { RdfFormat } from "./RdfFormat.js";
|
|
17
17
|
/**
|
|
18
18
|
* A GraphStore implementation backed by a single RdfFile.
|
|
19
19
|
*/
|
|
@@ -26,7 +26,8 @@ export class RdfFileGraphStore {
|
|
|
26
26
|
constructor(path, options) {
|
|
27
27
|
this.path = path;
|
|
28
28
|
this.fileSystem = options?.fileSystem ?? NodeFileSystem.instance;
|
|
29
|
-
this.format =
|
|
29
|
+
this.format =
|
|
30
|
+
options?.format ?? RdfFormat.fromFileName(path).unsafeCoerce();
|
|
30
31
|
this.logger = options?.logger ?? dummyLogger;
|
|
31
32
|
this.prefixMap = options?.prefixMap;
|
|
32
33
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export * from "./CompressedRdfFormat.js";
|
|
2
1
|
export * from "./CompressedRdfStream.js";
|
|
3
|
-
export * from "./CompressionMethod.js";
|
|
4
|
-
export * from "./compressionMethods.js";
|
|
5
2
|
export * from "./Dirent.js";
|
|
6
3
|
export * from "./ErrnoException.js";
|
|
7
4
|
export * from "./FileSystem.js";
|
|
@@ -11,9 +8,5 @@ export * from "./RdfDirectoryGraphStore.js";
|
|
|
11
8
|
export * from "./RdfFile.js";
|
|
12
9
|
export * from "./RdfFileGraphStore.js";
|
|
13
10
|
export * from "./RdfFileSystemEntry.js";
|
|
14
|
-
export * from "./RdfFormat.js";
|
|
15
11
|
export * from "./Stat.js";
|
|
16
|
-
export * from "./UncompressedRdfFormat.js";
|
|
17
|
-
export * from "./uncompressedRdfFormats.js";
|
|
18
|
-
export * from "./uncompressedRdfFormatsByMimeType.js";
|
|
19
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export * from "./CompressedRdfFormat.js";
|
|
2
1
|
export * from "./CompressedRdfStream.js";
|
|
3
|
-
export * from "./CompressionMethod.js";
|
|
4
|
-
export * from "./compressionMethods.js";
|
|
5
2
|
export * from "./Dirent.js";
|
|
6
3
|
export * from "./ErrnoException.js";
|
|
7
4
|
export * from "./FileSystem.js";
|
|
@@ -11,9 +8,5 @@ export * from "./RdfDirectoryGraphStore.js";
|
|
|
11
8
|
export * from "./RdfFile.js";
|
|
12
9
|
export * from "./RdfFileGraphStore.js";
|
|
13
10
|
export * from "./RdfFileSystemEntry.js";
|
|
14
|
-
export * from "./RdfFormat.js";
|
|
15
11
|
export * from "./Stat.js";
|
|
16
|
-
export * from "./UncompressedRdfFormat.js";
|
|
17
|
-
export * from "./uncompressedRdfFormats.js";
|
|
18
|
-
export * from "./uncompressedRdfFormatsByMimeType.js";
|
|
19
12
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@rdfx/collection": "0.0.
|
|
4
|
-
"@rdfx/data-factory": "0.0.
|
|
5
|
-
"@rdfx/
|
|
6
|
-
"@rdfx/
|
|
7
|
-
"@rdfx/
|
|
8
|
-
"@rdfx/
|
|
9
|
-
"@rdfx/
|
|
3
|
+
"@rdfx/collection": "0.0.52",
|
|
4
|
+
"@rdfx/data-factory": "0.0.52",
|
|
5
|
+
"@rdfx/format": "0.0.52",
|
|
6
|
+
"@rdfx/graph-store": "0.0.52",
|
|
7
|
+
"@rdfx/parser": "0.0.52",
|
|
8
|
+
"@rdfx/serializer": "0.0.52",
|
|
9
|
+
"@rdfx/stream": "0.0.52",
|
|
10
|
+
"@rdfx/string": "0.0.52",
|
|
10
11
|
"@rdfjs/types": "~2.0.1",
|
|
11
12
|
"@types/node": "^24",
|
|
12
13
|
"@types/unbzip2-stream": "~1.4.3",
|
|
13
|
-
"mime": "~4.1.0",
|
|
14
14
|
"purify-ts": "~2.1.4",
|
|
15
15
|
"ts-log": "~3.0.2",
|
|
16
16
|
"typescript-memoize": "~1.1.1",
|
|
17
17
|
"unbzip2-stream": "~1.4.3"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@rdfx/testing": "0.0.
|
|
20
|
+
"@rdfx/testing": "0.0.52"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"LICENSE",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
},
|
|
43
43
|
"type": "module",
|
|
44
44
|
"types": "./dist/index.d.ts",
|
|
45
|
-
"version": "0.0.
|
|
45
|
+
"version": "0.0.52"
|
|
46
46
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { CompressionMethod } from "./CompressionMethod.js";
|
|
2
|
-
import type { UncompressedRdfFormat } from "./UncompressedRdfFormat.js";
|
|
3
|
-
export interface CompressedRdfFormat extends Omit<UncompressedRdfFormat, "mimeType"> {
|
|
4
|
-
readonly mimeType: CompressionMethod;
|
|
5
|
-
readonly uncompressedMimeType: UncompressedRdfFormat["mimeType"];
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=CompressedRdfFormat.d.ts.map
|
package/dist/RdfFormat.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Either } from "purify-ts";
|
|
2
|
-
import type { CompressedRdfFormat } from "./CompressedRdfFormat.js";
|
|
3
|
-
import type { UncompressedRdfFormat } from "./UncompressedRdfFormat.js";
|
|
4
|
-
export type RdfFormat = CompressedRdfFormat | UncompressedRdfFormat;
|
|
5
|
-
export declare namespace RdfFormat {
|
|
6
|
-
function fromPath(filePath: string): Either<Error, RdfFormat>;
|
|
7
|
-
function isCompressed(rdfFormat: RdfFormat): rdfFormat is CompressedRdfFormat;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=RdfFormat.d.ts.map
|
package/dist/RdfFormat.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { Mime } from "mime";
|
|
3
|
-
import otherMimeTypes from "mime/types/other.js";
|
|
4
|
-
import standardMimeTypes from "mime/types/standard.js";
|
|
5
|
-
import { Left, Right } from "purify-ts";
|
|
6
|
-
import { compressionMethods } from "./compressionMethods.js";
|
|
7
|
-
import { uncompressedRdfFormatsByMimeType } from "./uncompressedRdfFormatsByMimeType.js";
|
|
8
|
-
const compressionMethodsSet = new Set(compressionMethods);
|
|
9
|
-
const mime = new Mime(standardMimeTypes, otherMimeTypes, {
|
|
10
|
-
"application/x-brotli": ["br"],
|
|
11
|
-
});
|
|
12
|
-
export var RdfFormat;
|
|
13
|
-
(function (RdfFormat) {
|
|
14
|
-
function fromPath(filePath) {
|
|
15
|
-
const mimeType = mime.getType(filePath);
|
|
16
|
-
if (mimeType === null) {
|
|
17
|
-
return Left(new Error(`unable to infer MIME type of ${filePath}`));
|
|
18
|
-
}
|
|
19
|
-
if (compressionMethodsSet.has(mimeType)) {
|
|
20
|
-
const uncompressedFileName = path.basename(path.basename(filePath), path.extname(filePath));
|
|
21
|
-
const uncompressedMimeType = mime.getType(uncompressedFileName);
|
|
22
|
-
if (uncompressedMimeType === null) {
|
|
23
|
-
return Left(new Error(`unable to infer MIME type of ${uncompressedFileName}`));
|
|
24
|
-
}
|
|
25
|
-
const uncompressedRdfFormat = uncompressedRdfFormatsByMimeType[uncompressedMimeType];
|
|
26
|
-
if (uncompressedRdfFormat === undefined) {
|
|
27
|
-
return Left(new Error(`${filePath} has a non-RDF MIME type: ${uncompressedMimeType}`));
|
|
28
|
-
}
|
|
29
|
-
return Right({
|
|
30
|
-
lineOriented: uncompressedRdfFormat.lineOriented,
|
|
31
|
-
mimeType: mimeType,
|
|
32
|
-
supportsQuads: uncompressedRdfFormat.supportsQuads,
|
|
33
|
-
uncompressedMimeType: uncompressedRdfFormat.mimeType,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
const uncompressedRdfFormat = uncompressedRdfFormatsByMimeType[mimeType];
|
|
37
|
-
if (uncompressedRdfFormat === undefined) {
|
|
38
|
-
return Left(new Error(`${filePath} has a non-RDF MIME type: ${mimeType}`));
|
|
39
|
-
}
|
|
40
|
-
return Right(uncompressedRdfFormat);
|
|
41
|
-
}
|
|
42
|
-
RdfFormat.fromPath = fromPath;
|
|
43
|
-
function isCompressed(rdfFormat) {
|
|
44
|
-
return compressionMethods.some((compressionMethod) => compressionMethod === rdfFormat.mimeType);
|
|
45
|
-
}
|
|
46
|
-
RdfFormat.isCompressed = isCompressed;
|
|
47
|
-
})(RdfFormat || (RdfFormat = {}));
|
|
48
|
-
//# sourceMappingURL=RdfFormat.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const RDF_FORMATS: readonly [];
|
|
2
|
-
export interface UncompressedRdfFormat {
|
|
3
|
-
readonly lineOriented: boolean;
|
|
4
|
-
readonly mimeType: "application/ld+json" | "application/n-quads" | "application/n-triples" | "application/rdf+xml" | "application/trig" | "text/n3" | "text/turtle";
|
|
5
|
-
readonly supportsQuads: boolean;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=UncompressedRdfFormat.d.ts.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export const uncompressedRdfFormats = [
|
|
2
|
-
{
|
|
3
|
-
lineOriented: false,
|
|
4
|
-
mimeType: "application/ld+json",
|
|
5
|
-
supportsQuads: true,
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
lineOriented: true,
|
|
9
|
-
mimeType: "application/n-quads",
|
|
10
|
-
supportsQuads: false,
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
lineOriented: true,
|
|
14
|
-
mimeType: "application/n-triples",
|
|
15
|
-
supportsQuads: false,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
lineOriented: false,
|
|
19
|
-
mimeType: "application/trig",
|
|
20
|
-
supportsQuads: true,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
lineOriented: false,
|
|
24
|
-
mimeType: "text/n3",
|
|
25
|
-
supportsQuads: false,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
lineOriented: false,
|
|
29
|
-
mimeType: "text/turtle",
|
|
30
|
-
supportsQuads: false,
|
|
31
|
-
},
|
|
32
|
-
];
|
|
33
|
-
//# sourceMappingURL=uncompressedRdfFormats.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { UncompressedRdfFormat } from "./UncompressedRdfFormat.js";
|
|
2
|
-
export declare const uncompressedRdfFormatsByMimeType: Record<"application/ld+json" | "application/n-quads" | "application/n-triples" | "application/rdf+xml" | "application/trig" | "text/n3" | "text/turtle", UncompressedRdfFormat>;
|
|
3
|
-
//# sourceMappingURL=uncompressedRdfFormatsByMimeType.d.ts.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { uncompressedRdfFormats } from "./uncompressedRdfFormats.js";
|
|
2
|
-
export const uncompressedRdfFormatsByMimeType = uncompressedRdfFormats.reduce((acc, uncompressedRdfFormat) => {
|
|
3
|
-
acc[uncompressedRdfFormat.mimeType] = uncompressedRdfFormat;
|
|
4
|
-
return acc;
|
|
5
|
-
}, {});
|
|
6
|
-
//# sourceMappingURL=uncompressedRdfFormatsByMimeType.js.map
|