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

@haneinfo/frontend-instances

v0.9.0

Published

Shared instance lists, collaboration and import/export pages

Readme

@haneinfo/frontend-instances

Reusable instance lists, collaboration and import/export pages for React 19 / Next 16. Backend packages stay free of React and NestJS is not a dependency of this package.

Mounting

Import renderInstanceListPage, renderInstanceDetailPage and renderImportPage from @haneinfo/frontend-instances/server. Each returns a server-renderable React tree. Supply:

  • apiFetch<T>(path, init?), using the current authenticated session and an App-owned API URL.
  • LinkComponent, t(LabelKey), getCurrentUser(), and basePath.
  • An App Server Action calling performInstanceRequest(apiFetch, request) and returning { data } or { error: instanceError(error) } after checking the session.
  • For imports, an authenticated uploadAction(FormData) calling readImportUpload, plus the App's { code, label }[] machine choices.

The list additionally takes machineCode and promised searchParams: { query?: string }. The detail takes id. The import takes machines and uploadAction. All UI labels are injected. System field labels use t; Form labels stay verbatim from the API. See LabelKey and the complete English/zh-TW mounting examples in validation/equipment-loan/instance-frontend/app/ in the source repository.

Add @source "../../node_modules/@haneinfo/frontend-instances/dist"; to the App's Tailwind CSS source declarations. Mount navigation in the App's sidebar, not generated plugin files. Set the App's Server Action body limit to allow multipart uploads (the example uses 16 MB). The backend HTTP body limit remains App-owned; API rejections are shown in the UI.

Client components and contracts

@haneinfo/frontend-instances/client exports ListClient, DetailClient, ImportClient, FilterEditor, JobStatus, JobReport, ImportConfirmation and prepareFilter. Use the server renderers for normal mounting. @haneinfo/frontend-instances/contracts exports HTTP-only types and labelKeys. The server entry also exports the contracts, dateRange, importMapping, normalizeQuery, performInstanceRequest, readImportUpload and instanceError.

Lists support PREDICATE/GROUP AND/OR, all eight operators, inclusive date ranges, up to eight sort keys, selected columns and offset/limit pagination (1–500). IN uses one literal per line. Datetime-local controls are in the display time zone (see below). Exports use the last applied query, not unapplied drawer changes. Saved views default to private; sharing controls depend only on canShare.

Details use pinned subject Form labels and the structured timeline; mentions come only from the instance-specific mentionable API. Following comes from the timeline or mutation response. Comments are append-only plain text and AI comments have a visible attribution.

CSV and xlsx headers are read using csv-parse and ExcelJS on the server, with a 10 MB upload bound. The backend performs the complete preflight and authorization. Duplicate keys are optional, mapped top-level keys with a five-key maximum. Preflight never confirms an import. Confirmation requires a separate button click; global errors and zero valid rows disable it. Re-upload to change a completed preflight's mapping.

JobStatus polls every two seconds, stops on terminal status or failure, and bounds automatic polling to 90 requests. A manual refresh resumes polling. Job state is owner-authorized by the backend. Binary result bytes and uploaded job params are removed before returning jobs to clients.

Downloads and safety

Mount ${basePath}/download?path=... as an authenticated, no-store streaming GET proxy. Constrain the path to /import-export/(imports|exports)/<id>/file, forward the current session token to that exact backend-provided downloadPath, and forward its disposition/type. Never synthesize job download paths or put file bytes/tokens in the URL. The App example includes this route.

Use real Next Server Actions so same-origin CSRF checks apply. All mutations have an immediate in-memory submission lock and disabled pending buttons. The backend remains authoritative for authorization and validation; the UI does not recreate RBAC. 401/403/404 display generic localized messages without raw API details. All user content is rendered as text nodes, including errors, field values, names, and timeline details. No HTML or Markdown rendering is used.

No submission, approval, rejection or transition controls are included. With showCreate the list and dashboard offer "New record" (an empty draft; the backend decides whether it is allowed).

Submitter display

List $submitterId cells and the detail submitter field display submitterName ?? submitterId. Both are plain React text nodes, including markup-like names. The HTTP contracts include nullable submitterName; older responses without it also fall back to the id. No new translation key, lookup request or App host-page change is required. Upgrade the state-machine and list-view backends with this frontend for names; otherwise the id remains visible.

