Skip to content

Class: Container

Represents the current status of a specific container on a Pod as known by LDO.

Example

const container = solidLdoDataset
  .getResource("https://example.com/container/");

Hierarchy

Container

Constructors

constructor

new Container(uri, context): Container

Parameters

Name Type Description
uri ContainerUri The uri of the container
context SolidLdoDatasetContext SolidLdoDatasetContext for the parent dataset

Returns

Container

Overrides

Resource.constructor

Defined in

packages/solid/src/resource/Container.ts:87

Properties

absent

Protected absent: undefined | boolean

True if this resource has been fetched but does not exist

Inherited from

Resource.absent

Defined in

packages/solid/src/resource/Resource.ts:84


context

Protected Readonly context: SolidLdoDatasetContext

The SolidLdoDatasetContext from the Parent Dataset

Inherited from

Resource.context

Defined in

packages/solid/src/resource/Resource.ts:51


didInitialFetch

Protected didInitialFetch: boolean = false

True if this resource has been fetched at least once

Inherited from

Resource.didInitialFetch

Defined in

packages/solid/src/resource/Resource.ts:78


isError

Readonly isError: false

Indicates that this resource is not an error

Defined in

packages/solid/src/resource/Container.ts:71


requester

Protected requester: ContainerBatchedRequester

Batched Requester for the Container

Overrides

Resource.requester

Defined in

packages/solid/src/resource/Container.ts:55


rootContainer

Protected rootContainer: undefined | boolean

True if this is the root container, false if not, undefined if unknown

Defined in

packages/solid/src/resource/Container.ts:61


status

status: UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess | ContainerReadSuccess | AbsentReadSuccess | DeleteSuccess | CheckRootContainerSuccess | Unfetched

The status of the last request made for this container

Overrides

Resource.status

Defined in

packages/solid/src/resource/Container.ts:76


type

Readonly type: "container"

Indicates that this resource is a container resource

Overrides

Resource.type

Defined in

packages/solid/src/resource/Container.ts:66


uri

Readonly uri: ContainerUri

The URI of the container

Overrides

Resource.uri

Defined in

packages/solid/src/resource/Container.ts:49


wacRule

Protected Optional wacRule: WacRule

If a wac rule was fetched, it is cached here

Inherited from

Resource.wacRule

Defined in

packages/solid/src/resource/Resource.ts:96


wacUri

Protected Optional wacUri: LeafUri

If a wac uri is fetched, it is cached here

Inherited from

Resource.wacUri

Defined in

packages/solid/src/resource/Resource.ts:90

Methods

addListener

addListener\<E>(event, listener): this

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E
listener { update: () => void }[E]

Returns

this

Inherited from

Resource.addListener

Defined in

node_modules/typed-emitter/index.d.ts:22


checkIfIsRootContainer

checkIfIsRootContainer(): Promise\<ResourceResult\<CheckRootResult, Container>>

Checks if this container is a root container by making a request

Returns

Promise\<ResourceResult\<CheckRootResult, Container>>

CheckRootResult

Defined in

packages/solid/src/resource/Container.ts:211


child

child(slug): Container

Returns a child resource with a given name (slug)

Parameters

Name Type Description
slug ContainerUri the given name for that child resource

Returns

Container

the child resource (either a Leaf or Container depending on the name)

Example

const root = solidLdoDataset.getResource("https://example.com/");
const container = solidLdoDataset.child("container/");
// Logs "https://example.com/container/"
console.log(container.uri);
const resource = container.child("resource.ttl");
// Logs "https://example.com/container/resource.ttl"
console.log(resource.uri);

Defined in

packages/solid/src/resource/Container.ts:331

child(slug): Leaf

Parameters

Name Type
slug LeafUri

Returns

Leaf

Defined in

packages/solid/src/resource/Container.ts:332

child(slug): Leaf | Container

Parameters

Name Type
slug string

Returns

Leaf | Container

Defined in

packages/solid/src/resource/Container.ts:333


children

children(): (Leaf | Container)[]

Lists the currently cached children of this container (no request is made)

Returns

(Leaf | Container)[]

An array of children

const result = await container.read();
if (!result.isError) {
  const children = container.children();
  children.forEach((child) => {
    console.log(child.uri);
  });
}

Defined in

packages/solid/src/resource/Container.ts:302


clear

