Skip to content

Class: ConnectedLdoDataset\<Plugins>

A ConnectedLdoDataset has all the functionality of a LdoDataset with the added functionality of keeping track of fetched remote Resources.

It is recommended to use the createConnectedLdoDataset to initialize this class.

Example

import { createConnectedLdoDataset } from "@ldo/connected";
import { ProfileShapeType } from "./.ldo/profile.shapeTypes.ts"

// At least one plugin needs to be provided to a ConnectedLdoDataset. In this
// example we'll use both the Solid and NextGraph plugins.
import { solidConnectedPlugin } from "@ldo/connected-solid";
import { nextGraphConnectedPlugin } from "@ldo/connected-nextgraph";

// ...

const connectedLdoDataset = createConnectedLdoDataset([
  solidConnectedPlugin,
  nextGraphConnectedPlugin
]);

const profileDocument = connectedLdoDataset
  .getResource("https://example.com/profile");
await profileDocument.read();

const profile = connectedLdoDataset
  .using(ProfileShapeType)
  .fromSubject("https://example.com/profile#me");

Type parameters

Name Type
Plugins extends ConnectedPlugin\<any, any, any, any>[]

Hierarchy

  • LdoDataset

ConnectedLdoDataset

Implements

Constructors

constructor

new ConnectedLdoDataset\<Plugins>(plugins, datasetFactory, transactionDatasetFactory, initialDataset?): ConnectedLdoDataset\<Plugins>

It is recommended to use the createConnectedLdoDataset function to instantiate a ConnectedLdoDataset.

Type parameters

Name Type
Plugins extends ConnectedPlugin\<any, any, any, any, any>[]

Parameters

Name Type Description
plugins Plugins An array of plugins for each platform to connect to
datasetFactory DatasetFactory\<Quad, Quad, Dataset\<Quad, Quad>> Creates Datasets
transactionDatasetFactory ITransactionDatasetFactory\<Quad> Creates Transaction Datasets
initialDataset? Dataset\<Quad, Quad> Initial quads

Returns

ConnectedLdoDataset\<Plugins>

Overrides

LdoDataset.constructor

Defined in

packages/connected/src/ConnectedLdoDataset.ts:84

Properties

context

Protected context: ConnectedContext\<Plugins>

Context for each plugin (usually utilities for authentication)

Defined in

packages/connected/src/ConnectedLdoDataset.ts:73


dataset

Protected dataset: DatasetCore\<Quad, Quad>

Implementation of

IConnectedLdoDataset.dataset

Inherited from

LdoDataset.dataset

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:3


datasetCoreFactory

Protected datasetCoreFactory: DatasetCoreFactory\<Quad, Quad, DatasetCore\<Quad, Quad>>

Implementation of

IConnectedLdoDataset.datasetCoreFactory

Inherited from

LdoDataset.datasetCoreFactory

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:4


datasetFactory

Protected datasetFactory: DatasetFactory\<Quad, Quad, Dataset\<Quad, Quad>>

Implementation of

IConnectedLdoDataset.datasetFactory

Inherited from

LdoDataset.datasetFactory

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:8


eventEmitter

Protected eventEmitter: EventEmitter\<DefaultEventMap>

Implementation of

IConnectedLdoDataset.eventEmitter

Inherited from

LdoDataset.eventEmitter

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:9


plugins

Private plugins: Plugins

A list of plugins used by this dataset

Defined in

packages/connected/src/ConnectedLdoDataset.ts:60


resourceMap

Protected resourceMap: Map\<string, Plugins[number]["types"]["resource"]>

A mapping between a resource URI and a resource

Defined in

packages/connected/src/ConnectedLdoDataset.ts:66


transactionDatasetFactory

Protected transactionDatasetFactory: ITransactionDatasetFactory\<Quad>

Implementation of

IConnectedLdoDataset.transactionDatasetFactory

Inherited from

LdoDataset.transactionDatasetFactory

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:10

Accessors

size

get size(): number

Returns

number

Implementation of

IConnectedLdoDataset.size

Inherited from

LdoDataset.size

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:26

Methods

[iterator]

[iterator](): Iterator\<Quad, Quad, undefined>

Returns

Iterator\<Quad, Quad, undefined>

Implementation of

IConnectedLdoDataset.[iterator]

Inherited from

LdoDataset.[iterator]

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:30


add

add(quad): this

Parameters

Name Type
quad Quad

Returns

this

Implementation of

IConnectedLdoDataset.add

Inherited from

LdoDataset.add

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:17


addAll

addAll(quads): this

Parameters

Name Type
quads Quad[] | Dataset\<Quad, Quad>

Returns

this

Implementation of

IConnectedLdoDataset.addAll

Inherited from

