moonconfigkit

MoonConfigKit is a MoonBit-native INI/properties configuration merge, validation, diagnostics, and reporting toolkit.

ini
properties
configuration
validation
moonbit
moon add crh12354/moonconfigkit@0.1.0
Download zip
Author
Version
0.1.0
License
Apache-2.0
Last updated
yesterday
Downloads
2
README

#crh12354/moonconfigkit

#
AuditPolicy

pub struct AuditPolicy {
name : String
rules : Array[Rule]
expected_keys : Array[String]
forbidden_keys : Array[String]
sensitive_keys : Array[String]
} derive(Eq,
Debug
)
A named audit policy for a class of deployments.

#
AuditSummary

pub struct AuditSummary {
policy_name : String
key_count : Int
error_count : Int
warning_count : Int
info_count : Int
score : Int
diagnostics : Array[Diagnostic]
} derive(Eq,
Debug
)
A compact health summary for a configuration view.

#
ConfigDocument

pub struct ConfigDocument {
name : String
entries : Array[ConfigEntry]
diagnostics : Array[Diagnostic]
} derive(Eq,
Debug
)
A full configuration document plus non-fatal diagnostics.

#
ConfigDocument::apply_edits

fn ConfigDocument::apply_edits(self : ConfigDocument, edits : Array[DocumentEdit]) -> ConfigDocument
Applies a sequence of document edits.

#
ConfigDocument::duplicate_paths

fn ConfigDocument::duplicate_paths(self : ConfigDocument) -> Array[String]
Returns all duplicate paths in a document.

#
ConfigDocument::find_key_prefix

fn ConfigDocument::find_key_prefix(self : ConfigDocument, prefix : String) -> Array[ConfigEntry]
Returns entries whose key names match a prefix.

#
ConfigDocument::get_path

fn ConfigDocument::get_path(self : ConfigDocument, path : String) -> String?
Finds the last entry matching a path.

#
ConfigDocument::key_style_diagnostics

fn ConfigDocument::key_style_diagnostics(self : ConfigDocument) -> Array[Diagnostic]
Returns a warning for keys that do not follow lowercase dot/underscore style.

#
ConfigDocument::rename_path

fn ConfigDocument::rename_path(self : ConfigDocument, old_path : String, new_path : String) -> ConfigDocument
Renames an entry path while preserving value and source metadata.

#
ConfigDocument::render_document_ini

fn ConfigDocument::render_document_ini(self : ConfigDocument) -> String
Renders a document directly as INI, preserving the current entry order.

#
ConfigDocument::section_entries

fn ConfigDocument::section_entries(self : ConfigDocument, section : String) -> Array[ConfigEntry]
Returns entries from one section.

#
ConfigDocument::sections

fn ConfigDocument::sections(self : ConfigDocument) -> Array[String]
Returns all section names in declaration order.

#
ConfigDocument::subdocument

fn ConfigDocument::subdocument(self : ConfigDocument, section : String) -> ConfigDocument
Extracts a document containing only keys below a section.

#
ConfigDocument::with_value

fn ConfigDocument::with_value(self : ConfigDocument, path : String, value : String) -> ConfigDocument
Creates a new document with an edited value.

#
ConfigDocument::without_path

fn ConfigDocument::without_path(self : ConfigDocument, path : String) -> ConfigDocument
Creates a new document without a path.

#
ConfigEntry

pub struct ConfigEntry {
section : String
key : String
value : String
source : String
span : Span
comments : Array[String]
} derive(Eq,
Debug
)
One parsed key/value assignment.

#
ConfigEntry::path

fn ConfigEntry::path(self : ConfigEntry) -> String
Returns the canonical path for an entry.

#
ConfigLayer

pub struct ConfigLayer {
name : String
priority : Int
document : ConfigDocument
} derive(Eq,
Debug
)
A named configuration layer, usually base/dev/prod/local/secret.

#
ConfigSchema

pub struct ConfigSchema {
name : String
version : String
sections : Array[SchemaSection]
} derive(Eq,
Debug
)
A complete configuration contract.

#
ConfigSchema::find_field

fn ConfigSchema::find_field(self : ConfigSchema, path : String) -> SchemaField?
Finds schema metadata for one path.

