@shipfox/client-workflows 19.0.0 → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/dist/components/workflow-run-duration-label.d.ts +8 -7
  4. package/dist/components/workflow-run-duration-label.d.ts.map +1 -1
  5. package/dist/components/workflow-run-duration-label.js +15 -31
  6. package/dist/components/workflow-run-duration-label.js.map +1 -1
  7. package/dist/components/workflow-run-list/workflow-run-row.d.ts.map +1 -1
  8. package/dist/components/workflow-run-list/workflow-run-row.js +9 -6
  9. package/dist/components/workflow-run-list/workflow-run-row.js.map +1 -1
  10. package/dist/components/workflow-run-summary/workflow-run-summary.d.ts.map +1 -1
  11. package/dist/components/workflow-run-summary/workflow-run-summary.js +7 -34
  12. package/dist/components/workflow-run-summary/workflow-run-summary.js.map +1 -1
  13. package/dist/components/workflow-status/status-visuals.d.ts.map +1 -1
  14. package/dist/components/workflow-status/status-visuals.js +0 -9
  15. package/dist/components/workflow-status/status-visuals.js.map +1 -1
  16. package/dist/components/workflow-status/workflow-status-icon.d.ts.map +1 -1
  17. package/dist/components/workflow-status/workflow-status-icon.js +0 -11
  18. package/dist/components/workflow-status/workflow-status-icon.js.map +1 -1
  19. package/dist/core/entities/workflow-run.d.ts +10 -55
  20. package/dist/core/entities/workflow-run.d.ts.map +1 -1
  21. package/dist/core/entities/workflow-run.js +1 -94
  22. package/dist/core/entities/workflow-run.js.map +1 -1
  23. package/dist/core/workflow-run.d.ts +2 -2
  24. package/dist/core/workflow-run.d.ts.map +1 -1
  25. package/dist/core/workflow-run.js +1 -1
  26. package/dist/core/workflow-run.js.map +1 -1
  27. package/dist/hooks/api/workflow-run-mapper.d.ts.map +1 -1
  28. package/dist/hooks/api/workflow-run-mapper.js +3 -1
  29. package/dist/hooks/api/workflow-run-mapper.js.map +1 -1
  30. package/dist/hooks/api/workflow-runs.js +1 -0
  31. package/dist/hooks/api/workflow-runs.js.map +1 -1
  32. package/dist/tsconfig.test.tsbuildinfo +1 -1
  33. package/package.json +2 -2
  34. package/src/components/workflow-run-duration-label.tsx +21 -44
  35. package/src/components/workflow-run-list/workflow-run-list-view.test.tsx +48 -0
  36. package/src/components/workflow-run-list/workflow-run-row.tsx +7 -6
  37. package/src/components/workflow-run-summary/workflow-run-summary.stories.tsx +0 -38
  38. package/src/components/workflow-run-summary/workflow-run-summary.test.tsx +73 -21
  39. package/src/components/workflow-run-summary/workflow-run-summary.tsx +6 -27
  40. package/src/components/workflow-status/status-visuals.ts +0 -4
  41. package/src/components/workflow-status/workflow-status-icon.stories.tsx +0 -1
  42. package/src/components/workflow-status/workflow-status-icon.tsx +0 -18
  43. package/src/core/entities/workflow-run.ts +9 -136
  44. package/src/core/workflow-run.test.ts +2 -0
  45. package/src/core/workflow-run.ts +0 -8
  46. package/src/hooks/api/workflow-run-mapper.ts +2 -0
  47. package/src/hooks/api/workflow-runs.ts +1 -1
  48. package/test/fixtures/workflow-run.ts +30 -3
  49. package/tsconfig.build.tsbuildinfo +1 -1
  50. package/src/core/entities/workflow-run-display.test.ts +0 -187
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/api/workflow-runs.ts"],"sourcesContent":["import {\n type RerunWorkflowRunBodyDto,\n type WorkflowRunRerunModeDto,\n workflowRunAttemptsResponseSchema,\n workflowRunDetailResponseSchema,\n workflowRunDtoSchema,\n workflowRunListResponseSchema,\n workflowRunResponseSchema,\n} from '@shipfox/api-workflows-dto';\nimport {checkedApiRequest, type StandardSchema} from '@shipfox/client-api';\nimport {\n type InfiniteData,\n infiniteQueryOptions,\n keepPreviousData,\n queryOptions,\n type UseInfiniteQueryOptions,\n type UseQueryOptions,\n useInfiniteQuery,\n useMutation,\n useQuery,\n useQueryClient,\n} from '@tanstack/react-query';\nimport {\n isWorkflowRunTerminal,\n type ManualWorkflowLaunch,\n type WorkflowRun,\n type WorkflowRunAttempt,\n WorkflowRunAttemptSummary,\n type WorkflowRunDetail,\n type WorkflowRunListItem,\n type WorkflowRunListPage,\n type WorkflowRunRecord,\n type WorkflowRunStatus,\n} from '#core/workflow-run.js';\nimport {\n toWorkflowRunAttempt,\n toWorkflowRunDetail,\n toWorkflowRunListPage,\n toWorkflowRunRecord,\n} from './workflow-run-mapper.js';\n\nexport interface WorkflowRunFilters {\n status?: WorkflowRunStatus | undefined;\n definitionId?: string | undefined;\n triggerSource?: string | undefined;\n createdFrom?: string | undefined;\n createdTo?: string | undefined;\n}\n\nexport const workflowRunsQueryKeys = {\n all: ['workflow-runs'] as const,\n lists: (projectId: string) => [...workflowRunsQueryKeys.all, 'list', projectId] as const,\n list: (projectId: string, filters: WorkflowRunFilters) =>\n [...workflowRunsQueryKeys.lists(projectId), normalizeFilters(filters)] as const,\n detail: (workflowRunId: string, runAttempt?: number | undefined) =>\n [...workflowRunsQueryKeys.all, 'detail', workflowRunId, runAttempt ?? null] as const,\n attempts: (workflowRunId: string) =>\n [...workflowRunsQueryKeys.all, 'attempts', workflowRunId] as const,\n};\n\ntype WorkflowRunsListQueryKey =\n | ReturnType<typeof workflowRunsQueryKeys.list>\n | readonly ['workflow-runs', 'list'];\ntype WorkflowRunDetailQueryKey =\n | ReturnType<typeof workflowRunsQueryKeys.detail>\n | readonly ['workflow-runs', 'detail'];\ntype WorkflowRunAttemptsQueryKey =\n | ReturnType<typeof workflowRunsQueryKeys.attempts>\n | readonly ['workflow-runs', 'attempts'];\ntype WorkflowRunsInfiniteQueryOptions = UseInfiniteQueryOptions<\n WorkflowRunListPage,\n Error,\n InfiniteData<WorkflowRunListPage, string | undefined>,\n WorkflowRunsListQueryKey,\n string | undefined\n>;\ntype WorkflowRunDetailQueryOptions = UseQueryOptions<\n WorkflowRunDetail,\n Error,\n WorkflowRunDetail,\n WorkflowRunDetailQueryKey\n>;\ntype WorkflowRunAttemptsQueryOptions = UseQueryOptions<\n WorkflowRunAttempt[],\n Error,\n WorkflowRunAttempt[],\n WorkflowRunAttemptsQueryKey\n>;\n\nfunction normalizeFilters(filters: WorkflowRunFilters) {\n return {\n status: filters.status ?? null,\n definitionId: filters.definitionId ?? null,\n triggerSource: filters.triggerSource ?? null,\n createdFrom: filters.createdFrom ?? null,\n createdTo: filters.createdTo ?? null,\n };\n}\n\nfunction appendFilters(params: URLSearchParams, filters: WorkflowRunFilters) {\n if (filters.status) params.set('status', filters.status);\n if (filters.definitionId) params.set('definition_id', filters.definitionId);\n if (filters.triggerSource) params.set('trigger_source', filters.triggerSource);\n if (filters.createdFrom) params.set('created_from', filters.createdFrom);\n if (filters.createdTo) params.set('created_to', filters.createdTo);\n}\n\nasync function listWorkflowRuns({\n projectId,\n filters,\n limit = 50,\n cursor,\n signal,\n}: {\n projectId: string;\n filters: WorkflowRunFilters;\n limit?: number;\n cursor?: string | undefined;\n signal?: AbortSignal;\n}): Promise<WorkflowRunListPage> {\n const params = new URLSearchParams({project_id: projectId, limit: String(limit)});\n if (cursor) params.set('cursor', cursor);\n appendFilters(params, filters);\n const response = await checkedApiRequest(\n workflowRunListResponseSchema,\n `/workflows/runs?${params.toString()}`,\n {signal},\n );\n return toWorkflowRunListPage(response);\n}\n\n/**\n * Fire the manual trigger of a workflow definition.\n *\n * The server resolves the manual subscription by definition id (workflows\n * may declare at most one manual trigger). `inputs` are forwarded to the\n * run when provided.\n */\nexport async function fireManualWorkflow({\n definitionId,\n inputs,\n}: {\n definitionId: string;\n inputs?: Record<string, unknown>;\n}): Promise<ManualWorkflowLaunch> {\n const response = await checkedApiRequest(\n manualWorkflowResponseSchema,\n `/workflow-definitions/${definitionId}/fire-manual`,\n {\n method: 'POST',\n body: inputs ? {inputs} : {},\n },\n );\n return {workflowRunId: response.workflow_run_id};\n}\n\nconst ACTIVE_POLL_MS = 4_000;\nconst IDLE_POLL_MS = 30_000;\n\ntype RunListInfinite = InfiniteData<WorkflowRunListPage, string | undefined>;\n\nexport function useWorkflowRunsInfiniteQuery(\n projectId: string | undefined,\n filters: WorkflowRunFilters,\n limit = 50,\n) {\n return useInfiniteQuery(workflowRunsInfiniteQueryOptions(projectId, filters, limit));\n}\n\nexport function workflowRunsInfiniteQueryOptions(\n projectId: string | undefined,\n filters: WorkflowRunFilters,\n limit = 50,\n): WorkflowRunsInfiniteQueryOptions {\n // Polling is owned by react-query, not the page. Polling fast (4s) while\n // any non-terminal run is visible covers state transitions; polling slow\n // (30s) when idle covers brand-new external runs (webhook/schedule\n // triggers) without leaving the list stale.\n //\n // We disable polling once the user has loaded more than one page. With\n // cursor pagination the cursor that bounds page 1 was computed from\n // page 0's last row; if a refetch shifts that boundary, a small range\n // of rows can drop into a between-pages gap. Users who scrolled into\n // history opted into \"reading mode\": pause until they refocus, filter,\n // or scroll back.\n return infiniteQueryOptions({\n queryKey: projectId\n ? workflowRunsQueryKeys.list(projectId, filters)\n : ([...workflowRunsQueryKeys.all, 'list'] as const),\n enabled: Boolean(projectId),\n initialPageParam: undefined as string | undefined,\n queryFn: ({pageParam, signal}) =>\n listWorkflowRuns({projectId: projectId ?? '', filters, limit, cursor: pageParam, signal}),\n getNextPageParam: (lastPage) => lastPage.nextCursor ?? undefined,\n placeholderData: keepPreviousData,\n staleTime: 2_000,\n refetchOnWindowFocus: true,\n refetchInterval: (query) => {\n const data = query.state.data;\n if (!data || data.pages.length > 1) return false;\n const hasActive = data.pages.some((page) =>\n page.runs.some((run) => !isWorkflowRunTerminal(run.status)),\n );\n return hasActive ? ACTIVE_POLL_MS : IDLE_POLL_MS;\n },\n refetchIntervalInBackground: false,\n });\n}\n\nasync function getWorkflowRun({\n workflowRunId,\n runAttempt,\n signal,\n}: {\n workflowRunId: string;\n runAttempt?: number | undefined;\n signal?: AbortSignal;\n}): Promise<WorkflowRunDetail> {\n const params = new URLSearchParams();\n if (runAttempt) params.set('attempt', String(runAttempt));\n const query = params.size > 0 ? `?${params.toString()}` : '';\n return toWorkflowRunDetail(\n await checkedApiRequest(\n workflowRunDetailResponseSchema,\n `/workflows/runs/${workflowRunId}${query}`,\n {\n signal,\n },\n ),\n );\n}\n\nasync function getWorkflowRunAttempts({\n workflowRunId,\n signal,\n}: {\n workflowRunId: string;\n signal?: AbortSignal;\n}): Promise<WorkflowRunAttempt[]> {\n const response = await checkedApiRequest(\n workflowRunAttemptsResponseSchema,\n `/workflows/runs/${workflowRunId}/attempts`,\n {\n signal,\n },\n );\n return response.attempts.map(toWorkflowRunAttempt);\n}\n\nasync function cancelWorkflowRun({\n workflowRunId,\n}: {\n workflowRunId: string;\n}): Promise<WorkflowRunRecord> {\n return toWorkflowRunRecord(\n await checkedApiRequest(workflowRunDtoSchema, `/workflows/runs/${workflowRunId}/cancel`, {\n method: 'POST',\n }),\n );\n}\n\nexport async function rerunWorkflowRun({\n workflowRunId,\n mode,\n}: {\n workflowRunId: string;\n mode: WorkflowRunRerunModeDto;\n}): Promise<WorkflowRunRecord> {\n return toWorkflowRunRecord(\n await checkedApiRequest(workflowRunResponseSchema, `/workflows/runs/${workflowRunId}/rerun`, {\n method: 'POST',\n body: {mode} satisfies RerunWorkflowRunBodyDto,\n }),\n );\n}\n\nconst manualWorkflowResponseSchema: StandardSchema<unknown, {workflow_run_id: string}> = {\n '~standard': {\n version: 1,\n vendor: 'client-workflows',\n validate: (value) => {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'workflow_run_id' in value &&\n typeof value.workflow_run_id === 'string'\n )\n return {value: {workflow_run_id: value.workflow_run_id}};\n return {issues: [{message: 'Expected workflow_run_id.'}]};\n },\n },\n};\n\nexport function useRerunWorkflowRunMutation(projectId: string) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: rerunWorkflowRun,\n onSuccess: async (_run, variables) => {\n await Promise.all([\n queryClient.invalidateQueries({queryKey: workflowRunsQueryKeys.lists(projectId)}),\n queryClient.invalidateQueries({\n queryKey: workflowRunsQueryKeys.detail(variables.workflowRunId),\n }),\n queryClient.invalidateQueries({\n queryKey: workflowRunsQueryKeys.attempts(variables.workflowRunId),\n }),\n ]);\n },\n });\n}\n\nfunction filtersAcceptManualPendingRun(\n filters: WorkflowRunFilters,\n definitionId: string,\n now: Date,\n): boolean {\n if (filters.status && filters.status !== 'pending') return false;\n if (filters.definitionId && filters.definitionId !== definitionId) return false;\n if (filters.triggerSource && filters.triggerSource !== 'manual') return false;\n if (filters.createdFrom && Date.parse(filters.createdFrom) > now.getTime()) return false;\n if (filters.createdTo && Date.parse(filters.createdTo) < now.getTime()) return false;\n return true;\n}\n\nfunction buildTempRun({\n projectId,\n definitionId,\n name,\n createdAt,\n}: {\n projectId: string;\n definitionId: string;\n name: string;\n createdAt: string;\n}): WorkflowRunListItem {\n const id = `temp-${cryptoRandomId()}`;\n return {\n id,\n projectId,\n definitionId,\n number: null,\n name,\n workflowName: name,\n status: 'pending',\n currentAttempt: 1,\n latestAttempt: 1,\n triggerProvider: null,\n triggerSource: 'manual',\n triggerEvent: 'fire',\n triggerPayload: {source: 'manual', event: 'fire'},\n triggerDisplayLabel: 'fire',\n triggerLabel: 'manual · fire',\n triggerReference: null,\n inputs: null,\n sourceSnapshot: null,\n createdAt,\n updatedAt: createdAt,\n isTemporary: true,\n // The optimistic row genuinely has no jobs yet: the server has not planned the graph.\n jobs: {preview: [], statusCounts: [], total: 0},\n runAttempt: new WorkflowRunAttemptSummary({\n workflowRunId: id,\n attempt: 1,\n status: 'pending',\n createdAt,\n startedAt: null,\n finishedAt: null,\n }),\n };\n}\n\nfunction cryptoRandomId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n\nexport interface FireManualWorkflowVariables {\n projectId: string;\n definitionId: string;\n inputs?: Record<string, unknown>;\n}\n\nexport function useFireManualWorkflowMutation() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: (variables: FireManualWorkflowVariables) =>\n fireManualWorkflow(\n variables.inputs\n ? {definitionId: variables.definitionId, inputs: variables.inputs}\n : {definitionId: variables.definitionId},\n ),\n onMutate: (variables) => {\n const definitionName = lookupDefinitionName(\n queryClient,\n variables.projectId,\n variables.definitionId,\n );\n const createdAt = new Date().toISOString();\n const tempRun = buildTempRun({\n projectId: variables.projectId,\n definitionId: variables.definitionId,\n name: definitionName ?? 'New run',\n createdAt,\n });\n\n const listsKey = workflowRunsQueryKeys.lists(variables.projectId);\n const touchedQueryKeys: Array<readonly unknown[]> = [];\n\n const entries = queryClient.getQueriesData<RunListInfinite>({queryKey: listsKey});\n const now = new Date(createdAt);\n for (const [queryKey] of entries) {\n const filters = readFiltersFromKey(queryKey);\n if (!filters) continue;\n if (!filtersAcceptManualPendingRun(filters, variables.definitionId, now)) continue;\n\n touchedQueryKeys.push(queryKey);\n queryClient.setQueryData<RunListInfinite>(queryKey, (current) => {\n if (!current || current.pages.length === 0) return current;\n const firstPage = current.pages[0];\n if (!firstPage) return current;\n const nextFirstPage: WorkflowRunListPage = {\n ...firstPage,\n runs: [tempRun, ...firstPage.runs],\n filteredTotalCount:\n firstPage.filteredTotalCount != null ? firstPage.filteredTotalCount + 1 : null,\n };\n return {...current, pages: [nextFirstPage, ...current.pages.slice(1)]};\n });\n }\n\n return {tempWorkflowRunId: tempRun.id, touchedQueryKeys};\n },\n onError: (_error, _variables, context) => {\n if (!context) return;\n for (const queryKey of context.touchedQueryKeys) {\n queryClient.setQueryData<RunListInfinite>(queryKey, (current) => {\n if (!current) return current;\n let removedCount = 0;\n const pages = current.pages.map((page) => {\n const runs = page.runs.filter((run) => {\n if (run.id !== context.tempWorkflowRunId) return true;\n removedCount += 1;\n return false;\n });\n if (runs.length === page.runs.length) return page;\n return {\n ...page,\n runs,\n filteredTotalCount:\n page.filteredTotalCount != null\n ? Math.max(0, page.filteredTotalCount - removedCount)\n : null,\n };\n });\n if (removedCount === 0) return current;\n return {...current, pages};\n });\n }\n },\n onSuccess: (_data, variables) => {\n void queryClient.invalidateQueries({\n queryKey: workflowRunsQueryKeys.lists(variables.projectId),\n });\n },\n });\n}\n\nfunction readFiltersFromKey(queryKey: readonly unknown[]): WorkflowRunFilters | null {\n if (queryKey.length < 4) return null;\n const normalized = queryKey[3];\n if (!normalized || typeof normalized !== 'object') return null;\n const obj = normalized as Record<string, unknown>;\n return {\n status: (obj.status as WorkflowRunStatus | null) ?? undefined,\n definitionId: (obj.definitionId as string | null) ?? undefined,\n triggerSource: (obj.triggerSource as string | null) ?? undefined,\n createdFrom: (obj.createdFrom as string | null) ?? undefined,\n createdTo: (obj.createdTo as string | null) ?? undefined,\n };\n}\n\nfunction lookupDefinitionName(\n queryClient: ReturnType<typeof useQueryClient>,\n projectId: string,\n definitionId: string,\n): string | undefined {\n const entries = queryClient.getQueriesData<\n InfiniteData<{definitions: Array<{id: string; name: string}>}>\n >({queryKey: ['definitions', 'list', projectId]});\n for (const [, data] of entries) {\n if (!data) continue;\n for (const page of data.pages) {\n const match = page.definitions.find((d) => d.id === definitionId);\n if (match) return match.name;\n }\n }\n return undefined;\n}\n\nexport function useWorkflowRunQuery(workflowRunId: string | undefined) {\n return useWorkflowRunAttemptQuery({workflowRunId, runAttempt: undefined});\n}\n\nexport function useWorkflowRunAttemptQuery({\n workflowRunId,\n runAttempt,\n enabled = true,\n}: {\n workflowRunId: string | undefined;\n runAttempt?: number | undefined;\n enabled?: boolean | undefined;\n}) {\n return useQuery(workflowRunQueryOptions({workflowRunId, runAttempt, enabled}));\n}\n\nexport function workflowRunQueryOptions({\n workflowRunId,\n runAttempt,\n enabled = true,\n}: {\n workflowRunId: string | undefined;\n runAttempt?: number | undefined;\n enabled?: boolean | undefined;\n}): WorkflowRunDetailQueryOptions {\n // Poll a non-terminal run so the open run detail stays live (same cadence as the run\n // list); stop once the run is terminal.\n return queryOptions({\n queryKey: workflowRunId\n ? workflowRunsQueryKeys.detail(workflowRunId, runAttempt)\n : ([...workflowRunsQueryKeys.all, 'detail'] as const),\n enabled: Boolean(workflowRunId) && enabled,\n queryFn: ({signal}) => getWorkflowRun({workflowRunId: workflowRunId ?? '', runAttempt, signal}),\n staleTime: 2_000,\n refetchOnWindowFocus: true,\n refetchInterval: (query) => {\n const status: WorkflowRunDetail['runAttempt']['status'] | undefined =\n query.state.data?.runAttempt.status;\n if (!status) return false;\n return isWorkflowRunTerminal(status) ? false : ACTIVE_POLL_MS;\n },\n refetchIntervalInBackground: false,\n });\n}\n\nexport function useWorkflowRunAttemptsQuery({\n workflowRunId,\n enabled,\n}: {\n workflowRunId: string | undefined;\n enabled: boolean;\n}) {\n return useQuery(workflowRunAttemptsQueryOptions({workflowRunId, enabled}));\n}\n\nexport function workflowRunAttemptsQueryOptions({\n workflowRunId,\n enabled,\n}: {\n workflowRunId: string | undefined;\n enabled: boolean;\n}): WorkflowRunAttemptsQueryOptions {\n return queryOptions({\n queryKey: workflowRunId\n ? workflowRunsQueryKeys.attempts(workflowRunId)\n : ([...workflowRunsQueryKeys.all, 'attempts'] as const),\n enabled: Boolean(workflowRunId) && enabled,\n queryFn: ({signal}) => getWorkflowRunAttempts({workflowRunId: workflowRunId ?? '', signal}),\n staleTime: 0,\n refetchOnMount: true,\n refetchOnWindowFocus: false,\n });\n}\n\nexport function useCancelWorkflowRunMutation(run: WorkflowRun | undefined) {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (): Promise<WorkflowRunRecord> => {\n if (!run) throw new Error('Workflow run is not loaded');\n return await cancelWorkflowRun({workflowRunId: run.id});\n },\n onSuccess: async () => {\n if (!run) return;\n await Promise.all([\n queryClient.invalidateQueries({queryKey: workflowRunsQueryKeys.detail(run.id)}),\n queryClient.invalidateQueries({queryKey: workflowRunsQueryKeys.lists(run.projectId)}),\n queryClient.invalidateQueries({queryKey: workflowRunsQueryKeys.attempts(run.id)}),\n ]);\n },\n });\n}\n"],"names":["workflowRunAttemptsResponseSchema","workflowRunDetailResponseSchema","workflowRunDtoSchema","workflowRunListResponseSchema","workflowRunResponseSchema","checkedApiRequest","infiniteQueryOptions","keepPreviousData","queryOptions","useInfiniteQuery","useMutation","useQuery","useQueryClient","isWorkflowRunTerminal","WorkflowRunAttemptSummary","toWorkflowRunAttempt","toWorkflowRunDetail","toWorkflowRunListPage","toWorkflowRunRecord","workflowRunsQueryKeys","all","lists","projectId","list","filters","normalizeFilters","detail","workflowRunId","runAttempt","attempts","status","definitionId","triggerSource","createdFrom","createdTo","appendFilters","params","set","listWorkflowRuns","limit","cursor","signal","URLSearchParams","project_id","String","response","toString","fireManualWorkflow","inputs","manualWorkflowResponseSchema","method","body","workflow_run_id","ACTIVE_POLL_MS","IDLE_POLL_MS","useWorkflowRunsInfiniteQuery","workflowRunsInfiniteQueryOptions","queryKey","enabled","Boolean","initialPageParam","undefined","queryFn","pageParam","getNextPageParam","lastPage","nextCursor","placeholderData","staleTime","refetchOnWindowFocus","refetchInterval","query","data","state","pages","length","hasActive","some","page","runs","run","refetchIntervalInBackground","getWorkflowRun","size","getWorkflowRunAttempts","map","cancelWorkflowRun","rerunWorkflowRun","mode","version","vendor","validate","value","issues","message","useRerunWorkflowRunMutation","queryClient","mutationFn","onSuccess","_run","variables","Promise","invalidateQueries","filtersAcceptManualPendingRun","now","Date","parse","getTime","buildTempRun","name","createdAt","id","cryptoRandomId","number","workflowName","currentAttempt","latestAttempt","triggerProvider","triggerEvent","triggerPayload","source","event","triggerDisplayLabel","triggerLabel","triggerReference","sourceSnapshot","updatedAt","isTemporary","jobs","preview","statusCounts","total","attempt","startedAt","finishedAt","crypto","randomUUID","Math","random","slice","useFireManualWorkflowMutation","onMutate","definitionName","lookupDefinitionName","toISOString","tempRun","listsKey","touchedQueryKeys","entries","getQueriesData","readFiltersFromKey","push","setQueryData","current","firstPage","nextFirstPage","filteredTotalCount","tempWorkflowRunId","onError","_error","_variables","context","removedCount","filter","max","_data","normalized","obj","match","definitions","find","d","useWorkflowRunQuery","useWorkflowRunAttemptQuery","workflowRunQueryOptions","useWorkflowRunAttemptsQuery","workflowRunAttemptsQueryOptions","refetchOnMount","useCancelWorkflowRunMutation","Error"],"mappings":"AAAA,SAGEA,iCAAiC,EAC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AAI,CAAClB,KAAK;YACV,MAAMqB,QAAQjF,GAAG,CAAC;gBAChB4E,YAAYM,iBAAiB,CAAC;oBAAC7C,UAAUtC,sBAAsBO,MAAM,CAACsD,IAAI+B,EAAE;gBAAC;gBAC7Ef,YAAYM,iBAAiB,CAAC;oBAAC7C,UAAUtC,sBAAsBE,KAAK,CAAC2D,IAAI1D,SAAS;gBAAC;gBACnF0E,YAAYM,iBAAiB,CAAC;oBAAC7C,UAAUtC,sBAAsBU,QAAQ,CAACmD,IAAI+B,EAAE;gBAAC;aAChF;QACH;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/hooks/api/workflow-runs.ts"],"sourcesContent":["import {\n type RerunWorkflowRunBodyDto,\n type WorkflowRunRerunModeDto,\n workflowRunAttemptsResponseSchema,\n workflowRunDetailResponseSchema,\n workflowRunDtoSchema,\n workflowRunListResponseSchema,\n workflowRunResponseSchema,\n} from '@shipfox/api-workflows-dto';\nimport {checkedApiRequest, type StandardSchema} from '@shipfox/client-api';\nimport {\n type InfiniteData,\n infiniteQueryOptions,\n keepPreviousData,\n queryOptions,\n type UseInfiniteQueryOptions,\n type UseQueryOptions,\n useInfiniteQuery,\n useMutation,\n useQuery,\n useQueryClient,\n} from '@tanstack/react-query';\nimport {\n isWorkflowRunTerminal,\n type ManualWorkflowLaunch,\n type WorkflowRun,\n type WorkflowRunAttempt,\n WorkflowRunAttemptSummary,\n type WorkflowRunDetail,\n type WorkflowRunListItem,\n type WorkflowRunListPage,\n type WorkflowRunRecord,\n type WorkflowRunStatus,\n} from '#core/workflow-run.js';\nimport {\n toWorkflowRunAttempt,\n toWorkflowRunDetail,\n toWorkflowRunListPage,\n toWorkflowRunRecord,\n} from './workflow-run-mapper.js';\n\nexport interface WorkflowRunFilters {\n status?: WorkflowRunStatus | undefined;\n definitionId?: string | undefined;\n triggerSource?: string | undefined;\n createdFrom?: string | undefined;\n createdTo?: string | undefined;\n}\n\nexport const workflowRunsQueryKeys = {\n all: ['workflow-runs'] as const,\n lists: (projectId: string) => [...workflowRunsQueryKeys.all, 'list', projectId] as const,\n list: (projectId: string, filters: WorkflowRunFilters) =>\n [...workflowRunsQueryKeys.lists(projectId), normalizeFilters(filters)] as const,\n detail: (workflowRunId: string, runAttempt?: number | undefined) =>\n [...workflowRunsQueryKeys.all, 'detail', workflowRunId, runAttempt ?? null] as const,\n attempts: (workflowRunId: string) =>\n [...workflowRunsQueryKeys.all, 'attempts', workflowRunId] as const,\n};\n\ntype WorkflowRunsListQueryKey =\n | ReturnType<typeof workflowRunsQueryKeys.list>\n | readonly ['workflow-runs', 'list'];\ntype WorkflowRunDetailQueryKey =\n | ReturnType<typeof workflowRunsQueryKeys.detail>\n | readonly ['workflow-runs', 'detail'];\ntype WorkflowRunAttemptsQueryKey =\n | ReturnType<typeof workflowRunsQueryKeys.attempts>\n | readonly ['workflow-runs', 'attempts'];\ntype WorkflowRunsInfiniteQueryOptions = UseInfiniteQueryOptions<\n WorkflowRunListPage,\n Error,\n InfiniteData<WorkflowRunListPage, string | undefined>,\n WorkflowRunsListQueryKey,\n string | undefined\n>;\ntype WorkflowRunDetailQueryOptions = UseQueryOptions<\n WorkflowRunDetail,\n Error,\n WorkflowRunDetail,\n WorkflowRunDetailQueryKey\n>;\ntype WorkflowRunAttemptsQueryOptions = UseQueryOptions<\n WorkflowRunAttempt[],\n Error,\n WorkflowRunAttempt[],\n WorkflowRunAttemptsQueryKey\n>;\n\nfunction normalizeFilters(filters: WorkflowRunFilters) {\n return {\n status: filters.status ?? null,\n definitionId: filters.definitionId ?? null,\n triggerSource: filters.triggerSource ?? null,\n createdFrom: filters.createdFrom ?? null,\n createdTo: filters.createdTo ?? null,\n };\n}\n\nfunction appendFilters(params: URLSearchParams, filters: WorkflowRunFilters) {\n if (filters.status) params.set('status', filters.status);\n if (filters.definitionId) params.set('definition_id', filters.definitionId);\n if (filters.triggerSource) params.set('trigger_source', filters.triggerSource);\n if (filters.createdFrom) params.set('created_from', filters.createdFrom);\n if (filters.createdTo) params.set('created_to', filters.createdTo);\n}\n\nasync function listWorkflowRuns({\n projectId,\n filters,\n limit = 50,\n cursor,\n signal,\n}: {\n projectId: string;\n filters: WorkflowRunFilters;\n limit?: number;\n cursor?: string | undefined;\n signal?: AbortSignal;\n}): Promise<WorkflowRunListPage> {\n const params = new URLSearchParams({project_id: projectId, limit: String(limit)});\n if (cursor) params.set('cursor', cursor);\n appendFilters(params, filters);\n const response = await checkedApiRequest(\n workflowRunListResponseSchema,\n `/workflows/runs?${params.toString()}`,\n {signal},\n );\n return toWorkflowRunListPage(response);\n}\n\n/**\n * Fire the manual trigger of a workflow definition.\n *\n * The server resolves the manual subscription by definition id (workflows\n * may declare at most one manual trigger). `inputs` are forwarded to the\n * run when provided.\n */\nexport async function fireManualWorkflow({\n definitionId,\n inputs,\n}: {\n definitionId: string;\n inputs?: Record<string, unknown>;\n}): Promise<ManualWorkflowLaunch> {\n const response = await checkedApiRequest(\n manualWorkflowResponseSchema,\n `/workflow-definitions/${definitionId}/fire-manual`,\n {\n method: 'POST',\n body: inputs ? {inputs} : {},\n },\n );\n return {workflowRunId: response.workflow_run_id};\n}\n\nconst ACTIVE_POLL_MS = 4_000;\nconst IDLE_POLL_MS = 30_000;\n\ntype RunListInfinite = InfiniteData<WorkflowRunListPage, string | undefined>;\n\nexport function useWorkflowRunsInfiniteQuery(\n projectId: string | undefined,\n filters: WorkflowRunFilters,\n limit = 50,\n) {\n return useInfiniteQuery(workflowRunsInfiniteQueryOptions(projectId, filters, limit));\n}\n\nexport function workflowRunsInfiniteQueryOptions(\n projectId: string | undefined,\n filters: WorkflowRunFilters,\n limit = 50,\n): WorkflowRunsInfiniteQueryOptions {\n // Polling is owned by react-query, not the page. Polling fast (4s) while\n // any non-terminal run is visible covers state transitions; polling slow\n // (30s) when idle covers brand-new external runs (webhook/schedule\n // triggers) without leaving the list stale.\n //\n // We disable polling once the user has loaded more than one page. With\n // cursor pagination the cursor that bounds page 1 was computed from\n // page 0's last row; if a refetch shifts that boundary, a small range\n // of rows can drop into a between-pages gap. Users who scrolled into\n // history opted into \"reading mode\": pause until they refocus, filter,\n // or scroll back.\n return infiniteQueryOptions({\n queryKey: projectId\n ? workflowRunsQueryKeys.list(projectId, filters)\n : ([...workflowRunsQueryKeys.all, 'list'] as const),\n enabled: Boolean(projectId),\n initialPageParam: undefined as string | undefined,\n queryFn: ({pageParam, signal}) =>\n listWorkflowRuns({projectId: projectId ?? '', filters, limit, cursor: pageParam, signal}),\n getNextPageParam: (lastPage) => lastPage.nextCursor ?? undefined,\n placeholderData: keepPreviousData,\n staleTime: 2_000,\n refetchOnWindowFocus: true,\n refetchInterval: (query) => {\n const data = query.state.data;\n if (!data || data.pages.length > 1) return false;\n const hasActive = data.pages.some((page) =>\n page.runs.some((run) => !isWorkflowRunTerminal(run.status)),\n );\n return hasActive ? ACTIVE_POLL_MS : IDLE_POLL_MS;\n },\n refetchIntervalInBackground: false,\n });\n}\n\nasync function getWorkflowRun({\n workflowRunId,\n runAttempt,\n signal,\n}: {\n workflowRunId: string;\n runAttempt?: number | undefined;\n signal?: AbortSignal;\n}): Promise<WorkflowRunDetail> {\n const params = new URLSearchParams();\n if (runAttempt) params.set('attempt', String(runAttempt));\n const query = params.size > 0 ? `?${params.toString()}` : '';\n return toWorkflowRunDetail(\n await checkedApiRequest(\n workflowRunDetailResponseSchema,\n `/workflows/runs/${workflowRunId}${query}`,\n {\n signal,\n },\n ),\n );\n}\n\nasync function getWorkflowRunAttempts({\n workflowRunId,\n signal,\n}: {\n workflowRunId: string;\n signal?: AbortSignal;\n}): Promise<WorkflowRunAttempt[]> {\n const response = await checkedApiRequest(\n workflowRunAttemptsResponseSchema,\n `/workflows/runs/${workflowRunId}/attempts`,\n {\n signal,\n },\n );\n return response.attempts.map(toWorkflowRunAttempt);\n}\n\nasync function cancelWorkflowRun({\n workflowRunId,\n}: {\n workflowRunId: string;\n}): Promise<WorkflowRunRecord> {\n return toWorkflowRunRecord(\n await checkedApiRequest(workflowRunDtoSchema, `/workflows/runs/${workflowRunId}/cancel`, {\n method: 'POST',\n }),\n );\n}\n\nexport async function rerunWorkflowRun({\n workflowRunId,\n mode,\n}: {\n workflowRunId: string;\n mode: WorkflowRunRerunModeDto;\n}): Promise<WorkflowRunRecord> {\n return toWorkflowRunRecord(\n await checkedApiRequest(workflowRunResponseSchema, `/workflows/runs/${workflowRunId}/rerun`, {\n method: 'POST',\n body: {mode} satisfies RerunWorkflowRunBodyDto,\n }),\n );\n}\n\nconst manualWorkflowResponseSchema: StandardSchema<unknown, {workflow_run_id: string}> = {\n '~standard': {\n version: 1,\n vendor: 'client-workflows',\n validate: (value) => {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'workflow_run_id' in value &&\n typeof value.workflow_run_id === 'string'\n )\n return {value: {workflow_run_id: value.workflow_run_id}};\n return {issues: [{message: 'Expected workflow_run_id.'}]};\n },\n },\n};\n\nexport function useRerunWorkflowRunMutation(projectId: string) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: rerunWorkflowRun,\n onSuccess: async (_run, variables) => {\n await Promise.all([\n queryClient.invalidateQueries({queryKey: workflowRunsQueryKeys.lists(projectId)}),\n queryClient.invalidateQueries({\n queryKey: workflowRunsQueryKeys.detail(variables.workflowRunId),\n }),\n queryClient.invalidateQueries({\n queryKey: workflowRunsQueryKeys.attempts(variables.workflowRunId),\n }),\n ]);\n },\n });\n}\n\nfunction filtersAcceptManualPendingRun(\n filters: WorkflowRunFilters,\n definitionId: string,\n now: Date,\n): boolean {\n if (filters.status && filters.status !== 'pending') return false;\n if (filters.definitionId && filters.definitionId !== definitionId) return false;\n if (filters.triggerSource && filters.triggerSource !== 'manual') return false;\n if (filters.createdFrom && Date.parse(filters.createdFrom) > now.getTime()) return false;\n if (filters.createdTo && Date.parse(filters.createdTo) < now.getTime()) return false;\n return true;\n}\n\nfunction buildTempRun({\n projectId,\n definitionId,\n name,\n createdAt,\n}: {\n projectId: string;\n definitionId: string;\n name: string;\n createdAt: string;\n}): WorkflowRunListItem {\n const id = `temp-${cryptoRandomId()}`;\n return {\n id,\n projectId,\n definitionId,\n number: null,\n name,\n workflowName: name,\n status: 'pending',\n currentAttempt: 1,\n latestAttempt: 1,\n triggerProvider: null,\n triggerSource: 'manual',\n triggerEvent: 'fire',\n triggerPayload: {source: 'manual', event: 'fire'},\n triggerDisplayLabel: 'fire',\n triggerLabel: 'manual · fire',\n triggerReference: null,\n inputs: null,\n sourceSnapshot: null,\n createdAt,\n updatedAt: createdAt,\n isTemporary: true,\n // The optimistic row genuinely has no jobs yet: the server has not planned the graph.\n jobs: {preview: [], statusCounts: [], hasStartedJobExecution: false, total: 0},\n runAttempt: new WorkflowRunAttemptSummary({\n workflowRunId: id,\n attempt: 1,\n status: 'pending',\n createdAt,\n startedAt: null,\n finishedAt: null,\n }),\n };\n}\n\nfunction cryptoRandomId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n\nexport interface FireManualWorkflowVariables {\n projectId: string;\n definitionId: string;\n inputs?: Record<string, unknown>;\n}\n\nexport function useFireManualWorkflowMutation() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: (variables: FireManualWorkflowVariables) =>\n fireManualWorkflow(\n variables.inputs\n ? {definitionId: variables.definitionId, inputs: variables.inputs}\n : {definitionId: variables.definitionId},\n ),\n onMutate: (variables) => {\n const definitionName = lookupDefinitionName(\n queryClient,\n variables.projectId,\n variables.definitionId,\n );\n const createdAt = new Date().toISOString();\n const tempRun = buildTempRun({\n projectId: variables.projectId,\n definitionId: variables.definitionId,\n name: definitionName ?? 'New run',\n createdAt,\n });\n\n const listsKey = workflowRunsQueryKeys.lists(variables.projectId);\n const touchedQueryKeys: Array<readonly unknown[]> = [];\n\n const entries = queryClient.getQueriesData<RunListInfinite>({queryKey: listsKey});\n const now = new Date(createdAt);\n for (const [queryKey] of entries) {\n const filters = readFiltersFromKey(queryKey);\n if (!filters) continue;\n if (!filtersAcceptManualPendingRun(filters, variables.definitionId, now)) continue;\n\n touchedQueryKeys.push(queryKey);\n queryClient.setQueryData<RunListInfinite>(queryKey, (current) => {\n if (!current || current.pages.length === 0) return current;\n const firstPage = current.pages[0];\n if (!firstPage) return current;\n const nextFirstPage: WorkflowRunListPage = {\n ...firstPage,\n runs: [tempRun, ...firstPage.runs],\n filteredTotalCount:\n firstPage.filteredTotalCount != null ? firstPage.filteredTotalCount + 1 : null,\n };\n return {...current, pages: [nextFirstPage, ...current.pages.slice(1)]};\n });\n }\n\n return {tempWorkflowRunId: tempRun.id, touchedQueryKeys};\n },\n onError: (_error, _variables, context) => {\n if (!context) return;\n for (const queryKey of context.touchedQueryKeys) {\n queryClient.setQueryData<RunListInfinite>(queryKey, (current) => {\n if (!current) return current;\n let removedCount = 0;\n const pages = current.pages.map((page) => {\n const runs = page.runs.filter((run) => {\n if (run.id !== context.tempWorkflowRunId) return true;\n removedCount += 1;\n return false;\n });\n if (runs.length === page.runs.length) return page;\n return {\n ...page,\n runs,\n filteredTotalCount:\n page.filteredTotalCount != null\n ? Math.max(0, page.filteredTotalCount - removedCount)\n : null,\n };\n });\n if (removedCount === 0) return current;\n return {...current, pages};\n });\n }\n },\n onSuccess: (_data, variables) => {\n void queryClient.invalidateQueries({\n queryKey: workflowRunsQueryKeys.lists(variables.projectId),\n });\n },\n });\n}\n\nfunction readFiltersFromKey(queryKey: readonly unknown[]): WorkflowRunFilters | null {\n if (queryKey.length < 4) return null;\n const normalized = queryKey[3];\n if (!normalized || typeof normalized !== 'object') return null;\n const obj = normalized as Record<string, unknown>;\n return {\n status: (obj.status as WorkflowRunStatus | null) ?? undefined,\n definitionId: (obj.definitionId as string | null) ?? undefined,\n triggerSource: (obj.triggerSource as string | null) ?? undefined,\n createdFrom: (obj.createdFrom as string | null) ?? undefined,\n createdTo: (obj.createdTo as string | null) ?? undefined,\n };\n}\n\nfunction lookupDefinitionName(\n queryClient: ReturnType<typeof useQueryClient>,\n projectId: string,\n definitionId: string,\n): string | undefined {\n const entries = queryClient.getQueriesData<\n InfiniteData<{definitions: Array<{id: string; name: string}>}>\n >({queryKey: ['definitions', 'list', projectId]});\n for (const [, data] of entries) {\n if (!data) continue;\n for (const page of data.pages) {\n const match = page.definitions.find((d) => d.id === definitionId);\n if (match) return match.name;\n }\n }\n return undefined;\n}\n\nexport function useWorkflowRunQuery(workflowRunId: string | undefined) {\n return useWorkflowRunAttemptQuery({workflowRunId, runAttempt: undefined});\n}\n\nexport function useWorkflowRunAttemptQuery({\n workflowRunId,\n runAttempt,\n enabled = true,\n}: {\n workflowRunId: string | undefined;\n runAttempt?: number | undefined;\n enabled?: boolean | undefined;\n}) {\n return useQuery(workflowRunQueryOptions({workflowRunId, runAttempt, enabled}));\n}\n\nexport function workflowRunQueryOptions({\n workflowRunId,\n runAttempt,\n enabled = true,\n}: {\n workflowRunId: string | undefined;\n runAttempt?: number | undefined;\n enabled?: boolean | undefined;\n}): WorkflowRunDetailQueryOptions {\n // Poll a non-terminal run so the open run detail stays live (same cadence as the run\n // list); stop once the run is terminal.\n return queryOptions({\n queryKey: workflowRunId\n ? workflowRunsQueryKeys.detail(workflowRunId, runAttempt)\n : ([...workflowRunsQueryKeys.all, 'detail'] as const),\n enabled: Boolean(workflowRunId) && enabled,\n queryFn: ({signal}) => getWorkflowRun({workflowRunId: workflowRunId ?? '', runAttempt, signal}),\n staleTime: 2_000,\n refetchOnWindowFocus: true,\n refetchInterval: (query) => {\n const status: WorkflowRunDetail['runAttempt']['status'] | undefined =\n query.state.data?.runAttempt.status;\n if (!status) return false;\n return isWorkflowRunTerminal(status) ? false : ACTIVE_POLL_MS;\n },\n refetchIntervalInBackground: false,\n });\n}\n\nexport function useWorkflowRunAttemptsQuery({\n workflowRunId,\n enabled,\n}: {\n workflowRunId: string | undefined;\n enabled: boolean;\n}) {\n return useQuery(workflowRunAttemptsQueryOptions({workflowRunId, enabled}));\n}\n\nexport function workflowRunAttemptsQueryOptions({\n workflowRunId,\n enabled,\n}: {\n workflowRunId: string | undefined;\n enabled: boolean;\n}): WorkflowRunAttemptsQueryOptions {\n return queryOptions({\n queryKey: workflowRunId\n ? workflowRunsQueryKeys.attempts(workflowRunId)\n : ([...workflowRunsQueryKeys.all, 'attempts'] as const),\n enabled: Boolean(workflowRunId) && enabled,\n queryFn: ({signal}) => getWorkflowRunAttempts({workflowRunId: workflowRunId ?? '', signal}),\n staleTime: 0,\n refetchOnMount: true,\n refetchOnWindowFocus: false,\n });\n}\n\nexport function useCancelWorkflowRunMutation(run: WorkflowRun | undefined) {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (): Promise<WorkflowRunRecord> => {\n if (!run) throw new Error('Workflow run is not loaded');\n return await cancelWorkflowRun({workflowRunId: run.id});\n },\n onSuccess: async () => {\n if (!run) return;\n await Promise.all([\n queryClient.invalidateQueries({queryKey: workflowRunsQueryKeys.detail(run.id)}),\n queryClient.invalidateQueries({queryKey: workflowRunsQueryKeys.lists(run.projectId)}),\n queryClient.invalidateQueries({queryKey: workflowRunsQueryKeys.attempts(run.id)}),\n ]);\n },\n });\n}\n"],"names":["workflowRunAttemptsResponseSchema","workflowRunDetailResponseSchema","workflowRunDtoSchema","workflowRunListResponseSchema","workflowRunResponseSchema","checkedApiRequest","infiniteQueryOptions","keepPreviousData","queryOptions","useInfiniteQuery","useMutation","useQuery","useQueryClient","isWorkflowRunTerminal","WorkflowRunAttemptSummary","toWorkflowRunAttempt","toWorkflowRunDetail","toWorkflowRunListPage","toWorkflowRunRecord","workflowRunsQueryKeys","all","lists","projectId","list","filters","normalizeFilters","detail","workflowRunId","runAttempt","attempts","status","definitionId","triggerSource","createdFrom","createdTo","appendFilters","params","set","listWorkflowRuns","limit","cursor","signal","URLSearchParams","project_id","String","response","toString","fireManualWorkflow","inputs","manualWorkflowResponseSchema","method","body","workflow_run_id","ACTIVE_POLL_MS","IDLE_POLL_MS","useWorkflowRunsInfiniteQuery","workflowRunsInfiniteQueryOptions","queryKey","enabled","Boolean","initialPageParam","undefined","queryFn","pageParam","getNextPageParam","lastPage","nextCursor","placeholderData","staleTime","refetchOnWindowFocus","refetchInterval","query","data","state","pages","length","hasActive","some","page","runs","run","refetchIntervalInBackground","getWorkflowRun","size","getWorkflowRunAttempts","map","cancelWorkflowRun","rerunWorkflowRun","mode","version","vendor","validate","value","issues","message","useRerunWorkflowRunMutation","queryClient","mutationFn","onSuccess","_run","variables","Promise","invalidateQueries","filtersAcceptManualPendingRun","now","Date","parse","getTime","buildTempRun","name","createdAt","id","cryptoRandomId","number","workflowName","currentAttempt","latestAttempt","triggerProvider","triggerEvent","triggerPayload","source","event","triggerDisplayLabel","triggerLabel","triggerReference","sourceSnapshot","updatedAt","isTemporary","jobs","preview","statusCounts","hasStartedJobExecution","total","attempt","startedAt","finishedAt","crypto","randomUUID","Math","random","slice","useFireManualWorkflowMutation","onMutate","definitionName","lookupDefinitionName","toISOString","tempRun","listsKey","touchedQueryKeys","entries","getQueriesData","readFiltersFromKey","push","setQueryData","current","firstPage","nextFirstPage","filteredTotalCount","tempWorkflowRunId","onError","_error","_variables","context","removedCount","filter","max","_data","normalized","obj","match","definitions","find","d","useWorkflowRunQuery","useWorkflowRunAttemptQuery","workflowRunQueryOptions","useWorkflowRunAttemptsQuery","workflowRunAttemptsQueryOptions","refetchOnMount","useCancelWorkflowRunMutation","Error"],"mappings":"AAAA,SAGEA,iCAAiC,EACjCC,+BAA+B,EAC/BC,oBAAoB,EACpBC,6BAA6B,EAC7BC,yBAAyB,QACpB,6BAA6B;AACpC,SAAQC,iBAAiB,QAA4B,sBAAsB;AAC3E,SAEEC,oBAAoB,EACpBC,gBAAgB,EAChBC,YAAY,EAGZC,gBAAgB,EAChBC,WAAW,EACXC,QAAQ,EACRC,cAAc,QACT,wBAAwB;AAC/B,SACEC,qBAAqB,EAIrBC,yBAAyB,QAMpB,wBAAwB;AAC/B,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,qBAAqB,EACrBC,mBAAmB,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