@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileMutations.js","names":[],"sources":["../../../src/hooks/file/useFileMutations.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useFileMutations.js","names":[],"sources":["../../../src/hooks/file/useFileMutations.ts"],"sourcesContent":["import { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityMutation } from \"@/hooks/useEntityMutation\";\nimport type { EveryskFile } from \"@/types/file\";\nimport { deleteFile, createFile, updateFile } from \"@/api/file\";\n\ntype CreateFileProps = {\n data: Partial<EveryskFile>;\n};\n\ntype UpdateFileProps = {\n id: string;\n data: Partial<EveryskFile>;\n};\n\ntype DeleteFileProps = {\n id: string;\n workspace: string;\n};\n\ntype UseFileMutationsProps = {\n queryKey?: unknown[];\n};\n\n/**\n * useFileMutations\n *\n * Mutation hook built on TanStack Query to perform EveryskFile write operations:\n * - create a file (POST)\n * - update a file (PUT)\n * - delete a file (DELETE)\n *\n * It also:\n * - optionally invalidates a target query cache key after successful mutations\n * - displays success/error alerts via `useAppAlert`\n *\n * Important notes:\n * - This hook is intended for side-effect operations only. Reading/retrieving data should be done via `useQuery` or `useFetchFile`.\n * - Cache invalidation is controlled by `queryKey`. If `queryKey` is not provided, the hook will still run\n * mutations and show alerts, but it will NOT invalidate any cached queries.\n * - `remove` requires a `workspace` parameter because the underlying API helper `deleteFile(api, id, workspace)`\n * expects it as a query param.\n *\n * - EveryskFile content (`data`):\n * - When creating/updating a file, the file content must be provided in `data` as a Base64-encoded string.\n * - Send only the raw Base64 content (do not include a data URL prefix like `data:<mime>;base64,`):\n * `fileToBase64(file)` gives it from a `File`, and a data URL is refused before the request\n * - `content_type` should match the file MIME type (e.g., \"text/csv\", \"application/pdf\").\n *\n * Parameters (UseFileMutationsProps):\n * @param {unknown[]} [queryKey]\n * Query key to invalidate after successful mutations. Use the same `queryKey` you pass to the relevant `useQuery`\n * (e.g., file list/detail) so UI data is refreshed automatically after a write.\n *\n * Tip:\n * - If you're using `useFetchFile`, you can pass its returned `queryKey` directly:\n * `const fetch = useFetchFile(...);`\n * `useFileMutations({ queryKey: fetch.queryKey });`\n *\n * Mutations:\n * - `create`:\n * - mutationFn: `createFile(api, data)`\n * - variables: `{ data: Partial<EveryskFile> }`\n * - success message: \"File created successfully.\"\n * - error message: \"Unable to create the file. Please try again.\" (fallback)\n *\n * - `update`:\n * - mutationFn: `updateFile(api, id, data)`\n * - variables: `{ id: string; data: Partial<EveryskFile> }`\n * - success message: \"File updated successfully.\"\n * - error message: \"Unable to update the file. Please try again.\" (fallback)\n *\n * - `remove`:\n * - mutationFn: `deleteFile(api, id, workspace)`\n * - variables: `{ id: string; workspace: string }`\n * - success message: \"File deleted successfully.\"\n * - error message: \"Unable to delete the file. Please try again.\" (fallback)\n *\n * Return value:\n * @returns {object}\n * Returns an object with the three TanStack Query mutation results:\n * - `create`: UseMutationResult<EveryskFile, Error, CreateFileProps, unknown>\n * - `update`: UseMutationResult<EveryskFile, Error, UpdateFileProps, unknown>\n * - `remove`: UseMutationResult<DeletedEntity, Error, DeleteFileProps, unknown>\n *\n * Each mutation includes standard TanStack Query helpers:\n * - `mutate(variables, options?)`\n * - `mutateAsync(variables, options?)`\n * - `isPending`, `isSuccess`, `isError`, `error`, `data`, etc.\n *\n * Examples:\n *\n * 1) Invalidate a file list query after mutations:\n * ```ts\n * const { create, update, remove } = useFileMutations({ queryKey: [\"file\"] });\n *\n * // Create\n * create.mutate({\n * data: {\n * name: \"My file\",\n * workspace: \"ws-1\",\n * content_type: \"text/plain\",\n * version: \"1\",\n * link_uid: null,\n * data: \"SGVsbG8gd29ybGQ=\", // Base64 content\n * }\n * });\n *\n * // Update\n * update.mutate({\n * id: \"file-123\",\n * data: {\n * name: \"Renamed file\",\n * content_type: \"text/plain\",\n * data: \"SGVsbG8gd29ybGQ=\", // Base64 content (optional if only renaming)\n * }\n * });\n *\n * // Delete\n * remove.mutate({ id: \"file-123\", workspace: \"ws-1\" });\n * ```\n *\n * 2) Using async/await with `mutateAsync`:\n * ```ts\n * const { create } = useFileMutations({ queryKey: [\"file\"] });\n *\n * await create.mutateAsync({\n * data: {\n * name: \"My file\",\n * workspace: \"ws-1\",\n * content_type: \"text/plain\",\n * version: \"1\",\n * link_uid: null,\n * data: \"SGVsbG8gd29ybGQ=\",\n * }\n * });\n * ```\n *\n * 3) Without cache invalidation (no queryKey):\n * ```ts\n * const { update } = useFileMutations({});\n *\n * update.mutate({\n * id: \"file-123\",\n * data: {\n * name: \"New name\",\n * content_type: \"text/plain\",\n * }\n * });\n * // Mutation still runs and alerts are shown, but cached queries are not invalidated.\n * ```\n *\n * 4) Using `useFetchFile` queryKey for automatic invalidation:\n * ```ts\n * const fetch = useFetchFile({\n * id: null,\n * filters: [{ field: \"workspace\", value: \"ws-1\" }],\n * });\n *\n * const { remove } = useFileMutations({ queryKey: fetch.queryKey });\n *\n * await remove.mutateAsync({ id: \"file-123\", workspace: \"ws-1\" });\n * ```\n */\n\nexport const useFileMutations = ({ queryKey }: UseFileMutationsProps) => {\n const { api } = useAxios();\n\n const create = useEntityMutation({\n mutationFn: ({ data }: CreateFileProps) => createFile(api, data),\n queryKey,\n successMessage: \"File created successfully.\",\n errorMessage: \"Unable to create the file. Please try again.\",\n });\n\n const update = useEntityMutation({\n mutationFn: ({ id, data }: UpdateFileProps) => updateFile(api, id, data),\n queryKey,\n successMessage: \"File updated successfully.\",\n errorMessage: \"Unable to update the file. Please try again.\",\n });\n\n const remove = useEntityMutation({\n mutationFn: ({ id, workspace }: DeleteFileProps) => deleteFile(api, id, workspace),\n queryKey,\n successMessage: \"File deleted successfully.\",\n errorMessage: \"Unable to delete the file. Please try again.\",\n });\n\n return { create, update, remove };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoKA,IAAa,oBAAoB,EAAE,eAAsC;CACrE,MAAM,EAAE,QAAQ,SAAS;CAuBzB,OAAO;EAAE,QArBM,kBAAkB;GAC7B,aAAa,EAAE,WAA4B,WAAW,KAAK,IAAI;GAC/D;GACA,gBAAgB;GAChB,cAAc;EAClB,CAgBS;EAAQ,QAdF,kBAAkB;GAC7B,aAAa,EAAE,IAAI,WAA4B,WAAW,KAAK,IAAI,IAAI;GACvE;GACA,gBAAgB;GAChB,cAAc;EAClB,CASiB;EAAQ,QAPV,kBAAkB;GAC7B,aAAa,EAAE,IAAI,gBAAiC,WAAW,KAAK,IAAI,SAAS;GACjF;GACA,gBAAgB;GAChB,cAAc;EAClB,CAEyB;CAAO;AACpC"}
|
|
@@ -1,52 +1,18 @@
|
|
|
1
1
|
import type { Portfolio } from "../../types/portfolio.d.ts";
|
|
2
|
-
import type {
|
|
3
|
-
export type FetchPortfolioProps<TData = Portfolio, TSelected = TData> =
|
|
2
|
+
import type { FetchEntityByIdProps } from "../../types/entityQuery.d.ts";
|
|
3
|
+
export type FetchPortfolioProps<TData = Portfolio, TSelected = TData> = FetchEntityByIdProps<TData, TSelected>;
|
|
4
4
|
/**
|
|
5
5
|
* useFetchPortfolio
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Fetches one portfolio; `data` is the portfolio, or whatever `select` makes of it. Idle while
|
|
8
|
+
* `id` is empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error alert.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - triggers an error alert via `useAppAlert` whenever `query.error` is present
|
|
12
|
-
*
|
|
13
|
-
* Important notes:
|
|
14
|
-
* - Always returns a single `Portfolio` object.
|
|
15
|
-
*
|
|
16
|
-
* Parameters (FetchPortfolioProps):
|
|
17
|
-
* @param {string} id
|
|
18
|
-
* Portfolio identifier (required).
|
|
19
|
-
*
|
|
20
|
-
* @param {string} workspace
|
|
21
|
-
* Workspace the portfolio belongs to (required by `getPortfolio`).
|
|
22
|
-
*
|
|
23
|
-
* @param {EntityQueryOptions<Portfolio>} [queryOptions=defaultQueryOptions]
|
|
24
|
-
* TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
|
|
25
|
-
*
|
|
26
|
-
* Returns:
|
|
27
|
-
* @returns {object}
|
|
28
|
-
* TanStack Query's `query` object extended with:
|
|
29
|
-
* - `queryKey`: the cache key used by React Query
|
|
30
|
-
*
|
|
31
|
-
* Tip:
|
|
32
|
-
* - The returned `queryKey` can be reused by mutation hooks for cache invalidation:
|
|
33
|
-
* ```ts
|
|
34
|
-
* const fetch = useFetchPortfolio({ id: "pf-123", workspace: "ws-1" });
|
|
35
|
-
* usePortfolioMutations({ queryKey: fetch.queryKey });
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* Example:
|
|
39
|
-
* ```ts
|
|
40
|
-
* const { data, isLoading } = useFetchPortfolio({
|
|
41
|
-
* id: "pf-123",
|
|
42
|
-
* workspace: "ws-1",
|
|
43
|
-
* });
|
|
44
|
-
* // data -> Portfolio
|
|
45
|
-
* ```
|
|
10
|
+
* @param {FetchPortfolioProps} props - `id`, `workspace`, `select` and TanStack `queryOptions`.
|
|
11
|
+
* @returns {object} The `useQuery` result, plus `queryKey`.
|
|
46
12
|
*/
|
|
47
|
-
export declare const useFetchPortfolio: ({ id, workspace, queryOptions }: FetchPortfolioProps) => {
|
|
13
|
+
export declare const useFetchPortfolio: <TSelected = Portfolio>({ id, workspace, select, queryOptions, }: FetchPortfolioProps<Portfolio, TSelected>) => {
|
|
48
14
|
queryKey: string[];
|
|
49
|
-
data:
|
|
15
|
+
data: TSelected;
|
|
50
16
|
error: Error;
|
|
51
17
|
isError: true;
|
|
52
18
|
isPending: false;
|
|
@@ -69,11 +35,11 @@ export declare const useFetchPortfolio: ({ id, workspace, queryOptions }: FetchP
|
|
|
69
35
|
isRefetching: boolean;
|
|
70
36
|
isStale: boolean;
|
|
71
37
|
isEnabled: boolean;
|
|
72
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
38
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
73
39
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
74
40
|
} | {
|
|
75
41
|
queryKey: string[];
|
|
76
|
-
data:
|
|
42
|
+
data: TSelected;
|
|
77
43
|
error: null;
|
|
78
44
|
isError: false;
|
|
79
45
|
isPending: false;
|
|
@@ -96,7 +62,7 @@ export declare const useFetchPortfolio: ({ id, workspace, queryOptions }: FetchP
|
|
|
96
62
|
isRefetching: boolean;
|
|
97
63
|
isStale: boolean;
|
|
98
64
|
isEnabled: boolean;
|
|
99
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
65
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
100
66
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
101
67
|
} | {
|
|
102
68
|
queryKey: string[];
|
|
@@ -123,7 +89,7 @@ export declare const useFetchPortfolio: ({ id, workspace, queryOptions }: FetchP
|
|
|
123
89
|
isRefetching: boolean;
|
|
124
90
|
isStale: boolean;
|
|
125
91
|
isEnabled: boolean;
|
|
126
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
92
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
127
93
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
128
94
|
} | {
|
|
129
95
|
queryKey: string[];
|
|
@@ -150,7 +116,7 @@ export declare const useFetchPortfolio: ({ id, workspace, queryOptions }: FetchP
|
|
|
150
116
|
isRefetching: boolean;
|
|
151
117
|
isStale: boolean;
|
|
152
118
|
isEnabled: boolean;
|
|
153
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
119
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
154
120
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
155
121
|
} | {
|
|
156
122
|
queryKey: string[];
|
|
@@ -177,11 +143,11 @@ export declare const useFetchPortfolio: ({ id, workspace, queryOptions }: FetchP
|
|
|
177
143
|
isRefetching: boolean;
|
|
178
144
|
isStale: boolean;
|
|
179
145
|
isEnabled: boolean;
|
|
180
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
146
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
181
147
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
182
148
|
} | {
|
|
183
149
|
queryKey: string[];
|
|
184
|
-
data:
|
|
150
|
+
data: TSelected;
|
|
185
151
|
isError: false;
|
|
186
152
|
error: null;
|
|
187
153
|
isPending: false;
|
|
@@ -204,7 +170,7 @@ export declare const useFetchPortfolio: ({ id, workspace, queryOptions }: FetchP
|
|
|
204
170
|
isRefetching: boolean;
|
|
205
171
|
isStale: boolean;
|
|
206
172
|
isEnabled: boolean;
|
|
207
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
173
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
208
174
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
209
175
|
};
|
|
210
176
|
//# sourceMappingURL=useFetchPortfolio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchPortfolio.d.ts","sourceRoot":"","sources":["../../../src/hooks/portfolio/useFetchPortfolio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFetchPortfolio.d.ts","sourceRoot":"","sources":["../../../src/hooks/portfolio/useFetchPortfolio.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,MAAM,MAAM,mBAAmB,CAAC,KAAK,GAAG,SAAS,EAAE,SAAS,GAAG,KAAK,IAAI,oBAAoB,CACxF,KAAK,EACL,SAAS,CACZ,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,GAAG,SAAS,EAAE,0CAKtD,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAe3C,CAAC"}
|
|
@@ -1,81 +1,33 @@
|
|
|
1
|
-
import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
|
|
2
1
|
import { useAxios } from "../useAxios.js";
|
|
2
|
+
import { useEntityQuery } from "../useEntityQuery.js";
|
|
3
|
+
import { missingWorkspaceError } from "../../api/entityQuery.js";
|
|
3
4
|
import { getPortfolio } from "../../api/portfolio.js";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
import { useQuery } from "@tanstack/react-query";
|
|
6
5
|
//#region src/hooks/portfolio/useFetchPortfolio.ts
|
|
7
|
-
var defaultQueryOptions = {
|
|
8
|
-
refetchOnMount: "always",
|
|
9
|
-
staleTime: 0,
|
|
10
|
-
gcTime: 0
|
|
11
|
-
};
|
|
12
6
|
/**
|
|
13
7
|
* useFetchPortfolio
|
|
14
8
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* It also:
|
|
18
|
-
* - builds a stable React Query `queryKey` that can be reused by mutation hooks for cache invalidation
|
|
19
|
-
* - triggers an error alert via `useAppAlert` whenever `query.error` is present
|
|
20
|
-
*
|
|
21
|
-
* Important notes:
|
|
22
|
-
* - Always returns a single `Portfolio` object.
|
|
23
|
-
*
|
|
24
|
-
* Parameters (FetchPortfolioProps):
|
|
25
|
-
* @param {string} id
|
|
26
|
-
* Portfolio identifier (required).
|
|
27
|
-
*
|
|
28
|
-
* @param {string} workspace
|
|
29
|
-
* Workspace the portfolio belongs to (required by `getPortfolio`).
|
|
30
|
-
*
|
|
31
|
-
* @param {EntityQueryOptions<Portfolio>} [queryOptions=defaultQueryOptions]
|
|
32
|
-
* TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
|
|
33
|
-
*
|
|
34
|
-
* Returns:
|
|
35
|
-
* @returns {object}
|
|
36
|
-
* TanStack Query's `query` object extended with:
|
|
37
|
-
* - `queryKey`: the cache key used by React Query
|
|
38
|
-
*
|
|
39
|
-
* Tip:
|
|
40
|
-
* - The returned `queryKey` can be reused by mutation hooks for cache invalidation:
|
|
41
|
-
* ```ts
|
|
42
|
-
* const fetch = useFetchPortfolio({ id: "pf-123", workspace: "ws-1" });
|
|
43
|
-
* usePortfolioMutations({ queryKey: fetch.queryKey });
|
|
44
|
-
* ```
|
|
9
|
+
* Fetches one portfolio; `data` is the portfolio, or whatever `select` makes of it. Idle while
|
|
10
|
+
* `id` is empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error alert.
|
|
45
11
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* const { data, isLoading } = useFetchPortfolio({
|
|
49
|
-
* id: "pf-123",
|
|
50
|
-
* workspace: "ws-1",
|
|
51
|
-
* });
|
|
52
|
-
* // data -> Portfolio
|
|
53
|
-
* ```
|
|
12
|
+
* @param {FetchPortfolioProps} props - `id`, `workspace`, `select` and TanStack `queryOptions`.
|
|
13
|
+
* @returns {object} The `useQuery` result, plus `queryKey`.
|
|
54
14
|
*/
|
|
55
|
-
var useFetchPortfolio = ({ id, workspace, queryOptions
|
|
15
|
+
var useFetchPortfolio = ({ id, workspace, select, queryOptions }) => {
|
|
56
16
|
const { api } = useAxios();
|
|
57
|
-
const { showAlert } = useAppAlert();
|
|
58
17
|
const queryKey = [
|
|
59
18
|
"portfolio",
|
|
60
19
|
id,
|
|
61
20
|
workspace
|
|
62
21
|
];
|
|
63
|
-
const query = useQuery({
|
|
64
|
-
queryKey,
|
|
65
|
-
queryFn: async () => {
|
|
66
|
-
return (await getPortfolio(api, id, workspace)).portfolio;
|
|
67
|
-
},
|
|
68
|
-
...queryOptions ?? {}
|
|
69
|
-
});
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (!query.error) return;
|
|
72
|
-
showAlert({
|
|
73
|
-
severity: "error",
|
|
74
|
-
message: query.error.message
|
|
75
|
-
});
|
|
76
|
-
}, [query.error, showAlert]);
|
|
77
22
|
return {
|
|
78
|
-
...
|
|
23
|
+
...useEntityQuery({
|
|
24
|
+
queryKey,
|
|
25
|
+
fetchEntity: (signal) => getPortfolio(api, id, workspace, signal),
|
|
26
|
+
select,
|
|
27
|
+
enabled: Boolean(id),
|
|
28
|
+
configError: workspace ? void 0 : missingWorkspaceError("useFetchPortfolio"),
|
|
29
|
+
queryOptions
|
|
30
|
+
}),
|
|
79
31
|
queryKey
|
|
80
32
|
};
|
|
81
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchPortfolio.js","names":[],"sources":["../../../src/hooks/portfolio/useFetchPortfolio.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useFetchPortfolio.js","names":[],"sources":["../../../src/hooks/portfolio/useFetchPortfolio.ts"],"sourcesContent":["import { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityQuery } from \"@/hooks/useEntityQuery\";\nimport { missingWorkspaceError } from \"@/api/entityQuery\";\nimport { getPortfolio } from \"@/api/portfolio\";\nimport type { Portfolio } from \"@/types/portfolio\";\nimport type { FetchEntityByIdProps } from \"@/types/entityQuery\";\n\nexport type FetchPortfolioProps<TData = Portfolio, TSelected = TData> = FetchEntityByIdProps<\n TData,\n TSelected\n>;\n\n/**\n * useFetchPortfolio\n *\n * Fetches one portfolio; `data` is the portfolio, or whatever `select` makes of it. Idle while\n * `id` is empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error alert.\n *\n * @param {FetchPortfolioProps} props - `id`, `workspace`, `select` and TanStack `queryOptions`.\n * @returns {object} The `useQuery` result, plus `queryKey`.\n */\nexport const useFetchPortfolio = <TSelected = Portfolio>({\n id,\n workspace,\n select,\n queryOptions,\n}: FetchPortfolioProps<Portfolio, TSelected>) => {\n const { api } = useAxios();\n\n const queryKey = [\"portfolio\", id, workspace];\n\n const query = useEntityQuery<Portfolio, TSelected>({\n queryKey,\n fetchEntity: (signal) => getPortfolio(api, id, workspace, signal),\n select,\n enabled: Boolean(id),\n configError: workspace ? undefined : missingWorkspaceError(\"useFetchPortfolio\"),\n queryOptions,\n });\n\n return { ...query, queryKey };\n};\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAa,qBAA4C,EACrD,IACA,WACA,QACA,mBAC6C;CAC7C,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,WAAW;EAAC;EAAa;EAAI;CAAS;CAW5C,OAAO;EAAE,GATK,eAAqC;GAC/C;GACA,cAAc,WAAW,aAAa,KAAK,IAAI,WAAW,MAAM;GAChE;GACA,SAAS,QAAQ,EAAE;GACnB,aAAa,YAAY,KAAA,IAAY,sBAAsB,mBAAmB;GAC9E;EACJ,CAEY;EAAO;CAAS;AAChC"}
|
|
@@ -1,60 +1,21 @@
|
|
|
1
|
-
import { type UseInfiniteQueryOptions, type QueryKey } from "@tanstack/react-query";
|
|
2
|
-
import type { FetchEntitiesParams } from "../../types/entityQuery.d.ts";
|
|
3
1
|
import type { Portfolio, PortfolioListResponse } from "../../types/portfolio.d.ts";
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
};
|
|
2
|
+
import type { FetchEntitiesProps, ListQueryProps, ListCache } from "../../types/entityQuery.d.ts";
|
|
3
|
+
/** The query cache of `useFetchPortfolios`, for typing `setQueryData`. */
|
|
4
|
+
export type PortfoliosCache = ListCache<PortfolioListResponse>;
|
|
5
|
+
export type FetchPortfoliosProps<TData = Portfolio[]> = ListQueryProps & FetchEntitiesProps<Portfolio, TData, PortfolioListResponse>;
|
|
9
6
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Data-fetching hook built on TanStack Query's `useInfiniteQuery` to retrieve
|
|
13
|
-
* portfolios with cursor-based pagination.
|
|
14
|
-
*
|
|
15
|
-
* It also:
|
|
16
|
-
* - flattens all pages into a single `Portfolio[]` via `select`
|
|
17
|
-
*
|
|
18
|
-
* Important notes:
|
|
19
|
-
* - `query.data` returns a flat `Portfolio[]` (all pages merged).
|
|
20
|
-
*
|
|
21
|
-
* Parameters (FetchInfinitePortfolioProps):
|
|
22
|
-
* @param {FilterClause[]} [filters=[]]
|
|
23
|
-
* Filters applied to every page request. Must include a `workspace` filter.
|
|
24
|
-
*
|
|
25
|
-
* @param {string[]} [order=[]]
|
|
26
|
-
* Sorting applied to every page request.
|
|
27
|
-
*
|
|
28
|
-
* @param {string} [projection=""]
|
|
29
|
-
* Single field to project: `"field"` returns only that field (others come back null),
|
|
30
|
-
* `"-field"` returns every field except that one. One field only — lists 500. Omitted when empty.
|
|
31
|
-
*
|
|
32
|
-
* @param {number} [pageSize=10]
|
|
33
|
-
* Number of portfolios to fetch per page.
|
|
34
|
-
*
|
|
35
|
-
* @param {InfiniteOptions<Portfolio[]>} [queryOptions]
|
|
36
|
-
* TanStack Query options passed through to `useInfiniteQuery`
|
|
37
|
-
* (e.g., enabled, staleTime, gcTime, etc.).
|
|
38
|
-
*
|
|
39
|
-
* Returns:
|
|
40
|
-
* @returns {object}
|
|
41
|
-
* - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)
|
|
42
|
-
* - `queryKey`: the cache key used by React Query
|
|
7
|
+
* useFetchPortfolios
|
|
43
8
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* filters: [{ field: "workspace", value: "ws-1" }],
|
|
48
|
-
* pageSize: 20,
|
|
49
|
-
* });
|
|
9
|
+
* Lists portfolios with cursor pagination; `query.data` is every loaded page merged, or
|
|
10
|
+
* whatever `select` makes of it. Paging, `select`, `fetchAllPages` and the
|
|
11
|
+
* missing-workspace error behave as in `useFetchDatastores`.
|
|
50
12
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
13
|
+
* @param {FetchPortfoliosProps} props - Filters (one must be `workspace`), order,
|
|
14
|
+
* projection, page size, `select`, `fetchAllPages` and TanStack `queryOptions`.
|
|
15
|
+
* @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
|
|
54
16
|
*/
|
|
55
|
-
export declare function useFetchPortfolios({ filters, order, projection, pageSize, queryOptions }:
|
|
56
|
-
query: import("@tanstack/react-query").UseInfiniteQueryResult<
|
|
17
|
+
export declare function useFetchPortfolios<TData = Portfolio[]>({ filters, order, projection, pageSize, select, fetchAllPages, queryOptions, }: FetchPortfoliosProps<TData>): {
|
|
18
|
+
query: import("@tanstack/react-query").UseInfiniteQueryResult<TData, Error>;
|
|
57
19
|
queryKey: unknown[];
|
|
58
20
|
};
|
|
59
|
-
export {};
|
|
60
21
|
//# sourceMappingURL=useFetchPortfolios.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchPortfolios.d.ts","sourceRoot":"","sources":["../../../src/hooks/portfolio/useFetchPortfolios.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFetchPortfolios.d.ts","sourceRoot":"","sources":["../../../src/hooks/portfolio/useFetchPortfolios.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQzF,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,qBAAqB,CAAC,CAAC;AAE/D,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,SAAS,EAAE,IAAI,cAAc,GAClE,kBAAkB,CAAC,SAAS,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,GAAG,SAAS,EAAE,EAAE,EACpD,OAAY,EACZ,KAAU,EACV,UAAe,EACf,QAAa,EACb,MAAM,EACN,aAAqB,EACrB,YAAY,GACf,EAAE,oBAAoB,CAAC,KAAK,CAAC;;;EA4B7B"}
|
|
@@ -1,84 +1,42 @@
|
|
|
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 { listPortfolios } from "../../api/portfolio.js";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
|
-
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
6
5
|
//#region src/hooks/portfolio/useFetchPortfolios.ts
|
|
7
|
-
var defaultQueryOptions = {
|
|
8
|
-
refetchOnMount: "always",
|
|
9
|
-
staleTime: 0,
|
|
10
|
-
gcTime: 0
|
|
11
|
-
};
|
|
12
6
|
/**
|
|
13
|
-
*
|
|
7
|
+
* useFetchPortfolios
|
|
14
8
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
9
|
+
* Lists portfolios with cursor pagination; `query.data` is every loaded page merged, or
|
|
10
|
+
* whatever `select` makes of it. Paging, `select`, `fetchAllPages` and the
|
|
11
|
+
* missing-workspace error behave as in `useFetchDatastores`.
|
|
17
12
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* Important notes:
|
|
22
|
-
* - `query.data` returns a flat `Portfolio[]` (all pages merged).
|
|
23
|
-
*
|
|
24
|
-
* Parameters (FetchInfinitePortfolioProps):
|
|
25
|
-
* @param {FilterClause[]} [filters=[]]
|
|
26
|
-
* Filters applied to every page request. Must include a `workspace` filter.
|
|
27
|
-
*
|
|
28
|
-
* @param {string[]} [order=[]]
|
|
29
|
-
* Sorting applied to every page request.
|
|
30
|
-
*
|
|
31
|
-
* @param {string} [projection=""]
|
|
32
|
-
* Single field to project: `"field"` returns only that field (others come back null),
|
|
33
|
-
* `"-field"` returns every field except that one. One field only — lists 500. Omitted when empty.
|
|
34
|
-
*
|
|
35
|
-
* @param {number} [pageSize=10]
|
|
36
|
-
* Number of portfolios to fetch per page.
|
|
37
|
-
*
|
|
38
|
-
* @param {InfiniteOptions<Portfolio[]>} [queryOptions]
|
|
39
|
-
* TanStack Query options passed through to `useInfiniteQuery`
|
|
40
|
-
* (e.g., enabled, staleTime, gcTime, etc.).
|
|
41
|
-
*
|
|
42
|
-
* Returns:
|
|
43
|
-
* @returns {object}
|
|
44
|
-
* - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)
|
|
45
|
-
* - `queryKey`: the cache key used by React Query
|
|
46
|
-
*
|
|
47
|
-
* Example:
|
|
48
|
-
* ```ts
|
|
49
|
-
* const { query } = useFetchInfinitePortfolios({
|
|
50
|
-
* filters: [{ field: "workspace", value: "ws-1" }],
|
|
51
|
-
* pageSize: 20,
|
|
52
|
-
* });
|
|
53
|
-
*
|
|
54
|
-
* // Flat list of all fetched portfolios
|
|
55
|
-
* const portfolios = query.data ?? [];
|
|
56
|
-
* ```
|
|
13
|
+
* @param {FetchPortfoliosProps} props - Filters (one must be `workspace`), order,
|
|
14
|
+
* projection, page size, `select`, `fetchAllPages` and TanStack `queryOptions`.
|
|
15
|
+
* @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
|
|
57
16
|
*/
|
|
58
|
-
function useFetchPortfolios({ filters = [], order = [], projection = "", pageSize = 10, queryOptions }) {
|
|
17
|
+
function useFetchPortfolios({ filters = [], order = [], projection = "", pageSize = 10, select, fetchAllPages = false, queryOptions }) {
|
|
59
18
|
const { api } = useAxios();
|
|
60
|
-
const queryKey = buildQueryKey(["portfolios"], filters
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
19
|
+
const queryKey = buildQueryKey(["portfolios"], filters, {
|
|
20
|
+
order,
|
|
21
|
+
projection,
|
|
22
|
+
pageSize,
|
|
23
|
+
fetchAllPages
|
|
24
|
+
});
|
|
65
25
|
return {
|
|
66
|
-
query:
|
|
26
|
+
query: useEntityInfiniteQuery({
|
|
67
27
|
queryKey,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
select: (data) => data.pages.flatMap((p) => p.portfolios),
|
|
81
|
-
...mergedQueryOptions
|
|
28
|
+
itemsKey: "portfolios",
|
|
29
|
+
fetchPage: (pageToken, signal) => listPortfolios(api, buildQueryObject({
|
|
30
|
+
filters,
|
|
31
|
+
order,
|
|
32
|
+
projection,
|
|
33
|
+
pageSize,
|
|
34
|
+
pageToken
|
|
35
|
+
}), signal),
|
|
36
|
+
select,
|
|
37
|
+
fetchAllPages,
|
|
38
|
+
configError: hasWorkspaceFilter(filters) ? void 0 : missingWorkspaceError("useFetchPortfolios"),
|
|
39
|
+
queryOptions
|
|
82
40
|
}),
|
|
83
41
|
queryKey
|
|
84
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchPortfolios.js","names":[],"sources":["../../../src/hooks/portfolio/useFetchPortfolios.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useFetchPortfolios.js","names":[],"sources":["../../../src/hooks/portfolio/useFetchPortfolios.ts"],"sourcesContent":["import { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityInfiniteQuery } from \"@/hooks/useEntityInfiniteQuery\";\nimport { listPortfolios } from \"@/api/portfolio\";\nimport type { Portfolio, PortfolioListResponse } from \"@/types/portfolio\";\nimport type { FetchEntitiesProps, ListQueryProps, ListCache } from \"@/types/entityQuery\";\nimport {\n buildQueryKey,\n buildQueryObject,\n hasWorkspaceFilter,\n missingWorkspaceError,\n} from \"@/api/entityQuery\";\n\n/** The query cache of `useFetchPortfolios`, for typing `setQueryData`. */\nexport type PortfoliosCache = ListCache<PortfolioListResponse>;\n\nexport type FetchPortfoliosProps<TData = Portfolio[]> = ListQueryProps &\n FetchEntitiesProps<Portfolio, TData, PortfolioListResponse>;\n\n/**\n * useFetchPortfolios\n *\n * Lists portfolios with cursor pagination; `query.data` is every loaded page merged, or\n * whatever `select` makes of it. Paging, `select`, `fetchAllPages` and the\n * missing-workspace error behave as in `useFetchDatastores`.\n *\n * @param {FetchPortfoliosProps} props - Filters (one must be `workspace`), order,\n * projection, page size, `select`, `fetchAllPages` and TanStack `queryOptions`.\n * @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.\n */\nexport function useFetchPortfolios<TData = Portfolio[]>({\n filters = [],\n order = [],\n projection = \"\",\n pageSize = 10,\n select,\n fetchAllPages = false,\n queryOptions,\n}: FetchPortfoliosProps<TData>) {\n const { api } = useAxios();\n\n const queryKey = buildQueryKey([\"portfolios\"], filters, {\n order,\n projection,\n pageSize,\n fetchAllPages,\n });\n\n const query = useEntityInfiniteQuery<PortfolioListResponse, \"portfolios\", TData>({\n queryKey,\n itemsKey: \"portfolios\",\n fetchPage: (pageToken, signal) =>\n listPortfolios(\n api,\n buildQueryObject({ filters, order, projection, pageSize, pageToken }),\n signal,\n ),\n select,\n fetchAllPages,\n configError: hasWorkspaceFilter(filters)\n ? undefined\n : missingWorkspaceError(\"useFetchPortfolios\"),\n queryOptions,\n });\n\n return { query, queryKey };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,SAAgB,mBAAwC,EACpD,UAAU,CAAC,GACX,QAAQ,CAAC,GACT,aAAa,IACb,WAAW,IACX,QACA,gBAAgB,OAChB,gBAC4B;CAC5B,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,WAAW,cAAc,CAAC,YAAY,GAAG,SAAS;EACpD;EACA;EACA;EACA;CACJ,CAAC;CAmBD,OAAO;EAAE,OAjBK,uBAAmE;GAC7E;GACA,UAAU;GACV,YAAY,WAAW,WACnB,eACI,KACA,iBAAiB;IAAE;IAAS;IAAO;IAAY;IAAU;GAAU,CAAC,GACpE,MACJ;GACJ;GACA;GACA,aAAa,mBAAmB,OAAO,IACjC,KAAA,IACA,sBAAsB,oBAAoB;GAChD;EACJ,CAES;EAAO;CAAS;AAC7B"}
|
|
@@ -47,26 +47,26 @@ type UsePortfolioMutationsProps = {
|
|
|
47
47
|
* - mutationFn: `createPortfolio(api, data)`
|
|
48
48
|
* - variables: `{ data: Partial<Portfolio> }`
|
|
49
49
|
* - success message: "Portfolio created successfully."
|
|
50
|
-
* - error message: "
|
|
50
|
+
* - error message: "Unable to create the portfolio. Please try again." (fallback)
|
|
51
51
|
*
|
|
52
52
|
* - `update`:
|
|
53
53
|
* - mutationFn: `updatePortfolio(api, id, data)`
|
|
54
54
|
* - variables: `{ id: string; data: Partial<Portfolio> }`
|
|
55
55
|
* - success message: "Portfolio updated successfully."
|
|
56
|
-
* - error message: "
|
|
56
|
+
* - error message: "Unable to update the portfolio. Please try again." (fallback)
|
|
57
57
|
*
|
|
58
58
|
* - `remove`:
|
|
59
59
|
* - mutationFn: `deletePortfolio(api, id, workspace)`
|
|
60
60
|
* - variables: `{ id: string; workspace: string }`
|
|
61
61
|
* - success message: "Portfolio deleted successfully."
|
|
62
|
-
* - error message: "
|
|
62
|
+
* - error message: "Unable to delete the portfolio. Please try again." (fallback)
|
|
63
63
|
*
|
|
64
64
|
* Return value:
|
|
65
65
|
* @returns {object}
|
|
66
66
|
* Returns an object with the three TanStack Query mutation results:
|
|
67
67
|
* - `create`: UseMutationResult<Portfolio, Error, CreatePortfolioProps, unknown>
|
|
68
68
|
* - `update`: UseMutationResult<Portfolio, Error, UpdatePortfolioProps, unknown>
|
|
69
|
-
* - `remove`: UseMutationResult<
|
|
69
|
+
* - `remove`: UseMutationResult<DeletedEntity, Error, DeletePortfolioProps, unknown>
|
|
70
70
|
*
|
|
71
71
|
* Each mutation includes standard TanStack Query helpers:
|
|
72
72
|
* - `mutate(variables, options?)`
|
|
@@ -79,7 +79,7 @@ type UsePortfolioMutationsProps = {
|
|
|
79
79
|
* ```ts
|
|
80
80
|
* const { create, update, remove } = usePortfolioMutations({ queryKey: ["portfolio"] });
|
|
81
81
|
*
|
|
82
|
-
|
|
82
|
+
* // Create (minimal example - other Security fields omitted for brevity)
|
|
83
83
|
* create.mutate({
|
|
84
84
|
* data: {
|
|
85
85
|
* name: "My Portfolio",
|
|
@@ -163,9 +163,9 @@ type UsePortfolioMutationsProps = {
|
|
|
163
163
|
* ```
|
|
164
164
|
*/
|
|
165
165
|
export declare const usePortfolioMutations: ({ queryKey }: UsePortfolioMutationsProps) => {
|
|
166
|
-
create: import("@tanstack/react-query").UseMutationResult<Portfolio,
|
|
167
|
-
update: import("@tanstack/react-query").UseMutationResult<Portfolio,
|
|
168
|
-
remove: import("@tanstack/react-query").UseMutationResult<
|
|
166
|
+
create: import("@tanstack/react-query").UseMutationResult<Portfolio, Error, CreatePortfolioProps, unknown>;
|
|
167
|
+
update: import("@tanstack/react-query").UseMutationResult<Portfolio, Error, UpdatePortfolioProps, unknown>;
|
|
168
|
+
remove: import("@tanstack/react-query").UseMutationResult<import("../..").DeletedEntity, Error, DeletePortfolioProps, unknown>;
|
|
169
169
|
};
|
|
170
170
|
export {};
|
|
171
171
|
//# sourceMappingURL=usePortfolioMutations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePortfolioMutations.d.ts","sourceRoot":"","sources":["../../../src/hooks/portfolio/usePortfolioMutations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePortfolioMutations.d.ts","sourceRoot":"","sources":["../../../src/hooks/portfolio/usePortfolioMutations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;CAC5B,CAAC;AAEF,KAAK,oBAAoB,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;CAC5B,CAAC;AAEF,KAAK,oBAAoB,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAC9B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoJG;AAEH,eAAO,MAAM,qBAAqB,GAAI,cAAc,0BAA0B;;;;CA0B7E,CAAC"}
|