@ldo/subscribable-dataset 1.0.0-alpha.32 → 1.0.0-alpha.36
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/SubscribableDataset.cjs +373 -0
- package/dist/SubscribableDataset.d.cts +172 -0
- package/dist/SubscribableDataset.d.cts.map +1 -0
- package/dist/SubscribableDataset.d.ts +172 -0
- package/dist/SubscribableDataset.d.ts.map +1 -0
- package/dist/SubscribableDataset.js +373 -0
- package/dist/SubscribableDataset.js.map +1 -0
- package/dist/SubscribableDatasetFactory.cjs +20 -0
- package/dist/SubscribableDatasetFactory.d.cts +20 -0
- package/dist/SubscribableDatasetFactory.d.cts.map +1 -0
- package/dist/SubscribableDatasetFactory.d.ts +20 -0
- package/dist/SubscribableDatasetFactory.d.ts.map +1 -0
- package/dist/SubscribableDatasetFactory.js +21 -0
- package/dist/SubscribableDatasetFactory.js.map +1 -0
- package/dist/TransactionDataset.cjs +211 -0
- package/dist/TransactionDataset.d.cts +133 -0
- package/dist/TransactionDataset.d.cts.map +1 -0
- package/dist/TransactionDataset.d.ts +133 -0
- package/dist/TransactionDataset.d.ts.map +1 -0
- package/dist/TransactionDataset.js +212 -0
- package/dist/TransactionDataset.js.map +1 -0
- package/dist/TransactionDatasetFactory.cjs +17 -0
- package/dist/TransactionDatasetFactory.d.cts +16 -0
- package/dist/TransactionDatasetFactory.d.cts.map +1 -0
- package/dist/TransactionDatasetFactory.d.ts +16 -0
- package/dist/TransactionDatasetFactory.d.ts.map +1 -0
- package/dist/TransactionDatasetFactory.js +18 -0
- package/dist/TransactionDatasetFactory.js.map +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/createSubscribableDataset.cjs +37 -0
- package/dist/createSubscribableDataset.d.cts +26 -0
- package/dist/createSubscribableDataset.d.cts.map +1 -0
- package/dist/createSubscribableDataset.d.ts +26 -0
- package/dist/createSubscribableDataset.d.ts.map +1 -0
- package/dist/createSubscribableDataset.js +35 -0
- package/dist/createSubscribableDataset.js.map +1 -0
- package/dist/createSubscribableDatasetFromSerializedInput.cjs +23 -0
- package/dist/createSubscribableDatasetFromSerializedInput.d.cts +22 -0
- package/dist/createSubscribableDatasetFromSerializedInput.d.cts.map +1 -0
- package/dist/createSubscribableDatasetFromSerializedInput.d.ts +22 -0
- package/dist/createSubscribableDatasetFromSerializedInput.d.ts.map +1 -0
- package/dist/createSubscribableDatasetFromSerializedInput.js +23 -0
- package/dist/createSubscribableDatasetFromSerializedInput.js.map +1 -0
- package/dist/index.cjs +19 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/mergeDatasetChanges.cjs +26 -0
- package/dist/mergeDatasetChanges.d.cts +16 -0
- package/dist/mergeDatasetChanges.d.cts.map +1 -0
- package/dist/mergeDatasetChanges.d.ts +16 -0
- package/dist/mergeDatasetChanges.d.ts.map +1 -0
- package/dist/mergeDatasetChanges.js +26 -0
- package/dist/mergeDatasetChanges.js.map +1 -0
- package/dist/types.d.cts +125 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +125 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/util.cjs +19 -0
- package/dist/util.d.cts +16 -0
- package/dist/util.d.cts.map +1 -0
- package/dist/util.d.ts +16 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +19 -0
- package/dist/util.js.map +1 -0
- package/package.json +19 -16
- package/src/SubscribableDataset.ts +1 -1
- package/src/SubscribableDatasetFactory.ts +2 -2
- package/src/TransactionDataset.ts +4 -7
- package/src/TransactionDatasetFactory.ts +2 -2
- package/src/createSubscribableDataset.ts +3 -3
- package/src/createSubscribableDatasetFromSerializedInput.ts +2 -2
- package/src/index.ts +9 -9
- package/src/util.ts +1 -1
- package/dist/cjs/SubscribableDataset.cjs +0 -313
- package/dist/cjs/SubscribableDataset.js.map +0 -1
- package/dist/cjs/SubscribableDatasetFactory.cjs +0 -18
- package/dist/cjs/SubscribableDatasetFactory.js.map +0 -1
- package/dist/cjs/TransactionDataset.cjs +0 -219
- package/dist/cjs/TransactionDataset.js.map +0 -1
- package/dist/cjs/TransactionDatasetFactory.cjs +0 -15
- package/dist/cjs/TransactionDatasetFactory.js.map +0 -1
- package/dist/cjs/createSubscribableDataset.cjs +0 -37
- package/dist/cjs/createSubscribableDataset.js.map +0 -1
- package/dist/cjs/createSubscribableDatasetFromSerializedInput.cjs +0 -21
- package/dist/cjs/createSubscribableDatasetFromSerializedInput.js.map +0 -1
- package/dist/cjs/index.cjs +0 -28
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/mergeDatasetChanges.cjs +0 -48
- package/dist/cjs/mergeDatasetChanges.js.map +0 -1
- package/dist/cjs/types.cjs +0 -3
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/util.cjs +0 -25
- package/dist/cjs/util.js.map +0 -1
- package/dist/esm/SubscribableDataset.js +0 -309
- package/dist/esm/SubscribableDataset.js.map +0 -1
- package/dist/esm/SubscribableDatasetFactory.js +0 -14
- package/dist/esm/SubscribableDatasetFactory.js.map +0 -1
- package/dist/esm/TransactionDataset.js +0 -215
- package/dist/esm/TransactionDataset.js.map +0 -1
- package/dist/esm/TransactionDatasetFactory.js +0 -11
- package/dist/esm/TransactionDatasetFactory.js.map +0 -1
- package/dist/esm/createSubscribableDataset.js +0 -32
- package/dist/esm/createSubscribableDataset.js.map +0 -1
- package/dist/esm/createSubscribableDatasetFromSerializedInput.js +0 -18
- package/dist/esm/createSubscribableDatasetFromSerializedInput.js.map +0 -1
- package/dist/esm/index.js +0 -10
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/mergeDatasetChanges.js +0 -45
- package/dist/esm/mergeDatasetChanges.js.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/util.js +0 -22
- package/dist/esm/util.js.map +0 -1
- package/dist/types/SubscribableDataset.d.ts +0 -166
- package/dist/types/SubscribableDataset.d.ts.map +0 -1
- package/dist/types/SubscribableDatasetFactory.d.ts +0 -13
- package/dist/types/SubscribableDatasetFactory.d.ts.map +0 -1
- package/dist/types/TransactionDataset.d.ts +0 -127
- package/dist/types/TransactionDataset.d.ts.map +0 -1
- package/dist/types/TransactionDatasetFactory.d.ts +0 -10
- package/dist/types/TransactionDatasetFactory.d.ts.map +0 -1
- package/dist/types/createSubscribableDataset.d.ts +0 -19
- package/dist/types/createSubscribableDataset.d.ts.map +0 -1
- package/dist/types/createSubscribableDatasetFromSerializedInput.d.ts +0 -16
- package/dist/types/createSubscribableDatasetFromSerializedInput.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/mergeDatasetChanges.d.ts +0 -9
- package/dist/types/mergeDatasetChanges.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -119
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/util.d.ts +0 -9
- package/dist/types/util.d.ts.map +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SubscribableDataset } from "./SubscribableDataset.js";
|
|
2
|
+
|
|
3
|
+
//#region src/SubscribableDatasetFactory.ts
|
|
4
|
+
/**
|
|
5
|
+
* A DatasetFactory that returns a SubscribableDataset given a generic DatasetFactory.
|
|
6
|
+
*/
|
|
7
|
+
var SubscribableDatasetFactory = class {
|
|
8
|
+
datasetFactory;
|
|
9
|
+
transactionDatasetFactory;
|
|
10
|
+
constructor(datasetFactory, transactionDatasetFactory) {
|
|
11
|
+
this.datasetFactory = datasetFactory;
|
|
12
|
+
this.transactionDatasetFactory = transactionDatasetFactory;
|
|
13
|
+
}
|
|
14
|
+
dataset(quads) {
|
|
15
|
+
return new SubscribableDataset(this.datasetFactory, this.transactionDatasetFactory, quads ? this.datasetFactory.dataset(quads) : void 0);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { SubscribableDatasetFactory };
|
|
21
|
+
//# sourceMappingURL=SubscribableDatasetFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscribableDatasetFactory.js","names":["datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>","transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>","quads?: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[]"],"sources":["../src/SubscribableDatasetFactory.ts"],"sourcesContent":["import type { DatasetFactory, BaseQuad, Dataset } from \"@rdfjs/types\";\nimport type { ITransactionDatasetFactory } from \"./types\";\nimport { SubscribableDataset } from \"./SubscribableDataset\";\n\n/**\n * A DatasetFactory that returns a SubscribableDataset given a generic DatasetFactory.\n */\nexport class SubscribableDatasetFactory<\n InAndOutQuad extends BaseQuad = BaseQuad,\n> implements DatasetFactory<InAndOutQuad, InAndOutQuad>\n{\n protected datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>;\n protected transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>;\n constructor(\n datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>,\n transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>,\n ) {\n this.datasetFactory = datasetFactory;\n this.transactionDatasetFactory = transactionDatasetFactory;\n }\n\n dataset(\n quads?: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[],\n ): SubscribableDataset<InAndOutQuad> {\n return new SubscribableDataset(\n this.datasetFactory,\n this.transactionDatasetFactory,\n quads ? this.datasetFactory.dataset(quads) : undefined,\n );\n }\n}\n"],"mappings":";;;;;;AAOA,IAAa,6BAAb,MAGA;CACE,AAAU;CACV,AAAU;CACV,YACEA,gBACAC,2BACA;AACA,OAAK,iBAAiB;AACtB,OAAK,4BAA4B;CAClC;CAED,QACEC,OACmC;AACnC,SAAO,IAAI,oBACT,KAAK,gBACL,KAAK,2BACL,QAAQ,KAAK,eAAe,QAAQ,MAAM;CAE7C;AACF"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
const require__Users_jacksonmorgan_O_ldo_packages_subscribable_dataset_src_SubscribableDataset = require('./SubscribableDataset.cjs');
|
|
2
|
+
const require__Users_jacksonmorgan_O_ldo_packages_subscribable_dataset_src_mergeDatasetChanges = require('./mergeDatasetChanges.cjs');
|
|
3
|
+
const require__Users_jacksonmorgan_O_ldo_packages_subscribable_dataset_src_util = require('./util.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/TransactionDataset.ts
|
|
6
|
+
/**
|
|
7
|
+
* Proxy Transactional Dataset is a transactional dataset that does not duplicate
|
|
8
|
+
* the parent dataset, it will dynamically determine the correct return value for
|
|
9
|
+
* methods in real time when the method is called.
|
|
10
|
+
*/
|
|
11
|
+
var TransactionDataset = class extends require__Users_jacksonmorgan_O_ldo_packages_subscribable_dataset_src_SubscribableDataset.SubscribableDataset {
|
|
12
|
+
/**
|
|
13
|
+
* The parent dataset that will be updated upon commit
|
|
14
|
+
*/
|
|
15
|
+
parentDataset;
|
|
16
|
+
/**
|
|
17
|
+
* The changes made that are ready to commit
|
|
18
|
+
*/
|
|
19
|
+
datasetChanges;
|
|
20
|
+
/**
|
|
21
|
+
* A list of changes made to the parent dataset upon commit used for rolling back changes.
|
|
22
|
+
* This is different from 'datasetChanges' because datasetChanges is allowed to overlap
|
|
23
|
+
* with the parent dataset.
|
|
24
|
+
* For example, the parent dataset may already have triple A, and datasetChanges can
|
|
25
|
+
* also have triple A.
|
|
26
|
+
*/
|
|
27
|
+
committedDatasetChanges;
|
|
28
|
+
/**
|
|
29
|
+
* Constructor
|
|
30
|
+
* @param parentDataset The dataset that will be updated upon commit
|
|
31
|
+
*/
|
|
32
|
+
constructor(parentDataset, datasetFactory, transactionDatasetFactory) {
|
|
33
|
+
super(datasetFactory, transactionDatasetFactory, datasetFactory.dataset());
|
|
34
|
+
this.parentDataset = parentDataset;
|
|
35
|
+
this.datasetChanges = {};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* ==================================================================
|
|
39
|
+
* DATASET METHODS
|
|
40
|
+
* ==================================================================
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* Imports the quads into this dataset.
|
|
44
|
+
* 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.
|
|
45
|
+
* @param quads
|
|
46
|
+
* @returns the dataset instance it was called on.
|
|
47
|
+
*/
|
|
48
|
+
addAll(quads) {
|
|
49
|
+
this.updateDatasetChanges({ added: quads });
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Bulk add and remove triples
|
|
54
|
+
* @param changed
|
|
55
|
+
*/
|
|
56
|
+
bulk(changes) {
|
|
57
|
+
this.updateDatasetChanges(changes);
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 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.
|
|
62
|
+
* @param subject
|
|
63
|
+
* @param predicate
|
|
64
|
+
* @param object
|
|
65
|
+
* @param graph
|
|
66
|
+
* @returns the dataset instance it was called on.
|
|
67
|
+
*/
|
|
68
|
+
deleteMatches(subject, predicate, object, graph) {
|
|
69
|
+
this.checkIfTransactionCommitted();
|
|
70
|
+
const matching = this.match(subject, predicate, object, graph);
|
|
71
|
+
for (const quad of matching) this.delete(quad);
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 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.
|
|
76
|
+
* @param subject
|
|
77
|
+
* @param predicate
|
|
78
|
+
* @param object
|
|
79
|
+
* @param graph
|
|
80
|
+
* @returns a Dataset with matching triples
|
|
81
|
+
*/
|
|
82
|
+
match(subject, predicate, object, graph) {
|
|
83
|
+
let finalMatch = this.parentDataset.match(subject, predicate, object, graph);
|
|
84
|
+
if (this.datasetChanges.removed) finalMatch = finalMatch.difference(this.datasetChanges.removed);
|
|
85
|
+
if (this.datasetChanges.added) finalMatch = finalMatch.union(this.datasetChanges.added.match(subject, predicate, object, graph));
|
|
86
|
+
return finalMatch;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A non-negative integer that specifies the number of quads in the set.
|
|
90
|
+
*/
|
|
91
|
+
get size() {
|
|
92
|
+
return this.parentDataset.size + (this.datasetChanges.added?.difference(this.parentDataset).size || 0) - (this.datasetChanges.removed?.intersection(this.parentDataset).size || 0);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Adds the specified quad to the dataset.
|
|
96
|
+
* Existing quads, as defined in Quad.equals, will be ignored.
|
|
97
|
+
* @param quad
|
|
98
|
+
* @returns the dataset instance it was called on.
|
|
99
|
+
*/
|
|
100
|
+
add(quad) {
|
|
101
|
+
this.updateDatasetChanges({ added: [quad] });
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Removes the specified quad from the dataset.
|
|
106
|
+
* This method returns the dataset instance it was called on.
|
|
107
|
+
* @param quad
|
|
108
|
+
*/
|
|
109
|
+
delete(quad) {
|
|
110
|
+
this.updateDatasetChanges({ removed: [quad] });
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Determines whether a dataset includes a certain quad, returning true or false as appropriate.
|
|
115
|
+
* @param quad
|
|
116
|
+
*/
|
|
117
|
+
has(quad) {
|
|
118
|
+
return !this.datasetChanges.removed?.has(quad) && (this.datasetChanges.added?.has(quad) || this.parentDataset.has(quad));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns an iterator
|
|
122
|
+
*/
|
|
123
|
+
[Symbol.iterator]() {
|
|
124
|
+
const addedIterator = (this.datasetChanges.added || [])[Symbol.iterator]();
|
|
125
|
+
let addedNext = addedIterator.next();
|
|
126
|
+
const parentIterator = this.parentDataset[Symbol.iterator]();
|
|
127
|
+
let parentNext = parentIterator.next();
|
|
128
|
+
return { next: () => {
|
|
129
|
+
if (!addedNext || !addedNext.done) {
|
|
130
|
+
const toReturn = addedNext;
|
|
131
|
+
addedNext = addedIterator.next();
|
|
132
|
+
return toReturn;
|
|
133
|
+
}
|
|
134
|
+
while (!parentNext.done) {
|
|
135
|
+
const toReturn = parentNext;
|
|
136
|
+
parentNext = parentIterator.next();
|
|
137
|
+
if (!(this.datasetChanges.added && this.datasetChanges.added.has(toReturn.value)) && !(this.datasetChanges.removed && this.datasetChanges.removed.has(toReturn.value))) return toReturn;
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
value: void 0,
|
|
141
|
+
done: true
|
|
142
|
+
};
|
|
143
|
+
} };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* ==================================================================
|
|
147
|
+
* TANSACTIONAL METHODS
|
|
148
|
+
* ==================================================================
|
|
149
|
+
*/
|
|
150
|
+
/**
|
|
151
|
+
* Checks if the transaction has been committed and throws an error if it has
|
|
152
|
+
* @param changed
|
|
153
|
+
*/
|
|
154
|
+
checkIfTransactionCommitted() {
|
|
155
|
+
if (this.committedDatasetChanges) throw new Error("Transaction has already committed");
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Helper method to update the changes made
|
|
159
|
+
* @param changes
|
|
160
|
+
*/
|
|
161
|
+
updateDatasetChanges(changes) {
|
|
162
|
+
this.checkIfTransactionCommitted();
|
|
163
|
+
const newDatasetChanges = {
|
|
164
|
+
added: changes.added ? this.datasetFactory.dataset(changes.added) : void 0,
|
|
165
|
+
removed: changes.removed ? this.datasetFactory.dataset(changes.removed) : void 0
|
|
166
|
+
};
|
|
167
|
+
require__Users_jacksonmorgan_O_ldo_packages_subscribable_dataset_src_mergeDatasetChanges.mergeDatasetChanges(this.datasetChanges, newDatasetChanges);
|
|
168
|
+
this.triggerSubscriptionForQuads(newDatasetChanges);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Helper method to update the parent dataset or any other provided dataset
|
|
172
|
+
*/
|
|
173
|
+
updateParentDataset(datasetChanges) {
|
|
174
|
+
return require__Users_jacksonmorgan_O_ldo_packages_subscribable_dataset_src_util.updateDatasetInBulk(this.parentDataset, datasetChanges);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Commits changes made to the parent dataset
|
|
178
|
+
*/
|
|
179
|
+
commit() {
|
|
180
|
+
this.checkIfTransactionCommitted();
|
|
181
|
+
this.committedDatasetChanges = {
|
|
182
|
+
added: this.datasetChanges.added?.difference(this.parentDataset),
|
|
183
|
+
removed: this.datasetChanges.removed?.intersection(this.parentDataset)
|
|
184
|
+
};
|
|
185
|
+
this.updateParentDataset(this.committedDatasetChanges);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Rolls back changes made to the parent dataset
|
|
189
|
+
*/
|
|
190
|
+
rollback() {
|
|
191
|
+
if (!this.committedDatasetChanges) throw new Error("Cannot rollback. Transaction has not yet been committed");
|
|
192
|
+
this.updateParentDataset({
|
|
193
|
+
added: this.committedDatasetChanges.removed,
|
|
194
|
+
removed: this.committedDatasetChanges.added
|
|
195
|
+
});
|
|
196
|
+
this.committedDatasetChanges = void 0;
|
|
197
|
+
}
|
|
198
|
+
getChanges() {
|
|
199
|
+
return this.datasetChanges;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Returns true if the transaction is holding changes that have yet to be committed.
|
|
203
|
+
* Returns false if no changes have yet been made to it.
|
|
204
|
+
*/
|
|
205
|
+
hasChanges() {
|
|
206
|
+
return (this.datasetChanges.added && this.datasetChanges.added.size > 0 || this.datasetChanges.removed && this.datasetChanges.removed.size > 0) ?? false;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
//#endregion
|
|
211
|
+
exports.TransactionDataset = TransactionDataset;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { ITransactionDataset, ITransactionDatasetFactory } from "./types.cjs";
|
|
2
|
+
import { SubscribableDataset } from "./SubscribableDataset.cjs";
|
|
3
|
+
import { BaseQuad, Dataset, DatasetFactory, Term } from "@rdfjs/types";
|
|
4
|
+
import { DatasetChanges } from "@ldo/rdf-utils";
|
|
5
|
+
|
|
6
|
+
//#region src/TransactionDataset.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Proxy Transactional Dataset is a transactional dataset that does not duplicate
|
|
10
|
+
* the parent dataset, it will dynamically determine the correct return value for
|
|
11
|
+
* methods in real time when the method is called.
|
|
12
|
+
*/
|
|
13
|
+
declare class TransactionDataset<InAndOutQuad extends BaseQuad = BaseQuad> extends SubscribableDataset<InAndOutQuad> implements ITransactionDataset<InAndOutQuad> {
|
|
14
|
+
/**
|
|
15
|
+
* The parent dataset that will be updated upon commit
|
|
16
|
+
*/
|
|
17
|
+
readonly parentDataset: Dataset<InAndOutQuad, InAndOutQuad>;
|
|
18
|
+
/**
|
|
19
|
+
* The changes made that are ready to commit
|
|
20
|
+
*/
|
|
21
|
+
private datasetChanges;
|
|
22
|
+
/**
|
|
23
|
+
* A list of changes made to the parent dataset upon commit used for rolling back changes.
|
|
24
|
+
* This is different from 'datasetChanges' because datasetChanges is allowed to overlap
|
|
25
|
+
* with the parent dataset.
|
|
26
|
+
* For example, the parent dataset may already have triple A, and datasetChanges can
|
|
27
|
+
* also have triple A.
|
|
28
|
+
*/
|
|
29
|
+
private committedDatasetChanges?;
|
|
30
|
+
/**
|
|
31
|
+
* Constructor
|
|
32
|
+
* @param parentDataset The dataset that will be updated upon commit
|
|
33
|
+
*/
|
|
34
|
+
constructor(parentDataset: Dataset<InAndOutQuad, InAndOutQuad>, datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>, transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>);
|
|
35
|
+
/**
|
|
36
|
+
* ==================================================================
|
|
37
|
+
* DATASET METHODS
|
|
38
|
+
* ==================================================================
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Imports the quads into this dataset.
|
|
42
|
+
* 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.
|
|
43
|
+
* @param quads
|
|
44
|
+
* @returns the dataset instance it was called on.
|
|
45
|
+
*/
|
|
46
|
+
addAll(quads: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[]): this;
|
|
47
|
+
/**
|
|
48
|
+
* Bulk add and remove triples
|
|
49
|
+
* @param changed
|
|
50
|
+
*/
|
|
51
|
+
bulk(changes: DatasetChanges<InAndOutQuad>): this;
|
|
52
|
+
/**
|
|
53
|
+
* 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.
|
|
54
|
+
* @param subject
|
|
55
|
+
* @param predicate
|
|
56
|
+
* @param object
|
|
57
|
+
* @param graph
|
|
58
|
+
* @returns the dataset instance it was called on.
|
|
59
|
+
*/
|
|
60
|
+
deleteMatches(subject?: Term, predicate?: Term, object?: Term, graph?: Term): this;
|
|
61
|
+
/**
|
|
62
|
+
* 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.
|
|
63
|
+
* @param subject
|
|
64
|
+
* @param predicate
|
|
65
|
+
* @param object
|
|
66
|
+
* @param graph
|
|
67
|
+
* @returns a Dataset with matching triples
|
|
68
|
+
*/
|
|
69
|
+
match(subject?: Term | null, predicate?: Term | null, object?: Term | null, graph?: Term | null): Dataset<InAndOutQuad, InAndOutQuad>;
|
|
70
|
+
/**
|
|
71
|
+
* A non-negative integer that specifies the number of quads in the set.
|
|
72
|
+
*/
|
|
73
|
+
get size(): number;
|
|
74
|
+
/**
|
|
75
|
+
* Adds the specified quad to the dataset.
|
|
76
|
+
* Existing quads, as defined in Quad.equals, will be ignored.
|
|
77
|
+
* @param quad
|
|
78
|
+
* @returns the dataset instance it was called on.
|
|
79
|
+
*/
|
|
80
|
+
add(quad: InAndOutQuad): this;
|
|
81
|
+
/**
|
|
82
|
+
* Removes the specified quad from the dataset.
|
|
83
|
+
* This method returns the dataset instance it was called on.
|
|
84
|
+
* @param quad
|
|
85
|
+
*/
|
|
86
|
+
delete(quad: InAndOutQuad): this;
|
|
87
|
+
/**
|
|
88
|
+
* Determines whether a dataset includes a certain quad, returning true or false as appropriate.
|
|
89
|
+
* @param quad
|
|
90
|
+
*/
|
|
91
|
+
has(quad: InAndOutQuad): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Returns an iterator
|
|
94
|
+
*/
|
|
95
|
+
[Symbol.iterator](): Iterator<InAndOutQuad>;
|
|
96
|
+
/**
|
|
97
|
+
* ==================================================================
|
|
98
|
+
* TANSACTIONAL METHODS
|
|
99
|
+
* ==================================================================
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* Checks if the transaction has been committed and throws an error if it has
|
|
103
|
+
* @param changed
|
|
104
|
+
*/
|
|
105
|
+
private checkIfTransactionCommitted;
|
|
106
|
+
/**
|
|
107
|
+
* Helper method to update the changes made
|
|
108
|
+
* @param changes
|
|
109
|
+
*/
|
|
110
|
+
private updateDatasetChanges;
|
|
111
|
+
/**
|
|
112
|
+
* Helper method to update the parent dataset or any other provided dataset
|
|
113
|
+
*/
|
|
114
|
+
private updateParentDataset;
|
|
115
|
+
/**
|
|
116
|
+
* Commits changes made to the parent dataset
|
|
117
|
+
*/
|
|
118
|
+
commit(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Rolls back changes made to the parent dataset
|
|
121
|
+
*/
|
|
122
|
+
rollback(): void;
|
|
123
|
+
getChanges(): DatasetChanges<InAndOutQuad>;
|
|
124
|
+
/**
|
|
125
|
+
* Returns true if the transaction is holding changes that have yet to be committed.
|
|
126
|
+
* Returns false if no changes have yet been made to it.
|
|
127
|
+
*/
|
|
128
|
+
hasChanges(): boolean;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=TransactionDataset.d.ts.map
|
|
131
|
+
//#endregion
|
|
132
|
+
export { TransactionDataset };
|
|
133
|
+
//# sourceMappingURL=TransactionDataset.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionDataset.d.cts","names":[],"sources":["../../src/TransactionDataset.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAYA;;;AAAgE,cAAnD,kBAAmD,CAAA,qBAAX,QAAW,GAAA,QAAA,CAAA,SACtD,mBADsD,CAClC,YADkC,CAAA,YAEnD,mBAFmD,CAE/B,YAF+B,CAAA,CAAA;EAAQ;;;EAOnB,SAAE,aAAA,EAAtB,OAAsB,CAAd,YAAc,EAAA,YAAA,CAAA;EAAY;;;EAqBd,QAAlC,cAAA;EAAO;;;;;;;EAsBmB,QAAlC,uBAAA;EAAO;;;;EAwBA,WACF,CAAA,aAAA,EA/CG,OA+CH,CA/CW,YA+CX,EA/CyB,YA+CzB,CAAA,EAAA,cAAA,EA9CI,cA8CJ,CA9CmB,YA8CnB,EA9CiC,YA8CjC,CAAA,EAAA,yBAAA,EA7Ce,0BA6Cf,CA7C0C,YA6C1C,CAAA;EAAI;;;;;EAuBH;;;;;;EA+CiB,MASf,CAAA,KAAA,EAxGR,OAwGQ,CAxGA,YAwGA,EAxGc,YAwGd,CAAA,GAxG8B,YAwG9B,EAAA,CAAA,EAAA,IAAA;EAAY;;;;EAqHmB,IAA3B,CAAA,OAAA,EAnNA,cAmNA,CAnNe,YAmNf,CAAA,CAAA,EAAA,IAAA;EAAc;;AA7QL;;;;;;0BAwElB,kBACE,eACH,cACD;;;;;;;;;kBAmBE,yBACE,sBACH,qBACD,cACP,QAAQ,cAAc;;;;;;;;;;;YAmCR;;;;;;eAUG;;;;;YASH;;;;GAUT,MAAA,CAAO,QAAA,KAAa,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2GhB,eAAe"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { ITransactionDataset, ITransactionDatasetFactory } from "./types.js";
|
|
2
|
+
import { SubscribableDataset$1 as SubscribableDataset } from "./SubscribableDataset.js";
|
|
3
|
+
import { DatasetChanges } from "@ldo/rdf-utils";
|
|
4
|
+
import { BaseQuad, Dataset, DatasetFactory, Term } from "@rdfjs/types";
|
|
5
|
+
|
|
6
|
+
//#region src/TransactionDataset.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Proxy Transactional Dataset is a transactional dataset that does not duplicate
|
|
10
|
+
* the parent dataset, it will dynamically determine the correct return value for
|
|
11
|
+
* methods in real time when the method is called.
|
|
12
|
+
*/
|
|
13
|
+
declare class TransactionDataset<InAndOutQuad extends BaseQuad = BaseQuad> extends SubscribableDataset<InAndOutQuad> implements ITransactionDataset<InAndOutQuad> {
|
|
14
|
+
/**
|
|
15
|
+
* The parent dataset that will be updated upon commit
|
|
16
|
+
*/
|
|
17
|
+
readonly parentDataset: Dataset<InAndOutQuad, InAndOutQuad>;
|
|
18
|
+
/**
|
|
19
|
+
* The changes made that are ready to commit
|
|
20
|
+
*/
|
|
21
|
+
private datasetChanges;
|
|
22
|
+
/**
|
|
23
|
+
* A list of changes made to the parent dataset upon commit used for rolling back changes.
|
|
24
|
+
* This is different from 'datasetChanges' because datasetChanges is allowed to overlap
|
|
25
|
+
* with the parent dataset.
|
|
26
|
+
* For example, the parent dataset may already have triple A, and datasetChanges can
|
|
27
|
+
* also have triple A.
|
|
28
|
+
*/
|
|
29
|
+
private committedDatasetChanges?;
|
|
30
|
+
/**
|
|
31
|
+
* Constructor
|
|
32
|
+
* @param parentDataset The dataset that will be updated upon commit
|
|
33
|
+
*/
|
|
34
|
+
constructor(parentDataset: Dataset<InAndOutQuad, InAndOutQuad>, datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>, transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>);
|
|
35
|
+
/**
|
|
36
|
+
* ==================================================================
|
|
37
|
+
* DATASET METHODS
|
|
38
|
+
* ==================================================================
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Imports the quads into this dataset.
|
|
42
|
+
* 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.
|
|
43
|
+
* @param quads
|
|
44
|
+
* @returns the dataset instance it was called on.
|
|
45
|
+
*/
|
|
46
|
+
addAll(quads: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[]): this;
|
|
47
|
+
/**
|
|
48
|
+
* Bulk add and remove triples
|
|
49
|
+
* @param changed
|
|
50
|
+
*/
|
|
51
|
+
bulk(changes: DatasetChanges<InAndOutQuad>): this;
|
|
52
|
+
/**
|
|
53
|
+
* 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.
|
|
54
|
+
* @param subject
|
|
55
|
+
* @param predicate
|
|
56
|
+
* @param object
|
|
57
|
+
* @param graph
|
|
58
|
+
* @returns the dataset instance it was called on.
|
|
59
|
+
*/
|
|
60
|
+
deleteMatches(subject?: Term, predicate?: Term, object?: Term, graph?: Term): this;
|
|
61
|
+
/**
|
|
62
|
+
* 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.
|
|
63
|
+
* @param subject
|
|
64
|
+
* @param predicate
|
|
65
|
+
* @param object
|
|
66
|
+
* @param graph
|
|
67
|
+
* @returns a Dataset with matching triples
|
|
68
|
+
*/
|
|
69
|
+
match(subject?: Term | null, predicate?: Term | null, object?: Term | null, graph?: Term | null): Dataset<InAndOutQuad, InAndOutQuad>;
|
|
70
|
+
/**
|
|
71
|
+
* A non-negative integer that specifies the number of quads in the set.
|
|
72
|
+
*/
|
|
73
|
+
get size(): number;
|
|
74
|
+
/**
|
|
75
|
+
* Adds the specified quad to the dataset.
|
|
76
|
+
* Existing quads, as defined in Quad.equals, will be ignored.
|
|
77
|
+
* @param quad
|
|
78
|
+
* @returns the dataset instance it was called on.
|
|
79
|
+
*/
|
|
80
|
+
add(quad: InAndOutQuad): this;
|
|
81
|
+
/**
|
|
82
|
+
* Removes the specified quad from the dataset.
|
|
83
|
+
* This method returns the dataset instance it was called on.
|
|
84
|
+
* @param quad
|
|
85
|
+
*/
|
|
86
|
+
delete(quad: InAndOutQuad): this;
|
|
87
|
+
/**
|
|
88
|
+
* Determines whether a dataset includes a certain quad, returning true or false as appropriate.
|
|
89
|
+
* @param quad
|
|
90
|
+
*/
|
|
91
|
+
has(quad: InAndOutQuad): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Returns an iterator
|
|
94
|
+
*/
|
|
95
|
+
[Symbol.iterator](): Iterator<InAndOutQuad>;
|
|
96
|
+
/**
|
|
97
|
+
* ==================================================================
|
|
98
|
+
* TANSACTIONAL METHODS
|
|
99
|
+
* ==================================================================
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* Checks if the transaction has been committed and throws an error if it has
|
|
103
|
+
* @param changed
|
|
104
|
+
*/
|
|
105
|
+
private checkIfTransactionCommitted;
|
|
106
|
+
/**
|
|
107
|
+
* Helper method to update the changes made
|
|
108
|
+
* @param changes
|
|
109
|
+
*/
|
|
110
|
+
private updateDatasetChanges;
|
|
111
|
+
/**
|
|
112
|
+
* Helper method to update the parent dataset or any other provided dataset
|
|
113
|
+
*/
|
|
114
|
+
private updateParentDataset;
|
|
115
|
+
/**
|
|
116
|
+
* Commits changes made to the parent dataset
|
|
117
|
+
*/
|
|
118
|
+
commit(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Rolls back changes made to the parent dataset
|
|
121
|
+
*/
|
|
122
|
+
rollback(): void;
|
|
123
|
+
getChanges(): DatasetChanges<InAndOutQuad>;
|
|
124
|
+
/**
|
|
125
|
+
* Returns true if the transaction is holding changes that have yet to be committed.
|
|
126
|
+
* Returns false if no changes have yet been made to it.
|
|
127
|
+
*/
|
|
128
|
+
hasChanges(): boolean;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=TransactionDataset.d.ts.map
|
|
131
|
+
//#endregion
|
|
132
|
+
export { TransactionDataset as TransactionDataset$1 };
|
|
133
|
+
//# sourceMappingURL=TransactionDataset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionDataset.d.ts","names":[],"sources":["../../src/TransactionDataset.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAYA;;;AAAgE,cAAnD,kBAAmD,CAAA,qBAAX,QAAW,GAAA,QAAA,CAAA,SACtD,mBADsD,CAClC,YADkC,CAAA,YAEnD,mBAFmD,CAE/B,YAF+B,CAAA,CAAA;EAAQ;;;EAOnB,SAAE,aAAA,EAAtB,OAAsB,CAAd,YAAc,EAAA,YAAA,CAAA;EAAY;;;EAqBd,QAAlC,cAAA;EAAO;;;;;;;EAsBmB,QAAlC,uBAAA;EAAO;;;;EAwBA,WACF,CAAA,aAAA,EA/CG,OA+CH,CA/CW,YA+CX,EA/CyB,YA+CzB,CAAA,EAAA,cAAA,EA9CI,cA8CJ,CA9CmB,YA8CnB,EA9CiC,YA8CjC,CAAA,EAAA,yBAAA,EA7Ce,0BA6Cf,CA7C0C,YA6C1C,CAAA;EAAI;;;;;EAuBH;;;;;;EA+CiB,MASf,CAAA,KAAA,EAxGR,OAwGQ,CAxGA,YAwGA,EAxGc,YAwGd,CAAA,GAxG8B,YAwG9B,EAAA,CAAA,EAAA,IAAA;EAAY;;;;EAqHmB,IAA3B,CAAA,OAAA,EAnNA,cAmNA,CAnNe,YAmNf,CAAA,CAAA,EAAA,IAAA;EAAc;;AA7QL;;;;;;0BAwElB,kBACE,eACH,cACD;;;;;;;;;kBAmBE,yBACE,sBACH,qBACD,cACP,QAAQ,cAAc;;;;;;;;;;;YAmCR;;;;;;eAUG;;;;;YASH;;;;GAUT,MAAA,CAAO,QAAA,KAAa,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2GhB,eAAe"}
|