parent
4d3eabc81e
commit
90d70c05ea
@ -0,0 +1,195 @@ |
|||||||
|
const resourceMethods: Record<string, string[]> = { |
||||||
|
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<string, string[]> = {}; |
||||||
|
|
||||||
|
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(); |
@ -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<false> { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
async create(): Promise<PresentContainerClass | LdoSolidError> { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
} |
@ -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<FetchedContainerClass | LdoSolidError> { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
reload(): Promise<FetchedContainerClass | LdoSolidError> { |
||||||
|
return this.read(); |
||||||
|
} |
||||||
|
load(): Promise<FetchedContainerClass | LdoSolidError> { |
||||||
|
return this.read(); |
||||||
|
} |
||||||
|
getCurrent(): ContainerClass { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
|
||||||
|
abstract getIsRootContainer(): Promise<boolean>; |
||||||
|
|
||||||
|
createContainerIn( |
||||||
|
_relativeUri: string, |
||||||
|
): Promise<BranchContainer | LdoSolidError> { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
|
||||||
|
createLeafDataResourceIn( |
||||||
|
_relativeUri: string, |
||||||
|
): Promise<DataLeaf | LdoSolidError> { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
|
||||||
|
uploadBinaryIn( |
||||||
|
_relativeUri, |
||||||
|
_blob: Blob, |
||||||
|
): Promise<BinaryLeaf | LdoSolidError> { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
|
||||||
|
clearIfPresent(): Promise<this | LdoSolidError> { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
|
||||||
|
createIfAbsent(): Promise<LdoSolidError | PresentContainerClass> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
createOrOverwrite(): Promise<LdoSolidError | PresentContainerClass> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
} |
@ -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<boolean> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
} |
@ -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<false> { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
getCurrent(): this { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
} |
@ -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"); |
||||||
|
} |
||||||
|
} |
@ -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<true> { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
@ -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<false> { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
async upload(_blob: Blob): Promise<BinaryLeaf | LdoSolidError> { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
uploadIfAbsent(_blob: Blob): Promise<BinaryLeaf | LdoSolidError> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
uploadOrOverwrite(_blob: Blob): Promise<BinaryLeaf | LdoSolidError> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
|
||||||
|
async create(): Promise<DataLeaf | LdoSolidError> { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
createIfAbsent(): Promise<LdoSolidError | PresentLeafClass> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
createOrOverwrite(): Promise<LdoSolidError | DataLeaf> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
} |
@ -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<FetchedLeafClass | LdoSolidError> { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
reload(): Promise<FetchedLeafClass | LdoSolidError> { |
||||||
|
return this.read(); |
||||||
|
} |
||||||
|
load(): Promise<FetchedLeafClass | LdoSolidError> { |
||||||
|
return this.read(); |
||||||
|
} |
||||||
|
getCurrent(): LeafClass { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
|
||||||
|
async createOrOverwrite(): Promise<DataLeaf | LdoSolidError> { |
||||||
|
throw new Error("Not Implemented"); |
||||||
|
} |
||||||
|
async uploadOrOverwrite(_blob: Blob): Promise<BinaryLeaf | LdoSolidError> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
} |
@ -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<boolean> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
|
||||||
|
uploadIfAbsent(_blob: Blob): Promise<LdoSolidError | PresentLeaf> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
uploadOrOverwrite(_blob: Blob): Promise<LdoSolidError | BinaryLeaf> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
|
||||||
|
createIfAbsent(): Promise<PresentLeaf | LdoSolidError> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
createOrOverwrite(): Promise<LdoSolidError | DataLeaf> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
} |
@ -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<LdoSolidError | BinaryLeaf> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
} |
@ -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<DataLeaf | LdoSolidError> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
createOrOverwrite(): Promise<DataLeaf | LdoSolidError> { |
||||||
|
throw new Error("Method not implemented."); |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
} |
||||||
|
} |
@ -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<RootContainerResource | LdoSolidError>; |
||||||
|
getParentContainer(): Promise<RootContainerResource | ContainerResource | LdoSolidError>; |
||||||
|
uploadOrOverwrite(blob: Blob): Promise<BinaryResource | LdoSolidError>; |
||||||
|
read(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
reload(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
load(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
delete(): Promise<AbsentBinaryResource | LdoSolidError>; |
||||||
|
deleteIfPresent(): Promise<AbsentBinaryResource | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export interface RootContainerResource { |
||||||
|
uri: string; |
||||||
|
isLoading: boolean; |
||||||
|
didInitialFetch: true; |
||||||
|
ldoDataset(): LdoDataset; |
||||||
|
getIsRootContainer(): Promise<boolean>; |
||||||
|
createContainerIn(relativeUri: string): Promise<ContainerResource | LdoSolidError>; |
||||||
|
createDataResourceIn(relativeUri: string): Promise<DataResource | LdoSolidError>; |
||||||
|
uploadBinaryIn(relativeUri, blob: Blob): Promise<BinaryResource | LdoSolidError>; |
||||||
|
createOrOverwrite(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
read(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
reload(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
load(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
clear(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
clearIfPresent(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export interface ContainerResource { |
||||||
|
uri: string; |
||||||
|
isLoading: boolean; |
||||||
|
didInitialFetch: true; |
||||||
|
parentContainer: ContainerResource | RootContainerResource; |
||||||
|
getIsRootContainer(): Promise<boolean>; |
||||||
|
getParentContainer(): Promise<RootContainerResource | ContainerResource | LdoSolidError>; |
||||||
|
childResources: ContainerResource | DataResource | BinaryResource | UnfetchedContainerResource | UnfetchedDataResource | UnfetchedBinaryResource; |
||||||
|
getRootContainer(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
createContainerIn(relativeUri: string): Promise<ContainerResource | LdoSolidError>; |
||||||
|
createDataResourceIn(relativeUri: string): Promise<DataResource | LdoSolidError>; |
||||||
|
uploadBinaryIn(relativeUri, blob: Blob): Promise<BinaryResource | LdoSolidError>; |
||||||
|
ldoDataset(): LdoDataset; |
||||||
|
createOrOverwrite(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
read(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
reload(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
load(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
delete(): Promise<AbsentContainerResource | LdoSolidError>; |
||||||
|
deleteIfPresent(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
clear(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
clearIfPresent(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export interface DataResource { |
||||||
|
uri: string; |
||||||
|
isLoading: boolean; |
||||||
|
didInitialFetch: true; |
||||||
|
parentContainer: ContainerResource | RootContainerResource; |
||||||
|
getParentContainer(): Promise<RootContainerResource | ContainerResource | LdoSolidError>; |
||||||
|
hasData(): boolean; |
||||||
|
ldoDataset(): LdoDataset; |
||||||
|
getRootContainer(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
createOrOverwrite(): Promise<DataResource | LdoSolidError>; |
||||||
|
read(): Promise<DataResource | LdoSolidError>; |
||||||
|
reload(): Promise<DataResource | LdoSolidError>; |
||||||
|
load(): Promise<DataResource | LdoSolidError>; |
||||||
|
delete(): Promise<AbsentDataResource | LdoSolidError>; |
||||||
|
deleteIfPresent(): Promise<AbsentBinaryResource | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export interface AbsentDataResource { |
||||||
|
uri: string; |
||||||
|
isLoading: boolean; |
||||||
|
didInitialFetch: true; |
||||||
|
parentContainer: ContainerResource | RootContainerResource; |
||||||
|
getParentContainer(): Promise<RootContainerResource | ContainerResource | LdoSolidError>; |
||||||
|
getRootContainer(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
createOrOverwrite(): Promise<DataResource | LdoSolidError>; |
||||||
|
create(): Promise<DataResource | LdoSolidError>; |
||||||
|
createIfAbsent(): Promise<DataResource | LdoSolidError>; |
||||||
|
read(): Promise<DataResource | LdoSolidError>; |
||||||
|
reload(): Promise<DataResource | LdoSolidError>; |
||||||
|
load(): Promise<DataResource | LdoSolidError>; |
||||||
|
deleteIfPresent(): Promise<AbsentBinaryResource | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export interface AbsentBinaryResource { |
||||||
|
uri: string; |
||||||
|
isLoading: boolean; |
||||||
|
didInitialFetch: true; |
||||||
|
parentContainer: ContainerResource | RootContainerResource; |
||||||
|
getParentContainer(): Promise<RootContainerResource | ContainerResource | LdoSolidError>; |
||||||
|
getRootContainer(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
uploadOrOverwrite(blob: Blob): Promise<BinaryResource | LdoSolidError>; |
||||||
|
upload(blob: Blob): Promise<BinaryResource | LdoSolidError>; |
||||||
|
uploadIfAbsent(blob: Blob): Promise<BinaryResource | BinaryResource>; |
||||||
|
read(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
reload(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
load(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
deleteIfPresent(): Promise<AbsentBinaryResource | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export interface AbsentContainerResource { |
||||||
|
uri: string; |
||||||
|
isLoading: boolean; |
||||||
|
didInitialFetch: true; |
||||||
|
parentContainer: ContainerResource | RootContainerResource; |
||||||
|
getIsRootContainer(): Promise<boolean>; |
||||||
|
getParentContainer(): Promise<RootContainerResource | ContainerResource | LdoSolidError>; |
||||||
|
getRootContainer(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
createContainerIn(relativeUri: string): Promise<ContainerResource | LdoSolidError>; |
||||||
|
createDataResourceIn(relativeUri: string): Promise<DataResource | LdoSolidError>; |
||||||
|
uploadBinaryIn(relativeUri, blob: Blob): Promise<BinaryResource | LdoSolidError>; |
||||||
|
createOrOverwrite(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
create(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
createIfAbsent(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
read(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
reload(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
load(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
deleteIfPresent(): Promise<AbsentContainerResource | LdoSolidError>; |
||||||
|
clearIfPresent(): Promise<AbsentContainerResource | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export interface UnfetchedDataResource { |
||||||
|
parentContainer: ContainerResource | RootContainerResource; |
||||||
|
getParentContainer(): Promise<RootContainerResource | ContainerResource | LdoSolidError>; |
||||||
|
uri: string; |
||||||
|
isLoading: boolean; |
||||||
|
didInitialFetch: false; |
||||||
|
getRootContainer(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
createOrOverwrite(): Promise<DataResource | LdoSolidError>; |
||||||
|
createIfAbsent(): Promise<DataResource | LdoSolidError>; |
||||||
|
read(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
reload(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
load(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
deleteIfPresent(): Promise<AbsentBinaryResource | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export interface UnfetchedBinaryResource { |
||||||
|
uri: string; |
||||||
|
isLoading: boolean; |
||||||
|
didInitialFetch: false; |
||||||
|
parentContainer: ContainerResource | RootContainerResource; |
||||||
|
getParentContainer(): Promise<RootContainerResource | ContainerResource | LdoSolidError>; |
||||||
|
getRootContainer(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
uploadOrOverwrite(blob: Blob): Promise<BinaryResource | LdoSolidError> |
||||||
|
createOrOverwrite(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
uploadIfAbsent(blob: Blob): Promise<BinaryResource | BinaryResource>; |
||||||
|
read(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
reload(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
load(): Promise<BinaryResource | LdoSolidError>; |
||||||
|
deleteIfPresent(): Promise<AbsentBinaryResource | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export interface UnfetchedContainerResource { |
||||||
|
uri: string; |
||||||
|
isLoading: boolean; |
||||||
|
didInitialFetch: false; |
||||||
|
getIsRootContainer(): Promise<boolean>; |
||||||
|
getParentContainer(): Promise<RootContainerResource | ContainerResource | LdoSolidError | undefined>; |
||||||
|
getRootContainer(): Promise<RootContainerResource | LdoSolidError>; |
||||||
|
createContainerIn(relativeUri: string): Promise<ContainerResource | LdoSolidError>; |
||||||
|
createDataResourceIn(relativeUri: string): Promise<DataResource | LdoSolidError>; |
||||||
|
uploadBinaryIn(relativeUri, blob: Blob): Promise<BinaryResource | LdoSolidError>; |
||||||
|
createOrOverwrite(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
createIfAbsent(): Promise<ContainerResource | LdoSolidError>; |
||||||
|
read(): Promise<ContainerResource | RootContainerResource | LdoSolidError>; |
||||||
|
reload(): Promise<ContainerResource | RootContainerResource | LdoSolidError>; |
||||||
|
load(): Promise<ContainerResource | RootContainerResource | LdoSolidError>; |
||||||
|
clearIfPresent(): Promise<ContainerResource | AbsentContainerResource | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface LdoSolidError extends Error { |
||||||
|
forResource: unknown // Some Kind of Resource
|
||||||
|
} |
@ -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<PresentLeaf | LdoSolidError>; |
||||||
|
uploadOrOverwrite(blob: Blob): Promise<BinaryLeaf | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export type PotentialDataClass = AbsentLeaf | UnfetchedLeaf | DataLeaf; |
||||||
|
export interface PotentialData { |
||||||
|
createIfAbsent(): Promise<PresentLeaf | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export type PotentialContainerClass = |
||||||
|
| RootContainer |
||||||
|
| BranchContainer |
||||||
|
| AbsentContainer |
||||||
|
| UnfetchedContainer; |
||||||
|
export interface PotentialContainer { |
||||||
|
createIfAbsent(): Promise<PresentContainerClass | LdoSolidError>; |
||||||
|
} |
||||||
|
|
||||||
|
export type FetchedContainerClass = |
||||||
|
| RootContainer |
||||||
|
| BranchContainer |
||||||
|
| AbsentContainer; |
||||||
|
export interface FetchedContainer {} |
||||||
|
|
||||||
|
export type FetchedLeafClass = DataLeaf | BinaryLeaf | AbsentLeaf; |
||||||
|
export interface FetchedLeaf {} |
@ -0,0 +1 @@ |
|||||||
|
export class Resource {}; |
@ -0,0 +1,3 @@ |
|||||||
|
import { PotentialDataResource } from "../dataResource/potentialDataResource"; |
||||||
|
|
||||||
|
export class Container extends PotentialDataResource {} |
@ -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 {} |
@ -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 {} |
@ -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; |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
} |
@ -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; |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
} |
||||||
|
} |
@ -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 {} |
@ -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) {} |
@ -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) {} |
@ -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) {} |
@ -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) {} |
@ -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) {} |
@ -0,0 +1 @@ |
|||||||
|
export class BranchContainer {} |
@ -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) {} |
@ -0,0 +1,3 @@ |
|||||||
|
import { PresentContainer } from "../abstract/container/PresentContainer"; |
||||||
|
|
||||||
|
export class RootContainer extends PresentContainer {} |
@ -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) {} |
@ -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, |
||||||
|
) {} |
Loading…
Reference in new issue