#
ConfigSchema::paths

fn ConfigSchema::paths(self : ConfigSchema) -> Array[String]
Returns all known field paths in declaration order.

#
ConfigSchema::render_markdown

fn ConfigSchema::render_markdown(self : ConfigSchema) -> String
Produces a Markdown contract table.

#
ConfigSchema::rules

fn ConfigSchema::rules(self : ConfigSchema) -> Array[Rule]
Converts schema fields into validation rules.

#
ConfigSchema::unknown_key_diagnostics

fn ConfigSchema::unknown_key_diagnostics(self : ConfigSchema, view : ConfigView) -> Array[Diagnostic]
Reports values present in the config but unknown to the schema.

#
ConfigSchema::validate

fn ConfigSchema::validate(self : ConfigSchema, view : ConfigView) -> Array[Diagnostic]
Validates a merged view against a schema.

#
ConfigView

pub struct ConfigView {
values : Array[ResolvedValue]
diagnostics : Array[Diagnostic]
} derive(Eq,
Debug
)
A merged configuration view with traceable values.

#
ConfigView::get

fn ConfigView::get(self : ConfigView, section : String, key : String) -> String?
Finds a raw resolved value by section and key.

#
ConfigView::get_bool

fn ConfigView::get_bool(self : ConfigView, path : String) -> Bool?
Reads a boolean value using common configuration spellings.

#
ConfigView::get_int

fn ConfigView::get_int(self : ConfigView, path : String) -> Int?
Reads an integer value.

#
ConfigView::get_list

fn ConfigView::get_list(self : ConfigView, path : String) -> Array[String]?
Reads a comma-separated list.

#
ConfigView::get_path

fn ConfigView::get_path(self : ConfigView, path : String) -> String?
Finds a raw resolved value by dotted path.

#
Diagnostic

pub struct Diagnostic {
severity : Severity
code : String
message : String
span : Span?
hint : String?
} derive(Eq,
Debug
)
A user-facing parser, merge, or validation message.

#
DiffItem

pub struct DiffItem {
path : String
before : String?
after : String?
kind : String
} derive(Eq,
Debug
)
A value-level change between two merged views.

#
DocumentEdit

pub enum DocumentEdit {
SetValue(String, String)
RemoveValue(String)
RenameValue(String, String)
} derive(Eq,
Debug
)
A simple editable operation over a parsed document.

#
FormatOptions

pub struct FormatOptions {
redact_secrets : Bool
include_source_comments : Bool
blank_line_between_sections : Bool
quote_values : Bool
} derive(Eq,
Debug
)
Formatting options for INI and properties output.

#
MigrationAction

pub struct MigrationAction {
old_path : String
new_path : String
value : String
source_layer : String
reason : String
} derive(Eq,
Debug
)
A concrete migration action derived from a view.

#
ParseOptions

pub struct ParseOptions {
allow_colon_separator : Bool
allow_empty_value : Bool
preserve_comments : Bool
strict_sections : Bool
} derive(Eq,
Debug
)
Options shared by the INI and properties parsers.

#
ParseResult

pub struct ParseResult {
document : ConfigDocument
ok : Bool
} derive(Eq,
Debug
)
The result of a parser operation.

#
Placeholder

pub struct Placeholder {
path : String
name : String
raw : String
} derive(Eq,
Debug
)
A variable placeholder found in a config value, such as ${DATABASE_URL}.

#
PlaceholderValue

pub struct PlaceholderValue {
name : String
value : String
} derive(Eq,
Debug
)
A resolved placeholder value supplied by a caller.

#
Profile

pub struct Profile {
name : String
view : ConfigView
schema : ConfigSchema?
policy : AuditPolicy?
} derive(Eq,
Debug
)
A named environment profile.

#
ProfileSummary

pub struct ProfileSummary {
name : String
key_count : Int
missing_required : Int
audit_score : Int?
sensitive_count : Int
} derive(Eq,
Debug
)
Summary row for comparing profiles.

#
RenameRule

pub struct RenameRule {
old_path : String
new_path : String
reason : String
} derive(Eq,
Debug
)
A suggested configuration key migration.

#
ResolvedValue

