From 0fa45f82de5c83bd9641b5e0142c089ac1cbd75d Mon Sep 17 00:00:00 2001 From: jaxoncreed Date: Thu, 7 Sep 2023 00:53:56 -0400 Subject: [PATCH] Simplified hierarchy --- .../solid/example/example-methodBrainstorm.ts | 195 ++++++++++++++ packages/solid/example/example.ts | 209 ++------------- packages/solid/src/ProcessManager.ts | 9 + packages/solid/src/ResourceStore.ts | 72 +++++ packages/solid/src/SolidLdoDatasetContext.ts | 8 - .../resource-old/container/AbsentContainer.ts | 39 --- .../src/resource-old/container/Container.ts | 77 ------ .../container/UnfetchedContainer.ts | 30 --- .../presentContainer/BranchContainer.ts | 18 -- .../presentContainer/PresentContainer.ts | 31 --- .../presentContainer/RootContainer.ts | 14 - .../solid/src/resource-old/leaf/AbsentLeaf.ts | 56 ---- packages/solid/src/resource-old/leaf/Leaf.ts | 38 --- .../src/resource-old/leaf/UnfetchedLeaf.ts | 49 ---- .../leaf/presentLeaf/BinaryLeaf.ts | 15 -- .../resource-old/leaf/presentLeaf/DataLeaf.ts | 26 -- .../leaf/presentLeaf/PresentLeaf.ts | 17 -- packages/solid/src/resource-old/notes.ts | 249 ------------------ packages/solid/src/resource-old/types.ts | 97 ------- packages/solid/src/resource/Container.ts | 3 + packages/solid/src/resource/Leaf.ts | 86 ++++++ packages/solid/src/resource/Resource.ts | 1 + .../src/resource/abstract/AbstractResource.ts | 1 + .../solid/src/resource/abstract/Resource.ts | 36 --- .../abstract/container/AbsentContainer.ts | 5 + .../abstract/container/AbstractContainer.ts | 3 + .../resource/abstract/container/Container.ts | 13 - .../abstract/container/FetchedContainer.ts | 8 + .../abstract/container/PresentContainer.ts | 11 +- .../abstract/container/UnfetchedContainer.ts | 5 + .../abstract/dataResource/DataResource.ts | 7 - .../dataResource/PotentialDataResource.ts | 26 -- .../resource/abstract/fetchStatus/Absent.ts | 16 +- .../abstract/fetchStatus/FetchStatus.ts | 7 - .../resource/abstract/fetchStatus/Fetched.ts | 25 +- .../resource/abstract/fetchStatus/Present.ts | 18 +- .../abstract/fetchStatus/Unfetched.ts | 27 +- .../src/resource/abstract/leaf/AbsentLeaf.ts | 5 + .../resource/abstract/leaf/AbstractLeaf.ts | 3 + .../src/resource/abstract/leaf/BinaryLeaf.ts | 3 + .../src/resource/abstract/leaf/DataLeaf.ts | 3 + .../src/resource/abstract/leaf/FetchedLeaf.ts | 8 +- .../solid/src/resource/abstract/leaf/Leaf.ts | 33 --- .../src/resource/abstract/leaf/PresentLeaf.ts | 3 - .../resource/abstract/leaf/UnfetchedLeaf.ts | 5 + .../src/resource/concrete/AbsentContainer.ts | 5 - .../solid/src/resource/concrete/AbsentLeaf.ts | 21 -- .../solid/src/resource/concrete/BinaryLeaf.ts | 5 - .../src/resource/concrete/BranchContainer.ts | 3 - .../solid/src/resource/concrete/DataLeaf.ts | 5 - .../src/resource/concrete/RootContainer.ts | 3 - .../resource/concrete/UnfetchedContainer.ts | 5 - .../src/resource/concrete/UnfetchedLeaf.ts | 10 - .../resource/error/MethodNotAllowedError.ts | 14 + .../solid/src/resource/error/ResourceError.ts | 6 + .../solid/src/resource/error/SolidLdoError.ts | 1 - packages/solid/src/test.ts | 21 ++ packages/solid/src/uriTypes.ts | 96 +++++++ 58 files changed, 573 insertions(+), 1232 deletions(-) create mode 100644 packages/solid/example/example-methodBrainstorm.ts create mode 100644 packages/solid/src/ProcessManager.ts create mode 100644 packages/solid/src/ResourceStore.ts delete mode 100644 packages/solid/src/resource-old/container/AbsentContainer.ts delete mode 100644 packages/solid/src/resource-old/container/Container.ts delete mode 100644 packages/solid/src/resource-old/container/UnfetchedContainer.ts delete mode 100644 packages/solid/src/resource-old/container/presentContainer/BranchContainer.ts delete mode 100644 packages/solid/src/resource-old/container/presentContainer/PresentContainer.ts delete mode 100644 packages/solid/src/resource-old/container/presentContainer/RootContainer.ts delete mode 100644 packages/solid/src/resource-old/leaf/AbsentLeaf.ts delete mode 100644 packages/solid/src/resource-old/leaf/Leaf.ts delete mode 100644 packages/solid/src/resource-old/leaf/UnfetchedLeaf.ts delete mode 100644 packages/solid/src/resource-old/leaf/presentLeaf/BinaryLeaf.ts delete mode 100644 packages/solid/src/resource-old/leaf/presentLeaf/DataLeaf.ts delete mode 100644 packages/solid/src/resource-old/leaf/presentLeaf/PresentLeaf.ts delete mode 100644 packages/solid/src/resource-old/notes.ts delete mode 100644 packages/solid/src/resource-old/types.ts create mode 100644 packages/solid/src/resource/Container.ts create mode 100644 packages/solid/src/resource/Leaf.ts create mode 100644 packages/solid/src/resource/Resource.ts create mode 100644 packages/solid/src/resource/abstract/AbstractResource.ts delete mode 100644 packages/solid/src/resource/abstract/Resource.ts create mode 100644 packages/solid/src/resource/abstract/container/AbsentContainer.ts create mode 100644 packages/solid/src/resource/abstract/container/AbstractContainer.ts delete mode 100644 packages/solid/src/resource/abstract/container/Container.ts create mode 100644 packages/solid/src/resource/abstract/container/FetchedContainer.ts create mode 100644 packages/solid/src/resource/abstract/container/UnfetchedContainer.ts delete mode 100644 packages/solid/src/resource/abstract/dataResource/DataResource.ts delete mode 100644 packages/solid/src/resource/abstract/dataResource/PotentialDataResource.ts delete mode 100644 packages/solid/src/resource/abstract/fetchStatus/FetchStatus.ts create mode 100644 packages/solid/src/resource/abstract/leaf/AbsentLeaf.ts create mode 100644 packages/solid/src/resource/abstract/leaf/AbstractLeaf.ts create mode 100644 packages/solid/src/resource/abstract/leaf/BinaryLeaf.ts create mode 100644 packages/solid/src/resource/abstract/leaf/DataLeaf.ts delete mode 100644 packages/solid/src/resource/abstract/leaf/Leaf.ts create mode 100644 packages/solid/src/resource/abstract/leaf/UnfetchedLeaf.ts delete mode 100644 packages/solid/src/resource/concrete/AbsentContainer.ts delete mode 100644 packages/solid/src/resource/concrete/AbsentLeaf.ts delete mode 100644 packages/solid/src/resource/concrete/BinaryLeaf.ts delete mode 100644 packages/solid/src/resource/concrete/BranchContainer.ts delete mode 100644 packages/solid/src/resource/concrete/DataLeaf.ts delete mode 100644 packages/solid/src/resource/concrete/RootContainer.ts delete mode 100644 packages/solid/src/resource/concrete/UnfetchedContainer.ts delete mode 100644 packages/solid/src/resource/concrete/UnfetchedLeaf.ts create mode 100644 packages/solid/src/resource/error/MethodNotAllowedError.ts create mode 100644 packages/solid/src/resource/error/ResourceError.ts delete mode 100644 packages/solid/src/resource/error/SolidLdoError.ts create mode 100644 packages/solid/src/test.ts create mode 100644 packages/solid/src/uriTypes.ts diff --git a/packages/solid/example/example-methodBrainstorm.ts b/packages/solid/example/example-methodBrainstorm.ts new file mode 100644 index 0000000..60aa3ec --- /dev/null +++ b/packages/solid/example/example-methodBrainstorm.ts @@ -0,0 +1,195 @@ +const resourceMethods: Record = { + RootContainerResource: [ + "uri", + "isLoading", + "didInitialFetch", + "ldoDataset", + "getIsRootContainer", + "createContainerIn", + "createDataResourceIn", + "uploadBinaryIn", + "createOrOverwrite", + "read", + "reload", + "load", + "clear", + "clearIfPresent", + ], + ContainerResource: [ + "uri", + "isLoading", + "didInitialFetch", + "parentContainer", + "getIsRootContainer", + "getParentContainer", + "childResources", + "getRootContainer", + "createContainerIn", + "createDataResourceIn", + "uploadBinaryIn", + "ldoDataset", + "createOrOverwrite", + "read", + "reload", + "load", + "delete", + "deleteIfPresent", + "clear", + "clearIfPresent", + ], + ChildDataResource: [ + "uri", + "isLoading", + "didInitialFetch", + "parentContainer", + "getParentContainer", + "hasData", + "ldoDataset", + "getRootContainer", + "createOrOverwrite", + "read", + "reload", + "load", + "delete", + "deleteIfPresent", + ], + BinaryResource: [ + "uri", + "isLoading", + "didInitialFetch", + "mimeType", + "fileExtension", + "getRootContainer", + "getParentContainer", + "uploadOrOverwrite", + "read", + "reload", + "load", + "delete", + "deleteIfPresent", + ], + AbsentContainerResource: [ + "uri", + "isLoading", + "didInitialFetch", + "parentContainer", + "getIsRootContainer", + "getParentContainer", + "getRootContainer", + "createContainerIn", + "createDataResourceIn", + "uploadBinaryIn", + "createOrOverwrite", + "create", + "createIfAbsent", + "read", + "reload", + "load", + "deleteIfPresent", + "clearIfPresent", + ], + AbsentChildDataResource: [ + "uri", + "isLoading", + "didInitialFetch", + "parentContainer", + "getParentContainer", + "getRootContainer", + "createOrOverwrite", + "create", + "createIfAbsent", + "read", + "reload", + "load", + "deleteIfPresent", + ], + AbsentBinaryResource: [ + "uri", + "isLoading", + "didInitialFetch", + "parentContainer", + "getParentContainer", + "getRootContainer", + "uploadOrOverwrite", + "upload", + "uploadIfAbsent", + "read", + "reload", + "load", + "deleteIfPresent", + ], + UnfetchedContainerResource: [ + "uri", + "isLoading", + "didInitialFetch", + "getIsRootContainer", + "getParentContainer", + "getRootContainer", + "createContainerIn", + "createDataResourceIn", + "uploadBinaryIn", + "createOrOverwrite", + "createIfAbsent", + "read", + "reload", + "load", + "clearIfPresent", + ], + UnfetchedChildDataResource: [ + "parentContainer", + "getParentContainer", + "uri", + "isLoading", + "didInitialFetch", + "getRootContainer", + "createOrOverwrite", + "createIfAbsent", + "read", + "reload", + "load", + "deleteIfPresent", + ], + UnfetchedBinaryResource: [ + "uri", + "isLoading", + "didInitialFetch", + "parentContainer", + "getParentContainer", + "getRootContainer", + "uploadOrOverwrite", + "createOrOverwrite", + "uploadIfAbsent", + "read", + "reload", + "load", + "deleteIfPresent", + ], +}; + +function processTypes() { + const usedKeys = new Set(); + const interfaces = Object.keys(resourceMethods); + const groupMap: Record = {}; + + interfaces.forEach((interfaceName) => { + resourceMethods[interfaceName].forEach((methodKey) => { + if (!usedKeys.has(methodKey)) { + usedKeys.add(methodKey); + + let groupName = ""; + interfaces.forEach((interfaceName) => { + if (resourceMethods[interfaceName].includes(methodKey)) { + groupName += `${interfaceName}|`; + } + }); + if (!groupMap[groupName]) { + groupMap[groupName] = []; + } + groupMap[groupName].push(methodKey); + } + }); + }); + + console.log(groupMap); +} +processTypes(); diff --git a/packages/solid/example/example.ts b/packages/solid/example/example.ts index 60aa3ec..9eaae91 100644 --- a/packages/solid/example/example.ts +++ b/packages/solid/example/example.ts @@ -1,195 +1,22 @@ -const resourceMethods: Record = { - RootContainerResource: [ - "uri", - "isLoading", - "didInitialFetch", - "ldoDataset", - "getIsRootContainer", - "createContainerIn", - "createDataResourceIn", - "uploadBinaryIn", - "createOrOverwrite", - "read", - "reload", - "load", - "clear", - "clearIfPresent", - ], - ContainerResource: [ - "uri", - "isLoading", - "didInitialFetch", - "parentContainer", - "getIsRootContainer", - "getParentContainer", - "childResources", - "getRootContainer", - "createContainerIn", - "createDataResourceIn", - "uploadBinaryIn", - "ldoDataset", - "createOrOverwrite", - "read", - "reload", - "load", - "delete", - "deleteIfPresent", - "clear", - "clearIfPresent", - ], - ChildDataResource: [ - "uri", - "isLoading", - "didInitialFetch", - "parentContainer", - "getParentContainer", - "hasData", - "ldoDataset", - "getRootContainer", - "createOrOverwrite", - "read", - "reload", - "load", - "delete", - "deleteIfPresent", - ], - BinaryResource: [ - "uri", - "isLoading", - "didInitialFetch", - "mimeType", - "fileExtension", - "getRootContainer", - "getParentContainer", - "uploadOrOverwrite", - "read", - "reload", - "load", - "delete", - "deleteIfPresent", - ], - AbsentContainerResource: [ - "uri", - "isLoading", - "didInitialFetch", - "parentContainer", - "getIsRootContainer", - "getParentContainer", - "getRootContainer", - "createContainerIn", - "createDataResourceIn", - "uploadBinaryIn", - "createOrOverwrite", - "create", - "createIfAbsent", - "read", - "reload", - "load", - "deleteIfPresent", - "clearIfPresent", - ], - AbsentChildDataResource: [ - "uri", - "isLoading", - "didInitialFetch", - "parentContainer", - "getParentContainer", - "getRootContainer", - "createOrOverwrite", - "create", - "createIfAbsent", - "read", - "reload", - "load", - "deleteIfPresent", - ], - AbsentBinaryResource: [ - "uri", - "isLoading", - "didInitialFetch", - "parentContainer", - "getParentContainer", - "getRootContainer", - "uploadOrOverwrite", - "upload", - "uploadIfAbsent", - "read", - "reload", - "load", - "deleteIfPresent", - ], - UnfetchedContainerResource: [ - "uri", - "isLoading", - "didInitialFetch", - "getIsRootContainer", - "getParentContainer", - "getRootContainer", - "createContainerIn", - "createDataResourceIn", - "uploadBinaryIn", - "createOrOverwrite", - "createIfAbsent", - "read", - "reload", - "load", - "clearIfPresent", - ], - UnfetchedChildDataResource: [ - "parentContainer", - "getParentContainer", - "uri", - "isLoading", - "didInitialFetch", - "getRootContainer", - "createOrOverwrite", - "createIfAbsent", - "read", - "reload", - "load", - "deleteIfPresent", - ], - UnfetchedBinaryResource: [ - "uri", - "isLoading", - "didInitialFetch", - "parentContainer", - "getParentContainer", - "getRootContainer", - "uploadOrOverwrite", - "createOrOverwrite", - "uploadIfAbsent", - "read", - "reload", - "load", - "deleteIfPresent", - ], -}; +import { Mixin } from "ts-mixer"; -function processTypes() { - const usedKeys = new Set(); - const interfaces = Object.keys(resourceMethods); - const groupMap: Record = {}; - - interfaces.forEach((interfaceName) => { - resourceMethods[interfaceName].forEach((methodKey) => { - if (!usedKeys.has(methodKey)) { - usedKeys.add(methodKey); +class Foo { + protected makeFoo() { + return "foo"; + } +} - let groupName = ""; - interfaces.forEach((interfaceName) => { - if (resourceMethods[interfaceName].includes(methodKey)) { - groupName += `${interfaceName}|`; - } - }); - if (!groupMap[groupName]) { - groupMap[groupName] = []; - } - groupMap[groupName].push(methodKey); - } - }); - }); +class Bar { + protected makeFoo() { + return "bar"; + } +} - console.log(groupMap); +class FooBar extends Mixin(Foo, Bar) { + public makeFooBar() { + return this.makeFoo() + this.makeFoo(); + } } -processTypes(); + +const fooBar = new FooBar(); +console.log(fooBar.makeFooBar()); diff --git a/packages/solid/src/ProcessManager.ts b/packages/solid/src/ProcessManager.ts new file mode 100644 index 0000000..42e26f6 --- /dev/null +++ b/packages/solid/src/ProcessManager.ts @@ -0,0 +1,9 @@ +interface loadingStatus; + +export class LoadingManager { + private loadingStatus: Record]>> + + public registerProcess(): void { + + } +} \ No newline at end of file diff --git a/packages/solid/src/ResourceStore.ts b/packages/solid/src/ResourceStore.ts new file mode 100644 index 0000000..d9c95fd --- /dev/null +++ b/packages/solid/src/ResourceStore.ts @@ -0,0 +1,72 @@ +import type { SolidLdoDatasetContext } from "../SolidLdoDatasetContext"; +import type { FetchableDocument } from "./FetchableDocument"; +import type { ResourceClass } from "./resource/abstract/AbstractResource"; +import type { ContainerClass } from "./resource/abstract/container/Container"; +import type { LeafClass } from "./resource/abstract/leaf/Leaf"; +import { UnfetchedContainer } from "./resource/concrete/UnfetchedContainer"; +import { UnfetchedLeaf } from "./resource/concrete/UnfetchedLeaf"; +import { ContainerUri, LeafUri, isContainerUri } from "./uriTypes"; + +export interface ResourceGetterOptions { + autoLoad?: boolean; +} + +export class ResourceStore { + protected resourceMap: Map; + protected context: SolidLdoDatasetContext; + + constructor(context: SolidLdoDatasetContext) { + this.documentMap = new Map(); + this.context = context; + } + + get(uri: ContainerUri, options?: ResourceGetterOptions): ContainerClass; + get(uri: LeafUri, options?: ResourceGetterOptions): LeafClass; + get(uri: string, options?: ResourceGetterOptions): ResourceClass; + get(uri: string, options?: ResourceGetterOptions): ResourceClass { + // Normalize URI by removing hash + const url = new URL(uri); + url.hash = ""; + const normalizedUri = url.toString(); + + // Get the document and return if exists + let resource = this.resourceMap.get(normalizedUri); + if (!resource) { + if (isContainerUri(normalizedUri)) { + resource = new UnfetchedContainer(); + } else { + resource = new UnfetchedLeaf(); + } + this.resourceMap.set(normalizedUri, resource); + } + + if (options?.autoLoad) { + resource.read(); + } + + return resource; + + + throw new Error("Not Implemented"); + // const initializer = this.normalizeInitializer(initializerInput); + // const document = this.documentMap.get(initializer); + // if (document) { + // if (options?.autoLoad) { + // document.read(); + // } + // return document; + // } + // const newDocument = this.create(initializer, options); + // this.documentMap.set(initializer, newDocument); + // return newDocument; + } +} + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore +const resourceStore = new ResourceStore(); + +const container = resourceStore.get("https://jackson.com/"); +const leaf = resourceStore.get("https://jackson.com/item.ttl"); +const thing: string = "https://jackson.com/"; +const resource = resourceStore.get(thing); diff --git a/packages/solid/src/SolidLdoDatasetContext.ts b/packages/solid/src/SolidLdoDatasetContext.ts index 1697218..f5c0f13 100644 --- a/packages/solid/src/SolidLdoDatasetContext.ts +++ b/packages/solid/src/SolidLdoDatasetContext.ts @@ -1,9 +1,5 @@ import type TypedEmitter from "typed-emitter"; import type { SolidLdoDataset } from "./SolidLdoDataset"; -import type { ContainerResourceStore } from "./document/resource/dataResource/containerResource/ContainerResourceStore"; -import type { AccessRulesStore } from "./document/accessRules/AccessRulesStore"; -import type { DataResourceStore } from "./document/resource/dataResource/DataResourceStore"; -import type { BinaryResourceStore } from "./document/resource/binaryResource/BinaryResourceStore"; import type { DocumentError } from "./document/errors/DocumentError"; export type OnDocumentErrorCallback = (error: DocumentError) => void; @@ -16,8 +12,4 @@ export interface SolidLdoDatasetContext { solidLdoDataset: SolidLdoDataset; documentEventEmitter: DocumentEventEmitter; fetch: typeof fetch; - accessRulesStore: AccessRulesStore; - containerResourceStore: ContainerResourceStore; - dataResourceStore: DataResourceStore; - binaryResourceStore: BinaryResourceStore; } diff --git a/packages/solid/src/resource-old/container/AbsentContainer.ts b/packages/solid/src/resource-old/container/AbsentContainer.ts deleted file mode 100644 index 5224fb3..0000000 --- a/packages/solid/src/resource-old/container/AbsentContainer.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type { Absent, FetchedContainer } from "../types"; -import type { LdoSolidError } from "../types"; -import { Container } from "./Container"; -import type { PresentContainerClass } from "./presentContainer/PresentContainer"; - -export class AbsentContainer - extends Container - implements Absent, FetchedContainer -{ - get isBinary(): false { - return false; - } - get isDataResource(): false { - return false; - } - get isPresent(): false { - return false; - } - get isAbsent(): true { - return true; - } - get isUnfetched(): false { - return false; - } - get isRootContainer(): false { - return false; - } - get isBranchContainer(): true { - return true; - } - - async getIsRootContainer(): Promise { - return false; - } - - async create(): Promise { - throw new Error("Not Implemented"); - } -} diff --git a/packages/solid/src/resource-old/container/Container.ts b/packages/solid/src/resource-old/container/Container.ts deleted file mode 100644 index 025392d..0000000 --- a/packages/solid/src/resource-old/container/Container.ts +++ /dev/null @@ -1,77 +0,0 @@ -import type { - FetchedContainerClass, - LdoSolidError, - PotentialContainer, - Resource, -} from "../types"; -import type { AbsentContainer } from "./AbsentContainer"; -import type { UnfetchedContainer } from "./UnfetchedContainer"; -import type { BranchContainer } from "./presentContainer/BranchContainer"; -import type { RootContainer } from "./presentContainer/RootContainer"; -import type { DataLeaf } from "../leaf/presentLeaf/DataLeaf"; -import type { BinaryLeaf } from "../leaf/presentLeaf/BinaryLeaf"; -import type { PresentContainerClass } from "./presentContainer/PresentContainer"; - -export type ContainerClass = - | BranchContainer - | RootContainer - | AbsentContainer - | UnfetchedContainer; - -export abstract class Container implements Resource, PotentialContainer { - abstract get isRootContainer(): boolean | undefined; - abstract get isBranchContainer(): boolean | undefined; - abstract get isPresent(): boolean; - abstract get isAbsent(): boolean; - abstract get isUnfetched(): boolean; - abstract get isBinary(): boolean | undefined; - abstract get isDataResource(): boolean | undefined; - - uri: string; - isLoading: boolean; - - read(): Promise { - throw new Error("Not Implemented"); - } - reload(): Promise { - return this.read(); - } - load(): Promise { - return this.read(); - } - getCurrent(): ContainerClass { - throw new Error("Method not implemented."); - } - - abstract getIsRootContainer(): Promise; - - createContainerIn( - _relativeUri: string, - ): Promise { - throw new Error("Not Implemented"); - } - - createLeafDataResourceIn( - _relativeUri: string, - ): Promise { - throw new Error("Not Implemented"); - } - - uploadBinaryIn( - _relativeUri, - _blob: Blob, - ): Promise { - throw new Error("Not Implemented"); - } - - clearIfPresent(): Promise { - throw new Error("Not Implemented"); - } - - createIfAbsent(): Promise { - throw new Error("Method not implemented."); - } - createOrOverwrite(): Promise { - throw new Error("Method not implemented."); - } -} diff --git a/packages/solid/src/resource-old/container/UnfetchedContainer.ts b/packages/solid/src/resource-old/container/UnfetchedContainer.ts deleted file mode 100644 index 445a495..0000000 --- a/packages/solid/src/resource-old/container/UnfetchedContainer.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { Unfetched } from "../types"; -import { Container } from "./Container"; - -export class UnfetchedContainer extends Container implements Unfetched { - get isBinary(): undefined { - return undefined; - } - get isDataResource(): undefined { - return undefined; - } - get isRootContainer(): undefined { - return undefined; - } - get isBranchContainer(): undefined { - return undefined; - } - get isPresent(): false { - return false; - } - get isAbsent(): false { - return false; - } - get isUnfetched(): true { - return true; - } - - getIsRootContainer(): Promise { - throw new Error("Method not implemented."); - } -} diff --git a/packages/solid/src/resource-old/container/presentContainer/BranchContainer.ts b/packages/solid/src/resource-old/container/presentContainer/BranchContainer.ts deleted file mode 100644 index 6364a18..0000000 --- a/packages/solid/src/resource-old/container/presentContainer/BranchContainer.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { PresentContainer } from "./PresentContainer"; - -export class BranchContainer extends PresentContainer { - get isRootContainer(): false { - return false; - } - get isBranchContainer(): true { - return true; - } - - async getIsRootContainer(): Promise { - return false; - } - - getCurrent(): this { - throw new Error("Method not implemented."); - } -} diff --git a/packages/solid/src/resource-old/container/presentContainer/PresentContainer.ts b/packages/solid/src/resource-old/container/presentContainer/PresentContainer.ts deleted file mode 100644 index cc997bb..0000000 --- a/packages/solid/src/resource-old/container/presentContainer/PresentContainer.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { LdoDataset } from "@ldo/ldo"; -import type { DataResource, FetchedContainer, Present } from "../../types"; -import { Container } from "../Container"; -import type { BranchContainer } from "./BranchContainer"; -import type { RootContainer } from "./RootContainer"; - -export type PresentContainerClass = BranchContainer | RootContainer; -export abstract class PresentContainer - extends Container - implements Present, DataResource, FetchedContainer -{ - get isPresent(): true { - return true; - } - get isAbsent(): false { - return false; - } - get isUnfetched(): false { - return false; - } - get isDataResource(): true { - return true; - } - get isBinary(): false { - return false; - } - - get ldoDataset(): LdoDataset { - throw new Error("Not Implemented"); - } -} diff --git a/packages/solid/src/resource-old/container/presentContainer/RootContainer.ts b/packages/solid/src/resource-old/container/presentContainer/RootContainer.ts deleted file mode 100644 index 3b060f4..0000000 --- a/packages/solid/src/resource-old/container/presentContainer/RootContainer.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { PresentContainer } from "./PresentContainer"; - -export class RootContainer extends PresentContainer { - get isRootContainer(): true { - return true; - } - get isBranchContainer(): false { - return false; - } - - async getIsRootContainer(): Promise { - return true; - } -} diff --git a/packages/solid/src/resource-old/leaf/AbsentLeaf.ts b/packages/solid/src/resource-old/leaf/AbsentLeaf.ts deleted file mode 100644 index 3afc42c..0000000 --- a/packages/solid/src/resource-old/leaf/AbsentLeaf.ts +++ /dev/null @@ -1,56 +0,0 @@ -import type { - Absent, - FetchedLeaf, - LdoSolidError, - PotentialBinary, - PotentialData, -} from "../types"; -import { Leaf } from "./Leaf"; -import type { BinaryLeaf } from "./presentLeaf/BinaryLeaf"; -import type { DataLeaf } from "./presentLeaf/DataLeaf"; -import type { PresentLeafClass } from "./presentLeaf/PresentLeaf"; - -export class AbsentLeaf - extends Leaf - implements Absent, PotentialBinary, PotentialData, FetchedLeaf -{ - get isBinary(): false { - return false; - } - get isDataResource(): false { - return false; - } - get isPresent(): false { - return false; - } - get isAbsent(): true { - return true; - } - get isUnfetched(): false { - return false; - } - - async getIsRootContainer(): Promise { - return false; - } - - async upload(_blob: Blob): Promise { - throw new Error("Not Implemented"); - } - uploadIfAbsent(_blob: Blob): Promise { - throw new Error("Method not implemented."); - } - uploadOrOverwrite(_blob: Blob): Promise { - throw new Error("Method not implemented."); - } - - async create(): Promise { - throw new Error("Not Implemented"); - } - createIfAbsent(): Promise { - throw new Error("Method not implemented."); - } - createOrOverwrite(): Promise { - throw new Error("Method not implemented."); - } -} diff --git a/packages/solid/src/resource-old/leaf/Leaf.ts b/packages/solid/src/resource-old/leaf/Leaf.ts deleted file mode 100644 index 67edb42..0000000 --- a/packages/solid/src/resource-old/leaf/Leaf.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { FetchedLeafClass, LdoSolidError, Resource } from "../types"; -import type { AbsentLeaf } from "./AbsentLeaf"; -import type { UnfetchedLeaf } from "./UnfetchedLeaf"; -import type { BinaryLeaf } from "./presentLeaf/BinaryLeaf"; -import type { DataLeaf } from "./presentLeaf/DataLeaf"; - -export type LeafClass = UnfetchedLeaf | AbsentLeaf | BinaryLeaf | DataLeaf; - -export abstract class Leaf implements Resource { - abstract get isBinary(): boolean | undefined; - abstract get isDataResource(): boolean | undefined; - abstract get isPresent(): boolean; - abstract get isAbsent(): boolean; - abstract get isUnfetched(): boolean; - - uri: string; - isLoading: boolean; - - read(): Promise { - throw new Error("Not Implemented"); - } - reload(): Promise { - return this.read(); - } - load(): Promise { - return this.read(); - } - getCurrent(): LeafClass { - throw new Error("Not Implemented"); - } - - async createOrOverwrite(): Promise { - throw new Error("Not Implemented"); - } - async uploadOrOverwrite(_blob: Blob): Promise { - throw new Error("Method not implemented."); - } -} diff --git a/packages/solid/src/resource-old/leaf/UnfetchedLeaf.ts b/packages/solid/src/resource-old/leaf/UnfetchedLeaf.ts deleted file mode 100644 index ccbb395..0000000 --- a/packages/solid/src/resource-old/leaf/UnfetchedLeaf.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { - LdoSolidError, - PotentialBinary, - PotentialData, - Unfetched, -} from "../types"; -import { Leaf } from "./Leaf"; -import type { BinaryLeaf } from "./presentLeaf/BinaryLeaf"; -import type { DataLeaf } from "./presentLeaf/DataLeaf"; -import type { PresentLeaf } from "./presentLeaf/PresentLeaf"; - -export class UnfetchedLeaf - extends Leaf - implements Unfetched, PotentialBinary, PotentialData -{ - get isBinary(): undefined { - return undefined; - } - get isDataResource(): undefined { - return undefined; - } - get isPresent(): false { - return false; - } - get isAbsent(): false { - return false; - } - get isUnfetched(): true { - return true; - } - - getIsRootContainer(): Promise { - throw new Error("Method not implemented."); - } - - uploadIfAbsent(_blob: Blob): Promise { - throw new Error("Method not implemented."); - } - uploadOrOverwrite(_blob: Blob): Promise { - throw new Error("Method not implemented."); - } - - createIfAbsent(): Promise { - throw new Error("Method not implemented."); - } - createOrOverwrite(): Promise { - throw new Error("Method not implemented."); - } -} diff --git a/packages/solid/src/resource-old/leaf/presentLeaf/BinaryLeaf.ts b/packages/solid/src/resource-old/leaf/presentLeaf/BinaryLeaf.ts deleted file mode 100644 index b27d47b..0000000 --- a/packages/solid/src/resource-old/leaf/presentLeaf/BinaryLeaf.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { LdoSolidError, PotentialBinary } from "../../types"; -import { PresentLeaf } from "./PresentLeaf"; - -export class BinaryLeaf extends PresentLeaf implements PotentialBinary { - get isBinary(): true { - return true; - } - get isDataResource(): false { - return false; - } - - uploadIfAbsent(_blob: Blob): Promise { - throw new Error("Method not implemented."); - } -} diff --git a/packages/solid/src/resource-old/leaf/presentLeaf/DataLeaf.ts b/packages/solid/src/resource-old/leaf/presentLeaf/DataLeaf.ts deleted file mode 100644 index 5423419..0000000 --- a/packages/solid/src/resource-old/leaf/presentLeaf/DataLeaf.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { LdoDataset } from "@ldo/ldo"; -import type { DataResource, LdoSolidError, PotentialData } from "../../types"; -import { PresentLeaf } from "./PresentLeaf"; - -export class DataLeaf - extends PresentLeaf - implements DataResource, PotentialData -{ - get isBinary(): false { - return false; - } - get isDataResource(): true { - return true; - } - - get ldoDataset(): LdoDataset { - throw new Error("Not Implemented"); - } - - createIfAbsent(): Promise { - throw new Error("Method not implemented."); - } - createOrOverwrite(): Promise { - throw new Error("Method not implemented."); - } -} diff --git a/packages/solid/src/resource-old/leaf/presentLeaf/PresentLeaf.ts b/packages/solid/src/resource-old/leaf/presentLeaf/PresentLeaf.ts deleted file mode 100644 index a16e571..0000000 --- a/packages/solid/src/resource-old/leaf/presentLeaf/PresentLeaf.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { FetchedLeaf, Present } from "../../types"; -import { Leaf } from "../Leaf"; -import type { BinaryLeaf } from "./BinaryLeaf"; -import type { DataLeaf } from "./DataLeaf"; - -export type PresentLeafClass = DataLeaf | BinaryLeaf; -export abstract class PresentLeaf extends Leaf implements Present, FetchedLeaf { - get isPresent(): true { - return true; - } - get isAbsent(): false { - return false; - } - get isUnfetched(): false { - return false; - } -} diff --git a/packages/solid/src/resource-old/notes.ts b/packages/solid/src/resource-old/notes.ts deleted file mode 100644 index 9c020ae..0000000 --- a/packages/solid/src/resource-old/notes.ts +++ /dev/null @@ -1,249 +0,0 @@ -const thing = { - "RootContainerResource|ContainerResource|ChildDataResource|BinaryResource|AbsentContainerResource|AbsentChildDataResource|AbsentBinaryResource|UnfetchedContainerResource|UnfetchedChildDataResource|UnfetchedBinaryResource|": - ["uri", "isLoading", "didInitialFetch", "read", "reload", "load"], - "RootContainerResource|ContainerResource|ChildDataResource|": ["ldoDataset"], - "RootContainerResource|ContainerResource|AbsentContainerResource|UnfetchedContainerResource|": - [ - "getIsRootContainer", - "createContainerIn", - "createDataResourceIn", - "uploadBinaryIn", - "clearIfPresent", - ], - "RootContainerResource|ContainerResource|ChildDataResource|AbsentContainerResource|AbsentChildDataResource|UnfetchedContainerResource|UnfetchedChildDataResource|UnfetchedBinaryResource|": - ["createOrOverwrite"], - "RootContainerResource|ContainerResource|": ["clear"], - "ContainerResource|ChildDataResource|AbsentContainerResource|AbsentChildDataResource|AbsentBinaryResource|UnfetchedChildDataResource|UnfetchedBinaryResource|": - ["parentContainer"], - "ContainerResource|ChildDataResource|BinaryResource|AbsentContainerResource|AbsentChildDataResource|AbsentBinaryResource|UnfetchedContainerResource|UnfetchedChildDataResource|UnfetchedBinaryResource|": - ["getParentContainer", "getRootContainer"], - "ContainerResource|": ["childResources"], - "ContainerResource|ChildDataResource|BinaryResource|": ["delete"], - "ContainerResource|ChildDataResource|BinaryResource|AbsentContainerResource|AbsentChildDataResource|AbsentBinaryResource|UnfetchedChildDataResource|UnfetchedBinaryResource|": - ["deleteIfPresent"], - "ChildDataResource|": ["hasData"], - "BinaryResource|": ["mimeType", "fileExtension"], - "BinaryResource|AbsentBinaryResource|UnfetchedBinaryResource|": [ - "uploadOrOverwrite", - ], - "AbsentContainerResource|AbsentChildDataResource|": ["create"], - "AbsentContainerResource|AbsentChildDataResource|UnfetchedContainerResource|UnfetchedChildDataResource|": - ["createIfAbsent"], - "AbsentBinaryResource|": ["upload"], - "AbsentBinaryResource|UnfetchedBinaryResource|": ["uploadIfAbsent"], -}; - -import { LdoDataset } from "@ldo/ldo"; -import { Quad } from "@rdfjs/types"; -import { create } from "domain"; -import { URL } from "url"; -import { SolidLdoDataset } from "../SolidLdoDataset"; - -export type ResourceStatus = BinaryResourceStatus | DataResourceStatus | ErrorResource | ErrorResourceStatus; - -export type BinaryResourceStore; - -/** - * Method and information definitions - */ -export interface IResource { - id: URL; - isDataResource: true, - -} - -/** - * Abstract Definitions - */ -export interface IDataResource extends IResource { - isDataResource: true; -} - -export interface IContainerResource extends IResource { - otherMethod(): void; -} - -/** - * Concrete Definitions - */ - -clearIfPresent - -export interface BinaryResource { - uri: string; - isLoading: boolean; - didInitialFetch: true; - mimeType: string; - fileExtension: string; - getRootContainer(): Promise; - getParentContainer(): Promise; - uploadOrOverwrite(blob: Blob): Promise; - read(): Promise; - reload(): Promise; - load(): Promise; - delete(): Promise; - deleteIfPresent(): Promise; -} - -export interface RootContainerResource { - uri: string; - isLoading: boolean; - didInitialFetch: true; - ldoDataset(): LdoDataset; - getIsRootContainer(): Promise; - createContainerIn(relativeUri: string): Promise; - createDataResourceIn(relativeUri: string): Promise; - uploadBinaryIn(relativeUri, blob: Blob): Promise; - createOrOverwrite(): Promise; - read(): Promise; - reload(): Promise; - load(): Promise; - clear(): Promise; - clearIfPresent(): Promise; -} - -export interface ContainerResource { - uri: string; - isLoading: boolean; - didInitialFetch: true; - parentContainer: ContainerResource | RootContainerResource; - getIsRootContainer(): Promise; - getParentContainer(): Promise; - childResources: ContainerResource | DataResource | BinaryResource | UnfetchedContainerResource | UnfetchedDataResource | UnfetchedBinaryResource; - getRootContainer(): Promise; - createContainerIn(relativeUri: string): Promise; - createDataResourceIn(relativeUri: string): Promise; - uploadBinaryIn(relativeUri, blob: Blob): Promise; - ldoDataset(): LdoDataset; - createOrOverwrite(): Promise; - read(): Promise; - reload(): Promise; - load(): Promise; - delete(): Promise; - deleteIfPresent(): Promise; - clear(): Promise; - clearIfPresent(): Promise; -} - -export interface DataResource { - uri: string; - isLoading: boolean; - didInitialFetch: true; - parentContainer: ContainerResource | RootContainerResource; - getParentContainer(): Promise; - hasData(): boolean; - ldoDataset(): LdoDataset; - getRootContainer(): Promise; - createOrOverwrite(): Promise; - read(): Promise; - reload(): Promise; - load(): Promise; - delete(): Promise; - deleteIfPresent(): Promise; -} - -export interface AbsentDataResource { - uri: string; - isLoading: boolean; - didInitialFetch: true; - parentContainer: ContainerResource | RootContainerResource; - getParentContainer(): Promise; - getRootContainer(): Promise; - createOrOverwrite(): Promise; - create(): Promise; - createIfAbsent(): Promise; - read(): Promise; - reload(): Promise; - load(): Promise; - deleteIfPresent(): Promise; -} - -export interface AbsentBinaryResource { - uri: string; - isLoading: boolean; - didInitialFetch: true; - parentContainer: ContainerResource | RootContainerResource; - getParentContainer(): Promise; - getRootContainer(): Promise; - uploadOrOverwrite(blob: Blob): Promise; - upload(blob: Blob): Promise; - uploadIfAbsent(blob: Blob): Promise; - read(): Promise; - reload(): Promise; - load(): Promise; - deleteIfPresent(): Promise; -} - -export interface AbsentContainerResource { - uri: string; - isLoading: boolean; - didInitialFetch: true; - parentContainer: ContainerResource | RootContainerResource; - getIsRootContainer(): Promise; - getParentContainer(): Promise; - getRootContainer(): Promise; - createContainerIn(relativeUri: string): Promise; - createDataResourceIn(relativeUri: string): Promise; - uploadBinaryIn(relativeUri, blob: Blob): Promise; - createOrOverwrite(): Promise; - create(): Promise; - createIfAbsent(): Promise; - read(): Promise; - reload(): Promise; - load(): Promise; - deleteIfPresent(): Promise; - clearIfPresent(): Promise; -} - -export interface UnfetchedDataResource { - parentContainer: ContainerResource | RootContainerResource; - getParentContainer(): Promise; - uri: string; - isLoading: boolean; - didInitialFetch: false; - getRootContainer(): Promise; - createOrOverwrite(): Promise; - createIfAbsent(): Promise; - read(): Promise; - reload(): Promise; - load(): Promise; - deleteIfPresent(): Promise; -} - -export interface UnfetchedBinaryResource { - uri: string; - isLoading: boolean; - didInitialFetch: false; - parentContainer: ContainerResource | RootContainerResource; - getParentContainer(): Promise; - getRootContainer(): Promise; - uploadOrOverwrite(blob: Blob): Promise - createOrOverwrite(): Promise; - uploadIfAbsent(blob: Blob): Promise; - read(): Promise; - reload(): Promise; - load(): Promise; - deleteIfPresent(): Promise; -} - -export interface UnfetchedContainerResource { - uri: string; - isLoading: boolean; - didInitialFetch: false; - getIsRootContainer(): Promise; - getParentContainer(): Promise; - getRootContainer(): Promise; - createContainerIn(relativeUri: string): Promise; - createDataResourceIn(relativeUri: string): Promise; - uploadBinaryIn(relativeUri, blob: Blob): Promise; - createOrOverwrite(): Promise; - createIfAbsent(): Promise; - read(): Promise; - reload(): Promise; - load(): Promise; - clearIfPresent(): Promise; -} - -export interface LdoSolidError extends Error { - forResource: unknown // Some Kind of Resource -} diff --git a/packages/solid/src/resource-old/types.ts b/packages/solid/src/resource-old/types.ts deleted file mode 100644 index 81a0adc..0000000 --- a/packages/solid/src/resource-old/types.ts +++ /dev/null @@ -1,97 +0,0 @@ -import type { LdoDataset } from "@ldo/ldo"; -import type { AbsentLeaf } from "./leaf/AbsentLeaf"; -import type { UnfetchedLeaf } from "./leaf/UnfetchedLeaf"; -import type { BinaryLeaf } from "./leaf/presentLeaf/BinaryLeaf"; -import type { BranchContainer } from "./container/presentContainer/BranchContainer"; -import type { RootContainer } from "./container/presentContainer/RootContainer"; -import type { DataLeaf } from "./leaf/presentLeaf/DataLeaf"; -import type { AbsentContainer } from "./container/AbsentContainer"; -import type { UnfetchedContainer } from "./container/UnfetchedContainer"; -import type { PresentContainerClass } from "./container/presentContainer/PresentContainer"; -import type { PresentLeaf } from "./leaf/presentLeaf/PresentLeaf"; - -export interface LdoSolidError extends Error {} - -export type ResouceClass = - | RootContainer - | BranchContainer - | DataLeaf - | BinaryLeaf - | AbsentContainer - | AbsentLeaf - | UnfetchedContainer - | UnfetchedLeaf; -export interface Resource { - uri: string; - isLoading: boolean; - isAbsent: boolean; - isUnfetched: boolean; - isPresent: boolean; - isBinary: boolean | undefined; - isDataResource: boolean | undefined; -} - -export type AbsentClass = AbsentContainer | AbsentLeaf; -export interface Absent { - isAbsent: true; - isUnfetched: false; - isPresent: false; - isBinary: false; - isDataResource: false; -} - -export type UnfetchedClass = UnfetchedContainer | UnfetchedLeaf; -export interface Unfetched { - isUnfetched: true; - isAbsent: false; - isPresent: false; - isBinary: undefined; - isDataResource: undefined; -} - -export type PresentClass = - | RootContainer - | BranchContainer - | DataLeaf - | BinaryLeaf; -export interface Present { - isPresent: true; - isAbsent: false; - isUnfetched: false; -} - -export type DataResourceClass = BranchContainer | RootContainer; -export interface DataResource { - isDataResource: true; - isBinary: false; - ldoDataset: LdoDataset; -} - -export type PotentialBinaryClass = AbsentLeaf | UnfetchedLeaf | BinaryLeaf; -export interface PotentialBinary { - uploadIfAbsent(blob: Blob): Promise; - uploadOrOverwrite(blob: Blob): Promise; -} - -export type PotentialDataClass = AbsentLeaf | UnfetchedLeaf | DataLeaf; -export interface PotentialData { - createIfAbsent(): Promise; -} - -export type PotentialContainerClass = - | RootContainer - | BranchContainer - | AbsentContainer - | UnfetchedContainer; -export interface PotentialContainer { - createIfAbsent(): Promise; -} - -export type FetchedContainerClass = - | RootContainer - | BranchContainer - | AbsentContainer; -export interface FetchedContainer {} - -export type FetchedLeafClass = DataLeaf | BinaryLeaf | AbsentLeaf; -export interface FetchedLeaf {} diff --git a/packages/solid/src/resource/Container.ts b/packages/solid/src/resource/Container.ts new file mode 100644 index 0000000..04c41ed --- /dev/null +++ b/packages/solid/src/resource/Container.ts @@ -0,0 +1,3 @@ +import { Resource } from "./Resource"; + +export class Container extends Resource {} diff --git a/packages/solid/src/resource/Leaf.ts b/packages/solid/src/resource/Leaf.ts new file mode 100644 index 0000000..981c61e --- /dev/null +++ b/packages/solid/src/resource/Leaf.ts @@ -0,0 +1,86 @@ +// import type { LdoDataset } from "@ldo/ldo"; +// import type { LeafMethodNotAllowedError } from "./error/MethodNotAllowedError"; +// import type { DatasetChanges } from "@ldo/rdf-utils"; +// import type { PresentContainer } from "./abstract/container/PresentContainer"; +import type { SolidLdoDatasetContext } from "../SolidLdoDatasetContext"; +import type { LeafUri } from "../uriTypes"; +import { Resource } from "./Resource"; + +export interface ConcreteInstance { + uri: LeafUri; + context: SolidLdoDatasetContext; + // methods: typeof AbstractLeaf; +} + +// REMEMBER: This file should be replaced with non abstract methods +export abstract class ConcreteLeaf extends Resource { + // // All intance variables + // private readonly i: SolidLdoDatasetContext; + // uri: string; + // abstract type(): LeafType["type"]; + // // Loading Methods + // isLoading(): boolean { + // return ( + // this.isCreating() || + // this.isReading() || + // this.isUpdating() || + // this.isDeletinng() + // ); + // } + // abstract isCreating(): boolean; + // abstract isReading(): boolean; + // abstract isUpdating(): boolean; + // abstract isDeletinng(): boolean; + // isDoingInitialFetch(): boolean { + // return this.isReading() && !this.didInitialFetch(); + // } + // // Checkers + // abstract didInitialFetch(): boolean; + // abstract isFetched(): boolean; + // abstract isUnfetched(): boolean; + // abstract isBinary: boolean | undefined; + // abstract isDataResource(): boolean | undefined; + // // Read Methods + // abstract read(): Promise; + // abstract readIfUnfetched(): Promise; + // // Create Methods + // abstract createOrOverwrite(): Promise; + // abstract createOrOverwrite(blob: Blob): Promise; + // abstract createIfAbsent(): Promise; + // abstract createIfAbsent(blob: Blob): Promise; + // // Delete Method + // abstract delete(): Promise; + // // Parent Container Methods -- Remember to change for Container + // abstract getCachedParentContainer(): ContainerType | LdoSolidError; + // abstract getParentContainer(): Promise; + // abstract reloadParentContainer(): Promise; + // abstract getRootContainerFromCache(): + // | ContainerType + // | undefined + // | LdoSolidError; + // abstract getRootContainer(): Promise< + // FetchedContainerType | undefined | LdoSolidError + // >; + // abstract getRootContainerFromPod(): Promise< + // FetchedContainerType | undefined | LdoSolidError + // >; + // // Exclusing Methods ========================================================= + // // Data Methods (Data Leaf Only) + // abstract getLdoDataset(): LdoDataset | LeafMethodNotAllowedError; + // abstract reloadLdoDataset(): Promise; + // abstract hasData(): boolean | LeafMethodNotAllowedError; + // abstract reloadHasData(): Promise; + // abstract update( + // changes: DatasetChanges, + // ): Promise; + // // Binary Methods (Binary Only) + // abstract getMimeType(): string | LeafMethodNotAllowedError; + // abstract reloadMimeType(): Promise; + // // Create Methods (AbsentLeaf Only) + // abstract create(): Promise< + // DataLeaf | LdoSolidError | LeafMethodNotAllowedError + // >; + // abstract create( + // blob: Blob, + // ): Promise; +} diff --git a/packages/solid/src/resource/Resource.ts b/packages/solid/src/resource/Resource.ts new file mode 100644 index 0000000..be3a3a1 --- /dev/null +++ b/packages/solid/src/resource/Resource.ts @@ -0,0 +1 @@ +export class Resource {} diff --git a/packages/solid/src/resource/abstract/AbstractResource.ts b/packages/solid/src/resource/abstract/AbstractResource.ts new file mode 100644 index 0000000..7cd02e2 --- /dev/null +++ b/packages/solid/src/resource/abstract/AbstractResource.ts @@ -0,0 +1 @@ +export abstract class AbstractResource {} diff --git a/packages/solid/src/resource/abstract/Resource.ts b/packages/solid/src/resource/abstract/Resource.ts deleted file mode 100644 index 0a8e6d3..0000000 --- a/packages/solid/src/resource/abstract/Resource.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { AbsentContainer } from "../concrete/AbsentContainer"; -import type { AbsentLeaf } from "../concrete/AbsentLeaf"; -import type { BinaryLeaf } from "../concrete/BinaryLeaf"; -import type { BranchContainer } from "../concrete/BranchContainer"; -import type { DataLeaf } from "../concrete/DataLeaf"; -import type { RootContainer } from "../concrete/RootContainer"; -import type { UnfetchedLeaf } from "../concrete/UnfetchedLeaf"; -import type { UnfetchedContainer } from "../concrete/UnfetchedContainer"; -import type { SolidLdoError } from "../error/SolidLdoError"; -import type { FetchedClass } from "./fetchStatus/Fetched"; -import type { AbsentClass } from "./fetchStatus/Absent"; -import type { PresentClass } from "./fetchStatus/Present"; - -export type ResourceClass = - | RootContainer - | BranchContainer - | DataLeaf - | BinaryLeaf - | AbsentContainer - | AbsentLeaf - | UnfetchedContainer - | UnfetchedLeaf; -export abstract class Resource { - readonly uri: string; - readonly lastUpdated: Date; - - abstract read(): Promise; - abstract readIfUnfetched(): Promise; - - abstract createIfAbsent(): Promise; - abstract createOrOverride(): Promise; - - abstract deleteIfPresent(): Promise; - - abstract getCurrent(): ResourceClass; -} diff --git a/packages/solid/src/resource/abstract/container/AbsentContainer.ts b/packages/solid/src/resource/abstract/container/AbsentContainer.ts new file mode 100644 index 0000000..35cb8f1 --- /dev/null +++ b/packages/solid/src/resource/abstract/container/AbsentContainer.ts @@ -0,0 +1,5 @@ +import { Mixin } from "ts-mixer"; +import { PresentContainer } from "./PresentContainer"; +import { Absent } from "../fetchStatus/Absent"; + +export class AbsentContainer extends Mixin(PresentContainer, Absent) {} diff --git a/packages/solid/src/resource/abstract/container/AbstractContainer.ts b/packages/solid/src/resource/abstract/container/AbstractContainer.ts new file mode 100644 index 0000000..7410f25 --- /dev/null +++ b/packages/solid/src/resource/abstract/container/AbstractContainer.ts @@ -0,0 +1,3 @@ +import { AbstractResource } from "../AbstractResource"; + +export abstract class AbstractContainer extends AbstractResource {} diff --git a/packages/solid/src/resource/abstract/container/Container.ts b/packages/solid/src/resource/abstract/container/Container.ts deleted file mode 100644 index 1cb88a6..0000000 --- a/packages/solid/src/resource/abstract/container/Container.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { SolidLdoError } from "../../error/SolidLdoError"; -import { PotentialDataResource } from "../dataResource/potentialDataResource"; - -export class Container extends PotentialDataResource { - async read(): Promise { - // Make query - // Select the Kind of Leaf - // Create it - - // Post Processing - throw new Error("Not Implemented"); - } -} diff --git a/packages/solid/src/resource/abstract/container/FetchedContainer.ts b/packages/solid/src/resource/abstract/container/FetchedContainer.ts new file mode 100644 index 0000000..f179089 --- /dev/null +++ b/packages/solid/src/resource/abstract/container/FetchedContainer.ts @@ -0,0 +1,8 @@ +import { Mixin } from "ts-mixer"; +import { AbstractContainer } from "./AbstractContainer"; +import { Fetched } from "../fetchStatus/Fetched"; + +export abstract class FetchedContainer extends Mixin( + AbstractContainer, + Fetched, +) {} diff --git a/packages/solid/src/resource/abstract/container/PresentContainer.ts b/packages/solid/src/resource/abstract/container/PresentContainer.ts index 67cf181..1705e2a 100644 --- a/packages/solid/src/resource/abstract/container/PresentContainer.ts +++ b/packages/solid/src/resource/abstract/container/PresentContainer.ts @@ -1,9 +1,8 @@ import { Mixin } from "ts-mixer"; -import type { BranchContainer } from "../../concrete/BranchContainer"; -import type { RootContainer } from "../../concrete/RootContainer"; -import { DataResource } from "../dataResource/DataResource"; -import { Container } from "./Container"; +import { FetchedContainer } from "./FetchedContainer"; import { Present } from "../fetchStatus/Present"; -export type PresentContainerClass = RootContainer | BranchContainer; -export class PresentContainer extends Mixin(Container, Present, DataResource) {} +export abstract class PresentContainer extends Mixin( + FetchedContainer, + Present, +) {} diff --git a/packages/solid/src/resource/abstract/container/UnfetchedContainer.ts b/packages/solid/src/resource/abstract/container/UnfetchedContainer.ts new file mode 100644 index 0000000..90c1ccd --- /dev/null +++ b/packages/solid/src/resource/abstract/container/UnfetchedContainer.ts @@ -0,0 +1,5 @@ +import { Mixin } from "ts-mixer"; +import { AbstractContainer } from "./AbstractContainer"; +import { Unfetched } from "../fetchStatus/Unfetched"; + +export class UnfetchedContainer extends Mixin(AbstractContainer, Unfetched) {} diff --git a/packages/solid/src/resource/abstract/dataResource/DataResource.ts b/packages/solid/src/resource/abstract/dataResource/DataResource.ts deleted file mode 100644 index 4a9bacd..0000000 --- a/packages/solid/src/resource/abstract/dataResource/DataResource.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { BranchContainer } from "../../concrete/BranchContainer"; -import type { DataLeaf } from "../../concrete/DataLeaf"; -import type { RootContainer } from "../../concrete/RootContainer"; -import { PotentialDataResource } from "./potentialDataResource"; - -export type DataResourceClass = RootContainer | BranchContainer | DataLeaf; -export class DataResource extends PotentialDataResource {} diff --git a/packages/solid/src/resource/abstract/dataResource/PotentialDataResource.ts b/packages/solid/src/resource/abstract/dataResource/PotentialDataResource.ts deleted file mode 100644 index e6d6691..0000000 --- a/packages/solid/src/resource/abstract/dataResource/PotentialDataResource.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { AbsentContainer } from "../../concrete/AbsentContainer"; -import type { AbsentLeaf } from "../../concrete/AbsentLeaf"; -import type { BranchContainer } from "../../concrete/BranchContainer"; -import type { RootContainer } from "../../concrete/RootContainer"; -import type { UnfetchedContainer } from "../../concrete/UnfetchedContainer"; -import type { UnfetchedLeaf } from "../../concrete/UnfetchedLeaf"; -import type { SolidLdoError } from "../../error/SolidLdoError"; -import type { ResourceClass } from "../Resource"; -import { Resource } from "../Resource"; -import type { DataResource } from "./DataResource"; - -export type PotentialDataResourceClass = - | RootContainer - | BranchContainer - | DataResource - | AbsentContainer - | AbsentLeaf - | UnfetchedContainer - | UnfetchedLeaf; -export abstract class PotentialDataResource extends Resource< - ResourceClass, - SolidLdoError -> { - - abstract -} diff --git a/packages/solid/src/resource/abstract/fetchStatus/Absent.ts b/packages/solid/src/resource/abstract/fetchStatus/Absent.ts index 204a4cd..1264c82 100644 --- a/packages/solid/src/resource/abstract/fetchStatus/Absent.ts +++ b/packages/solid/src/resource/abstract/fetchStatus/Absent.ts @@ -1,17 +1,3 @@ -import type { AbsentContainer } from "../../concrete/AbsentContainer"; -import type { AbsentLeaf } from "../../concrete/AbsentLeaf"; -import type { SolidLdoError } from "../../error/SolidLdoError"; import { Fetched } from "./Fetched"; -import type { PresentClass } from "./Present"; -export type AbsentClass = AbsentContainer | AbsentLeaf; -export abstract class Absent extends Fetched { - public get isAbsent(): true { - return true; - } - public get isPresent(): false { - return false; - } - - abstract create(...args: unknown[]): Promise; -} +export abstract class Absent extends Fetched {} diff --git a/packages/solid/src/resource/abstract/fetchStatus/FetchStatus.ts b/packages/solid/src/resource/abstract/fetchStatus/FetchStatus.ts deleted file mode 100644 index f90454d..0000000 --- a/packages/solid/src/resource/abstract/fetchStatus/FetchStatus.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Resource } from "../Resource"; - -export abstract class FetchStatus extends Resource { - public abstract get didInitialFetch(): boolean; - public abstract get isAbsent(): boolean | undefined; - public abstract get isPresent(): boolean | undefined; -} diff --git a/packages/solid/src/resource/abstract/fetchStatus/Fetched.ts b/packages/solid/src/resource/abstract/fetchStatus/Fetched.ts index 05b7756..b123341 100644 --- a/packages/solid/src/resource/abstract/fetchStatus/Fetched.ts +++ b/packages/solid/src/resource/abstract/fetchStatus/Fetched.ts @@ -1,24 +1 @@ -import type { AbsentContainer } from "../../concrete/AbsentContainer"; -import type { AbsentLeaf } from "../../concrete/AbsentLeaf"; -import type { BinaryLeaf } from "../../concrete/BinaryLeaf"; -import type { BranchContainer } from "../../concrete/BranchContainer"; -import type { DataLeaf } from "../../concrete/DataLeaf"; -import type { RootContainer } from "../../concrete/RootContainer"; -import { FetchStatus } from "./FetchStatus"; - -export type FetchedClass = - | RootContainer - | BranchContainer - | DataLeaf - | BinaryLeaf - | AbsentContainer - | AbsentLeaf; -export abstract class Fetched extends FetchStatus { - public get didInitialFetch(): true { - return true; - } - - async readIfUnfetched(): Promise { - return this; - } -} +export abstract class Fetched {} diff --git a/packages/solid/src/resource/abstract/fetchStatus/Present.ts b/packages/solid/src/resource/abstract/fetchStatus/Present.ts index d980993..0aa7688 100644 --- a/packages/solid/src/resource/abstract/fetchStatus/Present.ts +++ b/packages/solid/src/resource/abstract/fetchStatus/Present.ts @@ -1,19 +1,3 @@ -import type { BinaryLeaf } from "../../concrete/BinaryLeaf"; -import type { BranchContainer } from "../../concrete/BranchContainer"; -import type { DataLeaf } from "../../concrete/DataLeaf"; -import type { RootContainer } from "../../concrete/RootContainer"; import { Fetched } from "./Fetched"; -export type PresentClass = - | RootContainer - | BranchContainer - | DataLeaf - | BinaryLeaf; -export abstract class Present extends Fetched { - public get isAbsent(): false { - return false; - } - public get isPresent(): true { - return true; - } -} +export abstract class Present extends Fetched {} diff --git a/packages/solid/src/resource/abstract/fetchStatus/Unfetched.ts b/packages/solid/src/resource/abstract/fetchStatus/Unfetched.ts index 855b099..4d13721 100644 --- a/packages/solid/src/resource/abstract/fetchStatus/Unfetched.ts +++ b/packages/solid/src/resource/abstract/fetchStatus/Unfetched.ts @@ -1,26 +1 @@ -import type { UnfetchedContainer } from "../../concrete/UnfetchedContainer"; -import type { UnfetchedLeaf } from "../../concrete/UnfetchedLeaf"; -import type { SolidLdoError } from "../../error/SolidLdoError"; -import { FetchStatus } from "./FetchStatus"; -import type { FetchedClass } from "./Fetched"; - -export type UnfetchedClass = UnfetchedContainer | UnfetchedLeaf; -export abstract class Unfetched< - ReadReturn extends FetchedClass, - ReadError extends SolidLdoError, -> extends FetchStatus { - public get didInitialFetch(): false { - return false; - } - public get isAbsent(): undefined { - return undefined; - } - public get isPresent(): undefined { - return undefined; - } - - async readIfUnfetched(): Promise { - return this.read(); - } - abstract read(): Promise; -} +export abstract class Unfetched {} diff --git a/packages/solid/src/resource/abstract/leaf/AbsentLeaf.ts b/packages/solid/src/resource/abstract/leaf/AbsentLeaf.ts new file mode 100644 index 0000000..7e1755d --- /dev/null +++ b/packages/solid/src/resource/abstract/leaf/AbsentLeaf.ts @@ -0,0 +1,5 @@ +import { Mixin } from "ts-mixer"; +import { Absent } from "../fetchStatus/Absent"; +import { FetchedLeaf } from "./FetchedLeaf"; + +export class AbsentLeaf extends Mixin(FetchedLeaf, Absent) {} diff --git a/packages/solid/src/resource/abstract/leaf/AbstractLeaf.ts b/packages/solid/src/resource/abstract/leaf/AbstractLeaf.ts new file mode 100644 index 0000000..60e0c05 --- /dev/null +++ b/packages/solid/src/resource/abstract/leaf/AbstractLeaf.ts @@ -0,0 +1,3 @@ +import { AbstractResource } from "../AbstractResource"; + +export abstract class AbstractLeaf extends AbstractResource {} diff --git a/packages/solid/src/resource/abstract/leaf/BinaryLeaf.ts b/packages/solid/src/resource/abstract/leaf/BinaryLeaf.ts new file mode 100644 index 0000000..f1008f6 --- /dev/null +++ b/packages/solid/src/resource/abstract/leaf/BinaryLeaf.ts @@ -0,0 +1,3 @@ +import { PresentLeaf } from "./PresentLeaf"; + +export class BinaryLeaf extends PresentLeaf {} diff --git a/packages/solid/src/resource/abstract/leaf/DataLeaf.ts b/packages/solid/src/resource/abstract/leaf/DataLeaf.ts new file mode 100644 index 0000000..6ced3f0 --- /dev/null +++ b/packages/solid/src/resource/abstract/leaf/DataLeaf.ts @@ -0,0 +1,3 @@ +import { PresentLeaf } from "./PresentLeaf"; + +export class DataLeaf extends PresentLeaf {} diff --git a/packages/solid/src/resource/abstract/leaf/FetchedLeaf.ts b/packages/solid/src/resource/abstract/leaf/FetchedLeaf.ts index 2c73569..ef8f12c 100644 --- a/packages/solid/src/resource/abstract/leaf/FetchedLeaf.ts +++ b/packages/solid/src/resource/abstract/leaf/FetchedLeaf.ts @@ -1,9 +1,5 @@ import { Mixin } from "ts-mixer"; -import { Leaf } from "./Leaf"; +import { AbstractLeaf } from "./AbstractLeaf"; import { Fetched } from "../fetchStatus/Fetched"; -import type { DataLeaf } from "../../concrete/DataLeaf"; -import type { BinaryLeaf } from "../../concrete/BinaryLeaf"; -import type { AbsentLeaf } from "../../concrete/AbsentLeaf"; -export type FetchedLeafClass = DataLeaf | BinaryLeaf | AbsentLeaf; -export abstract class FetchedLeaf extends Mixin(Leaf, Fetched) {} +export abstract class FetchedLeaf extends Mixin(AbstractLeaf, Fetched) {} diff --git a/packages/solid/src/resource/abstract/leaf/Leaf.ts b/packages/solid/src/resource/abstract/leaf/Leaf.ts deleted file mode 100644 index 832779d..0000000 --- a/packages/solid/src/resource/abstract/leaf/Leaf.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { AbsentLeaf } from "../../concrete/AbsentLeaf"; -import type { BinaryLeaf } from "../../concrete/BinaryLeaf"; -import type { DataLeaf } from "../../concrete/DataLeaf"; -import type { UnfetchedLeaf } from "../../concrete/UnfetchedLeaf"; -import { SolidLdoError } from "../../error/SolidLdoError"; -import { Resource, ResourceClass } from "../Resource"; -import { FetchedClass } from "../fetchStatus/Fetched"; -import { PresentClass } from "../fetchStatus/Present"; -import type { FetchedLeafClass } from "./FetchedLeaf"; -import { PresentLeafClass } from "./PresentLeaf"; - -export type LeafClass = DataLeaf | BinaryLeaf | AbsentLeaf | UnfetchedLeaf; -export abstract class Leaf extends Resource { - async read(): Promise { - // Make query - // Select the Kind of Leaf - // Create it - - // Post Processing - throw new Error("Not Implemented"); - } - - async createIfAbsent(): Promise; - async createIfAbsent(blob: Blob): Promise; - async createIfAbsent(_blob?: Blob): Promise { - - return new SolidLdoError(); - } - - getCurrent(): LeafClass { - throw new Error("Not Implemented"); - } -} diff --git a/packages/solid/src/resource/abstract/leaf/PresentLeaf.ts b/packages/solid/src/resource/abstract/leaf/PresentLeaf.ts index 4997088..500c0a2 100644 --- a/packages/solid/src/resource/abstract/leaf/PresentLeaf.ts +++ b/packages/solid/src/resource/abstract/leaf/PresentLeaf.ts @@ -1,8 +1,5 @@ import { Mixin } from "ts-mixer"; import { FetchedLeaf } from "./FetchedLeaf"; import { Present } from "../fetchStatus/Present"; -import type { DataLeaf } from "../../concrete/DataLeaf"; -import type { BinaryLeaf } from "../../concrete/BinaryLeaf"; -export type PresentLeafClass = DataLeaf | BinaryLeaf; export abstract class PresentLeaf extends Mixin(FetchedLeaf, Present) {} diff --git a/packages/solid/src/resource/abstract/leaf/UnfetchedLeaf.ts b/packages/solid/src/resource/abstract/leaf/UnfetchedLeaf.ts new file mode 100644 index 0000000..c82a85b --- /dev/null +++ b/packages/solid/src/resource/abstract/leaf/UnfetchedLeaf.ts @@ -0,0 +1,5 @@ +import { Mixin } from "ts-mixer"; +import { AbstractLeaf } from "./AbstractLeaf"; +import { Unfetched } from "../fetchStatus/Unfetched"; + +export class UnfetchedLeaf extends Mixin(AbstractLeaf, Unfetched) {} diff --git a/packages/solid/src/resource/concrete/AbsentContainer.ts b/packages/solid/src/resource/concrete/AbsentContainer.ts deleted file mode 100644 index bc7eece..0000000 --- a/packages/solid/src/resource/concrete/AbsentContainer.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Mixin } from "ts-mixer"; -import { Absent } from "../abstract/fetchStatus/Absent"; -import { Container } from "../abstract/container/Container"; - -export class AbsentContainer extends Mixin(Absent, Container) {} diff --git a/packages/solid/src/resource/concrete/AbsentLeaf.ts b/packages/solid/src/resource/concrete/AbsentLeaf.ts deleted file mode 100644 index f21d00f..0000000 --- a/packages/solid/src/resource/concrete/AbsentLeaf.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Mixin } from "ts-mixer"; -import { Absent, AbsentClass } from "../abstract/fetchStatus/Absent"; -import { FetchedLeaf, FetchedLeafClass } from "../abstract/leaf/FetchedLeaf"; -import { FetchedClass } from "../abstract/fetchStatus/Fetched"; -import { PresentClass } from "../abstract/fetchStatus/Present"; -import { SolidLdoError } from "../error/SolidLdoError"; - -export class AbsentLeaf extends Mixin(Absent, FetchedLeaf) { - create(...args: unknown[]): Promise { - throw new Error("Method not implemented."); - } - read(): Promise { - throw new Error("Method not implemented."); - } - createOrOverride(): Promise { - throw new Error("Method not implemented."); - } - deleteIfPresent(): Promise { - throw new Error("Method not implemented."); - } -} diff --git a/packages/solid/src/resource/concrete/BinaryLeaf.ts b/packages/solid/src/resource/concrete/BinaryLeaf.ts deleted file mode 100644 index 8750e29..0000000 --- a/packages/solid/src/resource/concrete/BinaryLeaf.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Mixin } from "ts-mixer"; -import { PresentLeaf } from "../abstract/leaf/PresentLeaf"; -import { PotentialBinaryLeaf } from "../abstract/leaf/PotentialBinaryLeaf"; - -export class BinaryLeaf extends Mixin(PresentLeaf, PotentialBinaryLeaf) {} diff --git a/packages/solid/src/resource/concrete/BranchContainer.ts b/packages/solid/src/resource/concrete/BranchContainer.ts deleted file mode 100644 index 3c01df6..0000000 --- a/packages/solid/src/resource/concrete/BranchContainer.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { PresentContainer } from "../abstract/container/PresentContainer"; - -export class BranchContainer extends PresentContainer {} diff --git a/packages/solid/src/resource/concrete/DataLeaf.ts b/packages/solid/src/resource/concrete/DataLeaf.ts deleted file mode 100644 index 1535232..0000000 --- a/packages/solid/src/resource/concrete/DataLeaf.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Mixin } from "ts-mixer"; -import { PresentLeaf } from "../abstract/leaf/PresentLeaf"; -import { PotentialDataLeaf } from "../abstract/leaf/PotentialDataLeaf"; - -export class DataLeaf extends Mixin(PresentLeaf, PotentialDataLeaf) {} diff --git a/packages/solid/src/resource/concrete/RootContainer.ts b/packages/solid/src/resource/concrete/RootContainer.ts deleted file mode 100644 index e968753..0000000 --- a/packages/solid/src/resource/concrete/RootContainer.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { PresentContainer } from "../abstract/container/PresentContainer"; - -export class RootContainer extends PresentContainer {} diff --git a/packages/solid/src/resource/concrete/UnfetchedContainer.ts b/packages/solid/src/resource/concrete/UnfetchedContainer.ts deleted file mode 100644 index 89ee450..0000000 --- a/packages/solid/src/resource/concrete/UnfetchedContainer.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Mixin } from "ts-mixer"; -import { Container } from "../abstract/container/Container"; -import { Unfetched } from "../abstract/fetchStatus/Unfetched"; - -export class UnfetchedContainer extends Mixin(Container, Unfetched) {} diff --git a/packages/solid/src/resource/concrete/UnfetchedLeaf.ts b/packages/solid/src/resource/concrete/UnfetchedLeaf.ts deleted file mode 100644 index 393b5e5..0000000 --- a/packages/solid/src/resource/concrete/UnfetchedLeaf.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Mixin } from "ts-mixer"; -import { Unfetched } from "../abstract/fetchStatus/Unfetched"; -import { PotentialBinaryLeaf } from "../abstract/leaf/PotentialBinaryLeaf"; -import { PotentialDataLeaf } from "../abstract/leaf/PotentialDataLeaf"; - -export class UnfetchedLeaf extends Mixin( - Unfetched, - PotentialBinaryLeaf, - PotentialDataLeaf, -) {} diff --git a/packages/solid/src/resource/error/MethodNotAllowedError.ts b/packages/solid/src/resource/error/MethodNotAllowedError.ts new file mode 100644 index 0000000..2409f21 --- /dev/null +++ b/packages/solid/src/resource/error/MethodNotAllowedError.ts @@ -0,0 +1,14 @@ +import type { ResourceType } from "../abstract/AbstractResource"; +import type { LeafType } from "../abstract/leaf/Leaf"; +import { ResourceError } from "./ResourceError"; + +export class MethodNotAllowedError< + rType extends ResourceType, +> extends ResourceError { + type: "MethodNotAllowed"; + methodName: string; + currentResource: rType; +} + +export class LeafMethodNotAllowedError extends MethodNotAllowedError {} +export class ContainerMethodNotAllowedError extends MethodNotAllowedError {} diff --git a/packages/solid/src/resource/error/ResourceError.ts b/packages/solid/src/resource/error/ResourceError.ts new file mode 100644 index 0000000..7851a24 --- /dev/null +++ b/packages/solid/src/resource/error/ResourceError.ts @@ -0,0 +1,6 @@ +import type { ResourceType } from "../abstract/AbstractResource"; + +export abstract class ResourceError extends Error { + public abstract readonly currentResource: ResourceType; + public abstract readonly type: string; +} diff --git a/packages/solid/src/resource/error/SolidLdoError.ts b/packages/solid/src/resource/error/SolidLdoError.ts deleted file mode 100644 index edcc711..0000000 --- a/packages/solid/src/resource/error/SolidLdoError.ts +++ /dev/null @@ -1 +0,0 @@ -export class SolidLdoError extends Error {} diff --git a/packages/solid/src/test.ts b/packages/solid/src/test.ts new file mode 100644 index 0000000..e05b58f --- /dev/null +++ b/packages/solid/src/test.ts @@ -0,0 +1,21 @@ +import { Mixin } from "ts-mixer"; + +class Foo { + protected makeFoo() { + return "foo"; + } +} + +class Bar { + protected makeBar() { + return "bar"; + } +} + +class FooBar extends Mixin(Foo, Bar) { + public makeFooBar() { + return this.makeFoo() + this.makeBar(); + } +} + +const fooBar = new FooBar(); diff --git a/packages/solid/src/uriTypes.ts b/packages/solid/src/uriTypes.ts new file mode 100644 index 0000000..1fadb24 --- /dev/null +++ b/packages/solid/src/uriTypes.ts @@ -0,0 +1,96 @@ +export type ContainerUri = `${string}/${NonPathnameEnding}`; +export type LeafUri = + `${string}${EveryLegalPathnameCharacterOtherThanSlash}${NonPathnameEnding}`; + +export function isContainerUri(uri: string): uri is ContainerUri { + const url = new URL(uri); + return url.pathname.endsWith("/"); +} + +export function isLeafUri(uri: string): uri is LeafUri { + return !isContainerUri; +} + +type NonPathnameEnding = "" | `?${string}` | `#${string}`; +type EveryLegalPathnameCharacterOtherThanSlash = + | "A" + | "B" + | "C" + | "D" + | "E" + | "F" + | "G" + | "H" + | "I" + | "J" + | "K" + | "L" + | "M" + | "N" + | "O" + | "P" + | "Q" + | "R" + | "S" + | "T" + | "U" + | "V" + | "W" + | "X" + | "Y" + | "Z" + | "a" + | "b" + | "c" + | "d" + | "e" + | "f" + | "g" + | "h" + | "i" + | "j" + | "k" + | "l" + | "m" + | "n" + | "o" + | "p" + | "q" + | "r" + | "s" + | "t" + | "u" + | "v" + | "w" + | "x" + | "y" + | "z" + | "1" + | "2" + | "3" + | "4" + | "5" + | "6" + | "7" + | "8" + | "9" + | "0" + | "-" + | "." + | "_" + | "~" + | ":" + | "[" + | "]" + | "@" + | "!" + | "$" + | "&" + | "'" + | "(" + | ")" + | "*" + | "+" + | "," + | ";" + | "=";