@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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/agGrid/handleRowsScrollEnd.ts
|
|
2
|
+
/**
|
|
3
|
+
* handleRowsScrollEnd
|
|
4
|
+
*
|
|
5
|
+
* Requests the next page when an AG Grid is scrolled near its last row, or shows none — the
|
|
6
|
+
* grid paging on demand. The handler for what MUI X DataGrid calls `onRowsScrollEnd`; wire it
|
|
7
|
+
* to AG Grid's `onBodyScrollEnd` and `onModelUpdated`, the second so that a grid whose rows a
|
|
8
|
+
* client-side filter hid entirely keeps loading.
|
|
9
|
+
*
|
|
10
|
+
* A function, not part of any hook: the data hook does not know a grid exists, and the grid
|
|
11
|
+
* does not know where its rows come from. It lives in this subpath because it needs `GridApi`,
|
|
12
|
+
* and AG Grid is an optional peer.
|
|
13
|
+
*
|
|
14
|
+
* Events fire in bursts, before `isFetchingNextPage` has flipped, so the request is made with
|
|
15
|
+
* `cancelRefetch: false`: TanStack then ignores a repeat while the first one is in flight,
|
|
16
|
+
* instead of cancelling it and asking for the same page again.
|
|
17
|
+
*
|
|
18
|
+
* @param {GridApi} gridApi - The grid, from the event (`event.api`).
|
|
19
|
+
* @param {InfiniteQueryPaging} query - The infinite query feeding the grid.
|
|
20
|
+
* @param {HandleRowsScrollEndOptions} [options] - `scrollEndThreshold`, in pixels (default 80).
|
|
21
|
+
*
|
|
22
|
+
* Example:
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const { query } = useFetchDatastores({ filters, select: toRows });
|
|
25
|
+
*
|
|
26
|
+
* <AgGridReact
|
|
27
|
+
* rowData={query.data}
|
|
28
|
+
* onBodyScrollEnd={(event) => handleRowsScrollEnd(event.api, query)}
|
|
29
|
+
* onModelUpdated={(event) => handleRowsScrollEnd(event.api, query)}
|
|
30
|
+
* />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
var handleRowsScrollEnd = (gridApi, query, { scrollEndThreshold = 80 } = {}) => {
|
|
34
|
+
if (!query.hasNextPage || query.isFetchingNextPage) return;
|
|
35
|
+
const rowCount = gridApi.getDisplayedRowCount();
|
|
36
|
+
const lastRow = rowCount > 0 ? gridApi.getDisplayedRowAtIndex(rowCount - 1) : void 0;
|
|
37
|
+
if (lastRow) {
|
|
38
|
+
const rowsEnd = (lastRow.rowTop ?? 0) + (lastRow.rowHeight ?? 0);
|
|
39
|
+
const { bottom } = gridApi.getVerticalPixelRange();
|
|
40
|
+
if (rowsEnd - bottom > scrollEndThreshold) return;
|
|
41
|
+
}
|
|
42
|
+
query.fetchNextPage({ cancelRefetch: false });
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { handleRowsScrollEnd };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=handleRowsScrollEnd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleRowsScrollEnd.js","names":[],"sources":["../../src/agGrid/handleRowsScrollEnd.ts"],"sourcesContent":["import type { GridApi } from \"ag-grid-community\";\n\n/**\n * The part of an infinite query this needs. Structural, so it takes any list hook's `query`,\n * or a `useInfiniteQuery` an app writes itself.\n */\nexport type InfiniteQueryPaging = {\n hasNextPage: boolean;\n isFetchingNextPage: boolean;\n fetchNextPage: (options?: { cancelRefetch?: boolean }) => Promise<unknown>;\n};\n\nexport type HandleRowsScrollEndOptions = {\n /**\n * Distance in pixels from the end of the rows at which the next page is requested. Named and\n * measured as MUI X DataGrid's `scrollEndThreshold`, whose default it shares. Pixels rather\n * than rows, so it holds with rows of different heights.\n */\n scrollEndThreshold?: number;\n};\n\n/**\n * handleRowsScrollEnd\n *\n * Requests the next page when an AG Grid is scrolled near its last row, or shows none — the\n * grid paging on demand. The handler for what MUI X DataGrid calls `onRowsScrollEnd`; wire it\n * to AG Grid's `onBodyScrollEnd` and `onModelUpdated`, the second so that a grid whose rows a\n * client-side filter hid entirely keeps loading.\n *\n * A function, not part of any hook: the data hook does not know a grid exists, and the grid\n * does not know where its rows come from. It lives in this subpath because it needs `GridApi`,\n * and AG Grid is an optional peer.\n *\n * Events fire in bursts, before `isFetchingNextPage` has flipped, so the request is made with\n * `cancelRefetch: false`: TanStack then ignores a repeat while the first one is in flight,\n * instead of cancelling it and asking for the same page again.\n *\n * @param {GridApi} gridApi - The grid, from the event (`event.api`).\n * @param {InfiniteQueryPaging} query - The infinite query feeding the grid.\n * @param {HandleRowsScrollEndOptions} [options] - `scrollEndThreshold`, in pixels (default 80).\n *\n * Example:\n * ```tsx\n * const { query } = useFetchDatastores({ filters, select: toRows });\n *\n * <AgGridReact\n * rowData={query.data}\n * onBodyScrollEnd={(event) => handleRowsScrollEnd(event.api, query)}\n * onModelUpdated={(event) => handleRowsScrollEnd(event.api, query)}\n * />\n * ```\n */\nexport const handleRowsScrollEnd = (\n gridApi: GridApi,\n query: InfiniteQueryPaging,\n { scrollEndThreshold = 80 }: HandleRowsScrollEndOptions = {},\n): void => {\n if (!query.hasNextPage || query.isFetchingNextPage) return;\n\n const rowCount = gridApi.getDisplayedRowCount();\n const lastRow = rowCount > 0 ? gridApi.getDisplayedRowAtIndex(rowCount - 1) : undefined;\n\n if (lastRow) {\n const rowsEnd = (lastRow.rowTop ?? 0) + (lastRow.rowHeight ?? 0);\n const { bottom } = gridApi.getVerticalPixelRange();\n\n if (rowsEnd - bottom > scrollEndThreshold) return;\n }\n\n void query.fetchNextPage({ cancelRefetch: false });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,uBACT,SACA,OACA,EAAE,qBAAqB,OAAmC,CAAC,MACpD;CACP,IAAI,CAAC,MAAM,eAAe,MAAM,oBAAoB;CAEpD,MAAM,WAAW,QAAQ,qBAAqB;CAC9C,MAAM,UAAU,WAAW,IAAI,QAAQ,uBAAuB,WAAW,CAAC,IAAI,KAAA;CAE9E,IAAI,SAAS;EACT,MAAM,WAAW,QAAQ,UAAU,MAAM,QAAQ,aAAa;EAC9D,MAAM,EAAE,WAAW,QAAQ,sBAAsB;EAEjD,IAAI,UAAU,SAAS,oBAAoB;CAC/C;CAEA,MAAW,cAAc,EAAE,eAAe,MAAM,CAAC;AACrD"}
|
package/dist/agGrid/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { setAgGridLicense, AgGridLicenseProvider } from "../contexts/agGridLicenseContext/provider.js";
|
|
2
2
|
export type { AgGridLicenseProviderProps } from "../contexts/agGridLicenseContext/provider.js";
|
|
3
3
|
export { getAgGridTheme, useAgGridTheme, agGridThemeParams } from "./agGridTheme";
|
|
4
|
+
export { handleRowsScrollEnd } from "./handleRowsScrollEnd";
|
|
5
|
+
export type { HandleRowsScrollEndOptions, InfiniteQueryPaging } from "./handleRowsScrollEnd";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agGrid/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agGrid/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACnG,YAAY,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAE3F,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/agGrid/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { AgGridLicenseProvider, setAgGridLicense } from "../contexts/agGridLicenseContext/provider.js";
|
|
2
2
|
import { agGridThemeParams, getAgGridTheme, useAgGridTheme } from "./agGridTheme.js";
|
|
3
|
-
|
|
3
|
+
import { handleRowsScrollEnd } from "./handleRowsScrollEnd.js";
|
|
4
|
+
export { AgGridLicenseProvider, agGridThemeParams, getAgGridTheme, handleRowsScrollEnd, setAgGridLicense, useAgGridTheme };
|
package/dist/api/datastore.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
import type { DeletedEntity, QueryObject } from "../types/entityQuery.d.ts";
|
|
3
3
|
import type { Datastore, DatastoreListResponse } from "../types/datastore.d.ts";
|
|
4
4
|
/**
|
|
5
5
|
* getDatastore
|
|
@@ -9,24 +9,26 @@ import type { Datastore, DatastoreListResponse } from "../types/datastore.d.ts";
|
|
|
9
9
|
* @param {AxiosInstance} api - Axios instance.
|
|
10
10
|
* @param {string} id - Datastore identifier.
|
|
11
11
|
* @param {string} workspace - Workspace the datastore belongs to.
|
|
12
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
12
13
|
* @returns {Promise<Datastore>} The fetched datastore.
|
|
13
14
|
*
|
|
14
15
|
* @throws {Error} If the request fails.
|
|
15
16
|
*/
|
|
16
|
-
export declare const getDatastore: (api: AxiosInstance, id: string, workspace: string) => Promise<Datastore>;
|
|
17
|
+
export declare const getDatastore: (api: AxiosInstance, id: string, workspace: string, signal?: AbortSignal) => Promise<Datastore>;
|
|
17
18
|
/**
|
|
18
19
|
* listDatastores
|
|
19
20
|
*
|
|
20
21
|
* Fetches a list of datastores using a query object (filters, order, pagination, etc.).
|
|
21
22
|
*
|
|
22
23
|
* @param {AxiosInstance} api - Axios instance.
|
|
23
|
-
* @param {
|
|
24
|
+
* @param {QueryObject} query - Query object built via `buildQueryObject`.
|
|
25
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
|
|
24
26
|
* @returns {Promise<DatastoreListResponse>} Paginated list of datastores.
|
|
25
27
|
*
|
|
26
|
-
* @throws {Error} If workspace filter
|
|
28
|
+
* @throws {Error} If the query has no workspace filter.
|
|
27
29
|
* @throws {Error} If the request fails.
|
|
28
30
|
*/
|
|
29
|
-
export declare const listDatastores: (api: AxiosInstance, query: QueryObject) => Promise<DatastoreListResponse>;
|
|
31
|
+
export declare const listDatastores: (api: AxiosInstance, query: QueryObject, signal?: AbortSignal) => Promise<DatastoreListResponse>;
|
|
30
32
|
/**
|
|
31
33
|
* createDatastore
|
|
32
34
|
*
|
|
@@ -60,9 +62,9 @@ export declare const updateDatastore: (api: AxiosInstance, id: string, data: Par
|
|
|
60
62
|
* @param {AxiosInstance} api - Axios instance.
|
|
61
63
|
* @param {string} id - Datastore identifier.
|
|
62
64
|
* @param {string} workspace - Workspace the datastore belongs to.
|
|
63
|
-
* @returns {Promise<
|
|
65
|
+
* @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.
|
|
64
66
|
*
|
|
65
67
|
* @throws {Error} If the request fails.
|
|
66
68
|
*/
|
|
67
|
-
export declare const deleteDatastore: (api: AxiosInstance, id: string, workspace: string) => Promise<
|
|
69
|
+
export declare const deleteDatastore: (api: AxiosInstance, id: string, workspace: string) => Promise<DeletedEntity>;
|
|
68
70
|
//# sourceMappingURL=datastore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datastore.d.ts","sourceRoot":"","sources":["../../src/api/datastore.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"datastore.d.ts","sourceRoot":"","sources":["../../src/api/datastore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EACR,aAAa,EAGb,WAAW,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAS1E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GACrB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,WAAW,MAAM,EACjB,SAAS,WAAW,KACrB,OAAO,CAAC,SAAS,CASnB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GACvB,KAAK,aAAa,EAClB,OAAO,WAAW,EAClB,SAAS,WAAW,KACrB,OAAO,CAAC,qBAAqB,CAO/B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GACxB,KAAK,aAAa,EAClB,MAAM,OAAO,CAAC,SAAS,CAAC,KACzB,OAAO,CAAC,SAAS,CAQnB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GACxB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,MAAM,OAAO,CAAC,SAAS,CAAC,KACzB,OAAO,CAAC,SAAS,CAQnB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GACxB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,WAAW,MAAM,KAClB,OAAO,CAAC,aAAa,CAQvB,CAAC"}
|
package/dist/api/datastore.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { listParams, request, requireWorkspace } from "./request.js";
|
|
2
2
|
//#region src/api/datastore.ts
|
|
3
3
|
var baseUrl = "datastores";
|
|
4
4
|
/**
|
|
@@ -9,20 +9,17 @@ var baseUrl = "datastores";
|
|
|
9
9
|
* @param {AxiosInstance} api - Axios instance.
|
|
10
10
|
* @param {string} id - Datastore identifier.
|
|
11
11
|
* @param {string} workspace - Workspace the datastore belongs to.
|
|
12
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
12
13
|
* @returns {Promise<Datastore>} The fetched datastore.
|
|
13
14
|
*
|
|
14
15
|
* @throws {Error} If the request fails.
|
|
15
16
|
*/
|
|
16
|
-
var getDatastore = async (api, id, workspace) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error fetching datastore", { cause: error });
|
|
23
|
-
if (error instanceof Error) throw error;
|
|
24
|
-
throw new Error("Error fetching datastore", { cause: error });
|
|
25
|
-
}
|
|
17
|
+
var getDatastore = async (api, id, workspace, signal) => {
|
|
18
|
+
requireWorkspace(workspace, "fetch a datastore");
|
|
19
|
+
return (await request(() => api.get(`${baseUrl}/${id}`, {
|
|
20
|
+
params: { workspace },
|
|
21
|
+
signal
|
|
22
|
+
}), "Error fetching datastore")).datastore;
|
|
26
23
|
};
|
|
27
24
|
/**
|
|
28
25
|
* listDatastores
|
|
@@ -30,27 +27,19 @@ var getDatastore = async (api, id, workspace) => {
|
|
|
30
27
|
* Fetches a list of datastores using a query object (filters, order, pagination, etc.).
|
|
31
28
|
*
|
|
32
29
|
* @param {AxiosInstance} api - Axios instance.
|
|
33
|
-
* @param {
|
|
30
|
+
* @param {QueryObject} query - Query object built via `buildQueryObject`.
|
|
31
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
|
|
34
32
|
* @returns {Promise<DatastoreListResponse>} Paginated list of datastores.
|
|
35
33
|
*
|
|
36
|
-
* @throws {Error} If workspace filter
|
|
34
|
+
* @throws {Error} If the query has no workspace filter.
|
|
37
35
|
* @throws {Error} If the request fails.
|
|
38
36
|
*/
|
|
39
|
-
var listDatastores = async (api, query) => {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...query ? { query: JSON.stringify(query) } : {}
|
|
46
|
-
};
|
|
47
|
-
try {
|
|
48
|
-
return (await api.get(baseUrl, { params })).data;
|
|
49
|
-
} catch (error) {
|
|
50
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error listing datastores", { cause: error });
|
|
51
|
-
if (error instanceof Error) throw error;
|
|
52
|
-
throw new Error("Error listing datastores", { cause: error });
|
|
53
|
-
}
|
|
37
|
+
var listDatastores = async (api, query, signal) => {
|
|
38
|
+
const params = listParams(query, "list datastores");
|
|
39
|
+
return request(() => api.get(baseUrl, {
|
|
40
|
+
params,
|
|
41
|
+
signal
|
|
42
|
+
}), "Error listing datastores");
|
|
54
43
|
};
|
|
55
44
|
/**
|
|
56
45
|
* createDatastore
|
|
@@ -64,15 +53,8 @@ var listDatastores = async (api, query) => {
|
|
|
64
53
|
* @throws {Error} If the request fails.
|
|
65
54
|
*/
|
|
66
55
|
var createDatastore = async (api, data) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
return (await api.post(baseUrl, data)).data.datastore;
|
|
71
|
-
} catch (error) {
|
|
72
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error creating datastore", { cause: error });
|
|
73
|
-
if (error instanceof Error) throw error;
|
|
74
|
-
throw new Error("Error creating datastore", { cause: error });
|
|
75
|
-
}
|
|
56
|
+
requireWorkspace(data.workspace, "create a datastore");
|
|
57
|
+
return (await request(() => api.post(baseUrl, data), "Error creating datastore")).datastore;
|
|
76
58
|
};
|
|
77
59
|
/**
|
|
78
60
|
* updateDatastore
|
|
@@ -87,15 +69,8 @@ var createDatastore = async (api, data) => {
|
|
|
87
69
|
* @throws {Error} If the request fails.
|
|
88
70
|
*/
|
|
89
71
|
var updateDatastore = async (api, id, data) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
return (await api.put(`${baseUrl}/${id}`, data)).data.datastore;
|
|
94
|
-
} catch (error) {
|
|
95
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error updating datastore", { cause: error });
|
|
96
|
-
if (error instanceof Error) throw error;
|
|
97
|
-
throw new Error("Error updating datastore", { cause: error });
|
|
98
|
-
}
|
|
72
|
+
requireWorkspace(data.workspace, "update a datastore");
|
|
73
|
+
return (await request(() => api.put(`${baseUrl}/${id}`, data), "Error updating datastore")).datastore;
|
|
99
74
|
};
|
|
100
75
|
/**
|
|
101
76
|
* deleteDatastore
|
|
@@ -105,19 +80,13 @@ var updateDatastore = async (api, id, data) => {
|
|
|
105
80
|
* @param {AxiosInstance} api - Axios instance.
|
|
106
81
|
* @param {string} id - Datastore identifier.
|
|
107
82
|
* @param {string} workspace - Workspace the datastore belongs to.
|
|
108
|
-
* @returns {Promise<
|
|
83
|
+
* @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.
|
|
109
84
|
*
|
|
110
85
|
* @throws {Error} If the request fails.
|
|
111
86
|
*/
|
|
112
87
|
var deleteDatastore = async (api, id, workspace) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return (await api.delete(`${baseUrl}/${id}`, { params })).data.datastores;
|
|
116
|
-
} catch (error) {
|
|
117
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error removing datastore", { cause: error });
|
|
118
|
-
if (error instanceof Error) throw error;
|
|
119
|
-
throw new Error("Error removing datastore", { cause: error });
|
|
120
|
-
}
|
|
88
|
+
requireWorkspace(workspace, "delete a datastore");
|
|
89
|
+
return (await request(() => api.delete(`${baseUrl}/${id}`, { params: { workspace } }), "Error deleting datastore")).datastore;
|
|
121
90
|
};
|
|
122
91
|
//#endregion
|
|
123
92
|
export { createDatastore, deleteDatastore, getDatastore, listDatastores, updateDatastore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datastore.js","names":[],"sources":["../../src/api/datastore.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"datastore.js","names":[],"sources":["../../src/api/datastore.ts"],"sourcesContent":["import type { AxiosInstance } from \"axios\";\n\nimport type {\n DeletedEntity,\n DeleteEntityResponse,\n EntitySingleResponse,\n QueryObject,\n} from \"@/types/entityQuery\";\nimport type { Datastore, DatastoreListResponse } from \"@/types/datastore\";\nimport { listParams, request, requireWorkspace } from \"./request\";\n\nconst baseUrl = \"datastores\";\n\n/** The endpoint's envelopes, private: every function here returns the entity itself. */\ntype DatastoreSingleResponse = EntitySingleResponse<\"datastore\", Datastore>;\ntype DeleteDatastoreResponse = DeleteEntityResponse<\"datastore\">;\n\n/**\n * getDatastore\n *\n * Fetches a single datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {string} workspace - Workspace the datastore belongs to.\n * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.\n * @returns {Promise<Datastore>} The fetched datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const getDatastore = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n signal?: AbortSignal,\n): Promise<Datastore> => {\n requireWorkspace(workspace, \"fetch a datastore\");\n\n const body = await request(\n () =>\n api.get<DatastoreSingleResponse>(`${baseUrl}/${id}`, { params: { workspace }, signal }),\n \"Error fetching datastore\",\n );\n return body.datastore;\n};\n\n/**\n * listDatastores\n *\n * Fetches a list of datastores using a query object (filters, order, pagination, etc.).\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {QueryObject} query - Query object built via `buildQueryObject`.\n * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.\n * @returns {Promise<DatastoreListResponse>} Paginated list of datastores.\n *\n * @throws {Error} If the query has no workspace filter.\n * @throws {Error} If the request fails.\n */\nexport const listDatastores = async (\n api: AxiosInstance,\n query: QueryObject,\n signal?: AbortSignal,\n): Promise<DatastoreListResponse> => {\n const params = listParams(query, \"list datastores\");\n\n return request(\n () => api.get<DatastoreListResponse>(baseUrl, { params, signal }),\n \"Error listing datastores\",\n );\n};\n\n/**\n * createDatastore\n *\n * Creates a new datastore.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {Partial<Datastore>} data - Datastore payload.\n * @returns {Promise<Datastore>} The created datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const createDatastore = async (\n api: AxiosInstance,\n data: Partial<Datastore>,\n): Promise<Datastore> => {\n requireWorkspace(data.workspace, \"create a datastore\");\n\n const body = await request(\n () => api.post<DatastoreSingleResponse>(baseUrl, data),\n \"Error creating datastore\",\n );\n return body.datastore;\n};\n\n/**\n * updateDatastore\n *\n * Updates an existing datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {Partial<Datastore>} data - Fields to update.\n * @returns {Promise<Datastore>} The updated datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const updateDatastore = async (\n api: AxiosInstance,\n id: string,\n data: Partial<Datastore>,\n): Promise<Datastore> => {\n requireWorkspace(data.workspace, \"update a datastore\");\n\n const body = await request(\n () => api.put<DatastoreSingleResponse>(`${baseUrl}/${id}`, data),\n \"Error updating datastore\",\n );\n return body.datastore;\n};\n\n/**\n * deleteDatastore\n *\n * Deletes a datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {string} workspace - Workspace the datastore belongs to.\n * @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.\n *\n * @throws {Error} If the request fails.\n */\nexport const deleteDatastore = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n): Promise<DeletedEntity> => {\n requireWorkspace(workspace, \"delete a datastore\");\n\n const body = await request(\n () => api.delete<DeleteDatastoreResponse>(`${baseUrl}/${id}`, { params: { workspace } }),\n \"Error deleting datastore\",\n );\n return body.datastore;\n};\n"],"mappings":";;AAWA,IAAM,UAAU;;;;;;;;;;;;;;AAmBhB,IAAa,eAAe,OACxB,KACA,IACA,WACA,WACqB;CACrB,iBAAiB,WAAW,mBAAmB;CAO/C,QAAO,MALY,cAEX,IAAI,IAA6B,GAAG,QAAQ,GAAG,MAAM;EAAE,QAAQ,EAAE,UAAU;EAAG;CAAO,CAAC,GAC1F,0BACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;;AAeA,IAAa,iBAAiB,OAC1B,KACA,OACA,WACiC;CACjC,MAAM,SAAS,WAAW,OAAO,iBAAiB;CAElD,OAAO,cACG,IAAI,IAA2B,SAAS;EAAE;EAAQ;CAAO,CAAC,GAChE,0BACJ;AACJ;;;;;;;;;;;;AAaA,IAAa,kBAAkB,OAC3B,KACA,SACqB;CACrB,iBAAiB,KAAK,WAAW,oBAAoB;CAMrD,QAAO,MAJY,cACT,IAAI,KAA8B,SAAS,IAAI,GACrD,0BACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAC3B,KACA,IACA,SACqB;CACrB,iBAAiB,KAAK,WAAW,oBAAoB;CAMrD,QAAO,MAJY,cACT,IAAI,IAA6B,GAAG,QAAQ,GAAG,MAAM,IAAI,GAC/D,0BACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAC3B,KACA,IACA,cACyB;CACzB,iBAAiB,WAAW,oBAAoB;CAMhD,QAAO,MAJY,cACT,IAAI,OAAgC,GAAG,QAAQ,GAAG,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,GACvF,0BACJ,EAAA,CACY;AAChB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FilterClause, FilterExpression, EntityQueryParams, QueryObject } from "../types/entityQuery.d.ts";
|
|
1
|
+
import type { FilterClause, FilterExpression, EntityQueryParams, Projection, QueryObject } from "../types/entityQuery.d.ts";
|
|
2
2
|
/**
|
|
3
3
|
* toFilterTuple
|
|
4
4
|
*
|
|
@@ -21,58 +21,63 @@ import type { FilterClause, FilterExpression, EntityQueryParams, QueryObject } f
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export declare const toFilterTuple: (filter: FilterClause) => FilterExpression;
|
|
24
|
+
export declare const buildQueryObject: (params: EntityQueryParams) => QueryObject;
|
|
25
|
+
/** What, besides the filters, changes the response a list read gets back. */
|
|
26
|
+
export type QueryKeyParams = {
|
|
27
|
+
order?: string[];
|
|
28
|
+
projection?: Projection;
|
|
29
|
+
pageSize?: number;
|
|
30
|
+
fetchAllPages?: boolean;
|
|
31
|
+
/** The datastore hooks' `dataFormat`. In the key whenever a hook passes it; only those hooks do. */
|
|
32
|
+
dataFormat?: "object" | "matrix";
|
|
33
|
+
};
|
|
24
34
|
/**
|
|
25
|
-
*
|
|
35
|
+
* buildQueryKey
|
|
26
36
|
*
|
|
27
|
-
* Builds the
|
|
28
|
-
*
|
|
37
|
+
* Builds the React Query cache key of a list read: the base keys, then one object holding
|
|
38
|
+
* everything that changes the response.
|
|
29
39
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
40
|
+
* Every part of the request is in the key, not only the filter values. The key used to be
|
|
41
|
+
* `[...keys, ...values]`, so a `-data` metadata read and a full read of the same workspace,
|
|
42
|
+
* or `date = X` and `date >= X`, shared one cache entry and one of them rendered the other's
|
|
43
|
+
* data. Filters go in as the tuples the API receives, so field and operator are included.
|
|
44
|
+
*
|
|
45
|
+
* The base keys stay in front, so prefix invalidation keeps working:
|
|
46
|
+
* `invalidateQueries({ queryKey: ["workflow_executions", workflowId] })`.
|
|
47
|
+
*
|
|
48
|
+
* @param {(string | number | null)[]} keys - Base keys (entity name, then any ids).
|
|
49
|
+
* @param {FilterClause[]} filters - The filters of the read.
|
|
50
|
+
* @param {QueryKeyParams} [params] - Order, projection, page size and paging mode.
|
|
51
|
+
* @returns {unknown[]} Cache key array for use in `queryKey`.
|
|
39
52
|
*
|
|
40
53
|
* Example:
|
|
41
54
|
* ```ts
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* order: ["name"], // plain field name(s) only — no "asc"/"desc" suffix
|
|
45
|
-
* pageSize: 10,
|
|
46
|
-
* pageToken: "token-abc",
|
|
47
|
-
* projection: "name",
|
|
48
|
-
* });
|
|
49
|
-
* // -> {
|
|
50
|
-
* // filters: [["workspace", "ws-1"]],
|
|
51
|
-
* // order: ["name"],
|
|
52
|
-
* // projection: "name",
|
|
53
|
-
* // page_size: 10,
|
|
54
|
-
* // page_token: "token-abc",
|
|
55
|
-
* // }
|
|
55
|
+
* buildQueryKey(["datastores"], [{ field: "workspace", value: "ws-1" }], { pageSize: 10 });
|
|
56
|
+
* // -> ["datastores", { filters: [["workspace", "ws-1"]], pageSize: 10 }]
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
58
|
-
export declare const
|
|
59
|
+
export declare const buildQueryKey: (keys: (string | number | null)[], filters: FilterClause[], { order, projection, pageSize, fetchAllPages, dataFormat }?: QueryKeyParams) => unknown[];
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
+
* hasWorkspaceFilter
|
|
61
62
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
63
|
+
* Whether a read can be sent: every endpoint that takes filters rejects a request with no
|
|
64
|
+
* workspace. It reads the workspace through `workspaceOf`, as the list functions in `api/` do:
|
|
65
|
+
* while each read it its own way, it passed on a filter the request then ignored.
|
|
64
66
|
*
|
|
65
|
-
*
|
|
67
|
+
* @param {FilterClause[]} filters - The filters of the read.
|
|
68
|
+
* @returns {boolean} True when the first `workspace` filter carries a value.
|
|
69
|
+
*/
|
|
70
|
+
export declare const hasWorkspaceFilter: (filters: FilterClause[]) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* missingWorkspaceError
|
|
66
73
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
74
|
+
* The reason a hook gives, as `configError`, when it has no workspace to read. A missing
|
|
75
|
+
* workspace is a misconfigured app, never a state to wait out: the app config is merged into
|
|
76
|
+
* `window.APP_CONFIG` before the app renders, so an empty value there is a wrong or misspelled
|
|
77
|
+
* key. The message names the hook, so it points at the call to fix.
|
|
70
78
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* buildQueryKey(["datastores"], [{ field: "workspace", value: "ws-1" }]);
|
|
74
|
-
* // -> ["datastores", "ws-1"]
|
|
75
|
-
* ```
|
|
79
|
+
* @param {string} hookName - The hook that could not send its request.
|
|
80
|
+
* @returns {string} The error message.
|
|
76
81
|
*/
|
|
77
|
-
export declare const
|
|
82
|
+
export declare const missingWorkspaceError: (hookName: string) => string;
|
|
78
83
|
//# sourceMappingURL=entityQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityQuery.d.ts","sourceRoot":"","sources":["../../src/api/entityQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"entityQuery.d.ts","sourceRoot":"","sources":["../../src/api/entityQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,WAAW,EACd,MAAM,qBAAqB,CAAC;AAG7B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,YAAY,KAAG,gBAMpD,CAAC;AAyCF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,iBAAiB,KAAG,WAU5D,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,cAAc,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oGAAoG;IACpG,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,aAAa,GACtB,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,EAChC,SAAS,YAAY,EAAE,EACvB,6DAA4D,cAAmB,KAChF,OAAO,EAaT,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,YAAY,EAAE,KAAG,OACT,CAAC;AAErD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,MAED,CAAC"}
|
package/dist/api/entityQuery.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { workspaceOf } from "./request.js";
|
|
1
2
|
//#region src/api/entityQuery.ts
|
|
2
3
|
/**
|
|
3
4
|
* toFilterTuple
|
|
@@ -40,9 +41,10 @@ var toFilterTuple = (filter) => {
|
|
|
40
41
|
* @param {string[]} params.order - Sorting fields.
|
|
41
42
|
* @param {number} [params.pageSize] - Number of items per page.
|
|
42
43
|
* @param {string} [params.pageToken] - Cursor token for the next page.
|
|
43
|
-
* @param {
|
|
44
|
-
* field (every other field comes back null); `"-field"` returns all fields
|
|
45
|
-
*
|
|
44
|
+
* @param {Projection} [params.projection] - The fields to return: one, or a list. `"field"`
|
|
45
|
+
* returns only that field (every other field comes back null); `"-field"` returns all fields
|
|
46
|
+
* except that one. Pass several as a list, never comma-joined: `"a,b"` is a 500. Omitted from
|
|
47
|
+
* the payload when empty.
|
|
46
48
|
* @returns {QueryObject} Query payload ready to be passed to the API.
|
|
47
49
|
*
|
|
48
50
|
* Example:
|
|
@@ -63,12 +65,14 @@ var toFilterTuple = (filter) => {
|
|
|
63
65
|
* // }
|
|
64
66
|
* ```
|
|
65
67
|
*/
|
|
68
|
+
/** An empty string or list asks for every field, as no projection does. */
|
|
69
|
+
var hasProjection = (projection) => projection !== void 0 && projection.length > 0;
|
|
66
70
|
var buildQueryObject = (params) => {
|
|
67
71
|
const { filters, pageSize, pageToken, order, projection } = params;
|
|
68
72
|
return {
|
|
69
73
|
filters: filters.map(toFilterTuple),
|
|
70
74
|
order,
|
|
71
|
-
|
|
75
|
+
...hasProjection(projection) && { projection },
|
|
72
76
|
page_size: pageSize,
|
|
73
77
|
page_token: pageToken
|
|
74
78
|
};
|
|
@@ -76,25 +80,62 @@ var buildQueryObject = (params) => {
|
|
|
76
80
|
/**
|
|
77
81
|
* buildQueryKey
|
|
78
82
|
*
|
|
79
|
-
* Builds
|
|
80
|
-
*
|
|
83
|
+
* Builds the React Query cache key of a list read: the base keys, then one object holding
|
|
84
|
+
* everything that changes the response.
|
|
81
85
|
*
|
|
82
|
-
*
|
|
86
|
+
* Every part of the request is in the key, not only the filter values. The key used to be
|
|
87
|
+
* `[...keys, ...values]`, so a `-data` metadata read and a full read of the same workspace,
|
|
88
|
+
* or `date = X` and `date >= X`, shared one cache entry and one of them rendered the other's
|
|
89
|
+
* data. Filters go in as the tuples the API receives, so field and operator are included.
|
|
83
90
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
91
|
+
* The base keys stay in front, so prefix invalidation keeps working:
|
|
92
|
+
* `invalidateQueries({ queryKey: ["workflow_executions", workflowId] })`.
|
|
93
|
+
*
|
|
94
|
+
* @param {(string | number | null)[]} keys - Base keys (entity name, then any ids).
|
|
95
|
+
* @param {FilterClause[]} filters - The filters of the read.
|
|
96
|
+
* @param {QueryKeyParams} [params] - Order, projection, page size and paging mode.
|
|
86
97
|
* @returns {unknown[]} Cache key array for use in `queryKey`.
|
|
87
98
|
*
|
|
88
99
|
* Example:
|
|
89
100
|
* ```ts
|
|
90
|
-
* buildQueryKey(["datastores"], [{ field: "workspace", value: "ws-1" }]);
|
|
91
|
-
* // -> ["datastores", "ws-1"]
|
|
101
|
+
* buildQueryKey(["datastores"], [{ field: "workspace", value: "ws-1" }], { pageSize: 10 });
|
|
102
|
+
* // -> ["datastores", { filters: [["workspace", "ws-1"]], pageSize: 10 }]
|
|
92
103
|
* ```
|
|
93
104
|
*/
|
|
94
|
-
var buildQueryKey = (keys, filters) => {
|
|
95
|
-
return [...keys,
|
|
105
|
+
var buildQueryKey = (keys, filters, { order, projection, pageSize, fetchAllPages, dataFormat } = {}) => {
|
|
106
|
+
return [...keys, {
|
|
107
|
+
filters: filters.map(toFilterTuple),
|
|
108
|
+
...order?.length ? { order } : {},
|
|
109
|
+
...hasProjection(projection) ? { projection } : {},
|
|
110
|
+
...pageSize !== void 0 ? { pageSize } : {},
|
|
111
|
+
...fetchAllPages ? { fetchAllPages } : {},
|
|
112
|
+
...dataFormat ? { dataFormat } : {}
|
|
113
|
+
}];
|
|
96
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* hasWorkspaceFilter
|
|
117
|
+
*
|
|
118
|
+
* Whether a read can be sent: every endpoint that takes filters rejects a request with no
|
|
119
|
+
* workspace. It reads the workspace through `workspaceOf`, as the list functions in `api/` do:
|
|
120
|
+
* while each read it its own way, it passed on a filter the request then ignored.
|
|
121
|
+
*
|
|
122
|
+
* @param {FilterClause[]} filters - The filters of the read.
|
|
123
|
+
* @returns {boolean} True when the first `workspace` filter carries a value.
|
|
124
|
+
*/
|
|
125
|
+
var hasWorkspaceFilter = (filters) => Boolean(workspaceOf(filters.map(toFilterTuple)));
|
|
126
|
+
/**
|
|
127
|
+
* missingWorkspaceError
|
|
128
|
+
*
|
|
129
|
+
* The reason a hook gives, as `configError`, when it has no workspace to read. A missing
|
|
130
|
+
* workspace is a misconfigured app, never a state to wait out: the app config is merged into
|
|
131
|
+
* `window.APP_CONFIG` before the app renders, so an empty value there is a wrong or misspelled
|
|
132
|
+
* key. The message names the hook, so it points at the call to fix.
|
|
133
|
+
*
|
|
134
|
+
* @param {string} hookName - The hook that could not send its request.
|
|
135
|
+
* @returns {string} The error message.
|
|
136
|
+
*/
|
|
137
|
+
var missingWorkspaceError = (hookName) => `[apps-sdk] ${hookName}: the "workspace" filter is missing or empty, so the request was not sent. Check the workspace the app config provides.`;
|
|
97
138
|
//#endregion
|
|
98
|
-
export { buildQueryKey, buildQueryObject, toFilterTuple };
|
|
139
|
+
export { buildQueryKey, buildQueryObject, hasWorkspaceFilter, missingWorkspaceError, toFilterTuple };
|
|
99
140
|
|
|
100
141
|
//# sourceMappingURL=entityQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityQuery.js","names":[],"sources":["../../src/api/entityQuery.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"entityQuery.js","names":[],"sources":["../../src/api/entityQuery.ts"],"sourcesContent":["import type {\n FilterClause,\n FilterExpression,\n EntityQueryParams,\n Projection,\n QueryObject,\n} from \"@/types/entityQuery\";\nimport { workspaceOf } from \"./request\";\n\n/**\n * toFilterTuple\n *\n * Converts a `FilterClause` object into a `FilterExpression` tuple\n * compatible with the API query format.\n *\n * - If no operator is provided or operator is `\"=\"`, returns a 2-tuple `[field, value]`.\n * - Otherwise, returns a 3-tuple `[field, op, value]`.\n *\n * @param {FilterClause} filter - Filter clause to convert.\n * @returns {FilterExpression} Tuple representation of the filter.\n *\n * Examples:\n * ```ts\n * toFilterTuple({ field: \"workspace\", value: \"ws-1\" })\n * // -> [\"workspace\", \"ws-1\"]\n *\n * toFilterTuple({ field: \"age\", op: \">=\", value: 18 })\n * // -> [\"age\", \">=\", 18]\n * ```\n */\nexport const toFilterTuple = (filter: FilterClause): FilterExpression => {\n const { field, op, value } = filter;\n if (!op || op === \"=\") {\n return [field, value];\n }\n return [field, op, value];\n};\n\n/**\n * buildQueryObject\n *\n * Builds the query payload object to be sent to the API,\n * converting filters, ordering, pagination, and projection into the expected format.\n *\n * @param {EntityQueryParams} params - Query parameters.\n * @param {FilterClause[]} params.filters - Filters to apply (converted via `toFilterTuple`).\n * @param {string[]} params.order - Sorting fields.\n * @param {number} [params.pageSize] - Number of items per page.\n * @param {string} [params.pageToken] - Cursor token for the next page.\n * @param {Projection} [params.projection] - The fields to return: one, or a list. `\"field\"`\n * returns only that field (every other field comes back null); `\"-field\"` returns all fields\n * except that one. Pass several as a list, never comma-joined: `\"a,b\"` is a 500. Omitted from\n * the payload when empty.\n * @returns {QueryObject} Query payload ready to be passed to the API.\n *\n * Example:\n * ```ts\n * buildQueryObject({\n * filters: [{ field: \"workspace\", value: \"ws-1\" }],\n * order: [\"name\"], // plain field name(s) only — no \"asc\"/\"desc\" suffix\n * pageSize: 10,\n * pageToken: \"token-abc\",\n * projection: \"name\",\n * });\n * // -> {\n * // filters: [[\"workspace\", \"ws-1\"]],\n * // order: [\"name\"],\n * // projection: \"name\",\n * // page_size: 10,\n * // page_token: \"token-abc\",\n * // }\n * ```\n */\n/** An empty string or list asks for every field, as no projection does. */\nconst hasProjection = (projection: Projection | undefined): projection is Projection =>\n projection !== undefined && projection.length > 0;\n\nexport const buildQueryObject = (params: EntityQueryParams): QueryObject => {\n const { filters, pageSize, pageToken, order, projection } = params;\n\n return {\n filters: filters.map(toFilterTuple),\n order,\n ...(hasProjection(projection) && { projection }),\n page_size: pageSize,\n page_token: pageToken,\n };\n};\n\n/** What, besides the filters, changes the response a list read gets back. */\nexport type QueryKeyParams = {\n order?: string[];\n projection?: Projection;\n pageSize?: number;\n fetchAllPages?: boolean;\n /** The datastore hooks' `dataFormat`. In the key whenever a hook passes it; only those hooks do. */\n dataFormat?: \"object\" | \"matrix\";\n};\n\n/**\n * buildQueryKey\n *\n * Builds the React Query cache key of a list read: the base keys, then one object holding\n * everything that changes the response.\n *\n * Every part of the request is in the key, not only the filter values. The key used to be\n * `[...keys, ...values]`, so a `-data` metadata read and a full read of the same workspace,\n * or `date = X` and `date >= X`, shared one cache entry and one of them rendered the other's\n * data. Filters go in as the tuples the API receives, so field and operator are included.\n *\n * The base keys stay in front, so prefix invalidation keeps working:\n * `invalidateQueries({ queryKey: [\"workflow_executions\", workflowId] })`.\n *\n * @param {(string | number | null)[]} keys - Base keys (entity name, then any ids).\n * @param {FilterClause[]} filters - The filters of the read.\n * @param {QueryKeyParams} [params] - Order, projection, page size and paging mode.\n * @returns {unknown[]} Cache key array for use in `queryKey`.\n *\n * Example:\n * ```ts\n * buildQueryKey([\"datastores\"], [{ field: \"workspace\", value: \"ws-1\" }], { pageSize: 10 });\n * // -> [\"datastores\", { filters: [[\"workspace\", \"ws-1\"]], pageSize: 10 }]\n * ```\n */\nexport const buildQueryKey = (\n keys: (string | number | null)[],\n filters: FilterClause[],\n { order, projection, pageSize, fetchAllPages, dataFormat }: QueryKeyParams = {},\n): unknown[] => {\n return [\n ...keys,\n {\n filters: filters.map(toFilterTuple),\n ...(order?.length ? { order } : {}),\n // The request omits an empty projection, so the key must not tell it apart.\n ...(hasProjection(projection) ? { projection } : {}),\n ...(pageSize !== undefined ? { pageSize } : {}),\n ...(fetchAllPages ? { fetchAllPages } : {}),\n ...(dataFormat ? { dataFormat } : {}),\n },\n ];\n};\n\n/**\n * hasWorkspaceFilter\n *\n * Whether a read can be sent: every endpoint that takes filters rejects a request with no\n * workspace. It reads the workspace through `workspaceOf`, as the list functions in `api/` do:\n * while each read it its own way, it passed on a filter the request then ignored.\n *\n * @param {FilterClause[]} filters - The filters of the read.\n * @returns {boolean} True when the first `workspace` filter carries a value.\n */\nexport const hasWorkspaceFilter = (filters: FilterClause[]): boolean =>\n Boolean(workspaceOf(filters.map(toFilterTuple)));\n\n/**\n * missingWorkspaceError\n *\n * The reason a hook gives, as `configError`, when it has no workspace to read. A missing\n * workspace is a misconfigured app, never a state to wait out: the app config is merged into\n * `window.APP_CONFIG` before the app renders, so an empty value there is a wrong or misspelled\n * key. The message names the hook, so it points at the call to fix.\n *\n * @param {string} hookName - The hook that could not send its request.\n * @returns {string} The error message.\n */\nexport const missingWorkspaceError = (hookName: string): string =>\n `[apps-sdk] ${hookName}: the \"workspace\" filter is missing or empty, so the request was not ` +\n \"sent. Check the workspace the app config provides.\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,iBAAiB,WAA2C;CACrE,MAAM,EAAE,OAAO,IAAI,UAAU;CAC7B,IAAI,CAAC,MAAM,OAAO,KACd,OAAO,CAAC,OAAO,KAAK;CAExB,OAAO;EAAC;EAAO;EAAI;CAAK;AAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAM,iBAAiB,eACnB,eAAe,KAAA,KAAa,WAAW,SAAS;AAEpD,IAAa,oBAAoB,WAA2C;CACxE,MAAM,EAAE,SAAS,UAAU,WAAW,OAAO,eAAe;CAE5D,OAAO;EACH,SAAS,QAAQ,IAAI,aAAa;EAClC;EACA,GAAI,cAAc,UAAU,KAAK,EAAE,WAAW;EAC9C,WAAW;EACX,YAAY;CAChB;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAa,iBACT,MACA,SACA,EAAE,OAAO,YAAY,UAAU,eAAe,eAA+B,CAAC,MAClE;CACZ,OAAO,CACH,GAAG,MACH;EACI,SAAS,QAAQ,IAAI,aAAa;EAClC,GAAI,OAAO,SAAS,EAAE,MAAM,IAAI,CAAC;EAEjC,GAAI,cAAc,UAAU,IAAI,EAAE,WAAW,IAAI,CAAC;EAClD,GAAI,aAAa,KAAA,IAAY,EAAE,SAAS,IAAI,CAAC;EAC7C,GAAI,gBAAgB,EAAE,cAAc,IAAI,CAAC;EACzC,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;CACvC,CACJ;AACJ;;;;;;;;;;;AAYA,IAAa,sBAAsB,YAC/B,QAAQ,YAAY,QAAQ,IAAI,aAAa,CAAC,CAAC;;;;;;;;;;;;AAanD,IAAa,yBAAyB,aAClC,cAAc,SAAS"}
|