SelectoComponents.ScheduledExports behaviour (selecto_components v0.4.5)
Behavior and helpers for persisted scheduled export definitions and run history.
The persistence layer is intentionally app-owned. Host applications implement this behavior while SelectoComponents provides snapshot, normalization, and orchestration helpers.
Link to this section Summary
Functions
Build attributes for create_scheduled_export/2 from current assigns.
Build attributes for a scheduled export run record.
Build normalized update attrs for an existing scheduled export definition.
Fetch a field from a map/struct, supporting atom and string keys.
Calculate the next run timestamp for a first-phase schedule definition.
Normalize the persisted delivery configuration.
Normalize schedule configuration into the first-phase supported shape.
Link to this section Types
scheduled_export()
@type scheduled_export() :: map()
scheduled_export_run()
@type scheduled_export_run() :: map()
Link to this section Callbacks
create_scheduled_export(attrs, opts)
@callback create_scheduled_export(attrs :: map(), opts :: keyword()) :: {:ok, scheduled_export()} | {:error, term()}
create_scheduled_export_run(attrs, opts)
@callback create_scheduled_export_run(attrs :: map(), opts :: keyword()) :: {:ok, scheduled_export_run()} | {:error, term()}
delete_scheduled_export(scheduled_export, opts)
@callback delete_scheduled_export(scheduled_export(), opts :: keyword()) :: {:ok, scheduled_export()} | {:error, term()}
due_scheduled_exports(now, opts)
@callback due_scheduled_exports(now :: DateTime.t(), opts :: keyword()) :: [ scheduled_export() ]
get_scheduled_export_by_public_id(public_id, opts)
@callback get_scheduled_export_by_public_id(public_id :: String.t(), opts :: keyword()) :: scheduled_export() | nil
list_scheduled_exports(context, opts)
@callback list_scheduled_exports(context :: term(), opts :: keyword()) :: [ scheduled_export() ]
update_scheduled_export(scheduled_export, attrs, opts)
@callback update_scheduled_export(scheduled_export(), attrs :: map(), opts :: keyword()) :: {:ok, scheduled_export()} | {:error, term()}
update_scheduled_export_run(scheduled_export_run, attrs, opts)
@callback update_scheduled_export_run( scheduled_export_run(), attrs :: map(), opts :: keyword() ) :: {:ok, scheduled_export_run()} | {:error, term()}
Link to this section Functions
build_create_attrs(assigns, attrs)
Build attributes for create_scheduled_export/2 from current assigns.
build_run_attrs(scheduled_export, trigger_type, attrs \\ %{})
Build attributes for a scheduled export run record.
build_update_attrs(scheduled_export, attrs)
Build normalized update attrs for an existing scheduled export definition.
field(record, key, default \\ nil)
Fetch a field from a map/struct, supporting atom and string keys.
next_run_at(schedule, now \\ DateTime.utc_now())
@spec next_run_at(map() | nil, DateTime.t()) :: DateTime.t() | nil
Calculate the next run timestamp for a first-phase schedule definition.
normalize_delivery(delivery)
Normalize the persisted delivery configuration.
normalize_schedule(schedule)
Normalize schedule configuration into the first-phase supported shape.