Skip to content

Commit

Permalink
Updated e-service models and events (#15)
Browse files Browse the repository at this point in the history
* Added new events

* Bump version

* Udated events and e-service model

* fix format

* Bump version
  • Loading branch information
Carminepo2 authored Oct 17, 2024
1 parent a520391 commit 43aa9b8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pagopa/interop-outbound-models",
"version": "1.0.7",
"version": "1.0.8",
"description": "PagoPA Interoperability outbound models",
"main": "dist",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions proto/v2/eservice/eservice.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ message EServiceV2 {
repeated EServiceDescriptorV2 descriptors = 6;
int64 createdAt = 7;
EServiceModeV2 mode = 8;
optional bool isSignalHubEnabled = 9;
}

message EServiceAttributeValueV2 {
Expand Down
9 changes: 7 additions & 2 deletions proto/v2/eservice/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,17 @@ message EServiceDescriptionUpdatedV2 {
EServiceV2 eservice = 1;
}

message EServiceDescriptorApprovedV2 {
message EServiceDescriptorDelegateSubmittedV2 {
string descriptorId = 1;
EServiceV2 eservice = 2;
}

message EServiceDescriptorRejectedV2 {
message EServiceDescriptorDelegatorApprovedV2 {
string descriptorId = 1;
EServiceV2 eservice = 2;
}

message EServiceDescriptorDelegatorRejectedV2 {
string descriptorId = 1;
EServiceV2 eservice = 2;
}
32 changes: 22 additions & 10 deletions src/eservice/eventsV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import {
EServiceDraftDescriptorUpdatedV2,
EServiceDescriptorQuotasUpdatedV2,
EServiceDescriptionUpdatedV2,
EServiceDescriptorApprovedV2,
EServiceDescriptorRejectedV2,
EServiceDescriptorDelegateSubmittedV2,
EServiceDescriptorDelegatorApprovedV2,
EServiceDescriptorDelegatorRejectedV2,
} from "../gen/v2/eservice/events.js";

export function eServiceEventToBinaryDataV2(
Expand Down Expand Up @@ -86,11 +87,14 @@ export function eServiceEventToBinaryDataV2(
.with({ type: "EServiceDescriptionUpdated" }, ({ data }) =>
EServiceDescriptionUpdatedV2.toBinary(data)
)
.with({ type: "EServiceDescriptorApproved" }, ({ data }) =>
EServiceDescriptorApprovedV2.toBinary(data)
.with({ type: "EServiceDescriptorDelegateSubmitted" }, ({ data }) =>
EServiceDescriptorDelegateSubmittedV2.toBinary(data)
)
.with({ type: "EServiceDescriptorRejected" }, ({ data }) =>
EServiceDescriptorRejectedV2.toBinary(data)
.with({ type: "EServiceDescriptorDelegatorApproved" }, ({ data }) =>
EServiceDescriptorDelegatorApprovedV2.toBinary(data)
)
.with({ type: "EServiceDescriptorDelegatorRejected" }, ({ data }) =>
EServiceDescriptorDelegatorRejectedV2.toBinary(data)
)
.exhaustive();
}
Expand Down Expand Up @@ -250,16 +254,24 @@ export const EServiceEventV2 = z.discriminatedUnion("type", [
}),
z.object({
event_version: z.literal(2),
type: z.literal("EServiceDescriptorApproved"),
data: protobufDecoder(EServiceDescriptorApprovedV2),
type: z.literal("EServiceDescriptorDelegateSubmitted"),
data: protobufDecoder(EServiceDescriptorDelegateSubmittedV2),
stream_id: z.string(),
version: z.number(),
timestamp: z.coerce.date(),
}),
z.object({
event_version: z.literal(2),
type: z.literal("EServiceDescriptorDelegatorApproved"),
data: protobufDecoder(EServiceDescriptorDelegatorApprovedV2),
stream_id: z.string(),
version: z.number(),
timestamp: z.coerce.date(),
}),
z.object({
event_version: z.literal(2),
type: z.literal("EServiceDescriptorRejected"),
data: protobufDecoder(EServiceDescriptorRejectedV2),
type: z.literal("EServiceDescriptorDelegatorRejected"),
data: protobufDecoder(EServiceDescriptorDelegatorRejectedV2),
stream_id: z.string(),
version: z.number(),
timestamp: z.coerce.date(),
Expand Down

0 comments on commit 43aa9b8

Please sign in to comment.