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

PIN-6002 - Listing templates #1463

Open
wants to merge 9 commits into
base: feature/pin-4901_e-service-template
Choose a base branch
from
Open
231 changes: 231 additions & 0 deletions packages/api-clients/open-api/bffApi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13851,6 +13851,174 @@ paths:
schema:
type: integer
description: Time interval in milliseconds. Allowed requests will be constantly replenished during the interval. At the end of the interval the max allowed requests will be available
"/catalog/eservices/templates":
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
get:
tags:
- eserviceTemplates
summary: Retrieves EService templates catalog
description: Retrieves EService templates catalog
operationId: getEServiceTemplatesCatalog
parameters:
- in: query
name: q
description: Query to filter EService template by name
schema:
type: string
- in: query
name: creatorsIds
description: comma separated sequence of creators IDs
schema:
type: array
items:
type: string
format: uuid
default: []
explode: false
- in: query
name: offset
required: true
schema:
type: integer
format: int32
minimum: 0
- in: query
name: limit
required: true
schema:
type: integer
format: int32
minimum: 1
maximum: 50
responses:
"200":
description: A list of EService templates
content:
application/json:
schema:
$ref: "#/components/schemas/CatalogEServiceTemplates"
headers:
"X-Rate-Limit-Limit":
schema:
type: integer
description: Max allowed requests within time interval
"X-Rate-Limit-Remaining":
schema:
type: integer
description: Remaining requests within time interval
"X-Rate-Limit-Interval":
schema:
type: integer
description: Time interval in milliseconds. Allowed requests will be constantly replenished during the interval. At the end of the interval the max allowed requests will be available
"400":
description: Invalid input
headers:
"X-Rate-Limit-Limit":
schema:
type: integer
description: Max allowed requests within time interval
"X-Rate-Limit-Remaining":
schema:
type: integer
description: Remaining requests within time interval
"X-Rate-Limit-Interval":
schema:
type: integer
description: Time interval in milliseconds. Allowed requests will be constantly replenished during the interval. At the end of the interval the max allowed requests will be available
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
"429":
description: Too Many Requests
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
headers:
"X-Rate-Limit-Limit":
schema:
type: integer
description: Max allowed requests within time interval
"X-Rate-Limit-Remaining":
schema:
type: integer
description: Remaining requests within time interval
"X-Rate-Limit-Interval":
schema:
type: integer
description: Time interval in milliseconds. Allowed requests will be constantly replenished during the interval. At the end of the interval the max allowed requests will be available
"/producers/eservices/templates":
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
get:
tags:
- eserviceTemplates
summary: Retrieves Producer EService templates
description: Retrieves Producer EService templates
operationId: getProducerEServices
parameters:
- in: query
name: q
description: Query to filter EServices templates by name
schema:
type: string
- in: query
name: offset
required: true
schema:
type: integer
format: int32
minimum: 0
- in: query
name: limit
required: true
schema:
type: integer
format: int32
minimum: 1
maximum: 50
responses:
"200":
description: A list of EServices templates
content:
application/json:
schema:
$ref: "#/components/schemas/ProducerEServiceTemplates"
headers:
"X-Rate-Limit-Limit":
schema:
type: integer
description: Max allowed requests within time interval
"X-Rate-Limit-Remaining":
schema:
type: integer
description: Remaining requests within time interval
"X-Rate-Limit-Interval":
schema:
type: integer
description: Time interval in milliseconds. Allowed requests will be constantly replenished during the interval. At the end of the interval the max allowed requests will be available
"429":
description: Too Many Requests
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
headers:
"X-Rate-Limit-Limit":
schema:
type: integer
description: Max allowed requests within time interval
"X-Rate-Limit-Remaining":
schema:
type: integer
description: Remaining requests within time interval
"X-Rate-Limit-Interval":
schema:
type: integer
description: Time interval in milliseconds. Allowed requests will be constantly replenished during the interval. At the end of the interval the max allowed requests will be available

