Skip to content

Commit 88a0684

Browse files
refactor(mobile): keep automation contracts local
Leave mobile automation transport untouched until it can move onto the existing API client rather than promoting mobile-only contracts to shared. Generated-By: PostHog Code Task-Id: c1bbe3cf-742b-4b24-bf96-d11a18b4cf22
1 parent 4f49e1c commit 88a0684

12 files changed

Lines changed: 61 additions & 157 deletions

File tree

apps/mobile/src/features/tasks/api.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import type {
2-
Adapter,
3-
CreateTaskAutomationOptions,
4-
StoredLogEntry,
5-
Task,
6-
TaskAutomation,
7-
TaskRun,
8-
UpdateTaskAutomationOptions,
9-
} from "@posthog/shared";
1+
import type { Adapter, StoredLogEntry, Task, TaskRun } from "@posthog/shared";
102
import type {
113
SandboxCustomImage,
124
SandboxEnvironment,
@@ -21,8 +13,11 @@ import {
2113
} from "@/lib/api";
2214
import { logger } from "@/lib/logger";
2315
import type {
16+
CreateTaskAutomationOptions,
2417
CreateTaskOptions,
2518
Integration,
19+
TaskAutomation,
20+
UpdateTaskAutomationOptions,
2621
UserGithubIntegration,
2722
} from "./types";
2823

apps/mobile/src/features/tasks/components/AutomationDetail.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Text } from "@components/text";
2-
import type { TaskAutomation, TaskRun } from "@posthog/shared";
2+
import type { TaskRun } from "@posthog/shared";
33
import { ActivityIndicator, Pressable, View } from "react-native";
4+
import type { TaskAutomation } from "../types";
45
import { formatAutomationScheduleSummary } from "../utils/automationSchedule";
56
import { getAutomationTemplatePresentation } from "../utils/automationTemplatePresentation";
67
import { AutomationStatusBadge } from "./AutomationStatusBadge";

apps/mobile/src/features/tasks/components/AutomationForm.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Text } from "@components/text";
2-
import type { CreateTaskAutomationOptions } from "@posthog/shared";
32
import { CaretDown, GithubLogo } from "phosphor-react-native";
43
import { type MutableRefObject, useEffect, useMemo, useState } from "react";
54
import {
@@ -13,7 +12,10 @@ import { MarkdownText } from "@/features/chat/components/MarkdownText";
1312
import { useThemeColors } from "@/lib/theme";
1413
import { RepositoryPickerInline } from "../composer/RepositoryPickerInline";
1514
import { useIntegrations } from "../hooks/useIntegrations";
16-
import type { RepositorySelection } from "../types";
15+
import type {
16+
CreateTaskAutomationOptions,
17+
RepositorySelection,
18+
} from "../types";
1719
import {
1820
type AutomationScheduleDraft,
1921
buildCronExpression,

apps/mobile/src/features/tasks/components/AutomationItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Text } from "@components/text";
2-
import type { TaskAutomation, TaskRun } from "@posthog/shared";
2+
import type { TaskRun } from "@posthog/shared";
33
import { format, formatDistanceToNow } from "date-fns";
44
import { memo } from "react";
55
import { Pressable, View } from "react-native";
6+
import type { TaskAutomation } from "../types";
67
import { formatAutomationScheduleSummary } from "../utils/automationSchedule";
78
import { getAutomationTemplatePresentation } from "../utils/automationTemplatePresentation";
89
import { AutomationStatusBadge } from "./AutomationStatusBadge";

apps/mobile/src/features/tasks/components/AutomationList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Text } from "@components/text";
2-
import type { TaskAutomation } from "@posthog/shared";
32
import { Plus } from "phosphor-react-native";
43
import {
54
ActivityIndicator,
@@ -11,6 +10,7 @@ import {
1110
import { useThemeColors } from "@/lib/theme";
1211
import { useAutomations } from "../hooks/useAutomations";
1312
import { useTasks } from "../hooks/useTasks";
13+
import type { TaskAutomation } from "../types";
1414
import { AutomationItem } from "./AutomationItem";
1515

1616
interface AutomationListProps {

apps/mobile/src/features/tasks/hooks/useAutomations.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import type {
2-
CreateTaskAutomationOptions,
3-
TaskAutomation,
4-
UpdateTaskAutomationOptions,
5-
} from "@posthog/shared";
61
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
72
import { useAuthStore } from "@/features/auth";
83
import { logger } from "@/lib/logger";
@@ -14,6 +9,11 @@ import {
149
runTaskAutomation,
1510
updateTaskAutomation,
1611
} from "../api";
12+
import type {
13+
CreateTaskAutomationOptions,
14+
TaskAutomation,
15+
UpdateTaskAutomationOptions,
16+
} from "../types";
1717
import { taskKeys } from "./useTasks";
1818

1919
const log = logger.scope("automations-mutations");

apps/mobile/src/features/tasks/types.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,47 @@ import type {
55
TaskRunStatus,
66
} from "@posthog/shared";
77

8+
export interface TaskAutomation {
9+
id: string;
10+
name: string;
11+
prompt: string;
12+
repository: string;
13+
github_integration?: number | null;
14+
cron_expression: string;
15+
timezone?: string | null;
16+
template_id?: string | null;
17+
enabled: boolean;
18+
last_run_at: string | null;
19+
last_run_status: string | null;
20+
last_task_id: string | null;
21+
last_task_run_id: string | null;
22+
last_error: string | null;
23+
created_at: string;
24+
updated_at: string;
25+
}
26+
27+
export interface CreateTaskAutomationOptions {
28+
name: string;
29+
prompt: string;
30+
repository: string;
31+
github_integration?: number | null;
32+
cron_expression: string;
33+
timezone: string;
34+
enabled?: boolean;
35+
template_id?: string | null;
36+
}
37+
38+
export interface UpdateTaskAutomationOptions {
39+
name?: string;
40+
prompt?: string;
41+
repository?: string;
42+
github_integration?: number | null;
43+
cron_expression?: string;
44+
timezone?: string;
45+
enabled?: boolean;
46+
template_id?: string | null;
47+
}
48+
849
export interface MobileStoredLogEntry extends SharedStoredLogEntry {
950
direction?: "client" | "agent";
1051
}

apps/mobile/src/features/tasks/utils/automationSchedule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { TaskAutomation } from "@posthog/shared";
1+
import type { TaskAutomation } from "../types";
22

33
export type AutomationScheduleMode =
44
| "hourly"

apps/mobile/src/features/tasks/utils/automationTemplatePresentation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { TaskAutomation } from "@posthog/shared";
21
import { parseSkillTemplateId } from "../skills/skillTemplateIds";
2+
import type { TaskAutomation } from "../types";
33

44
export interface AutomationTemplatePresentation {
55
templateName: string | null;

packages/shared/src/index.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -325,18 +325,6 @@ export {
325325
stripFrontmatter,
326326
} from "./skills";
327327
export type { PostHogAPIConfig } from "./task";
328-
export {
329-
type CreateTaskAutomationOptions,
330-
createTaskAutomationSchema,
331-
type TaskAutomation,
332-
type TaskAutomationList,
333-
type TaskAutomationValidationErrorDetails,
334-
taskAutomationListSchema,
335-
taskAutomationSchema,
336-
taskAutomationValidationErrorSchema,
337-
type UpdateTaskAutomationOptions,
338-
updateTaskAutomationSchema,
339-
} from "./task-automation";
340328
export type {
341329
TaskCreationInput,
342330
TaskCreationOutput,

0 commit comments

Comments
 (0)