Skip to content

Commit

Permalink
Aggiornamento Versione 2.3 (#164)
Browse files Browse the repository at this point in the history
* aggiornamento Versione 2.3

* test rifatti

* test modificati

---------

Co-authored-by: MicheleBellizziNTT <[email protected]>
  • Loading branch information
MicheleBellizziNTT and MicheleBellizziNTT authored Apr 9, 2024
1 parent 7f8ce81 commit 86bee72
Show file tree
Hide file tree
Showing 42 changed files with 7,826 additions and 136 deletions.
1,181 changes: 1,181 additions & 0 deletions docs/postman_collection/PagoPA_v2.3_postman_collection.json

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions openapi/.swagger-codegen-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
1 change: 1 addition & 0 deletions openapi/.swagger-codegen/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.35
Empty file added openapi/README.md
Empty file.
6,496 changes: 6,496 additions & 0 deletions openapi/bundled-api-external-b2b-pa-v2-3.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions openapi/how-to-generate-the-bundled-openapi-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
```
curl https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.35/swagger-codegen-cli-3.0.35.jar -O
```
3. Run the command to generate the 'bundled-api-external-b2b-pa-v2-1.yaml'
3. Run the command to generate the 'bundled-api-external-b2b-pa-v2-3.yaml'
```
java -jar swagger-codegen-cli-3.0.35.jar generate -l openapi-yaml -i https://raw.githubusercontent.com/pagopa/pn-delivery/develop/docs/openapi/api-external-b2b-pa-bundle.yaml -o . -DoutputFile=bundled-api-external-b2b-pa-v2-1.yaml
java -jar swagger-codegen-cli-3.0.35.jar generate -l openapi-yaml -i https://raw.githubusercontent.com/pagopa/pn-delivery/develop/docs/openapi/api-external-b2b-pa-bundle.yaml -o . -DoutputFile=bundled-api-external-b2b-pa-v2-3.yaml
```
3. Then do the modification as below to the generated file.
4. Add to the `Problem` and `ProblemError` the `type: object` property
Expand Down
Binary file added openapi/swagger-codegen-cli-3.0.35.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "pn-local-validator",
"version": "2.1.3.1",
"version": "2.3",
"description": "A system that emulates some features of Piattaforma Notifiche platform.",
"main": "dist/main.js",
"scripts": {
"generate": "npm run generate:api && npm run generate:pnapi",
"generate:pnapi": "shx rm -rf ./src/generated/pnapi && shx mkdir -p ./src/generated/pnapi && gen-api-models --api-spec ./openapi/bundled-api-external-b2b-pa-v2-1.yaml --no-strict --out-dir ./src/generated/pnapi --request-types --response-decoders",
"generate:pnapi": "shx rm -rf ./src/generated/pnapi && shx mkdir -p ./src/generated/pnapi && gen-api-models --api-spec ./openapi/bundled-api-external-b2b-pa-v2-3.yaml --no-strict --out-dir ./src/generated/pnapi --request-types --response-decoders",
"generate:api": "shx rm -rf ./src/generated/api && shx mkdir -p ./src/generated/api && gen-api-models --api-spec ./openapi/internal.yaml --no-strict --out-dir ./src/generated/api",
"clean": "tsc --build --clean",
"postcompile": "shx cp -R ./src/adapters/http/download/exampledocuments ./dist/adapters/http/download/exampledocuments",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Notification Status Router', () => {

it('should return a 400 response with some data', async () => {
const response = await supertest(app)
.get('/api/delivery/v2.1/requests')
.get('/api/delivery/v2.3/requests')
.query({
notificationRequestId: '123',
});
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/http/checkNotificationStatus/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const handler =
export const makeNotificationStatusRouter = (env: SystemEnv): express.Router => {
const router = express.Router();

router.get('/delivery/v2.1/requests', toExpressHandler(handler(env)));
router.get('/delivery/v2.3/requests', toExpressHandler(handler(env)));

return router;
};
2 changes: 1 addition & 1 deletion src/adapters/http/checklist/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { evaluateReport } from '../../../domain/reportengine/reportengine';
import { report } from '../../../domain/checks/report';
import { SystemEnv } from '../../../useCases/SystemEnv';

const appVersion = '2.1.3';
const appVersion = '2.3';

const handler =
(env: SystemEnv): Handler =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Consume Event Stream Router', () => {

it('should return a 400 response with some data', async () => {
const response = await supertest(app)
.get('/api/delivery-progresses/streams/someStreamId/events')
.get('/api/delivery-progresses/v2.3/streams/someStreamId/events')
.query({
lastEventId: '123',
});
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/http/consumeEventStream/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const handler =
export const makeConsumeEventStreamRouter = (env: SystemEnv): express.Router => {
const router = express.Router();

router.get('/delivery-progresses/streams/:streamId/events', toExpressHandler(handler(env)));
router.get('/delivery-progresses/v2.3/streams/:streamId/events', toExpressHandler(handler(env)));

return router;
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Create Event Stream Router', () => {

it('should return a 400 response with some data', async () => {
const response = await supertest(app)
.post('/api/delivery-progresses/streams')
.post('/api/delivery-progresses/v2.3/streams')
.send({});

expect(response.status).toBe(400);
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/http/createEventStream/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const handler =
export const makeCreateEventStreamRouter = (env: SystemEnv): express.Router => {
const router = express.Router();

router.post('/delivery-progresses/streams', toExpressHandler(handler(env)));
router.post('/delivery-progresses/v2.3/streams', toExpressHandler(handler(env)));

return router;
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Delete Event Stream Router', () => {

it('should return a 500 response with some data', async () => {
const response = await supertest(app)
.delete('/api/delivery-progresses/streams/123')
.delete('/api/delivery-progresses/v2.3/streams/123')

expect(response.status).toBe(500);
});
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/http/deleteEventStream/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const handler =
export const makeDeleteEventStreamRouter = (env: SystemEnv): express.Router => {
const router = express.Router();

router.delete('/delivery-progresses/streams/:streamId', toExpressHandler(handler(env)));
router.delete('/delivery-progresses/v2.3/streams/:streamId', toExpressHandler(handler(env)));

return router;
};
2 changes: 1 addition & 1 deletion src/adapters/http/deleteNotification/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ const handler =

export const makeDeleteNotificationRouter = (env: SystemEnv): express.Router => {
const router = express.Router();
router.put('/delivery-push/v2.1/notifications/cancel/:iun', toExpressHandler(handler(env)));
router.put('/delivery-push/v2.3/notifications/cancel/:iun', toExpressHandler(handler(env)));
return router;
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Get Notification Detail Router', () => {

it('should return a 400 response with some data', async () => {
const response = await supertest(app)
.get('/api/delivery/v2.1/notifications/sent/1A')
.get('/api/delivery/v2.3/notifications/sent/1A')
.query({
notificationRequestId: '123',
});
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/http/getNotificationDetail/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const handler =
export const makeGetNotificationDetailRouter = (env: SystemEnv): express.Router => {
const router = express.Router();

router.get('/delivery/v2.1/notifications/sent/:iun', toExpressHandler(handler(env)));
router.get('/delivery/v2.3/notifications/sent/:iun', toExpressHandler(handler(env)));

return router;
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Get Notification Price Metadata Router', () => {

it('should return a 400 response with some data', async () => {
const response = await supertest(app)
.get('/api/delivery/price/3C/1A')
.get('/api/delivery/v2.3/price/3C/1A')
.query({
notificationRequestId: '123',
});
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/http/getNotificationPrice/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const handler =
export const makeGetNotificationPriceRouter = (env: SystemEnv): express.Router => {
const router = express.Router();

router.get('/delivery/price/:paTaxId/:noticeCode', toExpressHandler(handler(env)));
router.get('/delivery/v2.3/price/:paTaxId/:noticeCode', toExpressHandler(handler(env)));

return router;
};
2 changes: 1 addition & 1 deletion src/adapters/http/getStreamById/__tests__/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Get Stream By Id Router', () => {

it('should return a 400 response with some data', async () => {
const response = await supertest(app)
.get('/api/delivery-progresses/streams/1A')
.get('/api/delivery-progresses/v2.3/streams/1A')
.query({
notificationRequestId: '123',
});
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/http/getStreamById/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const handler =
export const makeGetEventStreamByIdRouter = (env: SystemEnv): express.Router => {
const router = express.Router();

router.get('/delivery-progresses/streams/:streamId', toExpressHandler(handler(env)));
router.get('/delivery-progresses/v2.3/streams/:streamId', toExpressHandler(handler(env)));

return router;
};
2 changes: 1 addition & 1 deletion src/adapters/http/listEventStream/__test__/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("ListEventStream router", () => {

it("With empty body response should be 404", async () => {
const response = await supertest(app)
.post('/delivery-progresses/streams')
.post('/delivery-progresses/v2.3/streams')
.set('x-api-key', data.apiKey.valid)
.send();

Expand Down
2 changes: 1 addition & 1 deletion src/adapters/http/listEventStream/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const handler =
export const makeListEventStreamRouter = (env: SystemEnv): express.Router => {
const router = express.Router();

router.get('/delivery-progresses/streams', toExpressHandler(handler(env)));
router.get('/delivery-progresses/2.3/streams', toExpressHandler(handler(env)));

return router;
};
2 changes: 1 addition & 1 deletion src/adapters/http/sendNotification/__test__/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("sendNotification router", () => {

it("With empty body response should be 400", async () => {
const response = await supertest(app)
.post('/delivery/v2.1/requests')
.post('/delivery/v2.3/requests')
.set('x-api-key', data.apiKey.valid)
.send();

Expand Down
6 changes: 3 additions & 3 deletions src/adapters/http/sendNotification/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import { Handler, toExpressHandler, removeNullValues } from '../Handler';
import { SystemEnv } from '../../../useCases/SystemEnv';
import { persistRecord } from '../../../useCases/PersistRecord';
import { makeNewNotificationRecord } from '../../../domain/NewNotificationRecord';
import { NewNotificationRequestV21 } from '../../../generated/pnapi/NewNotificationRequestV21';
import { NewNotificationRequestV23 } from '../../../generated/pnapi/NewNotificationRequestV23';

const handler =
(env: SystemEnv): Handler =>
(req, res) =>
pipe(
Apply.sequenceS(E.Apply)({
apiKey: t.string.decode(req.headers['x-api-key']),
body: NewNotificationRequestV21.decode(removeNullValues(req.body)),
body: NewNotificationRequestV23.decode(removeNullValues(req.body)),
}),
E.map(flow(makeNewNotificationRecord(env), constant, persistRecord(env))),
E.map(
Expand All @@ -33,7 +33,7 @@ const handler =
export const makeSendNotificationRouter = (env: SystemEnv): express.Router => {
const router = express.Router();

router.post('/delivery/v2.1/requests', toExpressHandler(handler(env)));
router.post('/delivery/v2.3/requests', toExpressHandler(handler(env)));

return router;
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("sendNotification router", () => {

it("With empty body response should be 404", async () => {
const response = await supertest(app)
.post('/delivery/requests')
.post('/delivery/v2.3/requests')
.set('x-api-key', data.apiKey.valid)
.send();

Expand Down
2 changes: 1 addition & 1 deletion src/adapters/http/updateEventStream/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const handler =
export const makeUpdateEventStreamRouter = (env: SystemEnv): express.Router => {
const router = express.Router();

router.put('/delivery-progresses/streams/:streamId', toExpressHandler(handler(env)));
router.put('/delivery-progresses/2.3/streams/:streamId', toExpressHandler(handler(env)));

return router;
};
18 changes: 9 additions & 9 deletions src/domain/CheckNotificationStatusRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as O from 'fp-ts/Option';
import * as RA from 'fp-ts/ReadonlyArray';
import { flow, identity, pipe } from 'fp-ts/function';
import * as t from 'io-ts';
import { NewNotificationRequestStatusResponseV21 } from '../generated/pnapi/NewNotificationRequestStatusResponseV21';
import { NewNotificationRequestStatusResponseV23 } from '../generated/pnapi/NewNotificationRequestStatusResponseV23';
import { NotificationDocument } from '../generated/pnapi/NotificationDocument';
import { PreLoadResponse } from '../generated/pnapi/PreLoadResponse';
import { SystemEnv } from '../useCases/SystemEnv';
Expand All @@ -22,8 +22,8 @@ export type CheckNotificationStatusRecord = AuditRecord & {
body: { paProtocolNumber: string; idempotenceToken?: string } | { notificationRequestId: string };
};
output:
| Response<200, NewNotificationRequestStatusResponseV21>
| Response<500, NewNotificationRequestStatusResponseV21>
| Response<200, NewNotificationRequestStatusResponseV23>
| Response<500, NewNotificationRequestStatusResponseV23>
| Response<403, UnauthorizedMessageBody>
| Response<404>;
};
Expand Down Expand Up @@ -56,18 +56,18 @@ export const makeCheckNotificationStatusRecord =
E.fold(
(nr) => ({ ...nr, notificationRequestStatus: 'WAITING' }),
(n) =>
t.exact(NewNotificationRequestStatusResponseV21).encode({ ...n, notificationRequestStatus: 'ACCEPTED' })
t.exact(NewNotificationRequestStatusResponseV23).encode({ ...n, notificationRequestStatus: 'ACCEPTED' })
)
),
O.map((response) =>
pipe(
response.recipients,
RA.reduce(response, function (res, invalidRec) {
const newRes = t.exact(NewNotificationRequestStatusResponseV21).encode(res as NewNotificationRequestStatusResponseV21);
const newRes = t.exact(NewNotificationRequestStatusResponseV23).encode(res as NewNotificationRequestStatusResponseV23);
const pastErrors = newRes.errors ? newRes.errors : [];
if (!VALID_CAPS[invalidRec.physicalAddress.zip as keyof typeof VALID_CAPS]) {
return t.exact(NewNotificationRequestStatusResponseV21).encode({
...res as NewNotificationRequestStatusResponseV21,
return t.exact(NewNotificationRequestStatusResponseV23).encode({
...res as NewNotificationRequestStatusResponseV23,
notificationRequestStatus: 'REFUSED',
errors: [
...pastErrors,
Expand All @@ -87,7 +87,7 @@ export const makeCheckNotificationStatusRecord =
response.documents,
// Scroll throw the documents of the responce
RA.reduce(response, (respAccrRaw, docRespRaw) => {
const respAccr = t.exact(NewNotificationRequestStatusResponseV21).encode(respAccrRaw as NewNotificationRequestStatusResponseV21);
const respAccr = t.exact(NewNotificationRequestStatusResponseV23).encode(respAccrRaw as NewNotificationRequestStatusResponseV23);
const docResp = docRespRaw as NotificationDocument;

const key = docResp.ref.key;
Expand Down Expand Up @@ -140,7 +140,7 @@ export const makeCheckNotificationStatusRecord =

if (!matchFound) {
const pastErrors = respAccr.errors ? respAccr.errors : [];
return t.exact(NewNotificationRequestStatusResponseV21).encode({
return t.exact(NewNotificationRequestStatusResponseV23).encode({
...respAccr,
notificationRequestStatus: 'REFUSED',
errors: [
Expand Down
4 changes: 4 additions & 0 deletions src/domain/DomainEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export type DomainEnv = {
uploadToS3URL: URL;
retryAfterMs: number;
notificationPrice: number;
analogCost: number;
totalPrice: number;
partialPrice: number;
sendFee: number;
// generators
iunGenerator: IO<IUN>;
dateGenerator: IO<Date>;
Expand Down
Loading

0 comments on commit 86bee72

Please sign in to comment.