-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [IOCOM-555] Replace
FullReceivedNotification
with the autogen…
…erated 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 <[email protected]>
- Loading branch information
Showing
14 changed files
with
57 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<PNMessage> => | ||
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 | ||
})) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<typeof NotificationStatus>; | ||
export const NotificationStatus = t.string; | ||
|
||
export type TimelineElementId = t.TypeOf<typeof TimelineElementId>; | ||
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<typeof NotificationPaymentInfo>; | ||
|
||
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<UIAttachment>; | ||
}>; |
Oops, something went wrong.