@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
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { isAxiosError, isCancel, type AxiosResponse } from "axios";
|
|
2
|
+
|
|
3
|
+
import type { AnyRecord } from "@/types/anyRecord";
|
|
4
|
+
import type { FilterExpression, QueryObject } from "@/types/entityQuery";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* request
|
|
8
|
+
*
|
|
9
|
+
* Sends one request and returns its body, with the error handling every `api/` function shares.
|
|
10
|
+
* Each of them used to carry its own copy of this `catch`, and the copies drifted: some
|
|
11
|
+
* rethrew a cancellation and some did not, and `runWorkflow` had lost its fallback message.
|
|
12
|
+
*
|
|
13
|
+
* The request goes in as a function rather than a config so each call site keeps calling
|
|
14
|
+
* `api.get`, `api.post`… itself, which is what reads as the endpoint and what the tests stub.
|
|
15
|
+
*
|
|
16
|
+
* - A cancellation is rethrown as axios made it: an abort is not a failure to report, and
|
|
17
|
+
* wrapped in a new Error `isCancel` would no longer see it.
|
|
18
|
+
* - An axios error becomes an Error with its message, or `failure` when it has none, and the
|
|
19
|
+
* axios error as `cause` — the only place the API's own `{ code, message }` body survives.
|
|
20
|
+
* - Any other Error is rethrown untouched, and anything else is wrapped, so a caller never
|
|
21
|
+
* catches a bare string.
|
|
22
|
+
*
|
|
23
|
+
* @param send - Makes the request.
|
|
24
|
+
* @param failure - The message when the error carries none.
|
|
25
|
+
* @returns The response body.
|
|
26
|
+
*/
|
|
27
|
+
export const request = async <T>(
|
|
28
|
+
send: () => Promise<AxiosResponse<T>>,
|
|
29
|
+
failure: string,
|
|
30
|
+
): Promise<T> => {
|
|
31
|
+
try {
|
|
32
|
+
const response = await send();
|
|
33
|
+
return response.data;
|
|
34
|
+
} catch (error: unknown) {
|
|
35
|
+
if (isCancel(error)) throw error;
|
|
36
|
+
|
|
37
|
+
if (isAxiosError<AnyRecord>(error)) {
|
|
38
|
+
throw new Error(error.message || failure, { cause: error });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (error instanceof Error) {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw new Error(failure, { cause: error });
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* isRetryableFailure
|
|
51
|
+
*
|
|
52
|
+
* Whether a failure `request()` reported may pass if the request is sent again: one that got no
|
|
53
|
+
* response (a network error), a 5XX, or a 429. It is read from the axios error `request()` keeps
|
|
54
|
+
* as `cause`. Anything else will fail the same way next time: any other 4XX, and anything that is
|
|
55
|
+
* not a request failure at all — a bug, or a body that is not the expected JSON, such as the HTML
|
|
56
|
+
* page an expired session gets.
|
|
57
|
+
*
|
|
58
|
+
* @param error - What a request function threw.
|
|
59
|
+
* @returns True when retrying may succeed.
|
|
60
|
+
*/
|
|
61
|
+
export const isRetryableFailure = (error: unknown): boolean => {
|
|
62
|
+
const cause = error instanceof Error ? error.cause : undefined;
|
|
63
|
+
if (!isAxiosError(cause)) return false;
|
|
64
|
+
|
|
65
|
+
const status = cause.response?.status;
|
|
66
|
+
return status === undefined || status >= 500 || status === 429;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* workspaceOf
|
|
71
|
+
*
|
|
72
|
+
* The workspace a list request names: the **first** `workspace` filter, when it is an equality
|
|
73
|
+
* on a name. One reading, shared by the request and by `hasWorkspaceFilter`, so the hooks' check
|
|
74
|
+
* cannot pass on a filter the request then reads another way — which is what happened while
|
|
75
|
+
* each read it its own way.
|
|
76
|
+
*
|
|
77
|
+
* Only an equality counts. The query's filters are what scope the data, so `["workspace", "!=",
|
|
78
|
+
* "ws-1"]` reads every *other* workspace; it named a workspace, so the check used to pass. A
|
|
79
|
+
* value that is not a name (an `IN` list) went out as `workspace[]=…`.
|
|
80
|
+
*
|
|
81
|
+
* @param filters - The query's filters, as tuples.
|
|
82
|
+
* @returns The workspace name, or `undefined` when the first `workspace` filter is missing or is
|
|
83
|
+
* not an equality on a name.
|
|
84
|
+
*/
|
|
85
|
+
export const workspaceOf = (filters: FilterExpression[]): string | undefined => {
|
|
86
|
+
const filter = filters.find((expression) => expression[0] === "workspace");
|
|
87
|
+
if (!filter) return undefined;
|
|
88
|
+
|
|
89
|
+
const isEquality = filter.length === 2 || filter[1] === "=";
|
|
90
|
+
const value = filter[filter.length - 1];
|
|
91
|
+
|
|
92
|
+
return isEquality && typeof value === "string" ? value : undefined;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* requireWorkspace
|
|
97
|
+
*
|
|
98
|
+
* Refuses a call without a workspace before it reaches the API. The API would not say why: a
|
|
99
|
+
* get or delete by id with `workspace=""` answers a bare 403, one without the parameter skips the
|
|
100
|
+
* check altogether, and a create falls back to `main`. One wording for every function: each used
|
|
101
|
+
* to carry its own check, two phrasings of it ("Workspace filter is required…" for a plain
|
|
102
|
+
* string), and three had lost it altogether.
|
|
103
|
+
*
|
|
104
|
+
* @param workspace - The workspace the call was given.
|
|
105
|
+
* @param action - What the call does, completing "Workspace is required to …".
|
|
106
|
+
* @throws {Error} When `workspace` is empty.
|
|
107
|
+
*/
|
|
108
|
+
export function requireWorkspace(
|
|
109
|
+
workspace: string | null | undefined,
|
|
110
|
+
action: string,
|
|
111
|
+
): asserts workspace is string {
|
|
112
|
+
if (!workspace) throw new Error(`Workspace is required to ${action}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* pageParams
|
|
117
|
+
*
|
|
118
|
+
* The query string of a list endpoint that takes a workspace and a cursor rather than a query
|
|
119
|
+
* object — workflows and workspaces, whose `query` is a name or tag search, not filters. The
|
|
120
|
+
* search goes out as `query`. Only what was given is sent: an empty value means "none", and sent
|
|
121
|
+
* as `""` it would read as one.
|
|
122
|
+
*
|
|
123
|
+
* @param page - The workspace, search, page size and page token, each optional.
|
|
124
|
+
* @returns The `workspace`, `query`, `page_size` and `page_token` parameters that carry a value.
|
|
125
|
+
*/
|
|
126
|
+
export const pageParams = ({
|
|
127
|
+
workspace,
|
|
128
|
+
search,
|
|
129
|
+
pageSize,
|
|
130
|
+
pageToken,
|
|
131
|
+
}: {
|
|
132
|
+
workspace?: string;
|
|
133
|
+
search?: string;
|
|
134
|
+
pageSize?: number;
|
|
135
|
+
pageToken?: string;
|
|
136
|
+
}): AnyRecord => ({
|
|
137
|
+
...(workspace ? { workspace } : {}),
|
|
138
|
+
...(search ? { query: search } : {}),
|
|
139
|
+
...(pageSize ? { page_size: pageSize } : {}),
|
|
140
|
+
...(pageToken ? { page_token: pageToken } : {}),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
/** The query string of a list endpoint, as `listParams` builds it. */
|
|
144
|
+
export type ListParams = {
|
|
145
|
+
workspace: string;
|
|
146
|
+
query: string;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* listParams
|
|
151
|
+
*
|
|
152
|
+
* The query string of a list endpoint: the workspace on its own, beside the serialized query
|
|
153
|
+
* that also carries it. They do different jobs. The query's filters are what scope the data — on
|
|
154
|
+
* this path the API ignores the parameter for that — while the parameter is what the API checks
|
|
155
|
+
* a sub-user's role against.
|
|
156
|
+
*
|
|
157
|
+
* @param query - The query object built with `buildQueryObject`.
|
|
158
|
+
* @param action - What the call does, for the missing-workspace message.
|
|
159
|
+
* @returns `{ workspace, query }`.
|
|
160
|
+
* @throws {Error} When the first `workspace` filter is absent, empty, or not an equality on a name.
|
|
161
|
+
*/
|
|
162
|
+
export const listParams = (query: QueryObject, action: string): ListParams => {
|
|
163
|
+
const workspace = workspaceOf(query.filters);
|
|
164
|
+
|
|
165
|
+
requireWorkspace(workspace, action);
|
|
166
|
+
|
|
167
|
+
return { workspace, query: JSON.stringify(query) };
|
|
168
|
+
};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import type { WebsocketsConfig } from "@/contexts/webSocketContext/types";
|
|
3
|
+
import { request } from "./request";
|
|
5
4
|
|
|
6
5
|
const baseUrl = "websockets_config";
|
|
7
6
|
|
|
7
|
+
/** What the provider connects with. Not public: only `WebSocketProvider` reads it. */
|
|
8
|
+
export type WebsocketsConfig = {
|
|
9
|
+
appConnectionURL: string;
|
|
10
|
+
appChannelID: string;
|
|
11
|
+
everyskUID: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* getWebsocketsConfig
|
|
10
16
|
*
|
|
@@ -14,19 +20,5 @@ const baseUrl = "websockets_config";
|
|
|
14
20
|
* @returns {Promise<WebsocketsConfig>} Connection URL, channel id, and session uid.
|
|
15
21
|
* @throws {Error} If the request fails.
|
|
16
22
|
*/
|
|
17
|
-
export const getWebsocketsConfig = async (api: AxiosInstance): Promise<WebsocketsConfig> =>
|
|
18
|
-
|
|
19
|
-
const response: AxiosResponse<WebsocketsConfig> = await api.get(baseUrl);
|
|
20
|
-
return response.data;
|
|
21
|
-
} catch (error: unknown) {
|
|
22
|
-
if (isAxiosError<AnyRecord>(error)) {
|
|
23
|
-
throw new Error(error.message || "Error fetching websockets config");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (error instanceof Error) {
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
throw new Error("Error fetching websockets config");
|
|
31
|
-
}
|
|
32
|
-
};
|
|
23
|
+
export const getWebsocketsConfig = async (api: AxiosInstance): Promise<WebsocketsConfig> =>
|
|
24
|
+
request(() => api.get<WebsocketsConfig>(baseUrl), "Error fetching websockets config");
|