Hyperse
  • Pricing
  • FAQs
Newsletter

Subscribe to our newsletter

Receive weekly updates with latest collections and exclusive offers, straight to your inbox.

Hyperse

Headless commerce solutions for brands, developers, and modern ecommerce teams.

Explore

  • Home
  • About Us
  • Partners
  • FAQs

Legal & resources

  • Proposal
  • Privacy Policy
  • Terms & Conditions

© 2026 Hyperse. All rights reserved.


  1. Home
  2. Vendure Plugins
  3. hps-plugin-cmdk
hps-plugin-cmdk

hps-plugin-cmdk

By Yingchun Tian

hps-plugin-cmdk is a Cmdk plugin in the Hub Search group.hps-plugin-cmdk provides Cmdk plugin capabilities for Hub Search. Search infrastructure, indexing, and discovery experiences. It is especially useful for search workflows.

CoreVendure Plugins

Specifications

Technical details and package information for this product.

Package

@hyperse-hub/hps-plugin-cmdk

Support by

Yingchun Tian

Support languages

TypeScript, JavaScript, Prolog, Shell, CSS

Integration type

Core

Category

Vendure Plugins

Compatible with

^3.0.0

Latest version

1.0.11

Downloads

0

Repository

https://github.com/hyperse-hub/hub-search

Last published

July 14, 2026

Description
Changelog
loading...

@hyperse-hub/hps-plugin-cmdk

Vendure plugin that feeds admin command-palette (cmdk) data through a single Shop API query. The list is built from pluggable search strategies, cached per channel and language, and refreshed on a schedule or on demand.

Intent

  • Give the storefront (or any Shop API client) a stable, typed cmdkActions query for the admin UI’s command palette: grouped sections (e.g. catalog, products) with paths, titles, subtitles, keywords, and optional icons.
  • Let projects extend what appears in cmdk without changing core plugin code: register CmdkSearchStrategy implementations that return rows for their section.
  • Avoid recomputing on every request by caching aggregated results; invalidate only when a scheduled job or an admin mutation runs.

Design

Strategy aggregation

  • HpsPluginCmdkOptions.cmdkSearchStrategies is an array of CmdkSearchStrategy instances.
  • Each strategy has a section label, optional priority (lower runs first), init(injector) for Vendure services, and getActions(ctx, channelId, languageCode).
  • aggregateCmdkActions sorts by priority, runs each strategy, and merges into [{ section, actions }], matching the GraphQL CmdkAction shape.
  • Use mergeCmdkSearchStrategies(...) to compose defaults with custom strategies. Reference catalog + product strategies are not exported from the package; copy them from the Examples section below (or from src/examples in this repo).

Caching and refresh

  • CmdkService caches the aggregated list per (channelId, languageCode) with no TTL; invalidation is explicit.
  • Scheduled task (refreshCmdkActionsTask): daily at 00:00, enqueues a refresh job for every channel × availableLanguageCodes.
  • Admin mutation refreshCmdkActions(channelId, languageCode?): enqueues a background job for one channel (language defaults to the caller’s context).
  • Refresh jobs rebuild an admin RequestContext scoped to the channel (by id), clear the cache key, and repopulate.

Bootstrap

  • HpsPluginCmdk.init() merges options; on application bootstrap, each strategy’s init() runs with a Vendure Injector.

GraphQL

Shop

  • Query.cmdkActions — [CmdkAction!]! for the current channel and language (from request context).

Admin

  • Mutation.refreshCmdkActions(channelId: ID!, languageCode: String) — queues a cache rebuild; returns true when the job is accepted (not when work finishes).

Installation

yarn add @hyperse-hub/hps-plugin-cmdk

Peer dependencies: @vendure/core (and Nest/GraphQL stack as in your Vendure app). See package.json for exact ranges.

Usage

Import what the package exports (HpsPluginCmdk, mergeCmdkSearchStrategies, AbstractCmdkSearchStrategy, etc.) and pass your own strategy instances. Wire in the reference examples by copying the files into your codebase (they are not published from @hyperse-hub/hps-plugin-cmdk).

import { HpsPluginCmdk, mergeCmdkSearchStrategies, } from '@hyperse-hub/hps-plugin-cmdk'; import { exampleCmdkSearchStrategies } from './cmdk/example-cmdk-search-strategies.js'; // plugins array HpsPluginCmdk.init({ cmdkSearchStrategies: exampleCmdkSearchStrategies(), // or mergeCmdkSearchStrategies(exampleCmdkSearchStrategies(), new MyCmdkStrategy()), });

Implement CmdkSearchStrategy or extend AbstractCmdkSearchStrategy for custom sections. For multi-channel shops, align ctx with channelId/languageCode in getActions so cached data matches the refresh path.

Examples

