From 90d70c05ea9a63b3a73f89c9238ee502ddcb5185 Mon Sep 17 00:00:00 2001 From: jaxoncreed Date: Tue, 5 Sep 2023 21:51:58 -0400 Subject: [PATCH] Set up muti-inheritance structure --- package-lock.json | 16 +- packages/solid/example/example.ts | 195 ++++++++++++++ packages/solid/package.json | 5 +- packages/solid/src/SolidLdoDataset.ts | 49 +--- .../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 | 254 ++++++++++++++++++ packages/solid/src/resource-old/types.ts | 97 +++++++ .../solid/src/resource/abstract/Resource.ts | 1 + .../resource/abstract/container/Container.ts | 3 + .../abstract/container/PresentContainer.ts | 0 .../abstract/dataResource/DataResource.ts | 7 + .../dataResource/PotentialDataResource.ts | 18 ++ .../resource/abstract/fetchStatus/Absent.ts | 13 + .../abstract/fetchStatus/FetchStatus.ts | 5 + .../resource/abstract/fetchStatus/Fetched.ts | 20 ++ .../resource/abstract/fetchStatus/Present.ts | 19 ++ .../abstract/fetchStatus/Unfetched.ts | 16 ++ .../solid/src/resource/abstract/leaf/Leaf.ts | 7 + .../abstract/leaf/PotentialBinaryLeaf.ts | 0 .../abstract/leaf/PotentialDataLeaf.ts | 9 + .../src/resource/abstract/leaf/PresentLeaf.ts | 8 + .../src/resource/concrete/AbsentContainer.ts | 5 + .../solid/src/resource/concrete/AbsentLeaf.ts | 5 + .../solid/src/resource/concrete/BinaryLeaf.ts | 5 + .../src/resource/concrete/BranchContainer.ts | 1 + .../solid/src/resource/concrete/DataLeaf.ts | 5 + .../src/resource/concrete/RootContainer.ts | 3 + .../resource/concrete/UnfetchedContainer.ts | 5 + .../src/resource/concrete/UnfetchedLeaf.ts | 10 + 40 files changed, 1144 insertions(+), 47 deletions(-) create mode 100644 packages/solid/src/resource-old/container/AbsentContainer.ts create mode 100644 packages/solid/src/resource-old/container/Container.ts create mode 100644 packages/solid/src/resource-old/container/UnfetchedContainer.ts create mode 100644 packages/solid/src/resource-old/container/presentContainer/BranchContainer.ts create mode 100644 packages/solid/src/resource-old/container/presentContainer/PresentContainer.ts create mode 100644 packages/solid/src/resource-old/container/presentContainer/RootContainer.ts create mode 100644 packages/solid/src/resource-old/leaf/AbsentLeaf.ts create mode 100644 packages/solid/src/resource-old/leaf/Leaf.ts create mode 100644 packages/solid/src/resource-old/leaf/UnfetchedLeaf.ts create mode 100644 packages/solid/src/resource-old/leaf/presentLeaf/BinaryLeaf.ts create mode 100644 packages/solid/src/resource-old/leaf/presentLeaf/DataLeaf.ts create mode 100644 packages/solid/src/resource-old/leaf/presentLeaf/PresentLeaf.ts create mode 100644 packages/solid/src/resource-old/notes.ts create mode 100644 packages/solid/src/resource-old/types.ts create mode 100644 packages/solid/src/resource/abstract/Resource.ts create mode 100644 packages/solid/src/resource/abstract/container/Container.ts create mode 100644 packages/solid/src/resource/abstract/container/PresentContainer.ts create mode 100644 packages/solid/src/resource/abstract/dataResource/DataResource.ts create mode 100644 packages/solid/src/resource/abstract/dataResource/PotentialDataResource.ts create mode 100644 packages/solid/src/resource/abstract/fetchStatus/Absent.ts create mode 100644 packages/solid/src/resource/abstract/fetchStatus/FetchStatus.ts create mode 100644 packages/solid/src/resource/abstract/fetchStatus/Fetched.ts create mode 100644 packages/solid/src/resource/abstract/fetchStatus/Present.ts create mode 100644 packages/solid/src/resource/abstract/fetchStatus/Unfetched.ts create mode 100644 packages/solid/src/resource/abstract/leaf/Leaf.ts create mode 100644 packages/solid/src/resource/abstract/leaf/PotentialBinaryLeaf.ts create mode 100644 packages/solid/src/resource/abstract/leaf/PotentialDataLeaf.ts create mode 100644 packages/solid/src/resource/abstract/leaf/PresentLeaf.ts create mode 100644 packages/solid/src/resource/concrete/AbsentContainer.ts create mode 100644 packages/solid/src/resource/concrete/AbsentLeaf.ts create mode 100644 packages/solid/src/resource/concrete/BinaryLeaf.ts create mode 100644 packages/solid/src/resource/concrete/BranchContainer.ts create mode 100644 packages/solid/src/resource/concrete/DataLeaf.ts create mode 100644 packages/solid/src/resource/concrete/RootContainer.ts create mode 100644 packages/solid/src/resource/concrete/UnfetchedContainer.ts create mode 100644 packages/solid/src/resource/concrete/UnfetchedLeaf.ts diff --git a/package-lock.json b/package-lock.json index 98bda34..4425e4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28297,6 +28297,11 @@ "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==" }, + "node_modules/ts-mixer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.3.tgz", + "integrity": "sha512-k43M7uCG1AkTyxgnmI5MPwKoUvS/bRvLvUb7+Pgpdlmok8AoqmUaZxUUw8zKM5B1lqZrt41GjYgnvAi0fppqgQ==" + }, "node_modules/ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", @@ -31078,7 +31083,8 @@ "@ldo/dataset": "^0.0.0", "@ldo/ldo": "^0.0.0", "@ldo/rdf-utils": "^0.0.0", - "cross-fetch": "^3.1.6" + "cross-fetch": "^3.1.6", + "ts-mixer": "^6.0.3" }, "devDependencies": { "@ldo/cli": "^0.0.0", @@ -31086,6 +31092,7 @@ "@rdfjs/types": "^1.0.1", "@types/jest": "^29.0.3", "ts-jest": "^29.0.2", + "ts-node": "^10.9.1", "typed-emitter": "^2.1.0" } }, @@ -39013,6 +39020,8 @@ "@types/jest": "^29.0.3", "cross-fetch": "^3.1.6", "ts-jest": "^29.0.2", + "ts-mixer": "*", + "ts-node": "^10.9.1", "typed-emitter": "^2.1.0" }, "dependencies": { @@ -59103,6 +59112,11 @@ "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==" }, + "ts-mixer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.3.tgz", + "integrity": "sha512-k43M7uCG1AkTyxgnmI5MPwKoUvS/bRvLvUb7+Pgpdlmok8AoqmUaZxUUw8zKM5B1lqZrt41GjYgnvAi0fppqgQ==" + }, "ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", diff --git a/packages/solid/example/example.ts b/packages/solid/example/example.ts index e69de29..60aa3ec 100644 --- a/packages/solid/example/example.ts +++ b/packages/solid/example/example.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/package.json b/packages/solid/package.json index f8c7035..7c1420d 100644 --- a/packages/solid/package.json +++ b/packages/solid/package.json @@ -4,6 +4,7 @@ "description": "A library for LDO and Solid", "main": "dist/index.js", "scripts": { + "example": "ts-node ./example/example.ts", "build": "tsc --project tsconfig.build.json", "watch": "tsc --watch", "test": "jest --coverage", @@ -28,12 +29,14 @@ "@rdfjs/types": "^1.0.1", "@types/jest": "^29.0.3", "ts-jest": "^29.0.2", + "ts-node": "^10.9.1", "typed-emitter": "^2.1.0" }, "dependencies": { "@ldo/dataset": "^0.0.0", "@ldo/ldo": "^0.0.0", "@ldo/rdf-utils": "^0.0.0", - "cross-fetch": "^3.1.6" + "cross-fetch": "^3.1.6", + "ts-mixer": "^6.0.3" } } diff --git a/packages/solid/src/SolidLdoDataset.ts b/packages/solid/src/SolidLdoDataset.ts index e94b9d7..16d8502 100644 --- a/packages/solid/src/SolidLdoDataset.ts +++ b/packages/solid/src/SolidLdoDataset.ts @@ -1,15 +1,7 @@ import { LdoDataset } from "@ldo/ldo"; -import type { DataResource } from "./document/resource/dataResource/DataResource"; -import type { ContainerResource } from "./document/resource/dataResource/containerResource/ContainerResource"; -import type { AccessRules } from "./document/accessRules/AccessRules"; -import type { BinaryResource } from "./document/resource/binaryResource/BinaryResource"; -import type { DocumentGetterOptions } from "./document/DocumentStore"; import type { Dataset, DatasetFactory } from "@rdfjs/types"; -import type { Resource } from "./document/resource/Resource"; -import type { - OnDocumentErrorCallback, - SolidLdoDatasetContext, -} from "./SolidLdoDatasetContext"; +import type { SolidLdoDatasetContext } from "./SolidLdoDatasetContext"; +import type { ResourceStatus } from "./resource/Resource"; export class SolidLdoDataset extends LdoDataset { public context: SolidLdoDatasetContext; @@ -23,40 +15,7 @@ export class SolidLdoDataset extends LdoDataset { this.context = context; } - getDataResource(uri: string, options?: DocumentGetterOptions): DataResource { - return this.context.dataResourceStore.get(uri, options); - } - - getContainerResource( - uri: string, - options?: DocumentGetterOptions, - ): ContainerResource { - return this.context.containerResourceStore.get(uri, options); - } - - getAccessRules( - forResource: string | Resource, - options?: DocumentGetterOptions, - ): AccessRules { - const resourceIdentifier = - typeof forResource === "string" - ? this.getDataResource(forResource) - : forResource; - return this.context.accessRulesStore.get(resourceIdentifier, options); - } - - getBinaryResource( - uri: string, - options?: DocumentGetterOptions, - ): BinaryResource { - return this.context.binaryResourceStore.get(uri, options); - } - - onDocumentError(callback: OnDocumentErrorCallback): void { - this.context.documentEventEmitter.on("documentError", callback); - } - - offDocumentError(callback: OnDocumentErrorCallback): void { - this.context.documentEventEmitter.off("documentError", callback); + getResourceStatus(): ResourceStatus { + throw new Error("Not Implemented"); } } diff --git a/packages/solid/src/resource-old/container/AbsentContainer.ts b/packages/solid/src/resource-old/container/AbsentContainer.ts new file mode 100644 index 0000000..5224fb3 --- /dev/null +++ b/packages/solid/src/resource-old/container/AbsentContainer.ts @@ -0,0 +1,39 @@ +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 new file mode 100644 index 0000000..025392d --- /dev/null +++ b/packages/solid/src/resource-old/container/Container.ts @@ -0,0 +1,77 @@ +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 new file mode 100644 index 0000000..445a495 --- /dev/null +++ b/packages/solid/src/resource-old/container/UnfetchedContainer.ts @@ -0,0 +1,30 @@ +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 new file mode 100644 index 0000000..6364a18 --- /dev/null +++ b/packages/solid/src/resource-old/container/presentContainer/BranchContainer.ts @@ -0,0 +1,18 @@ +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 new file mode 100644 index 0000000..cc997bb --- /dev/null +++ b/packages/solid/src/resource-old/container/presentContainer/PresentContainer.ts @@ -0,0 +1,31 @@ +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 new file mode 100644 index 0000000..3b060f4 --- /dev/null +++ b/packages/solid/src/resource-old/container/presentContainer/RootContainer.ts @@ -0,0 +1,14 @@ +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 new file mode 100644 index 0000000..3afc42c --- /dev/null +++ b/packages/solid/src/resource-old/leaf/AbsentLeaf.ts @@ -0,0 +1,56 @@ +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 new file mode 100644 index 0000000..67edb42 --- /dev/null +++ b/packages/solid/src/resource-old/leaf/Leaf.ts @@ -0,0 +1,38 @@ +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 new file mode 100644 index 0000000..ccbb395 --- /dev/null +++ b/packages/solid/src/resource-old/leaf/UnfetchedLeaf.ts @@ -0,0 +1,49 @@ +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 new file mode 100644 index 0000000..b27d47b --- /dev/null +++ b/packages/solid/src/resource-old/leaf/presentLeaf/BinaryLeaf.ts @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..5423419 --- /dev/null +++ b/packages/solid/src/resource-old/leaf/presentLeaf/DataLeaf.ts @@ -0,0 +1,26 @@ +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 new file mode 100644 index 0000000..a16e571 --- /dev/null +++ b/packages/solid/src/resource-old/leaf/presentLeaf/PresentLeaf.ts @@ -0,0 +1,17 @@ +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 new file mode 100644 index 0000000..7696d83 --- /dev/null +++ b/packages/solid/src/resource-old/notes.ts @@ -0,0 +1,254 @@ +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|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 +} \ No newline at end of file diff --git a/packages/solid/src/resource-old/types.ts b/packages/solid/src/resource-old/types.ts new file mode 100644 index 0000000..81a0adc --- /dev/null +++ b/packages/solid/src/resource-old/types.ts @@ -0,0 +1,97 @@ +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/abstract/Resource.ts b/packages/solid/src/resource/abstract/Resource.ts new file mode 100644 index 0000000..9d4fb8e --- /dev/null +++ b/packages/solid/src/resource/abstract/Resource.ts @@ -0,0 +1 @@ +export class Resource {}; \ No newline at end of file diff --git a/packages/solid/src/resource/abstract/container/Container.ts b/packages/solid/src/resource/abstract/container/Container.ts new file mode 100644 index 0000000..0765b0e --- /dev/null +++ b/packages/solid/src/resource/abstract/container/Container.ts @@ -0,0 +1,3 @@ +import { PotentialDataResource } from "../dataResource/potentialDataResource"; + +export class Container extends PotentialDataResource {} diff --git a/packages/solid/src/resource/abstract/container/PresentContainer.ts b/packages/solid/src/resource/abstract/container/PresentContainer.ts new file mode 100644 index 0000000..e69de29 diff --git a/packages/solid/src/resource/abstract/dataResource/DataResource.ts b/packages/solid/src/resource/abstract/dataResource/DataResource.ts new file mode 100644 index 0000000..4a9bacd --- /dev/null +++ b/packages/solid/src/resource/abstract/dataResource/DataResource.ts @@ -0,0 +1,7 @@ +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 new file mode 100644 index 0000000..202b0c2 --- /dev/null +++ b/packages/solid/src/resource/abstract/dataResource/PotentialDataResource.ts @@ -0,0 +1,18 @@ +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 { Resource } from "../Resource"; +import type { DataResource } from "./DataResource"; + +export type PotentialDataResourceClass = + | RootContainer + | BranchContainer + | DataResource + | AbsentContainer + | AbsentLeaf + | UnfetchedContainer + | UnfetchedLeaf; +export class PotentialDataResource extends Resource {} diff --git a/packages/solid/src/resource/abstract/fetchStatus/Absent.ts b/packages/solid/src/resource/abstract/fetchStatus/Absent.ts new file mode 100644 index 0000000..cdce77c --- /dev/null +++ b/packages/solid/src/resource/abstract/fetchStatus/Absent.ts @@ -0,0 +1,13 @@ +import type { AbsentContainer } from "../../concrete/AbsentContainer"; +import type { AbsentLeaf } from "../../concrete/AbsentLeaf"; +import { Fetched } from "./Fetched"; + +export type AbsentClass = AbsentContainer | AbsentLeaf; +export class Absent extends Fetched { + public get isAbsent(): true { + return true; + } + public get isPresent(): false { + return false; + } +} diff --git a/packages/solid/src/resource/abstract/fetchStatus/FetchStatus.ts b/packages/solid/src/resource/abstract/fetchStatus/FetchStatus.ts new file mode 100644 index 0000000..9e7ecbf --- /dev/null +++ b/packages/solid/src/resource/abstract/fetchStatus/FetchStatus.ts @@ -0,0 +1,5 @@ +export abstract class FetchStatus { + 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 new file mode 100644 index 0000000..4f056f1 --- /dev/null +++ b/packages/solid/src/resource/abstract/fetchStatus/Fetched.ts @@ -0,0 +1,20 @@ +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; + } +} diff --git a/packages/solid/src/resource/abstract/fetchStatus/Present.ts b/packages/solid/src/resource/abstract/fetchStatus/Present.ts new file mode 100644 index 0000000..5645b34 --- /dev/null +++ b/packages/solid/src/resource/abstract/fetchStatus/Present.ts @@ -0,0 +1,19 @@ +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 class Present extends Fetched { + public get isAbsent(): false { + return false; + } + public get isPresent(): true { + return true; + } +} diff --git a/packages/solid/src/resource/abstract/fetchStatus/Unfetched.ts b/packages/solid/src/resource/abstract/fetchStatus/Unfetched.ts new file mode 100644 index 0000000..bae2c05 --- /dev/null +++ b/packages/solid/src/resource/abstract/fetchStatus/Unfetched.ts @@ -0,0 +1,16 @@ +import type { UnfetchedContainer } from "../../concrete/UnfetchedContainer"; +import type { UnfetchedLeaf } from "../../concrete/UnfetchedLeaf"; +import { FetchStatus } from "./FetchStatus"; + +export type UnfetchedClass = UnfetchedContainer | UnfetchedLeaf; +export abstract class Unfetched extends FetchStatus { + public get didInitialFetch(): false { + return false; + } + public get isAbsent(): undefined { + return undefined; + } + public get isPresent(): undefined { + return undefined; + } +} diff --git a/packages/solid/src/resource/abstract/leaf/Leaf.ts b/packages/solid/src/resource/abstract/leaf/Leaf.ts new file mode 100644 index 0000000..12bc6d4 --- /dev/null +++ b/packages/solid/src/resource/abstract/leaf/Leaf.ts @@ -0,0 +1,7 @@ +import type { AbsentLeaf } from "../../concrete/AbsentLeaf"; +import type { BinaryLeaf } from "../../concrete/BinaryLeaf"; +import type { DataLeaf } from "../../concrete/DataLeaf"; +import type { UnfetchedLeaf } from "../../concrete/UnfetchedLeaf"; + +export type LeafClass = DataLeaf | BinaryLeaf | AbsentLeaf | UnfetchedLeaf; +export class Leaf {} diff --git a/packages/solid/src/resource/abstract/leaf/PotentialBinaryLeaf.ts b/packages/solid/src/resource/abstract/leaf/PotentialBinaryLeaf.ts new file mode 100644 index 0000000..e69de29 diff --git a/packages/solid/src/resource/abstract/leaf/PotentialDataLeaf.ts b/packages/solid/src/resource/abstract/leaf/PotentialDataLeaf.ts new file mode 100644 index 0000000..79bb967 --- /dev/null +++ b/packages/solid/src/resource/abstract/leaf/PotentialDataLeaf.ts @@ -0,0 +1,9 @@ +import { Mixin } from "ts-mixer"; +import type { AbsentLeaf } from "../../concrete/AbsentLeaf"; +import type { DataLeaf } from "../../concrete/DataLeaf"; +import type { UnfetchedLeaf } from "../../concrete/UnfetchedLeaf"; +import { PotentialDataResource } from "../dataResource/potentialDataResource"; +import { Leaf } from "./Leaf"; + +export type PotentialDataLeafClass = DataLeaf | AbsentLeaf | UnfetchedLeaf; +export class PotentialDataLeaf extends Mixin(Leaf, PotentialDataResource) {} diff --git a/packages/solid/src/resource/abstract/leaf/PresentLeaf.ts b/packages/solid/src/resource/abstract/leaf/PresentLeaf.ts new file mode 100644 index 0000000..520de66 --- /dev/null +++ b/packages/solid/src/resource/abstract/leaf/PresentLeaf.ts @@ -0,0 +1,8 @@ +import { Mixin } from "ts-mixer"; +import { Leaf } from "./Leaf"; +import { Present } from "../fetchStatus/Present"; +import type { DataLeaf } from "../../concrete/DataLeaf"; +import type { BinaryLeaf } from "../../concrete/BinaryLeaf"; + +export type PresentLeafClass = DataLeaf | BinaryLeaf; +export class PresentLeaf extends Mixin(Leaf, Present) {} diff --git a/packages/solid/src/resource/concrete/AbsentContainer.ts b/packages/solid/src/resource/concrete/AbsentContainer.ts new file mode 100644 index 0000000..bc7eece --- /dev/null +++ b/packages/solid/src/resource/concrete/AbsentContainer.ts @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..d94658c --- /dev/null +++ b/packages/solid/src/resource/concrete/AbsentLeaf.ts @@ -0,0 +1,5 @@ +import { Mixin } from "ts-mixer"; +import { Absent } from "../abstract/fetchStatus/Absent"; +import { PotentialBinaryLeaf } from "../abstract/leaf/PotentialBinaryLeaf"; + +export class AbsentLeaf extends Mixin(Absent, PotentialBinaryLeaf) {} diff --git a/packages/solid/src/resource/concrete/BinaryLeaf.ts b/packages/solid/src/resource/concrete/BinaryLeaf.ts new file mode 100644 index 0000000..8750e29 --- /dev/null +++ b/packages/solid/src/resource/concrete/BinaryLeaf.ts @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..3986ebe --- /dev/null +++ b/packages/solid/src/resource/concrete/BranchContainer.ts @@ -0,0 +1 @@ +export class BranchContainer {} diff --git a/packages/solid/src/resource/concrete/DataLeaf.ts b/packages/solid/src/resource/concrete/DataLeaf.ts new file mode 100644 index 0000000..1535232 --- /dev/null +++ b/packages/solid/src/resource/concrete/DataLeaf.ts @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..e968753 --- /dev/null +++ b/packages/solid/src/resource/concrete/RootContainer.ts @@ -0,0 +1,3 @@ +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 new file mode 100644 index 0000000..89ee450 --- /dev/null +++ b/packages/solid/src/resource/concrete/UnfetchedContainer.ts @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..393b5e5 --- /dev/null +++ b/packages/solid/src/resource/concrete/UnfetchedLeaf.ts @@ -0,0 +1,10 @@ +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, +) {}