clear(): Promise\<ResourceResult\<AggregateSuccess\<ResourceSuccess\<DeleteSuccess, Leaf | Container>> | AggregateError\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError>, Container>>

Deletes all contents in this container

Returns

Promise\<ResourceResult\<AggregateSuccess\<ResourceSuccess\<DeleteSuccess, Leaf | Container>> | AggregateError\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError>, Container>>

An AggregateSuccess or Aggregate error corresponding with all the deleted resources

Example

const result = container.clear();
if (!result.isError) {
  console.log("All deleted resources:");
  result.results.forEach((result) => console.log(result.uri));
}

Defined in

packages/solid/src/resource/Container.ts:500


createAndOverwrite

createAndOverwrite(): Promise\<ResourceResult\<ContainerCreateAndOverwriteResult, Container>>

Creates a container at this URI and overwrites any that already exists

Returns

Promise\<ResourceResult\<ContainerCreateAndOverwriteResult, Container>>

ContainerCreateAndOverwriteResult

Example

const result = await container.createAndOverwrite();
if (!result.isError) {
  // Do something
}

Overrides

Resource.createAndOverwrite

Defined in

packages/solid/src/resource/Container.ts:570


createChildAndOverwrite

createChildAndOverwrite(slug): Promise\<ResourceResult\<ContainerCreateAndOverwriteResult, Container>>

Creates a resource and overwrites any existing resource that existed at the URI

Parameters

Name Type Description
slug ContainerUri the name of the resource

Returns

Promise\<ResourceResult\<ContainerCreateAndOverwriteResult, Container>>

the result of creating that resource

Example

const container = solidLdoDataset
  .getResource("https://example.com/container/");
cosnt result = await container.createChildAndOverwrite("resource.ttl");
if (!result.isError) {
  // Do something
}

Defined in

packages/solid/src/resource/Container.ts:361

createChildAndOverwrite(slug): Promise\<ResourceResult\<LeafCreateAndOverwriteResult, Leaf>>

Parameters

Name Type
slug LeafUri

Returns

Promise\<ResourceResult\<LeafCreateAndOverwriteResult, Leaf>>

Defined in

packages/solid/src/resource/Container.ts:364

createChildAndOverwrite(slug): Promise\<ResourceResult\<UnexpectedResourceError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess, Leaf | Container>>

Parameters

Name Type
slug string

Returns

Promise\<ResourceResult\<UnexpectedResourceError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess, Leaf | Container>>

Defined in

packages/solid/src/resource/Container.ts:367


createChildIfAbsent

createChildIfAbsent(slug): Promise\<ResourceResult\<ContainerCreateIfAbsentResult, Container>>

Creates a resource only if that resource doesn't already exist on the Solid Pod

Parameters

Name Type Description
slug ContainerUri the name of the resource

Returns

Promise\<ResourceResult\<ContainerCreateIfAbsentResult, Container>>

the result of creating that resource

Example

const container = solidLdoDataset
  .getResource("https://example.com/container/");
cosnt result = await container.createChildIfAbsent("resource.ttl");
if (!result.isError) {
  // Do something
}

Defined in

packages/solid/src/resource/Container.ts:403

createChildIfAbsent(slug): Promise\<ResourceResult\<LeafCreateIfAbsentResult, Leaf>>

Parameters

Name Type
slug LeafUri

Returns

Promise\<ResourceResult\<LeafCreateIfAbsentResult, Leaf>>

Defined in

packages/solid/src/resource/Container.ts:406

createChildIfAbsent(slug): Promise\<ResourceResult\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess | BinaryReadSuccess | DataReadSuccess | ContainerReadSuccess, Leaf | Container>>

Parameters

Name Type
slug string

Returns

Promise\<ResourceResult\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess | BinaryReadSuccess | DataReadSuccess | ContainerReadSuccess, Leaf | Container>>

Defined in

packages/solid/src/resource/Container.ts:409


createIfAbsent

createIfAbsent(): Promise\<ResourceResult\<ContainerCreateIfAbsentResult, Container>>

Creates a container at this URI if the container doesn't already exist

Returns

Promise\<ResourceResult\<ContainerCreateIfAbsentResult, Container>>

ContainerCreateIfAbsentResult

Example

const result = await container.createIfAbsent();
if (!result.isError) {
  // Do something
}

Overrides

Resource.createIfAbsent

