Set up muti-inheritance structure

main
jaxoncreed 2 years ago
parent 4d3eabc81e
commit 90d70c05ea
  1. 16
      package-lock.json
  2. 195
      packages/solid/example/example.ts
  3. 5
      packages/solid/package.json
  4. 49
      packages/solid/src/SolidLdoDataset.ts
  5. 39
      packages/solid/src/resource-old/container/AbsentContainer.ts
  6. 77
      packages/solid/src/resource-old/container/Container.ts
  7. 30
      packages/solid/src/resource-old/container/UnfetchedContainer.ts
  8. 18
      packages/solid/src/resource-old/container/presentContainer/BranchContainer.ts
  9. 31
      packages/solid/src/resource-old/container/presentContainer/PresentContainer.ts
  10. 14
      packages/solid/src/resource-old/container/presentContainer/RootContainer.ts
  11. 56
      packages/solid/src/resource-old/leaf/AbsentLeaf.ts
  12. 38
      packages/solid/src/resource-old/leaf/Leaf.ts
  13. 49
      packages/solid/src/resource-old/leaf/UnfetchedLeaf.ts
  14. 15
      packages/solid/src/resource-old/leaf/presentLeaf/BinaryLeaf.ts
  15. 26
      packages/solid/src/resource-old/leaf/presentLeaf/DataLeaf.ts
  16. 17
      packages/solid/src/resource-old/leaf/presentLeaf/PresentLeaf.ts
  17. 254
      packages/solid/src/resource-old/notes.ts
  18. 97
      packages/solid/src/resource-old/types.ts
  19. 1
      packages/solid/src/resource/abstract/Resource.ts
  20. 3
      packages/solid/src/resource/abstract/container/Container.ts
  21. 0
      packages/solid/src/resource/abstract/container/PresentContainer.ts
  22. 7
      packages/solid/src/resource/abstract/dataResource/DataResource.ts
  23. 18
      packages/solid/src/resource/abstract/dataResource/PotentialDataResource.ts
  24. 13
      packages/solid/src/resource/abstract/fetchStatus/Absent.ts
  25. 5
      packages/solid/src/resource/abstract/fetchStatus/FetchStatus.ts
  26. 20
      packages/solid/src/resource/abstract/fetchStatus/Fetched.ts
  27. 19
      packages/solid/src/resource/abstract/fetchStatus/Present.ts
  28. 16
      packages/solid/src/resource/abstract/fetchStatus/Unfetched.ts
  29. 7
      packages/solid/src/resource/abstract/leaf/Leaf.ts
  30. 0
      packages/solid/src/resource/abstract/leaf/PotentialBinaryLeaf.ts
  31. 9
      packages/solid/src/resource/abstract/leaf/PotentialDataLeaf.ts
  32. 8
      packages/solid/src/resource/abstract/leaf/PresentLeaf.ts
  33. 5
      packages/solid/src/resource/concrete/AbsentContainer.ts
  34. 5
      packages/solid/src/resource/concrete/AbsentLeaf.ts
  35. 5
      packages/solid/src/resource/concrete/BinaryLeaf.ts
  36. 1
      packages/solid/src/resource/concrete/BranchContainer.ts
  37. 5
      packages/solid/src/resource/concrete/DataLeaf.ts
  38. 3
      packages/solid/src/resource/concrete/RootContainer.ts
  39. 5
      packages/solid/src/resource/concrete/UnfetchedContainer.ts
  40. 10
      packages/solid/src/resource/concrete/UnfetchedLeaf.ts

16
package-lock.json generated

@ -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",

@ -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();

@ -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"
}
}

@ -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");
}
}

@ -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,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,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…
Cancel
Save