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

@86d-app/customer-groups

v0.0.25

Published

Customer groups and segmentation module for 86d commerce platform

Readme

[!WARNING] This project is under active development and is not ready for production use. Please proceed with caution. Use at your own risk.

Customer Groups Module

Customer segmentation module for grouping customers into manual or rule-based segments. Enables wholesale pricing, VIP tiers, B2B customer management, and group-specific price adjustments.

Installation

npm install @86d-app/customer-groups

Usage

import customerGroups from "@86d-app/customer-groups";

const module = customerGroups({
  defaultGroupSlug: "retail",
  includeExpiredMemberships: false,
});

Configuration

| Option | Type | Default | Description | |---|---|---|---| | defaultGroupSlug | string | undefined | Slug of group to auto-assign new customers to | | includeExpiredMemberships | boolean | false | Whether to include expired memberships in group lookups |

Store Endpoints

| Method | Path | Description | |---|---|---| | GET | /customer-groups/mine | Get all groups the current customer belongs to | | GET | /customer-groups/pricing | Get active price adjustments for the current customer |

Admin Endpoints

Groups

| Method | Path | Description | |---|---|---| | GET | /admin/customer-groups | List all groups (filterable by type, active status) | | POST | /admin/customer-groups/create | Create a new group | | GET | /admin/customer-groups/stats | Get group statistics | | GET | /admin/customer-groups/:id | Get group details | | POST | /admin/customer-groups/:id/update | Update a group | | POST | /admin/customer-groups/:id/delete | Delete a group (cascades) |

Members

| Method | Path | Description | |---|---|---| | GET | /admin/customer-groups/:id/members | List group members | | POST | /admin/customer-groups/:id/members/add | Add a customer to a group | | POST | /admin/customer-groups/:id/members/remove | Remove a customer from a group |

Rules (Automatic Groups)

| Method | Path | Description | |---|---|---| | POST | /admin/customer-groups/:id/rules/add | Add a segmentation rule | | POST | /admin/customer-groups/rules/:ruleId/remove | Remove a rule | | POST | /admin/customer-groups/evaluate | Evaluate rules against customer data |

Pricing

| Method | Path | Description | |---|---|---| | POST | /admin/customer-groups/:id/pricing | Set a price adjustment for a group | | GET | /admin/customer-groups/:id/pricing/list | List price adjustments | | POST | /admin/customer-groups/pricing/:adjustmentId/remove | Remove a price adjustment |

Controller API

interface CustomerGroupController {
  createGroup(params: { name: string; slug: string; description?: string; type?: GroupType; priority?: number }): Promise<CustomerGroup>;
  getGroup(id: string): Promise<CustomerGroup | null>;
  getGroupBySlug(slug: string): Promise<CustomerGroup | null>;
  listGroups(opts?: { type?: GroupType; activeOnly?: boolean }): Promise<CustomerGroup[]>;
  updateGroup(id: string, data: Partial<CustomerGroup>): Promise<CustomerGroup>;
  deleteGroup(id: string): Promise<void>;

  addMember(params: { groupId: string; customerId: string; expiresAt?: Date }): Promise<GroupMembership>;
  removeMember(groupId: string, customerId: string): Promise<void>;
  listMembers(groupId: string, opts?: { includeExpired?: boolean }): Promise<GroupMembership[]>;
  getCustomerGroups(customerId: string, opts?: { activeOnly?: boolean }): Promise<CustomerGroup[]>;
  isMember(groupId: string, customerId: string): Promise<boolean>;

  addRule(params: { groupId: string; field: string; operator: RuleOperator; value: string }): Promise<GroupRule>;
  removeRule(ruleId: string): Promise<void>;
  listRules(groupId: string): Promise<GroupRule[]>;
  evaluateRules(customerData: Record<string, unknown>): Promise<string[]>;

  setPriceAdjustment(params: { groupId: string; adjustmentType: AdjustmentType; value: number; scope?: AdjustmentScope; scopeId?: string }): Promise<GroupPriceAdjustment>;
  removePriceAdjustment(id: string): Promise<void>;
  listPriceAdjustments(groupId: string): Promise<GroupPriceAdjustment[]>;
  getCustomerPricing(customerId: string, opts?: { scope?: AdjustmentScope; scopeId?: string }): Promise<GroupPriceAdjustment[]>;

  getStats(): Promise<GroupStats>;
}

Types

type GroupType = "manual" | "automatic";
type RuleOperator = "equals" | "not_equals" | "contains" | "not_contains" | "greater_than" | "less_than" | "in" | "not_in";
type AdjustmentType = "percentage" | "fixed";
type AdjustmentScope = "all" | "category" | "product";

interface CustomerGroup {
  id: string;
  name: string;
  slug: string;
  description?: string;
  type: GroupType;
  isActive: boolean;
  priority: number;
  metadata?: Record<string, unknown>;
  createdAt: Date;
  updatedAt: Date;
}

interface GroupMembership {
  id: string;
  groupId: string;
  customerId: string;
  joinedAt: Date;
  expiresAt?: Date;
  metadata?: Record<string, unknown>;
}

interface GroupRule {
  id: string;
  groupId: string;
  field: string;
  operator: RuleOperator;
  value: string;
  createdAt: Date;
}

interface GroupPriceAdjustment {
  id: string;
  groupId: string;
  adjustmentType: AdjustmentType;
  value: number;
  scope: AdjustmentScope;
  scopeId?: string;
  createdAt: Date;
  updatedAt: Date;
}

Notes

  • Two group types: manual groups require explicit membership management. automatic groups match customers via configurable rules.
  • Rule evaluation: All rules use AND logic — every rule must match for a customer to belong to an automatic group. Rules with no conditions never match.
  • Price adjustments: Each group can have multiple price adjustments scoped to all, category, or product. Setting an adjustment with the same scope/scopeId updates the existing one.
  • Membership expiration: Memberships can have an expiresAt date. Expired memberships are excluded from all lookups by default.
  • Cascade delete: Deleting a group removes all associated memberships, rules, and price adjustments.
  • Priority ordering: Groups are sorted by priority (ascending) — lower numbers appear first.