Delegation and access management (draft 202610-e2a9)

renderDelegationsPage accepts the same injected page dependencies as instance pages. The App mounts it at /dashboard/delegations and supplies an authenticated Server Action calling performInstanceRequest. Administrative controls depend on the successful admin list API; only DELEGATION_NOT_FOUND is treated as a denial. Other failures render an error. The datetime inputs (in the display time zone) require an explicit end; backend rules remain authoritative.

Pass showAccess: true to renderInstanceDetailPage to load the access list. InstanceAccessPanel is exported from the client entry for other hosts. It renders USER/ROLE, READ/WRITE, sources, grantor and timestamps. Only API canManage enables management, and only GRANTED rows have change/remove controls. Mutations refresh both the list and the enclosing activity timeline. Pickers use bounded explicit searches and keyboard combobox selection; user search needs two trimmed characters. Every mutation uses the supplied Server Action and a synchronous submit lock.

Merge the bilingual catalog fragments in validation/equipment-loan/delegation-access-frontend/app/ into the host's instances catalog. The new keys include the known error code allowlist. instanceError only maps recognized codes. Unknown/missing codes, even on 401/403/404, use requestFailed. Backend message, diagnostic message and lastError text are never rendered. Upgrade common and frontend-shell together so the production filter and API adapter retain code.

Attachment panel (draft 202610-a7c1)

Pass showAttachments: true to renderInstanceDetailPage. The client entry also exports AttachmentsPanel. The host supplies the existing authenticated action for attachments GET and deleteAttachment DELETE through performInstanceRequest. Successful mutations reload the list and enclosing timeline. Merge the complete bilingual catalogs in validation/equipment-loan/attachment-panel/app/.

Mount POST ${basePath}/:id/attachments/upload and GET ${basePath}/:id/attachments/:attachmentId/content in the App. Upload uses XHR multipart with per-file progress, a synchronous mutation lock and sequential requests. It never uses a Server Action. The route must authenticate, reject missing/mismatched Origin and Host, and stream the unaltered body/Content-Type/Content-Length to the fixed backend route with the current token. Abort the upstream request on disconnect. Exclude upload from Next Proxy's request-body cloning; in Next 16.3 the proxy otherwise buffers bytes even when the route itself streams. The example retains the existing 16 MB Server Action setting and verifies an 18 MiB route upload.

Use HTTP canUpload/canDelete only. Missing canUpload hides selection; remaining=0 disables it. Size/extension/remaining prechecks are advisory and still submit each selected file: only backend status and known codes determine the result. Unknown codes never expose response prose. READY downloads through the fixed App route; PENDING_SCAN shows scanning; REJECTED shows scan failed/content removed with no download. Rejections retain authorized record deletion and occupy no slots. Refresh rechecks scan status. Names, uploader labels and upload/delete timeline names are text nodes. Native buttons support keyboard selection/drop activation; progress is labelled.

Document panel (draft 202610-b9e2)

