@rdfx/graph-store 0.0.31 → 0.0.32
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/MultiplexingGraphStore.d.ts +21 -0
- package/dist/MultiplexingGraphStore.js +68 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Stream } from "@rdfjs/types";
|
|
2
|
+
import { type Either, Maybe } from "purify-ts";
|
|
3
|
+
import type { GraphIdentifier } from "./GraphIdentifier.js";
|
|
4
|
+
import type { GraphStore } from "./GraphStore.js";
|
|
5
|
+
/**
|
|
6
|
+
* A GraphStore implementation that multiplexes over multiple other GraphStore implementations.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MultiplexingGraphStore<ClearOptionsT extends object, ClearReturnT extends object, DeleteOptionsT extends object, DeleteReturnT extends object, GetOptionsT extends object, HeadOptionsT extends object, PostOptionsT extends object, PostReturnT extends object, PutOptionsT extends object, PutReturnT extends object> implements GraphStore {
|
|
9
|
+
private readonly readWriteGraphStore;
|
|
10
|
+
private readonly graphStores;
|
|
11
|
+
constructor(readWriteGraphStore: GraphStore<ClearOptionsT, ClearReturnT, DeleteOptionsT, DeleteReturnT, GetOptionsT, HeadOptionsT, PostOptionsT, PostReturnT, PutOptionsT, PutReturnT>, ...readOnlyGraphStores: readonly GraphStore<ClearOptionsT, ClearReturnT, DeleteOptionsT, DeleteReturnT, GetOptionsT, HeadOptionsT, PostOptionsT, PostReturnT, PutOptionsT, PutReturnT>[]);
|
|
12
|
+
clear(options?: ClearOptionsT): Promise<Either<Error, ClearReturnT>>;
|
|
13
|
+
delete(identifier: GraphIdentifier, options?: DeleteOptionsT): Promise<Either<Error, DeleteReturnT>>;
|
|
14
|
+
get(identifier: GraphIdentifier, options?: GetOptionsT): Promise<Either<Error, Maybe<Stream>>>;
|
|
15
|
+
head(identifier: GraphIdentifier, options?: HeadOptionsT): Promise<Either<Error, boolean>>;
|
|
16
|
+
identifiers(): Promise<Either<Error, readonly GraphIdentifier[]>>;
|
|
17
|
+
isEmpty(): Promise<Either<Error, boolean>>;
|
|
18
|
+
post(quads: Stream, options?: PostOptionsT): Promise<Either<Error, PostReturnT>>;
|
|
19
|
+
put(quads: Stream, options?: PutOptionsT): Promise<Either<Error, PutReturnT>>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=MultiplexingGraphStore.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { EitherAsync, Maybe } from "purify-ts";
|
|
2
|
+
/**
|
|
3
|
+
* A GraphStore implementation that multiplexes over multiple other GraphStore implementations.
|
|
4
|
+
*/
|
|
5
|
+
export class MultiplexingGraphStore {
|
|
6
|
+
readWriteGraphStore;
|
|
7
|
+
graphStores;
|
|
8
|
+
constructor(readWriteGraphStore, ...readOnlyGraphStores) {
|
|
9
|
+
this.readWriteGraphStore = readWriteGraphStore;
|
|
10
|
+
this.graphStores = [readWriteGraphStore, ...readOnlyGraphStores];
|
|
11
|
+
}
|
|
12
|
+
clear(options) {
|
|
13
|
+
return this.readWriteGraphStore.clear(options);
|
|
14
|
+
}
|
|
15
|
+
delete(identifier, options) {
|
|
16
|
+
return this.readWriteGraphStore.delete(identifier, options);
|
|
17
|
+
}
|
|
18
|
+
async get(identifier, options) {
|
|
19
|
+
return EitherAsync(async ({ liftEither }) => {
|
|
20
|
+
for (const graphStore of this.graphStores) {
|
|
21
|
+
const quads = await liftEither(await graphStore.get(identifier, options));
|
|
22
|
+
if (quads.isJust()) {
|
|
23
|
+
return quads;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return Maybe.empty();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async head(identifier, options) {
|
|
30
|
+
return EitherAsync(async ({ liftEither }) => {
|
|
31
|
+
for (const graphStore of this.graphStores) {
|
|
32
|
+
const result = await liftEither(await graphStore.head(identifier, options));
|
|
33
|
+
if (result) {
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async identifiers() {
|
|
41
|
+
return EitherAsync(async ({ liftEither }) => {
|
|
42
|
+
const identifiers = new Map();
|
|
43
|
+
for (const graphStore of this.graphStores) {
|
|
44
|
+
for (const identifier of await liftEither(await graphStore.identifiers())) {
|
|
45
|
+
identifiers.set(identifier.value, identifier);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return [...identifiers.values()];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async isEmpty() {
|
|
52
|
+
return EitherAsync(async ({ liftEither }) => {
|
|
53
|
+
for (const graphStore of this.graphStores) {
|
|
54
|
+
if (!(await liftEither(await graphStore.isEmpty()))) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
post(quads, options) {
|
|
62
|
+
return this.readWriteGraphStore.post(quads, options);
|
|
63
|
+
}
|
|
64
|
+
put(quads, options) {
|
|
65
|
+
return this.readWriteGraphStore.put(quads, options);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=MultiplexingGraphStore.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./ForwardingGraphStore.js";
|
|
|
2
2
|
export * from "./GraphIdentifier.js";
|
|
3
3
|
export * from "./GraphStore.js";
|
|
4
4
|
export * from "./LoggingGraphStore.js";
|
|
5
|
+
export * from "./MultiplexingGraphStore.js";
|
|
5
6
|
export * from "./RdfjsDatasetGraphStore.js";
|
|
6
7
|
export * from "./VersionedGraphStore.js";
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./ForwardingGraphStore.js";
|
|
|
2
2
|
export * from "./GraphIdentifier.js";
|
|
3
3
|
export * from "./GraphStore.js";
|
|
4
4
|
export * from "./LoggingGraphStore.js";
|
|
5
|
+
export * from "./MultiplexingGraphStore.js";
|
|
5
6
|
export * from "./RdfjsDatasetGraphStore.js";
|
|
6
7
|
export * from "./VersionedGraphStore.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"ts-log": "~3.0.2"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@rdfx/data-factory": "0.0.
|
|
10
|
+
"@rdfx/data-factory": "0.0.32",
|
|
11
11
|
"@rdfjs/dataset": "~2.0.2",
|
|
12
12
|
"get-stream": "~9.0.1",
|
|
13
13
|
"into-stream": "~9.1.0"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
},
|
|
36
36
|
"type": "module",
|
|
37
37
|
"types": "./dist/index.d.ts",
|
|
38
|
-
"version": "0.0.
|
|
38
|
+
"version": "0.0.32"
|
|
39
39
|
}
|