LdoDataset.addAll

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:14


addListener

addListener(eventName, listener): this

Parameters

Name Type
eventName QuadMatch
listener nodeEventListener\<Quad>

Returns

this

Implementation of

IConnectedLdoDataset.addListener

Inherited from

LdoDataset.addListener

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:20


bulk

bulk(changed): this

Parameters

Name Type
changed DatasetChanges\<Quad>

Returns

this

Implementation of

IConnectedLdoDataset.bulk

Inherited from

LdoDataset.bulk

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:15


contains

contains(other): boolean

Parameters

Name Type
other Dataset\<Quad, Quad>

Returns

boolean

Implementation of

IConnectedLdoDataset.contains

Inherited from

LdoDataset.contains

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:8


createData

createData\<Type>(shapeType, subject, resource, ...additionalResources): Type

Shorthand for connectedLdoDataset .usingType(shapeType) .write(...resources.map((r) => r.uri)) .fromSubject(subject);

Type parameters

Name Type
Type extends LdoBase

Parameters

Name Type Description
shapeType ShapeType\<Type> The shapetype to represent the data
subject string | SubjectNode A subject URI
resource Plugins[number]["types"]["resource"] -
...additionalResources Plugins[number]["types"]["resource"][] -

Returns

Type

Example

import { ProfielShapeType } from "./.ldo/foafProfile.shapeType.ts"

const resource = connectedLdoDataset
  .getResource("https://example.com/profile");
const profile = connectedLdoDataset.createData(
  ProfileShapeType,
  "https://example.com/profile#me",
  resource
);

Defined in

packages/connected/src/ConnectedLdoDataset.ts:251


createResource

createResource\<Name, Plugin>(pluginName, createResourceOptions?): Promise\<ReturnType\<Plugin["createResource"]>>

Generates a random uri and creates a resource.

Type parameters

Name Type
Name extends any
Plugin extends ConnectedPlugin\<any, any, any, any, any>

Parameters

Name Type Description
pluginName Name A string name for the platform you'd like to create the resource on.
createResourceOptions? Plugin["types"]["createResourceOptions"] Some set of options specific to the plugin you've selected.

Returns

Promise\<ReturnType\<Plugin["createResource"]>>

A created resource or an error

Example

const profileDocument = await connectedLdoDataset
  .createResource("solid");

Implementation of

IConnectedLdoDataset.createResource

Defined in

packages/connected/src/ConnectedLdoDataset.ts:178


delete

delete(quad): this

Parameters

Name Type
quad Quad

Returns

this

Implementation of

IConnectedLdoDataset.delete

Inherited from

LdoDataset.delete

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:18


deleteMatches

deleteMatches(subject?, predicate?, object?, graph?): this

Parameters

Name Type
subject? Term
predicate? Term
object? Term
graph? Term

Returns

this

Implementation of

IConnectedLdoDataset.deleteMatches

Inherited from

LdoDataset.deleteMatches

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:16


difference

difference(other): Dataset\<Quad, Quad>

Parameters

Name Type
other DatasetCore\<Quad, Quad>

Returns

Dataset\<Quad, Quad>

Implementation of

IConnectedLdoDataset.difference

Inherited from

LdoDataset.difference

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:10


emit

emit(eventName, changes): boolean

Parameters

Name Type
eventName QuadMatch
changes DatasetChanges\<Quad>

Returns

boolean

Implementation of

IConnectedLdoDataset.emit

Inherited from

LdoDataset.emit

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:21


equals

equals(other): boolean

Parameters

Name Type
other Dataset\<Quad, Quad>

Returns

boolean

Implementation of

IConnectedLdoDataset.equals

Inherited from

LdoDataset.equals

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:11


eventNames

eventNames(): QuadMatch[]

Returns

QuadMatch[]

Implementation of

IConnectedLdoDataset.eventNames

Inherited from

LdoDataset.eventNames

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:22


every

every(iteratee): boolean

Parameters

Name Type
iteratee (quad: Quad, dataset: this) => boolean

Returns

boolean

Implementation of

IConnectedLdoDataset.every

Inherited from

LdoDataset.every

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:12


filter

filter(iteratee): Dataset\<Quad, Quad>

Parameters

Name Type
iteratee (quad: Quad, dataset: this) => boolean

Returns

Dataset\<Quad, Quad>

Implementation of

IConnectedLdoDataset.filter

Inherited from

LdoDataset.filter

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:13


forEach

forEach(iteratee): void

Parameters

Name Type
iteratee (quad: Quad, dataset: this) => void

Returns

void

Implementation of

IConnectedLdoDataset.forEach

Inherited from

LdoDataset.forEach

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:14


forgetAllResources

forgetAllResources(): void

Removes all resources from memory

