@@ -13,11 +13,11 @@ import { Hono } from "hono";
1313import { describeRoute } from "hono-openapi" ;
1414import { resolver } from "hono-openapi/zod" ;
1515import { validator } from "shared/hono/middleware" ;
16- import { z } from "zod" ;
1716import { apiError } from "../errors" ;
1817import { auth } from "../middleware" ;
1918import { getJob , getJobLogs , getJobs } from "../repositories/jobs" ;
2019import { jobSchema , jobsPaginatedSchema } from "../schemas/jobs" ;
20+ import { z } from "../utils/zod" ;
2121
2222const inputSchema = z . discriminatedUnion ( "type" , [
2323 z . object ( {
@@ -28,16 +28,25 @@ const inputSchema = z.discriminatedUnion("type", [
2828 z . object ( {
2929 type : z . literal ( "audio" ) ,
3030 path : z . string ( ) ,
31- language : z . string ( ) . optional ( ) ,
31+ language : z . string ( ) . optional ( ) . openapi ( {
32+ description : "ISO 639 - 3 characters, language" ,
33+ } ) ,
3234 channels : z . number ( ) . optional ( ) ,
3335 } ) ,
3436 z . object ( {
3537 type : z . literal ( "text" ) ,
3638 path : z . string ( ) ,
37- language : z . string ( ) ,
39+ language : z . string ( ) . openapi ( {
40+ description : "ISO 639 - 3 characters, language" ,
41+ } ) ,
3842 } ) ,
3943] ) ;
4044
45+ const inputsSchema = z . array ( inputSchema ) . openapi ( {
46+ description :
47+ "The source media files, optional fields will be extracted from the source if possible." ,
48+ } ) ;
49+
4150const streamSchema = z . discriminatedUnion ( "type" , [
4251 z . object ( {
4352 type : z . literal ( "video" ) ,
@@ -50,15 +59,24 @@ const streamSchema = z.discriminatedUnion("type", [
5059 type : z . literal ( "audio" ) ,
5160 codec : z . enum ( [ "aac" , "ac3" , "eac3" ] ) ,
5261 bitrate : z . number ( ) . optional ( ) ,
53- language : z . string ( ) . optional ( ) ,
62+ language : z . string ( ) . optional ( ) . openapi ( {
63+ description : "ISO 639 - 3 characters, language" ,
64+ } ) ,
5465 channels : z . number ( ) . optional ( ) ,
5566 } ) ,
5667 z . object ( {
5768 type : z . literal ( "text" ) ,
58- language : z . string ( ) ,
69+ language : z . string ( ) . openapi ( {
70+ description : "ISO 639 - 3 characters, language" ,
71+ } ) ,
5972 } ) ,
6073] ) ;
6174
75+ const streamsSchema = z . array ( streamSchema ) . openapi ( {
76+ description :
77+ "Output streams, will try to find the best suitable input for the configured output." ,
78+ } ) ;
79+
6280export const jobsApp = new Hono ( )
6381 . use ( auth ( ) )
6482
@@ -90,13 +108,21 @@ export const jobsApp = new Hono()
90108 validator (
91109 "json" ,
92110 z . object ( {
93- assetId : z . string ( ) . uuid ( ) . default ( randomUUID ) ,
94- inputs : z . array ( inputSchema ) ,
95- streams : z . array ( streamSchema ) ,
111+ assetId : z . string ( ) . uuid ( ) . default ( randomUUID ) . openapi ( {
112+ default : "Randomly generated assetId" ,
113+ description :
114+ "Only provide when re-running this job, leave empty for auto generated id, which is advised." ,
115+ } ) ,
116+ inputs : inputsSchema ,
117+ streams : streamsSchema ,
96118 group : z . string ( ) . optional ( ) ,
97- language : z . string ( ) . optional ( ) ,
119+ language : z . string ( ) . optional ( ) . openapi ( {
120+ description : "ISO 639 - 3 characters, language" ,
121+ } ) ,
98122 concurrency : z . number ( ) . default ( DEFAULT_CONCURRENCY ) ,
99- public : z . boolean ( ) . default ( DEFAULT_PUBLIC ) ,
123+ public : z . boolean ( ) . default ( DEFAULT_PUBLIC ) . openapi ( {
124+ description : "S3 with public-read or private ACL" ,
125+ } ) ,
100126 } ) ,
101127 ) ,
102128 async ( c ) => {
@@ -139,10 +165,14 @@ export const jobsApp = new Hono()
139165 validator (
140166 "json" ,
141167 z . object ( {
142- assetId : z . string ( ) . uuid ( ) . default ( randomUUID ) ,
168+ assetId : z . string ( ) . uuid ( ) . default ( randomUUID ) . openapi ( {
169+ default : "Randomly generated assetId" ,
170+ description :
171+ "Only provide when re-running this job, leave empty for auto generated id, which is advised." ,
172+ } ) ,
143173 segmentSize : z . number ( ) . default ( DEFAULT_SEGMENT_SIZE ) ,
144- inputs : z . array ( inputSchema ) ,
145- streams : z . array ( streamSchema ) ,
174+ inputs : inputsSchema ,
175+ streams : streamsSchema ,
146176 group : z . string ( ) . optional ( ) ,
147177 } ) ,
148178 ) ,
@@ -187,9 +217,13 @@ export const jobsApp = new Hono()
187217 assetId : z . string ( ) . uuid ( ) . default ( randomUUID ) ,
188218 segmentSize : z . number ( ) . default ( DEFAULT_SEGMENT_SIZE ) ,
189219 name : z . string ( ) . default ( DEFAULT_PACKAGE_NAME ) ,
190- language : z . string ( ) . optional ( ) ,
220+ language : z . string ( ) . optional ( ) . openapi ( {
221+ description : "ISO 639 - 3 characters, language" ,
222+ } ) ,
191223 concurrency : z . number ( ) . default ( DEFAULT_CONCURRENCY ) ,
192- public : z . boolean ( ) . default ( DEFAULT_PUBLIC ) ,
224+ public : z . boolean ( ) . default ( DEFAULT_PUBLIC ) . openapi ( {
225+ description : "S3 with public-read or private ACL" ,
226+ } ) ,
193227 } ) ,
194228 ) ,
195229 async ( c ) => {
0 commit comments