pub struct ResolvedValue {
section : String
key : String
value : String
source_layer : String
source : String
span : Span
overwritten_by : Array[String]
} derive(Eq,
Debug
)
One effective value after layered merging.

#
Rule

pub enum Rule {
Required(String)
EnumValue(String, Array[String])
IntRange(String, Int?, Int?)
Deprecated(String, String)
Requires(String, String)
Conflicts(String, String)
SecretLike(String)
} derive(Eq,
Debug
)
A validation rule for one configuration path.

#
SchemaField

pub struct SchemaField {
path : String
kind : String
required : Bool
default_value : String?
description : String
rules : Array[Rule]
} derive(Eq,
Debug
)
Describes a typed configuration key.

#
SchemaSection

pub struct SchemaSection {
name : String
description : String
fields : Array[SchemaField]
} derive(Eq,
Debug
)
A named group of related fields.

#
SectionStats

pub struct SectionStats {
section : String
key_count : Int
sensitive_count : Int
} derive(Eq,
Debug
)
Counts keys by section in a merged view.

#
Severity

pub enum Severity {
Error
Warning
Info
} derive(Eq,
Debug
)
Severity used by diagnostics and validation reports.

#
Span

pub struct Span {
file : String
line : Int
column : Int
} derive(Eq,
Debug
)
Source location attached to parsed configuration items and diagnostics.

#
ValueTrace

pub struct ValueTrace {
path : String
final_layer : String
final_source : String
override_count : Int
sensitive : Bool
} derive(Eq,
Debug
)
Describes how one final value was produced.

#
ViewStats

pub struct ViewStats {
key_count : Int
section_count : Int
sensitive_count : Int
overridden_count : Int
diagnostics_count : Int
} derive(Eq,
Debug
)
Aggregate view statistics.

#
analyze_view

fn analyze_view(view : ConfigView) -> ViewStats

#
audit

fn audit(view : ConfigView, policy : AuditPolicy) -> AuditSummary
Runs a policy and computes a coarse 0-100 health score.

#
audit_policy

fn audit_policy(name : String, rules : Array[Rule], expected_keys? : Array[String], forbidden_keys? : Array[String], sensitive_keys? : Array[String]) -> AuditPolicy

#
ci_fixture_policy

fn ci_fixture_policy() -> AuditPolicy
A policy for CI test fixture configs.

#
cli_tool_schema

fn cli_tool_schema() -> ConfigSchema
A reusable schema for CLI tools.

#
common_service_rename_rules

fn common_service_rename_rules() -> Array[RenameRule]
Common migration rules for older service configs.

#
conflicts

fn conflicts(path : String, other_path : String) -> Rule

#
default_format_options

fn default_format_options() -> FormatOptions

#
default_parse_options

fn default_parse_options() -> ParseOptions
Default parser options for tolerant configuration files.

#
deployment_ready

fn deployment_ready(profile : Profile) -> Bool
Checks whether a production profile is ready enough for deployment.

#
deprecated

fn deprecated(path : String, replacement : String) -> Rule

#
development_service_policy

fn development_service_policy() -> AuditPolicy
A relaxed policy for local development.

#
diagnostics_ok

fn diagnostics_ok(diagnostics : Array[Diagnostic]) -> Bool
Returns true when the diagnostic list has no errors.

#
diff_views

fn diff_views(before : ConfigView, after : ConfigView) -> Array[DiffItem]
Computes added, removed, and changed keys between two views.

#
empty_document

fn empty_document(name : String) -> ConfigDocument
Builds an empty document with a stable name.

#
entry_path

fn entry_path(section : String, key : String) -> String
Creates a normalized path-like key using section and key parts.

#
enum_value

fn enum_value(path : String, allowed : Array[String]) -> Rule

#
error

fn error(code : String, message : String, span? : Span?, hint? : String?) -> Diagnostic
Creates an error diagnostic.

#
error_count

fn error_count(diagnostics : Array[Diagnostic]) -> Int
Returns the number of error diagnostics.

#
escape_properties_key

fn escape_properties_key(key : String) -> String
Escapes a properties key.

#
expand_placeholders

