@everysk/apps-sdk 0.2.0 → 0.3.0-beta-20261019175049
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 +342 -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/msw/fakeApi.d.ts +43 -0
- package/dist/test/msw/fakeApi.d.ts.map +1 -0
- package/dist/test/msw/fakeApi.js +74 -0
- package/dist/test/msw/fakeApi.js.map +1 -0
- package/dist/test/msw/handlers.d.ts +20 -0
- package/dist/test/msw/handlers.d.ts.map +1 -0
- package/dist/test/msw/handlers.js +279 -0
- package/dist/test/msw/handlers.js.map +1 -0
- package/dist/test/msw/index.d.ts +5 -0
- package/dist/test/msw/index.d.ts.map +1 -0
- package/dist/test/msw/index.js +2 -0
- package/dist/test/msw/query.d.ts +34 -0
- package/dist/test/msw/query.d.ts.map +1 -0
- package/dist/test/msw/query.js +96 -0
- package/dist/test/msw/query.js.map +1 -0
- package/dist/test/msw/recorder.d.ts +30 -0
- package/dist/test/msw/recorder.d.ts.map +1 -0
- package/dist/test/msw/recorder.js +65 -0
- package/dist/test/msw/recorder.js.map +1 -0
- package/dist/test/msw/store.d.ts +57 -0
- package/dist/test/msw/store.d.ts.map +1 -0
- package/dist/test/msw/store.js +145 -0
- package/dist/test/msw/store.js.map +1 -0
- 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 +10 -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/msw/fakeApi.ts +83 -0
- package/src/test/msw/handlers.ts +350 -0
- package/src/test/msw/index.ts +9 -0
- package/src/test/msw/query.ts +134 -0
- package/src/test/msw/recorder.ts +88 -0
- package/src/test/msw/store.ts +182 -0
- 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
package/src/api/workflow.ts
CHANGED
|
@@ -1,285 +1,158 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
2
|
|
|
3
3
|
import type { AnyRecord } from "@/types/anyRecord";
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
4
|
+
import { pageParams, request, requireWorkspace } from "./request";
|
|
5
|
+
import type { EntitySingleResponse } from "@/types/entityQuery";
|
|
6
|
+
import type {
|
|
7
|
+
WorkerExecution,
|
|
8
|
+
WorkerExecutionListResponse,
|
|
9
|
+
Workflow,
|
|
10
|
+
WorkflowExecution,
|
|
11
|
+
WorkflowExecutionListResponse,
|
|
12
|
+
WorkflowListResponse,
|
|
13
|
+
} from "@/types/workflow";
|
|
6
14
|
|
|
7
15
|
const baseUrl = "workflows";
|
|
8
16
|
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @param id - The unique identifier of the workflow to run.
|
|
17
|
-
* @param workspace - The workspace in which the workflow will be executed.
|
|
18
|
-
* @param parameters - Key-value parameters to pass to the workflow.
|
|
19
|
-
* @returns A promise that resolves with the workflow execution response data.
|
|
20
|
-
* @throws {Error} If `workspace` is not provided.
|
|
21
|
-
* @throws {Error} If the request fails.
|
|
22
|
-
*/
|
|
23
|
-
export const runWorkflow = async (api: AxiosInstance, id: string, workspace: string, parameters: AnyRecord): Promise<AnyRecord> => {
|
|
24
|
-
|
|
25
|
-
if (!workspace) {
|
|
26
|
-
throw new Error("Workspace is required to run workflow");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const body: AnyRecord = {
|
|
31
|
-
workspace,
|
|
32
|
-
parameters,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
-
const response: AxiosResponse<any> = await api.post(`${baseUrl}/${id}/run`, body);
|
|
37
|
-
|
|
38
|
-
return response.data;
|
|
39
|
-
} catch (error: unknown) {
|
|
40
|
-
if (isAxiosError<AnyRecord>(error)) {
|
|
41
|
-
throw new Error(error.message || "", { cause: error });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (error instanceof Error) {
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
throw new Error("Error while running workflow", { cause: error });
|
|
49
|
-
}
|
|
50
|
-
};
|
|
17
|
+
/** The endpoints' envelopes, private: every function here returns the entity itself. */
|
|
18
|
+
type WorkflowSingleResponse = EntitySingleResponse<"workflow", Workflow>;
|
|
19
|
+
type WorkflowExecutionSingleResponse = EntitySingleResponse<
|
|
20
|
+
"workflow_execution",
|
|
21
|
+
WorkflowExecution
|
|
22
|
+
>;
|
|
23
|
+
type WorkerExecutionSingleResponse = EntitySingleResponse<"worker_execution", WorkerExecution>;
|
|
51
24
|
|
|
52
25
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* Union of the backend's `WORKFLOW_EXECUTION_STATUS_FINISHED` set and the API's documented
|
|
57
|
-
* terminal `run_status` values (`SUCCEEDED`/`FAILED`/`KILLED`). `KILLED` is included so a
|
|
58
|
-
* killed execution is detected as terminal instead of polling until timeout.
|
|
26
|
+
* What `POST /workflows/:id/run` answers: the execution it started, still `RUNNING`, and a
|
|
27
|
+
* `result` that is always `null` — the run is asynchronous, and the output is read from the
|
|
28
|
+
* Ender's worker execution once it finishes. Private: `runWorkflow` returns the execution.
|
|
59
29
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
TERMINAL_RUN_STATUSES.includes(String(runStatus ?? "").toUpperCase() as (typeof TERMINAL_RUN_STATUSES)[number]);
|
|
64
|
-
|
|
65
|
-
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
|
|
66
|
-
|
|
67
|
-
export type PollWorkflowExecutionOptions = {
|
|
68
|
-
/** Delay between status checks, in milliseconds. Defaults to 2000ms. */
|
|
69
|
-
intervalMs?: number;
|
|
70
|
-
/** Maximum time to wait for a terminal status before giving up, in milliseconds. Defaults to 5 minutes. */
|
|
71
|
-
timeoutMs?: number;
|
|
72
|
-
/** Optional abort signal to cancel polling (e.g. on unmount). */
|
|
73
|
-
signal?: AbortSignal;
|
|
30
|
+
type RunWorkflowResponse = {
|
|
31
|
+
workflow_execution: WorkflowExecution;
|
|
32
|
+
result: null;
|
|
74
33
|
};
|
|
75
34
|
|
|
76
35
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* This is the interim, non-blocking replacement for synchronous (`synchronous: true`) execution:
|
|
80
|
-
* the workflow is started asynchronously and its status is checked periodically until it completes.
|
|
81
|
-
*
|
|
82
|
-
* @param api - Axios instance used to make the HTTP request.
|
|
83
|
-
* @param workflowId - The unique identifier of the workflow.
|
|
84
|
-
* @param executionId - The unique identifier of the workflow execution to poll.
|
|
85
|
-
* @param workspace - The workspace in which the workflow execution resides.
|
|
86
|
-
* @param options - Polling configuration (interval, timeout, abort signal).
|
|
87
|
-
* @returns A promise that resolves with the terminal {@link WorkflowExecution}.
|
|
88
|
-
* @throws {Error} If `workspace` is not provided.
|
|
89
|
-
* @throws {Error} If polling is aborted via `options.signal`.
|
|
90
|
-
* @throws {Error} If a terminal status is not reached before `options.timeoutMs` elapses.
|
|
91
|
-
*/
|
|
92
|
-
export const pollWorkflowExecution = async (
|
|
93
|
-
api: AxiosInstance,
|
|
94
|
-
workflowId: string,
|
|
95
|
-
executionId: string,
|
|
96
|
-
workspace: string,
|
|
97
|
-
options: PollWorkflowExecutionOptions = {}
|
|
98
|
-
): Promise<WorkflowExecution> => {
|
|
99
|
-
if (!workspace) {
|
|
100
|
-
throw new Error("Workspace is required to poll a workflow execution");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const { intervalMs = 2000, timeoutMs = 5 * 60 * 1000, signal } = options;
|
|
104
|
-
const startedAt = Date.now();
|
|
105
|
-
|
|
106
|
-
while (true) {
|
|
107
|
-
if (signal?.aborted) {
|
|
108
|
-
throw new Error("Workflow execution polling was aborted");
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const execution = await getWorkflowExecution(api, workflowId, executionId, workspace);
|
|
112
|
-
|
|
113
|
-
if (isTerminalRunStatus(execution.run_status)) {
|
|
114
|
-
return execution;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (Date.now() - startedAt >= timeoutMs) {
|
|
118
|
-
throw new Error("Timed out while waiting for the workflow execution to complete");
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
await sleep(intervalMs);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Starts a workflow asynchronously and polls its execution until completion.
|
|
36
|
+
* Runs a workflow asynchronously.
|
|
127
37
|
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
38
|
+
* Starts the workflow in a non-blocking way: the response carries a workflow execution
|
|
39
|
+
* with a non-terminal status (e.g. "RUNNING"). `useRunWorkflow` waits for the end over
|
|
40
|
+
* the websocket.
|
|
131
41
|
*
|
|
132
42
|
* @param api - Axios instance used to make the HTTP request.
|
|
133
43
|
* @param id - The unique identifier of the workflow to run.
|
|
134
44
|
* @param workspace - The workspace in which the workflow will be executed.
|
|
135
45
|
* @param parameters - Key-value parameters to pass to the workflow.
|
|
136
|
-
* @
|
|
137
|
-
*
|
|
46
|
+
* @returns The execution the run started, still `RUNNING`. It used to be the raw body,
|
|
47
|
+
* `{ workflow_execution, result: null }`, where every other function returns the entity.
|
|
138
48
|
* @throws {Error} If `workspace` is not provided.
|
|
139
|
-
* @throws {Error} If the
|
|
140
|
-
* @throws {Error} If the workflow execution ends in a "FAILED" run status.
|
|
141
|
-
* @throws {Error} If polling times out or is aborted.
|
|
49
|
+
* @throws {Error} If the request fails.
|
|
142
50
|
*/
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
options: PollWorkflowExecutionOptions = {}
|
|
51
|
+
export const runWorkflow = async (
|
|
52
|
+
api: AxiosInstance,
|
|
53
|
+
id: string,
|
|
54
|
+
workspace: string,
|
|
55
|
+
parameters: AnyRecord,
|
|
149
56
|
): Promise<WorkflowExecution> => {
|
|
150
|
-
|
|
151
|
-
throw new Error("Workspace is required to run workflow");
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Start the workflow asynchronously (non-blocking).
|
|
155
|
-
const startResponse = await runWorkflow(api, id, workspace, parameters);
|
|
156
|
-
const executionId = (startResponse.workflow_execution as WorkflowExecution | undefined)?.id;
|
|
157
|
-
|
|
158
|
-
if (!executionId) {
|
|
159
|
-
throw new Error("Workflow run did not return an execution id to poll");
|
|
160
|
-
}
|
|
57
|
+
requireWorkspace(workspace, "run a workflow");
|
|
161
58
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return execution;
|
|
59
|
+
const body = await request(
|
|
60
|
+
() => api.post<RunWorkflowResponse>(`${baseUrl}/${id}/run`, { workspace, parameters }),
|
|
61
|
+
"Error running workflow",
|
|
62
|
+
);
|
|
63
|
+
return body.workflow_execution;
|
|
170
64
|
};
|
|
171
65
|
|
|
172
66
|
/**
|
|
173
|
-
* The
|
|
67
|
+
* The run statuses a workflow execution can end with. The backend writes `RUNNING` when the run
|
|
68
|
+
* starts, and `SUCCEEDED` or `FAILED` once its Ender finishes; `CANCELED` is reserved for a
|
|
69
|
+
* cancellation it does not write yet. This list used to carry `KILLED`, which the backend never
|
|
70
|
+
* writes, and `COMPLETED`, the value of the deprecated `status` field, seen in `run_status` only
|
|
71
|
+
* on executions from before 2024-10-03.
|
|
174
72
|
*/
|
|
175
|
-
export
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
/** The ender worker execution, or `null` if the execution did not reference one. */
|
|
179
|
-
workerExecution: WorkerExecution | null;
|
|
180
|
-
/** The output data produced by the ender worker (`workerExecution.result`), or `null`. */
|
|
181
|
-
result: Record<string, unknown> | null;
|
|
182
|
-
};
|
|
73
|
+
export const TERMINAL_RUN_STATUSES = ["SUCCEEDED", "FAILED", "CANCELED"] as const;
|
|
74
|
+
|
|
75
|
+
export type TerminalRunStatus = (typeof TERMINAL_RUN_STATUSES)[number];
|
|
183
76
|
|
|
184
77
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* `ender_worker_execution_id`, and that worker execution's `result` field holds the actual data.
|
|
189
|
-
* This helper performs the full flow: start (async) → poll → fetch ender worker → return its `result`.
|
|
190
|
-
*
|
|
191
|
-
* @param api - Axios instance used to make the HTTP request.
|
|
192
|
-
* @param id - The unique identifier of the workflow to run.
|
|
193
|
-
* @param workspace - The workspace in which the workflow will be executed.
|
|
194
|
-
* @param parameters - Key-value parameters to pass to the workflow.
|
|
195
|
-
* @param options - Polling configuration (interval, timeout, abort signal).
|
|
196
|
-
* @returns A promise that resolves with the {@link WorkflowResult} (execution, ender worker execution, and its result).
|
|
197
|
-
* @throws {Error} If `workspace` is not provided.
|
|
198
|
-
* @throws {Error} If the workflow execution ends in a "FAILED" run status.
|
|
199
|
-
* @throws {Error} If polling times out or is aborted.
|
|
78
|
+
* The status a run ended with, read whatever its case; `null` while it has not ended. A missing
|
|
79
|
+
* status — a projection can drop the field, and JSON can carry it as `null` — is a run not known
|
|
80
|
+
* to have ended. The one place a run's status is read, so a comparison against it is typed.
|
|
200
81
|
*/
|
|
201
|
-
export const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
options: PollWorkflowExecutionOptions = {}
|
|
207
|
-
): Promise<WorkflowResult> => {
|
|
208
|
-
const execution = await runWorkflowAndPoll(api, id, workspace, parameters, options);
|
|
209
|
-
|
|
210
|
-
const enderWorkerExecutionId = execution.ender_worker_execution_id;
|
|
211
|
-
if (!enderWorkerExecutionId) {
|
|
212
|
-
return { execution, workerExecution: null, result: null };
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const workerExecution = await getWorkerExecution(api, id, enderWorkerExecutionId, workspace);
|
|
216
|
-
|
|
217
|
-
return { execution, workerExecution, result: workerExecution.result ?? null };
|
|
82
|
+
export const terminalRunStatusOf = (
|
|
83
|
+
runStatus: string | null | undefined,
|
|
84
|
+
): TerminalRunStatus | null => {
|
|
85
|
+
const upper = runStatus?.toUpperCase();
|
|
86
|
+
return TERMINAL_RUN_STATUSES.find((status) => status === upper) ?? null;
|
|
218
87
|
};
|
|
219
88
|
|
|
89
|
+
/** Whether a run with this `run_status` has ended; see `terminalRunStatusOf`. */
|
|
90
|
+
export const isTerminalRunStatus = (runStatus: string | null | undefined): boolean =>
|
|
91
|
+
terminalRunStatusOf(runStatus) !== null;
|
|
92
|
+
|
|
220
93
|
/**
|
|
221
94
|
* Fetches a single workflow by ID.
|
|
222
95
|
*
|
|
223
96
|
* @param api - Axios instance used to make the HTTP request.
|
|
224
97
|
* @param id - The unique identifier of the workflow to fetch.
|
|
225
98
|
* @param workspace - The workspace in which the workflow resides.
|
|
99
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
226
100
|
* @returns A promise that resolves with the {@link Workflow} object.
|
|
227
101
|
* @throws {Error} If `workspace` is not provided.
|
|
228
102
|
* @throws {Error} If the request fails.
|
|
229
103
|
*/
|
|
230
|
-
export const getWorkflow = async (
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
throw error;
|
|
246
|
-
}
|
|
104
|
+
export const getWorkflow = async (
|
|
105
|
+
api: AxiosInstance,
|
|
106
|
+
id: string,
|
|
107
|
+
workspace: string,
|
|
108
|
+
signal?: AbortSignal,
|
|
109
|
+
): Promise<Workflow> => {
|
|
110
|
+
requireWorkspace(workspace, "fetch a workflow");
|
|
111
|
+
|
|
112
|
+
const body = await request(
|
|
113
|
+
() =>
|
|
114
|
+
api.get<WorkflowSingleResponse>(`${baseUrl}/${id}`, { params: { workspace }, signal }),
|
|
115
|
+
"Error fetching workflow",
|
|
116
|
+
);
|
|
117
|
+
return body.workflow;
|
|
118
|
+
};
|
|
247
119
|
|
|
248
|
-
|
|
249
|
-
|
|
120
|
+
/** What `listWorkflows` sends. */
|
|
121
|
+
export type WorkflowListParams = {
|
|
122
|
+
/** Required: without one the API lists `main` rather than failing, and refuses a sub-user. */
|
|
123
|
+
workspace: string;
|
|
124
|
+
/** A name prefix, an id, `#tag #tag` (every tag), or `&link_uid`. Sent as `query`. */
|
|
125
|
+
search?: string;
|
|
126
|
+
pageSize?: number;
|
|
127
|
+
pageToken?: string;
|
|
250
128
|
};
|
|
251
129
|
|
|
252
130
|
/**
|
|
253
|
-
*
|
|
131
|
+
* Lists the workflows of a workspace, a page at a time.
|
|
132
|
+
*
|
|
133
|
+
* The endpoint takes a text search rather than the JSON query the other lists take, so this
|
|
134
|
+
* takes `search` rather than a `QueryObject`.
|
|
254
135
|
*
|
|
255
136
|
* @param api - Axios instance used to make the HTTP request.
|
|
256
|
-
* @param
|
|
257
|
-
* @param
|
|
258
|
-
* @
|
|
259
|
-
* @
|
|
137
|
+
* @param params - Workspace, search and paging.
|
|
138
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
|
|
139
|
+
* @returns A page of workflows, with the cursor to the next one.
|
|
140
|
+
* @throws {Error} If `workspace` is empty.
|
|
260
141
|
* @throws {Error} If the request fails.
|
|
261
142
|
*/
|
|
262
|
-
export const listWorkflows = async (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (error instanceof Error) {
|
|
278
|
-
throw error;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
throw new Error("Error listing workflows", { cause: error });
|
|
282
|
-
}
|
|
143
|
+
export const listWorkflows = async (
|
|
144
|
+
api: AxiosInstance,
|
|
145
|
+
{ workspace, search, pageSize, pageToken }: WorkflowListParams,
|
|
146
|
+
signal?: AbortSignal,
|
|
147
|
+
): Promise<WorkflowListResponse> => {
|
|
148
|
+
requireWorkspace(workspace, "list workflows");
|
|
149
|
+
|
|
150
|
+
const params = pageParams({ workspace, search, pageSize, pageToken });
|
|
151
|
+
|
|
152
|
+
return request(
|
|
153
|
+
() => api.get<WorkflowListResponse>(baseUrl, { params, signal }),
|
|
154
|
+
"Error listing workflows",
|
|
155
|
+
);
|
|
283
156
|
};
|
|
284
157
|
|
|
285
158
|
/**
|
|
@@ -287,70 +160,83 @@ export const listWorkflows = async (api: AxiosInstance, workspace?: string, page
|
|
|
287
160
|
*
|
|
288
161
|
* @param api - Axios instance used to make the HTTP request.
|
|
289
162
|
* @param workflowId - The unique identifier of the workflow.
|
|
290
|
-
* @param
|
|
163
|
+
* @param workflowExecutionId - The unique identifier of the workflow execution to fetch.
|
|
291
164
|
* @param workspace - The workspace in which the workflow execution resides.
|
|
165
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
292
166
|
* @returns A promise that resolves with the {@link WorkflowExecution} object.
|
|
293
167
|
* @throws {Error} If `workspace` is not provided.
|
|
294
168
|
* @throws {Error} If the request fails.
|
|
295
169
|
*/
|
|
296
|
-
export const getWorkflowExecution = async (
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
170
|
+
export const getWorkflowExecution = async (
|
|
171
|
+
api: AxiosInstance,
|
|
172
|
+
workflowId: string,
|
|
173
|
+
workflowExecutionId: string,
|
|
174
|
+
workspace: string,
|
|
175
|
+
signal?: AbortSignal,
|
|
176
|
+
): Promise<WorkflowExecution> => {
|
|
177
|
+
requireWorkspace(workspace, "fetch a workflow execution");
|
|
178
|
+
|
|
179
|
+
const params: AnyRecord = { workspace, workflow_execution_id: workflowExecutionId };
|
|
180
|
+
const body = await request(
|
|
181
|
+
() =>
|
|
182
|
+
api.get<WorkflowExecutionSingleResponse>(
|
|
183
|
+
`${baseUrl}/${workflowId}/workflow_executions`,
|
|
184
|
+
{ params, signal },
|
|
185
|
+
),
|
|
186
|
+
"Error fetching workflow execution",
|
|
187
|
+
);
|
|
188
|
+
return body.workflow_execution;
|
|
189
|
+
};
|
|
313
190
|
|
|
314
|
-
|
|
315
|
-
|
|
191
|
+
/** What `listWorkflowExecutions` sends: the parameters the endpoint reads, each from the URL. */
|
|
192
|
+
export type WorkflowExecutionListParams = {
|
|
193
|
+
/** Not used to filter: the endpoint lists the workflow's executions. A sub-user's role check needs it. */
|
|
194
|
+
workspace: string;
|
|
195
|
+
pageSize?: number;
|
|
196
|
+
pageToken?: string;
|
|
197
|
+
/** Only the executions this worker took part in. */
|
|
198
|
+
workerId?: string;
|
|
199
|
+
/** Include each execution's `resume`, the per-worker summary. The API leaves it out by default. */
|
|
200
|
+
withResume?: boolean;
|
|
316
201
|
};
|
|
317
202
|
|
|
318
203
|
/**
|
|
319
|
-
*
|
|
204
|
+
* Lists the executions of one workflow, newest first, a page at a time.
|
|
205
|
+
*
|
|
206
|
+
* Everything goes in the URL. The endpoint reads `page_size`, `page_token`, `worker_id` and
|
|
207
|
+
* `with_resume` from there and ignores a JSON `query`, which is what this function used to send:
|
|
208
|
+
* the page size had no effect and every "next page" came back as the first one.
|
|
320
209
|
*
|
|
321
210
|
* @param api - Axios instance used to make the HTTP request.
|
|
322
|
-
* @param workflowId - The
|
|
323
|
-
* @param
|
|
324
|
-
*
|
|
325
|
-
* @returns A
|
|
326
|
-
* @throws {Error} If
|
|
211
|
+
* @param workflowId - The workflow whose executions to list.
|
|
212
|
+
* @param params - Workspace, paging, and the endpoint's two filters.
|
|
213
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
|
|
214
|
+
* @returns A page of executions, with the cursor to the next one.
|
|
215
|
+
* @throws {Error} If `workspace` is empty.
|
|
327
216
|
* @throws {Error} If the request fails.
|
|
328
217
|
*/
|
|
329
|
-
export const listWorkflowExecutions = async (
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
218
|
+
export const listWorkflowExecutions = async (
|
|
219
|
+
api: AxiosInstance,
|
|
220
|
+
workflowId: string,
|
|
221
|
+
{ workspace, pageSize, pageToken, workerId, withResume }: WorkflowExecutionListParams,
|
|
222
|
+
signal?: AbortSignal,
|
|
223
|
+
): Promise<WorkflowExecutionListResponse> => {
|
|
224
|
+
requireWorkspace(workspace, "list workflow executions");
|
|
225
|
+
|
|
226
|
+
const params = {
|
|
227
|
+
...pageParams({ workspace, pageSize, pageToken }),
|
|
228
|
+
...(workerId ? { worker_id: workerId } : {}),
|
|
229
|
+
...(withResume !== undefined ? { with_resume: withResume } : {}),
|
|
339
230
|
};
|
|
340
231
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
throw error;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
throw new Error("Error listing workflow executions", { cause: error });
|
|
353
|
-
}
|
|
232
|
+
return request(
|
|
233
|
+
() =>
|
|
234
|
+
api.get<WorkflowExecutionListResponse>(`${baseUrl}/${workflowId}/workflow_executions`, {
|
|
235
|
+
params,
|
|
236
|
+
signal,
|
|
237
|
+
}),
|
|
238
|
+
"Error listing workflow executions",
|
|
239
|
+
);
|
|
354
240
|
};
|
|
355
241
|
|
|
356
242
|
/**
|
|
@@ -360,68 +246,80 @@ export const listWorkflowExecutions = async (api: AxiosInstance, workflowId: str
|
|
|
360
246
|
* @param workflowId - The unique identifier of the parent workflow.
|
|
361
247
|
* @param workerExecutionId - The unique identifier of the worker execution to fetch.
|
|
362
248
|
* @param workspace - The workspace in which the worker execution resides.
|
|
249
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
363
250
|
* @returns A promise that resolves with the {@link WorkerExecution} object.
|
|
364
251
|
* @throws {Error} If `workspace` is not provided.
|
|
365
252
|
* @throws {Error} If the request fails.
|
|
366
253
|
*/
|
|
367
|
-
export const getWorkerExecution = async (
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
254
|
+
export const getWorkerExecution = async (
|
|
255
|
+
api: AxiosInstance,
|
|
256
|
+
workflowId: string,
|
|
257
|
+
workerExecutionId: string,
|
|
258
|
+
workspace: string,
|
|
259
|
+
signal?: AbortSignal,
|
|
260
|
+
): Promise<WorkerExecution> => {
|
|
261
|
+
requireWorkspace(workspace, "fetch a worker execution");
|
|
371
262
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
263
|
+
const params: AnyRecord = {
|
|
264
|
+
workspace,
|
|
265
|
+
worker_execution_id: workerExecutionId,
|
|
266
|
+
with_result: true,
|
|
267
|
+
};
|
|
268
|
+
const body = await request(
|
|
269
|
+
() =>
|
|
270
|
+
api.get<WorkerExecutionSingleResponse>(`${baseUrl}/${workflowId}/worker_executions`, {
|
|
271
|
+
params,
|
|
272
|
+
signal,
|
|
273
|
+
}),
|
|
274
|
+
"Error fetching worker execution",
|
|
275
|
+
);
|
|
276
|
+
return body.worker_execution;
|
|
277
|
+
};
|
|
384
278
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
279
|
+
/** What `listWorkerExecutions` sends besides the execution id. */
|
|
280
|
+
export type WorkerExecutionListParams = {
|
|
281
|
+
/** Not used to filter. A sub-user's role check needs it. */
|
|
282
|
+
workspace: string;
|
|
283
|
+
/** Include each run's `result` and `input_params`. The API leaves them out by default. */
|
|
284
|
+
withResult?: boolean;
|
|
285
|
+
};
|
|
388
286
|
|
|
389
287
|
/**
|
|
390
|
-
*
|
|
288
|
+
* Lists every worker execution of one workflow execution, grouped by worker.
|
|
289
|
+
*
|
|
290
|
+
* The endpoint returns them all at once: it is not paginated and takes no query. Each group is
|
|
291
|
+
* one worker, with its run as `execution`, or every parallel run as `executions`.
|
|
391
292
|
*
|
|
392
293
|
* @param api - Axios instance used to make the HTTP request.
|
|
393
|
-
* @param workflowId - The
|
|
394
|
-
* @param workflowExecutionId - The
|
|
395
|
-
* @param
|
|
396
|
-
*
|
|
397
|
-
* @returns
|
|
398
|
-
* @throws {Error} If
|
|
294
|
+
* @param workflowId - The parent workflow.
|
|
295
|
+
* @param workflowExecutionId - The workflow execution whose workers to list.
|
|
296
|
+
* @param params - Workspace, and whether to include results.
|
|
297
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the hooks pass the query's own.
|
|
298
|
+
* @returns The groups, and the highest parallel index among them.
|
|
299
|
+
* @throws {Error} If `workspace` is empty.
|
|
399
300
|
* @throws {Error} If the request fails.
|
|
400
301
|
*/
|
|
401
|
-
export const listWorkerExecutions = async (
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
302
|
+
export const listWorkerExecutions = async (
|
|
303
|
+
api: AxiosInstance,
|
|
304
|
+
workflowId: string,
|
|
305
|
+
workflowExecutionId: string,
|
|
306
|
+
{ workspace, withResult }: WorkerExecutionListParams,
|
|
307
|
+
signal?: AbortSignal,
|
|
308
|
+
): Promise<WorkerExecutionListResponse> => {
|
|
309
|
+
requireWorkspace(workspace, "list worker executions");
|
|
310
|
+
|
|
311
|
+
const params = {
|
|
312
|
+
workspace,
|
|
313
|
+
workflow_execution_id: workflowExecutionId,
|
|
314
|
+
...(withResult !== undefined ? { with_result: withResult } : {}),
|
|
412
315
|
};
|
|
413
316
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
throw new Error("Error listing worker executions", { cause: error });
|
|
426
|
-
}
|
|
427
|
-
};
|
|
317
|
+
return request(
|
|
318
|
+
() =>
|
|
319
|
+
api.get<WorkerExecutionListResponse>(`${baseUrl}/${workflowId}/worker_executions`, {
|
|
320
|
+
params,
|
|
321
|
+
signal,
|
|
322
|
+
}),
|
|
323
|
+
"Error listing worker executions",
|
|
324
|
+
);
|
|
325
|
+
};
|