Introductionâ
Source plugins resolve host dictionary values through services.Dict(). Dynamic plugins declare service: dict in plugin.yaml and access it through the pluginbridge.Default().Dict() client. This capability is suitable for displaying business status codes, type codes, and enum values as labels in the current language, without requiring plugins to directly depend on host dictionary tables or cache implementations.
Capability Phase: Runtime
Supported Plugin Types: Source plugins, Dynamic plugins
Capability Designâ
Label View Modelâ
The Dict capability resolves host dictionary values into stable label views, supporting runtime translation keys and current-language labels:
| Field | Description |
|---|---|
Type | Dictionary type |
Value | Dictionary value |
LabelKey | Stable runtime translation key |
Label | Optional resolved label in the current language |
ResolveInput.IncludeLabel controls whether Label is resolved. When only stable keys are needed or localization will be handled later, label text can be omitted.
Resolution Flowâ
Usage Boundariesâ
- Only one dictionary type per resolution. A single
ResolveInputresolves multipleValues for oneType. - Refresh is a management command. Dictionary refresh may affect host cache and multi-plugin display results, and is only exposed through
Admin().Dict(). - Dictionaries are not configuration. Dictionary values are used for business enum display. Plugin runtime parameters should use the configuration management capability.
- Dictionaries are not internationalization catalogs.
LabelKeycan be passed to the runtime translation capability for resolution, but the dictionary capability itself does not maintain language packs.
Interface Definitionsâ
Source Plugin Interfaceâ
| Entry | Method | Description |
|---|---|---|
Dict() | ResolveLabels | Batch resolves multiple values under one dictionary type, returning label views and a missing set that does not reveal specific reasons |
Admin().Dict() | Refresh | Refreshes the view or cache for a specific dictionary type |
Dynamic Plugin Interfaceâ
Dynamic plugins declare authorized methods through hostServices.dict:
| Dynamic Method | Description |
|---|---|
labels.resolve | Batch resolves multiple values under one dictionary type, returning label views |
Usageâ
Source Plugin Usageâ
Source plugins resolve dictionary values through services.Dict():
// Batch resolve dictionary value labels
result, err := services.Dict().ResolveLabels(ctx, capabilityCtx, dictcap.ResolveInput{
Type: "order_status",
Values: []dictcap.Value{"pending", "processing", "completed"},
IncludeLabel: true,
})
// Use label views
for _, proj := range result.Projections {
fmt.Printf("%s -> %s\n", proj.Value, proj.Label)
}
Trusted source plugin refreshing a dictionary view:
err := services.Admin().Dict().Refresh(ctx, capabilityCtx, "order_status")
Dynamic Plugin Usageâ
Dynamic plugins declare the dict service in plugin.yaml:
hostServices:
- service: dict
methods:
- labels.resolve
Dynamic plugins call through the pluginbridge.Default().Dict() client:
dictSvc := pluginbridge.Default().Dict()
// Batch resolve dictionary value labels
result, err := dictSvc.ResolveLabels(ctx, capabilityCtx, dictcap.ResolveInput{
Type: "order_status",
Values: []dictcap.Value{"pending", "processing", "completed"},
IncludeLabel: true,
})
Design Constraintsâ
- No dictionary table structure exposed. Plugins can only see
Type,Value, and label views. - Missing results do not reveal specific reasons. Missing values are returned without distinguishing between non-existent, invisible, or rejected.
- Refresh requires audit context. Trusted source plugins should provide caller source, operator, tenant, and reason when invoking the refresh command.
- Dynamic plugins are read-only. Dynamic plugins declare the
labels.resolvemethod throughhostServices.dictand only read label views, without involving dictionary refresh.