Returns

void

Example

connectedLdoDataset.forgetAllResources();

Implementation of

IConnectedLdoDataset.forgetAllResources

Defined in

packages/connected/src/ConnectedLdoDataset.ts:225


forgetResource

forgetResource(uri): boolean

Removes a resource from local memory

Parameters

Name Type Description
uri string the URI of the resource to remove

Returns

boolean

true if the resource was present before removal

Example

connectedLdoDataset.forgetResource("https://example.com/resource.ttl");

Implementation of

IConnectedLdoDataset.forgetResource

Defined in

packages/connected/src/ConnectedLdoDataset.ts:211


getMaxListeners

getMaxListeners(): number

Returns

number

Implementation of

IConnectedLdoDataset.getMaxListeners

Inherited from

LdoDataset.getMaxListeners

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:23


getResource

getResource\<Name, Plugin, UriType>(uri, pluginName?): GetResourceReturnType\<Plugin, UriType>

Retireves a representation of a Resource at the given URI. This resource represents the current state of the resource: whether it is currently fetched or in the process of fetching as well as some information about it.

Type parameters

Name Type
Name extends any
Plugin extends ConnectedPlugin\<any, any, any, any, any>
UriType extends string

Parameters

Name Type Description
uri UriType the URI of the resource
pluginName? Name optionally, force this function to choose a specific plugin to use rather than perform content negotiation.

Returns

GetResourceReturnType\<Plugin, UriType>

a Resource

Example

const profileDocument = connectedLdoDataset
  .getResource("https://example.com/profile");

Implementation of

IConnectedLdoDataset.getResource

Defined in

packages/connected/src/ConnectedLdoDataset.ts:145


getValidPlugin

getValidPlugin(uri, pluginName?): undefined | Plugins[number]

A helper function to return a plugin based in the plugin name and uri.

Parameters

Name Type
uri string
pluginName? string

Returns

undefined | Plugins[number]

Defined in

packages/connected/src/ConnectedLdoDataset.ts:108


has

has(quad): boolean

Parameters

Name Type
quad Quad

Returns

boolean

Implementation of

IConnectedLdoDataset.has

Inherited from

LdoDataset.has

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:29


import

import(stream): Promise\<ConnectedLdoDataset\<Plugins>>

Parameters

Name Type
stream Stream\<Quad>

Returns

Promise\<ConnectedLdoDataset\<Plugins>>

Implementation of

IConnectedLdoDataset.import

Inherited from

LdoDataset.import

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:15


intersection

intersection(other): Dataset\<Quad, Quad>

Parameters

Name Type
other Dataset\<Quad, Quad>

Returns

Dataset\<Quad, Quad>

Implementation of

IConnectedLdoDataset.intersection

Inherited from

LdoDataset.intersection

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:16


listenerCount

listenerCount(eventName): number

Parameters

Name Type
eventName QuadMatch

Returns

number

Implementation of

IConnectedLdoDataset.listenerCount

Inherited from

LdoDataset.listenerCount

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:24


listeners

listeners(eventName): nodeEventListener\<Quad>[]

Parameters

Name Type
eventName QuadMatch

Returns

nodeEventListener\<Quad>[]

Implementation of

IConnectedLdoDataset.listeners

Inherited from

LdoDataset.listeners

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:25


map

map(iteratee): Dataset\<Quad, Quad>

Parameters

Name Type
iteratee (quad: Quad, dataset: this) => Quad

Returns

Dataset\<Quad, Quad>

Implementation of

IConnectedLdoDataset.map

Inherited from

LdoDataset.map

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:17


match

match(subject?, predicate?, object?, graph?): Dataset\<Quad, Quad>

Parameters

Name Type
subject? null | Term
predicate? null | Term
object? null | Term
graph? null | Term

Returns

Dataset\<Quad, Quad>

Implementation of

IConnectedLdoDataset.match

Inherited from

LdoDataset.match

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:25


off

off(eventName, listener): void

Parameters

Name Type
eventName QuadMatch
listener nodeEventListener\<Quad>

Returns

void

Implementation of

IConnectedLdoDataset.off

Inherited from

LdoDataset.off

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:26


on

on(eventName, listener): this

Parameters

Name Type
eventName QuadMatch
listener nodeEventListener\<Quad>

Returns

this

Implementation of

IConnectedLdoDataset.on

Inherited from

LdoDataset.on

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:27


once

once(eventName, listener): this

Parameters

Name Type
eventName QuadMatch
listener nodeEventListener\<Quad>

Returns

this

Implementation of

IConnectedLdoDataset.once

Inherited from

LdoDataset.once

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:28


prependListener

prependListener(eventName, listener): this

Parameters

