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

@underlay/pipeline

v0.0.4

Published

This repo is the pipeline library and runtime.

Downloads

2

Readme

pipeline

This repo is the pipeline library and runtime.

Each block is a folder inside src/blocks, and has three parts: an interface, an editor, and a runtime. Interfaces are values of the generic type Block<State, Inputs, Outputs>; runtimes are values of the generic type Evaluate<State, Inputs, Outputs>; and editors are values of the generic type Editor<State>. These types are defined in src/types.ts.

An object of all block interfaces is exported from src/blocks/index.ts; an object of all block runtimes is exported from src/blocks/runtimes.ts; and an object of all block editors is exported from src/blocks/editors.ts.

Interfaces

Block interfaces are the default export of src/blocks/[block-name]/index.ts (e.g. src/blocks/csv-import/index.ts). A block interface is generic in three parameters: State, Inputs extends Record<string, Schema.Schema>, and Outputs extends Record<string, Schema.Schema>, and it contains runtime validators for the state type and each input and output schema.

interface Block<
	State,
	Inputs extends Record<string, Schema.Schema>,
	Outputs extends Record<string, Schema.Schema>
> {
	state: t.Type<State>
	inputs: {
		[input in keyof Inputs]: t.Type<Inputs[input], Inputs[input], Schema.Schema>
	}
	outputs: {
		[output in keyof Outputs]: t.Type<
			Outputs[output],
			Outputs[output],
			Schema.Schema
		>
	}
	validate: (state: State, schemas: Inputs) => Outputs
}

Block interfaces also have a validate function that produces output schemas given a state and input schema object.

Editors

Block editors are the default export of src/blocks/[block-name]/editor/index.tsx (e.g. src/blocks/csv-import/editor/index.tsx). Editors are generic in just the State parameter:

type Editor<State> = React.FC<{
	state: State
	setState: (state: State) => void
}>

Runtimes

Block runtimes are the default export of src/blocks/[block-name]/runtime/index.ts (e.g. src/blocks/csv-import/runtime/index.ts). Runtimes are a function Evaluate that is generic in all three parameters:

type Evaluate<
	State,
	Inputs extends Record<string, Schema.Schema>,
	Outputs extends Record<string, Schema.Schema>
> = (
	state: State,
	schemas: Inputs,
	instances: { [input in keyof Inputs]: Instance.Instance<Inputs[input]> }
) => Promise<{
	schemas: Outputs
	instances: { [output in keyof Outputs]: Instance.Instance<Outputs[output]> }
}>

Graphs

Pipelines are represented as graphs:

type NodeID = string
type EdgeID = string
type Graph = {
	nodes: Record<
		NodeID,
		{
			kind: string
			inputs: Record<string, EdgeID>
			outputs: Record<string, EdgeID[]>
			state: unknown
		}
	>
	edges: Record<
		EdgeID,
		{
			source: { id: NodeID; output: string }
			target: { id: NodeID; input: string }
		}
	>
}

... although this type is not defined as such - instead we use the runtime validator Graph exported from src/graph.ts, which also validates the graph structure proper (edges connecting valid outputs to valid inputs).