Skip to content

Commit 2d002f9

Browse files
committed
Shared the AITimeFilter type
1 parent ffe7697 commit 2d002f9

File tree

7 files changed

+18
-33
lines changed

7 files changed

+18
-33
lines changed

apps/webapp/app/components/code/AIQueryInput.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@ import { Spinner } from "~/components/primitives/Spinner";
1818
import { useEnvironment } from "~/hooks/useEnvironment";
1919
import { useOrganization } from "~/hooks/useOrganizations";
2020
import { useProject } from "~/hooks/useProject";
21+
import type { AITimeFilter } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/types";
2122
import { cn } from "~/utils/cn";
2223

23-
interface AITimeFilter {
24-
period?: string;
25-
from?: string;
26-
to?: string;
27-
}
28-
2924
type StreamEventType =
3025
| { type: "thinking"; content: string }
3126
| { type: "tool_call"; tool: string; args: unknown }

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/AITabContent.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { useState } from "react";
22
import { AIQueryInput } from "~/components/code/AIQueryInput";
33
import { Header3 } from "~/components/primitives/Headers";
4-
5-
interface AITimeFilter {
6-
period?: string;
7-
from?: string;
8-
to?: string;
9-
}
4+
import type { AITimeFilter } from "./types";
105

116
export function AITabContent({
127
onQueryGenerated,

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/QueryHelpSidebar.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ import { AITabContent } from "./AITabContent";
1010
import { ExamplesContent } from "./ExamplesContent";
1111
import { TableSchemaContent } from "./TableSchemaContent";
1212
import { TRQLGuideContent } from "./TRQLGuideContent";
13-
14-
interface AITimeFilter {
15-
period?: string;
16-
from?: string;
17-
to?: string;
18-
}
13+
import type { AITimeFilter } from "./types";
1914

2015
export function QueryHelpSidebar({
2116
onTryExample,

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import { FEATURE_FLAG, validateFeatureFlagValue } from "~/v3/featureFlags.server
6363
import { querySchemas } from "~/v3/querySchemas";
6464
import { QueryHelpSidebar } from "./QueryHelpSidebar";
6565
import { QueryHistoryPopover } from "./QueryHistoryPopover";
66+
import type { AITimeFilter } from "./types";
6667
import { formatQueryStats } from "./utils";
6768
import { requireUser } from "~/services/session.server";
6869
import parse from "parse-duration";
@@ -464,12 +465,6 @@ const QueryEditorForm = forwardRef<
464465
);
465466
});
466467

467-
interface AITimeFilter {
468-
period?: string;
469-
from?: string;
470-
to?: string;
471-
}
472-
473468
export default function Page() {
474469
const { defaultQuery, history, isAdmin } = useTypedLoaderData<typeof loader>();
475470
const results = useTypedActionData<typeof action>();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Time filter configuration that can be set by the AI.
3+
* Used across both server and client code for AI query generation.
4+
*/
5+
export type AITimeFilter = {
6+
period?: string;
7+
from?: string;
8+
to?: string;
9+
};

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query.ai-generate.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { z } from "zod";
44
import { env } from "~/env.server";
55
import { findProjectBySlug } from "~/models/project.server";
66
import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
7+
import type { AITimeFilter } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/types";
78
import { requireUserId } from "~/services/session.server";
89
import { EnvironmentParamSchema } from "~/utils/pathBuilder";
9-
import { AIQueryService, type AITimeFilter } from "~/v3/services/aiQueryService.server";
10+
import { AIQueryService } from "~/v3/services/aiQueryService.server";
1011
import { querySchemas } from "~/v3/querySchemas";
1112

1213
const RequestSchema = z.object({

apps/webapp/app/v3/services/aiQueryService.server.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@ import {
77
} from "@internal/tsql";
88
import { streamText, type LanguageModelV1, tool } from "ai";
99
import { z } from "zod";
10+
import type { AITimeFilter } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/types";
1011

11-
/**
12-
* Time filter configuration that can be set by the AI
13-
*/
14-
export interface AITimeFilter {
15-
period?: string;
16-
from?: string;
17-
to?: string;
18-
}
12+
// Re-export for backwards compatibility
13+
export type { AITimeFilter };
1914

2015
/**
2116
* Stream event types for AI query generation

0 commit comments

Comments
 (0)