From 1ff4c9154950e4a44c9b654c1eb8363e927a0a3f Mon Sep 17 00:00:00 2001 From: Alessandro Dell'Oste Date: Tue, 26 Sep 2023 23:20:06 +0200 Subject: [PATCH] feat: [IOCOM-555] Replace `FullReceivedNotification` with the autogenerated one (#5024) ## Short description This PR replaces the `FullReceivedNotification` type with the autogenerated one. ## List of changes proposed in this pull request - updated definitions - replaced the `FullReceivedNotification` with the autogenerated `IOReceivedNotification`. ## How to test run the tests and verify that everything works --------- Co-authored-by: Andrea --- package.json | 25 ++--- ts/features/pn/analytics/index.ts | 6 +- .../pn/components/LegacyPnMessageDetails.tsx | 3 +- .../pn/components/PnMessageDetails.tsx | 3 +- .../pn/components/PnMessagePayment.tsx | 2 +- .../__test__/PnMessageDetails.test.tsx | 6 +- .../__test__/PnMessagePayment.test.tsx | 2 +- .../screens/LegacyPnMessageDetailsScreen.tsx | 3 +- .../pn/screens/PnMessageDetailsScreen.tsx | 3 +- .../pn/store/types/__test__/types.test.ts | 26 +++--- ts/features/pn/store/types/transformers.ts | 18 ++-- ts/features/pn/store/types/types.ts | 92 +------------------ ts/features/pn/utils/index.ts | 7 +- ts/features/pn/utils/rptId.ts | 2 +- 14 files changed, 57 insertions(+), 141 deletions(-) diff --git a/package.json b/package.json index ed14239e9c6..f6dff7dfc8e 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,23 @@ { "name": "italia-app", "version": "2.42.0-rc.1", - "io_backend_api": "https://raw.githubusercontent.com/pagopa/io-backend/v12.6.1-RELEASE/api_backend.yaml", - "io_public_api": "https://raw.githubusercontent.com/pagopa/io-backend/v12.6.1-RELEASE/api_public.yaml", + "io_backend_api": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/api_backend.yaml", + "io_public_api": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/api_public.yaml", "io_content_specs": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.27/definitions.yml", - "io_bonus_vacanze_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v12.6.1-RELEASE/api_bonus.yaml", - "io_cgn_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v13.2.1-RELEASE/api_cgn.yaml", - "io_cgn_merchants_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v13.2.1-RELEASE/api_cgn_operator_search.yaml", + "io_bonus_vacanze_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/api_bonus.yaml", + "io_cgn_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/api_cgn.yaml", + "io_cgn_merchants_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/api_cgn_operator_search.yaml", "io_bpd_citizen": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.27/bonus/specs/bpd/citizen.json", "io_bpd_citizen_v2": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.27/bonus/specs/bpd/citizen_v2.json", "io_bpd_payment": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.27/bonus/specs/bpd/payment.json", "io_bpd_award_periods": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.27/bonus/specs/bpd/award.json", "io_bpd_winning_transactions": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.27/bonus/specs/bpd/winning_transactions.json", "io_bpd_winning_transactions_v2": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.27/bonus/specs/bpd/winning_transactions_v2.json", - "api_fci": "https://raw.githubusercontent.com/pagopa/io-backend/v12.6.1-RELEASE/api_io_sign.yaml", - "io_eu_covid_cert": "https://raw.githubusercontent.com/pagopa/io-backend/v12.6.1-RELEASE/api_eucovidcert.yaml", - "io_sicilia_vola_token": "https://raw.githubusercontent.com/pagopa/io-backend/v12.6.1-RELEASE/api_mit_voucher.yaml", - "io_pn_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v12.6.1-RELEASE/api_pn.yaml", + "api_fci": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/api_io_sign.yaml", + "io_eu_covid_cert": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/api_eucovidcert.yaml", + "io_sicilia_vola_token": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/api_mit_voucher.yaml", + "io_pn_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/api_pn.yaml", + "io_consumed_pn_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/openapi/consumed/api-piattaforma-notifiche.yaml", "api_sicilia_vola": "assets/SiciliaVola.yml", "api_cdc": "assets/CdcSwagger.yml", "pagopa_api": "assets/paymentManager/spec.json", @@ -24,8 +25,8 @@ "pagopa_cobadge_configuration": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.27/pagopa/cobadge/abi_definitions.yml", "pagopa_privative_configuration": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.27/pagopa/privative/definitions.yml", "idpay_api": "https://raw.githubusercontent.com/pagopa/cstar-infrastructure/v3.3.0/src/domains/idpay-app/api/idpay_appio_full/openapi.appio.full.yml", - "lollipop_api": "https://raw.githubusercontent.com/pagopa/io-backend/v12.6.1-RELEASE/api_lollipop_first_consumer.yaml", - "fast_login_api": "https://raw.githubusercontent.com/pagopa/io-backend/v12.6.1-RELEASE/openapi/generated/api_fast_login.yaml", + "lollipop_api": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/api_lollipop_first_consumer.yaml", + "fast_login_api": "https://raw.githubusercontent.com/pagopa/io-backend/v13.6.2-RELEASE/openapi/generated/api_fast_login.yaml", "pagopa_api_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/ca0f61d6c764dcc8a8594c1593d436dcdae58a7c/src/domains/wallet-app/api/wallet-service/v1/_openapi.json.tpl", "private": true, "scripts": { @@ -75,7 +76,7 @@ "generate:eu-covid-cert": "rimraf definitions/eu_covid_cert && mkdir -p definitions/eu_covid_cert && gen-api-models --api-spec $npm_package_io_eu_covid_cert --out-dir ./definitions/eu_covid_cert --no-strict --request-types --response-decoders", "generate:io_sicilia_vola_token": "rimraf definitions/io_sicilia_vola_token && mkdir -p definitions/io_sicilia_vola_token && gen-api-models --api-spec $npm_package_io_sicilia_vola_token --out-dir ./definitions/io_sicilia_vola_token --no-strict --request-types --response-decoders", "generate:sicilia_vola_api": "rimraf definitions/api_sicilia_vola && mkdir -p definitions/api_sicilia_vola && gen-api-models --api-spec $npm_package_api_sicilia_vola --out-dir ./definitions/api_sicilia_vola --no-strict --request-types --response-decoders", - "generate:pn-definitions": "rimraf definitions/pn && mkdir -p definitions/pn && gen-api-models --api-spec $npm_package_io_pn_specs --out-dir ./definitions/pn --no-strict --request-types --response-decoders", + "generate:pn-definitions": "rimraf definitions/pn && mkdir -p definitions/pn && gen-api-models --api-spec $npm_package_io_consumed_pn_specs --out-dir ./definitions/pn && gen-api-models --api-spec $npm_package_io_pn_specs --out-dir ./definitions/pn --no-strict --request-types --response-decoders", "generate:pagopa-api-walletv2": "rimraf definitions/pagopa/walletv2 && mkdir -p definitions/pagopa/walletv2 && gen-api-models --api-spec $npm_package_pagopa_api_walletv2 --out-dir ./definitions/pagopa/walletv2 --no-strict --request-types --response-decoders", "generate:pagopa-cobadge-configuration": "rimraf definitions/pagopa/cobadge/configuration && mkdir -p definitions/pagopa/cobadge/configuration && gen-api-models --api-spec $npm_package_pagopa_cobadge_configuration --out-dir ./definitions/pagopa/cobadge/configuration", "generate:pagopa-privative-configuration": "rimraf definitions/pagopa/privative/configuration && mkdir -p definitions/pagopa/privative/configuration && gen-api-models --api-spec $npm_package_pagopa_privative_configuration --out-dir ./definitions/pagopa/privative/configuration", diff --git a/ts/features/pn/analytics/index.ts b/ts/features/pn/analytics/index.ts index adb713e1745..7dffd1d3804 100644 --- a/ts/features/pn/analytics/index.ts +++ b/ts/features/pn/analytics/index.ts @@ -3,10 +3,8 @@ import * as A from "fp-ts/lib/Array"; import * as O from "fp-ts/lib/Option"; import { mixpanelTrack } from "../../../mixpanel"; import { TransactionSummaryErrorContent } from "../../../screens/wallet/payment/NewTransactionSummaryScreen"; -import { - NotificationStatusHistoryElement, - PNMessage -} from "../../pn/store/types/types"; +import { PNMessage } from "../../pn/store/types/types"; +import { NotificationStatusHistoryElement } from "../../../../definitions/pn/NotificationStatusHistoryElement"; import { UIAttachment } from "../../../store/reducers/entities/messages/types"; import { booleanToYesNo, buildEventProperties } from "../../../utils/analytics"; diff --git a/ts/features/pn/components/LegacyPnMessageDetails.tsx b/ts/features/pn/components/LegacyPnMessageDetails.tsx index 3b1c5c0e108..13c2cbf7ce7 100644 --- a/ts/features/pn/components/LegacyPnMessageDetails.tsx +++ b/ts/features/pn/components/LegacyPnMessageDetails.tsx @@ -30,7 +30,8 @@ import { useOnFirstRender } from "../../../utils/hooks/useOnFirstRender"; import { isDuplicatedPayment } from "../../../utils/payment"; import { MessageAttachments } from "../../messages/components/MessageAttachments"; import PN_ROUTES from "../navigation/routes"; -import { NotificationPaymentInfo, PNMessage } from "../store/types/types"; +import { PNMessage } from "../store/types/types"; +import { NotificationPaymentInfo } from "../../../../definitions/pn/NotificationPaymentInfo"; import { trackPNAttachmentOpening, trackPNPaymentInfoError, diff --git a/ts/features/pn/components/PnMessageDetails.tsx b/ts/features/pn/components/PnMessageDetails.tsx index 274a94d315b..c4c662b68ec 100644 --- a/ts/features/pn/components/PnMessageDetails.tsx +++ b/ts/features/pn/components/PnMessageDetails.tsx @@ -27,7 +27,8 @@ import { useOnFirstRender } from "../../../utils/hooks/useOnFirstRender"; import { isDuplicatedPayment } from "../../../utils/payment"; import { MessageAttachments } from "../../messages/components/MessageAttachments"; import PN_ROUTES from "../navigation/routes"; -import { NotificationPaymentInfo, PNMessage } from "../store/types/types"; +import { PNMessage } from "../store/types/types"; +import { NotificationPaymentInfo } from "../../../../definitions/pn/NotificationPaymentInfo"; import { trackPNAttachmentOpening, trackPNPaymentInfoError, diff --git a/ts/features/pn/components/PnMessagePayment.tsx b/ts/features/pn/components/PnMessagePayment.tsx index 400950b619f..083e2b7a81d 100644 --- a/ts/features/pn/components/PnMessagePayment.tsx +++ b/ts/features/pn/components/PnMessagePayment.tsx @@ -4,7 +4,7 @@ import React from "react"; import I18n from "i18n-js"; import { VSpacer } from "@pagopa/io-app-design-system"; import { useNavigation } from "@react-navigation/native"; -import { NotificationPaymentInfo } from "../store/types/types"; +import { NotificationPaymentInfo } from "../../../../definitions/pn/NotificationPaymentInfo"; import { TransactionSummary } from "../../../screens/wallet/payment/components/TransactionSummary"; import { TransactionSummaryErrorDetails } from "../../../screens/wallet/payment/components/TransactionSummaryErrorDetails"; import { PotFromActions } from "../../../types/utils"; diff --git a/ts/features/pn/components/__test__/PnMessageDetails.test.tsx b/ts/features/pn/components/__test__/PnMessageDetails.test.tsx index 15c252f68a1..5b81d1f96d0 100644 --- a/ts/features/pn/components/__test__/PnMessageDetails.test.tsx +++ b/ts/features/pn/components/__test__/PnMessageDetails.test.tsx @@ -16,8 +16,8 @@ import { import { PNMessage } from "../../store/types/types"; import { InitializedProfile } from "../../../../../definitions/backend/InitializedProfile"; import { BackendStatusState } from "../../../../store/reducers/backendStatus"; -import { ServiceId } from "../../../../../definitions/backend/ServiceId"; import { Download } from "../../../../store/reducers/entities/messages/downloads"; +import { NotificationRecipient } from "../../../../../definitions/pn/NotificationRecipient"; const mockedOnAttachmentSelect = jest.fn(); @@ -124,10 +124,10 @@ const generatePnMessage = () => subject: "This is the message subject", senderDenomination: "Sender denomination", abstract: "Message abstract", - serviceId: "" as ServiceId, notificationStatusHistory: [], recipients: [ { + recipientType: "-", taxId: generateTestFiscalCode(), denomination: "AaAaAa BbBbBb", payment: { @@ -135,7 +135,7 @@ const generatePnMessage = () => creditorTaxId: "00000000009" } } - ], + ] as Array, attachments: [ { messageId: generateTestMessageId(), diff --git a/ts/features/pn/components/__test__/PnMessagePayment.test.tsx b/ts/features/pn/components/__test__/PnMessagePayment.test.tsx index 251b7b583f1..b80fefd8db6 100644 --- a/ts/features/pn/components/__test__/PnMessagePayment.test.tsx +++ b/ts/features/pn/components/__test__/PnMessagePayment.test.tsx @@ -5,7 +5,7 @@ import { RenderAPI, fireEvent, render } from "@testing-library/react-native"; import { NavigationAction } from "@react-navigation/native"; import { PnMessagePayment } from "../PnMessagePayment"; import { UIMessageId } from "../../../../store/reducers/entities/messages/types"; -import { NotificationPaymentInfo } from "../../store/types/types"; +import { NotificationPaymentInfo } from "../../../../../definitions/pn/NotificationPaymentInfo"; import PN_ROUTES from "../../navigation/routes"; import ROUTES from "../../../../navigation/routes"; diff --git a/ts/features/pn/screens/LegacyPnMessageDetailsScreen.tsx b/ts/features/pn/screens/LegacyPnMessageDetailsScreen.tsx index 5a382a3973f..d02adc9b392 100644 --- a/ts/features/pn/screens/LegacyPnMessageDetailsScreen.tsx +++ b/ts/features/pn/screens/LegacyPnMessageDetailsScreen.tsx @@ -22,7 +22,8 @@ import { LegacyPnMessageDetails } from "../components/LegacyPnMessageDetails"; import { PnMessageDetailsError } from "../components/PnMessageDetailsError"; import { PnParamsList } from "../navigation/params"; import { pnMessageFromIdSelector } from "../store/reducers"; -import { NotificationPaymentInfo, PNMessage } from "../store/types/types"; +import { PNMessage } from "../store/types/types"; +import { NotificationPaymentInfo } from "../../../../definitions/pn/NotificationPaymentInfo"; import { cancelPreviousAttachmentDownload } from "../../../store/actions/messages"; import { profileFiscalCodeSelector } from "../../../store/reducers/profile"; import { isCancelledFromPNMessagePot, paymentFromPNMessagePot } from "../utils"; diff --git a/ts/features/pn/screens/PnMessageDetailsScreen.tsx b/ts/features/pn/screens/PnMessageDetailsScreen.tsx index 494fc15623f..4908febc4df 100644 --- a/ts/features/pn/screens/PnMessageDetailsScreen.tsx +++ b/ts/features/pn/screens/PnMessageDetailsScreen.tsx @@ -22,7 +22,8 @@ import { PnMessageDetails } from "../components/PnMessageDetails"; import { PnMessageDetailsError } from "../components/PnMessageDetailsError"; import { PnParamsList } from "../navigation/params"; import { pnMessageFromIdSelector } from "../store/reducers"; -import { NotificationPaymentInfo, PNMessage } from "../store/types/types"; +import { PNMessage } from "../store/types/types"; +import { NotificationPaymentInfo } from "../../../../definitions/pn/NotificationPaymentInfo"; import { cancelPreviousAttachmentDownload } from "../../../store/actions/messages"; import { profileFiscalCodeSelector } from "../../../store/reducers/profile"; import { isCancelledFromPNMessagePot, paymentFromPNMessagePot } from "../utils"; diff --git a/ts/features/pn/store/types/__test__/types.test.ts b/ts/features/pn/store/types/__test__/types.test.ts index 8874640ff10..d2336b7a09f 100644 --- a/ts/features/pn/store/types/__test__/types.test.ts +++ b/ts/features/pn/store/types/__test__/types.test.ts @@ -1,5 +1,5 @@ import * as E from "fp-ts/lib/Either"; -import { FullReceivedNotification } from "../types"; +import { IOReceivedNotification } from "../../../../../../definitions/pn/IOReceivedNotification"; describe("FullReceivedNotification type", () => { it("should decode a cancelled notification with completed payments list", () => { @@ -16,16 +16,16 @@ describe("FullReceivedNotification type", () => { isCancelled: true, completedPayments }; - const maybeFullReceivedNotification = FullReceivedNotification.decode( + const maybeFullReceivedNotification = IOReceivedNotification.decode( fullReceivedNotification ); expect(E.isRight(maybeFullReceivedNotification)).toBe(true); expect( - (maybeFullReceivedNotification as E.Right).right + (maybeFullReceivedNotification as E.Right).right .isCancelled ).toBe(true); expect( - (maybeFullReceivedNotification as E.Right).right + (maybeFullReceivedNotification as E.Right).right .completedPayments ).toBe(completedPayments); }); @@ -37,16 +37,16 @@ describe("FullReceivedNotification type", () => { notificationStatusHistory: [], isCancelled: true }; - const maybeFullReceivedNotification = FullReceivedNotification.decode( + const maybeFullReceivedNotification = IOReceivedNotification.decode( fullReceivedNotification ); expect(E.isRight(maybeFullReceivedNotification)).toBe(true); expect( - (maybeFullReceivedNotification as E.Right).right + (maybeFullReceivedNotification as E.Right).right .isCancelled ).toBe(true); expect( - (maybeFullReceivedNotification as E.Right).right + (maybeFullReceivedNotification as E.Right).right .completedPayments ).toBeUndefined(); }); @@ -58,16 +58,16 @@ describe("FullReceivedNotification type", () => { notificationStatusHistory: [], isCancelled: false }; - const maybeFullReceivedNotification = FullReceivedNotification.decode( + const maybeFullReceivedNotification = IOReceivedNotification.decode( fullReceivedNotification ); expect(E.isRight(maybeFullReceivedNotification)).toBe(true); expect( - (maybeFullReceivedNotification as E.Right).right + (maybeFullReceivedNotification as E.Right).right .isCancelled ).toBe(false); expect( - (maybeFullReceivedNotification as E.Right).right + (maybeFullReceivedNotification as E.Right).right .completedPayments ).toBeUndefined(); }); @@ -78,16 +78,16 @@ describe("FullReceivedNotification type", () => { recipients: [], notificationStatusHistory: [] }; - const maybeFullReceivedNotification = FullReceivedNotification.decode( + const maybeFullReceivedNotification = IOReceivedNotification.decode( fullReceivedNotification ); expect(E.isRight(maybeFullReceivedNotification)).toBe(true); expect( - (maybeFullReceivedNotification as E.Right).right + (maybeFullReceivedNotification as E.Right).right .isCancelled ).toBeUndefined(); expect( - (maybeFullReceivedNotification as E.Right).right + (maybeFullReceivedNotification as E.Right).right .completedPayments ).toBeUndefined(); }); diff --git a/ts/features/pn/store/types/transformers.ts b/ts/features/pn/store/types/transformers.ts index 04f1b167a06..2a8526f3dad 100644 --- a/ts/features/pn/store/types/transformers.ts +++ b/ts/features/pn/store/types/transformers.ts @@ -1,23 +1,23 @@ import { pipe } from "fp-ts/lib/function"; -import * as E from "fp-ts/lib/Either"; import * as O from "fp-ts/lib/Option"; import { ThirdPartyMessageWithContent } from "../../../../../definitions/backend/ThirdPartyMessageWithContent"; +import { ThirdPartyMessage } from "../../../../../definitions/pn/ThirdPartyMessage"; import { attachmentsFromThirdPartyMessage } from "../../../../store/reducers/entities/messages/transformers"; -import { PNMessage, FullReceivedNotification } from "./types"; +import { PNMessage } from "./types"; export const toPNMessage = ( messageFromApi: ThirdPartyMessageWithContent ): O.Option => pipe( - messageFromApi.third_party_message.details, - FullReceivedNotification.decode, - E.map(notification => ({ - ...notification, - serviceId: messageFromApi.sender_service_id, + messageFromApi.third_party_message, + ThirdPartyMessage.decode, + O.fromEither, + O.chainNullableK(message => message.details), + O.map(details => ({ + ...details, attachments: pipe( attachmentsFromThirdPartyMessage(messageFromApi, "PN"), O.toUndefined ) - })), - O.fromEither + })) ); diff --git a/ts/features/pn/store/types/types.ts b/ts/features/pn/store/types/types.ts index b4e4de8bbd0..13daf1695e6 100644 --- a/ts/features/pn/store/types/types.ts +++ b/ts/features/pn/store/types/types.ts @@ -1,95 +1,7 @@ -import * as t from "io-ts"; -import { IsoDateFromString } from "@pagopa/ts-commons/lib/dates"; -import { ServiceId } from "../../../../../definitions/backend/ServiceId"; +import { IOReceivedNotification } from "../../../../../definitions/pn/IOReceivedNotification"; import { UIAttachment } from "../../../../store/reducers/entities/messages/types"; -export type NotificationStatus = t.TypeOf; -export const NotificationStatus = t.string; - -export type TimelineElementId = t.TypeOf; -export const TimelineElementId = t.string; - -const NotificationStatusHistoryElementR = t.interface({ - activeFrom: IsoDateFromString, - - relatedTimelineElements: t.readonlyArray( - TimelineElementId, - "array of TimelineElementId" - ), - - status: NotificationStatus -}); -const NotificationStatusHistoryElementO = t.partial({}); - -export const NotificationStatusHistoryElement = t.intersection( - [NotificationStatusHistoryElementR, NotificationStatusHistoryElementO], - "NotificationStatusHistoryElement" -); -export type NotificationStatusHistoryElement = t.TypeOf< - typeof NotificationStatusHistoryElement ->; - -export type NotificationStatusHistory = t.TypeOf< - typeof NotificationStatusHistory ->; -export const NotificationStatusHistory = t.readonlyArray( - NotificationStatusHistoryElement, - "array of NotificationStatusHistoryElement" -); - -export const NotificationPaymentInfoR = t.interface({ - noticeCode: t.string, - creditorTaxId: t.string -}); - -export const NotificationPaymentInfoO = t.partial({}); - -export const NotificationPaymentInfo = t.intersection( - [NotificationPaymentInfoR, NotificationPaymentInfoO], - "NotificationPaymentInfo" -); - -export type NotificationPaymentInfo = t.TypeOf; - -export const NotificationRecipientR = t.interface({ - denomination: t.string, - taxId: t.string -}); - -export const NotificationRecipientO = t.partial({ - payment: NotificationPaymentInfo -}); - -export const NotificationRecipient = t.intersection( - [NotificationRecipientR, NotificationRecipientO], - "NotificationRecipient" -); - -export const FullReceivedNotificationR = t.interface({ - subject: t.string, - iun: t.string, - recipients: t.array(NotificationRecipient), - notificationStatusHistory: NotificationStatusHistory -}); - -export const FullReceivedNotificationO = t.partial({ - abstract: t.string, - senderDenomination: t.string, - isCancelled: t.boolean, - completedPayments: t.readonlyArray(t.string) -}); - -export const FullReceivedNotification = t.intersection( - [FullReceivedNotificationR, FullReceivedNotificationO], - "FullReceivedNotification" -); - -export type FullReceivedNotification = t.TypeOf< - typeof FullReceivedNotification ->; - -export type PNMessage = FullReceivedNotification & +export type PNMessage = IOReceivedNotification & Readonly<{ - serviceId: ServiceId; attachments?: ReadonlyArray; }>; diff --git a/ts/features/pn/utils/index.ts b/ts/features/pn/utils/index.ts index 9889ffd2185..19d97a1a035 100644 --- a/ts/features/pn/utils/index.ts +++ b/ts/features/pn/utils/index.ts @@ -1,10 +1,11 @@ import * as pot from "@pagopa/ts-commons/lib/pot"; import { identity, pipe } from "fp-ts/lib/function"; -import * as A from "fp-ts/lib/Array"; import * as O from "fp-ts/lib/Option"; +import * as RA from "fp-ts/lib/ReadonlyArray"; import I18n from "../../../i18n"; import { UIService } from "../../../store/reducers/entities/services/types"; -import { NotificationStatus, PNMessage } from "../store/types/types"; +import { PNMessage } from "../store/types/types"; +import { NotificationStatus } from "../../../../definitions/pn/NotificationStatus"; import { CTAS } from "../../../types/MessageCTA"; import { isServiceDetailNavigationLink } from "../../../utils/internalLink"; import { GlobalState } from "../../../store/reducers/types"; @@ -80,7 +81,7 @@ export const paymentFromPNMessagePot = ( O.chain(message => pipe( message.recipients, - A.findFirst(recipient => recipient.taxId === userFiscalCode) + RA.findFirst(recipient => recipient.taxId === userFiscalCode) ) ), O.chainNullableK(recipient => recipient.payment), diff --git a/ts/features/pn/utils/rptId.ts b/ts/features/pn/utils/rptId.ts index a2601e64f88..90cba93ce3e 100644 --- a/ts/features/pn/utils/rptId.ts +++ b/ts/features/pn/utils/rptId.ts @@ -3,7 +3,7 @@ import * as O from "fp-ts/lib/Option"; import { pipe } from "fp-ts/lib/function"; import { sequenceS } from "fp-ts/lib/Apply"; import { RptId } from "@pagopa/io-pagopa-commons/lib/pagopa"; -import { NotificationPaymentInfo } from "../store/types/types"; +import { NotificationPaymentInfo } from "../../../../definitions/pn/NotificationPaymentInfo"; import { PaymentNoticeNumber } from "../../../../definitions/backend/PaymentNoticeNumber"; import { OrganizationFiscalCode } from "../../../../definitions/backend/OrganizationFiscalCode"; import { getRptIdFromNoticeNumber } from "../../../utils/payment";