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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stsdti/approvable-core

v0.1.12

Published

Framework-agnostic client, domain models and view-model derivations for laravel-approvable.

Readme

@stsdti/approvable-core

The framework-agnostic half of laravel-approvable: the API client, the domain models, and the derivations a UI needs in order to render an approval.

You do not normally install this directly. @stsdti/approvable-vue depends on it. Reach for it when you are building a binding for another framework, or driving the API without a UI at all.

npm install @stsdti/approvable-core

It has no runtime dependencies, and imports no UI framework — a test in this package enforces both.

This package is ESM only: it publishes ES modules and no CommonJS build. Use import, or a dynamic import() from CommonJS.

Configuring the client

The default works in a browser with no setup, using fetch and sending the XSRF-TOKEN cookie back as X-XSRF-TOKEN so Laravel's CSRF check passes.

To reuse an application's own axios instance, with its interceptors and auth:

import axios from 'axios'
import { configureApprovableClient } from '@stsdti/approvable-core'

configureApprovableClient({ axios })

configureApprovableClient also accepts fetch, adapter and baseURL. It is sugar over setApprovableClient(new ApprovableClient({ … })), which stays available for whatever it does not cover, and returns the client it installed.

Any object with a request({ method, url, data, headers, signal }) method returning { data, status, headers } is a valid adapter, which is also the seam to stub in tests.

Ports

import { setApprovableNotifier, setApprovableDateFormatter } from '@stsdti/approvable-core'

setApprovableNotifier({ success: toast.success, error: toast.error })
setApprovableDateFormatter((value) => dayjs(value).format('LLL'))

Without them, notifications go to the console and dates render as dd.MM.yyyy HH:mm.

View models

The derivations that decide what an approval looks like — which buttons show, whether a step is visible, how a comment is truncated — are plain functions over plain data:

import { createApprovableViewModel, createStepViewModel } from '@stsdti/approvable-core'

const approval = createApprovableViewModel(document)
//  { hasApprovable, approvable, steps, hasInactiveSteps, status, statusName, updatedAt }

const step = createStepViewModel(approval.steps[0])
//  { isVisible, isActive, opacity, status, approverName, performedAt, buttons, comment }

A Vue binding wraps these in computed, a React one in useMemo, a server-rendered template calls them directly. Keeping the logic here is what stops two bindings from quietly disagreeing about behaviour.

Actions

import { performStepAction } from '@stsdti/approvable-core'

const result = await performStepAction({
  stepId: step.id,
  button: 'approve',
  buttons: step.buttons
})
// { ok: true }  |  { ok: false, skipped: 'no-status-code' }  |  { ok: false, error }

Returns a result rather than throwing, and reports through the notifier port, so a binding only has to toggle a loading flag and refresh.

Custom action buttons

A button carrying an action_ui value renders through a registered renderer:

import { registerActionRenderer } from '@stsdti/approvable-core'

registerActionRenderer('pdf-signature', MySignatureComponent)

The stored value is opaque to this package, so any framework's component is valid. The Vue binding wraps registration to mark components raw.

License

MIT