Skip to content

Commit

Permalink
added delegatedConsumer models
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterITA committed Nov 11, 2024
1 parent f5606e1 commit 5020f6e
Show file tree
Hide file tree
Showing 4 changed files with 38 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.6c",
"version": "1.0.6d",
"description": "PagoPA Interoperability outbound models",
"main": "dist",
"type": "module",
Expand Down
8 changes: 8 additions & 0 deletions proto/v2/tenant/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ message TenantDelegatedProducerFeatureAddedV2 {
message TenantDelegatedProducerFeatureRemovedV2 {
TenantV2 tenant = 1;
}

message TenantDelegatedConsumerFeatureAddedV2 {
TenantV2 tenant = 1;
}

message TenantDelegatedConsumerFeatureRemovedV2 {
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 @@ -32,6 +32,7 @@ message TenantFeatureV2 {
oneof sealed_value {
CertifierV2 certifier = 1;
DelegatedProducerV2 delegatedProducer = 2;
DelegatedConsumerV2 delegatedConsumer = 3;
}
}

Expand All @@ -43,6 +44,10 @@ message DelegatedProducerV2 {
int64 availabilityTimestamp = 1;
}

message DelegatedConsumerV2 {
int64 availabilityTimestamp = 1;
}

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

Expand Down Expand Up @@ -66,6 +68,12 @@ export function tenantEventToBinaryDataV2(event: TenantEventV2): Uint8Array {
.with({ type: "TenantDelegatedProducerFeatureRemoved" }, ({ data }) =>
TenantDelegatedProducerFeatureRemovedV2.toBinary(data)
)
.with({ type: "TenantDelegatedConsumerFeatureAdded" }, ({ data }) =>
TenantDelegatedConsumerFeatureAddedV2.toBinary(data)
)
.with({ type: "TenantDelegatedConsumerFeatureRemoved" }, ({ data }) =>
TenantDelegatedConsumerFeatureRemovedV2.toBinary(data)
)
.exhaustive();
}

Expand Down Expand Up @@ -190,6 +198,22 @@ export const TenantEventV2 = z.discriminatedUnion("type", [
version: z.number(),
timestamp: z.coerce.date(),
}),
z.object({
event_version: z.literal(2),
type: z.literal("TenantDelegatedConsumerFeatureAdded"),
data: protobufDecoder(TenantDelegatedConsumerFeatureAddedV2),
stream_id: z.string(),
version: z.number(),
timestamp: z.coerce.date(),
}),
z.object({
event_version: z.literal(2),
type: z.literal("TenantDelegatedConsumerFeatureRemoved"),
data: protobufDecoder(TenantDelegatedConsumerFeatureRemovedV2),
stream_id: z.string(),
version: z.number(),
timestamp: z.coerce.date(),
}),
]);

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

0 comments on commit 5020f6e

Please sign in to comment.