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

@bscotch/blork-shared

v0.30.1

Published

Client and shared utilities for Blork projects.

Downloads

754

Readme

Blork! Shared Utilities and Types

Blork! is an internal work management service developed and used by Butterscotch Shenanigans ("Bscotch"). It is currently not available in any public way, so this package is only of use to Bscotch staff.

This package includes a client for talking to Blork servers and a bunch of shared utilities for various aspects of working with Blork data.

Requirements

  • Node.js 20+ (though many features work in both Node.js and modern browsers)

Blork! Client

To automate tasks in Blork, in particular creating new tasks, you can use the Blork Client provided by this package.

import { BlorkClient, textToNewTasks } from '@bscotch/blork-shared';

const client = new BlorkClient({
	baseUrl: 'http://localhost:8080', // or wherever the Blork instance is hosted
	userId: 'your-user-id', // Unless you can rely on browser cookies
	password: 'your-password', // ^^
});

// Make sure the server is up
await client.isHealthy();

// Get *all* tasks
const allTasks = await client.getTasks();

// Create a new, empty task
const newTask = await client.createTasks('parent-task-id', { tasks: [{}] });

// Create some tasks from a nested, text-based task list
const asTasks = textToNewTasks('hello\n\tworld\n\thi');
await client.createTasks('parent-task-id', { tasks: asTasks });

// Or just send the template directly!
await client.createTasks('parent-task-id', {
	template: 'hello\n\tworld\n\thi',
});

// ... plus lots of methods to set done-state, snooze a task, delete a task, etc etc

Task Cache utilities

The Blork server and webapp both construct and maintain task caches to stay up to date and validate operations. For most other use-cases this will be overkill, but since this package includes a lot of utilities for a "Task Cache" you may want to construct one even if it doesn't need to be kept up to date.

For example:

import {
	type TaskCache,
	listTaskChildrenRecursive,
	planTaskDeletion,
	taskIsNotBlocked,
} from '@bscotch/blork-shared';

// Get *all* tasks
const allTasks = await client.getTasks();

// Turn them into a simple, Map-based cache
const cache: TaskCache = new Map();
allTasks.forEach((task) => cache.set(task.taskId, task));

// Use that cache for all kinds of operations
const children = listTaskChildrenRecursive(cache, 'some-task-id');
// See if a deletion is possible, and what all changes will happen
// as a consequence (the Blork server performs this process, so you
// you don't need to do it before attempting to delete a task)
const deletionPlan = planTaskDeletion(cache, 'some-task-id');
if (taskIsNotBlocked(cache, 'some-task-id')) {
	// Then this task is not blocked by anything
}

You can also use the Blork Query Language to search through your task cache:

import { searchTasks } from '@bscotch/blork-shared';

const users = await client.listAllUsers();

const { parsedQuery, matches } = searchTasks(
	'hello world > is:starred > @me title:some stuff',
	taskCache,
	{
		users,
		currentUserId: 'my-user-id',
	},
);