Defined in

packages/solid/src/resource/Container.ts:591


delete

delete(): Promise\<ResourceResult\<DeleteResult | AggregateError\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError>, Container>>

Deletes this container and all its contents

Returns

Promise\<ResourceResult\<DeleteResult | AggregateError\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError>, Container>>

A Delete result for this container

const result = await container.delete();
if (!result.isError) {
  // Do something
}

Defined in

packages/solid/src/resource/Container.ts:545


emit

emit\<E>(event, ...args): boolean

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E
...args Parameters\<{ update: () => void }[E]>

Returns

boolean

Inherited from

Resource.emit

Defined in

node_modules/typed-emitter/index.d.ts:32


emitThisAndParent

emitThisAndParent(): void

Emits an update event for both this resource and the parent

Returns

void

Inherited from

Resource.emitThisAndParent

Defined in

packages/solid/src/resource/Resource.ts:313


eventNames

eventNames(): (string | symbol)[]

Returns

(string | symbol)[]

Inherited from

Resource.eventNames

Defined in

node_modules/typed-emitter/index.d.ts:34


getMaxListeners

getMaxListeners(): number

Returns

number

Inherited from

Resource.getMaxListeners

Defined in

node_modules/typed-emitter/index.d.ts:39


getParentContainer

getParentContainer(): Promise\<undefined | CheckRootResultError | Container>

Gets the parent container for this container by making a request

Returns

Promise\<undefined | CheckRootResultError | Container>

The parent container or undefined if there is no parent container because this container is the root container

Example

Suppose the root container is at https://example.com/

const root = solidLdoDataset.getResource("https://example.com/");
const container = solidLdoDataset
  .getResource("https://example.com/container");
const rootParent = await root.getParentContainer();
console.log(rootParent); // Logs "undefined"
const containerParent = await container.getParentContainer();
if (!containerParent.isError) {
  // Logs "https://example.com/"
  console.log(containerParent.uri);
}

Overrides

Resource.getParentContainer

Defined in

packages/solid/src/resource/Container.ts:270


getRootContainer

getRootContainer(): Promise\<CheckRootResultError | Container>

Gets the root container of this container. If this container is the root container, this function returns itself.

Returns

Promise\<CheckRootResultError | Container>

The root container for this container

Example

Suppose the root container is at https://example.com/

const container = ldoSolidDataset
  .getResource("https://example.com/container/");
const rootContainer = await container.getRootContainer();
if (!rootContainer.isError) {
  // logs "https://example.com/"
  console.log(rootContainer.uri);
}

Overrides

Resource.getRootContainer

Defined in

packages/solid/src/resource/Container.ts:240


getWac

getWac(options?): Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | NotFoundHttpError | GetWacRuleSuccess | WacRuleAbsent>

Retrieves web access control (WAC) rules for this resource

Parameters

Name Type Description
options? Object set the "ignoreCache" field to true to ignore any cached information on WAC rules.
options.ignoreCache boolean -

Returns

Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | NotFoundHttpError | GetWacRuleSuccess | WacRuleAbsent>

WAC Rules results

Example

const resource = ldoSolidDataset
  .getResource("https://example.com/container/resource.ttl");
