Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: clean up MOSIP code #7879

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions packages/client/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -15140,18 +15140,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "mosipAid",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "otherInformantType",
"description": null,
Expand Down Expand Up @@ -15523,18 +15511,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "mosipAid",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "otherInformantType",
"description": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export function setBirthRegistrationSectionTransformer(
draftData[sectionId].registrationNumber
}

if (draftData[sectionId].mosipAid) {
transformedData[sectionId].mosipAid = draftData[sectionId].mosipAid
}

if (!transformedData[sectionId].status) {
transformedData[sectionId].status = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,3 @@ export function getBirthRegistrationSectionTransformer(
transformStatusData(transformedData, queryData[sectionId].status, sectionId)
}
}

export function mosipAidTransformer(
transformedData: IFormData,
queryData: any,
sectionId: string,
targetSectionId?: string,
targetFieldName?: string
) {
if (queryData[sectionId].mosipAid) {
transformedData[targetSectionId || sectionId][
targetFieldName || 'mosipAid'
] = queryData[sectionId].mosipAid
}
}

export function mosipAidLabelTransformer(
transformedData: IFormData,
queryData: any,
sectionId: string,
targetSectionId?: string,
targetFieldName?: string
) {
if (queryData[sectionId].mosipAid) {
transformedData[targetSectionId || sectionId][
targetFieldName || 'mosipAIDLabel'
] = 'MOSIP Application ID'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,33 +123,6 @@ export const fieldToIdentityTransformer =
return transformedData
}

export const nidVerificationFieldToIdentityTransformer = (
transformedData: TransformedData,
draftData: IFormData,
sectionId: string,
field: IFormField
) => {
fieldToIdentityTransformer('id', 'MOSIP_PSUT_TOKEN_ID')(
transformedData,
draftData,
sectionId,
field
)
const sectionData = transformedData[sectionId]
const existingIdentity = sectionData.identifier.find(
(identifier: IdentityType) =>
identifier.type && identifier.type === 'MOSIP_PSUT_TOKEN_ID'
)
if (existingIdentity) {
const modifiedFields = draftData[sectionId][
'fieldsModifiedByNidUserInfo'
] as string[] | undefined
existingIdentity['fieldsModifiedByIdentity'] =
modifiedFields?.join(',') ?? ''
}
return transformedData
}

interface IAddress {
[key: string]: any
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
DeathRegistration,
MarriageRegistration,
Address,
IdentityType,
EventRegistration
} from '@client/utils/gateway'
import {
Expand Down Expand Up @@ -241,36 +240,6 @@ export const identityToFieldTransformer =
return transformedData
}

export const identityToNidVerificationFieldTransformer = (
transformedData: IFormData,
queryData: QueryData,
sectionId: SectionId,
field: IFormField
) => {
identityToFieldTransformer('id', 'MOSIP_PSUT_TOKEN_ID')(
transformedData,
queryData,
sectionId,
field
)
const existingIdentity = queryData[sectionId]?.identifier?.find(
(identity: IdentityType) =>
(identity.type as string) === 'MOSIP_PSUT_TOKEN_ID'
)
if (!transformedData[sectionId]) {
transformedData[sectionId] = {}
}

if (existingIdentity) {
const modifiedFields = existingIdentity[
'fieldsModifiedByIdentity'
] as string[]
transformedData[sectionId].fieldsModifiedByNidUserInfo = modifiedFields
}

return transformedData
}

export const addressQueryTransformer =
(config: {
useCase: string
Expand Down Expand Up @@ -625,52 +594,6 @@ export const nestedValueToFieldTransformer =
return transformedData
}

export const nestedIdentityValueToFieldTransformer =
(nestedField: SectionId) =>
(
transformedData: IFormData,
queryData: QueryData,
sectionId: SectionId,
field: IFormField
) => {
if (!queryData[sectionId] || !queryData[sectionId][nestedField]) {
return transformedData
}
const clonedData = cloneDeep(transformedData)
if (!clonedData[nestedField]) {
clonedData[nestedField] = {}
}

identityToFieldTransformer('id', 'MOSIP_PSUT_TOKEN_ID')(
clonedData,
queryData[sectionId],
nestedField,
field
)

if (clonedData[nestedField][field.name] === undefined) {
return transformedData
}
transformedData[sectionId][field.name] = clonedData[nestedField][field.name]

const existingIdentity = queryData[sectionId][nestedField].identifier?.find(
(identity: IdentityType) =>
(identity.type as string) === 'MOSIP_PSUT_TOKEN_ID'
)
if (!transformedData[sectionId]) {
transformedData[sectionId] = {}
}

if (existingIdentity) {
const modifiedFields = existingIdentity[
'fieldsModifiedByIdentity'
] as string[]
transformedData[sectionId].fieldsModifiedByNidUserInfo = modifiedFields
}

return transformedData
}

export const booleanTransformer = (
transformedData: IFormData,
queryData: QueryData,
Expand Down
50 changes: 0 additions & 50 deletions packages/client/src/tests/forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
"operation": "registrationNumberTransformer"
},
{ "fieldName": "qrCode", "operation": "QRCodeTransformer" },
{ "fieldName": "mosipAid", "operation": "mosipAidTransformer" },
{
"fieldName": "mosipAIDLabel",
"operation": "mosipAidLabelTransformer"
},
{
"fieldName": "certificateDate",
"operation": "certificateDateTransformer",
Expand Down Expand Up @@ -1106,51 +1101,6 @@
}
}
},
{
"name": "informantNidVerification",
"type": "NID_VERIFICATION_BUTTON",
"label": {
"defaultMessage": "National ID number (in English)",
"description": "Option for form field: Type of ID",
"id": "form.field.label.iDTypeNationalID"
},
"required": true,
"initialValue": "",
"validator": [],
"conditionals": [
{
"action": "hide",
"expression": "const nationalIdSystem =\n offlineCountryConfig &&\n offlineCountryConfig.systems.find(s => s.integratingSystemType === 'MOSIP');\n !nationalIdSystem ||\n !nationalIdSystem.settings.openIdProviderBaseUrl ||\n !nationalIdSystem.settings.openIdProviderClientId ||\n !nationalIdSystem.settings.openIdProviderClaims;\n "
},
{
"action": "hide",
"expression": "((values.informantType===\"MOTHER\") || (values.informantType===\"FATHER\") || (!values.informantType))"
}
],
"mapping": {
"mutation": {
"operation": "nidVerificationFieldToIdentityTransformer"
},
"query": {
"operation": "identityToNidVerificationFieldTransformer"
}
},
"labelForVerified": {
"defaultMessage": "Authenticated",
"description": "label for unverified nid state",
"id": "form.field.nidVerified"
},
"labelForUnverified": {
"defaultMessage": "Authenticate",
"description": "label for verified nid state",
"id": "form.field.nidNotVerified"
},
"labelForOffline": {
"defaultMessage": "National ID authentication is currently not available offline.",
"description": "Label for indicating offline status for the user. NID verification is not currently available offline.",
"id": "form.field.nidVerificationOngoing"
}
},
{
"name": "primaryAddress",
"type": "SUBSECTION_HEADER",
Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/tests/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,6 @@ type Registration {
_fhirID: ID
draftId: String
trackingId: String
mosipAid: String
registrationNumber: String
paperFormID: String
page: String
Expand Down Expand Up @@ -1490,7 +1489,6 @@ input RegistrationInput {
_fhirID: ID
draftId: String
trackingId: String
mosipAid: String
registrationNumber: String
paperFormID: String
page: String
Expand Down
9 changes: 0 additions & 9 deletions packages/client/src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,6 @@ export type Registration = {
inCompleteFields?: Maybe<Scalars['String']>
informantType?: Maybe<Scalars['String']>
informantsSignature?: Maybe<Scalars['String']>
mosipAid?: Maybe<Scalars['String']>
otherInformantType?: Maybe<Scalars['String']>
page?: Maybe<Scalars['String']>
paperFormID?: Maybe<Scalars['String']>
Expand Down Expand Up @@ -1736,7 +1735,6 @@ export type RegistrationInput = {
informantType?: InputMaybe<Scalars['String']>
informantsSignature?: InputMaybe<Scalars['String']>
location?: InputMaybe<LocationInput>
mosipAid?: InputMaybe<Scalars['String']>
otherInformantType?: InputMaybe<Scalars['String']>
page?: InputMaybe<Scalars['String']>
paperFormID?: InputMaybe<Scalars['String']>
Expand Down Expand Up @@ -3225,7 +3223,6 @@ export type FetchBirthRegistrationForReviewQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down Expand Up @@ -3572,7 +3569,6 @@ export type FetchBirthRegistrationForCertificateQuery = {
informantsSignature?: string | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
status?: Array<{
__typename?: 'RegWorkflow'
type?: RegStatus | null
Expand Down Expand Up @@ -4752,7 +4748,6 @@ export type FetchMarriageRegistrationForReviewQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down Expand Up @@ -5107,7 +5102,6 @@ export type FetchMarriageRegistrationForCertificateQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down Expand Up @@ -7829,7 +7823,6 @@ export type FetchViewRecordByCompositionQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down Expand Up @@ -8215,7 +8208,6 @@ export type FetchViewRecordByCompositionQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down Expand Up @@ -8533,7 +8525,6 @@ export type FetchViewRecordByCompositionQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down
Loading
Loading