@@ -63,11 +63,11 @@ export const canvasDataQueryInput = z
6363 . object ( {
6464 // A typed query node passed straight to the query runner. Opaque here (the
6565 // node schemas are large + product-owned); validated by the API on execution.
66- query : z . record ( z . string ( ) , z . unknown ( ) ) . optional ( ) ,
66+ query : z . record ( z . string ( ) . max ( 256 ) , z . unknown ( ) ) . optional ( ) ,
6767 // Inline HogQL string (the escape hatch). Server wraps it as a HogQLQuery.
68- hogql : z . string ( ) . min ( 1 ) . optional ( ) ,
68+ hogql : z . string ( ) . min ( 1 ) . max ( 20_000 ) . optional ( ) ,
6969 // Reserved for bound parameters (Phase 3 named queries). Edit mode ignores it.
70- params : z . record ( z . string ( ) , z . unknown ( ) ) . optional ( ) ,
70+ params : z . record ( z . string ( ) . max ( 128 ) , z . unknown ( ) ) . optional ( ) ,
7171 } )
7272 . refine ( ( v ) => v . query != null || v . hogql != null , {
7373 message : "ph.query requires a query node or a HogQL string" ,
@@ -99,7 +99,7 @@ export type CanvasDataResult = z.infer<typeof canvasDataResultSchema>;
9999// shape as `ph.query`.
100100// ---------------------------------------------------------------------------
101101export const canvasLoadInsightInput = z . object ( {
102- shortId : z . string ( ) . min ( 1 ) ,
102+ shortId : z . string ( ) . min ( 1 ) . max ( 128 ) ,
103103 dateRange : z
104104 . object ( { date_from : z . string ( ) . nullish ( ) , date_to : z . string ( ) . nullish ( ) } )
105105 . optional ( ) ,
@@ -111,8 +111,8 @@ export type CanvasLoadInsightInput = z.infer<typeof canvasLoadInsightInput>;
111111// the private read token still never enters the iframe. `distinctId` is who the
112112// event is attributed to; defaults host-side when omitted.
113113export const canvasCaptureInput = z . object ( {
114- event : z . string ( ) . min ( 1 ) ,
115- distinctId : z . string ( ) . min ( 1 ) . optional ( ) ,
114+ event : z . string ( ) . min ( 1 ) . max ( 200 ) ,
115+ distinctId : z . string ( ) . min ( 1 ) . max ( 200 ) . optional ( ) ,
116116 properties : z . record ( z . string ( ) , z . unknown ( ) ) . optional ( ) ,
117117} ) ;
118118export type CanvasCaptureInput = z . infer < typeof canvasCaptureInput > ;
@@ -228,8 +228,8 @@ export const canvasToHostMessageSchema = z.discriminatedUnion("type", [
228228 z . object ( {
229229 channel : z . literal ( CANVAS_CHANNEL ) ,
230230 type : z . literal ( "data-request" ) ,
231- id : z . string ( ) ,
232- method : z . string ( ) ,
231+ id : z . string ( ) . min ( 1 ) . max ( 128 ) ,
232+ method : z . enum ( [ "query" , "loadInsight" , "capture" , "run" ] ) ,
233233 payload : z . unknown ( ) ,
234234 } ) ,
235235 // A runtime/compile error from inside the iframe, surfaced so the host can
@@ -238,8 +238,8 @@ export const canvasToHostMessageSchema = z.discriminatedUnion("type", [
238238 z . object ( {
239239 channel : z . literal ( CANVAS_CHANNEL ) ,
240240 type : z . literal ( "error" ) ,
241- message : z . string ( ) ,
242- stack : z . string ( ) . optional ( ) ,
241+ message : z . string ( ) . max ( 10_000 ) ,
242+ stack : z . string ( ) . max ( 50_000 ) . optional ( ) ,
243243 } ) ,
244244 // The canvas rendered successfully (clears any prior error state).
245245 z . object ( {
0 commit comments