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

@ts-pf/mvc-kit

v0.1.3

Published

Opt-in bindClient and issuesToFieldErrors for mvc-kit Resources

Readme

@ts-pf/mvc-kit

Opt-in mvc-kit helpers for a ts-pf client. Inject disposeSignal on every call and map VALIDATION issues onto FormModel.setErrors — you still write Resource methods and still call useLocal / useSingleton yourself.

Agent skill: skills/ts-pf-mvc-kit/. Sync with npx skills experimental_sync -y.

This package does not wrap Resource, add React hooks, generate a Service, or fold into @ts-pf/client. Pass the client from createClient<typeof contract>(link) or createClient<Contract>(link) with a generated Contract from @ts-pf/codegen. Requires mvc-kit >= 4.9.0.

Setup

import { createClient } from '@ts-pf/client'
import { FetchLink } from '@ts-pf/client-http'
import { bindClient, issuesToFieldErrors } from '@ts-pf/mvc-kit'
import { Resource, type DedupeConfig } from 'mvc-kit'
import type { InferContractInputs, InferContractOutputs } from '@ts-pf/contract'
import type { contract } from './contract'

export const client = createClient<typeof contract>(new FetchLink({ url: '/rpc' }))
type Planet = InferContractOutputs<typeof contract>['planet']['find']

class PlanetsResource extends Resource<Planet> {
  static DEDUPE: DedupeConfig<PlanetsResource> = {
    loadAll: true,
    loadById: (id) => id,
  }

  private rpc = bindClient(client, this)

  protected onInit() {
    if (this.length === 0) this.loadAll()
  }

  async loadAll() {
    this.reset(await this.rpc.planet.list())
  }

  async loadById(id: number) {
    this.upsert(await this.rpc.planet.find({ id }))
  }

  async create(input: InferContractInputs<typeof contract>['planet']['create']) {
    const row = await this.rpc.planet.create(input)
    this.add(row)
    return row
  }
}

createClient / FetchLink stay yours: Fetch interceptors, codec, and headers on FetchLink; call plugins (RetryPlugin, …) on createClient. bindClient only injects { signal: host.disposeSignal } at call time. A caller-provided { signal } wins.

App tsconfigs should use moduleResolution: "bundler" (Vite’s default) or "nodenext" when subclassing mvc-kit Resource. Node16 does not inherit Resource members onto subclasses.

Errors

Resource methods throw. mvc-kit classifies the thrown PFError as-is:

resource.async.loadById.errorCode === 'NOT_FOUND' // not 'not_found'
resource.async.loadById.cause // the PFError; .data is on the instance

Do not wrap PFError in CodedError or HttpError. PFError already has code and numeric status. CodedError is mvc-kit’s class if you throw by hand without that envelope.

Do not throw error.toJSON() — the JSON object has no status, so 4.9 will classify it as 'unknown'.

asResult in ViewModels

asResult is for ViewModel branching (forms). Async tracking keys off throw. If a Resource method asResults and does not rethrow, async.method.error stays null.

import { asResult } from '@ts-pf/client'
import { issuesToFieldErrors } from '@ts-pf/mvc-kit'

const result = await asResult(this.rpc.planet.create(input))
if (!result.ok && result.error.code === 'VALIDATION') {
  this.form.setErrors(issuesToFieldErrors(result.error.data.issues))
  // rethrow if you also want vm.async.submit.errorCode === 'VALIDATION'
}

Abort

Pass nothing. bindClient injects host.disposeSignal. Dispose/unmount aborts the in-flight call. FetchLink maps abort to PFError { code: 'INTERNAL', local: true, status: 0, cause: AbortError }. mvc-kit walks cause one level and swallows it — no error flash.

For Pending / offline-kit, pass the provided signal so it wins:

this.pending.enqueue(id, 'create', (signal) =>
  this.rpc.planet.create(input, { signal }).then((row) => {
    this.add(row)
  }),
)

Do not pass this.disposeSignal into Pending’s execute. Do not list Pending writes in static DEDUPE (joined reads must close over the host signal, which is the default).

Feed recipe

No helper in v1. Feed owns the cursor; Resource upserts rows:

const page = await this.rpc.planet.listPage({ cursor: this.feed.cursor })
this.planets.upsert(...page.items)
this.feed.setResult(page)

Streams, SSE, files

Same contracts, opt-in codec on the link you already own:

import { StreamCodec } from '@ts-pf/stream'

const client = createClient<typeof contract>(
  new FetchLink({ url: '/rpc', codec: new StreamCodec() }),
)

const items = await this.rpc.planet.describe({ id })
for await (const item of items) {
  this.upsert(item)
}

Cancel is the injected signal. There is no Stream→Feed helper.

Channel is a reconnecting inbound event bus. It is not RPC-over-WebSocket (@ts-pf/message-client WsLink) and not SseCodec (POST that streams then ends).

offline-kit

One line; do not bindClient that path — the outbox owns the signal:

send: (entry, signal) => client.todo.create(entry.payload, { signal })

Entity id is string. Procedure-shaped non-CRUD writes do not belong there.

Not in this package

  • TanStack Query / queryOptions / query keys
  • createResources / fromProcedure (one procedure is not a Resource)
  • Pass-through Service (call the client from the Resource)
  • Wrapping useLocal / useSingleton
  • Channel / WsLink wrapper
  • Retry (RetryPlugin on createClient)
  • Mapping NOT_FOUND'not_found'
  • instanceof HttpError for RPC
  • Walking app instead of the contract