import EventEmitter from "events"; import type { Resource, ResourceEventEmitter } from "./Resource.js"; import { InvalidUriError } from "./results/error/InvalidUriError.js"; /** * A resource that represents a URI that does not have a valid URI given the * plugins available to the ConnectedLdoDataset. */ export class InvalidIdentifierResource extends (EventEmitter as new () => ResourceEventEmitter) implements Resource { public readonly uri: string; public readonly type = "InvalidIdentifierResouce" as const; public status: InvalidUriError; public readonly isError = false as const; constructor(uri: string) { super(); this.uri = uri; this.status = new InvalidUriError(this); } isLoading(): boolean { return false; } isFetched(): boolean { return false; } isUnfetched(): boolean { return true; } isDoingInitialFetch(): boolean { return false; } isPresent(): boolean { return false; } isAbsent(): boolean { return true; } isSubscribedToNotifications(): boolean { return false; } async read(): Promise> { return this.status; } async readIfUnfetched(): Promise> { return this.status; } async update(): Promise> { return this.status; } async subscribeToNotifications(_callbacks?: { onNotification: (message: unknown) => void; onNotificationError: (err: Error) => void; }): Promise { throw new Error("Cannot subscribe to an invalid resource."); } async unsubscribeFromNotifications(_subscriptionId: string): Promise { // Do Nothing } async unsubscribeFromAllNotifications(): Promise { // Do Nothing } }