diff --git a/gqlgen.yml b/gqlgen.yml index d7837a69..ed5ac8d5 100644 --- a/gqlgen.yml +++ b/gqlgen.yml @@ -82,9 +82,9 @@ models: FacilityInput: model: - github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto.FacilityInput - PINInput: + PinInput: model: - - github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto.PINInput + - github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto.PinInput UserProfile: fields: roleDetails: diff --git a/pkg/onboarding/application/dto/input.go b/pkg/onboarding/application/dto/input.go index 8aacf225..25b9e23f 100644 --- a/pkg/onboarding/application/dto/input.go +++ b/pkg/onboarding/application/dto/input.go @@ -71,12 +71,12 @@ func (i *FacilitySortInput) ToURLValues() (values url.Values) { type MetricInput struct { // TODO Metric types should be a controlled list i.e enum - Type enums.MetricType `json:"metric_type"` + Type enums.MetricType `json:"metricType"` // this will vary by context // should not identify the user (there's a UID field) // focus on the actual event - Payload datatypes.JSON `gorm:"column:payload"` + Payload datatypes.JSON `json:"payload"` Timestamp time.Time `json:"time"` @@ -85,34 +85,34 @@ type MetricInput struct { UID string `json:"uid"` } -// PINInput represents the PIN input data structure -type PINInput struct { +// PinInput represents the PIN input data structure +type PinInput struct { PIN string `json:"pin"` - ConfirmedPin string `json:"confirmed_pin"` + ConfirmedPin string `json:"confirmedPin"` Flavour feedlib.Flavour `json:"flavour"` } // LoginInput represents the Login input data structure type LoginInput struct { - UserID string `json:"user_id"` + UserID string `json:"userID"` PIN string `json:"pin"` Flavour feedlib.Flavour `json:"flavour"` } // StaffProfileInput contains input required to register a staff type StaffProfileInput struct { - StaffNumber string + StaffNumber string `json:"staffNumber"` - // Facilities []*domain.Facility // TODO: needs at least one + // Facilities []*domain.Facility `json:"facilities"` // TODO: needs at least one // A UI switcher optionally toggles the default // TODO: the list of facilities to switch between is strictly those that the user is assigned to - DefaultFacilityID *string // TODO: required, FK to facility + DefaultFacilityID *string `json:"defaultFacilityID"` // // there is nothing special about super-admin; just the set of roles they have // Roles []domain.RoleType `json:"roles"` // TODO: roles are an enum (controlled list), known to both FE and BE - // Addresses []*domain.UserAddress + Addresses []*AddressesInput `json:"addresses"` } // ClientProfileInput is used to supply the client profile input @@ -122,32 +122,42 @@ type ClientProfileInput struct { // UserInput is used to supply user input for registration type UserInput struct { - Username string // @handle, also globally unique; nickname + Username string `json:"username"` // @handle, also globally unique; nickname - DisplayName string // user's preferred display name + DisplayName string `json:"dispalyName"` // user's preferred display name // TODO Consider making the names optional in DB; validation in frontends - FirstName string // given name - MiddleName string - LastName string + FirstName string `json:"firstName"` // given name + MiddleName string `json:"middleName"` + LastName string `json:"lastName"` - UserType enums.UsersType // TODO enum; e.g client, health care worker + UserType enums.UsersType `json:"userType"` - Gender enumutils.Gender // TODO enum; genders; keep it simple + Gender enumutils.Gender `json:"gender"` - Contacts []*ContactInput // TODO: validate, ensure + Contacts []*ContactInput `json:"contactInput"` // TODO: validate, ensure - // // for the preferred language list, order matters - Languages []enumutils.Language // TODO: turn this into a slice of enums, start small (en, sw) - Flavour feedlib.Flavour + // for the preferred language list, order matters + Languages []enumutils.Language `json:"languages"` + Flavour feedlib.Flavour `json:"flavour"` } // ContactInput contains input required to register a user type ContactInput struct { - Type enums.ContactType - Contact string //TODO Validate: phones are E164, emails are valid - Active bool + Type enums.ContactType `json:"type"` + Contact string `json:"contact"` //TODO Validate: phones are E164, emails are valid + Active bool `json:"active"` // a user may opt not to be contacted via this contact // e.g if it's a shared phone owned by a teenager - OptedIn bool + OptedIn bool `json:"optedIn"` +} + +// AddressesInput defines the values required when setting up user information +type AddressesInput struct { + Type enums.AddressesType `json:"type"` + Text string `json:"text"` // actual address, can be multi-line + Country enums.CountryType `json:"country"` + PostalCode string `json:"postalCode"` + County enums.CountyType `json:"county"` + Active bool `json:"active"` } diff --git a/pkg/onboarding/application/enums/counties_of_country.go b/pkg/onboarding/application/enums/counties_of_country.go new file mode 100644 index 00000000..36deaf1d --- /dev/null +++ b/pkg/onboarding/application/enums/counties_of_country.go @@ -0,0 +1,61 @@ +package enums + +import "fmt" + +// CountiesOfCountry defines the counties of a country +type CountiesOfCountry struct { + Country CountryType + Counties []CountyType +} + +// Create a struct with a combined list of counties of countries +var countiesOfCountries = []CountiesOfCountry{ + { + Country: CountryTypeKenya, + Counties: KenyanCounties, + }, + // Other CountiesOfCountries +} + +// ValidateCountiesOfCountries validates the county passed to a country is valid +func ValidateCountiesOfCountries(country CountryType, county CountyType) error { + // ensure we are working with a correct country type to begin with + if !country.IsValid() { + return fmt.Errorf("failed to validate country: %s", country) + } + // Validate the county too + if !county.IsValid() { + return fmt.Errorf("failed to validate county: %s", county) + } + + ok, counties := findSelectedCountryCounties(countiesOfCountries, country) + if !ok { + return fmt.Errorf("failed to find selected country's counties: %s", county) + } + + err := findCounty(counties.Counties, county) + if err != nil { + return fmt.Errorf("failed to find county: %s", err) + } + return nil +} + +// finds the selected country te ensure it's part of the enum, then return the respective counties it has +func findSelectedCountryCounties(countriesCounties []CountiesOfCountry, countryInput CountryType) (bool, *CountiesOfCountry) { + for i, countryCounty := range countriesCounties { + if countryCounty.Country == countryInput { + return true, &countiesOfCountries[i] + } + } + return false, nil +} + +// checks whether the county provided is present in the list of the selected country's counties +func findCounty(counties []CountyType, countyInput CountyType) error { + for _, county := range counties { + if county == countyInput { + return nil + } + } + return fmt.Errorf("failed to find county: %s", countyInput) +} diff --git a/pkg/onboarding/application/enums/country_types.go b/pkg/onboarding/application/enums/country_types.go new file mode 100644 index 00000000..51e1d032 --- /dev/null +++ b/pkg/onboarding/application/enums/country_types.go @@ -0,0 +1,54 @@ +package enums + +import ( + "fmt" + "io" + "strconv" +) + +// CountryType defines various countries available +type CountryType string + +const ( + // CountryTypeKenya defines country type KENYA + CountryTypeKenya CountryType = "KENYA" + // Other countries +) + +// AllCountries represents a slice of all countries available +var AllCountries = []CountryType{ + CountryTypeKenya, +} + +// IsValid returns true if a country type is valid +func (e CountryType) IsValid() bool { + switch e { + case CountryTypeKenya: + return true + } + return false +} + +// String converts country type to string. +func (e CountryType) String() string { + return string(e) +} + +// UnmarshalGQL converts the supplied value to a country type. +func (e *CountryType) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = CountryType(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid CountryType", str) + } + return nil +} + +// MarshalGQL writes the country type to the supplied writer +func (e CountryType) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/pkg/onboarding/application/enums/county_types.go b/pkg/onboarding/application/enums/county_types.go new file mode 100644 index 00000000..52752066 --- /dev/null +++ b/pkg/onboarding/application/enums/county_types.go @@ -0,0 +1,239 @@ +package enums + +import ( + "fmt" + "io" + "strconv" +) + +// CountyType defines various Counties available +type CountyType string + +const ( + // CountyTypeMombasa is a county in country type KENYA + CountyTypeMombasa CountyType = "Mombasa" + // CountyTypeKwale is a county in country type KENYA + CountyTypeKwale CountyType = "Kwale" + // CountyTypeKilifi is a county in country type KENYA + CountyTypeKilifi CountyType = "Kilifi" + // CountyTypeTanaRiver is a county in country type KENYA + CountyTypeTanaRiver CountyType = "Tana_River" + // CountyTypeLamu is a county in country type KENYA + CountyTypeLamu CountyType = "Lamu" + // CountyTypeTaitaTaveta is a county in country type KENYA + CountyTypeTaitaTaveta CountyType = "Taita_Taveta" + // CountyTypeGarissa is a county in country type KENYA + CountyTypeGarissa CountyType = "Garissa" + // CountyTypeWajir is a county in country type KENYA + CountyTypeWajir CountyType = "Wajir" + // CountyTypeMandera is a county in country type KENYA + CountyTypeMandera CountyType = "Mandera" + // CountyTypeMarsabit is a county in country type KENYA + CountyTypeMarsabit CountyType = "Marsabit" + // CountyTypeIsiolo is a county in country type KENYA + CountyTypeIsiolo CountyType = "Isiolo" + // CountyTypeMeru is a county in country type KENYA + CountyTypeMeru CountyType = "Meru" + // CountyTypeTharakaNithi is a county in country type KENYA + CountyTypeTharakaNithi CountyType = "Tharaka_Nithi" + // CountyTypeEmbu is a county in country type KENYA + CountyTypeEmbu CountyType = "Embu" + // CountyTypeKitui is a county in country type KENYA + CountyTypeKitui CountyType = "Kitui" + // CountyTypeMachakos is a county in country type KENYA + CountyTypeMachakos CountyType = "Machakos" + // CountyTypeMakueni is a county in country type KENYA + CountyTypeMakueni CountyType = "Makueni" + // CountyTypeNyandarua is a county in country type KENYA + CountyTypeNyandarua CountyType = "Nyandarua" + // CountyTypeNyeri is a county in country type KENYA + CountyTypeNyeri CountyType = "Nyeri" + // CountyTypeKirinyaga is a county in country type KENYA + CountyTypeKirinyaga CountyType = "Kirinyaga" + // CountyTypeMuranga is a county in country type KENYA + CountyTypeMuranga CountyType = "Muranga" + // CountyTypeKiambu is a county in country type KENYA + CountyTypeKiambu CountyType = "Kiambu" + // CountyTypeTurkana is a county in country type KENYA + CountyTypeTurkana CountyType = "Turkana" + // CountyTypeWestPokot is a county in country type KENYA + CountyTypeWestPokot CountyType = "West_Pokot" + // CountyTypeSamburu is a county in country type KENYA + CountyTypeSamburu CountyType = "Samburu" + // CountyTypeTransNzoia is a county in country type KENYA + CountyTypeTransNzoia CountyType = "Trans_Nzoia" + // CountyTypeUasinGishu is a county in country type KENYA + CountyTypeUasinGishu CountyType = "Uasin_Gishu" + // CountyTypeElgeyoMarakwet is a county in country type KENYA. + CountyTypeElgeyoMarakwet CountyType = "Elgeyo_Marakwet" + // CountyTypeNandi is a county in country type KENYA + CountyTypeNandi CountyType = "Nandi" + // CountyTypeBaringo is a county in country type KENYA + CountyTypeBaringo CountyType = "Baringo" + // CountyTypeLaikipia is a county in country type KENYA + CountyTypeLaikipia CountyType = "Laikipia" + // CountyTypeNakuru is a county in country type KENYA + CountyTypeNakuru CountyType = "Nakuru" + // CountyTypeNarok is a county in country type KENYA + CountyTypeNarok CountyType = "Narok" + // CountyTypeKajiado is a county in country type KENYA + CountyTypeKajiado CountyType = "Kajiado" + // CountyTypeKericho is a county in country type KENYA + CountyTypeKericho CountyType = "Kericho" + // CountyTypeBomet is a county in country type KENYA + CountyTypeBomet CountyType = "Bomet" + // CountyTypeKakamega is a county in country type KENYA + CountyTypeKakamega CountyType = "Kakamega" + // CountyTypeVihiga is a county in country type KENYA + CountyTypeVihiga CountyType = "Vihiga" + // CountyTypeBungoma is a county in country type KENYA + CountyTypeBungoma CountyType = "Bungoma" + // CountyTypeBusia is a county in country type KENYA + CountyTypeBusia CountyType = "Busia" + // CountyTypeSiaya is a county in country type KENYA + CountyTypeSiaya CountyType = "Siaya" + // CountyTypeKisumu is a county in country type KENYA + CountyTypeKisumu CountyType = "Kisumu" + // CountyTypeHomaBay is a county in country type KENYA + CountyTypeHomaBay CountyType = "Homa_Bay" + // CountyTypeMigori is a county in country type KENYA + CountyTypeMigori CountyType = "Migori" + // CountyTypeKisii is a county in country type KENYA + CountyTypeKisii CountyType = "Kisii" + // CountyTypeNyamira is a county in country type KENYA + CountyTypeNyamira CountyType = "Nyamira" + // CountyTypeNairobi is a county in country type KENYA + CountyTypeNairobi CountyType = "Nairobi" + + // Other counties +) + +// KenyanCounties represent all contyTypes of country type KENYA +var KenyanCounties = []CountyType{ + CountyTypeMombasa, + CountyTypeKwale, + CountyTypeKilifi, + CountyTypeTanaRiver, + CountyTypeLamu, + CountyTypeTaitaTaveta, + CountyTypeGarissa, + CountyTypeWajir, + CountyTypeMandera, + CountyTypeMarsabit, + CountyTypeIsiolo, + CountyTypeMeru, + CountyTypeTharakaNithi, + CountyTypeEmbu, + CountyTypeKitui, + CountyTypeMachakos, + CountyTypeMakueni, + CountyTypeNyandarua, + CountyTypeNyeri, + CountyTypeKirinyaga, + CountyTypeMuranga, + CountyTypeKiambu, + CountyTypeTurkana, + CountyTypeWestPokot, + CountyTypeSamburu, + CountyTypeTransNzoia, + CountyTypeUasinGishu, + CountyTypeElgeyoMarakwet, + CountyTypeNandi, + CountyTypeBaringo, + CountyTypeLaikipia, + CountyTypeNakuru, + CountyTypeNarok, + CountyTypeKajiado, + CountyTypeKericho, + CountyTypeBomet, + CountyTypeKakamega, + CountyTypeVihiga, + CountyTypeBungoma, + CountyTypeBusia, + CountyTypeSiaya, + CountyTypeKisumu, + CountyTypeHomaBay, + CountyTypeMigori, + CountyTypeKisii, + CountyTypeNyamira, + CountyTypeNairobi, +} + +// IsValid returns true if a county type is valid +func (e CountyType) IsValid() bool { + switch e { + case CountyTypeMombasa, + CountyTypeKwale, + CountyTypeKilifi, + CountyTypeTanaRiver, + CountyTypeLamu, + CountyTypeTaitaTaveta, + CountyTypeGarissa, + CountyTypeWajir, + CountyTypeMandera, + CountyTypeMarsabit, + CountyTypeIsiolo, + CountyTypeMeru, + CountyTypeTharakaNithi, + CountyTypeEmbu, + CountyTypeKitui, + CountyTypeMachakos, + CountyTypeMakueni, + CountyTypeNyandarua, + CountyTypeNyeri, + CountyTypeKirinyaga, + CountyTypeMuranga, + CountyTypeKiambu, + CountyTypeTurkana, + CountyTypeWestPokot, + CountyTypeSamburu, + CountyTypeTransNzoia, + CountyTypeUasinGishu, + CountyTypeElgeyoMarakwet, + CountyTypeNandi, + CountyTypeBaringo, + CountyTypeLaikipia, + CountyTypeNakuru, + CountyTypeNarok, + CountyTypeKajiado, + CountyTypeKericho, + CountyTypeBomet, + CountyTypeKakamega, + CountyTypeVihiga, + CountyTypeBungoma, + CountyTypeBusia, + CountyTypeSiaya, + CountyTypeKisumu, + CountyTypeHomaBay, + CountyTypeMigori, + CountyTypeKisii, + CountyTypeNyamira, + CountyTypeNairobi: + return true + } + return false +} + +// String converts county type to string. +func (e CountyType) String() string { + return string(e) +} + +// UnmarshalGQL converts the supplied value to a county type. +func (e *CountyType) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = CountyType(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid CountyType", str) + } + return nil +} + +// MarshalGQL writes the county type to the supplied writer +func (e CountyType) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/pkg/onboarding/application/enums/user_adress_type.go b/pkg/onboarding/application/enums/user_adress_type.go new file mode 100644 index 00000000..7fb59f40 --- /dev/null +++ b/pkg/onboarding/application/enums/user_adress_type.go @@ -0,0 +1,59 @@ +package enums + +import ( + "fmt" + "io" + "strconv" +) + +// AddressesType defines various addresses available +type AddressesType string + +const ( + // AddressesTypePostal adderess country type POSTAL + AddressesTypePostal AddressesType = "POSTAL" + // AddressesTypePhysical adderess country type PHYSICAL + AddressesTypePhysical AddressesType = "PHYSICAL" + // AddressesTypePostalPhysical adderess country type POSTALPHYSICAL + AddressesTypePostalPhysical AddressesType = "POSTALPHYSICAL" +) + +// AllAddresses represents a slice of all addresses available +var AllAddresses = []AddressesType{ + AddressesTypePostal, + AddressesTypePhysical, + AddressesTypePostalPhysical, +} + +// IsValid returns true if an address type is valid +func (e AddressesType) IsValid() bool { + switch e { + case AddressesTypePostal, AddressesTypePhysical, AddressesTypePostalPhysical: + return true + } + return false +} + +// String converts addresses type to string. +func (e AddressesType) String() string { + return string(e) +} + +// UnmarshalGQL converts the supplied value to a user address type. +func (e *AddressesType) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = AddressesType(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid AddressesType", str) + } + return nil +} + +// MarshalGQL writes the user address type to the supplied writer +func (e AddressesType) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/pkg/onboarding/domain/models.go b/pkg/onboarding/domain/models.go index d935f933..7c6cff70 100644 --- a/pkg/onboarding/domain/models.go +++ b/pkg/onboarding/domain/models.go @@ -16,14 +16,14 @@ import ( // e.g CCC clinics, Pharmacies. type Facility struct { // ID is the Global facility ID(GCID) - ID *string + ID *string `json:"id"` // unique within this structure - Name string + Name string `json:"name"` // MFL Code for Kenyan facilities, globally unique - Code string - Active bool - County string // TODO: Controlled list of counties - Description string + Code string `json:"code"` + Active bool `json:"active"` + County string `json:"county"` // TODO: Controlled list of counties + Description string `json:"description"` } // // FacilityPage models the structure of all facilities including pagination @@ -46,66 +46,65 @@ type Facility struct { // // Client and Staff cannot exist without being a user type User struct { - ID *string // globally unique ID + ID *string `json:"id"` // globally unique ID - Username string // @handle, also globally unique; nickname + Username string `json:"username"` // @handle, also globally unique; nickname - DisplayName string // user's preferred display name + DisplayName string `json:"displayName"` // user's preferred display name // TODO Consider making the names optional in DB; validation in frontends - FirstName string // given name - MiddleName string - LastName string - - UserType enums.UsersType // TODO enum; e.g client, health care worker + FirstName string `json:"firstName"` // given name + MiddleName string `json:"middleName"` + LastName string `json:"lastName"` - Gender enumutils.Gender // TODO enum; genders; keep it simple + UserType enums.UsersType `json:"userType"` + Gender enumutils.Gender `json:"gender"` Active bool - Contacts []*Contact // TODO: validate, ensure + Contacts []*Contact `json:"contact"` // TODO: validate, ensure // for the preferred language list, order matters - Languages []enumutils.Language // TODO: turn this into a slice of enums, start small (en, sw) + Languages []enumutils.Language `json:"languages"` // PushTokens []string // when a user logs in successfully, set this - LastSuccessfulLogin *time.Time + LastSuccessfulLogin *time.Time `json:"lastSuccessfulLogin"` // whenever there is a failed login (e.g bad PIN), set this // reset to null / blank when they succeed at logging in - LastFailedLogin *time.Time + LastFailedLogin *time.Time `json:"lastFailedLogin"` // each time there is a failed login, **increment** this // set to zero after successful login - FailedLoginCount string + FailedLoginCount string `json:"failedLoginCount"` // calculated each time there is a failed login - NextAllowedLogin *time.Time + NextAllowedLogin *time.Time `json:"NextAllowedLogin"` - TermsAccepted bool - AcceptedTermsID string // foreign key to version of terms they accepted - Flavour feedlib.Flavour + TermsAccepted bool `json:"termsAccepted"` + AcceptedTermsID string `json:"AcceptedTermsID"` // foreign key to version of terms they accepted + Flavour feedlib.Flavour `json:"flavour"` } // AuthCredentials is the authentication credentials for a given user type AuthCredentials struct { - User *User + User *User `json:"user"` - RefreshToken string - IDToken string - ExpiresIn string + RefreshToken string `json:"refreshToken"` + IDToken string `json:"idToken"` + ExpiresIn string `json:"expiresIn"` } // UserPIN is used to store users' PINs and their entire change history. type UserPIN struct { - UserID string `json:"user_id"` - HashedPIN string `json:"column:hashed_pin"` - ValidFrom time.Time `json:"column:valid_from"` - ValidTo time.Time `json:"column:valid_to"` + UserID string `json:"userID"` + HashedPIN string `json:"column:hashedPin"` + ValidFrom time.Time `json:"column:validFrom"` + ValidTo time.Time `json:"column:validTo"` Flavour feedlib.Flavour `json:"flavour"` - IsValid bool `json:"is_valid"` + IsValid bool `json:"isValid"` Salt string `json:"salt"` } @@ -131,49 +130,48 @@ type Identifier struct { //It is a linkage model e.g to tie together all of a person's identifiers // and their health record ID type ClientProfile struct { - ID *string // globally unique identifier; synthetic i.e has no encoded meaning + ID *string `json:"id"` // globally unique identifier; synthetic i.e has no encoded meaning // every client is a user first // biodata is linked to the user record // the client record is for bridging to other identifiers e.g patient record IDs - UserID *string // TODO: Foreign key to User + UserID *string `json:"userID"` - TreatmentEnrollmentDate *time.Time // use for date of treatment enrollment + TreatmentEnrollmentDate *time.Time `json:"treatmentEnrollmentDate"` // use for date of treatment enrollment - ClientType enums.ClientType + ClientType enums.ClientType `json:"ClientType"` - Active bool + Active bool `json:"Active"` - HealthRecordID *string // optional link to a health record e.g FHIR Patient ID + HealthRecordID *string `json:"healthRecordID"` // optional link to a health record e.g FHIR Patient ID // TODO: a client can have many identifiers; an identifier belongs to a client // (implement reverse relation lookup) - Identifiers []*Identifier + Identifiers []*Identifier `json:"identifiers"` - Addresses []*UserAddress + Addresses []*Addresses `json:"addresses"` - RelatedPersons []*RelatedPerson // e.g next of kin + RelatedPersons []*RelatedPerson `json:"relatedPersons"` // e.g next of kin // client's currently assigned facility - FacilityID string // TODO: FK + FacilityID string `json:"facilityID"` // TODO: FK - TreatmentBuddyUserID string // TODO: optional, FK to User + TreatmentBuddyUserID string `json:"treatmentBuddyUserID"` // TODO: optional, FK to User - CHVUserID string // TODO: optional, FK to User + CHVUserID string `json:"CHVUserID"` // TODO: optional, FK to User - ClientCounselled bool + ClientCounselled bool `json:"clientCounselled"` } -// UserAddress are value objects for user address e.g postal code -type UserAddress struct { - ID string - - Type string // TODO: enum; postal, physical or both - Text string // actual address, can be multi-line - Country string // TODO: enum - PostalCode string - County string // TODO: counties belong to a country - Active bool +// Addresses are value objects for user address e.g postal code +type Addresses struct { + ID string `json:"id"` + Type enums.AddressesType `json:"type"` + Text string `json:"text"` // actual address, can be multi-line + Country enums.CountryType `json:"country"` + PostalCode string `json:"postalCode"` + County enums.CountyType `json:"county"` + Active bool `json:"active"` } // RelatedPerson holds the details for person we consider relates to a Client @@ -191,7 +189,7 @@ type RelatedPerson struct { Gender string // TODO: enum DateOfBirth *scalarutils.Date // TODO: optional - Addresses []*UserAddress // TODO: optional + Addresses []*Addresses // TODO: optional Contacts []*Contact // TODO: optional } @@ -208,7 +206,7 @@ type ClientProfileRegistrationPayload struct { PrimaryIdentifier *Identifier // TODO: optional, default set if not givemn - Addresses []*UserAddress + Addresses []*Addresses FacilityID uuid.UUID @@ -223,8 +221,7 @@ type ClientProfileRegistrationPayload struct { type Contact struct { ID *string - Type enums.ContactType // TODO enum - + Type enums.ContactType Contact string // TODO Validate: phones are E164, emails are valid Active bool @@ -239,7 +236,6 @@ type Metric struct { // ensures we don't re-save the same metric; opaque; globally unique MetricID *string - // TODO Metric types should be a controlled list i.e enum Type enums.MetricType // this will vary by context @@ -266,16 +262,16 @@ type StaffProfile struct { // A UI switcher optionally toggles the default // TODO: the list of facilities to switch between is strictly those that the user is assigned to - DefaultFacilityID *string // TODO: required, FK to facility + DefaultFacilityID *string // there is nothing special about super-admin; just the set of roles they have Roles []string // TODO: roles are an enum (controlled list), known to both FE and BE - Addresses []*UserAddress + Addresses []*Addresses } -// PIN model contain the information about given PIN -type PIN struct { +// Pin model contain the information about given PIN +type Pin struct { UserID string PIN string ConfirmedPin string diff --git a/pkg/onboarding/infrastructure/database/postgres/gorm/mock/gorm_mock.go b/pkg/onboarding/infrastructure/database/postgres/gorm/mock/gorm_mock.go index 4897e805..5f81f0f2 100644 --- a/pkg/onboarding/infrastructure/database/postgres/gorm/mock/gorm_mock.go +++ b/pkg/onboarding/infrastructure/database/postgres/gorm/mock/gorm_mock.go @@ -245,6 +245,17 @@ func NewGormMock() *GormMock { UserID: &ID, StaffNumber: "s123", DefaultFacilityID: &ID, + Addresses: []*gorm.Addresses{ + { + AddressesID: &ID, + Type: enums.AddressesTypePhysical, + Text: "test", + Country: enums.CountryTypeKenya, + PostalCode: "test code", + County: "test", + Active: true, + }, + }, }, }, nil }, diff --git a/pkg/onboarding/infrastructure/database/postgres/gorm/tables.go b/pkg/onboarding/infrastructure/database/postgres/gorm/tables.go index c50b8c6e..11261dec 100644 --- a/pkg/onboarding/infrastructure/database/postgres/gorm/tables.go +++ b/pkg/onboarding/infrastructure/database/postgres/gorm/tables.go @@ -190,7 +190,7 @@ type StaffProfile struct { // // there is nothing special about super-admin; just the set of roles they have // Roles []string `gorm:"type:text[];column:roles"` // TODO: roles are an enum (controlled list), known to both FE and BE - // Addresses []*UserAddress `gorm:"many2many:staffprofile_useraddress;"` + Addresses []*Addresses `gorm:"ForeignKey:StaffProfileID"` } // BeforeCreate is a hook run before creating a new staff profile @@ -205,28 +205,29 @@ func (StaffProfile) TableName() string { return "staffprofile" } -// UserAddress are value objects for user address e.g postal code -type UserAddress struct { - UserAddressID *string `gorm:"primaryKey;unique;column:useraddress_id"` // globally unique - - Type string `gorm:"column:type"` // TODO: enum; postal, physical or both - Text string `gorm:"column:text"` // actual address, can be multi-line - Country string `gorm:"column:country"` // TODO: enum - PostalCode string `gorm:"column:postal_code"` - County string `gorm:"column:county"` // TODO: counties belong to a country - Active bool `gorm:"column:active"` +// Addresses are value objects for user address e.g postal code +type Addresses struct { + AddressesID *string `gorm:"primaryKey;unique;column:useraddress_id"` // globally unique + + Type enums.AddressesType `gorm:"column:type"` // TODO: enum; postal, physical or both + Text string `gorm:"column:text"` // actual address, can be multi-line + Country enums.CountryType `gorm:"column:country"` // TODO: enum + PostalCode string `gorm:"column:postal_code"` + County enums.CountyType `gorm:"column:county"` // TODO: counties belong to a country + Active bool `gorm:"column:active"` + StaffProfileID *string `gorm:"column:staff_profile_id"` } // BeforeCreate is a hook run before creating a new address -func (a *UserAddress) BeforeCreate(tx *gorm.DB) (err error) { +func (a *Addresses) BeforeCreate(tx *gorm.DB) (err error) { id := uuid.New().String() - a.UserAddressID = &id + a.AddressesID = &id return } // TableName customizes how the table name is generated -func (UserAddress) TableName() string { - return "useraddress" +func (Addresses) TableName() string { + return "address" } // StaffUserProfile combines user and staff profile @@ -259,7 +260,7 @@ type ClientProfile struct { // (implement reverse relation lookup) Identifiers []*Identifier `gorm:"foreignKey:ClientID"` - // Addresses []*domain.UserAddress `gorm:"column:addresses"` + // Addresses []*domain.Addresses `gorm:"column:addresses"` // RelatedPersons []*domain.RelatedPerson `gorm:"column:related_persons"` @@ -360,7 +361,7 @@ func allTables() []interface{} { &StaffProfile{}, &ClientProfile{}, &Identifier{}, - &UserAddress{}, + &Addresses{}, &PINData{}, } return tables diff --git a/pkg/onboarding/infrastructure/database/postgres/mappers.go b/pkg/onboarding/infrastructure/database/postgres/mappers.go index f67a6dce..1425e982 100644 --- a/pkg/onboarding/infrastructure/database/postgres/mappers.go +++ b/pkg/onboarding/infrastructure/database/postgres/mappers.go @@ -102,6 +102,19 @@ func (d *OnboardingDb) mapRegisterStaffObjectToDomain(userStaffObject *gorm.Staf user := createMapUser(userObject) + addresses := []*domain.Addresses{} + for _, a := range staffObject.Addresses { + address := &domain.Addresses{ + Type: a.Type, + Text: a.Text, + Country: a.Country, + PostalCode: a.PostalCode, + County: a.County, + Active: a.Active, + } + addresses = append(addresses, address) + } + staffProfile := &domain.StaffProfile{ ID: staffObject.StaffProfileID, UserID: userObject.UserID, @@ -109,7 +122,7 @@ func (d *OnboardingDb) mapRegisterStaffObjectToDomain(userStaffObject *gorm.Staf // Facilities: staffObject.Facilities, DefaultFacilityID: staffObject.DefaultFacilityID, // Roles: staffObject.Roles, - // Addresses: staffObject.Addresses, + Addresses: addresses, } return &domain.StaffUserProfile{ User: user, diff --git a/pkg/onboarding/infrastructure/database/postgres/mock/pg_mock.go b/pkg/onboarding/infrastructure/database/postgres/mock/pg_mock.go index 2b92fdec..2291ff4e 100644 --- a/pkg/onboarding/infrastructure/database/postgres/mock/pg_mock.go +++ b/pkg/onboarding/infrastructure/database/postgres/mock/pg_mock.go @@ -168,6 +168,17 @@ func NewPostgresMock() *PostgresMock { UserID: &ID, StaffNumber: "s123", DefaultFacilityID: &ID, + Addresses: []*domain.Addresses{ + { + ID: ID, + Type: enums.AddressesTypePhysical, + Text: "test", + Country: enums.CountryTypeKenya, + PostalCode: "test code", + County: enums.CountyTypeBaringo, + Active: true, + }, + }, }, }, nil }, diff --git a/pkg/onboarding/infrastructure/database/postgres/pg_create.go b/pkg/onboarding/infrastructure/database/postgres/pg_create.go index 6a32c0f0..afddcf39 100644 --- a/pkg/onboarding/infrastructure/database/postgres/pg_create.go +++ b/pkg/onboarding/infrastructure/database/postgres/pg_create.go @@ -94,9 +94,30 @@ func (d *OnboardingDb) RegisterStaffUser(ctx context.Context, user *dto.UserInpu userObject := createUserObject(user) + addresses := []*gorm.Addresses{} + if len(staff.Addresses) > 0 { + for _, a := range staff.Addresses { + // ensure counties belong to a country + err := enums.ValidateCountiesOfCountries(enums.CountryType(a.Country), enums.CountyType(a.County)) + if err != nil { + return nil, fmt.Errorf("failed to validate %v county belongs to %v: %v", a.County, a.Country, err) + } + address := &gorm.Addresses{ + Type: a.Type, + Text: a.Text, + Country: a.Country, + PostalCode: a.PostalCode, + County: a.County, + Active: a.Active, + } + addresses = append(addresses, address) + } + } + staffObject := &gorm.StaffProfile{ StaffNumber: staff.StaffNumber, DefaultFacilityID: staff.DefaultFacilityID, + Addresses: addresses, } userStaffProfile, err := d.create.RegisterStaffUser(ctx, userObject, staffObject) diff --git a/pkg/onboarding/infrastructure/database/postgres/pg_create_test.go b/pkg/onboarding/infrastructure/database/postgres/pg_create_test.go index 9403802f..e92526fb 100644 --- a/pkg/onboarding/infrastructure/database/postgres/pg_create_test.go +++ b/pkg/onboarding/infrastructure/database/postgres/pg_create_test.go @@ -273,6 +273,16 @@ func TestOnboardingDb_RegisterStaffUser(t *testing.T) { staffInput := &dto.StaffProfileInput{ StaffNumber: "s123", DefaultFacilityID: &testFacilityID, + Addresses: []*dto.AddressesInput{ + { + Type: enums.AddressesTypePhysical, + Text: "test", + Country: enums.CountryTypeKenya, + PostalCode: "test code", + County: enums.CountyTypeBaringo, + Active: true, + }, + }, } staffNoFacilityIDInput := &dto.StaffProfileInput{ StaffNumber: "s123", @@ -354,6 +364,17 @@ func TestOnboardingDb_RegisterStaffUser(t *testing.T) { UserID: &testUserID, StaffNumber: "s123", DefaultFacilityID: &testFacilityID, + Addresses: []*gorm.Addresses{ + { + AddressesID: &testID, + Type: enums.AddressesTypePhysical, + Text: "test", + Country: enums.CountryTypeKenya, + PostalCode: "test code", + County: enums.CountyTypeBaringo, + Active: true, + }, + }, }, }, nil } diff --git a/pkg/onboarding/presentation/graph/emum.graphql b/pkg/onboarding/presentation/graph/emum.graphql deleted file mode 100644 index 7f0c3600..00000000 --- a/pkg/onboarding/presentation/graph/emum.graphql +++ /dev/null @@ -1,9 +0,0 @@ -enum ContactType { - PHONE - EMAIL -} - -enum UsersType { - HEALTHCAREWORKER - CLIENT -} diff --git a/pkg/onboarding/presentation/graph/enums.graphql b/pkg/onboarding/presentation/graph/enums.graphql index f2867186..29d0607c 100644 --- a/pkg/onboarding/presentation/graph/enums.graphql +++ b/pkg/onboarding/presentation/graph/enums.graphql @@ -14,3 +14,76 @@ enum IdentifierUse { TEMPORARY OLD } +enum ContactType { + PHONE + EMAIL +} + +enum UsersType { + HEALTHCAREWORKER + CLIENT +} + +enum CountryType { + KENYA + # other countries +} + +enum CountyType { + Mombasa + Kwale + Kilifi + Tana_River + Lamu + Taita_Taveta + Garissa + Wajir + Mandera + Marsabit + Isiolo + Meru + Tharaka_Nithi + Embu + Kitui + Machakos + Makueni + Nyandarua + Nyeri + Kirinyaga + Muranga + Kiambu + Turkana + West_Pokot + Samburu + Trans_Nzoia + Uasin_Gishu + Elgeyo_Marakwet + Nandi + Baringo + Laikipia + Nakuru + Narok + Kajiado + Kericho + Bomet + Kakamega + Vihiga + Bungoma + Busia + Siaya + Kisumu + Homa_Bay + Migori + Kisii + Nyamira + Nairobi + # other counties + +} + +enum AddressesType { + POSTAL + PHYSICAL + POSTALPHYSICAL +} + diff --git a/pkg/onboarding/presentation/graph/facility.graphql b/pkg/onboarding/presentation/graph/facility.graphql index dbe2d84a..55a1f89c 100644 --- a/pkg/onboarding/presentation/graph/facility.graphql +++ b/pkg/onboarding/presentation/graph/facility.graphql @@ -2,7 +2,7 @@ extend type Mutation { createFacility(input: FacilityInput!): Facility! deleteFacility(id: String!): Boolean! - setUserPIN(input: PINInput): Boolean! + setUserPIN(input: PinInput): Boolean! } extend type Query { diff --git a/pkg/onboarding/presentation/graph/facility.resolvers.go b/pkg/onboarding/presentation/graph/facility.resolvers.go index d9f57d1b..ac80907a 100644 --- a/pkg/onboarding/presentation/graph/facility.resolvers.go +++ b/pkg/onboarding/presentation/graph/facility.resolvers.go @@ -19,7 +19,7 @@ func (r *mutationResolver) DeleteFacility(ctx context.Context, id string) (bool, return r.interactor.FacilityUsecase.DeleteFacility(ctx, id) } -func (r *mutationResolver) SetUserPin(ctx context.Context, input *dto.PINInput) (bool, error) { +func (r *mutationResolver) SetUserPin(ctx context.Context, input *dto.PinInput) (bool, error) { return r.interactor.UserUsecase.SetUserPIN(ctx, input) } diff --git a/pkg/onboarding/presentation/graph/generated/generated.go b/pkg/onboarding/presentation/graph/generated/generated.go index 8a67a538..abbecf9e 100644 --- a/pkg/onboarding/presentation/graph/generated/generated.go +++ b/pkg/onboarding/presentation/graph/generated/generated.go @@ -49,7 +49,6 @@ type Config struct { type ResolverRoot interface { Entity() EntityResolver Mutation() MutationResolver - PIN() PINResolver Query() QueryResolver UserProfile() UserProfileResolver VerifiedIdentifier() VerifiedIdentifierResolver @@ -68,6 +67,16 @@ type ComplexityRoot struct { PlaceID func(childComplexity int) int } + Addresses struct { + Active func(childComplexity int) int + Country func(childComplexity int) int + County func(childComplexity int) int + ID func(childComplexity int) int + PostalCode func(childComplexity int) int + Text func(childComplexity int) int + Type func(childComplexity int) int + } + BioData struct { DateOfBirth func(childComplexity int) int FirstName func(childComplexity int) int @@ -187,7 +196,7 @@ type ComplexityRoot struct { SetPrimaryEmailAddress func(childComplexity int, email string, otp string) int SetPrimaryPhoneNumber func(childComplexity int, phone string, otp string) int SetUserCommunicationsSettings func(childComplexity int, allowWhatsApp *bool, allowTextSms *bool, allowPush *bool, allowEmail *bool) int - SetUserPin func(childComplexity int, input *dto1.PINInput) int + SetUserPin func(childComplexity int, input *dto1.PinInput) int SetupAsExperimentParticipant func(childComplexity int, participate *bool) int TestMutation func(childComplexity int) int UpdateRolePermissions func(childComplexity int, input dto.RolePermissionInput) int @@ -222,13 +231,6 @@ type ComplexityRoot struct { Title func(childComplexity int) int } - Pin struct { - ConfirmedPin func(childComplexity int) int - Flavour func(childComplexity int) int - Pin func(childComplexity int) int - User func(childComplexity int) int - } - PageInfo struct { EndCursor func(childComplexity int) int HasNextPage func(childComplexity int) int @@ -243,6 +245,13 @@ type ComplexityRoot struct { Scope func(childComplexity int) int } + Pin struct { + ConfirmedPin func(childComplexity int) int + Flavour func(childComplexity int) int + PIN func(childComplexity int) int + UserID func(childComplexity int) int + } + Query struct { DummyQuery func(childComplexity int) int FetchFacilities func(childComplexity int) int @@ -276,6 +285,7 @@ type ComplexityRoot struct { } StaffProfile struct { + Addresses func(childComplexity int) int DefaultFacilityID func(childComplexity int) int ID func(childComplexity int) int StaffNumber func(childComplexity int) int @@ -368,7 +378,7 @@ type MutationResolver interface { AddIdentifier(ctx context.Context, clientID string, idType enums.IdentifierType, idValue string, isPrimary bool) (*domain1.Identifier, error) CreateFacility(ctx context.Context, input dto1.FacilityInput) (*domain1.Facility, error) DeleteFacility(ctx context.Context, id string) (bool, error) - SetUserPin(ctx context.Context, input *dto1.PINInput) (bool, error) + SetUserPin(ctx context.Context, input *dto1.PinInput) (bool, error) TestMutation(ctx context.Context) (*bool, error) RegisterStaffUser(ctx context.Context, userInput dto1.UserInput, staffInput dto1.StaffProfileInput) (*domain1.StaffUserProfile, error) CompleteSignup(ctx context.Context, flavour feedlib.Flavour) (bool, error) @@ -402,12 +412,6 @@ type MutationResolver interface { ActivateRole(ctx context.Context, roleID string) (*dto.RoleOutput, error) DeactivateRole(ctx context.Context, roleID string) (*dto.RoleOutput, error) } -type PINResolver interface { - User(ctx context.Context, obj *domain.PIN) (string, error) - Pin(ctx context.Context, obj *domain.PIN) (string, error) - ConfirmedPin(ctx context.Context, obj *domain.PIN) (string, error) - Flavour(ctx context.Context, obj *domain.PIN) (feedlib.Flavour, error) -} type QueryResolver interface { FetchFacilities(ctx context.Context) ([]*domain1.Facility, error) RetrieveFacility(ctx context.Context, id string, active bool) (*domain1.Facility, error) @@ -491,6 +495,55 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Address.PlaceID(childComplexity), true + case "Addresses.Active": + if e.complexity.Addresses.Active == nil { + break + } + + return e.complexity.Addresses.Active(childComplexity), true + + case "Addresses.Country": + if e.complexity.Addresses.Country == nil { + break + } + + return e.complexity.Addresses.Country(childComplexity), true + + case "Addresses.County": + if e.complexity.Addresses.County == nil { + break + } + + return e.complexity.Addresses.County(childComplexity), true + + case "Addresses.ID": + if e.complexity.Addresses.ID == nil { + break + } + + return e.complexity.Addresses.ID(childComplexity), true + + case "Addresses.PostalCode": + if e.complexity.Addresses.PostalCode == nil { + break + } + + return e.complexity.Addresses.PostalCode(childComplexity), true + + case "Addresses.Text": + if e.complexity.Addresses.Text == nil { + break + } + + return e.complexity.Addresses.Text(childComplexity), true + + case "Addresses.Type": + if e.complexity.Addresses.Type == nil { + break + } + + return e.complexity.Addresses.Type(childComplexity), true + case "BioData.dateOfBirth": if e.complexity.BioData.DateOfBirth == nil { break @@ -1251,7 +1304,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Mutation.SetUserPin(childComplexity, args["input"].(*dto1.PINInput)), true + return e.complexity.Mutation.SetUserPin(childComplexity, args["input"].(*dto1.PinInput)), true case "Mutation.setupAsExperimentParticipant": if e.complexity.Mutation.SetupAsExperimentParticipant == nil { @@ -1418,34 +1471,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.NestedNavAction.Title(childComplexity), true - case "PIN.confirmedPin": - if e.complexity.Pin.ConfirmedPin == nil { - break - } - - return e.complexity.Pin.ConfirmedPin(childComplexity), true - - case "PIN.flavour": - if e.complexity.Pin.Flavour == nil { - break - } - - return e.complexity.Pin.Flavour(childComplexity), true - - case "PIN.pin": - if e.complexity.Pin.Pin == nil { - break - } - - return e.complexity.Pin.Pin(childComplexity), true - - case "PIN.user": - if e.complexity.Pin.User == nil { - break - } - - return e.complexity.Pin.User(childComplexity), true - case "PageInfo.endCursor": if e.complexity.PageInfo.EndCursor == nil { break @@ -1502,6 +1527,34 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Permission.Scope(childComplexity), true + case "Pin.confirmedPin": + if e.complexity.Pin.ConfirmedPin == nil { + break + } + + return e.complexity.Pin.ConfirmedPin(childComplexity), true + + case "Pin.flavour": + if e.complexity.Pin.Flavour == nil { + break + } + + return e.complexity.Pin.Flavour(childComplexity), true + + case "Pin.Pin": + if e.complexity.Pin.PIN == nil { + break + } + + return e.complexity.Pin.PIN(childComplexity), true + + case "Pin.userID": + if e.complexity.Pin.UserID == nil { + break + } + + return e.complexity.Pin.UserID(childComplexity), true + case "Query.dummyQuery": if e.complexity.Query.DummyQuery == nil { break @@ -1719,6 +1772,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.RoleOutput.Users(childComplexity), true + case "StaffProfile.addresses": + if e.complexity.StaffProfile.Addresses == nil { + break + } + + return e.complexity.StaffProfile.Addresses(childComplexity), true + case "StaffProfile.defaultFacilityID": if e.complexity.StaffProfile.DefaultFacilityID == nil { break @@ -2188,16 +2248,6 @@ var sources = []*ast.Source{ isPrimary: Boolean! ): Identifier! } -`, BuiltIn: false}, - {Name: "pkg/onboarding/presentation/graph/emum.graphql", Input: `enum ContactType { - PHONE - EMAIL -} - -enum UsersType { - HEALTHCAREWORKER - CLIENT -} `, BuiltIn: false}, {Name: "pkg/onboarding/presentation/graph/enums.graphql", Input: `enum ClientType { PMTCT @@ -2213,13 +2263,87 @@ enum IdentifierType { enum IdentifierUse { OFFICIAL TEMPORARY + OLD +} +enum ContactType { + PHONE + EMAIL +} + +enum UsersType { + HEALTHCAREWORKER + CLIENT +} + +enum CountryType { + KENYA + # other countries +} + +enum CountyType { + Mombasa + Kwale + Kilifi + Tana_River + Lamu + Taita_Taveta + Garissa + Wajir + Mandera + Marsabit + Isiolo + Meru + Tharaka_Nithi + Embu + Kitui + Machakos + Makueni + Nyandarua + Nyeri + Kirinyaga + Muranga + Kiambu + Turkana + West_Pokot + Samburu + Trans_Nzoia + Uasin_Gishu + Elgeyo_Marakwet + Nandi + Baringo + Laikipia + Nakuru + Narok + Kajiado + Kericho + Bomet + Kakamega + Vihiga + Bungoma + Busia + Siaya + Kisumu + Homa_Bay + Migori + Kisii + Nyamira + Nairobi + # other counties + +} + +enum AddressesType { + POSTAL + PHYSICAL + POSTALPHYSICAL } + `, BuiltIn: false}, {Name: "pkg/onboarding/presentation/graph/facility.graphql", Input: ` extend type Mutation { createFacility(input: FacilityInput!): Facility! deleteFacility(id: String!): Boolean! - setUserPIN(input: PINInput): Boolean! + setUserPIN(input: PinInput): Boolean! } extend type Query { @@ -2235,8 +2359,8 @@ extend type Query { description: String! } -input PINInput { - pin: String! +input PinInput { + Pin: String! confirmedPin: String! flavour: Flavour! } @@ -2248,25 +2372,25 @@ input UserInput { firstName: String! middleName: String! lastName: String! - userType: UsersType! # TODO enum; e.g client, health care worker - gender: Gender! # TODO enum; genders; keep it simple + userType: UsersType! + gender: Gender! contacts: [ContactInput!]! languages: [Language!]! flavour: Flavour! } input StaffProfileInput { - staffNumber: String! - # facilities: [FacilityInput!] + staffNumber: String! + # facilities: [FacilityInput!] defaultFacilityID: String! - # roles: [RoleType] # TODO: roles are an enum (controlled list), known to both FE and BE - # addresses: [ContactAddressInput!] + # roles: [RoleType] # TODO: roles are an enum (controlled list), known to both FE and BE + addresses: [AddressesInput!]! } input ContactInput { - Type: ContactType! + Type: ContactType! Contact: String! #TODO Validate: phones are E164, emails are valid - Active: Boolean! + Active: Boolean! #a user may opt not to be contacted via this contact #e.g if it's a shared phone owned by a teenager OptedIn: Boolean! @@ -2276,6 +2400,15 @@ input ContactInput { input ClientProfileInput { clientType: ClientType! } + +input AddressesInput { + Type: AddressesType! + Text: String! + Country: CountryType! + PostalCode: String! + County: CountyType! + Active: Boolean! +} `, BuiltIn: false}, {Name: "pkg/onboarding/presentation/graph/profile.graphql", Input: `extend type Query { testQuery: Boolean @@ -2297,9 +2430,9 @@ extend type Mutation { description: String! } -type PIN { - user: String! - pin: String! +type Pin { + userID: String! + Pin: String! confirmedPin: String! flavour: Flavour! } @@ -2343,7 +2476,7 @@ type StaffProfile { # facilities: [Facility!] defaultFacilityID: String! # roles: [String!] # TODO: roles are an enum (controlled list), known to both FE and BE - # addresses: [UserAddress!] + addresses: [Addresses!] } type StaffUserProfile { @@ -2356,7 +2489,7 @@ type ClientProfile { userID: String! clientType: ClientType active: Boolean - treatmentEnrollmentDate: Date + treatmentEnrollmentDate: Time healthRecordID: String facilityID: String treatmentBuddyUserID: String @@ -2376,11 +2509,21 @@ type Identifier { identifierUse: IdentifierUse! identifierValue: String! description: String - validFrom: Date - validTo: Date + validFrom: Time + validTo: Time active: Boolean! isPrimaryIdentifier: Boolean! } + +type Addresses { + ID: String! + Type: AddressesType! + Text: String! + Country: CountryType! + PostalCode: String! + County: CountyType! + Active: Boolean! +} `, BuiltIn: false}, {Name: "federation/directives.graphql", Input: ` scalar _Any @@ -3480,10 +3623,10 @@ func (ec *executionContext) field_Mutation_setUserCommunicationsSettings_args(ct func (ec *executionContext) field_Mutation_setUserPIN_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 *dto1.PINInput + var arg0 *dto1.PinInput if tmp, ok := rawArgs["input"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalOPINInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐPINInput(ctx, tmp) + arg0, err = ec.unmarshalOPinInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐPinInput(ctx, tmp) if err != nil { return nil, err } @@ -3950,7 +4093,7 @@ func (ec *executionContext) _Address_formattedAddress(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _BioData_firstName(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { +func (ec *executionContext) _Addresses_ID(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -3958,7 +4101,7 @@ func (ec *executionContext) _BioData_firstName(ctx context.Context, field graphq } }() fc := &graphql.FieldContext{ - Object: "BioData", + Object: "Addresses", Field: field, Args: nil, IsMethod: false, @@ -3968,21 +4111,24 @@ func (ec *executionContext) _BioData_firstName(ctx context.Context, field graphq ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.FirstName, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _BioData_lastName(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { +func (ec *executionContext) _Addresses_Type(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -3990,7 +4136,7 @@ func (ec *executionContext) _BioData_lastName(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "BioData", + Object: "Addresses", Field: field, Args: nil, IsMethod: false, @@ -4000,21 +4146,24 @@ func (ec *executionContext) _BioData_lastName(ctx context.Context, field graphql ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.LastName, nil + return obj.Type, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(enums.AddressesType) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNAddressesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐAddressesType(ctx, field.Selections, res) } -func (ec *executionContext) _BioData_dateOfBirth(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { +func (ec *executionContext) _Addresses_Text(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4022,7 +4171,7 @@ func (ec *executionContext) _BioData_dateOfBirth(ctx context.Context, field grap } }() fc := &graphql.FieldContext{ - Object: "BioData", + Object: "Addresses", Field: field, Args: nil, IsMethod: false, @@ -4032,21 +4181,24 @@ func (ec *executionContext) _BioData_dateOfBirth(ctx context.Context, field grap ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DateOfBirth, nil + return obj.Text, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*scalarutils.Date) + res := resTmp.(string) fc.Result = res - return ec.marshalODate2ᚖgithubᚗcomᚋsavannahghiᚋscalarutilsᚐDate(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _BioData_gender(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { +func (ec *executionContext) _Addresses_Country(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4054,7 +4206,7 @@ func (ec *executionContext) _BioData_gender(ctx context.Context, field graphql.C } }() fc := &graphql.FieldContext{ - Object: "BioData", + Object: "Addresses", Field: field, Args: nil, IsMethod: false, @@ -4064,21 +4216,24 @@ func (ec *executionContext) _BioData_gender(ctx context.Context, field graphql.C ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Gender, nil + return obj.Country, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(enumutils.Gender) + res := resTmp.(enums.CountryType) fc.Result = res - return ec.marshalOGender2githubᚗcomᚋsavannahghiᚋenumutilsᚐGender(ctx, field.Selections, res) + return ec.marshalNCountryType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐCountryType(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_id(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Addresses_PostalCode(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4086,7 +4241,7 @@ func (ec *executionContext) _ClientProfile_id(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Addresses", Field: field, Args: nil, IsMethod: false, @@ -4096,7 +4251,7 @@ func (ec *executionContext) _ClientProfile_id(ctx context.Context, field graphql ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.PostalCode, nil }) if err != nil { ec.Error(ctx, err) @@ -4108,12 +4263,12 @@ func (ec *executionContext) _ClientProfile_id(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalNString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_userID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Addresses_County(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4121,7 +4276,7 @@ func (ec *executionContext) _ClientProfile_userID(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Addresses", Field: field, Args: nil, IsMethod: false, @@ -4131,7 +4286,7 @@ func (ec *executionContext) _ClientProfile_userID(ctx context.Context, field gra ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.UserID, nil + return obj.County, nil }) if err != nil { ec.Error(ctx, err) @@ -4143,12 +4298,12 @@ func (ec *executionContext) _ClientProfile_userID(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(enums.CountyType) fc.Result = res - return ec.marshalNString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNCountyType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐCountyType(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_clientType(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Addresses_Active(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4156,7 +4311,7 @@ func (ec *executionContext) _ClientProfile_clientType(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Addresses", Field: field, Args: nil, IsMethod: false, @@ -4166,21 +4321,24 @@ func (ec *executionContext) _ClientProfile_clientType(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ClientType, nil + return obj.Active, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(enums.ClientType) + res := resTmp.(bool) fc.Result = res - return ec.marshalOClientType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐClientType(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_active(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _BioData_firstName(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4188,7 +4346,7 @@ func (ec *executionContext) _ClientProfile_active(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "BioData", Field: field, Args: nil, IsMethod: false, @@ -4198,7 +4356,7 @@ func (ec *executionContext) _ClientProfile_active(ctx context.Context, field gra ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Active, nil + return obj.FirstName, nil }) if err != nil { ec.Error(ctx, err) @@ -4207,12 +4365,12 @@ func (ec *executionContext) _ClientProfile_active(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*string) fc.Result = res - return ec.marshalOBoolean2bool(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_treatmentEnrollmentDate(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _BioData_lastName(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4220,7 +4378,7 @@ func (ec *executionContext) _ClientProfile_treatmentEnrollmentDate(ctx context.C } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "BioData", Field: field, Args: nil, IsMethod: false, @@ -4230,7 +4388,7 @@ func (ec *executionContext) _ClientProfile_treatmentEnrollmentDate(ctx context.C ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TreatmentEnrollmentDate, nil + return obj.LastName, nil }) if err != nil { ec.Error(ctx, err) @@ -4239,12 +4397,12 @@ func (ec *executionContext) _ClientProfile_treatmentEnrollmentDate(ctx context.C if resTmp == nil { return graphql.Null } - res := resTmp.(*scalarutils.Date) + res := resTmp.(*string) fc.Result = res - return ec.marshalODate2ᚖgithubᚗcomᚋsavannahghiᚋscalarutilsᚐDate(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_healthRecordID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _BioData_dateOfBirth(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4252,7 +4410,7 @@ func (ec *executionContext) _ClientProfile_healthRecordID(ctx context.Context, f } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "BioData", Field: field, Args: nil, IsMethod: false, @@ -4262,7 +4420,7 @@ func (ec *executionContext) _ClientProfile_healthRecordID(ctx context.Context, f ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.HealthRecordID, nil + return obj.DateOfBirth, nil }) if err != nil { ec.Error(ctx, err) @@ -4271,12 +4429,12 @@ func (ec *executionContext) _ClientProfile_healthRecordID(ctx context.Context, f if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*scalarutils.Date) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalODate2ᚖgithubᚗcomᚋsavannahghiᚋscalarutilsᚐDate(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_facilityID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _BioData_gender(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4284,7 +4442,7 @@ func (ec *executionContext) _ClientProfile_facilityID(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "BioData", Field: field, Args: nil, IsMethod: false, @@ -4294,7 +4452,7 @@ func (ec *executionContext) _ClientProfile_facilityID(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.FacilityID, nil + return obj.Gender, nil }) if err != nil { ec.Error(ctx, err) @@ -4303,12 +4461,12 @@ func (ec *executionContext) _ClientProfile_facilityID(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(enumutils.Gender) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalOGender2githubᚗcomᚋsavannahghiᚋenumutilsᚐGender(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_treatmentBuddyUserID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _ClientProfile_id(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4326,21 +4484,24 @@ func (ec *executionContext) _ClientProfile_treatmentBuddyUserID(ctx context.Cont ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TreatmentBuddyUserID, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_chvUserID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _ClientProfile_userID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4358,21 +4519,24 @@ func (ec *executionContext) _ClientProfile_chvUserID(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CHVUserID, nil + return obj.UserID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_clientCounselled(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _ClientProfile_clientType(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4390,7 +4554,7 @@ func (ec *executionContext) _ClientProfile_clientCounselled(ctx context.Context, ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ClientCounselled, nil + return obj.ClientType, nil }) if err != nil { ec.Error(ctx, err) @@ -4399,12 +4563,12 @@ func (ec *executionContext) _ClientProfile_clientCounselled(ctx context.Context, if resTmp == nil { return graphql.Null } - res := resTmp.(bool) + res := resTmp.(enums.ClientType) fc.Result = res - return ec.marshalOBoolean2bool(ctx, field.Selections, res) + return ec.marshalOClientType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐClientType(ctx, field.Selections, res) } -func (ec *executionContext) _ClientUserProfile_user(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientUserProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _ClientProfile_active(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4412,7 +4576,7 @@ func (ec *executionContext) _ClientUserProfile_user(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "ClientUserProfile", + Object: "ClientProfile", Field: field, Args: nil, IsMethod: false, @@ -4422,21 +4586,245 @@ func (ec *executionContext) _ClientUserProfile_user(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.User, nil + return obj.Active, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*domain1.User) + res := resTmp.(bool) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐUser(ctx, field.Selections, res) + return ec.marshalOBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) _ClientProfile_treatmentEnrollmentDate(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "ClientProfile", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TreatmentEnrollmentDate, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*time.Time) + fc.Result = res + return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) _ClientProfile_healthRecordID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "ClientProfile", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.HealthRecordID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _ClientProfile_facilityID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "ClientProfile", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FacilityID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _ClientProfile_treatmentBuddyUserID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "ClientProfile", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TreatmentBuddyUserID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _ClientProfile_chvUserID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "ClientProfile", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CHVUserID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _ClientProfile_clientCounselled(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "ClientProfile", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ClientCounselled, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalOBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) _ClientUserProfile_user(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientUserProfile) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "ClientUserProfile", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.User, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*domain1.User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _ClientUserProfile_client(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientUserProfile) (ret graphql.Marshaler) { @@ -5381,9 +5769,9 @@ func (ec *executionContext) _Identifier_validFrom(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.(*scalarutils.Date) + res := resTmp.(*time.Time) fc.Result = res - return ec.marshalODate2ᚖgithubᚗcomᚋsavannahghiᚋscalarutilsᚐDate(ctx, field.Selections, res) + return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Identifier_validTo(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { @@ -5413,9 +5801,9 @@ func (ec *executionContext) _Identifier_validTo(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.(*scalarutils.Date) + res := resTmp.(*time.Time) fc.Result = res - return ec.marshalODate2ᚖgithubᚗcomᚋsavannahghiᚋscalarutilsᚐDate(ctx, field.Selections, res) + return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Identifier_active(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { @@ -6013,7 +6401,7 @@ func (ec *executionContext) _Mutation_setUserPIN(ctx context.Context, field grap fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().SetUserPin(rctx, args["input"].(*dto1.PINInput)) + return ec.resolvers.Mutation().SetUserPin(rctx, args["input"].(*dto1.PinInput)) }) if err != nil { ec.Error(ctx, err) @@ -7808,7 +8196,7 @@ func (ec *executionContext) _NestedNavAction_onTapRoute(ctx context.Context, fie return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _PIN_user(ctx context.Context, field graphql.CollectedField, obj *domain.PIN) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -7816,17 +8204,17 @@ func (ec *executionContext) _PIN_user(ctx context.Context, field graphql.Collect } }() fc := &graphql.FieldContext{ - Object: "PIN", + Object: "PageInfo", Field: field, Args: nil, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.PIN().User(rctx, obj) + return obj.HasNextPage, nil }) if err != nil { ec.Error(ctx, err) @@ -7838,12 +8226,12 @@ func (ec *executionContext) _PIN_user(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _PIN_pin(ctx context.Context, field graphql.CollectedField, obj *domain.PIN) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -7851,17 +8239,17 @@ func (ec *executionContext) _PIN_pin(ctx context.Context, field graphql.Collecte } }() fc := &graphql.FieldContext{ - Object: "PIN", + Object: "PageInfo", Field: field, Args: nil, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.PIN().Pin(rctx, obj) + return obj.HasPreviousPage, nil }) if err != nil { ec.Error(ctx, err) @@ -7873,12 +8261,12 @@ func (ec *executionContext) _PIN_pin(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _PIN_confirmedPin(ctx context.Context, field graphql.CollectedField, obj *domain.PIN) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -7886,34 +8274,31 @@ func (ec *executionContext) _PIN_confirmedPin(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "PIN", + Object: "PageInfo", Field: field, Args: nil, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.PIN().ConfirmedPin(rctx, obj) + return obj.StartCursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _PIN_flavour(ctx context.Context, field graphql.CollectedField, obj *domain.PIN) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -7921,34 +8306,31 @@ func (ec *executionContext) _PIN_flavour(ctx context.Context, field graphql.Coll } }() fc := &graphql.FieldContext{ - Object: "PIN", + Object: "PageInfo", Field: field, Args: nil, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.PIN().Flavour(rctx, obj) + return obj.EndCursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(feedlib.Flavour) + res := resTmp.(*string) fc.Result = res - return ec.marshalNFlavour2githubᚗcomᚋsavannahghiᚋfeedlibᚐFlavour(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { +func (ec *executionContext) _Permission_scope(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -7956,7 +8338,7 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "PageInfo", + Object: "Permission", Field: field, Args: nil, IsMethod: false, @@ -7966,7 +8348,7 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.HasNextPage, nil + return obj.Scope, nil }) if err != nil { ec.Error(ctx, err) @@ -7978,12 +8360,12 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { +func (ec *executionContext) _Permission_description(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -7991,7 +8373,7 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "PageInfo", + Object: "Permission", Field: field, Args: nil, IsMethod: false, @@ -8001,7 +8383,7 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.HasPreviousPage, nil + return obj.Description, nil }) if err != nil { ec.Error(ctx, err) @@ -8013,12 +8395,12 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { +func (ec *executionContext) _Permission_group(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8026,7 +8408,7 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "PageInfo", + Object: "Permission", Field: field, Args: nil, IsMethod: false, @@ -8036,21 +8418,24 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.StartCursor, nil + return obj.Group, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(profileutils.PermissionGroup) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNPermissionGroup2githubᚗcomᚋsavannahghiᚋprofileutilsᚐPermissionGroup(ctx, field.Selections, res) } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { +func (ec *executionContext) _Permission_allowed(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8058,7 +8443,7 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph } }() fc := &graphql.FieldContext{ - Object: "PageInfo", + Object: "Permission", Field: field, Args: nil, IsMethod: false, @@ -8068,21 +8453,24 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EndCursor, nil + return obj.Allowed, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Permission_scope(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { +func (ec *executionContext) _Pin_userID(ctx context.Context, field graphql.CollectedField, obj *domain1.Pin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8090,7 +8478,7 @@ func (ec *executionContext) _Permission_scope(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "Permission", + Object: "Pin", Field: field, Args: nil, IsMethod: false, @@ -8100,7 +8488,7 @@ func (ec *executionContext) _Permission_scope(ctx context.Context, field graphql ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Scope, nil + return obj.UserID, nil }) if err != nil { ec.Error(ctx, err) @@ -8117,7 +8505,7 @@ func (ec *executionContext) _Permission_scope(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Permission_description(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { +func (ec *executionContext) _Pin_Pin(ctx context.Context, field graphql.CollectedField, obj *domain1.Pin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8125,7 +8513,7 @@ func (ec *executionContext) _Permission_description(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "Permission", + Object: "Pin", Field: field, Args: nil, IsMethod: false, @@ -8135,7 +8523,7 @@ func (ec *executionContext) _Permission_description(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.PIN, nil }) if err != nil { ec.Error(ctx, err) @@ -8152,7 +8540,7 @@ func (ec *executionContext) _Permission_description(ctx context.Context, field g return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Permission_group(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { +func (ec *executionContext) _Pin_confirmedPin(ctx context.Context, field graphql.CollectedField, obj *domain1.Pin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8160,7 +8548,7 @@ func (ec *executionContext) _Permission_group(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "Permission", + Object: "Pin", Field: field, Args: nil, IsMethod: false, @@ -8170,7 +8558,7 @@ func (ec *executionContext) _Permission_group(ctx context.Context, field graphql ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Group, nil + return obj.ConfirmedPin, nil }) if err != nil { ec.Error(ctx, err) @@ -8182,12 +8570,12 @@ func (ec *executionContext) _Permission_group(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(profileutils.PermissionGroup) + res := resTmp.(string) fc.Result = res - return ec.marshalNPermissionGroup2githubᚗcomᚋsavannahghiᚋprofileutilsᚐPermissionGroup(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Permission_allowed(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { +func (ec *executionContext) _Pin_flavour(ctx context.Context, field graphql.CollectedField, obj *domain1.Pin) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8195,7 +8583,7 @@ func (ec *executionContext) _Permission_allowed(ctx context.Context, field graph } }() fc := &graphql.FieldContext{ - Object: "Permission", + Object: "Pin", Field: field, Args: nil, IsMethod: false, @@ -8205,7 +8593,7 @@ func (ec *executionContext) _Permission_allowed(ctx context.Context, field graph ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Allowed, nil + return obj.Flavour, nil }) if err != nil { ec.Error(ctx, err) @@ -8217,9 +8605,9 @@ func (ec *executionContext) _Permission_allowed(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(feedlib.Flavour) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNFlavour2githubᚗcomᚋsavannahghiᚋfeedlibᚐFlavour(ctx, field.Selections, res) } func (ec *executionContext) _Query_fetchFacilities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { @@ -9356,6 +9744,38 @@ func (ec *executionContext) _StaffProfile_defaultFacilityID(ctx context.Context, return ec.marshalNString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) _StaffProfile_addresses(ctx context.Context, field graphql.CollectedField, obj *domain1.StaffProfile) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "StaffProfile", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Addresses, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*domain1.Addresses) + fc.Result = res + return ec.marshalOAddresses2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐAddressesᚄ(ctx, field.Selections, res) +} + func (ec *executionContext) _StaffUserProfile_user(ctx context.Context, field graphql.CollectedField, obj *domain1.StaffUserProfile) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -12173,6 +12593,66 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** +func (ec *executionContext) unmarshalInputAddressesInput(ctx context.Context, obj interface{}) (dto1.AddressesInput, error) { + var it dto1.AddressesInput + var asMap = obj.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "Type": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Type")) + it.Type, err = ec.unmarshalNAddressesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐAddressesType(ctx, v) + if err != nil { + return it, err + } + case "Text": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Text")) + it.Text, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "Country": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Country")) + it.Country, err = ec.unmarshalNCountryType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐCountryType(ctx, v) + if err != nil { + return it, err + } + case "PostalCode": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("PostalCode")) + it.PostalCode, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "County": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("County")) + it.County, err = ec.unmarshalNCountyType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐCountyType(ctx, v) + if err != nil { + return it, err + } + case "Active": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Active")) + it.Active, err = ec.unmarshalNBoolean2bool(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputClientProfileInput(ctx context.Context, obj interface{}) (dto1.ClientProfileInput, error) { var it dto1.ClientProfileInput var asMap = obj.(map[string]interface{}) @@ -12397,33 +12877,41 @@ func (ec *executionContext) unmarshalInputMicroserviceInput(ctx context.Context, return it, nil } -func (ec *executionContext) unmarshalInputPINInput(ctx context.Context, obj interface{}) (dto1.PINInput, error) { - var it dto1.PINInput +func (ec *executionContext) unmarshalInputPaginationInput(ctx context.Context, obj interface{}) (firebasetools.PaginationInput, error) { + var it firebasetools.PaginationInput var asMap = obj.(map[string]interface{}) for k, v := range asMap { switch k { - case "pin": + case "first": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pin")) - it.PIN, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + it.First, err = ec.unmarshalOInt2int(ctx, v) if err != nil { return it, err } - case "confirmedPin": + case "last": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("confirmedPin")) - it.ConfirmedPin, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) + it.Last, err = ec.unmarshalOInt2int(ctx, v) if err != nil { return it, err } - case "flavour": + case "after": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("flavour")) - it.Flavour, err = ec.unmarshalNFlavour2githubᚗcomᚋsavannahghiᚋfeedlibᚐFlavour(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + it.After, err = ec.unmarshalOString2string(ctx, v) + if err != nil { + return it, err + } + case "before": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) + it.Before, err = ec.unmarshalOString2string(ctx, v) if err != nil { return it, err } @@ -12433,41 +12921,33 @@ func (ec *executionContext) unmarshalInputPINInput(ctx context.Context, obj inte return it, nil } -func (ec *executionContext) unmarshalInputPaginationInput(ctx context.Context, obj interface{}) (firebasetools.PaginationInput, error) { - var it firebasetools.PaginationInput +func (ec *executionContext) unmarshalInputPinInput(ctx context.Context, obj interface{}) (dto1.PinInput, error) { + var it dto1.PinInput var asMap = obj.(map[string]interface{}) for k, v := range asMap { switch k { - case "first": + case "Pin": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - it.First, err = ec.unmarshalOInt2int(ctx, v) - if err != nil { - return it, err - } - case "last": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - it.Last, err = ec.unmarshalOInt2int(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Pin")) + it.PIN, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - case "after": + case "confirmedPin": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - it.After, err = ec.unmarshalOString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("confirmedPin")) + it.ConfirmedPin, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - case "before": + case "flavour": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - it.Before, err = ec.unmarshalOString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("flavour")) + it.Flavour, err = ec.unmarshalNFlavour2githubᚗcomᚋsavannahghiᚋfeedlibᚐFlavour(ctx, v) if err != nil { return it, err } @@ -12683,6 +13163,14 @@ func (ec *executionContext) unmarshalInputStaffProfileInput(ctx context.Context, if err != nil { return it, err } + case "addresses": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addresses")) + it.Addresses, err = ec.unmarshalNAddressesInput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐAddressesInputᚄ(ctx, v) + if err != nil { + return it, err + } } } @@ -12964,6 +13452,63 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, return out } +var addressesImplementors = []string{"Addresses"} + +func (ec *executionContext) _Addresses(ctx context.Context, sel ast.SelectionSet, obj *domain1.Addresses) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, addressesImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Addresses") + case "ID": + out.Values[i] = ec._Addresses_ID(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "Type": + out.Values[i] = ec._Addresses_Type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "Text": + out.Values[i] = ec._Addresses_Text(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "Country": + out.Values[i] = ec._Addresses_Country(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "PostalCode": + out.Values[i] = ec._Addresses_PostalCode(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "County": + out.Values[i] = ec._Addresses_County(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "Active": + out.Values[i] = ec._Addresses_Active(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + var bioDataImplementors = []string{"BioData"} func (ec *executionContext) _BioData(ctx context.Context, sel ast.SelectionSet, obj *profileutils.BioData) graphql.Marshaler { @@ -13761,84 +14306,6 @@ func (ec *executionContext) _NestedNavAction(ctx context.Context, sel ast.Select return out } -var pINImplementors = []string{"PIN"} - -func (ec *executionContext) _PIN(ctx context.Context, sel ast.SelectionSet, obj *domain.PIN) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, pINImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("PIN") - case "user": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._PIN_user(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "pin": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._PIN_pin(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "confirmedPin": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._PIN_confirmedPin(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "flavour": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._PIN_flavour(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - var pageInfoImplementors = []string{"PageInfo", "_Entity"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *firebasetools.PageInfo) graphql.Marshaler { @@ -13917,6 +14384,48 @@ func (ec *executionContext) _Permission(ctx context.Context, sel ast.SelectionSe return out } +var pinImplementors = []string{"Pin"} + +func (ec *executionContext) _Pin(ctx context.Context, sel ast.SelectionSet, obj *domain1.Pin) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, pinImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Pin") + case "userID": + out.Values[i] = ec._Pin_userID(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "Pin": + out.Values[i] = ec._Pin_Pin(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "confirmedPin": + out.Values[i] = ec._Pin_confirmedPin(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "flavour": + out.Values[i] = ec._Pin_flavour(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -14265,6 +14774,8 @@ func (ec *executionContext) _StaffProfile(ctx context.Context, sel ast.Selection if out.Values[i] == graphql.Null { invalids++ } + case "addresses": + out.Values[i] = ec._StaffProfile_addresses(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -14909,6 +15420,52 @@ func (ec *executionContext) marshalNAddressType2githubᚗcomᚋsavannahghiᚋenu return v } +func (ec *executionContext) marshalNAddresses2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐAddresses(ctx context.Context, sel ast.SelectionSet, v *domain1.Addresses) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._Addresses(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNAddressesInput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐAddressesInputᚄ(ctx context.Context, v interface{}) ([]*dto1.AddressesInput, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]*dto1.AddressesInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNAddressesInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐAddressesInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalNAddressesInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐAddressesInput(ctx context.Context, v interface{}) (*dto1.AddressesInput, error) { + res, err := ec.unmarshalInputAddressesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNAddressesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐAddressesType(ctx context.Context, v interface{}) (enums.AddressesType, error) { + var res enums.AddressesType + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNAddressesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐAddressesType(ctx context.Context, sel ast.SelectionSet, v enums.AddressesType) graphql.Marshaler { + return v +} + func (ec *executionContext) unmarshalNAny2interface(ctx context.Context, v interface{}) (interface{}, error) { res, err := graphql.UnmarshalAny(v) return res, graphql.ErrorOnPath(ctx, err) @@ -15067,6 +15624,26 @@ func (ec *executionContext) marshalNContactType2githubᚗcomᚋsavannahghiᚋonb return v } +func (ec *executionContext) unmarshalNCountryType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐCountryType(ctx context.Context, v interface{}) (enums.CountryType, error) { + var res enums.CountryType + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNCountryType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐCountryType(ctx context.Context, sel ast.SelectionSet, v enums.CountryType) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNCountyType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐCountyType(ctx context.Context, v interface{}) (enums.CountyType, error) { + var res enums.CountyType + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNCountyType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐCountyType(ctx context.Context, sel ast.SelectionSet, v enums.CountyType) graphql.Marshaler { + return v +} + func (ec *executionContext) unmarshalNDate2githubᚗcomᚋsavannahghiᚋscalarutilsᚐDate(ctx context.Context, v interface{}) (scalarutils.Date, error) { var res scalarutils.Date err := res.UnmarshalGQL(v) @@ -16038,6 +16615,46 @@ func (ec *executionContext) marshalOAddress2ᚖgithubᚗcomᚋsavannahghiᚋprof return ec._Address(ctx, sel, v) } +func (ec *executionContext) marshalOAddresses2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐAddressesᚄ(ctx context.Context, sel ast.SelectionSet, v []*domain1.Addresses) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNAddresses2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐAddresses(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + func (ec *executionContext) unmarshalOAny2interface(ctx context.Context, v interface{}) (interface{}, error) { if v == nil { return nil, nil @@ -16580,14 +17197,6 @@ func (ec *executionContext) marshalONestedNavAction2ᚕgithubᚗcomᚋsavannahgh return ret } -func (ec *executionContext) unmarshalOPINInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐPINInput(ctx context.Context, v interface{}) (*dto1.PINInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputPINInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) marshalOPermission2githubᚗcomᚋsavannahghiᚋprofileutilsᚐPermission(ctx context.Context, sel ast.SelectionSet, v profileutils.Permission) graphql.Marshaler { return ec._Permission(ctx, sel, &v) } @@ -16696,6 +17305,14 @@ func (ec *executionContext) marshalOPermissionType2ᚕgithubᚗcomᚋsavannahghi return ret } +func (ec *executionContext) unmarshalOPinInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐPinInput(ctx context.Context, v interface{}) (*dto1.PinInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputPinInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalORoleOutput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx context.Context, sel ast.SelectionSet, v []*dto.RoleOutput) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/pkg/onboarding/presentation/graph/input.graphql b/pkg/onboarding/presentation/graph/input.graphql index ab991e89..2b9f75e2 100644 --- a/pkg/onboarding/presentation/graph/input.graphql +++ b/pkg/onboarding/presentation/graph/input.graphql @@ -6,8 +6,8 @@ input FacilityInput { description: String! } -input PINInput { - pin: String! +input PinInput { + Pin: String! confirmedPin: String! flavour: Flavour! } @@ -19,25 +19,25 @@ input UserInput { firstName: String! middleName: String! lastName: String! - userType: UsersType! # TODO enum; e.g client, health care worker - gender: Gender! # TODO enum; genders; keep it simple + userType: UsersType! + gender: Gender! contacts: [ContactInput!]! languages: [Language!]! flavour: Flavour! } input StaffProfileInput { - staffNumber: String! - # facilities: [FacilityInput!] + staffNumber: String! + # facilities: [FacilityInput!] defaultFacilityID: String! - # roles: [RoleType] # TODO: roles are an enum (controlled list), known to both FE and BE - # addresses: [ContactAddressInput!] + # roles: [RoleType] # TODO: roles are an enum (controlled list), known to both FE and BE + addresses: [AddressesInput!]! } input ContactInput { - Type: ContactType! + Type: ContactType! Contact: String! #TODO Validate: phones are E164, emails are valid - Active: Boolean! + Active: Boolean! #a user may opt not to be contacted via this contact #e.g if it's a shared phone owned by a teenager OptedIn: Boolean! @@ -47,3 +47,12 @@ input ContactInput { input ClientProfileInput { clientType: ClientType! } + +input AddressesInput { + Type: AddressesType! + Text: String! + Country: CountryType! + PostalCode: String! + County: CountyType! + Active: Boolean! +} diff --git a/pkg/onboarding/presentation/graph/types.graphql b/pkg/onboarding/presentation/graph/types.graphql index ca02b6b3..d7958b87 100644 --- a/pkg/onboarding/presentation/graph/types.graphql +++ b/pkg/onboarding/presentation/graph/types.graphql @@ -7,9 +7,9 @@ type Facility { description: String! } -type PIN { - user: String! - pin: String! +type Pin { + userID: String! + Pin: String! confirmedPin: String! flavour: Flavour! } @@ -53,7 +53,7 @@ type StaffProfile { # facilities: [Facility!] defaultFacilityID: String! # roles: [String!] # TODO: roles are an enum (controlled list), known to both FE and BE - # addresses: [UserAddress!] + addresses: [Addresses!] } type StaffUserProfile { @@ -66,7 +66,7 @@ type ClientProfile { userID: String! clientType: ClientType active: Boolean - treatmentEnrollmentDate: Date + treatmentEnrollmentDate: Time healthRecordID: String facilityID: String treatmentBuddyUserID: String @@ -86,8 +86,18 @@ type Identifier { identifierUse: IdentifierUse! identifierValue: String! description: String - validFrom: Date - validTo: Date + validFrom: Time + validTo: Time active: Boolean! isPrimaryIdentifier: Boolean! } + +type Addresses { + ID: String! + Type: AddressesType! + Text: String! + Country: CountryType! + PostalCode: String! + County: CountyType! + Active: Boolean! +} diff --git a/pkg/onboarding/presentation/graph/types.resolvers.go b/pkg/onboarding/presentation/graph/types.resolvers.go deleted file mode 100644 index cd736b26..00000000 --- a/pkg/onboarding/presentation/graph/types.resolvers.go +++ /dev/null @@ -1,34 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. - -import ( - "context" - "fmt" - - "github.com/savannahghi/feedlib" - "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/graph/generated" - "github.com/savannahghi/onboarding/pkg/onboarding/domain" -) - -func (r *pINResolver) User(ctx context.Context, obj *domain.PIN) (string, error) { - panic(fmt.Errorf("not implemented")) -} - -func (r *pINResolver) Pin(ctx context.Context, obj *domain.PIN) (string, error) { - panic(fmt.Errorf("not implemented")) -} - -func (r *pINResolver) ConfirmedPin(ctx context.Context, obj *domain.PIN) (string, error) { - panic(fmt.Errorf("not implemented")) -} - -func (r *pINResolver) Flavour(ctx context.Context, obj *domain.PIN) (feedlib.Flavour, error) { - panic(fmt.Errorf("not implemented")) -} - -// PIN returns generated.PINResolver implementation. -func (r *Resolver) PIN() generated.PINResolver { return &pINResolver{r} } - -type pINResolver struct{ *Resolver } diff --git a/pkg/onboarding/usecases/mock/usecase_mock.go b/pkg/onboarding/usecases/mock/usecase_mock.go index f23f6ede..76c9d6e9 100644 --- a/pkg/onboarding/usecases/mock/usecase_mock.go +++ b/pkg/onboarding/usecases/mock/usecase_mock.go @@ -109,6 +109,17 @@ func NewCreateMock() *CreateMock { UserID: &ID, StaffNumber: "s123", DefaultFacilityID: &ID, + Addresses: []*domain.Addresses{ + { + ID: ID, + Type: enums.AddressesTypePhysical, + Text: "test", + Country: enums.CountryTypeKenya, + PostalCode: "test code", + County: enums.CountyTypeBaringo, + Active: true, + }, + }, }, }, nil }, diff --git a/pkg/onboarding/usecases/staff/staff_integration_test.go b/pkg/onboarding/usecases/staff/staff_integration_test.go index 3c303ea7..c81ddbaa 100644 --- a/pkg/onboarding/usecases/staff/staff_integration_test.go +++ b/pkg/onboarding/usecases/staff/staff_integration_test.go @@ -60,6 +60,16 @@ func TestUseCaseStaffProfileImpl_RegisterStaffUser(t *testing.T) { staffInput := &dto.StaffProfileInput{ StaffNumber: staffID, DefaultFacilityID: facility.ID, + Addresses: []*dto.AddressesInput{ + { + Type: enums.AddressesTypePhysical, + Text: "test", + Country: enums.CountryTypeKenya, + PostalCode: "test code", + County: enums.CountyTypeNakuru, + Active: true, + }, + }, } // Second set of valid Inputs @@ -87,6 +97,16 @@ func TestUseCaseStaffProfileImpl_RegisterStaffUser(t *testing.T) { staffInpu2 := &dto.StaffProfileInput{ StaffNumber: staffID2, DefaultFacilityID: facility.ID, + Addresses: []*dto.AddressesInput{ + { + Type: enums.AddressesTypePhysical, + Text: "test", + Country: enums.CountryTypeKenya, + PostalCode: "test code", + County: enums.CountyTypeBaringo, + Active: true, + }, + }, } // Invalid facility id @@ -95,8 +115,57 @@ func TestUseCaseStaffProfileImpl_RegisterStaffUser(t *testing.T) { DefaultFacilityID: &testFacilityID, } + // Invalid country input + staffInputInvalidCountry := &dto.StaffProfileInput{ + StaffNumber: staffID2, + DefaultFacilityID: facility.ID, + Addresses: []*dto.AddressesInput{ + { + Type: enums.AddressesTypePhysical, + Text: "test", + Country: "Invalid", + PostalCode: "test code", + County: enums.CountyTypeBaringo, + Active: true, + }, + }, + } + + // Invalid county input + staffInputInvalidCounty := &dto.StaffProfileInput{ + StaffNumber: staffID2, + DefaultFacilityID: facility.ID, + Addresses: []*dto.AddressesInput{ + { + Type: enums.AddressesTypePhysical, + Text: "test", + Country: enums.CountryTypeKenya, + PostalCode: "test code", + County: "Invalid", + Active: true, + }, + }, + } + + // invalid: non existent facility assignment + useStaffProfile, err := f.RegisterStaffUser(ctx, userInput, staffInputNoFacility) + assert.Nil(t, useStaffProfile) + assert.NotNil(t, err) + + // invalid: non existent country + useStaffProfile, err = f.RegisterStaffUser(ctx, userInput, staffInputInvalidCountry) + assert.Nil(t, useStaffProfile) + assert.NotNil(t, err) + + // invalid: non existent county + useStaffProfile, err = f.RegisterStaffUser(ctx, userInput, staffInputInvalidCounty) + assert.Nil(t, useStaffProfile) + assert.NotNil(t, err) + + // TODO:add case where county is valid but does not belong to country after another country is available + //valid: create a staff user with valid parameters - useStaffProfile, err := f.RegisterStaffUser(ctx, userInput, staffInput) + useStaffProfile, err = f.RegisterStaffUser(ctx, userInput, staffInput) assert.Nil(t, err) assert.NotNil(t, useStaffProfile) @@ -120,11 +189,6 @@ func TestUseCaseStaffProfileImpl_RegisterStaffUser(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, useStaffProfile) - // invalid: non existent facility assignment - useStaffProfile, err = f.RegisterStaffUser(ctx, userInput, staffInputNoFacility) - assert.Nil(t, useStaffProfile) - assert.NotNil(t, err) - // TODO: teardown the user and replace randomdata with gofakeit } diff --git a/pkg/onboarding/usecases/staff/staff_unit_test.go b/pkg/onboarding/usecases/staff/staff_unit_test.go index 66f0b05b..6dbbe038 100644 --- a/pkg/onboarding/usecases/staff/staff_unit_test.go +++ b/pkg/onboarding/usecases/staff/staff_unit_test.go @@ -133,6 +133,17 @@ func TestOnboardingDb_RegisterStaffUser(t *testing.T) { UserID: &testUserID, StaffNumber: "s123", DefaultFacilityID: &testFacilityID, + Addresses: []*domain.Addresses{ + { + ID: testID, + Type: enums.AddressesTypePhysical, + Text: "test", + Country: enums.CountryTypeKenya, + PostalCode: "test code", + County: enums.CountyTypeBaringo, + Active: true, + }, + }, }, }, nil } diff --git a/pkg/onboarding/usecases/user/user.go b/pkg/onboarding/usecases/user/user.go index bde26aa0..c8753efb 100644 --- a/pkg/onboarding/usecases/user/user.go +++ b/pkg/onboarding/usecases/user/user.go @@ -86,7 +86,7 @@ type ISetUserPIN interface { // entry in the table; and also invalidate past PINs. // it means that the same table can be used to check for PIN reuse. // TODO: all PINs are hashed - SetUserPIN(ctx context.Context, input *dto.PINInput) (bool, error) + SetUserPIN(ctx context.Context, input *dto.PinInput) (bool, error) } // ResetPIN ... @@ -316,7 +316,7 @@ func (us *UseCasesUserImpl) Invite(userID string, flavour string) (bool, error) } // SetUserPIN sets a user's PIN. -func (us *UseCasesUserImpl) SetUserPIN(ctx context.Context, input *dto.PINInput) (bool, error) { +func (us *UseCasesUserImpl) SetUserPIN(ctx context.Context, input *dto.PinInput) (bool, error) { //Get user profile PIN err := utils.ValidatePIN(input.PIN) diff --git a/pkg/onboarding/usecases/user/user_integration_test.go b/pkg/onboarding/usecases/user/user_integration_test.go index 336b2bae..49b9293c 100644 --- a/pkg/onboarding/usecases/user/user_integration_test.go +++ b/pkg/onboarding/usecases/user/user_integration_test.go @@ -21,19 +21,19 @@ func TestUseCasesUserImpl_SetUserPIN_Integration(t *testing.T) { m := testInfrastructureInteractor - validPINInput := &dto.PINInput{ + validPINInput := &dto.PinInput{ PIN: "1234", ConfirmedPin: "1234", Flavour: feedlib.FlavourConsumer, } - invalidPINInput := &dto.PINInput{ + invalidPINInput := &dto.PinInput{ PIN: "12", ConfirmedPin: "1234", Flavour: "CONSUMER", } - invalidPINInput2 := &dto.PINInput{ + invalidPINInput2 := &dto.PinInput{ PIN: "", ConfirmedPin: "", Flavour: "CONSUMER", @@ -119,7 +119,7 @@ func TestUseCasesUserImpl_Login_Integration_Test(t *testing.T) { assert.NotNil(t, encodedPIN) assert.NotNil(t, salt) - PINInput := &domain.UserPIN{ + PinInput := &domain.UserPIN{ UserID: *staffUserProfile.User.ID, HashedPIN: encodedPIN, ValidFrom: time.Now(), @@ -129,7 +129,7 @@ func TestUseCasesUserImpl_Login_Integration_Test(t *testing.T) { Salt: salt, } - isSet, err := m.SetUserPIN(ctx, PINInput) + isSet, err := m.SetUserPIN(ctx, PinInput) assert.Nil(t, err) assert.Equal(t, true, isSet) diff --git a/pkg/onboarding/usecases/user/user_unit_test.go b/pkg/onboarding/usecases/user/user_unit_test.go index 672f3c3a..d2938294 100644 --- a/pkg/onboarding/usecases/user/user_unit_test.go +++ b/pkg/onboarding/usecases/user/user_unit_test.go @@ -16,13 +16,13 @@ func TestUseCasesUserImpl_SetUserPIN_Unittest(t *testing.T) { f := testFakeInfrastructureInteractor - validPINInput := &dto.PINInput{ + validPINInput := &dto.PinInput{ PIN: "1234", ConfirmedPin: "1234", Flavour: feedlib.FlavourConsumer, } - invalidPINInput := &dto.PINInput{ + invalidPINInput := &dto.PinInput{ PIN: "", ConfirmedPin: "1234", Flavour: "CONSUMER", @@ -30,7 +30,7 @@ func TestUseCasesUserImpl_SetUserPIN_Unittest(t *testing.T) { type args struct { ctx context.Context - input *dto.PINInput + input *dto.PinInput } tests := []struct { name string