Skip to content

Commit dde5b15

Browse files
authored
Share batch operation in restate (#2199)
* chores * add db function * add start-trial route in apps/api * update apps/desktop to support trial * openapi stuffs for apps/api * openapi client genertion * use rpc in apps/api * rename stuff * openapi stuff * onboarding wip * fix bearer case sensitive * trial flow got it working in desktop * done * fix stuff
1 parent aaf7d51 commit dde5b15

File tree

17 files changed

+809
-147
lines changed

17 files changed

+809
-147
lines changed

apps/api/openapi.gen.json

Lines changed: 206 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"get": {
3838
"responses": {
3939
"200": {
40-
"description": "-",
40+
"description": "result",
4141
"content": {
4242
"application/json": {
4343
"schema": {
@@ -222,6 +222,209 @@
222222
}
223223
}
224224
},
225+
"/file-transcription/start": {
226+
"post": {
227+
"responses": {
228+
"200": {
229+
"description": "Pipeline started",
230+
"content": {
231+
"application/json": {
232+
"schema": {
233+
"type": "object",
234+
"properties": {
235+
"pipelineId": {
236+
"type": "string"
237+
},
238+
"invocationId": {
239+
"type": "string"
240+
}
241+
},
242+
"required": [
243+
"pipelineId",
244+
"invocationId"
245+
],
246+
"additionalProperties": false
247+
}
248+
}
249+
}
250+
},
251+
"400": {
252+
"description": "Invalid fileId"
253+
},
254+
"401": {
255+
"description": "Unauthorized"
256+
},
257+
"500": {
258+
"description": "Internal error"
259+
}
260+
},
261+
"operationId": "postFile-transcriptionStart",
262+
"tags": [
263+
"private"
264+
],
265+
"parameters": [],
266+
"security": [
267+
{
268+
"Bearer": []
269+
}
270+
],
271+
"requestBody": {
272+
"content": {
273+
"application/json": {
274+
"schema": {
275+
"type": "object",
276+
"properties": {
277+
"fileId": {
278+
"type": "string"
279+
},
280+
"pipelineId": {
281+
"type": "string"
282+
}
283+
},
284+
"required": [
285+
"fileId"
286+
],
287+
"additionalProperties": false
288+
}
289+
}
290+
}
291+
}
292+
}
293+
},
294+
"/file-transcription/status/{pipelineId}": {
295+
"get": {
296+
"responses": {
297+
"200": {
298+
"description": "Pipeline status",
299+
"content": {
300+
"application/json": {
301+
"schema": {
302+
"type": "object",
303+
"properties": {
304+
"status": {
305+
"type": "string",
306+
"enum": [
307+
"QUEUED",
308+
"TRANSCRIBING",
309+
"TRANSCRIBED",
310+
"LLM_RUNNING",
311+
"DONE",
312+
"ERROR"
313+
]
314+
},
315+
"transcript": {
316+
"type": "string"
317+
},
318+
"llmResult": {
319+
"type": "string"
320+
},
321+
"error": {
322+
"type": "string"
323+
}
324+
},
325+
"required": [
326+
"status"
327+
],
328+
"additionalProperties": false
329+
}
330+
}
331+
}
332+
},
333+
"401": {
334+
"description": "Unauthorized"
335+
},
336+
"500": {
337+
"description": "Internal error"
338+
}
339+
},
340+
"operationId": "getFile-transcriptionStatusByPipelineId",
341+
"tags": [
342+
"private"
343+
],
344+
"parameters": [
345+
{
346+
"in": "path",
347+
"name": "pipelineId",
348+
"schema": {
349+
"type": "string"
350+
},
351+
"required": true
352+
}
353+
],
354+
"security": [
355+
{
356+
"Bearer": []
357+
}
358+
]
359+
}
360+
},
361+
"/file-transcription/result/{pipelineId}": {
362+
"get": {
363+
"responses": {
364+
"200": {
365+
"description": "Pipeline result",
366+
"content": {
367+
"application/json": {
368+
"schema": {
369+
"type": "object",
370+
"properties": {
371+
"status": {
372+
"type": "string",
373+
"enum": [
374+
"QUEUED",
375+
"TRANSCRIBING",
376+
"TRANSCRIBED",
377+
"LLM_RUNNING",
378+
"DONE",
379+
"ERROR"
380+
]
381+
},
382+
"transcript": {
383+
"type": "string"
384+
},
385+
"llmResult": {
386+
"type": "string"
387+
},
388+
"error": {
389+
"type": "string"
390+
}
391+
},
392+
"required": [
393+
"status"
394+
],
395+
"additionalProperties": false
396+
}
397+
}
398+
}
399+
},
400+
"401": {
401+
"description": "Unauthorized"
402+
},
403+
"500": {
404+
"description": "Internal error"
405+
}
406+
},
407+
"operationId": "getFile-transcriptionResultByPipelineId",
408+
"tags": [
409+
"private"
410+
],
411+
"parameters": [
412+
{
413+
"in": "path",
414+
"name": "pipelineId",
415+
"schema": {
416+
"type": "string"
417+
},
418+
"required": true
419+
}
420+
],
421+
"security": [
422+
{
423+
"Bearer": []
424+
}
425+
]
426+
}
427+
},
225428
"/rpc/can-start-trial": {
226429
"get": {
227430
"responses": {
@@ -287,7 +490,7 @@
287490
"post": {
288491
"responses": {
289492
"200": {
290-
"description": "-",
493+
"description": "result",
291494
"content": {
292495
"application/json": {
293496
"schema": {
@@ -421,7 +624,7 @@
421624
"post": {
422625
"responses": {
423626
"200": {
424-
"description": "-",
627+
"description": "result",
425628
"content": {
426629
"application/json": {
427630
"schema": {

apps/api/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"private": true,
44
"type": "module",
55
"scripts": {
6-
"dev": "dotenvx run --ignore MISSING_ENV_FILE -f ../../.env.supabase -f ../../.env.stripe -f .env -- bun --hot src/index.ts",
6+
"dev": "dotenvx run --ignore MISSING_ENV_FILE -f ../../.env.supabase -f ../../.env.stripe -f ../../.env.restate -f .env -- bun --hot src/index.ts",
77
"stripe:migrate": "dotenvx run --ignore MISSING_ENV_FILE -f ../../.env.supabase -f ../../.env.stripe -f .env -- bun src/scripts/run-stripe-migrations.ts",
88
"openapi": "CI=true bun src/scripts/generate-openapi.ts",
99
"typecheck": "tsc --noEmit",
1010
"test": "bun test"
1111
},
1212
"dependencies": {
1313
"@hypr/api-client": "workspace:*",
14+
"@restatedev/restate-sdk-clients": "^1.9.1",
1415
"@hono/zod-validator": "^0.7.5",
1516
"@posthog/ai": "^7.2.1",
1617
"@scalar/hono-api-reference": "^0.5.184",

apps/api/src/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const env = createEnv({
2525
ASSEMBLYAI_API_KEY: z.string().min(1),
2626
SONIOX_API_KEY: z.string().min(1),
2727
POSTHOG_API_KEY: z.string().min(1),
28+
RESTATE_INGRESS_URL: z.url(),
2829
OVERRIDE_AUTH: z.string().optional(),
2930
},
3031
runtimeEnv: Bun.env,

apps/api/src/integration/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from "./supabase";
22
export * from "./stripe";
33
export * from "./openrouter";
44
export * from "./posthog";
5+
export * from "./restate";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as clients from "@restatedev/restate-sdk-clients";
2+
3+
import { env } from "../env";
4+
5+
let restateClientInstance: ReturnType<typeof clients.connect> | null = null;
6+
7+
export function getRestateClient() {
8+
if (!restateClientInstance) {
9+
restateClientInstance = clients.connect({ url: env.RESTATE_INGRESS_URL });
10+
}
11+
return restateClientInstance;
12+
}

0 commit comments

Comments
 (0)