import { GetResourceReturnType, IConnectedLdoDataset } from "./types/IConnectedLdoDataset.mjs"; import { ConnectedContext } from "./types/ConnectedContext.mjs"; import { ConnectedPlugin } from "./types/ConnectedPlugin.mjs"; import { ConnectedLdoBuilder } from "./ConnectedLdoBuilder.mjs"; import { ConnectedLdoTransactionDataset } from "./ConnectedLdoTransactionDataset.mjs"; import { LdoBase, LdoDataset, ShapeType } from "@ldo/ldo"; import { SubjectNode } from "@ldo/rdf-utils"; import { ITransactionDatasetFactory } from "@ldo/subscribable-dataset"; import { Dataset, DatasetFactory, Quad } from "@rdfjs/types"; //#region src/ConnectedLdoDataset.d.ts /** * A ConnectedLdoDataset has all the functionality of a LdoDataset with the * added functionality of keeping track of fetched remote Resources. * * It is recommended to use the { @link createConnectedLdoDataset } to * initialize this class. * * @example * ```typescript * import { createConnectedLdoDataset } from "@ldo/connected"; * import { ProfileShapeType } from "./_ldo/profile.shapeTypes.ts" * * // At least one plugin needs to be provided to a ConnectedLdoDataset. In this * // example we'll use both the Solid and NextGraph plugins. * import { solidConnectedPlugin } from "@ldo/connected-solid"; * import { nextGraphConnectedPlugin } from "@ldo/connected-nextgraph"; * * // ... * * const connectedLdoDataset = createConnectedLdoDataset([ * solidConnectedPlugin, * nextGraphConnectedPlugin * ]); * * const profileDocument = connectedLdoDataset * .getResource("https://example.com/profile"); * await profileDocument.read(); * * const profile = connectedLdoDataset * .using(ProfileShapeType) * .fromSubject("https://example.com/profile#me"); * ``` */ declare class ConnectedLdoDataset[]> extends LdoDataset implements IConnectedLdoDataset { /** * @internal * * A list of plugins used by this dataset */ private plugins; /** * @internal * * A mapping between a resource URI and a resource */ protected resourceMap: Map; /** * @internal * * Context for each plugin (usually utilities for authentication) */ protected context: ConnectedContext; /** * It is recommended to use the `createConnectedLdoDataset` function to * instantiate a ConnectedLdoDataset. * * @param plugins An array of plugins for each platform to connect to * @param datasetFactory Creates Datasets * @param transactionDatasetFactory Creates Transaction Datasets * @param initialDataset Initial quads */ constructor(plugins: Plugins, datasetFactory: DatasetFactory, transactionDatasetFactory: ITransactionDatasetFactory, initialDataset?: Dataset); /** * @internal * * A helper function to return a plugin based in the plugin name and uri. */ private getValidPlugin; /** * Retireves a representation of a Resource at the given URI. This resource * represents the current state of the resource: whether it is currently * fetched or in the process of fetching as well as some information about it. * * @param uri - the URI of the resource * @param pluginName - optionally, force this function to choose a specific * plugin to use rather than perform content negotiation. * * @returns a Resource * * @example * ```typescript * const profileDocument = connectedLdoDataset * .getResource("https://example.com/profile"); * ``` */ getResource, UriType extends string>(uri: UriType, pluginName?: Name): GetResourceReturnType; getResources(): GetResourceReturnType[]; getFetchedResources(): GetResourceReturnType[]; /** * Generates a random uri and creates a resource. * * @param pluginName - A string name for the platform you'd like to create * the resource on. * @param createResourceOptions - Some set of options specific to the plugin * you've selected. * @returns A created resource or an error * * @example * ```typescript * const profileDocument = await connectedLdoDataset * .createResource("solid"); * ``` */ createResource>(pluginName: Name, createResourceOptions?: Plugin["types"]["createResourceOptions"]): Promise>; /** * Removes a resource from local memory * @param uri - the URI of the resource to remove * @returns true if the resource was present before removal * * @example * ```typescript * connectedLdoDataset.forgetResource("https://example.com/resource.ttl"); * ``` */ forgetResource(uri: string): boolean; /** * Removes all resources from memory * * @example * ```typescript * connectedLdoDataset.forgetAllResources(); * ``` */ forgetAllResources(): void; /** * Shorthand for connectedLdoDataset * .usingType(shapeType) * .write(...resources.map((r) => r.uri)) * .fromSubject(subject); * @param shapeType - The shapetype to represent the data * @param subject - A subject URI * @param resources - The resources changes to should written to * * @example * ```typescript * import { ProfielShapeType } from "./_ldo/foafProfile.shapeType.ts" * * const resource = connectedLdoDataset * .getResource("https://example.com/profile"); * const profile = connectedLdoDataset.createData( * ProfileShapeType, * "https://example.com/profile#me", * resource * ); * ``` */ createData(shapeType: ShapeType, subject: string | SubjectNode, resource: Plugins[number]["types"]["resource"], ...additionalResources: Plugins[number]["types"]["resource"][]): Type; /** * Sets conetext for a specific plugin * * @param pluginName - the name of the plugin * @param context - the context for this specific plugin */ setContext>(pluginName: Name, context: Plugin["types"]["context"]): void; usingType(shapeType: ShapeType): ConnectedLdoBuilder; startTransaction(): ConnectedLdoTransactionDataset; } //#endregion export { ConnectedLdoDataset }; //# sourceMappingURL=ConnectedLdoDataset.d.mts.map