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-core
hps-plugin-core

hps-plugin-core

By Hyperse

hps-plugin-core is a Core plugin in the Hub Core group.hps-plugin-core provides Core plugin capabilities for Hub Core. Core platform infrastructure and extension runtime. It is especially useful for core workflows.

CoreVendure Plugins

Specifications

Technical details and package information for this product.

Package

@hyperse-hub/hps-plugin-core

Support by

Hyperse

Support languages

TypeScript, JavaScript, HTML, CSS, Prolog, Shell

Integration type

Core

Category

Vendure Plugins

Compatible with

^3.0.0

Latest version

1.1.6

Downloads

0

Repository

ssh://git@github.com/hyperse-hub/hub-core

Last published

July 14, 2026

Description
Changelog
loading...

@hyperse-hub/hps-plugin-core

Vendure plugin providing shared core capabilities for Hyperse Hub plugins, including:

  • reCAPTCHA v3 verification helper
  • Facet/FacetValue helpers with caching
  • Next.js SSG cache revalidation helper (Admin API)
  • Admin helper to query customer session token (SuperAdmin)
  • i18n translation resource registration
  • Exchange rates (OpenExchangeRates.org), persisted in Vendure Settings Store, daily scheduled sync, and Admin mutation to refresh manually

Install

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

Usage

Register the plugin in your Vendure config:

import { HpsPluginCore } from '@hyperse-hub/hps-plugin-core'; export const config = { plugins: [ HpsPluginCore.init({ devMode: process.env.NODE_ENV !== 'production', reCaptchaV3SecretKey: process.env.RECAPTCHA_V3_SECRET_KEY ?? '', exchangeRateOptions: { exchangeRateAppId: process.env.OPENEXCHANGERATES_APP_ID ?? '', }, ttlCache: { variantFacets: 5 * 60 * 1000, }, nextCacheOptions: { nextFrontEndPoint: process.env.NEXT_FRONTEND_ENDPOINT ?? 'https://www.hyperse.net', nextCleanSSGCacheToken: process.env.NEXT_REVALIDATE_TOKEN ?? '', }, cacheType: 'memory', cacheOptions: { cacheSize: 10_000, namespace: 'hyperse', }, }), ], };

Configuration

HpsPluginCore.init() accepts (see PluginInitOptions in src/types.ts):

OptionDescription
devModeWhen true: reCAPTCHA verification is skipped (mock success); scheduled exchange rate sync is skipped. Manual Admin refreshExchangeRate still runs.
reCaptchaV3SecretKeyServer-side secret for reCAPTCHA v3.
exchangeRateOptions.exchangeRateAppIdOpenExchangeRates App ID. Required for fetching rates; leave empty only if you do not use exchange features.
ttlCache.variantFacetsCache TTL (ms) for variant facet values lookup.
nextCacheOptionsBase URL and token for Next.js POST /api/revalidate.
cacheType'memory' | 'redis' | 'sql'. When or , the plugin registers the matching Vendure cache plugin.

Settings Store registration

The plugin merges into VendureConfig.settingsStoreFields a global, read-only (for GraphQL) field:

  • Namespace: hpsCore
  • Field: currencyExchangeRates
  • Full key: hpsCore.currencyExchangeRates (also exported as SETTINGS_STORE_CURRENCY_EXCHANGE_RATES_KEY)

Programmatic updates use SettingsStoreService.set() (for example inside ExchangeRatesService); the Admin Settings Store UI treats the field as read-only.

If your app already defines settingsStoreFields.hpsCore, this plugin merges its field and avoids duplicating currencyExchangeRates.

Scheduler

On load, the plugin pushes a scheduled task into config.schedulerOptions.tasks:

PropertyValue
idrefresh-exchange-rate-task
scheduleDaily at 00:00 (server timezone)
behaviorCalls ExchangeRatesService.syncSiteCurrencyRate with non-forced sync, so devMode: true skips the job.

Vendure’s scheduler can run duplicate work on multiple server instances; see vendure#1425 if you need stronger single-flight behavior.

What this plugin provides

GraphQL extensions

Both Admin API and Shop API are extended with:

  • RecaptchaInput: token: String!, action: String

This package only provides the shared input type; actual usage depends on downstream resolvers/mutations.