fn expand_placeholders(value : String, supplied : Array[PlaceholderValue]) -> String
Replaces placeholders in a value.

#
field

fn field(path : String, kind : String, required? : Bool, default_value? : String?, description? : String, rules? : Array[Rule]) -> SchemaField

#
find_placeholders

fn find_placeholders(view : ConfigView) -> Array[Placeholder]
Finds ${NAME} placeholders in all effective values.

#
has_errors

fn has_errors(diagnostics : Array[Diagnostic]) -> Bool
Returns true if any diagnostic is an error.

#
info

fn info(code : String, message : String, span? : Span?, hint? : String?) -> Diagnostic
Creates an informational diagnostic.

#
int_range

fn int_range(path : String, min : Int?, max : Int?) -> Rule

#
is_sensitive_path

fn is_sensitive_path(path : String) -> Bool
Returns true for common secret-bearing key names.

#
layer

fn layer(name : String, priority : Int, document : ConfigDocument) -> ConfigLayer
Creates a layer with an explicit priority. Higher priority wins.

#
merge_layers

fn merge_layers(layers : Array[ConfigLayer]) -> ConfigView
Merges layers in priority order and keeps the final source for every key.

#
missing_schema_fields

fn missing_schema_fields(schema : ConfigSchema, view : ConfigView) -> Array[String]

#
overridden_values

fn overridden_values(view : ConfigView) -> Array[ResolvedValue]

#
parse_ini

fn parse_ini(name : String, text : String) -> ParseResult
Parses INI text using default tolerant options.

#
parse_ini_with_options

fn parse_ini_with_options(name : String, text : String, options : ParseOptions) -> ParseResult
Parses INI text with explicit options.

#
parse_options

fn parse_options(allow_colon_separator? : Bool, allow_empty_value? : Bool, preserve_comments? : Bool, strict_sections? : Bool) -> ParseOptions
Creates parser options for callers that need strict or custom behavior.

#
parse_properties

fn parse_properties(name : String, text : String) -> ParseResult
Parses Java-style properties text using defaults close to INI mode.

#
parse_properties_with_options

fn parse_properties_with_options(name : String, text : String, options : ParseOptions) -> ParseResult
Parses properties text with explicit options.

#
placeholder_value

fn placeholder_value(name : String, value : String) -> PlaceholderValue

#
plan_renames

fn plan_renames(view : ConfigView, rules : Array[RenameRule]) -> Array[MigrationAction]
Builds migration actions for rename rules that match existing keys.

#
production_service_policy

fn production_service_policy() -> AuditPolicy
A strict policy suitable for production services.

#
profile

fn profile(name : String, view : ConfigView, schema? : ConfigSchema?, policy? : AuditPolicy?) -> Profile

#
profile_gap_report

fn profile_gap_report(schema : ConfigSchema, profiles : Array[(String, ConfigView)]) -> Array[Diagnostic]
Compares required schema keys across multiple profiles.

#
profile_presence_matrix

fn profile_presence_matrix(profiles : Array[(String, ConfigView)]) -> String
Finds keys that are only present in some profiles.

#
profile_value_differences

fn profile_value_differences(profiles : Array[Profile]) -> Array[String]
Finds keys whose values differ across profiles.

#
redact_value

fn redact_value(path : String, value : String) -> String
Redacts a value when the path looks sensitive.

#
remove_value

fn remove_value(path : String) -> DocumentEdit

#
rename_rule

fn rename_rule(old_path : String, new_path : String, reason? : String) -> RenameRule

#
rename_value

fn rename_value(old_path : String, new_path : String) -> DocumentEdit

#
render_audit_summary

fn render_audit_summary(summary : AuditSummary) -> String
Renders the audit summary as Markdown.

#
render_defaults_preview

fn render_defaults_preview(schema : ConfigSchema, view : ConfigView) -> String
Returns a document preview with defaults from schema filled into missing keys.

#
render_deployment_check

fn render_deployment_check(profile : Profile) -> String

#
render_diff_markdown

fn render_diff_markdown(items : Array[DiffItem]) -> String
Renders changes as a Markdown table.

#
render_edit_patch

fn render_edit_patch(document : ConfigDocument, edits : Array[DocumentEdit]) -> String
Creates an INI patch from edits without mutating the original document.

