Skip to content

Commit

Permalink
[#IC-46] Special service model upgrade (#172)
Browse files Browse the repository at this point in the history
* [#IC-40] Special service model upgrade
Use temporary reference to local branch of `io-functions-commons` waiting the new package version.

* [#IC-46] remove local references to io-functions-commons
Now we use reference to v21.8.0 package version

* [#IC-46] Compact version of apiServiceToService

* [#IC-40] New ServicePayload and ServiceMetadata definitions

* [#IC-40] Upgrade fn-commons definitions and package
  • Loading branch information
BurnedMarshal authored Nov 29, 2021
1 parent e6b9877 commit 71642cb
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 53 deletions.
50 changes: 32 additions & 18 deletions openapi/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ definitions:
required:
- email
EmailAddress:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/EmailAddress"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/EmailAddress"
ServiceCollection:
type: object
properties:
Expand All @@ -491,39 +491,53 @@ definitions:
- items
- page_size
ProblemJson:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/ProblemJson"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/ProblemJson"
Service:
"$ref": "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/Service"
"$ref": "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/Service"
ServiceMetadata:
"$ref": "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/ServiceMetadata"
"$ref": "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/ServiceMetadata"
CommonServiceMetadata:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/CommonServiceMetadata"
StandardServiceMetadata:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/StandardServiceMetadata"
SpecialServiceMetadata:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/SpecialServiceMetadata"
ServiceScope:
"$ref": "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/ServiceScope"
"$ref": "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/ServiceScope"
ServiceCategory:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/ServiceCategory"
SpecialServiceCategory:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/SpecialServiceCategory"
StandardServiceCategory:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/StandardServiceCategory"
ServicePayload:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/ServicePayload"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/ServicePayload"
ExtendedServicePayload:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/ExtendedServicePayload"
HiddenServicePayload:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/HiddenServicePayload"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/HiddenServicePayload"
VisibleServicePayload:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/VisibleServicePayload"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/VisibleServicePayload"
CommonServicePayload:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/CommonServicePayload"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/CommonServicePayload"
ServiceId:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/ServiceId"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/ServiceId"
ServiceName:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/ServiceName"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/ServiceName"
OrganizationName:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/OrganizationName"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/OrganizationName"
DepartmentName:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/DepartmentName"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/DepartmentName"
CIDR:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/CIDR"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/CIDR"
MaxAllowedPaymentAmount:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/MaxAllowedPaymentAmount"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/MaxAllowedPaymentAmount"
OrganizationFiscalCode:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/OrganizationFiscalCode"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/OrganizationFiscalCode"
FiscalCode:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/FiscalCode"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/FiscalCode"
ExtendedProfile:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v19.1.0/openapi/definitions.yaml#/ExtendedProfile"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v22.0.1/openapi/definitions.yaml#/ExtendedProfile"
UserGroupsPayload:
description: |-
All the groups with which the user must be associated.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@azure/ms-rest-js": "^2.5.1",
"@azure/ms-rest-nodeauth": "^2.0.6",
"@pagopa/express-azure-functions": "^2.0.0",
"@pagopa/io-functions-commons": "^21.5.3",
"@pagopa/io-functions-commons": "^22.0.1",
"@pagopa/ts-commons": "^10.0.1",
"@types/archiver": "^3.1.1",
"@types/randomstring": "^1.1.6",
Expand Down
84 changes: 56 additions & 28 deletions utils/conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Errors } from "io-ts";
import { errorsToReadableMessages } from "@pagopa/ts-commons/lib/reporters";
import { EmailString, FiscalCode } from "@pagopa/ts-commons/lib/strings";
import { pipe } from "fp-ts/lib/function";
import { SpecialServiceMetadata } from "../generated/definitions/SpecialServiceMetadata";
import { CIDR } from "../generated/definitions/CIDR";
import { Group, Group as ApiGroup } from "../generated/definitions/Group";
import {
Expand All @@ -28,6 +29,7 @@ import {
import { User, User as ApiUser } from "../generated/definitions/User";
import { UserCreated as ApiUserCreated } from "../generated/definitions/UserCreated";
import { UserStateEnum } from "../generated/definitions/UserState";
import { StandardServiceCategoryEnum } from "../generated/definitions/StandardServiceCategory";

// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
function errorsToError(errors: Errors): Error {
Expand All @@ -54,34 +56,60 @@ function removeNullProperties<T>(obj: T): unknown {
*/
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function apiServiceToService(service: ApiService): Service {
return {
authorizedCIDRs: toAuthorizedCIDRs(service.authorized_cidrs),
authorizedRecipients: toAuthorizedRecipients(service.authorized_recipients),
departmentName: service.department_name,
isVisible: service.is_visible,
maxAllowedPaymentAmount: service.max_allowed_payment_amount,
organizationFiscalCode: service.organization_fiscal_code,
organizationName: service.organization_name,
requireSecureChannels: service.require_secure_channels,
serviceId: service.service_id,
serviceMetadata: service.service_metadata && {
address: service.service_metadata.address,
appAndroid: service.service_metadata.app_android,
appIos: service.service_metadata.app_ios,
cta: service.service_metadata.cta,
description: service.service_metadata.description,
email: service.service_metadata.email,
pec: service.service_metadata.pec,
phone: service.service_metadata.phone,
privacyUrl: service.service_metadata.privacy_url,
scope: service.service_metadata.scope,
supportUrl: service.service_metadata.support_url,
tokenName: service.service_metadata.token_name,
tosUrl: service.service_metadata.tos_url,
webUrl: service.service_metadata.web_url
},
serviceName: service.service_name
};
return pipe(
{
authorizedCIDRs: toAuthorizedCIDRs(service.authorized_cidrs),
authorizedRecipients: toAuthorizedRecipients(
service.authorized_recipients
),
departmentName: service.department_name,
isVisible: service.is_visible,
maxAllowedPaymentAmount: service.max_allowed_payment_amount,
organizationFiscalCode: service.organization_fiscal_code,
organizationName: service.organization_name,
requireSecureChannels: service.require_secure_channels,
serviceId: service.service_id,
serviceMetadata: service.service_metadata && {
address: service.service_metadata.address,
appAndroid: service.service_metadata.app_android,
appIos: service.service_metadata.app_ios,
cta: service.service_metadata.cta,
description: service.service_metadata.description,
email: service.service_metadata.email,
pec: service.service_metadata.pec,
phone: service.service_metadata.phone,
privacyUrl: service.service_metadata.privacy_url,
scope: service.service_metadata.scope,
supportUrl: service.service_metadata.support_url,
tokenName: service.service_metadata.token_name,
tosUrl: service.service_metadata.tos_url,
webUrl: service.service_metadata.web_url
},
serviceName: service.service_name
} as Service,
commonService =>
SpecialServiceMetadata.is(service.service_metadata)
? {
...commonService,
serviceMetadata: {
...commonService.serviceMetadata,
category: service.service_metadata.category,
customSpecialFlow: service.service_metadata.custom_special_flow
}
}
: service.service_metadata
? ({
...commonService,
serviceMetadata: {
...commonService.serviceMetadata,
// When service_metadata is defined the default value of category is STANDARD
category: StandardServiceCategoryEnum.STANDARD,
customSpecialFlow: undefined
}
} as Service)
: // Service without metadata
commonService
);
}

// Returns an API Service Metadata from an internal Service model
Expand Down
29 changes: 23 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -945,15 +945,15 @@
resolved "https://registry.yarnpkg.com/@pagopa/express-azure-functions/-/express-azure-functions-2.0.0.tgz#eb52a0b997d931c1509372e2a9bea22a8ca85c17"
integrity sha512-IFZqtk0e2sfkMZIxYqPORzxcKRkbIrVJesR6eMLNwzh1rA4bl2uh9ZHk1m55LNq4ZmaxREDu+1JcGlIaZQgKNQ==

"@pagopa/io-functions-commons@^21.5.3":
version "21.5.3"
resolved "https://registry.yarnpkg.com/@pagopa/io-functions-commons/-/io-functions-commons-21.5.3.tgz#655b953efc482848a871a4a6c6d6302f35fd5b4c"
integrity sha512-Xiu+vDR9qD1UTXMDk92/BvkCuJKxunwNfTgBY7n2VeHFg4hMBwfk6EaVfdYAaNhj2RUJO3qP9IgIENubcMpkiA==
"@pagopa/io-functions-commons@^22.0.1":
version "22.0.1"
resolved "https://registry.yarnpkg.com/@pagopa/io-functions-commons/-/io-functions-commons-22.0.1.tgz#332243e405c29db4862780135525f968c667da47"
integrity sha512-9ZQ1N8PEZkSsceiP2SG2lTsO+sQxJG0QZpCPVjK/ulpkF0RSqiaFufTzUaSXxiNkaUMd+mYaeo92vfg2GWqxaA==
dependencies:
"@azure/cosmos" "^3.11.5"
"@pagopa/ts-commons" "^10.0.1"
applicationinsights "^1.8.10"
azure-storage "^2.10.4"
azure-storage "^2.10.5"
cidr-matcher "^2.1.1"
fp-ts "^2.10.5"
helmet "^4.6.0"
Expand Down Expand Up @@ -1954,6 +1954,23 @@ azure-storage@^2.10.4:
xml2js "0.2.8"
xmlbuilder "^9.0.7"

azure-storage@^2.10.5:
version "2.10.5"
resolved "https://registry.yarnpkg.com/azure-storage/-/azure-storage-2.10.5.tgz#2193314940954c8e90c14d0601fb146470740f70"
integrity sha512-kLCbiW1lvwwJwB/iOX7ic7xw/RIcSReF1sUFetEyFSiE+HDdv/wpSlsQx0F0khkXrPtJmBJRH0y9s/CRuRBWLQ==
dependencies:
browserify-mime "~1.2.9"
extend "^3.0.2"
json-edm-parser "0.1.2"
md5.js "1.3.4"
readable-stream "~2.0.0"
request "^2.86.0"
underscore "^1.12.1"
uuid "^3.0.0"
validator "~13.6.0"
xml2js "0.2.8"
xmlbuilder "^9.0.7"

azurite@^3.13.1:
version "3.14.0"
resolved "https://registry.yarnpkg.com/azurite/-/azurite-3.14.0.tgz#be8f551b6e34a76da2c17c060dcca6b9ea15d7be"
Expand Down Expand Up @@ -10116,7 +10133,7 @@ validator@^10.0.0, validator@^10.1.0:
resolved "https://registry.yarnpkg.com/validator/-/validator-10.11.0.tgz#003108ea6e9a9874d31ccc9e5006856ccd76b228"
integrity sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw==

validator@^13.6.0:
validator@^13.6.0, validator@~13.6.0:
version "13.6.0"
resolved "https://registry.yarnpkg.com/validator/-/validator-13.6.0.tgz#1e71899c14cdc7b2068463cb24c1cc16f6ec7059"
integrity sha512-gVgKbdbHgtxpRyR8K0O6oFZPhhB5tT1jeEHZR0Znr9Svg03U0+r9DXWMrnRAB+HtCStDQKlaIZm42tVsVjqtjg==
Expand Down

0 comments on commit 71642cb

Please sign in to comment.