@everysk/apps-sdk 0.2.0 → 0.3.0-beta-20261016180126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +298 -12
- package/dist/EveryskApp.d.ts +34 -2
- package/dist/EveryskApp.d.ts.map +1 -1
- package/dist/EveryskApp.js +35 -2
- package/dist/EveryskApp.js.map +1 -1
- package/dist/agGrid/handleRowsScrollEnd.d.ts +53 -0
- package/dist/agGrid/handleRowsScrollEnd.d.ts.map +1 -0
- package/dist/agGrid/handleRowsScrollEnd.js +47 -0
- package/dist/agGrid/handleRowsScrollEnd.js.map +1 -0
- package/dist/agGrid/index.d.ts +2 -0
- package/dist/agGrid/index.d.ts.map +1 -1
- package/dist/agGrid/index.js +2 -1
- package/dist/api/datastore.d.ts +10 -8
- package/dist/api/datastore.d.ts.map +1 -1
- package/dist/api/datastore.js +24 -55
- package/dist/api/datastore.js.map +1 -1
- package/dist/api/entityQuery.d.ts +46 -41
- package/dist/api/entityQuery.d.ts.map +1 -1
- package/dist/api/entityQuery.js +55 -14
- package/dist/api/entityQuery.js.map +1 -1
- package/dist/api/file.d.ts +26 -9
- package/dist/api/file.d.ts.map +1 -1
- package/dist/api/file.js +45 -55
- package/dist/api/file.js.map +1 -1
- package/dist/api/portfolio.d.ts +11 -8
- package/dist/api/portfolio.d.ts.map +1 -1
- package/dist/api/portfolio.js +24 -55
- package/dist/api/portfolio.js.map +1 -1
- package/dist/api/profile.d.ts +3 -2
- package/dist/api/profile.d.ts.map +1 -1
- package/dist/api/profile.js +4 -9
- package/dist/api/profile.js.map +1 -1
- package/dist/api/request.d.ts +106 -0
- package/dist/api/request.d.ts.map +1 -0
- package/dist/api/request.js +132 -0
- package/dist/api/request.js.map +1 -0
- package/dist/api/websocketsConfig.d.ts +7 -2
- package/dist/api/websocketsConfig.d.ts.map +1 -1
- package/dist/api/websocketsConfig.js +2 -10
- package/dist/api/websocketsConfig.js.map +1 -1
- package/dist/api/workflow.d.ts +84 -89
- package/dist/api/workflow.d.ts.map +1 -1
- package/dist/api/workflow.js +121 -208
- package/dist/api/workflow.js.map +1 -1
- package/dist/api/workspace.d.ts +18 -8
- package/dist/api/workspace.d.ts.map +1 -1
- package/dist/api/workspace.js +21 -26
- package/dist/api/workspace.js.map +1 -1
- package/dist/components/ui/Footer/index.d.ts.map +1 -1
- package/dist/components/ui/Footer/index.js.map +1 -1
- package/dist/components/ui/GlobalLoading/index.d.ts.map +1 -1
- package/dist/components/ui/GlobalLoading/index.js.map +1 -1
- package/dist/components/ui/PageContainer/index.d.ts +1 -1
- package/dist/components/ui/PageContainer/index.d.ts.map +1 -1
- package/dist/components/ui/PageContainer/index.js.map +1 -1
- package/dist/components/ui/Toolbar/index.d.ts +40 -3
- package/dist/components/ui/Toolbar/index.d.ts.map +1 -1
- package/dist/components/ui/Toolbar/index.js +42 -15
- package/dist/components/ui/Toolbar/index.js.map +1 -1
- package/dist/contexts/appAlertContext/provider.js.map +1 -1
- package/dist/contexts/appAlertContext/types.d.ts.map +1 -1
- package/dist/contexts/appConfigContext/index.d.ts.map +1 -1
- package/dist/contexts/appConfigContext/index.js.map +1 -1
- package/dist/contexts/appConfigContext/provider.d.ts.map +1 -1
- package/dist/contexts/appConfigContext/provider.js.map +1 -1
- package/dist/contexts/webSocketContext/handler.d.ts +3 -2
- package/dist/contexts/webSocketContext/handler.d.ts.map +1 -1
- package/dist/contexts/webSocketContext/handler.js.map +1 -1
- package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts +1 -1
- package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js +1 -1
- package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js.map +1 -1
- package/dist/contexts/webSocketContext/provider.d.ts +6 -3
- package/dist/contexts/webSocketContext/provider.d.ts.map +1 -1
- package/dist/contexts/webSocketContext/provider.js +42 -7
- package/dist/contexts/webSocketContext/provider.js.map +1 -1
- package/dist/contexts/webSocketContext/types.d.ts +7 -5
- package/dist/contexts/webSocketContext/types.d.ts.map +1 -1
- package/dist/file/index.d.ts +2 -0
- package/dist/file/index.d.ts.map +1 -1
- package/dist/hooks/datastore/useDatastoreMutations.d.ts +4 -4
- package/dist/hooks/datastore/useDatastoreMutations.d.ts.map +1 -1
- package/dist/hooks/datastore/useDatastoreMutations.js +17 -55
- package/dist/hooks/datastore/useDatastoreMutations.js.map +1 -1
- package/dist/hooks/datastore/useFetchDatastore.d.ts +30 -41
- package/dist/hooks/datastore/useFetchDatastore.d.ts.map +1 -1
- package/dist/hooks/datastore/useFetchDatastore.js +25 -59
- package/dist/hooks/datastore/useFetchDatastore.js.map +1 -1
- package/dist/hooks/datastore/useFetchDatastores.d.ts +47 -52
- package/dist/hooks/datastore/useFetchDatastores.d.ts.map +1 -1
- package/dist/hooks/datastore/useFetchDatastores.js +55 -70
- package/dist/hooks/datastore/useFetchDatastores.js.map +1 -1
- package/dist/hooks/file/fileData.d.ts +17 -0
- package/dist/hooks/file/fileData.d.ts.map +1 -0
- package/dist/hooks/file/fileData.js +10 -0
- package/dist/hooks/file/fileData.js.map +1 -0
- package/dist/hooks/file/useFetchFile.d.ts +38 -58
- package/dist/hooks/file/useFetchFile.d.ts.map +1 -1
- package/dist/hooks/file/useFetchFile.js +26 -66
- package/dist/hooks/file/useFetchFile.js.map +1 -1
- package/dist/hooks/file/useFetchFiles.d.ts +18 -52
- package/dist/hooks/file/useFetchFiles.d.ts.map +1 -1
- package/dist/hooks/file/useFetchFiles.js +53 -69
- package/dist/hooks/file/useFetchFiles.js.map +1 -1
- package/dist/hooks/file/useFileMutations.d.ts +9 -8
- package/dist/hooks/file/useFileMutations.d.ts.map +1 -1
- package/dist/hooks/file/useFileMutations.js +23 -60
- package/dist/hooks/file/useFileMutations.js.map +1 -1
- package/dist/hooks/portfolio/useFetchPortfolio.d.ts +16 -50
- package/dist/hooks/portfolio/useFetchPortfolio.d.ts.map +1 -1
- package/dist/hooks/portfolio/useFetchPortfolio.js +15 -63
- package/dist/hooks/portfolio/useFetchPortfolio.js.map +1 -1
- package/dist/hooks/portfolio/useFetchPortfolios.d.ts +13 -52
- package/dist/hooks/portfolio/useFetchPortfolios.d.ts.map +1 -1
- package/dist/hooks/portfolio/useFetchPortfolios.js +29 -71
- package/dist/hooks/portfolio/useFetchPortfolios.js.map +1 -1
- package/dist/hooks/portfolio/usePortfolioMutations.d.ts +8 -8
- package/dist/hooks/portfolio/usePortfolioMutations.d.ts.map +1 -1
- package/dist/hooks/portfolio/usePortfolioMutations.js +20 -58
- package/dist/hooks/portfolio/usePortfolioMutations.js.map +1 -1
- package/dist/hooks/profile/useFetchProfile.d.ts +18 -44
- package/dist/hooks/profile/useFetchProfile.d.ts.map +1 -1
- package/dist/hooks/profile/useFetchProfile.js +16 -48
- package/dist/hooks/profile/useFetchProfile.js.map +1 -1
- package/dist/hooks/useAxios.js.map +1 -1
- package/dist/hooks/useEntityInfiniteQuery.d.ts +88 -0
- package/dist/hooks/useEntityInfiniteQuery.d.ts.map +1 -0
- package/dist/hooks/useEntityInfiniteQuery.js +111 -0
- package/dist/hooks/useEntityInfiniteQuery.js.map +1 -0
- package/dist/hooks/useEntityMutation.d.ts +47 -0
- package/dist/hooks/useEntityMutation.d.ts.map +1 -0
- package/dist/hooks/useEntityMutation.js +58 -0
- package/dist/hooks/useEntityMutation.js.map +1 -0
- package/dist/hooks/useEntityQuery.d.ts +68 -0
- package/dist/hooks/useEntityQuery.d.ts.map +1 -0
- package/dist/hooks/useEntityQuery.js +75 -0
- package/dist/hooks/useEntityQuery.js.map +1 -0
- package/dist/hooks/workflow/useFetchWorkerExecution.d.ts +17 -34
- package/dist/hooks/workflow/useFetchWorkerExecution.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkerExecution.js +16 -46
- package/dist/hooks/workflow/useFetchWorkerExecution.js.map +1 -1
- package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts +179 -41
- package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkerExecutions.js +29 -62
- package/dist/hooks/workflow/useFetchWorkerExecutions.js.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflow.d.ts +16 -35
- package/dist/hooks/workflow/useFetchWorkflow.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflow.js +15 -48
- package/dist/hooks/workflow/useFetchWorkflow.js.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts +17 -34
- package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflowExecution.js +16 -46
- package/dist/hooks/workflow/useFetchWorkflowExecution.js.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts +22 -36
- package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflowExecutions.js +43 -56
- package/dist/hooks/workflow/useFetchWorkflowExecutions.js.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflows.d.ts +20 -37
- package/dist/hooks/workflow/useFetchWorkflows.d.ts.map +1 -1
- package/dist/hooks/workflow/useFetchWorkflows.js +32 -47
- package/dist/hooks/workflow/useFetchWorkflows.js.map +1 -1
- package/dist/hooks/workflow/useRunWorkflow.d.ts +21 -16
- package/dist/hooks/workflow/useRunWorkflow.d.ts.map +1 -1
- package/dist/hooks/workflow/useRunWorkflow.js +66 -29
- package/dist/hooks/workflow/useRunWorkflow.js.map +1 -1
- package/dist/hooks/workflow/useTriggerWorkflow.d.ts +20 -0
- package/dist/hooks/workflow/useTriggerWorkflow.d.ts.map +1 -0
- package/dist/hooks/workflow/useTriggerWorkflow.js +32 -0
- package/dist/hooks/workflow/useTriggerWorkflow.js.map +1 -0
- package/dist/hooks/workspace/useFetchWorkspace.d.ts +19 -34
- package/dist/hooks/workspace/useFetchWorkspace.d.ts.map +1 -1
- package/dist/hooks/workspace/useFetchWorkspace.js +16 -46
- package/dist/hooks/workspace/useFetchWorkspace.js.map +1 -1
- package/dist/hooks/workspace/useFetchWorkspaces.d.ts +17 -37
- package/dist/hooks/workspace/useFetchWorkspaces.d.ts.map +1 -1
- package/dist/hooks/workspace/useFetchWorkspaces.js +25 -47
- package/dist/hooks/workspace/useFetchWorkspaces.js.map +1 -1
- package/dist/index.d.ts +13 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -11
- package/dist/lib/abort.d.ts +58 -0
- package/dist/lib/abort.d.ts.map +1 -0
- package/dist/lib/abort.js +112 -0
- package/dist/lib/abort.js.map +1 -0
- package/dist/lib/datastoreTable.d.ts +59 -54
- package/dist/lib/datastoreTable.d.ts.map +1 -1
- package/dist/lib/datastoreTable.js +58 -62
- package/dist/lib/datastoreTable.js.map +1 -1
- package/dist/lib/file.d.ts +34 -0
- package/dist/lib/file.d.ts.map +1 -0
- package/dist/lib/file.js +63 -0
- package/dist/lib/file.js.map +1 -0
- package/dist/lib/queryClient.d.ts.map +1 -1
- package/dist/lib/queryClient.js.map +1 -1
- package/dist/lib/workflowRun.d.ts +91 -0
- package/dist/lib/workflowRun.d.ts.map +1 -0
- package/dist/lib/workflowRun.js +224 -0
- package/dist/lib/workflowRun.js.map +1 -0
- package/dist/socket/index.d.ts +1 -3
- package/dist/socket/index.d.ts.map +1 -1
- package/dist/socket/index.js +3 -5
- package/dist/test/mocks/index.d.ts +1 -1
- package/dist/test/mocks/index.d.ts.map +1 -1
- package/dist/test/renderWithProviders.d.ts +2 -2
- package/dist/test/renderWithProviders.d.ts.map +1 -1
- package/dist/test/renderWithProviders.js.map +1 -1
- package/dist/test/setup.js.map +1 -1
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/overrides/index.d.ts +4 -2
- package/dist/theme/overrides/index.d.ts.map +1 -1
- package/dist/theme/overrides/index.js +5 -3
- package/dist/theme/overrides/index.js.map +1 -1
- package/dist/theme/overrides/muiButton.d.ts +2 -2
- package/dist/theme/overrides/muiButton.js.map +1 -1
- package/dist/theme/overrides/muiCssBaseline.d.ts.map +1 -1
- package/dist/theme/overrides/muiCssBaseline.js.map +1 -1
- package/dist/theme/overrides/muiDatePicker.js.map +1 -1
- package/dist/theme/overrides/muiFormControl.js.map +1 -1
- package/dist/theme/overrides/muiIconButton.d.ts +2 -2
- package/dist/theme/overrides/muiIconButton.js.map +1 -1
- package/dist/theme/overrides/muiSelect.d.ts.map +1 -1
- package/dist/theme/overrides/muiSelect.js.map +1 -1
- package/dist/theme/overrides/muiSvgIcon.d.ts.map +1 -1
- package/dist/theme/overrides/muiSvgIcon.js.map +1 -1
- package/dist/theme/overrides/muiTextField.js.map +1 -1
- package/dist/theme/overrides/muiToggleButton.d.ts +2 -2
- package/dist/theme/overrides/muiToggleButton.js.map +1 -1
- package/dist/theme/overrides/muiToggleButtonGroup.d.ts +2 -2
- package/dist/theme/overrides/muiToggleButtonGroup.js.map +1 -1
- package/dist/theme/themes/DefaultDark.js +2 -2
- package/dist/theme/themes/DefaultDark.js.map +1 -1
- package/dist/theme/themes/DefaultLight.js +2 -2
- package/dist/theme/themes/DefaultLight.js.map +1 -1
- package/dist/theme/themes/EveryskDark.js +2 -2
- package/dist/theme/themes/EveryskDark.js.map +1 -1
- package/dist/theme/themes/EveryskLight.js +2 -2
- package/dist/theme/themes/EveryskLight.js.map +1 -1
- package/dist/theme/themes/MidnightEmber.js +2 -2
- package/dist/theme/themes/MidnightEmber.js.map +1 -1
- package/dist/types/anyRecord.d.ts.map +1 -1
- package/dist/types/datastore.d.ts +35 -5
- package/dist/types/datastore.d.ts.map +1 -1
- package/dist/types/datastoreDataFormat.d.ts +13 -0
- package/dist/types/datastoreDataFormat.d.ts.map +1 -0
- package/dist/types/entityQuery.d.ts +86 -16
- package/dist/types/entityQuery.d.ts.map +1 -1
- package/dist/types/file.d.ts +7 -3
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/portfolio.d.ts +1 -3
- package/dist/types/portfolio.d.ts.map +1 -1
- package/dist/types/profile.d.ts +0 -10
- package/dist/types/profile.d.ts.map +1 -1
- package/dist/types/workflow.d.ts +35 -6
- package/dist/types/workflow.d.ts.map +1 -1
- package/dist/types/workspace.d.ts +1 -2
- package/dist/types/workspace.d.ts.map +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/workflow/index.d.ts +2 -0
- package/dist/workflow/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/EveryskApp.tsx +53 -2
- package/src/agGrid/handleRowsScrollEnd.ts +71 -0
- package/src/agGrid/index.ts +5 -1
- package/src/api/datastore.ts +79 -107
- package/src/api/entityQuery.ts +86 -17
- package/src/api/file.ts +110 -103
- package/src/api/portfolio.ts +82 -125
- package/src/api/profile.ts +25 -18
- package/src/api/request.ts +168 -0
- package/src/api/websocketsConfig.ts +11 -19
- package/src/api/workflow.ts +232 -334
- package/src/api/workspace.ts +43 -43
- package/src/components/ui/Footer/index.tsx +8 -7
- package/src/components/ui/GlobalLoading/index.tsx +13 -3
- package/src/components/ui/PageContainer/index.tsx +9 -2
- package/src/components/ui/Toolbar/index.tsx +105 -30
- package/src/contexts/appAlertContext/provider.tsx +1 -1
- package/src/contexts/appAlertContext/types.ts +3 -3
- package/src/contexts/appConfigContext/index.tsx +1 -1
- package/src/contexts/appConfigContext/provider.tsx +1 -5
- package/src/contexts/webSocketContext/handler.ts +8 -2
- package/src/contexts/webSocketContext/hooks/useWebSocket/index.ts +1 -1
- package/src/contexts/webSocketContext/provider.tsx +64 -14
- package/src/contexts/webSocketContext/types.ts +7 -6
- package/src/file/index.ts +2 -0
- package/src/hooks/datastore/useDatastoreMutations.ts +19 -60
- package/src/hooks/datastore/useFetchDatastore.ts +45 -73
- package/src/hooks/datastore/useFetchDatastores.ts +106 -131
- package/src/hooks/file/fileData.ts +19 -0
- package/src/hooks/file/useFetchFile.ts +41 -76
- package/src/hooks/file/useFetchFiles.ts +92 -87
- package/src/hooks/file/useFileMutations.ts +23 -73
- package/src/hooks/portfolio/useFetchPortfolio.ts +26 -78
- package/src/hooks/portfolio/useFetchPortfolios.ts +50 -93
- package/src/hooks/portfolio/usePortfolioMutations.ts +22 -72
- package/src/hooks/profile/useFetchProfile.ts +24 -65
- package/src/hooks/useAxios.ts +5 -5
- package/src/hooks/useEntityInfiniteQuery.ts +193 -0
- package/src/hooks/useEntityMutation.ts +70 -0
- package/src/hooks/useEntityQuery.ts +117 -0
- package/src/hooks/workflow/useFetchWorkerExecution.ts +27 -56
- package/src/hooks/workflow/useFetchWorkerExecutions.ts +54 -79
- package/src/hooks/workflow/useFetchWorkflow.ts +24 -58
- package/src/hooks/workflow/useFetchWorkflowExecution.ts +27 -57
- package/src/hooks/workflow/useFetchWorkflowExecutions.ts +64 -73
- package/src/hooks/workflow/useFetchWorkflows.ts +48 -64
- package/src/hooks/workflow/useRunWorkflow.ts +82 -36
- package/src/hooks/workflow/useTriggerWorkflow.ts +36 -0
- package/src/hooks/workspace/useFetchWorkspace.ts +25 -58
- package/src/hooks/workspace/useFetchWorkspaces.ts +38 -69
- package/src/index.ts +34 -19
- package/src/lib/abort.ts +131 -0
- package/src/lib/datastoreTable.ts +127 -74
- package/src/lib/file.ts +67 -0
- package/src/lib/queryClient.ts +11 -13
- package/src/lib/workflowRun.ts +329 -0
- package/src/socket/index.ts +1 -3
- package/src/test/mocks/index.ts +1 -5
- package/src/test/renderWithProviders.tsx +8 -3
- package/src/test/setup.ts +16 -16
- package/src/theme/index.ts +1 -1
- package/src/theme/overrides/index.ts +5 -3
- package/src/theme/overrides/muiButton.ts +3 -3
- package/src/theme/overrides/muiCssBaseline.ts +11 -12
- package/src/theme/overrides/muiDatePicker.ts +2 -2
- package/src/theme/overrides/muiFormControl.ts +2 -2
- package/src/theme/overrides/muiIconButton.ts +3 -3
- package/src/theme/overrides/muiSelect.ts +2 -2
- package/src/theme/overrides/muiSvgIcon.ts +2 -2
- package/src/theme/overrides/muiTextField.ts +1 -1
- package/src/theme/overrides/muiToggleButton.ts +4 -4
- package/src/theme/overrides/muiToggleButtonGroup.ts +4 -4
- package/src/theme/themes/DefaultDark.ts +2 -2
- package/src/theme/themes/DefaultLight.ts +2 -2
- package/src/theme/themes/EveryskDark.ts +2 -2
- package/src/theme/themes/EveryskLight.ts +2 -2
- package/src/theme/themes/MidnightEmber.ts +15 -15
- package/src/types/anyRecord.ts +2 -2
- package/src/types/datastore.ts +56 -22
- package/src/types/datastoreDataFormat.ts +12 -0
- package/src/types/entityQuery.ts +122 -38
- package/src/types/file.ts +8 -6
- package/src/types/portfolio.ts +70 -74
- package/src/types/profile.ts +0 -11
- package/src/types/workflow.ts +38 -9
- package/src/types/workspace.ts +2 -4
- package/src/ui/index.ts +1 -1
- package/src/workflow/index.ts +5 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { useAxios } from "./../useAxios";
|
|
4
|
-
import { useAppAlert } from "@/contexts/appAlertContext/useAppAlert";
|
|
1
|
+
import { useAxios } from "@/hooks/useAxios";
|
|
2
|
+
import { useEntityMutation } from "@/hooks/useEntityMutation";
|
|
5
3
|
import type { Datastore } from "@/types/datastore";
|
|
6
4
|
import { deleteDatastore, createDatastore, updateDatastore } from "@/api/datastore";
|
|
7
5
|
|
|
@@ -23,9 +21,6 @@ type UseDatastoreMutationsProps = {
|
|
|
23
21
|
queryKey?: unknown[];
|
|
24
22
|
};
|
|
25
23
|
|
|
26
|
-
const getErrorMessage = (err: unknown, fallback: string) =>
|
|
27
|
-
err instanceof Error && err.message ? err.message : fallback;
|
|
28
|
-
|
|
29
24
|
/**
|
|
30
25
|
* useDatastoreMutations
|
|
31
26
|
*
|
|
@@ -79,7 +74,7 @@ const getErrorMessage = (err: unknown, fallback: string) =>
|
|
|
79
74
|
* Returns an object with the three TanStack Query mutation results:
|
|
80
75
|
* - `create`: UseMutationResult<Datastore, Error, CreateDatastoreProps, unknown>
|
|
81
76
|
* - `update`: UseMutationResult<Datastore, Error, UpdateDatastoreProps, unknown>
|
|
82
|
-
* - `remove`: UseMutationResult<
|
|
77
|
+
* - `remove`: UseMutationResult<DeletedEntity, Error, DeleteDatastoreProps, unknown>
|
|
83
78
|
*
|
|
84
79
|
* Each mutation includes standard TanStack Query helpers:
|
|
85
80
|
* - `mutate(variables, options?)`
|
|
@@ -158,63 +153,27 @@ const getErrorMessage = (err: unknown, fallback: string) =>
|
|
|
158
153
|
|
|
159
154
|
export const useDatastoreMutations = ({ queryKey }: UseDatastoreMutationsProps) => {
|
|
160
155
|
const { api } = useAxios();
|
|
161
|
-
const { showAlert } = useAppAlert();
|
|
162
|
-
const queryClient = useQueryClient();
|
|
163
|
-
|
|
164
|
-
const invalidate = async () => {
|
|
165
|
-
if (!queryKey?.length) return;
|
|
166
|
-
await queryClient.invalidateQueries({ queryKey });
|
|
167
|
-
};
|
|
168
156
|
|
|
169
|
-
const create =
|
|
170
|
-
mutationFn:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
severity: "success",
|
|
175
|
-
message: "Datastore created successfully.",
|
|
176
|
-
});
|
|
177
|
-
},
|
|
178
|
-
onError: (err: unknown) => {
|
|
179
|
-
showAlert({
|
|
180
|
-
severity: "error",
|
|
181
|
-
message: getErrorMessage(err, "Unable to create the datastore. Please try again."),
|
|
182
|
-
});
|
|
183
|
-
},
|
|
157
|
+
const create = useEntityMutation({
|
|
158
|
+
mutationFn: ({ data }: CreateDatastoreProps) => createDatastore(api, data),
|
|
159
|
+
queryKey,
|
|
160
|
+
successMessage: "Datastore created successfully.",
|
|
161
|
+
errorMessage: "Unable to create the datastore. Please try again.",
|
|
184
162
|
});
|
|
185
163
|
|
|
186
|
-
const update =
|
|
187
|
-
mutationFn:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
severity: "success",
|
|
192
|
-
message: "Datastore updated successfully.",
|
|
193
|
-
});
|
|
194
|
-
},
|
|
195
|
-
onError: (err: unknown) => {
|
|
196
|
-
showAlert({
|
|
197
|
-
severity: "error",
|
|
198
|
-
message: getErrorMessage(err, "Unable to update the datastore. Please try again."),
|
|
199
|
-
});
|
|
200
|
-
},
|
|
164
|
+
const update = useEntityMutation({
|
|
165
|
+
mutationFn: ({ id, data }: UpdateDatastoreProps) => updateDatastore(api, id, data),
|
|
166
|
+
queryKey,
|
|
167
|
+
successMessage: "Datastore updated successfully.",
|
|
168
|
+
errorMessage: "Unable to update the datastore. Please try again.",
|
|
201
169
|
});
|
|
202
170
|
|
|
203
|
-
const remove =
|
|
204
|
-
mutationFn:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
message: "Datastore deleted successfully.",
|
|
210
|
-
});
|
|
211
|
-
},
|
|
212
|
-
onError: (err: unknown) => {
|
|
213
|
-
showAlert({
|
|
214
|
-
severity: "error",
|
|
215
|
-
message: getErrorMessage(err, "Unable to delete the datastore. Please try again."),
|
|
216
|
-
});
|
|
217
|
-
},
|
|
171
|
+
const remove = useEntityMutation({
|
|
172
|
+
mutationFn: ({ id, workspace }: DeleteDatastoreProps) =>
|
|
173
|
+
deleteDatastore(api, id, workspace),
|
|
174
|
+
queryKey,
|
|
175
|
+
successMessage: "Datastore deleted successfully.",
|
|
176
|
+
errorMessage: "Unable to delete the datastore. Please try again.",
|
|
218
177
|
});
|
|
219
178
|
|
|
220
179
|
return { create, update, remove };
|
|
@@ -1,95 +1,67 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
import { useQuery } from "@tanstack/react-query";
|
|
4
|
-
|
|
5
1
|
import { useAxios } from "@/hooks/useAxios";
|
|
6
|
-
import {
|
|
2
|
+
import { useEntityQuery } from "@/hooks/useEntityQuery";
|
|
3
|
+
import { missingWorkspaceError } from "@/api/entityQuery";
|
|
7
4
|
import { getDatastore } from "@/api/datastore";
|
|
8
|
-
import {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
|
|
12
|
-
export type FetchDatastoreProps = FetchEntityParams<DatastoreWithRows>;
|
|
5
|
+
import { parseDatastore } from "@/lib/datastoreTable";
|
|
6
|
+
import type { ParsedDatastore } from "@/types/datastore";
|
|
7
|
+
import type { DatastoreDataFormat } from "@/types/datastoreDataFormat";
|
|
8
|
+
import type { FetchEntityByIdProps } from "@/types/entityQuery";
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
export type FetchDatastoreProps<
|
|
11
|
+
F extends DatastoreDataFormat = "object",
|
|
12
|
+
TSelected = ParsedDatastore<F>,
|
|
13
|
+
> = FetchEntityByIdProps<ParsedDatastore<F>, TSelected> & {
|
|
14
|
+
/**
|
|
15
|
+
* Tabular datastores only: `"object"` (default) turns the matrix into one object per row;
|
|
16
|
+
* `"matrix"` leaves the matrix, header row included. A JSON datastore's `data` is unchanged either way.
|
|
17
|
+
*/
|
|
18
|
+
dataFormat?: F;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* useFetchDatastore
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* Important notes:
|
|
29
|
-
* - Returns a `DatastoreWithRows` object: the full `Datastore` shape with `data`
|
|
30
|
-
* replaced by `AnyRecord[]` (rows transformed via `tableToObjects`).
|
|
31
|
-
*
|
|
32
|
-
* Parameters (FetchDatastoreProps):
|
|
33
|
-
* @param {string} id
|
|
34
|
-
* Datastore identifier (required).
|
|
24
|
+
* Fetches one datastore. `data` is a `ParsedDatastore` — a table's matrix converted to row
|
|
25
|
+
* objects with `fields`, or a JSON datastore's content untouched, told apart by `format`, the
|
|
26
|
+
* same shape `useFetchDatastores` returns — or whatever `select` makes of it. With
|
|
27
|
+
* `dataFormat: "matrix"` a tabular datastore keeps its matrix unconverted, as in `useFetchDatastores`.
|
|
35
28
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
29
|
+
* Idle while `id` is empty; fails loudly, without a request, while `workspace` is. A failure is
|
|
30
|
+
* shown as an error alert.
|
|
38
31
|
*
|
|
39
|
-
* @param {
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* Returns:
|
|
43
|
-
* @returns {object}
|
|
44
|
-
* TanStack Query's `query` object extended with:
|
|
45
|
-
* - `queryKey`: the cache key used by React Query
|
|
32
|
+
* @param {FetchDatastoreProps} props - `id`, `workspace`, `dataFormat`, `select` and TanStack
|
|
33
|
+
* `queryOptions`.
|
|
34
|
+
* @returns {object} The `useQuery` result, plus `queryKey`.
|
|
46
35
|
*
|
|
47
36
|
* Example:
|
|
48
37
|
* ```ts
|
|
49
|
-
* const { data, isLoading } = useFetchDatastore({
|
|
50
|
-
* id: "abc123",
|
|
51
|
-
* workspace: "my-workspace",
|
|
52
|
-
* });
|
|
53
|
-
* // data -> DatastoreWithRows (datastore metadata + rows as AnyRecord[])
|
|
54
|
-
* // data.name -> "my-datastore"
|
|
55
|
-
* // data.data -> [{ datastoreId: "abc123", col1: "value", ... }]
|
|
38
|
+
* const { data, isLoading, queryKey } = useFetchDatastore({ id: "abc123", workspace: "ws-1" });
|
|
56
39
|
* ```
|
|
57
40
|
*/
|
|
58
|
-
export const useFetchDatastore =
|
|
59
|
-
|
|
41
|
+
export const useFetchDatastore = <
|
|
42
|
+
F extends DatastoreDataFormat = "object",
|
|
43
|
+
TSelected = ParsedDatastore<F>,
|
|
44
|
+
>({
|
|
45
|
+
id,
|
|
46
|
+
workspace,
|
|
47
|
+
dataFormat,
|
|
48
|
+
select,
|
|
49
|
+
queryOptions,
|
|
50
|
+
}: FetchDatastoreProps<F, TSelected>) => {
|
|
60
51
|
const { api } = useAxios();
|
|
61
|
-
const { showAlert } = useAppAlert();
|
|
62
52
|
|
|
63
|
-
const
|
|
53
|
+
const format = (dataFormat ?? "object") as F;
|
|
54
|
+
const queryKey = ["datastore", id, workspace, format];
|
|
64
55
|
|
|
65
|
-
const query =
|
|
56
|
+
const query = useEntityQuery<ParsedDatastore<F>, TSelected>({
|
|
66
57
|
queryKey,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
datastore.id,
|
|
74
|
-
datastore.data?.[0] as string[],
|
|
75
|
-
datastore.data
|
|
76
|
-
),
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
|
-
...queryOptions ?? {}
|
|
58
|
+
fetchEntity: async (signal) =>
|
|
59
|
+
parseDatastore(await getDatastore(api, id, workspace, signal), format),
|
|
60
|
+
select,
|
|
61
|
+
enabled: Boolean(id),
|
|
62
|
+
configError: workspace ? undefined : missingWorkspaceError("useFetchDatastore"),
|
|
63
|
+
queryOptions,
|
|
80
64
|
});
|
|
81
65
|
|
|
82
|
-
|
|
83
|
-
if (!query.error) return;
|
|
84
|
-
|
|
85
|
-
showAlert({
|
|
86
|
-
severity: "error",
|
|
87
|
-
message: query.error.message,
|
|
88
|
-
});
|
|
89
|
-
}, [query.error, showAlert]);
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
...query,
|
|
93
|
-
queryKey,
|
|
94
|
-
};
|
|
66
|
+
return { ...query, queryKey };
|
|
95
67
|
};
|
|
@@ -1,162 +1,137 @@
|
|
|
1
|
-
//import { useCallback, useMemo, useRef } from "react";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { useInfiniteQuery, type UseInfiniteQueryOptions, type QueryKey } from "@tanstack/react-query";
|
|
4
|
-
|
|
5
|
-
//import type { GridApi } from "ag-grid-community";
|
|
6
|
-
|
|
7
1
|
import { useAxios } from "@/hooks/useAxios";
|
|
8
|
-
import {
|
|
2
|
+
import { useEntityInfiniteQuery } from "@/hooks/useEntityInfiniteQuery";
|
|
3
|
+
import { parseDatastore } from "@/lib/datastoreTable";
|
|
9
4
|
import { listDatastores } from "@/api/datastore";
|
|
10
5
|
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
import type { DatastoreListResponse, ParsedDatastore } from "@/types/datastore";
|
|
7
|
+
import type { DatastoreDataFormat } from "@/types/datastoreDataFormat";
|
|
8
|
+
import type {
|
|
9
|
+
PagedResponse,
|
|
10
|
+
FetchEntitiesProps,
|
|
11
|
+
ListQueryProps,
|
|
12
|
+
ListCache,
|
|
13
|
+
} from "@/types/entityQuery";
|
|
14
|
+
import {
|
|
15
|
+
buildQueryKey,
|
|
16
|
+
buildQueryObject,
|
|
17
|
+
hasWorkspaceFilter,
|
|
18
|
+
missingWorkspaceError,
|
|
19
|
+
} from "@/api/entityQuery";
|
|
20
|
+
|
|
21
|
+
export type DatastoreQueryPage<F extends DatastoreDataFormat = "object"> = PagedResponse & {
|
|
22
|
+
datastores: ParsedDatastore<F>[];
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
/** The query cache of `useFetchDatastores`, for typing `setQueryData`. */
|
|
26
|
+
export type DatastoresCache<F extends DatastoreDataFormat = "object"> = ListCache<
|
|
27
|
+
DatastoreQueryPage<F>
|
|
28
|
+
>;
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
export type FetchDatastoresProps<
|
|
31
|
+
F extends DatastoreDataFormat = "object",
|
|
32
|
+
TData = ParsedDatastore<F>[],
|
|
33
|
+
> = ListQueryProps &
|
|
34
|
+
FetchEntitiesProps<ParsedDatastore<F>, TData, DatastoreQueryPage<F>> & {
|
|
35
|
+
/**
|
|
36
|
+
* Tabular datastores only: `"object"` (default) turns the matrix into one object per row;
|
|
37
|
+
* `"matrix"` leaves the matrix, header row included. A JSON datastore's `data` is unchanged either way.
|
|
38
|
+
*/
|
|
39
|
+
dataFormat?: F;
|
|
40
|
+
};
|
|
36
41
|
|
|
37
42
|
/**
|
|
38
43
|
* useFetchDatastores
|
|
39
44
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* It also:
|
|
44
|
-
* - flattens all pages into a single `DatastoreWithRows[]` via `select`
|
|
45
|
-
* - exposes `actions` for cache management
|
|
46
|
-
* - exposes `events` for ag-Grid integration
|
|
47
|
-
*
|
|
48
|
-
* Important notes:
|
|
49
|
-
* - `query.data` returns a flat `DatastoreWithRows[]` (all pages merged).
|
|
50
|
-
* - Each item retains the full `Datastore` shape, with `data` replaced by `AnyRecord[]` (rows transformed via `tableToObjects`).
|
|
45
|
+
* Lists datastores with cursor pagination. `query.data` is every loaded page merged into one
|
|
46
|
+
* `ParsedDatastore[]`, each datastore's matrix converted to row objects — or whatever
|
|
47
|
+
* `select` makes of that list.
|
|
51
48
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
49
|
+
* Built to be used directly rather than wrapped: `select` shapes the result, `queryKey` and
|
|
50
|
+
* `DatastoresCache` let an app write to the cache, and `fetchAllPages` reads a whole set.
|
|
51
|
+
* Paging on grid scroll is `handleRowsScrollEnd` from `@everysk/apps-sdk/ag-grid`, kept out of
|
|
52
|
+
* this hook so it works for any list.
|
|
55
53
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
54
|
+
* Without a `workspace` filter, or with an empty one, the read fails at once with an error
|
|
55
|
+
* naming this hook, logged to the console, and no request is sent. The app config is in place
|
|
56
|
+
* before the app renders, so a missing workspace is a misconfigured app, never a wait.
|
|
58
57
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
58
|
+
* Rows are converted in the request (`parseDatastore`), so the cache holds objects and an
|
|
59
|
+
* app patches a row as `{ ...row, ...patch }`. `dataFormat: "matrix"` skips the conversion and
|
|
60
|
+
* leaves a tabular datastore's matrix unconverted, for a grid that takes arrays, an export, or a
|
|
61
|
+
* datastore too large to convert. It is a value, not a conversion function, so that it can be
|
|
62
|
+
* part of the cache key: two callers converting differently would otherwise share one entry.
|
|
62
63
|
*
|
|
63
|
-
* @param {
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* @
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* - `events.handleFetchIfGridEmptyOrNearEnd(gridApi)`: triggers next page fetch when the ag-Grid is empty or near the end of the list
|
|
64
|
+
* @param {FilterClause[]} [filters=[]] - Filters of every page request; one must be `workspace`.
|
|
65
|
+
* @param {string[]} [order=[]] - Sorting of every page request.
|
|
66
|
+
* @param {Projection} [projection=""] - The fields to return, one or a list: `"field"` returns
|
|
67
|
+
* only that field (others come back null), `"-field"` every field but that one. Several go as a
|
|
68
|
+
* list, never comma-joined — `"a,b"` is a 500.
|
|
69
|
+
* @param {number} [pageSize=10] - Datastores per request.
|
|
70
|
+
* @param {"object" | "matrix"} [dataFormat="object"] - How a table's rows are handed over.
|
|
71
|
+
* @param {(datastores: ParsedDatastore[]) => TData} [select] - Shapes the merged list.
|
|
72
|
+
* @param {boolean} [fetchAllPages=false] - Reads to the last page before reporting success.
|
|
73
|
+
* @param {EntityInfiniteQueryOptions} [queryOptions] - Passed through to `useInfiniteQuery`.
|
|
74
|
+
* @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
|
|
75
75
|
*
|
|
76
76
|
* Example:
|
|
77
77
|
* ```ts
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* pageSize: 20,
|
|
81
|
-
* });
|
|
82
|
-
*
|
|
83
|
-
* // Flat list of all fetched datastores with transformed rows
|
|
84
|
-
* const datastores = query.data ?? [];
|
|
78
|
+
* // A list can mix tabular and JSON datastores; only a table's `data` is rows.
|
|
79
|
+
* const toRows = (datastores: ParsedDatastore[]) => datastores.filter(isTableDatastore).flatMap((d) => d.data);
|
|
85
80
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
81
|
+
* const { query } = useFetchDatastores({
|
|
82
|
+
* filters: [{ field: "workspace", value: workspace }],
|
|
83
|
+
* select: toRows, // query.data: AnyRecord[]
|
|
84
|
+
* });
|
|
88
85
|
* ```
|
|
89
86
|
*/
|
|
90
|
-
export function useFetchDatastores
|
|
87
|
+
export function useFetchDatastores<
|
|
88
|
+
F extends DatastoreDataFormat = "object",
|
|
89
|
+
TData = ParsedDatastore<F>[],
|
|
90
|
+
>({
|
|
91
|
+
filters = [],
|
|
92
|
+
order = [],
|
|
93
|
+
projection = "",
|
|
94
|
+
pageSize = 10,
|
|
95
|
+
dataFormat,
|
|
96
|
+
select,
|
|
97
|
+
fetchAllPages = false,
|
|
98
|
+
queryOptions,
|
|
99
|
+
}: FetchDatastoresProps<F, TData>) {
|
|
91
100
|
const { api } = useAxios();
|
|
92
101
|
|
|
93
|
-
|
|
94
|
-
const queryKey = buildQueryKey(["datastores"], filters
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
const format = (dataFormat ?? "object") as F;
|
|
103
|
+
const queryKey = buildQueryKey(["datastores"], filters, {
|
|
104
|
+
order,
|
|
105
|
+
projection,
|
|
106
|
+
pageSize,
|
|
107
|
+
fetchAllPages,
|
|
108
|
+
dataFormat: format,
|
|
109
|
+
});
|
|
100
110
|
|
|
101
|
-
const query =
|
|
111
|
+
const query = useEntityInfiniteQuery<DatastoreQueryPage<F>, "datastores", TData>({
|
|
102
112
|
queryKey,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
projection,
|
|
111
|
-
pageSize,
|
|
112
|
-
pageToken: pageParam ?? undefined,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const response: DatastoreListResponse = await listDatastores(api, queryFilter);
|
|
116
|
-
|
|
117
|
-
const nested: DatastoreWithRows[] = response.datastores.map((datastore: Datastore) => ({
|
|
118
|
-
...datastore,
|
|
119
|
-
data: tableToObjects(
|
|
120
|
-
datastore.id,
|
|
121
|
-
datastore.data?.[0] as string[],
|
|
122
|
-
datastore.data
|
|
123
|
-
),
|
|
124
|
-
}));
|
|
113
|
+
itemsKey: "datastores",
|
|
114
|
+
fetchPage: async (pageToken, signal) => {
|
|
115
|
+
const response: DatastoreListResponse = await listDatastores(
|
|
116
|
+
api,
|
|
117
|
+
buildQueryObject({ filters, order, projection, pageSize, pageToken }),
|
|
118
|
+
signal,
|
|
119
|
+
);
|
|
125
120
|
|
|
126
121
|
return {
|
|
127
122
|
next_page_token: response.next_page_token,
|
|
128
|
-
datastores:
|
|
123
|
+
datastores: response.datastores.map((datastore) =>
|
|
124
|
+
parseDatastore(datastore, format),
|
|
125
|
+
),
|
|
129
126
|
};
|
|
130
127
|
},
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
select,
|
|
129
|
+
fetchAllPages,
|
|
130
|
+
configError: hasWorkspaceFilter(filters)
|
|
131
|
+
? undefined
|
|
132
|
+
: missingWorkspaceError("useFetchDatastores"),
|
|
133
|
+
queryOptions,
|
|
135
134
|
});
|
|
136
135
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const handleFetchIfGridEmptyOrNearEnd = useCallback((gridApi: GridApi) => {
|
|
140
|
-
if (!hasNextPage || isFetchingNextPage || fetchingGuardRef.current) return;
|
|
141
|
-
|
|
142
|
-
const total = gridApi.getDisplayedRowCount();
|
|
143
|
-
const last = gridApi.getLastDisplayedRowIndex();
|
|
144
|
-
|
|
145
|
-
const isEmpty = total === 0 || last < 0;
|
|
146
|
-
const isNearEnd = !isEmpty && (total - 1 - last) <= 30;
|
|
147
|
-
|
|
148
|
-
if (!isEmpty && !isNearEnd) return;
|
|
149
|
-
|
|
150
|
-
fetchingGuardRef.current = true;
|
|
151
|
-
fetchNextPage().finally(() => {
|
|
152
|
-
fetchingGuardRef.current = false;
|
|
153
|
-
});
|
|
154
|
-
}, [hasNextPage, isFetchingNextPage, fetchNextPage]);
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
return {
|
|
158
|
-
query,
|
|
159
|
-
queryKey,
|
|
160
|
-
//events: { handleFetchIfGridEmptyOrNearEnd },
|
|
161
|
-
};
|
|
162
|
-
}
|
|
136
|
+
return { query, queryKey };
|
|
137
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EveryskFile } from "@/types/file";
|
|
2
|
+
|
|
3
|
+
/** What the file hooks take about a file's content. */
|
|
4
|
+
export type FileDataProps = {
|
|
5
|
+
/**
|
|
6
|
+
* `true` returns the content (`data`, base64). Left out by default: it is a third larger than
|
|
7
|
+
* the file, and showing or downloading a file needs only its `url` (`/file/<hash>`), which
|
|
8
|
+
* the platform serves inline with the user's session and the devkit's dev server serves too.
|
|
9
|
+
* With a list `projection` of the app's own that includes fields, `data` comes only if the
|
|
10
|
+
* projection names it.
|
|
11
|
+
*/
|
|
12
|
+
withData?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** The file without its content, as the hooks return it unless `withData` asks for it. */
|
|
16
|
+
export const withoutData = <F extends { data: EveryskFile["data"] }>(file: F): F => ({
|
|
17
|
+
...file,
|
|
18
|
+
data: null,
|
|
19
|
+
});
|