import { ITransactionDataset, ITransactionDatasetFactory } from "./types.mjs"; import { SubscribableDataset } from "./SubscribableDataset.mjs"; import { DatasetChanges } from "@ldo/rdf-utils"; import { BaseQuad, Dataset, DatasetFactory, Term } from "@rdfjs/types"; //#region src/TransactionDataset.d.ts /** * Proxy Transactional Dataset is a transactional dataset that does not duplicate * the parent dataset, it will dynamically determine the correct return value for * methods in real time when the method is called. */ declare class TransactionDataset extends SubscribableDataset implements ITransactionDataset { /** * The parent dataset that will be updated upon commit */ readonly parentDataset: Dataset; /** * The changes made that are ready to commit */ private datasetChanges; /** * A list of changes made to the parent dataset upon commit used for rolling back changes. * This is different from 'datasetChanges' because datasetChanges is allowed to overlap * with the parent dataset. * For example, the parent dataset may already have triple A, and datasetChanges can * also have triple A. */ private committedDatasetChanges?; /** * Constructor * @param parentDataset The dataset that will be updated upon commit */ constructor(parentDataset: Dataset, datasetFactory: DatasetFactory, transactionDatasetFactory: ITransactionDatasetFactory); /** * ================================================================== * DATASET METHODS * ================================================================== */ /** * Imports the quads into this dataset. * 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. * @param quads * @returns the dataset instance it was called on. */ addAll(quads: Dataset | InAndOutQuad[]): this; /** * Bulk add and remove triples * @param changed */ bulk(changes: DatasetChanges): this; /** * 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. * @param subject * @param predicate * @param object * @param graph * @returns the dataset instance it was called on. */ deleteMatches(subject?: Term, predicate?: Term, object?: Term, graph?: Term): this; /** * 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. * @param subject * @param predicate * @param object * @param graph * @returns a Dataset with matching triples */ match(subject?: Term | null, predicate?: Term | null, object?: Term | null, graph?: Term | null): Dataset; /** * A non-negative integer that specifies the number of quads in the set. */ get size(): number; /** * Adds the specified quad to the dataset. * Existing quads, as defined in Quad.equals, will be ignored. * @param quad * @returns the dataset instance it was called on. */ add(quad: InAndOutQuad): this; /** * Removes the specified quad from the dataset. * This method returns the dataset instance it was called on. * @param quad */ delete(quad: InAndOutQuad): this; /** * Determines whether a dataset includes a certain quad, returning true or false as appropriate. * @param quad */ has(quad: InAndOutQuad): boolean; /** * Returns an iterator */ [Symbol.iterator](): Iterator; /** * ================================================================== * TANSACTIONAL METHODS * ================================================================== */ /** * Checks if the transaction has been committed and throws an error if it has * @param changed */ private checkIfTransactionCommitted; /** * Helper method to update the changes made * @param changes */ private updateDatasetChanges; /** * Helper method to update the parent dataset or any other provided dataset */ private updateParentDataset; /** * Commits changes made to the parent dataset */ commit(): void; /** * Rolls back changes made to the parent dataset */ rollback(): void; getChanges(): DatasetChanges; /** * Returns true if the transaction is holding changes that have yet to be committed. * Returns false if no changes have yet been made to it. */ hasChanges(): boolean; } //#endregion export { TransactionDataset }; //# sourceMappingURL=TransactionDataset.d.mts.map