@ldo/subscribable-dataset 0.0.1-alpha.17 → 0.0.1-alpha.19
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/ProxyTransactionalDataset.d.ts +2 -2
- package/dist/ProxyTransactionalDataset.js +2 -1
- package/dist/ProxyTransactionalDataset.js.map +1 -1
- package/dist/SubscribableDataset.d.ts +37 -0
- package/dist/SubscribableDataset.js +180 -0
- package/dist/SubscribableDataset.js.map +1 -0
- package/dist/SubscribableDatasetFactory.d.ts +9 -0
- package/dist/SubscribableDatasetFactory.js +15 -0
- package/dist/SubscribableDatasetFactory.js.map +1 -0
- package/dist/TransactionDataset.d.ts +25 -0
- package/dist/TransactionDataset.js +124 -0
- package/dist/TransactionDataset.js.map +1 -0
- package/dist/TransactionDatasetFactory.d.ts +9 -0
- package/dist/TransactionDatasetFactory.js +15 -0
- package/dist/TransactionDatasetFactory.js.map +1 -0
- package/dist/WrapperSubscribableDataset.d.ts +1 -1
- package/dist/WrapperSubscribableDataset.js +4 -6
- package/dist/WrapperSubscribableDataset.js.map +1 -1
- package/dist/WrapperSubscribableDatasetFactory.d.ts +2 -2
- package/dist/WrapperSubscribableDatasetFactory.js +4 -6
- package/dist/WrapperSubscribableDatasetFactory.js.map +1 -1
- package/dist/createSubscribableDataset.d.ts +5 -0
- package/dist/createSubscribableDataset.js +25 -0
- package/dist/createSubscribableDataset.js.map +1 -0
- package/dist/createSubscribableDatasetFromSerializedInput.d.ts +4 -0
- package/dist/createSubscribableDatasetFromSerializedInput.js +11 -0
- package/dist/createSubscribableDatasetFromSerializedInput.js.map +1 -0
- package/dist/createWrapperSubscribableDataset.d.ts +3 -3
- package/dist/createWrapperSubscribableDataset.js +4 -7
- package/dist/createWrapperSubscribableDataset.js.map +1 -1
- package/dist/createWrapperSubscribableDatasetFromSerializedInput.d.ts +2 -2
- package/dist/createWrapperSubscribableDatasetFromSerializedInput.js +3 -2
- package/dist/createWrapperSubscribableDatasetFromSerializedInput.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +9 -15
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +14 -9
- package/dist/util.d.ts +3 -0
- package/dist/util.js +20 -0
- package/dist/util.js.map +1 -0
- package/package.json +2 -2
- package/src/{WrapperSubscribableDataset.ts → SubscribableDataset.ts} +42 -234
- package/src/SubscribableDatasetFactory.ts +31 -0
- package/src/{ProxyTransactionalDataset.ts → TransactionDataset.ts} +10 -43
- package/src/TransactionDatasetFactory.ts +27 -0
- package/src/createSubscribableDataset.ts +46 -0
- package/src/{createWrapperSubscribableDatasetFromSerializedInput.ts → createSubscribableDatasetFromSerializedInput.ts} +6 -6
- package/src/index.ts +7 -8
- package/src/types.ts +35 -12
- package/src/util.ts +27 -0
- package/src/WrapperSubscribableDatasetFactory.ts +0 -27
- package/src/createWrapperSubscribableDataset.ts +0 -30
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSubscribableDataset = exports.createSubscribableDatasetFactory = exports.createTransactionDatasetFactory = void 0;
|
|
4
|
+
const dataset_1 = require("@ldo/dataset");
|
|
5
|
+
const SubscribableDatasetFactory_1 = require("./SubscribableDatasetFactory");
|
|
6
|
+
const TransactionDatasetFactory_1 = require("./TransactionDatasetFactory");
|
|
7
|
+
const datasetFactory = {
|
|
8
|
+
dataset: (quads) => {
|
|
9
|
+
return (0, dataset_1.createDataset)(quads);
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
function createTransactionDatasetFactory() {
|
|
13
|
+
return new TransactionDatasetFactory_1.TransactionDatasetFactory(datasetFactory);
|
|
14
|
+
}
|
|
15
|
+
exports.createTransactionDatasetFactory = createTransactionDatasetFactory;
|
|
16
|
+
function createSubscribableDatasetFactory() {
|
|
17
|
+
return new SubscribableDatasetFactory_1.SubscribableDatasetFactory(datasetFactory, createTransactionDatasetFactory());
|
|
18
|
+
}
|
|
19
|
+
exports.createSubscribableDatasetFactory = createSubscribableDatasetFactory;
|
|
20
|
+
function createSubscribableDataset(quads) {
|
|
21
|
+
const subscribableDatasetFactory = createSubscribableDatasetFactory();
|
|
22
|
+
return subscribableDatasetFactory.dataset(quads);
|
|
23
|
+
}
|
|
24
|
+
exports.createSubscribableDataset = createSubscribableDataset;
|
|
25
|
+
//# sourceMappingURL=createSubscribableDataset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSubscribableDataset.js","sourceRoot":"","sources":["../src/createSubscribableDataset.ts"],"names":[],"mappings":";;;AACA,0CAA6C;AAC7C,6EAA0E;AAM1E,2EAAwE;AAExE,MAAM,cAAc,GAAyB;IAC3C,OAAO,EAAE,CAAC,KAA8B,EAAiB,EAAE;QACzD,OAAO,IAAA,uBAAa,EAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;CACF,CAAC;AAMF,SAAgB,+BAA+B;IAC7C,OAAO,IAAI,qDAAyB,CAAC,cAAc,CAAC,CAAC;AACvD,CAAC;AAFD,0EAEC;AAMD,SAAgB,gCAAgC;IAC9C,OAAO,IAAI,uDAA0B,CACnC,cAAc,EACd,+BAA+B,EAAE,CAClC,CAAC;AACJ,CAAC;AALD,4EAKC;AAOD,SAAgB,yBAAyB,CACvC,KAA8B;IAE9B,MAAM,0BAA0B,GAAG,gCAAgC,EAAE,CAAC;IACtE,OAAO,0BAA0B,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC;AALD,8DAKC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Quad } from "@rdfjs/types";
|
|
2
|
+
import type { ParserOptions } from "@ldo/rdf-utils";
|
|
3
|
+
import type { ISubscribableDataset } from "./types";
|
|
4
|
+
export declare function createWrapperSubscribableDatasetFromSerializedInput(data: string, options?: ParserOptions): Promise<ISubscribableDataset<Quad>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWrapperSubscribableDatasetFromSerializedInput = void 0;
|
|
4
|
+
const dataset_1 = require("@ldo/dataset");
|
|
5
|
+
const createSubscribableDataset_1 = require("./createSubscribableDataset");
|
|
6
|
+
async function createWrapperSubscribableDatasetFromSerializedInput(data, options) {
|
|
7
|
+
const datasetFactory = (0, createSubscribableDataset_1.createSubscribableDatasetFactory)();
|
|
8
|
+
return (0, dataset_1.createDatasetFromSerializedInput)(datasetFactory, data, options);
|
|
9
|
+
}
|
|
10
|
+
exports.createWrapperSubscribableDatasetFromSerializedInput = createWrapperSubscribableDatasetFromSerializedInput;
|
|
11
|
+
//# sourceMappingURL=createSubscribableDatasetFromSerializedInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSubscribableDatasetFromSerializedInput.js","sourceRoot":"","sources":["../src/createSubscribableDatasetFromSerializedInput.ts"],"names":[],"mappings":";;;AAEA,0CAAgE;AAChE,2EAA+E;AAcxE,KAAK,UAAU,mDAAmD,CACvE,IAAY,EACZ,OAAuB;IAEvB,MAAM,cAAc,GAAG,IAAA,4DAAgC,GAAE,CAAC;IAC1D,OAAO,IAAA,0CAAgC,EACrC,cAAc,EACd,IAAI,EACJ,OAAO,CACR,CAAC;AACJ,CAAC;AAVD,kHAUC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dataset, Quad } from "@rdfjs/types";
|
|
2
|
-
import type { WrapperSubscribableDataset } from "
|
|
3
|
-
import WrapperSubscribableDatasetFactory from "./WrapperSubscribableDatasetFactory";
|
|
2
|
+
import type { WrapperSubscribableDataset } from "./WrapperSubscribableDataset";
|
|
3
|
+
import { WrapperSubscribableDatasetFactory } from "./WrapperSubscribableDatasetFactory";
|
|
4
4
|
export declare function createWrapperSubscribableDatasetFactory(): WrapperSubscribableDatasetFactory<Quad>;
|
|
5
|
-
export
|
|
5
|
+
export declare function createWrapperSubscribableDataset(quads?: Dataset<Quad> | Quad[]): WrapperSubscribableDataset<Quad>;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createWrapperSubscribableDatasetFactory = void 0;
|
|
3
|
+
exports.createWrapperSubscribableDataset = exports.createWrapperSubscribableDatasetFactory = void 0;
|
|
7
4
|
const dataset_1 = require("@ldo/dataset");
|
|
8
|
-
const WrapperSubscribableDatasetFactory_1 =
|
|
5
|
+
const WrapperSubscribableDatasetFactory_1 = require("./WrapperSubscribableDatasetFactory");
|
|
9
6
|
function createWrapperSubscribableDatasetFactory() {
|
|
10
7
|
const datasetFactory = {
|
|
11
8
|
dataset: (quads) => {
|
|
12
9
|
return (0, dataset_1.createDataset)(quads);
|
|
13
10
|
},
|
|
14
11
|
};
|
|
15
|
-
return new WrapperSubscribableDatasetFactory_1.
|
|
12
|
+
return new WrapperSubscribableDatasetFactory_1.WrapperSubscribableDatasetFactory(datasetFactory);
|
|
16
13
|
}
|
|
17
14
|
exports.createWrapperSubscribableDatasetFactory = createWrapperSubscribableDatasetFactory;
|
|
18
15
|
function createWrapperSubscribableDataset(quads) {
|
|
19
16
|
const wrapperSubscribableDatasetFactory = createWrapperSubscribableDatasetFactory();
|
|
20
17
|
return wrapperSubscribableDatasetFactory.dataset(quads);
|
|
21
18
|
}
|
|
22
|
-
exports.
|
|
19
|
+
exports.createWrapperSubscribableDataset = createWrapperSubscribableDataset;
|
|
23
20
|
//# sourceMappingURL=createWrapperSubscribableDataset.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWrapperSubscribableDataset.js","sourceRoot":"","sources":["../src/createWrapperSubscribableDataset.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createWrapperSubscribableDataset.js","sourceRoot":"","sources":["../src/createWrapperSubscribableDataset.ts"],"names":[],"mappings":";;;AAEA,0CAA6C;AAC7C,2FAAwF;AAMxF,SAAgB,uCAAuC;IACrD,MAAM,cAAc,GAAyB;QAC3C,OAAO,EAAE,CAAC,KAA8B,EAAiB,EAAE;YACzD,OAAO,IAAA,uBAAa,EAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;IACF,OAAO,IAAI,qEAAiC,CAAC,cAAc,CAAC,CAAC;AAC/D,CAAC;AAPD,0FAOC;AAOD,SAAgB,gCAAgC,CAC9C,KAA8B;IAE9B,MAAM,iCAAiC,GACrC,uCAAuC,EAAE,CAAC;IAC5C,OAAO,iCAAiC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAND,4EAMC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Quad } from "@rdfjs/types";
|
|
2
2
|
import type { ParserOptions } from "@ldo/rdf-utils";
|
|
3
|
-
import type WrapperSubscribableDataset from "./WrapperSubscribableDataset";
|
|
4
|
-
export
|
|
3
|
+
import type { WrapperSubscribableDataset } from "./WrapperSubscribableDataset";
|
|
4
|
+
export declare function createWrapperSubscribableDatasetFromSerializedInput(data: string, options?: ParserOptions): Promise<WrapperSubscribableDataset<Quad>>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWrapperSubscribableDatasetFromSerializedInput = void 0;
|
|
3
4
|
const dataset_1 = require("@ldo/dataset");
|
|
4
5
|
const createWrapperSubscribableDataset_1 = require("./createWrapperSubscribableDataset");
|
|
5
|
-
async function
|
|
6
|
+
async function createWrapperSubscribableDatasetFromSerializedInput(data, options) {
|
|
6
7
|
const datasetFactory = (0, createWrapperSubscribableDataset_1.createWrapperSubscribableDatasetFactory)();
|
|
7
8
|
return (0, dataset_1.createDatasetFromSerializedInput)(datasetFactory, data, options);
|
|
8
9
|
}
|
|
9
|
-
exports.
|
|
10
|
+
exports.createWrapperSubscribableDatasetFromSerializedInput = createWrapperSubscribableDatasetFromSerializedInput;
|
|
10
11
|
//# sourceMappingURL=createWrapperSubscribableDatasetFromSerializedInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWrapperSubscribableDatasetFromSerializedInput.js","sourceRoot":"","sources":["../src/createWrapperSubscribableDatasetFromSerializedInput.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createWrapperSubscribableDatasetFromSerializedInput.js","sourceRoot":"","sources":["../src/createWrapperSubscribableDatasetFromSerializedInput.ts"],"names":[],"mappings":";;;AAEA,0CAAgE;AAChE,yFAA6F;AActF,KAAK,UAAU,mDAAmD,CACvE,IAAY,EACZ,OAAuB;IAEvB,MAAM,cAAc,GAAG,IAAA,0EAAuC,GAAE,CAAC;IACjE,OAAO,IAAA,0CAAgC,EACrC,cAAc,EACd,IAAI,EACJ,OAAO,CACR,CAAC;AACJ,CAAC;AAVD,kHAUC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export * from "./createSubscribableDataset";
|
|
2
|
+
export { createWrapperSubscribableDatasetFromSerializedInput as serializedToSubscribableDataset } from "./createSubscribableDatasetFromSerializedInput";
|
|
3
|
+
export * from "./TransactionDataset";
|
|
4
|
+
export * from "./TransactionDatasetFactory";
|
|
5
|
+
export * from "./SubscribableDataset";
|
|
6
|
+
export * from "./SubscribableDatasetFactory";
|
|
6
7
|
export * from "./types";
|
|
7
8
|
export * from "./mergeDatasetChanges";
|
|
9
|
+
export * from "./util";
|
package/dist/index.js
CHANGED
|
@@ -13,22 +13,16 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Object.defineProperty(exports, "
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var WrapperSubscribableDataset_1 = require("./WrapperSubscribableDataset");
|
|
29
|
-
Object.defineProperty(exports, "WrapperSubscribableDataset", { enumerable: true, get: function () { return __importDefault(WrapperSubscribableDataset_1).default; } });
|
|
30
|
-
var WrapperSubscribableDatasetFactory_1 = require("./WrapperSubscribableDatasetFactory");
|
|
31
|
-
Object.defineProperty(exports, "WrapperSubscribableDatasetFactory", { enumerable: true, get: function () { return __importDefault(WrapperSubscribableDatasetFactory_1).default; } });
|
|
17
|
+
exports.serializedToSubscribableDataset = void 0;
|
|
18
|
+
__exportStar(require("./createSubscribableDataset"), exports);
|
|
19
|
+
var createSubscribableDatasetFromSerializedInput_1 = require("./createSubscribableDatasetFromSerializedInput");
|
|
20
|
+
Object.defineProperty(exports, "serializedToSubscribableDataset", { enumerable: true, get: function () { return createSubscribableDatasetFromSerializedInput_1.createWrapperSubscribableDatasetFromSerializedInput; } });
|
|
21
|
+
__exportStar(require("./TransactionDataset"), exports);
|
|
22
|
+
__exportStar(require("./TransactionDatasetFactory"), exports);
|
|
23
|
+
__exportStar(require("./SubscribableDataset"), exports);
|
|
24
|
+
__exportStar(require("./SubscribableDatasetFactory"), exports);
|
|
32
25
|
__exportStar(require("./types"), exports);
|
|
33
26
|
__exportStar(require("./mergeDatasetChanges"), exports);
|
|
27
|
+
__exportStar(require("./util"), exports);
|
|
34
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,+GAAwJ;AAA/I,+JAAA,mDAAmD,OAAmC;AAC/F,uDAAqC;AACrC,8DAA4C;AAC5C,wDAAsC;AACtC,+DAA6C;AAC7C,0CAAwB;AACxB,wDAAsC;AACtC,yCAAuB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import type { DatasetChanges, QuadMatch } from "@ldo/rdf-utils";
|
|
2
|
-
import type { Dataset, BaseQuad } from "@rdfjs/types";
|
|
2
|
+
import type { Dataset, BaseQuad, DatasetFactory } from "@rdfjs/types";
|
|
3
3
|
export type nodeEventListener<InAndOutQuad extends BaseQuad = BaseQuad> = (changes: DatasetChanges<InAndOutQuad>) => void;
|
|
4
|
-
export interface
|
|
4
|
+
export interface IBulkEditableDataset<InAndOutQuad extends BaseQuad = BaseQuad> extends Dataset<InAndOutQuad, InAndOutQuad> {
|
|
5
5
|
bulk(changes: DatasetChanges<InAndOutQuad>): this;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
commit(): void;
|
|
10
|
-
getChanges(): DatasetChanges<InAndOutQuad>;
|
|
11
|
-
}
|
|
12
|
-
export interface SubscribableDataset<InAndOutQuad extends BaseQuad = BaseQuad> extends BulkEditableDataset<InAndOutQuad> {
|
|
7
|
+
export type ISubscribableDatasetFactory<InAndOutQuad extends BaseQuad = BaseQuad> = DatasetFactory<InAndOutQuad, InAndOutQuad, ISubscribableDataset<InAndOutQuad>>;
|
|
8
|
+
export interface ISubscribableDataset<InAndOutQuad extends BaseQuad = BaseQuad> extends IBulkEditableDataset<InAndOutQuad> {
|
|
13
9
|
addListener(eventName: QuadMatch, listener: nodeEventListener<InAndOutQuad>): this;
|
|
14
10
|
emit(eventName: QuadMatch, changes: DatasetChanges<InAndOutQuad>): boolean;
|
|
15
11
|
eventNames(): QuadMatch[];
|
|
@@ -26,5 +22,14 @@ export interface SubscribableDataset<InAndOutQuad extends BaseQuad = BaseQuad> e
|
|
|
26
22
|
removeListenerFromAllEvents(listener: nodeEventListener<InAndOutQuad>): this;
|
|
27
23
|
setMaxListeners(n: number): this;
|
|
28
24
|
rawListeners(eventName: QuadMatch): nodeEventListener<InAndOutQuad>[];
|
|
29
|
-
startTransaction():
|
|
25
|
+
startTransaction(): ITransactionDataset<InAndOutQuad>;
|
|
26
|
+
}
|
|
27
|
+
export interface ITransactionDatasetFactory<InAndOutQuad extends BaseQuad = BaseQuad> {
|
|
28
|
+
transactionDataset(parent: Dataset<InAndOutQuad, InAndOutQuad>): ITransactionDataset<InAndOutQuad>;
|
|
29
|
+
}
|
|
30
|
+
export interface ITransactionDataset<InAndOutQuad extends BaseQuad = BaseQuad> extends ISubscribableDataset<InAndOutQuad> {
|
|
31
|
+
readonly parentDataset: Dataset<InAndOutQuad, InAndOutQuad>;
|
|
32
|
+
rollback(): void;
|
|
33
|
+
commit(): void;
|
|
34
|
+
getChanges(): DatasetChanges<InAndOutQuad>;
|
|
30
35
|
}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DatasetChanges } from "@ldo/rdf-utils";
|
|
2
|
+
import type { BaseQuad, Dataset } from "@rdfjs/types";
|
|
3
|
+
export declare function updateDatasetInBulk<InAndOutQuad extends BaseQuad = BaseQuad>(dataset: Dataset<InAndOutQuad>, datasetChanges: DatasetChanges<InAndOutQuad>): void;
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateDatasetInBulk = void 0;
|
|
4
|
+
function updateDatasetInBulk(dataset, datasetChanges) {
|
|
5
|
+
if (dataset.bulk) {
|
|
6
|
+
dataset.bulk(datasetChanges);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
if (datasetChanges.added) {
|
|
10
|
+
dataset.addAll(datasetChanges.added);
|
|
11
|
+
}
|
|
12
|
+
if (datasetChanges.removed) {
|
|
13
|
+
datasetChanges.removed.forEach((curQuad) => {
|
|
14
|
+
dataset.delete(curQuad);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.updateDatasetInBulk = updateDatasetInBulk;
|
|
20
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AASA,SAAgB,mBAAmB,CACjC,OAA8B,EAC9B,cAA4C;IAG5C,IAAK,OAAe,CAAC,IAAI,EAAE;QACxB,OAA8C,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;KACtE;SAAM;QACL,IAAI,cAAc,CAAC,KAAK,EAAE;YACxB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;SACtC;QACD,IAAI,cAAc,CAAC,OAAO,EAAE;YAC1B,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBACzC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;SACJ;KACF;AACH,CAAC;AAjBD,kDAiBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/subscribable-dataset",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.19",
|
|
4
4
|
"description": "An RDFJS dataset implementation that can be subscribed to for updates",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "c21144a5552978622d05c3f1db4a3b68d304813c"
|
|
47
47
|
}
|
|
@@ -8,40 +8,36 @@ import type {
|
|
|
8
8
|
ObjectNode,
|
|
9
9
|
GraphNode,
|
|
10
10
|
} from "@ldo/rdf-utils";
|
|
11
|
-
import type {
|
|
12
|
-
Dataset,
|
|
13
|
-
BaseQuad,
|
|
14
|
-
Stream,
|
|
15
|
-
Term,
|
|
16
|
-
DatasetFactory,
|
|
17
|
-
} from "@rdfjs/types";
|
|
11
|
+
import type { Dataset, BaseQuad, Term, DatasetFactory } from "@rdfjs/types";
|
|
18
12
|
import type {
|
|
19
13
|
nodeEventListener,
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
ISubscribableDataset,
|
|
15
|
+
ITransactionDataset,
|
|
16
|
+
ITransactionDatasetFactory,
|
|
22
17
|
} from "./types";
|
|
23
|
-
import
|
|
18
|
+
import { ExtendedDataset } from "@ldo/dataset";
|
|
24
19
|
|
|
25
20
|
/**
|
|
26
21
|
* A wrapper for a dataset that allows subscriptions to be made on nodes to
|
|
27
22
|
* be triggered whenever a quad containing that added or removed.
|
|
28
23
|
*/
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
export class SubscribableDataset<InAndOutQuad extends BaseQuad = BaseQuad>
|
|
25
|
+
extends ExtendedDataset<InAndOutQuad>
|
|
26
|
+
implements ISubscribableDataset<InAndOutQuad>
|
|
32
27
|
{
|
|
33
28
|
/**
|
|
34
|
-
*
|
|
29
|
+
* DatasetFactory for creating new datasets
|
|
35
30
|
*/
|
|
36
|
-
|
|
31
|
+
protected datasetFactory: DatasetFactory<InAndOutQuad>;
|
|
32
|
+
|
|
37
33
|
/**
|
|
38
|
-
* The underlying
|
|
34
|
+
* The underlying event emitter
|
|
39
35
|
*/
|
|
40
|
-
|
|
36
|
+
protected eventEmitter: EventEmitter;
|
|
41
37
|
/**
|
|
42
|
-
* The underlying
|
|
38
|
+
* The underlying dataset factory for creating transaction datasets
|
|
43
39
|
*/
|
|
44
|
-
|
|
40
|
+
protected transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>;
|
|
45
41
|
/**
|
|
46
42
|
* Helps find all the events for a given listener
|
|
47
43
|
*/
|
|
@@ -49,17 +45,18 @@ export default class WrapperSubscribableDataset<
|
|
|
49
45
|
new Map();
|
|
50
46
|
|
|
51
47
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param
|
|
54
|
-
* @param initialDataset
|
|
48
|
+
* @param datasetFactory A RDF/JS Dataset Factory
|
|
49
|
+
* @param initialDataset An RDF/JS Dataset with initial Quads
|
|
55
50
|
*/
|
|
56
51
|
constructor(
|
|
57
52
|
datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>,
|
|
53
|
+
transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>,
|
|
58
54
|
initialDataset?: Dataset<InAndOutQuad, InAndOutQuad>,
|
|
59
55
|
) {
|
|
60
|
-
|
|
61
|
-
this.
|
|
56
|
+
super(initialDataset || datasetFactory.dataset(), datasetFactory);
|
|
57
|
+
this.transactionDatasetFactory = transactionDatasetFactory;
|
|
62
58
|
this.eventEmitter = new EventEmitter();
|
|
59
|
+
this.datasetFactory = datasetFactory;
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
/**
|
|
@@ -68,6 +65,18 @@ export default class WrapperSubscribableDataset<
|
|
|
68
65
|
* ==================================================================
|
|
69
66
|
*/
|
|
70
67
|
|
|
68
|
+
/**
|
|
69
|
+
* A helper method that mimics what the super of addAll would be
|
|
70
|
+
*/
|
|
71
|
+
private superAddAll(
|
|
72
|
+
quads: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[],
|
|
73
|
+
): this {
|
|
74
|
+
for (const quad of quads) {
|
|
75
|
+
super.add(quad);
|
|
76
|
+
}
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
/**
|
|
72
81
|
* Imports the quads into this dataset.
|
|
73
82
|
* This method differs from Dataset.union in that it adds all quads to the current instance, rather than combining quads and the current instance to create a new instance.
|
|
@@ -77,7 +86,7 @@ export default class WrapperSubscribableDataset<
|
|
|
77
86
|
public addAll(
|
|
78
87
|
quads: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[],
|
|
79
88
|
): this {
|
|
80
|
-
this.
|
|
89
|
+
this.superAddAll(quads);
|
|
81
90
|
this.triggerSubscriptionForQuads({
|
|
82
91
|
added: this.datasetFactory.dataset(quads),
|
|
83
92
|
});
|
|
@@ -90,26 +99,17 @@ export default class WrapperSubscribableDataset<
|
|
|
90
99
|
*/
|
|
91
100
|
public bulk(changed: DatasetChanges<InAndOutQuad>): this {
|
|
92
101
|
if (changed.added) {
|
|
93
|
-
this.
|
|
102
|
+
this.superAddAll(changed.added);
|
|
94
103
|
}
|
|
95
104
|
if (changed.removed) {
|
|
96
105
|
changed.removed.forEach((quad) => {
|
|
97
|
-
|
|
106
|
+
super.delete(quad);
|
|
98
107
|
});
|
|
99
108
|
}
|
|
100
109
|
this.triggerSubscriptionForQuads(changed);
|
|
101
110
|
return this;
|
|
102
111
|
}
|
|
103
112
|
|
|
104
|
-
/**
|
|
105
|
-
* Returns true if the current instance is a superset of the given dataset; differently put: if the given dataset is a subset of, is contained in the current dataset.
|
|
106
|
-
* Blank Nodes will be normalized.
|
|
107
|
-
* @param other
|
|
108
|
-
*/
|
|
109
|
-
public contains(other: Dataset<InAndOutQuad, InAndOutQuad>): boolean {
|
|
110
|
-
return this.dataset.contains(other);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
113
|
/**
|
|
114
114
|
* This method removes the quads in the current instance that match the given arguments. The logic described in Quad Matching is applied for each quad in this dataset to select the quads which will be deleted.
|
|
115
115
|
* @param subject
|
|
@@ -124,191 +124,14 @@ export default class WrapperSubscribableDataset<
|
|
|
124
124
|
object?: Term,
|
|
125
125
|
graph?: Term,
|
|
126
126
|
): this {
|
|
127
|
-
const matching =
|
|
127
|
+
const matching = super.match(subject, predicate, object, graph);
|
|
128
128
|
for (const quad of matching) {
|
|
129
|
-
|
|
129
|
+
super.delete(quad);
|
|
130
130
|
}
|
|
131
131
|
this.triggerSubscriptionForQuads({ removed: matching });
|
|
132
132
|
return this;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
/**
|
|
136
|
-
* Returns a new dataset that contains alls quads from the current dataset, not included in the given dataset.
|
|
137
|
-
* @param other
|
|
138
|
-
*/
|
|
139
|
-
public difference(
|
|
140
|
-
other: Dataset<InAndOutQuad, InAndOutQuad>,
|
|
141
|
-
): Dataset<InAndOutQuad, InAndOutQuad> {
|
|
142
|
-
return this.dataset.difference(other);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Returns true if the current instance contains the same graph structure as the given dataset.
|
|
147
|
-
* @param other
|
|
148
|
-
*/
|
|
149
|
-
public equals(other: Dataset<InAndOutQuad, InAndOutQuad>): boolean {
|
|
150
|
-
return this.dataset.equals(other);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Universal quantification method, tests whether every quad in the dataset passes the test implemented by the provided iteratee.
|
|
155
|
-
* This method immediately returns boolean false once a quad that does not pass the test is found.
|
|
156
|
-
* This method always returns boolean true on an empty dataset.
|
|
157
|
-
* Note: This method is aligned with Array.prototype.every() in ECMAScript-262.
|
|
158
|
-
* @param iteratee
|
|
159
|
-
*/
|
|
160
|
-
public every(
|
|
161
|
-
iteratee: (quad: InAndOutQuad, dataset: this) => boolean,
|
|
162
|
-
): boolean {
|
|
163
|
-
return this.dataset.every((quad) => iteratee(quad, this));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Creates a new dataset with all the quads that pass the test implemented by the provided iteratee.
|
|
168
|
-
* Note: This method is aligned with Array.prototype.filter() in ECMAScript-262.
|
|
169
|
-
* @param iteratee
|
|
170
|
-
*/
|
|
171
|
-
public filter(
|
|
172
|
-
iteratee: (quad: InAndOutQuad, dataset: this) => boolean,
|
|
173
|
-
): Dataset<InAndOutQuad, InAndOutQuad> {
|
|
174
|
-
return this.dataset.filter((quad) => iteratee(quad, this));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Executes the provided iteratee once on each quad in the dataset.
|
|
179
|
-
* Note: This method is aligned with Array.prototype.forEach() in ECMAScript-262.
|
|
180
|
-
* @param iteratee
|
|
181
|
-
*/
|
|
182
|
-
public forEach(iteratee: (quad: InAndOutQuad, dataset: this) => void): void {
|
|
183
|
-
return this.dataset.forEach((quad) => iteratee(quad, this));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Imports all quads from the given stream into the dataset.
|
|
188
|
-
* The stream events end and error are wrapped in a Promise.
|
|
189
|
-
* @param stream
|
|
190
|
-
*/
|
|
191
|
-
public async import(stream: Stream<InAndOutQuad>): Promise<this> {
|
|
192
|
-
await this.dataset.import(stream);
|
|
193
|
-
return this;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Returns a new dataset containing alls quads from the current dataset that are also included in the given dataset.
|
|
198
|
-
* @param other
|
|
199
|
-
*/
|
|
200
|
-
// Typescript disabled because rdf-js has incorrect typings
|
|
201
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
202
|
-
// @ts-ignore
|
|
203
|
-
public intersection(
|
|
204
|
-
other: Dataset<InAndOutQuad, InAndOutQuad>,
|
|
205
|
-
): Dataset<InAndOutQuad, InAndOutQuad> {
|
|
206
|
-
return this.dataset.intersection(other);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Returns a new dataset containing all quads returned by applying iteratee to each quad in the current dataset.
|
|
211
|
-
* @param iteratee
|
|
212
|
-
*/
|
|
213
|
-
public map(
|
|
214
|
-
iteratee: (quad: InAndOutQuad, dataset: this) => InAndOutQuad,
|
|
215
|
-
): Dataset<InAndOutQuad, InAndOutQuad> {
|
|
216
|
-
return this.dataset.map((quad) => iteratee(quad, this));
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* This method calls the iteratee on each quad of the DatasetCore. The first time the iteratee is called, the accumulator value is the initialValue or, if not given, equals to the first quad of the Dataset. The return value of the iteratee is used as accumulator value for the next calls.
|
|
221
|
-
* This method returns the return value of the last iteratee call.
|
|
222
|
-
* Note: This method is aligned with Array.prototype.reduce() in ECMAScript-262.
|
|
223
|
-
* @param iteratee
|
|
224
|
-
* @param initialValue
|
|
225
|
-
*/
|
|
226
|
-
public reduce<A = unknown>(
|
|
227
|
-
iteratee: (accumulator: A, quad: InAndOutQuad, dataset: this) => A,
|
|
228
|
-
initialValue?: A,
|
|
229
|
-
): A {
|
|
230
|
-
return this.dataset.reduce(
|
|
231
|
-
(acc, quad) => iteratee(acc, quad, this),
|
|
232
|
-
initialValue,
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Existential quantification method, tests whether some quads in the dataset pass the test implemented by the provided iteratee.
|
|
238
|
-
* Note: This method is aligned with Array.prototype.some() in ECMAScript-262.
|
|
239
|
-
* @param iteratee
|
|
240
|
-
* @returns boolean true once a quad that passes the test is found.
|
|
241
|
-
*/
|
|
242
|
-
public some(
|
|
243
|
-
iteratee: (quad: InAndOutQuad, dataset: this) => boolean,
|
|
244
|
-
): boolean {
|
|
245
|
-
return this.dataset.some((quad) => iteratee(quad, this));
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Returns the set of quads within the dataset as a host language native sequence, for example an Array in ECMAScript-262.
|
|
250
|
-
* Note: Since a DatasetCore is an unordered set, the order of the quads within the returned sequence is arbitrary.
|
|
251
|
-
*/
|
|
252
|
-
public toArray(): InAndOutQuad[] {
|
|
253
|
-
return this.dataset.toArray();
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Returns an N-Quads string representation of the dataset, preprocessed with RDF Dataset Normalization algorithm.
|
|
258
|
-
*/
|
|
259
|
-
public toCanonical(): string {
|
|
260
|
-
return this.dataset.toCanonical();
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Returns a stream that contains all quads of the dataset.
|
|
265
|
-
*/
|
|
266
|
-
public toStream(): Stream<InAndOutQuad> {
|
|
267
|
-
return this.dataset.toStream();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Returns an N-Quads string representation of the dataset.
|
|
272
|
-
* No prior normalization is required, therefore the results for the same quads may vary depending on the Dataset implementation.
|
|
273
|
-
*/
|
|
274
|
-
public toString(): string {
|
|
275
|
-
return this.dataset.toString();
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Returns a new Dataset that is a concatenation of this dataset and the quads given as an argument.
|
|
280
|
-
* @param other
|
|
281
|
-
*/
|
|
282
|
-
public union(
|
|
283
|
-
quads: Dataset<InAndOutQuad, InAndOutQuad>,
|
|
284
|
-
): Dataset<InAndOutQuad, InAndOutQuad> {
|
|
285
|
-
return this.dataset.union(quads);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* This method returns a new dataset that is comprised of all quads in the current instance matching the given arguments. The logic described in Quad Matching is applied for each quad in this dataset to check if it should be included in the output dataset.
|
|
290
|
-
* @param subject
|
|
291
|
-
* @param predicate
|
|
292
|
-
* @param object
|
|
293
|
-
* @param graph
|
|
294
|
-
* @returns a Dataset with matching triples
|
|
295
|
-
*/
|
|
296
|
-
public match(
|
|
297
|
-
subject?: Term | null,
|
|
298
|
-
predicate?: Term | null,
|
|
299
|
-
object?: Term | null,
|
|
300
|
-
graph?: Term | null,
|
|
301
|
-
): Dataset<InAndOutQuad, InAndOutQuad> {
|
|
302
|
-
return this.dataset.match(subject, predicate, object, graph);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* A non-negative integer that specifies the number of quads in the set.
|
|
307
|
-
*/
|
|
308
|
-
public get size(): number {
|
|
309
|
-
return this.dataset.size;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
135
|
/**
|
|
313
136
|
* Adds the specified quad to the dataset.
|
|
314
137
|
* Existing quads, as defined in Quad.equals, will be ignored.
|
|
@@ -316,7 +139,7 @@ export default class WrapperSubscribableDataset<
|
|
|
316
139
|
* @returns the dataset instance it was called on.
|
|
317
140
|
*/
|
|
318
141
|
public add(quad: InAndOutQuad): this {
|
|
319
|
-
|
|
142
|
+
super.add(quad);
|
|
320
143
|
this.triggerSubscriptionForQuads({
|
|
321
144
|
added: this.datasetFactory.dataset([quad]),
|
|
322
145
|
});
|
|
@@ -329,28 +152,13 @@ export default class WrapperSubscribableDataset<
|
|
|
329
152
|
* @param quad
|
|
330
153
|
*/
|
|
331
154
|
public delete(quad: InAndOutQuad): this {
|
|
332
|
-
|
|
155
|
+
super.delete(quad);
|
|
333
156
|
this.triggerSubscriptionForQuads({
|
|
334
157
|
removed: this.datasetFactory.dataset([quad]),
|
|
335
158
|
});
|
|
336
159
|
return this;
|
|
337
160
|
}
|
|
338
161
|
|
|
339
|
-
/**
|
|
340
|
-
* Determines whether a dataset includes a certain quad, returning true or false as appropriate.
|
|
341
|
-
* @param quad
|
|
342
|
-
*/
|
|
343
|
-
public has(quad: InAndOutQuad): boolean {
|
|
344
|
-
return this.dataset.has(quad);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Returns an iterator
|
|
349
|
-
*/
|
|
350
|
-
public [Symbol.iterator](): Iterator<InAndOutQuad, unknown, undefined> {
|
|
351
|
-
return this.dataset[Symbol.iterator]();
|
|
352
|
-
}
|
|
353
|
-
|
|
354
162
|
/**
|
|
355
163
|
* ==================================================================
|
|
356
164
|
* EVENTEMITTER METHODS
|
|
@@ -610,7 +418,7 @@ export default class WrapperSubscribableDataset<
|
|
|
610
418
|
/**
|
|
611
419
|
* Returns a transactional dataset that will update this dataset when its transaction is committed.
|
|
612
420
|
*/
|
|
613
|
-
public startTransaction():
|
|
614
|
-
return
|
|
421
|
+
public startTransaction(): ITransactionDataset<InAndOutQuad> {
|
|
422
|
+
return this.transactionDatasetFactory.transactionDataset(this);
|
|
615
423
|
}
|
|
616
424
|
}
|