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

Link to this type

scheduled_export()

@type scheduled_export() :: map()
Link to this type

scheduled_export_run()

@type scheduled_export_run() :: map()

Link to this section Callbacks

Link to this callback

create_scheduled_export(attrs, opts)

@callback create_scheduled_export(attrs :: map(), opts :: keyword()) ::
  {:ok, scheduled_export()} | {:error, term()}
Link to this callback

create_scheduled_export_run(attrs, opts)

@callback create_scheduled_export_run(attrs :: map(), opts :: keyword()) ::
  {:ok, scheduled_export_run()} | {:error, term()}
Link to this callback

delete_scheduled_export(scheduled_export, opts)

@callback delete_scheduled_export(scheduled_export(), opts :: keyword()) ::
  {:ok, scheduled_export()} | {:error, term()}
Link to this callback

due_scheduled_exports(now, opts)

@callback due_scheduled_exports(now :: DateTime.t(), opts :: keyword()) :: [
  scheduled_export()
]
Link to this callback

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
Link to this callback

list_scheduled_exports(context, opts)

@callback list_scheduled_exports(context :: term(), opts :: keyword()) :: [
  scheduled_export()
]
Link to this callback

update_scheduled_export(scheduled_export, attrs, opts)

@callback update_scheduled_export(scheduled_export(), attrs :: map(), opts :: keyword()) ::
  {:ok, scheduled_export()} | {:error, term()}
Link to this callback

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

Link to this function

build_create_attrs(assigns, attrs)

@spec build_create_attrs(map(), map()) :: map()

Build attributes for create_scheduled_export/2 from current assigns.

Link to this function

build_run_attrs(scheduled_export, trigger_type, attrs \\ %{})

@spec build_run_attrs(map(), atom(), map()) :: map()

Build attributes for a scheduled export run record.

Link to this function

build_update_attrs(scheduled_export, attrs)

@spec build_update_attrs(map(), map()) :: map()

Build normalized update attrs for an existing scheduled export definition.

Link to this function

field(record, key, default \\ nil)

@spec field(map() | nil, atom(), term()) :: term()

Fetch a field from a map/struct, supporting atom and string keys.

Link to this function

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.

Link to this function

normalize_delivery(delivery)

@spec normalize_delivery(map() | nil) :: map()

Normalize the persisted delivery configuration.

Link to this function

normalize_schedule(schedule)

@spec normalize_schedule(map() | nil) :: map()

Normalize schedule configuration into the first-phase supported shape.