factlib.js
A library for node.js written in Typescript that enables clients and processes to interact with Linked Data Platforms according to the FactDAG model while preserving and creating correct provenance information.
⚠️ The API is currently under reconstruction and will change in the near future. The updated API will be incompatible with the current version. The WIP-Version of the updated API can be found in the feature/backendAbstraction branch. Updated example can be found in that branch as well.
Configuration
The config.json configuration file defines URIs for the authority the process exists under, the fact representing the process and the activities that are generated by the process. They should point to an existing Trellis instance.
Getting Started
Import factlib.js
Gitlab users with access to the project repository can load the library from the npm registry as a dependency using
npm install @i5/factlib.js
A list of the available versions can be found in the Packages section in Gitlab.
To authenticate, a .npmrc
file must be present containing:
@i5:registry=https://git.rwth-aachen.de/api/v4/packages/npm/
//git.rwth-aachen.de/api/v4/packages/npm/:_authToken=<TOKEN>
The <TOKEN>
can be a personal access token that can be created in the user settings in Gitlab.
The Gitlab-Documentation contains further details.
The library can then be imported like this:
import {Fact} from "@i5/factlib.js";
Modify RDF resources
Factlib.js uses rdflib.js to store LDP resources locally.
For each resource, a local Rdflib.js store is created.
The Resource-class exposes the queryStore
method that can be used to retrieve data from this local store.
How the local store works and how it can be used is documented by the rdflib.js project.
Examples
There are multiple examples that show how the library can be used.
-
A possible docker-compose setup for a multi-authority development environment.
-
The books example consists of different processes that show different ways of using the library like fact creation, subscriptions and timemap retrieval.
-
The binary example shows the handling of binary resources.
-
This is an example of a possible Gitlab-CI setup that can be committed to a process repository and enables tracking of process provenance. The pipeline create a revision of a process fact in an LDP and stores the URI of the current commit with it.
Documentation
The TypeDoc Documentation documents the functions and classes that are provided by factlib.js.