npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@treecg/curation

v0.0.6

Published

This library implements a class (Curator) with methods to curate an announcement LDES in LDP.

Downloads

1

Readme

Curation of announcements

This library implements a class (Curator) with methods to curate an announcement LDES in LDP ( e.g. announcement LDES).

Requirements

  • AnnouncementURI: The uri of a valid LDESinLDP of announcements[^fn1]

  • SynchronizedURI: The uri of an LDP container[^fn2]

  • CurationURI: The uri of an LDP container[^fn2]

  • Credentials for a WebID at an Identity Provider (IDP), that way you can create a Session and log in

    [^fn1]: Currently, the object of an announcement can only by a DCAT Dataset Application Profile, DCAT DataService Application profile or a description of an LDES view. Those interfaces are defined in the LDES-Announcements package. [^fn2]: When the LDP is a Solid pod, you need a ACL:Write grant for the WebID you are using.

Flow to curate the contents of an announcement

Log in

Log in with your webID to retrieve credentials[^fn3]. With those credentials, create a Session and log in. Now an object of the class Curator can be created.

In order for logging in to work, an environment file (.env) is required that contains the Identy provider used for your WebID.

SOLID_IDP=https://broker.pod.inrupt.com

Adding or rejecting the contents of an announcement to a curated EventStream is done with an object of the Curator class.

[^fn3]: In the package LDES-Ochestrator, there is script which can generate such credentials.

const { login, isLoggedin, getSession } = require('@treecg/ldes-orchestrator');
const { Curator } = require('@treecg/curation');

login();
await isLoggedin(); // code that checks whether you are already logged in
const session = await getSession();

const announcementIRI = 'https://tree.linkeddatafragments.org/announcements/';
const curatedIRI = 'https://tree.linkeddatafragments.org/datasets/curated/';
const synchronizedIRI = 'https://tree.linkeddatafragments.org/datasets/synced/';

const config = {
  ldesIRI: rootIRI,
  curatedIRI: curatedIRI,
  synchronizedIRI: synchronizedIRI
};
const curator = new Curator(config, session);

Synchronise

The first thing that has to be created using the Curator object is to synchronize with the announcement-LDES.

Synchronizing fetches all the ids of the members within the announcement LDES and stores them in a collection (the Synchronized Collection). This Synchronized collection contains the state of the curation process. It consists of all members of the LDES announcements minus the announcements that we don't care about or were accepted to the Curated LDES already.

// synchronizing with announcement LDES
await curator.synchronize();

NOTE: The synchronize method uses the LDESClient. Only when this client has fully streamed the LDES and updated the synchronized LDES, should curation occur. Otherwise the most recent announcements will not be the actual most recent ones.

Initialize

The initialisation of the curation means that a curated LDP will be created if it does not exist yet. It is required that before you start accepting or rejecting the content of an announcement, the Curator object is initaliased.

// loading the state of the Curation LDES (and creating it if it does not exist yet)
await curator.init()

Curation

Curation is done using the URI of an announcement.

Accepting

const uri = "...";
await curator.accept(uri)

When previously the uri was already fetched (and extracted to its value), it is possible to accept without fetching and extracting the contents again. For this the member contents, iri and timestamp have to be given to the accept method.

const uri = "...";
const member = {}; // already fetched previously
const timestamp = 123456789; // already fetched previously
await curator.accept(uri, member, timestamp);

Rejecting

const uri = "...";
await curator.reject(uri)

Again, slightly more bandwidth efficient.

const uri = "...";
const timestamp = 123456789; // already fetched previously
await curator.reject(uri, timestamp);

Notes

Currently it is possible to reject the same member multiple times Also accepting the same member multiple is possible. Especially when accepting this is not allowed

Can be fixed by checking before an accept in the collection if it exists in the syncrhonized collection. Only when it's in there, it should be added to the curated ldes.