The snippets below mirror src/examples in this repository. They depend on optional Hyperse plugins (@hyperse-hub/hps-plugin-storage, @hyperse-hub/hps-plugin-smart-search, etc.); adjust services to match your stack.

cmdk-search-catalog.example.ts

import { AssetHydrateService } from '@hyperse-hub/hps-plugin-storage'; import type { Collection, ID } from '@vendure/core'; import { CollectionService, type RequestContext } from '@vendure/core'; import type { CmdkSectionActions } from '@hyperse-hub/hps-plugin-cmdk'; import { AbstractCmdkSearchStrategy } from '@hyperse-hub/hps-plugin-cmdk'; /** * Example: collections as cmdk actions (paths under `/category/:slug`). * Requires `@hyperse-hub/glass-plugin-helpers` when used. */ export class ExampleCmdkSearchCatalog extends AbstractCmdkSearchStrategy { readonly section = 'category'; readonly priority = 10; /** Uses `ctx` only; safe when shop/refresh context already matches the target channel. */ getActions( ctx: RequestContext, _channelId: ID, _languageCode: string ): Promise<CmdkSectionActions[]> { return this.constructActions(ctx); } private async constructActions( ctx: RequestContext ): Promise<CmdkSectionActions[]> { const collectionService = this.injector.get(CollectionService); const assetHydrateService = this.injector.get(AssetHydrateService); const catalogItems: Collection[] = []; while (true) { const { items } = await collectionService.findAll(ctx, { skip: catalogItems.length, take: 1000, }); if (items.length === 0) { break; } catalogItems.push(...items); } const result: CmdkSectionActions[] = []; for (const item of catalogItems) { if (item.featuredAsset) { await assetHydrateService.hydrateAsset(ctx, item.featuredAsset); } const metaTags = item.customFields?.['metaTags']; result.push({ path: `/category/${item.slug}`, title: item.name, subTitle: item.description, keywords: !metaTags ? [] : Array.isArray(metaTags) ? metaTags : [metaTags], icon: item.featuredAsset?.preview, }); } return result; } }

cmdk-search-product.example.ts

import { FulltextSearchService } from '@hyperse-hub/hps-plugin-smart-search'; import { AssetHydrateService } from '@hyperse-hub/hps-plugin-storage'; import type { Asset, ID, RequestContext } from '@vendure/core'; import type { CmdkSectionActions } from '@hyperse-hub/hps-plugin-cmdk'; import { AbstractCmdkSearchStrategy } from '@hyperse-hub/hps-plugin-cmdk'; /** * Example: product variants from fulltext search as cmdk actions (`/product/:slug`). * Requires `@hyperse-hub/hps-plugin-smart-search` and `@hyperse-hub/glass-plugin-helpers`. */ export class ExampleCmdkSearchProduct extends AbstractCmdkSearchStrategy { readonly section = 'products'; readonly priority = 20; /** Uses `ctx` only; safe when shop/refresh context already matches the target channel. */ getActions( ctx: RequestContext, _channelId: ID, _languageCode: string ): Promise<CmdkSectionActions[]> { return this.constructActions(ctx); } private async constructActions( ctx: RequestContext ): Promise<CmdkSectionActions[]> { const searchService = this.injector.get(FulltextSearchService); const assetHydrateService = this.injector.get(AssetHydrateService); const { items } = await searchService.search( ctx, { groupByProduct: false, take: 100000, }, true ); const result: CmdkSectionActions[] = []; for (const item of items) { if (item.productAsset) { await assetHydrateService.hydrateAsset(ctx, item.productAsset as Asset); } result.push({ path: `/product/${item.slug}`, title: item.sku, subTitle: item.productName, icon: item.productAsset?.preview, keywords: [], }); } return result; } }

example-cmdk-search-strategies.ts

import type { CmdkSearchStrategy } from '@hyperse-hub/hps-plugin-cmdk'; import { ExampleCmdkSearchCatalog } from './cmdk-search-catalog.example.js'; import { ExampleCmdkSearchProduct } from './cmdk-search-product.example.js'; /** * Reference implementation: catalog + product sections. Pass to `HpsPluginCmdk.init` * as `cmdkSearchStrategies: exampleCmdkSearchStrategies()` when you want this behavior. */ export function exampleCmdkSearchStrategies(): CmdkSearchStrategy[] { return [new ExampleCmdkSearchCatalog(), new ExampleCmdkSearchProduct()]; }

Compatibility

  • Vendure plugin compatibility: >=3.0.0
  • Node: >=20.0.0

License

GPL-3.0-only — see package.json.

On this page

  • @hyperse-hub/hps-plugin-cmdk
    • Intent
    • Design
      • Strategy aggregation
      • Caching and refresh
      • Bootstrap
    • GraphQL
    • Installation
    • Usage
    • Examples
      • cmdk-search-catalog.example.ts
      • cmdk-search-product.example.ts
      • example-cmdk-search-strategies.ts
    • Compatibility
    • License