zf

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

type.ex (9269B)


      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.Intent.Type do
     19 @moduledoc false
     20 
     21 use Absinthe.Schema.Notation
     22 
     23 alias Zenflows.VF.Intent.Resolv
     24 
     25 @action """
     26 Relates an intent to a verb, such as consume, produce, work, improve, etc.
     27 """
     28 @action_id "(`Action`) #{@action}"
     29 @input_of "Defines the process to which this intent is an input."
     30 @input_of_id "(`Process`) #{@input_of}"
     31 @output_of "Defines the process to which this intent is an output."
     32 @output_of_id "(`Process`) #{@output_of}"
     33 @provider """
     34 The economic agent from whom the intent is initiated.  This implies that
     35 the intent is an offer.
     36 """
     37 @provider_id "(`Agent`) #{@provider}"
     38 @receiver """
     39 The economic agent whom the intent is for.  This implies that the intent
     40 is a request.
     41 """
     42 @receiver_id "(`Agent`) #{@receiver}"
     43 @resource_inventoried_as """
     44 When a specific `EconomicResource` is known which can service the
     45 `Intent`, this defines that resource.
     46 """
     47 @resource_inventoried_as_id "(`EconomicResource`) #{@resource_inventoried_as}"
     48 @resource_conforms_to """
     49 The primary resource specification or definition of an existing or
     50 potential economic resource.  A resource will have only one, as this
     51 specifies exactly what the resource is.
     52 """
     53 @resource_conforms_to_id "(`ResourceSpecification`) #{@resource_conforms_to}"
     54 @resource_classified_as """
     55 References a concept in a common taxonomy or other classification scheme
     56 for purposes of categorization or grouping.
     57 """
     58 @resource_quantity """
     59 The amount and unit of the economic resource counted or inventoried.  This
     60 is the quantity that could be used to increment or decrement a resource,
     61 depending on the type of resource and resource effect of action.
     62 """
     63 @effort_quantity """
     64 The amount and unit of the work or use or citation effort-based action.
     65 This is often a time duration, but also could be cycle counts or other
     66 measures of effort or usefulness.
     67 """
     68 @available_quantity "The total quantity of the offered resource available."
     69 @has_beginning "The planned beginning of the intent."
     70 @has_end "The planned end of the intent."
     71 @has_point_in_time """
     72 The planned date/time for the intent.  Can be used instead of beginning
     73 and end.
     74 """
     75 @due "The time something is expected to be complete."
     76 @finished """
     77 The intent is complete or not.  This is irrespective of if the original
     78 goal has been met, and indicates that no more will be done.
     79 """
     80 @at_location "The place where an intent would occur.  Usually mappable."
     81 @at_location_id "(`SpatialThing`) #{@at_location}"
     82 @image """
     83 The base64-encoded image binary relevant to the intent, such as a photo.
     84 """
     85 @name """
     86 An informal or formal textual identifier for an intent.  Does not imply
     87 uniqueness.
     88 """
     89 @note "A textual description or comment."
     90 @agreed_in """
     91 Reference to an agreement between agents which specifies the rules or
     92 policies or calculations which govern this intent.
     93 """
     94 @deletable "The intent can be safely deleted, has no dependent information."
     95 
     96 @desc """
     97 A planned economic flow which has not been committed to, which can lead
     98 to EconomicEvents (sometimes through Commitments).
     99 """
    100 object :intent do
    101 	field :id, non_null(:id)
    102 
    103 	@desc @action
    104 	field :action, non_null(:action), resolve: &Resolv.action/3
    105 
    106 	@desc @input_of
    107 	field :input_of, :process, resolve: &Resolv.input_of/3
    108 
    109 	@desc @output_of
    110 	field :output_of, :process, resolve: &Resolv.output_of/3
    111 
    112 	@desc @provider
    113 	field :provider, :agent, resolve: &Resolv.provider/3
    114 
    115 	@desc @receiver
    116 	field :receiver, :agent, resolve: &Resolv.receiver/3
    117 
    118 	@desc @resource_inventoried_as
    119 	field :resource_inventoried_as, :economic_resource,
    120 		resolve: &Resolv.resource_inventoried_as/3
    121 
    122 	@desc @resource_conforms_to
    123 	field :resource_conforms_to, :resource_specification,
    124 		resolve: &Resolv.resource_conforms_to/3
    125 
    126 	@desc @resource_classified_as
    127 	field :resource_classified_as, list_of(non_null(:uri))
    128 
    129 	@desc @resource_quantity
    130 	field :resource_quantity, :measure,
    131 		resolve: &Resolv.resource_quantity/3
    132 
    133 	@desc @effort_quantity
    134 	field :effort_quantity, :measure,
    135 		resolve: &Resolv.effort_quantity/3
    136 
    137 	@desc @available_quantity
    138 	field :available_quantity, :measure,
    139 		resolve: &Resolv.available_quantity/3
    140 
    141 	@desc @has_beginning
    142 	field :has_beginning, :datetime
    143 
    144 	@desc @has_end
    145 	field :has_end, :datetime
    146 
    147 	@desc @has_point_in_time
    148 	field :has_point_in_time, :datetime
    149 
    150 	@desc @due
    151 	field :due, :datetime
    152 
    153 	@desc @finished
    154 	field :finished, non_null(:boolean)
    155 
    156 	@desc @at_location
    157 	field :at_location, :spatial_thing, resolve: &Resolv.at_location/3
    158 
    159 	@desc @image
    160 	field :image, :base64
    161 
    162 	@desc @name
    163 	field :name, :string
    164 
    165 	@desc @note
    166 	field :note, :string
    167 
    168 	@desc @agreed_in
    169 	field :agreed_in, :uri
    170 
    171 	@desc @deletable
    172 	field :deletable, non_null(:boolean)
    173 
    174 	field :published_in, list_of(non_null(:proposed_intent)),
    175 		resolve: &Resolv.published_in/3
    176 end
    177 
    178 input_object :intent_create_params do
    179 	@desc @action_id
    180 	field :action_id, non_null(:string), name: "action"
    181 
    182 	@desc @input_of_id
    183 	field :input_of_id, :id, name: "input_of"
    184 
    185 	@desc @output_of_id
    186 	field :output_of_id, :id, name: "output_of"
    187 
    188 	@desc @provider_id
    189 	field :provider_id, :id, name: "provider"
    190 
    191 	@desc @receiver_id
    192 	field :receiver_id, :id, name: "receiver"
    193 
    194 	@desc @resource_inventoried_as_id
    195 	field :resource_inventoried_as_id, :id, name: "resource_inventoried_as"
    196 
    197 	@desc @resource_conforms_to_id
    198 	field :resource_conforms_to_id, :id, name: "resource_conforms_to"
    199 
    200 	@desc @resource_classified_as
    201 	field :resource_classified_as, list_of(non_null(:uri))
    202 
    203 	@desc @resource_quantity
    204 	field :resource_quantity, :imeasure
    205 
    206 	@desc @effort_quantity
    207 	field :effort_quantity, :imeasure
    208 
    209 	@desc @available_quantity
    210 	field :available_quantity, :imeasure
    211 
    212 	@desc @has_beginning
    213 	field :has_beginning, :datetime
    214 
    215 	@desc @has_end
    216 	field :has_end, :datetime
    217 
    218 	@desc @has_point_in_time
    219 	field :has_point_in_time, :datetime
    220 
    221 	@desc @due
    222 	field :due, :datetime
    223 
    224 	@desc @finished
    225 	field :finished, :boolean
    226 
    227 	@desc @at_location_id
    228 	field :at_location_id, :id, name: "at_location"
    229 
    230 	@desc @image
    231 	field :image, :base64
    232 
    233 	@desc @name
    234 	field :name, :string
    235 
    236 	@desc @note
    237 	field :note, :string
    238 
    239 	@desc @agreed_in
    240 	field :agreed_in, :uri
    241 end
    242 
    243 input_object :intent_update_params do
    244 	field :id, non_null(:id)
    245 
    246 	@desc @action_id
    247 	field :action_id, :string, name: "action"
    248 
    249 	@desc @input_of_id
    250 	field :input_of_id, :id, name: "input_of"
    251 
    252 	@desc @output_of_id
    253 	field :output_of_id, :id, name: "output_of"
    254 
    255 	@desc @provider_id
    256 	field :provider_id, :id, name: "provider"
    257 
    258 	@desc @receiver_id
    259 	field :receiver_id, :id, name: "receiver"
    260 
    261 	@desc @resource_inventoried_as_id
    262 	field :resource_inventoried_as_id, :id, name: "resource_inventoried_as"
    263 
    264 	@desc @resource_conforms_to_id
    265 	field :resource_conforms_to_id, :id, name: "resource_conforms_to"
    266 
    267 	@desc @resource_classified_as
    268 	field :resource_classified_as, list_of(non_null(:uri))
    269 
    270 	@desc @resource_quantity
    271 	field :resource_quantity, :imeasure
    272 
    273 	@desc @effort_quantity
    274 	field :effort_quantity, :imeasure
    275 
    276 	@desc @available_quantity
    277 	field :available_quantity, :imeasure
    278 
    279 	@desc @has_beginning
    280 	field :has_beginning, :datetime
    281 
    282 	@desc @has_end
    283 	field :has_end, :datetime
    284 
    285 	@desc @has_point_in_time
    286 	field :has_point_in_time, :datetime
    287 
    288 	@desc @due
    289 	field :due, :datetime
    290 
    291 	@desc @finished
    292 	field :finished, :boolean
    293 
    294 	@desc @at_location_id
    295 	field :at_location_id, :id, name: "at_location"
    296 
    297 	@desc @image
    298 	field :image, :base64
    299 
    300 	@desc @name
    301 	field :name, :string
    302 
    303 	@desc @note
    304 	field :note, :string
    305 
    306 	@desc @agreed_in
    307 	field :agreed_in, :uri
    308 end
    309 
    310 object :intent_response do
    311 	field :intent, non_null(:intent)
    312 end
    313 
    314 object :intent_edge do
    315 	field :cursor, non_null(:id)
    316 	field :node, non_null(:intent)
    317 end
    318 
    319 object :intent_connection do
    320 	field :page_info, non_null(:page_info)
    321 	field :edges, non_null(list_of(non_null(:intent_edge)))
    322 end
    323 
    324 object :query_intent do
    325 	field :intent, :intent do
    326 		arg :id, non_null(:id)
    327 		resolve &Resolv.intent/2
    328 	end
    329 
    330 	field :intents, non_null(:intent_connection) do
    331 		arg :first, :integer
    332 		arg :after, :id
    333 		arg :last, :integer
    334 		arg :before, :id
    335 		resolve &Resolv.intents/2
    336 	end
    337 end
    338 
    339 object :mutation_intent do
    340 	field :create_intent, non_null(:intent_response) do
    341 		arg :intent, non_null(:intent_create_params)
    342 		resolve &Resolv.create_intent/2
    343 	end
    344 
    345 	field :update_intent, non_null(:intent_response) do
    346 		arg :intent, non_null(:intent_update_params)
    347 		resolve &Resolv.update_intent/2
    348 	end
    349 
    350 	field :delete_intent, non_null(:boolean) do
    351 		arg :id, non_null(:id)
    352 		resolve &Resolv.delete_intent/2
    353 	end
    354 end
    355 end