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

[#Ente-143] Add FiscalCode inside Jira Ticket #143

Open
wants to merge 5 commits into
base: master
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
1 change: 1 addition & 0 deletions .env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ JIRA_TRANSITION_UPDATED_ID=11

JIRA_DELEGATE_ID_FIELD=customfield_xxxxx
JIRA_EMAIL_ID_FIELD=customfield_xxxxx
JIRA_ORGANIZATION_FISCALCODE=customfield_xxxxx
JIRA_ORGANIZATION_ID_FIELD=customfield_xxxxx
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ coverage
src/**/*.js
.env
.vscode
generated
generated/api/*
build
16 changes: 15 additions & 1 deletion src/__tests__/jira-client.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { EmailString, NonEmptyString } from "italia-ts-commons/lib/strings";
import {
EmailString,
NonEmptyString,
OrganizationFiscalCode
} from "italia-ts-commons/lib/strings";
import { ServiceId } from "../../generated/api/ServiceId";
import * as config from "../config";
import { JiraAPIClient } from "../jira_client";
Expand All @@ -8,6 +12,7 @@ const JIRA_CONFIG = {
JIRA_DELEGATE_ID_FIELD: "",
JIRA_EMAIL_ID_FIELD: "",
JIRA_NAMESPACE_URL: "board.atlassian.com",
JIRA_ORGANIZATION_FISCALCODE_ID_FIELD: "",
JIRA_ORGANIZATION_ID_FIELD: "",
JIRA_STATUS_COMPLETE: "COMPLETE",
JIRA_STATUS_IN_PROGRESS: "REVIEW",
Expand Down Expand Up @@ -73,6 +78,8 @@ describe("JiraAPIClient#createJiraIssue", () => {
delegateIdField: JIRA_CONFIG.JIRA_DELEGATE_ID_FIELD,
emailIdField: JIRA_CONFIG.JIRA_EMAIL_ID_FIELD,
jiraEmail: JIRA_CONFIG.JIRA_USERNAME,
organizationFiscalCodeIdField:
JIRA_CONFIG.JIRA_ORGANIZATION_FISCALCODE_ID_FIELD,
organizationIdField: JIRA_CONFIG.JIRA_ORGANIZATION_ID_FIELD,
statusComplete: JIRA_CONFIG.JIRA_STATUS_COMPLETE,
token: JIRA_CONFIG.JIRA_TOKEN
Expand All @@ -86,6 +93,7 @@ describe("JiraAPIClient#createJiraIssue", () => {
{
delegateName: "firstName lastName" as NonEmptyString,
email: "test@email.com" as EmailString,
organizationFiscalCode: "00000000000" as OrganizationFiscalCode,
organizationName: "MyOrganizationName" as NonEmptyString,
serviceId: (ServiceId as unknown) as NonEmptyString
},
Expand Down Expand Up @@ -117,6 +125,8 @@ describe("JiraAPIClient#search and apply transition", () => {
delegateIdField: JIRA_CONFIG.JIRA_DELEGATE_ID_FIELD,
emailIdField: JIRA_CONFIG.JIRA_EMAIL_ID_FIELD,
jiraEmail: JIRA_CONFIG.JIRA_USERNAME,
organizationFiscalCodeIdField:
JIRA_CONFIG.JIRA_ORGANIZATION_FISCALCODE_ID_FIELD,
organizationIdField: JIRA_CONFIG.JIRA_ORGANIZATION_ID_FIELD,
statusComplete: JIRA_CONFIG.JIRA_STATUS_COMPLETE,
token: JIRA_CONFIG.JIRA_TOKEN
Expand Down Expand Up @@ -149,6 +159,8 @@ describe("JiraAPIClient#search and apply transition", () => {
delegateIdField: JIRA_CONFIG.JIRA_DELEGATE_ID_FIELD,
emailIdField: JIRA_CONFIG.JIRA_EMAIL_ID_FIELD,
jiraEmail: JIRA_CONFIG.JIRA_USERNAME,
organizationFiscalCodeIdField:
JIRA_CONFIG.JIRA_ORGANIZATION_FISCALCODE_ID_FIELD,
organizationIdField: JIRA_CONFIG.JIRA_ORGANIZATION_ID_FIELD,
statusComplete: JIRA_CONFIG.JIRA_STATUS_COMPLETE,
token: JIRA_CONFIG.JIRA_TOKEN
Expand Down Expand Up @@ -179,6 +191,8 @@ describe("JiraAPIClient#search and apply transition", () => {
delegateIdField: JIRA_CONFIG.JIRA_DELEGATE_ID_FIELD,
emailIdField: JIRA_CONFIG.JIRA_EMAIL_ID_FIELD,
jiraEmail: JIRA_CONFIG.JIRA_USERNAME,
organizationFiscalCodeIdField:
JIRA_CONFIG.JIRA_ORGANIZATION_FISCALCODE_ID_FIELD,
organizationIdField: JIRA_CONFIG.JIRA_ORGANIZATION_ID_FIELD,
statusComplete: JIRA_CONFIG.JIRA_STATUS_COMPLETE,
token: JIRA_CONFIG.JIRA_TOKEN
Expand Down
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const IJIRA_CONFIG = t.interface({
JIRA_DELEGATE_ID_FIELD: NonEmptyString,
JIRA_EMAIL_ID_FIELD: NonEmptyString,
JIRA_NAMESPACE_URL: NonEmptyString,
JIRA_ORGANIZATION_FISCALCODE_ID_FIELD: NonEmptyString,
JIRA_ORGANIZATION_ID_FIELD: NonEmptyString,
JIRA_STATUS_COMPLETE: NonEmptyString,
JIRA_STATUS_IN_PROGRESS: NonEmptyString,
Expand All @@ -142,6 +143,9 @@ export const getJiraConfigOrThrow = () =>
JIRA_EMAIL_ID_FIELD: fromNullable(
process.env.JIRA_EMAIL_ID_FIELD
).getOrElse(""),
JIRA_ORGANIZATION_FISCALCODE_ID_FIELD: fromNullable(
process.env.JIRA_ORGANIZATION_FISCALCODE_ID_FIELD
).getOrElse(""),
JIRA_ORGANIZATION_ID_FIELD: fromNullable(
process.env.JIRA_ORGANIZATION_ID_FIELD
).getOrElse(""),
Expand Down
4 changes: 4 additions & 0 deletions src/controllers/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ export async function newDisableRequest(
{
delegateName: `${authenticatedUser.given_name} ${authenticatedUser.family_name}` as NonEmptyString,
email: authenticatedUser.emails[0],
organizationFiscalCode:
errorOrService.value.organization_fiscal_code,
organizationName: errorOrService.value.organization_name,
serviceId
},
Expand Down Expand Up @@ -612,6 +614,8 @@ export async function newReviewRequest(
{
delegateName: `${authenticatedUser.given_name} ${authenticatedUser.family_name}` as NonEmptyString,
email: authenticatedUser.emails[0],
organizationFiscalCode:
errorOrService.value.organization_fiscal_code,
organizationName: errorOrService.value.organization_name,
serviceId
}
Expand Down
5 changes: 5 additions & 0 deletions src/jira_client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { OrganizationFiscalCode } from "@pagopa/ts-commons/lib/strings";
import { toError } from "fp-ts/lib/Either";
import { fromNullable } from "fp-ts/lib/Option";
import {
Expand All @@ -18,6 +19,7 @@ export interface IJiraConfig {
readonly boardId: NonEmptyString;
readonly delegateIdField: NonEmptyString;
readonly emailIdField: NonEmptyString;
readonly organizationFiscalCodeIdField: NonEmptyString;
readonly organizationIdField: NonEmptyString;
readonly jiraEmail: EmailAddress;
readonly statusComplete: NonEmptyString;
Expand Down Expand Up @@ -91,6 +93,7 @@ export interface IJiraAPIClient {
serviceData: {
readonly delegateName: NonEmptyString;
readonly email: EmailString;
readonly organizationFiscalCode: OrganizationFiscalCode;
readonly organizationName: NonEmptyString;
readonly serviceId: NonEmptyString;
},
Expand Down Expand Up @@ -164,6 +167,7 @@ export function JiraAPIClient(
serviceData: {
readonly delegateName: NonEmptyString;
readonly email: EmailString;
readonly organizationFiscalCode: OrganizationFiscalCode;
readonly organizationName: NonEmptyString;
readonly serviceId: NonEmptyString;
},
Expand All @@ -180,6 +184,7 @@ export function JiraAPIClient(
},
[`${config.delegateIdField}`]: `${serviceData.delegateName}`,
[`${config.emailIdField}`]: `${serviceData.email}`,
[`${config.organizationFiscalCodeIdField}`]: `${serviceData.organizationFiscalCode}`,
[`${config.organizationIdField}`]: `${serviceData.organizationName}`,
labels: [
`${JIRA_SERVICE_TAG_PREFIX}${serviceData.serviceId}`
Expand Down
2 changes: 2 additions & 0 deletions src/middlewares/api_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export function getJiraClientMiddleware(
delegateIdField: jiraConfig.JIRA_DELEGATE_ID_FIELD,
emailIdField: jiraConfig.JIRA_EMAIL_ID_FIELD,
jiraEmail: jiraConfig.JIRA_USERNAME,
organizationFiscalCodeIdField:
jiraConfig.JIRA_ORGANIZATION_FISCALCODE_ID_FIELD,
organizationIdField: jiraConfig.JIRA_ORGANIZATION_ID_FIELD,
statusComplete: jiraConfig.JIRA_STATUS_COMPLETE,
token: jiraConfig.JIRA_TOKEN
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"sourceMap": true,
"outDir": "build"
"outDir": "build",
"skipLibCheck": true
},
"include": [
"src/**/*",
"package.json"
],
"exclude": [
"node_modules"
"node_modules",
]
}