# SPDX-FileCopyrightText: 2025 diffo_example contributors # # SPDX-License-Identifier: MIT defmodule DiffoExample.Nbn.NniGroupCharacteristic do @moduledoc "Typed characteristic for an NNI Group's identity." use Ash.Resource, fragments: [Diffo.Provider.BaseCharacteristic], domain: DiffoExample.Nbn resource do description "Typed characteristic carrying NNI Group identity fields" plural_name :nni_group_characteristics end attributes do attribute :group_name, :string, public?: true attribute :location, :string, public?: true end calculations do calculate :value, Diffo.Type.CharacteristicValue, Diffo.Provider.Calculations.CharacteristicValue do public? true end end preparations do prepare build(load: [:value]) end jason do pick [:name, :value] compact true end end defmodule DiffoExample.Nbn.NniGroupCharacteristic.Value do @moduledoc false use Ash.TypedStruct, extensions: [AshJason.TypedStruct, AshOutstanding.TypedStruct] jason do pick [:group_name, :location] compact true rename group_name: "name" end outstanding do expect [:group_name, :location] end typed_struct do field :group_name, :string field :location, :string end end