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',
userId: 'your-user-id',
password: 'your-password',
});
await client.isHealthy();
const allTasks = await client.getTasks();
const newTask = await client.createTasks('parent-task-id', { tasks: [{}] });
const asTasks = textToNewTasks('hello\n\tworld\n\thi');
await client.createTasks('parent-task-id', { tasks: asTasks });
await client.createTasks('parent-task-id', {
template: 'hello\n\tworld\n\thi',
});
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';
const allTasks = await client.getTasks();
const cache: TaskCache = new Map();
allTasks.forEach((task) => cache.set(task.taskId, task));
const children = listTaskChildrenRecursive(cache, 'some-task-id');
const deletionPlan = planTaskDeletion(cache, 'some-task-id');
if (taskIsNotBlocked(cache, 'some-task-id')) {
}
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',
},
);