@pagopa/interop-outbound-models 1.0.12-b → 1.0.12-c
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/dist/delegation/eventsV2.d.ts +174 -0
- package/dist/delegation/eventsV2.d.ts.map +1 -0
- package/dist/delegation/eventsV2.js +82 -0
- package/dist/delegation/index.d.ts +81 -0
- package/dist/delegation/index.d.ts.map +1 -0
- package/dist/delegation/index.js +36 -0
- package/dist/gen/v2/delegation/delegation.d.ts +202 -0
- package/dist/gen/v2/delegation/delegation.d.ts.map +1 -0
- package/dist/gen/v2/delegation/delegation.js +385 -0
- package/dist/gen/v2/delegation/events.d.ts +161 -0
- package/dist/gen/v2/delegation/events.d.ts.map +1 -0
- package/dist/gen/v2/delegation/events.js +373 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +2 -2
- package/proto/v2/delegation/delegation.proto +52 -0
- package/proto/v2/delegation/events.proto +37 -0
- package/src/delegation/eventsV2.ts +113 -0
- package/src/delegation/index.ts +49 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ProducerDelegationSubmittedV2, ProducerDelegationApprovedV2, ProducerDelegationRejectedV2, ProducerDelegationRevokedV2, ConsumerDelegationApprovedV2, ConsumerDelegationRejectedV2, ConsumerDelegationRevokedV2, ConsumerDelegationSubmittedV2 } from "../gen/v2/delegation/events.js";
|
|
3
|
+
export declare function delegationEventToBinaryDataV2(event: DelegationEventV2): Uint8Array;
|
|
4
|
+
export declare const DelegationEventV2: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
5
|
+
event_version: z.ZodLiteral<2>;
|
|
6
|
+
type: z.ZodLiteral<"ProducerDelegationSubmitted">;
|
|
7
|
+
data: z.ZodEffects<z.ZodAny, ProducerDelegationSubmittedV2, any>;
|
|
8
|
+
stream_id: z.ZodString;
|
|
9
|
+
version: z.ZodNumber;
|
|
10
|
+
timestamp: z.ZodDate;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
event_version: 2;
|
|
13
|
+
type: "ProducerDelegationSubmitted";
|
|
14
|
+
version: number;
|
|
15
|
+
data: ProducerDelegationSubmittedV2;
|
|
16
|
+
stream_id: string;
|
|
17
|
+
timestamp: Date;
|
|
18
|
+
}, {
|
|
19
|
+
event_version: 2;
|
|
20
|
+
type: "ProducerDelegationSubmitted";
|
|
21
|
+
version: number;
|
|
22
|
+
stream_id: string;
|
|
23
|
+
timestamp: Date;
|
|
24
|
+
data?: any;
|
|
25
|
+
}>, z.ZodObject<{
|
|
26
|
+
event_version: z.ZodLiteral<2>;
|
|
27
|
+
type: z.ZodLiteral<"ProducerDelegationApproved">;
|
|
28
|
+
data: z.ZodEffects<z.ZodAny, ProducerDelegationApprovedV2, any>;
|
|
29
|
+
stream_id: z.ZodString;
|
|
30
|
+
version: z.ZodNumber;
|
|
31
|
+
timestamp: z.ZodDate;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
event_version: 2;
|
|
34
|
+
type: "ProducerDelegationApproved";
|
|
35
|
+
version: number;
|
|
36
|
+
data: ProducerDelegationApprovedV2;
|
|
37
|
+
stream_id: string;
|
|
38
|
+
timestamp: Date;
|
|
39
|
+
}, {
|
|
40
|
+
event_version: 2;
|
|
41
|
+
type: "ProducerDelegationApproved";
|
|
42
|
+
version: number;
|
|
43
|
+
stream_id: string;
|
|
44
|
+
timestamp: Date;
|
|
45
|
+
data?: any;
|
|
46
|
+
}>, z.ZodObject<{
|
|
47
|
+
event_version: z.ZodLiteral<2>;
|
|
48
|
+
type: z.ZodLiteral<"ProducerDelegationRejected">;
|
|
49
|
+
data: z.ZodEffects<z.ZodAny, ProducerDelegationRejectedV2, any>;
|
|
50
|
+
stream_id: z.ZodString;
|
|
51
|
+
version: z.ZodNumber;
|
|
52
|
+
timestamp: z.ZodDate;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
event_version: 2;
|
|
55
|
+
type: "ProducerDelegationRejected";
|
|
56
|
+
version: number;
|
|
57
|
+
data: ProducerDelegationRejectedV2;
|
|
58
|
+
stream_id: string;
|
|
59
|
+
timestamp: Date;
|
|
60
|
+
}, {
|
|
61
|
+
event_version: 2;
|
|
62
|
+
type: "ProducerDelegationRejected";
|
|
63
|
+
version: number;
|
|
64
|
+
stream_id: string;
|
|
65
|
+
timestamp: Date;
|
|
66
|
+
data?: any;
|
|
67
|
+
}>, z.ZodObject<{
|
|
68
|
+
event_version: z.ZodLiteral<2>;
|
|
69
|
+
type: z.ZodLiteral<"ProducerDelegationRevoked">;
|
|
70
|
+
data: z.ZodEffects<z.ZodAny, ProducerDelegationRevokedV2, any>;
|
|
71
|
+
stream_id: z.ZodString;
|
|
72
|
+
version: z.ZodNumber;
|
|
73
|
+
timestamp: z.ZodDate;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
event_version: 2;
|
|
76
|
+
type: "ProducerDelegationRevoked";
|
|
77
|
+
version: number;
|
|
78
|
+
data: ProducerDelegationRevokedV2;
|
|
79
|
+
stream_id: string;
|
|
80
|
+
timestamp: Date;
|
|
81
|
+
}, {
|
|
82
|
+
event_version: 2;
|
|
83
|
+
type: "ProducerDelegationRevoked";
|
|
84
|
+
version: number;
|
|
85
|
+
stream_id: string;
|
|
86
|
+
timestamp: Date;
|
|
87
|
+
data?: any;
|
|
88
|
+
}>, z.ZodObject<{
|
|
89
|
+
event_version: z.ZodLiteral<2>;
|
|
90
|
+
type: z.ZodLiteral<"ConsumerDelegationSubmitted">;
|
|
91
|
+
data: z.ZodEffects<z.ZodAny, ConsumerDelegationSubmittedV2, any>;
|
|
92
|
+
stream_id: z.ZodString;
|
|
93
|
+
version: z.ZodNumber;
|
|
94
|
+
timestamp: z.ZodDate;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
event_version: 2;
|
|
97
|
+
type: "ConsumerDelegationSubmitted";
|
|
98
|
+
version: number;
|
|
99
|
+
data: ConsumerDelegationSubmittedV2;
|
|
100
|
+
stream_id: string;
|
|
101
|
+
timestamp: Date;
|
|
102
|
+
}, {
|
|
103
|
+
event_version: 2;
|
|
104
|
+
type: "ConsumerDelegationSubmitted";
|
|
105
|
+
version: number;
|
|
106
|
+
stream_id: string;
|
|
107
|
+
timestamp: Date;
|
|
108
|
+
data?: any;
|
|
109
|
+
}>, z.ZodObject<{
|
|
110
|
+
event_version: z.ZodLiteral<2>;
|
|
111
|
+
type: z.ZodLiteral<"ConsumerDelegationApproved">;
|
|
112
|
+
data: z.ZodEffects<z.ZodAny, ConsumerDelegationApprovedV2, any>;
|
|
113
|
+
stream_id: z.ZodString;
|
|
114
|
+
version: z.ZodNumber;
|
|
115
|
+
timestamp: z.ZodDate;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
event_version: 2;
|
|
118
|
+
type: "ConsumerDelegationApproved";
|
|
119
|
+
version: number;
|
|
120
|
+
data: ConsumerDelegationApprovedV2;
|
|
121
|
+
stream_id: string;
|
|
122
|
+
timestamp: Date;
|
|
123
|
+
}, {
|
|
124
|
+
event_version: 2;
|
|
125
|
+
type: "ConsumerDelegationApproved";
|
|
126
|
+
version: number;
|
|
127
|
+
stream_id: string;
|
|
128
|
+
timestamp: Date;
|
|
129
|
+
data?: any;
|
|
130
|
+
}>, z.ZodObject<{
|
|
131
|
+
event_version: z.ZodLiteral<2>;
|
|
132
|
+
type: z.ZodLiteral<"ConsumerDelegationRejected">;
|
|
133
|
+
data: z.ZodEffects<z.ZodAny, ConsumerDelegationRejectedV2, any>;
|
|
134
|
+
stream_id: z.ZodString;
|
|
135
|
+
version: z.ZodNumber;
|
|
136
|
+
timestamp: z.ZodDate;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
event_version: 2;
|
|
139
|
+
type: "ConsumerDelegationRejected";
|
|
140
|
+
version: number;
|
|
141
|
+
data: ConsumerDelegationRejectedV2;
|
|
142
|
+
stream_id: string;
|
|
143
|
+
timestamp: Date;
|
|
144
|
+
}, {
|
|
145
|
+
event_version: 2;
|
|
146
|
+
type: "ConsumerDelegationRejected";
|
|
147
|
+
version: number;
|
|
148
|
+
stream_id: string;
|
|
149
|
+
timestamp: Date;
|
|
150
|
+
data?: any;
|
|
151
|
+
}>, z.ZodObject<{
|
|
152
|
+
event_version: z.ZodLiteral<2>;
|
|
153
|
+
type: z.ZodLiteral<"ConsumerDelegationRevoked">;
|
|
154
|
+
data: z.ZodEffects<z.ZodAny, ConsumerDelegationRevokedV2, any>;
|
|
155
|
+
stream_id: z.ZodString;
|
|
156
|
+
version: z.ZodNumber;
|
|
157
|
+
timestamp: z.ZodDate;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
event_version: 2;
|
|
160
|
+
type: "ConsumerDelegationRevoked";
|
|
161
|
+
version: number;
|
|
162
|
+
data: ConsumerDelegationRevokedV2;
|
|
163
|
+
stream_id: string;
|
|
164
|
+
timestamp: Date;
|
|
165
|
+
}, {
|
|
166
|
+
event_version: 2;
|
|
167
|
+
type: "ConsumerDelegationRevoked";
|
|
168
|
+
version: number;
|
|
169
|
+
stream_id: string;
|
|
170
|
+
timestamp: Date;
|
|
171
|
+
data?: any;
|
|
172
|
+
}>]>;
|
|
173
|
+
export type DelegationEventV2 = z.infer<typeof DelegationEventV2>;
|
|
174
|
+
//# sourceMappingURL=eventsV2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventsV2.d.ts","sourceRoot":"","sources":["../../src/delegation/eventsV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,4BAA4B,EAC5B,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,gCAAgC,CAAC;AAGxC,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,iBAAiB,GACvB,UAAU,CA2BZ;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiE5B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { match } from "ts-pattern";
|
|
3
|
+
import { ProducerDelegationSubmittedV2, ProducerDelegationApprovedV2, ProducerDelegationRejectedV2, ProducerDelegationRevokedV2, ConsumerDelegationApprovedV2, ConsumerDelegationRejectedV2, ConsumerDelegationRevokedV2, ConsumerDelegationSubmittedV2, } from "../gen/v2/delegation/events.js";
|
|
4
|
+
import { protobufDecoder } from "../utils.js";
|
|
5
|
+
export function delegationEventToBinaryDataV2(event) {
|
|
6
|
+
return match(event)
|
|
7
|
+
.with({ type: "ProducerDelegationSubmitted" }, ({ data }) => ProducerDelegationSubmittedV2.toBinary(data))
|
|
8
|
+
.with({ type: "ProducerDelegationApproved" }, ({ data }) => ProducerDelegationApprovedV2.toBinary(data))
|
|
9
|
+
.with({ type: "ProducerDelegationRejected" }, ({ data }) => ProducerDelegationRejectedV2.toBinary(data))
|
|
10
|
+
.with({ type: "ProducerDelegationRevoked" }, ({ data }) => ProducerDelegationRevokedV2.toBinary(data))
|
|
11
|
+
.with({ type: "ConsumerDelegationSubmitted" }, ({ data }) => ConsumerDelegationSubmittedV2.toBinary(data))
|
|
12
|
+
.with({ type: "ConsumerDelegationApproved" }, ({ data }) => ConsumerDelegationApprovedV2.toBinary(data))
|
|
13
|
+
.with({ type: "ConsumerDelegationRejected" }, ({ data }) => ConsumerDelegationRejectedV2.toBinary(data))
|
|
14
|
+
.with({ type: "ConsumerDelegationRevoked" }, ({ data }) => ConsumerDelegationRevokedV2.toBinary(data))
|
|
15
|
+
.exhaustive();
|
|
16
|
+
}
|
|
17
|
+
export const DelegationEventV2 = z.discriminatedUnion("type", [
|
|
18
|
+
z.object({
|
|
19
|
+
event_version: z.literal(2),
|
|
20
|
+
type: z.literal("ProducerDelegationSubmitted"),
|
|
21
|
+
data: protobufDecoder(ProducerDelegationSubmittedV2),
|
|
22
|
+
stream_id: z.string(),
|
|
23
|
+
version: z.number(),
|
|
24
|
+
timestamp: z.coerce.date(),
|
|
25
|
+
}),
|
|
26
|
+
z.object({
|
|
27
|
+
event_version: z.literal(2),
|
|
28
|
+
type: z.literal("ProducerDelegationApproved"),
|
|
29
|
+
data: protobufDecoder(ProducerDelegationApprovedV2),
|
|
30
|
+
stream_id: z.string(),
|
|
31
|
+
version: z.number(),
|
|
32
|
+
timestamp: z.coerce.date(),
|
|
33
|
+
}),
|
|
34
|
+
z.object({
|
|
35
|
+
event_version: z.literal(2),
|
|
36
|
+
type: z.literal("ProducerDelegationRejected"),
|
|
37
|
+
data: protobufDecoder(ProducerDelegationRejectedV2),
|
|
38
|
+
stream_id: z.string(),
|
|
39
|
+
version: z.number(),
|
|
40
|
+
timestamp: z.coerce.date(),
|
|
41
|
+
}),
|
|
42
|
+
z.object({
|
|
43
|
+
event_version: z.literal(2),
|
|
44
|
+
type: z.literal("ProducerDelegationRevoked"),
|
|
45
|
+
data: protobufDecoder(ProducerDelegationRevokedV2),
|
|
46
|
+
stream_id: z.string(),
|
|
47
|
+
version: z.number(),
|
|
48
|
+
timestamp: z.coerce.date(),
|
|
49
|
+
}),
|
|
50
|
+
z.object({
|
|
51
|
+
event_version: z.literal(2),
|
|
52
|
+
type: z.literal("ConsumerDelegationSubmitted"),
|
|
53
|
+
data: protobufDecoder(ConsumerDelegationSubmittedV2),
|
|
54
|
+
stream_id: z.string(),
|
|
55
|
+
version: z.number(),
|
|
56
|
+
timestamp: z.coerce.date(),
|
|
57
|
+
}),
|
|
58
|
+
z.object({
|
|
59
|
+
event_version: z.literal(2),
|
|
60
|
+
type: z.literal("ConsumerDelegationApproved"),
|
|
61
|
+
data: protobufDecoder(ConsumerDelegationApprovedV2),
|
|
62
|
+
stream_id: z.string(),
|
|
63
|
+
version: z.number(),
|
|
64
|
+
timestamp: z.coerce.date(),
|
|
65
|
+
}),
|
|
66
|
+
z.object({
|
|
67
|
+
event_version: z.literal(2),
|
|
68
|
+
type: z.literal("ConsumerDelegationRejected"),
|
|
69
|
+
data: protobufDecoder(ConsumerDelegationRejectedV2),
|
|
70
|
+
stream_id: z.string(),
|
|
71
|
+
version: z.number(),
|
|
72
|
+
timestamp: z.coerce.date(),
|
|
73
|
+
}),
|
|
74
|
+
z.object({
|
|
75
|
+
event_version: z.literal(2),
|
|
76
|
+
type: z.literal("ConsumerDelegationRevoked"),
|
|
77
|
+
data: protobufDecoder(ConsumerDelegationRevokedV2),
|
|
78
|
+
stream_id: z.string(),
|
|
79
|
+
version: z.number(),
|
|
80
|
+
timestamp: z.coerce.date(),
|
|
81
|
+
}),
|
|
82
|
+
]);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DelegationEventV2 } from "./eventsV2.js";
|
|
3
|
+
export declare function encodeOutboundDelegationEvent(event: DelegationEvent): string;
|
|
4
|
+
export declare function decodeOutboundDelegationEvent(encodedEvent: string): DelegationEvent;
|
|
5
|
+
export declare const DelegationEvent: z.ZodEffects<z.ZodDiscriminatedUnion<"event_version", [z.ZodObject<{
|
|
6
|
+
event_version: z.ZodLiteral<1>;
|
|
7
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
8
|
+
event_version: z.ZodLiteral<1>;
|
|
9
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
10
|
+
event_version: z.ZodLiteral<1>;
|
|
11
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
12
|
+
event_version: z.ZodLiteral<2>;
|
|
13
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
14
|
+
event_version: z.ZodLiteral<2>;
|
|
15
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
16
|
+
event_version: z.ZodLiteral<2>;
|
|
17
|
+
}, z.ZodTypeAny, "passthrough">>]>, {
|
|
18
|
+
event_version: 2;
|
|
19
|
+
type: "ProducerDelegationSubmitted";
|
|
20
|
+
version: number;
|
|
21
|
+
data: import("../gen/v2/delegation/events.js").ProducerDelegationSubmittedV2;
|
|
22
|
+
stream_id: string;
|
|
23
|
+
timestamp: Date;
|
|
24
|
+
} | {
|
|
25
|
+
event_version: 2;
|
|
26
|
+
type: "ProducerDelegationApproved";
|
|
27
|
+
version: number;
|
|
28
|
+
data: import("../gen/v2/delegation/events.js").ProducerDelegationApprovedV2;
|
|
29
|
+
stream_id: string;
|
|
30
|
+
timestamp: Date;
|
|
31
|
+
} | {
|
|
32
|
+
event_version: 2;
|
|
33
|
+
type: "ProducerDelegationRejected";
|
|
34
|
+
version: number;
|
|
35
|
+
data: import("../gen/v2/delegation/events.js").ProducerDelegationRejectedV2;
|
|
36
|
+
stream_id: string;
|
|
37
|
+
timestamp: Date;
|
|
38
|
+
} | {
|
|
39
|
+
event_version: 2;
|
|
40
|
+
type: "ProducerDelegationRevoked";
|
|
41
|
+
version: number;
|
|
42
|
+
data: import("../gen/v2/delegation/events.js").ProducerDelegationRevokedV2;
|
|
43
|
+
stream_id: string;
|
|
44
|
+
timestamp: Date;
|
|
45
|
+
} | {
|
|
46
|
+
event_version: 2;
|
|
47
|
+
type: "ConsumerDelegationSubmitted";
|
|
48
|
+
version: number;
|
|
49
|
+
data: import("../gen/v2/delegation/events.js").ConsumerDelegationSubmittedV2;
|
|
50
|
+
stream_id: string;
|
|
51
|
+
timestamp: Date;
|
|
52
|
+
} | {
|
|
53
|
+
event_version: 2;
|
|
54
|
+
type: "ConsumerDelegationApproved";
|
|
55
|
+
version: number;
|
|
56
|
+
data: import("../gen/v2/delegation/events.js").ConsumerDelegationApprovedV2;
|
|
57
|
+
stream_id: string;
|
|
58
|
+
timestamp: Date;
|
|
59
|
+
} | {
|
|
60
|
+
event_version: 2;
|
|
61
|
+
type: "ConsumerDelegationRejected";
|
|
62
|
+
version: number;
|
|
63
|
+
data: import("../gen/v2/delegation/events.js").ConsumerDelegationRejectedV2;
|
|
64
|
+
stream_id: string;
|
|
65
|
+
timestamp: Date;
|
|
66
|
+
} | {
|
|
67
|
+
event_version: 2;
|
|
68
|
+
type: "ConsumerDelegationRevoked";
|
|
69
|
+
version: number;
|
|
70
|
+
data: import("../gen/v2/delegation/events.js").ConsumerDelegationRevokedV2;
|
|
71
|
+
stream_id: string;
|
|
72
|
+
timestamp: Date;
|
|
73
|
+
}, z.objectInputType<{
|
|
74
|
+
event_version: z.ZodLiteral<1>;
|
|
75
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
76
|
+
event_version: z.ZodLiteral<2>;
|
|
77
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
78
|
+
export type DelegationEventType = DelegationEvent["type"];
|
|
79
|
+
export type DelegationEvent = z.infer<typeof DelegationEvent>;
|
|
80
|
+
export { DelegationEventV2 };
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/delegation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,iBAAiB,EAElB,MAAM,eAAe,CAAC;AAQvB,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAS5E;AAED,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,MAAM,GACnB,eAAe,CAEjB;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAa1B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAC1D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { match } from "ts-pattern";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { VersionedEvent } from "../utils.js";
|
|
4
|
+
import { DelegationEventV2, delegationEventToBinaryDataV2, } from "./eventsV2.js";
|
|
5
|
+
function delegationEventToBinaryData(event) {
|
|
6
|
+
return match(event)
|
|
7
|
+
.with({ event_version: 2 }, delegationEventToBinaryDataV2)
|
|
8
|
+
.exhaustive();
|
|
9
|
+
}
|
|
10
|
+
export function encodeOutboundDelegationEvent(event) {
|
|
11
|
+
return JSON.stringify({
|
|
12
|
+
event_version: event.event_version,
|
|
13
|
+
type: event.type,
|
|
14
|
+
data: Buffer.from(delegationEventToBinaryData(event)).toString("hex"),
|
|
15
|
+
stream_id: event.stream_id,
|
|
16
|
+
version: event.version,
|
|
17
|
+
timestamp: event.timestamp,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function decodeOutboundDelegationEvent(encodedEvent) {
|
|
21
|
+
return DelegationEvent.parse(JSON.parse(encodedEvent));
|
|
22
|
+
}
|
|
23
|
+
export const DelegationEvent = VersionedEvent.transform((obj, ctx) => {
|
|
24
|
+
const res = match(obj)
|
|
25
|
+
.with({ event_version: 1 }, () => {
|
|
26
|
+
throw new Error("Unsupported event version");
|
|
27
|
+
})
|
|
28
|
+
.with({ event_version: 2 }, () => DelegationEventV2.safeParse(obj))
|
|
29
|
+
.exhaustive();
|
|
30
|
+
if (!res.success) {
|
|
31
|
+
res.error.issues.forEach(ctx.addIssue);
|
|
32
|
+
return z.NEVER;
|
|
33
|
+
}
|
|
34
|
+
return res.data;
|
|
35
|
+
});
|
|
36
|
+
export { DelegationEventV2 };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
2
|
+
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
3
|
+
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
4
|
+
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
5
|
+
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
6
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
7
|
+
/**
|
|
8
|
+
* @generated from protobuf message delegation.v2.DelegationV2
|
|
9
|
+
*/
|
|
10
|
+
export interface DelegationV2 {
|
|
11
|
+
/**
|
|
12
|
+
* @generated from protobuf field: string id = 1;
|
|
13
|
+
*/
|
|
14
|
+
id: string;
|
|
15
|
+
/**
|
|
16
|
+
* @generated from protobuf field: string delegatorId = 2;
|
|
17
|
+
*/
|
|
18
|
+
delegatorId: string;
|
|
19
|
+
/**
|
|
20
|
+
* @generated from protobuf field: string delegateId = 3;
|
|
21
|
+
*/
|
|
22
|
+
delegateId: string;
|
|
23
|
+
/**
|
|
24
|
+
* @generated from protobuf field: string eserviceId = 4;
|
|
25
|
+
*/
|
|
26
|
+
eserviceId: string;
|
|
27
|
+
/**
|
|
28
|
+
* @generated from protobuf field: int64 createdAt = 5;
|
|
29
|
+
*/
|
|
30
|
+
createdAt: bigint;
|
|
31
|
+
/**
|
|
32
|
+
* @generated from protobuf field: int64 submittedAt = 6;
|
|
33
|
+
*/
|
|
34
|
+
submittedAt: bigint;
|
|
35
|
+
/**
|
|
36
|
+
* @generated from protobuf field: optional int64 approvedAt = 7;
|
|
37
|
+
*/
|
|
38
|
+
approvedAt?: bigint;
|
|
39
|
+
/**
|
|
40
|
+
* @generated from protobuf field: optional int64 rejectedAt = 8;
|
|
41
|
+
*/
|
|
42
|
+
rejectedAt?: bigint;
|
|
43
|
+
/**
|
|
44
|
+
* @generated from protobuf field: optional string rejectionReason = 9;
|
|
45
|
+
*/
|
|
46
|
+
rejectionReason?: string;
|
|
47
|
+
/**
|
|
48
|
+
* @generated from protobuf field: optional int64 revokedAt = 10;
|
|
49
|
+
*/
|
|
50
|
+
revokedAt?: bigint;
|
|
51
|
+
/**
|
|
52
|
+
* @generated from protobuf field: delegation.v2.DelegationStateV2 state = 11;
|
|
53
|
+
*/
|
|
54
|
+
state: DelegationStateV2;
|
|
55
|
+
/**
|
|
56
|
+
* @generated from protobuf field: delegation.v2.DelegationKindV2 kind = 12;
|
|
57
|
+
*/
|
|
58
|
+
kind: DelegationKindV2;
|
|
59
|
+
/**
|
|
60
|
+
* @generated from protobuf field: delegation.v2.DelegationStampsV2 stamps = 13;
|
|
61
|
+
*/
|
|
62
|
+
stamps?: DelegationStampsV2;
|
|
63
|
+
/**
|
|
64
|
+
* @generated from protobuf field: optional delegation.v2.DelegationContractDocumentV2 activationContract = 14;
|
|
65
|
+
*/
|
|
66
|
+
activationContract?: DelegationContractDocumentV2;
|
|
67
|
+
/**
|
|
68
|
+
* @generated from protobuf field: optional delegation.v2.DelegationContractDocumentV2 revocationContract = 15;
|
|
69
|
+
*/
|
|
70
|
+
revocationContract?: DelegationContractDocumentV2;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @generated from protobuf message delegation.v2.DelegationContractDocumentV2
|
|
74
|
+
*/
|
|
75
|
+
export interface DelegationContractDocumentV2 {
|
|
76
|
+
/**
|
|
77
|
+
* @generated from protobuf field: string id = 1;
|
|
78
|
+
*/
|
|
79
|
+
id: string;
|
|
80
|
+
/**
|
|
81
|
+
* @generated from protobuf field: string name = 2;
|
|
82
|
+
*/
|
|
83
|
+
name: string;
|
|
84
|
+
/**
|
|
85
|
+
* @generated from protobuf field: string prettyName = 3;
|
|
86
|
+
*/
|
|
87
|
+
prettyName: string;
|
|
88
|
+
/**
|
|
89
|
+
* @generated from protobuf field: string contentType = 4;
|
|
90
|
+
*/
|
|
91
|
+
contentType: string;
|
|
92
|
+
/**
|
|
93
|
+
* @generated from protobuf field: int64 createdAt = 5;
|
|
94
|
+
*/
|
|
95
|
+
createdAt: bigint;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @generated from protobuf message delegation.v2.DelegationStampV2
|
|
99
|
+
*/
|
|
100
|
+
export interface DelegationStampV2 {
|
|
101
|
+
/**
|
|
102
|
+
* @generated from protobuf field: int64 when = 1;
|
|
103
|
+
*/
|
|
104
|
+
when: bigint;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @generated from protobuf message delegation.v2.DelegationStampsV2
|
|
108
|
+
*/
|
|
109
|
+
export interface DelegationStampsV2 {
|
|
110
|
+
/**
|
|
111
|
+
* @generated from protobuf field: delegation.v2.DelegationStampV2 submission = 1;
|
|
112
|
+
*/
|
|
113
|
+
submission?: DelegationStampV2;
|
|
114
|
+
/**
|
|
115
|
+
* @generated from protobuf field: optional delegation.v2.DelegationStampV2 activation = 2;
|
|
116
|
+
*/
|
|
117
|
+
activation?: DelegationStampV2;
|
|
118
|
+
/**
|
|
119
|
+
* @generated from protobuf field: optional delegation.v2.DelegationStampV2 rejection = 3;
|
|
120
|
+
*/
|
|
121
|
+
rejection?: DelegationStampV2;
|
|
122
|
+
/**
|
|
123
|
+
* @generated from protobuf field: optional delegation.v2.DelegationStampV2 revocation = 4;
|
|
124
|
+
*/
|
|
125
|
+
revocation?: DelegationStampV2;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @generated from protobuf enum delegation.v2.DelegationStateV2
|
|
129
|
+
*/
|
|
130
|
+
export declare enum DelegationStateV2 {
|
|
131
|
+
/**
|
|
132
|
+
* @generated from protobuf enum value: WAITING_FOR_APPROVAL = 0;
|
|
133
|
+
*/
|
|
134
|
+
WAITING_FOR_APPROVAL = 0,
|
|
135
|
+
/**
|
|
136
|
+
* @generated from protobuf enum value: ACTIVE = 1;
|
|
137
|
+
*/
|
|
138
|
+
ACTIVE = 1,
|
|
139
|
+
/**
|
|
140
|
+
* @generated from protobuf enum value: REJECTED = 2;
|
|
141
|
+
*/
|
|
142
|
+
REJECTED = 2,
|
|
143
|
+
/**
|
|
144
|
+
* @generated from protobuf enum value: REVOKED = 3;
|
|
145
|
+
*/
|
|
146
|
+
REVOKED = 3
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @generated from protobuf enum delegation.v2.DelegationKindV2
|
|
150
|
+
*/
|
|
151
|
+
export declare enum DelegationKindV2 {
|
|
152
|
+
/**
|
|
153
|
+
* @generated from protobuf enum value: DELEGATED_PRODUCER = 0;
|
|
154
|
+
*/
|
|
155
|
+
DELEGATED_PRODUCER = 0,
|
|
156
|
+
/**
|
|
157
|
+
* @generated from protobuf enum value: DELEGATED_CONSUMER = 1;
|
|
158
|
+
*/
|
|
159
|
+
DELEGATED_CONSUMER = 1
|
|
160
|
+
}
|
|
161
|
+
declare class DelegationV2$Type extends MessageType<DelegationV2> {
|
|
162
|
+
constructor();
|
|
163
|
+
create(value?: PartialMessage<DelegationV2>): DelegationV2;
|
|
164
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: DelegationV2): DelegationV2;
|
|
165
|
+
internalBinaryWrite(message: DelegationV2, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @generated MessageType for protobuf message delegation.v2.DelegationV2
|
|
169
|
+
*/
|
|
170
|
+
export declare const DelegationV2: DelegationV2$Type;
|
|
171
|
+
declare class DelegationContractDocumentV2$Type extends MessageType<DelegationContractDocumentV2> {
|
|
172
|
+
constructor();
|
|
173
|
+
create(value?: PartialMessage<DelegationContractDocumentV2>): DelegationContractDocumentV2;
|
|
174
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: DelegationContractDocumentV2): DelegationContractDocumentV2;
|
|
175
|
+
internalBinaryWrite(message: DelegationContractDocumentV2, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* @generated MessageType for protobuf message delegation.v2.DelegationContractDocumentV2
|
|
179
|
+
*/
|
|
180
|
+
export declare const DelegationContractDocumentV2: DelegationContractDocumentV2$Type;
|
|
181
|
+
declare class DelegationStampV2$Type extends MessageType<DelegationStampV2> {
|
|
182
|
+
constructor();
|
|
183
|
+
create(value?: PartialMessage<DelegationStampV2>): DelegationStampV2;
|
|
184
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: DelegationStampV2): DelegationStampV2;
|
|
185
|
+
internalBinaryWrite(message: DelegationStampV2, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* @generated MessageType for protobuf message delegation.v2.DelegationStampV2
|
|
189
|
+
*/
|
|
190
|
+
export declare const DelegationStampV2: DelegationStampV2$Type;
|
|
191
|
+
declare class DelegationStampsV2$Type extends MessageType<DelegationStampsV2> {
|
|
192
|
+
constructor();
|
|
193
|
+
create(value?: PartialMessage<DelegationStampsV2>): DelegationStampsV2;
|
|
194
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: DelegationStampsV2): DelegationStampsV2;
|
|
195
|
+
internalBinaryWrite(message: DelegationStampsV2, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* @generated MessageType for protobuf message delegation.v2.DelegationStampsV2
|
|
199
|
+
*/
|
|
200
|
+
export declare const DelegationStampsV2: DelegationStampsV2$Type;
|
|
201
|
+
export {};
|
|
202
|
+
//# sourceMappingURL=delegation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation.d.ts","sourceRoot":"","sources":["../../../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