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

@minimistapp/client-ts

v1.2.7

Published

TypeScript gRPC client for Minimist APIs

Readme

@minimist/client-ts

TypeScript gRPC client library for Minimist APIs. This package provides fully typed clients generated from protobuf definitions using Buf and Connect-ES.

Installation

# Using pnpm (recommended)
pnpm add @minimistapp/client-ts

# Using npm
npm install @minimistapp/client-ts

# Using yarn
yarn add @minimistapp/client-ts

Quick Start

Basic Setup

import { createClient } from "@connectrpc/connect";
import {
  createTransport,
  PredictorService,
} from "@minimistapp/client-ts";

// Get an access token from your authentication service
async function getAccessToken() {
  // Implement your token retrieval logic here
  return "your-access-token";
}

// Create a transport with authentication (preferred: no side effects)
const transport = createTransport({
  getAccessToken,
  // Optional overrides:
  // baseUrl: process.env.MINIMIST_API_URL ?? "https://api-grpc.mnm.st",
  // defaultTimeoutMs: 30000,
});

// Create a client
const client = createClient(PredictorService, transport);

Example: Predict Category from Images

import { createClient } from "@connectrpc/connect";
import { create } from "@bufbuild/protobuf";
import { 
  createTransport,
  PredictorService,
  PredictCategoryRequestSchema,
  PredictCategoryResponse
} from "@minimistapp/client-ts";

async function getAccessToken() {
  // Implement your token retrieval logic here
  return "your-access-token";
}

async function predictCategory() {
  // Setup client
  const transport = createTransport({ getAccessToken });
  const client = createClient(PredictorService, transport);

  // Prepare request (recommended): use the schema-aware create() helper
  const request = create(PredictCategoryRequestSchema, {
    listingId: "listing_123",
    imageUrls: [
      "https://example.com/product-image-1.jpg",
      "https://example.com/product-image-2.jpg"
    ],
    storeId: "store_456", // deprecated but kept for compatibility
    tenantId: "tenant_789"
  });

  try {
    // Make the API call
    const response = await client.predictCategory(request);

    // response is of type `PredictCategoryResponse`
    return response;
  } catch (error) {
    console.error("Failed to predict category:", error);
    throw error;
  }
}

Creating request messages with create()

All request/response messages come with a generated *Schema that can be used with create() from @bufbuild/protobuf. Benefits:

  • Strong typing guided by the schema at compile-time
  • Default values are applied (e.g. empty arrays/strings)
  • Nested messages and oneof fields are easy to construct
import { create } from "@bufbuild/protobuf";
import {
  PredictCategoryRequestSchema,
  PredictCategoryByAttributesRequestSchema,
  PredictCategoryByAttributesRequest_ProvidedAttributeSchema,
  SessionContextSchema,
  AttributePredictedSchema,
} from "@minimistapp/client-ts";

// Basic request
const req = create(PredictCategoryRequestSchema, {
  listingId: "abc",
  imageUrls: ["https://example.com/img.jpg"],
});

// With optional session context
const session = create(SessionContextSchema, {
  userId: "user_123",
  locale: "en-US",
});
const reqWithContext = create(PredictCategoryRequestSchema, {
  listingId: "abc",
  imageUrls: ["https://example.com/img.jpg"],
  sessionContext: session,
});

// PredictCategoryByAttributes with a oneof ProvidedAttribute
const providedAttribute = create(
  PredictCategoryByAttributesRequest_ProvidedAttributeSchema,
  {
    attribute: {
      case: "attributePrediction",
      value: create(AttributePredictedSchema, {
        // fill predicted attribute fields here
      }),
    },
  },
);

const byAttributes = create(PredictCategoryByAttributesRequestSchema, {
  attributes: [providedAttribute],
});

Using a singleton transport (optional)

Prefer createTransport() for a new, side-effect-free transport per call. If you need to share a single instance across your app, you can use getTransport() which caches the first created transport:

import { getTransport } from "@minimistapp/client-ts";

const transport = getTransport({ getAccessToken });
// Subsequent calls to getTransport() will return the same instance

In-memory testing

You can test your client without a running server by using an in-memory router transport. This is ideal for unit tests and does not perform network I/O.

import { createClient, createRouterTransport, ConnectError, Code } from "@connectrpc/connect";
import { create } from "@bufbuild/protobuf";
import {
  PredictorService,
  PredictCategoryRequestSchema,
  PredictCategoryResponseSchema,
} from "@minimistapp/client-ts";

// Define in-memory routes for tests
const transport = createRouterTransport(({ service }) => {
  service(PredictorService, {
    async predictCategory(req) {
      // You can add assertions here in your tests
      return create(PredictCategoryResponseSchema, {
        listingId: req.listingId,
      });
    },
  });
});

// Use your normal client with the in-memory transport
const client = createClient(PredictorService, transport);
const res = await client.predictCategory(
  create(PredictCategoryRequestSchema, {
    listingId: "listing-1",
    imageUrls: ["https://example/img.jpg"],
  })
);

// Example: Raising a ConnectError in a route
createRouterTransport(({ service }) => {
  service(PredictorService, {
    predictCategory() {
      throw new ConnectError("invalid", Code.InvalidArgument);
    },
  });
});

Error Handling

import { ConnectError, Code } from "@connectrpc/connect";

try {
  const response = await client.yourMethod(request);
} catch (err) {
  if (err instanceof ConnectError) {
    switch (err.code) {
      case Code.NotFound:
        console.log("Resource not found");
        break;
      case Code.Unauthenticated:
        console.log("Authentication required");
        break;
      default:
        console.log(`gRPC error: ${err.message}`);
    }
  }
}