Accrue.Entitlements.Observation (accrue v1.5.1)

Copy Markdown View Source

Privacy-bounded, rail-qualified entitlement evidence received from a provider.

Observations retain only normalized fields needed for later projection and repair. Raw receipts, JWS payloads, notification bodies, and owner identity must remain outside this durable queryable boundary.

Summary

Functions

Builds the bounded ingest changeset and maps database identity constraints.

Inserts an observation once and returns the durable row selected by PostgreSQL.

Types

t()

@type t() :: %Accrue.Entitlements.Observation{
  __meta__: term(),
  account: term(),
  account_id: term(),
  environment: term(),
  evidence_digest: term(),
  evidence_expires_at: term(),
  evidence_ref: term(),
  expires_at: term(),
  id: term(),
  inserted_at: term(),
  kind: term(),
  metadata: term(),
  next_retry_at: term(),
  observed_at: term(),
  provider_event_id: term(),
  provider_lineage_id: term(),
  provider_order: term(),
  provider_order_key: term(),
  provider_product_id: term(),
  provider_transaction_id: term(),
  quarantine_reason: term(),
  rail: term(),
  retry_count: term(),
  state: term(),
  updated_at: term()
}

Functions

ingest_changeset(attrs)

@spec ingest_changeset(map()) :: Ecto.Changeset.t()

Builds the bounded ingest changeset and maps database identity constraints.

insert_idempotently(repo, attrs)

@spec insert_idempotently(Ecto.Repo.t(), map()) ::
  {:ok, t()} | {:error, Ecto.Changeset.t()}

Inserts an observation once and returns the durable row selected by PostgreSQL.