Demo

DeveloperConfigService

System-level developer/admin configuration keyed by pluginName + key. Public and private configs are separate APIs; there is no generic get(pluginName, key) helper.

Inject

TSXinject
1import { 2 ContainerRegistryManager, 3 DeveloperConfigService, 4 Inject, 5 Service, 6} from "@quan-erp/shared-backend-core"; 7 8@Service() 9export class MyPluginService { 10 @Inject(DeveloperConfigService, ContainerRegistryManager.BUILTIN_PLUGIN) 11 private developerConfigService: DeveloperConfigService; 12}

Write / remove

set upserts by conflict on (key, pluginName). Use private: true for secrets; encrypt: true stores an encrypted payload.

  • set(props: CreateServiceProps<DeveloperConfigDto | DeveloperConfigDto[]>) — upsert one or many configs (key, value, pluginName, datatype required; displayName, description, private, encrypt optional)
  • remove(key: string, pluginName: string) — delete that config row and invalidate cache
  • authorizeDeveloper(password: string): Promise<boolean> — checks against the builtin developer-config password (returns true if no password is set yet)
TSXset
1import { 2 ContainerRegistryManager, 3 DeveloperConfigService, 4 Inject, 5 Service, 6} from "@quan-erp/shared-backend-core"; 7import metadata from "../../module.metadata.json" with { type: "json" }; 8 9@Service() 10export class PluginDevConfigService { 11 @Inject(DeveloperConfigService, ContainerRegistryManager.BUILTIN_PLUGIN) 12 private developerConfigService: DeveloperConfigService; 13 14 async enableFeatureFlag() { 15 await this.developerConfigService.set({ 16 data: { 17 key: "feature.newCheckout", 18 value: true, 19 pluginName: metadata.name, 20 datatype: "boolean", 21 displayName: "New checkout", 22 private: false, 23 }, 24 }); 25 } 26}

Read methods

  • getPublicConfigByKeyAndPlugin(pluginName, key, option?) — public (private=false) config; option may include manager / lock for transactions
  • getPrivateConfig(pluginName, key, option?) — private config; option.decrypt?: boolean when the value was stored with encrypt
  • getAllPublicConfigs(skip, limit) — paginated public configs ordered by displayName
TSXread
1import { 2 ContainerRegistryManager, 3 DeveloperConfigService, 4 Inject, 5 Service, 6} from "@quan-erp/shared-backend-core"; 7import metadata from "../../module.metadata.json" with { type: "json" }; 8 9@Service() 10export class PluginDevConfigService { 11 @Inject(DeveloperConfigService, ContainerRegistryManager.BUILTIN_PLUGIN) 12 private developerConfigService: DeveloperConfigService; 13 14 async isNewCheckoutEnabled() { 15 const row = await this.developerConfigService.getPublicConfigByKeyAndPlugin( 16 metadata.name, 17 "feature.newCheckout" 18 ); 19 return Boolean(row?.value); 20 } 21 22 async apiSecret() { 23 return this.developerConfigService.getPrivateConfig( 24 metadata.name, 25 "integrations.apiSecret", 26 { decrypt: true } 27 ); 28 } 29}