diff --git a/go.mod b/go.mod index 0f73d4fb..275ea01d 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,6 @@ require ( firebase.google.com/go v3.13.0+incompatible github.com/99designs/gqlgen v0.13.0 github.com/GoogleCloudPlatform/cloudsql-proxy v1.26.0 - github.com/Pallinder/go-randomdata v1.2.0 github.com/casbin/casbin/v2 v2.31.3 github.com/google/uuid v1.3.0 github.com/gorilla/handlers v1.5.1 @@ -22,7 +21,6 @@ require ( github.com/lib/pq v1.10.3 github.com/savannahghi/converterandformatter v0.0.9 github.com/savannahghi/enumutils v0.0.3 - github.com/savannahghi/errorcodeutil v0.0.1 github.com/savannahghi/feedlib v0.0.4 github.com/savannahghi/firebasetools v0.0.15 github.com/savannahghi/interserviceclient v0.0.13 @@ -32,7 +30,6 @@ require ( github.com/savannahghi/serverutils v0.0.6 github.com/segmentio/ksuid v1.0.4 github.com/sirupsen/logrus v1.8.1 - github.com/stretchr/testify v1.7.0 github.com/tj/assert v0.0.3 github.com/vektah/gqlparser/v2 v2.1.0 go.opencensus.io v0.23.0 @@ -41,5 +38,4 @@ require ( gorm.io/datatypes v1.0.2 gorm.io/driver/postgres v1.1.2 gorm.io/gorm v1.21.16 - moul.io/http2curl v1.0.0 // indirect ) diff --git a/go.sum b/go.sum index 8b38c9d4..5e3e3ce2 100644 --- a/go.sum +++ b/go.sum @@ -88,8 +88,6 @@ github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/Pallinder/go-randomdata v1.2.0 h1:DZ41wBchNRb/0GfsePLiSwb0PHZmT67XY00lCDlaYPg= -github.com/Pallinder/go-randomdata v1.2.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y= github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= @@ -340,7 +338,6 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1 h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= @@ -476,7 +473,6 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= @@ -685,9 +681,7 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= @@ -1334,8 +1328,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -moul.io/http2curl v1.0.0 h1:6XwpyZOYsgZJrU8exnG87ncVkU1FVCcTRpwzOkTDUi8= -moul.io/http2curl v1.0.0/go.mod h1:f6cULg+e4Md/oW1cYmwW4IWQOVl2lGbmCNGOHvzX2kE= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/pkg/onboarding/infrastructure/database/postgres/gorm/create.go b/pkg/onboarding/infrastructure/database/postgres/gorm/create.go index bf9fede7..543501ae 100644 --- a/pkg/onboarding/infrastructure/database/postgres/gorm/create.go +++ b/pkg/onboarding/infrastructure/database/postgres/gorm/create.go @@ -8,19 +8,6 @@ import ( // Create contains all the methods used to perform a create operation in DB type Create interface { GetOrCreateFacility(ctx context.Context, facility *Facility) (*Facility, error) - CollectMetrics(ctx context.Context, metrics *Metric) (*Metric, error) - SavePin(ctx context.Context, pinData *PINData) (bool, error) - RegisterStaffUser(ctx context.Context, user *User, staff *StaffProfile) (*StaffUserProfile, error) - RegisterClient( - ctx context.Context, - userInput *User, - clientInput *ClientProfile, - ) (*ClientUserProfile, error) - - AddIdentifier( - ctx context.Context, - identifier *Identifier, - ) (*Identifier, error) } // GetOrCreateFacility ... @@ -33,115 +20,3 @@ func (db *PGInstance) GetOrCreateFacility(ctx context.Context, facility *Facilit return facility, nil } - -// SavePin does the actual saving of the users PIN in the database -func (db *PGInstance) SavePin(ctx context.Context, pinData *PINData) (bool, error) { - err := db.DB.Create(pinData).Error - - if err != nil { - return false, fmt.Errorf("failed to save pin data: %v", err) - } - - return true, nil -} - -// CollectMetrics takes the collected metrics and saves them in the database. -func (db *PGInstance) CollectMetrics(ctx context.Context, metrics *Metric) (*Metric, error) { - err := db.DB.Create(metrics).Error - - if err != nil { - return nil, fmt.Errorf("failed to create a facility: %v", err) - } - - return metrics, nil -} - -// RegisterStaffUser creates both the user profile and the staff profile. -func (db *PGInstance) RegisterStaffUser(ctx context.Context, user *User, staff *StaffProfile) (*StaffUserProfile, error) { - // Initialize a database transaction - tx := db.DB.Begin() - defer func() { - if r := recover(); r != nil { - tx.Rollback() - } - }() - if err := tx.Error; err != nil { - return nil, fmt.Errorf("failied initialize database transaction %v", err) - } - - // create a user profile, then rollback the transaction if it is unsuccessful - if err := tx.Create(user).Error; err != nil { - tx.Rollback() - return nil, fmt.Errorf("failed to create a user %v", err) - } - - // assign userID in staff a value due to foreign keys constraint - staff.UserID = user.UserID - - // create a staff profile, then rollback the transaction if it is unsuccessful - if err := tx.Create(staff).Error; err != nil { - tx.Rollback() - return nil, fmt.Errorf("failed to create a staff profile %v", err) - } - - // try to commit the transactions - if err := tx.Commit().Error; err != nil { - tx.Rollback() - return nil, fmt.Errorf("transaction commit to create a staff profile failed: %v", err) - } - - return &StaffUserProfile{ - User: user, - Staff: staff, - }, nil -} - -// RegisterClient picks the clients registration details and saves them in the database -func (db *PGInstance) RegisterClient( - ctx context.Context, - user *User, - clientProfile *ClientProfile, -) (*ClientUserProfile, error) { - // begin a transaction - tx := db.DB.Begin() - defer func() { - if r := recover(); r != nil { - tx.Rollback() - } - }() - - if err := tx.Error; err != nil { - return nil, err - } - - if err := tx.Create(user).Error; err != nil { - tx.Rollback() - return nil, fmt.Errorf("failed to create a user %v", err) - } - - clientProfile.UserID = user.UserID - - if err := tx.Create(clientProfile).Error; err != nil { - tx.Rollback() - return nil, fmt.Errorf("failed to create a client profile %v", err) - } - - if err := tx.Commit().Error; err != nil { - tx.Rollback() - return nil, fmt.Errorf("transaction commit to create a staff profile failed: %v", err) - } - - return &ClientUserProfile{ - User: user, - Client: clientProfile, - }, nil - -} - -// AddIdentifier saves a client's identifier record to the database -func (db *PGInstance) AddIdentifier(ctx context.Context, identifier *Identifier) (*Identifier, error) { - if err := db.DB.Create(identifier).Error; err != nil { - return nil, fmt.Errorf("failed to create identifier: %v", err) - } - return identifier, nil -} 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 5637cddf..59059fac 100644 --- a/pkg/onboarding/infrastructure/database/postgres/gorm/mock/gorm_mock.go +++ b/pkg/onboarding/infrastructure/database/postgres/gorm/mock/gorm_mock.go @@ -3,89 +3,25 @@ package mock import ( "context" "strconv" - "time" "github.com/google/uuid" - "github.com/savannahghi/enumutils" - "github.com/savannahghi/feedlib" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" - "github.com/segmentio/ksuid" - "gorm.io/datatypes" ) // GormMock struct implements mocks of `gorm's`internal methods. // // This mock struct should be separate from our own internal methods. type GormMock struct { - GetOrCreateFacilityFn func(ctx context.Context, facility *gorm.Facility) (*gorm.Facility, error) - RetrieveFacilityFn func(ctx context.Context, id *string, isActive bool) (*gorm.Facility, error) - RetrieveFacilityByMFLCodeFn func(ctx context.Context, MFLCode string, isActive bool) (*gorm.Facility, error) - GetFacilitiesFn func(ctx context.Context) ([]gorm.Facility, error) - DeleteFacilityFn func(ctx context.Context, mfl_code string) (bool, error) - CollectMetricsFn func(ctx context.Context, metrics *gorm.Metric) (*gorm.Metric, error) - SavePinFn func(ctx context.Context, pinData *gorm.PINData) (bool, error) - GetUserPINByUserIDFn func(ctx context.Context, userID string) (*gorm.PINData, error) - GetUserProfileByUserIDFn func(ctx context.Context, userID string, flavour feedlib.Flavour) (*gorm.User, error) - RegisterStaffUserFn func(ctx context.Context, user *gorm.User, staff *gorm.StaffProfile) (*gorm.StaffUserProfile, error) - RegisterClientFn func(ctx context.Context, userInput *gorm.User, clientInput *gorm.ClientProfile) (*gorm.ClientUserProfile, error) - AddIdentifierFn func(ctx context.Context, identifier *gorm.Identifier) (*gorm.Identifier, error) - GetClientProfileByClientIDFn func(ctx context.Context, clientID string) (*gorm.ClientProfile, error) - GetStaffProfileFn func(ctx context.Context, staffNumber string) (*gorm.StaffProfile, error) - - //Updates - UpdateUserLastSuccessfulLoginFn func(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error - UpdateUserLastFailedLoginFn func(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error - UpdateUserFailedLoginCountFn func(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error - UpdateUserNextAllowedLoginFn func(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error - UpdateStaffUserFn func(ctx context.Context, userID string, user *gorm.User, staff *gorm.StaffProfile) (bool, error) - TransferClientFn func( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, - ) (bool, error) - InvalidatePINFn func(ctx context.Context, userID string) error + GetOrCreateFacilityFn func(ctx context.Context, facility *gorm.Facility) (*gorm.Facility, error) + RetrieveFacilityFn func(ctx context.Context, id *string, isActive bool) (*gorm.Facility, error) + RetrieveFacilityByMFLCodeFn func(ctx context.Context, MFLCode string, isActive bool) (*gorm.Facility, error) + GetFacilitiesFn func(ctx context.Context) ([]gorm.Facility, error) + DeleteFacilityFn func(ctx context.Context, mfl_code string) (bool, error) } // NewGormMock initializes a new instance of `GormMock` then mocking the case of success. func NewGormMock() *GormMock { return &GormMock{ - RegisterClientFn: func(ctx context.Context, userInput *gorm.User, clientInput *gorm.ClientProfile) (*gorm.ClientUserProfile, error) { - return &gorm.ClientUserProfile{ - User: &gorm.User{ - FirstName: "FirstName", - LastName: "Last Name", - Username: "User Name", - MiddleName: userInput.MiddleName, - DisplayName: "Display Name", - Gender: enumutils.GenderMale, - }, - Client: &gorm.ClientProfile{ - ClientType: enums.ClientTypeOvc, - }, - }, nil - }, - - AddIdentifierFn: func(ctx context.Context, identifier *gorm.Identifier) (*gorm.Identifier, error) { - return &gorm.Identifier{ - ClientID: identifier.ClientID, - IdentifierType: enums.IdentifierTypeCCC, - IdentifierUse: enums.IdentifierUseOfficial, - IdentifierValue: "Just a random value", - Description: "Random description", - }, nil - }, - - GetClientProfileByClientIDFn: func(ctx context.Context, clientID string) (*gorm.ClientProfile, error) { - ID := uuid.New().String() - return &gorm.ClientProfile{ - ID: &clientID, - UserID: &ID, - }, nil - }, GetOrCreateFacilityFn: func(ctx context.Context, facility *gorm.Facility) (*gorm.Facility, error) { id := uuid.New().String() @@ -140,18 +76,6 @@ func NewGormMock() *GormMock { return true, nil }, - CollectMetricsFn: func(ctx context.Context, metrics *gorm.Metric) (*gorm.Metric, error) { - now := time.Now() - metricID := uuid.New().String() - return &gorm.Metric{ - MetricID: &metricID, - Type: enums.EngagementMetrics, - Payload: datatypes.JSON([]byte(`{"who": "test user", "keyword": "suicidal"}`)), - Timestamp: now, - UID: ksuid.New().String(), - }, nil - }, - RetrieveFacilityByMFLCodeFn: func(ctx context.Context, MFLCode string, isActive bool) (*gorm.Facility, error) { facilityID := uuid.New().String() name := "Kanairo One" @@ -167,148 +91,6 @@ func NewGormMock() *GormMock { Description: description, }, nil }, - - SavePinFn: func(ctx context.Context, pinData *gorm.PINData) (bool, error) { - return true, nil - }, - - GetUserProfileByUserIDFn: func(ctx context.Context, userID string, flavour feedlib.Flavour) (*gorm.User, error) { - id := uuid.New().String() - usercontact := &gorm.Contact{ - ContactID: &id, - Type: "test", - Contact: "test", - Active: true, - OptedIn: true, - } - time := time.Now() - return &gorm.User{ - Base: gorm.Base{}, - UserID: &id, - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Flavour: "test", - UserType: "test", - Gender: "test", - Active: false, - Contacts: []gorm.Contact{*usercontact}, - Languages: []string{"en"}, - PushTokens: []string{"push-token"}, - LastSuccessfulLogin: &time, - LastFailedLogin: &time, - FailedLoginCount: "test", - NextAllowedLogin: &time, - TermsAccepted: false, - AcceptedTermsID: "test", - }, nil - }, - - GetUserPINByUserIDFn: func(ctx context.Context, userID string) (*gorm.PINData, error) { - return &gorm.PINData{ - UserID: userID, - HashedPIN: "mbzcbvhbxchjbvhdbvhhjdfskgbfhas832y38hjsdnfkjbh73y73y72", - ValidFrom: time.Now(), - ValidTo: time.Now(), - Flavour: "CONSUMER", - IsValid: true, - Salt: "test-salt", - }, nil - }, - - GetStaffProfileFn: func(ctx context.Context, staffNumber string) (*gorm.StaffProfile, error) { - testUID := ksuid.New().String() - address := &gorm.Addresses{ - Type: "test", - Text: "test", - Country: "test", - PostalCode: "test", - County: "test", - Active: false, - StaffProfileID: new(string), - } - return &gorm.StaffProfile{ - StaffProfileID: &testUID, - UserID: &testUID, - User: gorm.User{}, - StaffNumber: "s100", - DefaultFacilityID: &testUID, - Addresses: []*gorm.Addresses{address}, - }, nil - }, - - UpdateUserLastSuccessfulLoginFn: func(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error { - return nil - }, - - UpdateUserLastFailedLoginFn: func(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - return nil - }, - - UpdateUserFailedLoginCountFn: func(ctx context.Context, userID, failedLoginCount string, flavour feedlib.Flavour) error { - return nil - }, - - UpdateUserNextAllowedLoginFn: func(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error { - return nil - }, - - UpdateStaffUserFn: func(ctx context.Context, userID string, user *gorm.User, staff *gorm.StaffProfile) (bool, error) { - return true, nil - }, - - RegisterStaffUserFn: func(ctx context.Context, user *gorm.User, staff *gorm.StaffProfile) (*gorm.StaffUserProfile, error) { - ID := uuid.New().String() - testTime := time.Now() - roles := []string{enums.RolesTypeCanInviteClient.String()} - languages := []string{string(enumutils.LanguageEn)} - return &gorm.StaffUserProfile{ - User: &gorm.User{ - UserID: &ID, - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Active: true, - LastSuccessfulLogin: &testTime, - LastFailedLogin: &testTime, - NextAllowedLogin: &testTime, - FailedLoginCount: "0", - TermsAccepted: true, - AcceptedTermsID: ID, - Languages: languages, - }, - Staff: &gorm.StaffProfile{ - StaffProfileID: &ID, - 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, - }, - }, - Roles: roles, - }, - }, nil - }, - - TransferClientFn: func(ctx context.Context, clientID, originFacilityID, destinationFacilityID string, reason enums.TransferReason, notes string) (bool, error) { - return true, nil - }, - - InvalidatePINFn: func(ctx context.Context, userID string) error { - return nil - }, } } @@ -336,97 +118,3 @@ func (gm *GormMock) GetFacilities(ctx context.Context) ([]gorm.Facility, error) func (gm *GormMock) DeleteFacility(ctx context.Context, mflcode string) (bool, error) { return gm.DeleteFacilityFn(ctx, mflcode) } - -// CollectMetrics mocks the implementation of CollectMetrics method. -func (gm *GormMock) CollectMetrics(ctx context.Context, metrics *gorm.Metric) (*gorm.Metric, error) { - return gm.CollectMetricsFn(ctx, metrics) -} - -//SavePin mocks the implementation of SetUserPIN method -func (gm *GormMock) SavePin(ctx context.Context, pinData *gorm.PINData) (bool, error) { - return gm.SavePinFn(ctx, pinData) -} - -// GetUserPINByUserID ... -func (gm *GormMock) GetUserPINByUserID(ctx context.Context, userID string) (*gorm.PINData, error) { - return gm.GetUserPINByUserIDFn(ctx, userID) -} - -// GetUserProfileByUserID gets user profile by user ID -func (gm *GormMock) GetUserProfileByUserID(ctx context.Context, userID string, flavour feedlib.Flavour) (*gorm.User, error) { - return gm.GetUserProfileByUserIDFn(ctx, userID, flavour) -} - -//UpdateUserLastSuccessfulLogin updates the user's last successful login time -func (gm *GormMock) UpdateUserLastSuccessfulLogin(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error { - return gm.UpdateUserLastSuccessfulLoginFn(ctx, userID, lastLoginTime, flavour) -} - -// UpdateUserLastFailedLogin updates the user's last failed login -func (gm *GormMock) UpdateUserLastFailedLogin(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - return gm.UpdateUserLastFailedLoginFn(ctx, userID, lastFailedLoginTime, flavour) -} - -// UpdateUserFailedLoginCount updates the users failed login count -func (gm *GormMock) UpdateUserFailedLoginCount(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error { - return gm.UpdateUserFailedLoginCountFn(ctx, userID, failedLoginCount, flavour) -} - -// UpdateUserNextAllowedLogin updates the user's next allowed login time -func (gm *GormMock) UpdateUserNextAllowedLogin(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error { - return gm.UpdateUserNextAllowedLoginFn(ctx, userID, nextAllowedLoginTime, flavour) -} - -// RegisterStaffUser mocks the implementation of RegisterStaffUser method. -func (gm *GormMock) RegisterStaffUser(ctx context.Context, user *gorm.User, staff *gorm.StaffProfile) (*gorm.StaffUserProfile, error) { - return gm.RegisterStaffUserFn(ctx, user, staff) -} - -// UpdateStaffUserProfile mocks the implementation of UpdateStaffUserProfile method. -func (gm *GormMock) UpdateStaffUserProfile(ctx context.Context, userID string, user *gorm.User, staff *gorm.StaffProfile) (bool, error) { - return gm.UpdateStaffUserFn(ctx, userID, user, staff) -} - -// GetStaffProfile mocks the implementation of GetStaffProfile method. -func (gm *GormMock) GetStaffProfile(ctx context.Context, staffNumber string) (*gorm.StaffProfile, error) { - return gm.GetStaffProfileFn(ctx, staffNumber) -} - -// RegisterClient mocks the implementation of RegisterClient method -func (gm *GormMock) RegisterClient( - ctx context.Context, - userInput *gorm.User, - clientInput *gorm.ClientProfile, -) (*gorm.ClientUserProfile, error) { - return gm.RegisterClientFn(ctx, userInput, clientInput) -} - -// AddIdentifier mocks the `AddIdentifier` implementation -func (gm *GormMock) AddIdentifier( - ctx context.Context, - identifier *gorm.Identifier, -) (*gorm.Identifier, error) { - return gm.AddIdentifierFn(ctx, identifier) -} - -// GetClientProfileByClientID mocks the method that fetches a client profile by the ID -func (gm *GormMock) GetClientProfileByClientID(ctx context.Context, clientID string) (*gorm.ClientProfile, error) { - return gm.GetClientProfileByClientIDFn(ctx, clientID) -} - -// TransferClient mocks the implementation of TransferClient method -func (gm *GormMock) TransferClient( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, -) (bool, error) { - return gm.TransferClientFn(ctx, clientID, originFacilityID, destinationFacilityID, reason, notes) -} - -// InvalidatePIN mocks the invalidate pin implementation -func (gm *GormMock) InvalidatePIN(ctx context.Context, userID string) error { - return gm.InvalidatePINFn(ctx, userID) -} diff --git a/pkg/onboarding/infrastructure/database/postgres/gorm/query.go b/pkg/onboarding/infrastructure/database/postgres/gorm/query.go index 1593cf99..1c682804 100644 --- a/pkg/onboarding/infrastructure/database/postgres/gorm/query.go +++ b/pkg/onboarding/infrastructure/database/postgres/gorm/query.go @@ -5,8 +5,6 @@ import ( "fmt" "log" "strconv" - - "github.com/savannahghi/feedlib" ) // Query contains all the db query methods @@ -14,10 +12,6 @@ type Query interface { RetrieveFacility(ctx context.Context, id *string, isActive bool) (*Facility, error) RetrieveFacilityByMFLCode(ctx context.Context, MFLCode string, isActive bool) (*Facility, error) GetFacilities(ctx context.Context) ([]Facility, error) - GetUserProfileByUserID(ctx context.Context, userID string, flavour feedlib.Flavour) (*User, error) - GetUserPINByUserID(ctx context.Context, userID string) (*PINData, error) - GetClientProfileByClientID(ctx context.Context, clientID string) (*ClientProfile, error) - GetStaffProfile(ctx context.Context, staffNumber string) (*StaffProfile, error) } // RetrieveFacility fetches a single facility @@ -41,24 +35,6 @@ func (db *PGInstance) RetrieveFacilityByMFLCode(ctx context.Context, MFLCode str return &facility, nil } -// GetUserProfileByUserID fetches a user profile facility using the user ID -func (db *PGInstance) GetUserProfileByUserID(ctx context.Context, userID string, flavour feedlib.Flavour) (*User, error) { - var user User - if err := db.DB.Where(&User{UserID: &userID, Flavour: flavour}).Preload("Contacts").First(&user).Error; err != nil { - return nil, fmt.Errorf("failed to get user by userID %v: %v", userID, err) - } - return &user, nil -} - -// GetUserPINByUserID fetches a user profile facility using the user ID -func (db *PGInstance) GetUserPINByUserID(ctx context.Context, userID string) (*PINData, error) { - var pin PINData - if err := db.DB.Where(&PINData{UserID: userID, IsValid: true}).First(&pin).Error; err != nil { - return nil, fmt.Errorf("failed to get facility by MFL Code %v: %v", userID, err) - } - return &pin, nil -} - // GetFacilities fetches all the healthcare facilities in the platform. func (db *PGInstance) GetFacilities(ctx context.Context) ([]Facility, error) { var facility []Facility @@ -70,23 +46,3 @@ func (db *PGInstance) GetFacilities(ctx context.Context) ([]Facility, error) { log.Printf("these are the facilities %v", facility) return facility, nil } - -// GetClientProfileByClientID retrieves a client profile by ID -func (db *PGInstance) GetClientProfileByClientID(ctx context.Context, clientID string) (*ClientProfile, error) { - var client ClientProfile - if err := db.DB.Where(&ClientProfile{ID: &clientID}).First(&client).Error; err != nil { - return nil, err - } - - return &client, nil -} - -// GetStaffProfile retrieves a client profile by ID -func (db *PGInstance) GetStaffProfile(ctx context.Context, staffNumber string) (*StaffProfile, error) { - var staff StaffProfile - if err := db.DB.Where(&StaffProfile{StaffNumber: staffNumber}).First(&staff).Error; err != nil { - return nil, err - } - - return &staff, nil -} diff --git a/pkg/onboarding/infrastructure/database/postgres/gorm/tables.go b/pkg/onboarding/infrastructure/database/postgres/gorm/tables.go index 372243c2..b2d4039e 100644 --- a/pkg/onboarding/infrastructure/database/postgres/gorm/tables.go +++ b/pkg/onboarding/infrastructure/database/postgres/gorm/tables.go @@ -379,15 +379,6 @@ func (Identifier) TableName() string { func allTables() []interface{} { tables := []interface{}{ &Facility{}, - &Metric{}, - &User{}, - &Contact{}, - &StaffProfile{}, - &ClientProfile{}, - &Identifier{}, - &Addresses{}, - &PINData{}, - &ClientTransfer{}, } return tables } diff --git a/pkg/onboarding/infrastructure/database/postgres/gorm/update.go b/pkg/onboarding/infrastructure/database/postgres/gorm/update.go deleted file mode 100644 index 8d859121..00000000 --- a/pkg/onboarding/infrastructure/database/postgres/gorm/update.go +++ /dev/null @@ -1,206 +0,0 @@ -package gorm - -import ( - "context" - "fmt" - "time" - - "github.com/savannahghi/feedlib" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" -) - -// Update represents all `update` ops to the database -type Update interface { - UpdateUserLastSuccessfulLogin(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error - UpdateUserLastFailedLogin(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error - UpdateUserFailedLoginCount(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error - UpdateUserNextAllowedLogin(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error - UpdateStaffUserProfile(ctx context.Context, userID string, user *User, staff *StaffProfile) (bool, error) - TransferClient( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, - ) (bool, error) - InvalidatePIN(ctx context.Context, userID string) error -} - -// UpdateUserLastSuccessfulLogin updates users last successful login time -func (db *PGInstance) UpdateUserLastSuccessfulLogin(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error { - userProfile, err := db.GetUserProfileByUserID(ctx, userID, flavour) - if err != nil { - return fmt.Errorf("unable to get user profile by userID when updating: %v", err) - } - - return db.DB.Model(&User{}).Where(&User{UserID: userProfile.UserID, Flavour: userProfile.Flavour}).Updates(&User{LastSuccessfulLogin: &lastLoginTime}).Error -} - -// UpdateUserLastFailedLogin updates user's last failed login time -func (db *PGInstance) UpdateUserLastFailedLogin(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - userProfile, err := db.GetUserProfileByUserID(ctx, userID, flavour) - if err != nil { - return fmt.Errorf("unable to get user profile by userID when updating: %v", err) - } - - return db.DB.Model(&User{}).Where(&User{UserID: userProfile.UserID, Flavour: userProfile.Flavour}).Updates(&User{LastFailedLogin: &lastFailedLoginTime}).Error -} - -// UpdateUserFailedLoginCount updates users failed login count -func (db *PGInstance) UpdateUserFailedLoginCount(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error { - userProfile, err := db.GetUserProfileByUserID(ctx, userID, flavour) - if err != nil { - return fmt.Errorf("unable to get user profile by userID when updating: %v", err) - } - - return db.DB.Model(&User{}).Where(&User{UserID: userProfile.UserID, Flavour: userProfile.Flavour}). - Updates(&User{FailedLoginCount: failedLoginCount}).Error -} - -// UpdateUserNextAllowedLogin updates the users next allowed login time -func (db *PGInstance) UpdateUserNextAllowedLogin(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error { - userProfile, err := db.GetUserProfileByUserID(ctx, userID, flavour) - if err != nil { - return fmt.Errorf("unable to get user profile by userID when updating: %v", err) - } - - return db.DB.Model(&User{}).Where(&User{UserID: userProfile.UserID, Flavour: userProfile.Flavour}).Updates(&User{NextAllowedLogin: &nextAllowedLoginTime}).Error -} - -// UpdateStaffUserProfile updates the staff user -func (db *PGInstance) UpdateStaffUserProfile(ctx context.Context, userID string, user *User, staff *StaffProfile) (bool, error) { - userProfile, err := db.GetUserProfileByUserID(ctx, userID, user.Flavour) - if err != nil { - return false, fmt.Errorf("unable to get user profile by userID: %v", err) - } - - staffProfile, err := db.GetStaffProfile(ctx, staff.StaffNumber) - if err != nil { - return false, fmt.Errorf("unable to get staff profile by staff number: %v", err) - } - - // Initialize a database transaction - tx := db.DB.Begin() - defer func() { - if r := recover(); r != nil { - tx.Rollback() - } - }() - if err := tx.Error; err != nil { - return false, fmt.Errorf("failied initialize database transaction %v", err) - } - - for _, c := range user.Contacts { - if err := tx.Model(&Contact{}).Where(&Contact{UserID: &userID}).Updates(&Contact{ - Type: c.Type, - Contact: c.Contact, - Active: c.Active, - OptedIn: c.OptedIn, - }).Error; err != nil { - tx.Rollback() - return false, fmt.Errorf("failed to update a user data: %v", err) - } - } - - for _, a := range staff.Addresses { - if err := tx.Model(&Addresses{}).Where(&Addresses{StaffProfileID: staffProfile.StaffProfileID}).Updates(&Addresses{ - Type: a.Type, - Text: a.Text, - Country: a.Country, - PostalCode: a.PostalCode, - County: a.County, - Active: a.Active, - }).Error; err != nil { - tx.Rollback() - return false, fmt.Errorf("failed to update a staff profile: %v", err) - } - } - - // Update a user profile, then rollback the transaction if it is unsuccessful - if err := tx.Model(&User{}).Where(&User{UserID: userProfile.UserID, Flavour: userProfile.Flavour}).Updates(&User{ - Languages: user.Languages, - }).Error; err != nil { - tx.Rollback() - return false, fmt.Errorf("failed to update a user data: %v", err) - } - - // update a staff profile, then rollback the transaction if it is unsuccessful - if err := tx.Model(&StaffProfile{}).Where(&StaffProfile{UserID: userProfile.UserID}).Updates(&StaffProfile{ - DefaultFacilityID: staff.DefaultFacilityID, - }).Error; err != nil { - tx.Rollback() - return false, fmt.Errorf("failed to update a staff data: %v", err) - } - - // try to commit the transactions - if err := tx.Commit().Error; err != nil { - tx.Rollback() - return false, fmt.Errorf("transaction commit to update a staff profile failed: %v", err) - } - - return true, nil -} - -// TransferClient handles transfer of a client -func (db *PGInstance) TransferClient( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, -) (bool, error) { - if clientID == "" { - return false, fmt.Errorf("clientID cannot be empty") - } - - clientProfile, err := db.GetClientProfileByClientID(ctx, clientID) - if err != nil { - return false, fmt.Errorf("unable to get client profile with the provided client ID: %v", err) - } - - transferRecord := &ClientTransfer{ - ClientID: clientID, - OriginFacilityID: originFacilityID, - DestinationFacilityID: destinationFacilityID, - Reason: reason, - Notes: notes, - } - - tx := db.DB.Begin() - defer func() { - if r := recover(); r != nil { - tx.Rollback() - } - }() - if err := tx.Error; err != nil { - return false, fmt.Errorf("unable to initialize database transaction: %v", err) - } - - //Update client profile with the new facility. Rollback if transaction fails - if err := tx.Model(&ClientProfile{}).Where(&ClientProfile{UserID: clientProfile.UserID}).Updates(&ClientProfile{ - FacilityID: destinationFacilityID, - }).Error; err != nil { - tx.Rollback() - return false, fmt.Errorf("failed to update client profile: %v", err) - } - - //Create transfer record for the client - if err := tx.Create(transferRecord).Error; err != nil { - tx.Rollback() - return false, fmt.Errorf("failed to create client transfer record: %v", err) - } - - if err := tx.Commit().Error; err != nil { - tx.Rollback() - return false, fmt.Errorf("failed to commit the transaction: %v", err) - } - - return true, nil -} - -// InvalidatePIN toggles the valid field of a pin from true to false -func (db *PGInstance) InvalidatePIN(ctx context.Context, userID string) error { - return db.DB.Model(&PINData{}).Where(&PINData{UserID: userID, IsValid: true}).Select("IsValid").Updates(PINData{IsValid: false}).Error -} diff --git a/pkg/onboarding/infrastructure/database/postgres/mappers.go b/pkg/onboarding/infrastructure/database/postgres/mappers.go index b3bfdc81..e006a1a7 100644 --- a/pkg/onboarding/infrastructure/database/postgres/mappers.go +++ b/pkg/onboarding/infrastructure/database/postgres/mappers.go @@ -3,8 +3,6 @@ package postgres import ( "strconv" - "github.com/savannahghi/enumutils" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" ) @@ -30,228 +28,3 @@ func (d *OnboardingDb) mapFacilityObjectToDomain(facilityObject *gorm.Facility) Description: facilityObject.Description, } } - -// mapMetricObjectToDomain maps the db metrics to a domain model. -// It searches the database to fetch items specific to the metrics -func (d *OnboardingDb) mapMetricObjectToDomain(metricObject *gorm.Metric) *domain.Metric { - if metricObject == nil { - return nil - } - - return &domain.Metric{ - MetricID: metricObject.MetricID, - Type: metricObject.Type, - Payload: metricObject.Payload, - Timestamp: metricObject.Timestamp, - UID: metricObject.UID, - } -} - -// mapProfileObjectToDomain maps the db metrics to a domain model. -// It searches the database to fetch items specific to the metrics -func (d *OnboardingDb) mapProfileObjectToDomain(profileObject *gorm.User) *domain.User { - if profileObject == nil { - return nil - } - - user := createMapUser(profileObject) - - return user -} - -// mapPINObjectToDomain maps the db pin data to a domain model. -// It searches the database to fetch items specific to the PIN -func (d *OnboardingDb) mapPINObjectToDomain(pinObj *gorm.PINData) *domain.UserPIN { - if pinObj == nil { - return nil - } - - return &domain.UserPIN{ - UserID: pinObj.UserID, - HashedPIN: pinObj.HashedPIN, - ValidFrom: pinObj.ValidFrom, - ValidTo: pinObj.ValidTo, - Flavour: pinObj.Flavour, - IsValid: pinObj.IsValid, - Salt: pinObj.Salt, - } -} - -// mapUserObjectToDomain maps the db user to a domain model. -// It searches the database to fetch items specific to the user -func (d *OnboardingDb) mapRegisterStaffObjectToDomain(userStaffObject *gorm.StaffUserProfile) *domain.StaffUserProfile { - - userObject := userStaffObject.User - staffObject := userStaffObject.Staff - - 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) - } - - roles := []enums.RolesType{} - for _, r := range staffObject.Roles { - roles = append(roles, enums.RolesType(r)) - - } - - staffProfile := &domain.StaffProfile{ - ID: staffObject.StaffProfileID, - UserID: userObject.UserID, - StaffNumber: staffObject.StaffNumber, - // Facilities: staffObject.Facilities, - DefaultFacilityID: staffObject.DefaultFacilityID, - Addresses: addresses, - Roles: roles, - } - return &domain.StaffUserProfile{ - User: user, - Staff: staffProfile, - } -} - -// mapRegisterClientObjectToDomain maps the database client object to our custom domain type -func (d *OnboardingDb) mapRegisterClientObjectToDomain(clientObject *gorm.ClientUserProfile) *domain.ClientUserProfile { - userObject := clientObject.User - client := clientObject.Client - - user := createMapUser(userObject) - - clientProfile := &domain.ClientProfile{ - ID: client.ID, - UserID: client.UserID, - ClientType: client.ClientType, - } - - return &domain.ClientUserProfile{ - User: user, - Client: clientProfile, - } -} - -// a helper method to create mapped user -func createMapUser(userObject *gorm.User) *domain.User { - contacts := []*domain.Contact{} - if len(userObject.Contacts) > 0 { - for _, u := range userObject.Contacts { - contact := &domain.Contact{ - ID: u.ContactID, - Type: u.Type, - Contact: u.Contact, - Active: u.Active, - OptedIn: u.OptedIn, - } - contacts = append(contacts, contact) - } - } - - languages := []enumutils.Language{} - for _, l := range userObject.Languages { - languages = append(languages, enumutils.Language(l)) - - } - - user := &domain.User{ - ID: userObject.UserID, - Username: userObject.Username, - DisplayName: userObject.DisplayName, - FirstName: userObject.FirstName, - MiddleName: userObject.MiddleName, - LastName: userObject.LastName, - Gender: userObject.Gender, - UserType: userObject.UserType, - Contacts: contacts, - Languages: languages, - Active: userObject.Active, - LastSuccessfulLogin: userObject.LastSuccessfulLogin, - LastFailedLogin: userObject.LastFailedLogin, - FailedLoginCount: userObject.FailedLoginCount, - NextAllowedLogin: userObject.NextAllowedLogin, - TermsAccepted: userObject.TermsAccepted, - AcceptedTermsID: userObject.AcceptedTermsID, - Flavour: userObject.Flavour, - } - return user -} - -// mapIdentifierObjectToDomain maps the identifier object to our domain defined type -func (d *OnboardingDb) mapIdentifierObjectToDomain(identifierObject *gorm.Identifier) *domain.Identifier { - if identifierObject == nil { - return nil - } - - return &domain.Identifier{ - ID: identifierObject.ID, - ClientID: identifierObject.ClientID, - IdentifierType: identifierObject.IdentifierType, - IdentifierUse: identifierObject.IdentifierUse, - IdentifierValue: identifierObject.IdentifierValue, - Description: identifierObject.Description, - ValidFrom: identifierObject.ValidFrom, - ValidTo: identifierObject.ValidTo, - Active: identifierObject.Active, - IsPrimaryIdentifier: identifierObject.IsPrimaryIdentifier, - } -} - -// mapClientObjectToDomain maps the client object to the domain defined type -func (d *OnboardingDb) mapClientObjectToDomain(client *gorm.ClientProfile) *domain.ClientProfile { - if client == nil { - return nil - } - - return &domain.ClientProfile{ - ID: client.ID, - UserID: client.UserID, - TreatmentEnrollmentDate: client.TreatmentEnrollmentDate, - ClientType: client.ClientType, - Active: client.Active, - HealthRecordID: client.HealthRecordID, - // Identifiers: client.Identifiers, - FacilityID: client.FacilityID, - TreatmentBuddyUserID: client.TreatmentBuddy, - CHVUserID: client.CHVUserID, - ClientCounselled: client.ClientCounselled, - } -} - -//mapStaffObjectToDomain maps the staff object to the domain defined type -func (d *OnboardingDb) mapStaffObjectToDomain(staff *gorm.StaffProfile) *domain.StaffProfile { - if staff == nil { - return nil - } - - addresses := []*domain.Addresses{} - if len(staff.Addresses) > 0 { - for _, a := range staff.Addresses { - address := &domain.Addresses{ - ID: *a.AddressesID, - Type: a.Type, - Text: a.Text, - Country: a.Country, - PostalCode: a.PostalCode, - County: a.County, - Active: a.Active, - } - addresses = append(addresses, address) - } - } - - return &domain.StaffProfile{ - ID: staff.StaffProfileID, - UserID: staff.UserID, - StaffNumber: staff.StaffNumber, - DefaultFacilityID: staff.DefaultFacilityID, - Addresses: addresses, - } -} diff --git a/pkg/onboarding/infrastructure/database/postgres/mock/pg_mock.go b/pkg/onboarding/infrastructure/database/postgres/mock/pg_mock.go index 83483708..3d5a2004 100644 --- a/pkg/onboarding/infrastructure/database/postgres/mock/pg_mock.go +++ b/pkg/onboarding/infrastructure/database/postgres/mock/pg_mock.go @@ -2,44 +2,18 @@ package mock import ( "context" - "time" "github.com/google/uuid" - "github.com/savannahghi/enumutils" - "github.com/savannahghi/feedlib" "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" - "github.com/segmentio/ksuid" ) // PostgresMock struct implements mocks of `postgres's` internal methods. type PostgresMock struct { //Get - GetOrCreateFacilityFn func(ctx context.Context, facility *dto.FacilityInput) (*domain.Facility, error) - GetFacilitiesFn func(ctx context.Context) ([]*domain.Facility, error) - RetrieveFacilityFn func(ctx context.Context, id *string, isActive bool) (*domain.Facility, error) - SetUserPINFn func(ctx context.Context, pinData *domain.UserPIN) (bool, error) - GetUserPINByUserIDFn func(ctx context.Context, userID string) (*domain.UserPIN, error) - GetUserProfileByUserIDFn func(ctx context.Context, userID string, flavour feedlib.Flavour) (*domain.User, error) - RegisterStaffUserFn func(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) - GetStaffProfileFn func(ctx context.Context, staffNumber string) (*gorm.StaffProfile, error) - - //Updates - UpdateUserLastSuccessfulLoginFn func(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error - UpdateUserLastFailedLoginFn func(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error - UpdateUserFailedLoginCountFn func(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error - UpdateUserNextAllowedLoginFn func(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error - UpdateStaffUserFn func(ctx context.Context, userID string, user *gorm.User, staff *gorm.StaffProfile) (bool, error) - TransferClientFn func( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, - ) (bool, error) + GetOrCreateFacilityFn func(ctx context.Context, facility *dto.FacilityInput) (*domain.Facility, error) + GetFacilitiesFn func(ctx context.Context) ([]*domain.Facility, error) + RetrieveFacilityFn func(ctx context.Context, id *string, isActive bool) (*domain.Facility, error) } // NewPostgresMock initializes a new instance of `GormMock` then mocking the case of success. @@ -92,142 +66,6 @@ func NewPostgresMock() *PostgresMock { Description: description, }, nil }, - SetUserPINFn: func(ctx context.Context, pinData *domain.UserPIN) (bool, error) { - return true, nil - }, - - GetUserProfileByUserIDFn: func(ctx context.Context, userID string, flavour feedlib.Flavour) (*domain.User, error) { - id := uuid.New().String() - contact := &domain.Contact{ - ID: &id, - Type: enums.PhoneContact, - Contact: "test", - Active: true, - OptedIn: true, - } - time := time.Now() - return &domain.User{ - ID: &id, - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - UserType: enums.HealthcareWorkerUser, - Gender: enumutils.GenderMale, - Active: false, - Contacts: []*domain.Contact{contact}, - Languages: []enumutils.Language{enumutils.LanguageEn}, - // PushTokens: []string{"push-token"}, - LastSuccessfulLogin: &time, - LastFailedLogin: &time, - FailedLoginCount: "test", - NextAllowedLogin: &time, - TermsAccepted: false, - AcceptedTermsID: "test", - Flavour: feedlib.FlavourPro, - }, nil - }, - - GetUserPINByUserIDFn: func(ctx context.Context, userID string) (*domain.UserPIN, error) { - return &domain.UserPIN{ - UserID: userID, - HashedPIN: "mbzcbvhbxchjbvhdbvhhjdfskgbfhas832y38hjsdnfkjbh73y73y72", - ValidFrom: time.Now(), - ValidTo: time.Now(), - Flavour: "CONSUMER", - IsValid: true, - Salt: "test-salt", - }, nil - }, - - GetStaffProfileFn: func(ctx context.Context, staffNumber string) (*gorm.StaffProfile, error) { - testUID := ksuid.New().String() - address := &gorm.Addresses{ - Type: "test", - Text: "test", - Country: "test", - PostalCode: "test", - County: "test", - Active: false, - StaffProfileID: new(string), - } - return &gorm.StaffProfile{ - StaffProfileID: &testUID, - UserID: &testUID, - User: gorm.User{}, - StaffNumber: "s100", - DefaultFacilityID: &testUID, - Addresses: []*gorm.Addresses{address}, - }, nil - }, - - UpdateUserLastSuccessfulLoginFn: func(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error { - return nil - }, - - UpdateUserLastFailedLoginFn: func(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - return nil - }, - - UpdateUserFailedLoginCountFn: func(ctx context.Context, userID, failedLoginCount string, flavour feedlib.Flavour) error { - return nil - }, - - UpdateUserNextAllowedLoginFn: func(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error { - return nil - }, - - UpdateStaffUserFn: func(ctx context.Context, userID string, user *gorm.User, staff *gorm.StaffProfile) (bool, error) { - return true, nil - }, - - RegisterStaffUserFn: func(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - ID := uuid.New().String() - testTime := time.Now() - roles := []enums.RolesType{enums.RolesTypeCanInviteClient} - languages := []enumutils.Language{enumutils.LanguageEn} - return &domain.StaffUserProfile{ - User: &domain.User{ - ID: &ID, - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Active: true, - LastSuccessfulLogin: &testTime, - LastFailedLogin: &testTime, - NextAllowedLogin: &testTime, - FailedLoginCount: "0", - TermsAccepted: true, - AcceptedTermsID: ID, - Languages: languages, - }, - Staff: &domain.StaffProfile{ - ID: &ID, - 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, - }, - }, - Roles: roles, - }, - }, nil - }, - - TransferClientFn: func(ctx context.Context, clientID, originFacilityID, destinationFacilityID string, reason enums.TransferReason, notes string) (bool, error) { - return true, nil - }, } } @@ -240,60 +78,3 @@ func (gm *PostgresMock) GetOrCreateFacility(ctx context.Context, facility *dto.F func (gm *PostgresMock) RetrieveFacility(ctx context.Context, id *string, isActive bool) (*domain.Facility, error) { return gm.RetrieveFacilityFn(ctx, id, isActive) } - -//SetUserPIN mocks the implementation of SetUserPIN method -func (gm *PostgresMock) SetUserPIN(ctx context.Context, pinData *domain.UserPIN) (bool, error) { - return gm.SetUserPINFn(ctx, pinData) -} - -// GetUserPINByUserID ... -func (gm *PostgresMock) GetUserPINByUserID(ctx context.Context, userID string) (*domain.UserPIN, error) { - return gm.GetUserPINByUserIDFn(ctx, userID) -} - -// GetUserProfileByUserID gets user profile by user ID -func (gm *PostgresMock) GetUserProfileByUserID(ctx context.Context, userID string, flavour feedlib.Flavour) (*domain.User, error) { - return gm.GetUserProfileByUserIDFn(ctx, userID, flavour) -} - -//UpdateUserLastSuccessfulLogin ... -func (gm *PostgresMock) UpdateUserLastSuccessfulLogin(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error { - return gm.UpdateUserLastSuccessfulLoginFn(ctx, userID, lastLoginTime, flavour) -} - -// UpdateUserLastFailedLogin ... -func (gm *PostgresMock) UpdateUserLastFailedLogin(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - return gm.UpdateUserLastFailedLoginFn(ctx, userID, lastFailedLoginTime, flavour) -} - -// UpdateUserFailedLoginCount ... -func (gm *PostgresMock) UpdateUserFailedLoginCount(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error { - return gm.UpdateUserFailedLoginCountFn(ctx, userID, failedLoginCount, flavour) -} - -// UpdateUserNextAllowedLogin ... -func (gm *PostgresMock) UpdateUserNextAllowedLogin(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error { - return gm.UpdateUserNextAllowedLoginFn(ctx, userID, nextAllowedLoginTime, flavour) -} - -// UpdateStaffUserProfile mocks the implementation of UpdateStaffUserProfile method. -func (gm *PostgresMock) UpdateStaffUserProfile(ctx context.Context, userID string, user *gorm.User, staff *gorm.StaffProfile) (bool, error) { - return gm.UpdateStaffUserFn(ctx, userID, user, staff) -} - -// RegisterStaffUser mocks the implementation of `gorm's` RegisterStaffUser method. -func (gm *PostgresMock) RegisterStaffUser(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - return gm.RegisterStaffUserFn(ctx, user, staff) -} - -// TransferClient mocks the implementation of TransferClient method -func (gm *PostgresMock) TransferClient( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, -) (bool, error) { - return gm.TransferClientFn(ctx, clientID, originFacilityID, destinationFacilityID, reason, notes) -} diff --git a/pkg/onboarding/infrastructure/database/postgres/pg.go b/pkg/onboarding/infrastructure/database/postgres/pg.go index 364729ef..409eec05 100644 --- a/pkg/onboarding/infrastructure/database/postgres/pg.go +++ b/pkg/onboarding/infrastructure/database/postgres/pg.go @@ -8,11 +8,10 @@ import ( type OnboardingDb struct { create gorm.Create query gorm.Query - update gorm.Update delete gorm.Delete } // NewOnboardingDb initializes a new instance of the OnboardingDB struct -func NewOnboardingDb(c gorm.Create, q gorm.Query, u gorm.Update, d gorm.Delete) *OnboardingDb { - return &OnboardingDb{create: c, query: q, update: u, delete: d} +func NewOnboardingDb(c gorm.Create, q gorm.Query, d gorm.Delete) *OnboardingDb { + return &OnboardingDb{create: c, query: q, delete: d} } diff --git a/pkg/onboarding/infrastructure/database/postgres/pg_create.go b/pkg/onboarding/infrastructure/database/postgres/pg_create.go index b7b82537..5485fde5 100644 --- a/pkg/onboarding/infrastructure/database/postgres/pg_create.go +++ b/pkg/onboarding/infrastructure/database/postgres/pg_create.go @@ -4,11 +4,8 @@ import ( "context" "fmt" "strconv" - "time" - "github.com/lib/pq" "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" ) @@ -39,191 +36,3 @@ func (d *OnboardingDb) GetOrCreateFacility(ctx context.Context, facility *dto.Fa return d.mapFacilityObjectToDomain(facilitySession), nil } - -// SavePin does the actual saving of the users PIN in the database -func (d *OnboardingDb) SavePin(ctx context.Context, pinData *domain.UserPIN) (bool, error) { - if pinData.UserID == "" { - return false, fmt.Errorf("userID cannot be empty") - } - pinObj := &gorm.PINData{ - Base: gorm.Base{}, - UserID: pinData.UserID, - HashedPIN: pinData.HashedPIN, - ValidFrom: time.Time{}, - ValidTo: time.Time{}, - IsValid: pinData.IsValid, - Flavour: pinData.Flavour, - Salt: pinData.Salt, - } - - _, err := d.create.SavePin(ctx, pinObj) - if err != nil { - return false, fmt.Errorf("failed to save user pin: %v", err) - } - - return true, nil -} - -// CollectMetrics is responsible for cretating a representation of metrics data. -func (d *OnboardingDb) CollectMetrics(ctx context.Context, metric *dto.MetricInput) (*domain.Metric, error) { - - if metric.Type == "" { - return nil, fmt.Errorf("metric type must be specified") - } - - metricObj := &gorm.Metric{ - Type: metric.Type, - Payload: metric.Payload, - Timestamp: metric.Timestamp, - UID: metric.UID, - } - - metricSession, err := d.create.CollectMetrics(ctx, metricObj) - if err != nil { - return nil, fmt.Errorf("failed to create facility: %v", err) - } - - return d.mapMetricObjectToDomain(metricSession), nil -} - -// RegisterStaffUser creates both the user profile and the staff profile. -func (d *OnboardingDb) RegisterStaffUser(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - if staff.DefaultFacilityID == nil { - return nil, fmt.Errorf("expected default facility ID to be provided") - } - - 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) - } - } - - roles := []string{} - for _, r := range staff.Roles { - if !r.IsValid() { - return nil, fmt.Errorf("role %s is not valid", r) - } - - roles = append(roles, r.String()) - } - - staffObject := &gorm.StaffProfile{ - StaffNumber: staff.StaffNumber, - DefaultFacilityID: staff.DefaultFacilityID, - Addresses: addresses, - Roles: roles, - } - - userStaffProfile, err := d.create.RegisterStaffUser(ctx, userObject, staffObject) - if err != nil { - - return nil, fmt.Errorf("failed to create user session %v", err) - } - - return d.mapRegisterStaffObjectToDomain(userStaffProfile), nil - -} - -// AddIdentifier is responsible for creating an identifier and associating it with a specific client -func (d *OnboardingDb) AddIdentifier( - ctx context.Context, - clientID string, - idType enums.IdentifierType, - idValue string, - isPrimary bool, -) (*domain.Identifier, error) { - identifierPayload := &gorm.Identifier{ - ClientID: clientID, - IdentifierType: idType, - IdentifierValue: idValue, - IdentifierUse: enums.IdentifierUseOfficial, - IsPrimaryIdentifier: isPrimary, - Active: true, - } - - identifier, err := d.create.AddIdentifier(ctx, identifierPayload) - if err != nil { - return nil, fmt.Errorf("failed to create identifier: %v", err) - } - - return d.mapIdentifierObjectToDomain(identifier), nil -} - -// RegisterClient is responsible for registering and saving the client's data to the database -func (d *OnboardingDb) RegisterClient( - ctx context.Context, - userInput *dto.UserInput, - clientInput *dto.ClientProfileInput, -) (*domain.ClientUserProfile, error) { - if clientInput == nil { - return nil, fmt.Errorf("expected client input to be provided") - } - - if userInput == nil { - return nil, fmt.Errorf("expected user input to be provided") - } - - userObject := createUserObject(userInput) - - clientObject := &gorm.ClientProfile{ - ClientType: clientInput.ClientType, - } - - clientUserProfile, err := d.create.RegisterClient(ctx, userObject, clientObject) - if err != nil { - return nil, fmt.Errorf("failed to create client: %v", err) - } - - return d.mapRegisterClientObjectToDomain(clientUserProfile), nil -} - -// A helper method to create a user object -func createUserObject(user *dto.UserInput) *gorm.User { - contacts := []gorm.Contact{} - if len(user.Contacts) > 0 { - for _, u := range user.Contacts { - contact := gorm.Contact{ - Type: u.Type, - Contact: u.Contact, - Active: u.Active, - OptedIn: u.OptedIn, - } - contacts = append(contacts, contact) - } - } - - languages := []string{} - for _, l := range user.Languages { - languages = append(languages, l.String()) - } - - userObject := &gorm.User{ - Username: user.Username, - DisplayName: user.DisplayName, - FirstName: user.FirstName, - MiddleName: user.MiddleName, - LastName: user.LastName, - Gender: user.Gender, - Contacts: contacts, - UserType: user.UserType, - Languages: pq.StringArray(languages), - Flavour: user.Flavour, - } - return userObject -} diff --git a/pkg/onboarding/infrastructure/database/postgres/pg_create_test.go b/pkg/onboarding/infrastructure/database/postgres/pg_create_test.go index a86a42c1..0315ba85 100644 --- a/pkg/onboarding/infrastructure/database/postgres/pg_create_test.go +++ b/pkg/onboarding/infrastructure/database/postgres/pg_create_test.go @@ -4,19 +4,11 @@ import ( "context" "fmt" "testing" - "time" - "github.com/google/uuid" - "github.com/lib/pq" - "github.com/savannahghi/enumutils" - "github.com/savannahghi/feedlib" "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" gormMock "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm/mock" - "github.com/segmentio/ksuid" - "gorm.io/datatypes" ) func TestOnboardingDb_CreateFacility(t *testing.T) { @@ -66,7 +58,7 @@ func TestOnboardingDb_CreateFacility(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) + d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm) got, err := d.GetOrCreateFacility(tt.args.ctx, tt.args.facility) if tt.name == "sad case - facility code not defined" { fakeGorm.GetOrCreateFacilityFn = func(ctx context.Context, facility *gorm.Facility) (*gorm.Facility, error) { @@ -94,432 +86,3 @@ func TestOnboardingDb_CreateFacility(t *testing.T) { }) } } - -func TestOnboardingDb_CollectMetrics_Unittest(t *testing.T) { - ctx := context.Background() - - metric := &dto.MetricInput{ - Type: enums.EngagementMetrics, - Payload: datatypes.JSON([]byte(`{"who": "test user", "keyword": "suicidal"}`)), - Timestamp: time.Now(), - UID: ksuid.New().String(), - } - - invalidMetric := &dto.MetricInput{ - Type: "", - Payload: datatypes.JSON([]byte(`{"who": "test user", "keyword": "suicidal"}`)), - Timestamp: time.Now(), - UID: ksuid.New().String(), - } - - type args struct { - ctx context.Context - metric *dto.MetricInput - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - metric: metric, - }, - wantErr: false, - }, - - { - name: "Sad case", - args: args{ - ctx: ctx, - metric: invalidMetric, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - if tt.name == "Happy case" { - fakeGorm.CollectMetricsFn = func(ctx context.Context, metrics *gorm.Metric) (*gorm.Metric, error) { - now := time.Now() - metricID := uuid.New().String() - return &gorm.Metric{ - MetricID: &metricID, - Type: enums.EngagementMetrics, - Payload: datatypes.JSON([]byte(`{"who": "test user", "keyword": "suicidal"}`)), - Timestamp: now, - UID: ksuid.New().String(), - }, nil - } - } - - if tt.name == "Sad case" { - fakeGorm.CollectMetricsFn = func(ctx context.Context, metrics *gorm.Metric) (*gorm.Metric, error) { - return nil, fmt.Errorf("an error occurred while collecting metrics") - } - } - - _, err := d.CollectMetrics(tt.args.ctx, tt.args.metric) - if (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.CollectMetrics() error = %v, wantErr %v", err, tt.wantErr) - return - } - }) - } -} - -func TestOnboardingDb_SetUserPIN(t *testing.T) { - ctx := context.Background() - - validPINDataINput := &domain.UserPIN{ - UserID: ksuid.New().String(), - HashedPIN: "test-Pin", - ValidFrom: time.Time{}, - ValidTo: time.Time{}, - Flavour: "CONSUMER", - IsValid: false, - Salt: "salt", - } - - invalidPINDataINput := &domain.UserPIN{ - UserID: "", - HashedPIN: "test-Pin", - ValidFrom: time.Time{}, - ValidTo: time.Time{}, - Flavour: "CONSUMER", - IsValid: false, - Salt: "salt", - } - type args struct { - ctx context.Context - pinData *domain.UserPIN - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - pinData: validPINDataINput, - }, - wantErr: false, - }, - - { - name: "Sad case", - args: args{ - ctx: ctx, - pinData: invalidPINDataINput, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - _, err := d.SavePin(tt.args.ctx, tt.args.pinData) - if (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.SetUserPIN() error = %v, wantErr %v", err, tt.wantErr) - return - } - }) - } -} - -func TestOnboardingDb_RegisterStaffUser(t *testing.T) { - ctx := context.Background() - - testFacilityID := uuid.New().String() - testUserID := uuid.New().String() - testTime := time.Now() - testID := uuid.New().String() - rolesInput := []enums.RolesType{enums.RolesTypeCanInviteClient} - - type args struct { - ctx context.Context - user *dto.UserInput - staff *dto.StaffProfileInput - } - - contactInput := &dto.ContactInput{ - Type: enums.PhoneContact, - Contact: "+254700000000", - Active: true, - OptedIn: true, - } - - userInput := &dto.UserInput{ - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Gender: enumutils.GenderMale, - UserType: enums.HealthcareWorkerUser, - Contacts: []*dto.ContactInput{contactInput}, - Languages: []enumutils.Language{enumutils.LanguageEn}, - Flavour: feedlib.FlavourPro, - } - - 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, - }, - }, - Roles: rolesInput, - } - staffNoFacilityIDInput := &dto.StaffProfileInput{ - StaffNumber: "s123", - } - - tests := []struct { - name string - args args - want *domain.StaffUserProfile - wantErr bool - }{ - { - name: "happy case", - args: args{ - ctx: ctx, - user: userInput, - staff: staffInput, - }, - wantErr: false, - }, - { - name: "invalid: missing facility", - args: args{ - ctx: ctx, - user: userInput, - staff: staffNoFacilityIDInput, - }, - wantErr: true, - }, - } - for _, tt := range tests { - var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - t.Run(tt.name, func(t *testing.T) { - - if tt.name == "Happy case" { - - fakeGorm.GetOrCreateFacilityFn = func(ctx context.Context, facility *gorm.Facility) (*gorm.Facility, error) { - return &gorm.Facility{ - FacilityID: &testFacilityID, - Name: "test", - Code: "f1234", - Active: "true", - County: "test", - Description: "test description", - }, nil - } - fakeGorm.RegisterStaffUserFn = func(ctx context.Context, user *gorm.User, staff *gorm.StaffProfile) (*gorm.StaffUserProfile, error) { - contact := gorm.Contact{ - ContactID: &testID, - Type: enums.PhoneContact, - Contact: "+254700000000", - Active: true, - OptedIn: true, - } - return &gorm.StaffUserProfile{ - User: &gorm.User{ - UserID: &testUserID, - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Gender: enumutils.GenderMale, - Active: true, - Contacts: []gorm.Contact{contact}, - UserType: enums.HealthcareWorkerUser, - Languages: pq.StringArray{"EN", "SW"}, - LastSuccessfulLogin: &testTime, - LastFailedLogin: &testTime, - NextAllowedLogin: &testTime, - FailedLoginCount: "0", - TermsAccepted: true, - AcceptedTermsID: testID, - Flavour: feedlib.FlavourPro, - }, - Staff: &gorm.StaffProfile{ - StaffProfileID: &testID, - 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, - }, - }, - Roles: []string{enums.RolesTypeCanInviteClient.String()}, - }, - }, nil - } - } - - if tt.name == "invalid: missing facility" { - fakeGorm.RegisterStaffUserFn = func(ctx context.Context, user *gorm.User, staff *gorm.StaffProfile) (*gorm.StaffUserProfile, error) { - return nil, fmt.Errorf("test error") - } - } - - _, err := d.RegisterStaffUser(tt.args.ctx, tt.args.user, tt.args.staff) - if (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.RegisterStaffUser() error = %v, wantErr %v", err, tt.wantErr) - return - } - }) - } -} - -func TestOnboardingDb_RegisterClient(t *testing.T) { - ctx := context.Background() - userInput := &dto.UserInput{ - FirstName: "John", - LastName: "Joe", - Username: "Jontez", - MiddleName: "Johnny", - DisplayName: "jo", - Gender: enumutils.GenderMale, - } - - clientInput := dto.ClientProfileInput{ - ClientType: enums.ClientTypeOvc, - } - type args struct { - ctx context.Context - userInput *dto.UserInput - clientInput *dto.ClientProfileInput - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy Case", - args: args{ - ctx: ctx, - userInput: userInput, - clientInput: &clientInput, - }, - wantErr: false, - }, - { - name: "Sad Case: Fail to create user", - args: args{ - ctx: ctx, - userInput: userInput, - clientInput: &clientInput, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - if tt.name == "Sad Case: Fail to create user" { - fakeGorm.RegisterClientFn = func(ctx context.Context, userInput *gorm.User, clientInput *gorm.ClientProfile) (*gorm.ClientUserProfile, error) { - return nil, fmt.Errorf("failed to create a client user") - } - } - - got, err := d.RegisterClient(tt.args.ctx, tt.args.userInput, tt.args.clientInput) - if (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.RegisterClient() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !tt.wantErr && got == nil { - t.Errorf("expected a response but got :%v", got) - } - }) - } -} - -func TestOnboardingDb_AddIdentifier(t *testing.T) { - ctx := context.Background() - type args struct { - ctx context.Context - clientID string - idType enums.IdentifierType - idValue string - isPrimary bool - } - tests := []struct { - name string - args args - want *domain.Identifier - wantErr bool - }{ - { - name: "Happy Case - Successfully add identifier", - args: args{ - ctx: ctx, - clientID: "12345", - idType: enums.IdentifierTypeCCC, - idValue: "1224", - isPrimary: true, - }, - wantErr: false, - }, - { - name: "Sad Case - Fail to add identifier", - args: args{ - ctx: ctx, - clientID: "12345", - idType: enums.IdentifierTypeCCC, - idValue: "1224", - isPrimary: true, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - if tt.name == "Sad Case - Fail to add identifier" { - fakeGorm.AddIdentifierFn = func(ctx context.Context, identifier *gorm.Identifier) (*gorm.Identifier, error) { - return nil, fmt.Errorf("failed to add identifier") - } - } - got, err := d.AddIdentifier(tt.args.ctx, tt.args.clientID, tt.args.idType, tt.args.idValue, tt.args.isPrimary) - if (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.AddIdentifier() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !tt.wantErr && got == nil { - t.Errorf("expected a response but got :%v", got) - } - }) - } -} diff --git a/pkg/onboarding/infrastructure/database/postgres/pg_delete_unit_test.go b/pkg/onboarding/infrastructure/database/postgres/pg_delete_unit_test.go index a892037f..21a33669 100644 --- a/pkg/onboarding/infrastructure/database/postgres/pg_delete_unit_test.go +++ b/pkg/onboarding/infrastructure/database/postgres/pg_delete_unit_test.go @@ -13,7 +13,7 @@ func TestOnboardingDb_DeleteFacility_Unittest(t *testing.T) { ctx := context.Background() var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) + d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm) facilityInput := &dto.FacilityInput{ Name: "Kanairo One", @@ -73,7 +73,7 @@ func TestOnboardingDb_DeleteFacility_Unittest(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) + d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm) if tt.name == "Happy case" { fakeGorm.DeleteFacilityFn = func(ctx context.Context, mfl_code string) (bool, error) { diff --git a/pkg/onboarding/infrastructure/database/postgres/pg_query.go b/pkg/onboarding/infrastructure/database/postgres/pg_query.go index 3342f3a8..ac70778c 100644 --- a/pkg/onboarding/infrastructure/database/postgres/pg_query.go +++ b/pkg/onboarding/infrastructure/database/postgres/pg_query.go @@ -5,7 +5,6 @@ import ( "fmt" "strconv" - "github.com/savannahghi/feedlib" "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" ) @@ -65,43 +64,3 @@ func (d *OnboardingDb) RetrieveByFacilityMFLCode(ctx context.Context, MFLCode st return d.mapFacilityObjectToDomain(facilitySession), nil } - -// GetUserProfileByUserID fetches a user profile facility using the user ID -func (d *OnboardingDb) GetUserProfileByUserID(ctx context.Context, userID string, flavour feedlib.Flavour) (*domain.User, error) { - user, err := d.query.GetUserProfileByUserID(ctx, userID, flavour) - if err != nil { - return nil, fmt.Errorf("failed to retrieve user profile by user ID: %s", err) - } - - return d.mapProfileObjectToDomain(user), nil -} - -// GetUserPINByUserID fetches a user profile facility using the user ID -func (d *OnboardingDb) GetUserPINByUserID(ctx context.Context, userID string) (*domain.UserPIN, error) { - pinData, err := d.query.GetUserPINByUserID(ctx, userID) - if err != nil { - return nil, fmt.Errorf("failed query and retrieve user PIN data by user ID: %s", err) - } - - return d.mapPINObjectToDomain(pinData), nil -} - -// GetClientProfileByClientID retrieves a client profile using the client ID -func (d *OnboardingDb) GetClientProfileByClientID(ctx context.Context, clientID string) (*domain.ClientProfile, error) { - client, err := d.query.GetClientProfileByClientID(ctx, clientID) - if err != nil { - return nil, err - } - - return d.mapClientObjectToDomain(client), err -} - -// GetStaffProfile retrieves a staff profile using the staff number -func (d *OnboardingDb) GetStaffProfile(ctx context.Context, staffNumber string) (*domain.StaffProfile, error) { - staff, err := d.query.GetStaffProfile(ctx, staffNumber) - if err != nil { - return nil, err - } - - return d.mapStaffObjectToDomain(staff), err -} diff --git a/pkg/onboarding/infrastructure/database/postgres/pg_query_test.go b/pkg/onboarding/infrastructure/database/postgres/pg_query_test.go index e5f7bcf2..f5f07f3c 100644 --- a/pkg/onboarding/infrastructure/database/postgres/pg_query_test.go +++ b/pkg/onboarding/infrastructure/database/postgres/pg_query_test.go @@ -18,7 +18,7 @@ func TestOnboardingDb_RetrieveFacility_Unittest(t *testing.T) { ctx := context.Background() var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) + d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm) facilityInput := &dto.FacilityInput{ Name: "Kanairo One", @@ -165,7 +165,7 @@ func TestOnboardingDb_GetFacilities(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) + d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm) if tt.name == "sad case - facility want data not given" { fakeGorm.GetFacilitiesFn = func(ctx context.Context) ([]gorm.Facility, error) { @@ -213,7 +213,7 @@ func TestOnboardingDb_RetrieveByFacilityMFLCode(t *testing.T) { ctx := context.Background() var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) + d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm) facilityInput := &dto.FacilityInput{ Name: "Kanairo One", @@ -299,54 +299,3 @@ func TestOnboardingDb_RetrieveByFacilityMFLCode(t *testing.T) { }) } } - -func TestOnboardingDb_GetClientProfileByClientID(t *testing.T) { - ctx := context.Background() - var fakeGorm = gormMock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - type args struct { - ctx context.Context - clientID string - } - tests := []struct { - name string - args args - want *domain.ClientProfile - wantErr bool - }{ - { - name: "Happy Case - Successfully fetch client profile", - args: args{ - ctx: ctx, - clientID: "1234", - }, - wantErr: false, - }, - { - name: "Sad Case - Fail to get profile", - args: args{ - ctx: ctx, - clientID: "1234", - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.name == "Sad Case - Fail to get profile" { - fakeGorm.GetClientProfileByClientIDFn = func(ctx context.Context, clientID string) (*gorm.ClientProfile, error) { - return nil, fmt.Errorf("failed to get client profile by ID") - } - } - got, err := d.GetClientProfileByClientID(tt.args.ctx, tt.args.clientID) - if (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.GetClientProfileByClientID() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !tt.wantErr && got == nil { - t.Errorf("expected a response but got :%v", got) - } - }) - } -} diff --git a/pkg/onboarding/infrastructure/database/postgres/pg_update.go b/pkg/onboarding/infrastructure/database/postgres/pg_update.go deleted file mode 100644 index 2c454be9..00000000 --- a/pkg/onboarding/infrastructure/database/postgres/pg_update.go +++ /dev/null @@ -1,107 +0,0 @@ -package postgres - -import ( - "context" - "time" - - "github.com/savannahghi/feedlib" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" -) - -// InvalidatePIN invalidates a pin that is linked to the user profile. -// This is done by toggling the IsValid field to false -func (d *OnboardingDb) InvalidatePIN(ctx context.Context, userID string) error { - return d.update.InvalidatePIN(ctx, userID) -} - -// UpdateUserLastSuccessfulLogin update the user with the last login time -func (d *OnboardingDb) UpdateUserLastSuccessfulLogin(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error { - return d.update.UpdateUserLastSuccessfulLogin(ctx, userID, lastLoginTime, flavour) -} - -// UpdateUserLastFailedLogin updates the user's last failed login time -func (d *OnboardingDb) UpdateUserLastFailedLogin(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - return d.update.UpdateUserLastFailedLogin(ctx, userID, lastFailedLoginTime, flavour) -} - -// UpdateUserFailedLoginCount updates the user's failed login count. -func (d *OnboardingDb) UpdateUserFailedLoginCount(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error { - return d.update.UpdateUserFailedLoginCount(ctx, userID, failedLoginCount, flavour) -} - -// UpdateUserNextAllowedLogin updates the user's next allowed login time -func (d *OnboardingDb) UpdateUserNextAllowedLogin(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error { - return d.update.UpdateUserNextAllowedLogin(ctx, userID, nextAllowedLoginTime, flavour) -} - -// UpdateStaffUserProfile updates the staff user details -func (d *OnboardingDb) UpdateStaffUserProfile(ctx context.Context, userID string, user *dto.UserInput, staff *dto.StaffProfileInput) (bool, error) { - contacts := []gorm.Contact{} - if len(user.Contacts) > 0 { - for _, u := range user.Contacts { - contact := gorm.Contact{ - Type: u.Type, - Contact: u.Contact, - Active: u.Active, - OptedIn: u.OptedIn, - } - contacts = append(contacts, contact) - } - } - - addresses := []*gorm.Addresses{} - if len(staff.Addresses) > 0 { - for _, a := range staff.Addresses { - 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) - } - } - - languages := []string{} - for _, l := range user.Languages { - languages = append(languages, l.String()) - } - - userData := &gorm.User{ - Username: user.Username, - DisplayName: user.DisplayName, - FirstName: user.FirstName, - MiddleName: user.MiddleName, - LastName: user.LastName, - UserType: user.UserType, - Gender: user.Gender, - Contacts: contacts, - Languages: languages, - Flavour: user.Flavour, - } - - staffData := &gorm.StaffProfile{ - StaffNumber: staff.StaffNumber, - DefaultFacilityID: staff.DefaultFacilityID, - Facility: gorm.Facility{}, - Addresses: addresses, - } - - return d.update.UpdateStaffUserProfile(ctx, userID, userData, staffData) -} - -// TransferClient transfers client -func (d *OnboardingDb) TransferClient( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, -) (bool, error) { - return d.update.TransferClient(ctx, clientID, originFacilityID, destinationFacilityID, reason, notes) -} diff --git a/pkg/onboarding/infrastructure/database/postgres/pg_update_test.go b/pkg/onboarding/infrastructure/database/postgres/pg_update_test.go deleted file mode 100644 index 9e32945d..00000000 --- a/pkg/onboarding/infrastructure/database/postgres/pg_update_test.go +++ /dev/null @@ -1,360 +0,0 @@ -package postgres - -import ( - "context" - "fmt" - "testing" - "time" - - "github.com/google/uuid" - "github.com/savannahghi/enumutils" - "github.com/savannahghi/feedlib" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" - gormmock "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm/mock" - "github.com/segmentio/ksuid" - "github.com/tj/assert" -) - -func TestOnboardingDb_UpdateUserLastSuccessfulLogin(t *testing.T) { - ctx := context.Background() - - type args struct { - ctx context.Context - userID string - lastLoginTime time.Time - flavour feedlib.Flavour - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - userID: "1zixbASMwkk3QTnSDmH0EDHZ6H8", - lastLoginTime: time.Now(), - flavour: "CONSUMER", - }, - wantErr: false, - }, - - { - name: "Sad case", - args: args{ - ctx: ctx, - userID: "1zixbASMwkk3QTnSDmH0EDHZ6H8", - lastLoginTime: time.Now(), - flavour: "invalid-flavour", - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var fakeGorm = gormmock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - if tt.name == "Sad case" { - fakeGorm.UpdateUserLastSuccessfulLoginFn = func(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error { - return fmt.Errorf("an error occurred") - } - } - - if err := d.UpdateUserLastSuccessfulLogin(tt.args.ctx, tt.args.userID, tt.args.lastLoginTime, tt.args.flavour); (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.UpdateUserLastSuccessfulLogin() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestOnboardingDb_UpdateUserLastFailedLogin(t *testing.T) { - ctx := context.Background() - type args struct { - ctx context.Context - userID string - lastFailedLoginTime time.Time - flavour feedlib.Flavour - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - userID: "1zixbASMwkk3QTnSDmH0EDHZ6H8", - lastFailedLoginTime: time.Now(), - flavour: "CONSUMER", - }, - wantErr: false, - }, - - { - name: "Sad case", - args: args{ - ctx: ctx, - userID: "1zixbASMwkk3QTnSDmH0EDHZ6H8", - lastFailedLoginTime: time.Now(), - flavour: "Invalid -flavour", - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var fakeGorm = gormmock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - if tt.name == "Sad case" { - fakeGorm.UpdateUserLastFailedLoginFn = func(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - return fmt.Errorf("an error occurred") - } - } - if err := d.UpdateUserLastFailedLogin(tt.args.ctx, tt.args.userID, tt.args.lastFailedLoginTime, tt.args.flavour); (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.UpdateUserLastFailedLogin() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestOnboardingDb_UpdateUserFailedLoginCount(t *testing.T) { - ctx := context.Background() - - type args struct { - ctx context.Context - userID string - failedLoginCount string - flavour feedlib.Flavour - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - userID: "1zixbASMwkk3QTnSDmH0EDHZ6H8", - failedLoginCount: "0", - flavour: "CONSUMER", - }, - wantErr: false, - }, - - { - name: "Sad case", - args: args{ - ctx: ctx, - userID: "1zixbASMwkk3QTnSDmH0EDHZ6H8", - failedLoginCount: "0", - flavour: "Invalid", - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var fakeGorm = gormmock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - if tt.name == "Sad case" { - fakeGorm.UpdateUserLastFailedLoginFn = func(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - return fmt.Errorf("an error occurred") - } - } - if err := d.UpdateUserFailedLoginCount(tt.args.ctx, tt.args.userID, tt.args.failedLoginCount, tt.args.flavour); (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.UpdateUserFailedLoginCount() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestOnboardingDb_UpdateUserNextAllowedLogin(t *testing.T) { - ctx := context.Background() - - type args struct { - ctx context.Context - userID string - nextAllowedLoginTime time.Time - flavour feedlib.Flavour - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - userID: "1zixbASMwkk3QTnSDmH0EDHZ6H8", - nextAllowedLoginTime: time.Now(), - flavour: "CONSUMER", - }, - wantErr: false, - }, - - { - name: "Sad case", - args: args{ - ctx: ctx, - userID: "1zixbASMwkk3QTnSDmH0EDHZ6H8", - nextAllowedLoginTime: time.Now(), - flavour: "Invalid-CONSUMER", - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var fakeGorm = gormmock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - if tt.name == "Sad case" { - fakeGorm.UpdateUserNextAllowedLoginFn = func(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error { - return fmt.Errorf("an error occurred") - } - } - if err := d.UpdateUserNextAllowedLogin(tt.args.ctx, tt.args.userID, tt.args.nextAllowedLoginTime, tt.args.flavour); (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.UpdateUserNextAllowedLogin() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestOnboardingDb_UpdateStaffUser(t *testing.T) { - ctx := context.Background() - - defaultFacilityID := ksuid.New().String() - - type args struct { - ctx context.Context - userID string - user *dto.UserInput - staff *dto.StaffProfileInput - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - userID: "test-UserID", - user: &dto.UserInput{ - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - UserType: "test", - Gender: "test", - Languages: []enumutils.Language{enumutils.LanguageEn}, - Flavour: feedlib.FlavourPro, - }, - staff: &dto.StaffProfileInput{ - StaffNumber: "test-UserID", - DefaultFacilityID: &defaultFacilityID, - }, - }, - wantErr: false, - }, - - { - name: "Sad case", - args: args{ - ctx: ctx, - userID: "test-UserID", - user: &dto.UserInput{ - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - UserType: "test", - Gender: "test", - Languages: []enumutils.Language{enumutils.LanguageEn}, - Flavour: feedlib.FlavourPro, - }, - staff: &dto.StaffProfileInput{ - StaffNumber: "", - DefaultFacilityID: &defaultFacilityID, - }, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var fakeGorm = gormmock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - if tt.name == "Sad case" { - fakeGorm.UpdateStaffUserFn = func(ctx context.Context, userID string, user *gorm.User, staff *gorm.StaffProfile) (bool, error) { - return false, fmt.Errorf("an error occurred when updating the user") - } - } - - got, err := d.UpdateStaffUserProfile(tt.args.ctx, tt.args.userID, tt.args.user, tt.args.staff) - if (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.UpdateStaffUserProfile() error = %v, wantErr %v", err, tt.wantErr) - return - } - assert.NotNil(t, got) - }) - } -} - -func TestOnboardingDb_InvalidatePIN(t *testing.T) { - ctx := context.Background() - - type args struct { - ctx context.Context - userID string - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy Case - Successfully invalidate pin", - args: args{ - ctx: ctx, - userID: uuid.New().String(), - }, - wantErr: false, - }, - { - name: "Sad Case - Fail to invalidate pin", - args: args{ - ctx: ctx, - userID: uuid.New().String(), - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var fakeGorm = gormmock.NewGormMock() - d := NewOnboardingDb(fakeGorm, fakeGorm, fakeGorm, fakeGorm) - - if tt.name == "Sad Case - Fail to invalidate pin" { - fakeGorm.InvalidatePINFn = func(ctx context.Context, userID string) error { - return fmt.Errorf("failed to invalidate pin") - } - } - if err := d.InvalidatePIN(tt.args.ctx, tt.args.userID); (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.InvalidatePIN() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} diff --git a/pkg/onboarding/infrastructure/infrastructure.go b/pkg/onboarding/infrastructure/infrastructure.go index b12d8b69..e37e03e2 100644 --- a/pkg/onboarding/infrastructure/infrastructure.go +++ b/pkg/onboarding/infrastructure/infrastructure.go @@ -23,7 +23,6 @@ type Infrastructure struct { Create Delete Query - Update libOnboardingUsecase.LoginUseCases libOnboardingUsecase.SignUpUseCases engagementSvc.ServiceEngagementImpl @@ -37,7 +36,6 @@ type Interactor struct { Create Delete Query - Update libOnboardingUsecase.LoginUseCases libOnboardingUsecase.SignUpUseCases engagementSvc.ServiceEngagementImpl @@ -62,18 +60,16 @@ func NewInteractor() Interactor { if err != nil { log.Fatal(err) } - db := pg.NewOnboardingDb(postgres, postgres, postgres, postgres) + db := pg.NewOnboardingDb(postgres, postgres, postgres) create := NewServiceCreateImpl(*db) delete := NewServiceDeleteImpl(*db) query := NewServiceQueryImpl(*db) - update := NewServiceUpdateImpl(*db) pinExt := baseExt.NewPINExtensionImpl() return Interactor{ create, delete, query, - update, login, signup, *engagement, diff --git a/pkg/onboarding/infrastructure/repository.go b/pkg/onboarding/infrastructure/repository.go index 7bd7c617..cc4d3404 100644 --- a/pkg/onboarding/infrastructure/repository.go +++ b/pkg/onboarding/infrastructure/repository.go @@ -2,11 +2,8 @@ package infrastructure import ( "context" - "time" - "github.com/savannahghi/feedlib" "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" pg "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres" ) @@ -16,21 +13,6 @@ import ( // All the contracts for create operations are assembled here type Create interface { GetOrCreateFacility(ctx context.Context, facility dto.FacilityInput) (*domain.Facility, error) - CollectMetrics(ctx context.Context, metric *dto.MetricInput) (*domain.Metric, error) - SavePin(ctx context.Context, pinInput *domain.UserPIN) (bool, error) - RegisterStaffUser(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) - RegisterClient( - ctx context.Context, - userInput *dto.UserInput, - clientInput *dto.ClientProfileInput, - ) (*domain.ClientUserProfile, error) - AddIdentifier( - ctx context.Context, - clientID string, - idType enums.IdentifierType, - idValue string, - isPrimary bool, - ) (*domain.Identifier, error) } // Delete represents all the deletion action interfaces @@ -55,50 +37,11 @@ func (f ServiceCreateImpl) GetOrCreateFacility(ctx context.Context, facility dto return f.onboarding.GetOrCreateFacility(ctx, &facility) } -// CollectMetrics is responsible for creating a representation of a metric -func (f ServiceCreateImpl) CollectMetrics(ctx context.Context, metric *dto.MetricInput) (*domain.Metric, error) { - return f.onboarding.CollectMetrics(ctx, metric) -} - -// SavePin saves user's PIN data -func (f ServiceCreateImpl) SavePin(ctx context.Context, input *domain.UserPIN) (bool, error) { - return f.onboarding.SavePin(ctx, input) -} - -// RegisterStaffUser is responsible for creating a representation of a staff user -func (f ServiceCreateImpl) RegisterStaffUser(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - return f.onboarding.RegisterStaffUser(ctx, user, staff) -} - -// AddIdentifier adds an identifier that is associated to a given client -func (f ServiceCreateImpl) AddIdentifier( - ctx context.Context, - clientID string, - idType enums.IdentifierType, - idValue string, - isPrimary bool, -) (*domain.Identifier, error) { - return f.onboarding.AddIdentifier(ctx, clientID, idType, idValue, isPrimary) -} - -// RegisterClient creates a client user and saves the details in the database -func (f ServiceCreateImpl) RegisterClient( - ctx context.Context, - userInput *dto.UserInput, - clientInput *dto.ClientProfileInput, -) (*domain.ClientUserProfile, error) { - return f.onboarding.RegisterClient(ctx, userInput, clientInput) -} - // Query contains all query methods type Query interface { RetrieveFacility(ctx context.Context, id *string, isActive bool) (*domain.Facility, error) GetFacilities(ctx context.Context) ([]*domain.Facility, error) RetrieveFacilityByMFLCode(ctx context.Context, MFLCode string, isActive bool) (*domain.Facility, error) - GetUserProfileByUserID(ctx context.Context, userID string, flavour feedlib.Flavour) (*domain.User, error) - GetUserPINByUserID(ctx context.Context, userID string) (*domain.UserPIN, error) - GetClientProfileByClientID(ctx context.Context, clientID string) (*domain.ClientProfile, error) - GetStaffProfile(ctx context.Context, staffNumber string) (*domain.StaffProfile, error) } // ServiceQueryImpl contains implementation for the Query interface @@ -133,26 +76,6 @@ func (f ServiceDeleteImpl) DeleteFacility(ctx context.Context, id string) (bool, return f.onboarding.DeleteFacility(ctx, id) } -// GetUserProfileByUserID gets user profile by user ID -func (q ServiceQueryImpl) GetUserProfileByUserID(ctx context.Context, userID string, flavour feedlib.Flavour) (*domain.User, error) { - return q.onboarding.GetUserProfileByUserID(ctx, userID, flavour) -} - -// GetUserPINByUserID gets user PIN by user ID -func (q ServiceQueryImpl) GetUserPINByUserID(ctx context.Context, userID string) (*domain.UserPIN, error) { - return q.onboarding.GetUserPINByUserID(ctx, userID) -} - -// GetClientProfileByClientID fetches a client profile using the client ID -func (q ServiceQueryImpl) GetClientProfileByClientID(ctx context.Context, clientID string) (*domain.ClientProfile, error) { - return q.onboarding.GetClientProfileByClientID(ctx, clientID) -} - -// GetStaffProfile fetches a staffs profile using the staff number -func (q ServiceQueryImpl) GetStaffProfile(ctx context.Context, staffNumber string) (*domain.StaffProfile, error) { - return q.onboarding.GetStaffProfile(ctx, staffNumber) -} - // ServiceDeleteImpl represents delete facility implementation object type ServiceDeleteImpl struct { onboarding pg.OnboardingDb @@ -164,75 +87,3 @@ func NewServiceDeleteImpl(on pg.OnboardingDb) Delete { onboarding: on, } } - -// Update contains all update methods -type Update interface { - UpdateUserLastSuccessfulLogin(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error - UpdateUserLastFailedLogin(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error - UpdateUserFailedLoginCount(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error - UpdateUserNextAllowedLogin(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error - UpdateStaffUserProfile(ctx context.Context, userID string, user *dto.UserInput, staff *dto.StaffProfileInput) (bool, error) - TransferClient( - ctx context.Context, - clientID string, - OriginFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, - ) (bool, error) - InvalidatePIN(ctx context.Context, userID string) error -} - -// ServiceUpdateImpl represents update user implementation object -type ServiceUpdateImpl struct { - onboarding pg.OnboardingDb -} - -// NewServiceUpdateImpl returns new instance of NewServiceUpdateImpl -func NewServiceUpdateImpl(on pg.OnboardingDb) Update { - return &ServiceUpdateImpl{ - onboarding: on, - } -} - -// InvalidatePIN invalidates pin(s) that are linked to a user -func (u *ServiceUpdateImpl) InvalidatePIN(ctx context.Context, userID string) error { - return u.onboarding.InvalidatePIN(ctx, userID) -} - -// UpdateUserLastSuccessfulLogin ... -func (u *ServiceUpdateImpl) UpdateUserLastSuccessfulLogin(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error { - return u.onboarding.UpdateUserLastSuccessfulLogin(ctx, userID, lastLoginTime, flavour) -} - -// UpdateUserLastFailedLogin ... -func (u *ServiceUpdateImpl) UpdateUserLastFailedLogin(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - return u.onboarding.UpdateUserLastFailedLogin(ctx, userID, lastFailedLoginTime, flavour) -} - -// UpdateUserFailedLoginCount ... -func (u *ServiceUpdateImpl) UpdateUserFailedLoginCount(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error { - return u.onboarding.UpdateUserFailedLoginCount(ctx, userID, failedLoginCount, flavour) -} - -// UpdateUserNextAllowedLogin ... -func (u *ServiceUpdateImpl) UpdateUserNextAllowedLogin(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error { - return u.onboarding.UpdateUserNextAllowedLogin(ctx, userID, nextAllowedLoginTime, flavour) -} - -// UpdateStaffUserProfile updates the staffs data -func (u *ServiceUpdateImpl) UpdateStaffUserProfile(ctx context.Context, userID string, user *dto.UserInput, staff *dto.StaffProfileInput) (bool, error) { - return u.onboarding.UpdateStaffUserProfile(ctx, userID, user, staff) -} - -// TransferClient implements the clients transfer -func (u *ServiceUpdateImpl) TransferClient( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, -) (bool, error) { - return u.onboarding.TransferClient(ctx, clientID, originFacilityID, destinationFacilityID, reason, notes) -} diff --git a/pkg/onboarding/presentation/config.go b/pkg/onboarding/presentation/config.go index 40037777..a5e13c9f 100644 --- a/pkg/onboarding/presentation/config.go +++ b/pkg/onboarding/presentation/config.go @@ -15,22 +15,15 @@ import ( "github.com/99designs/gqlgen/graphql/handler" "github.com/gorilla/handlers" "github.com/gorilla/mux" - onboardingExtension "github.com/savannahghi/onboarding-service/pkg/onboarding/application/extension" infra "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" postgres "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres" "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/graph" "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/graph/generated" "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/interactor" - internalRest "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/rest" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/client" "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/facility" - metrics "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/metric" - staff "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/staff" - userusecase "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/user" "github.com/savannahghi/onboarding/pkg/onboarding/application/extension" osinfra "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure" - "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure/services/engagement" openSourcePresentation "github.com/savannahghi/onboarding/pkg/onboarding/presentation" "github.com/savannahghi/onboarding/pkg/onboarding/presentation/rest" osusecases "github.com/savannahghi/onboarding/pkg/onboarding/usecases" @@ -68,18 +61,12 @@ func Router(ctx context.Context) (*mux.Router, error) { // Initialize base (common) extension baseExt := extension.NewBaseExtensionImpl(fc) - // Initialize ISC clients - engagementISC := onboardingExtension.NewInterServiceClient(engagementService) - pinExt := extension.NewPINExtensionImpl() - onboardingExt := onboardingExtension.NewOnboardingLibImpl() // Initialize new instances of the infrastructure services // Initialize new open source interactors infrastructure := osinfra.NewInfrastructureInteractor() - engagement := engagement.NewServiceEngagementImpl(engagementISC, baseExt) - openSourceUsecases := osusecases.NewUsecasesInteractor(infrastructure, baseExt, pinExt) // initialize internal infrastructure @@ -88,37 +75,21 @@ func Router(ctx context.Context) (*mux.Router, error) { // Initialize facility usecase facilityUseCase := facility.NewFacilityUsecase(infra) - //Initialize metric usecases - metricsUsecase := metrics.NewMetricUsecase(infra) - - userUsecase := userusecase.NewUseCasesUserImpl(infra, onboardingExt, engagement) - // Initialize staff usecases - staffUsecase := staff.NewUsecasesStaffProfileImpl(infra) - - // Initialize client usecases - clientUseCase := client.NewUseCasesClientImpl(infra) - pg, err := gorm.NewPGInstance() if err != nil { return nil, fmt.Errorf("can't instantiate repository in resolver: %v", err) } - db := postgres.NewOnboardingDb(pg, pg, pg, pg) + db := postgres.NewOnboardingDb(pg, pg, pg) // Initialize the interactor i := interactor.NewOnboardingInteractor( infrastructure, *db, - openSourceUsecases, facilityUseCase, - metricsUsecase, - userUsecase, - staffUsecase, - clientUseCase, ) h := rest.NewHandlersInterfaces(infrastructure, openSourceUsecases) - internalHandlers := internalRest.NewOnboardingHandlersInterfaces(infra, *i) r := mux.NewRouter() // gorilla mux r.Use(otelmux.Middleware(serverutils.MetricsCollectorService("onboarding"))) @@ -140,21 +111,6 @@ func Router(ctx context.Context) (*mux.Router, error) { // Shared authenticated routes openSourcePresentation.SharedAuthenticatedRoutes(h, r) - // Onboarding service rest routes - r.Path("/collect_metrics"). - Methods(http.MethodPost, http.MethodOptions). - HandlerFunc(internalHandlers.CollectMetricsHandler()) - - // Onboarding service rest routes - r.Path("/login"). - Methods(http.MethodPost, http.MethodOptions). - HandlerFunc(internalHandlers.LoginHandler()) - - r.Path("/reset_pin").Methods( - http.MethodPost, - http.MethodOptions, - ).HandlerFunc(internalHandlers.ResetPin()) - // Graphql route authR := r.Path("/graphql").Subrouter() authR.Use(firebasetools.AuthenticationMiddleware(firebaseApp)) diff --git a/pkg/onboarding/presentation/graph/client.graphql b/pkg/onboarding/presentation/graph/client.graphql deleted file mode 100644 index 6a9ce6f8..00000000 --- a/pkg/onboarding/presentation/graph/client.graphql +++ /dev/null @@ -1,23 +0,0 @@ -extend type Mutation { - registerClientUser( - userInput: UserInput! - clientInput: ClientProfileInput! - ): ClientUserProfile! - - addIdentifier( - clientID: String! - idType: IdentifierType! - idValue: String! - isPrimary: Boolean! - ): Identifier! - - inviteClient(userID: String!, flavour: Flavour!): Boolean! - transferClient( - clientID: String! - OriginFacilityID: String - destinationFacilityID: String - Reason: TransferReason! - Notes: String! - ): Boolean! - -} diff --git a/pkg/onboarding/presentation/graph/client.resolvers.go b/pkg/onboarding/presentation/graph/client.resolvers.go deleted file mode 100644 index 81d1c5ff..00000000 --- a/pkg/onboarding/presentation/graph/client.resolvers.go +++ /dev/null @@ -1,35 +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" - - "github.com/savannahghi/feedlib" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/graph/generated" -) - -func (r *mutationResolver) RegisterClientUser(ctx context.Context, userInput dto.UserInput, clientInput dto.ClientProfileInput) (*domain.ClientUserProfile, error) { - return r.interactor.ClientUseCase.RegisterClient(ctx, &userInput, &clientInput) -} - -func (r *mutationResolver) AddIdentifier(ctx context.Context, clientID string, idType enums.IdentifierType, idValue string, isPrimary bool) (*domain.Identifier, error) { - return r.interactor.ClientUseCase.AddIdentifier(ctx, clientID, idType, idValue, isPrimary) -} - -func (r *mutationResolver) InviteClient(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error) { - return r.interactor.UserUsecase.Invite(ctx, userID, flavour) -} - -func (r *mutationResolver) TransferClient(ctx context.Context, clientID string, originFacilityID *string, destinationFacilityID *string, reason enums.TransferReason, notes string) (bool, error) { - return r.interactor.ClientUseCase.TransferClient(ctx, clientID, *originFacilityID, *destinationFacilityID, reason, notes) -} - -// Mutation returns generated.MutationResolver implementation. -func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } - -type mutationResolver struct{ *Resolver } diff --git a/pkg/onboarding/presentation/graph/entity.resolvers.go b/pkg/onboarding/presentation/graph/entity.resolvers.go index bd9e8cc1..c8c76734 100644 --- a/pkg/onboarding/presentation/graph/entity.resolvers.go +++ b/pkg/onboarding/presentation/graph/entity.resolvers.go @@ -5,6 +5,7 @@ package graph import ( "context" + "fmt" "github.com/savannahghi/firebasetools" "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/graph/generated" @@ -12,13 +13,11 @@ import ( ) func (r *entityResolver) FindPageInfoByHasNextPage(ctx context.Context, hasNextPage bool) (*firebasetools.PageInfo, error) { - return nil, nil + panic(fmt.Errorf("not implemented")) } func (r *entityResolver) FindUserProfileByID(ctx context.Context, id string) (*profileutils.UserProfile, error) { - r.checkPreconditions() - r.CheckUserTokenInContext(ctx) - return r.interactor.OpenSourceUsecases.GetProfileByID(ctx, &id) + panic(fmt.Errorf("not implemented")) } // Entity returns generated.EntityResolver implementation. diff --git a/pkg/onboarding/presentation/graph/facility.graphql b/pkg/onboarding/presentation/graph/facility.graphql index 55a1f89c..fb5584af 100644 --- a/pkg/onboarding/presentation/graph/facility.graphql +++ b/pkg/onboarding/presentation/graph/facility.graphql @@ -2,7 +2,6 @@ extend type Mutation { createFacility(input: FacilityInput!): Facility! deleteFacility(id: String!): 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 ac80907a..d604c3a1 100644 --- a/pkg/onboarding/presentation/graph/facility.resolvers.go +++ b/pkg/onboarding/presentation/graph/facility.resolvers.go @@ -12,30 +12,35 @@ import ( ) func (r *mutationResolver) CreateFacility(ctx context.Context, input dto.FacilityInput) (*domain.Facility, error) { + r.checkPreconditions() return r.interactor.FacilityUsecase.GetOrCreateFacility(ctx, input) } func (r *mutationResolver) DeleteFacility(ctx context.Context, id string) (bool, error) { + r.checkPreconditions() return r.interactor.FacilityUsecase.DeleteFacility(ctx, id) } -func (r *mutationResolver) SetUserPin(ctx context.Context, input *dto.PinInput) (bool, error) { - return r.interactor.UserUsecase.SetUserPIN(ctx, input) -} - func (r *queryResolver) FetchFacilities(ctx context.Context) ([]*domain.Facility, error) { + r.checkPreconditions() return r.interactor.FacilityUsecase.FetchFacilities(ctx) } func (r *queryResolver) RetrieveFacility(ctx context.Context, id string, active bool) (*domain.Facility, error) { + r.checkPreconditions() return r.interactor.FacilityUsecase.RetrieveFacility(ctx, &id, active) } func (r *queryResolver) RetrieveFacilityByMFLCode(ctx context.Context, mflCode string, isActive bool) (*domain.Facility, error) { + r.checkPreconditions() return r.interactor.FacilityUsecase.RetrieveFacilityByMFLCode(ctx, mflCode, isActive) } +// Mutation returns generated.MutationResolver implementation. +func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } + // Query returns generated.QueryResolver implementation. func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } +type mutationResolver struct{ *Resolver } type queryResolver struct{ *Resolver } diff --git a/pkg/onboarding/presentation/graph/generated/generated.go b/pkg/onboarding/presentation/graph/generated/generated.go index c2c7495f..d1db8281 100644 --- a/pkg/onboarding/presentation/graph/generated/generated.go +++ b/pkg/onboarding/presentation/graph/generated/generated.go @@ -10,7 +10,6 @@ import ( "strconv" "sync" "sync/atomic" - "time" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" @@ -19,7 +18,6 @@ import ( "github.com/savannahghi/feedlib" "github.com/savannahghi/firebasetools" dto1 "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" domain1 "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" "github.com/savannahghi/onboarding/pkg/onboarding/application/dto" "github.com/savannahghi/onboarding/pkg/onboarding/domain" @@ -67,16 +65,6 @@ 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 @@ -84,32 +72,6 @@ type ComplexityRoot struct { LastName func(childComplexity int) int } - ClientProfile struct { - Active func(childComplexity int) int - CHVUserID func(childComplexity int) int - ClientCounselled func(childComplexity int) int - ClientType func(childComplexity int) int - FacilityID func(childComplexity int) int - HealthRecordID func(childComplexity int) int - ID func(childComplexity int) int - TreatmentBuddyUserID func(childComplexity int) int - TreatmentEnrollmentDate func(childComplexity int) int - UserID func(childComplexity int) int - } - - ClientUserProfile struct { - Client func(childComplexity int) int - User func(childComplexity int) int - } - - Contact struct { - Active func(childComplexity int) int - Contact func(childComplexity int) int - ID func(childComplexity int) int - OptedIn func(childComplexity int) int - Type func(childComplexity int) int - } - Cover struct { MemberName func(childComplexity int) int MemberNumber func(childComplexity int) int @@ -136,19 +98,6 @@ type ComplexityRoot struct { Secondary func(childComplexity int) int } - Identifier struct { - Active func(childComplexity int) int - ClientID func(childComplexity int) int - Description func(childComplexity int) int - ID func(childComplexity int) int - IdentifierType func(childComplexity int) int - IdentifierUse func(childComplexity int) int - IdentifierValue func(childComplexity int) int - IsPrimaryIdentifier func(childComplexity int) int - ValidFrom func(childComplexity int) int - ValidTo func(childComplexity int) int - } - Link struct { Description func(childComplexity int) int ID func(childComplexity int) int @@ -168,7 +117,6 @@ type ComplexityRoot struct { Mutation struct { ActivateRole func(childComplexity int, roleID string) int AddAddress func(childComplexity int, input dto.UserAddressInput, addressType enumutils.AddressType) int - AddIdentifier func(childComplexity int, clientID string, idType enums.IdentifierType, idValue string, isPrimary bool) int AddPermissionsToRole func(childComplexity int, input dto.RolePermissionInput) int AddSecondaryEmailAddress func(childComplexity int, email []string) int AddSecondaryPhoneNumber func(childComplexity int, phone []string) int @@ -183,12 +131,9 @@ type ComplexityRoot struct { DeleteRole func(childComplexity int, roleID string) int DeregisterAllMicroservices func(childComplexity int) int DeregisterMicroservice func(childComplexity int, id string) int - InviteClient func(childComplexity int, userID string, flavour feedlib.Flavour) int RecordPostVisitSurvey func(childComplexity int, input dto.PostVisitSurveyInput) int - RegisterClientUser func(childComplexity int, userInput dto1.UserInput, clientInput dto1.ClientProfileInput) int RegisterMicroservice func(childComplexity int, input domain.Microservice) int RegisterPushToken func(childComplexity int, token string) int - RegisterStaffUser func(childComplexity int, userInput dto1.UserInput, staffInput dto1.StaffProfileInput) int RetireSecondaryEmailAddresses func(childComplexity int, emails []string) int RetireSecondaryPhoneNumbers func(childComplexity int, phones []string) int RevokeRole func(childComplexity int, userID string, roleID string, reason string) int @@ -197,12 +142,8 @@ 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 SetupAsExperimentParticipant func(childComplexity int, participate *bool) int - TestMutation func(childComplexity int) int - TransferClient func(childComplexity int, clientID string, originFacilityID *string, destinationFacilityID *string, reason enums.TransferReason, notes string) int UpdateRolePermissions func(childComplexity int, input dto.RolePermissionInput) int - UpdateStaffUserProfile func(childComplexity int, userID string, userInput *dto1.UserInput, staffInput *dto1.StaffProfileInput) int UpdateUserName func(childComplexity int, username string) int UpdateUserPin func(childComplexity int, phone string, pin string) int UpdateUserProfile func(childComplexity int, input dto.UserProfileInput) int @@ -248,13 +189,6 @@ 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 @@ -271,7 +205,6 @@ type ComplexityRoot struct { ResumeWithPin func(childComplexity int, pin string) int RetrieveFacility func(childComplexity int, id string, active bool) int RetrieveFacilityByMFLCode func(childComplexity int, mflCode string, isActive bool) int - TestQuery func(childComplexity int) int UserProfile func(childComplexity int) int __resolve__service func(childComplexity int) int __resolve_entities func(childComplexity int, representations []map[string]interface{}) int @@ -287,46 +220,11 @@ type ComplexityRoot struct { Users func(childComplexity int) int } - StaffProfile struct { - Addresses func(childComplexity int) int - DefaultFacilityID func(childComplexity int) int - ID func(childComplexity int) int - Roles func(childComplexity int) int - StaffNumber func(childComplexity int) int - UserID func(childComplexity int) int - } - - StaffUserProfile struct { - Staff func(childComplexity int) int - User func(childComplexity int) int - } - ThinAddress struct { Latitude func(childComplexity int) int Longitude func(childComplexity int) int } - User struct { - AcceptedTermsID func(childComplexity int) int - Active func(childComplexity int) int - Contacts func(childComplexity int) int - DisplayName func(childComplexity int) int - FailedLoginCount func(childComplexity int) int - FirstName func(childComplexity int) int - Flavour func(childComplexity int) int - Gender func(childComplexity int) int - ID func(childComplexity int) int - Languages func(childComplexity int) int - LastFailedLogin func(childComplexity int) int - LastName func(childComplexity int) int - LastSuccessfulLogin func(childComplexity int) int - MiddleName func(childComplexity int) int - NextAllowedLogin func(childComplexity int) int - TermsAccepted func(childComplexity int) int - UserType func(childComplexity int) int - Username func(childComplexity int) int - } - UserAddresses struct { HomeAddress func(childComplexity int) int WorkAddress func(childComplexity int) int @@ -378,16 +276,8 @@ type EntityResolver interface { FindUserProfileByID(ctx context.Context, id string) (*profileutils.UserProfile, error) } type MutationResolver interface { - RegisterClientUser(ctx context.Context, userInput dto1.UserInput, clientInput dto1.ClientProfileInput) (*domain1.ClientUserProfile, error) - AddIdentifier(ctx context.Context, clientID string, idType enums.IdentifierType, idValue string, isPrimary bool) (*domain1.Identifier, error) - InviteClient(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error) - TransferClient(ctx context.Context, clientID string, originFacilityID *string, destinationFacilityID *string, reason enums.TransferReason, notes string) (bool, 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) - TestMutation(ctx context.Context) (*bool, error) - RegisterStaffUser(ctx context.Context, userInput dto1.UserInput, staffInput dto1.StaffProfileInput) (*domain1.StaffUserProfile, error) - UpdateStaffUserProfile(ctx context.Context, userID string, userInput *dto1.UserInput, staffInput *dto1.StaffProfileInput) (bool, error) CompleteSignup(ctx context.Context, flavour feedlib.Flavour) (bool, error) UpdateUserProfile(ctx context.Context, input dto.UserProfileInput) (*profileutils.UserProfile, error) UpdateUserPin(ctx context.Context, phone string, pin string) (bool, error) @@ -423,7 +313,6 @@ type QueryResolver interface { FetchFacilities(ctx context.Context) ([]*domain1.Facility, error) RetrieveFacility(ctx context.Context, id string, active bool) (*domain1.Facility, error) RetrieveFacilityByMFLCode(ctx context.Context, mflCode string, isActive bool) (*domain1.Facility, error) - TestQuery(ctx context.Context) (*bool, error) DummyQuery(ctx context.Context) (*bool, error) UserProfile(ctx context.Context) (*profileutils.UserProfile, error) ResumeWithPin(ctx context.Context, pin string) (bool, error) @@ -502,55 +391,6 @@ 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 @@ -579,125 +419,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.BioData.LastName(childComplexity), true - case "ClientProfile.active": - if e.complexity.ClientProfile.Active == nil { - break - } - - return e.complexity.ClientProfile.Active(childComplexity), true - - case "ClientProfile.chvUserID": - if e.complexity.ClientProfile.CHVUserID == nil { - break - } - - return e.complexity.ClientProfile.CHVUserID(childComplexity), true - - case "ClientProfile.clientCounselled": - if e.complexity.ClientProfile.ClientCounselled == nil { - break - } - - return e.complexity.ClientProfile.ClientCounselled(childComplexity), true - - case "ClientProfile.clientType": - if e.complexity.ClientProfile.ClientType == nil { - break - } - - return e.complexity.ClientProfile.ClientType(childComplexity), true - - case "ClientProfile.facilityID": - if e.complexity.ClientProfile.FacilityID == nil { - break - } - - return e.complexity.ClientProfile.FacilityID(childComplexity), true - - case "ClientProfile.healthRecordID": - if e.complexity.ClientProfile.HealthRecordID == nil { - break - } - - return e.complexity.ClientProfile.HealthRecordID(childComplexity), true - - case "ClientProfile.id": - if e.complexity.ClientProfile.ID == nil { - break - } - - return e.complexity.ClientProfile.ID(childComplexity), true - - case "ClientProfile.treatmentBuddyUserID": - if e.complexity.ClientProfile.TreatmentBuddyUserID == nil { - break - } - - return e.complexity.ClientProfile.TreatmentBuddyUserID(childComplexity), true - - case "ClientProfile.treatmentEnrollmentDate": - if e.complexity.ClientProfile.TreatmentEnrollmentDate == nil { - break - } - - return e.complexity.ClientProfile.TreatmentEnrollmentDate(childComplexity), true - - case "ClientProfile.userID": - if e.complexity.ClientProfile.UserID == nil { - break - } - - return e.complexity.ClientProfile.UserID(childComplexity), true - - case "ClientUserProfile.client": - if e.complexity.ClientUserProfile.Client == nil { - break - } - - return e.complexity.ClientUserProfile.Client(childComplexity), true - - case "ClientUserProfile.user": - if e.complexity.ClientUserProfile.User == nil { - break - } - - return e.complexity.ClientUserProfile.User(childComplexity), true - - case "Contact.Active": - if e.complexity.Contact.Active == nil { - break - } - - return e.complexity.Contact.Active(childComplexity), true - - case "Contact.Contact": - if e.complexity.Contact.Contact == nil { - break - } - - return e.complexity.Contact.Contact(childComplexity), true - - case "Contact.ID": - if e.complexity.Contact.ID == nil { - break - } - - return e.complexity.Contact.ID(childComplexity), true - - case "Contact.OptedIn": - if e.complexity.Contact.OptedIn == nil { - break - } - - return e.complexity.Contact.OptedIn(childComplexity), true - - case "Contact.Type": - if e.complexity.Contact.Type == nil { - break - } - - return e.complexity.Contact.Type(childComplexity), true - case "Cover.memberName": if e.complexity.Cover.MemberName == nil { break @@ -806,76 +527,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.GroupedNavigationActions.Secondary(childComplexity), true - case "Identifier.active": - if e.complexity.Identifier.Active == nil { - break - } - - return e.complexity.Identifier.Active(childComplexity), true - - case "Identifier.clientID": - if e.complexity.Identifier.ClientID == nil { - break - } - - return e.complexity.Identifier.ClientID(childComplexity), true - - case "Identifier.description": - if e.complexity.Identifier.Description == nil { - break - } - - return e.complexity.Identifier.Description(childComplexity), true - - case "Identifier.id": - if e.complexity.Identifier.ID == nil { - break - } - - return e.complexity.Identifier.ID(childComplexity), true - - case "Identifier.identifierType": - if e.complexity.Identifier.IdentifierType == nil { - break - } - - return e.complexity.Identifier.IdentifierType(childComplexity), true - - case "Identifier.identifierUse": - if e.complexity.Identifier.IdentifierUse == nil { - break - } - - return e.complexity.Identifier.IdentifierUse(childComplexity), true - - case "Identifier.identifierValue": - if e.complexity.Identifier.IdentifierValue == nil { - break - } - - return e.complexity.Identifier.IdentifierValue(childComplexity), true - - case "Identifier.isPrimaryIdentifier": - if e.complexity.Identifier.IsPrimaryIdentifier == nil { - break - } - - return e.complexity.Identifier.IsPrimaryIdentifier(childComplexity), true - - case "Identifier.validFrom": - if e.complexity.Identifier.ValidFrom == nil { - break - } - - return e.complexity.Identifier.ValidFrom(childComplexity), true - - case "Identifier.validTo": - if e.complexity.Identifier.ValidTo == nil { - break - } - - return e.complexity.Identifier.ValidTo(childComplexity), true - case "Link.Description": if e.complexity.Link.Description == nil { break @@ -970,18 +621,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.AddAddress(childComplexity, args["input"].(dto.UserAddressInput), args["addressType"].(enumutils.AddressType)), true - case "Mutation.addIdentifier": - if e.complexity.Mutation.AddIdentifier == nil { - break - } - - args, err := ec.field_Mutation_addIdentifier_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.AddIdentifier(childComplexity, args["clientID"].(string), args["idType"].(enums.IdentifierType), args["idValue"].(string), args["isPrimary"].(bool)), true - case "Mutation.addPermissionsToRole": if e.complexity.Mutation.AddPermissionsToRole == nil { break @@ -1145,18 +784,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.DeregisterMicroservice(childComplexity, args["id"].(string)), true - case "Mutation.inviteClient": - if e.complexity.Mutation.InviteClient == nil { - break - } - - args, err := ec.field_Mutation_inviteClient_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.InviteClient(childComplexity, args["userID"].(string), args["flavour"].(feedlib.Flavour)), true - case "Mutation.recordPostVisitSurvey": if e.complexity.Mutation.RecordPostVisitSurvey == nil { break @@ -1169,18 +796,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.RecordPostVisitSurvey(childComplexity, args["input"].(dto.PostVisitSurveyInput)), true - case "Mutation.registerClientUser": - if e.complexity.Mutation.RegisterClientUser == nil { - break - } - - args, err := ec.field_Mutation_registerClientUser_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.RegisterClientUser(childComplexity, args["userInput"].(dto1.UserInput), args["clientInput"].(dto1.ClientProfileInput)), true - case "Mutation.registerMicroservice": if e.complexity.Mutation.RegisterMicroservice == nil { break @@ -1205,18 +820,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.RegisterPushToken(childComplexity, args["token"].(string)), true - case "Mutation.registerStaffUser": - if e.complexity.Mutation.RegisterStaffUser == nil { - break - } - - args, err := ec.field_Mutation_registerStaffUser_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.RegisterStaffUser(childComplexity, args["userInput"].(dto1.UserInput), args["staffInput"].(dto1.StaffProfileInput)), true - case "Mutation.retireSecondaryEmailAddresses": if e.complexity.Mutation.RetireSecondaryEmailAddresses == nil { break @@ -1313,18 +916,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.SetUserCommunicationsSettings(childComplexity, args["allowWhatsApp"].(*bool), args["allowTextSMS"].(*bool), args["allowPush"].(*bool), args["allowEmail"].(*bool)), true - case "Mutation.setUserPIN": - if e.complexity.Mutation.SetUserPin == nil { - break - } - - args, err := ec.field_Mutation_setUserPIN_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.SetUserPin(childComplexity, args["input"].(*dto1.PinInput)), true - case "Mutation.setupAsExperimentParticipant": if e.complexity.Mutation.SetupAsExperimentParticipant == nil { break @@ -1337,25 +928,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.SetupAsExperimentParticipant(childComplexity, args["participate"].(*bool)), true - case "Mutation.testMutation": - if e.complexity.Mutation.TestMutation == nil { - break - } - - return e.complexity.Mutation.TestMutation(childComplexity), true - - case "Mutation.transferClient": - if e.complexity.Mutation.TransferClient == nil { - break - } - - args, err := ec.field_Mutation_transferClient_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.TransferClient(childComplexity, args["clientID"].(string), args["OriginFacilityID"].(*string), args["destinationFacilityID"].(*string), args["Reason"].(enums.TransferReason), args["Notes"].(string)), true - case "Mutation.updateRolePermissions": if e.complexity.Mutation.UpdateRolePermissions == nil { break @@ -1368,18 +940,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.UpdateRolePermissions(childComplexity, args["input"].(dto.RolePermissionInput)), true - case "Mutation.updateStaffUserProfile": - if e.complexity.Mutation.UpdateStaffUserProfile == nil { - break - } - - args, err := ec.field_Mutation_updateStaffUserProfile_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.UpdateStaffUserProfile(childComplexity, args["userID"].(string), args["userInput"].(*dto1.UserInput), args["staffInput"].(*dto1.StaffProfileInput)), true - case "Mutation.updateUserName": if e.complexity.Mutation.UpdateUserName == nil { break @@ -1570,34 +1130,6 @@ 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 @@ -1733,13 +1265,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.RetrieveFacilityByMFLCode(childComplexity, args["mflCode"].(string), args["isActive"].(bool)), true - case "Query.testQuery": - if e.complexity.Query.TestQuery == nil { - break - } - - return e.complexity.Query.TestQuery(childComplexity), true - case "Query.userProfile": if e.complexity.Query.UserProfile == nil { break @@ -1815,236 +1340,54 @@ 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 { + case "ThinAddress.latitude": + if e.complexity.ThinAddress.Latitude == nil { break } - return e.complexity.StaffProfile.Addresses(childComplexity), true + return e.complexity.ThinAddress.Latitude(childComplexity), true - case "StaffProfile.defaultFacilityID": - if e.complexity.StaffProfile.DefaultFacilityID == nil { + case "ThinAddress.longitude": + if e.complexity.ThinAddress.Longitude == nil { break } - return e.complexity.StaffProfile.DefaultFacilityID(childComplexity), true + return e.complexity.ThinAddress.Longitude(childComplexity), true - case "StaffProfile.id": - if e.complexity.StaffProfile.ID == nil { + case "UserAddresses.homeAddress": + if e.complexity.UserAddresses.HomeAddress == nil { break } - return e.complexity.StaffProfile.ID(childComplexity), true + return e.complexity.UserAddresses.HomeAddress(childComplexity), true - case "StaffProfile.roles": - if e.complexity.StaffProfile.Roles == nil { + case "UserAddresses.workAddress": + if e.complexity.UserAddresses.WorkAddress == nil { break } - return e.complexity.StaffProfile.Roles(childComplexity), true + return e.complexity.UserAddresses.WorkAddress(childComplexity), true - case "StaffProfile.staffNumber": - if e.complexity.StaffProfile.StaffNumber == nil { + case "UserCommunicationsSetting.allowEmail": + if e.complexity.UserCommunicationsSetting.AllowEmail == nil { break } - return e.complexity.StaffProfile.StaffNumber(childComplexity), true + return e.complexity.UserCommunicationsSetting.AllowEmail(childComplexity), true - case "StaffProfile.userID": - if e.complexity.StaffProfile.UserID == nil { + case "UserCommunicationsSetting.allowPush": + if e.complexity.UserCommunicationsSetting.AllowPush == nil { break } - return e.complexity.StaffProfile.UserID(childComplexity), true + return e.complexity.UserCommunicationsSetting.AllowPush(childComplexity), true - case "StaffUserProfile.staff": - if e.complexity.StaffUserProfile.Staff == nil { + case "UserCommunicationsSetting.allowTextSMS": + if e.complexity.UserCommunicationsSetting.AllowTextSMS == nil { break } - return e.complexity.StaffUserProfile.Staff(childComplexity), true - - case "StaffUserProfile.user": - if e.complexity.StaffUserProfile.User == nil { - break - } - - return e.complexity.StaffUserProfile.User(childComplexity), true - - case "ThinAddress.latitude": - if e.complexity.ThinAddress.Latitude == nil { - break - } - - return e.complexity.ThinAddress.Latitude(childComplexity), true - - case "ThinAddress.longitude": - if e.complexity.ThinAddress.Longitude == nil { - break - } - - return e.complexity.ThinAddress.Longitude(childComplexity), true - - case "User.acceptedTermsID": - if e.complexity.User.AcceptedTermsID == nil { - break - } - - return e.complexity.User.AcceptedTermsID(childComplexity), true - - case "User.active": - if e.complexity.User.Active == nil { - break - } - - return e.complexity.User.Active(childComplexity), true - - case "User.contacts": - if e.complexity.User.Contacts == nil { - break - } - - return e.complexity.User.Contacts(childComplexity), true - - case "User.displayName": - if e.complexity.User.DisplayName == nil { - break - } - - return e.complexity.User.DisplayName(childComplexity), true - - case "User.failedLoginCount": - if e.complexity.User.FailedLoginCount == nil { - break - } - - return e.complexity.User.FailedLoginCount(childComplexity), true - - case "User.firstName": - if e.complexity.User.FirstName == nil { - break - } - - return e.complexity.User.FirstName(childComplexity), true - - case "User.flavour": - if e.complexity.User.Flavour == nil { - break - } - - return e.complexity.User.Flavour(childComplexity), true - - case "User.gender": - if e.complexity.User.Gender == nil { - break - } - - return e.complexity.User.Gender(childComplexity), true - - case "User.id": - if e.complexity.User.ID == nil { - break - } - - return e.complexity.User.ID(childComplexity), true - - case "User.languages": - if e.complexity.User.Languages == nil { - break - } - - return e.complexity.User.Languages(childComplexity), true - - case "User.lastFailedLogin": - if e.complexity.User.LastFailedLogin == nil { - break - } - - return e.complexity.User.LastFailedLogin(childComplexity), true - - case "User.lastName": - if e.complexity.User.LastName == nil { - break - } - - return e.complexity.User.LastName(childComplexity), true - - case "User.lastSuccessfulLogin": - if e.complexity.User.LastSuccessfulLogin == nil { - break - } - - return e.complexity.User.LastSuccessfulLogin(childComplexity), true - - case "User.middleName": - if e.complexity.User.MiddleName == nil { - break - } - - return e.complexity.User.MiddleName(childComplexity), true - - case "User.nextAllowedLogin": - if e.complexity.User.NextAllowedLogin == nil { - break - } - - return e.complexity.User.NextAllowedLogin(childComplexity), true - - case "User.termsAccepted": - if e.complexity.User.TermsAccepted == nil { - break - } - - return e.complexity.User.TermsAccepted(childComplexity), true - - case "User.userType": - if e.complexity.User.UserType == nil { - break - } - - return e.complexity.User.UserType(childComplexity), true - - case "User.username": - if e.complexity.User.Username == nil { - break - } - - return e.complexity.User.Username(childComplexity), true - - case "UserAddresses.homeAddress": - if e.complexity.UserAddresses.HomeAddress == nil { - break - } - - return e.complexity.UserAddresses.HomeAddress(childComplexity), true - - case "UserAddresses.workAddress": - if e.complexity.UserAddresses.WorkAddress == nil { - break - } - - return e.complexity.UserAddresses.WorkAddress(childComplexity), true - - case "UserCommunicationsSetting.allowEmail": - if e.complexity.UserCommunicationsSetting.AllowEmail == nil { - break - } - - return e.complexity.UserCommunicationsSetting.AllowEmail(childComplexity), true - - case "UserCommunicationsSetting.allowPush": - if e.complexity.UserCommunicationsSetting.AllowPush == nil { - break - } - - return e.complexity.UserCommunicationsSetting.AllowPush(childComplexity), true - - case "UserCommunicationsSetting.allowTextSMS": - if e.complexity.UserCommunicationsSetting.AllowTextSMS == nil { - break - } - - return e.complexity.UserCommunicationsSetting.AllowTextSMS(childComplexity), true + return e.complexity.UserCommunicationsSetting.AllowTextSMS(childComplexity), true case "UserCommunicationsSetting.allowWhatsApp": if e.complexity.UserCommunicationsSetting.AllowWhatsApp == nil { @@ -2285,30 +1628,6 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var sources = []*ast.Source{ - {Name: "pkg/onboarding/presentation/graph/client.graphql", Input: `extend type Mutation { - registerClientUser( - userInput: UserInput! - clientInput: ClientProfileInput! - ): ClientUserProfile! - - addIdentifier( - clientID: String! - idType: IdentifierType! - idValue: String! - isPrimary: Boolean! - ): Identifier! - - inviteClient(userID: String!, flavour: Flavour!): Boolean! - transferClient( - clientID: String! - OriginFacilityID: String - destinationFacilityID: String - Reason: TransferReason! - Notes: String! - ): Boolean! - -} -`, BuiltIn: false}, {Name: "pkg/onboarding/presentation/graph/enums.graphql", Input: `enum RolesType { CAN_REGISTER_STAFF CAN_INVITE_STAFF @@ -2424,7 +1743,6 @@ enum TransferReason { extend type Mutation { createFacility(input: FacilityInput!): Facility! deleteFacility(id: String!): Boolean! - setUserPIN(input: PinInput): Boolean! } extend type Query { @@ -2440,69 +1758,7 @@ extend type Query { description: String! } -input PinInput { - Pin: String! - confirmedPin: String! - flavour: Flavour! -} - - -input UserInput { - username: String! - displayName: String! - firstName: String! - middleName: String! - lastName: String! - userType: UsersType! - gender: Gender! - contacts: [ContactInput!]! - languages: [Language!]! - flavour: Flavour! -} - -input StaffProfileInput { - staffNumber: String! - # facilities: [FacilityInput!] - defaultFacilityID: String! - addresses: [AddressesInput!]! - roles: [RolesType] # TODO: roles are an enum (controlled list), known to both FE and BE -} - -input ContactInput { - Type: ContactType! - Contact: String! #TODO Validate: phones are E164, emails are valid - 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! -} - - -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 -} - -extend type Mutation { - testMutation: Boolean -} `, BuiltIn: false}, - {Name: "pkg/onboarding/presentation/graph/staff.graphql", Input: `extend type Mutation { - registerStaffUser(userInput: UserInput!, staffInput: StaffProfileInput!) :StaffUserProfile - updateStaffUserProfile(userID: String!, userInput: UserInput, staffInput: StaffProfileInput): Boolean! -}`, BuiltIn: false}, {Name: "pkg/onboarding/presentation/graph/types.graphql", Input: `type Facility { ID: String! name: String! @@ -2510,103 +1766,7 @@ extend type Mutation { active: Boolean! county: String! description: String! -} - -type Pin { - userID: String! - Pin: String! - confirmedPin: String! - flavour: Flavour! -} - -type User { - id: String! - username: String - displayName: String - middleName: String - firstName: String - lastName: String - gender: Gender - userType: UsersType - active: Boolean - contacts: [Contact!]! - languages: [Language] - # pushTokens: [String!] - lastSuccessfulLogin: Time - lastFailedLogin: Time - failedLoginCount: String! - nextAllowedLogin: Time - termsAccepted: Boolean - acceptedTermsID: String - flavour: Flavour! -} - -type Contact { - ID: String! - Type: ContactType! - Contact: String! #TODO Validate: phones are E164, emails are valid - 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! -} - -type StaffProfile { - id: String! - userID: String! - staffNumber: String! - # facilities: [Facility!] - defaultFacilityID: String! - addresses: [Addresses!] - roles: [RolesType!] -} - -type StaffUserProfile { - user: User! - staff: StaffProfile! -} - -type ClientProfile { - id: String! - userID: String! - clientType: ClientType - active: Boolean - treatmentEnrollmentDate: Time - healthRecordID: String - facilityID: String - treatmentBuddyUserID: String - chvUserID: String - clientCounselled: Boolean -} - -type ClientUserProfile { - user: User! - client: ClientProfile! -} - -type Identifier { - id: String! - clientID: String! - identifierType: IdentifierType! - identifierUse: IdentifierUse! - identifierValue: String! - description: String - 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}, +}`, BuiltIn: false}, {Name: "federation/directives.graphql", Input: ` scalar _Any scalar _FieldSet @@ -3171,48 +2331,6 @@ func (ec *executionContext) field_Mutation_addAddress_args(ctx context.Context, return args, nil } -func (ec *executionContext) field_Mutation_addIdentifier_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["clientID"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clientID")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["clientID"] = arg0 - var arg1 enums.IdentifierType - if tmp, ok := rawArgs["idType"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idType")) - arg1, err = ec.unmarshalNIdentifierType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐIdentifierType(ctx, tmp) - if err != nil { - return nil, err - } - } - args["idType"] = arg1 - var arg2 string - if tmp, ok := rawArgs["idValue"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idValue")) - arg2, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["idValue"] = arg2 - var arg3 bool - if tmp, ok := rawArgs["isPrimary"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("isPrimary")) - arg3, err = ec.unmarshalNBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["isPrimary"] = arg3 - return args, nil -} - func (ec *executionContext) field_Mutation_addPermissionsToRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -3426,30 +2544,6 @@ func (ec *executionContext) field_Mutation_deregisterMicroservice_args(ctx conte return args, nil } -func (ec *executionContext) field_Mutation_inviteClient_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["userID"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["userID"] = arg0 - var arg1 feedlib.Flavour - if tmp, ok := rawArgs["flavour"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("flavour")) - arg1, err = ec.unmarshalNFlavour2githubᚗcomᚋsavannahghiᚋfeedlibᚐFlavour(ctx, tmp) - if err != nil { - return nil, err - } - } - args["flavour"] = arg1 - return args, nil -} - func (ec *executionContext) field_Mutation_recordPostVisitSurvey_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -3465,30 +2559,6 @@ func (ec *executionContext) field_Mutation_recordPostVisitSurvey_args(ctx contex return args, nil } -func (ec *executionContext) field_Mutation_registerClientUser_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 dto1.UserInput - if tmp, ok := rawArgs["userInput"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userInput")) - arg0, err = ec.unmarshalNUserInput2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐUserInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["userInput"] = arg0 - var arg1 dto1.ClientProfileInput - if tmp, ok := rawArgs["clientInput"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clientInput")) - arg1, err = ec.unmarshalNClientProfileInput2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐClientProfileInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["clientInput"] = arg1 - return args, nil -} - func (ec *executionContext) field_Mutation_registerMicroservice_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -3519,30 +2589,6 @@ func (ec *executionContext) field_Mutation_registerPushToken_args(ctx context.Co return args, nil } -func (ec *executionContext) field_Mutation_registerStaffUser_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 dto1.UserInput - if tmp, ok := rawArgs["userInput"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userInput")) - arg0, err = ec.unmarshalNUserInput2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐUserInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["userInput"] = arg0 - var arg1 dto1.StaffProfileInput - if tmp, ok := rawArgs["staffInput"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("staffInput")) - arg1, err = ec.unmarshalNStaffProfileInput2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐStaffProfileInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["staffInput"] = arg1 - return args, nil -} - func (ec *executionContext) field_Mutation_retireSecondaryEmailAddresses_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -3726,28 +2772,13 @@ func (ec *executionContext) field_Mutation_setUserCommunicationsSettings_args(ct return args, nil } -func (ec *executionContext) field_Mutation_setUserPIN_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_setupAsExperimentParticipant_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - 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) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_setupAsExperimentParticipant_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *bool - if tmp, ok := rawArgs["participate"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("participate")) - arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) + var arg0 *bool + if tmp, ok := rawArgs["participate"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("participate")) + arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) if err != nil { return nil, err } @@ -3756,57 +2787,6 @@ func (ec *executionContext) field_Mutation_setupAsExperimentParticipant_args(ctx return args, nil } -func (ec *executionContext) field_Mutation_transferClient_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["clientID"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clientID")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["clientID"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["OriginFacilityID"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("OriginFacilityID")) - arg1, err = ec.unmarshalOString2ᚖstring(ctx, tmp) - if err != nil { - return nil, err - } - } - args["OriginFacilityID"] = arg1 - var arg2 *string - if tmp, ok := rawArgs["destinationFacilityID"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("destinationFacilityID")) - arg2, err = ec.unmarshalOString2ᚖstring(ctx, tmp) - if err != nil { - return nil, err - } - } - args["destinationFacilityID"] = arg2 - var arg3 enums.TransferReason - if tmp, ok := rawArgs["Reason"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Reason")) - arg3, err = ec.unmarshalNTransferReason2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐTransferReason(ctx, tmp) - if err != nil { - return nil, err - } - } - args["Reason"] = arg3 - var arg4 string - if tmp, ok := rawArgs["Notes"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Notes")) - arg4, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["Notes"] = arg4 - return args, nil -} - func (ec *executionContext) field_Mutation_updateRolePermissions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -3822,39 +2802,6 @@ func (ec *executionContext) field_Mutation_updateRolePermissions_args(ctx contex return args, nil } -func (ec *executionContext) field_Mutation_updateStaffUserProfile_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["userID"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["userID"] = arg0 - var arg1 *dto1.UserInput - if tmp, ok := rawArgs["userInput"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userInput")) - arg1, err = ec.unmarshalOUserInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐUserInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["userInput"] = arg1 - var arg2 *dto1.StaffProfileInput - if tmp, ok := rawArgs["staffInput"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("staffInput")) - arg2, err = ec.unmarshalOStaffProfileInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐStaffProfileInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["staffInput"] = arg2 - return args, nil -} - func (ec *executionContext) field_Mutation_updateUserName_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -4283,7 +3230,7 @@ func (ec *executionContext) _Address_formattedAddress(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Addresses_ID(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (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)) @@ -4291,7 +3238,7 @@ func (ec *executionContext) _Addresses_ID(ctx context.Context, field graphql.Col } }() fc := &graphql.FieldContext{ - Object: "Addresses", + Object: "BioData", Field: field, Args: nil, IsMethod: false, @@ -4301,24 +3248,21 @@ func (ec *executionContext) _Addresses_ID(ctx context.Context, field graphql.Col 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.FirstName, 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) _Addresses_Type(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (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)) @@ -4326,7 +3270,7 @@ func (ec *executionContext) _Addresses_Type(ctx context.Context, field graphql.C } }() fc := &graphql.FieldContext{ - Object: "Addresses", + Object: "BioData", Field: field, Args: nil, IsMethod: false, @@ -4336,24 +3280,21 @@ func (ec *executionContext) _Addresses_Type(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.Type, nil + return obj.LastName, 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.AddressesType) + res := resTmp.(*string) fc.Result = res - return ec.marshalNAddressesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐAddressesType(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Addresses_Text(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (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)) @@ -4361,7 +3302,7 @@ func (ec *executionContext) _Addresses_Text(ctx context.Context, field graphql.C } }() fc := &graphql.FieldContext{ - Object: "Addresses", + Object: "BioData", Field: field, Args: nil, IsMethod: false, @@ -4371,24 +3312,21 @@ func (ec *executionContext) _Addresses_Text(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.Text, nil + return obj.DateOfBirth, 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.(*scalarutils.Date) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalODate2ᚖgithubᚗcomᚋsavannahghiᚋscalarutilsᚐDate(ctx, field.Selections, res) } -func (ec *executionContext) _Addresses_Country(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (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)) @@ -4396,7 +3334,7 @@ func (ec *executionContext) _Addresses_Country(ctx context.Context, field graphq } }() fc := &graphql.FieldContext{ - Object: "Addresses", + Object: "BioData", Field: field, Args: nil, IsMethod: false, @@ -4406,24 +3344,21 @@ func (ec *executionContext) _Addresses_Country(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.Country, nil + return obj.Gender, 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.CountryType) + res := resTmp.(enumutils.Gender) fc.Result = res - return ec.marshalNCountryType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐCountryType(ctx, field.Selections, res) + return ec.marshalOGender2githubᚗcomᚋsavannahghiᚋenumutilsᚐGender(ctx, field.Selections, res) } -func (ec *executionContext) _Addresses_PostalCode(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (ret graphql.Marshaler) { +func (ec *executionContext) _Cover_payerName(ctx context.Context, field graphql.CollectedField, obj *profileutils.Cover) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4431,7 +3366,7 @@ func (ec *executionContext) _Addresses_PostalCode(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "Addresses", + Object: "Cover", Field: field, Args: nil, IsMethod: false, @@ -4441,7 +3376,7 @@ func (ec *executionContext) _Addresses_PostalCode(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.PostalCode, nil + return obj.PayerName, nil }) if err != nil { ec.Error(ctx, err) @@ -4458,7 +3393,7 @@ func (ec *executionContext) _Addresses_PostalCode(ctx context.Context, field gra return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Addresses_County(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (ret graphql.Marshaler) { +func (ec *executionContext) _Cover_payerSladeCode(ctx context.Context, field graphql.CollectedField, obj *profileutils.Cover) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4466,7 +3401,7 @@ func (ec *executionContext) _Addresses_County(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "Addresses", + Object: "Cover", Field: field, Args: nil, IsMethod: false, @@ -4476,7 +3411,7 @@ func (ec *executionContext) _Addresses_County(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.County, nil + return obj.PayerSladeCode, nil }) if err != nil { ec.Error(ctx, err) @@ -4488,12 +3423,12 @@ func (ec *executionContext) _Addresses_County(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(enums.CountyType) + res := resTmp.(int) fc.Result = res - return ec.marshalNCountyType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐCountyType(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _Addresses_Active(ctx context.Context, field graphql.CollectedField, obj *domain1.Addresses) (ret graphql.Marshaler) { +func (ec *executionContext) _Cover_memberNumber(ctx context.Context, field graphql.CollectedField, obj *profileutils.Cover) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4501,7 +3436,7 @@ func (ec *executionContext) _Addresses_Active(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "Addresses", + Object: "Cover", Field: field, Args: nil, IsMethod: false, @@ -4511,7 +3446,7 @@ func (ec *executionContext) _Addresses_Active(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.Active, nil + return obj.MemberNumber, nil }) if err != nil { ec.Error(ctx, err) @@ -4523,12 +3458,12 @@ func (ec *executionContext) _Addresses_Active(ctx context.Context, field graphql } 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) _BioData_firstName(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { +func (ec *executionContext) _Cover_memberName(ctx context.Context, field graphql.CollectedField, obj *profileutils.Cover) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4536,7 +3471,7 @@ func (ec *executionContext) _BioData_firstName(ctx context.Context, field graphq } }() fc := &graphql.FieldContext{ - Object: "BioData", + Object: "Cover", Field: field, Args: nil, IsMethod: false, @@ -4546,21 +3481,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.MemberName, 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) _Entity_findPageInfoByHasNextPage(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4568,31 +3506,41 @@ func (ec *executionContext) _BioData_lastName(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "BioData", + Object: "Entity", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Entity_findPageInfoByHasNextPage_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Entity().FindPageInfoByHasNextPage(rctx, args["hasNextPage"].(bool)) }) 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.(*firebasetools.PageInfo) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋsavannahghiᚋfirebasetoolsᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) _BioData_dateOfBirth(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { +func (ec *executionContext) _Entity_findUserProfileByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4600,31 +3548,41 @@ func (ec *executionContext) _BioData_dateOfBirth(ctx context.Context, field grap } }() fc := &graphql.FieldContext{ - Object: "BioData", + Object: "Entity", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Entity_findUserProfileByID_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Entity().FindUserProfileByID(rctx, args["id"].(string)) }) 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.(*profileutils.UserProfile) fc.Result = res - return ec.marshalODate2ᚖgithubᚗcomᚋsavannahghiᚋscalarutilsᚐDate(ctx, field.Selections, res) + return ec.marshalNUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) } -func (ec *executionContext) _BioData_gender(ctx context.Context, field graphql.CollectedField, obj *profileutils.BioData) (ret graphql.Marshaler) { +func (ec *executionContext) _Facility_ID(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4632,7 +3590,7 @@ func (ec *executionContext) _BioData_gender(ctx context.Context, field graphql.C } }() fc := &graphql.FieldContext{ - Object: "BioData", + Object: "Facility", Field: field, Args: nil, IsMethod: false, @@ -4642,21 +3600,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.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.(enumutils.Gender) + res := resTmp.(*string) fc.Result = res - return ec.marshalOGender2githubᚗcomᚋsavannahghiᚋenumutilsᚐGender(ctx, field.Selections, res) + return ec.marshalNString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_id(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Facility_name(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4664,7 +3625,7 @@ func (ec *executionContext) _ClientProfile_id(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Facility", Field: field, Args: nil, IsMethod: false, @@ -4674,7 +3635,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.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -4686,12 +3647,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) _Facility_code(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4699,7 +3660,7 @@ func (ec *executionContext) _ClientProfile_userID(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Facility", Field: field, Args: nil, IsMethod: false, @@ -4709,7 +3670,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.Code, nil }) if err != nil { ec.Error(ctx, err) @@ -4721,12 +3682,12 @@ func (ec *executionContext) _ClientProfile_userID(ctx context.Context, field gra } 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_clientType(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Facility_active(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4734,7 +3695,7 @@ func (ec *executionContext) _ClientProfile_clientType(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Facility", Field: field, Args: nil, IsMethod: false, @@ -4744,21 +3705,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) _Facility_county(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4766,7 +3730,7 @@ func (ec *executionContext) _ClientProfile_active(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Facility", Field: field, Args: nil, IsMethod: false, @@ -4776,21 +3740,24 @@ 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.County, 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.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalOBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_treatmentEnrollmentDate(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Facility_description(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4798,7 +3765,7 @@ func (ec *executionContext) _ClientProfile_treatmentEnrollmentDate(ctx context.C } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Facility", Field: field, Args: nil, IsMethod: false, @@ -4808,21 +3775,24 @@ 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.Description, 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.(*time.Time) + res := resTmp.(string) fc.Result = res - return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_healthRecordID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _GroupedNavigationActions_primary(ctx context.Context, field graphql.CollectedField, obj *dto.GroupedNavigationActions) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4830,7 +3800,7 @@ func (ec *executionContext) _ClientProfile_healthRecordID(ctx context.Context, f } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "GroupedNavigationActions", Field: field, Args: nil, IsMethod: false, @@ -4840,7 +3810,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.Primary, nil }) if err != nil { ec.Error(ctx, err) @@ -4849,12 +3819,12 @@ func (ec *executionContext) _ClientProfile_healthRecordID(ctx context.Context, f if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]domain.NavigationAction) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalONavigationAction2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋdomainᚐNavigationAction(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_facilityID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _GroupedNavigationActions_secondary(ctx context.Context, field graphql.CollectedField, obj *dto.GroupedNavigationActions) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4862,7 +3832,7 @@ func (ec *executionContext) _ClientProfile_facilityID(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "GroupedNavigationActions", Field: field, Args: nil, IsMethod: false, @@ -4872,7 +3842,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.Secondary, nil }) if err != nil { ec.Error(ctx, err) @@ -4881,12 +3851,12 @@ func (ec *executionContext) _ClientProfile_facilityID(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.([]domain.NavigationAction) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalONavigationAction2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋdomainᚐNavigationAction(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_treatmentBuddyUserID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_ID(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4894,7 +3864,7 @@ func (ec *executionContext) _ClientProfile_treatmentBuddyUserID(ctx context.Cont } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Link", Field: field, Args: nil, IsMethod: false, @@ -4904,7 +3874,7 @@ 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) @@ -4918,7 +3888,7 @@ func (ec *executionContext) _ClientProfile_treatmentBuddyUserID(ctx context.Cont return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_chvUserID(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_URL(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4926,7 +3896,7 @@ func (ec *executionContext) _ClientProfile_chvUserID(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Link", Field: field, Args: nil, IsMethod: false, @@ -4936,7 +3906,7 @@ 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.URL, nil }) if err != nil { ec.Error(ctx, err) @@ -4950,7 +3920,7 @@ func (ec *executionContext) _ClientProfile_chvUserID(ctx context.Context, field return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _ClientProfile_clientCounselled(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_LinkType(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4958,7 +3928,7 @@ func (ec *executionContext) _ClientProfile_clientCounselled(ctx context.Context, } }() fc := &graphql.FieldContext{ - Object: "ClientProfile", + Object: "Link", Field: field, Args: nil, IsMethod: false, @@ -4968,7 +3938,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.LinkType, nil }) if err != nil { ec.Error(ctx, err) @@ -4977,12 +3947,12 @@ func (ec *executionContext) _ClientProfile_clientCounselled(ctx context.Context, if resTmp == nil { return graphql.Null } - res := resTmp.(bool) + res := resTmp.(feedlib.LinkType) fc.Result = res - return ec.marshalOBoolean2bool(ctx, field.Selections, res) + return ec.marshalOLinkType2githubᚗcomᚋsavannahghiᚋfeedlibᚐLinkType(ctx, field.Selections, res) } -func (ec *executionContext) _ClientUserProfile_user(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientUserProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_Title(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4990,7 +3960,7 @@ func (ec *executionContext) _ClientUserProfile_user(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "ClientUserProfile", + Object: "Link", Field: field, Args: nil, IsMethod: false, @@ -5000,24 +3970,21 @@ 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.Title, 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.(string) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐUser(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _ClientUserProfile_client(ctx context.Context, field graphql.CollectedField, obj *domain1.ClientUserProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_Description(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5025,7 +3992,7 @@ func (ec *executionContext) _ClientUserProfile_client(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "ClientUserProfile", + Object: "Link", Field: field, Args: nil, IsMethod: false, @@ -5035,24 +4002,21 @@ func (ec *executionContext) _ClientUserProfile_client(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.Client, nil + return obj.Description, 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.ClientProfile) + res := resTmp.(string) fc.Result = res - return ec.marshalNClientProfile2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐClientProfile(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Contact_ID(ctx context.Context, field graphql.CollectedField, obj *domain1.Contact) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_Thumbnail(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5060,7 +4024,7 @@ func (ec *executionContext) _Contact_ID(ctx context.Context, field graphql.Colle } }() fc := &graphql.FieldContext{ - Object: "Contact", + Object: "Link", Field: field, Args: nil, IsMethod: false, @@ -5070,24 +4034,21 @@ func (ec *executionContext) _Contact_ID(ctx context.Context, field graphql.Colle 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.Thumbnail, 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.marshalNString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Contact_Type(ctx context.Context, field graphql.CollectedField, obj *domain1.Contact) (ret graphql.Marshaler) { +func (ec *executionContext) _Microservice_id(ctx context.Context, field graphql.CollectedField, obj *domain.Microservice) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5095,7 +4056,7 @@ func (ec *executionContext) _Contact_Type(ctx context.Context, field graphql.Col } }() fc := &graphql.FieldContext{ - Object: "Contact", + Object: "Microservice", Field: field, Args: nil, IsMethod: false, @@ -5105,7 +4066,7 @@ func (ec *executionContext) _Contact_Type(ctx context.Context, field graphql.Col 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.Type, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -5117,12 +4078,12 @@ func (ec *executionContext) _Contact_Type(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(enums.ContactType) + res := resTmp.(string) fc.Result = res - return ec.marshalNContactType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐContactType(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Contact_Contact(ctx context.Context, field graphql.CollectedField, obj *domain1.Contact) (ret graphql.Marshaler) { +func (ec *executionContext) _Microservice_name(ctx context.Context, field graphql.CollectedField, obj *domain.Microservice) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5130,7 +4091,7 @@ func (ec *executionContext) _Contact_Contact(ctx context.Context, field graphql. } }() fc := &graphql.FieldContext{ - Object: "Contact", + Object: "Microservice", Field: field, Args: nil, IsMethod: false, @@ -5140,7 +4101,7 @@ func (ec *executionContext) _Contact_Contact(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.Contact, nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -5157,7 +4118,7 @@ func (ec *executionContext) _Contact_Contact(ctx context.Context, field graphql. return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Contact_Active(ctx context.Context, field graphql.CollectedField, obj *domain1.Contact) (ret graphql.Marshaler) { +func (ec *executionContext) _Microservice_url(ctx context.Context, field graphql.CollectedField, obj *domain.Microservice) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5165,7 +4126,7 @@ func (ec *executionContext) _Contact_Active(ctx context.Context, field graphql.C } }() fc := &graphql.FieldContext{ - Object: "Contact", + Object: "Microservice", Field: field, Args: nil, IsMethod: false, @@ -5175,7 +4136,7 @@ func (ec *executionContext) _Contact_Active(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.Active, nil + return obj.URL, nil }) if err != nil { ec.Error(ctx, err) @@ -5187,12 +4148,12 @@ func (ec *executionContext) _Contact_Active(ctx context.Context, field graphql.C } 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) _Contact_OptedIn(ctx context.Context, field graphql.CollectedField, obj *domain1.Contact) (ret graphql.Marshaler) { +func (ec *executionContext) _Microservice_description(ctx context.Context, field graphql.CollectedField, obj *domain.Microservice) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5200,7 +4161,7 @@ func (ec *executionContext) _Contact_OptedIn(ctx context.Context, field graphql. } }() fc := &graphql.FieldContext{ - Object: "Contact", + Object: "Microservice", Field: field, Args: nil, IsMethod: false, @@ -5210,7 +4171,7 @@ func (ec *executionContext) _Contact_OptedIn(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.OptedIn, nil + return obj.Description, nil }) if err != nil { ec.Error(ctx, err) @@ -5222,12 +4183,12 @@ func (ec *executionContext) _Contact_OptedIn(ctx context.Context, field graphql. } 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) _Cover_payerName(ctx context.Context, field graphql.CollectedField, obj *profileutils.Cover) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_createFacility(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5235,17 +4196,24 @@ func (ec *executionContext) _Cover_payerName(ctx context.Context, field graphql. } }() fc := &graphql.FieldContext{ - Object: "Cover", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_createFacility_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PayerName, nil + return ec.resolvers.Mutation().CreateFacility(rctx, args["input"].(dto1.FacilityInput)) }) if err != nil { ec.Error(ctx, err) @@ -5257,12 +4225,12 @@ func (ec *executionContext) _Cover_payerName(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*domain1.Facility) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNFacility2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐFacility(ctx, field.Selections, res) } -func (ec *executionContext) _Cover_payerSladeCode(ctx context.Context, field graphql.CollectedField, obj *profileutils.Cover) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_deleteFacility(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5270,17 +4238,24 @@ func (ec *executionContext) _Cover_payerSladeCode(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "Cover", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_deleteFacility_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PayerSladeCode, nil + return ec.resolvers.Mutation().DeleteFacility(rctx, args["id"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -5292,12 +4267,12 @@ func (ec *executionContext) _Cover_payerSladeCode(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(int) + res := resTmp.(bool) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Cover_memberNumber(ctx context.Context, field graphql.CollectedField, obj *profileutils.Cover) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_completeSignup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5305,17 +4280,24 @@ func (ec *executionContext) _Cover_memberNumber(ctx context.Context, field graph } }() fc := &graphql.FieldContext{ - Object: "Cover", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_completeSignup_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MemberNumber, nil + return ec.resolvers.Mutation().CompleteSignup(rctx, args["flavour"].(feedlib.Flavour)) }) if err != nil { ec.Error(ctx, err) @@ -5327,12 +4309,12 @@ func (ec *executionContext) _Cover_memberNumber(ctx context.Context, field graph } 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) _Cover_memberName(ctx context.Context, field graphql.CollectedField, obj *profileutils.Cover) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateUserProfile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5340,17 +4322,24 @@ func (ec *executionContext) _Cover_memberName(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "Cover", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_updateUserProfile_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MemberName, nil + return ec.resolvers.Mutation().UpdateUserProfile(rctx, args["input"].(dto.UserProfileInput)) }) if err != nil { ec.Error(ctx, err) @@ -5362,12 +4351,12 @@ func (ec *executionContext) _Cover_memberName(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*profileutils.UserProfile) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) } -func (ec *executionContext) _Entity_findPageInfoByHasNextPage(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateUserPIN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5375,7 +4364,7 @@ func (ec *executionContext) _Entity_findPageInfoByHasNextPage(ctx context.Contex } }() fc := &graphql.FieldContext{ - Object: "Entity", + Object: "Mutation", Field: field, Args: nil, IsMethod: true, @@ -5384,7 +4373,7 @@ func (ec *executionContext) _Entity_findPageInfoByHasNextPage(ctx context.Contex ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Entity_findPageInfoByHasNextPage_args(ctx, rawArgs) + args, err := ec.field_Mutation_updateUserPIN_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -5392,7 +4381,7 @@ func (ec *executionContext) _Entity_findPageInfoByHasNextPage(ctx context.Contex 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.Entity().FindPageInfoByHasNextPage(rctx, args["hasNextPage"].(bool)) + return ec.resolvers.Mutation().UpdateUserPin(rctx, args["phone"].(string), args["pin"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -5404,12 +4393,12 @@ func (ec *executionContext) _Entity_findPageInfoByHasNextPage(ctx context.Contex } return graphql.Null } - res := resTmp.(*firebasetools.PageInfo) + res := resTmp.(bool) fc.Result = res - return ec.marshalNPageInfo2ᚖgithubᚗcomᚋsavannahghiᚋfirebasetoolsᚐPageInfo(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Entity_findUserProfileByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_setPrimaryPhoneNumber(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5417,7 +4406,7 @@ func (ec *executionContext) _Entity_findUserProfileByID(ctx context.Context, fie } }() fc := &graphql.FieldContext{ - Object: "Entity", + Object: "Mutation", Field: field, Args: nil, IsMethod: true, @@ -5426,7 +4415,7 @@ func (ec *executionContext) _Entity_findUserProfileByID(ctx context.Context, fie ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Entity_findUserProfileByID_args(ctx, rawArgs) + args, err := ec.field_Mutation_setPrimaryPhoneNumber_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -5434,7 +4423,7 @@ func (ec *executionContext) _Entity_findUserProfileByID(ctx context.Context, fie 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.Entity().FindUserProfileByID(rctx, args["id"].(string)) + return ec.resolvers.Mutation().SetPrimaryPhoneNumber(rctx, args["phone"].(string), args["otp"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -5446,12 +4435,12 @@ func (ec *executionContext) _Entity_findUserProfileByID(ctx context.Context, fie } return graphql.Null } - res := resTmp.(*profileutils.UserProfile) + res := resTmp.(bool) fc.Result = res - return ec.marshalNUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Facility_ID(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_setPrimaryEmailAddress(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5459,17 +4448,24 @@ func (ec *executionContext) _Facility_ID(ctx context.Context, field graphql.Coll } }() fc := &graphql.FieldContext{ - Object: "Facility", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_setPrimaryEmailAddress_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Mutation().SetPrimaryEmailAddress(rctx, args["email"].(string), args["otp"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -5481,12 +4477,12 @@ func (ec *executionContext) _Facility_ID(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Facility_name(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_addSecondaryPhoneNumber(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5494,17 +4490,24 @@ func (ec *executionContext) _Facility_name(ctx context.Context, field graphql.Co } }() fc := &graphql.FieldContext{ - Object: "Facility", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_addSecondaryPhoneNumber_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Mutation().AddSecondaryPhoneNumber(rctx, args["phone"].([]string)) }) if err != nil { ec.Error(ctx, err) @@ -5516,12 +4519,12 @@ func (ec *executionContext) _Facility_name(ctx context.Context, field graphql.Co } 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) _Facility_code(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_retireSecondaryPhoneNumbers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5529,17 +4532,24 @@ func (ec *executionContext) _Facility_code(ctx context.Context, field graphql.Co } }() fc := &graphql.FieldContext{ - Object: "Facility", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_retireSecondaryPhoneNumbers_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Code, nil + return ec.resolvers.Mutation().RetireSecondaryPhoneNumbers(rctx, args["phones"].([]string)) }) if err != nil { ec.Error(ctx, err) @@ -5551,12 +4561,12 @@ func (ec *executionContext) _Facility_code(ctx context.Context, field graphql.Co } 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) _Facility_active(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_addSecondaryEmailAddress(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5564,17 +4574,24 @@ func (ec *executionContext) _Facility_active(ctx context.Context, field graphql. } }() fc := &graphql.FieldContext{ - Object: "Facility", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_addSecondaryEmailAddress_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Mutation().AddSecondaryEmailAddress(rctx, args["email"].([]string)) }) if err != nil { ec.Error(ctx, err) @@ -5591,7 +4608,7 @@ func (ec *executionContext) _Facility_active(ctx context.Context, field graphql. return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Facility_county(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_retireSecondaryEmailAddresses(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5599,52 +4616,24 @@ func (ec *executionContext) _Facility_county(ctx context.Context, field graphql. } }() fc := &graphql.FieldContext{ - Object: "Facility", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.County, nil - }) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_retireSecondaryEmailAddresses_args(ctx, rawArgs) 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) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _Facility_description(ctx context.Context, field graphql.CollectedField, obj *domain1.Facility) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Facility", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) + fc.Args = args 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 ec.resolvers.Mutation().RetireSecondaryEmailAddresses(rctx, args["emails"].([]string)) }) if err != nil { ec.Error(ctx, err) @@ -5656,44 +4645,12 @@ func (ec *executionContext) _Facility_description(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _GroupedNavigationActions_primary(ctx context.Context, field graphql.CollectedField, obj *dto.GroupedNavigationActions) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "GroupedNavigationActions", - 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.Primary, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]domain.NavigationAction) + res := resTmp.(bool) fc.Result = res - return ec.marshalONavigationAction2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋdomainᚐNavigationAction(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _GroupedNavigationActions_secondary(ctx context.Context, field graphql.CollectedField, obj *dto.GroupedNavigationActions) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateUserName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5701,49 +4658,24 @@ func (ec *executionContext) _GroupedNavigationActions_secondary(ctx context.Cont } }() fc := &graphql.FieldContext{ - Object: "GroupedNavigationActions", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.Secondary, nil - }) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_updateUserName_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]domain.NavigationAction) - fc.Result = res - return ec.marshalONavigationAction2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋdomainᚐNavigationAction(ctx, field.Selections, res) -} - -func (ec *executionContext) _Identifier_id(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Identifier", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) + fc.Args = args 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 ec.resolvers.Mutation().UpdateUserName(rctx, args["username"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -5755,12 +4687,12 @@ func (ec *executionContext) _Identifier_id(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Identifier_clientID(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_registerPushToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5768,52 +4700,24 @@ func (ec *executionContext) _Identifier_clientID(ctx context.Context, field grap } }() fc := &graphql.FieldContext{ - Object: "Identifier", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.ClientID, nil - }) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_registerPushToken_args(ctx, rawArgs) 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) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _Identifier_identifierType(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Identifier", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IdentifierType, nil + return ec.resolvers.Mutation().RegisterPushToken(rctx, args["token"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -5825,12 +4729,12 @@ func (ec *executionContext) _Identifier_identifierType(ctx context.Context, fiel } return graphql.Null } - res := resTmp.(enums.IdentifierType) + res := resTmp.(bool) fc.Result = res - return ec.marshalNIdentifierType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐIdentifierType(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Identifier_identifierUse(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_recordPostVisitSurvey(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5838,52 +4742,24 @@ func (ec *executionContext) _Identifier_identifierUse(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "Identifier", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.IdentifierUse, nil - }) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_recordPostVisitSurvey_args(ctx, rawArgs) 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.IdentifierUse) - fc.Result = res - return ec.marshalNIdentifierUse2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐIdentifierUse(ctx, field.Selections, res) -} - -func (ec *executionContext) _Identifier_identifierValue(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Identifier", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IdentifierValue, nil + return ec.resolvers.Mutation().RecordPostVisitSurvey(rctx, args["input"].(dto.PostVisitSurveyInput)) }) if err != nil { ec.Error(ctx, err) @@ -5895,12 +4771,12 @@ func (ec *executionContext) _Identifier_identifierValue(ctx context.Context, fie } 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) _Identifier_description(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_setupAsExperimentParticipant(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5908,63 +4784,41 @@ func (ec *executionContext) _Identifier_description(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "Identifier", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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 - }) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_setupAsExperimentParticipant_args(ctx, rawArgs) 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) _Identifier_validFrom(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Identifier", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ValidFrom, nil + return ec.resolvers.Mutation().SetupAsExperimentParticipant(rctx, args["participate"].(*bool)) }) 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.(*time.Time) + res := resTmp.(bool) fc.Result = res - return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Identifier_validTo(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_addAddress(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5972,2565 +4826,24 @@ func (ec *executionContext) _Identifier_validTo(ctx context.Context, field graph } }() fc := &graphql.FieldContext{ - Object: "Identifier", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.ValidTo, nil - }) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_addAddress_args(ctx, rawArgs) 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) _Identifier_active(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Identifier", - 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.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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Identifier_isPrimaryIdentifier(ctx context.Context, field graphql.CollectedField, obj *domain1.Identifier) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Identifier", - 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.IsPrimaryIdentifier, 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Link_ID(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Link", - 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.ID, 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) _Link_URL(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Link", - 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.URL, 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) _Link_LinkType(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Link", - 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.LinkType, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(feedlib.LinkType) - fc.Result = res - return ec.marshalOLinkType2githubᚗcomᚋsavannahghiᚋfeedlibᚐLinkType(ctx, field.Selections, res) -} - -func (ec *executionContext) _Link_Title(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Link", - 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.Title, 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) _Link_Description(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Link", - 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.Description, 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) _Link_Thumbnail(ctx context.Context, field graphql.CollectedField, obj *feedlib.Link) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Link", - 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.Thumbnail, 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) _Microservice_id(ctx context.Context, field graphql.CollectedField, obj *domain.Microservice) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Microservice", - 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.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) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _Microservice_name(ctx context.Context, field graphql.CollectedField, obj *domain.Microservice) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Microservice", - 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.Name, 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) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _Microservice_url(ctx context.Context, field graphql.CollectedField, obj *domain.Microservice) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Microservice", - 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.URL, 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) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _Microservice_description(ctx context.Context, field graphql.CollectedField, obj *domain.Microservice) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Microservice", - 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.Description, 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) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_registerClientUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_registerClientUser_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().RegisterClientUser(rctx, args["userInput"].(dto1.UserInput), args["clientInput"].(dto1.ClientProfileInput)) - }) - 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.ClientUserProfile) - fc.Result = res - return ec.marshalNClientUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐClientUserProfile(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_addIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_addIdentifier_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().AddIdentifier(rctx, args["clientID"].(string), args["idType"].(enums.IdentifierType), args["idValue"].(string), args["isPrimary"].(bool)) - }) - 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.Identifier) - fc.Result = res - return ec.marshalNIdentifier2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐIdentifier(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_inviteClient(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_inviteClient_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().InviteClient(rctx, args["userID"].(string), args["flavour"].(feedlib.Flavour)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_transferClient(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_transferClient_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().TransferClient(rctx, args["clientID"].(string), args["OriginFacilityID"].(*string), args["destinationFacilityID"].(*string), args["Reason"].(enums.TransferReason), args["Notes"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_createFacility(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_createFacility_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().CreateFacility(rctx, args["input"].(dto1.FacilityInput)) - }) - 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.Facility) - fc.Result = res - return ec.marshalNFacility2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐFacility(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_deleteFacility(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_deleteFacility_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().DeleteFacility(rctx, args["id"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_setUserPIN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_setUserPIN_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_testMutation(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - 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.Mutation().TestMutation(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*bool) - fc.Result = res - return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_registerStaffUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_registerStaffUser_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().RegisterStaffUser(rctx, args["userInput"].(dto1.UserInput), args["staffInput"].(dto1.StaffProfileInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*domain1.StaffUserProfile) - fc.Result = res - return ec.marshalOStaffUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐStaffUserProfile(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_updateStaffUserProfile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_updateStaffUserProfile_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().UpdateStaffUserProfile(rctx, args["userID"].(string), args["userInput"].(*dto1.UserInput), args["staffInput"].(*dto1.StaffProfileInput)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_completeSignup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_completeSignup_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().CompleteSignup(rctx, args["flavour"].(feedlib.Flavour)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_updateUserProfile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_updateUserProfile_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().UpdateUserProfile(rctx, args["input"].(dto.UserProfileInput)) - }) - 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.(*profileutils.UserProfile) - fc.Result = res - return ec.marshalNUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_updateUserPIN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_updateUserPIN_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().UpdateUserPin(rctx, args["phone"].(string), args["pin"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_setPrimaryPhoneNumber(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_setPrimaryPhoneNumber_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().SetPrimaryPhoneNumber(rctx, args["phone"].(string), args["otp"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_setPrimaryEmailAddress(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_setPrimaryEmailAddress_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().SetPrimaryEmailAddress(rctx, args["email"].(string), args["otp"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_addSecondaryPhoneNumber(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_addSecondaryPhoneNumber_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().AddSecondaryPhoneNumber(rctx, args["phone"].([]string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_retireSecondaryPhoneNumbers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_retireSecondaryPhoneNumbers_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().RetireSecondaryPhoneNumbers(rctx, args["phones"].([]string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_addSecondaryEmailAddress(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_addSecondaryEmailAddress_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().AddSecondaryEmailAddress(rctx, args["email"].([]string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_retireSecondaryEmailAddresses(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_retireSecondaryEmailAddresses_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().RetireSecondaryEmailAddresses(rctx, args["emails"].([]string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_updateUserName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_updateUserName_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().UpdateUserName(rctx, args["username"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_registerPushToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_registerPushToken_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().RegisterPushToken(rctx, args["token"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_recordPostVisitSurvey(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_recordPostVisitSurvey_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().RecordPostVisitSurvey(rctx, args["input"].(dto.PostVisitSurveyInput)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_setupAsExperimentParticipant(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_setupAsExperimentParticipant_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().SetupAsExperimentParticipant(rctx, args["participate"].(*bool)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_addAddress(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_addAddress_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().AddAddress(rctx, args["input"].(dto.UserAddressInput), args["addressType"].(enumutils.AddressType)) - }) - 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.(*profileutils.Address) - fc.Result = res - return ec.marshalNAddress2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐAddress(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_setUserCommunicationsSettings(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_setUserCommunicationsSettings_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().SetUserCommunicationsSettings(rctx, args["allowWhatsApp"].(*bool), args["allowTextSMS"].(*bool), args["allowPush"].(*bool), args["allowEmail"].(*bool)) - }) - 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.(*profileutils.UserCommunicationsSetting) - fc.Result = res - return ec.marshalNUserCommunicationsSetting2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserCommunicationsSetting(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_saveFavoriteNavAction(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_saveFavoriteNavAction_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().SaveFavoriteNavAction(rctx, args["title"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_deleteFavoriteNavAction(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_deleteFavoriteNavAction_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().DeleteFavoriteNavAction(rctx, args["title"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_registerMicroservice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_registerMicroservice_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().RegisterMicroservice(rctx, args["input"].(domain.Microservice)) - }) - 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.(*domain.Microservice) - fc.Result = res - return ec.marshalNMicroservice2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋdomainᚐMicroservice(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_deregisterMicroservice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_deregisterMicroservice_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().DeregisterMicroservice(rctx, args["id"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_deregisterAllMicroservices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - 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.Mutation().DeregisterAllMicroservices(rctx) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_createRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_createRole_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().CreateRole(rctx, args["input"].(dto.RoleInput)) - }) - 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.(*dto.RoleOutput) - fc.Result = res - return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_deleteRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_deleteRole_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().DeleteRole(rctx, args["roleID"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_addPermissionsToRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_addPermissionsToRole_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().AddPermissionsToRole(rctx, args["input"].(dto.RolePermissionInput)) - }) - 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.(*dto.RoleOutput) - fc.Result = res - return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_revokeRolePermission(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_revokeRolePermission_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().RevokeRolePermission(rctx, args["input"].(dto.RolePermissionInput)) - }) - 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.(*dto.RoleOutput) - fc.Result = res - return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_updateRolePermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_updateRolePermissions_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().UpdateRolePermissions(rctx, args["input"].(dto.RolePermissionInput)) - }) - 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.(*dto.RoleOutput) - fc.Result = res - return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_assignRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_assignRole_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().AssignRole(rctx, args["userID"].(string), args["roleID"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_assignMultipleRoles(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_assignMultipleRoles_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().AssignMultipleRoles(rctx, args["userID"].(string), args["roleIDs"].([]string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_revokeRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_revokeRole_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().RevokeRole(rctx, args["userID"].(string), args["roleID"].(string), args["reason"].(string)) - }) - 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.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_activateRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_activateRole_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().ActivateRole(rctx, args["roleID"].(string)) - }) - 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.(*dto.RoleOutput) - fc.Result = res - return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_deactivateRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_deactivateRole_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().DeactivateRole(rctx, args["roleID"].(string)) - }) - 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.(*dto.RoleOutput) - fc.Result = res - return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) -} - -func (ec *executionContext) _NavAction_title(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavAction", - 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.Title, 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) _NavAction_onTapRoute(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavAction", - 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.OnTapRoute, 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) _NavAction_icon(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavAction", - 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.Icon, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(feedlib.Link) - fc.Result = res - return ec.marshalOLink2githubᚗcomᚋsavannahghiᚋfeedlibᚐLink(ctx, field.Selections, res) -} - -func (ec *executionContext) _NavAction_favourite(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavAction", - 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.Favourite, 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) _NavAction_nested(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavAction", - 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.Nested, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]profileutils.NestedNavAction) - fc.Result = res - return ec.marshalONestedNavAction2ᚕgithubᚗcomᚋsavannahghiᚋprofileutilsᚐNestedNavAction(ctx, field.Selections, res) -} - -func (ec *executionContext) _NavigationAction_title(ctx context.Context, field graphql.CollectedField, obj *domain.NavigationAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavigationAction", - 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.Title, 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) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _NavigationAction_onTapRoute(ctx context.Context, field graphql.CollectedField, obj *domain.NavigationAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavigationAction", - 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.OnTapRoute, 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) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _NavigationAction_icon(ctx context.Context, field graphql.CollectedField, obj *domain.NavigationAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavigationAction", - 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.Icon, 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) _NavigationAction_favorite(ctx context.Context, field graphql.CollectedField, obj *domain.NavigationAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavigationAction", - 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.Favorite, 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) _NavigationAction_nested(ctx context.Context, field graphql.CollectedField, obj *domain.NavigationAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavigationAction", - 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.Nested, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]interface{}) - fc.Result = res - return ec.marshalOAny2ᚕinterface(ctx, field.Selections, res) -} - -func (ec *executionContext) _NavigationActions_primary(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavigationActions) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavigationActions", - 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.Primary, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]profileutils.NavAction) - fc.Result = res - return ec.marshalONavAction2ᚕgithubᚗcomᚋsavannahghiᚋprofileutilsᚐNavAction(ctx, field.Selections, res) -} - -func (ec *executionContext) _NavigationActions_secondary(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavigationActions) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NavigationActions", - 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.Secondary, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]profileutils.NavAction) - fc.Result = res - return ec.marshalONavAction2ᚕgithubᚗcomᚋsavannahghiᚋprofileutilsᚐNavAction(ctx, field.Selections, res) -} - -func (ec *executionContext) _NestedNavAction_title(ctx context.Context, field graphql.CollectedField, obj *profileutils.NestedNavAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NestedNavAction", - 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.Title, 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) _NestedNavAction_onTapRoute(ctx context.Context, field graphql.CollectedField, obj *profileutils.NestedNavAction) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "NestedNavAction", - 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.OnTapRoute, 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) _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)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) + fc.Args = args 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 ec.resolvers.Mutation().AddAddress(rctx, args["input"].(dto.UserAddressInput), args["addressType"].(enumutils.AddressType)) }) if err != nil { ec.Error(ctx, err) @@ -8542,12 +4855,12 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*profileutils.Address) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNAddress2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐAddress(ctx, field.Selections, res) } -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_setUserCommunicationsSettings(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8555,17 +4868,24 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "PageInfo", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_setUserCommunicationsSettings_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Mutation().SetUserCommunicationsSettings(rctx, args["allowWhatsApp"].(*bool), args["allowTextSMS"].(*bool), args["allowPush"].(*bool), args["allowEmail"].(*bool)) }) if err != nil { ec.Error(ctx, err) @@ -8577,12 +4897,12 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*profileutils.UserCommunicationsSetting) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNUserCommunicationsSetting2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserCommunicationsSetting(ctx, field.Selections, res) } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_saveFavoriteNavAction(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8590,31 +4910,41 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "PageInfo", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_saveFavoriteNavAction_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Mutation().SaveFavoriteNavAction(rctx, args["title"].(string)) }) 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) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *firebasetools.PageInfo) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_deleteFavoriteNavAction(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8622,31 +4952,41 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph } }() fc := &graphql.FieldContext{ - Object: "PageInfo", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_deleteFavoriteNavAction_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Mutation().DeleteFavoriteNavAction(rctx, args["title"].(string)) }) 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) _Mutation_registerMicroservice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8654,17 +4994,24 @@ func (ec *executionContext) _Permission_scope(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "Permission", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_registerMicroservice_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Mutation().RegisterMicroservice(rctx, args["input"].(domain.Microservice)) }) if err != nil { ec.Error(ctx, err) @@ -8676,12 +5023,12 @@ func (ec *executionContext) _Permission_scope(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*domain.Microservice) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNMicroservice2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋdomainᚐMicroservice(ctx, field.Selections, res) } -func (ec *executionContext) _Permission_description(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_deregisterMicroservice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8689,17 +5036,24 @@ func (ec *executionContext) _Permission_description(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "Permission", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_deregisterMicroservice_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Mutation().DeregisterMicroservice(rctx, args["id"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -8711,12 +5065,12 @@ func (ec *executionContext) _Permission_description(ctx context.Context, field g } 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) _Permission_group(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_deregisterAllMicroservices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8724,17 +5078,17 @@ func (ec *executionContext) _Permission_group(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "Permission", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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 ec.resolvers.Mutation().DeregisterAllMicroservices(rctx) }) if err != nil { ec.Error(ctx, err) @@ -8746,12 +5100,12 @@ func (ec *executionContext) _Permission_group(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(profileutils.PermissionGroup) + res := resTmp.(bool) fc.Result = res - return ec.marshalNPermissionGroup2githubᚗcomᚋsavannahghiᚋprofileutilsᚐPermissionGroup(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Permission_allowed(ctx context.Context, field graphql.CollectedField, obj *profileutils.Permission) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_createRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8759,17 +5113,24 @@ func (ec *executionContext) _Permission_allowed(ctx context.Context, field graph } }() fc := &graphql.FieldContext{ - Object: "Permission", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_createRole_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Mutation().CreateRole(rctx, args["input"].(dto.RoleInput)) }) if err != nil { ec.Error(ctx, err) @@ -8781,12 +5142,12 @@ func (ec *executionContext) _Permission_allowed(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*dto.RoleOutput) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) } -func (ec *executionContext) _Pin_userID(ctx context.Context, field graphql.CollectedField, obj *domain1.Pin) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_deleteRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8794,17 +5155,24 @@ func (ec *executionContext) _Pin_userID(ctx context.Context, field graphql.Colle } }() fc := &graphql.FieldContext{ - Object: "Pin", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_deleteRole_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Mutation().DeleteRole(rctx, args["roleID"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -8816,12 +5184,12 @@ func (ec *executionContext) _Pin_userID(ctx context.Context, field graphql.Colle } 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 *domain1.Pin) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_addPermissionsToRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8829,17 +5197,24 @@ func (ec *executionContext) _Pin_Pin(ctx context.Context, field graphql.Collecte } }() fc := &graphql.FieldContext{ - Object: "Pin", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_addPermissionsToRole_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PIN, nil + return ec.resolvers.Mutation().AddPermissionsToRole(rctx, args["input"].(dto.RolePermissionInput)) }) if err != nil { ec.Error(ctx, err) @@ -8851,12 +5226,12 @@ func (ec *executionContext) _Pin_Pin(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*dto.RoleOutput) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) } -func (ec *executionContext) _Pin_confirmedPin(ctx context.Context, field graphql.CollectedField, obj *domain1.Pin) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_revokeRolePermission(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8864,17 +5239,24 @@ func (ec *executionContext) _Pin_confirmedPin(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "Pin", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_revokeRolePermission_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ConfirmedPin, nil + return ec.resolvers.Mutation().RevokeRolePermission(rctx, args["input"].(dto.RolePermissionInput)) }) if err != nil { ec.Error(ctx, err) @@ -8886,12 +5268,12 @@ func (ec *executionContext) _Pin_confirmedPin(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*dto.RoleOutput) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) } -func (ec *executionContext) _Pin_flavour(ctx context.Context, field graphql.CollectedField, obj *domain1.Pin) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateRolePermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8899,17 +5281,24 @@ func (ec *executionContext) _Pin_flavour(ctx context.Context, field graphql.Coll } }() fc := &graphql.FieldContext{ - Object: "Pin", + Object: "Mutation", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_updateRolePermissions_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Flavour, nil + return ec.resolvers.Mutation().UpdateRolePermissions(rctx, args["input"].(dto.RolePermissionInput)) }) if err != nil { ec.Error(ctx, err) @@ -8921,12 +5310,12 @@ func (ec *executionContext) _Pin_flavour(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(feedlib.Flavour) + res := resTmp.(*dto.RoleOutput) fc.Result = res - return ec.marshalNFlavour2githubᚗcomᚋsavannahghiᚋfeedlibᚐFlavour(ctx, field.Selections, res) + return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) } -func (ec *executionContext) _Query_fetchFacilities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_assignRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8934,7 +5323,7 @@ func (ec *executionContext) _Query_fetchFacilities(ctx context.Context, field gr } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, Args: nil, IsMethod: true, @@ -8942,23 +5331,33 @@ func (ec *executionContext) _Query_fetchFacilities(ctx context.Context, field gr } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_assignRole_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + 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.Query().FetchFacilities(rctx) + return ec.resolvers.Mutation().AssignRole(rctx, args["userID"].(string), args["roleID"].(string)) }) 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.Facility) + res := resTmp.(bool) fc.Result = res - return ec.marshalOFacility2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐFacility(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Query_retrieveFacility(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_assignMultipleRoles(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -8966,7 +5365,7 @@ func (ec *executionContext) _Query_retrieveFacility(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, Args: nil, IsMethod: true, @@ -8975,7 +5374,7 @@ func (ec *executionContext) _Query_retrieveFacility(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_retrieveFacility_args(ctx, rawArgs) + args, err := ec.field_Mutation_assignMultipleRoles_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -8983,21 +5382,24 @@ func (ec *executionContext) _Query_retrieveFacility(ctx context.Context, field g 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.Query().RetrieveFacility(rctx, args["id"].(string), args["active"].(bool)) + return ec.resolvers.Mutation().AssignMultipleRoles(rctx, args["userID"].(string), args["roleIDs"].([]string)) }) 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.Facility) + res := resTmp.(bool) fc.Result = res - return ec.marshalOFacility2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐFacility(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Query_retrieveFacilityByMFLCode(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_revokeRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9005,7 +5407,7 @@ func (ec *executionContext) _Query_retrieveFacilityByMFLCode(ctx context.Context } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, Args: nil, IsMethod: true, @@ -9014,7 +5416,7 @@ func (ec *executionContext) _Query_retrieveFacilityByMFLCode(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_retrieveFacilityByMFLCode_args(ctx, rawArgs) + args, err := ec.field_Mutation_revokeRole_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -9022,7 +5424,7 @@ func (ec *executionContext) _Query_retrieveFacilityByMFLCode(ctx context.Context 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.Query().RetrieveFacilityByMFLCode(rctx, args["mflCode"].(string), args["isActive"].(bool)) + return ec.resolvers.Mutation().RevokeRole(rctx, args["userID"].(string), args["roleID"].(string), args["reason"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -9034,12 +5436,12 @@ func (ec *executionContext) _Query_retrieveFacilityByMFLCode(ctx context.Context } return graphql.Null } - res := resTmp.(*domain1.Facility) + res := resTmp.(bool) fc.Result = res - return ec.marshalNFacility2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐFacility(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Query_testQuery(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_activateRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9047,7 +5449,7 @@ func (ec *executionContext) _Query_testQuery(ctx context.Context, field graphql. } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, Args: nil, IsMethod: true, @@ -9055,23 +5457,33 @@ func (ec *executionContext) _Query_testQuery(ctx context.Context, field graphql. } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_activateRole_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + 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.Query().TestQuery(rctx) + return ec.resolvers.Mutation().ActivateRole(rctx, args["roleID"].(string)) }) 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.(*bool) + res := resTmp.(*dto.RoleOutput) fc.Result = res - return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) + return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) } -func (ec *executionContext) _Query_dummyQuery(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_deactivateRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9079,7 +5491,7 @@ func (ec *executionContext) _Query_dummyQuery(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, Args: nil, IsMethod: true, @@ -9087,23 +5499,33 @@ func (ec *executionContext) _Query_dummyQuery(ctx context.Context, field graphql } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_deactivateRole_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + 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.Query().DummyQuery(rctx) + return ec.resolvers.Mutation().DeactivateRole(rctx, args["roleID"].(string)) }) 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.(*bool) + res := resTmp.(*dto.RoleOutput) fc.Result = res - return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) + return ec.marshalNRoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) } -func (ec *executionContext) _Query_userProfile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavAction_title(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9111,34 +5533,31 @@ func (ec *executionContext) _Query_userProfile(ctx context.Context, field graphq } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavAction", 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.Query().UserProfile(rctx) + return obj.Title, 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.(*profileutils.UserProfile) + res := resTmp.(string) fc.Result = res - return ec.marshalNUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query_resumeWithPIN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavAction_onTapRoute(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9146,41 +5565,31 @@ func (ec *executionContext) _Query_resumeWithPIN(ctx context.Context, field grap } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavAction", Field: field, Args: nil, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_resumeWithPIN_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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.Query().ResumeWithPin(rctx, args["pin"].(string)) + return obj.OnTapRoute, 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.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query_getAddresses(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavAction_icon(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9188,34 +5597,31 @@ func (ec *executionContext) _Query_getAddresses(ctx context.Context, field graph } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavAction", 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.Query().GetAddresses(rctx) + return obj.Icon, 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.(*domain.UserAddresses) + res := resTmp.(feedlib.Link) fc.Result = res - return ec.marshalNUserAddresses2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋdomainᚐUserAddresses(ctx, field.Selections, res) + return ec.marshalOLink2githubᚗcomᚋsavannahghiᚋfeedlibᚐLink(ctx, field.Selections, res) } -func (ec *executionContext) _Query_getUserCommunicationsSettings(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavAction_favourite(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9223,34 +5629,31 @@ func (ec *executionContext) _Query_getUserCommunicationsSettings(ctx context.Con } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavAction", 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.Query().GetUserCommunicationsSettings(rctx) + return obj.Favourite, 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.(*profileutils.UserCommunicationsSetting) + res := resTmp.(bool) fc.Result = res - return ec.marshalNUserCommunicationsSetting2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserCommunicationsSetting(ctx, field.Selections, res) + return ec.marshalOBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Query_fetchUserNavigationActions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavAction_nested(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9258,17 +5661,17 @@ func (ec *executionContext) _Query_fetchUserNavigationActions(ctx context.Contex } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavAction", 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.Query().FetchUserNavigationActions(rctx) + return obj.Nested, nil }) if err != nil { ec.Error(ctx, err) @@ -9277,12 +5680,12 @@ func (ec *executionContext) _Query_fetchUserNavigationActions(ctx context.Contex if resTmp == nil { return graphql.Null } - res := resTmp.(*profileutils.NavigationActions) + res := resTmp.([]profileutils.NestedNavAction) fc.Result = res - return ec.marshalONavigationActions2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐNavigationActions(ctx, field.Selections, res) + return ec.marshalONestedNavAction2ᚕgithubᚗcomᚋsavannahghiᚋprofileutilsᚐNestedNavAction(ctx, field.Selections, res) } -func (ec *executionContext) _Query_listMicroservices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavigationAction_title(ctx context.Context, field graphql.CollectedField, obj *domain.NavigationAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9290,17 +5693,17 @@ func (ec *executionContext) _Query_listMicroservices(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavigationAction", 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.Query().ListMicroservices(rctx) + return obj.Title, nil }) if err != nil { ec.Error(ctx, err) @@ -9312,12 +5715,12 @@ func (ec *executionContext) _Query_listMicroservices(ctx context.Context, field } return graphql.Null } - res := resTmp.([]*domain.Microservice) + res := resTmp.(string) fc.Result = res - return ec.marshalNMicroservice2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋdomainᚐMicroserviceᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query_getAllRoles(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavigationAction_onTapRoute(ctx context.Context, field graphql.CollectedField, obj *domain.NavigationAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9325,31 +5728,34 @@ func (ec *executionContext) _Query_getAllRoles(ctx context.Context, field graphq } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavigationAction", 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.Query().GetAllRoles(rctx) + return obj.OnTapRoute, 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.([]*dto.RoleOutput) + res := resTmp.(string) fc.Result = res - return ec.marshalORoleOutput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query_findRoleByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavigationAction_icon(ctx context.Context, field graphql.CollectedField, obj *domain.NavigationAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9357,24 +5763,17 @@ func (ec *executionContext) _Query_findRoleByName(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavigationAction", Field: field, Args: nil, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_findRoleByName_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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.Query().FindRoleByName(rctx, args["roleName"].(*string)) + return obj.Icon, nil }) if err != nil { ec.Error(ctx, err) @@ -9383,12 +5782,12 @@ func (ec *executionContext) _Query_findRoleByName(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.([]*dto.RoleOutput) + res := resTmp.(string) fc.Result = res - return ec.marshalORoleOutput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query_getAllPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavigationAction_favorite(ctx context.Context, field graphql.CollectedField, obj *domain.NavigationAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9396,34 +5795,31 @@ func (ec *executionContext) _Query_getAllPermissions(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavigationAction", 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.Query().GetAllPermissions(rctx) + return obj.Favorite, 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.([]*profileutils.Permission) + res := resTmp.(bool) fc.Result = res - return ec.marshalNPermission2ᚕᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐPermissionᚄ(ctx, field.Selections, res) + return ec.marshalOBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Query_findUserByPhone(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavigationAction_nested(ctx context.Context, field graphql.CollectedField, obj *domain.NavigationAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9431,41 +5827,31 @@ func (ec *executionContext) _Query_findUserByPhone(ctx context.Context, field gr } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavigationAction", Field: field, Args: nil, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_findUserByPhone_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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.Query().FindUserByPhone(rctx, args["phoneNumber"].(string)) + return obj.Nested, 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.(*profileutils.UserProfile) + res := resTmp.([]interface{}) fc.Result = res - return ec.marshalNUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) + return ec.marshalOAny2ᚕinterface(ctx, field.Selections, res) } -func (ec *executionContext) _Query_findUsersByPhone(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavigationActions_primary(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavigationActions) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9473,24 +5859,17 @@ func (ec *executionContext) _Query_findUsersByPhone(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavigationActions", Field: field, Args: nil, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_findUsersByPhone_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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.Query().FindUsersByPhone(rctx, args["phoneNumber"].(string)) + return obj.Primary, nil }) if err != nil { ec.Error(ctx, err) @@ -9499,12 +5878,12 @@ func (ec *executionContext) _Query_findUsersByPhone(ctx context.Context, field g if resTmp == nil { return graphql.Null } - res := resTmp.([]*profileutils.UserProfile) + res := resTmp.([]profileutils.NavAction) fc.Result = res - return ec.marshalOUserProfile2ᚕᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) + return ec.marshalONavAction2ᚕgithubᚗcomᚋsavannahghiᚋprofileutilsᚐNavAction(ctx, field.Selections, res) } -func (ec *executionContext) _Query_getNavigationActions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NavigationActions_secondary(ctx context.Context, field graphql.CollectedField, obj *profileutils.NavigationActions) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9512,17 +5891,17 @@ func (ec *executionContext) _Query_getNavigationActions(ctx context.Context, fie } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NavigationActions", 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.Query().GetNavigationActions(rctx) + return obj.Secondary, nil }) if err != nil { ec.Error(ctx, err) @@ -9531,12 +5910,12 @@ func (ec *executionContext) _Query_getNavigationActions(ctx context.Context, fie if resTmp == nil { return graphql.Null } - res := resTmp.(*dto.GroupedNavigationActions) + res := resTmp.([]profileutils.NavAction) fc.Result = res - return ec.marshalOGroupedNavigationActions2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐGroupedNavigationActions(ctx, field.Selections, res) + return ec.marshalONavAction2ᚕgithubᚗcomᚋsavannahghiᚋprofileutilsᚐNavAction(ctx, field.Selections, res) } -func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NestedNavAction_title(ctx context.Context, field graphql.CollectedField, obj *profileutils.NestedNavAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9544,41 +5923,31 @@ func (ec *executionContext) _Query__entities(ctx context.Context, field graphql. } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NestedNavAction", Field: field, Args: nil, - IsMethod: true, + IsMethod: false, IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query__entities_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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.__resolve_entities(ctx, args["representations"].([]map[string]interface{})) + return obj.Title, 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.([]fedruntime.Entity) + res := resTmp.(string) fc.Result = res - return ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _NestedNavAction_onTapRoute(ctx context.Context, field graphql.CollectedField, obj *profileutils.NestedNavAction) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9586,34 +5955,31 @@ func (ec *executionContext) _Query__service(ctx context.Context, field graphql.C } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "NestedNavAction", Field: field, Args: nil, - IsMethod: 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.__resolve__service(ctx) + return obj.OnTapRoute, 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.(fedruntime.Service) + res := resTmp.(string) fc.Result = res - return ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (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)) @@ -9621,38 +5987,34 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, Args: nil, - IsMethod: true, + IsMethod: false, IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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.introspectType(args["name"].(string)) + return obj.HasNextPage, 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.(*introspection.Type) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (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)) @@ -9660,31 +6022,34 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C } }() fc := &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, Args: nil, - IsMethod: 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.introspectSchema() + return obj.HasPreviousPage, 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.(*introspection.Schema) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _RoleOutput_id(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (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)) @@ -9692,7 +6057,7 @@ func (ec *executionContext) _RoleOutput_id(ctx context.Context, field graphql.Co } }() fc := &graphql.FieldContext{ - Object: "RoleOutput", + Object: "PageInfo", Field: field, Args: nil, IsMethod: false, @@ -9702,24 +6067,21 @@ func (ec *executionContext) _RoleOutput_id(ctx context.Context, field graphql.Co 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.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.marshalNID2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _RoleOutput_name(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (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)) @@ -9727,7 +6089,7 @@ func (ec *executionContext) _RoleOutput_name(ctx context.Context, field graphql. } }() fc := &graphql.FieldContext{ - Object: "RoleOutput", + Object: "PageInfo", Field: field, Args: nil, IsMethod: false, @@ -9737,24 +6099,21 @@ func (ec *executionContext) _RoleOutput_name(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.Name, nil + 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.(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) _RoleOutput_description(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (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)) @@ -9762,7 +6121,7 @@ func (ec *executionContext) _RoleOutput_description(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "RoleOutput", + Object: "Permission", Field: field, Args: nil, IsMethod: false, @@ -9772,7 +6131,7 @@ func (ec *executionContext) _RoleOutput_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.Scope, nil }) if err != nil { ec.Error(ctx, err) @@ -9789,7 +6148,7 @@ func (ec *executionContext) _RoleOutput_description(ctx context.Context, field g return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _RoleOutput_active(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (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)) @@ -9797,7 +6156,7 @@ func (ec *executionContext) _RoleOutput_active(ctx context.Context, field graphq } }() fc := &graphql.FieldContext{ - Object: "RoleOutput", + Object: "Permission", Field: field, Args: nil, IsMethod: false, @@ -9807,7 +6166,7 @@ func (ec *executionContext) _RoleOutput_active(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.Active, nil + return obj.Description, nil }) if err != nil { ec.Error(ctx, err) @@ -9819,12 +6178,12 @@ func (ec *executionContext) _RoleOutput_active(ctx context.Context, field graphq } 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) _RoleOutput_scopes(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (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)) @@ -9832,7 +6191,7 @@ func (ec *executionContext) _RoleOutput_scopes(ctx context.Context, field graphq } }() fc := &graphql.FieldContext{ - Object: "RoleOutput", + Object: "Permission", Field: field, Args: nil, IsMethod: false, @@ -9842,21 +6201,24 @@ func (ec *executionContext) _RoleOutput_scopes(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.Scopes, 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) _RoleOutput_permissions(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (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)) @@ -9864,7 +6226,7 @@ func (ec *executionContext) _RoleOutput_permissions(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "RoleOutput", + Object: "Permission", Field: field, Args: nil, IsMethod: false, @@ -9874,21 +6236,24 @@ func (ec *executionContext) _RoleOutput_permissions(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.Permissions, 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.([]profileutils.Permission) + res := resTmp.(bool) fc.Result = res - return ec.marshalOPermission2ᚕgithubᚗcomᚋsavannahghiᚋprofileutilsᚐPermission(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _RoleOutput_users(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_fetchFacilities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9896,17 +6261,17 @@ func (ec *executionContext) _RoleOutput_users(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "RoleOutput", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.Users, nil + return ec.resolvers.Query().FetchFacilities(rctx) }) if err != nil { ec.Error(ctx, err) @@ -9915,12 +6280,12 @@ func (ec *executionContext) _RoleOutput_users(ctx context.Context, field graphql if resTmp == nil { return graphql.Null } - res := resTmp.([]*profileutils.UserProfile) + res := resTmp.([]*domain1.Facility) fc.Result = res - return ec.marshalOUserProfile2ᚕᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) + return ec.marshalOFacility2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐFacility(ctx, field.Selections, res) } -func (ec *executionContext) _StaffProfile_id(ctx context.Context, field graphql.CollectedField, obj *domain1.StaffProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_retrieveFacility(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9928,34 +6293,38 @@ func (ec *executionContext) _StaffProfile_id(ctx context.Context, field graphql. } }() fc := &graphql.FieldContext{ - Object: "StaffProfile", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_retrieveFacility_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Query().RetrieveFacility(rctx, args["id"].(string), args["active"].(bool)) }) 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.(*domain1.Facility) fc.Result = res - return ec.marshalNString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOFacility2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐFacility(ctx, field.Selections, res) } -func (ec *executionContext) _StaffProfile_userID(ctx context.Context, field graphql.CollectedField, obj *domain1.StaffProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_retrieveFacilityByMFLCode(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9963,17 +6332,24 @@ func (ec *executionContext) _StaffProfile_userID(ctx context.Context, field grap } }() fc := &graphql.FieldContext{ - Object: "StaffProfile", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_retrieveFacilityByMFLCode_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Query().RetrieveFacilityByMFLCode(rctx, args["mflCode"].(string), args["isActive"].(bool)) }) if err != nil { ec.Error(ctx, err) @@ -9985,12 +6361,12 @@ func (ec *executionContext) _StaffProfile_userID(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*domain1.Facility) fc.Result = res - return ec.marshalNString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNFacility2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐFacility(ctx, field.Selections, res) } -func (ec *executionContext) _StaffProfile_staffNumber(ctx context.Context, field graphql.CollectedField, obj *domain1.StaffProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_dummyQuery(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9998,34 +6374,31 @@ func (ec *executionContext) _StaffProfile_staffNumber(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "StaffProfile", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.StaffNumber, nil + return ec.resolvers.Query().DummyQuery(rctx) }) 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.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } -func (ec *executionContext) _StaffProfile_defaultFacilityID(ctx context.Context, field graphql.CollectedField, obj *domain1.StaffProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_userProfile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10033,17 +6406,17 @@ func (ec *executionContext) _StaffProfile_defaultFacilityID(ctx context.Context, } }() fc := &graphql.FieldContext{ - Object: "StaffProfile", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.DefaultFacilityID, nil + return ec.resolvers.Query().UserProfile(rctx) }) if err != nil { ec.Error(ctx, err) @@ -10055,12 +6428,12 @@ func (ec *executionContext) _StaffProfile_defaultFacilityID(ctx context.Context, } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*profileutils.UserProfile) fc.Result = res - return ec.marshalNString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) } -func (ec *executionContext) _StaffProfile_addresses(ctx context.Context, field graphql.CollectedField, obj *domain1.StaffProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_resumeWithPIN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10068,31 +6441,41 @@ func (ec *executionContext) _StaffProfile_addresses(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "StaffProfile", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_resumeWithPIN_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Addresses, nil + return ec.resolvers.Query().ResumeWithPin(rctx, args["pin"].(string)) }) 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.Addresses) + res := resTmp.(bool) fc.Result = res - return ec.marshalOAddresses2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐAddressesᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _StaffProfile_roles(ctx context.Context, field graphql.CollectedField, obj *domain1.StaffProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_getAddresses(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10100,31 +6483,34 @@ func (ec *executionContext) _StaffProfile_roles(ctx context.Context, field graph } }() fc := &graphql.FieldContext{ - Object: "StaffProfile", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.Roles, nil + return ec.resolvers.Query().GetAddresses(rctx) }) 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.RolesType) + res := resTmp.(*domain.UserAddresses) fc.Result = res - return ec.marshalORolesType2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesTypeᚄ(ctx, field.Selections, res) + return ec.marshalNUserAddresses2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋdomainᚐUserAddresses(ctx, field.Selections, res) } -func (ec *executionContext) _StaffUserProfile_user(ctx context.Context, field graphql.CollectedField, obj *domain1.StaffUserProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_getUserCommunicationsSettings(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10132,17 +6518,17 @@ func (ec *executionContext) _StaffUserProfile_user(ctx context.Context, field gr } }() fc := &graphql.FieldContext{ - Object: "StaffUserProfile", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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 ec.resolvers.Query().GetUserCommunicationsSettings(rctx) }) if err != nil { ec.Error(ctx, err) @@ -10154,12 +6540,12 @@ func (ec *executionContext) _StaffUserProfile_user(ctx context.Context, field gr } return graphql.Null } - res := resTmp.(*domain1.User) + res := resTmp.(*profileutils.UserCommunicationsSetting) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐUser(ctx, field.Selections, res) + return ec.marshalNUserCommunicationsSetting2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserCommunicationsSetting(ctx, field.Selections, res) } -func (ec *executionContext) _StaffUserProfile_staff(ctx context.Context, field graphql.CollectedField, obj *domain1.StaffUserProfile) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_fetchUserNavigationActions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10167,34 +6553,31 @@ func (ec *executionContext) _StaffUserProfile_staff(ctx context.Context, field g } }() fc := &graphql.FieldContext{ - Object: "StaffUserProfile", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.Staff, nil + return ec.resolvers.Query().FetchUserNavigationActions(rctx) }) 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.StaffProfile) + res := resTmp.(*profileutils.NavigationActions) fc.Result = res - return ec.marshalNStaffProfile2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐStaffProfile(ctx, field.Selections, res) + return ec.marshalONavigationActions2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐNavigationActions(ctx, field.Selections, res) } -func (ec *executionContext) _ThinAddress_latitude(ctx context.Context, field graphql.CollectedField, obj *domain.ThinAddress) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listMicroservices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10202,17 +6585,17 @@ func (ec *executionContext) _ThinAddress_latitude(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "ThinAddress", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.Latitude, nil + return ec.resolvers.Query().ListMicroservices(rctx) }) if err != nil { ec.Error(ctx, err) @@ -10224,12 +6607,12 @@ func (ec *executionContext) _ThinAddress_latitude(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(float64) + res := resTmp.([]*domain.Microservice) fc.Result = res - return ec.marshalNFloat2float64(ctx, field.Selections, res) + return ec.marshalNMicroservice2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋdomainᚐMicroserviceᚄ(ctx, field.Selections, res) } -func (ec *executionContext) _ThinAddress_longitude(ctx context.Context, field graphql.CollectedField, obj *domain.ThinAddress) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_getAllRoles(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10237,34 +6620,31 @@ func (ec *executionContext) _ThinAddress_longitude(ctx context.Context, field gr } }() fc := &graphql.FieldContext{ - Object: "ThinAddress", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.Longitude, nil + return ec.resolvers.Query().GetAllRoles(rctx) }) 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.(float64) + res := resTmp.([]*dto.RoleOutput) fc.Result = res - return ec.marshalNFloat2float64(ctx, field.Selections, res) + return ec.marshalORoleOutput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_findRoleByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10272,34 +6652,38 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_findRoleByName_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.resolvers.Query().FindRoleByName(rctx, args["roleName"].(*string)) }) 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.([]*dto.RoleOutput) fc.Result = res - return ec.marshalNString2ᚖstring(ctx, field.Selections, res) + return ec.marshalORoleOutput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐRoleOutput(ctx, field.Selections, res) } -func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_getAllPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10307,31 +6691,34 @@ func (ec *executionContext) _User_username(ctx context.Context, field graphql.Co } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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.Username, nil + return ec.resolvers.Query().GetAllPermissions(rctx) }) 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.Permission) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNPermission2ᚕᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐPermissionᚄ(ctx, field.Selections, res) } -func (ec *executionContext) _User_displayName(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_findUserByPhone(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10339,31 +6726,41 @@ func (ec *executionContext) _User_displayName(ctx context.Context, field graphql } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_findUserByPhone_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DisplayName, nil + return ec.resolvers.Query().FindUserByPhone(rctx, args["phoneNumber"].(string)) }) 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.UserProfile) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) } -func (ec *executionContext) _User_middleName(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_findUsersByPhone(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10371,17 +6768,24 @@ func (ec *executionContext) _User_middleName(ctx context.Context, field graphql. } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_findUsersByPhone_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MiddleName, nil + return ec.resolvers.Query().FindUsersByPhone(rctx, args["phoneNumber"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -10390,12 +6794,12 @@ func (ec *executionContext) _User_middleName(ctx context.Context, field graphql. if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*profileutils.UserProfile) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalOUserProfile2ᚕᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) } -func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_getNavigationActions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10403,17 +6807,17 @@ func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.C } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, Args: nil, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, } 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 ec.resolvers.Query().GetNavigationActions(rctx) }) if err != nil { ec.Error(ctx, err) @@ -10422,12 +6826,12 @@ func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*dto.GroupedNavigationActions) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalOGroupedNavigationActions2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐGroupedNavigationActions(ctx, field.Selections, res) } -func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10435,31 +6839,41 @@ func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.Co } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query__entities_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args 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 ec.__resolve_entities(ctx, args["representations"].([]map[string]interface{})) }) 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.([]fedruntime.Entity) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) } -func (ec *executionContext) _User_gender(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10467,31 +6881,34 @@ func (ec *executionContext) _User_gender(ctx context.Context, field graphql.Coll } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, 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.Gender, nil + return ec.__resolve__service(ctx) }) 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.(fedruntime.Service) fc.Result = res - return ec.marshalOGender2githubᚗcomᚋsavannahghiᚋenumutilsᚐGender(ctx, field.Selections, res) + return ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) } -func (ec *executionContext) _User_userType(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10499,17 +6916,24 @@ func (ec *executionContext) _User_userType(ctx context.Context, field graphql.Co } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, IsResolver: false, } ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.UserType, nil + return ec.introspectType(args["name"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -10518,12 +6942,12 @@ func (ec *executionContext) _User_userType(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.(enums.UsersType) + res := resTmp.(*introspection.Type) fc.Result = res - return ec.marshalOUsersType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐUsersType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) _User_active(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10531,17 +6955,17 @@ func (ec *executionContext) _User_active(ctx context.Context, field graphql.Coll } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, 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.Active, nil + return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) @@ -10550,12 +6974,12 @@ func (ec *executionContext) _User_active(ctx context.Context, field graphql.Coll if resTmp == nil { return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Schema) fc.Result = res - return ec.marshalOBoolean2bool(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) _User_contacts(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _RoleOutput_id(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10563,7 +6987,7 @@ func (ec *executionContext) _User_contacts(ctx context.Context, field graphql.Co } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "RoleOutput", Field: field, Args: nil, IsMethod: false, @@ -10573,7 +6997,7 @@ func (ec *executionContext) _User_contacts(ctx context.Context, field graphql.Co 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.Contacts, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -10585,12 +7009,12 @@ func (ec *executionContext) _User_contacts(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.([]*domain1.Contact) + res := resTmp.(string) fc.Result = res - return ec.marshalNContact2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐContactᚄ(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_languages(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _RoleOutput_name(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10598,7 +7022,7 @@ func (ec *executionContext) _User_languages(ctx context.Context, field graphql.C } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "RoleOutput", Field: field, Args: nil, IsMethod: false, @@ -10608,21 +7032,24 @@ func (ec *executionContext) _User_languages(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.Languages, nil + return obj.Name, 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.Language) + res := resTmp.(string) fc.Result = res - return ec.marshalOLanguage2ᚕgithubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_lastSuccessfulLogin(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _RoleOutput_description(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10630,7 +7057,7 @@ func (ec *executionContext) _User_lastSuccessfulLogin(ctx context.Context, field } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "RoleOutput", Field: field, Args: nil, IsMethod: false, @@ -10640,21 +7067,24 @@ func (ec *executionContext) _User_lastSuccessfulLogin(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.LastSuccessfulLogin, nil + return obj.Description, 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.(*time.Time) + res := resTmp.(string) fc.Result = res - return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_lastFailedLogin(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _RoleOutput_active(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10662,7 +7092,7 @@ func (ec *executionContext) _User_lastFailedLogin(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "RoleOutput", Field: field, Args: nil, IsMethod: false, @@ -10672,21 +7102,24 @@ func (ec *executionContext) _User_lastFailedLogin(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.LastFailedLogin, 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.(*time.Time) + res := resTmp.(bool) fc.Result = res - return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _User_failedLoginCount(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _RoleOutput_scopes(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10694,7 +7127,7 @@ func (ec *executionContext) _User_failedLoginCount(ctx context.Context, field gr } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "RoleOutput", Field: field, Args: nil, IsMethod: false, @@ -10704,24 +7137,21 @@ func (ec *executionContext) _User_failedLoginCount(ctx context.Context, field gr 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.FailedLoginCount, nil + return obj.Scopes, 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) _User_nextAllowedLogin(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _RoleOutput_permissions(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10729,7 +7159,7 @@ func (ec *executionContext) _User_nextAllowedLogin(ctx context.Context, field gr } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "RoleOutput", Field: field, Args: nil, IsMethod: false, @@ -10739,7 +7169,7 @@ func (ec *executionContext) _User_nextAllowedLogin(ctx context.Context, field gr 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.NextAllowedLogin, nil + return obj.Permissions, nil }) if err != nil { ec.Error(ctx, err) @@ -10748,12 +7178,12 @@ func (ec *executionContext) _User_nextAllowedLogin(ctx context.Context, field gr if resTmp == nil { return graphql.Null } - res := resTmp.(*time.Time) + res := resTmp.([]profileutils.Permission) fc.Result = res - return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) + return ec.marshalOPermission2ᚕgithubᚗcomᚋsavannahghiᚋprofileutilsᚐPermission(ctx, field.Selections, res) } -func (ec *executionContext) _User_termsAccepted(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _RoleOutput_users(ctx context.Context, field graphql.CollectedField, obj *dto.RoleOutput) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10761,7 +7191,7 @@ func (ec *executionContext) _User_termsAccepted(ctx context.Context, field graph } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "RoleOutput", Field: field, Args: nil, IsMethod: false, @@ -10771,7 +7201,7 @@ func (ec *executionContext) _User_termsAccepted(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.TermsAccepted, nil + return obj.Users, nil }) if err != nil { ec.Error(ctx, err) @@ -10780,12 +7210,12 @@ func (ec *executionContext) _User_termsAccepted(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]*profileutils.UserProfile) fc.Result = res - return ec.marshalOBoolean2bool(ctx, field.Selections, res) + return ec.marshalOUserProfile2ᚕᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx, field.Selections, res) } -func (ec *executionContext) _User_acceptedTermsID(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _ThinAddress_latitude(ctx context.Context, field graphql.CollectedField, obj *domain.ThinAddress) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10793,7 +7223,7 @@ func (ec *executionContext) _User_acceptedTermsID(ctx context.Context, field gra } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "ThinAddress", Field: field, Args: nil, IsMethod: false, @@ -10803,21 +7233,24 @@ func (ec *executionContext) _User_acceptedTermsID(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.AcceptedTermsID, nil + return obj.Latitude, 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.(float64) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) _User_flavour(ctx context.Context, field graphql.CollectedField, obj *domain1.User) (ret graphql.Marshaler) { +func (ec *executionContext) _ThinAddress_longitude(ctx context.Context, field graphql.CollectedField, obj *domain.ThinAddress) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10825,7 +7258,7 @@ func (ec *executionContext) _User_flavour(ctx context.Context, field graphql.Col } }() fc := &graphql.FieldContext{ - Object: "User", + Object: "ThinAddress", Field: field, Args: nil, IsMethod: false, @@ -10835,7 +7268,7 @@ func (ec *executionContext) _User_flavour(ctx context.Context, field graphql.Col 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.Flavour, nil + return obj.Longitude, nil }) if err != nil { ec.Error(ctx, err) @@ -10847,9 +7280,9 @@ func (ec *executionContext) _User_flavour(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(feedlib.Flavour) + res := resTmp.(float64) fc.Result = res - return ec.marshalNFlavour2githubᚗcomᚋsavannahghiᚋfeedlibᚐFlavour(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _UserAddresses_homeAddress(ctx context.Context, field graphql.CollectedField, obj *domain.UserAddresses) (ret graphql.Marshaler) { @@ -12941,130 +9374,6 @@ 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{}) - - for k, v := range asMap { - switch k { - case "clientType": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clientType")) - it.ClientType, err = ec.unmarshalNClientType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐClientType(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputContactInput(ctx context.Context, obj interface{}) (dto1.ContactInput, error) { - var it dto1.ContactInput - 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.unmarshalNContactType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐContactType(ctx, v) - if err != nil { - return it, err - } - case "Contact": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Contact")) - it.Contact, err = ec.unmarshalNString2string(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 - } - case "OptedIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("OptedIn")) - it.OptedIn, err = ec.unmarshalNBoolean2bool(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - func (ec *executionContext) unmarshalInputFacilityInput(ctx context.Context, obj interface{}) (dto1.FacilityInput, error) { var it dto1.FacilityInput var asMap = obj.(map[string]interface{}) @@ -13269,42 +9578,6 @@ func (ec *executionContext) unmarshalInputPaginationInput(ctx context.Context, o return it, nil } -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 "Pin": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Pin")) - it.PIN, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "confirmedPin": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("confirmedPin")) - it.ConfirmedPin, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "flavour": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("flavour")) - it.Flavour, err = ec.unmarshalNFlavour2githubᚗcomᚋsavannahghiᚋfeedlibᚐFlavour(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - func (ec *executionContext) unmarshalInputPostVisitSurveyInput(ctx context.Context, obj interface{}) (dto.PostVisitSurveyInput, error) { var it dto.PostVisitSurveyInput var asMap = obj.(map[string]interface{}) @@ -13466,216 +9739,80 @@ func (ec *executionContext) unmarshalInputSortParam(ctx context.Context, obj int var asMap = obj.(map[string]interface{}) for k, v := range asMap { - switch k { - case "fieldName": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fieldName")) - it.FieldName, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "sortOrder": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortOrder")) - it.SortOrder, err = ec.unmarshalNSortOrder2githubᚗcomᚋsavannahghiᚋenumutilsᚐSortOrder(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputStaffProfileInput(ctx context.Context, obj interface{}) (dto1.StaffProfileInput, error) { - var it dto1.StaffProfileInput - var asMap = obj.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "staffNumber": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("staffNumber")) - it.StaffNumber, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "defaultFacilityID": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("defaultFacilityID")) - it.DefaultFacilityID, err = ec.unmarshalNString2ᚖstring(ctx, v) - 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 - } - case "roles": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("roles")) - it.Roles, err = ec.unmarshalORolesType2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputUserAddressInput(ctx context.Context, obj interface{}) (dto.UserAddressInput, error) { - var it dto.UserAddressInput - var asMap = obj.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "latitude": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("latitude")) - it.Latitude, err = ec.unmarshalNFloat2float64(ctx, v) - if err != nil { - return it, err - } - case "longitude": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("longitude")) - it.Longitude, err = ec.unmarshalNFloat2float64(ctx, v) - if err != nil { - return it, err - } - case "locality": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("locality")) - it.Locality, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "name": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "placeID": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("placeID")) - it.PlaceID, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "formattedAddress": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("formattedAddress")) - it.FormattedAddress, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputUserInput(ctx context.Context, obj interface{}) (dto1.UserInput, error) { - var it dto1.UserInput - var asMap = obj.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "username": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - it.Username, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "displayName": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("displayName")) - it.DisplayName, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "firstName": + switch k { + case "fieldName": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstName")) - it.FirstName, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fieldName")) + it.FieldName, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - case "middleName": + case "sortOrder": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("middleName")) - it.MiddleName, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortOrder")) + it.SortOrder, err = ec.unmarshalNSortOrder2githubᚗcomᚋsavannahghiᚋenumutilsᚐSortOrder(ctx, v) if err != nil { return it, err } - case "lastName": + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputUserAddressInput(ctx context.Context, obj interface{}) (dto.UserAddressInput, error) { + var it dto.UserAddressInput + var asMap = obj.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "latitude": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastName")) - it.LastName, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("latitude")) + it.Latitude, err = ec.unmarshalNFloat2float64(ctx, v) if err != nil { return it, err } - case "userType": + case "longitude": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userType")) - it.UserType, err = ec.unmarshalNUsersType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐUsersType(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("longitude")) + it.Longitude, err = ec.unmarshalNFloat2float64(ctx, v) if err != nil { return it, err } - case "gender": + case "locality": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gender")) - it.Gender, err = ec.unmarshalNGender2githubᚗcomᚋsavannahghiᚋenumutilsᚐGender(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("locality")) + it.Locality, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "contacts": + case "name": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("contacts")) - it.Contacts, err = ec.unmarshalNContactInput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐContactInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "languages": + case "placeID": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("languages")) - it.Languages, err = ec.unmarshalNLanguage2ᚕgithubᚗcomᚋsavannahghiᚋenumutilsᚐLanguageᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("placeID")) + it.PlaceID, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "flavour": + case "formattedAddress": 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("formattedAddress")) + it.FormattedAddress, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } @@ -13808,63 +9945,6 @@ 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 { @@ -13895,133 +9975,6 @@ func (ec *executionContext) _BioData(ctx context.Context, sel ast.SelectionSet, return out } -var clientProfileImplementors = []string{"ClientProfile"} - -func (ec *executionContext) _ClientProfile(ctx context.Context, sel ast.SelectionSet, obj *domain1.ClientProfile) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, clientProfileImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ClientProfile") - case "id": - out.Values[i] = ec._ClientProfile_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "userID": - out.Values[i] = ec._ClientProfile_userID(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "clientType": - out.Values[i] = ec._ClientProfile_clientType(ctx, field, obj) - case "active": - out.Values[i] = ec._ClientProfile_active(ctx, field, obj) - case "treatmentEnrollmentDate": - out.Values[i] = ec._ClientProfile_treatmentEnrollmentDate(ctx, field, obj) - case "healthRecordID": - out.Values[i] = ec._ClientProfile_healthRecordID(ctx, field, obj) - case "facilityID": - out.Values[i] = ec._ClientProfile_facilityID(ctx, field, obj) - case "treatmentBuddyUserID": - out.Values[i] = ec._ClientProfile_treatmentBuddyUserID(ctx, field, obj) - case "chvUserID": - out.Values[i] = ec._ClientProfile_chvUserID(ctx, field, obj) - case "clientCounselled": - out.Values[i] = ec._ClientProfile_clientCounselled(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var clientUserProfileImplementors = []string{"ClientUserProfile"} - -func (ec *executionContext) _ClientUserProfile(ctx context.Context, sel ast.SelectionSet, obj *domain1.ClientUserProfile) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, clientUserProfileImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ClientUserProfile") - case "user": - out.Values[i] = ec._ClientUserProfile_user(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "client": - out.Values[i] = ec._ClientUserProfile_client(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 contactImplementors = []string{"Contact"} - -func (ec *executionContext) _Contact(ctx context.Context, sel ast.SelectionSet, obj *domain1.Contact) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, contactImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Contact") - case "ID": - out.Values[i] = ec._Contact_ID(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "Type": - out.Values[i] = ec._Contact_Type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "Contact": - out.Values[i] = ec._Contact_Contact(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "Active": - out.Values[i] = ec._Contact_Active(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "OptedIn": - out.Values[i] = ec._Contact_OptedIn(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 coverImplementors = []string{"Cover"} func (ec *executionContext) _Cover(ctx context.Context, sel ast.SelectionSet, obj *profileutils.Cover) graphql.Marshaler { @@ -14196,69 +10149,6 @@ func (ec *executionContext) _GroupedNavigationActions(ctx context.Context, sel a return out } -var identifierImplementors = []string{"Identifier"} - -func (ec *executionContext) _Identifier(ctx context.Context, sel ast.SelectionSet, obj *domain1.Identifier) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, identifierImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Identifier") - case "id": - out.Values[i] = ec._Identifier_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "clientID": - out.Values[i] = ec._Identifier_clientID(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "identifierType": - out.Values[i] = ec._Identifier_identifierType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "identifierUse": - out.Values[i] = ec._Identifier_identifierUse(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "identifierValue": - out.Values[i] = ec._Identifier_identifierValue(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - out.Values[i] = ec._Identifier_description(ctx, field, obj) - case "validFrom": - out.Values[i] = ec._Identifier_validFrom(ctx, field, obj) - case "validTo": - out.Values[i] = ec._Identifier_validTo(ctx, field, obj) - case "active": - out.Values[i] = ec._Identifier_active(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "isPrimaryIdentifier": - out.Values[i] = ec._Identifier_isPrimaryIdentifier(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 linkImplementors = []string{"Link"} func (ec *executionContext) _Link(ctx context.Context, sel ast.SelectionSet, obj *feedlib.Link) graphql.Marshaler { @@ -14350,26 +10240,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") - case "registerClientUser": - out.Values[i] = ec._Mutation_registerClientUser(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "addIdentifier": - out.Values[i] = ec._Mutation_addIdentifier(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "inviteClient": - out.Values[i] = ec._Mutation_inviteClient(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "transferClient": - out.Values[i] = ec._Mutation_transferClient(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } case "createFacility": out.Values[i] = ec._Mutation_createFacility(ctx, field) if out.Values[i] == graphql.Null { @@ -14380,20 +10250,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { invalids++ } - case "setUserPIN": - out.Values[i] = ec._Mutation_setUserPIN(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "testMutation": - out.Values[i] = ec._Mutation_testMutation(ctx, field) - case "registerStaffUser": - out.Values[i] = ec._Mutation_registerStaffUser(ctx, field) - case "updateStaffUserProfile": - out.Values[i] = ec._Mutation_updateStaffUserProfile(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } case "completeSignup": out.Values[i] = ec._Mutation_completeSignup(ctx, field) if out.Values[i] == graphql.Null { @@ -14755,48 +10611,6 @@ 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 { @@ -14848,17 +10662,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) - case "testQuery": - 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._Query_testQuery(ctx, field) - return res - }) case "dummyQuery": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -15114,84 +10917,6 @@ func (ec *executionContext) _RoleOutput(ctx context.Context, sel ast.SelectionSe return out } -var staffProfileImplementors = []string{"StaffProfile"} - -func (ec *executionContext) _StaffProfile(ctx context.Context, sel ast.SelectionSet, obj *domain1.StaffProfile) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, staffProfileImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("StaffProfile") - case "id": - out.Values[i] = ec._StaffProfile_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "userID": - out.Values[i] = ec._StaffProfile_userID(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "staffNumber": - out.Values[i] = ec._StaffProfile_staffNumber(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "defaultFacilityID": - out.Values[i] = ec._StaffProfile_defaultFacilityID(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "addresses": - out.Values[i] = ec._StaffProfile_addresses(ctx, field, obj) - case "roles": - out.Values[i] = ec._StaffProfile_roles(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var staffUserProfileImplementors = []string{"StaffUserProfile"} - -func (ec *executionContext) _StaffUserProfile(ctx context.Context, sel ast.SelectionSet, obj *domain1.StaffUserProfile) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, staffUserProfileImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("StaffUserProfile") - case "user": - out.Values[i] = ec._StaffUserProfile_user(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "staff": - out.Values[i] = ec._StaffUserProfile_staff(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 thinAddressImplementors = []string{"ThinAddress"} func (ec *executionContext) _ThinAddress(ctx context.Context, sel ast.SelectionSet, obj *domain.ThinAddress) graphql.Marshaler { @@ -15224,76 +10949,6 @@ func (ec *executionContext) _ThinAddress(ctx context.Context, sel ast.SelectionS return out } -var userImplementors = []string{"User"} - -func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *domain1.User) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("User") - case "id": - out.Values[i] = ec._User_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "username": - out.Values[i] = ec._User_username(ctx, field, obj) - case "displayName": - out.Values[i] = ec._User_displayName(ctx, field, obj) - case "middleName": - out.Values[i] = ec._User_middleName(ctx, field, obj) - case "firstName": - out.Values[i] = ec._User_firstName(ctx, field, obj) - case "lastName": - out.Values[i] = ec._User_lastName(ctx, field, obj) - case "gender": - out.Values[i] = ec._User_gender(ctx, field, obj) - case "userType": - out.Values[i] = ec._User_userType(ctx, field, obj) - case "active": - out.Values[i] = ec._User_active(ctx, field, obj) - case "contacts": - out.Values[i] = ec._User_contacts(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "languages": - out.Values[i] = ec._User_languages(ctx, field, obj) - case "lastSuccessfulLogin": - out.Values[i] = ec._User_lastSuccessfulLogin(ctx, field, obj) - case "lastFailedLogin": - out.Values[i] = ec._User_lastFailedLogin(ctx, field, obj) - case "failedLoginCount": - out.Values[i] = ec._User_failedLoginCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "nextAllowedLogin": - out.Values[i] = ec._User_nextAllowedLogin(ctx, field, obj) - case "termsAccepted": - out.Values[i] = ec._User_termsAccepted(ctx, field, obj) - case "acceptedTermsID": - out.Values[i] = ec._User_acceptedTermsID(ctx, field, obj) - case "flavour": - out.Values[i] = ec._User_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 userAddressesImplementors = []string{"UserAddresses"} func (ec *executionContext) _UserAddresses(ctx context.Context, sel ast.SelectionSet, obj *domain.UserAddresses) graphql.Marshaler { @@ -15773,248 +11428,60 @@ func (ec *executionContext) marshalNAddress2githubᚗcomᚋsavannahghiᚋprofile return ec._Address(ctx, sel, &v) } -func (ec *executionContext) marshalNAddress2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐAddress(ctx context.Context, sel ast.SelectionSet, v *profileutils.Address) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._Address(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNAddressType2githubᚗcomᚋsavannahghiᚋenumutilsᚐAddressType(ctx context.Context, v interface{}) (enumutils.AddressType, error) { - var res enumutils.AddressType - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNAddressType2githubᚗcomᚋsavannahghiᚋenumutilsᚐAddressType(ctx context.Context, sel ast.SelectionSet, v enumutils.AddressType) graphql.Marshaler { - 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) -} - -func (ec *executionContext) marshalNAny2interface(ctx context.Context, sel ast.SelectionSet, v interface{}) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := graphql.MarshalAny(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) marshalNClientProfile2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐClientProfile(ctx context.Context, sel ast.SelectionSet, v *domain1.ClientProfile) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._ClientProfile(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNClientProfileInput2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐClientProfileInput(ctx context.Context, v interface{}) (dto1.ClientProfileInput, error) { - res, err := ec.unmarshalInputClientProfileInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNClientType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐClientType(ctx context.Context, v interface{}) (enums.ClientType, error) { - var res enums.ClientType - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNClientType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐClientType(ctx context.Context, sel ast.SelectionSet, v enums.ClientType) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalNClientUserProfile2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐClientUserProfile(ctx context.Context, sel ast.SelectionSet, v domain1.ClientUserProfile) graphql.Marshaler { - return ec._ClientUserProfile(ctx, sel, &v) -} - -func (ec *executionContext) marshalNClientUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐClientUserProfile(ctx context.Context, sel ast.SelectionSet, v *domain1.ClientUserProfile) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._ClientUserProfile(ctx, sel, v) -} - -func (ec *executionContext) marshalNContact2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐContactᚄ(ctx context.Context, sel ast.SelectionSet, v []*domain1.Contact) graphql.Marshaler { - 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.marshalNContact2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐContact(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - return ret -} - -func (ec *executionContext) marshalNContact2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐContact(ctx context.Context, sel ast.SelectionSet, v *domain1.Contact) graphql.Marshaler { +func (ec *executionContext) marshalNAddress2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐAddress(ctx context.Context, sel ast.SelectionSet, v *profileutils.Address) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } - return ec._Contact(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNContactInput2ᚕᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐContactInputᚄ(ctx context.Context, v interface{}) ([]*dto1.ContactInput, 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.ContactInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNContactInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐContactInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalNContactInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐContactInput(ctx context.Context, v interface{}) (*dto1.ContactInput, error) { - res, err := ec.unmarshalInputContactInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) + return ec._Address(ctx, sel, v) } -func (ec *executionContext) unmarshalNContactType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐContactType(ctx context.Context, v interface{}) (enums.ContactType, error) { - var res enums.ContactType +func (ec *executionContext) unmarshalNAddressType2githubᚗcomᚋsavannahghiᚋenumutilsᚐAddressType(ctx context.Context, v interface{}) (enumutils.AddressType, error) { + var res enumutils.AddressType err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNContactType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐContactType(ctx context.Context, sel ast.SelectionSet, v enums.ContactType) graphql.Marshaler { +func (ec *executionContext) marshalNAddressType2githubᚗcomᚋsavannahghiᚋenumutilsᚐAddressType(ctx context.Context, sel ast.SelectionSet, v enumutils.AddressType) graphql.Marshaler { 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) +func (ec *executionContext) unmarshalNAny2interface(ctx context.Context, v interface{}) (interface{}, error) { + res, err := graphql.UnmarshalAny(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) marshalNAny2interface(ctx context.Context, sel ast.SelectionSet, v interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := graphql.MarshalAny(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + } + return res } -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) +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { + res, err := graphql.UnmarshalBoolean(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) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + res := graphql.MarshalBoolean(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + } + return res } func (ec *executionContext) unmarshalNDate2githubᚗcomᚋsavannahghiᚋscalarutilsᚐDate(ctx context.Context, v interface{}) (scalarutils.Date, error) { @@ -16097,16 +11564,6 @@ func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.S return res } -func (ec *executionContext) unmarshalNGender2githubᚗcomᚋsavannahghiᚋenumutilsᚐGender(ctx context.Context, v interface{}) (enumutils.Gender, error) { - var res enumutils.Gender - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNGender2githubᚗcomᚋsavannahghiᚋenumutilsᚐGender(ctx context.Context, sel ast.SelectionSet, v enumutils.Gender) graphql.Marshaler { - return v -} - func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalID(v) return res, graphql.ErrorOnPath(ctx, err) @@ -16152,40 +11609,6 @@ func (ec *executionContext) marshalNID2ᚕstringᚄ(ctx context.Context, sel ast return ret } -func (ec *executionContext) marshalNIdentifier2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐIdentifier(ctx context.Context, sel ast.SelectionSet, v domain1.Identifier) graphql.Marshaler { - return ec._Identifier(ctx, sel, &v) -} - -func (ec *executionContext) marshalNIdentifier2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐIdentifier(ctx context.Context, sel ast.SelectionSet, v *domain1.Identifier) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._Identifier(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNIdentifierType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐIdentifierType(ctx context.Context, v interface{}) (enums.IdentifierType, error) { - var res enums.IdentifierType - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNIdentifierType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐIdentifierType(ctx context.Context, sel ast.SelectionSet, v enums.IdentifierType) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalNIdentifierUse2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐIdentifierUse(ctx context.Context, v interface{}) (enums.IdentifierUse, error) { - var res enums.IdentifierUse - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNIdentifierUse2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐIdentifierUse(ctx context.Context, sel ast.SelectionSet, v enums.IdentifierUse) graphql.Marshaler { - return v -} - func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { res, err := graphql.UnmarshalInt(v) return res, graphql.ErrorOnPath(ctx, err) @@ -16201,74 +11624,6 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } -func (ec *executionContext) unmarshalNLanguage2githubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx context.Context, v interface{}) (enumutils.Language, error) { - var res enumutils.Language - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNLanguage2githubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx context.Context, sel ast.SelectionSet, v enumutils.Language) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalNLanguage2ᚕgithubᚗcomᚋsavannahghiᚋenumutilsᚐLanguageᚄ(ctx context.Context, v interface{}) ([]enumutils.Language, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } - } - var err error - res := make([]enumutils.Language, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNLanguage2githubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalNLanguage2ᚕgithubᚗcomᚋsavannahghiᚋenumutilsᚐLanguageᚄ(ctx context.Context, sel ast.SelectionSet, v []enumutils.Language) graphql.Marshaler { - 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.marshalNLanguage2githubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - return ret -} - func (ec *executionContext) unmarshalNLoginProviderType2githubᚗcomᚋsavannahghiᚋprofileutilsᚐLoginProviderType(ctx context.Context, v interface{}) (profileutils.LoginProviderType, error) { tmp, err := graphql.UnmarshalString(v) res := profileutils.LoginProviderType(tmp) @@ -16467,22 +11822,6 @@ func (ec *executionContext) unmarshalNRolePermissionInput2githubᚗcomᚋsavanna return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNRolesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx context.Context, v interface{}) (enums.RolesType, error) { - tmp, err := graphql.UnmarshalString(v) - res := enums.RolesType(tmp) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNRolesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx context.Context, sel ast.SelectionSet, v enums.RolesType) graphql.Marshaler { - res := graphql.MarshalString(string(v)) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - func (ec *executionContext) unmarshalNSortOrder2githubᚗcomᚋsavannahghiᚋenumutilsᚐSortOrder(ctx context.Context, v interface{}) (enumutils.SortOrder, error) { var res enumutils.SortOrder err := res.UnmarshalGQL(v) @@ -16493,21 +11832,6 @@ func (ec *executionContext) marshalNSortOrder2githubᚗcomᚋsavannahghiᚋenumu return v } -func (ec *executionContext) marshalNStaffProfile2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐStaffProfile(ctx context.Context, sel ast.SelectionSet, v *domain1.StaffProfile) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._StaffProfile(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNStaffProfileInput2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐStaffProfileInput(ctx context.Context, v interface{}) (dto1.StaffProfileInput, error) { - res, err := ec.unmarshalInputStaffProfileInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) @@ -16578,26 +11902,6 @@ func (ec *executionContext) marshalNThinAddress2githubᚗcomᚋsavannahghiᚋonb return ec._ThinAddress(ctx, sel, &v) } -func (ec *executionContext) unmarshalNTransferReason2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐTransferReason(ctx context.Context, v interface{}) (enums.TransferReason, error) { - var res enums.TransferReason - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNTransferReason2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐTransferReason(ctx context.Context, sel ast.SelectionSet, v enums.TransferReason) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐUser(ctx context.Context, sel ast.SelectionSet, v *domain1.User) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._User(ctx, sel, v) -} - func (ec *executionContext) unmarshalNUserAddressInput2githubᚗcomᚋsavannahghiᚋonboardingᚋpkgᚋonboardingᚋapplicationᚋdtoᚐUserAddressInput(ctx context.Context, v interface{}) (dto.UserAddressInput, error) { res, err := ec.unmarshalInputUserAddressInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -16631,11 +11935,6 @@ func (ec *executionContext) marshalNUserCommunicationsSetting2ᚖgithubᚗcomᚋ return ec._UserCommunicationsSetting(ctx, sel, v) } -func (ec *executionContext) unmarshalNUserInput2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐUserInput(ctx context.Context, v interface{}) (dto1.UserInput, error) { - res, err := ec.unmarshalInputUserInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) marshalNUserProfile2githubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx context.Context, sel ast.SelectionSet, v profileutils.UserProfile) graphql.Marshaler { return ec._UserProfile(ctx, sel, &v) } @@ -16655,22 +11954,6 @@ func (ec *executionContext) unmarshalNUserProfileInput2githubᚗcomᚋsavannahgh return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNUsersType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐUsersType(ctx context.Context, v interface{}) (enums.UsersType, error) { - tmp, err := graphql.UnmarshalString(v) - res := enums.UsersType(tmp) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNUsersType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐUsersType(ctx context.Context, sel ast.SelectionSet, v enums.UsersType) graphql.Marshaler { - res := graphql.MarshalString(string(v)) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { res, err := graphql.UnmarshalMap(v) return res, graphql.ErrorOnPath(ctx, err) @@ -16992,66 +12275,26 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) marshalOAddress2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐAddress(ctx context.Context, sel ast.SelectionSet, v *profileutils.Address) graphql.Marshaler { - if v == nil { - return graphql.Null - } - 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) +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") } + } + return res +} +func (ec *executionContext) marshalOAddress2ᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐAddress(ctx context.Context, sel ast.SelectionSet, v *profileutils.Address) graphql.Marshaler { + if v == nil { + return graphql.Null } - wg.Wait() - return ret + return ec._Address(ctx, sel, v) } func (ec *executionContext) unmarshalOAny2interface(ctx context.Context, v interface{}) (interface{}, error) { @@ -17133,16 +12376,6 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return graphql.MarshalBoolean(*v) } -func (ec *executionContext) unmarshalOClientType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐClientType(ctx context.Context, v interface{}) (enums.ClientType, error) { - var res enums.ClientType - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOClientType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐClientType(ctx context.Context, sel ast.SelectionSet, v enums.ClientType) graphql.Marshaler { - return v -} - func (ec *executionContext) marshalOCover2githubᚗcomᚋsavannahghiᚋprofileutilsᚐCover(ctx context.Context, sel ast.SelectionSet, v profileutils.Cover) graphql.Marshaler { return ec._Cover(ctx, sel, &v) } @@ -17369,80 +12602,6 @@ func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.Selecti return graphql.MarshalInt(v) } -func (ec *executionContext) unmarshalOLanguage2githubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx context.Context, v interface{}) (enumutils.Language, error) { - var res enumutils.Language - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOLanguage2githubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx context.Context, sel ast.SelectionSet, v enumutils.Language) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalOLanguage2ᚕgithubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx context.Context, v interface{}) ([]enumutils.Language, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } - } - var err error - res := make([]enumutils.Language, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalOLanguage2githubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOLanguage2ᚕgithubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx context.Context, sel ast.SelectionSet, v []enumutils.Language) 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.marshalOLanguage2githubᚗcomᚋsavannahghiᚋenumutilsᚐLanguage(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - return ret -} - func (ec *executionContext) marshalOLink2githubᚗcomᚋsavannahghiᚋfeedlibᚐLink(ctx context.Context, sel ast.SelectionSet, v feedlib.Link) graphql.Marshaler { return ec._Link(ctx, sel, &v) } @@ -17704,14 +12863,6 @@ 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 @@ -17759,144 +12910,6 @@ func (ec *executionContext) marshalORoleOutput2ᚖgithubᚗcomᚋsavannahghiᚋo return ec._RoleOutput(ctx, sel, v) } -func (ec *executionContext) unmarshalORolesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx context.Context, v interface{}) (enums.RolesType, error) { - tmp, err := graphql.UnmarshalString(v) - res := enums.RolesType(tmp) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalORolesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx context.Context, sel ast.SelectionSet, v enums.RolesType) graphql.Marshaler { - return graphql.MarshalString(string(v)) -} - -func (ec *executionContext) unmarshalORolesType2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx context.Context, v interface{}) ([]enums.RolesType, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } - } - var err error - res := make([]enums.RolesType, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalORolesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalORolesType2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx context.Context, sel ast.SelectionSet, v []enums.RolesType) 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.marshalORolesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - return ret -} - -func (ec *executionContext) unmarshalORolesType2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesTypeᚄ(ctx context.Context, v interface{}) ([]enums.RolesType, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } - } - var err error - res := make([]enums.RolesType, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNRolesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalORolesType2ᚕgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []enums.RolesType) 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.marshalNRolesType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐRolesType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - return ret -} - func (ec *executionContext) unmarshalOSortParam2ᚕᚖgithubᚗcomᚋsavannahghiᚋfirebasetoolsᚐSortParam(ctx context.Context, v interface{}) ([]*firebasetools.SortParam, error) { if v == nil { return nil, nil @@ -17929,21 +12942,6 @@ func (ec *executionContext) unmarshalOSortParam2ᚖgithubᚗcomᚋsavannahghiᚋ return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalOStaffProfileInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐStaffProfileInput(ctx context.Context, v interface{}) (*dto1.StaffProfileInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputStaffProfileInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOStaffUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋdomainᚐStaffUserProfile(ctx context.Context, sel ast.SelectionSet, v *domain1.StaffUserProfile) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._StaffUserProfile(ctx, sel, v) -} - func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) @@ -18040,29 +13038,6 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return graphql.MarshalString(*v) } -func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalTime(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return graphql.MarshalTime(*v) -} - -func (ec *executionContext) unmarshalOUserInput2ᚖgithubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋdtoᚐUserInput(ctx context.Context, v interface{}) (*dto1.UserInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputUserInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) marshalOUserProfile2ᚕᚖgithubᚗcomᚋsavannahghiᚋprofileutilsᚐUserProfile(ctx context.Context, sel ast.SelectionSet, v []*profileutils.UserProfile) graphql.Marshaler { if v == nil { return graphql.Null @@ -18110,16 +13085,6 @@ func (ec *executionContext) marshalOUserProfile2ᚖgithubᚗcomᚋsavannahghiᚋ return ec._UserProfile(ctx, sel, v) } -func (ec *executionContext) unmarshalOUsersType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐUsersType(ctx context.Context, v interface{}) (enums.UsersType, error) { - tmp, err := graphql.UnmarshalString(v) - res := enums.UsersType(tmp) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOUsersType2githubᚗcomᚋsavannahghiᚋonboardingᚑserviceᚋpkgᚋonboardingᚋapplicationᚋenumsᚐUsersType(ctx context.Context, sel ast.SelectionSet, v enums.UsersType) graphql.Marshaler { - return graphql.MarshalString(string(v)) -} - func (ec *executionContext) marshalOVerifiedIdentifier2githubᚗcomᚋsavannahghiᚋprofileutilsᚐVerifiedIdentifier(ctx context.Context, sel ast.SelectionSet, v profileutils.VerifiedIdentifier) graphql.Marshaler { return ec._VerifiedIdentifier(ctx, sel, &v) } diff --git a/pkg/onboarding/presentation/graph/input.graphql b/pkg/onboarding/presentation/graph/input.graphql index bbc49c22..94d2a39c 100644 --- a/pkg/onboarding/presentation/graph/input.graphql +++ b/pkg/onboarding/presentation/graph/input.graphql @@ -6,53 +6,3 @@ input FacilityInput { description: String! } -input PinInput { - Pin: String! - confirmedPin: String! - flavour: Flavour! -} - - -input UserInput { - username: String! - displayName: String! - firstName: String! - middleName: String! - lastName: String! - userType: UsersType! - gender: Gender! - contacts: [ContactInput!]! - languages: [Language!]! - flavour: Flavour! -} - -input StaffProfileInput { - staffNumber: String! - # facilities: [FacilityInput!] - defaultFacilityID: String! - addresses: [AddressesInput!]! - roles: [RolesType] # TODO: roles are an enum (controlled list), known to both FE and BE -} - -input ContactInput { - Type: ContactType! - Contact: String! #TODO Validate: phones are E164, emails are valid - 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! -} - - -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/profile.graphql b/pkg/onboarding/presentation/graph/profile.graphql deleted file mode 100644 index ae998378..00000000 --- a/pkg/onboarding/presentation/graph/profile.graphql +++ /dev/null @@ -1,7 +0,0 @@ -extend type Query { - testQuery: Boolean -} - -extend type Mutation { - testMutation: Boolean -} diff --git a/pkg/onboarding/presentation/graph/profile.resolvers.go b/pkg/onboarding/presentation/graph/profile.resolvers.go deleted file mode 100644 index 23fcf47b..00000000 --- a/pkg/onboarding/presentation/graph/profile.resolvers.go +++ /dev/null @@ -1,17 +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" -) - -func (r *mutationResolver) TestMutation(ctx context.Context) (*bool, error) { - panic(fmt.Errorf("not implemented")) -} - -func (r *queryResolver) TestQuery(ctx context.Context) (*bool, error) { - panic(fmt.Errorf("not implemented")) -} diff --git a/pkg/onboarding/presentation/graph/staff.graphql b/pkg/onboarding/presentation/graph/staff.graphql deleted file mode 100644 index e31a523e..00000000 --- a/pkg/onboarding/presentation/graph/staff.graphql +++ /dev/null @@ -1,4 +0,0 @@ -extend type Mutation { - registerStaffUser(userInput: UserInput!, staffInput: StaffProfileInput!) :StaffUserProfile - updateStaffUserProfile(userID: String!, userInput: UserInput, staffInput: StaffProfileInput): Boolean! -} \ No newline at end of file diff --git a/pkg/onboarding/presentation/graph/staff.resolvers.go b/pkg/onboarding/presentation/graph/staff.resolvers.go deleted file mode 100644 index e61cf810..00000000 --- a/pkg/onboarding/presentation/graph/staff.resolvers.go +++ /dev/null @@ -1,19 +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" - - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" -) - -func (r *mutationResolver) RegisterStaffUser(ctx context.Context, userInput dto.UserInput, staffInput dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - return r.interactor.StaffUsecase.RegisterStaffUser(ctx, &userInput, &staffInput) -} - -func (r *mutationResolver) UpdateStaffUserProfile(ctx context.Context, userID string, userInput *dto.UserInput, staffInput *dto.StaffProfileInput) (bool, error) { - return r.interactor.StaffUsecase.UpdateStaffUserProfile(ctx, userID, userInput, staffInput) -} diff --git a/pkg/onboarding/presentation/graph/types.graphql b/pkg/onboarding/presentation/graph/types.graphql index 7653158a..1a95aa84 100644 --- a/pkg/onboarding/presentation/graph/types.graphql +++ b/pkg/onboarding/presentation/graph/types.graphql @@ -5,99 +5,4 @@ type Facility { active: Boolean! county: String! description: String! -} - -type Pin { - userID: String! - Pin: String! - confirmedPin: String! - flavour: Flavour! -} - -type User { - id: String! - username: String - displayName: String - middleName: String - firstName: String - lastName: String - gender: Gender - userType: UsersType - active: Boolean - contacts: [Contact!]! - languages: [Language] - # pushTokens: [String!] - lastSuccessfulLogin: Time - lastFailedLogin: Time - failedLoginCount: String! - nextAllowedLogin: Time - termsAccepted: Boolean - acceptedTermsID: String - flavour: Flavour! -} - -type Contact { - ID: String! - Type: ContactType! - Contact: String! #TODO Validate: phones are E164, emails are valid - 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! -} - -type StaffProfile { - id: String! - userID: String! - staffNumber: String! - # facilities: [Facility!] - defaultFacilityID: String! - addresses: [Addresses!] - roles: [RolesType!] -} - -type StaffUserProfile { - user: User! - staff: StaffProfile! -} - -type ClientProfile { - id: String! - userID: String! - clientType: ClientType - active: Boolean - treatmentEnrollmentDate: Time - healthRecordID: String - facilityID: String - treatmentBuddyUserID: String - chvUserID: String - clientCounselled: Boolean -} - -type ClientUserProfile { - user: User! - client: ClientProfile! -} - -type Identifier { - id: String! - clientID: String! - identifierType: IdentifierType! - identifierUse: IdentifierUse! - identifierValue: String! - description: String - validFrom: Time - validTo: Time - active: Boolean! - isPrimaryIdentifier: Boolean! -} - -type Addresses { - ID: String! - Type: AddressesType! - Text: String! - Country: CountryType! - PostalCode: String! - County: CountyType! - Active: Boolean! -} +} \ No newline at end of file diff --git a/pkg/onboarding/presentation/interactor/interactor.go b/pkg/onboarding/presentation/interactor/interactor.go index 788ea29a..193fbbd7 100644 --- a/pkg/onboarding/presentation/interactor/interactor.go +++ b/pkg/onboarding/presentation/interactor/interactor.go @@ -4,46 +4,26 @@ package interactor import ( pg "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/client" "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/facility" - metrics "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/metric" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/staff" - userusecase "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/user" "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure" - libOnboardingUsecase "github.com/savannahghi/onboarding/pkg/onboarding/usecases" ) // Interactor represents an assemble of all use cases into a single object that can be instantiated anywhere type Interactor struct { - OpenSourceInfra infrastructure.Infrastructure - database pg.OnboardingDb - OpenSourceUsecases libOnboardingUsecase.Interactor - FacilityUsecase facility.UseCasesFacility - MetricUsecase metrics.UsecasesMetrics - UserUsecase userusecase.UseCasesUser - StaffUsecase staff.UsecasesStaffProfile - ClientUseCase client.UseCasesClientProfile + OpenSourceInfra infrastructure.Infrastructure + database pg.OnboardingDb + FacilityUsecase facility.UseCasesFacility } // NewOnboardingInteractor returns a new onboarding interactor func NewOnboardingInteractor( openSourceInfra infrastructure.Infrastructure, database pg.OnboardingDb, - openSourceUsecases libOnboardingUsecase.Interactor, facilityUseCase facility.UseCasesFacility, - metricUsecase metrics.UsecasesMetrics, - usecaseUser userusecase.UseCasesUser, - staffProfileUsecase staff.UsecasesStaffProfile, - clientUseCase client.UseCasesClientProfile, ) *Interactor { return &Interactor{ - OpenSourceInfra: openSourceInfra, - database: database, - OpenSourceUsecases: openSourceUsecases, - FacilityUsecase: facilityUseCase, - MetricUsecase: metricUsecase, - StaffUsecase: staffProfileUsecase, - UserUsecase: usecaseUser, - ClientUseCase: clientUseCase, + OpenSourceInfra: openSourceInfra, + database: database, + FacilityUsecase: facilityUseCase, } } diff --git a/pkg/onboarding/presentation/rest/handlers.go b/pkg/onboarding/presentation/rest/handlers.go index 63d4fd20..b8b29938 100644 --- a/pkg/onboarding/presentation/rest/handlers.go +++ b/pkg/onboarding/presentation/rest/handlers.go @@ -1,22 +1,13 @@ package rest import ( - "fmt" - "net/http" - - "github.com/savannahghi/errorcodeutil" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/interactor" - "github.com/savannahghi/serverutils" ) // OnboardingHandlersInterfaces represents all the REST API logic type OnboardingHandlersInterfaces interface { //Collect metrics handler - CollectMetricsHandler() http.HandlerFunc - LoginHandler() http.HandlerFunc - ResetPin() http.HandlerFunc } // OnboardingHandlersInterfacesImpl represents the usecase implementation object @@ -29,73 +20,3 @@ type OnboardingHandlersInterfacesImpl struct { func NewOnboardingHandlersInterfaces(infrastructure infrastructure.Interactor, interactor interactor.Interactor) OnboardingHandlersInterfaces { return &OnboardingHandlersInterfacesImpl{infrastructure, interactor} } - -// CollectMetricsHandler is an unauthenticated endpoint that is called to collect various metrics -func (h *OnboardingHandlersInterfacesImpl) CollectMetricsHandler() http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - ctx := r.Context() - - metric := &dto.MetricInput{} - serverutils.DecodeJSONToTargetStruct(w, r, metric) - - response, err := h.interactor.MetricUsecase.CollectMetrics(ctx, metric) - if err != nil { - serverutils.WriteJSONResponse(w, err, http.StatusBadRequest) - return - } - - serverutils.WriteJSONResponse(w, response, http.StatusCreated) - } -} - -// LoginHandler is an unauthenticated endpoint that is called to login user -func (h *OnboardingHandlersInterfacesImpl) LoginHandler() http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - ctx := r.Context() - - loginPayload := &dto.LoginInput{} - serverutils.DecodeJSONToTargetStruct(w, r, loginPayload) - - response, _, err := h.interactor.UserUsecase.Login(ctx, loginPayload.UserID, loginPayload.PIN, loginPayload.Flavour) - if err != nil { - serverutils.WriteJSONResponse(w, err, http.StatusBadRequest) - return - } - - serverutils.WriteJSONResponse(w, response, http.StatusCreated) - } -} - -// ResetPin is used to generate and send new pin to a user (client/staff) -func (h *OnboardingHandlersInterfacesImpl) ResetPin() http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - ctx := r.Context() - - resetPinPayload := &dto.ResetPinInput{} - serverutils.DecodeJSONToTargetStruct(w, r, resetPinPayload) - - if resetPinPayload.UserID == "" || resetPinPayload.Flavour == "" { - err := fmt.Errorf("expected `userID` and `flavour` to be defines") - serverutils.WriteJSONResponse( - w, - errorcodeutil.CustomError{ - Err: err, - Message: err.Error(), - }, - http.StatusBadRequest, - ) - return - } - - response, err := h.interactor.UserUsecase.ResetPIN( - ctx, - resetPinPayload.UserID, - resetPinPayload.Flavour, - ) - if err != nil { - serverutils.WriteJSONResponse(w, err, http.StatusBadRequest) - return - } - serverutils.WriteJSONResponse(w, response, http.StatusOK) - } -} diff --git a/pkg/onboarding/usecases/client/client.go b/pkg/onboarding/usecases/client/client.go deleted file mode 100644 index 6f896ce8..00000000 --- a/pkg/onboarding/usecases/client/client.go +++ /dev/null @@ -1,197 +0,0 @@ -package client - -import ( - "context" - - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" -) - -// IRegisterClient ... -type IRegisterClient interface { - // TODO: the input client profile must not have an ID set - // validate identifiers when creating - // if the enrolment date is not supplied, set it automatically - // default to the client profile being active right after creation - // create a patient on FHIR (HealthRecordID - // if identifiers not supplied (e.g patient being created on app), set - // an internal identifier as the default. It should be updated later - // with the CCC number or other final identifier - // TODO: ensure the user exists...supplied user ID - // TODO: only register clients who've been counselled - // TODO: consider: after successful registration, send invite link automatically - RegisterClient( - ctx context.Context, - userInput *dto.UserInput, - clientInput *dto.ClientProfileInput, - ) (*domain.ClientUserProfile, error) -} - -// IAddClientIdentifier ... -type IAddClientIdentifier interface { - // TODO use idType and settings to decide if it's a primary identifier or not - AddIdentifier(ctx context.Context, clientID string, idType enums.IdentifierType, idValue string, isPrimary bool) (*domain.Identifier, error) -} - -// IInactivateClient ... -type IInactivateClient interface { - // TODO Consider making reasons an enum - InactivateClient(clientID string, reason string, notes string) (bool, error) -} - -// IReactivateClient ... -type IReactivateClient interface { - ReactivateClient(clientID string, reason string, notes string) (bool, error) -} - -// ITransferClient ... -type ITransferClient interface { - // TODO: maintain log of past transfers, who did it etc - TransferClient( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, - ) (bool, error) -} - -// IGetClientIdentifiers ... -type IGetClientIdentifiers interface { - GetIdentifiers(clientID string, active bool) ([]*domain.Identifier, error) -} - -// IInactivateClientIdentifier ... -type IInactivateClientIdentifier interface { - InactivateIdentifier(clientID string, identifierID string) (bool, error) -} - -// IAssignTreatmentSupporter ... -type IAssignTreatmentSupporter interface { - AssignTreatmentSupporter( - clientID string, - treatmentSupporterID string, - treatmentSupporterType string, // TODO: enum, start with CHV and Treatment buddy - ) (bool, error) -} - -// IUnassignTreatmentSupporter ... -type IUnassignTreatmentSupporter interface { - UnassignTreatmentSupporter( - clientID string, - treatmentSupporterID string, - reason string, // TODO: ensure these are in an audit log - notes string, // TODO: Optional - ) (bool, error) -} - -// IAddRelatedPerson ... -type IAddRelatedPerson interface { - // add next of kin - AddRelatedPerson( - clientID string, - relatedPerson *domain.RelatedPerson, - ) (*domain.RelatedPerson, bool) -} - -// UseCasesClientProfile ... -type UseCasesClientProfile interface { - IAddClientIdentifier - IGetClientIdentifiers - IInactivateClientIdentifier - IRegisterClient - IInactivateClient - IReactivateClient - ITransferClient - IAssignTreatmentSupporter - IUnassignTreatmentSupporter - IAddRelatedPerson -} - -// UseCasesClientImpl represents user implementation object -type UseCasesClientImpl struct { - Infrastructure infrastructure.Interactor -} - -// NewUseCasesClientImpl returns a new Client service -func NewUseCasesClientImpl(infra infrastructure.Interactor) *UseCasesClientImpl { - return &UseCasesClientImpl{ - Infrastructure: infra, - } -} - -// RegisterClient registers a client into the platform -func (cl *UseCasesClientImpl) RegisterClient( - ctx context.Context, - userInput *dto.UserInput, - clientInput *dto.ClientProfileInput, -) (*domain.ClientUserProfile, error) { - return cl.Infrastructure.RegisterClient(ctx, userInput, clientInput) -} - -// AddIdentifier stages and adds client identifiers -func (cl *UseCasesClientImpl) AddIdentifier(ctx context.Context, clientID string, idType enums.IdentifierType, idValue string, isPrimary bool) (*domain.Identifier, error) { - return cl.Infrastructure.AddIdentifier(ctx, clientID, idType, idValue, isPrimary) -} - -// InactivateClient makes a client inactive and removes the client from the list of active users -func (cl *UseCasesClientImpl) InactivateClient(clientID string, reason string, notes string) (bool, error) { - return true, nil -} - -// ReactivateClient makes inactive client active and returns the client to the list of active user -func (cl *UseCasesClientImpl) ReactivateClient(clientID string, reason string, notes string) (bool, error) { - return true, nil -} - -// TransferClient transfers a client from one facility to another facility for various reasons -func (cl *UseCasesClientImpl) TransferClient( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, -) (bool, error) { - return cl.Infrastructure.TransferClient(ctx, clientID, originFacilityID, destinationFacilityID, reason, notes) -} - -// GetIdentifiers fetches and returns a list of client active identifiers -func (cl *UseCasesClientImpl) GetIdentifiers(clientID string, active bool) ([]*domain.Identifier, error) { - return nil, nil -} - -// InactivateIdentifier toggles and make client identifier inactive -func (cl *UseCasesClientImpl) InactivateIdentifier(clientID string, identifierID string) (bool, error) { - return true, nil -} - -// AssignTreatmentSupporter assigns a treatment supporter to a client -func (cl *UseCasesClientImpl) AssignTreatmentSupporter( - clientID string, - treatmentSupporterID string, - treatmentSupporterType string, // TODO: enum, start with CHV and Treatment buddy -) (bool, error) { - return true, nil -} - -// UnassignTreatmentSupporter unassign treatment supporter from a client -func (cl *UseCasesClientImpl) UnassignTreatmentSupporter( - clientID string, - treatmentSupporterID string, - reason string, // TODO: ensure these are in an audit log - notes string, // TODO: Optional -) (bool, error) { - return true, nil -} - -// AddRelatedPerson adds client related person. The related person here is like Next of Kin -func (cl *UseCasesClientImpl) AddRelatedPerson( - clientID string, - relatedPerson *domain.RelatedPerson, -) (*domain.RelatedPerson, bool) { - return nil, false -} diff --git a/pkg/onboarding/usecases/client/client_test.go b/pkg/onboarding/usecases/client/client_test.go deleted file mode 100644 index 5551c6e3..00000000 --- a/pkg/onboarding/usecases/client/client_test.go +++ /dev/null @@ -1,152 +0,0 @@ -package client_test - -import ( - "context" - "testing" - - "github.com/savannahghi/enumutils" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" - "github.com/segmentio/ksuid" - "github.com/tj/assert" -) - -func TestUseCasesClientImplIntegration_RegisterClient(t *testing.T) { - ctx := context.Background() - f := testInfrastructureInteractor - - userPayload := &dto.UserInput{ - FirstName: "FirstName", - LastName: "Last Name", - Username: "User Name", - MiddleName: "Middle Name", - DisplayName: "Display Name", - Gender: enumutils.GenderMale, - } - - clientPayload := &dto.ClientProfileInput{ - ClientType: enums.ClientTypeOvc, - } - - // Create an empty client, it should returns an error - client, err := f.RegisterClient(ctx, nil, nil) - assert.NotNil(t, err) - assert.Nil(t, client) - - // Create a client with valid payload - client1, err := f.RegisterClient(ctx, userPayload, clientPayload) - assert.Nil(t, err) - assert.NotNil(t, client1) - - // TODO: Try creating the same user twice, should throw an error after we check for uniqueness -} - -func TestUseCasesClientImpl_AddIdentifier(t *testing.T) { - ctx := context.Background() - f := testInfrastructureInteractor - - userPayload := &dto.UserInput{ - FirstName: "FirstName", - LastName: "Last Name", - Username: "User Name", - MiddleName: "Middle Name", - DisplayName: "Display Name", - Gender: enumutils.GenderMale, - } - - clientPayload := &dto.ClientProfileInput{ - ClientType: enums.ClientTypeOvc, - } - client, err := f.RegisterClient(ctx, userPayload, clientPayload) - if err != nil { - t.Errorf("failed to create client: %v", err) - return - } - - type args struct { - ctx context.Context - clientID string - idType enums.IdentifierType - idValue string - isPrimary bool - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy Case - Successfully add identifier", - args: args{ - ctx: ctx, - clientID: *client.Client.ID, - idType: enums.IdentifierTypeCCC, - idValue: "12345", - isPrimary: true, - }, - wantErr: false, - }, - { - name: "Sad Case - Fail to add identifier", - args: args{ - ctx: ctx, - clientID: "non-existent", - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := f.AddIdentifier(tt.args.ctx, tt.args.clientID, tt.args.idType, tt.args.idValue, tt.args.isPrimary) - if (err != nil) != tt.wantErr { - t.Errorf("UseCasesClientImpl.AddIdentifier() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !tt.wantErr && got == nil { - t.Errorf("expected a response but got: %v", got) - return - } - }) - } -} - -func TestUseCasesClientImpl_TransferClient_Integration(t *testing.T) { - ctx := context.Background() - - m := testInfrastructureInteractor - i := testInteractor - - originalFacilityID := ksuid.New().String() - destinationFacilityID := ksuid.New().String() - reason := enums.RelocationTransferReason - notes := "Other" - - userPayload := &dto.UserInput{ - FirstName: "FirstName", - LastName: "Last Name", - Username: "User Name", - MiddleName: "Middle Name", - DisplayName: "Display Name", - Gender: enumutils.GenderMale, - } - - clientPayload := &dto.ClientProfileInput{ - ClientType: enums.ClientTypeOvc, - } - client, err := m.RegisterClient(ctx, userPayload, clientPayload) - assert.Nil(t, err) - assert.NotNil(t, client) - - clientProfile, err1 := m.GetClientProfileByClientID(ctx, *client.Client.ID) - assert.Nil(t, err1) - assert.NotNil(t, clientProfile) - - bool, err2 := i.ClientUseCase.TransferClient(ctx, *clientProfile.ID, originalFacilityID, destinationFacilityID, reason, notes) - assert.Nil(t, err2) - assert.Equal(t, true, bool) - - bool1, err3 := i.ClientUseCase.TransferClient(ctx, "", originalFacilityID, destinationFacilityID, reason, notes) - assert.NotNil(t, err3) - assert.Equal(t, false, bool1) - -} diff --git a/pkg/onboarding/usecases/client/client_unit_test.go b/pkg/onboarding/usecases/client/client_unit_test.go deleted file mode 100644 index a3191cdd..00000000 --- a/pkg/onboarding/usecases/client/client_unit_test.go +++ /dev/null @@ -1,207 +0,0 @@ -package client_test - -import ( - "context" - "fmt" - "testing" - "time" - - "github.com/google/uuid" - "github.com/savannahghi/enumutils" - "github.com/savannahghi/feedlib" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/mock" - "github.com/segmentio/ksuid" - "github.com/tj/assert" -) - -func TestUseCasesClientImpl_RegisterClient(t *testing.T) { - ctx := context.Background() - d := testFakeInfrastructureInteractor - - userPayload := &dto.UserInput{ - FirstName: "FirstName", - LastName: "Last Name", - Username: "User Name", - MiddleName: "Middle Name", - DisplayName: "Display Name", - Gender: enumutils.GenderMale, - } - - clientPayload := &dto.ClientProfileInput{ - ClientType: enums.ClientTypeOvc, - } - type args struct { - ctx context.Context - userInput *dto.UserInput - clientInput *dto.ClientProfileInput - } - - tests := []struct { - name string - args args - wantErr bool - }{ - // { - // name: "Happy Case", - // args: args{ - // ctx: ctx, - // userInput: userPayload, - // clientInput: clientPayload, - // }, - // wantErr: false, - // }, - { - name: "Sad Case: Fail to register user", - args: args{ - ctx: ctx, - userInput: userPayload, - clientInput: clientPayload, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - _ = mock.NewCreateMock() - - if tt.name == "Sad Case: Fail to register user" { - fakeCreate.RegisterClientFn = func(ctx context.Context, userInput *dto.UserInput, clientInput *dto.ClientProfileInput) (*domain.ClientUserProfile, error) { - return nil, fmt.Errorf("failed to register a client") - } - } - - got, err := d.RegisterClient(tt.args.ctx, tt.args.userInput, tt.args.clientInput) - if (err != nil) != tt.wantErr { - t.Errorf("UseCasesClientImpl.RegisterClient() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !tt.wantErr && got == nil { - t.Errorf("expected a response but got: %v", nil) - } - }) - } -} - -func TestUseCasesClientImpl_TransferClient_Unittest(t *testing.T) { - ctx := context.Background() - f := testFakeInfrastructureInteractor - - ID := uuid.New().String() - - type args struct { - ctx context.Context - clientID string - originFacilityID string - destinationFacilityID string - reason enums.TransferReason - notes string - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - clientID: ksuid.New().String(), - originFacilityID: ksuid.New().String(), - destinationFacilityID: ksuid.New().String(), - reason: enums.RelocationTransferReason, - notes: ksuid.New().String(), - }, - wantErr: false, - }, - - { - name: "Sad case", - args: args{ - ctx: ctx, - clientID: "", - originFacilityID: ksuid.New().String(), - destinationFacilityID: ksuid.New().String(), - reason: enums.OtherTransferReason, - notes: "other-reason", - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.name == "Happy case" { - fakeCreate.RegisterClientFn = func(ctx context.Context, userInput *dto.UserInput, clientInput *dto.ClientProfileInput) (*domain.ClientUserProfile, error) { - return &domain.ClientUserProfile{ - User: &domain.User{ - ID: &ID, - Username: "User Name", - DisplayName: "Display Name", - FirstName: "FirstName", - MiddleName: userInput.MiddleName, - LastName: "Last Name", - UserType: enums.HealthcareWorkerUser, - Gender: enumutils.GenderMale, - Active: false, - Contacts: []*domain.Contact{}, - Languages: []enumutils.Language{}, - LastSuccessfulLogin: &time.Time{}, - LastFailedLogin: &time.Time{}, - FailedLoginCount: "0", - NextAllowedLogin: &time.Time{}, - TermsAccepted: false, - AcceptedTermsID: ksuid.New().String(), - Flavour: feedlib.FlavourConsumer, - }, - Client: &domain.ClientProfile{ - ClientType: enums.ClientTypeOvc, - }, - }, nil - } - - fakeQuery.GetClientProfileByClientIDFn = func(ctx context.Context, clientID string) (*domain.ClientProfile, error) { - - healthRecordID := ksuid.New().String() - return &domain.ClientProfile{ - ID: &ID, - UserID: new(string), - TreatmentEnrollmentDate: &time.Time{}, - ClientType: enums.ClientTypeOvc, - Active: false, - HealthRecordID: &healthRecordID, - Identifiers: []*domain.Identifier{}, - Addresses: []*domain.Addresses{}, - RelatedPersons: []*domain.RelatedPerson{}, - FacilityID: ksuid.New().String(), - TreatmentBuddyUserID: ksuid.New().String(), - CHVUserID: ksuid.New().String(), - ClientCounselled: false, - }, nil - } - - fakeUpdate.TransferClientFn = func(ctx context.Context, clientID, originFacilityID, destinationFacilityID string, reason enums.TransferReason, notes string) (bool, error) { - return true, nil - } - } - - if tt.name == "Sad case" { - fakeCreate.RegisterClientFn = func(ctx context.Context, userInput *dto.UserInput, clientInput *dto.ClientProfileInput) (*domain.ClientUserProfile, error) { - return nil, fmt.Errorf("failed to register a client") - } - - fakeUpdate.TransferClientFn = func(ctx context.Context, clientID, originFacilityID, destinationFacilityID string, reason enums.TransferReason, notes string) (bool, error) { - return false, fmt.Errorf("failed to register a client") - } - } - - got, err := f.TransferClient(tt.args.ctx, tt.args.clientID, tt.args.originFacilityID, tt.args.destinationFacilityID, tt.args.reason, tt.args.notes) - if (err != nil) != tt.wantErr { - t.Errorf("UseCasesClientImpl.TransferClient() error = %v, wantErr %v", err, tt.wantErr) - return - } - assert.NotNil(t, got) - }) - } -} diff --git a/pkg/onboarding/usecases/client/config_test.go b/pkg/onboarding/usecases/client/config_test.go deleted file mode 100644 index 8166e09f..00000000 --- a/pkg/onboarding/usecases/client/config_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package client_test - -import ( - "context" - "log" - "os" - "testing" - - "github.com/savannahghi/firebasetools" - onboardingExtension "github.com/savannahghi/onboarding-service/pkg/onboarding/application/extension" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" - "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/interactor" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/client" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/facility" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/metric" - usecaseMock "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/mock" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/staff" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/user" - baseExt "github.com/savannahghi/onboarding/pkg/onboarding/application/extension" - openSourceInfra "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure" - "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure/services/engagement" - libOnboardingUsecase "github.com/savannahghi/onboarding/pkg/onboarding/usecases" -) - -var ( - testInfrastructureInteractor infrastructure.Interactor - testInteractor interactor.Interactor - testFakeInfrastructureInteractor usecases.Interactor - - fakeCreate usecaseMock.CreateMock - fakeQuery usecaseMock.QueryMock - fakeUpdate usecaseMock.UpdateMock -) - -const ( - engagementService = "engagement" -) - -func TestMain(m *testing.M) { - ctx := context.Background() - - infra, err := InitializeTestInfrastructure(ctx) - if err != nil { - log.Printf("failed to initialize infrastructure: %v", err) - } - - interactor := InitializeTestInteractor(ctx) - - fakeInfra, err := InitializeFakeTestlInteractor(ctx) - if err != nil { - log.Printf("failed to initialize fake usecase interractor: %v", err) - } - testFakeInfrastructureInteractor = fakeInfra - - purgeRecords := func() { - - } - - purgeRecords() - - testInfrastructureInteractor = infra - testInteractor = interactor - - // run the tests - log.Printf("about to run tests\n") - code := m.Run() - log.Printf("finished running tests\n") - - // cleanup here - os.Exit(code) -} - -func InitializeTestInfrastructure(ctx context.Context) (infrastructure.Interactor, error) { - i := infrastructure.NewInteractor() - return i, nil -} - -func InitializeTestInteractor(ctx context.Context) interactor.Interactor { - osinfra := openSourceInfra.NewInfrastructureInteractor() - pgInstance, err := gorm.NewPGInstance() - if err != nil { - log.Fatal(err) - } - // Initialize ISC clients - engagementISC := onboardingExtension.NewInterServiceClient(engagementService) - infra := infrastructure.NewInteractor() - facilityUsecase := facility.NewFacilityUsecase(infra) - metricUsecase := metric.NewMetricUsecase(infra) - db := postgres.NewOnboardingDb(pgInstance, pgInstance, pgInstance, pgInstance) - var fc firebasetools.IFirebaseClient - baseExtension := baseExt.NewBaseExtensionImpl(fc) - pinExtension := baseExt.NewPINExtensionImpl() - onboardingExtension := onboardingExtension.NewOnboardingLibImpl() - engagement := engagement.NewServiceEngagementImpl(engagementISC, baseExtension) - libUsecasee := libOnboardingUsecase.NewUsecasesInteractor(osinfra, baseExtension, pinExtension) - userUsecase := user.NewUseCasesUserImpl(infra, onboardingExtension, engagement) - staff := staff.NewUsecasesStaffProfileImpl(infra) - client := client.NewUseCasesClientImpl(infra) - i := interactor.NewOnboardingInteractor(osinfra, *db, libUsecasee, facilityUsecase, metricUsecase, userUsecase, staff, client) - - return *i -} - -func InitializeFakeTestlInteractor(ctx context.Context) (usecases.Interactor, error) { - - var create infrastructure.Create = &fakeCreate - var query infrastructure.Query = &fakeQuery - var update infrastructure.Update = &fakeUpdate - - infra := func() infrastructure.Interactor { - return infrastructure.Interactor{ - Create: create, - Query: query, - Update: update, - } - }() - - i := usecases.NewUsecasesInteractor(infra) - - return i, nil -} diff --git a/pkg/onboarding/usecases/facility/config_test.go b/pkg/onboarding/usecases/facility/config_test.go index e4d7094c..fb1afea8 100644 --- a/pkg/onboarding/usecases/facility/config_test.go +++ b/pkg/onboarding/usecases/facility/config_test.go @@ -7,12 +7,18 @@ import ( "testing" "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" + "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres" + "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" + "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/interactor" "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases" + "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/facility" usecaseMock "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/mock" + openSourceInfra "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure" ) var ( testInfrastructureInteractor infrastructure.Interactor + testInteractor interactor.Interactor testFakeInfrastructureInteractor usecases.Interactor fakeCreate usecaseMock.CreateMock @@ -27,6 +33,8 @@ func TestMain(m *testing.M) { log.Printf("failed to initialize infrastructure: %v", err) } + interactor := InitializeTestInteractor(ctx) + fakeInfra, err := InitializeFakeTestlInteractor(ctx) if err != nil { log.Printf("failed to initialize fake usecase interractor: %v", err) @@ -40,6 +48,7 @@ func TestMain(m *testing.M) { purgeRecords() testInfrastructureInteractor = infra + testInteractor = interactor // run the tests log.Printf("about to run tests\n") @@ -55,6 +64,20 @@ func InitializeTestInfrastructure(ctx context.Context) (infrastructure.Interacto return i, nil } +func InitializeTestInteractor(ctx context.Context) interactor.Interactor { + osinfra := openSourceInfra.NewInfrastructureInteractor() + pgInstance, err := gorm.NewPGInstance() + if err != nil { + log.Fatal(err) + } + infra := infrastructure.NewInteractor() + facilityUsecase := facility.NewFacilityUsecase(infra) + db := postgres.NewOnboardingDb(pgInstance, pgInstance, pgInstance) + i := interactor.NewOnboardingInteractor(osinfra, *db, facilityUsecase) + + return *i +} + func InitializeFakeTestlInteractor(ctx context.Context) (usecases.Interactor, error) { var create infrastructure.Create = &fakeCreate diff --git a/pkg/onboarding/usecases/facility/facility_integration_test.go b/pkg/onboarding/usecases/facility/facility_integration_test.go index 790de468..4b55cd69 100644 --- a/pkg/onboarding/usecases/facility/facility_integration_test.go +++ b/pkg/onboarding/usecases/facility/facility_integration_test.go @@ -166,15 +166,16 @@ func TestUseCaseFacilityImpl_RetrieveFacility_Integration(t *testing.T) { } } -func TestUseCaseFacilityImpl_DeleteFacility_Integration(t *testing.T) { +func TestUseCaseFacilityImpl_DeleteFacility_Integrationtest(t *testing.T) { ctx := context.Background() i := testInfrastructureInteractor + u := testInteractor //Create facility facilityInput := &dto.FacilityInput{ Name: "Kanairo One", - Code: "KN005", + Code: ksuid.New().String(), County: "Kanairo", Active: true, Description: "This is just for integration testing", @@ -190,22 +191,51 @@ func TestUseCaseFacilityImpl_DeleteFacility_Integration(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, facility1) - //Delete a facility - isDeleted, err := i.DeleteFacility(ctx, facility.Code) - assert.Nil(t, err) - assert.NotNil(t, isDeleted) - assert.Equal(t, true, isDeleted) + type args struct { + ctx context.Context + id string + } + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: "Happy case", + args: args{ + ctx: ctx, + id: *facility1.ID, + }, + wantErr: false, + }, - // retrieve the facility checks if the facility is deleted - facility2, err := i.RetrieveFacility(ctx, facility.ID, true) - assert.Nil(t, err) - assert.Nil(t, facility2) + { + name: "Sad case - bad id", + args: args{ + ctx: ctx, + id: ksuid.New().String(), + }, + wantErr: false, + }, - //Delete a facility again. - isDeleted1, err := i.DeleteFacility(ctx, facility.Code) - assert.Nil(t, err) - assert.NotNil(t, isDeleted1) - assert.Equal(t, true, isDeleted1) + { + name: "Sad case - empty id", + args: args{ + ctx: ctx, + id: "", + }, + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := u.FacilityUsecase.DeleteFacility(tt.args.ctx, tt.args.id) + if (err != nil) != tt.wantErr { + t.Errorf("UseCaseFacilityImpl.DeleteFacility() error = %v, wantErr %v", err, tt.wantErr) + return + } + }) + } } func TestUseCaseFacilityImpl_RetrieveFacilityByMFLCode_Integration(t *testing.T) { diff --git a/pkg/onboarding/usecases/metric/config_test.go b/pkg/onboarding/usecases/metric/config_test.go deleted file mode 100644 index 716ca2a0..00000000 --- a/pkg/onboarding/usecases/metric/config_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package metric_test - -import ( - "context" - "log" - "os" - "testing" - - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases" - usecaseMock "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/mock" -) - -var ( - testInfrastructureInteractor infrastructure.Interactor - testFakeInfrastructureInteractor usecases.Interactor - - fakeCreate usecaseMock.CreateMock -) - -func TestMain(m *testing.M) { - ctx := context.Background() - - infra, err := InitializeTestInfrastructure(ctx) - if err != nil { - log.Printf("failed to initialize infrastructure: %v", err) - } - - fakeInfra, err := InitializeFakeTestlInteractor(ctx) - if err != nil { - log.Printf("failed to initialize fake usecase interractor: %v", err) - } - testFakeInfrastructureInteractor = fakeInfra - - purgeRecords := func() { - - } - - purgeRecords() - - testInfrastructureInteractor = infra - - // run the tests - log.Printf("about to run tests\n") - code := m.Run() - log.Printf("finished running tests\n") - - // cleanup here - os.Exit(code) -} - -func InitializeTestInfrastructure(ctx context.Context) (infrastructure.Interactor, error) { - i := infrastructure.NewInteractor() - return i, nil -} - -func InitializeFakeTestlInteractor(ctx context.Context) (usecases.Interactor, error) { - - var create infrastructure.Create = &fakeCreate - - infra := func() infrastructure.Interactor { - return infrastructure.Interactor{ - Create: create, - } - }() - - i := usecases.NewUsecasesInteractor(infra) - - return i, nil -} diff --git a/pkg/onboarding/usecases/metric/metric_unit_test.go b/pkg/onboarding/usecases/metric/metric_unit_test.go deleted file mode 100644 index dc9e0ff2..00000000 --- a/pkg/onboarding/usecases/metric/metric_unit_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package metric_test - -import ( - "context" - "fmt" - "testing" - "time" - - "github.com/google/uuid" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/segmentio/ksuid" - "gorm.io/datatypes" -) - -func TestUsecaseMetricsImpl_CollectMetrics_Unittest(t *testing.T) { - ctx := context.Background() - - f := testFakeInfrastructureInteractor - - metric := &dto.MetricInput{ - Type: enums.EngagementMetrics, - Payload: datatypes.JSON([]byte(`{"who": "test user", "keyword": "suicidal"}`)), - Timestamp: time.Now(), - UID: ksuid.New().String(), - } - - invalidMetric := &dto.MetricInput{ - Type: "", - Payload: datatypes.JSON([]byte(`{"who": "test user", "keyword": "bored"}`)), - Timestamp: time.Now(), - UID: ksuid.New().String(), - } - - type args struct { - ctx context.Context - metric *dto.MetricInput - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - metric: metric, - }, - wantErr: false, - }, - - { - name: "Sad case", - args: args{ - ctx: ctx, - metric: invalidMetric, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.name == "Sad case" { - fakeCreate.CollectMetricsFn = func(ctx context.Context, metric *dto.MetricInput) (*domain.Metric, error) { - return nil, fmt.Errorf("an error occurred while collecting metrics.") - } - } - if tt.name == "Happy case" { - fakeCreate.CollectMetricsFn = func(ctx context.Context, metric *dto.MetricInput) (*domain.Metric, error) { - metricID := uuid.New().String() - return &domain.Metric{ - MetricID: &metricID, - Type: enums.EngagementMetrics, - Payload: datatypes.JSON([]byte(`{"who": "test user", "keyword": "bored"}`)), - Timestamp: time.Now(), - UID: ksuid.New().String(), - }, nil - } - } - - _, err := f.CollectMetrics(tt.args.ctx, tt.args.metric) - if (err != nil) != tt.wantErr { - t.Errorf("UsecaseMetricsImpl.CollectMetrics() error = %v, wantErr %v", err, tt.wantErr) - return - } - }) - } -} diff --git a/pkg/onboarding/usecases/metric/metrics.go b/pkg/onboarding/usecases/metric/metrics.go deleted file mode 100644 index 008abf42..00000000 --- a/pkg/onboarding/usecases/metric/metrics.go +++ /dev/null @@ -1,62 +0,0 @@ -package metric - -import ( - "context" - "fmt" - - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/utils" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" -) - -// UsecasesMetrics contains a list of all interfaces that collect metrics. -type UsecasesMetrics interface { - IMetricsCollect -} - -// IMetricsCollect contains metrics collection methods -type IMetricsCollect interface { - // TODO Check identifier; ensure idempotency - CollectMetrics(ctx context.Context, metric *dto.MetricInput) (*domain.Metric, error) -} - -// UsecaseMetricsImpl represents the metrics implementation -type UsecaseMetricsImpl struct { - Infrastructure infrastructure.Interactor - //Hashing utils.IHashing -} - -// NewMetricUsecase returns a new metric usecase -func NewMetricUsecase(infra infrastructure.Interactor) *UsecaseMetricsImpl { - return &UsecaseMetricsImpl{ - Infrastructure: infra, - } -} - -// CollectMetrics collects the various metrics. -func (m *UsecaseMetricsImpl) CollectMetrics(ctx context.Context, metric *dto.MetricInput) (*domain.Metric, error) { - //If the UID of the user is provided, hash it - if metric.UID != "" { - // Encrypting UID - salt, encryptedUID := utils.EncryptUID(metric.UID, nil) - - // Comparing Salted UID - matched := utils.CompareUID(metric.UID, salt, encryptedUID, nil) - if !matched { - return nil, fmt.Errorf("the provided UID do not match") - - } - - metricData := &dto.MetricInput{ - Type: metric.Type, - Payload: metric.Payload, - Timestamp: metric.Timestamp, - UID: encryptedUID, - } - - return m.Infrastructure.CollectMetrics(ctx, metricData) - } - - return m.Infrastructure.CollectMetrics(ctx, metric) -} diff --git a/pkg/onboarding/usecases/metric/metrics_integration_test.go b/pkg/onboarding/usecases/metric/metrics_integration_test.go deleted file mode 100644 index 394d18e4..00000000 --- a/pkg/onboarding/usecases/metric/metrics_integration_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package metric_test - -import ( - "context" - "testing" - "time" - - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/utils" - "github.com/segmentio/ksuid" - "github.com/tj/assert" - "gorm.io/datatypes" -) - -func TestUsecaseMetricsImpl_CollectMetrics_Integration_Test(t *testing.T) { - ctx := context.Background() - - m := testInfrastructureInteractor - - metric := &dto.MetricInput{ - Type: enums.EngagementMetrics, - Payload: datatypes.JSON([]byte(`{"who": "test user", "keyword": "suicidal"}`)), - Timestamp: time.Now(), - UID: ksuid.New().String(), - } - - invalidMetric := &dto.MetricInput{ - Type: "", - Payload: datatypes.JSON([]byte(`{"who": "test user", "keyword": "bored"}`)), - Timestamp: time.Now(), - UID: ksuid.New().String(), - } - - // Encrypt UID - salt, encryptedData := utils.EncryptUID("1234", nil) - assert.NotNil(t, encryptedData) - assert.NotNil(t, salt) - - // Check whether the UID has been encrypted - isEncypted := utils.CompareUID("1234", salt, encryptedData, nil) - assert.True(t, isEncypted) - assert.Equal(t, true, isEncypted) - - // Collect valid metrics - collectedMetric, err := m.CollectMetrics(ctx, metric) - assert.Nil(t, err) - assert.NotNil(t, collectedMetric) - - // Collect invalid metrics - invalidmetric, err := m.CollectMetrics(ctx, invalidMetric) - assert.NotNil(t, err) - assert.Nil(t, invalidmetric) - -} diff --git a/pkg/onboarding/usecases/mock/usecase_mock.go b/pkg/onboarding/usecases/mock/usecase_mock.go index 4c2f908e..611e9685 100644 --- a/pkg/onboarding/usecases/mock/usecase_mock.go +++ b/pkg/onboarding/usecases/mock/usecase_mock.go @@ -2,59 +2,20 @@ package mock import ( "context" - "time" "github.com/google/uuid" - "github.com/savannahghi/enumutils" - "github.com/savannahghi/feedlib" "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/segmentio/ksuid" - "gorm.io/datatypes" ) // CreateMock is a mock of the create methods type CreateMock struct { GetOrCreateFacilityFn func(ctx context.Context, facility dto.FacilityInput) (*domain.Facility, error) - CollectMetricsFn func(ctx context.Context, metric *dto.MetricInput) (*domain.Metric, error) - RegisterStaffUserFn func(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) - SavePinFn func(ctx context.Context, input *domain.UserPIN) (bool, error) - RegisterClientFn func(ctx context.Context, userInput *dto.UserInput, clientInput *dto.ClientProfileInput) (*domain.ClientUserProfile, error) - AddIdentifierFn func(ctx context.Context, clientID string, idType enums.IdentifierType, idValue string, isPrimary bool) (*domain.Identifier, error) } // NewCreateMock creates in itializes create type mocks func NewCreateMock() *CreateMock { return &CreateMock{ - RegisterClientFn: func(ctx context.Context, userInput *dto.UserInput, clientInput *dto.ClientProfileInput) (*domain.ClientUserProfile, error) { - ID := uuid.New().String() - testTime := time.Now() - - return &domain.ClientUserProfile{ - User: &domain.User{ - ID: &ID, - FirstName: "FirstName", - LastName: "Last Name", - Username: "User Name", - MiddleName: "Middle Name", - DisplayName: "Display Name", - Gender: enumutils.GenderMale, - Active: true, - LastSuccessfulLogin: &testTime, - LastFailedLogin: &testTime, - NextAllowedLogin: &testTime, - TermsAccepted: true, - AcceptedTermsID: ID, - }, - Client: &domain.ClientProfile{ - ID: &ID, - UserID: &ID, - ClientType: enums.ClientTypeOvc, - HealthRecordID: &ID, - }, - }, nil - }, GetOrCreateFacilityFn: func(ctx context.Context, facility dto.FacilityInput) (*domain.Facility, error) { id := uuid.New().String() @@ -71,63 +32,6 @@ func NewCreateMock() *CreateMock { Description: description, }, nil }, - - CollectMetricsFn: func(ctx context.Context, metric *dto.MetricInput) (*domain.Metric, error) { - metricID := uuid.New().String() - return &domain.Metric{ - MetricID: &metricID, - Type: enums.EngagementMetrics, - Payload: datatypes.JSON([]byte(`{"who": "test user", "keyword": "suicidal"}`)), - Timestamp: time.Now(), - UID: ksuid.New().String(), - }, nil - }, - - SavePinFn: func(ctx context.Context, input *domain.UserPIN) (bool, error) { - return true, nil - }, - RegisterStaffUserFn: func(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - ID := uuid.New().String() - testTime := time.Now() - roles := []enums.RolesType{enums.RolesTypeCanInviteClient} - languages := []enumutils.Language{enumutils.LanguageEn} - return &domain.StaffUserProfile{ - User: &domain.User{ - ID: &ID, - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Active: true, - LastSuccessfulLogin: &testTime, - LastFailedLogin: &testTime, - NextAllowedLogin: &testTime, - FailedLoginCount: "0", - TermsAccepted: true, - AcceptedTermsID: ID, - Languages: languages, - }, - Staff: &domain.StaffProfile{ - ID: &ID, - 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, - }, - }, - Roles: roles, - }, - }, nil - }, } } @@ -136,44 +40,11 @@ func (f *CreateMock) GetOrCreateFacility(ctx context.Context, facility dto.Facil return f.GetOrCreateFacilityFn(ctx, facility) } -// CollectMetrics mocks the implementation of `gorm's` CollectMetrics method. -func (f *CreateMock) CollectMetrics(ctx context.Context, metric *dto.MetricInput) (*domain.Metric, error) { - return f.CollectMetricsFn(ctx, metric) -} - -//SavePin mocks the implementation of SavePin method -func (f *CreateMock) SavePin(ctx context.Context, pinData *domain.UserPIN) (bool, error) { - return f.SavePinFn(ctx, pinData) -} - -// RegisterStaffUser mocks the implementation of RegisterStaffUser method. -func (f *CreateMock) RegisterStaffUser(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - return f.RegisterStaffUserFn(ctx, user, staff) -} - -// RegisterClient mocks the implementation of `gorm's` RegisterClient method -func (f *CreateMock) RegisterClient( - ctx context.Context, - userInput *dto.UserInput, - clientInput *dto.ClientProfileInput, -) (*domain.ClientUserProfile, error) { - return f.RegisterClientFn(ctx, userInput, clientInput) -} - -// AddIdentifier mocks the implementation of `gorm's` AddIdentifier method -func (f *CreateMock) AddIdentifier(ctx context.Context, clientID string, idType enums.IdentifierType, idValue string, isPrimary bool) (*domain.Identifier, error) { - return f.AddIdentifierFn(ctx, clientID, idType, idValue, isPrimary) -} - // QueryMock is a mock of the query methods type QueryMock struct { - RetrieveFacilityFn func(ctx context.Context, id *string, isActive bool) (*domain.Facility, error) - RetrieveFacilityByMFLCodeFn func(ctx context.Context, MFLCode string, isActive bool) (*domain.Facility, error) - GetFacilitiesFn func(ctx context.Context) ([]*domain.Facility, error) - GetUserPINByUserIDFn func(ctx context.Context, userID string) (*domain.UserPIN, error) - GetUserProfileByUserIDFn func(ctx context.Context, userID string, flavour feedlib.Flavour) (*domain.User, error) - GetClientProfileByClientIDFn func(ctx context.Context, clientID string) (*domain.ClientProfile, error) - GetStaffProfileFn func(ctx context.Context, staffNumber string) (*domain.StaffProfile, error) + RetrieveFacilityFn func(ctx context.Context, id *string, isActive bool) (*domain.Facility, error) + RetrieveFacilityByMFLCodeFn func(ctx context.Context, MFLCode string, isActive bool) (*domain.Facility, error) + GetFacilitiesFn func(ctx context.Context) ([]*domain.Facility, error) } // NewQueryMock initializes a new instance of `GormMock` then mocking the case of success. @@ -229,18 +100,6 @@ func NewQueryMock() *QueryMock { }, }, nil }, - - GetUserPINByUserIDFn: func(ctx context.Context, userID string) (*domain.UserPIN, error) { - return &domain.UserPIN{ - UserID: userID, - HashedPIN: "mbzcbvhbxchjbvhdbvhhjdfskgbfhas832y38hjsdnfkjbh73y73y72", - ValidFrom: time.Now(), - ValidTo: time.Now(), - Flavour: "CONSUMER", - IsValid: true, - Salt: "test-salt", - }, nil - }, } } @@ -259,117 +118,13 @@ func (f *QueryMock) GetFacilities(ctx context.Context) ([]*domain.Facility, erro return f.GetFacilitiesFn(ctx) } -// GetUserPINByUserID ... -func (f *QueryMock) GetUserPINByUserID(ctx context.Context, userID string) (*domain.UserPIN, error) { - return f.GetUserPINByUserIDFn(ctx, userID) -} - -// GetUserProfileByUserID gets user profile by user ID -func (f *QueryMock) GetUserProfileByUserID(ctx context.Context, userID string, flavour feedlib.Flavour) (*domain.User, error) { - return f.GetUserProfileByUserIDFn(ctx, userID, flavour) -} - -// GetClientProfileByClientID defines a mock for fetching a client profile using the client's ID -func (f *QueryMock) GetClientProfileByClientID(ctx context.Context, clientID string) (*domain.ClientProfile, error) { - return f.GetClientProfileByClientIDFn(ctx, clientID) -} - -// GetStaffProfile mocks the implementation of GetStaffProfile method. -func (f *QueryMock) GetStaffProfile(ctx context.Context, staffNumber string) (*domain.StaffProfile, error) { - return f.GetStaffProfileFn(ctx, staffNumber) -} - // UpdateMock ... type UpdateMock struct { - UpdateUserLastSuccessfulLoginFn func(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error - UpdateUserLastFailedLoginFn func(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error - UpdateUserFailedLoginCountFn func(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error - UpdateUserNextAllowedLoginFn func(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error - UpdateStaffUserProfileFn func(ctx context.Context, userID string, user *dto.UserInput, staff *dto.StaffProfileInput) (bool, error) - TransferClientFn func( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, - ) (bool, error) - InvalidatePINFn func(ctx context.Context, userID string) error } // NewUpdateMock initializes a new instance of `GormMock` then mocking the case of success. func NewUpdateMock() *UpdateMock { - return &UpdateMock{ - UpdateUserLastSuccessfulLoginFn: func(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error { - return nil - }, - - UpdateUserLastFailedLoginFn: func(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - return nil - }, - - UpdateUserFailedLoginCountFn: func(ctx context.Context, userID, failedLoginCount string, flavour feedlib.Flavour) error { - return nil - }, - - UpdateUserNextAllowedLoginFn: func(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error { - return nil - }, - - UpdateStaffUserProfileFn: func(ctx context.Context, userID string, user *dto.UserInput, staff *dto.StaffProfileInput) (bool, error) { - return true, nil - }, - - TransferClientFn: func(ctx context.Context, clientID, originFacilityID, destinationFacilityID string, reason enums.TransferReason, notes string) (bool, error) { - return true, nil - }, - - InvalidatePINFn: func(ctx context.Context, userID string) error { - return nil - }, - } -} - -//UpdateUserLastSuccessfulLogin updates users last successful login time -func (um *UpdateMock) UpdateUserLastSuccessfulLogin(ctx context.Context, userID string, lastLoginTime time.Time, flavour feedlib.Flavour) error { - return um.UpdateUserLastSuccessfulLoginFn(ctx, userID, lastLoginTime, flavour) -} - -// UpdateUserLastFailedLogin updates the users last failed login time -func (um *UpdateMock) UpdateUserLastFailedLogin(ctx context.Context, userID string, lastFailedLoginTime time.Time, flavour feedlib.Flavour) error { - return um.UpdateUserLastFailedLoginFn(ctx, userID, lastFailedLoginTime, flavour) -} - -// UpdateUserFailedLoginCount updates the users failed login count -func (um *UpdateMock) UpdateUserFailedLoginCount(ctx context.Context, userID string, failedLoginCount string, flavour feedlib.Flavour) error { - return um.UpdateUserFailedLoginCountFn(ctx, userID, failedLoginCount, flavour) -} - -// UpdateUserNextAllowedLogin updates the user's next allowed login time -func (um *UpdateMock) UpdateUserNextAllowedLogin(ctx context.Context, userID string, nextAllowedLoginTime time.Time, flavour feedlib.Flavour) error { - return um.UpdateUserNextAllowedLoginFn(ctx, userID, nextAllowedLoginTime, flavour) -} - -// UpdateStaffUserProfile mocks the implementation of UpdateStaffUserProfile method. -func (um *UpdateMock) UpdateStaffUserProfile(ctx context.Context, userID string, user *dto.UserInput, staff *dto.StaffProfileInput) (bool, error) { - return um.UpdateStaffUserProfileFn(ctx, userID, user, staff) -} - -// TransferClient mocks the implementation of TransferClient method -func (um *UpdateMock) TransferClient( - ctx context.Context, - clientID string, - originFacilityID string, - destinationFacilityID string, - reason enums.TransferReason, - notes string, -) (bool, error) { - return um.TransferClientFn(ctx, clientID, originFacilityID, destinationFacilityID, reason, notes) -} - -// InvalidatePIN mocks the invalidate pin method -func (um *UpdateMock) InvalidatePIN(ctx context.Context, userID string) error { - return um.InvalidatePINFn(ctx, userID) + return &UpdateMock{} } // DeleteMock .... diff --git a/pkg/onboarding/usecases/staff/config_test.go b/pkg/onboarding/usecases/staff/config_test.go deleted file mode 100644 index d2133e1d..00000000 --- a/pkg/onboarding/usecases/staff/config_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package staff_test - -import ( - "context" - "log" - "os" - "testing" - - "github.com/savannahghi/firebasetools" - onboardingExtension "github.com/savannahghi/onboarding-service/pkg/onboarding/application/extension" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" - "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/interactor" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/client" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/facility" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/metric" - usecaseMock "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/mock" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/staff" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/user" - baseExt "github.com/savannahghi/onboarding/pkg/onboarding/application/extension" - openSourceInfra "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure" - "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure/services/engagement" - libOnboardingUsecase "github.com/savannahghi/onboarding/pkg/onboarding/usecases" -) - -var ( - testInfrastructureInteractor infrastructure.Interactor - testInteractor interactor.Interactor - testFakeInfrastructureInteractor usecases.Interactor - - fakeCreate usecaseMock.CreateMock - fakeQuery usecaseMock.QueryMock - fakeUpdate usecaseMock.UpdateMock -) - -const ( - engagementService = "engagement" -) - -func TestMain(m *testing.M) { - ctx := context.Background() - - infra, err := InitializeTestInfrastructure(ctx) - if err != nil { - log.Printf("failed to initialize infrastructure: %v", err) - } - - interactor := InitializeTestInteractor(ctx) - - fakeInfra, err := InitializeFakeTestlInteractor(ctx) - if err != nil { - log.Printf("failed to initialize fake usecase interractor: %v", err) - } - testFakeInfrastructureInteractor = fakeInfra - - purgeRecords := func() { - - } - - purgeRecords() - - testInfrastructureInteractor = infra - testInteractor = interactor - - // run the tests - log.Printf("about to run tests\n") - code := m.Run() - log.Printf("finished running tests\n") - - // cleanup here - os.Exit(code) -} - -func InitializeTestInfrastructure(ctx context.Context) (infrastructure.Interactor, error) { - i := infrastructure.NewInteractor() - return i, nil -} - -func InitializeTestInteractor(ctx context.Context) interactor.Interactor { - osinfra := openSourceInfra.NewInfrastructureInteractor() - pgInstance, err := gorm.NewPGInstance() - if err != nil { - log.Fatal(err) - } - // Initialize ISC clients - engagementISC := onboardingExtension.NewInterServiceClient(engagementService) - infra := infrastructure.NewInteractor() - facilityUsecase := facility.NewFacilityUsecase(infra) - metricUsecase := metric.NewMetricUsecase(infra) - db := postgres.NewOnboardingDb(pgInstance, pgInstance, pgInstance, pgInstance) - var fc firebasetools.IFirebaseClient - baseExtension := baseExt.NewBaseExtensionImpl(fc) - pinExtension := baseExt.NewPINExtensionImpl() - onboardingExtension := onboardingExtension.NewOnboardingLibImpl() - engagement := engagement.NewServiceEngagementImpl(engagementISC, baseExtension) - libUsecasee := libOnboardingUsecase.NewUsecasesInteractor(osinfra, baseExtension, pinExtension) - userUsecase := user.NewUseCasesUserImpl(infra, onboardingExtension, engagement) - staff := staff.NewUsecasesStaffProfileImpl(infra) - client := client.NewUseCasesClientImpl(infra) - i := interactor.NewOnboardingInteractor(osinfra, *db, libUsecasee, facilityUsecase, metricUsecase, userUsecase, staff, client) - - return *i -} - -func InitializeFakeTestlInteractor(ctx context.Context) (usecases.Interactor, error) { - - var create infrastructure.Create = &fakeCreate - var query infrastructure.Query = &fakeQuery - var update infrastructure.Update = &fakeUpdate - - infra := func() infrastructure.Interactor { - return infrastructure.Interactor{ - Create: create, - Query: query, - Update: update, - } - }() - - i := usecases.NewUsecasesInteractor(infra) - - return i, nil -} diff --git a/pkg/onboarding/usecases/staff/staff.go b/pkg/onboarding/usecases/staff/staff.go deleted file mode 100644 index 6a26423e..00000000 --- a/pkg/onboarding/usecases/staff/staff.go +++ /dev/null @@ -1,74 +0,0 @@ -package staff - -import ( - "context" - - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" -) - -// IRegisterStaffUser contains staff registration methods -type IRegisterStaffUser interface { - // TODO: ensure default facility is set - // validation: ensure the staff profile has at least one facility - // ensure that the default facility is one of these - // TODO: ensure the user exists...userID in profile - RegisterStaffUser(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) -} - -// IUpdateStaffUser contains staff update methods -type IUpdateStaffUser interface { - // TODO: ensure default facility is set - // validation: ensure the staff profile has at least one facility - // ensure that the default facility is one of these - // TODO: ensure the user exists...userID in profile - UpdateStaffUserProfile(ctx context.Context, userID string, user *dto.UserInput, staff *dto.StaffProfileInput) (bool, error) -} - -// // IAddRoles contains add staff role methods -// type IAddRoles interface { -// AddRoles(userID string, roles []string) (bool, error) -// } - -// // IRemoveRole contains remove role methods for staff -// type IRemoveRole interface { -// RemoveRole(userID string, role string) (bool, error) -// } - -// // IUpdateDefaultFacility contains update default facility methods for staff -// type IUpdateDefaultFacility interface { -// // TODO: the list of facilities to switch between is strictly those that the user is assigned to -// UpdateDefaultFacility(userID string, facilityID string) (bool, error) -// } - -// UsecasesStaffProfile contains all the staff profile usecases -type UsecasesStaffProfile interface { - IRegisterStaffUser - IUpdateStaffUser - // IAddRoles - // IRemoveRole - // IUpdateDefaultFacility -} - -// UsecasesStaffProfileImpl represents user implementation object -type UsecasesStaffProfileImpl struct { - Infrastructure infrastructure.Interactor -} - -// NewUsecasesStaffProfileImpl returns a new staff profile service -func NewUsecasesStaffProfileImpl(infra infrastructure.Interactor) *UsecasesStaffProfileImpl { - return &UsecasesStaffProfileImpl{ - Infrastructure: infra, - } -} - -// RegisterStaffUser returns a staff profile -func (u *UsecasesStaffProfileImpl) RegisterStaffUser(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - return u.Infrastructure.RegisterStaffUser(ctx, user, staff) -} - -// UpdateStaffUserProfile updates a staff profile -func (u *UsecasesStaffProfileImpl) UpdateStaffUserProfile(ctx context.Context, userID string, user *dto.UserInput, staff *dto.StaffProfileInput) (bool, error) { - return u.Infrastructure.UpdateStaffUserProfile(ctx, userID, user, staff) -} diff --git a/pkg/onboarding/usecases/staff/staff_integration_test.go b/pkg/onboarding/usecases/staff/staff_integration_test.go deleted file mode 100644 index 321cbbc9..00000000 --- a/pkg/onboarding/usecases/staff/staff_integration_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package staff_test - -import ( - "context" - "testing" - - "github.com/Pallinder/go-randomdata" - "github.com/google/uuid" - "github.com/savannahghi/enumutils" - "github.com/savannahghi/feedlib" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" - "github.com/segmentio/ksuid" - "github.com/stretchr/testify/assert" -) - -func TestUseCaseStaffProfileImpl_RegisterStaffUser(t *testing.T) { - - f := testInfrastructureInteractor - ctx := context.Background() - - testFacilityID := uuid.New().String() - - code := ksuid.New().String() - facilityInput := dto.FacilityInput{ - Name: "test", - Code: code, - Active: true, - County: "test", - Description: "test description", - } - - //valid: Create a facility - facility, err := f.GetOrCreateFacility(ctx, facilityInput) - assert.Nil(t, err) - assert.NotNil(t, facility) - - // First Set of Valid Input - contactInput := &dto.ContactInput{ - Type: enums.PhoneContact, - Contact: randomdata.PhoneNumber(), - Active: true, - OptedIn: true, - } - - userInput := &dto.UserInput{ - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Gender: enumutils.GenderMale, - UserType: enums.HealthcareWorkerUser, - Contacts: []*dto.ContactInput{contactInput}, - Languages: []enumutils.Language{enumutils.LanguageEn}, - Flavour: feedlib.FlavourPro, - } - - staffID := ksuid.New().String() - 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, - }, - }, - Roles: []enums.RolesType{enums.RolesTypeCanInviteClient}, - } - - // Second set of valid Inputs - contactInput2 := &dto.ContactInput{ - Type: enums.PhoneContact, - Contact: randomdata.PhoneNumber(), - Active: true, - OptedIn: true, - } - - userInput2 := &dto.UserInput{ - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Gender: enumutils.GenderMale, - UserType: enums.HealthcareWorkerUser, - Contacts: []*dto.ContactInput{contactInput2}, - Languages: []enumutils.Language{enumutils.LanguageEn}, - Flavour: feedlib.FlavourPro, - } - - staffID2 := ksuid.New().String() - 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, - }, - }, - Roles: []enums.RolesType{enums.RolesTypeCanInviteClient}, - } - - // Invalid facility id - staffInputNoFacility := &dto.StaffProfileInput{ - StaffNumber: ksuid.New().String(), - 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 role - staffInputInvalidRole := &dto.StaffProfileInput{ - StaffNumber: ksuid.New().String(), - DefaultFacilityID: &testFacilityID, - Roles: []enums.RolesType{"invalid"}, - } - - // 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 - - // invalid: non existent facility assignment - useStaffProfile, err = f.RegisterStaffUser(ctx, userInput, staffInputNoFacility) - assert.Nil(t, useStaffProfile) - assert.NotNil(t, err) - - // invalid: invalid tole provided - useStaffProfile, err = f.RegisterStaffUser(ctx, userInput, staffInputInvalidRole) - assert.Nil(t, useStaffProfile) - assert.NotNil(t, err) - - //valid: create a staff user with valid parameters - useStaffProfile, err = f.RegisterStaffUser(ctx, userInput, staffInput) - assert.Nil(t, err) - assert.NotNil(t, useStaffProfile) - - //Invalid: creating a user with duplicate staff number and contact - useStaffProfile, err = f.RegisterStaffUser(ctx, userInput, staffInput) - assert.Nil(t, useStaffProfile) - assert.NotNil(t, err) - - //Invalid: creating a user with duplicate staff number (changed contact only) - useStaffProfile, err = f.RegisterStaffUser(ctx, userInput2, staffInput) - assert.Nil(t, useStaffProfile) - assert.NotNil(t, err) - - //Invalid: creating a user with duplicate Contact (changed staff number only) - useStaffProfile, err = f.RegisterStaffUser(ctx, userInput, staffInpu2) - assert.Nil(t, useStaffProfile) - assert.NotNil(t, err) - - // Valid: saves again if the duplicate Contact and Staff number are rectified - useStaffProfile, err = f.RegisterStaffUser(ctx, userInput2, staffInpu2) - assert.Nil(t, err) - assert.NotNil(t, useStaffProfile) - - // TODO: teardown the user and replace randomdata with gofakeit - -} - -func TestUsecasesStaffProfileImpl_UpdateStaffUser_Integration(t *testing.T) { - ctx := context.Background() - - f := testInfrastructureInteractor - i := testInteractor - - testFacilityID := uuid.New().String() - - code := ksuid.New().String() - facilityInput := dto.FacilityInput{ - Name: "test", - Code: code, - Active: true, - County: "test", - Description: "test description", - } - - //valid: Create a facility - facility, err := f.GetOrCreateFacility(ctx, facilityInput) - assert.Nil(t, err) - assert.NotNil(t, facility) - - // First Set of Valid Input - contactInput := &dto.ContactInput{ - Type: enums.PhoneContact, - Contact: randomdata.PhoneNumber(), - Active: true, - OptedIn: true, - } - - userInput := &dto.UserInput{ - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Gender: enumutils.GenderMale, - UserType: enums.HealthcareWorkerUser, - Contacts: []*dto.ContactInput{contactInput}, - Languages: []enumutils.Language{enumutils.LanguageEn}, - Flavour: feedlib.FlavourPro, - } - - staffID := ksuid.New().String() - staffInput := &dto.StaffProfileInput{ - StaffNumber: staffID, - DefaultFacilityID: facility.ID, - } - - // Second set of valid Inputs - contactInput2 := &dto.ContactInput{ - Type: enums.PhoneContact, - Contact: randomdata.PhoneNumber(), - Active: true, - OptedIn: true, - } - - userInput2 := &dto.UserInput{ - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Gender: enumutils.GenderMale, - UserType: enums.HealthcareWorkerUser, - Contacts: []*dto.ContactInput{contactInput2}, - Languages: []enumutils.Language{enumutils.LanguageSw}, - Flavour: feedlib.FlavourPro, - } - - staffInput2 := &dto.StaffProfileInput{ - StaffNumber: staffID, - DefaultFacilityID: facility.ID, - } - - // Invalid facility id - staffInputNoFacility := &dto.StaffProfileInput{ - StaffNumber: ksuid.New().String(), - DefaultFacilityID: &testFacilityID, - } - - //valid: create a staff user with valid parameters - userStaffProfile, err := f.RegisterStaffUser(ctx, userInput, staffInput) - assert.Nil(t, err) - assert.NotNil(t, userStaffProfile) - - // Valid userID - userProfile, err := f.GetUserProfileByUserID(ctx, *userStaffProfile.User.ID, userStaffProfile.User.Flavour) - assert.Nil(t, err) - assert.NotNil(t, userProfile) - - staffProfile, err5 := f.GetStaffProfile(ctx, staffID) - assert.Nil(t, err5) - assert.NotNil(t, staffProfile) - - updated, err := i.StaffUsecase.UpdateStaffUserProfile(ctx, *userStaffProfile.User.ID, userInput2, staffInput2) - assert.Nil(t, err) - assert.Equal(t, true, updated) - - //Invalid: update user with wrong data - userProfile2, err := f.GetUserProfileByUserID(ctx, *userStaffProfile.User.ID, userStaffProfile.User.Flavour) - assert.Nil(t, err) - assert.NotNil(t, userProfile2) - - staffProfile3, err6 := f.GetStaffProfile(ctx, "staffID") - assert.NotNil(t, err6) - assert.Nil(t, staffProfile3) - - updated2, err := i.StaffUsecase.UpdateStaffUserProfile(ctx, *userStaffProfile.User.ID, userInput2, staffInputNoFacility) - assert.NotNil(t, err) - assert.Equal(t, false, updated2) - -} diff --git a/pkg/onboarding/usecases/staff/staff_unit_test.go b/pkg/onboarding/usecases/staff/staff_unit_test.go deleted file mode 100644 index 142d66ef..00000000 --- a/pkg/onboarding/usecases/staff/staff_unit_test.go +++ /dev/null @@ -1,353 +0,0 @@ -package staff_test - -import ( - "context" - "fmt" - "testing" - "time" - - "github.com/google/uuid" - "github.com/savannahghi/enumutils" - "github.com/savannahghi/feedlib" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/segmentio/ksuid" - "github.com/stretchr/testify/assert" -) - -func TestOnboardingDb_RegisterStaffUser(t *testing.T) { - ctx := context.Background() - - testFacilityID := uuid.New().String() - testUserID := uuid.New().String() - testTime := time.Now() - testID := uuid.New().String() - - d := testFakeInfrastructureInteractor - - contactInput := &dto.ContactInput{ - Type: enums.PhoneContact, - Contact: "+254700000000", - Active: true, - OptedIn: true, - } - - userInput := &dto.UserInput{ - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Gender: enumutils.GenderMale, - UserType: enums.HealthcareWorkerUser, - Contacts: []*dto.ContactInput{contactInput}, - Languages: []enumutils.Language{enumutils.LanguageEn}, - Flavour: feedlib.FlavourPro, - } - - staffInput := &dto.StaffProfileInput{ - StaffNumber: "s123", - DefaultFacilityID: &testFacilityID, - Roles: []enums.RolesType{enums.RolesTypeCanInviteClient}, - } - - staffNoFacilityInput := &dto.StaffProfileInput{ - StaffNumber: "s123", - } - - type args struct { - ctx context.Context - user *dto.UserInput - staff *dto.StaffProfileInput - } - tests := []struct { - name string - args args - want *domain.StaffUserProfile - wantErr bool - }{ - { - name: "happy case", - args: args{ - ctx: ctx, - user: userInput, - staff: staffInput, - }, - wantErr: false, - }, - { - name: "invalid: missing facility", - args: args{ - ctx: ctx, - user: userInput, - staff: staffNoFacilityInput, - }, - wantErr: true, - }, - } - for _, tt := range tests { - - t.Run(tt.name, func(t *testing.T) { - - if tt.name == "happy case" { - - fakeCreate.GetOrCreateFacilityFn = func(ctx context.Context, facility dto.FacilityInput) (*domain.Facility, error) { - return &domain.Facility{ - ID: &testFacilityID, - Name: "test", - Code: "f1234", - Active: true, - County: "test", - Description: "test description", - }, nil - } - fakeCreate.RegisterStaffUserFn = func(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - contact := &domain.Contact{ - ID: &testID, - Type: enums.PhoneContact, - Contact: "+254700000000", - Active: true, - OptedIn: true, - } - return &domain.StaffUserProfile{ - User: &domain.User{ - ID: &testUserID, - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Gender: enumutils.GenderMale, - Active: true, - Contacts: []*domain.Contact{contact}, - UserType: enums.HealthcareWorkerUser, - Languages: []enumutils.Language{enumutils.LanguageEn}, - LastSuccessfulLogin: &testTime, - LastFailedLogin: &testTime, - NextAllowedLogin: &testTime, - FailedLoginCount: "0", - TermsAccepted: true, - AcceptedTermsID: testID, - Flavour: feedlib.FlavourPro, - }, - Staff: &domain.StaffProfile{ - ID: &testID, - 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, - }, - }, - Roles: []enums.RolesType{enums.RolesTypeCanInviteClient}, - }, - }, nil - } - } - - if tt.name == "invalid: missing facility" { - fakeCreate.RegisterStaffUserFn = func(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - return nil, fmt.Errorf("test error") - } - } - - _, err := d.RegisterStaffUser(tt.args.ctx, tt.args.user, tt.args.staff) - if (err != nil) != tt.wantErr { - t.Errorf("OnboardingDb.RegisterStaffUser() error = %v, wantErr %v", err, tt.wantErr) - return - } - }) - } -} - -func TestUsecasesStaffProfileImpl_UpdateStaffUser_Unittest(t *testing.T) { - ctx := context.Background() - - d := testFakeInfrastructureInteractor - - testFacilityID := uuid.New().String() - testUserID := uuid.New().String() - testTime := time.Now() - testID := uuid.New().String() - - contactInput := &dto.ContactInput{ - Type: enums.PhoneContact, - Contact: "+254700000000", - Active: true, - OptedIn: true, - } - - userInput := &dto.UserInput{ - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Gender: enumutils.GenderMale, - UserType: enums.HealthcareWorkerUser, - Contacts: []*dto.ContactInput{contactInput}, - Languages: []enumutils.Language{enumutils.LanguageEn}, - Flavour: feedlib.FlavourPro, - } - - staffInput := &dto.StaffProfileInput{ - StaffNumber: "s123", - DefaultFacilityID: &testFacilityID, - } - - staffNoFacilityInput := &dto.StaffProfileInput{ - StaffNumber: "s123", - DefaultFacilityID: nil, - } - - type args struct { - ctx context.Context - userID string - user *dto.UserInput - staff *dto.StaffProfileInput - } - tests := []struct { - name string - args args - want bool - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - userID: testUserID, - user: userInput, - staff: staffInput, - }, - wantErr: false, - }, - - { - name: "Sad case", - args: args{ - ctx: ctx, - userID: testUserID, - user: userInput, - staff: staffNoFacilityInput, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - - if tt.name == "Happy case" { - - fakeCreate.GetOrCreateFacilityFn = func(ctx context.Context, facility dto.FacilityInput) (*domain.Facility, error) { - return &domain.Facility{ - ID: &testFacilityID, - Name: "test", - Code: "f1234", - Active: true, - County: "test", - Description: "test description", - }, nil - } - - fakeCreate.RegisterStaffUserFn = func(ctx context.Context, user *dto.UserInput, staff *dto.StaffProfileInput) (*domain.StaffUserProfile, error) { - contact := &domain.Contact{ - ID: &testID, - Type: enums.PhoneContact, - Contact: "+254700000000", - Active: true, - OptedIn: true, - } - return &domain.StaffUserProfile{ - User: &domain.User{ - ID: &testUserID, - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Gender: enumutils.GenderMale, - Active: true, - Contacts: []*domain.Contact{contact}, - UserType: enums.HealthcareWorkerUser, - Languages: []enumutils.Language{enumutils.LanguageEn}, - LastSuccessfulLogin: &testTime, - LastFailedLogin: &testTime, - NextAllowedLogin: &testTime, - FailedLoginCount: "0", - TermsAccepted: true, - AcceptedTermsID: testID, - Flavour: feedlib.FlavourPro, - }, - Staff: &domain.StaffProfile{ - ID: &testID, - UserID: &testUserID, - StaffNumber: "s123", - DefaultFacilityID: &testFacilityID, - }, - }, nil - } - - fakeQuery.GetUserProfileByUserIDFn = func(ctx context.Context, userID string, flavour feedlib.Flavour) (*domain.User, error) { - UID := ksuid.New().String() - return &domain.User{ - ID: &UID, - Username: "TEST", - DisplayName: "TEST", - FirstName: "TEST", - MiddleName: "TEST", - LastName: "TEST", - UserType: "TEST", - Gender: "TEST", - Active: false, - Contacts: []*domain.Contact{}, - Languages: []enumutils.Language{enumutils.LanguageEn}, - LastSuccessfulLogin: &time.Time{}, - LastFailedLogin: &time.Time{}, - FailedLoginCount: "TEST", - NextAllowedLogin: &time.Time{}, - TermsAccepted: false, - AcceptedTermsID: "TEST", - Flavour: "TEST", - }, nil - } - - fakeUpdate.UpdateStaffUserProfileFn = func(ctx context.Context, userID string, user *dto.UserInput, staff *dto.StaffProfileInput) (bool, error) { - return true, nil - } - } - - if tt.name == "Sad case" { - fakeCreate.GetOrCreateFacilityFn = func(ctx context.Context, facility dto.FacilityInput) (*domain.Facility, error) { - return &domain.Facility{ - ID: &testFacilityID, - Name: "test", - Code: "f1234", - Active: true, - County: "test", - Description: "test description", - }, nil - } - - fakeUpdate.UpdateStaffUserProfileFn = func(ctx context.Context, userID string, user *dto.UserInput, staff *dto.StaffProfileInput) (bool, error) { - return false, fmt.Errorf("an error occurred while updating staff") - } - } - - got, err := d.UpdateStaffUserProfile(tt.args.ctx, tt.args.userID, tt.args.user, tt.args.staff) - if (err != nil) != tt.wantErr { - t.Errorf("UsecasesStaffProfileImpl.UpdateStaffUserProfile() error = %v, wantErr %v", err, tt.wantErr) - return - } - assert.NotNil(t, got) - }) - } -} diff --git a/pkg/onboarding/usecases/usecase.go b/pkg/onboarding/usecases/usecase.go index f902d0eb..e525f6c0 100644 --- a/pkg/onboarding/usecases/usecase.go +++ b/pkg/onboarding/usecases/usecase.go @@ -1,42 +1,20 @@ package usecases import ( - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/extension" "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/client" "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/facility" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/metric" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/staff" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/user" - engagementSvc "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure/services/engagement" ) // Interactor is an implementation of the usecases interface type Interactor struct { - *engagementSvc.ServiceEngagementImpl *facility.UseCaseFacilityImpl - *metric.UsecaseMetricsImpl - *user.UseCasesUserImpl - *client.UseCasesClientImpl - *staff.UsecasesStaffProfileImpl } // NewUsecasesInteractor initializes a new usecases interactor func NewUsecasesInteractor(infrastructure infrastructure.Interactor) Interactor { - var engagement *engagementSvc.ServiceEngagementImpl - onboardingExt := extension.NewOnboardingLibImpl() facility := facility.NewFacilityUsecase(infrastructure) - metrics := metric.NewMetricUsecase(infrastructure) - user := user.NewUseCasesUserImpl(infrastructure, onboardingExt, engagement) - client := client.NewUseCasesClientImpl(infrastructure) - staff := staff.NewUsecasesStaffProfileImpl(infrastructure) return Interactor{ - engagement, facility, - metrics, - user, - client, - staff, } } diff --git a/pkg/onboarding/usecases/user/config_test.go b/pkg/onboarding/usecases/user/config_test.go deleted file mode 100644 index a8e0a451..00000000 --- a/pkg/onboarding/usecases/user/config_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package user_test - -import ( - "context" - "log" - "os" - "testing" - - "github.com/savannahghi/firebasetools" - onboardingExtension "github.com/savannahghi/onboarding-service/pkg/onboarding/application/extension" - onboardingExtMock "github.com/savannahghi/onboarding-service/pkg/onboarding/application/extension/mock" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure/database/postgres/gorm" - "github.com/savannahghi/onboarding-service/pkg/onboarding/presentation/interactor" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/client" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/facility" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/metric" - usecaseMock "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/mock" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/staff" - "github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/user" - baseExt "github.com/savannahghi/onboarding/pkg/onboarding/application/extension" - openSourceInfra "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure" - "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure/services/engagement" - libOnboardingUsecase "github.com/savannahghi/onboarding/pkg/onboarding/usecases" -) - -var ( - testInfrastructureInteractor infrastructure.Interactor - testInteractor interactor.Interactor - testFakeInfrastructureInteractor usecases.Interactor - - fakeCreate usecaseMock.CreateMock - fakeQuery usecaseMock.QueryMock - fakeUpdate usecaseMock.UpdateMock - fakeOnboarding onboardingExtMock.FakeOnboardingLibraryExtensionImpl -) - -const ( - engagementService = "engagement" -) - -func TestMain(m *testing.M) { - ctx := context.Background() - - infra, err := InitializeTestInfrastructure(ctx) - if err != nil { - log.Printf("failed to initialize infrastructure: %v", err) - } - - interactor := InitializeTestInteractor(ctx) - - fakeInfra, err := InitializeFakeTestlInteractor(ctx) - if err != nil { - log.Printf("failed to initialize fake usecase interractor: %v", err) - } - testFakeInfrastructureInteractor = fakeInfra - - purgeRecords := func() { - - } - - purgeRecords() - - testInfrastructureInteractor = infra - testInteractor = interactor - - // run the tests - log.Printf("about to run tests\n") - code := m.Run() - log.Printf("finished running tests\n") - - // cleanup here - os.Exit(code) -} - -func InitializeTestInfrastructure(ctx context.Context) (infrastructure.Interactor, error) { - i := infrastructure.NewInteractor() - return i, nil -} - -func InitializeTestInteractor(ctx context.Context) interactor.Interactor { - osinfra := openSourceInfra.NewInfrastructureInteractor() - pgInstance, err := gorm.NewPGInstance() - if err != nil { - log.Fatal(err) - } - // Initialize ISC clients - engagementISC := onboardingExtension.NewInterServiceClient(engagementService) - infra := infrastructure.NewInteractor() - facilityUsecase := facility.NewFacilityUsecase(infra) - metricUsecase := metric.NewMetricUsecase(infra) - db := postgres.NewOnboardingDb(pgInstance, pgInstance, pgInstance, pgInstance) - var fc firebasetools.IFirebaseClient - baseExtension := baseExt.NewBaseExtensionImpl(fc) - pinExtension := baseExt.NewPINExtensionImpl() - onboardingExtension := onboardingExtension.NewOnboardingLibImpl() - engagement := engagement.NewServiceEngagementImpl(engagementISC, baseExtension) - libUsecasee := libOnboardingUsecase.NewUsecasesInteractor(osinfra, baseExtension, pinExtension) - userUsecase := user.NewUseCasesUserImpl(infra, onboardingExtension, engagement) - staff := staff.NewUsecasesStaffProfileImpl(infra) - client := client.NewUseCasesClientImpl(infra) - i := interactor.NewOnboardingInteractor(osinfra, *db, libUsecasee, facilityUsecase, metricUsecase, userUsecase, staff, client) - - return *i -} - -func InitializeFakeTestlInteractor(ctx context.Context) (usecases.Interactor, error) { - - var create infrastructure.Create = &fakeCreate - var query infrastructure.Query = &fakeQuery - var update infrastructure.Update = &fakeUpdate - - infra := func() infrastructure.Interactor { - return infrastructure.Interactor{ - Create: create, - Query: query, - Update: update, - } - }() - - i := usecases.NewUsecasesInteractor(infra) - - return i, nil -} diff --git a/pkg/onboarding/usecases/user/user.go b/pkg/onboarding/usecases/user/user.go deleted file mode 100644 index 19d21388..00000000 --- a/pkg/onboarding/usecases/user/user.go +++ /dev/null @@ -1,449 +0,0 @@ -package user - -import ( - "context" - "fmt" - "strconv" - "time" - - "github.com/savannahghi/feedlib" - "github.com/savannahghi/firebasetools" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/enums" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/extension" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/utils" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure" - "github.com/savannahghi/onboarding/pkg/onboarding/application/exceptions" - "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure/services/engagement" -) - -const ( - inviteSMSMessage = "You have been invited to My Afya Hub. Download the app on %v. Your single use pin is %v" - inviteLink = "https://bwl.mobi/dl" -) - -// ILogin ... -type ILogin interface { - // ... - // when successful: return the user object - // when not successful: nil user, error **code**, error - // error codes should be standardized (enum) - // the second param: intended for the clients (mobile, web) to understand - // the third param: a technical error that can be handled in Go e.g logged - // TODO: After verifying PIN, check PIN valid to - // if in future; allow login - // if in past; require change - // require change: communicate to mobile/web client via error code (second return value) - // ONLY create access token/cookie etc AFTER all checks pass - // TODO: error codes (second param) need to be a controlled list (enum) that is - // synchronized between the frontend clients, Go code and GraphQL schema. - // it needs to be discussed by mobile + backend devs together. - // TODO Only allow active users to log in - // TODO For successful logins, reset last failed login and failed login count; set last successful login - // TODO For failed logins: - // increment failed login count - // update last failed login timestamp - // set next allowed login timestamp - // use the failed login count (post increment) as the exponent to calculate the duration/interval - // to add in order to get the next allowed login timestamp - // the base (for the exponential backoff calculation) is a setting (env + default) - // default this base to 4...but override to 3 for a start in env - // TODO: Only users who have accepted terms can login - // TODO: Update metrics e.g login count, failed login count, successful login count etc - Login(ctx context.Context, userID string, pin string, flavour feedlib.Flavour) (*domain.AuthCredentials, string, error) -} - -// IUserForget models the behavior needed to comply with privacy laws e.g GDPR -// and "forget me" -type IUserForget interface { - - // Forget inactivates the user record AND hashes all identifiable information - // After this: the user should not be available on user lists or able to log in - // After this: it should not be possible to re-identify the user - // This is irreversible and the UX should ensure confirmation - // Validate: A user can only forget themselves - // Validate: PIN is correct - Forget(userID string, pin string, flavour string) (bool, error) -} - -// IRequestDataExport allows a user to request data known about them -// Mostly for legal compliance. -// The first impl. will simply create a task (for manual follow up) and acknowledge -type IRequestDataExport interface { - RequestDataExport(userID string, pin string, flavour string) (bool, error) -} - -// ISetUserPIN ... -type ISetUserPIN interface { - // SetUserPIN sets a user's PIN. - // It can be used to set a PIN for the first time. - // It can be used to change the PIN. - // It can also be used to change a PIN e.g on first login after invite or - // after expiry. - // TODO: auditable - // TODO: Consult CLIENT_PIN_VALIDITY_DAYS and PRO_PIN_VALIDITY DAYS env/setting to set expiry - // TODO: flavour is an enum...same enum used in profile e.g Client, Pro - // TODO: ensure that old PINs are not re-used - // this presumes that we keep a record of **hashed** PINs per user - // TODO Each time a PIN is set, recalculate valid to / valid from and update the - // cached IsActive value as appropriate i.e latest PIN active, others inactive - // - // PINs should not be re-used (compare hashed PINs) - // TODO: the user pin table has validity and each new PIN that is set should be a new - // 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) -} - -// IResetPIN ... -type IResetPIN interface { - // ResetPIN can be used by admins or healthcare workers to generate and send - // a new PIN for a client or other user. - // The new PIN is generated automatically and set to expire immediately so - // that a PIN change is forced on next login. - // TODO: Notify user after PIN reset - ResetPIN(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error) -} - -// IVerifyPIN is used e.g to check the PIN when accessing sensitive content -type IVerifyPIN interface { - VerifyPIN(userID string, flavour string, pin string) (bool, error) -} - -// IReviewTerms ... -type IReviewTerms interface { - - // ReviewTerms can be used to accept or review terms - ReviewTerms(userID string, accepted bool, flavour string) (bool, error) -} - -// IAnonymizedIdentifier ... -type IAnonymizedIdentifier interface { - // GetAnonymizedUserIdentifier is used to get an opaque (but **stable**) user - // identifier for events, analytics etc - GetAnonymizedUserIdentifier(userID string, flavour string) (string, error) -} - -// IAddPushToken ... -type IAddPushToken interface { - AddPushtoken(userID string, flavour string) (bool, error) -} - -// IRemovePushtoken ... -type IRemovePushtoken interface { - RemovePushToken(userID string, flavour string) (bool, error) -} - -// IUpdateLanguagePreferences ... -type IUpdateLanguagePreferences interface { - UpdateLanguagePreferences(userID string, language string) (bool, error) -} - -// IUserInvite ... -type IUserInvite interface { - - // TODO: send invite link via e.g SMS - // the invite deep link: opens the app if installed OR goes to the store if not installed - // a first time PIN is set and sent to the user - // this PIN must be changed on first use - // this PIN can be used only once - // **encode** first use PIN and user ID into invite link - // i.e not a generic invite link - // TODO: generate first time PIN, must change, link to user - // TODO: set the PIN valid to to the current moment so that the user is forced to change upon login - // TODO determine communication channel for invite (e.g SMS) from settings - Invite(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error) -} - -// UseCasesUser group all business logic usecases related to user -type UseCasesUser interface { - IUserInvite - IUserForget - ISetUserPIN - ILogin - IRequestDataExport - IReviewTerms - IAnonymizedIdentifier - IAddPushToken - IRemovePushtoken - IUpdateLanguagePreferences - IResetPIN -} - -// UseCasesUserImpl represents user implementation object -type UseCasesUserImpl struct { - Infrastructure infrastructure.Interactor - engagement engagement.ServiceEngagement - onboardingExt extension.OnboardingLibraryExtension -} - -// NewUseCasesUserImpl returns a new user service -func NewUseCasesUserImpl( - infra infrastructure.Interactor, - onboarding extension.OnboardingLibraryExtension, - engagement engagement.ServiceEngagement, -) *UseCasesUserImpl { - return &UseCasesUserImpl{ - Infrastructure: infra, - onboardingExt: onboarding, - engagement: engagement, - } -} - -// Login is used to login the user into the application -func (us *UseCasesUserImpl) Login(ctx context.Context, userID string, pin string, flavour feedlib.Flavour) (*domain.AuthCredentials, string, error) { - // Get user profile by UserID - userProfile, err := us.Infrastructure.GetUserProfileByUserID(ctx, userID, flavour) - if err != nil { - return nil, "", fmt.Errorf("unable to get user profile by userID: %v", err) - } - - var nextAllowedLoginTime time.Time - - if userProfile.NextAllowedLogin == nil { - nextAllowedLoginTime = time.Now() - } else { - nextAllowedLoginTime = *userProfile.NextAllowedLogin - } - - checkCurrentTime := time.Now() - if checkCurrentTime.Before(nextAllowedLoginTime) { - waitTime := nextAllowedLoginTime.Sub(checkCurrentTime).Seconds() - return nil, "", fmt.Errorf("unable to login at the moment. Please try again after %v seconds", waitTime) - } - - //Fetch PIN by UserID - userPINData, err := us.Infrastructure.GetUserPINByUserID(ctx, userID) - if err != nil { - return nil, "", fmt.Errorf("unable to get user PIN by userID: %v", err) - } - - //Compare PIN to check for validity - isMatch := us.onboardingExt.ComparePIN(pin, userPINData.Salt, userPINData.HashedPIN, nil) - // On any mis-match: - if !isMatch { - failedLoginCount, err := strconv.Atoi(userProfile.FailedLoginCount) - if err != nil { - return nil, "", err - } - failedLoginAttempts := failedLoginCount + 1 - //Convert trials to string - numberOfFailedAttempts := strconv.Itoa(failedLoginAttempts) - - // Implement exponential back-off, record the number of trials and last successful login - // 1. Record the user's number of failed login time - if err := us.Infrastructure.UpdateUserFailedLoginCount(ctx, userID, numberOfFailedAttempts, flavour); err != nil { - return nil, "unable to update number of user failed login counts", fmt.Errorf("unable to update number of user failed login counts: %v", err) - } - - // 2. Update user's last failed login time - lastFailedLoginTime := time.Now() - if err := us.Infrastructure.UpdateUserLastFailedLogin(ctx, userID, lastFailedLoginTime, flavour); err != nil { - return nil, "unable to update number of user last failed login time", fmt.Errorf("unable to update number of user last failed login time: %v", err) - } - - // Exponential back-off and Next Allowed Login time - nextAllowedLoginTime := utils.NextAllowedLoginTime(failedLoginAttempts) - if err := us.Infrastructure.UpdateUserNextAllowedLogin(ctx, userID, nextAllowedLoginTime, flavour); err != nil { - return nil, "unable to update user next allowed login time", fmt.Errorf("unable to update user next allowed: %v", err) - } - - return nil, "", fmt.Errorf("an error occurred") - } - - // Update last successful login - currentTime := time.Now() - if err := us.Infrastructure.UpdateUserLastSuccessfulLogin(ctx, userID, currentTime, flavour); err != nil { - return nil, "", fmt.Errorf("unable to update user last successful login: %v", err) - } - - // Reset failed login count to zero after successful login - if err := us.Infrastructure.UpdateUserFailedLoginCount(ctx, userID, "0", flavour); err != nil { - return nil, "unable to reset the number of failed user's failed login attempts", fmt.Errorf("unable to reset the number of failed user's failed login attempts: %v", err) - } - - customToken, err := firebasetools.CreateFirebaseCustomToken(ctx, *userProfile.ID) - if err != nil { - return nil, "", exceptions.CustomTokenError(err) - } - - userTokens, err := firebasetools.AuthenticateCustomFirebaseToken(customToken) - if err != nil { - return nil, "", exceptions.AuthenticateTokenError(err) - } - - //Generate Authentication credentials - authCredentials := &domain.AuthCredentials{ - User: userProfile, - RefreshToken: userTokens.RefreshToken, - IDToken: userTokens.IDToken, - ExpiresIn: userTokens.ExpiresIn, - } - - //Return authentication credentials, string and an error. - return authCredentials, "", nil -} - -// ResetPIN resets user PIN -func (us *UseCasesUserImpl) ResetPIN(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error) { - _, err := us.Infrastructure.GetUserProfileByUserID(ctx, userID, flavour) - if err != nil { - return false, fmt.Errorf("failed to get user profile: %v", err) - } - - pin, err := us.onboardingExt.GenerateTempPIN(ctx) - if err != nil { - return false, err - } - salt, encryptedPin := us.onboardingExt.EncryptPIN(pin, nil) - // Set the pin to be valid for a week - expiryDate := time.Now().AddDate(0, 0, 7) - - pinPayload := &domain.UserPIN{ - UserID: userID, - HashedPIN: encryptedPin, - Salt: salt, - ValidFrom: time.Now(), - ValidTo: expiryDate, - Flavour: flavour, - IsValid: true, - } - - err = us.Infrastructure.InvalidatePIN(ctx, userID) - if err != nil { - return false, fmt.Errorf("failed to invalidate existing pins: %v", err) - } - - _, err = us.Infrastructure.SavePin(ctx, pinPayload) - if err != nil { - return false, err - } - - // TODO: Notify user that pin reset occurred - - return true, nil -} - -// VerifyPIN verifies user PIN -func (us *UseCasesUserImpl) VerifyPIN(userID string, flavour string, pin string) (bool, error) { - return true, nil -} - -// ReviewTerms is used to accept or review terms -func (us *UseCasesUserImpl) ReviewTerms(userID string, accepted bool, flavour string) (bool, error) { - return true, nil -} - -// GetAnonymizedUserIdentifier is used to get an opaque (but **stable**) user -// -// identifier for events, analytics etc -func (us *UseCasesUserImpl) GetAnonymizedUserIdentifier(userID string, flavour string) (string, error) { - return "", nil -} - -// AddPushtoken adds push token to a user -func (us *UseCasesUserImpl) AddPushtoken(userID string, flavour string) (bool, error) { - return true, nil -} - -// RemovePushToken removes/retires user push token -func (us *UseCasesUserImpl) RemovePushToken(userID string, flavour string) (bool, error) { - return true, nil -} - -// UpdateLanguagePreferences updates user language preferences -func (us *UseCasesUserImpl) UpdateLanguagePreferences(userID string, language string) (bool, error) { - return true, nil -} - -// Invite sends an invite to a user (client/staff) -// The invite contains: link to app/play store, temporary PIN that **MUST** be changed on first login -// -// The default invite channel is SMS -func (us *UseCasesUserImpl) Invite(ctx context.Context, userID string, flavour feedlib.Flavour) (bool, error) { - pin, err := us.onboardingExt.GenerateTempPIN(ctx) - if err != nil { - return false, err - } - salt, encryptedPin := us.onboardingExt.EncryptPIN(pin, nil) - // Set the pin to be valid for a week - expiryDate := time.Now().AddDate(0, 0, 7) - - pinPayload := &domain.UserPIN{ - UserID: userID, - HashedPIN: encryptedPin, - Salt: salt, - ValidFrom: time.Now(), - ValidTo: expiryDate, - Flavour: flavour, - IsValid: true, - } - - _, err = us.Infrastructure.SavePin(ctx, pinPayload) - if err != nil { - return false, err - } - - user, err := us.Infrastructure.GetUserProfileByUserID(ctx, userID, flavour) - if err != nil { - return false, fmt.Errorf("failed to fetch a user profile: %v", err) - } - - var phoneNumber string - for _, contact := range user.Contacts { - if contact.Type == enums.PhoneContact { - phoneNumber = contact.Contact - } - } - - message := fmt.Sprintf(inviteSMSMessage, inviteLink, pin) - err = us.onboardingExt.SendSMS(ctx, []string{phoneNumber}, message) - if err != nil { - return false, fmt.Errorf("failed to send SMS: %v", err) - } - - return true, nil -} - -// SetUserPIN sets a user's PIN. -func (us *UseCasesUserImpl) SetUserPIN(ctx context.Context, input *dto.PinInput) (bool, error) { - //Get user profile PIN - - err := utils.ValidatePIN(input.PIN) - if err != nil { - return false, fmt.Errorf("invalid PIN provided: %v", err) - } - salt, encryptedPIN := us.onboardingExt.EncryptPIN(input.PIN, nil) - - isMatch := us.onboardingExt.ComparePIN(input.ConfirmedPin, salt, encryptedPIN, nil) - if !isMatch { - return false, fmt.Errorf("the provided PINs do not match") - } - - // Ensure that the PIN is only valid for the next 24 hours. - validTo := utils.GetHourMinuteSecond(24, 0, 0) - - pinDataInput := &domain.UserPIN{ - UserID: "57d64e09-4e15-4d38-983c-6d33cb6416ed", - HashedPIN: encryptedPIN, - ValidFrom: time.Now(), - ValidTo: validTo, // Consult for appropriate timings - Flavour: input.Flavour, - IsValid: isMatch, - Salt: salt, - } - - return us.Infrastructure.SavePin(ctx, pinDataInput) -} - -// Forget ... -func (us *UseCasesUserImpl) Forget(userID string, pin string, flavour string) (bool, error) { - return true, nil -} - -// RequestDataExport ... -func (us *UseCasesUserImpl) RequestDataExport(userID string, pin string, flavour string) (bool, error) { - return true, nil -} diff --git a/pkg/onboarding/usecases/user/user_integration_test.go b/pkg/onboarding/usecases/user/user_integration_test.go deleted file mode 100644 index 20ebe7ff..00000000 --- a/pkg/onboarding/usecases/user/user_integration_test.go +++ /dev/null @@ -1,237 +0,0 @@ -package user_test - -import ( - "context" - "strconv" - "testing" - "time" - - "github.com/savannahghi/feedlib" - "github.com/savannahghi/firebasetools" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/utils" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/segmentio/ksuid" - "github.com/tj/assert" -) - -func TestUseCasesUserImpl_SetUserPIN_Integration(t *testing.T) { - ctx := context.Background() - - m := testInfrastructureInteractor - - validPINInput := &dto.PinInput{ - PIN: "1234", - ConfirmedPin: "1234", - Flavour: feedlib.FlavourConsumer, - } - - invalidPINInput := &dto.PinInput{ - PIN: "12", - ConfirmedPin: "1234", - Flavour: "CONSUMER", - } - - invalidPINInput2 := &dto.PinInput{ - PIN: "", - ConfirmedPin: "", - Flavour: "CONSUMER", - } - - //check for valid PIN - err1 := utils.ValidatePIN(validPINInput.PIN) - assert.Nil(t, err1) - - // check for invalid PIN - err2 := utils.ValidatePIN(invalidPINInput.PIN) - assert.NotNil(t, err2) - - // check for empty PIN - err3 := utils.ValidatePIN(invalidPINInput2.PIN) - assert.NotNil(t, err3) - - salt, encodedPIN := m.EncryptPIN(validPINInput.PIN, nil) - - isMatch := m.ComparePIN(validPINInput.PIN, salt, encodedPIN, nil) - - pinDataInput := &domain.UserPIN{ - UserID: ksuid.New().String(), - HashedPIN: encodedPIN, - ValidFrom: time.Time{}, - ValidTo: time.Time{}, - Flavour: validPINInput.Flavour, - IsValid: isMatch, - Salt: salt, - } - - isTrue, err := m.SavePin(ctx, pinDataInput) - assert.Nil(t, err) - assert.NotNil(t, isTrue) - assert.Equal(t, true, isTrue) - -} - -func TestUseCasesUserImpl_Login_Integration_Test(t *testing.T) { - ctx := context.Background() - - m := testInfrastructureInteractor - i := testInteractor - - flavour := feedlib.FlavourConsumer - pin := "1234" - - facilityInput := dto.FacilityInput{ - Name: "test", - Code: "c123", - Active: true, - County: "test", - Description: "test description", - } - - // Create a facility - facility, err := i.FacilityUsecase.GetOrCreateFacility(ctx, facilityInput) - if err != nil { - t.Errorf("Failed to create facility: %v", err) - } - - userInput := &dto.UserInput{ - Username: "test", - DisplayName: "test", - FirstName: "test", - MiddleName: "test", - LastName: "test", - Flavour: feedlib.FlavourConsumer, - } - - staffInput := &dto.StaffProfileInput{ - StaffNumber: ksuid.New().String(), - DefaultFacilityID: facility.ID, - } - - // Register user - staffUserProfile, err := i.StaffUsecase.RegisterStaffUser(ctx, userInput, staffInput) - assert.Nil(t, err) - assert.NotNil(t, staffUserProfile) - - // Set PIN - salt, encodedPIN := m.EncryptPIN(pin, nil) - assert.NotNil(t, encodedPIN) - assert.NotNil(t, salt) - - PinInput := &domain.UserPIN{ - UserID: *staffUserProfile.User.ID, - HashedPIN: encodedPIN, - ValidFrom: time.Now(), - ValidTo: utils.GetHourMinuteSecond(24, 0, 0), - Flavour: flavour, - IsValid: true, - Salt: salt, - } - - isSet, err := m.SavePin(ctx, PinInput) - assert.Nil(t, err) - assert.Equal(t, true, isSet) - - // Valid userID - userProfile, err := m.GetUserProfileByUserID(ctx, *staffUserProfile.User.ID, flavour) - assert.Nil(t, err) - assert.NotNil(t, userProfile) - - //Valid: Fetch PIN by UserID - userPINData, err := m.GetUserPINByUserID(ctx, *userProfile.ID) - assert.Nil(t, err) - assert.NotNil(t, userPINData) - - isMatch := m.ComparePIN("1234", userPINData.Salt, userPINData.HashedPIN, nil) - assert.Equal(t, true, isMatch) - - successTime := time.Now() - err = m.UpdateUserLastSuccessfulLogin(ctx, *userProfile.ID, successTime, flavour) - assert.Nil(t, err) - - err = m.UpdateUserFailedLoginCount(ctx, *userProfile.ID, "0", flavour) - assert.Nil(t, err) - - customToken, err := firebasetools.CreateFirebaseCustomToken(ctx, *userProfile.ID) - assert.Nil(t, err) - assert.NotNil(t, customToken) - - userTokens, err := firebasetools.AuthenticateCustomFirebaseToken(customToken) - assert.Nil(t, err) - assert.NotNil(t, userTokens) - - //Login - authCred, str, err := i.UserUsecase.Login(ctx, *userProfile.ID, pin, userProfile.Flavour) - assert.Nil(t, err) - assert.Empty(t, str) - assert.NotNil(t, str) - assert.NotNil(t, authCred) - - // Invalid - invalidPIN1 := "4321" - profile, err1 := m.GetUserProfileByUserID(ctx, *staffUserProfile.User.ID, flavour) - assert.Nil(t, err1) - assert.NotNil(t, profile) - - //Valid: Fetch PIN by UserID - userPINData2, err2 := m.GetUserPINByUserID(ctx, *profile.ID) - assert.Nil(t, err2) - assert.NotNil(t, userPINData2) - - isMatch = m.ComparePIN(invalidPIN1, userPINData.Salt, userPINData.HashedPIN, nil) - assert.Equal(t, false, isMatch) - - err3 := m.UpdateUserFailedLoginCount(ctx, *profile.ID, "1", flavour) - assert.Nil(t, err3) - - lastFailedLoginTime := time.Now() - err4 := m.UpdateUserLastFailedLogin(ctx, *staffUserProfile.User.ID, lastFailedLoginTime, flavour) - assert.Nil(t, err4) - - //Cannot Login - authCred, str, err = i.UserUsecase.Login(ctx, *staffUserProfile.User.ID, invalidPIN1, flavour) - assert.NotNil(t, err) - assert.Empty(t, str) - assert.Nil(t, authCred) - - invalidPIN2 := "4321" - profile2, err5 := m.GetUserProfileByUserID(ctx, *staffUserProfile.User.ID, flavour) - assert.Nil(t, err5) - assert.NotNil(t, profile2) - - //Valid: Fetch PIN by UserID - userPINData3, err6 := m.GetUserPINByUserID(ctx, *profile2.ID) - assert.Nil(t, err6) - assert.NotNil(t, userPINData3) - - isMatch2 := m.ComparePIN(invalidPIN2, userPINData.Salt, userPINData.HashedPIN, nil) - assert.Equal(t, false, isMatch) - if !isMatch2 { - failedLoginCount, err7 := strconv.Atoi(profile2.FailedLoginCount) - assert.Nil(t, err7) - assert.NotNil(t, failedLoginCount) - trials := failedLoginCount + 1 - //Convert trials to string - numberOfTrials := strconv.Itoa(trials) - assert.NotNil(t, numberOfTrials) - - err8 := m.UpdateUserFailedLoginCount(ctx, *profile2.ID, numberOfTrials, flavour) - assert.Nil(t, err8) - - lastFailedLoginTime := time.Now() - err9 := m.UpdateUserLastFailedLogin(ctx, *profile2.ID, lastFailedLoginTime, flavour) - assert.Nil(t, err9) - - nextAllowedLoginTime := utils.NextAllowedLoginTime(trials) - err10 := m.UpdateUserNextAllowedLogin(ctx, *profile2.ID, nextAllowedLoginTime, flavour) - assert.Nil(t, err10) - - } - - //Cannot Login - authCred, str, err = i.UserUsecase.Login(ctx, *staffUserProfile.User.ID, invalidPIN2, flavour) - assert.NotNil(t, err) - assert.Empty(t, str) - assert.Nil(t, authCred) - -} diff --git a/pkg/onboarding/usecases/user/user_unit_test.go b/pkg/onboarding/usecases/user/user_unit_test.go deleted file mode 100644 index 50d93fc7..00000000 --- a/pkg/onboarding/usecases/user/user_unit_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package user_test - -import ( - "context" - "fmt" - "testing" - - "github.com/savannahghi/feedlib" - "github.com/savannahghi/onboarding-service/pkg/onboarding/application/dto" - "github.com/savannahghi/onboarding-service/pkg/onboarding/domain" - "github.com/savannahghi/onboarding/pkg/onboarding/application/extension" -) - -func TestUseCasesUserImpl_SetUserPIN_Unittest(t *testing.T) { - ctx := context.Background() - - f := testFakeInfrastructureInteractor - - validPINInput := &dto.PinInput{ - PIN: "1234", - ConfirmedPin: "1234", - Flavour: feedlib.FlavourConsumer, - } - - invalidPINInput := &dto.PinInput{ - PIN: "", - ConfirmedPin: "1234", - Flavour: "CONSUMER", - } - - type args struct { - ctx context.Context - input *dto.PinInput - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Happy case", - args: args{ - ctx: ctx, - input: validPINInput, - }, - wantErr: false, - }, - { - name: "Sad case", - args: args{ - ctx: ctx, - input: invalidPINInput, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.name == "Sad case" { - fakeCreate.SavePinFn = func(ctx context.Context, pinData *domain.UserPIN) (bool, error) { - return false, fmt.Errorf("an error occurred") - } - } - if tt.name == "Happy case" { - fakeOnboarding.EncryptPINFn = func(rawPwd string, options *extension.Options) (string, string) { - return "salt", "encryptedPIN" - } - fakeCreate.SavePinFn = func(ctx context.Context, pinData *domain.UserPIN) (bool, error) { - return true, nil - } - } - _, err := f.SetUserPIN(tt.args.ctx, tt.args.input) - if (err != nil) != tt.wantErr { - t.Errorf("UseCasesUserImpl.SetUserPIN() error = %v, wantErr %v", err, tt.wantErr) - return - } - - }) - } -}