PhoenixKitCatalogue.Import.Pro100TemplateLoader (PhoenixKitCatalogue v0.12.5)

Copy Markdown View Source

Applies a Pro100TemplatePlan to the catalogue.

Safe to run twice. Identity is resolved at every level, because the one question nobody can answer — whether PRO100 regenerates its guids on each export — decides whether a second run updates or duplicates:

folder      by name
catalogue   by data["pro100"]["template_guid"], else by (folder, name)
category    by (catalogue, parent, name)
item        by data["pro100"]["template_guid"], else by (category, name)
            and only when that item carries no guid of its own

The last condition is what stops a renamed line from overwriting an unrelated item that happens to share its new name: if the candidate already has a guid, it belongs to a different line, and the incoming row is reported instead.

Nothing is ever deleted. Items in a catalogue with no line in the file are reported as :absent, which is the only signal that a position was dropped upstream.

dry_run: true performs every lookup and decision and writes nothing.

Summary

Types

report()

@type report() :: %{
  folder: :created | :reused,
  catalogues: [map()],
  rules: [map()],
  absent: [map()],
  reported: [map()],
  stats: map()
}

Functions

apply_plan(plan, opts \\ [])

@spec apply_plan(
  map(),
  keyword()
) :: {:ok, report()} | {:error, term()}