github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/models/timeline.ts (about)

     1  import { z } from 'zod';
     2  
     3  // Since the backend may return 'null': https://github.com/pyroscope-io/pyroscope/issues/930
     4  // We create an empty object so that the defaults kick in
     5  export const TimelineSchema = z.preprocess(
     6    (val: unknown) => {
     7      return val ?? {};
     8    },
     9    z.object({
    10      startTime: z.number().default(0),
    11      samples: z.array(z.number()).default([]),
    12      durationDelta: z.number().default(0),
    13    })
    14  );
    15  
    16  export type Timeline = z.infer<typeof TimelineSchema>;