Admin API is additionally extended with:

  • Query: queryCustomerSessionToken(email: String, customerId: ID): String
    • Requires Permission.SuperAdmin
    • Returns the user session token (if any) for the given customer
  • Mutation: revalidateSlug(slug: String!): Boolean!
    • Requires Permission.UpdateCatalog
    • Calls the Next.js revalidation endpoint configured via nextCacheOptions
  • Mutation: refreshExchangeRate: Boolean!
    • Requires Permission.UpdateCatalog
    • Fetches latest rates from OpenExchangeRates and writes the payload to Settings Store (hpsCore.currencyExchangeRates)
    • Uses a forced sync path, so it still runs when devMode is true (useful for local testing)

Exchange rates

  • Source: OpenExchangeRates.org latest.json (USD-based by default).
  • Persistence: JSON payload stored under hpsCore.currencyExchangeRates via Vendure SettingsStoreService.
  • In-memory cache: Responses are cached through Vendure CacheService (TTL ~12h per plugin setup) to limit API calls.
  • Legacy: Older deployments may have stored the same data on the Setting entity with key currency_exchange_rates; that is not read by this plugin. Migrate the value into Settings Store if you still rely on historical rows.

ExchangeRatesService (DI):

  • syncSiteCurrencyRate(ctx, forceUpdate?): fetch and persist. When forceUpdate is false and devMode is true, returns early without calling the API.
  • getCurrentExchangeRates(ctx): returns ExchangeRateApiResult (typed in src/types.ts). Prefers the Settings Store snapshot from the last successful sync (hpsCore.currencyExchangeRates); if none is stored or the payload is invalid, falls back to getLatestRates() (OpenExchange + in-memory cache).
  • getLatestRates(base?, refresh?): returns ExchangeRateApiResult from OpenExchangeRates only (USD base by default). Uses the plugin HTTP cache unless is .

Public constant SETTINGS_STORE_CURRENCY_EXCHANGE_RATES_KEY is re-exported from the package entry for custom tooling or direct reads via SettingsStoreService.get().

Services

All services are available via Nest/Vendure DI when the plugin is installed.

GoogleRecaptchaService

  • verify(token: string, secretKey?: string): verifies a client token via Google reCAPTCHA v3.
    • Uses secretKey parameter if provided, otherwise reCaptchaV3SecretKey from plugin options.
    • When devMode: true, it returns a successful mock response (and logs a debug message).
    • Uses a request timeout (10s).

CacheRevalidateService

  • revalidateNextCache(ctx, issueSlug, includeAllSites?): calls Next.js POST /api/revalidate
    • Sends x-next-purge-token header using nextCleanSSGCacheToken
    • When failing and devMode: false, it logs a structured HTTP error summary
    • Uses a request timeout (10s)

FacetValueHelpService

Helpers around product/variant facet values:

  • productVariantFacetValues(ctx, productVariantId): returns merged facet values (product + variant) with caching (channel-aware cache key).
  • refreshedProductVariantFacetValues(ctx, productVariantId): same but without cache.
  • orderLineHasFacetValues(ctx, orderLine, facetValueIds): checks if order line contains all facet values.
  • orderLineAgainstAnyOfFacetValues(ctx, orderLine, facetValueIds): checks if order line contains any facet value; empty list returns false.
  • orderLineContainAnyOfFacetValues(ctx, orderLine, facetValueIds): checks if order line contains any facet value; empty list returns true.
    • Facet relation hydration is done in a single batched query (avoids N+1).

i18n resources

I18nTranslationService is used on bootstrap to register i18nResources (currently en and zh).

Development

From repo root:

yarn workspace @hyperse-hub/hps-plugin-core build yarn workspace @hyperse-hub/hps-plugin-core test yarn workspace @hyperse-hub/hps-plugin-core lint

On this page

  • @hyperse-hub/hps-plugin-core
    • Install
    • Usage
    • Configuration
      • Settings Store registration
      • Scheduler
    • What this plugin provides
      • GraphQL extensions
      • Exchange rates
      • Services
        • GoogleRecaptchaService
        • CacheRevalidateService
        • FacetValueHelpService
      • i18n resources
    • Development

'redis'
'sql'
cacheOptionsPassed to Vendure cache plugin init (shape depends on cacheType).
refresh
true
  • exchangeCurrencyTo(amount, targetCode, currencyCode?): formats a converted price using getLatestRates() (not the Settings Store snapshot) and built-in symbol metadata for common CurrencyCodes.