File tree Expand file tree Collapse file tree 5 files changed +49
-41
lines changed Expand file tree Collapse file tree 5 files changed +49
-41
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @thirdweb-dev/service-utils " : patch
3
+ ---
4
+
5
+ [ service-utils] fix: Add missing CompressionCodecs import
Original file line number Diff line number Diff line change 26
26
},
27
27
"typesVersions" : {
28
28
"*" : {
29
- "node" : [
30
- " ./dist/types/node/index.d.ts"
31
- ],
32
- "cf-worker" : [
33
- " ./dist/types/cf-worker/index.d.ts"
34
- ]
29
+ "node" : [" ./dist/types/node/index.d.ts" ],
30
+ "cf-worker" : [" ./dist/types/cf-worker/index.d.ts" ]
35
31
}
36
32
},
37
33
"repository" : " https://github.com/thirdweb-dev/js/tree/main/packages/pay" ,
40
36
"url" : " https://github.com/thirdweb-dev/js/issues"
41
37
},
42
38
"author" : " thirdweb eng <eng@thirdweb.com>" ,
43
- "files" : [
44
- " dist/"
45
- ],
39
+ "files" : [" dist/" ],
46
40
"sideEffects" : false ,
47
41
"dependencies" : {
48
42
"aws4fetch" : " 1.0.20" ,
49
43
"kafkajs" : " 2.2.4" ,
50
- "lz4js" : " ^ 0.2.0" ,
44
+ "lz4js" : " 0.2.0" ,
51
45
"zod" : " 3.24.1"
52
46
},
53
47
"devDependencies" : {
54
48
"@cloudflare/workers-types" : " 4.20250129.0" ,
55
- "@types/lz4js" : " ^ 0.2.1" ,
49
+ "@types/lz4js" : " 0.2.1" ,
56
50
"@types/node" : " 22.13.0" ,
57
51
"typescript" : " 5.7.3" ,
58
52
"vitest" : " 3.0.4"
Original file line number Diff line number Diff line change 1
- import type { ServiceName } from "../node/index.js" ;
1
+ import type { ServiceName } from "./services.js" ;
2
+
3
+ export type UsageV2Source = ServiceName | "sdk" ;
2
4
3
5
export interface UsageV2Event {
4
6
/**
@@ -53,6 +55,6 @@ export interface UsageV2Event {
53
55
[ key : string ] : boolean | number | string | Date | null | undefined ;
54
56
}
55
57
56
- export function getTopicName ( productName : ServiceName ) {
57
- return `usage_v2.raw_${ productName } ` ;
58
+ export function getTopicName ( source : UsageV2Source ) {
59
+ return `usage_v2.raw_${ source } ` ;
58
60
}
Original file line number Diff line number Diff line change 1
1
import { randomUUID } from "node:crypto" ;
2
2
import { checkServerIdentity } from "node:tls" ;
3
3
import {
4
- CompressionCodecs ,
5
4
CompressionTypes ,
6
5
Kafka ,
7
6
type Producer ,
8
7
type ProducerConfig ,
9
8
} from "kafkajs" ;
10
9
import { compress , decompress } from "lz4js" ;
11
- import type { ServiceName } from "../core/services.js" ;
12
- import { type UsageV2Event , getTopicName } from "../core/usageV2.js" ;
10
+ import {
11
+ type UsageV2Event ,
12
+ type UsageV2Source ,
13
+ getTopicName ,
14
+ } from "../core/usageV2.js" ;
15
+
16
+ // CompressionCodecs is not exported properly in kafkajs. Source: https://github.com/tulios/kafkajs/issues/1391
17
+ import KafkaJS from "kafkajs" ;
18
+ const { CompressionCodecs } = KafkaJS ;
13
19
14
20
/**
15
21
* Creates a UsageV2Producer which opens a persistent TCP connection.
@@ -40,9 +46,9 @@ export class UsageV2Producer {
40
46
*/
41
47
environment : "development" | "production" ;
42
48
/**
43
- * The product "source" where usage is coming from.
49
+ * The product where usage is coming from.
44
50
*/
45
- productName : ServiceName ;
51
+ source : UsageV2Source ;
46
52
/**
47
53
* Whether to compress the events.
48
54
*/
@@ -54,7 +60,7 @@ export class UsageV2Producer {
54
60
const {
55
61
producerName,
56
62
environment,
57
- productName ,
63
+ source ,
58
64
shouldCompress = true ,
59
65
username,
60
66
password,
@@ -78,7 +84,7 @@ export class UsageV2Producer {
78
84
} ,
79
85
} ) ;
80
86
81
- this . topic = getTopicName ( productName ) ;
87
+ this . topic = getTopicName ( source ) ;
82
88
this . compression = shouldCompress
83
89
? CompressionTypes . LZ4
84
90
: CompressionTypes . None ;
You can’t perform that action at this time.
0 commit comments