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

@rikology/pupitre-media

v1.0.0

Published

Media library, reusable media picker field and image conversions for Pupitre

Readme

@rikology/pupitre-media

Reusable, tenant-aware media for Pupitre. The package is server-only; its /catalog export contains only Zod schemas. The picker UI lives in @rikology/pupitre-ui and is loaded lazily.

Install

node ace add @rikology/pupitre-media
node ace migration:run

Configure an Adonis Drive disk and install sharp if image dimensions and conversions are required. Without this optional peer, originals remain usable and conversions are empty.

import { media, mediaPicker, mediaEntry } from '@rikology/pupitre-media'

panel.plugins([
  media({
    disk: 'uploads', directory: 'media', visibility: 'private',
    maxFileSize: 10 * 1024 * 1024,
    acceptedFileTypes: ['image/*'],
    conversions: { thumb: { width: 320, format: 'webp' } },
    navigationGroup: 'Content', tenancy: true,
    authorize: (ctx, ability, record) => editorialMediaAccess(ctx, ability, record),
  }),
])

mediaPicker('coverMediaId').accept(['image/*']).conversion('thumb')
mediaPicker('gallery').multiple().maxItems(5).accept(['image/*'])
mediaEntry('coverMediaId').conversion('thumb')

The host must provide the referenced editorialMediaAccess authorization function. Without an authorize callback, configure a MediaPolicy in Pupitre's policy loader with viewAny, view, create, update and delete abilities. Missing policy/ability fails closed. Each ability receives the normal authenticated Bouncer user, and record abilities receive PupitreMedia.

Browser registration:

import { mediaCatalog } from '@rikology/pupitre-media/catalog'
import { components } from '@rikology/pupitre-ui'
import { defineRegistry } from '@rikology/pupitre-react'
const registry = defineRegistry(components, { extensions: [mediaCatalog] })

Persistence and security

Single pickers store a nullable integer ID. Multiple pickers store an ordered array of integer IDs; use an explicitly JSON-prepared/consumed model column on both SQLite and PostgreSQL. IDs must exist in the current tenant, pass resource viewAny and record view, satisfy the accepted MIME types, and obey the item limit. Duplicates and forged IDs are rejected server-side.

The Media resource offers a thumbnail grid, filename/alt search, MIME/date filters, multi-file header upload, metadata edit/view, delete and bulk delete. Uploads use core Pupitre's MIME sniffing, size ceiling, session ownership and consumption tracking. Active content including SVG is rejected. Images default to a 320px WebP thumb; named conversions can set width, optional height, and WebP/JPEG/PNG format. conversions: false disables generated files. Private objects and conversions use the core 30-minute signed URL resolver.

Overlapping attempts to adopt one upload create at most one library record. A failed adoption removes its own conversions, but preserves the original when another adoption already owns it.

tenancy: true requires an active panel tenant and scopes rows by tenant_id; do not use this on a panel without tenancy. tenancy: false explicitly leaves media global, bypassing automatic tenant scoping. Storage cleanup removes the original and every generated conversion when library records are deleted. A nullable foreign key with ON DELETE SET NULL is recommended for single-picker columns. Multiple-ID JSON columns are host-owned: removed IDs cease to render and are rejected on subsequent saves.

Protocol

GET <panel-path>/_pupitre/media?q=...&ids[0]=...&conversion=thumb returns authorized { rows } with ID, filename, MIME, alt and signed thumbnail URLs. Results are bounded to 50 browse records or 100 explicitly requested IDs. POST to the same URL accepts { paths, filenames? }, adopts only files uploaded for the Media resource's path field by the current session, and returns created rows. Inline upload first uses the existing /_pupitre/upload endpoint. These routes share the core authenticated, tenant-resolved panel route groups and CSRF protection; no public media lookup endpoint is registered.