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

@kindgi/blob-binding

v0.8.1

Published

Kindgi™ blob storage binding contract. Types only: the BlobStorageBinding interface that storage implementations provide and @kindgi/api consumes — blobId-addressed put / get / head / list / delete, S3-compatible putByKey / getByKey / headByKey / deleteBy

Readme

@kindgi/blob-binding

Storage contract for Kindgi artifacts (blobs). BlobStorageBinding is the interface a storage adapter implements and @kindgi/api consumes through its blobStorage input; it backs both the /v1/artifacts/* surface and the S3-compatible /s3/* surface. This package contains types only and has no runtime code.

Purpose

Keep storage out of the API package while giving both wire surfaces one store. Every blob has two addresses kept in a single metadata record: a blobId (used by /v1/artifacts/*) and a (bucket, key) pair (used by /s3/*). Uploads through put get a synthetic (bucket, key) so they are also reachable over S3, and head(blobId) and headByKey(bucket, key) return the same BlobMeta for the same blob. Every method takes tenantId explicitly so adapters can partition storage per workspace. Cursors and continuation tokens are opaque and adapter-defined.

Contract rules adapters follow:

  • BlobMeta.hash is the lowercase hex SHA-256 of the exact bytes persisted. When BlobPutInput.expectedHash is set, a mismatch fails the write with blob-hash-mismatch. The one exception is a multipart-assembled object, whose hash is the S3 multipart ETag.
  • delete and deleteByKey are idempotent: { deleted: true } on the first call, { deleted: false } afterwards. Adapters may tombstone or remove data.
  • listByPrefix sorts lexicographically by key, as S3 does; putByKey overwrites an existing key.

Exports

  • FileVersionsBinding — files with versions, beside BlobStorageBinding: a file is a name and its versions 1, 2, 3, each one stored blob. create, get, list, delete; listVersions, getVersion, readVersion, addVersion, restoreVersion, deleteVersion; pinVersion, unpinVersion, pinHistory. Its types: StoredFile, FileVersion (version, blobId, name, contentType, size, hash, tags, parentVersion?, restoredFrom?, madeVia, createdBy?, runId?, pin?, deletedAt?, purgedAt?, and more), FilePin, FilePinChange, FileVersionSelector (a number or latest), FileCreateInput, FileVersionAddInput (expectedVersion?, name?), FileRestoreInput, FilePinInput, FileVersionWrite (version, created), FileVersionRead, FileFilter, the pages, FileDeleteOutcome, and FileError (file-not-found, file-version-not-found, file-version-conflict, file-version-pinned, file-last-version, and the storage errors).
  • BlobStorageBinding — the adapter interface, in three groups:
    • By blobId — put(tenantId, input), get(tenantId, blobId) (body as a ReadableStream), head(tenantId, blobId) (null when unknown), list(tenantId, filter, cursor?, limit?), delete(tenantId, blobId), and, optional, storageUsed(tenantId) (BlobStorageUsed: usedBytes, what the tenant's files take, with the uploads under way).
    • By (bucket, key) — putByKey, getByKey, headByKey, deleteByKey, and listByPrefix(tenantId, bucket, prefix, continuationToken?, maxKeys?) (maxKeys 1 to 1000, default 1000).
    • Multipart upload — initiateMultipartUpload (returns uploadId), uploadPart (returns the part etag), completeMultipartUpload (parts in ascending partNumber), abortMultipartUpload, listParts.
  • Inputs
    • BlobPutInput — name, contentType, bytes (ReadableStream<Uint8Array> or Uint8Array), size?, tags?, ownerRunId?, expectedHash?, forRun? (an upload for a run that hasn't started, deleted if no run that names it starts in time).
    • MultipartInitiateInput — contentType, tags?, ownerRunId?.
    • BlobFilter — ownerRunId, contentType, tags (all must match), scope (a Scope from @kindgi/platform), and inherit (no effect here: blobs always live at project level).
  • Results — BlobMeta (blobId, tenantId, name, contentType, size, hash, tags, ownerRunId?, createdAt, expiresAt? (when a forRun upload is deleted unless such a run has started), bucket?, key?, fileId? and version? for a blob that is a file's version), BlobRead (meta + stream), BlobListPage (data, nextCursor?), BlobDeleteOutcome (deleted), S3ListPage (contents, isTruncated, nextContinuationToken?), MultipartListPartsPage (parts with partNumber, etag, size, lastModified).
  • BlobError — union discriminated by code: blob-not-found (blobId), blob-hash-mismatch (expected, actual), blob-size-mismatch (declared, actual), blob-storage-error (cause?), artifact-in-file (blobId, fileId: deleting bytes a file still needs), storage-limit-reached (limit: 'storage', storageMiB, usedBytes, neededBytes: the tenant's storage limit has no room for the put, and nothing was stored).

Example

import { createHash } from 'node:crypto';

import type { BlobMeta, BlobStorageBinding } from '@kindgi/blob-binding';
import type { RunId, TenantId } from '@kindgi/types';

async function storeReport(
  blobs: BlobStorageBinding,
  tenantId: TenantId,
  runId: RunId,
  report: string,
): Promise<BlobMeta> {
  const bytes = new TextEncoder().encode(report);
  const stored = await blobs.put(tenantId, {
    name: 'q3-report.txt',
    contentType: 'text/plain',
    bytes,
    size: bytes.byteLength,
    tags: { kind: 'report' },
    ownerRunId: runId,
    // Optional integrity check: the binding rejects the write if its own sha256 differs.
    expectedHash: createHash('sha256').update(bytes).digest('hex'),
  });
  if (stored.kind === 'err') throw new Error(`${stored.error.code}: ${stored.error.message}`);
  const meta = stored.value;

  // The same object is addressable by (bucket, key) on the S3-compatible surface.
  if (meta.bucket !== undefined && meta.key !== undefined) {
    const viaKey = await blobs.headByKey(tenantId, meta.bucket, meta.key);
    console.log(viaKey?.blobId === meta.blobId); // true
  }

  // Everything this run has produced with the same tag, first page.
  const page = await blobs.list(tenantId, { ownerRunId: runId, tags: { kind: 'report' } }, undefined, 20);
  if (page.kind === 'ok') console.log(page.value.data.map((b) => `${b.name} ${b.size}B`));

  return meta;
}

Non-goals

  • No storage implementation. Filesystem, object-store, and other adapters implement BlobStorageBinding in their own packages.
  • No Content-MD5 verification. The S3-compatible route verifies it before calling the binding.
  • No object versioning. Writing an existing (bucket, key) replaces the object (last write wins).
  • No scope inheritance for blobs. Blobs are project-level content; BlobFilter.inherit exists only to keep one filter shape across scope-aware bindings.

Related

  • @kindgi/api — mounts /v1/artifacts/* over a BlobStorageBinding, and /s3/* when an S3 credential binding is also supplied.
  • @kindgi/platform — Scope.
  • @kindgi/types — ArtifactId, Cursor, FileId, ProjectId, RunId, TenantId, Timestamp, Result.