@pagopa/interop-outbound-models 1.8.20 → 1.8.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -2
- package/dist/gen/v2/agreement/agreement.d.ts +45 -2
- package/dist/gen/v2/agreement/agreement.d.ts.map +1 -1
- package/dist/gen/v2/agreement/agreement.js +100 -6
- package/dist/gen/v2/eservice/eservice.d.ts +60 -0
- package/dist/gen/v2/eservice/eservice.d.ts.map +1 -1
- package/dist/gen/v2/eservice/eservice.js +97 -1
- package/dist/gen/v2/eservice-template/eservice-template.d.ts +5 -0
- package/dist/gen/v2/eservice-template/eservice-template.d.ts.map +1 -1
- package/dist/gen/v2/eservice-template/eservice-template.js +9 -1
- package/dist/gen/v2/tenant/events.d.ts +107 -0
- package/dist/gen/v2/tenant/events.d.ts.map +1 -1
- package/dist/gen/v2/tenant/events.js +254 -0
- package/dist/gen/v2/tenant/tenant.d.ts +68 -0
- package/dist/gen/v2/tenant/tenant.d.ts.map +1 -1
- package/dist/gen/v2/tenant/tenant.js +153 -2
- package/dist/tenant/eventsV2.d.ts +106 -1
- package/dist/tenant/eventsV2.d.ts.map +1 -1
- package/dist/tenant/eventsV2.js +46 -1
- package/dist/tenant/index.d.ts +35 -0
- package/dist/tenant/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/proto/v2/agreement/agreement.proto +11 -1
- package/proto/v2/eservice/eservice.proto +16 -0
- package/proto/v2/eservice-template/eservice-template.proto +1 -0
- package/proto/v2/tenant/events.proto +23 -0
- package/proto/v2/tenant/tenant.proto +15 -0
- package/src/tenant/eventsV2.ts +60 -0
- package/tests/agreement.test.ts +30 -1
- package/tests/eservice.test.ts +6 -0
- package/tests/template.test.ts +6 -0
- package/tests/tenant.test.ts +49 -1
package/src/tenant/eventsV2.ts
CHANGED
|
@@ -19,6 +19,11 @@ import {
|
|
|
19
19
|
TenantDelegatedProducerFeatureRemovedV2,
|
|
20
20
|
TenantDelegatedConsumerFeatureAddedV2,
|
|
21
21
|
TenantDelegatedConsumerFeatureRemovedV2,
|
|
22
|
+
TenantCertifiedDiscreteAttributeAssignedV2,
|
|
23
|
+
TenantCertifiedDiscreteAttributeRevokedV2,
|
|
24
|
+
TenantCertifiedDiscreteAttributeUpdatedV2,
|
|
25
|
+
TenantRemoteIdAssignedV2,
|
|
26
|
+
MaintenanceTenantRemoteIdDeletedV2,
|
|
22
27
|
} from "../gen/v2/tenant/events.js";
|
|
23
28
|
import { protobufDecoder } from "../utils.js";
|
|
24
29
|
|
|
@@ -78,6 +83,21 @@ export function tenantEventToBinaryDataV2(event: TenantEventV2): Uint8Array {
|
|
|
78
83
|
.with({ type: "TenantDelegatedConsumerFeatureRemoved" }, ({ data }) =>
|
|
79
84
|
TenantDelegatedConsumerFeatureRemovedV2.toBinary(data)
|
|
80
85
|
)
|
|
86
|
+
.with({ type: "TenantCertifiedDiscreteAttributeAssigned" }, ({ data }) =>
|
|
87
|
+
TenantCertifiedDiscreteAttributeAssignedV2.toBinary(data)
|
|
88
|
+
)
|
|
89
|
+
.with({ type: "TenantCertifiedDiscreteAttributeRevoked" }, ({ data }) =>
|
|
90
|
+
TenantCertifiedDiscreteAttributeRevokedV2.toBinary(data)
|
|
91
|
+
)
|
|
92
|
+
.with({ type: "TenantCertifiedDiscreteAttributeUpdated" }, ({ data }) =>
|
|
93
|
+
TenantCertifiedDiscreteAttributeUpdatedV2.toBinary(data)
|
|
94
|
+
)
|
|
95
|
+
.with({ type: "TenantRemoteIdAssigned" }, ({ data }) =>
|
|
96
|
+
TenantRemoteIdAssignedV2.toBinary(data)
|
|
97
|
+
)
|
|
98
|
+
.with({ type: "MaintenanceTenantRemoteIdDeleted" }, ({ data }) =>
|
|
99
|
+
MaintenanceTenantRemoteIdDeletedV2.toBinary(data)
|
|
100
|
+
)
|
|
81
101
|
.exhaustive();
|
|
82
102
|
}
|
|
83
103
|
|
|
@@ -226,6 +246,46 @@ export const TenantEventV2 = z.discriminatedUnion("type", [
|
|
|
226
246
|
version: z.number(),
|
|
227
247
|
timestamp: z.coerce.date(),
|
|
228
248
|
}),
|
|
249
|
+
z.object({
|
|
250
|
+
event_version: z.literal(2),
|
|
251
|
+
type: z.literal("TenantCertifiedDiscreteAttributeAssigned"),
|
|
252
|
+
data: protobufDecoder(TenantCertifiedDiscreteAttributeAssignedV2),
|
|
253
|
+
stream_id: z.string(),
|
|
254
|
+
version: z.number(),
|
|
255
|
+
timestamp: z.coerce.date(),
|
|
256
|
+
}),
|
|
257
|
+
z.object({
|
|
258
|
+
event_version: z.literal(2),
|
|
259
|
+
type: z.literal("TenantCertifiedDiscreteAttributeRevoked"),
|
|
260
|
+
data: protobufDecoder(TenantCertifiedDiscreteAttributeRevokedV2),
|
|
261
|
+
stream_id: z.string(),
|
|
262
|
+
version: z.number(),
|
|
263
|
+
timestamp: z.coerce.date(),
|
|
264
|
+
}),
|
|
265
|
+
z.object({
|
|
266
|
+
event_version: z.literal(2),
|
|
267
|
+
type: z.literal("TenantCertifiedDiscreteAttributeUpdated"),
|
|
268
|
+
data: protobufDecoder(TenantCertifiedDiscreteAttributeUpdatedV2),
|
|
269
|
+
stream_id: z.string(),
|
|
270
|
+
version: z.number(),
|
|
271
|
+
timestamp: z.coerce.date(),
|
|
272
|
+
}),
|
|
273
|
+
z.object({
|
|
274
|
+
event_version: z.literal(2),
|
|
275
|
+
type: z.literal("TenantRemoteIdAssigned"),
|
|
276
|
+
data: protobufDecoder(TenantRemoteIdAssignedV2),
|
|
277
|
+
stream_id: z.string(),
|
|
278
|
+
version: z.number(),
|
|
279
|
+
timestamp: z.coerce.date(),
|
|
280
|
+
}),
|
|
281
|
+
z.object({
|
|
282
|
+
event_version: z.literal(2),
|
|
283
|
+
type: z.literal("MaintenanceTenantRemoteIdDeleted"),
|
|
284
|
+
data: protobufDecoder(MaintenanceTenantRemoteIdDeletedV2),
|
|
285
|
+
stream_id: z.string(),
|
|
286
|
+
version: z.number(),
|
|
287
|
+
timestamp: z.coerce.date(),
|
|
288
|
+
}),
|
|
229
289
|
]);
|
|
230
290
|
|
|
231
291
|
export type TenantEventV2 = z.infer<typeof TenantEventV2>;
|
package/tests/agreement.test.ts
CHANGED
|
@@ -24,5 +24,34 @@ describe("agreement", () => {
|
|
|
24
24
|
expect(decoded).toEqual(event);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
it("should correctly encode and decode AgreementAdded V2 event with certified discrete attributes", () => {
|
|
28
|
+
const event: AgreementEvent = {
|
|
29
|
+
event_version: 2,
|
|
30
|
+
type: "AgreementAdded",
|
|
31
|
+
data: {
|
|
32
|
+
agreement: {
|
|
33
|
+
id: "agreement-id",
|
|
34
|
+
eserviceId: "eservice-id",
|
|
35
|
+
descriptorId: "descriptor-id",
|
|
36
|
+
producerId: "producer-id",
|
|
37
|
+
consumerId: "consumer-id",
|
|
38
|
+
state: 1,
|
|
39
|
+
verifiedAttributes: [],
|
|
40
|
+
certifiedAttributes: [{ id: "certified-id" }],
|
|
41
|
+
declaredAttributes: [],
|
|
42
|
+
consumerDocuments: [],
|
|
43
|
+
createdAt: 1n,
|
|
44
|
+
certifiedDiscreteAttributes: [{ id: "certified-discrete-id" }],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
stream_id: "agreement-stream",
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
version: 1,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const encoded = encodeOutboundAgreementEvent(event);
|
|
53
|
+
const decoded = decodeOutboundAgreementEvent(encoded);
|
|
54
|
+
|
|
55
|
+
expect(decoded).toEqual(event);
|
|
56
|
+
});
|
|
28
57
|
});
|
package/tests/eservice.test.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
EServiceTechnologyV2,
|
|
9
9
|
EServiceDescriptorStateV2,
|
|
10
10
|
AgreementApprovalPolicyV2,
|
|
11
|
+
AttributeCertifiedDiscreteComparatorV2,
|
|
11
12
|
} from "../src/index.js";
|
|
12
13
|
|
|
13
14
|
describe("eservice", () => {
|
|
@@ -46,6 +47,11 @@ describe("eservice", () => {
|
|
|
46
47
|
id: "test",
|
|
47
48
|
explicitAttributeVerification: true,
|
|
48
49
|
dailyCallsPerConsumer: 10,
|
|
50
|
+
discreteConfig: {
|
|
51
|
+
threshold: 50,
|
|
52
|
+
comparator:
|
|
53
|
+
AttributeCertifiedDiscreteComparatorV2.GTE,
|
|
54
|
+
},
|
|
49
55
|
},
|
|
50
56
|
],
|
|
51
57
|
},
|
package/tests/template.test.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
EServiceModeV2,
|
|
9
9
|
EServiceTechnologyV2,
|
|
10
10
|
AgreementApprovalPolicyV2,
|
|
11
|
+
AttributeCertifiedDiscreteComparatorV2,
|
|
11
12
|
} from "../src/index.js";
|
|
12
13
|
|
|
13
14
|
describe("eservice-template", () => {
|
|
@@ -43,6 +44,11 @@ describe("eservice-template", () => {
|
|
|
43
44
|
{
|
|
44
45
|
id: "attr-id",
|
|
45
46
|
explicitAttributeVerification: false,
|
|
47
|
+
discreteConfig: {
|
|
48
|
+
threshold: 75,
|
|
49
|
+
comparator:
|
|
50
|
+
AttributeCertifiedDiscreteComparatorV2.LTE,
|
|
51
|
+
},
|
|
46
52
|
},
|
|
47
53
|
],
|
|
48
54
|
},
|
package/tests/tenant.test.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
encodeOutboundTenantEvent,
|
|
4
4
|
decodeOutboundTenantEvent,
|
|
5
5
|
TenantEvent,
|
|
6
|
+
TenantKindV2,
|
|
6
7
|
} from "../src/index.js";
|
|
7
8
|
|
|
8
9
|
describe("tenant", () => {
|
|
@@ -24,5 +25,52 @@ describe("tenant", () => {
|
|
|
24
25
|
expect(decoded).toEqual(event);
|
|
25
26
|
});
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
it("should correctly encode and decode TenantOnboarded event with remote ids and certified discrete attributes", () => {
|
|
29
|
+
const event: TenantEvent = {
|
|
30
|
+
event_version: 2,
|
|
31
|
+
type: "TenantOnboarded",
|
|
32
|
+
data: {
|
|
33
|
+
tenant: {
|
|
34
|
+
id: "tenant-id",
|
|
35
|
+
selfcareId: "selfcare-id",
|
|
36
|
+
externalId: {
|
|
37
|
+
origin: "IPA",
|
|
38
|
+
value: "tenant-code",
|
|
39
|
+
},
|
|
40
|
+
features: [],
|
|
41
|
+
attributes: [
|
|
42
|
+
{
|
|
43
|
+
sealedValue: {
|
|
44
|
+
oneofKind: "certifiedDiscreteAttribute",
|
|
45
|
+
certifiedDiscreteAttribute: {
|
|
46
|
+
id: "attribute-id",
|
|
47
|
+
assignmentTimestamp: 1n,
|
|
48
|
+
discreteValue: 42,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
createdAt: 1n,
|
|
54
|
+
name: "Tenant name",
|
|
55
|
+
kind: TenantKindV2.PA,
|
|
56
|
+
onboardedAt: 1n,
|
|
57
|
+
remoteIds: [
|
|
58
|
+
{
|
|
59
|
+
origin: "ANAC",
|
|
60
|
+
value: "remote-code",
|
|
61
|
+
assignmentTimestamp: 1n,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
stream_id: "tenant-stream",
|
|
67
|
+
timestamp: new Date(),
|
|
68
|
+
version: 1,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const encoded = encodeOutboundTenantEvent(event);
|
|
72
|
+
const decoded = decodeOutboundTenantEvent(encoded);
|
|
73
|
+
|
|
74
|
+
expect(decoded).toEqual(event);
|
|
75
|
+
});
|
|
28
76
|
});
|