type.ex (5950B)
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.Person.Type do 19 @moduledoc false 20 21 use Absinthe.Schema.Notation 22 23 alias Zenflows.VF.Person.Resolv 24 25 @name "The name that this agent will be referred to by." 26 @images """ 27 The image files relevant to the agent, such as a logo, avatar, photo, etc. 28 """ 29 @note "A textual description or comment." 30 @primary_location """ 31 The main place an agent is located, often an address where activities 32 occur and mail can be sent. This is usually a mappable geographic 33 location. It also could be a website address, as in the case of agents 34 who have no physical location. 35 """ 36 @primary_location_id "(`SpatialThing`) #{@primary_location}" 37 @user "Username of the agent. Implies uniqueness." 38 @email "Email address of the agent. Implies uniqueness." 39 @ecdh_public_key "ecdh public key, encoded by zenroom" 40 @eddsa_public_key "eddsa public key, encoded by zenroom" 41 @ethereum_address "ethereum address, encoded by zenroom" 42 @reflow_public_key "reflow public key, encoded by zenroom" 43 @bitcoin_public_key "bitcoin public key, encoded by zenroom" 44 45 @desc "A natural person." 46 object :person do 47 interface :agent 48 49 field :id, non_null(:id) 50 51 @desc @name 52 field :name, non_null(:string) 53 54 @desc @images 55 field :images, list_of(non_null(:file)), resolve: &Resolv.images/3 56 57 @desc @note 58 field :note, :string 59 60 @desc @primary_location 61 field :primary_location, :spatial_thing, 62 resolve: &Resolv.primary_location/3 63 64 @desc @user 65 field :user, non_null(:string) 66 67 @desc @email 68 field :email, non_null(:string) 69 70 @desc @ecdh_public_key 71 field :ecdh_public_key, :string 72 73 @desc @eddsa_public_key 74 field :eddsa_public_key, :string 75 76 @desc @ethereum_address 77 field :ethereum_address, :string 78 79 @desc @reflow_public_key 80 field :reflow_public_key, :string 81 82 @desc @bitcoin_public_key 83 field :bitcoin_public_key, :string 84 end 85 86 @desc "Person eddsa public key" 87 object :person_pubkey do 88 @desc @eddsa_public_key 89 field :eddsa_public_key, :string 90 end 91 92 input_object :person_create_params do 93 @desc @name 94 field :name, non_null(:string) 95 96 @desc @images 97 field :images, list_of(non_null(:ifile)) 98 99 @desc @note 100 field :note, :string 101 102 @desc @primary_location_id 103 field :primary_location_id, :id, name: "primary_location" 104 105 @desc @user 106 field :user, non_null(:string) 107 108 @desc @email 109 field :email, non_null(:string) 110 111 @desc @ecdh_public_key 112 field :ecdh_public_key, :string 113 114 @desc @eddsa_public_key 115 field :eddsa_public_key, :string 116 117 @desc @ethereum_address 118 field :ethereum_address, :string 119 120 @desc @reflow_public_key 121 field :reflow_public_key, :string 122 123 @desc @bitcoin_public_key 124 field :bitcoin_public_key, :string 125 end 126 127 input_object :person_update_params do 128 field :id, non_null(:id) 129 130 @desc @name 131 field :name, :string 132 133 @desc @note 134 field :note, :string 135 136 @desc @primary_location_id 137 field :primary_location_id, :id, name: "primary_location" 138 139 @desc @user 140 field :user, :string 141 end 142 143 object :person_response do 144 field :agent, non_null(:person) 145 end 146 147 object :person_edge do 148 field :cursor, non_null(:id) 149 field :node, non_null(:person) 150 end 151 152 object :person_connection do 153 field :page_info, non_null(:page_info) 154 field :edges, non_null(list_of(non_null(:person_edge))) 155 end 156 157 input_object :person_filter_params do 158 field :name, :string 159 field :user, :string 160 field :user_or_name, :string 161 end 162 163 object :query_person do 164 @desc "Find a person by their ID." 165 field :person, :person do 166 arg :id, non_null(:id) 167 resolve &Resolv.person/2 168 end 169 170 @desc """ 171 Loads all people who have publicly registered with this collaboration 172 space. 173 """ 174 field :people, :person_connection do 175 arg :first, :integer 176 arg :after, :id 177 arg :last, :integer 178 arg :before, :id 179 arg :filter, :person_filter_params 180 resolve &Resolv.people/2 181 end 182 183 @desc "Check if a person exists by email xor username." 184 field :person_exists, non_null(:boolean) do 185 meta only_guest?: true 186 arg :email, :string 187 arg :user, :string 188 resolve &Resolv.person_exists/2 189 end 190 191 @desc "If exists, find a person by email and eddsa-public-key." 192 field :person_check, non_null(:person) do 193 meta only_guest?: true 194 arg :email, non_null(:string) 195 arg :eddsa_public_key, non_null(:string) 196 resolve &Resolv.person_check/2 197 end 198 199 @desc "Retrieve a Person's public key by its id." 200 field :person_pubkey, non_null(:string) do 201 meta only_guest?: true 202 arg :id, non_null(:id) 203 resolve &Resolv.person_pubkey/2 204 end 205 end 206 207 object :mutation_person do 208 @desc "Registers a new (human) person with the collaboration space." 209 field :create_person, non_null(:person_response) do 210 meta only_admin?: true 211 arg :person, non_null(:person_create_params) 212 resolve &Resolv.create_person/2 213 end 214 215 @desc "Update profile details." 216 field :update_person, non_null(:person_response) do 217 arg :person, non_null(:person_update_params) 218 resolve &Resolv.update_person/2 219 end 220 221 @desc """ 222 Erase record of a person and thus remove them from the 223 collaboration space. 224 """ 225 field :delete_person, non_null(:boolean) do 226 meta only_admin?: true 227 arg :id, non_null(:id) 228 resolve &Resolv.delete_person/2 229 end 230 231 field :claim_person, non_null(:json) do 232 arg :id, non_null(:id) 233 resolve &Resolv.claim_person/2 234 end 235 end 236 end