@everysk/apps-sdk 0.1.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 +395 -8
- 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 +6 -6
- 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,70 +1,65 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
export type DatastoreQueryPage = EntityDefaultResponse & {
|
|
7
|
-
datastores: DatastoreWithRows[];
|
|
1
|
+
import type { ParsedDatastore } from "../../types/datastore.d.ts";
|
|
2
|
+
import type { DatastoreDataFormat } from "../../types/datastoreDataFormat.d.ts";
|
|
3
|
+
import type { PagedResponse, FetchEntitiesProps, ListQueryProps, ListCache } from "../../types/entityQuery.d.ts";
|
|
4
|
+
export type DatastoreQueryPage<F extends DatastoreDataFormat = "object"> = PagedResponse & {
|
|
5
|
+
datastores: ParsedDatastore<F>[];
|
|
8
6
|
};
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
/** The query cache of `useFetchDatastores`, for typing `setQueryData`. */
|
|
8
|
+
export type DatastoresCache<F extends DatastoreDataFormat = "object"> = ListCache<DatastoreQueryPage<F>>;
|
|
9
|
+
export type FetchDatastoresProps<F extends DatastoreDataFormat = "object", TData = ParsedDatastore<F>[]> = ListQueryProps & FetchEntitiesProps<ParsedDatastore<F>, TData, DatastoreQueryPage<F>> & {
|
|
10
|
+
/**
|
|
11
|
+
* Tabular datastores only: `"object"` (default) turns the matrix into one object per row;
|
|
12
|
+
* `"matrix"` leaves the matrix, header row included. A JSON datastore's `data` is unchanged either way.
|
|
13
|
+
*/
|
|
14
|
+
dataFormat?: F;
|
|
11
15
|
};
|
|
12
16
|
/**
|
|
13
17
|
* useFetchDatastores
|
|
14
18
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
19
|
+
* Lists datastores with cursor pagination. `query.data` is every loaded page merged into one
|
|
20
|
+
* `ParsedDatastore[]`, each datastore's matrix converted to row objects — or whatever
|
|
21
|
+
* `select` makes of that list.
|
|
17
22
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
23
|
+
* Built to be used directly rather than wrapped: `select` shapes the result, `queryKey` and
|
|
24
|
+
* `DatastoresCache` let an app write to the cache, and `fetchAllPages` reads a whole set.
|
|
25
|
+
* Paging on grid scroll is `handleRowsScrollEnd` from `@everysk/apps-sdk/ag-grid`, kept out of
|
|
26
|
+
* this hook so it works for any list.
|
|
22
27
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
28
|
+
* Without a `workspace` filter, or with an empty one, the read fails at once with an error
|
|
29
|
+
* naming this hook, logged to the console, and no request is sent. The app config is in place
|
|
30
|
+
* before the app renders, so a missing workspace is a misconfigured app, never a wait.
|
|
26
31
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
32
|
+
* Rows are converted in the request (`parseDatastore`), so the cache holds objects and an
|
|
33
|
+
* app patches a row as `{ ...row, ...patch }`. `dataFormat: "matrix"` skips the conversion and
|
|
34
|
+
* leaves a tabular datastore's matrix unconverted, for a grid that takes arrays, an export, or a
|
|
35
|
+
* datastore too large to convert. It is a value, not a conversion function, so that it can be
|
|
36
|
+
* part of the cache key: two callers converting differently would otherwise share one entry.
|
|
30
37
|
*
|
|
31
|
-
* @param {
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param {
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @
|
|
42
|
-
* TanStack Query options passed through to `useInfiniteQuery`
|
|
43
|
-
* (e.g., enabled, staleTime, gcTime, etc.).
|
|
44
|
-
*
|
|
45
|
-
* Returns:
|
|
46
|
-
* @returns {object}
|
|
47
|
-
* - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)
|
|
48
|
-
* - `queryKey`: the cache key used by React Query
|
|
49
|
-
* - `events.handleFetchIfGridEmptyOrNearEnd(gridApi)`: triggers next page fetch when the ag-Grid is empty or near the end of the list
|
|
38
|
+
* @param {FilterClause[]} [filters=[]] - Filters of every page request; one must be `workspace`.
|
|
39
|
+
* @param {string[]} [order=[]] - Sorting of every page request.
|
|
40
|
+
* @param {Projection} [projection=""] - The fields to return, one or a list: `"field"` returns
|
|
41
|
+
* only that field (others come back null), `"-field"` every field but that one. Several go as a
|
|
42
|
+
* list, never comma-joined — `"a,b"` is a 500.
|
|
43
|
+
* @param {number} [pageSize=10] - Datastores per request.
|
|
44
|
+
* @param {"object" | "matrix"} [dataFormat="object"] - How a table's rows are handed over.
|
|
45
|
+
* @param {(datastores: ParsedDatastore[]) => TData} [select] - Shapes the merged list.
|
|
46
|
+
* @param {boolean} [fetchAllPages=false] - Reads to the last page before reporting success.
|
|
47
|
+
* @param {EntityInfiniteQueryOptions} [queryOptions] - Passed through to `useInfiniteQuery`.
|
|
48
|
+
* @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
|
|
50
49
|
*
|
|
51
50
|
* Example:
|
|
52
51
|
* ```ts
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* pageSize: 20,
|
|
56
|
-
* });
|
|
57
|
-
*
|
|
58
|
-
* // Flat list of all fetched datastores with transformed rows
|
|
59
|
-
* const datastores = query.data ?? [];
|
|
52
|
+
* // A list can mix tabular and JSON datastores; only a table's `data` is rows.
|
|
53
|
+
* const toRows = (datastores: ParsedDatastore[]) => datastores.filter(isTableDatastore).flatMap((d) => d.data);
|
|
60
54
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
55
|
+
* const { query } = useFetchDatastores({
|
|
56
|
+
* filters: [{ field: "workspace", value: workspace }],
|
|
57
|
+
* select: toRows, // query.data: AnyRecord[]
|
|
58
|
+
* });
|
|
63
59
|
* ```
|
|
64
60
|
*/
|
|
65
|
-
export declare function useFetchDatastores({ filters, order, projection, pageSize, queryOptions }:
|
|
66
|
-
query: import("@tanstack/react-query").UseInfiniteQueryResult<
|
|
61
|
+
export declare function useFetchDatastores<F extends DatastoreDataFormat = "object", TData = ParsedDatastore<F>[]>({ filters, order, projection, pageSize, dataFormat, select, fetchAllPages, queryOptions, }: FetchDatastoresProps<F, TData>): {
|
|
62
|
+
query: import("@tanstack/react-query").UseInfiniteQueryResult<TData, Error>;
|
|
67
63
|
queryKey: unknown[];
|
|
68
64
|
};
|
|
69
|
-
export {};
|
|
70
65
|
//# sourceMappingURL=useFetchDatastores.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchDatastores.d.ts","sourceRoot":"","sources":["../../../src/hooks/datastore/useFetchDatastores.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFetchDatastores.d.ts","sourceRoot":"","sources":["../../../src/hooks/datastore/useFetchDatastores.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAyB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EACR,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,SAAS,EACZ,MAAM,qBAAqB,CAAC;AAQ7B,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,mBAAmB,GAAG,QAAQ,IAAI,aAAa,GAAG;IACvF,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;CACpC,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,mBAAmB,GAAG,QAAQ,IAAI,SAAS,CAC7E,kBAAkB,CAAC,CAAC,CAAC,CACxB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAC5B,CAAC,SAAS,mBAAmB,GAAG,QAAQ,EACxC,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,IAC5B,cAAc,GACd,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG;IACnE;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,CAAC;CAClB,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,kBAAkB,CAC9B,CAAC,SAAS,mBAAmB,GAAG,QAAQ,EACxC,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,EAC9B,EACE,OAAY,EACZ,KAAU,EACV,UAAe,EACf,QAAa,EACb,UAAU,EACV,MAAM,EACN,aAAqB,EACrB,YAAY,GACf,EAAE,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC;;;EAsChC"}
|
|
@@ -1,100 +1,85 @@
|
|
|
1
1
|
import { useAxios } from "../useAxios.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useEntityInfiniteQuery } from "../useEntityInfiniteQuery.js";
|
|
3
|
+
import { buildQueryKey, buildQueryObject, hasWorkspaceFilter, missingWorkspaceError } from "../../api/entityQuery.js";
|
|
3
4
|
import { listDatastores } from "../../api/datastore.js";
|
|
4
|
-
import {
|
|
5
|
-
import { useMemo } from "react";
|
|
6
|
-
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
5
|
+
import { parseDatastore } from "../../lib/datastoreTable.js";
|
|
7
6
|
//#region src/hooks/datastore/useFetchDatastores.ts
|
|
8
|
-
var defaultQueryOptions = {
|
|
9
|
-
refetchOnMount: "always",
|
|
10
|
-
staleTime: 0,
|
|
11
|
-
gcTime: 0
|
|
12
|
-
};
|
|
13
7
|
/**
|
|
14
8
|
* useFetchDatastores
|
|
15
9
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
10
|
+
* Lists datastores with cursor pagination. `query.data` is every loaded page merged into one
|
|
11
|
+
* `ParsedDatastore[]`, each datastore's matrix converted to row objects — or whatever
|
|
12
|
+
* `select` makes of that list.
|
|
18
13
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
14
|
+
* Built to be used directly rather than wrapped: `select` shapes the result, `queryKey` and
|
|
15
|
+
* `DatastoresCache` let an app write to the cache, and `fetchAllPages` reads a whole set.
|
|
16
|
+
* Paging on grid scroll is `handleRowsScrollEnd` from `@everysk/apps-sdk/ag-grid`, kept out of
|
|
17
|
+
* this hook so it works for any list.
|
|
23
18
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
19
|
+
* Without a `workspace` filter, or with an empty one, the read fails at once with an error
|
|
20
|
+
* naming this hook, logged to the console, and no request is sent. The app config is in place
|
|
21
|
+
* before the app renders, so a missing workspace is a misconfigured app, never a wait.
|
|
27
22
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
23
|
+
* Rows are converted in the request (`parseDatastore`), so the cache holds objects and an
|
|
24
|
+
* app patches a row as `{ ...row, ...patch }`. `dataFormat: "matrix"` skips the conversion and
|
|
25
|
+
* leaves a tabular datastore's matrix unconverted, for a grid that takes arrays, an export, or a
|
|
26
|
+
* datastore too large to convert. It is a value, not a conversion function, so that it can be
|
|
27
|
+
* part of the cache key: two callers converting differently would otherwise share one entry.
|
|
31
28
|
*
|
|
32
|
-
* @param {
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param {
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
43
|
-
* TanStack Query options passed through to `useInfiniteQuery`
|
|
44
|
-
* (e.g., enabled, staleTime, gcTime, etc.).
|
|
45
|
-
*
|
|
46
|
-
* Returns:
|
|
47
|
-
* @returns {object}
|
|
48
|
-
* - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)
|
|
49
|
-
* - `queryKey`: the cache key used by React Query
|
|
50
|
-
* - `events.handleFetchIfGridEmptyOrNearEnd(gridApi)`: triggers next page fetch when the ag-Grid is empty or near the end of the list
|
|
29
|
+
* @param {FilterClause[]} [filters=[]] - Filters of every page request; one must be `workspace`.
|
|
30
|
+
* @param {string[]} [order=[]] - Sorting of every page request.
|
|
31
|
+
* @param {Projection} [projection=""] - The fields to return, one or a list: `"field"` returns
|
|
32
|
+
* only that field (others come back null), `"-field"` every field but that one. Several go as a
|
|
33
|
+
* list, never comma-joined — `"a,b"` is a 500.
|
|
34
|
+
* @param {number} [pageSize=10] - Datastores per request.
|
|
35
|
+
* @param {"object" | "matrix"} [dataFormat="object"] - How a table's rows are handed over.
|
|
36
|
+
* @param {(datastores: ParsedDatastore[]) => TData} [select] - Shapes the merged list.
|
|
37
|
+
* @param {boolean} [fetchAllPages=false] - Reads to the last page before reporting success.
|
|
38
|
+
* @param {EntityInfiniteQueryOptions} [queryOptions] - Passed through to `useInfiniteQuery`.
|
|
39
|
+
* @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
|
|
51
40
|
*
|
|
52
41
|
* Example:
|
|
53
42
|
* ```ts
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* pageSize: 20,
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* // Flat list of all fetched datastores with transformed rows
|
|
60
|
-
* const datastores = query.data ?? [];
|
|
43
|
+
* // A list can mix tabular and JSON datastores; only a table's `data` is rows.
|
|
44
|
+
* const toRows = (datastores: ParsedDatastore[]) => datastores.filter(isTableDatastore).flatMap((d) => d.data);
|
|
61
45
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
46
|
+
* const { query } = useFetchDatastores({
|
|
47
|
+
* filters: [{ field: "workspace", value: workspace }],
|
|
48
|
+
* select: toRows, // query.data: AnyRecord[]
|
|
49
|
+
* });
|
|
64
50
|
* ```
|
|
65
51
|
*/
|
|
66
|
-
function useFetchDatastores({ filters = [], order = [], projection = "", pageSize = 10, queryOptions }) {
|
|
52
|
+
function useFetchDatastores({ filters = [], order = [], projection = "", pageSize = 10, dataFormat, select, fetchAllPages = false, queryOptions }) {
|
|
67
53
|
const { api } = useAxios();
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
54
|
+
const format = dataFormat ?? "object";
|
|
55
|
+
const queryKey = buildQueryKey(["datastores"], filters, {
|
|
56
|
+
order,
|
|
57
|
+
projection,
|
|
58
|
+
pageSize,
|
|
59
|
+
fetchAllPages,
|
|
60
|
+
dataFormat: format
|
|
61
|
+
});
|
|
73
62
|
return {
|
|
74
|
-
query:
|
|
63
|
+
query: useEntityInfiniteQuery({
|
|
75
64
|
queryKey,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const queryFilter = buildQueryObject({
|
|
65
|
+
itemsKey: "datastores",
|
|
66
|
+
fetchPage: async (pageToken, signal) => {
|
|
67
|
+
const response = await listDatastores(api, buildQueryObject({
|
|
80
68
|
filters,
|
|
81
69
|
order,
|
|
82
70
|
projection,
|
|
83
71
|
pageSize,
|
|
84
|
-
pageToken
|
|
85
|
-
});
|
|
86
|
-
const response = await listDatastores(api, queryFilter);
|
|
87
|
-
const nested = response.datastores.map((datastore) => ({
|
|
88
|
-
...datastore,
|
|
89
|
-
data: tableToObjects(datastore.id, datastore.data?.[0], datastore.data)
|
|
90
|
-
}));
|
|
72
|
+
pageToken
|
|
73
|
+
}), signal);
|
|
91
74
|
return {
|
|
92
75
|
next_page_token: response.next_page_token,
|
|
93
|
-
datastores:
|
|
76
|
+
datastores: response.datastores.map((datastore) => parseDatastore(datastore, format))
|
|
94
77
|
};
|
|
95
78
|
},
|
|
96
|
-
select
|
|
97
|
-
|
|
79
|
+
select,
|
|
80
|
+
fetchAllPages,
|
|
81
|
+
configError: hasWorkspaceFilter(filters) ? void 0 : missingWorkspaceError("useFetchDatastores"),
|
|
82
|
+
queryOptions
|
|
98
83
|
}),
|
|
99
84
|
queryKey
|
|
100
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchDatastores.js","names":[],"sources":["../../../src/hooks/datastore/useFetchDatastores.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"useFetchDatastores.js","names":[],"sources":["../../../src/hooks/datastore/useFetchDatastores.ts"],"sourcesContent":["import { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityInfiniteQuery } from \"@/hooks/useEntityInfiniteQuery\";\nimport { parseDatastore } from \"@/lib/datastoreTable\";\nimport { listDatastores } from \"@/api/datastore\";\n\nimport type { DatastoreListResponse, ParsedDatastore } from \"@/types/datastore\";\nimport type { DatastoreDataFormat } from \"@/types/datastoreDataFormat\";\nimport type {\n PagedResponse,\n FetchEntitiesProps,\n ListQueryProps,\n ListCache,\n} from \"@/types/entityQuery\";\nimport {\n buildQueryKey,\n buildQueryObject,\n hasWorkspaceFilter,\n missingWorkspaceError,\n} from \"@/api/entityQuery\";\n\nexport type DatastoreQueryPage<F extends DatastoreDataFormat = \"object\"> = PagedResponse & {\n datastores: ParsedDatastore<F>[];\n};\n\n/** The query cache of `useFetchDatastores`, for typing `setQueryData`. */\nexport type DatastoresCache<F extends DatastoreDataFormat = \"object\"> = ListCache<\n DatastoreQueryPage<F>\n>;\n\nexport type FetchDatastoresProps<\n F extends DatastoreDataFormat = \"object\",\n TData = ParsedDatastore<F>[],\n> = ListQueryProps &\n FetchEntitiesProps<ParsedDatastore<F>, TData, DatastoreQueryPage<F>> & {\n /**\n * Tabular datastores only: `\"object\"` (default) turns the matrix into one object per row;\n * `\"matrix\"` leaves the matrix, header row included. A JSON datastore's `data` is unchanged either way.\n */\n dataFormat?: F;\n };\n\n/**\n * useFetchDatastores\n *\n * Lists datastores with cursor pagination. `query.data` is every loaded page merged into one\n * `ParsedDatastore[]`, each datastore's matrix converted to row objects — or whatever\n * `select` makes of that list.\n *\n * Built to be used directly rather than wrapped: `select` shapes the result, `queryKey` and\n * `DatastoresCache` let an app write to the cache, and `fetchAllPages` reads a whole set.\n * Paging on grid scroll is `handleRowsScrollEnd` from `@everysk/apps-sdk/ag-grid`, kept out of\n * this hook so it works for any list.\n *\n * Without a `workspace` filter, or with an empty one, the read fails at once with an error\n * naming this hook, logged to the console, and no request is sent. The app config is in place\n * before the app renders, so a missing workspace is a misconfigured app, never a wait.\n *\n * Rows are converted in the request (`parseDatastore`), so the cache holds objects and an\n * app patches a row as `{ ...row, ...patch }`. `dataFormat: \"matrix\"` skips the conversion and\n * leaves a tabular datastore's matrix unconverted, for a grid that takes arrays, an export, or a\n * datastore too large to convert. It is a value, not a conversion function, so that it can be\n * part of the cache key: two callers converting differently would otherwise share one entry.\n *\n * @param {FilterClause[]} [filters=[]] - Filters of every page request; one must be `workspace`.\n * @param {string[]} [order=[]] - Sorting of every page request.\n * @param {Projection} [projection=\"\"] - The fields to return, one or a list: `\"field\"` returns\n * only that field (others come back null), `\"-field\"` every field but that one. Several go as a\n * list, never comma-joined — `\"a,b\"` is a 500.\n * @param {number} [pageSize=10] - Datastores per request.\n * @param {\"object\" | \"matrix\"} [dataFormat=\"object\"] - How a table's rows are handed over.\n * @param {(datastores: ParsedDatastore[]) => TData} [select] - Shapes the merged list.\n * @param {boolean} [fetchAllPages=false] - Reads to the last page before reporting success.\n * @param {EntityInfiniteQueryOptions} [queryOptions] - Passed through to `useInfiniteQuery`.\n * @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.\n *\n * Example:\n * ```ts\n * // A list can mix tabular and JSON datastores; only a table's `data` is rows.\n * const toRows = (datastores: ParsedDatastore[]) => datastores.filter(isTableDatastore).flatMap((d) => d.data);\n *\n * const { query } = useFetchDatastores({\n * filters: [{ field: \"workspace\", value: workspace }],\n * select: toRows, // query.data: AnyRecord[]\n * });\n * ```\n */\nexport function useFetchDatastores<\n F extends DatastoreDataFormat = \"object\",\n TData = ParsedDatastore<F>[],\n>({\n filters = [],\n order = [],\n projection = \"\",\n pageSize = 10,\n dataFormat,\n select,\n fetchAllPages = false,\n queryOptions,\n}: FetchDatastoresProps<F, TData>) {\n const { api } = useAxios();\n\n const format = (dataFormat ?? \"object\") as F;\n const queryKey = buildQueryKey([\"datastores\"], filters, {\n order,\n projection,\n pageSize,\n fetchAllPages,\n dataFormat: format,\n });\n\n const query = useEntityInfiniteQuery<DatastoreQueryPage<F>, \"datastores\", TData>({\n queryKey,\n itemsKey: \"datastores\",\n fetchPage: async (pageToken, signal) => {\n const response: DatastoreListResponse = await listDatastores(\n api,\n buildQueryObject({ filters, order, projection, pageSize, pageToken }),\n signal,\n );\n\n return {\n next_page_token: response.next_page_token,\n datastores: response.datastores.map((datastore) =>\n parseDatastore(datastore, format),\n ),\n };\n },\n select,\n fetchAllPages,\n configError: hasWorkspaceFilter(filters)\n ? undefined\n : missingWorkspaceError(\"useFetchDatastores\"),\n queryOptions,\n });\n\n return { query, queryKey };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,SAAgB,mBAGd,EACE,UAAU,CAAC,GACX,QAAQ,CAAC,GACT,aAAa,IACb,WAAW,IACX,YACA,QACA,gBAAgB,OAChB,gBAC+B;CAC/B,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,SAAU,cAAc;CAC9B,MAAM,WAAW,cAAc,CAAC,YAAY,GAAG,SAAS;EACpD;EACA;EACA;EACA;EACA,YAAY;CAChB,CAAC;CA2BD,OAAO;EAAE,OAzBK,uBAAmE;GAC7E;GACA,UAAU;GACV,WAAW,OAAO,WAAW,WAAW;IACpC,MAAM,WAAkC,MAAM,eAC1C,KACA,iBAAiB;KAAE;KAAS;KAAO;KAAY;KAAU;IAAU,CAAC,GACpE,MACJ;IAEA,OAAO;KACH,iBAAiB,SAAS;KAC1B,YAAY,SAAS,WAAW,KAAK,cACjC,eAAe,WAAW,MAAM,CACpC;IACJ;GACJ;GACA;GACA;GACA,aAAa,mBAAmB,OAAO,IACjC,KAAA,IACA,sBAAsB,oBAAoB;GAChD;EACJ,CAES;EAAO;CAAS;AAC7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EveryskFile } from "../../types/file.d.ts";
|
|
2
|
+
/** What the file hooks take about a file's content. */
|
|
3
|
+
export type FileDataProps = {
|
|
4
|
+
/**
|
|
5
|
+
* `true` returns the content (`data`, base64). Left out by default: it is a third larger than
|
|
6
|
+
* the file, and showing or downloading a file needs only its `url` (`/file/<hash>`), which
|
|
7
|
+
* the platform serves inline with the user's session and the devkit's dev server serves too.
|
|
8
|
+
* With a list `projection` of the app's own that includes fields, `data` comes only if the
|
|
9
|
+
* projection names it.
|
|
10
|
+
*/
|
|
11
|
+
withData?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/** The file without its content, as the hooks return it unless `withData` asks for it. */
|
|
14
|
+
export declare const withoutData: <F extends {
|
|
15
|
+
data: EveryskFile["data"];
|
|
16
|
+
}>(file: F) => F;
|
|
17
|
+
//# sourceMappingURL=fileData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileData.d.ts","sourceRoot":"","sources":["../../../src/hooks/file/fileData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,uDAAuD;AACvD,MAAM,MAAM,aAAa,GAAG;IACxB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS;IAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,EAAE,MAAM,CAAC,KAAG,CAG7E,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/hooks/file/fileData.ts
|
|
2
|
+
/** The file without its content, as the hooks return it unless `withData` asks for it. */
|
|
3
|
+
var withoutData = (file) => ({
|
|
4
|
+
...file,
|
|
5
|
+
data: null
|
|
6
|
+
});
|
|
7
|
+
//#endregion
|
|
8
|
+
export { withoutData };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=fileData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileData.js","names":[],"sources":["../../../src/hooks/file/fileData.ts"],"sourcesContent":["import type { EveryskFile } from \"@/types/file\";\n\n/** What the file hooks take about a file's content. */\nexport type FileDataProps = {\n /**\n * `true` returns the content (`data`, base64). Left out by default: it is a third larger than\n * the file, and showing or downloading a file needs only its `url` (`/file/<hash>`), which\n * the platform serves inline with the user's session and the devkit's dev server serves too.\n * With a list `projection` of the app's own that includes fields, `data` comes only if the\n * projection names it.\n */\n withData?: boolean;\n};\n\n/** The file without its content, as the hooks return it unless `withData` asks for it. */\nexport const withoutData = <F extends { data: EveryskFile[\"data\"] }>(file: F): F => ({\n ...file,\n data: null,\n});\n"],"mappings":";;AAeA,IAAa,eAAwD,UAAgB;CACjF,GAAG;CACH,MAAM;AACV"}
|
|
@@ -1,54 +1,24 @@
|
|
|
1
1
|
import type { EveryskFile } from "../../types/file.d.ts";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { FetchEntityByIdProps } from "../../types/entityQuery.d.ts";
|
|
3
|
+
import { type FileDataProps } from "./fileData";
|
|
4
|
+
export type FetchFileProps<TData = EveryskFile, TSelected = TData> = FetchEntityByIdProps<TData, TSelected> & FileDataProps;
|
|
4
5
|
/**
|
|
5
6
|
* useFetchFile
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
+
* Fetches one file; `data` is the file, or whatever `select` makes of it. Idle while `id` is
|
|
9
|
+
* empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error
|
|
10
|
+
* alert. The file comes without its content unless `withData` asks for it: show or download it
|
|
11
|
+
* through its `url`.
|
|
8
12
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Important notes:
|
|
14
|
-
* - Always returns a single `EveryskFile` object.
|
|
15
|
-
* - `EveryskFile.data` represents the file content and is expected to be a Base64-encoded string
|
|
16
|
-
* when provided by the API (or when sending content through mutations).
|
|
17
|
-
*
|
|
18
|
-
* Parameters (FetchFileProps):
|
|
19
|
-
* @param {string} id
|
|
20
|
-
* EveryskFile identifier (required).
|
|
21
|
-
*
|
|
22
|
-
* @param {string} workspace
|
|
23
|
-
* Workspace the file belongs to (required by `getFile`).
|
|
24
|
-
*
|
|
25
|
-
* @param {EntityQueryOptions<any>} [queryOptions=defaultQueryOptions]
|
|
26
|
-
* TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
|
|
27
|
-
*
|
|
28
|
-
* Returns:
|
|
29
|
-
* @returns {object}
|
|
30
|
-
* TanStack Query's `query` object extended with:
|
|
31
|
-
* - `queryKey`: the cache key used by React Query
|
|
32
|
-
*
|
|
33
|
-
* Tip:
|
|
34
|
-
* - The returned `queryKey` can be reused by mutation hooks for cache invalidation:
|
|
35
|
-
* ```ts
|
|
36
|
-
* const fetch = useFetchFile({ id: "file-123", workspace: "ws-1" });
|
|
37
|
-
* useFileMutations({ queryKey: fetch.queryKey });
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* Example:
|
|
41
|
-
* ```ts
|
|
42
|
-
* const { data, isLoading } = useFetchFile({
|
|
43
|
-
* id: "file-123",
|
|
44
|
-
* workspace: "ws-1",
|
|
45
|
-
* });
|
|
46
|
-
* // data -> EveryskFile
|
|
47
|
-
* ```
|
|
13
|
+
* @param {FetchFileProps} props - `id`, `workspace`, `withData`, `select` and TanStack
|
|
14
|
+
* `queryOptions`.
|
|
15
|
+
* @returns {object} The `useQuery` result, plus `queryKey`.
|
|
48
16
|
*/
|
|
49
|
-
export declare const useFetchFile: ({ id, workspace, queryOptions }: FetchFileProps) => {
|
|
50
|
-
queryKey: string
|
|
51
|
-
|
|
17
|
+
export declare const useFetchFile: <TSelected = EveryskFile>({ id, workspace, select, queryOptions, withData, }: FetchFileProps<EveryskFile, TSelected>) => {
|
|
18
|
+
queryKey: (string | {
|
|
19
|
+
withData: boolean;
|
|
20
|
+
})[];
|
|
21
|
+
data: TSelected;
|
|
52
22
|
error: Error;
|
|
53
23
|
isError: true;
|
|
54
24
|
isPending: false;
|
|
@@ -71,11 +41,13 @@ export declare const useFetchFile: ({ id, workspace, queryOptions }: FetchFilePr
|
|
|
71
41
|
isRefetching: boolean;
|
|
72
42
|
isStale: boolean;
|
|
73
43
|
isEnabled: boolean;
|
|
74
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
44
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
75
45
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
76
46
|
} | {
|
|
77
|
-
queryKey: string
|
|
78
|
-
|
|
47
|
+
queryKey: (string | {
|
|
48
|
+
withData: boolean;
|
|
49
|
+
})[];
|
|
50
|
+
data: TSelected;
|
|
79
51
|
error: null;
|
|
80
52
|
isError: false;
|
|
81
53
|
isPending: false;
|
|
@@ -98,10 +70,12 @@ export declare const useFetchFile: ({ id, workspace, queryOptions }: FetchFilePr
|
|
|
98
70
|
isRefetching: boolean;
|
|
99
71
|
isStale: boolean;
|
|
100
72
|
isEnabled: boolean;
|
|
101
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
73
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
102
74
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
103
75
|
} | {
|
|
104
|
-
queryKey: string
|
|
76
|
+
queryKey: (string | {
|
|
77
|
+
withData: boolean;
|
|
78
|
+
})[];
|
|
105
79
|
data: undefined;
|
|
106
80
|
error: Error;
|
|
107
81
|
isError: true;
|
|
@@ -125,10 +99,12 @@ export declare const useFetchFile: ({ id, workspace, queryOptions }: FetchFilePr
|
|
|
125
99
|
isRefetching: boolean;
|
|
126
100
|
isStale: boolean;
|
|
127
101
|
isEnabled: boolean;
|
|
128
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
102
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
129
103
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
130
104
|
} | {
|
|
131
|
-
queryKey: string
|
|
105
|
+
queryKey: (string | {
|
|
106
|
+
withData: boolean;
|
|
107
|
+
})[];
|
|
132
108
|
data: undefined;
|
|
133
109
|
error: null;
|
|
134
110
|
isError: false;
|
|
@@ -152,10 +128,12 @@ export declare const useFetchFile: ({ id, workspace, queryOptions }: FetchFilePr
|
|
|
152
128
|
isRefetching: boolean;
|
|
153
129
|
isStale: boolean;
|
|
154
130
|
isEnabled: boolean;
|
|
155
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
131
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
156
132
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
157
133
|
} | {
|
|
158
|
-
queryKey: string
|
|
134
|
+
queryKey: (string | {
|
|
135
|
+
withData: boolean;
|
|
136
|
+
})[];
|
|
159
137
|
data: undefined;
|
|
160
138
|
error: null;
|
|
161
139
|
isError: false;
|
|
@@ -179,11 +157,13 @@ export declare const useFetchFile: ({ id, workspace, queryOptions }: FetchFilePr
|
|
|
179
157
|
isRefetching: boolean;
|
|
180
158
|
isStale: boolean;
|
|
181
159
|
isEnabled: boolean;
|
|
182
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
160
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
183
161
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
184
162
|
} | {
|
|
185
|
-
queryKey: string
|
|
186
|
-
|
|
163
|
+
queryKey: (string | {
|
|
164
|
+
withData: boolean;
|
|
165
|
+
})[];
|
|
166
|
+
data: TSelected;
|
|
187
167
|
isError: false;
|
|
188
168
|
error: null;
|
|
189
169
|
isPending: false;
|
|
@@ -206,7 +186,7 @@ export declare const useFetchFile: ({ id, workspace, queryOptions }: FetchFilePr
|
|
|
206
186
|
isRefetching: boolean;
|
|
207
187
|
isStale: boolean;
|
|
208
188
|
isEnabled: boolean;
|
|
209
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
189
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
210
190
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
211
191
|
};
|
|
212
192
|
//# sourceMappingURL=useFetchFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchFile.d.ts","sourceRoot":"","sources":["../../../src/hooks/file/useFetchFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFetchFile.d.ts","sourceRoot":"","sources":["../../../src/hooks/file/useFetchFile.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7D,MAAM,MAAM,cAAc,CAAC,KAAK,GAAG,WAAW,EAAE,SAAS,GAAG,KAAK,IAAI,oBAAoB,CACrF,KAAK,EACL,SAAS,CACZ,GACG,aAAa,CAAC;AAElB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,GAAG,WAAW,EAAE,oDAMnD,cAAc,CAAC,WAAW,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBxC,CAAC"}
|