All files / server/ai schemas.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61          54x                                                                                                              
/**
 * Generic query schemas for AI agents
 * Teaches AI how to construct analysis queries
 */
 
export const QUERY_SCHEMAS = {
  funnel: {
    description: 'Track conversion through sequential steps. Entities (identified by bindingKey) move through ordered steps.',
    structure: {
      funnel: {
        bindingKey: 'Cube.dimension - identifies entities moving through funnel',
        timeDimension: 'Cube.dimension - time field for ordering events',
        steps: [
          {
            name: 'string - human readable step name',
            filter: {
              member: 'Cube.dimension',
              operator: 'equals | notEquals | contains | ...',
              values: ['array of filter values']
            },
            timeToConvert: 'optional - max time window e.g. "7 days"'
          }
        ],
        dateRange: '[start, end] array OR string like "last 7 days", "last 3 months", "this quarter"'
      }
    }
  },
 
  flow: {
    description: 'Analyze paths users take before/after a specific event. Shows event sequences.',
    structure: {
      flow: {
        bindingKey: 'Cube.dimension - identifies entities',
        timeDimension: 'Cube.dimension - time field for ordering',
        eventDimension: 'Cube.dimension - the event type field',
        startingStep: {
          filter: { member: 'Cube.dimension', operator: 'equals', values: ['event value'] }
        },
        stepsBefore: 'number - how many steps to show before starting step',
        stepsAfter: 'number - how many steps to show after starting step',
        dateRange: '[start, end] array OR string like "last 7 days", "last 3 months", "this quarter"'
      }
    }
  },
 
  retention: {
    description: 'Measure how many users return over time periods after initial activity.',
    structure: {
      retention: {
        bindingKey: 'Cube.dimension - identifies entities',
        timeDimension: 'Cube.dimension - time field for cohort assignment',
        granularity: 'day | week | month - period size',
        periods: 'number - how many periods to analyze',
        dateRange: '[start, end] array OR string like "last 7 days", "last 3 months", "this quarter"'
      }
    }
  }
} as const
 
export type QuerySchemas = typeof QUERY_SCHEMAS