zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

type.ex (6001B)


      1 # Zenflows is designed to implement the Valueflows vocabulary,
      2 # written and maintained by srfsh <info@dyne.org>.
      3 # Copyright (C) 2021-2023 Dyne.org foundation <foundation@dyne.org>.
      4 #
      5 # This program is free software: you can redistribute it and/or modify
      6 # it under the terms of the GNU Affero General Public License as published by
      7 # the Free Software Foundation, either version 3 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU Affero General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU Affero General Public License
     16 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     17 
     18 defmodule Zenflows.VF.Proposal.Type do
     19 @moduledoc false
     20 
     21 use Absinthe.Schema.Notation
     22 
     23 alias Zenflows.VF.Proposal.Resolv
     24 
     25 @name  """
     26 An informal or formal textual identifier for a proposal.  Does not
     27 imply uniqueness.
     28 """
     29 @note "A textual description or comment."
     30 @has_beginning "The beginning time of proposal publication."
     31 @has_end "The end time of proposal publication."
     32 @unit_based """
     33 This proposal contains unit based quantities, which can be multiplied to
     34 create commitments; commonly seen in a price list or e-commerce.
     35 """
     36 @created "The date and time the proposal was created."
     37 @eligible_location "The location at which this proposal is eligible."
     38 @eligible_location_id "(`SpatialThing`) #{@eligible_location}"
     39 
     40 @desc "The status of the proposal: pending, accepted, or refused."
     41 enum :proposed_status do
     42 	value :pending
     43 	value :accepted
     44 	value :refused
     45 end
     46 
     47 @desc """
     48 Published requests or offers, sometimes with what is expected in return.
     49 """
     50 object :proposal do
     51 	field :id, non_null(:id)
     52 
     53 	@desc @name
     54 	field :name, :string
     55 
     56 	@desc @note
     57 	field :note, :string
     58 
     59 	@desc @has_beginning
     60 	field :has_beginning, :datetime
     61 
     62 	@desc @has_end
     63 	field :has_end, :datetime
     64 
     65 	@desc @unit_based
     66 	field :unit_based, :boolean
     67 
     68 	@desc @created
     69 	field :created, non_null(:datetime), resolve: &Resolv.created/3
     70 
     71 	@desc @eligible_location
     72 	field :eligible_location, :spatial_thing, resolve: &Resolv.eligible_location/3
     73 
     74 	field :publishes, list_of(non_null(:proposed_intent)),
     75 		resolve: &Resolv.publishes/3
     76 
     77 	field :primary_intents, list_of(non_null(:intent)),
     78 		resolve: &Resolv.primary_intents/3
     79 
     80 	field :reciprocal_intents, list_of(non_null(:intent)),
     81 		resolve: &Resolv.reciprocal_intents/3
     82 
     83 	field :status, non_null(:proposed_status),
     84 		resolve: &Resolv.status/3
     85 end
     86 
     87 input_object :proposal_create_params do
     88 	@desc @name
     89 	field :name, :string
     90 
     91 	@desc @note
     92 	field :note, :string
     93 
     94 	@desc @has_beginning
     95 	field :has_beginning, :datetime
     96 
     97 	@desc @has_end
     98 	field :has_end, :datetime
     99 
    100 	@desc @unit_based
    101 	field :unit_based, :boolean
    102 
    103 	@desc @eligible_location_id
    104 	field :eligible_location_id, :id, name: "eligible_location"
    105 end
    106 
    107 input_object :proposal_update_params do
    108 	field :id, non_null(:id)
    109 
    110 	@desc @name
    111 	field :name, :string
    112 
    113 	@desc @note
    114 	field :note, :string
    115 
    116 	@desc @has_beginning
    117 	field :has_beginning, :datetime
    118 
    119 	@desc @has_end
    120 	field :has_end, :datetime
    121 
    122 	@desc @unit_based
    123 	field :unit_based, :boolean
    124 
    125 	@desc @eligible_location_id
    126 	field :eligible_location_id, :id, name: "eligible_location"
    127 end
    128 
    129 object :proposal_response do
    130 	field :proposal, non_null(:proposal)
    131 end
    132 
    133 object :proposal_edge do
    134 	field :cursor, non_null(:id)
    135 	field :node, non_null(:proposal)
    136 end
    137 
    138 object :proposal_connection do
    139 	field :page_info, non_null(:page_info)
    140 	field :edges, non_null(list_of(non_null(:proposal_edge)))
    141 end
    142 
    143 input_object :proposal_filter_params do
    144 	field :primary_intents_resource_inventoried_as_conforms_to, list_of(non_null(:id))
    145 	field :or_primary_intents_resource_inventoried_as_conforms_to, list_of(non_null(:id))
    146 	field :primary_intents_resource_inventoried_as_primary_accountable, list_of(non_null(:id))
    147 	field :or_primary_intents_resource_inventoried_as_primary_accountable, list_of(non_null(:id))
    148 	field :primary_intents_resource_inventoried_as_classified_as, list_of(non_null(:uri))
    149 	field :or_primary_intents_resource_inventoried_as_classified_as, list_of(non_null(:uri))
    150 	field :primary_intents_resource_inventoried_as_name, :string
    151 	field :or_primary_intents_resource_inventoried_as_name, :string
    152 	field :primary_intents_resource_inventoried_as_note, :string
    153 	field :or_primary_intents_resource_inventoried_as_note, :string
    154 	field :primary_intents_resource_inventoried_as_id, list_of(non_null(:id))
    155 	field :or_primary_intents_resource_inventoried_as_id, list_of(non_null(:id))
    156 	field :status, :proposed_status
    157 	field :or_status, :proposed_status
    158 	field :not_status, :proposed_status
    159 end
    160 
    161 object :query_proposal do
    162 	field :proposal, :proposal do
    163 		arg :id, non_null(:id)
    164 		resolve &Resolv.proposal/2
    165 	end
    166 
    167 	field :proposals, non_null(:proposal_connection) do
    168 		meta only_guest?: true
    169 		arg :first, :integer
    170 		arg :after, :id
    171 		arg :last, :integer
    172 		arg :before, :id
    173 		arg :filter, :proposal_filter_params
    174 		resolve &Resolv.proposals/2
    175 	end
    176 
    177 	@desc "List all proposals that are being listed as offers."
    178 	field :offers, non_null(:proposal_connection) do
    179 		arg :first, :integer
    180 		arg :after, :id
    181 		arg :last, :integer
    182 		arg :before, :id
    183 		resolve &Resolv.offers/2
    184 	end
    185 
    186 	@desc "List all proposals that are being listed as requests."
    187 	field :requests, non_null(:proposal_connection) do
    188 		arg :first, :integer
    189 		arg :after, :id
    190 		arg :last, :integer
    191 		arg :before, :id
    192 		resolve &Resolv.offers/2
    193 	end
    194 end
    195 
    196 object :mutation_proposal do
    197 	field :create_proposal, non_null(:proposal_response) do
    198 		arg :proposal, non_null(:proposal_create_params)
    199 		resolve &Resolv.create_proposal/2
    200 	end
    201 
    202 	field :update_proposal, non_null(:proposal_response) do
    203 		arg :proposal, non_null(:proposal_update_params)
    204 		resolve &Resolv.update_proposal/2
    205 	end
    206 
    207 	field :delete_proposal, non_null(:boolean) do
    208 		arg :id, non_null(:id)
    209 		resolve &Resolv.delete_proposal/2
    210 	end
    211 end
    212 end