Name Type
eventName QuadMatch
listener nodeEventListener\<Quad>

Returns

this

Implementation of

IConnectedLdoDataset.prependListener

Inherited from

LdoDataset.prependListener

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:29


prependOnceListener

prependOnceListener(eventName, listener): this

Parameters

Name Type
eventName QuadMatch
listener nodeEventListener\<Quad>

Returns

this

Implementation of

IConnectedLdoDataset.prependOnceListener

Inherited from

LdoDataset.prependOnceListener

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:30


rawListeners

rawListeners(eventName): nodeEventListener\<Quad>[]

Parameters

Name Type
eventName QuadMatch

Returns

nodeEventListener\<Quad>[]

Implementation of

IConnectedLdoDataset.rawListeners

Inherited from

LdoDataset.rawListeners

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:35


reduce

reduce\<A>(iteratee, initialValue?): A

Type parameters

Name Type
A unknown

Parameters

Name Type
iteratee (accumulator: A, quad: Quad, dataset: this) => A
initialValue? A

Returns

A

Implementation of

IConnectedLdoDataset.reduce

Inherited from

LdoDataset.reduce

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:18


removeAllListeners

removeAllListeners(eventName): this

Parameters

Name Type
eventName QuadMatch

Returns

this

Implementation of

IConnectedLdoDataset.removeAllListeners

Inherited from

LdoDataset.removeAllListeners

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:31


removeListener

removeListener(eventName, listener): this

Parameters

Name Type
eventName QuadMatch
listener nodeEventListener\<Quad>

Returns

this

Implementation of

IConnectedLdoDataset.removeListener

Inherited from

LdoDataset.removeListener

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:32


removeListenerFromAllEvents

removeListenerFromAllEvents(listener): this

Parameters

Name Type
listener nodeEventListener\<Quad>

Returns

this

Implementation of

IConnectedLdoDataset.removeListenerFromAllEvents

Inherited from

LdoDataset.removeListenerFromAllEvents

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:33


setContext

setContext\<Name, Plugin>(pluginName, context): void

Sets conetext for a specific plugin

Type parameters

Name Type
Name extends any
Plugin extends ConnectedPlugin\<any, any, any, any, any>

Parameters

Name Type Description
pluginName Name the name of the plugin
context Plugin["types"]["context"] the context for this specific plugin

Returns

void

Implementation of

IConnectedLdoDataset.setContext

Defined in

packages/connected/src/ConnectedLdoDataset.ts:271


setMaxListeners

setMaxListeners(n): this

Parameters

Name Type
n number

Returns

this

Implementation of

IConnectedLdoDataset.setMaxListeners

Inherited from

LdoDataset.setMaxListeners

Defined in

packages/subscribable-dataset/dist/SubscribableDataset.d.ts:34


some

some(iteratee): boolean

Parameters

Name Type
iteratee (quad: Quad, dataset: this) => boolean

Returns

boolean

Implementation of

IConnectedLdoDataset.some

Inherited from

LdoDataset.some

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:19


startTransaction

startTransaction(): ConnectedLdoTransactionDataset\<Plugins>

Returns

ConnectedLdoTransactionDataset\<Plugins>

Implementation of

IConnectedLdoDataset.startTransaction

Overrides

LdoDataset.startTransaction

Defined in

packages/connected/src/ConnectedLdoDataset.ts:280


toArray

toArray(): Quad[]

Returns

Quad[]

Implementation of

IConnectedLdoDataset.toArray

Inherited from

LdoDataset.toArray

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:20


toCanonical

toCanonical(): string

Returns

string

Implementation of

IConnectedLdoDataset.toCanonical

Inherited from

LdoDataset.toCanonical

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:21


toStream

toStream(): Stream\<Quad>

Returns

Stream\<Quad>

Implementation of

IConnectedLdoDataset.toStream

Inherited from

LdoDataset.toStream

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:22


toString

toString(): string

Returns

string

Implementation of

IConnectedLdoDataset.toString

Inherited from

LdoDataset.toString

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:23


union

union(other): Dataset\<Quad, Quad>

Parameters

Name Type
other Dataset\<Quad, Quad>

Returns

Dataset\<Quad, Quad>

Implementation of

IConnectedLdoDataset.union

Inherited from

LdoDataset.union

Defined in

packages/dataset/dist/ExtendedDataset.d.ts:24


usingType

usingType\<Type>(shapeType): LdoBuilder\<Type>

Type parameters

Name Type
Type extends LdoBase

Parameters

Name Type
shapeType ShapeType\<Type>

Returns

LdoBuilder\<Type>

Implementation of

IConnectedLdoDataset.usingType

Inherited from

LdoDataset.usingType

Defined in

packages/ldo/dist/LdoDataset.d.ts:9