Added Multi Inheritance

main
jaxoncreed 2 years ago
parent 90d70c05ea
commit fed926ff15
  1. 1
      packages/demo-react/src/dashboard/Dashboard.tsx
  2. 7
      packages/solid/src/resource-old/notes.ts
  3. 37
      packages/solid/src/resource/abstract/Resource.ts
  4. 12
      packages/solid/src/resource/abstract/container/Container.ts
  5. 9
      packages/solid/src/resource/abstract/container/PresentContainer.ts
  6. 10
      packages/solid/src/resource/abstract/dataResource/PotentialDataResource.ts
  7. 6
      packages/solid/src/resource/abstract/fetchStatus/Absent.ts
  8. 4
      packages/solid/src/resource/abstract/fetchStatus/FetchStatus.ts
  9. 4
      packages/solid/src/resource/abstract/fetchStatus/Fetched.ts
  10. 2
      packages/solid/src/resource/abstract/fetchStatus/Present.ts
  11. 12
      packages/solid/src/resource/abstract/fetchStatus/Unfetched.ts
  12. 9
      packages/solid/src/resource/abstract/leaf/FetchedLeaf.ts
  13. 28
      packages/solid/src/resource/abstract/leaf/Leaf.ts
  14. 0
      packages/solid/src/resource/abstract/leaf/PotentialBinaryLeaf.ts
  15. 9
      packages/solid/src/resource/abstract/leaf/PotentialDataLeaf.ts
  16. 4
      packages/solid/src/resource/abstract/leaf/PresentLeaf.ts
  17. 22
      packages/solid/src/resource/concrete/AbsentLeaf.ts
  18. 4
      packages/solid/src/resource/concrete/BranchContainer.ts
  19. 1
      packages/solid/src/resource/error/SolidLdoError.ts

@ -17,7 +17,6 @@ export const Dashboard: FunctionComponent = () => {
const mainContainer = useDataResource(containerUri);
if (mainContainer instanceof AccessRules) {
console.log("here");
}

@ -29,22 +29,20 @@ const thing = {
"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
*/
@ -71,7 +69,6 @@ export interface IContainerResource extends IResource {
clearIfPresent
export interface BinaryResource {
uri: string;
isLoading: boolean;
@ -247,8 +244,6 @@ export interface UnfetchedContainerResource {
clearIfPresent(): Promise<ContainerResource | AbsentContainerResource | LdoSolidError>;
}
export interface LdoSolidError extends Error {
forResource: unknown // Some Kind of Resource
}

@ -1 +1,36 @@
export class Resource {};
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<FetchedClass | SolidLdoError>;
abstract readIfUnfetched(): Promise<FetchedClass | SolidLdoError>;
abstract createIfAbsent(): Promise<PresentClass | SolidLdoError>;
abstract createOrOverride(): Promise<PresentClass | SolidLdoError>;
abstract deleteIfPresent(): Promise<AbsentClass | SolidLdoError>;
abstract getCurrent(): ResourceClass;
}

@ -1,3 +1,13 @@
import { SolidLdoError } from "../../error/SolidLdoError";
import { PotentialDataResource } from "../dataResource/potentialDataResource";
export class Container extends PotentialDataResource {}
export class Container extends PotentialDataResource {
async read(): Promise<FetchedLeafClass | SolidLdoError> {
// Make query
// Select the Kind of Leaf
// Create it
// Post Processing
throw new Error("Not Implemented");
}
}

@ -0,0 +1,9 @@
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 { Present } from "../fetchStatus/Present";
export type PresentContainerClass = RootContainer | BranchContainer;
export class PresentContainer extends Mixin(Container, Present, DataResource) {}

@ -4,6 +4,8 @@ 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";
@ -15,4 +17,10 @@ export type PotentialDataResourceClass =
| AbsentLeaf
| UnfetchedContainer
| UnfetchedLeaf;
export class PotentialDataResource extends Resource {}
export abstract class PotentialDataResource extends Resource<
ResourceClass,
SolidLdoError
> {
abstract
}

@ -1,13 +1,17 @@
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 class Absent extends Fetched {
export abstract class Absent extends Fetched {
public get isAbsent(): true {
return true;
}
public get isPresent(): false {
return false;
}
abstract create(...args: unknown[]): Promise<PresentClass | SolidLdoError>;
}

@ -1,4 +1,6 @@
export abstract class FetchStatus {
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;

@ -17,4 +17,8 @@ export abstract class Fetched extends FetchStatus {
public get didInitialFetch(): true {
return true;
}
async readIfUnfetched(): Promise<this> {
return this;
}
}

@ -9,7 +9,7 @@ export type PresentClass =
| BranchContainer
| DataLeaf
| BinaryLeaf;
export class Present extends Fetched {
export abstract class Present extends Fetched {
public get isAbsent(): false {
return false;
}

@ -1,9 +1,14 @@
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 extends FetchStatus {
export abstract class Unfetched<
ReadReturn extends FetchedClass,
ReadError extends SolidLdoError,
> extends FetchStatus {
public get didInitialFetch(): false {
return false;
}
@ -13,4 +18,9 @@ export abstract class Unfetched extends FetchStatus {
public get isPresent(): undefined {
return undefined;
}
async readIfUnfetched(): Promise<ReadReturn | ReadError> {
return this.read();
}
abstract read(): Promise<ReadReturn | ReadError>;
}

@ -0,0 +1,9 @@
import { Mixin } from "ts-mixer";
import { Leaf } from "./Leaf";
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) {}

@ -2,6 +2,32 @@ 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 class Leaf {}
export abstract class Leaf extends Resource {
async read(): Promise<FetchedLeafClass | SolidLdoError> {
// Make query
// Select the Kind of Leaf
// Create it
// Post Processing
throw new Error("Not Implemented");
}
async createIfAbsent(): Promise<DataLeaf | SolidLdoError>;
async createIfAbsent(blob: Blob): Promise<BinaryLeaf | SolidLdoError>;
async createIfAbsent(_blob?: Blob): Promise<PresentLeafClass | SolidLdoError> {
return new SolidLdoError();
}
getCurrent(): LeafClass {
throw new Error("Not Implemented");
}
}

@ -1,9 +0,0 @@
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) {}

@ -1,8 +1,8 @@
import { Mixin } from "ts-mixer";
import { Leaf } from "./Leaf";
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 class PresentLeaf extends Mixin(Leaf, Present) {}
export abstract class PresentLeaf extends Mixin(FetchedLeaf, Present) {}

@ -1,5 +1,21 @@
import { Mixin } from "ts-mixer";
import { Absent } from "../abstract/fetchStatus/Absent";
import { PotentialBinaryLeaf } from "../abstract/leaf/PotentialBinaryLeaf";
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, PotentialBinaryLeaf) {}
export class AbsentLeaf extends Mixin(Absent, FetchedLeaf) {
create(...args: unknown[]): Promise<PresentClass | SolidLdoError> {
throw new Error("Method not implemented.");
}
read(): Promise<SolidLdoError | FetchedLeafClass> {
throw new Error("Method not implemented.");
}
createOrOverride(): Promise<PresentClass | SolidLdoError> {
throw new Error("Method not implemented.");
}
deleteIfPresent(): Promise<SolidLdoError | AbsentClass> {
throw new Error("Method not implemented.");
}
}

@ -1 +1,3 @@
export class BranchContainer {}
import { PresentContainer } from "../abstract/container/PresentContainer";
export class BranchContainer extends PresentContainer {}

@ -0,0 +1 @@
export class SolidLdoError extends Error {}
Loading…
Cancel
Save