Chronicle.Events.MigrationBuilder (cratis_chronicle v0.2.0)

Copy Markdown View Source

Fluent builder for event migration property transformations.

The builder produces the JMESPath-compatible JSON fragments Chronicle expects when registering event type migrations.

Summary

Functions

Combines multiple source properties into a target property.

Copies a property unchanged.

Copies a property from one name to another.

Sets a default value for a property.

Creates an empty migration builder.

Renames a property from source_property to target_property.

Splits a source property and maps one part to a target property.

Returns the builder as JSON.

Returns the builder as a map.

Types

property_name()

@type property_name() :: atom() | String.t()

t()

@type t() :: %Chronicle.Events.MigrationBuilder{properties: map()}

Functions

combine_properties(builder, source_properties, target_property, separator)

@spec combine_properties(t(), [property_name()], property_name(), String.t()) :: t()

Combines multiple source properties into a target property.

copy_property(builder, property)

@spec copy_property(t(), property_name()) :: t()

Copies a property unchanged.

Since Chronicle preserves unspecified properties automatically, the single argument form is a no-op that keeps pipeline code expressive.

copy_property(builder, source_property, target_property)

@spec copy_property(t(), property_name(), property_name()) :: t()

Copies a property from one name to another.

default_value(builder, target_property, value)

@spec default_value(t(), property_name(), term()) :: t()

Sets a default value for a property.

new()

@spec new() :: t()

Creates an empty migration builder.

rename_property(builder, source_property, target_property)

@spec rename_property(t(), property_name(), property_name()) :: t()

Renames a property from source_property to target_property.

renamed_from(builder, target_property, source_property)

@spec renamed_from(t(), property_name(), property_name()) :: t()

Alias for rename_property/3 with the target property first.

set_property(builder, target_property, value)

@spec set_property(t(), property_name(), term()) :: t()

Alias for default_value/3.

split_property(builder, source_property, target_property, separator, part)

@spec split_property(
  t(),
  property_name(),
  property_name(),
  String.t(),
  non_neg_integer()
) :: t()

Splits a source property and maps one part to a target property.

to_json(builder)

@spec to_json(t()) :: String.t()

Returns the builder as JSON.

to_map(migration_builder)

@spec to_map(t()) :: map()

Returns the builder as a map.