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

@telicent-oss/catalogservice

v0.0.2-sitest

Published

Simple client-side library for working with DCAT data.

Downloads

187

Readme

@telicent-oss/catalogservice

Monorepo Location: ./packages/CatalogService

Build status

Utility classes for managing RDF data for DCAT3-compliant data catalogs via SPARQL.

Plus a ApiFactory that uses the above to create a convenience api object for Catalog web app (may move out of this package).

Background

@telicent-oss/rdfservice (./packages/RdfService) package was created to give separation between UI code and SPARQL query logic. This package, extends upon @telicent-oss/rdfservice to give the the data catalog functionality.

Install

yarn install @telicent-oss/catalogservice

Usage

DCAT classes

A simple example for data catalogs:

:warning: Temporarily broken

import {
  CatalogService,
  DCATCatalog,
} from "@company-oss/catalogservice";

// Initialize the CatalogService
const catalogService = await CatalogService.createAsync({
  writeEnabled: true,
  triplestoreUri: "http://localhost:3030",
  dataset: "dataset",
});

// Create Catalog
const catalog1 = await DCATCatalog.createAsync(
  catalogService,
  "http://mysche.ma/data/catalog1",
  "Catalog",
  "2023-01-01"
);

:warning: Temporarily broken

/*

Given we want to create this structure:
.
├── catalog1/
│   └── catalog1_1/
│       ├── DataService1_1_1
│       ├── DataSet1_1_1
│       └── DataSet1_1_2
└── catalog2/
    └── DataSet_2_1
*/
import {
  CatalogService,
  DCATCatalog,
  DCATDataset,
  DCATDataService,
} from "@company-oss/catalogservice";

// Initialize the CatalogService
const catalogService = await CatalogService.createAsync({
  writeEnabled: true,
  triplestoreUri: "http://localhost:3030/"
  dataset: "dataset"
});
const DC3 = 'http://mysche.ma/data/'
// Create Catalog 1
const catalog1 = await DCATCatalog.createAsync(
  catalogService,
  `${DC3}catalog1`,
  "Catalog 1",
  "2023-01-01"
);

// Create nested Catalog 1_1
const catalog1_1 = await DCATCatalog.createAsync(
  catalogService,
  `${DC3}catalog1_1`,
  "Catalog 1_1",
  "2023-02-01"
);
catalog1.addSubCatalog(catalog1_1);

// Add DataService to Catalog1_1
const dataService1_1_1 = await DCATDataService.createAsync(
  catalogService,
  `${DC3}catalog1_1/DataService1_1_1`,
  "Data Service 1_1_1"
);
catalog1_1.addOwnedResource(dataService1_1_1);

// Add DataSets to Catalog1_1
const dataSet1_1_1 = await DCATDataset.createAsync(
  catalogService,
  `${DC3}catalog1_1/DataSet1_1_1`,
  "Data Set 1_1_1",
  "2023-03-01",
  catalog1_1
);
const dataSet1_1_2 = await DCATDataset.createAsync(
  catalogService,
  `${DC3}catalog1_1/DataSet1_1_2`,
  "Data Set 1_1_2",
  "2023-03-02",
  catalog1_1
);

// Create Catalog 2
const catalog2 = await DCATCatalog.createAsync(
  catalogService,
  `${DC3}catalog2`,
  "Catalog 2",
  "2023-04-01"
);

// Add DataSet to Catalog2
const dataSet2_1 = await DCATDataset.createAsync(
  catalogService,
  `${DC3}catalog2/DataSet2_1`,
  "Data Set 2_1",
  "2023-05-01",
  catalog2
);

Using ApiFactory for the Data Catalog UI

You can find a working example in https://github.com/Telicent-oss/catalog

export const catalogService = await CatalogService.createAsync({
  writeEnabled: true,
  triplestoreUri: `${config.env.TRIPLE_STORE_URL}/`,
  dataset: "catalog",
});
const api = await apiFactory(catalogService);

const Page = ({ searchTerm, dataResourceFilters, set }) => {
  const catalog = useQuery({
    queryKey: ['catalog', dataResourceFilters],
    queryFn: () => api.catalog({ dataResourceFilters }),
  });
  const search = useQuery({
    queryKey: ['search', searchTerm],
    queryFn: () => api.search({ searchTerm })
  });
  return (
    <>
      <SearchInput
        onSearch={searchTerm => set({ searchTerm })}
      />
      <DataResourceFilters
        data={catalog.data}
        onSelect={val => set({ dataResourceFilters: val })}
      />
    <>
  );
}

Development

Build

git clone https://github.com/Telicent-oss/rdf-libraries
cd catalog
yarn install
cd /packages/CatalogService
# make changes
npx nx affected:build

Develop locally

Run the provided triple store

yarn start:triple-store-for-local-dev-and-tests

Or alternatively run your own.

Related Links

  • Catalog - ReactJS web app that uses this package
  • RdfService - sibling package; This package extends some of its RDF utility classes

Definitions

  • DCAT3: Data Catalog Vocabulary, version 3, a W3C standard for representing data catalogs.
  • SPARQL: SPARQL Protocol and RDF Query Language, used for querying RDF data.
  • Triple Store: A type of database optimized for storing and retrieving RDF triples.

API

For detailed API usage examples, refer to CatalogService.test.ts (and other tests)