@hyperse-hub/hps-plugin-setting
A Vendure plugin that provides a translatable key/value settings store exposed via both Shop API (read-only, enabled-only) and Admin API (CRUD).
Install
yarn add @hyperse-hub/hps-plugin-setting
Usage
Register the plugin in your Vendure config:
import { HpsPluginSetting } from '@hyperse-hub/hps-plugin-setting';
plugins: [
HpsPluginSetting.init({
customSettings: [
{
key: 'currency_exchange_rates',
enabled: true,
translations: [
{ languageCode: 'en', value: { USD: 1, EUR: 0.92 } },
{ languageCode: 'zh', value: { USD: 1, EUR: 0.92 } },
],
},
],
}),
],
Plugin options
customSettings
An optional list of settings to seed/sync at application bootstrap:
- Upserted by
key (idempotent)
- Existing records will have
enabled and translations updated (translations are overwritten so code-defined defaults remain source of truth)
Type: CreateSettingInput[] (see Admin API schema).
GraphQL API
Shop API
Read-only access:
setting(id: ID, key: String): Setting
- requires
id or key
- returns
null when the setting is disabled
settings(options: SettingListOptions): SettingList!
- always enforces
enabled = true server-side
Admin API
CRUD access (requires catalog permissions):
settings(options: SettingListOptions): SettingList!
setting(id: ID!): Setting
createSetting(input: CreateSettingInput!): Setting!
updateSetting(input: UpdateSettingInput!): Setting!
deleteSetting(id: ID!): DeletionResponse!
Development
Run e2e tests
yarn workspace @hyperse-hub/hps-plugin-setting test-e2e
Run unit tests
yarn workspace @hyperse-hub/hps-plugin-setting test-unit
Local Development (please make sure to build plugin-admin first)