@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":"provider.js","names":[],"sources":["../../../src/contexts/webSocketContext/provider.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { getWebsocketsConfig } from \"@/api/websocketsConfig\";\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport { WebSocketContext } from \".\";\nimport { WebSocketHandler } from \"./handler\";\nimport type {
|
|
1
|
+
{"version":3,"file":"provider.js","names":[],"sources":["../../../src/contexts/webSocketContext/provider.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { getWebsocketsConfig } from \"@/api/websocketsConfig\";\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport { WebSocketContext } from \".\";\nimport { WebSocketHandler } from \"./handler\";\nimport type {\n WebSocketContextType,\n WebSocketNotification,\n WebSocketProviderProps,\n WebSocketStatus,\n} from \"./types\";\n\n/**\n * Calls a status listener, logging and skipping one that throws, as notification listeners are,\n * so it cannot keep the others from hearing the change.\n */\nconst tellStatus = (listener: (status: WebSocketStatus) => void, status: WebSocketStatus) => {\n try {\n listener(status);\n } catch (error) {\n console.error(\"WebSocket status listener threw:\", error);\n }\n};\n\n/**\n * WebSocketProvider\n *\n * React context provider that exposes a receive-only pub/sub API backed by Socket.IO.\n *\n * What this provider does:\n * - Fetches `/api/websockets_config` once on mount to get the connection URL, channel id,\n * and session uid. Socket.IO handles reconnection internally — the config is not re-fetched,\n * and the effect that does it runs once (`changeStatus`, its only dependency, is stable).\n * - Opens a `WebSocketHandler` instance that connects and joins the per-user channel.\n * - Exposes `subscribe`, `subscribeStatus`, `lastMessage`, and `status` via `WebSocketContext`.\n *\n * Why the pending buffer exists (`pendingRef`):\n * - The handler is created asynchronously (after the config fetch resolves).\n * - Consumers that call `subscribe` before the handler is ready have their callbacks buffered\n * and registered once the handler initializes, ensuring no early subscriptions are lost.\n *\n * Subscribe buffering behavior:\n * - If `subscribe(fn)` is called before the handler exists, `fn` is stored with a `null` placeholder.\n * - Once the handler is ready, all pending callbacks are registered and their unsubscribe functions\n * stored back into the map.\n * - The returned cleanup always works: it calls the real unsubscribe if available, or removes\n * the entry from the pending map.\n *\n * Usage:\n * ```tsx\n * <WebSocketProvider>\n * <YourPage />\n * </WebSocketProvider>\n * ```\n *\n * Context value (WebSocketContextType):\n * @returns {object}\n * - `subscribe(fn)`: register a listener; returns an unsubscribe function.\n * - `subscribeStatus(fn)`: hear the current status at once, then every status the socket\n * reports, repeats included; returns an unsubscribe function.\n * - `lastMessage`: the most recently received notification (or null).\n * - `status`: current connection status (\"idle\" | \"connecting\" | \"connected\" | \"error\").\n */\nexport const WebSocketProvider = ({ children }: WebSocketProviderProps) => {\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n\n // Refs keep the latest values accessible inside the mount-only effect without\n // making it re-run when api or showAlert change.\n const apiRef = useRef(api);\n const showAlertRef = useRef(showAlert);\n useEffect(() => {\n apiRef.current = api;\n });\n useEffect(() => {\n showAlertRef.current = showAlert;\n });\n\n const handlerRef = useRef<WebSocketHandler | null>(null);\n const unsubscribeProviderRef = useRef<(() => void) | null>(null);\n const [lastMessage, setLastMessage] = useState<WebSocketNotification | null>(null);\n const [status, setStatus] = useState<WebSocketStatus>(\"idle\");\n const statusListenersRef = useRef(new Set<(status: WebSocketStatus) => void>());\n const currentStatusRef = useRef<WebSocketStatus>(\"idle\");\n\n /**\n * Sets `status` and tells the status listeners, so both see the same sequence. The current\n * status is also kept in a ref, so a new listener is told it at once rather than from React\n * state, which lags a change until the next render.\n */\n const changeStatus = useCallback((next: WebSocketStatus) => {\n currentStatusRef.current = next;\n setStatus(next);\n statusListenersRef.current.forEach((listener) => tellStatus(listener, next));\n }, []);\n\n const pendingRef = useRef(new Map<(m: WebSocketNotification) => void, (() => void) | null>());\n\n useEffect(() => {\n let cancelled = false;\n const pending = pendingRef.current;\n\n getWebsocketsConfig(apiRef.current)\n .then((config) => {\n if (cancelled) return;\n\n changeStatus(\"connecting\");\n const handler = new WebSocketHandler({\n ...config,\n onStatusChange: changeStatus,\n });\n handlerRef.current = handler;\n\n unsubscribeProviderRef.current = handler.listen((message) =>\n setLastMessage(message),\n );\n\n for (const [fn, unsub] of pending.entries()) {\n if (!unsub) {\n const realUnsub = handler.listen(fn);\n pending.set(fn, realUnsub);\n }\n }\n })\n .catch((error) => {\n if (cancelled) return;\n console.error(\"Failed to initialize WebSocket connection:\", error);\n changeStatus(\"error\");\n showAlertRef.current({\n message: \"Real-time notifications are unavailable. Please refresh the page.\",\n severity: \"error\",\n });\n });\n\n return () => {\n cancelled = true;\n unsubscribeProviderRef.current?.();\n unsubscribeProviderRef.current = null;\n handlerRef.current?.close();\n handlerRef.current = null;\n pending.clear();\n };\n }, [changeStatus]);\n\n const subscribe = useCallback((fn: (m: WebSocketNotification) => void) => {\n if (handlerRef.current) {\n return handlerRef.current.listen(fn);\n }\n\n pendingRef.current.set(fn, null);\n\n return () => {\n const maybeUnsub = pendingRef.current.get(fn);\n if (maybeUnsub) maybeUnsub();\n pendingRef.current.delete(fn);\n };\n }, []);\n\n const subscribeStatus = useCallback((listener: (status: WebSocketStatus) => void) => {\n statusListenersRef.current.add(listener);\n tellStatus(listener, currentStatusRef.current);\n return () => {\n statusListenersRef.current.delete(listener);\n };\n }, []);\n\n const value: WebSocketContextType = useMemo(\n () => ({ subscribe, subscribeStatus, lastMessage, status }),\n [subscribe, subscribeStatus, lastMessage, status],\n );\n\n return <WebSocketContext.Provider value={value}>{children}</WebSocketContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;AAkBA,IAAM,cAAc,UAA6C,WAA4B;CACzF,IAAI;EACA,SAAS,MAAM;CACnB,SAAS,OAAO;EACZ,QAAQ,MAAM,oCAAoC,KAAK;CAC3D;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,qBAAqB,EAAE,eAAuC;CACvE,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAIlC,MAAM,SAAS,OAAO,GAAG;CACzB,MAAM,eAAe,OAAO,SAAS;CACrC,gBAAgB;EACZ,OAAO,UAAU;CACrB,CAAC;CACD,gBAAgB;EACZ,aAAa,UAAU;CAC3B,CAAC;CAED,MAAM,aAAa,OAAgC,IAAI;CACvD,MAAM,yBAAyB,OAA4B,IAAI;CAC/D,MAAM,CAAC,aAAa,kBAAkB,SAAuC,IAAI;CACjF,MAAM,CAAC,QAAQ,aAAa,SAA0B,MAAM;CAC5D,MAAM,qBAAqB,uBAAO,IAAI,IAAuC,CAAC;CAC9E,MAAM,mBAAmB,OAAwB,MAAM;;;;;;CAOvD,MAAM,eAAe,aAAa,SAA0B;EACxD,iBAAiB,UAAU;EAC3B,UAAU,IAAI;EACd,mBAAmB,QAAQ,SAAS,aAAa,WAAW,UAAU,IAAI,CAAC;CAC/E,GAAG,CAAC,CAAC;CAEL,MAAM,aAAa,uBAAO,IAAI,IAA6D,CAAC;CAE5F,gBAAgB;EACZ,IAAI,YAAY;EAChB,MAAM,UAAU,WAAW;EAE3B,oBAAoB,OAAO,OAAO,CAAC,CAC9B,MAAM,WAAW;GACd,IAAI,WAAW;GAEf,aAAa,YAAY;GACzB,MAAM,UAAU,IAAI,iBAAiB;IACjC,GAAG;IACH,gBAAgB;GACpB,CAAC;GACD,WAAW,UAAU;GAErB,uBAAuB,UAAU,QAAQ,QAAQ,YAC7C,eAAe,OAAO,CAC1B;GAEA,KAAK,MAAM,CAAC,IAAI,UAAU,QAAQ,QAAQ,GACtC,IAAI,CAAC,OAAO;IACR,MAAM,YAAY,QAAQ,OAAO,EAAE;IACnC,QAAQ,IAAI,IAAI,SAAS;GAC7B;EAER,CAAC,CAAC,CACD,OAAO,UAAU;GACd,IAAI,WAAW;GACf,QAAQ,MAAM,8CAA8C,KAAK;GACjE,aAAa,OAAO;GACpB,aAAa,QAAQ;IACjB,SAAS;IACT,UAAU;GACd,CAAC;EACL,CAAC;EAEL,aAAa;GACT,YAAY;GACZ,uBAAuB,UAAU;GACjC,uBAAuB,UAAU;GACjC,WAAW,SAAS,MAAM;GAC1B,WAAW,UAAU;GACrB,QAAQ,MAAM;EAClB;CACJ,GAAG,CAAC,YAAY,CAAC;CAEjB,MAAM,YAAY,aAAa,OAA2C;EACtE,IAAI,WAAW,SACX,OAAO,WAAW,QAAQ,OAAO,EAAE;EAGvC,WAAW,QAAQ,IAAI,IAAI,IAAI;EAE/B,aAAa;GACT,MAAM,aAAa,WAAW,QAAQ,IAAI,EAAE;GAC5C,IAAI,YAAY,WAAW;GAC3B,WAAW,QAAQ,OAAO,EAAE;EAChC;CACJ,GAAG,CAAC,CAAC;CAEL,MAAM,kBAAkB,aAAa,aAAgD;EACjF,mBAAmB,QAAQ,IAAI,QAAQ;EACvC,WAAW,UAAU,iBAAiB,OAAO;EAC7C,aAAa;GACT,mBAAmB,QAAQ,OAAO,QAAQ;EAC9C;CACJ,GAAG,CAAC,CAAC;CAEL,MAAM,QAA8B,eACzB;EAAE;EAAW;EAAiB;EAAa;CAAO,IACzD;EAAC;EAAW;EAAiB;EAAa;CAAM,CACpD;CAEA,OAAO,oBAAC,iBAAiB,UAAlB;EAAkC;EAAQ;CAAoC,CAAA;AACzF"}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
export type WebsocketsConfig = {
|
|
3
|
-
appConnectionURL: string;
|
|
4
|
-
appChannelID: string;
|
|
5
|
-
everyskUID: string;
|
|
6
|
-
};
|
|
7
2
|
export type WebSocketStatus = "idle" | "connecting" | "connected" | "error";
|
|
8
3
|
export type AppNotificationPayload = {
|
|
9
4
|
[key: string]: unknown;
|
|
@@ -32,6 +27,13 @@ export type AppNotification = WebSocketNotification & {
|
|
|
32
27
|
};
|
|
33
28
|
export type WebSocketContextType = {
|
|
34
29
|
subscribe: (listener: (msg: WebSocketNotification) => void) => () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Calls `listener` with the current status at once, then on every status the socket reports,
|
|
32
|
+
* repeats included; returns the unsubscribe. For code that waits on the socket outside React,
|
|
33
|
+
* where `status` cannot be watched: a reconnect is when it must catch up on what was
|
|
34
|
+
* published in between, which the server does not replay.
|
|
35
|
+
*/
|
|
36
|
+
subscribeStatus: (listener: (status: WebSocketStatus) => void) => () => void;
|
|
35
37
|
lastMessage: WebSocketNotification | null;
|
|
36
38
|
status: WebSocketStatus;
|
|
37
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/contexts/webSocketContext/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/contexts/webSocketContext/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AAE5E,MAAM,MAAM,sBAAsB,GAAG;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,qBAAqB,GAAG;IAClD,UAAU,EAAE,uBAAuB,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,sBAAsB,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,qBAAqB,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IAC1E;;;;;OAKG;IACH,eAAe,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IAC7E,WAAW,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC1C,MAAM,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IAIjC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,CAAC"}
|
package/dist/file/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export * from "../types/file.d.ts";
|
|
|
3
3
|
export * from "../hooks/file/useFetchFile.js";
|
|
4
4
|
export * from "../hooks/file/useFetchFiles.js";
|
|
5
5
|
export * from "../hooks/file/useFileMutations.js";
|
|
6
|
+
export * from "../lib/file.js";
|
|
7
|
+
export type { FileDataProps } from "../hooks/file/fileData.js";
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/file/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAQA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAQA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -66,7 +66,7 @@ type UseDatastoreMutationsProps = {
|
|
|
66
66
|
* Returns an object with the three TanStack Query mutation results:
|
|
67
67
|
* - `create`: UseMutationResult<Datastore, Error, CreateDatastoreProps, unknown>
|
|
68
68
|
* - `update`: UseMutationResult<Datastore, Error, UpdateDatastoreProps, unknown>
|
|
69
|
-
* - `remove`: UseMutationResult<
|
|
69
|
+
* - `remove`: UseMutationResult<DeletedEntity, Error, DeleteDatastoreProps, unknown>
|
|
70
70
|
*
|
|
71
71
|
* Each mutation includes standard TanStack Query helpers:
|
|
72
72
|
* - `mutate(variables, options?)`
|
|
@@ -143,9 +143,9 @@ type UseDatastoreMutationsProps = {
|
|
|
143
143
|
* ```
|
|
144
144
|
*/
|
|
145
145
|
export declare const useDatastoreMutations: ({ queryKey }: UseDatastoreMutationsProps) => {
|
|
146
|
-
create: import("@tanstack/react-query").UseMutationResult<Datastore,
|
|
147
|
-
update: import("@tanstack/react-query").UseMutationResult<Datastore,
|
|
148
|
-
remove: import("@tanstack/react-query").UseMutationResult<import("../..").
|
|
146
|
+
create: import("@tanstack/react-query").UseMutationResult<Datastore, Error, CreateDatastoreProps, unknown>;
|
|
147
|
+
update: import("@tanstack/react-query").UseMutationResult<Datastore, Error, UpdateDatastoreProps, unknown>;
|
|
148
|
+
remove: import("@tanstack/react-query").UseMutationResult<import("../..").DeletedEntity, Error, DeleteDatastoreProps, unknown>;
|
|
149
149
|
};
|
|
150
150
|
export {};
|
|
151
151
|
//# sourceMappingURL=useDatastoreMutations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDatastoreMutations.d.ts","sourceRoot":"","sources":["../../../src/hooks/datastore/useDatastoreMutations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDatastoreMutations.d.ts","sourceRoot":"","sources":["../../../src/hooks/datastore/useDatastoreMutations.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgIG;AAEH,eAAO,MAAM,qBAAqB,GAAI,cAAc,0BAA0B;;;;CA0B7E,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
|
|
2
1
|
import { useAxios } from "../useAxios.js";
|
|
2
|
+
import { useEntityMutation } from "../useEntityMutation.js";
|
|
3
3
|
import { createDatastore, deleteDatastore, updateDatastore } from "../../api/datastore.js";
|
|
4
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
4
|
//#region src/hooks/datastore/useDatastoreMutations.ts
|
|
6
|
-
var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? err.message : fallback;
|
|
7
5
|
/**
|
|
8
6
|
* useDatastoreMutations
|
|
9
7
|
*
|
|
@@ -57,7 +55,7 @@ var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? e
|
|
|
57
55
|
* Returns an object with the three TanStack Query mutation results:
|
|
58
56
|
* - `create`: UseMutationResult<Datastore, Error, CreateDatastoreProps, unknown>
|
|
59
57
|
* - `update`: UseMutationResult<Datastore, Error, UpdateDatastoreProps, unknown>
|
|
60
|
-
* - `remove`: UseMutationResult<
|
|
58
|
+
* - `remove`: UseMutationResult<DeletedEntity, Error, DeleteDatastoreProps, unknown>
|
|
61
59
|
*
|
|
62
60
|
* Each mutation includes standard TanStack Query helpers:
|
|
63
61
|
* - `mutate(variables, options?)`
|
|
@@ -135,60 +133,24 @@ var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? e
|
|
|
135
133
|
*/
|
|
136
134
|
var useDatastoreMutations = ({ queryKey }) => {
|
|
137
135
|
const { api } = useAxios();
|
|
138
|
-
const { showAlert } = useAppAlert();
|
|
139
|
-
const queryClient = useQueryClient();
|
|
140
|
-
const invalidate = async () => {
|
|
141
|
-
if (!queryKey?.length) return;
|
|
142
|
-
await queryClient.invalidateQueries({ queryKey });
|
|
143
|
-
};
|
|
144
136
|
return {
|
|
145
|
-
create:
|
|
146
|
-
mutationFn:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
severity: "success",
|
|
151
|
-
message: "Datastore created successfully."
|
|
152
|
-
});
|
|
153
|
-
},
|
|
154
|
-
onError: (err) => {
|
|
155
|
-
showAlert({
|
|
156
|
-
severity: "error",
|
|
157
|
-
message: getErrorMessage(err, "Unable to create the datastore. Please try again.")
|
|
158
|
-
});
|
|
159
|
-
}
|
|
137
|
+
create: useEntityMutation({
|
|
138
|
+
mutationFn: ({ data }) => createDatastore(api, data),
|
|
139
|
+
queryKey,
|
|
140
|
+
successMessage: "Datastore created successfully.",
|
|
141
|
+
errorMessage: "Unable to create the datastore. Please try again."
|
|
160
142
|
}),
|
|
161
|
-
update:
|
|
162
|
-
mutationFn:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
severity: "success",
|
|
167
|
-
message: "Datastore updated successfully."
|
|
168
|
-
});
|
|
169
|
-
},
|
|
170
|
-
onError: (err) => {
|
|
171
|
-
showAlert({
|
|
172
|
-
severity: "error",
|
|
173
|
-
message: getErrorMessage(err, "Unable to update the datastore. Please try again.")
|
|
174
|
-
});
|
|
175
|
-
}
|
|
143
|
+
update: useEntityMutation({
|
|
144
|
+
mutationFn: ({ id, data }) => updateDatastore(api, id, data),
|
|
145
|
+
queryKey,
|
|
146
|
+
successMessage: "Datastore updated successfully.",
|
|
147
|
+
errorMessage: "Unable to update the datastore. Please try again."
|
|
176
148
|
}),
|
|
177
|
-
remove:
|
|
178
|
-
mutationFn:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
severity: "success",
|
|
183
|
-
message: "Datastore deleted successfully."
|
|
184
|
-
});
|
|
185
|
-
},
|
|
186
|
-
onError: (err) => {
|
|
187
|
-
showAlert({
|
|
188
|
-
severity: "error",
|
|
189
|
-
message: getErrorMessage(err, "Unable to delete the datastore. Please try again.")
|
|
190
|
-
});
|
|
191
|
-
}
|
|
149
|
+
remove: useEntityMutation({
|
|
150
|
+
mutationFn: ({ id, workspace }) => deleteDatastore(api, id, workspace),
|
|
151
|
+
queryKey,
|
|
152
|
+
successMessage: "Datastore deleted successfully.",
|
|
153
|
+
errorMessage: "Unable to delete the datastore. Please try again."
|
|
192
154
|
})
|
|
193
155
|
};
|
|
194
156
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDatastoreMutations.js","names":[],"sources":["../../../src/hooks/datastore/useDatastoreMutations.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useDatastoreMutations.js","names":[],"sources":["../../../src/hooks/datastore/useDatastoreMutations.ts"],"sourcesContent":["import { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityMutation } from \"@/hooks/useEntityMutation\";\nimport type { Datastore } from \"@/types/datastore\";\nimport { deleteDatastore, createDatastore, updateDatastore } from \"@/api/datastore\";\n\ntype CreateDatastoreProps = {\n data: Partial<Datastore>;\n};\n\ntype UpdateDatastoreProps = {\n id: string;\n data: Partial<Datastore>;\n};\n\ntype DeleteDatastoreProps = {\n id: string;\n workspace: string;\n};\n\ntype UseDatastoreMutationsProps = {\n queryKey?: unknown[];\n};\n\n/**\n * useDatastoreMutations\n *\n * Mutation hook built on TanStack Query to perform Datastore write operations:\n * - create a datastore (POST)\n * - update a datastore (PUT)\n * - delete a datastore (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 `useFetchDatastore`.\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 `deleteDatastore(api, id, workspace)`\n * expects it as a query param.\n *\n * Parameters (UseDatastoreMutationsProps):\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., datastore list/detail) so UI data is refreshed automatically after a write.\n *\n * Tip:\n * - If you're using `useFetchDatastore`, you can pass its returned `queryKey` directly:\n * `const fetch = useFetchDatastore(...);`\n * `useDatastoreMutations({ queryKey: fetch.queryKey });`\n *\n * Mutations:\n * - `create`:\n * - mutationFn: `createDatastore(api, data)`\n * - variables: `{ data: Partial<Datastore> }`\n * - success message: \"Datastore created successfully.\"\n * - error message: \"Unable to create the datastore. Please try again.\" (fallback)\n *\n * - `update`:\n * - mutationFn: `updateDatastore(api, id, data)`\n * - variables: `{ id: string; data: Partial<Datastore> }`\n * - success message: \"Datastore updated successfully.\"\n * - error message: \"Unable to update the datastore. Please try again.\" (fallback)\n *\n * - `remove`:\n * - mutationFn: `deleteDatastore(api, id, workspace)`\n * - variables: `{ id: string; workspace: string }`\n * - success message: \"Datastore deleted successfully.\"\n * - error message: \"Unable to delete the datastore. 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<Datastore, Error, CreateDatastoreProps, unknown>\n * - `update`: UseMutationResult<Datastore, Error, UpdateDatastoreProps, unknown>\n * - `remove`: UseMutationResult<DeletedEntity, Error, DeleteDatastoreProps, 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 datastore list query after mutations:\n * ```ts\n * const { create, update, remove } = useDatastoreMutations({ queryKey: [\"datastore\"] });\n *\n * // Create\n * create.mutate({\n * data: {\n * name: \"My datastore\",\n * workspace: \"ws-1\",\n * data: [[\"id\", \"name\"], [\"ABEOX135\", \"Jorge\"]],\n * }\n * });\n *\n * // Update\n * update.mutate({\n * id: \"ds-123\",\n * data: {\n * name: \"Renamed datastore\",\n * data: [[\"id\", \"name\"], [\"ABEOX135\", \"Jorge\"]],\n * }\n * });\n *\n * // Delete\n * remove.mutate({\n * id: \"ds-123\",\n * workspace: \"ws-1\"\n * });\n * ```\n *\n * 2) Using async/await with `mutateAsync`:\n * ```ts\n * const { create } = useDatastoreMutations({ queryKey: [\"datastore\"] });\n *\n * await create.mutateAsync({\n * data: {\n * name: \"My datastore\",\n * workspace: \"ws-1\",\n * data: [[\"id\", \"name\"], [\"ABEOX135\", \"Jorge\"]],\n * }\n * });\n * ```\n *\n * 3) Without cache invalidation (no queryKey):\n * ```ts\n * const { update } = useDatastoreMutations({});\n *\n * update.mutate({\n * id: \"ds-123\",\n * data: { name: \"Renamed datastore\" }\n * });\n * // Mutation still runs and alerts are shown, but cached queries are not invalidated.\n * ```\n *\n * 4) Using `useFetchDatastore` queryKey for automatic invalidation:\n * ```ts\n * const fetch = useFetchDatastore({\n * id: null,\n * filters: [{ field: \"workspace\", value: \"ws-1\" }],\n * });\n *\n * const { create } = useDatastoreMutations({ queryKey: fetch.queryKey });\n *\n * await create.mutateAsync({\n * data: { name: \"My datastore\", workspace: \"ws-1\" }\n * });\n * ```\n */\n\nexport const useDatastoreMutations = ({ queryKey }: UseDatastoreMutationsProps) => {\n const { api } = useAxios();\n\n const create = useEntityMutation({\n mutationFn: ({ data }: CreateDatastoreProps) => createDatastore(api, data),\n queryKey,\n successMessage: \"Datastore created successfully.\",\n errorMessage: \"Unable to create the datastore. Please try again.\",\n });\n\n const update = useEntityMutation({\n mutationFn: ({ id, data }: UpdateDatastoreProps) => updateDatastore(api, id, data),\n queryKey,\n successMessage: \"Datastore updated successfully.\",\n errorMessage: \"Unable to update the datastore. Please try again.\",\n });\n\n const remove = useEntityMutation({\n mutationFn: ({ id, workspace }: DeleteDatastoreProps) =>\n deleteDatastore(api, id, workspace),\n queryKey,\n successMessage: \"Datastore deleted successfully.\",\n errorMessage: \"Unable to delete the datastore. Please try again.\",\n });\n\n return { create, update, remove };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyJA,IAAa,yBAAyB,EAAE,eAA2C;CAC/E,MAAM,EAAE,QAAQ,SAAS;CAwBzB,OAAO;EAAE,QAtBM,kBAAkB;GAC7B,aAAa,EAAE,WAAiC,gBAAgB,KAAK,IAAI;GACzE;GACA,gBAAgB;GAChB,cAAc;EAClB,CAiBS;EAAQ,QAfF,kBAAkB;GAC7B,aAAa,EAAE,IAAI,WAAiC,gBAAgB,KAAK,IAAI,IAAI;GACjF;GACA,gBAAgB;GAChB,cAAc;EAClB,CAUiB;EAAQ,QARV,kBAAkB;GAC7B,aAAa,EAAE,IAAI,gBACf,gBAAgB,KAAK,IAAI,SAAS;GACtC;GACA,gBAAgB;GAChB,cAAc;EAClB,CAEyB;CAAO;AACpC"}
|
|
@@ -1,47 +1,36 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import type { ParsedDatastore } from "../../types/datastore.d.ts";
|
|
2
|
+
import type { DatastoreDataFormat } from "../../types/datastoreDataFormat.d.ts";
|
|
3
|
+
import type { FetchEntityByIdProps } from "../../types/entityQuery.d.ts";
|
|
4
|
+
export type FetchDatastoreProps<F extends DatastoreDataFormat = "object", TSelected = ParsedDatastore<F>> = FetchEntityByIdProps<ParsedDatastore<F>, TSelected> & {
|
|
5
|
+
/**
|
|
6
|
+
* Tabular datastores only: `"object"` (default) turns the matrix into one object per row;
|
|
7
|
+
* `"matrix"` leaves the matrix, header row included. A JSON datastore's `data` is unchanged either way.
|
|
8
|
+
*/
|
|
9
|
+
dataFormat?: F;
|
|
10
|
+
};
|
|
4
11
|
/**
|
|
5
12
|
* useFetchDatastore
|
|
6
13
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Important notes:
|
|
13
|
-
* - Returns a `DatastoreWithRows` object: the full `Datastore` shape with `data`
|
|
14
|
-
* replaced by `AnyRecord[]` (rows transformed via `tableToObjects`).
|
|
15
|
-
*
|
|
16
|
-
* Parameters (FetchDatastoreProps):
|
|
17
|
-
* @param {string} id
|
|
18
|
-
* Datastore identifier (required).
|
|
19
|
-
*
|
|
20
|
-
* @param {string} workspace
|
|
21
|
-
* Workspace the datastore belongs to (required by `getDatastore`).
|
|
14
|
+
* Fetches one datastore. `data` is a `ParsedDatastore` — a table's matrix converted to row
|
|
15
|
+
* objects with `fields`, or a JSON datastore's content untouched, told apart by `format`, the
|
|
16
|
+
* same shape `useFetchDatastores` returns — or whatever `select` makes of it. With
|
|
17
|
+
* `dataFormat: "matrix"` a tabular datastore keeps its matrix unconverted, as in `useFetchDatastores`.
|
|
22
18
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
19
|
+
* Idle while `id` is empty; fails loudly, without a request, while `workspace` is. A failure is
|
|
20
|
+
* shown as an error alert.
|
|
25
21
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* - `queryKey`: the cache key used by React Query
|
|
22
|
+
* @param {FetchDatastoreProps} props - `id`, `workspace`, `dataFormat`, `select` and TanStack
|
|
23
|
+
* `queryOptions`.
|
|
24
|
+
* @returns {object} The `useQuery` result, plus `queryKey`.
|
|
30
25
|
*
|
|
31
26
|
* Example:
|
|
32
27
|
* ```ts
|
|
33
|
-
* const { data, isLoading } = useFetchDatastore({
|
|
34
|
-
* id: "abc123",
|
|
35
|
-
* workspace: "my-workspace",
|
|
36
|
-
* });
|
|
37
|
-
* // data -> DatastoreWithRows (datastore metadata + rows as AnyRecord[])
|
|
38
|
-
* // data.name -> "my-datastore"
|
|
39
|
-
* // data.data -> [{ datastoreId: "abc123", col1: "value", ... }]
|
|
28
|
+
* const { data, isLoading, queryKey } = useFetchDatastore({ id: "abc123", workspace: "ws-1" });
|
|
40
29
|
* ```
|
|
41
30
|
*/
|
|
42
|
-
export declare const useFetchDatastore: ({ id, workspace, queryOptions }: FetchDatastoreProps) => {
|
|
31
|
+
export declare const useFetchDatastore: <F extends DatastoreDataFormat = "object", TSelected = ParsedDatastore<F>>({ id, workspace, dataFormat, select, queryOptions, }: FetchDatastoreProps<F, TSelected>) => {
|
|
43
32
|
queryKey: string[];
|
|
44
|
-
data:
|
|
33
|
+
data: TSelected;
|
|
45
34
|
error: Error;
|
|
46
35
|
isError: true;
|
|
47
36
|
isPending: false;
|
|
@@ -64,11 +53,11 @@ export declare const useFetchDatastore: ({ id, workspace, queryOptions }: FetchD
|
|
|
64
53
|
isRefetching: boolean;
|
|
65
54
|
isStale: boolean;
|
|
66
55
|
isEnabled: boolean;
|
|
67
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
56
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
68
57
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
69
58
|
} | {
|
|
70
59
|
queryKey: string[];
|
|
71
|
-
data:
|
|
60
|
+
data: TSelected;
|
|
72
61
|
error: null;
|
|
73
62
|
isError: false;
|
|
74
63
|
isPending: false;
|
|
@@ -91,7 +80,7 @@ export declare const useFetchDatastore: ({ id, workspace, queryOptions }: FetchD
|
|
|
91
80
|
isRefetching: boolean;
|
|
92
81
|
isStale: boolean;
|
|
93
82
|
isEnabled: boolean;
|
|
94
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
83
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
95
84
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
96
85
|
} | {
|
|
97
86
|
queryKey: string[];
|
|
@@ -118,7 +107,7 @@ export declare const useFetchDatastore: ({ id, workspace, queryOptions }: FetchD
|
|
|
118
107
|
isRefetching: boolean;
|
|
119
108
|
isStale: boolean;
|
|
120
109
|
isEnabled: boolean;
|
|
121
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
110
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
122
111
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
123
112
|
} | {
|
|
124
113
|
queryKey: string[];
|
|
@@ -145,7 +134,7 @@ export declare const useFetchDatastore: ({ id, workspace, queryOptions }: FetchD
|
|
|
145
134
|
isRefetching: boolean;
|
|
146
135
|
isStale: boolean;
|
|
147
136
|
isEnabled: boolean;
|
|
148
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
137
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
149
138
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
150
139
|
} | {
|
|
151
140
|
queryKey: string[];
|
|
@@ -172,11 +161,11 @@ export declare const useFetchDatastore: ({ id, workspace, queryOptions }: FetchD
|
|
|
172
161
|
isRefetching: boolean;
|
|
173
162
|
isStale: boolean;
|
|
174
163
|
isEnabled: boolean;
|
|
175
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
164
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
176
165
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
177
166
|
} | {
|
|
178
167
|
queryKey: string[];
|
|
179
|
-
data:
|
|
168
|
+
data: TSelected;
|
|
180
169
|
isError: false;
|
|
181
170
|
error: null;
|
|
182
171
|
isPending: false;
|
|
@@ -199,7 +188,7 @@ export declare const useFetchDatastore: ({ id, workspace, queryOptions }: FetchD
|
|
|
199
188
|
isRefetching: boolean;
|
|
200
189
|
isStale: boolean;
|
|
201
190
|
isEnabled: boolean;
|
|
202
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
191
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
|
|
203
192
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
204
193
|
};
|
|
205
194
|
//# sourceMappingURL=useFetchDatastore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchDatastore.d.ts","sourceRoot":"","sources":["../../../src/hooks/datastore/useFetchDatastore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFetchDatastore.d.ts","sourceRoot":"","sources":["../../../src/hooks/datastore/useFetchDatastore.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,MAAM,MAAM,mBAAmB,CAC3B,CAAC,SAAS,mBAAmB,GAAG,QAAQ,EACxC,SAAS,GAAG,eAAe,CAAC,CAAC,CAAC,IAC9B,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG;IACtD;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,iBAAiB,GAC1B,CAAC,SAAS,mBAAmB,GAAG,QAAQ,EACxC,SAAS,GAAG,eAAe,CAAC,CAAC,CAAC,EAChC,sDAMC,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBnC,CAAC"}
|
|
@@ -1,81 +1,47 @@
|
|
|
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 { getDatastore } from "../../api/datastore.js";
|
|
4
|
-
import {
|
|
5
|
-
import { useEffect } from "react";
|
|
6
|
-
import { useQuery } from "@tanstack/react-query";
|
|
5
|
+
import { parseDatastore } from "../../lib/datastoreTable.js";
|
|
7
6
|
//#region src/hooks/datastore/useFetchDatastore.ts
|
|
8
|
-
var defaultQueryOptions = {
|
|
9
|
-
refetchOnMount: "always",
|
|
10
|
-
staleTime: 0,
|
|
11
|
-
gcTime: 0
|
|
12
|
-
};
|
|
13
7
|
/**
|
|
14
8
|
* useFetchDatastore
|
|
15
9
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* Important notes:
|
|
22
|
-
* - Returns a `DatastoreWithRows` object: the full `Datastore` shape with `data`
|
|
23
|
-
* replaced by `AnyRecord[]` (rows transformed via `tableToObjects`).
|
|
24
|
-
*
|
|
25
|
-
* Parameters (FetchDatastoreProps):
|
|
26
|
-
* @param {string} id
|
|
27
|
-
* Datastore identifier (required).
|
|
28
|
-
*
|
|
29
|
-
* @param {string} workspace
|
|
30
|
-
* Workspace the datastore belongs to (required by `getDatastore`).
|
|
10
|
+
* Fetches one datastore. `data` is a `ParsedDatastore` — a table's matrix converted to row
|
|
11
|
+
* objects with `fields`, or a JSON datastore's content untouched, told apart by `format`, the
|
|
12
|
+
* same shape `useFetchDatastores` returns — or whatever `select` makes of it. With
|
|
13
|
+
* `dataFormat: "matrix"` a tabular datastore keeps its matrix unconverted, as in `useFetchDatastores`.
|
|
31
14
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
15
|
+
* Idle while `id` is empty; fails loudly, without a request, while `workspace` is. A failure is
|
|
16
|
+
* shown as an error alert.
|
|
34
17
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* - `queryKey`: the cache key used by React Query
|
|
18
|
+
* @param {FetchDatastoreProps} props - `id`, `workspace`, `dataFormat`, `select` and TanStack
|
|
19
|
+
* `queryOptions`.
|
|
20
|
+
* @returns {object} The `useQuery` result, plus `queryKey`.
|
|
39
21
|
*
|
|
40
22
|
* Example:
|
|
41
23
|
* ```ts
|
|
42
|
-
* const { data, isLoading } = useFetchDatastore({
|
|
43
|
-
* id: "abc123",
|
|
44
|
-
* workspace: "my-workspace",
|
|
45
|
-
* });
|
|
46
|
-
* // data -> DatastoreWithRows (datastore metadata + rows as AnyRecord[])
|
|
47
|
-
* // data.name -> "my-datastore"
|
|
48
|
-
* // data.data -> [{ datastoreId: "abc123", col1: "value", ... }]
|
|
24
|
+
* const { data, isLoading, queryKey } = useFetchDatastore({ id: "abc123", workspace: "ws-1" });
|
|
49
25
|
* ```
|
|
50
26
|
*/
|
|
51
|
-
var useFetchDatastore = ({ id, workspace,
|
|
27
|
+
var useFetchDatastore = ({ id, workspace, dataFormat, select, queryOptions }) => {
|
|
52
28
|
const { api } = useAxios();
|
|
53
|
-
const
|
|
29
|
+
const format = dataFormat ?? "object";
|
|
54
30
|
const queryKey = [
|
|
55
31
|
"datastore",
|
|
56
32
|
id,
|
|
57
|
-
workspace
|
|
33
|
+
workspace,
|
|
34
|
+
format
|
|
58
35
|
];
|
|
59
|
-
const query = useQuery({
|
|
60
|
-
queryKey,
|
|
61
|
-
queryFn: async () => {
|
|
62
|
-
const datastore = await getDatastore(api, id, workspace);
|
|
63
|
-
return {
|
|
64
|
-
...datastore,
|
|
65
|
-
data: tableToObjects(datastore.id, datastore.data?.[0], datastore.data)
|
|
66
|
-
};
|
|
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
36
|
return {
|
|
78
|
-
...
|
|
37
|
+
...useEntityQuery({
|
|
38
|
+
queryKey,
|
|
39
|
+
fetchEntity: async (signal) => parseDatastore(await getDatastore(api, id, workspace, signal), format),
|
|
40
|
+
select,
|
|
41
|
+
enabled: Boolean(id),
|
|
42
|
+
configError: workspace ? void 0 : missingWorkspaceError("useFetchDatastore"),
|
|
43
|
+
queryOptions
|
|
44
|
+
}),
|
|
79
45
|
queryKey
|
|
80
46
|
};
|
|
81
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchDatastore.js","names":[],"sources":["../../../src/hooks/datastore/useFetchDatastore.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useFetchDatastore.js","names":[],"sources":["../../../src/hooks/datastore/useFetchDatastore.ts"],"sourcesContent":["import { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityQuery } from \"@/hooks/useEntityQuery\";\nimport { missingWorkspaceError } from \"@/api/entityQuery\";\nimport { getDatastore } from \"@/api/datastore\";\nimport { parseDatastore } from \"@/lib/datastoreTable\";\nimport type { ParsedDatastore } from \"@/types/datastore\";\nimport type { DatastoreDataFormat } from \"@/types/datastoreDataFormat\";\nimport type { FetchEntityByIdProps } from \"@/types/entityQuery\";\n\nexport type FetchDatastoreProps<\n F extends DatastoreDataFormat = \"object\",\n TSelected = ParsedDatastore<F>,\n> = FetchEntityByIdProps<ParsedDatastore<F>, TSelected> & {\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 * useFetchDatastore\n *\n * Fetches one datastore. `data` is a `ParsedDatastore` — a table's matrix converted to row\n * objects with `fields`, or a JSON datastore's content untouched, told apart by `format`, the\n * same shape `useFetchDatastores` returns — or whatever `select` makes of it. With\n * `dataFormat: \"matrix\"` a tabular datastore keeps its matrix unconverted, as in `useFetchDatastores`.\n *\n * Idle while `id` is empty; fails loudly, without a request, while `workspace` is. A failure is\n * shown as an error alert.\n *\n * @param {FetchDatastoreProps} props - `id`, `workspace`, `dataFormat`, `select` and TanStack\n * `queryOptions`.\n * @returns {object} The `useQuery` result, plus `queryKey`.\n *\n * Example:\n * ```ts\n * const { data, isLoading, queryKey } = useFetchDatastore({ id: \"abc123\", workspace: \"ws-1\" });\n * ```\n */\nexport const useFetchDatastore = <\n F extends DatastoreDataFormat = \"object\",\n TSelected = ParsedDatastore<F>,\n>({\n id,\n workspace,\n dataFormat,\n select,\n queryOptions,\n}: FetchDatastoreProps<F, TSelected>) => {\n const { api } = useAxios();\n\n const format = (dataFormat ?? \"object\") as F;\n const queryKey = [\"datastore\", id, workspace, format];\n\n const query = useEntityQuery<ParsedDatastore<F>, TSelected>({\n queryKey,\n fetchEntity: async (signal) =>\n parseDatastore(await getDatastore(api, id, workspace, signal), format),\n select,\n enabled: Boolean(id),\n configError: workspace ? undefined : missingWorkspaceError(\"useFetchDatastore\"),\n queryOptions,\n });\n\n return { ...query, queryKey };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,qBAGX,EACE,IACA,WACA,YACA,QACA,mBACqC;CACrC,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,SAAU,cAAc;CAC9B,MAAM,WAAW;EAAC;EAAa;EAAI;EAAW;CAAM;CAYpD,OAAO;EAAE,GAVK,eAA8C;GACxD;GACA,aAAa,OAAO,WAChB,eAAe,MAAM,aAAa,KAAK,IAAI,WAAW,MAAM,GAAG,MAAM;GACzE;GACA,SAAS,QAAQ,EAAE;GACnB,aAAa,YAAY,KAAA,IAAY,sBAAsB,mBAAmB;GAC9E;EACJ,CAEY;EAAO;CAAS;AAChC"}
|