#
render_expanded_properties

fn render_expanded_properties(view : ConfigView, supplied : Array[PlaceholderValue]) -> String
Renders properties with placeholders expanded.

#
render_ini

fn render_ini(view : ConfigView, options? : FormatOptions) -> String
Renders a merged view as INI text.

#
render_inventory

fn render_inventory(view : ConfigView) -> String
Produces a plain key inventory grouped by section.

#
render_json_like_report

fn render_json_like_report(view : ConfigView, diagnostics : Array[Diagnostic]) -> String
Renders a compact JSON-like report without depending on a JSON package.

#
render_markdown_report

fn render_markdown_report(view : ConfigView, validation_diagnostics : Array[Diagnostic]) -> String
Renders a Markdown report for humans and CI summaries.

#
render_migration_patch

fn render_migration_patch(actions : Array[MigrationAction]) -> String
Applies rename actions into a new properties-style patch.

#
render_migration_plan

fn render_migration_plan(actions : Array[MigrationAction]) -> String
Renders migration actions as a readable checklist.

#
render_placeholder_report

fn render_placeholder_report(view : ConfigView, supplied : Array[PlaceholderValue]) -> String
Produces a placeholder inventory table.

#
render_profile_diff_summary

fn render_profile_diff_summary(profiles : Array[Profile]) -> String

#
render_profile_summary

fn render_profile_summary(profiles : Array[Profile]) -> String

#
render_properties

fn render_properties(view : ConfigView, options? : FormatOptions) -> String
Renders a merged view as Java-style properties text.

#
render_schema_gap_markdown

fn render_schema_gap_markdown(schema : ConfigSchema, view : ConfigView) -> String

#
render_stats_markdown

fn render_stats_markdown(view : ConfigView) -> String

#
render_trace_markdown

fn render_trace_markdown(view : ConfigView) -> String

#
required

fn required(path : String) -> Rule

#
requires

fn requires(path : String, required_path : String) -> Rule

#
safe_format_options

fn safe_format_options() -> FormatOptions

#
schema

fn schema(name : String, version : String, sections : Array[SchemaSection]) -> ConfigSchema

#
schema_coverage

fn schema_coverage(schema : ConfigSchema, view : ConfigView) -> Int
Measures how many schema fields are filled by current values or defaults.

#
secret_like

fn secret_like(path : String) -> Rule

#
section

fn section(name : String, description : String, fields : Array[SchemaField]) -> SchemaSection

#
section_stats

fn section_stats(view : ConfigView) -> Array[SectionStats]

#
sensitive_paths

fn sensitive_paths(view : ConfigView) -> Array[String]

#
service_profiles

fn service_profiles(dev : ConfigDocument, test_doc : ConfigDocument, prod : ConfigDocument) -> Array[Profile]
Creates common dev/test/prod profiles from documents.

#
set_value

fn set_value(path : String, value : String) -> DocumentEdit

#
span

fn span(file : String, line : Int, column : Int) -> Span
Creates a location object for synthetic values.

#
summarize_profile

fn summarize_profile(profile : Profile) -> ProfileSummary

#
summarize_profiles

fn summarize_profiles(profiles : Array[Profile]) -> Array[ProfileSummary]

#
test_environment_schema

fn test_environment_schema() -> ConfigSchema
A reusable schema for test environments.

#
trace_values

fn trace_values(view : ConfigView) -> Array[ValueTrace]

#
unescape_properties_value

fn unescape_properties_value(value : String) -> String
Unescapes common properties escape sequences.

#
unresolved_placeholder_diagnostics

fn unresolved_placeholder_diagnostics(view : ConfigView, supplied : Array[PlaceholderValue]) -> Array[Diagnostic]
Reports placeholders without supplied values.

#
validate

fn validate(view : ConfigView, rules : Array[Rule]) -> Array[Diagnostic]
Applies validation rules to an already-merged view.

#
warning

fn warning(code : String, message : String, span? : Span?, hint? : String?) -> Diagnostic
Creates a warning diagnostic.

#
web_service_schema

fn web_service_schema() -> ConfigSchema
A reusable schema for small web services.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io