From 356ecf8c67c44c34ecfab1d3bb60e46caf3366f2 Mon Sep 17 00:00:00 2001 From: Jackson Morgan Date: Wed, 12 Mar 2025 19:40:45 -0400 Subject: [PATCH] connected library builds --- .../src/SolidConnectedPlugin.ts | 13 ++ .../src/resources/SolidResource.ts | 127 ++++++++++++++- packages/connected/src/ConnectedContext.ts | 7 +- packages/connected/src/ConnectedLdoDataset.ts | 62 +++++--- packages/connected/src/ConnectedPlugin.ts | 26 +++- .../src/InvalidIdentifierResource.ts | 6 +- packages/connected/src/Resource.ts | 8 +- packages/connected/src/index.ts | 5 +- .../src/notifications/NotificationMessage.ts | 10 -- .../notifications/NotificationSubscription.ts | 144 ------------------ .../error}/NotificationErrors.ts | 13 +- .../success/CheckRootContainerSuccess.ts | 19 --- .../src/results/success/CreateSuccess.ts | 13 -- .../src/results/success/DeleteSuccess.ts | 14 -- .../src/results/success/ReadSuccess.ts | 71 --------- .../src/results/success/UpdateSuccess.ts | 24 --- 16 files changed, 223 insertions(+), 339 deletions(-) delete mode 100644 packages/connected/src/notifications/NotificationMessage.ts delete mode 100644 packages/connected/src/notifications/NotificationSubscription.ts rename packages/connected/src/{notifications/results => results/error}/NotificationErrors.ts (71%) delete mode 100644 packages/connected/src/results/success/CheckRootContainerSuccess.ts delete mode 100644 packages/connected/src/results/success/CreateSuccess.ts delete mode 100644 packages/connected/src/results/success/DeleteSuccess.ts delete mode 100644 packages/connected/src/results/success/ReadSuccess.ts delete mode 100644 packages/connected/src/results/success/UpdateSuccess.ts diff --git a/packages/connected-solid/src/SolidConnectedPlugin.ts b/packages/connected-solid/src/SolidConnectedPlugin.ts index 96d16df..9db09c3 100644 --- a/packages/connected-solid/src/SolidConnectedPlugin.ts +++ b/packages/connected-solid/src/SolidConnectedPlugin.ts @@ -9,6 +9,12 @@ export interface SolidConnectedPlugin extends ConnectedPlugin { getResource: | ((uri: SolidLeafUri) => SolidLeaf) | ((uri: SolidContainerUri) => SolidContainer); + createResource(): Promise; + isUriValid(uri: string): uri is SolidLeafUri | SolidContainerUri; + normalizeUri?: (uri: string) => SolidLeafUri | SolidContainerUri; + context: { + fetch?: typeof fetch; + }; } export const solidConnectedPlugin: SolidConnectedPlugin = { @@ -17,4 +23,11 @@ export const solidConnectedPlugin: SolidConnectedPlugin = { getResource(_uri: SolidUri): SolidContainer | SolidLeaf { throw new Error("Not Implemented"); }, + createResource: function (): Promise { + throw new Error("Function not implemented."); + }, + isUriValid: function (uri: string): uri is SolidLeafUri | SolidContainerUri { + throw new Error("Function not implemented."); + }, + context: {}, }; diff --git a/packages/connected-solid/src/resources/SolidResource.ts b/packages/connected-solid/src/resources/SolidResource.ts index 74c7e92..820a551 100644 --- a/packages/connected-solid/src/resources/SolidResource.ts +++ b/packages/connected-solid/src/resources/SolidResource.ts @@ -1,3 +1,126 @@ -import type { Resource } from "@ldo/connected"; +import type { + ConnectedResult, + Resource, + ResourceResult, + SubscriptionCallbacks, +} from "@ldo/connected"; +import type { SolidContainerUri, SolidLeafUri } from "../types"; -export class SolidResource implements Resource {} +export class SolidResource + implements Resource +{ + uri: SolidLeafUri | SolidContainerUri; + type: string; + status: ConnectedResult; + isLoading(): boolean { + throw new Error("Method not implemented."); + } + isFetched(): boolean { + throw new Error("Method not implemented."); + } + isUnfetched(): boolean { + throw new Error("Method not implemented."); + } + isDoingInitialFetch(): boolean { + throw new Error("Method not implemented."); + } + isPresent(): boolean { + throw new Error("Method not implemented."); + } + isAbsent(): boolean { + throw new Error("Method not implemented."); + } + isSubscribedToNotifications(): boolean { + throw new Error("Method not implemented."); + } + read(): Promise> { + throw new Error("Method not implemented."); + } + readIfAbsent(): Promise> { + throw new Error("Method not implemented."); + } + subscribeToNotifications(callbacks?: SubscriptionCallbacks): Promise { + throw new Error("Method not implemented."); + } + unsubscribeFromNotifications(subscriptionId: string): Promise { + throw new Error("Method not implemented."); + } + unsubscribeFromAllNotifications(): Promise { + throw new Error("Method not implemented."); + } + addListener( + event: E, + listener: { update: () => void; notification: () => void }[E], + ): this { + throw new Error("Method not implemented."); + } + on( + event: E, + listener: { update: () => void; notification: () => void }[E], + ): this { + throw new Error("Method not implemented."); + } + once( + event: E, + listener: { update: () => void; notification: () => void }[E], + ): this { + throw new Error("Method not implemented."); + } + prependListener( + event: E, + listener: { update: () => void; notification: () => void }[E], + ): this { + throw new Error("Method not implemented."); + } + prependOnceListener( + event: E, + listener: { update: () => void; notification: () => void }[E], + ): this { + throw new Error("Method not implemented."); + } + off( + event: E, + listener: { update: () => void; notification: () => void }[E], + ): this { + throw new Error("Method not implemented."); + } + removeAllListeners( + event?: E | undefined, + ): this { + throw new Error("Method not implemented."); + } + removeListener( + event: E, + listener: { update: () => void; notification: () => void }[E], + ): this { + throw new Error("Method not implemented."); + } + emit( + event: E, + ...args: Parameters<{ update: () => void; notification: () => void }[E]> + ): boolean { + throw new Error("Method not implemented."); + } + eventNames(): (string | symbol)[] { + throw new Error("Method not implemented."); + } + rawListeners( + event: E, + ): { update: () => void; notification: () => void }[E][] { + throw new Error("Method not implemented."); + } + listeners( + event: E, + ): { update: () => void; notification: () => void }[E][] { + throw new Error("Method not implemented."); + } + listenerCount(event: E): number { + throw new Error("Method not implemented."); + } + getMaxListeners(): number { + throw new Error("Method not implemented."); + } + setMaxListeners(maxListeners: number): this { + throw new Error("Method not implemented."); + } +} diff --git a/packages/connected/src/ConnectedContext.ts b/packages/connected/src/ConnectedContext.ts index b705546..2c72178 100644 --- a/packages/connected/src/ConnectedContext.ts +++ b/packages/connected/src/ConnectedContext.ts @@ -1,8 +1,11 @@ import type { ConnectedLdoDataset } from "./ConnectedLdoDataset"; import type { ConnectedPlugin } from "./ConnectedPlugin"; -export type ConnectedContext = { +export type ConnectedContext< + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Plugins extends ConnectedPlugin[], +> = { dataset: ConnectedLdoDataset; } & { - [P in Plugins[number] as P["name"]]: P["context"]; + [P in Plugins[number] as P["name"]]: P["types"]["context"]; }; diff --git a/packages/connected/src/ConnectedLdoDataset.ts b/packages/connected/src/ConnectedLdoDataset.ts index 3765ec5..e961924 100644 --- a/packages/connected/src/ConnectedLdoDataset.ts +++ b/packages/connected/src/ConnectedLdoDataset.ts @@ -1,22 +1,17 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import { LdoDataset } from "@ldo/ldo"; import type { ConnectedPlugin } from "./ConnectedPlugin"; import type { Dataset, DatasetFactory, Quad } from "@rdfjs/types"; import type { ITransactionDatasetFactory } from "@ldo/subscribable-dataset"; import { InvalidIdentifierResource } from "./InvalidIdentifierResource"; +import type { ConnectedContext } from "./ConnectedContext"; -type ReturnTypeFromArgs = T extends (arg: Arg) => infer R ? R : never; -type ResourceTypes = - | ReturnType - | InvalidIdentifierResource; -type GetResourceReturn< - Plugin extends ConnectedPlugin, - UriType extends string, -> = UriType extends Parameters[0] - ? ReturnTypeFromArgs - : ResourceTypes<[Plugin]>; +type ReturnTypeFromArgs = Func extends (arg: Arg) => infer R + ? R + : never; export class ConnectedLdoDataset< - Plugins extends ConnectedPlugin[], + Plugins extends ConnectedPlugin[], > extends LdoDataset { private plugins: Plugins; /** @@ -24,7 +19,8 @@ export class ConnectedLdoDataset< * * A mapping between a resource URI and a Solid resource */ - protected resourceMap: Map>; + protected resourceMap: Map; + protected context: ConnectedContext; constructor( plugins: Plugins, @@ -35,6 +31,12 @@ export class ConnectedLdoDataset< super(datasetFactory, transactionDatasetFactory, initialDataset); this.plugins = plugins; this.resourceMap = new Map(); + this.context = { + dataset: this, + }; + this.plugins.forEach( + (plugin) => (this.context[plugin.name] = plugin.initialContext), + ); } /** @@ -58,16 +60,18 @@ export class ConnectedLdoDataset< Name extends Plugins[number]["name"], Plugin extends Extract, UriType extends string, - >(uri: UriType, pluginName?: Name): GetResourceReturn { + >( + uri: UriType, + pluginName?: Name, + ): UriType extends Plugin["types"]["uri"] + ? ReturnTypeFromArgs + : ReturnType | InvalidIdentifierResource { // Check for which plugins this uri is valid const validPlugins = this.plugins .filter((plugin) => plugin.isUriValid(uri)) .filter((plugin) => (pluginName ? pluginName === plugin.name : true)); if (validPlugins.length === 0) { - return new InvalidIdentifierResource(uri) as GetResourceReturn< - Plugin, - UriType - >; + return new InvalidIdentifierResource(uri) as any; } else if (validPlugins.length > 1) { // TODO: LDO is currently not architected to have an ID valid in multiple // protocols. This will need to be refactored if this is ever the case. @@ -80,9 +84,29 @@ export class ConnectedLdoDataset< let resource = this.resourceMap.get(normalizedUri); if (!resource) { - resource = plugin.getResource(uri) as ResourceTypes; + resource = plugin.getResource(uri, this.context); this.resourceMap.set(normalizedUri, resource); } - return resource as GetResourceReturn; + return resource as any; + } + + async createResource< + Name extends Plugins[number]["name"], + Plugin extends Extract, + >(name: Name): Promise> { + const validPlugin = this.plugins.find((plugin) => name === plugin.name)!; + const newResourceResult = await validPlugin.createResource(this.context); + if (newResourceResult.isError) return newResourceResult; + this.resourceMap.set(newResourceResult.uri, newResourceResult); + return newResourceResult; + } + + setContext< + Name extends Plugins[number]["name"], + Plugin extends Extract, + >(name: Name, context: Plugin["types"]["context"]) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + this.context[name] = context; } } diff --git a/packages/connected/src/ConnectedPlugin.ts b/packages/connected/src/ConnectedPlugin.ts index 1c371a8..ae152db 100644 --- a/packages/connected/src/ConnectedPlugin.ts +++ b/packages/connected/src/ConnectedPlugin.ts @@ -1,9 +1,23 @@ import type { Resource } from "./Resource"; +import type { ErrorResult } from "./results/error/ErrorResult"; -export interface ConnectedPlugin { - name: string; - getResource(uri: string): Resource; - createResource(): Promise; - isUriValid(uri: string): boolean; - normalizeUri?: (uri: string) => string; +export interface ConnectedPlugin< + Name extends string, + UriType extends string, + ResourceType extends Resource, + ContextType, +> { + name: Name; + getResource(uri: UriType, context: ContextType): ResourceType | ErrorResult; + createResource(context: ContextType): Promise; + isUriValid(uri: UriType): boolean; + normalizeUri?: (uri: UriType) => UriType; + initialContext: ContextType; + // This object exists to transfer typescript types. It does not need to be + // filled out in an actual instance. + types: { + uri: UriType; + context: ContextType; + resource: ResourceType; + }; } diff --git a/packages/connected/src/InvalidIdentifierResource.ts b/packages/connected/src/InvalidIdentifierResource.ts index 546abbc..ff4e3ae 100644 --- a/packages/connected/src/InvalidIdentifierResource.ts +++ b/packages/connected/src/InvalidIdentifierResource.ts @@ -1,7 +1,6 @@ import EventEmitter from "events"; import type { Resource, ResourceEventEmitter } from "./Resource"; import { InvalidUriError } from "./results/error/InvalidUriError"; -import type { SubscriptionCallbacks } from "./notifications/NotificationSubscription"; export class InvalidIdentifierResource extends (EventEmitter as new () => ResourceEventEmitter) @@ -10,6 +9,7 @@ export class InvalidIdentifierResource public readonly uri: string; public readonly type = "InvalidIdentifierResouce" as const; public status: InvalidUriError; + public readonly isError = false as const; constructor(uri: string) { super(); @@ -50,9 +50,7 @@ export class InvalidIdentifierResource async createIfAbsent(): Promise> { return this.status; } - async subscribeToNotifications( - _callbacks?: SubscriptionCallbacks, - ): Promise { + async subscribeToNotifications(_callbacks): Promise { throw new Error("Cannot subscribe to an invalid resource."); } async unsubscribeFromNotifications(_subscriptionId: string): Promise { diff --git a/packages/connected/src/Resource.ts b/packages/connected/src/Resource.ts index d3b0d46..a98b621 100644 --- a/packages/connected/src/Resource.ts +++ b/packages/connected/src/Resource.ts @@ -1,7 +1,7 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import type TypedEmitter from "typed-emitter"; import type { ConnectedResult } from "./results/ConnectedResult"; import type { ResourceResult } from "./results/ResourceResult"; -import type { SubscriptionCallbacks } from "./notifications/NotificationSubscription"; export type ResourceEventEmitter = TypedEmitter<{ update: () => void; @@ -10,6 +10,7 @@ export type ResourceEventEmitter = TypedEmitter<{ export interface Resource extends ResourceEventEmitter { + readonly isError: false; readonly uri: UriType; readonly type: string; status: ConnectedResult; @@ -22,7 +23,10 @@ export interface Resource isSubscribedToNotifications(): boolean; read(): Promise>; readIfAbsent(): Promise>; - subscribeToNotifications(callbacks?: SubscriptionCallbacks): Promise; + subscribeToNotifications(callbacks?: { + onNotification: (message: any) => void; + onNotificationError: (err: Error) => void; + }): Promise; unsubscribeFromNotifications(subscriptionId: string): Promise; unsubscribeFromAllNotifications(): Promise; } diff --git a/packages/connected/src/index.ts b/packages/connected/src/index.ts index 13899ef..ee5a043 100644 --- a/packages/connected/src/index.ts +++ b/packages/connected/src/index.ts @@ -4,11 +4,10 @@ export * from "./Resource"; export * from "./InvalidIdentifierResource"; export * from "./ConnectedContext"; -export * from "./notifications/NotificationMessage"; -export * from "./notifications/NotificationSubscription"; - export * from "./results/ConnectedResult"; export * from "./results/ResourceResult"; export * from "./results/error/ErrorResult"; +export * from "./results/error/InvalidUriError"; +export * from "./results/error/NotificationErrors"; export * from "./results/success/SuccessResult"; export * from "./results/success/Unfetched"; diff --git a/packages/connected/src/notifications/NotificationMessage.ts b/packages/connected/src/notifications/NotificationMessage.ts deleted file mode 100644 index 14e5c2d..0000000 --- a/packages/connected/src/notifications/NotificationMessage.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * A message sent from the Pod as a notification - */ -export interface NotificationMessage { - "@context": string | string[]; - id: string; - type: "Update" | "Delete" | "Remove" | "Add"; - object: string; - published: string; -} diff --git a/packages/connected/src/notifications/NotificationSubscription.ts b/packages/connected/src/notifications/NotificationSubscription.ts deleted file mode 100644 index 4961075..0000000 --- a/packages/connected/src/notifications/NotificationSubscription.ts +++ /dev/null @@ -1,144 +0,0 @@ -import type { SolidLdoDatasetContext } from "../../SolidLdoDatasetContext"; -import type { Resource } from "../Resource"; -import type { NotificationMessage } from "./NotificationMessage"; -import type { NotificationCallbackError } from "./results/NotificationErrors"; -import { v4 } from "uuid"; - -export interface SubscriptionCallbacks { - onNotification?: (message: NotificationMessage) => void; - // TODO: make notification errors more specific - onNotificationError?: (error: Error) => void; -} - -/** - * @internal - * Abstract class for notification subscription methods. - */ -export abstract class NotificationSubscription { - protected resource: Resource; - protected parentSubscription: (message: NotificationMessage) => void; - protected context: SolidLdoDatasetContext; - protected subscriptions: Record = {}; - private isOpen: boolean = false; - - constructor( - resource: Resource, - parentSubscription: (message: NotificationMessage) => void, - context: SolidLdoDatasetContext, - ) { - this.resource = resource; - this.parentSubscription = parentSubscription; - this.context = context; - } - - public isSubscribedToNotifications(): boolean { - return this.isOpen; - } - - /** - * =========================================================================== - * PUBLIC - * =========================================================================== - */ - - /** - * @internal - * subscribeToNotifications - */ - async subscribeToNotifications( - subscriptionCallbacks?: SubscriptionCallbacks, - ): Promise { - const subscriptionId = v4(); - this.subscriptions[subscriptionId] = subscriptionCallbacks ?? {}; - if (!this.isOpen) { - await this.open(); - this.setIsOpen(true); - } - return subscriptionId; - } - - /** - * @internal - * unsubscribeFromNotification - */ - async unsubscribeFromNotification(subscriptionId: string): Promise { - if ( - !!this.subscriptions[subscriptionId] && - Object.keys(this.subscriptions).length === 1 - ) { - await this.close(); - this.setIsOpen(false); - } - delete this.subscriptions[subscriptionId]; - } - - /** - * @internal - * unsubscribeFromAllNotifications - */ - async unsubscribeFromAllNotifications(): Promise { - await Promise.all( - Object.keys(this.subscriptions).map((id) => - this.unsubscribeFromNotification(id), - ), - ); - } - - /** - * =========================================================================== - * HELPERS - * =========================================================================== - */ - - /** - * @internal - * Opens the subscription - */ - protected abstract open(): Promise; - - /** - * @internal - * Closes the subscription - */ - protected abstract close(): Promise; - - /** - * =========================================================================== - * CALLBACKS - * =========================================================================== - */ - - /** - * @internal - * onNotification - */ - protected onNotification(message: NotificationMessage): void { - this.parentSubscription(message); - Object.values(this.subscriptions).forEach(({ onNotification }) => { - onNotification?.(message); - }); - } - - /** - * @internal - * onNotificationError - */ - protected onNotificationError(message: NotificationCallbackError): void { - Object.values(this.subscriptions).forEach(({ onNotificationError }) => { - onNotificationError?.(message); - }); - if (message.type === "disconnectedNotAttemptingReconnectError") { - this.setIsOpen(false); - } - } - - /** - * @internal - * setIsOpen - */ - protected setIsOpen(status: boolean) { - const shouldUpdate = status !== this.isOpen; - this.isOpen = status; - if (shouldUpdate) this.resource.emit("update"); - } -} diff --git a/packages/connected/src/notifications/results/NotificationErrors.ts b/packages/connected/src/results/error/NotificationErrors.ts similarity index 71% rename from packages/connected/src/notifications/results/NotificationErrors.ts rename to packages/connected/src/results/error/NotificationErrors.ts index f196c86..6521911 100644 --- a/packages/connected/src/notifications/results/NotificationErrors.ts +++ b/packages/connected/src/results/error/NotificationErrors.ts @@ -1,30 +1,31 @@ -import type { UnexpectedResourceError } from "../../../requester/results/error/ErrorResult"; -import { ResourceError } from "../../../requester/results/error/ErrorResult"; +import type { Resource } from "../../Resource"; +import type { UnexpectedResourceError } from "./ErrorResult"; +import { ResourceError } from "./ErrorResult"; export type NotificationCallbackError = | DisconnectedAttemptingReconnectError | DisconnectedNotAttemptingReconnectError | UnsupportedNotificationError - | UnexpectedResourceError; + | UnexpectedResourceError; /** * Indicates that the requested method for receiving notifications is not * supported by this Pod. */ -export class UnsupportedNotificationError extends ResourceError { +export class UnsupportedNotificationError extends ResourceError { readonly type = "unsupportedNotificationError" as const; } /** * Indicates that the socket has disconnected and is attempting to reconnect. */ -export class DisconnectedAttemptingReconnectError extends ResourceError { +export class DisconnectedAttemptingReconnectError extends ResourceError { readonly type = "disconnectedAttemptingReconnectError" as const; } /** * Indicates that the socket has disconnected and is attempting to reconnect. */ -export class DisconnectedNotAttemptingReconnectError extends ResourceError { +export class DisconnectedNotAttemptingReconnectError extends ResourceError { readonly type = "disconnectedNotAttemptingReconnectError" as const; } diff --git a/packages/connected/src/results/success/CheckRootContainerSuccess.ts b/packages/connected/src/results/success/CheckRootContainerSuccess.ts deleted file mode 100644 index 77a435f..0000000 --- a/packages/connected/src/results/success/CheckRootContainerSuccess.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { Container } from "../../../resource/Container"; -import type { ResourceSuccess, SuccessResult } from "./SuccessResult"; - -/** - * Indicates that the request to check if a resource is the root container was - * a success. - */ -export interface CheckRootContainerSuccess extends ResourceSuccess { - type: "checkRootContainerSuccess"; - /** - * True if this resoure is the root container - */ - isRootContainer: boolean; -} - -export interface GetStorageContainerFromWebIdSuccess extends SuccessResult { - type: "getStorageContainerFromWebIdSuccess"; - storageContainers: Container[]; -} diff --git a/packages/connected/src/results/success/CreateSuccess.ts b/packages/connected/src/results/success/CreateSuccess.ts deleted file mode 100644 index 3d83b9f..0000000 --- a/packages/connected/src/results/success/CreateSuccess.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { ResourceSuccess } from "./SuccessResult"; - -/** - * Indicates that the request to create the resource was a success. - */ -export interface CreateSuccess extends ResourceSuccess { - type: "createSuccess"; - /** - * True if there was a resource that existed before at the given URI that was - * overwritten - */ - didOverwrite: boolean; -} diff --git a/packages/connected/src/results/success/DeleteSuccess.ts b/packages/connected/src/results/success/DeleteSuccess.ts deleted file mode 100644 index 0345a1c..0000000 --- a/packages/connected/src/results/success/DeleteSuccess.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { ResourceSuccess } from "./SuccessResult"; - -/** - * Indicates that the request to delete a resource was a success. - */ -export interface DeleteSuccess extends ResourceSuccess { - type: "deleteSuccess"; - - /** - * True if there was a resource at the provided URI that was deleted. False if - * a resource didn't exist. - */ - resourceExisted: boolean; -} diff --git a/packages/connected/src/results/success/ReadSuccess.ts b/packages/connected/src/results/success/ReadSuccess.ts deleted file mode 100644 index 756642a..0000000 --- a/packages/connected/src/results/success/ReadSuccess.ts +++ /dev/null @@ -1,71 +0,0 @@ -import type { ResourceSuccess, SuccessResult } from "./SuccessResult"; - -/** - * Indicates that the request to read a resource was a success - */ -export interface ReadSuccess extends ResourceSuccess { - /** - * True if the resource was recalled from local memory rather than a recent - * request - */ - recalledFromMemory: boolean; -} - -/** - * Indicates that the read request was successful and that the resource - * retrieved was a binary resource. - */ -export interface BinaryReadSuccess extends ReadSuccess { - type: "binaryReadSuccess"; - /** - * The raw data for the binary resource - */ - blob: Blob; - /** - * The mime type of the binary resource - */ - mimeType: string; -} - -/** - * Indicates that the read request was successful and that the resource - * retrieved was a data (RDF) resource. - */ -export interface DataReadSuccess extends ReadSuccess { - type: "dataReadSuccess"; -} - -/** - * Indicates that the read request was successful and that the resource - * retrieved was a container resource. - */ -export interface ContainerReadSuccess extends ReadSuccess { - type: "containerReadSuccess"; - /** - * True if this container is a root container - */ - isRootContainer: boolean; -} - -/** - * Indicates that the read request was successful, but no resource exists at - * the provided URI. - */ -export interface AbsentReadSuccess extends ReadSuccess { - type: "absentReadSuccess"; -} - -/** - * A helper function that checks to see if a result is a ReadSuccess result - * - * @param result - the result to check - * @returns true if the result is a ReadSuccessResult result - */ -export function isReadSuccess(result: SuccessResult): result is ReadSuccess { - return ( - result.type === "binaryReadSuccess" || - result.type === "dataReadSuccess" || - result.type === "absentReadSuccess" || - result.type === "containerReadSuccess" - ); -} diff --git a/packages/connected/src/results/success/UpdateSuccess.ts b/packages/connected/src/results/success/UpdateSuccess.ts deleted file mode 100644 index 5b740a0..0000000 --- a/packages/connected/src/results/success/UpdateSuccess.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { ResourceSuccess } from "./SuccessResult"; - -/** - * Indicates that an update request to a resource was successful - */ -export interface UpdateSuccess extends ResourceSuccess { - type: "updateSuccess"; -} - -/** - * Indicates that an update request to the default graph was successful. This - * data was not written to a Pod. It was only written locally. - */ -export interface UpdateDefaultGraphSuccess extends ResourceSuccess { - type: "updateDefaultGraphSuccess"; -} - -/** - * Indicates that LDO ignored an invalid update (usually because a container - * attempted an update) - */ -export interface IgnoredInvalidUpdateSuccess extends ResourceSuccess { - type: "ignoredInvalidUpdateSuccess"; -}