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

@api-client/graph-project

v0.1.4

Published

AMF graph project general components and libraries, including API navigation and events.

Downloads

14

Readme

Graph project

AMF graph project general components and libraries, including API navigation and events.

This is a work in progress.

This library contains general purpose web components and libraries to support AMF based API projects. It contains definitions for components ecosystem events and API navigation.

Usage

Installation

npm install --save @api-client/graph-project

API data model

The navigation component works with @api-client/amf-store. Use the store to initialize the API. The store acts as a value provider for the component. When initialized, the component dispatches a series of DOM events handled by the store to read the data from the graph. The hosting application has to initialize the API and the graph before this element is inserted into the DOM.

import { AmfStoreService } from '@api-client/amf-store';

const store = new AmfStoreService(window, {
  workerLocation: './node_modules/@api-client/amf-store/workers/AmfWorker.js',
});
await store.init();
const graphModel = await readDataModelSomehow();
await store.loadGraph(graphModel);

The navigation element queries the store once it is attached to the DOM. YOu can manually refresh the state by calling the queryGraph() function. You can also use the apiId property / attribute as declarative was of refreshing the state. When the value change (presumably the id of the web/async API) it queries for the new data.

Endpoints sorting

By default the element renders paths for endpoints as they are declared in the API spec file. SOmetimes, however, you may want to create a tree structure from the API endpoints list. In such case set the sort attribute. The navigation then sorts the endpoints alphabetically and creates a view tree from endpoints. It may create a number of "virtual" endpoints which are the closest common paths between two endpoints.

For example, consider having the following endpoint paths structure defined in the API:

smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured
smartylighting/streetlights/1/0/action/{streetlightId}/turn/on
smartylighting/streetlights/1/0/action/{streetlightId}/turn/off
smartylighting/streetlights/1/0/action/{streetlightId}/dim

By default the navigation render these paths as declared. When using the sort option the navigation renders the following tree

smartylighting/streetlights/1/0
  /action/{streetlightId}
    /dim
    /turn/off
    /turn/on
  /event/{streetlightId}/lighting/measured

Navigation list filtering

When the filter option is set then the navigation renders the filter text input. The user can use this input to filter menu items by any string provided in this input. Each item (depending on the item) is passed through the filter and the element only renders items that contains the user query. For example, an endpoint is filtered by its path and name. Operation is filtered by the method and name. And so on.

Development

git clone https://github.com/@api-client/amf-store
cd amf-store
npm install

Running the demo locally

npm start

Running the tests

npm test

License