| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { Permission, SettingsStoreScopes, VendurePlugin } from '@vendure/core';
- /**
- * Test plugin that registers various settings store fields for testing different
- * scoping, validation, and permission scenarios.
- */
- @VendurePlugin({
- configuration: config => {
- config.settingsStoreFields = {
- ...config.settingsStoreFields,
- test: [
- {
- name: 'globalSetting',
- scope: SettingsStoreScopes.global,
- },
- {
- name: 'userSetting',
- scope: SettingsStoreScopes.user,
- },
- {
- name: 'channelSetting',
- scope: SettingsStoreScopes.channel,
- },
- {
- name: 'userAndChannelSetting',
- scope: SettingsStoreScopes.userAndChannel,
- },
- {
- name: 'readonlyField',
- scope: SettingsStoreScopes.global,
- readonly: true,
- },
- {
- name: 'validatedField',
- scope: SettingsStoreScopes.global,
- validate: value => {
- if (!['valid-option', 'another-option'].includes(value)) {
- return 'Value must be valid-option or another-option';
- }
- },
- },
- {
- name: 'complexData',
- scope: SettingsStoreScopes.global,
- },
- {
- name: 'bulk1',
- scope: SettingsStoreScopes.global,
- },
- {
- name: 'bulk2',
- scope: SettingsStoreScopes.global,
- },
- {
- name: 'adminOnlyField',
- scope: SettingsStoreScopes.global,
- requiresPermission: Permission.CreateAdministrator,
- },
- ],
- };
- return config;
- },
- })
- export class SettingsStoreTestPlugin {}
|