Skip to content

Commit 859acdb

Browse files
committed
feat: exported OpenAI Realtime API types are now exported from the package so that they can easily be used in a consuming project
1 parent fb28856 commit 859acdb

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

packages/browser/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"types": "./dist/WebRTC/index.d.ts",
2424
"import": "./dist/WebRTC/index.js"
2525
},
26+
"./openai": {
27+
"types": "./dist/openai/index.d.ts"
28+
},
2629
"./*": {
2730
"types": "./dist/*.d.ts",
2831
"import": "./dist/*.js"
@@ -35,9 +38,11 @@
3538
},
3639
"devDependencies": {
3740
"@tsconfig/node20": "^20.1.4",
41+
"@types/lodash-es": "^4.17.12",
3842
"type-fest": "^4.33.0"
3943
},
4044
"dependencies": {
45+
"lodash-es": "^4.17.21",
4146
"typescript-event-target": "^1.1.1"
4247
}
4348
}

packages/browser/scripts/gen-openai-from-openapi.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ parent_dir=$(cd "${this_dir}/.."; pwd)
99
# https://github.com/openai/openai-openapi
1010
# https://raw.githubusercontent.com/openai/openai-openapi/25be47865ea2df1179a46be045c2f6b65f38e982/openapi.yaml
1111

12-
npx openapi-typescript "https://raw.githubusercontent.com/openai/openai-openapi/25be47865ea2df1179a46be045c2f6b65f38e982/openapi.yaml" -o "${parent_dir}/src/types/openai/openapi.d.ts"
12+
npx openapi-typescript "https://raw.githubusercontent.com/openai/openai-openapi/25be47865ea2df1179a46be045c2f6b65f38e982/openapi.yaml" -o "${parent_dir}/src/openai/openapi.ts"

packages/browser/src/WebRTC/events.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
RealtimeServerEvent,
44
RealtimeConversationItem,
55
RealtimeSession,
6-
} from "../types/openai"
6+
} from "../openai"
77

88
// Add this index signature allows the key to be string
99
// & {
@@ -19,15 +19,15 @@ type RealtimeClientEventObjects =
1919
RealtimeClientEventMap[RealtimeClientEventNames]
2020

2121
class BaseEvent<
22-
TType extends keyof RealtimeClientEventMap | RealtimeServerEvent["type"]
22+
TType extends keyof RealtimeClientEventMap | RealtimeServerEvent["type"],
2323
> extends Event {
2424
constructor(public readonly type: TType) {
2525
super(type)
2626
}
2727
}
2828

2929
export class RealtimeServerEventEvent<
30-
T extends RealtimeServerEvent = RealtimeServerEvent
30+
T extends RealtimeServerEvent = RealtimeServerEvent,
3131
> extends BaseEvent<"serverEvent"> {
3232
constructor(public readonly event: T) {
3333
super("serverEvent")
@@ -60,7 +60,7 @@ export class SessionCreatedEvent extends BaseEvent<"sessionCreated"> {
6060
}
6161

6262
export interface EventTargetListener<
63-
TEvent extends RealtimeClientEventObjects
63+
TEvent extends RealtimeClientEventObjects,
6464
> {
6565
(evt: TEvent): void
6666
}

0 commit comments

Comments
 (0)