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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@fjell/client-api

v4.4.68

Published

Client API for Fjell

Readme

@fjell/client-api

HTTP client for Fjell operations.

Installation

npm install @fjell/client-api @fjell/http-api @fjell/core

Overview

@fjell/client-api provides HTTP client implementations for Fjell's Operations interface. It enables you to interact with Fjell-based APIs over HTTP using the same consistent interface as local operations.

v4.5.0+ Breaking Changes

The ClientApi interface now directly extends @fjell/core Operations. This means:

  • Consistent interface across all transport layers
  • Better type safety
  • Smaller bundle size
  • Full compatibility with other Operations implementations

Key Changes

  1. Core Operations Interface: ClientApi now extends the core Operations interface
  2. Upsert Support: Added missing upsert operation
  3. CreateOptions: The create method now accepts CreateOptions for more flexibility
  4. Action Parameters: Action methods now use params (OperationParams) instead of body

Usage

Basic Example

import { createClientApi } from '@fjell/client-api';
import { HttpApi } from '@fjell/http-api';
import type { Item } from '@fjell/core';

// Define your item type
interface User extends Item<'user'> {
  name: string;
  email: string;
}

// Create HTTP API instance
const httpApi = new HttpApi({ baseUrl: 'https://api.example.com' });

// Create client API
const userApi = createClientApi<User, 'user'>(
  httpApi,
  'user',
  ['user']
);

// Use the operations
const users = await userApi.all({});
const user = await userApi.get({ kt: 'user', pk: 'user-123' });
const created = await userApi.create({ name: 'Alice', email: '[email protected]' });
const updated = await userApi.update({ kt: 'user', pk: 'user-123' }, { name: 'Alice Smith' });

Contained Items

import { createCItemApi } from '@fjell/client-api';

interface Comment extends Item<'comment', 'post'> {
  text: string;
  author: string;
}

const commentApi = createCItemApi<Comment, 'comment', 'post'>(
  httpApi,
  'comment',
  ['post', 'comment']
);

// Operations scoped to a specific location
const comments = await commentApi.all({}, [{ kt: 'post', lk: 'post-123' }]);
const comment = await commentApi.create(
  { text: 'Great post!', author: 'alice' },
  { locations: [{ kt: 'post', lk: 'post-123' }] }
);

All Operations

The ClientApi implements all standard Operations:

  • CRUD: get, create, update, upsert, remove
  • Query: all, one, find, findOne
  • Actions: action, allAction
  • Facets: facet, allFacet

Migration from v4.4.x

Update Dependencies

npm install @fjell/core@latest @fjell/client-api@latest

Code Changes

The API is mostly backward compatible. Key changes:

1. Create Method Signature

// Before (v4.4.x)
await api.create(item, locations);

// After (v4.5.0+) - still works
await api.create(item, { locations });

// New options
await api.create(item, { key: { kt: 'user', pk: 'custom-id' } });

2. Action Parameters

// Before (v4.4.x) - "body" parameter
await api.action(key, 'promote', { role: 'admin' });

// After (v4.5.0+) - "params" parameter (works the same)
await api.action(key, 'promote', { role: 'admin' });

3. Upsert Operation

// Now available
const user = await api.upsert(
  { kt: 'user', pk: 'user-123' },
  { name: 'Alice', email: '[email protected]' }
);

Type Exports

import type { 
  ClientApi,
  CItemApi,
  OperationParams,
  AffectedKeys,
  CreateOptions
} from '@fjell/client-api';

Benefits

  • Consistent API: Same Operations interface as @fjell/lib, @fjell/lib-firestore, etc.
  • Type Safety: Full TypeScript support with generic types
  • Interchangeable: Can be used anywhere that accepts Operations
  • HTTP Transport: Built on @fjell/http-api for reliable HTTP communication

Documentation

For detailed documentation, see:

License

Apache-2.0