Skip to content

Commit

Permalink
Added new tenant delegated producer event (#11)
Browse files Browse the repository at this point in the history
* Added new outbound event

* Bump version

* Updated event name

* Added other delegations events

* Undo e-service model change

* Revert "Undo e-service model change"

This reverts commit 502b26b.

* Revert "Added other delegations events"

This reverts commit 9b0534c.
  • Loading branch information
Carminepo2 authored Oct 16, 2024
1 parent e0ba820 commit cda86c5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
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.4",
"version": "1.0.5",
"description": "PagoPA Interoperability outbound models",
"main": "dist",
"type": "module",
Expand Down
5 changes: 5 additions & 0 deletions proto/v2/tenant/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ message TenantKindUpdatedV2 {
optional TenantKindV2 oldKind = 1;
TenantV2 tenant = 2;
}

message TenantDelegatedProducerFeatureAddedV2 {
TenantV2 tenant = 1;
}

5 changes: 5 additions & 0 deletions proto/v2/tenant/tenant.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ enum TenantUnitTypeV2 {
message TenantFeatureV2 {
oneof sealed_value {
CertifierV2 certifier = 1;
DelegatedProducerV2 delegatedProducer = 2;
}
}

message CertifierV2 {
string certifierId = 1;
}

message DelegatedProducerV2 {
int64 availabilityTimestamp = 1;
}

message TenantVerifierV2 {
string id = 1;
int64 verificationDate = 2;
Expand Down
12 changes: 12 additions & 0 deletions src/tenant/eventsV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
TenantVerifiedAttributeExtensionUpdatedV2,
TenantKindUpdatedV2,
MaintenanceTenantPromotedToCertifierV2,
TenantDelegatedProducerFeatureAddedV2,
} from "../gen/v2/tenant/events.js";
import { protobufDecoder } from "../utils.js";

Expand Down Expand Up @@ -58,6 +59,9 @@ export function tenantEventToBinaryDataV2(event: TenantEventV2): Uint8Array {
.with({ type: "MaintenanceTenantPromotedToCertifier" }, ({ data }) =>
MaintenanceTenantPromotedToCertifierV2.toBinary(data)
)
.with({ type: "TenantDelegatedProducerFeatureAdded" }, ({ data }) =>
TenantDelegatedProducerFeatureAddedV2.toBinary(data)
)
.exhaustive();
}

Expand Down Expand Up @@ -166,6 +170,14 @@ export const TenantEventV2 = z.discriminatedUnion("type", [
version: z.number(),
timestamp: z.coerce.date(),
}),
z.object({
event_version: z.literal(2),
type: z.literal("TenantDelegatedProducerFeatureAdded"),
data: protobufDecoder(TenantDelegatedProducerFeatureAddedV2),
stream_id: z.string(),
version: z.number(),
timestamp: z.coerce.date(),
}),
]);

export type TenantEventV2 = z.infer<typeof TenantEventV2>;

0 comments on commit cda86c5

Please sign in to comment.