Skip to content

Commit a4a142d

Browse files
authored
chore(eventstream-marshaller): change HeaderValue to type (#3737)
1 parent f810679 commit a4a142d

File tree

1 file changed

+11
-44
lines changed

1 file changed

+11
-44
lines changed

packages/eventstream-marshaller/src/Message.ts

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,17 @@ export interface Message {
1212

1313
export type MessageHeaders = Record<string, MessageHeaderValue>;
1414

15-
export interface BooleanHeaderValue {
16-
type: "boolean";
17-
value: boolean;
18-
}
19-
20-
export interface ByteHeaderValue {
21-
type: "byte";
22-
value: number;
23-
}
24-
25-
export interface ShortHeaderValue {
26-
type: "short";
27-
value: number;
28-
}
29-
30-
export interface IntegerHeaderValue {
31-
type: "integer";
32-
value: number;
33-
}
34-
35-
export interface LongHeaderValue {
36-
type: "long";
37-
value: Int64;
38-
}
39-
40-
export interface BinaryHeaderValue {
41-
type: "binary";
42-
value: Uint8Array;
43-
}
44-
45-
export interface StringHeaderValue {
46-
type: "string";
47-
value: string;
48-
}
49-
50-
export interface TimestampHeaderValue {
51-
type: "timestamp";
52-
value: Date;
53-
}
54-
55-
export interface UuidHeaderValue {
56-
type: "uuid";
57-
value: string;
58-
}
15+
type HeaderValue<K extends string, V> = { type: K; value: V };
16+
17+
export type BooleanHeaderValue = HeaderValue<"boolean", boolean>;
18+
export type ByteHeaderValue = HeaderValue<"byte", number>;
19+
export type ShortHeaderValue = HeaderValue<"short", number>;
20+
export type IntegerHeaderValue = HeaderValue<"integer", number>;
21+
export type LongHeaderValue = HeaderValue<"long", Int64>;
22+
export type BinaryHeaderValue = HeaderValue<"binary", Uint8Array>;
23+
export type StringHeaderValue = HeaderValue<"string", string>;
24+
export type TimestampHeaderValue = HeaderValue<"timestamp", Date>;
25+
export type UuidHeaderValue = HeaderValue<"uuid", string>;
5926

6027
export type MessageHeaderValue =
6128
| BooleanHeaderValue

0 commit comments

Comments
 (0)