Skip to content

Commit 0da075d

Browse files
committed
fix stream response type and update bindings
1 parent 4e90687 commit 0da075d

File tree

20 files changed

+900
-266
lines changed

20 files changed

+900
-266
lines changed

crates/transcribe-moonshine/src/service/streaming.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ where
276276
.collect();
277277

278278
let response = StreamResponse::TranscriptResponse {
279-
type_field: "Results".to_string(),
280279
start: start_f64,
281280
duration: duration_f64,
282281
is_final: true,

crates/transcribe-whisper-local/src/service/streaming.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ async fn process_transcription_stream(
270270
.collect();
271271

272272
let response = StreamResponse::TranscriptResponse {
273-
type_field: "Results".to_string(),
274273
start: adjusted_start_f64,
275274
duration: duration_f64,
276275
is_final: true,

owhisper/owhisper-interface/src/stream.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ impl Default for Metadata {
6262
}
6363

6464
common_derives! {
65-
#[serde(untagged)]
65+
#[serde(tag = "type")]
6666
#[non_exhaustive]
6767
pub enum StreamResponse {
68+
#[serde(rename = "Results")]
6869
TranscriptResponse {
69-
#[serde(rename = "type")]
70-
type_field: String,
7170
start: f64,
7271
duration: f64,
7372
is_final: bool,
@@ -77,21 +76,20 @@ common_derives! {
7776
metadata: Metadata,
7877
channel_index: Vec<i32>,
7978
},
79+
#[serde(rename = "Metadata")]
8080
TerminalResponse {
8181
request_id: String,
8282
created: String,
8383
duration: f64,
8484
channels: u32,
8585
},
86+
#[serde(rename = "SpeechStarted")]
8687
SpeechStartedResponse {
87-
#[serde(rename = "type")]
88-
type_field: String,
8988
channel: Vec<u8>,
9089
timestamp: f64,
9190
},
91+
#[serde(rename = "UtteranceEnd")]
9292
UtteranceEndResponse {
93-
#[serde(rename = "type")]
94-
type_field: String,
9593
channel: Vec<u8>,
9694
last_word_end: f64,
9795
},

plugins/analytics/js/bindings.gen.ts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,37 @@
77

88

99
export const commands = {
10-
async event(payload: AnalyticsPayload) : Promise<null> {
11-
return await TAURI_INVOKE("plugin:analytics|event", { payload });
10+
async event(payload: AnalyticsPayload) : Promise<Result<null, string>> {
11+
try {
12+
return { status: "ok", data: await TAURI_INVOKE("plugin:analytics|event", { payload }) };
13+
} catch (e) {
14+
if(e instanceof Error) throw e;
15+
else return { status: "error", error: e as any };
16+
}
1217
},
13-
async setProperties(payload: PropertiesPayload) : Promise<null> {
14-
return await TAURI_INVOKE("plugin:analytics|set_properties", { payload });
18+
async setProperties(payload: PropertiesPayload) : Promise<Result<null, string>> {
19+
try {
20+
return { status: "ok", data: await TAURI_INVOKE("plugin:analytics|set_properties", { payload }) };
21+
} catch (e) {
22+
if(e instanceof Error) throw e;
23+
else return { status: "error", error: e as any };
24+
}
1525
},
16-
async setDisabled(disabled: boolean) : Promise<null> {
17-
return await TAURI_INVOKE("plugin:analytics|set_disabled", { disabled });
26+
async setDisabled(disabled: boolean) : Promise<Result<null, string>> {
27+
try {
28+
return { status: "ok", data: await TAURI_INVOKE("plugin:analytics|set_disabled", { disabled }) };
29+
} catch (e) {
30+
if(e instanceof Error) throw e;
31+
else return { status: "error", error: e as any };
32+
}
1833
},
19-
async isDisabled() : Promise<boolean> {
20-
return await TAURI_INVOKE("plugin:analytics|is_disabled");
34+
async isDisabled() : Promise<Result<boolean, string>> {
35+
try {
36+
return { status: "ok", data: await TAURI_INVOKE("plugin:analytics|is_disabled") };
37+
} catch (e) {
38+
if(e instanceof Error) throw e;
39+
else return { status: "error", error: e as any };
40+
}
2141
}
2242
}
2343

plugins/apple-calendar/js/bindings.gen.ts

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,29 @@
77

88

99
export const commands = {
10-
async openCalendar() : Promise<null> {
11-
return await TAURI_INVOKE("plugin:apple-calendar|open_calendar");
10+
async openCalendar() : Promise<Result<null, string>> {
11+
try {
12+
return { status: "ok", data: await TAURI_INVOKE("plugin:apple-calendar|open_calendar") };
13+
} catch (e) {
14+
if(e instanceof Error) throw e;
15+
else return { status: "error", error: e as any };
16+
}
1217
},
13-
async openCalendarAccessSettings() : Promise<null> {
14-
return await TAURI_INVOKE("plugin:apple-calendar|open_calendar_access_settings");
18+
async openCalendarAccessSettings() : Promise<Result<null, string>> {
19+
try {
20+
return { status: "ok", data: await TAURI_INVOKE("plugin:apple-calendar|open_calendar_access_settings") };
21+
} catch (e) {
22+
if(e instanceof Error) throw e;
23+
else return { status: "error", error: e as any };
24+
}
1525
},
16-
async openContactsAccessSettings() : Promise<null> {
17-
return await TAURI_INVOKE("plugin:apple-calendar|open_contacts_access_settings");
26+
async openContactsAccessSettings() : Promise<Result<null, string>> {
27+
try {
28+
return { status: "ok", data: await TAURI_INVOKE("plugin:apple-calendar|open_contacts_access_settings") };
29+
} catch (e) {
30+
if(e instanceof Error) throw e;
31+
else return { status: "error", error: e as any };
32+
}
1833
},
1934
async calendarAccessStatus() : Promise<boolean> {
2035
return await TAURI_INVOKE("plugin:apple-calendar|calendar_access_status");
@@ -28,11 +43,21 @@ async requestCalendarAccess() : Promise<void> {
2843
async requestContactsAccess() : Promise<void> {
2944
await TAURI_INVOKE("plugin:apple-calendar|request_contacts_access");
3045
},
31-
async syncCalendars() : Promise<null> {
32-
return await TAURI_INVOKE("plugin:apple-calendar|sync_calendars");
46+
async syncCalendars() : Promise<Result<null, string>> {
47+
try {
48+
return { status: "ok", data: await TAURI_INVOKE("plugin:apple-calendar|sync_calendars") };
49+
} catch (e) {
50+
if(e instanceof Error) throw e;
51+
else return { status: "error", error: e as any };
52+
}
3353
},
34-
async syncEvents() : Promise<null> {
35-
return await TAURI_INVOKE("plugin:apple-calendar|sync_events");
54+
async syncEvents() : Promise<Result<null, string>> {
55+
try {
56+
return { status: "ok", data: await TAURI_INVOKE("plugin:apple-calendar|sync_events") };
57+
} catch (e) {
58+
if(e instanceof Error) throw e;
59+
else return { status: "error", error: e as any };
60+
}
3661
}
3762
}
3863

plugins/auth/js/bindings.gen.ts

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,69 @@
77

88

99
export const commands = {
10-
async startOauthServer() : Promise<number> {
11-
return await TAURI_INVOKE("plugin:auth|start_oauth_server");
10+
async startOauthServer() : Promise<Result<number, string>> {
11+
try {
12+
return { status: "ok", data: await TAURI_INVOKE("plugin:auth|start_oauth_server") };
13+
} catch (e) {
14+
if(e instanceof Error) throw e;
15+
else return { status: "error", error: e as any };
16+
}
1217
},
13-
async stopOauthServer(port: number) : Promise<null> {
14-
return await TAURI_INVOKE("plugin:auth|stop_oauth_server", { port });
18+
async stopOauthServer(port: number) : Promise<Result<null, string>> {
19+
try {
20+
return { status: "ok", data: await TAURI_INVOKE("plugin:auth|stop_oauth_server", { port }) };
21+
} catch (e) {
22+
if(e instanceof Error) throw e;
23+
else return { status: "error", error: e as any };
24+
}
1525
},
16-
async initVault(userId: string) : Promise<null> {
17-
return await TAURI_INVOKE("plugin:auth|init_vault", { userId });
26+
async initVault(userId: string) : Promise<Result<null, string>> {
27+
try {
28+
return { status: "ok", data: await TAURI_INVOKE("plugin:auth|init_vault", { userId }) };
29+
} catch (e) {
30+
if(e instanceof Error) throw e;
31+
else return { status: "error", error: e as any };
32+
}
1833
},
19-
async resetVault() : Promise<null> {
20-
return await TAURI_INVOKE("plugin:auth|reset_vault");
34+
async resetVault() : Promise<Result<null, string>> {
35+
try {
36+
return { status: "ok", data: await TAURI_INVOKE("plugin:auth|reset_vault") };
37+
} catch (e) {
38+
if(e instanceof Error) throw e;
39+
else return { status: "error", error: e as any };
40+
}
2141
},
22-
async getFromVault(key: VaultKey) : Promise<string | null> {
23-
return await TAURI_INVOKE("plugin:auth|get_from_vault", { key });
42+
async getFromVault(key: VaultKey) : Promise<Result<string | null, string>> {
43+
try {
44+
return { status: "ok", data: await TAURI_INVOKE("plugin:auth|get_from_vault", { key }) };
45+
} catch (e) {
46+
if(e instanceof Error) throw e;
47+
else return { status: "error", error: e as any };
48+
}
2449
},
25-
async getFromStore(key: StoreKey) : Promise<string | null> {
26-
return await TAURI_INVOKE("plugin:auth|get_from_store", { key });
50+
async getFromStore(key: StoreKey) : Promise<Result<string | null, string>> {
51+
try {
52+
return { status: "ok", data: await TAURI_INVOKE("plugin:auth|get_from_store", { key }) };
53+
} catch (e) {
54+
if(e instanceof Error) throw e;
55+
else return { status: "error", error: e as any };
56+
}
2757
},
28-
async setInVault(key: VaultKey, value: string) : Promise<null> {
29-
return await TAURI_INVOKE("plugin:auth|set_in_vault", { key, value });
58+
async setInVault(key: VaultKey, value: string) : Promise<Result<null, string>> {
59+
try {
60+
return { status: "ok", data: await TAURI_INVOKE("plugin:auth|set_in_vault", { key, value }) };
61+
} catch (e) {
62+
if(e instanceof Error) throw e;
63+
else return { status: "error", error: e as any };
64+
}
3065
},
31-
async setInStore(key: StoreKey, value: string) : Promise<null> {
32-
return await TAURI_INVOKE("plugin:auth|set_in_store", { key, value });
66+
async setInStore(key: StoreKey, value: string) : Promise<Result<null, string>> {
67+
try {
68+
return { status: "ok", data: await TAURI_INVOKE("plugin:auth|set_in_store", { key, value }) };
69+
} catch (e) {
70+
if(e instanceof Error) throw e;
71+
else return { status: "error", error: e as any };
72+
}
3373
}
3474
}
3575

0 commit comments

Comments
 (0)