Skip to main content

LdpContainerService

This service is automatically created by the LdpService with the key ldp.container.

Actions

The following service actions are available:

attach

Attach a resource to a container

Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of container to which the resource will be attached
resourceUriStringrequiredURI of resource to attach
webIdStringLogged user's webIdUser doing the action

clear

Delete all the resources attached to a container

Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of the container to clear
webIdStringLogged user's webIdUser doing the action

create

  • Create a new LDP container
  • This does not create the relative API routes.
Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of the container to create
titleStringTitle of the container
descriptionStringDescription of the container
permissionsStringWAC permissions to apply to the new container
webIdStringLogged user's webIdUser doing the action

createAndAttach

  • Create a container and attach it to its parent container(s)
  • Recursively create the parent container(s) if they don't exist
  • In Pod provider config, the webId is required to find the Pod root
Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of the container to create
titleStringTitle of the container
descriptionStringDescription of the container
permissionsStringWAC permissions to apply to the new container
webIdStringLogged user's webIdUser doing the action

detach

Detach a resource from a container

Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of container to which the resource will be detached
resourceUriStringrequiredURI of resource to attach
webIdStringLogged user's webIdUser doing the action

exist

Check if a container exists

Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of container to check
webIdStringLogged user's webIdUser doing the action
Return

true or false

get

Get the LDP container with all its resources (which are dereferenced)

Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of container
acceptStringrequiredType to return
filtersObjectKey/value with predicates and value
jsonContextObjector StringJSON-LD context to use when compacting the results
webIdStringLogged user's webIdUser doing the action

You can also pass parameters defined in the container options.

Return

Triples, Turtle or JSON-LD depending on accept type.

getAll

Get the list of all existing containers

Parameters
PropertyTypeDefaultDescription
datasetStringDataset (required in Pod provider config)
Return

Array of URIs

getPath

Get the container path based on the provided resourceType. For example, if you pass pair:ProjectType, it will return /pair/project-type. Ontologies must be previously registered or the action will throw an error.

Parameters
PropertyTypeDefaultDescription
resourceTypeStringrequiredURI or prefixed resource type
Return

The path of the container

getUris

Get the list of all resources within a container

Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of container
Return

Array of URIs

includes

Checks if a resource is in the container

Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of container
resourceUriStringrequiredURI of resource
webIdStringLogged user's webIdUser doing the action
Return

Boolean

isEmpty

Checks if a container is empty

Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of container
webIdStringLogged user's webIdUser doing the action
Return

Boolean

patch

Attach and/or detach resource(s) from a container

Parameters
PropertyTypeDefaultDescription
containerUriStringrequiredURI of container to which the resource will be attached or detached
triplesToAddArrayTriples to add, in RDF/JS format. See below for details.
triplesToRemoveArrayTriples to remove, in RDF/JS format. See below for details.
webIdstringLogged user's webIdUser doing the action

Example usage:

const { triple, namedNode } = require('@rdfjs/data-model');

await this.broker.call('ldp.container.patch', {
containerUri: 'http://localhost:3002/resources',
triplesToAdd: [
triple(
namedNode('http://localhost:3002/resources'),
namedNode('http://www.w3.org/ns/ldp#contains'),
namedNode('http://localhost:3001/resources/my-resource')
)
]
});

If the resource being patched is a remote resource, it will be stored locally (with ldp.remote.store) before being attached to the container.

post

  • Generate an URI, create the resource (calling ldp.resource.create), and attach it to a container
  • Content type can be triples, turtle or JSON-LD (see @semapps/mime-types package)
Parameters
PropertyTypeDefaultDescription
resourceObjectrequiredResource to create
containerUriStringrequiredContainer where the resource will be created
contentTypeStringrequiredType of data
slugStringSpecific ID tu use for URI instead generated UUID
webIdStringLogged user's webIdUser doing the action

The slug parameter is ignored if the resourcesWithContainerPath setting is false.

Return

URI of the created resource

Events

The following events are emitted.

ldp.container.attached

Sent after a resource is attached to a container

Payload
PropertyTypeDescription
containerUriStringURI of container
resourceUriStringURI of resource

ldp.container.detached

Sent after a resource is detached from a container

Payload
PropertyTypeDescription
containerUriStringURI of container
resourceUriStringURI of resource

ldp.container.patched

Sent after a PATCH operation on the container

Payload
PropertyTypeDescription
containerUriStringURI of container