Liking cljdoc? Tell your friends :D

urpx.coerce

Coerce raw URPX parser output into typed Clojure values.

The parser (urpx.core/load-rate-plan) produces a Clojure map with namespaced keys but all-string leaf values. This namespace applies the :decode/urpx-jsonld decoders attached to urpx.schema schemas to convert those strings into BigDecimals, LocalDates, LocalTimes, LocalDateTimes, Durations, and integer month numbers — and to normalize fields that URPX permits as either a single map or a vector of maps.

Coerce raw URPX parser output into typed Clojure values.

The parser (`urpx.core/load-rate-plan`) produces a Clojure map with
namespaced keys but all-string leaf values. This namespace applies the
`:decode/urpx-jsonld` decoders attached to `urpx.schema` schemas to convert
those strings into BigDecimals, LocalDates, LocalTimes, LocalDateTimes,
Durations, and integer month numbers — and to normalize fields that URPX
permits as either a single map or a vector of maps.
raw docstring

urpx.core

URPX rate plan loading and price resolution.

Parses URPX JSON-LD rate plan documents into Clojure data structures and resolves prices for any given timestamp and timezone.

URPX rate plan loading and price resolution.

Parses URPX JSON-LD rate plan documents into Clojure data structures
and resolves prices for any given timestamp and timezone.
raw docstring

urpx.index

Build and query an entity index for URPX documents.

URPX JSON-LD documents are graphs: most entities carry a :jsonld/id and refer to other entities by reference shape {:jsonld/id "urpx:foo"}. Coercion leaves these references intact; consumers dereference them on demand against an index keyed by id string.

Note: many references point to vocabulary IRIs in the URPX ontology (e.g. urpx:peakTier, urpx:allDays, urpx:bundledLedger) rather than entities defined in the document. Those lookups return nil — callers distinguish internal refs (resolve to a node) from vocabulary terms (do not).

Build and query an entity index for URPX documents.

URPX JSON-LD documents are graphs: most entities carry a :jsonld/id and refer
to other entities by reference shape `{:jsonld/id "urpx:foo"}`. Coercion
leaves these references intact; consumers dereference them on demand against
an index keyed by id string.

Note: many references point to vocabulary IRIs in the URPX ontology
(e.g. urpx:peakTier, urpx:allDays, urpx:bundledLedger) rather than entities
defined in the document. Those lookups return nil — callers distinguish
internal refs (resolve to a node) from vocabulary terms (do not).
raw docstring

urpx.price

Resolve applicable per-energy prices for a URPX rate plan at a given instant.

Given a coerced rate plan (urpx.coerce/coerce-rate-plan) and a ZonedDateTime, resolve-prices returns the season, the matched TOU period (if any), and one entry per active per-energy ledger (commodity, distribution, public benefits, etc.). Each ledger entry carries a :tiers vector — for block-tiered ledgers (CPAU E-1) every tier's bound and unit-price is surfaced so the caller can pick the active one based on cumulative usage; for non-tiered ledgers the vector has a single entry.

Skipped:

  • PriceDefinitions whose own :urpx/hasCalculationMethod is set (recurring fixed charges like a monthly customer charge — these are subscription-style and don't apply to instantaneous lookup).

Day types honored: urpx:allDays, urpx:weekday, urpx:weekend, urpx:holiday. Holiday matching requires the caller to pass a :holiday? predicate (LocalDate -> bool); without it, urpx:holiday brackets never match.

Resolve applicable per-energy prices for a URPX rate plan at a given instant.

Given a coerced rate plan (`urpx.coerce/coerce-rate-plan`) and a
ZonedDateTime, `resolve-prices` returns the season, the matched TOU period
(if any), and one entry per active per-energy ledger (commodity, distribution,
public benefits, etc.). Each ledger entry carries a `:tiers` vector — for
block-tiered ledgers (CPAU E-1) every tier's bound and unit-price is
surfaced so the caller can pick the active one based on cumulative usage;
for non-tiered ledgers the vector has a single entry.

Skipped:
  - PriceDefinitions whose own `:urpx/hasCalculationMethod` is set
    (recurring fixed charges like a monthly customer charge — these are
    subscription-style and don't apply to instantaneous lookup).

Day types honored: urpx:allDays, urpx:weekday, urpx:weekend, urpx:holiday.
Holiday matching requires the caller to pass a `:holiday?` predicate
(LocalDate -> bool); without it, urpx:holiday brackets never match.
raw docstring

urpx.schedule

Generate contiguous price-interval schedules from a coerced URPX rate plan.

price-schedule walks a [start, end) instant window in the rate plan's local timezone, calls urpx.price/resolve-prices at each step, and merges adjacent steps whose ledger resolutions are identical.

Output is a vector of interval maps each carrying :tick/beginning and :tick/end (java.time.Instants) plus the full urpx.price resolved structure under :urpx.interval/resolved. Suitable for feeding to a consumer like the price-server's TariffFetcher, which can extract a single $/kWh value per interval via urpx.price/marginal-unit-rate.

Default step is 1 hour, anchored to the start-of-hour of start. Pass {:step (Duration/ofMinutes 15)} etc. for finer granularity when a rate plan defines sub-hour TOU bracket transitions.

Generate contiguous price-interval schedules from a coerced URPX rate plan.

`price-schedule` walks a [start, end) instant window in the rate plan's
local timezone, calls `urpx.price/resolve-prices` at each step, and
merges adjacent steps whose ledger resolutions are identical.

Output is a vector of interval maps each carrying `:tick/beginning` and
`:tick/end` (java.time.Instants) plus the full `urpx.price` resolved
structure under `:urpx.interval/resolved`. Suitable for feeding to a
consumer like the price-server's TariffFetcher, which can extract a
single $/kWh value per interval via `urpx.price/marginal-unit-rate`.

Default step is 1 hour, anchored to the start-of-hour of `start`. Pass
`{:step (Duration/ofMinutes 15)}` etc. for finer granularity when a rate
plan defines sub-hour TOU bracket transitions.
raw docstring

urpx.schema

Malli schemas for URPX entities, describing the coerced shape.

Two-layer model (mirroring the clj-oa3 pattern):

  • urpx.core — raw parse: JSON-LD with namespaced keys, all string values.
  • urpx.schema — coerced shape: typed Clojure values (BigDecimal, LocalDate, LocalTime, LocalDateTime, Duration, integer month numbers).

Schemas carry :decode/urpx-jsonld decoders that turn the raw parser output (strings) into the typed shape described here. The transformer is built and applied in urpx.coerce. Reference resolution (URPX-ej9) keeps :jsonld/id references intact; consumers dereference via an entity index.

Schemas are bare def vars referenced by symbol — there is no central registry.

Malli schemas for URPX entities, describing the coerced shape.

Two-layer model (mirroring the clj-oa3 pattern):
  - urpx.core      — raw parse: JSON-LD with namespaced keys, all string values.
  - urpx.schema    — coerced shape: typed Clojure values (BigDecimal, LocalDate,
                     LocalTime, LocalDateTime, Duration, integer month numbers).

Schemas carry `:decode/urpx-jsonld` decoders that turn the raw parser output
(strings) into the typed shape described here. The transformer is built and
applied in `urpx.coerce`. Reference resolution (URPX-ej9) keeps :jsonld/id
references intact; consumers dereference via an entity index.

Schemas are bare def vars referenced by symbol — there is no central registry.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close