Files
zeekay 40d120dbf7 refactor(api): say /v1/ in the Python callers
Every first-party Python caller and test now names the mount the API actually
answers on. Mechanical: URL literals only, and only where the /api/ was ours --
a preceding word character means it was a module path like insights/api/ or a
third-party host like slack.com/api/, and those are untouched.

Left saying /api/, each for a reason rather than for safety:
- products/warehouse_sources/.../sources/** is a catalogue of vendor endpoints
- services/llm-gateway deploys separately and is under a code freeze, so moving
  its two calls would break it during the skew
- the mcp_store and Slack/Teams redirect_uris are registered with third parties
  and must byte-match what was registered
- the Wizard and Raycast client-metadata paths are OAuth client_ids
- /api/surveys and /api/feature_flag/local_evaluation are SDK aliases the
  ingress routes to the Rust fleets, held by released SDK versions

Test URLconfs moved with the requests that call them, and the Datastore
user-selection fixtures now carry the leading slash that request.path has.
2026-08-08 18:38:44 -07:00

49 lines
3.6 KiB
TypeScript

// Real captured insight API responses, shared with the frontend's MSW fixtures
// (frontend/src/mocks/fixtures/api/projects/team_id/insights/). They are legacy
// `/v1/insight/` payloads whose `result` field carries the same series items the
// modern `/query/` endpoint returns under `results` — the part the UI app type
// guards and visualizers inspect. `queryPayload` re-wraps a fixture's series as
// the `{ query, results }` payload the MCP UI apps receive.
import dataVisualizationInsightsQLJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/dataVisualizationInsightsQL.json'
import funnelHistoricalTrendsJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelHistoricalTrends.json'
import funnelTimeToConvertJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTimeToConvert.json'
import funnelTopToBottomJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottom.json'
import funnelTopToBottomBreakdownJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomBreakdown.json'
import lifecycleJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/lifecycle.json'
import retentionJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/retention.json'
import stickinessJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/stickiness.json'
import trendsLineJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/trendsLine.json'
import trendsLineBreakdownJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/trendsLineBreakdown.json'
import trendsNumberJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/trendsNumber.json'
import trendsPieJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/trendsPie.json'
import trendsWorldMapJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/trendsWorldMap.json'
import userPathsJson from '../../../../frontend/src/mocks/fixtures/api/projects/team_id/insights/userPaths.json'
export const insightResults = {
trendsLine: trendsLineJson.result,
trendsLineBreakdown: trendsLineBreakdownJson.result,
/** BoldNumber display — single series with `aggregated_value`. */
trendsNumber: trendsNumberJson.result,
trendsPie: trendsPieJson.result,
trendsWorldMap: trendsWorldMapJson.result,
/** Stickiness rows duck-type as trends (`data`/`labels`/`days`). */
stickiness: stickinessJson.result,
/** Funnel in trends visualization mode — time-series rows, not steps. */
funnelHistoricalTrends: funnelHistoricalTrendsJson.result,
funnelTopToBottom: funnelTopToBottomJson.result,
/** Breakdown funnel — nested array of step arrays, one per breakdown. */
funnelTopToBottomBreakdown: funnelTopToBottomBreakdownJson.result,
/** Time-to-convert funnel — `{ average_conversion_time, bins }` object, no steps. */
funnelTimeToConvert: funnelTimeToConvertJson.result,
lifecycle: lifecycleJson.result,
retention: retentionJson.result,
userPaths: userPathsJson.result,
/** The legacy serializer flattens `columns` to the top level; `/query/` nests them. */
insightsqlTable: { columns: dataVisualizationInsightsQLJson.columns, results: dataVisualizationInsightsQLJson.result },
} as const
export function queryPayload(results: unknown, kind?: string): { results: unknown; query?: { kind: string } } {
return { results, ...(kind ? { query: { kind } } : {}) }
}