Pass showDocuments: true and documentDownloadUrl (the App's fixed same-origin POST route) to renderInstanceDetailPage. DocumentsPanel is also exported from the client entry. The existing authenticated action calls performInstanceRequest with documentTemplates to GET /state-machine-instances/:id/documents/templates. Only the backend decides availability; an empty list renders an explanation with no controls. Merge the complete English/zh-TW catalogs in validation/equipment-loan/document-panel/app/frontend/messages/ into the host's instances.

The host route must check the current session and exact Origin/Host, stream the JSON request to POST /state-machine-instances/:id/documents, and return the upstream status and Content-Type, Content-Disposition, X-Content-Type-Options, Cache-Control and Content-Length unchanged. Propagate request aborts and downstream cancellation. The example excludes the route from Next Proxy and keeps file bytes out of Server Actions. Never put tokens or backend URLs in links.

The panel POSTs { templateCode, format: 'pdf' | 'docx' } using fetch. It accepts only a successful HTTP response with the requested format's MIME type before creating a Blob/object URL download. Errors read only known JSON codes, never raw messages or binary text. A synchronous lock covers all templates and formats until download and timeline refresh finish. The object URL is released after the browser starts the download; unmount aborts in-flight requests. UTF-8 filename* wins over filename; unsafe/malformed names use a bounded template-code/format fallback. Blob storage can retain up to the backend's default 10 MiB output limit plus browser-managed copies; Next does not buffer the response. DOCUMENT history renders translated template code/version/format/actor as text. No preview, attachment persistence or workflow transition controls are added.

Instance management (draft 202610-6e7f)

Pass showManagement: true to renderInstanceDetailPage to add three things to the detail page: the tag panel, the lifecycle actions and, for a draft the reader may edit, the draft editor. renderDeletedInstancesPage renders the deleted-drafts page (restore, remaining retention days); the list page links to it at ${basePath}/deleted. Merge the complete English/zh-TW catalogs in validation/equipment-loan/management-panel/app/frontend/messages/ into the host's instances.

What each control offers comes from the server, never from the client: canAdd on the tag list, canRemove per tag, and canArchive, canUnarchive, canDelete, canEdit on the instance read. Tags use GET /tags/suggest for a keyboard-operable combobox and are plain text everywhere. The list page adds a tag filter (all or any) and an archive selector (EXCLUDE, INCLUDE, ONLY) that are saved with views; when the backend answers TAGS_NOT_AVAILABLE the tag controls disappear.

The draft editor edits top-level text, textarea, number, date, datetime, radio, select, checkbox and switch fields and subform rows from the pinned Form. User pickers, formulas and number-assigned fields remain read only. Required fields are hinted until a submission fails validation. Edits autosave through PATCH /state-machine-instances/:id/data/fields with the current baseRevision: one serialized queue, at least two seconds between requests, only changed fields, changedByOthers fields refreshed unless being edited, and a leave-page prompt plus a same-origin keepalive write (draftKeepaliveUrl, a host route that forwards the same JSON). A VERSION_CONFLICT opens a dialog that shows the current value and your value per field and resends the fields you keep with the new revision; RATE_LIMITED waits for retryAfterSeconds. Enable showProcess for the workflow controls described below; their revision always comes from the last acknowledged draft save.

Quality overhaul (draft 202610-a8d3, phase two)

Implemented against the draft; the decision remains draft.

New page options and entry points

Every page renderer accepts locale (zh-TW or en) and timeZone. With locale, backend requests carry Accept-Language so field, option, state and transition labels arrive in that language (withLocale(apiFetch, locale) does the same for other calls); pass the same locale as performInstanceRequest(apiFetch, request, { locale }) in the App's Server Action. timeZone defaults to the DISPLAY_TIME_ZONE environment variable, then Asia/Taipei; the server passes it to the client components, so server-rendered and hydrated text are identical.

renderInstanceListPage and renderInstanceDetailPage also accept personField (the Form key of the person a record is about; default: the first text field) and the list showCreate. renderInstanceDashboardPage({ machineCode, personField, showCreate, links }) renders my open records by state (report $state counts with a $leadTime count to exclude finished records), the five most recently created records and quick actions; without the instance-analytics mechanism it degrades to recent records and quick actions, and it welcomes people without any records. DashboardSkeleton, ListSkeleton and DetailSkeleton (with a label for screen readers) are loading placeholders for the App's loading.tsx or a Suspense fallback. All existing options keep working.

Rendering

formatFieldValue(field, value, { locale, timeZone }) (with formatFieldText) returns a display descriptor for every Form field type: text (multi-line kept, long text collapsible), numbers by locale, calendar dates without zone conversion, date-times in the display zone, select/radio option labels (unknown values shown and marked), checkbox options, yes/no switches, subforms as tables of typed cells, user names, calculated (formula) values, — for empty values with a screen-reader text, and invalid instead of JSON for malformed data. Dates and times are built from numeric fields with fixed separators and a fixed zone-name table, never from ICU patterns. <time dateTime> elements show the full date and time on hover and keyboard focus; relative times ("3 minutes ago") only appear in the activity feed and only after hydration.

State badges show stateLabel with a dot and soft background for stateTone. The host must define the tone tokens (light and dark) and map them for Tailwind, e.g.:

@theme inline {
  --color-tone-success: var(--tone-success);
  --color-tone-success-soft: var(--tone-success-soft);
  /* … warning, info, danger */
}
:root { --tone-success: oklch(0.448 0.119 151.328); --tone-success-soft: oklch(0.962 0.044 156.743); }
.dark { --tone-success: oklch(0.871 0.15 154.449); --tone-success-soft: oklch(0.266 0.065 152.934); }

Without them badges keep their text and neutral borders. Hosts should also honour prefers-reduced-motion globally; components use motion-safe: for their own animation.

The activity feed turns every structured timeline kind (START, TRANSITION, CHOICE, NUMBER, NOTIFICATION_FAILURE, COMMENT, ACCESS, ATTACHMENT, TAG, REFERENCE, SPACE, DOCUMENT, LIFECYCLE) into a translated sentence, grouped by day in the display zone and sorted by time. People appear by display name (unknown people as "Unknown person"), the system as "System", comment mentions as @Name; deprecated actorId/details are never rendered.

Screens

  • Detail: header (number, or record name and creation date; state badge; archived; person, submitter, created, last updated), an action area (data-slot="instance-actions") with follow and a "More actions" lifecycle menu, the content card in Form order (two columns on wide screens, subforms full width) or the draft editor in its place, and tabs (activity with the comment form, attachments, documents, access and tags) with counts. Narrow screens stack summary, content, actions and tabs.
  • List: exact-match search over filterable text fields (no contains operator exists), state chips, a saved-view menu with "Save current view", a filter drawer, removable applied-filter chips with "Clear all", default columns (number, person, state, created, tags with +N), sortable sticky headers, whole-row links, cards under 768 px, skeleton rows while loading, "no records" and "no matching records" states, pagination with rows per page, and a More menu (import, CSV/Excel export, deleted drafts). The applied query is kept in the URL.
  • Deleted drafts, delegations, import, attachments, documents, tags and access use the same headings, dates, empty, loading and error states. Granting access moved into a dialog.

ListClient and DetailClient take new props (see their exported prop types). LifecyclePanel is deprecated in favor of LifecycleMenu. Client components link with next/link; LinkComponent is used for server-rendered links (back links, dashboard). lucide-react is a peer dependency.

Translations

New label keys are listed in src/ui-messages.ts. defaultLabels(locale) returns complete English and Traditional Chinese (Taiwan) catalogs; page renderers resolve the host's t through resolveLabels, which uses the default for keys the host does not translate. Hosts should still ship every key: the complete catalogs used by the equipment-loan App are in validation/equipment-loan/frontend-quality-ui/app/frontend/messages/ (regenerate with catalogs.mjs).

Workflow operations and personal tasks (draft 202610-d1f4)

Enable showProcess on renderInstanceDetailPage alongside showManagement. The existing action slot renders only server-provided transitions, with a primary button, additional-action menu and state-label confirmation dialog. Pending or failed draft saves disable transitions with an accessible explanation. Requests carry the last saved expectedRevision. Revision conflicts reuse the field-choice dialog; bounded INVALID_DATA fieldErrors map to controls, including subform columns. Unknown codes use generic translated text. Subform rows can be edited, added and removed, with the entire array saved as one field. A failed CHOICE shows recovery guidance and the server-authorized retry button. Successful operations refresh state, revision, tasks and timeline and announce the result. Input is blocked during the mutation.

Mount renderMyTasksPage with the usual authenticated action, API, translation, locale and basePath options (basePath points to instance details). It defaults to OPEN, supports ALL, and paginates the returned authorized task snapshot in groups of 20. Task responses are available in expanded rows and the detail pending-items section, always with confirmation. Enable showTasks and optional tasksPath on renderInstanceDashboardPage for the first five tasks. Use TaskCountBadge from the client entry inside the task navigation link, with the action and tasksCountLabel translation. Key it by the current pathname to refresh on navigation. Responses emit haneinfo:tasks-changed; there is no push subscription or periodic count polling. Counts above 99 display 99+ while the accessible name preserves the actual number.

All writes remain authenticated same-origin Server Actions. Regenerate both catalogs using validation/equipment-loan/process-operations/catalogs.mjs after building this package. The reversible process-operations overlay includes the App mounts, disposable services, production HTTP integration tests, browser workflows, screenshots, axe and byte-exact restore.