"/status":
get:
security: []
Expand Down Expand Up @@ -16700,6 +16868,69 @@ components:
$ref: "#/components/schemas/DescriptorAttributes"
eserviceTemplate:
$ref: "#/components/schemas/EServiceTemplateDetails"
CatalogEServiceTemplate:
type: object
additionalProperties: false
required:
- id
- name
- description
- creator
- publishedVersion
properties:
id:
type: string
format: uuid
name:
type: string
description:
type: string
creator:
$ref: "#/components/schemas/CompactOrganization"
publishedVersion:
$ref: "#/components/schemas/CompactEServiceTemplateVersion"
ProducerEServiceTemplate:
type: object
additionalProperties: false
required:
- id
- name
properties:
id:
type: string
format: uuid
name:
type: string
activeVersion:
$ref: "#/components/schemas/CompactEServiceTemplateVersion"
draftVersion:
$ref: "#/components/schemas/CompactEServiceTemplateVersion"
CatalogEServiceTemplates:
type: object
additionalProperties: false
properties:
results:
type: array
items:
$ref: "#/components/schemas/CatalogEServiceTemplate"
pagination:
$ref: "#/components/schemas/Pagination"
required:
- results
- pagination
ProducerEServiceTemplates:
type: object
additionalProperties: false
properties:
results:
type: array
items:
$ref: "#/components/schemas/ProducerEServiceTemplate"
pagination:
$ref: "#/components/schemas/Pagination"
required:
- results
- pagination
Problem:
type: object
additionalProperties: false
Expand Down
4 changes: 2 additions & 2 deletions packages/api-clients/open-api/eserviceTemplateApi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ paths:
schema:
type: string
- in: query
name: producersIds
description: comma separated sequence of producers IDs
name: eserviceTemplatesIds
description: comma separated sequence of eservice templates IDs
schema:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ import {
eserviceTemplateApi,
tenantApi,
} from "pagopa-interop-api-clients";
import { catalogEServiceTemplatePublishedVersionNotFound } from "../model/errors.js";
import { toBffCatalogApiEserviceRiskAnalysis } from "./catalogApiConverter.js";
import { toBffCompactOrganization } from "./agreementApiConverter.js";

export function toBffCompactEServiceTemplateVersion(
eserviceTemplateVersion: eserviceTemplateApi.EServiceTemplateVersion
): bffApi.CompactEServiceTemplateVersion {
return {
id: eserviceTemplateVersion.id,
version: eserviceTemplateVersion.version,
state: eserviceTemplateVersion.state,
};
}

export function toBffEServiceTemplateApiEServiceTemplateDetails(
eserviceTemplate: eserviceTemplateApi.EServiceTemplate,
Expand All @@ -15,15 +27,61 @@ export function toBffEServiceTemplateApiEServiceTemplateDetails(
audienceDescription: eserviceTemplate.audienceDescription,
eserviceDescription: eserviceTemplate.eserviceDescription,
technology: eserviceTemplate.technology,
creator: {
id: creator.id,
name: creator.name,
},
creator: toBffCompactOrganization(creator),
mode: eserviceTemplate.mode,
riskAnalysis: eserviceTemplate.riskAnalysis.map(
toBffCatalogApiEserviceRiskAnalysis
),
versions: eserviceTemplate.versions,
versions: eserviceTemplate.versions.map(
toBffCompactEServiceTemplateVersion
),
isSignalHubEnabled: eserviceTemplate.isSignalHubEnabled,
};
}

export function toBffCatalogEServiceTemplate(
eserviceTemplate: eserviceTemplateApi.EServiceTemplate,
creator: tenantApi.Tenant
): bffApi.CatalogEServiceTemplate {
const publishedVersion = eserviceTemplate.versions.find(
(v) =>
v.state ===
eserviceTemplateApi.EServiceTemplateVersionState.Values.PUBLISHED
);

if (!publishedVersion) {
throw catalogEServiceTemplatePublishedVersionNotFound(eserviceTemplate.id);
}

return {
id: eserviceTemplate.id,
name: eserviceTemplate.name,
description: eserviceTemplate.audienceDescription,
creator: toBffCompactOrganization(creator),
publishedVersion: toBffCompactEServiceTemplateVersion(publishedVersion),
};
}

export function toBffProducerEServiceTemplate(
eserviceTemplate: eserviceTemplateApi.EServiceTemplate
): bffApi.ProducerEServiceTemplate {
const activeVersion = eserviceTemplate.versions.find(
(v) =>
v.state ===
eserviceTemplateApi.EServiceTemplateVersionState.Values.PUBLISHED ||
v.state ===
eserviceTemplateApi.EServiceTemplateVersionState.Values.SUSPENDED
);

const draftVersion = eserviceTemplate.versions.find(
(v) =>
v.state === eserviceTemplateApi.EServiceTemplateVersionState.Values.DRAFT
);

return {
id: eserviceTemplate.id,
name: eserviceTemplate.name,
activeVersion,
draftVersion,
};
}
11 changes: 11 additions & 0 deletions packages/backend-for-frontend/src/model/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const errorCodes = {
eserviceDelegated: "0043",
delegatedEserviceNotExportable: "0044",
eserviceTemplateVersionNotFound: "0045",
catalogEServiceTemplatePublishedVersionNotFound: "0046",
};

export type ErrorCodes = keyof typeof errorCodes;
Expand Down Expand Up @@ -450,3 +451,13 @@ export function eserviceTemplateVersionNotFound(
title: "EService template version not found",
});
}

export function catalogEServiceTemplatePublishedVersionNotFound(
eserviceTemplateId: string
): ApiError<ErrorCodes> {
return new ApiError({
detail: `Published version not found in catalog Eservice template ${eserviceTemplateId}`,
code: "catalogEServiceTemplatePublishedVersionNotFound",
title: "Catalog EService template published version not found",
});
}
Loading
Loading