const wacRulesResult = await resource.getWac();
if (!wacRulesResult.isError) {
  const wacRules = wacRulesResult.wacRule;
  // True if the resource is publicly readable
  console.log(wacRules.public.read);
  // True if authenticated agents can write to the resource
  console.log(wacRules.authenticated.write);
  // True if the given WebId has append access
  console.log(
    wacRules.agent[https://example.com/person1/profile/card#me].append
  );
  // True if the given WebId has control access
  console.log(
    wacRules.agent[https://example.com/person1/profile/card#me].control
  );
}

Inherited from

Resource.getWac

Defined in

packages/solid/src/resource/Resource.ts:596


getWacUri

getWacUri(options?): Promise\<GetWacUriResult>

Retrieves the URI for the web access control (WAC) rules for this resource

Parameters

Name Type Description
options? Object set the "ignoreCache" field to true to ignore any cached information on WAC rules.
options.ignoreCache boolean -

Returns

Promise\<GetWacUriResult>

WAC Rules results

Inherited from

Resource.getWacUri

Defined in

packages/solid/src/resource/Resource.ts:545


handleCreateAndOverwrite

handleCreateAndOverwrite(): Promise\<UnexpectedResourceError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess>

Helper method that handles the core functions for creating and overwriting a resource

Returns

Promise\<UnexpectedResourceError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess>

DeleteResult

Inherited from

Resource.handleCreateAndOverwrite

Defined in

packages/solid/src/resource/Resource.ts:457


handleCreateIfAbsent

handleCreateIfAbsent(): Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess | BinaryReadSuccess | DataReadSuccess | ContainerReadSuccess>

Helper method that handles the core functions for creating a resource if absent

Returns

Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess | BinaryReadSuccess | DataReadSuccess | ContainerReadSuccess>

DeleteResult

Inherited from

Resource.handleCreateIfAbsent

Defined in

packages/solid/src/resource/Resource.ts:493


handleDelete

handleDelete(): Promise\<DeleteResult>

Helper method that handles the core functions for deleting a resource

Returns

Promise\<DeleteResult>

DeleteResult

Inherited from

Resource.handleDelete

Defined in

packages/solid/src/resource/Resource.ts:405


handleRead

handleRead(): Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | BinaryReadSuccess | DataReadSuccess | ContainerReadSuccess | AbsentReadSuccess>

A helper method that handles the core functions for reading

Returns

Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | BinaryReadSuccess | DataReadSuccess | ContainerReadSuccess | AbsentReadSuccess>

ReadResult

Inherited from

Resource.handleRead

Defined in

packages/solid/src/resource/Resource.ts:343


isAbsent

isAbsent(): undefined | boolean

Is this resource currently absent (it does not exist)

Returns

undefined | boolean

true if the resource is absent, false if not, undefined if unknown

Example

// Logs "undefined"
console.log(resource.isAbsent());
const result = resource.read();
if (!result.isError) {
  // False if the resource exists, true if it does not
  console.log(resource.isAbsent());
}

Inherited from

Resource.isAbsent

Defined in

packages/solid/src/resource/Resource.ts:280


isCreating

isCreating(): boolean

Checks to see if this resource is being created

Returns

boolean

true if the resource is currently being created

Example

resource.read().then(() => {
  // Logs "false"
  console.log(resource.isCreating())
});
// Logs "true"
console.log(resource.isCreating());

Inherited from

Resource.isCreating

Defined in

packages/solid/src/resource/Resource.ts:144


isDeleting

isDeleting(): boolean

Checks to see if this resource is being deleted

Returns

boolean

true if the resource is currently being deleted

Example

resource.read().then(() => {
  // Logs "false"
  console.log(resource.isDeleting())
});
// Logs "true"
console.log(resource.isDeleting());

Inherited from

Resource.isDeleting

Defined in

packages/solid/src/resource/Resource.ts:180


isDoingInitialFetch

isDoingInitialFetch(): boolean

Checks to see if this resource is being read for the first time

Returns

boolean

true if the resource is currently being read for the first time

Example

resource.read().then(() => {
  // Logs "false"
  console.log(resource.isDoingInitialFetch())
});
// Logs "true"
console.log(resource.isDoingInitialFetch());

Inherited from

Resource.isDoingInitialFetch

Defined in

packages/solid/src/resource/Resource.ts:198


isFetched

isFetched(): boolean

Check to see if this resource has been fetched

Returns

boolean

true if this resource has been fetched before

Example

// Logs "false"
console.log(resource.isFetched());
const result = await resource.read();
if (!result.isError) {
  // Logs "true"
  console.log(resource.isFetched());
}

Inherited from

Resource.isFetched

Defined in

packages/solid/src/resource/Resource.ts:242


isLoading

isLoading(): boolean

Checks to see if this resource is loading in any way

Returns

boolean

true if the resource is currently loading

Example

resource.read().then(() => {
  // Logs "false"
  console.log(resource.isLoading())
});
// Logs "true"
console.log(resource.isLoading());

Inherited from

Resource.isLoading

Defined in

packages/solid/src/resource/Resource.ts:126


isPresent

isPresent(): undefined | boolean

Is this resource currently present on the Pod

Returns

undefined | boolean

false if the resource is absent, true if not, undefined if unknown

Example

// Logs "undefined"
console.log(resource.isPresent());
const result = resource.read();
if (!result.isError) {
  // True if the resource exists, false if it does not
  console.log(resource.isPresent());
}

Inherited from

Resource.isPresent

Defined in

packages/solid/src/resource/Resource.ts:299


isReading

isReading(): boolean

Checks to see if this resource is being read

Returns

boolean

true if the resource is currently being read

Example

resource.read().then(() => {
  // Logs "false"
  console.log(resource.isReading())
});
// Logs "true"
console.log(resource.isReading());

Inherited from

Resource.isReading

Defined in

packages/solid/src/resource/Resource.ts:162


isReloading

isReloading(): boolean

Checks to see if this resource is being read for a subsequent time

Returns

boolean

true if the resource is currently being read for a subsequent time

Example

await resource.read();
resource.read().then(() => {
  // Logs "false"
  console.log(resource.isCreating())
});
// Logs "true"
console.log(resource.isCreating());

Inherited from

Resource.isReloading

Defined in

packages/solid/src/resource/Resource.ts:217


isRootContainer

isRootContainer(): undefined | boolean

Checks if this container is a root container

Returns

undefined | boolean

true if this container is a root container, false if not, and undefined if this is unknown at the moment.

Example

// Returns "undefined" when the container is unfetched
console.log(container.isRootContainer());
const result = await container.read();
if (!result.isError) {
  // Returns true or false
  console.log(container.isRootContainer());
}

Defined in

packages/solid/src/resource/Container.ts:110


isUnfetched

isUnfetched(): boolean

Check to see if this resource is currently unfetched

Returns

boolean

true if the resource is currently unfetched

Example

// Logs "true"
console.log(resource.isUnetched());
const result = await resource.read();
if (!result.isError) {
  // Logs "false"
  console.log(resource.isUnfetched());
}

Inherited from

Resource.isUnfetched

Defined in

packages/solid/src/resource/Resource.ts:261


listenerCount

listenerCount\<E>(event): number

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E

Returns

number

Inherited from

Resource.listenerCount

Defined in

node_modules/typed-emitter/index.d.ts:37


listeners

listeners\<E>(event): { update: () => void }[E][]

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E

Returns

{ update: () => void }[E][]

Inherited from

Resource.listeners

Defined in

node_modules/typed-emitter/index.d.ts:36


off

off\<E>(event, listener): this

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E
listener { update: () => void }[E]

Returns

this

Inherited from

Resource.off

Defined in

node_modules/typed-emitter/index.d.ts:28


on

on\<E>(event, listener): this

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E
listener { update: () => void }[E]

Returns

this

Inherited from

Resource.on

Defined in

node_modules/typed-emitter/index.d.ts:23


once

once\<E>(event, listener): this

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E
listener { update: () => void }[E]

Returns

this

Inherited from

Resource.once

Defined in

node_modules/typed-emitter/index.d.ts:24


prependListener

prependListener\<E>(event, listener): this

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E
listener { update: () => void }[E]

Returns

this

Inherited from

Resource.prependListener

Defined in

node_modules/typed-emitter/index.d.ts:25


prependOnceListener

prependOnceListener\<E>(event, listener): this

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E
listener { update: () => void }[E]

Returns

this

Inherited from

Resource.prependOnceListener

Defined in

node_modules/typed-emitter/index.d.ts:26


rawListeners

rawListeners\<E>(event): { update: () => void }[E][]

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E

Returns

{ update: () => void }[E][]

Inherited from

Resource.rawListeners

Defined in

node_modules/typed-emitter/index.d.ts:35


read

read(): Promise\<ResourceResult\<ReadContainerResult, Container>>

Reads the container

Returns

Promise\<ResourceResult\<ReadContainerResult, Container>>

A read result

Example

const result = await container.read();
if (result.isError) {
  // Do something
}

Overrides

Resource.read

Defined in

packages/solid/src/resource/Container.ts:146


readIfUnfetched

readIfUnfetched(): Promise\<ResourceResult\<ReadContainerResult, Container>>

Makes a request to read this container if it hasn't been fetched yet. If it has, return the cached informtation

Returns

Promise\<ResourceResult\<ReadContainerResult, Container>>

a ReadContainerResult

Example

const result = await container.read();
if (!result.isError) {
  // Will execute without making a request
  const result2 = await container.readIfUnfetched();
}

Overrides

Resource.readIfUnfetched

Defined in

packages/solid/src/resource/Container.ts:192


removeAllListeners

removeAllListeners\<E>(event?): this

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event? E

Returns

this

Inherited from

Resource.removeAllListeners

Defined in

node_modules/typed-emitter/index.d.ts:29


removeListener

removeListener\<E>(event, listener): this

Type parameters

Name Type
E extends "update"

Parameters

Name Type
event E
listener { update: () => void }[E]

Returns

this

Inherited from

Resource.removeListener

Defined in

node_modules/typed-emitter/index.d.ts:30


setMaxListeners

setMaxListeners(maxListeners): this

Parameters

Name Type
maxListeners number

Returns

this

Inherited from

Resource.setMaxListeners

Defined in

node_modules/typed-emitter/index.d.ts:40


setWac

setWac(wacRule): Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | NotFoundHttpError | SetWacRuleSuccess>

Sets access rules for a specific resource

Parameters

Name Type Description
wacRule WacRule the access rules to set

Returns

Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | NotFoundHttpError | SetWacRuleSuccess>

SetWacRuleResult

Example

const resource = ldoSolidDataset
  .getResource("https://example.com/container/resource.ttl");
const wacRulesResult = await resource.setWac({
  public: {
    read: true,
    write: false,
    append: false,
    control: false
  },
  authenticated: {
    read: true,
    write: false,
    append: true,
    control: false
  },
  agent: {
    "https://example.com/person1/profile/card#me": {
      read: true,
      write: true,
      append: true,
      control: true
    }
  }
});

Inherited from

Resource.setWac

Defined in

packages/solid/src/resource/Resource.ts:669


toReadResult

toReadResult(): ResourceResult\<ReadContainerResult, Container>

Converts the current state of this container to a readResult

Returns

ResourceResult\<ReadContainerResult, Container>

a ReadContainerResult

Overrides

Resource.toReadResult

Defined in

packages/solid/src/resource/Container.ts:157


updateWithCreateSuccess

updateWithCreateSuccess(result): void

A helper method updates this resource's internal state upon create success

Parameters

Name Type
result ResourceSuccess

Returns

void

Inherited from

Resource.updateWithCreateSuccess

Defined in

packages/solid/src/resource/Resource.ts:424


updateWithDeleteSuccess

updateWithDeleteSuccess(_result): void

A helper method updates this resource's internal state upon delete success

Parameters

Name Type
_result DeleteSuccess

Returns

void

Inherited from

Resource.updateWithDeleteSuccess

Defined in

packages/solid/src/resource/Resource.ts:395


updateWithReadSuccess

updateWithReadSuccess(result): void

A helper method updates this container's internal state upon read success

Parameters

Name Type Description
result ContainerReadSuccess | AbsentReadSuccess the result of the read success

Returns

void

Overrides

Resource.updateWithReadSuccess

Defined in

packages/solid/src/resource/Container.ts:125


uploadChildAndOverwrite

uploadChildAndOverwrite(slug, blob, mimeType): Promise\<ResourceResult\<LeafCreateAndOverwriteResult, Leaf>>

Creates a new binary resource and overwrites any existing resource that existed at the URI

Parameters

Name Type Description
slug LeafUri the name of the resource
blob Blob -
mimeType string -

Returns

Promise\<ResourceResult\<LeafCreateAndOverwriteResult, Leaf>>

the result of creating that resource

Example

const container = solidLdoDataset
  .getResource("https://example.com/container/");
cosnt result = await container.uploadChildAndOverwrite(
  "resource.txt",
  new Blob("some text."),
  "text/txt",
);
if (!result.isError) {
  // Do something
}

Defined in

packages/solid/src/resource/Container.ts:449


uploadChildIfAbsent

uploadChildIfAbsent(slug, blob, mimeType): Promise\<ResourceResult\<LeafCreateIfAbsentResult, Leaf>>

Creates a new binary resource and overwrites any existing resource that existed at the URI

Parameters

Name Type Description
slug LeafUri the name of the resource
blob Blob -
mimeType string -

Returns

Promise\<ResourceResult\<LeafCreateIfAbsentResult, Leaf>>

the result of creating that resource

Example

const container = solidLdoDataset
  .getResource("https://example.com/container/");
cosnt result = await container.uploadChildIfAbsent(
  "resource.txt",
  new Blob("some text."),
  "text/txt",
);
if (!result.isError) {
  // Do something
}

Defined in

packages/solid/src/resource/Container.ts:478