import { ConnectedResult } from "./results/ConnectedResult.mjs"; import { IgnoredInvalidUpdateSuccess, UpdateSuccess } from "./results/success/UpdateSuccess.mjs"; import { ResourceError } from "./results/error/ErrorResult.mjs"; import { ReadSuccess } from "./results/success/ReadSuccess.mjs"; import { DatasetChanges } from "@ldo/rdf-utils"; import * as _$typed_emitter0 from "typed-emitter"; //#region src/Resource.d.ts type ResourceEventEmitter = _$typed_emitter0.default<{ update: () => void; notification: () => void; }>; /** * A resource is an abstract representation for a group of data on a remote * platform. For example, "Solid" has resources that could be containers or * leafs. */ interface Resource extends ResourceEventEmitter { /** * Indicates that this is not an error */ readonly isError: false; /** * The uri of the resource */ readonly uri: UriType; /** * The name of the resource. For example "NextGraphResource" */ readonly type: string; /** * The most recent result from one of the resource methods. */ status: ConnectedResult; /** * Returns true if this resource is currently loading. */ isLoading(): boolean; /** * Returns true if this resource has performed a fetch at least once */ isFetched(): boolean; /** * Returns true if this reosource has not performed a fetch at least once */ isUnfetched(): boolean; /** * Returns true if this resource is currently performing its first fetch */ isDoingInitialFetch(): boolean; /** * Returns true if this resource exists. Returns undefined if that is * currently unknown. */ isPresent(): boolean | undefined; /** * Returns true if its confirmed that this resource doesn't exist. Returns * undefined if that is currently unknown. */ isAbsent(): boolean | undefined; /** * Returns true if this resource is currently subscribed to notifications. */ isSubscribedToNotifications(): boolean; /** * Fetches the resource. */ read(): Promise | ResourceError>; /** * Fetches the resource if it hasn't been fetched yet. */ readIfUnfetched(): Promise | ResourceError>; /** * Applies updates to this resource. * @param datasetChanges - A list of changes to data */ update(datasetChanges: DatasetChanges): Promise | IgnoredInvalidUpdateSuccess | ResourceError>; /** * Begins a subscription to this resource * @param callbacks - optional set of callbacks to be called when this * resource is updated */ subscribeToNotifications(callbacks?: { onNotification: (message: any) => void; onNotificationError: (err: Error) => void; }): Promise; /** * Unsubscribes from notifications on this resource * @param subscriptionId the Id of the subscription to unsubscribe */ unsubscribeFromNotifications(subscriptionId: string): Promise; /** * Unsubscribes from all notifications. */ unsubscribeFromAllNotifications(): Promise; } //#endregion export { Resource, ResourceEventEmitter }; //# sourceMappingURL=Resource.d.mts.map