@everysk/apps-sdk 0.2.0 → 0.3.0-beta-20261016180126
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.
- package/README.md +298 -12
- package/dist/EveryskApp.d.ts +34 -2
- package/dist/EveryskApp.d.ts.map +1 -1
- package/dist/EveryskApp.js +35 -2
- package/dist/EveryskApp.js.map +1 -1
- package/dist/agGrid/handleRowsScrollEnd.d.ts +53 -0
- package/dist/agGrid/handleRowsScrollEnd.d.ts.map +1 -0
- package/dist/agGrid/handleRowsScrollEnd.js +47 -0
- package/dist/agGrid/handleRowsScrollEnd.js.map +1 -0
- package/dist/agGrid/index.d.ts +2 -0
- package/dist/agGrid/index.d.ts.map +1 -1
- package/dist/agGrid/index.js +2 -1
- package/dist/api/datastore.d.ts +10 -8
- package/dist/api/datastore.d.ts.map +1 -1
- package/dist/api/datastore.js +24 -55
- package/dist/api/datastore.js.map +1 -1
- package/dist/api/entityQuery.d.ts +46 -41
- package/dist/api/entityQuery.d.ts.map +1 -1
- package/dist/api/entityQuery.js +55 -14
- package/dist/api/entityQuery.js.map +1 -1
- package/dist/api/file.d.ts +26 -9
- package/dist/api/file.d.ts.map +1 -1
- package/dist/api/file.js +45 -55
- package/dist/api/file.js.map +1 -1
- package/dist/api/portfolio.d.ts +11 -8
- package/dist/api/portfolio.d.ts.map +1 -1
- package/dist/api/portfolio.js +24 -55
- package/dist/api/portfolio.js.map +1 -1
- package/dist/api/profile.d.ts +3 -2
- package/dist/api/profile.d.ts.map +1 -1
- package/dist/api/profile.js +4 -9
- package/dist/api/profile.js.map +1 -1
- package/dist/api/request.d.ts +106 -0
- package/dist/api/request.d.ts.map +1 -0
- package/dist/api/request.js +132 -0
- package/dist/api/request.js.map +1 -0
- package/dist/api/websocketsConfig.d.ts +7 -2
- package/dist/api/websocketsConfig.d.ts.map +1 -1
- package/dist/api/websocketsConfig.js +2 -10
- package/dist/api/websocketsConfig.js.map +1 -1
- package/dist/api/workflow.d.ts +84 -89
- package/dist/api/workflow.d.ts.map +1 -1
- package/dist/api/workflow.js +121 -208
- package/dist/api/workflow.js.map +1 -1
- package/dist/api/workspace.d.ts +18 -8
- package/dist/api/workspace.d.ts.map +1 -1
- package/dist/api/workspace.js +21 -26
- package/dist/api/workspace.js.map +1 -1
- package/dist/components/ui/Footer/index.d.ts.map +1 -1
- package/dist/components/ui/Footer/index.js.map +1 -1
- package/dist/components/ui/GlobalLoading/index.d.ts.map +1 -1
- package/dist/components/ui/GlobalLoading/index.js.map +1 -1
- package/dist/components/ui/PageContainer/index.d.ts +1 -1
- package/dist/components/ui/PageContainer/index.d.ts.map +1 -1
- package/dist/components/ui/PageContainer/index.js.map +1 -1
- package/dist/components/ui/Toolbar/index.d.ts +40 -3
- package/dist/components/ui/Toolbar/index.d.ts.map +1 -1
- package/dist/components/ui/Toolbar/index.js +42 -15
- package/dist/components/ui/Toolbar/index.js.map +1 -1
- package/dist/contexts/appAlertContext/provider.js.map +1 -1
- package/dist/contexts/appAlertContext/types.d.ts.map +1 -1
- package/dist/contexts/appConfigContext/index.d.ts.map +1 -1
- package/dist/contexts/appConfigContext/index.js.map +1 -1
- package/dist/contexts/appConfigContext/provider.d.ts.map +1 -1
- package/dist/contexts/appConfigContext/provider.js.map +1 -1
- package/dist/contexts/webSocketContext/handler.d.ts +3 -2
- package/dist/contexts/webSocketContext/handler.d.ts.map +1 -1
- package/dist/contexts/webSocketContext/handler.js.map +1 -1
- package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts +1 -1
- package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js +1 -1
- package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js.map +1 -1
- package/dist/contexts/webSocketContext/provider.d.ts +6 -3
- package/dist/contexts/webSocketContext/provider.d.ts.map +1 -1
- package/dist/contexts/webSocketContext/provider.js +42 -7
- package/dist/contexts/webSocketContext/provider.js.map +1 -1
- package/dist/contexts/webSocketContext/types.d.ts +7 -5
- package/dist/contexts/webSocketContext/types.d.ts.map +1 -1
- package/dist/file/index.d.ts +2 -0
- package/dist/file/index.d.ts.map +1 -1
- package/dist/hooks/datastore/useDatastoreMutations.d.ts +4 -4
- package/dist/hooks/datastore/useDatastoreMutations.d.ts.map +1 -1
- package/dist/hooks/datastore/useDatastoreMutations.js +17 -55
- package/dist/hooks/datastore/useDatastoreMutations.js.map +1 -1
- package/dist/hooks/datastore/useFetchDatastore.d.ts +30 -41
- package/dist/hooks/datastore/useFetchDatastore.d.ts.map +1 -1
- package/dist/hooks/datastore/useFetchDatastore.js +25 -59
- package/dist/hooks/datastore/useFetchDatastore.js.map +1 -1
- package/dist/hooks/datastore/useFetchDatastores.d.ts +47 -52
- package/dist/hooks/datastore/useFetchDatastores.d.ts.map +1 -1
- package/dist/hooks/datastore/useFetchDatastores.js +55 -70
- package/dist/hooks/datastore/useFetchDatastores.js.map +1 -1
- package/dist/hooks/file/fileData.d.ts +17 -0
- package/dist/hooks/file/fileData.d.ts.map +1 -0
- package/dist/hooks/file/fileData.js +10 -0
- package/dist/hooks/file/fileData.js.map +1 -0
- package/dist/hooks/file/useFetchFile.d.ts +38 -58
- package/dist/hooks/file/useFetchFile.d.ts.map +1 -1
- package/dist/hooks/file/useFetchFile.js +26 -66
- package/dist/hooks/file/useFetchFile.js.map +1 -1
- package/dist/hooks/file/useFetchFiles.d.ts +18 -52
- package/dist/hooks/file/useFetchFiles.d.ts.map +1 -1
- package/dist/hooks/file/useFetchFiles.js +53 -69
- package/dist/hooks/file/useFetchFiles.js.map +1 -1
- package/dist/hooks/file/useFileMutations.d.ts +9 -8
- package/dist/hooks/file/useFileMutations.d.ts.map +1 -1
- package/dist/hooks/file/useFileMutations.js +23 -60
- package/dist/hooks/file/useFileMutations.js.map +1 -1
- package/dist/hooks/portfolio/useFetchPortfolio.d.ts +16 -50
- package/dist/hooks/portfolio/useFetchPortfolio.d.ts.map +1 -1
- package/dist/hooks/portfolio/useFetchPortfolio.js +15 -63
- package/dist/hooks/portfolio/useFetchPortfolio.js.map +1 -1
- package/dist/hooks/portfolio/useFetchPortfolios.d.ts +13 -52
- package/dist/hooks/portfolio/useFetchPortfolios.d.ts.map +1 -1
- package/dist/hooks/portfolio/useFetchPortfolios.js +29 -71
- package/dist/hooks/portfolio/useFetchPortfolios.js.map +1 -1
- package/dist/hooks/portfolio/usePortfolioMutations.d.ts +8 -8
- package/dist/hooks/portfolio/usePortfolioMutations.d.ts.map +1 -1
- package/dist/hooks/portfolio/usePortfolioMutations.js +20 -58
- package/dist/hooks/portfolio/usePortfolioMutations.js.map +1 -1
- package/dist/hooks/profile/useFetchProfile.d.ts +18 -44
- package/dist/hooks/profile/useFetchProfile.d.ts.map +1 -1
- package/dist/hooks/profile/useFetchProfile.js +16 -48
- package/dist/hooks/profile/useFetchProfile.js.map +1 -1
- package/dist/hooks/useAxios.js.map +1 -1
- package/dist/hooks/useEntityInfiniteQuery.d.ts +88 -0
- package/dist/hooks/useEntityInfiniteQuery.d.ts.map +1 -0
- package/dist/hooks/useEntityInfiniteQuery.js +111 -0
- package/dist/hooks/useEntityInfiniteQuery.js.map +1 -0
- package/dist/hooks/useEntityMutation.d.ts +47 -0
- package/dist/hooks/useEntityMutation.d.ts.map +1 -0
- package/dist/hooks/useEntityMutation.js +58 -0
- package/dist/hooks/useEntityMutation.js.map +1 -0
- package/dist/hooks/useEntityQuery.d.ts +68 -0
- package/dist/hooks/useEntityQuery.d.ts.map +1 -0
- package/dist/hooks/useEntityQuery.js +75 -0
- package/dist/hooks/useEntityQuery.js.map +1 -0
- package/dist/hooks/workflow/useFetchWorkerExecution.d.ts +17 -34
- package/dist/hooks/workflow/useFetchWorkerExecution.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkerExecution.js +16 -46
- package/dist/hooks/workflow/useFetchWorkerExecution.js.map +1 -1
- package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts +179 -41
- package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkerExecutions.js +29 -62
- package/dist/hooks/workflow/useFetchWorkerExecutions.js.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflow.d.ts +16 -35
- package/dist/hooks/workflow/useFetchWorkflow.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflow.js +15 -48
- package/dist/hooks/workflow/useFetchWorkflow.js.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts +17 -34
- package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflowExecution.js +16 -46
- package/dist/hooks/workflow/useFetchWorkflowExecution.js.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts +22 -36
- package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflowExecutions.js +43 -56
- package/dist/hooks/workflow/useFetchWorkflowExecutions.js.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflows.d.ts +20 -37
- package/dist/hooks/workflow/useFetchWorkflows.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflows.js +32 -47
- package/dist/hooks/workflow/useFetchWorkflows.js.map +1 -1
- package/dist/hooks/workflow/useRunWorkflow.d.ts +21 -16
- package/dist/hooks/workflow/useRunWorkflow.d.ts.map +1 -1
- package/dist/hooks/workflow/useRunWorkflow.js +66 -29
- package/dist/hooks/workflow/useRunWorkflow.js.map +1 -1
- package/dist/hooks/workflow/useTriggerWorkflow.d.ts +20 -0
- package/dist/hooks/workflow/useTriggerWorkflow.d.ts.map +1 -0
- package/dist/hooks/workflow/useTriggerWorkflow.js +32 -0
- package/dist/hooks/workflow/useTriggerWorkflow.js.map +1 -0
- package/dist/hooks/workspace/useFetchWorkspace.d.ts +19 -34
- package/dist/hooks/workspace/useFetchWorkspace.d.ts.map +1 -1
- package/dist/hooks/workspace/useFetchWorkspace.js +16 -46
- package/dist/hooks/workspace/useFetchWorkspace.js.map +1 -1
- package/dist/hooks/workspace/useFetchWorkspaces.d.ts +17 -37
- package/dist/hooks/workspace/useFetchWorkspaces.d.ts.map +1 -1
- package/dist/hooks/workspace/useFetchWorkspaces.js +25 -47
- package/dist/hooks/workspace/useFetchWorkspaces.js.map +1 -1
- package/dist/index.d.ts +13 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -11
- package/dist/lib/abort.d.ts +58 -0
- package/dist/lib/abort.d.ts.map +1 -0
- package/dist/lib/abort.js +112 -0
- package/dist/lib/abort.js.map +1 -0
- package/dist/lib/datastoreTable.d.ts +59 -54
- package/dist/lib/datastoreTable.d.ts.map +1 -1
- package/dist/lib/datastoreTable.js +58 -62
- package/dist/lib/datastoreTable.js.map +1 -1
- package/dist/lib/file.d.ts +34 -0
- package/dist/lib/file.d.ts.map +1 -0
- package/dist/lib/file.js +63 -0
- package/dist/lib/file.js.map +1 -0
- package/dist/lib/queryClient.d.ts.map +1 -1
- package/dist/lib/queryClient.js.map +1 -1
- package/dist/lib/workflowRun.d.ts +91 -0
- package/dist/lib/workflowRun.d.ts.map +1 -0
- package/dist/lib/workflowRun.js +224 -0
- package/dist/lib/workflowRun.js.map +1 -0
- package/dist/socket/index.d.ts +1 -3
- package/dist/socket/index.d.ts.map +1 -1
- package/dist/socket/index.js +3 -5
- package/dist/test/mocks/index.d.ts +1 -1
- package/dist/test/mocks/index.d.ts.map +1 -1
- package/dist/test/renderWithProviders.d.ts +2 -2
- package/dist/test/renderWithProviders.d.ts.map +1 -1
- package/dist/test/renderWithProviders.js.map +1 -1
- package/dist/test/setup.js.map +1 -1
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/overrides/index.d.ts +4 -2
- package/dist/theme/overrides/index.d.ts.map +1 -1
- package/dist/theme/overrides/index.js +5 -3
- package/dist/theme/overrides/index.js.map +1 -1
- package/dist/theme/overrides/muiButton.d.ts +2 -2
- package/dist/theme/overrides/muiButton.js.map +1 -1
- package/dist/theme/overrides/muiCssBaseline.d.ts.map +1 -1
- package/dist/theme/overrides/muiCssBaseline.js.map +1 -1
- package/dist/theme/overrides/muiDatePicker.js.map +1 -1
- package/dist/theme/overrides/muiFormControl.js.map +1 -1
- package/dist/theme/overrides/muiIconButton.d.ts +2 -2
- package/dist/theme/overrides/muiIconButton.js.map +1 -1
- package/dist/theme/overrides/muiSelect.d.ts.map +1 -1
- package/dist/theme/overrides/muiSelect.js.map +1 -1
- package/dist/theme/overrides/muiSvgIcon.d.ts.map +1 -1
- package/dist/theme/overrides/muiSvgIcon.js.map +1 -1
- package/dist/theme/overrides/muiTextField.js.map +1 -1
- package/dist/theme/overrides/muiToggleButton.d.ts +2 -2
- package/dist/theme/overrides/muiToggleButton.js.map +1 -1
- package/dist/theme/overrides/muiToggleButtonGroup.d.ts +2 -2
- package/dist/theme/overrides/muiToggleButtonGroup.js.map +1 -1
- package/dist/theme/themes/DefaultDark.js +2 -2
- package/dist/theme/themes/DefaultDark.js.map +1 -1
- package/dist/theme/themes/DefaultLight.js +2 -2
- package/dist/theme/themes/DefaultLight.js.map +1 -1
- package/dist/theme/themes/EveryskDark.js +2 -2
- package/dist/theme/themes/EveryskDark.js.map +1 -1
- package/dist/theme/themes/EveryskLight.js +2 -2
- package/dist/theme/themes/EveryskLight.js.map +1 -1
- package/dist/theme/themes/MidnightEmber.js +2 -2
- package/dist/theme/themes/MidnightEmber.js.map +1 -1
- package/dist/types/anyRecord.d.ts.map +1 -1
- package/dist/types/datastore.d.ts +35 -5
- package/dist/types/datastore.d.ts.map +1 -1
- package/dist/types/datastoreDataFormat.d.ts +13 -0
- package/dist/types/datastoreDataFormat.d.ts.map +1 -0
- package/dist/types/entityQuery.d.ts +86 -16
- package/dist/types/entityQuery.d.ts.map +1 -1
- package/dist/types/file.d.ts +7 -3
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/portfolio.d.ts +1 -3
- package/dist/types/portfolio.d.ts.map +1 -1
- package/dist/types/profile.d.ts +0 -10
- package/dist/types/profile.d.ts.map +1 -1
- package/dist/types/workflow.d.ts +35 -6
- package/dist/types/workflow.d.ts.map +1 -1
- package/dist/types/workspace.d.ts +1 -2
- package/dist/types/workspace.d.ts.map +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/workflow/index.d.ts +2 -0
- package/dist/workflow/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/EveryskApp.tsx +53 -2
- package/src/agGrid/handleRowsScrollEnd.ts +71 -0
- package/src/agGrid/index.ts +5 -1
- package/src/api/datastore.ts +79 -107
- package/src/api/entityQuery.ts +86 -17
- package/src/api/file.ts +110 -103
- package/src/api/portfolio.ts +82 -125
- package/src/api/profile.ts +25 -18
- package/src/api/request.ts +168 -0
- package/src/api/websocketsConfig.ts +11 -19
- package/src/api/workflow.ts +232 -334
- package/src/api/workspace.ts +43 -43
- package/src/components/ui/Footer/index.tsx +8 -7
- package/src/components/ui/GlobalLoading/index.tsx +13 -3
- package/src/components/ui/PageContainer/index.tsx +9 -2
- package/src/components/ui/Toolbar/index.tsx +105 -30
- package/src/contexts/appAlertContext/provider.tsx +1 -1
- package/src/contexts/appAlertContext/types.ts +3 -3
- package/src/contexts/appConfigContext/index.tsx +1 -1
- package/src/contexts/appConfigContext/provider.tsx +1 -5
- package/src/contexts/webSocketContext/handler.ts +8 -2
- package/src/contexts/webSocketContext/hooks/useWebSocket/index.ts +1 -1
- package/src/contexts/webSocketContext/provider.tsx +64 -14
- package/src/contexts/webSocketContext/types.ts +7 -6
- package/src/file/index.ts +2 -0
- package/src/hooks/datastore/useDatastoreMutations.ts +19 -60
- package/src/hooks/datastore/useFetchDatastore.ts +45 -73
- package/src/hooks/datastore/useFetchDatastores.ts +106 -131
- package/src/hooks/file/fileData.ts +19 -0
- package/src/hooks/file/useFetchFile.ts +41 -76
- package/src/hooks/file/useFetchFiles.ts +92 -87
- package/src/hooks/file/useFileMutations.ts +23 -73
- package/src/hooks/portfolio/useFetchPortfolio.ts +26 -78
- package/src/hooks/portfolio/useFetchPortfolios.ts +50 -93
- package/src/hooks/portfolio/usePortfolioMutations.ts +22 -72
- package/src/hooks/profile/useFetchProfile.ts +24 -65
- package/src/hooks/useAxios.ts +5 -5
- package/src/hooks/useEntityInfiniteQuery.ts +193 -0
- package/src/hooks/useEntityMutation.ts +70 -0
- package/src/hooks/useEntityQuery.ts +117 -0
- package/src/hooks/workflow/useFetchWorkerExecution.ts +27 -56
- package/src/hooks/workflow/useFetchWorkerExecutions.ts +54 -79
- package/src/hooks/workflow/useFetchWorkflow.ts +24 -58
- package/src/hooks/workflow/useFetchWorkflowExecution.ts +27 -57
- package/src/hooks/workflow/useFetchWorkflowExecutions.ts +64 -73
- package/src/hooks/workflow/useFetchWorkflows.ts +48 -64
- package/src/hooks/workflow/useRunWorkflow.ts +82 -36
- package/src/hooks/workflow/useTriggerWorkflow.ts +36 -0
- package/src/hooks/workspace/useFetchWorkspace.ts +25 -58
- package/src/hooks/workspace/useFetchWorkspaces.ts +38 -69
- package/src/index.ts +34 -19
- package/src/lib/abort.ts +131 -0
- package/src/lib/datastoreTable.ts +127 -74
- package/src/lib/file.ts +67 -0
- package/src/lib/queryClient.ts +11 -13
- package/src/lib/workflowRun.ts +329 -0
- package/src/socket/index.ts +1 -3
- package/src/test/mocks/index.ts +1 -5
- package/src/test/renderWithProviders.tsx +8 -3
- package/src/test/setup.ts +16 -16
- package/src/theme/index.ts +1 -1
- package/src/theme/overrides/index.ts +5 -3
- package/src/theme/overrides/muiButton.ts +3 -3
- package/src/theme/overrides/muiCssBaseline.ts +11 -12
- package/src/theme/overrides/muiDatePicker.ts +2 -2
- package/src/theme/overrides/muiFormControl.ts +2 -2
- package/src/theme/overrides/muiIconButton.ts +3 -3
- package/src/theme/overrides/muiSelect.ts +2 -2
- package/src/theme/overrides/muiSvgIcon.ts +2 -2
- package/src/theme/overrides/muiTextField.ts +1 -1
- package/src/theme/overrides/muiToggleButton.ts +4 -4
- package/src/theme/overrides/muiToggleButtonGroup.ts +4 -4
- package/src/theme/themes/DefaultDark.ts +2 -2
- package/src/theme/themes/DefaultLight.ts +2 -2
- package/src/theme/themes/EveryskDark.ts +2 -2
- package/src/theme/themes/EveryskLight.ts +2 -2
- package/src/theme/themes/MidnightEmber.ts +15 -15
- package/src/types/anyRecord.ts +2 -2
- package/src/types/datastore.ts +56 -22
- package/src/types/datastoreDataFormat.ts +12 -0
- package/src/types/entityQuery.ts +122 -38
- package/src/types/file.ts +8 -6
- package/src/types/portfolio.ts +70 -74
- package/src/types/profile.ts +0 -11
- package/src/types/workflow.ts +38 -9
- package/src/types/workspace.ts +2 -4
- package/src/ui/index.ts +1 -1
- package/src/workflow/index.ts +5 -0
|
@@ -1,62 +1,47 @@
|
|
|
1
1
|
import { useAxios } from "../useAxios.js";
|
|
2
|
+
import { useEntityInfiniteQuery } from "../useEntityInfiniteQuery.js";
|
|
3
|
+
import { buildQueryKey, missingWorkspaceError } from "../../api/entityQuery.js";
|
|
2
4
|
import { listWorkflows } from "../../api/workflow.js";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
5
5
|
//#region src/hooks/workflow/useFetchWorkflows.ts
|
|
6
|
-
var defaultQueryOptions = {
|
|
7
|
-
refetchOnMount: "always",
|
|
8
|
-
staleTime: 0,
|
|
9
|
-
gcTime: 0
|
|
10
|
-
};
|
|
11
6
|
/**
|
|
12
7
|
* useFetchWorkflows
|
|
13
8
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
9
|
+
* Lists workflows with cursor pagination; `query.data` is every loaded page merged, or
|
|
10
|
+
* whatever `select` makes of it. `select` and `fetchAllPages` behave as in
|
|
11
|
+
* `useFetchDatastores`. This endpoint takes a workspace and a text `search` rather than
|
|
12
|
+
* filters.
|
|
16
13
|
*
|
|
17
|
-
*
|
|
14
|
+
* A missing workspace fails loudly, without a request, as in every other hook. This hook used to
|
|
15
|
+
* allow one, documented as listing the account's workflows; the API reads `main` instead.
|
|
18
16
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
22
|
-
* Current workspace name. Sent as a query param via the legacy method, required by some API configurations.
|
|
23
|
-
*
|
|
24
|
-
* @param {number} [pageSize=10]
|
|
25
|
-
* Number of workflows to fetch per page.
|
|
26
|
-
*
|
|
27
|
-
* @param {InfiniteOptions<Workflow[]>} [queryOptions]
|
|
28
|
-
* TanStack Query options passed through to `useInfiniteQuery`
|
|
29
|
-
* (e.g., enabled, staleTime, gcTime, etc.).
|
|
30
|
-
*
|
|
31
|
-
* @returns {{ query, queryKey }}
|
|
32
|
-
* - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)
|
|
33
|
-
* - `queryKey`: the cache key used by React Query
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* const { query } = useFetchWorkflows({ workspace: "ws-1", pageSize: 20 });
|
|
38
|
-
*
|
|
39
|
-
* // Flat list of all fetched workflows
|
|
40
|
-
* const workflows = query.data ?? [];
|
|
41
|
-
* ```
|
|
17
|
+
* @param {FetchWorkflowsProps} props - Workspace, search, page size, `select`,
|
|
18
|
+
* `fetchAllPages` and TanStack `queryOptions`.
|
|
19
|
+
* @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
|
|
42
20
|
*/
|
|
43
|
-
function useFetchWorkflows({ workspace, pageSize = 10, queryOptions }) {
|
|
21
|
+
function useFetchWorkflows({ workspace, search, pageSize = 10, select, fetchAllPages = false, queryOptions }) {
|
|
44
22
|
const { api } = useAxios();
|
|
45
|
-
const queryKey = [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
23
|
+
const queryKey = buildQueryKey([
|
|
24
|
+
"workflows",
|
|
25
|
+
workspace,
|
|
26
|
+
search ?? null
|
|
27
|
+
], [], {
|
|
28
|
+
pageSize,
|
|
29
|
+
fetchAllPages
|
|
30
|
+
});
|
|
50
31
|
return {
|
|
51
|
-
query:
|
|
32
|
+
query: useEntityInfiniteQuery({
|
|
52
33
|
queryKey,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
34
|
+
itemsKey: "workflows",
|
|
35
|
+
fetchPage: (pageToken, signal) => listWorkflows(api, {
|
|
36
|
+
workspace,
|
|
37
|
+
search,
|
|
38
|
+
pageSize,
|
|
39
|
+
pageToken: pageToken ?? void 0
|
|
40
|
+
}, signal),
|
|
41
|
+
select,
|
|
42
|
+
fetchAllPages,
|
|
43
|
+
configError: workspace ? void 0 : missingWorkspaceError("useFetchWorkflows"),
|
|
44
|
+
queryOptions
|
|
60
45
|
}),
|
|
61
46
|
queryKey
|
|
62
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchWorkflows.js","names":[],"sources":["../../../src/hooks/workflow/useFetchWorkflows.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useFetchWorkflows.js","names":[],"sources":["../../../src/hooks/workflow/useFetchWorkflows.ts"],"sourcesContent":["import { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityInfiniteQuery } from \"@/hooks/useEntityInfiniteQuery\";\nimport { listWorkflows } from \"@/api/workflow\";\nimport { buildQueryKey, missingWorkspaceError } from \"@/api/entityQuery\";\nimport type { Workflow, WorkflowListResponse } from \"@/types/workflow\";\nimport type { FetchEntitiesProps, ListCache } from \"@/types/entityQuery\";\n\n/** The query cache of `useFetchWorkflows`, for typing `setQueryData`. */\nexport type WorkflowsCache = ListCache<WorkflowListResponse>;\n\nexport type FetchWorkflowsProps<TData = Workflow[]> = FetchEntitiesProps<\n Workflow,\n TData,\n WorkflowListResponse\n> & {\n /** Workspace to list. Required: without one the API reads `main`, not the account. */\n workspace: string;\n /** A name prefix, an id, `#tag #tag` (every tag), or `&link_uid`. */\n search?: string;\n};\n\n/**\n * useFetchWorkflows\n *\n * Lists workflows with cursor pagination; `query.data` is every loaded page merged, or\n * whatever `select` makes of it. `select` and `fetchAllPages` behave as in\n * `useFetchDatastores`. This endpoint takes a workspace and a text `search` rather than\n * filters.\n *\n * A missing workspace fails loudly, without a request, as in every other hook. This hook used to\n * allow one, documented as listing the account's workflows; the API reads `main` instead.\n *\n * @param {FetchWorkflowsProps} props - Workspace, search, page size, `select`,\n * `fetchAllPages` and TanStack `queryOptions`.\n * @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.\n */\nexport function useFetchWorkflows<TData = Workflow[]>({\n workspace,\n search,\n pageSize = 10,\n select,\n fetchAllPages = false,\n queryOptions,\n}: FetchWorkflowsProps<TData>) {\n const { api } = useAxios();\n\n const queryKey = buildQueryKey([\"workflows\", workspace, search ?? null], [], {\n pageSize,\n fetchAllPages,\n });\n\n const query = useEntityInfiniteQuery<WorkflowListResponse, \"workflows\", TData>({\n queryKey,\n itemsKey: \"workflows\",\n fetchPage: (pageToken, signal) =>\n listWorkflows(\n api,\n { workspace, search, pageSize, pageToken: pageToken ?? undefined },\n signal,\n ),\n select,\n fetchAllPages,\n configError: workspace ? undefined : missingWorkspaceError(\"useFetchWorkflows\"),\n queryOptions,\n });\n\n return { query, queryKey };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,kBAAsC,EAClD,WACA,QACA,WAAW,IACX,QACA,gBAAgB,OAChB,gBAC2B;CAC3B,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,WAAW,cAAc;EAAC;EAAa;EAAW,UAAU;CAAI,GAAG,CAAC,GAAG;EACzE;EACA;CACJ,CAAC;CAiBD,OAAO;EAAE,OAfK,uBAAiE;GAC3E;GACA,UAAU;GACV,YAAY,WAAW,WACnB,cACI,KACA;IAAE;IAAW;IAAQ;IAAU,WAAW,aAAa,KAAA;GAAU,GACjE,MACJ;GACJ;GACA;GACA,aAAa,YAAY,KAAA,IAAY,sBAAsB,mBAAmB;GAC9E;EACJ,CAES;EAAO;CAAS;AAC7B"}
|
|
@@ -1,30 +1,35 @@
|
|
|
1
|
+
import { type WorkflowWaitOptions } from "../../lib/workflowRun.js";
|
|
1
2
|
import type { AnyRecord } from "../../types/anyRecord.d.ts";
|
|
2
|
-
import type {
|
|
3
|
+
import type { WorkflowResult } from "../../types/workflow.d.ts";
|
|
3
4
|
type RunWorkflowProps = {
|
|
4
5
|
id: string;
|
|
5
6
|
workspace: string;
|
|
6
7
|
parameters: AnyRecord;
|
|
7
|
-
|
|
8
|
+
/** How the run is waited for; see `WorkflowWaitOptions`. */
|
|
9
|
+
waitOptions?: WorkflowWaitOptions;
|
|
8
10
|
};
|
|
9
11
|
/**
|
|
10
12
|
* useRunWorkflow
|
|
11
13
|
*
|
|
12
|
-
* TanStack Query
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* A TanStack Query mutation that starts a workflow run, waits for it to end, then reads the
|
|
15
|
+
* Ender's worker execution. Resolves with `{ execution, workerExecution, result }` (`result` is
|
|
16
|
+
* `null` when the run has no output), and fails unless the run ended `SUCCEEDED`.
|
|
15
17
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* when the workflow produces no output. This is the replacement for the old synchronous flow.
|
|
18
|
+
* It waits over the websocket (see `runWorkflowToEnd`), not by polling: the backend announces
|
|
19
|
+
* each worker and the run's end on the app's channel, and the end itself is then read from the
|
|
20
|
+
* API. So it requires `WebSocketProvider`, and throws on render without it. To start a run
|
|
21
|
+
* without waiting, and without a websocket, use `useTriggerWorkflow`.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
23
|
+
* Leaving the screen stops it — listening, reads in flight and the result read — and so does
|
|
24
|
+
* `waitOptions.signal`. Neither is alerted: there is no screen left, or the app asked for it. Both
|
|
25
|
+
* fail the mutation with a `WorkflowRunAbortedError`, the signal's reason as the cause. The run itself goes
|
|
26
|
+
* on on the server. `waitOptions.timeoutMs` bounds only the wait for the end; the result read
|
|
27
|
+
* after it is a single request that the timeout does not cover. Any other failure is shown as an
|
|
28
|
+
* error alert through `useAppAlert`, and logged with its cause, which says why a wait timed out.
|
|
29
|
+
*
|
|
30
|
+
* @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters, waitOptions })`
|
|
31
|
+
* starts a run and waits for it.
|
|
24
32
|
*/
|
|
25
|
-
export declare const useRunWorkflow: () =>
|
|
26
|
-
runAsync: import("@tanstack/react-query").UseMutationResult<AnyRecord, Error, RunWorkflowProps, unknown>;
|
|
27
|
-
runAndGetResult: import("@tanstack/react-query").UseMutationResult<import("../../api/workflow.js").WorkflowResult, Error, RunWorkflowProps, unknown>;
|
|
28
|
-
};
|
|
33
|
+
export declare const useRunWorkflow: () => import("@tanstack/react-query").UseMutationResult<WorkflowResult, Error, RunWorkflowProps, unknown>;
|
|
29
34
|
export {};
|
|
30
35
|
//# sourceMappingURL=useRunWorkflow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRunWorkflow.d.ts","sourceRoot":"","sources":["../../../src/hooks/workflow/useRunWorkflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRunWorkflow.d.ts","sourceRoot":"","sources":["../../../src/hooks/workflow/useRunWorkflow.ts"],"names":[],"mappings":"AAaA,OAAO,EAIH,KAAK,mBAAmB,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,KAAK,gBAAgB,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,SAAS,CAAC;IACtB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,2GAuD1B,CAAC"}
|
|
@@ -1,48 +1,85 @@
|
|
|
1
1
|
import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
|
|
2
2
|
import { useAxios } from "../useAxios.js";
|
|
3
|
-
import { runWorkflow,
|
|
3
|
+
import { getWorkerExecution, getWorkflowExecution, runWorkflow, terminalRunStatusOf } from "../../api/workflow.js";
|
|
4
|
+
import { useWebSocket } from "../../contexts/webSocketContext/hooks/useWebSocket/index.js";
|
|
5
|
+
import { anySignal, unlessAborted } from "../../lib/abort.js";
|
|
6
|
+
import { WorkflowRunAbortedError, runWorkflowToEnd } from "../../lib/workflowRun.js";
|
|
7
|
+
import { useEffect, useRef } from "react";
|
|
4
8
|
import { useMutation } from "@tanstack/react-query";
|
|
5
9
|
//#region src/hooks/workflow/useRunWorkflow.ts
|
|
6
|
-
var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? err.message : fallback;
|
|
7
10
|
/**
|
|
8
11
|
* useRunWorkflow
|
|
9
12
|
*
|
|
10
|
-
* TanStack Query
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
+
* A TanStack Query mutation that starts a workflow run, waits for it to end, then reads the
|
|
14
|
+
* Ender's worker execution. Resolves with `{ execution, workerExecution, result }` (`result` is
|
|
15
|
+
* `null` when the run has no output), and fails unless the run ended `SUCCEEDED`.
|
|
13
16
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* when the workflow produces no output. This is the replacement for the old synchronous flow.
|
|
17
|
+
* It waits over the websocket (see `runWorkflowToEnd`), not by polling: the backend announces
|
|
18
|
+
* each worker and the run's end on the app's channel, and the end itself is then read from the
|
|
19
|
+
* API. So it requires `WebSocketProvider`, and throws on render without it. To start a run
|
|
20
|
+
* without waiting, and without a websocket, use `useTriggerWorkflow`.
|
|
19
21
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
+
* Leaving the screen stops it — listening, reads in flight and the result read — and so does
|
|
23
|
+
* `waitOptions.signal`. Neither is alerted: there is no screen left, or the app asked for it. Both
|
|
24
|
+
* fail the mutation with a `WorkflowRunAbortedError`, the signal's reason as the cause. The run itself goes
|
|
25
|
+
* on on the server. `waitOptions.timeoutMs` bounds only the wait for the end; the result read
|
|
26
|
+
* after it is a single request that the timeout does not cover. Any other failure is shown as an
|
|
27
|
+
* error alert through `useAppAlert`, and logged with its cause, which says why a wait timed out.
|
|
28
|
+
*
|
|
29
|
+
* @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters, waitOptions })`
|
|
30
|
+
* starts a run and waits for it.
|
|
22
31
|
*/
|
|
23
32
|
var useRunWorkflow = () => {
|
|
24
33
|
const { api } = useAxios();
|
|
25
34
|
const { showAlert } = useAppAlert();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
const socket = useWebSocket();
|
|
36
|
+
const unmounted = useRef(void 0);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
unmounted.current = controller.signal;
|
|
40
|
+
return () => controller.abort();
|
|
41
|
+
}, []);
|
|
42
|
+
return useMutation({
|
|
43
|
+
mutationFn: async ({ id, workspace, parameters, waitOptions }) => {
|
|
44
|
+
const { signal, dispose } = anySignal([waitOptions?.signal, unmounted.current]);
|
|
45
|
+
try {
|
|
46
|
+
const execution = await runWorkflowToEnd({
|
|
47
|
+
startRun: () => runWorkflow(api, id, workspace, parameters),
|
|
48
|
+
getExecution: (workflowExecutionId, readSignal) => getWorkflowExecution(api, id, workflowExecutionId, workspace, readSignal),
|
|
49
|
+
subscribeToEvents: socket.subscribe,
|
|
50
|
+
subscribeToStatus: socket.subscribeStatus,
|
|
51
|
+
...waitOptions,
|
|
52
|
+
signal
|
|
33
53
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
const runStatus = terminalRunStatusOf(execution.run_status);
|
|
55
|
+
if (runStatus !== "SUCCEEDED") throw new Error(`Workflow execution ${runStatus?.toLowerCase()}`);
|
|
56
|
+
const enderId = execution.ender_worker_execution_id;
|
|
57
|
+
if (!enderId) return {
|
|
58
|
+
execution,
|
|
59
|
+
workerExecution: null,
|
|
60
|
+
result: null
|
|
61
|
+
};
|
|
62
|
+
const workerExecution = await unlessAborted(getWorkerExecution(api, id, enderId, workspace, signal), signal).catch((error) => {
|
|
63
|
+
throw signal.aborted ? new WorkflowRunAbortedError(signal.reason) : error;
|
|
42
64
|
});
|
|
65
|
+
return {
|
|
66
|
+
execution,
|
|
67
|
+
workerExecution,
|
|
68
|
+
result: workerExecution.result ?? null
|
|
69
|
+
};
|
|
70
|
+
} finally {
|
|
71
|
+
dispose();
|
|
43
72
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
73
|
+
},
|
|
74
|
+
onError: (error) => {
|
|
75
|
+
if (error instanceof WorkflowRunAbortedError || unmounted.current?.aborted) return;
|
|
76
|
+
console.error("Workflow run failed:", error);
|
|
77
|
+
showAlert({
|
|
78
|
+
severity: "error",
|
|
79
|
+
message: error.message || "Unable to run the workflow. Please try again."
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
46
83
|
};
|
|
47
84
|
//#endregion
|
|
48
85
|
export { useRunWorkflow };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRunWorkflow.js","names":[],"sources":["../../../src/hooks/workflow/useRunWorkflow.ts"],"sourcesContent":["import { useMutation } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport
|
|
1
|
+
{"version":3,"file":"useRunWorkflow.js","names":[],"sources":["../../../src/hooks/workflow/useRunWorkflow.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useMutation } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport { useWebSocket } from \"@/contexts/webSocketContext/hooks/useWebSocket\";\nimport {\n getWorkerExecution,\n getWorkflowExecution,\n runWorkflow,\n terminalRunStatusOf,\n} from \"@/api/workflow\";\nimport { anySignal, unlessAborted } from \"@/lib/abort\";\nimport {\n RUN_FAILED_MESSAGE,\n WorkflowRunAbortedError,\n runWorkflowToEnd,\n type WorkflowWaitOptions,\n} from \"@/lib/workflowRun\";\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { WorkflowResult } from \"@/types/workflow\";\n\ntype RunWorkflowProps = {\n id: string;\n workspace: string;\n parameters: AnyRecord;\n /** How the run is waited for; see `WorkflowWaitOptions`. */\n waitOptions?: WorkflowWaitOptions;\n};\n\n/**\n * useRunWorkflow\n *\n * A TanStack Query mutation that starts a workflow run, waits for it to end, then reads the\n * Ender's worker execution. Resolves with `{ execution, workerExecution, result }` (`result` is\n * `null` when the run has no output), and fails unless the run ended `SUCCEEDED`.\n *\n * It waits over the websocket (see `runWorkflowToEnd`), not by polling: the backend announces\n * each worker and the run's end on the app's channel, and the end itself is then read from the\n * API. So it requires `WebSocketProvider`, and throws on render without it. To start a run\n * without waiting, and without a websocket, use `useTriggerWorkflow`.\n *\n * Leaving the screen stops it — listening, reads in flight and the result read — and so does\n * `waitOptions.signal`. Neither is alerted: there is no screen left, or the app asked for it. Both\n * fail the mutation with a `WorkflowRunAbortedError`, the signal's reason as the cause. The run itself goes\n * on on the server. `waitOptions.timeoutMs` bounds only the wait for the end; the result read\n * after it is a single request that the timeout does not cover. Any other failure is shown as an\n * error alert through `useAppAlert`, and logged with its cause, which says why a wait timed out.\n *\n * @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters, waitOptions })`\n * starts a run and waits for it.\n */\nexport const useRunWorkflow = () => {\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n const socket = useWebSocket();\n const unmounted = useRef<AbortSignal | undefined>(undefined);\n\n useEffect(() => {\n const controller = new AbortController();\n unmounted.current = controller.signal;\n return () => controller.abort();\n }, []);\n\n return useMutation({\n mutationFn: async ({\n id,\n workspace,\n parameters,\n waitOptions,\n }: RunWorkflowProps): Promise<WorkflowResult> => {\n const { signal, dispose } = anySignal([waitOptions?.signal, unmounted.current]);\n try {\n const execution = await runWorkflowToEnd({\n startRun: () => runWorkflow(api, id, workspace, parameters),\n getExecution: (workflowExecutionId, readSignal) =>\n getWorkflowExecution(api, id, workflowExecutionId, workspace, readSignal),\n subscribeToEvents: socket.subscribe,\n subscribeToStatus: socket.subscribeStatus,\n ...waitOptions,\n signal,\n });\n\n const runStatus = terminalRunStatusOf(execution.run_status);\n if (runStatus !== \"SUCCEEDED\")\n throw new Error(`Workflow execution ${runStatus?.toLowerCase()}`);\n\n const enderId = execution.ender_worker_execution_id;\n if (!enderId) return { execution, workerExecution: null, result: null };\n\n const workerExecution = await unlessAborted(\n getWorkerExecution(api, id, enderId, workspace, signal),\n signal,\n ).catch((error: unknown) => {\n throw signal.aborted ? new WorkflowRunAbortedError(signal.reason) : error;\n });\n return { execution, workerExecution, result: workerExecution.result ?? null };\n } finally {\n dispose();\n }\n },\n onError: (error) => {\n if (error instanceof WorkflowRunAbortedError || unmounted.current?.aborted) return;\n console.error(\"Workflow run failed:\", error);\n showAlert({ severity: \"error\", message: error.message || RUN_FAILED_MESSAGE });\n },\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,uBAAuB;CAChC,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAClC,MAAM,SAAS,aAAa;CAC5B,MAAM,YAAY,OAAgC,KAAA,CAAS;CAE3D,gBAAgB;EACZ,MAAM,aAAa,IAAI,gBAAgB;EACvC,UAAU,UAAU,WAAW;EAC/B,aAAa,WAAW,MAAM;CAClC,GAAG,CAAC,CAAC;CAEL,OAAO,YAAY;EACf,YAAY,OAAO,EACf,IACA,WACA,YACA,kBAC6C;GAC7C,MAAM,EAAE,QAAQ,YAAY,UAAU,CAAC,aAAa,QAAQ,UAAU,OAAO,CAAC;GAC9E,IAAI;IACA,MAAM,YAAY,MAAM,iBAAiB;KACrC,gBAAgB,YAAY,KAAK,IAAI,WAAW,UAAU;KAC1D,eAAe,qBAAqB,eAChC,qBAAqB,KAAK,IAAI,qBAAqB,WAAW,UAAU;KAC5E,mBAAmB,OAAO;KAC1B,mBAAmB,OAAO;KAC1B,GAAG;KACH;IACJ,CAAC;IAED,MAAM,YAAY,oBAAoB,UAAU,UAAU;IAC1D,IAAI,cAAc,aACd,MAAM,IAAI,MAAM,sBAAsB,WAAW,YAAY,GAAG;IAEpE,MAAM,UAAU,UAAU;IAC1B,IAAI,CAAC,SAAS,OAAO;KAAE;KAAW,iBAAiB;KAAM,QAAQ;IAAK;IAEtE,MAAM,kBAAkB,MAAM,cAC1B,mBAAmB,KAAK,IAAI,SAAS,WAAW,MAAM,GACtD,MACJ,CAAC,CAAC,OAAO,UAAmB;KACxB,MAAM,OAAO,UAAU,IAAI,wBAAwB,OAAO,MAAM,IAAI;IACxE,CAAC;IACD,OAAO;KAAE;KAAW;KAAiB,QAAQ,gBAAgB,UAAU;IAAK;GAChF,UAAU;IACN,QAAQ;GACZ;EACJ;EACA,UAAU,UAAU;GAChB,IAAI,iBAAiB,2BAA2B,UAAU,SAAS,SAAS;GAC5E,QAAQ,MAAM,wBAAwB,KAAK;GAC3C,UAAU;IAAE,UAAU;IAAS,SAAS,MAAM,WAAA;GAA8B,CAAC;EACjF;CACJ,CAAC;AACL"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AnyRecord } from "../../types/anyRecord.d.ts";
|
|
2
|
+
type TriggerWorkflowProps = {
|
|
3
|
+
id: string;
|
|
4
|
+
workspace: string;
|
|
5
|
+
parameters: AnyRecord;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* useTriggerWorkflow
|
|
9
|
+
*
|
|
10
|
+
* A TanStack Query mutation that starts a workflow run and resolves with the execution it started,
|
|
11
|
+
* still `RUNNING`. Fire-and-forget, for when nothing waits for the output; it needs no websocket.
|
|
12
|
+
* To wait for the run and read its result, use `useRunWorkflow`.
|
|
13
|
+
*
|
|
14
|
+
* A failure is shown as an error alert through `useAppAlert`.
|
|
15
|
+
*
|
|
16
|
+
* @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters })` starts a run.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useTriggerWorkflow: () => import("@tanstack/react-query").UseMutationResult<import("../..").WorkflowExecution, Error, TriggerWorkflowProps, unknown>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=useTriggerWorkflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTriggerWorkflow.d.ts","sourceRoot":"","sources":["../../../src/hooks/workflow/useTriggerWorkflow.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,KAAK,oBAAoB,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,SAAS,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,kIAU9B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
|
|
2
|
+
import { useAxios } from "../useAxios.js";
|
|
3
|
+
import { runWorkflow } from "../../api/workflow.js";
|
|
4
|
+
import "../../lib/workflowRun.js";
|
|
5
|
+
import { useMutation } from "@tanstack/react-query";
|
|
6
|
+
//#region src/hooks/workflow/useTriggerWorkflow.ts
|
|
7
|
+
/**
|
|
8
|
+
* useTriggerWorkflow
|
|
9
|
+
*
|
|
10
|
+
* A TanStack Query mutation that starts a workflow run and resolves with the execution it started,
|
|
11
|
+
* still `RUNNING`. Fire-and-forget, for when nothing waits for the output; it needs no websocket.
|
|
12
|
+
* To wait for the run and read its result, use `useRunWorkflow`.
|
|
13
|
+
*
|
|
14
|
+
* A failure is shown as an error alert through `useAppAlert`.
|
|
15
|
+
*
|
|
16
|
+
* @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters })` starts a run.
|
|
17
|
+
*/
|
|
18
|
+
var useTriggerWorkflow = () => {
|
|
19
|
+
const { api } = useAxios();
|
|
20
|
+
const { showAlert } = useAppAlert();
|
|
21
|
+
return useMutation({
|
|
22
|
+
mutationFn: ({ id, workspace, parameters }) => runWorkflow(api, id, workspace, parameters),
|
|
23
|
+
onError: (error) => showAlert({
|
|
24
|
+
severity: "error",
|
|
25
|
+
message: error.message || "Unable to run the workflow. Please try again."
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useTriggerWorkflow };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=useTriggerWorkflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTriggerWorkflow.js","names":[],"sources":["../../../src/hooks/workflow/useTriggerWorkflow.ts"],"sourcesContent":["import { useMutation } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport { runWorkflow } from \"@/api/workflow\";\nimport { RUN_FAILED_MESSAGE } from \"@/lib/workflowRun\";\nimport type { AnyRecord } from \"@/types/anyRecord\";\n\ntype TriggerWorkflowProps = {\n id: string;\n workspace: string;\n parameters: AnyRecord;\n};\n\n/**\n * useTriggerWorkflow\n *\n * A TanStack Query mutation that starts a workflow run and resolves with the execution it started,\n * still `RUNNING`. Fire-and-forget, for when nothing waits for the output; it needs no websocket.\n * To wait for the run and read its result, use `useRunWorkflow`.\n *\n * A failure is shown as an error alert through `useAppAlert`.\n *\n * @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters })` starts a run.\n */\nexport const useTriggerWorkflow = () => {\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n\n return useMutation({\n mutationFn: ({ id, workspace, parameters }: TriggerWorkflowProps) =>\n runWorkflow(api, id, workspace, parameters),\n onError: (error) =>\n showAlert({ severity: \"error\", message: error.message || RUN_FAILED_MESSAGE }),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,IAAa,2BAA2B;CACpC,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAElC,OAAO,YAAY;EACf,aAAa,EAAE,IAAI,WAAW,iBAC1B,YAAY,KAAK,IAAI,WAAW,UAAU;EAC9C,UAAU,UACN,UAAU;GAAE,UAAU;GAAS,SAAS,MAAM,WAAA;EAA8B,CAAC;CACrF,CAAC;AACL"}
|
|
@@ -1,39 +1,24 @@
|
|
|
1
1
|
import type { Workspace } from "../../types/workspace.d.ts";
|
|
2
|
-
import type {
|
|
3
|
-
export type FetchWorkspaceProps<TData = Workspace, TSelected = TData> = {
|
|
2
|
+
import type { FetchEntityProps } from "../../types/entityQuery.d.ts";
|
|
3
|
+
export type FetchWorkspaceProps<TData = Workspace, TSelected = TData> = FetchEntityProps<TData, TSelected> & {
|
|
4
4
|
name: string;
|
|
5
|
-
queryOptions?: EntityQueryOptions<TData, TSelected>;
|
|
6
5
|
};
|
|
7
6
|
/**
|
|
8
7
|
* useFetchWorkspace
|
|
9
8
|
*
|
|
10
|
-
*
|
|
9
|
+
* Fetches one workspace by name; `data` is the workspace, or whatever `select` makes of it.
|
|
11
10
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* A workspace is identified by its name — the API's `GET /workspaces/:id` takes the name, its
|
|
12
|
+
* UID — so `name` is this hook's id, and like the other hooks' id it usually comes from a
|
|
13
|
+
* selection the user has not made yet: while it is empty the hook stays idle, rather than fail
|
|
14
|
+
* as a misconfigured app. A failure is shown as an error alert.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
* @
|
|
18
|
-
* Workspace name (required).
|
|
19
|
-
*
|
|
20
|
-
* @param queryOptions
|
|
21
|
-
* TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
|
|
22
|
-
*
|
|
23
|
-
* Returns:
|
|
24
|
-
* @returns {object}
|
|
25
|
-
* TanStack Query's `query` object extended with:
|
|
26
|
-
* - `queryKey`: the cache key used by React Query
|
|
27
|
-
*
|
|
28
|
-
* Example:
|
|
29
|
-
* ```ts
|
|
30
|
-
* const { data, isLoading } = useFetchWorkspace({ name: "main" });
|
|
31
|
-
* // data -> Workspace
|
|
32
|
-
* ```
|
|
16
|
+
* @param {FetchWorkspaceProps} props - `name`, `select` and TanStack `queryOptions`.
|
|
17
|
+
* @returns {object} The `useQuery` result, plus `queryKey`.
|
|
33
18
|
*/
|
|
34
|
-
export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceProps) => {
|
|
19
|
+
export declare const useFetchWorkspace: <TSelected = Workspace>({ name, select, queryOptions, }: FetchWorkspaceProps<Workspace, TSelected>) => {
|
|
35
20
|
queryKey: string[];
|
|
36
|
-
data:
|
|
21
|
+
data: TSelected;
|
|
37
22
|
error: Error;
|
|
38
23
|
isError: true;
|
|
39
24
|
isPending: false;
|
|
@@ -56,11 +41,11 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
|
|
|
56
41
|
isRefetching: boolean;
|
|
57
42
|
isStale: boolean;
|
|
58
43
|
isEnabled: boolean;
|
|
59
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
44
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
60
45
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
61
46
|
} | {
|
|
62
47
|
queryKey: string[];
|
|
63
|
-
data:
|
|
48
|
+
data: TSelected;
|
|
64
49
|
error: null;
|
|
65
50
|
isError: false;
|
|
66
51
|
isPending: false;
|
|
@@ -83,7 +68,7 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
|
|
|
83
68
|
isRefetching: boolean;
|
|
84
69
|
isStale: boolean;
|
|
85
70
|
isEnabled: boolean;
|
|
86
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
71
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
87
72
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
88
73
|
} | {
|
|
89
74
|
queryKey: string[];
|
|
@@ -110,7 +95,7 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
|
|
|
110
95
|
isRefetching: boolean;
|
|
111
96
|
isStale: boolean;
|
|
112
97
|
isEnabled: boolean;
|
|
113
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
98
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
114
99
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
115
100
|
} | {
|
|
116
101
|
queryKey: string[];
|
|
@@ -137,7 +122,7 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
|
|
|
137
122
|
isRefetching: boolean;
|
|
138
123
|
isStale: boolean;
|
|
139
124
|
isEnabled: boolean;
|
|
140
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
125
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
141
126
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
142
127
|
} | {
|
|
143
128
|
queryKey: string[];
|
|
@@ -164,11 +149,11 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
|
|
|
164
149
|
isRefetching: boolean;
|
|
165
150
|
isStale: boolean;
|
|
166
151
|
isEnabled: boolean;
|
|
167
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
152
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
168
153
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
169
154
|
} | {
|
|
170
155
|
queryKey: string[];
|
|
171
|
-
data:
|
|
156
|
+
data: TSelected;
|
|
172
157
|
isError: false;
|
|
173
158
|
error: null;
|
|
174
159
|
isPending: false;
|
|
@@ -191,7 +176,7 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
|
|
|
191
176
|
isRefetching: boolean;
|
|
192
177
|
isStale: boolean;
|
|
193
178
|
isEnabled: boolean;
|
|
194
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
179
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
195
180
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
196
181
|
};
|
|
197
182
|
//# sourceMappingURL=useFetchWorkspace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchWorkspace.d.ts","sourceRoot":"","sources":["../../../src/hooks/workspace/useFetchWorkspace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFetchWorkspace.d.ts","sourceRoot":"","sources":["../../../src/hooks/workspace/useFetchWorkspace.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,MAAM,mBAAmB,CAAC,KAAK,GAAG,SAAS,EAAE,SAAS,GAAG,KAAK,IAAI,gBAAgB,CACpF,KAAK,EACL,SAAS,CACZ,GAAG;IACA,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,GAAG,SAAS,EAAE,iCAItD,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAc3C,CAAC"}
|
|
@@ -1,61 +1,31 @@
|
|
|
1
|
-
import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
|
|
2
1
|
import { useAxios } from "../useAxios.js";
|
|
2
|
+
import { useEntityQuery } from "../useEntityQuery.js";
|
|
3
3
|
import { getWorkspace } from "../../api/workspace.js";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
import { useQuery } from "@tanstack/react-query";
|
|
6
4
|
//#region src/hooks/workspace/useFetchWorkspace.ts
|
|
7
|
-
var defaultQueryOptions = {
|
|
8
|
-
refetchOnMount: "always",
|
|
9
|
-
staleTime: 0,
|
|
10
|
-
gcTime: 0
|
|
11
|
-
};
|
|
12
5
|
/**
|
|
13
6
|
* useFetchWorkspace
|
|
14
7
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* It also:
|
|
18
|
-
* - builds a stable React Query `queryKey` that can be reused by mutation hooks for cache invalidation
|
|
19
|
-
* - triggers an error alert via `useAppAlert` whenever `query.error` is present
|
|
20
|
-
*
|
|
21
|
-
* Parameters (FetchWorkspaceProps):
|
|
22
|
-
* @param {string} name
|
|
23
|
-
* Workspace name (required).
|
|
24
|
-
*
|
|
25
|
-
* @param queryOptions
|
|
26
|
-
* TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
|
|
8
|
+
* Fetches one workspace by name; `data` is the workspace, or whatever `select` makes of it.
|
|
27
9
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
10
|
+
* A workspace is identified by its name — the API's `GET /workspaces/:id` takes the name, its
|
|
11
|
+
* UID — so `name` is this hook's id, and like the other hooks' id it usually comes from a
|
|
12
|
+
* selection the user has not made yet: while it is empty the hook stays idle, rather than fail
|
|
13
|
+
* as a misconfigured app. A failure is shown as an error alert.
|
|
32
14
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* const { data, isLoading } = useFetchWorkspace({ name: "main" });
|
|
36
|
-
* // data -> Workspace
|
|
37
|
-
* ```
|
|
15
|
+
* @param {FetchWorkspaceProps} props - `name`, `select` and TanStack `queryOptions`.
|
|
16
|
+
* @returns {object} The `useQuery` result, plus `queryKey`.
|
|
38
17
|
*/
|
|
39
|
-
var useFetchWorkspace = ({ name, queryOptions
|
|
18
|
+
var useFetchWorkspace = ({ name, select, queryOptions }) => {
|
|
40
19
|
const { api } = useAxios();
|
|
41
|
-
const { showAlert } = useAppAlert();
|
|
42
20
|
const queryKey = ["workspace", name];
|
|
43
|
-
const query = useQuery({
|
|
44
|
-
queryKey,
|
|
45
|
-
queryFn: async () => {
|
|
46
|
-
return await getWorkspace(api, name);
|
|
47
|
-
},
|
|
48
|
-
...queryOptions ?? {}
|
|
49
|
-
});
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (!query.error) return;
|
|
52
|
-
showAlert({
|
|
53
|
-
severity: "error",
|
|
54
|
-
message: query.error.message
|
|
55
|
-
});
|
|
56
|
-
}, [query.error, showAlert]);
|
|
57
21
|
return {
|
|
58
|
-
...
|
|
22
|
+
...useEntityQuery({
|
|
23
|
+
queryKey,
|
|
24
|
+
fetchEntity: (signal) => getWorkspace(api, name, signal),
|
|
25
|
+
select,
|
|
26
|
+
enabled: Boolean(name),
|
|
27
|
+
queryOptions
|
|
28
|
+
}),
|
|
59
29
|
queryKey
|
|
60
30
|
};
|
|
61
31
|
};
|