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

caliper

v0.2.2

Published

Incubator for an IMS Caliper implementation

Downloads

131

Readme

caliper

A Typescript implementation of the IMS Caliper specification

As a work-in-progress, this library is likely still in flux. Use it at your own risk.

Development

Clone the repository and run npm install to get started. The majority of the outstanding work is in defining entities, events, and implementing the profiles as tests.

Profile Tests

Tests should be written for the 10 Metric Profiles. Because the tests POST the events to IMS for validation, you will need the IMS_TEST_TOKEN environment variable set in order to successfully run the tests. To get a token, go to the IMS Caliper testing server (you'll need an IMS Global account) and set the "Bearer Token" value in your environment:

export IMS_TEST_TOKEN=<bearer_token>

Usage

The profile tests provide real-world examples of how to construct events. For instance, a ToolUse Event:

import Caliper from 'caliper';

// create the sensor and add a client endpoint
const sensor = new Caliper.Sensor();
sensor.createClient({
  baseURL: 'https://www.example.com/v1',
  headers: {
    Authorization: 'Bearer my-token',
    'Content-Type': 'application/json',
  },
});

// use factory methods to create the actor & object, and attach them to an event
// NOTE: the ToolUseEvent automatically applies the 'Used' action
const actor = Caliper.createEntity(Caliper.Entities.Person);
const object = Caliper.createEntity(Caliper.Entities.SoftwareApplication);
const event = Caliper.createEvent(Caliper.Events.ToolUseEvent, { actor, object });

// send the event (returns a Promise)
sensor.send(event);

Definition

Caliper has two major components that can be used to form an event, which takes the form of a triple (subject-predicate-object in RDF language and agent-action-object in Caliper):

  • Entities: the nouns (action & object) in the Caliper event triple (e.g., Person or SoftwareApplication)
    • These are the core of the spec. They are objects with many properties.
  • Actions: the verbs in the Caliper event (e.g., Used or NavigatedTo)
    • Actions are just single words and are easy to implement as a collection or enum.

These are used to compose Events, which require an actor, action, and object (e.g., Person Used SoftwareApplication).

Additionally, the spec defines a Sensor component that is used to transmit the events (POST to an endpoint) in a wrapper (Envelope).

Profiles & Certification

A Caliper profile defines a collection of one or more events that are related. Profiles are used for certification and organization only. For instance, the Assessment Profile simply contains the AssessmentEvent, AssessmentItemEvent, NavigationEvent, ViewEvent, meaning to receive the Assessment Profile certification, tool authors just need to emit those four events.

While IMS defines 10 default profiles in 1.1, we are allowed to define our own profiles if we feel that theirs don’t meet all of our needs.