@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
package/dist/api/file.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
2
|
import type { EveryskFile, FileListResponse } from "../types/file.d.ts";
|
|
3
|
-
import type {
|
|
3
|
+
import type { DeletedEntity, QueryObject } from "../types/entityQuery.d.ts";
|
|
4
|
+
export type GetFileParams = {
|
|
5
|
+
/**
|
|
6
|
+
* `false` leaves `data` out (`null`): sent as `with_data=false`, which the API reads as the
|
|
7
|
+
* projection `-data` (everysk/client `EveryskAPIEngine_V2._get_entity_by_id`). The content
|
|
8
|
+
* comes as base64, a third larger than the file. The file hooks leave it out by default;
|
|
9
|
+
* this function, which mirrors the API, includes it.
|
|
10
|
+
*/
|
|
11
|
+
withData?: boolean;
|
|
12
|
+
};
|
|
4
13
|
/**
|
|
5
14
|
* getFile
|
|
6
15
|
*
|
|
@@ -9,11 +18,13 @@ import type { DeleteEntityDefaultResponse, QueryObject } from "../types/entityQu
|
|
|
9
18
|
* @param {AxiosInstance} api - Axios instance.
|
|
10
19
|
* @param {string} id - EveryskFile identifier.
|
|
11
20
|
* @param {string} workspace - Workspace the file belongs to.
|
|
21
|
+
* @param {GetFileParams} [options] - Whether to include the content.
|
|
22
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
12
23
|
* @returns {Promise<EveryskFile>} The fetched file.
|
|
13
24
|
*
|
|
14
25
|
* @throws {Error} If the request fails.
|
|
15
26
|
*/
|
|
16
|
-
export declare const getFile: (api: AxiosInstance, id: string, workspace: string) => Promise<EveryskFile>;
|
|
27
|
+
export declare const getFile: (api: AxiosInstance, id: string, workspace: string, { withData }?: GetFileParams, signal?: AbortSignal) => Promise<EveryskFile>;
|
|
17
28
|
/**
|
|
18
29
|
* listFiles
|
|
19
30
|
*
|
|
@@ -24,20 +35,24 @@ export declare const getFile: (api: AxiosInstance, id: string, workspace: string
|
|
|
24
35
|
*
|
|
25
36
|
* @param {AxiosInstance} api - Axios instance.
|
|
26
37
|
* @param {QueryObject} query - Query object built via `buildQueryObject`.
|
|
27
|
-
* @
|
|
38
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
|
|
39
|
+
* @returns {Promise<FileListResponse>} Paginated list of files.
|
|
28
40
|
*
|
|
41
|
+
* @throws {Error} If the query has no workspace filter.
|
|
29
42
|
* @throws {Error} If the request fails.
|
|
30
43
|
*/
|
|
31
|
-
export declare const listFiles: (api: AxiosInstance, query: QueryObject) => Promise<FileListResponse>;
|
|
44
|
+
export declare const listFiles: (api: AxiosInstance, query: QueryObject, signal?: AbortSignal) => Promise<FileListResponse>;
|
|
32
45
|
/**
|
|
33
46
|
* createFile
|
|
34
47
|
*
|
|
35
48
|
* Creates a new file.
|
|
36
49
|
*
|
|
37
50
|
* @param {AxiosInstance} api - Axios instance.
|
|
38
|
-
* @param {Partial<EveryskFile>} data - EveryskFile payload.
|
|
51
|
+
* @param {Partial<EveryskFile>} data - EveryskFile payload. Its `data` is the content as raw
|
|
52
|
+
* base64, as `fileToBase64` returns it from a `File`.
|
|
39
53
|
* @returns {Promise<EveryskFile>} The created file.
|
|
40
54
|
*
|
|
55
|
+
* @throws {Error} If `workspace` is missing, or `data` is a data URL rather than raw base64.
|
|
41
56
|
* @throws {Error} If the request fails.
|
|
42
57
|
*/
|
|
43
58
|
export declare const createFile: (api: AxiosInstance, data: Partial<EveryskFile>) => Promise<EveryskFile>;
|
|
@@ -48,9 +63,11 @@ export declare const createFile: (api: AxiosInstance, data: Partial<EveryskFile>
|
|
|
48
63
|
*
|
|
49
64
|
* @param {AxiosInstance} api - Axios instance.
|
|
50
65
|
* @param {string} id - EveryskFile identifier.
|
|
51
|
-
* @param {Partial<EveryskFile>} data - Fields to update.
|
|
66
|
+
* @param {Partial<EveryskFile>} data - Fields to update. A new `data` is the content as raw
|
|
67
|
+
* base64, as `fileToBase64` returns it from a `File`.
|
|
52
68
|
* @returns {Promise<EveryskFile>} The updated file.
|
|
53
69
|
*
|
|
70
|
+
* @throws {Error} If `workspace` is missing, or `data` is a data URL rather than raw base64.
|
|
54
71
|
* @throws {Error} If the request fails.
|
|
55
72
|
*/
|
|
56
73
|
export declare const updateFile: (api: AxiosInstance, id: string, data: Partial<EveryskFile>) => Promise<EveryskFile>;
|
|
@@ -62,9 +79,9 @@ export declare const updateFile: (api: AxiosInstance, id: string, data: Partial<
|
|
|
62
79
|
* @param {AxiosInstance} api - Axios instance.
|
|
63
80
|
* @param {string} id - EveryskFile identifier.
|
|
64
81
|
* @param {string} workspace - Workspace the file belongs to.
|
|
65
|
-
* @returns {Promise<
|
|
82
|
+
* @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.
|
|
66
83
|
*
|
|
67
84
|
* @throws {Error} If the request fails.
|
|
68
85
|
*/
|
|
69
|
-
export declare const deleteFile: (api: AxiosInstance, id: string, workspace: string) => Promise<
|
|
86
|
+
export declare const deleteFile: (api: AxiosInstance, id: string, workspace: string) => Promise<DeletedEntity>;
|
|
70
87
|
//# sourceMappingURL=file.d.ts.map
|
package/dist/api/file.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/api/file.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/api/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,EACR,aAAa,EAGb,WAAW,EACd,MAAM,qBAAqB,CAAC;AAS7B,MAAM,MAAM,aAAa,GAAG;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,OAAO,GAChB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,WAAW,MAAM,EACjB,eAAc,aAAkB,EAChC,SAAS,WAAW,KACrB,OAAO,CAAC,WAAW,CASrB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,SAAS,GAClB,KAAK,aAAa,EAClB,OAAO,WAAW,EAClB,SAAS,WAAW,KACrB,OAAO,CAAC,gBAAgB,CAO1B,CAAC;AAeF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GACnB,KAAK,aAAa,EAClB,MAAM,OAAO,CAAC,WAAW,CAAC,KAC3B,OAAO,CAAC,WAAW,CASrB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,GACnB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,MAAM,OAAO,CAAC,WAAW,CAAC,KAC3B,OAAO,CAAC,WAAW,CASrB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GACnB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,WAAW,MAAM,KAClB,OAAO,CAAC,aAAa,CAQvB,CAAC"}
|
package/dist/api/file.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { listParams, request, requireWorkspace } from "./request.js";
|
|
2
2
|
//#region src/api/file.ts
|
|
3
3
|
var baseUrl = "files";
|
|
4
4
|
/**
|
|
@@ -9,19 +9,22 @@ var baseUrl = "files";
|
|
|
9
9
|
* @param {AxiosInstance} api - Axios instance.
|
|
10
10
|
* @param {string} id - EveryskFile identifier.
|
|
11
11
|
* @param {string} workspace - Workspace the file belongs to.
|
|
12
|
+
* @param {GetFileParams} [options] - Whether to include the content.
|
|
13
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
12
14
|
* @returns {Promise<EveryskFile>} The fetched file.
|
|
13
15
|
*
|
|
14
16
|
* @throws {Error} If the request fails.
|
|
15
17
|
*/
|
|
16
|
-
var getFile = async (api, id, workspace) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
var getFile = async (api, id, workspace, { withData } = {}, signal) => {
|
|
19
|
+
requireWorkspace(workspace, "fetch a file");
|
|
20
|
+
const params = {
|
|
21
|
+
workspace,
|
|
22
|
+
...withData === false && { with_data: false }
|
|
23
|
+
};
|
|
24
|
+
return (await request(() => api.get(`${baseUrl}/${id}`, {
|
|
25
|
+
params,
|
|
26
|
+
signal
|
|
27
|
+
}), "Error fetching file")).file;
|
|
25
28
|
};
|
|
26
29
|
/**
|
|
27
30
|
* listFiles
|
|
@@ -33,25 +36,26 @@ var getFile = async (api, id, workspace) => {
|
|
|
33
36
|
*
|
|
34
37
|
* @param {AxiosInstance} api - Axios instance.
|
|
35
38
|
* @param {QueryObject} query - Query object built via `buildQueryObject`.
|
|
36
|
-
* @
|
|
39
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
|
|
40
|
+
* @returns {Promise<FileListResponse>} Paginated list of files.
|
|
37
41
|
*
|
|
42
|
+
* @throws {Error} If the query has no workspace filter.
|
|
38
43
|
* @throws {Error} If the request fails.
|
|
39
44
|
*/
|
|
40
|
-
var listFiles = async (api, query) => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
45
|
+
var listFiles = async (api, query, signal) => {
|
|
46
|
+
const params = listParams(query, "list files");
|
|
47
|
+
return request(() => api.get(baseUrl, {
|
|
48
|
+
params,
|
|
49
|
+
signal
|
|
50
|
+
}), "Error listing files");
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Refuses content sent as a data URL. The API stores `data` as given, so the
|
|
54
|
+
* `data:<type>;base64,` prefix `FileReader` puts in front would become part of the file, which
|
|
55
|
+
* then comes out corrupt with no error anywhere.
|
|
56
|
+
*/
|
|
57
|
+
var requireRawBase64 = ({ data }) => {
|
|
58
|
+
if (data?.startsWith("data:")) throw new Error("A file's data must be raw base64, without the data: prefix: read it with fileToBase64");
|
|
55
59
|
};
|
|
56
60
|
/**
|
|
57
61
|
* createFile
|
|
@@ -59,21 +63,17 @@ var listFiles = async (api, query) => {
|
|
|
59
63
|
* Creates a new file.
|
|
60
64
|
*
|
|
61
65
|
* @param {AxiosInstance} api - Axios instance.
|
|
62
|
-
* @param {Partial<EveryskFile>} data - EveryskFile payload.
|
|
66
|
+
* @param {Partial<EveryskFile>} data - EveryskFile payload. Its `data` is the content as raw
|
|
67
|
+
* base64, as `fileToBase64` returns it from a `File`.
|
|
63
68
|
* @returns {Promise<EveryskFile>} The created file.
|
|
64
69
|
*
|
|
70
|
+
* @throws {Error} If `workspace` is missing, or `data` is a data URL rather than raw base64.
|
|
65
71
|
* @throws {Error} If the request fails.
|
|
66
72
|
*/
|
|
67
73
|
var createFile = async (api, data) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return (await api.post(baseUrl, data)).data.file;
|
|
72
|
-
} catch (error) {
|
|
73
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while creating file");
|
|
74
|
-
if (error instanceof Error) throw error;
|
|
75
|
-
throw new Error("Error while creating file");
|
|
76
|
-
}
|
|
74
|
+
requireWorkspace(data.workspace, "create a file");
|
|
75
|
+
requireRawBase64(data);
|
|
76
|
+
return (await request(() => api.post(baseUrl, data), "Error creating file")).file;
|
|
77
77
|
};
|
|
78
78
|
/**
|
|
79
79
|
* updateFile
|
|
@@ -82,21 +82,17 @@ var createFile = async (api, data) => {
|
|
|
82
82
|
*
|
|
83
83
|
* @param {AxiosInstance} api - Axios instance.
|
|
84
84
|
* @param {string} id - EveryskFile identifier.
|
|
85
|
-
* @param {Partial<EveryskFile>} data - Fields to update.
|
|
85
|
+
* @param {Partial<EveryskFile>} data - Fields to update. A new `data` is the content as raw
|
|
86
|
+
* base64, as `fileToBase64` returns it from a `File`.
|
|
86
87
|
* @returns {Promise<EveryskFile>} The updated file.
|
|
87
88
|
*
|
|
89
|
+
* @throws {Error} If `workspace` is missing, or `data` is a data URL rather than raw base64.
|
|
88
90
|
* @throws {Error} If the request fails.
|
|
89
91
|
*/
|
|
90
92
|
var updateFile = async (api, id, data) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return (await api.put(`${baseUrl}/${id}`, data)).data.file;
|
|
95
|
-
} catch (error) {
|
|
96
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while updating file");
|
|
97
|
-
if (error instanceof Error) throw error;
|
|
98
|
-
throw new Error("Error while updating file");
|
|
99
|
-
}
|
|
93
|
+
requireWorkspace(data.workspace, "update a file");
|
|
94
|
+
requireRawBase64(data);
|
|
95
|
+
return (await request(() => api.put(`${baseUrl}/${id}`, data), "Error updating file")).file;
|
|
100
96
|
};
|
|
101
97
|
/**
|
|
102
98
|
* deleteFile
|
|
@@ -106,19 +102,13 @@ var updateFile = async (api, id, data) => {
|
|
|
106
102
|
* @param {AxiosInstance} api - Axios instance.
|
|
107
103
|
* @param {string} id - EveryskFile identifier.
|
|
108
104
|
* @param {string} workspace - Workspace the file belongs to.
|
|
109
|
-
* @returns {Promise<
|
|
105
|
+
* @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.
|
|
110
106
|
*
|
|
111
107
|
* @throws {Error} If the request fails.
|
|
112
108
|
*/
|
|
113
109
|
var deleteFile = async (api, id, workspace) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return (await api.delete(`${baseUrl}/${id}`, { params })).data.files;
|
|
117
|
-
} catch (error) {
|
|
118
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while deleting file");
|
|
119
|
-
if (error instanceof Error) throw error;
|
|
120
|
-
throw new Error("Error while deleting file");
|
|
121
|
-
}
|
|
110
|
+
requireWorkspace(workspace, "delete a file");
|
|
111
|
+
return (await request(() => api.delete(`${baseUrl}/${id}`, { params: { workspace } }), "Error deleting file")).file;
|
|
122
112
|
};
|
|
123
113
|
//#endregion
|
|
124
114
|
export { createFile, deleteFile, getFile, listFiles, updateFile };
|
package/dist/api/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","names":[],"sources":["../../src/api/file.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"file.js","names":[],"sources":["../../src/api/file.ts"],"sourcesContent":["import type { AxiosInstance } from \"axios\";\n\nimport type { EveryskFile, FileListResponse } from \"@/types/file\";\nimport type {\n DeletedEntity,\n DeleteEntityResponse,\n EntitySingleResponse,\n QueryObject,\n} from \"@/types/entityQuery\";\nimport { listParams, request, requireWorkspace } from \"./request\";\n\nconst baseUrl = \"files\";\n\n/** The endpoint's envelopes, private: every function here returns the entity itself. */\ntype FileSingleResponse = EntitySingleResponse<\"file\", EveryskFile>;\ntype DeleteFileResponse = DeleteEntityResponse<\"file\">;\n\nexport type GetFileParams = {\n /**\n * `false` leaves `data` out (`null`): sent as `with_data=false`, which the API reads as the\n * projection `-data` (everysk/client `EveryskAPIEngine_V2._get_entity_by_id`). The content\n * comes as base64, a third larger than the file. The file hooks leave it out by default;\n * this function, which mirrors the API, includes it.\n */\n withData?: boolean;\n};\n\n/**\n * getFile\n *\n * Fetches a single file by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - EveryskFile identifier.\n * @param {string} workspace - Workspace the file belongs to.\n * @param {GetFileParams} [options] - Whether to include the content.\n * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.\n * @returns {Promise<EveryskFile>} The fetched file.\n *\n * @throws {Error} If the request fails.\n */\nexport const getFile = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n { withData }: GetFileParams = {},\n signal?: AbortSignal,\n): Promise<EveryskFile> => {\n requireWorkspace(workspace, \"fetch a file\");\n\n const params = { workspace, ...(withData === false && { with_data: false }) };\n const body = await request(\n () => api.get<FileSingleResponse>(`${baseUrl}/${id}`, { params, signal }),\n \"Error fetching file\",\n );\n return body.file;\n};\n\n/**\n * listFiles\n *\n * Fetches a list of files using a query object (filters, order, pagination, etc.).\n *\n * Note: `workspace` is extracted from the query filters and sent as a separate\n * query param alongside the serialized query object.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {QueryObject} query - Query object built via `buildQueryObject`.\n * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.\n * @returns {Promise<FileListResponse>} Paginated list of files.\n *\n * @throws {Error} If the query has no workspace filter.\n * @throws {Error} If the request fails.\n */\nexport const listFiles = async (\n api: AxiosInstance,\n query: QueryObject,\n signal?: AbortSignal,\n): Promise<FileListResponse> => {\n const params = listParams(query, \"list files\");\n\n return request(\n () => api.get<FileListResponse>(baseUrl, { params, signal }),\n \"Error listing files\",\n );\n};\n\n/**\n * Refuses content sent as a data URL. The API stores `data` as given, so the\n * `data:<type>;base64,` prefix `FileReader` puts in front would become part of the file, which\n * then comes out corrupt with no error anywhere.\n */\nconst requireRawBase64 = ({ data }: Partial<EveryskFile>) => {\n if (data?.startsWith(\"data:\")) {\n throw new Error(\n \"A file's data must be raw base64, without the data: prefix: read it with fileToBase64\",\n );\n }\n};\n\n/**\n * createFile\n *\n * Creates a new file.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {Partial<EveryskFile>} data - EveryskFile payload. Its `data` is the content as raw\n * base64, as `fileToBase64` returns it from a `File`.\n * @returns {Promise<EveryskFile>} The created file.\n *\n * @throws {Error} If `workspace` is missing, or `data` is a data URL rather than raw base64.\n * @throws {Error} If the request fails.\n */\nexport const createFile = async (\n api: AxiosInstance,\n data: Partial<EveryskFile>,\n): Promise<EveryskFile> => {\n requireWorkspace(data.workspace, \"create a file\");\n requireRawBase64(data);\n\n const body = await request(\n () => api.post<FileSingleResponse>(baseUrl, data),\n \"Error creating file\",\n );\n return body.file;\n};\n\n/**\n * updateFile\n *\n * Updates an existing file by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - EveryskFile identifier.\n * @param {Partial<EveryskFile>} data - Fields to update. A new `data` is the content as raw\n * base64, as `fileToBase64` returns it from a `File`.\n * @returns {Promise<EveryskFile>} The updated file.\n *\n * @throws {Error} If `workspace` is missing, or `data` is a data URL rather than raw base64.\n * @throws {Error} If the request fails.\n */\nexport const updateFile = async (\n api: AxiosInstance,\n id: string,\n data: Partial<EveryskFile>,\n): Promise<EveryskFile> => {\n requireWorkspace(data.workspace, \"update a file\");\n requireRawBase64(data);\n\n const body = await request(\n () => api.put<FileSingleResponse>(`${baseUrl}/${id}`, data),\n \"Error updating file\",\n );\n return body.file;\n};\n\n/**\n * deleteFile\n *\n * Deletes a file by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - EveryskFile identifier.\n * @param {string} workspace - Workspace the file belongs to.\n * @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.\n *\n * @throws {Error} If the request fails.\n */\nexport const deleteFile = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n): Promise<DeletedEntity> => {\n requireWorkspace(workspace, \"delete a file\");\n\n const body = await request(\n () => api.delete<DeleteFileResponse>(`${baseUrl}/${id}`, { params: { workspace } }),\n \"Error deleting file\",\n );\n return body.file;\n};\n"],"mappings":";;AAWA,IAAM,UAAU;;;;;;;;;;;;;;;AA8BhB,IAAa,UAAU,OACnB,KACA,IACA,WACA,EAAE,aAA4B,CAAC,GAC/B,WACuB;CACvB,iBAAiB,WAAW,cAAc;CAE1C,MAAM,SAAS;EAAE;EAAW,GAAI,aAAa,SAAS,EAAE,WAAW,MAAM;CAAG;CAK5E,QAAO,MAJY,cACT,IAAI,IAAwB,GAAG,QAAQ,GAAG,MAAM;EAAE;EAAQ;CAAO,CAAC,GACxE,qBACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;;;;;AAkBA,IAAa,YAAY,OACrB,KACA,OACA,WAC4B;CAC5B,MAAM,SAAS,WAAW,OAAO,YAAY;CAE7C,OAAO,cACG,IAAI,IAAsB,SAAS;EAAE;EAAQ;CAAO,CAAC,GAC3D,qBACJ;AACJ;;;;;;AAOA,IAAM,oBAAoB,EAAE,WAAiC;CACzD,IAAI,MAAM,WAAW,OAAO,GACxB,MAAM,IAAI,MACN,uFACJ;AAER;;;;;;;;;;;;;;AAeA,IAAa,aAAa,OACtB,KACA,SACuB;CACvB,iBAAiB,KAAK,WAAW,eAAe;CAChD,iBAAiB,IAAI;CAMrB,QAAO,MAJY,cACT,IAAI,KAAyB,SAAS,IAAI,GAChD,qBACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;;;AAgBA,IAAa,aAAa,OACtB,KACA,IACA,SACuB;CACvB,iBAAiB,KAAK,WAAW,eAAe;CAChD,iBAAiB,IAAI;CAMrB,QAAO,MAJY,cACT,IAAI,IAAwB,GAAG,QAAQ,GAAG,MAAM,IAAI,GAC1D,qBACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;AAcA,IAAa,aAAa,OACtB,KACA,IACA,cACyB;CACzB,iBAAiB,WAAW,eAAe;CAM3C,QAAO,MAJY,cACT,IAAI,OAA2B,GAAG,QAAQ,GAAG,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,GAClF,qBACJ,EAAA,CACY;AAChB"}
|
package/dist/api/portfolio.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { QueryObject } from "../types/entityQuery.d.ts";
|
|
3
|
-
import type { Portfolio, PortfolioListResponse
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
import type { DeletedEntity, QueryObject } from "../types/entityQuery.d.ts";
|
|
3
|
+
import type { Portfolio, PortfolioListResponse } from "../types/portfolio.d.ts";
|
|
4
4
|
/**
|
|
5
5
|
* getPortfolio
|
|
6
6
|
*
|
|
@@ -9,11 +9,12 @@ import type { Portfolio, PortfolioListResponse, PortfolioSingleResponse } from "
|
|
|
9
9
|
* @param {AxiosInstance} api - Axios instance.
|
|
10
10
|
* @param {string} id - Portfolio identifier.
|
|
11
11
|
* @param {string} workspace - Workspace the portfolio belongs to.
|
|
12
|
-
* @
|
|
12
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
13
|
+
* @returns {Promise<Portfolio>} The fetched portfolio.
|
|
13
14
|
*
|
|
14
15
|
* @throws {Error} If the request fails.
|
|
15
16
|
*/
|
|
16
|
-
export declare const getPortfolio: (api: AxiosInstance, id: string, workspace: string) => Promise<
|
|
17
|
+
export declare const getPortfolio: (api: AxiosInstance, id: string, workspace: string, signal?: AbortSignal) => Promise<Portfolio>;
|
|
17
18
|
/**
|
|
18
19
|
* listPortfolios
|
|
19
20
|
*
|
|
@@ -21,11 +22,13 @@ export declare const getPortfolio: (api: AxiosInstance, id: string, workspace: s
|
|
|
21
22
|
*
|
|
22
23
|
* @param {AxiosInstance} api - Axios instance.
|
|
23
24
|
* @param {QueryObject} query - Query object built via `buildQueryObject`.
|
|
25
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
|
|
24
26
|
* @returns {Promise<PortfolioListResponse>} List of portfolios.
|
|
25
27
|
*
|
|
28
|
+
* @throws {Error} If the query has no workspace filter.
|
|
26
29
|
* @throws {Error} If the request fails.
|
|
27
30
|
*/
|
|
28
|
-
export declare const listPortfolios: (api: AxiosInstance, query: QueryObject) => Promise<PortfolioListResponse>;
|
|
31
|
+
export declare const listPortfolios: (api: AxiosInstance, query: QueryObject, signal?: AbortSignal) => Promise<PortfolioListResponse>;
|
|
29
32
|
/**
|
|
30
33
|
* createPortfolio
|
|
31
34
|
*
|
|
@@ -59,9 +62,9 @@ export declare const updatePortfolio: (api: AxiosInstance, id: string, data: Par
|
|
|
59
62
|
* @param {AxiosInstance} api - Axios instance.
|
|
60
63
|
* @param {string} id - Portfolio identifier.
|
|
61
64
|
* @param {string} workspace - Workspace the portfolio belongs to.
|
|
62
|
-
* @returns {Promise<
|
|
65
|
+
* @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.
|
|
63
66
|
*
|
|
64
67
|
* @throws {Error} If the request fails.
|
|
65
68
|
*/
|
|
66
|
-
export declare const deletePortfolio: (api: AxiosInstance, id: string, workspace: string) => Promise<
|
|
69
|
+
export declare const deletePortfolio: (api: AxiosInstance, id: string, workspace: string) => Promise<DeletedEntity>;
|
|
67
70
|
//# sourceMappingURL=portfolio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../../src/api/portfolio.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../../src/api/portfolio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EACR,aAAa,EAGb,WAAW,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAS1E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GACrB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,WAAW,MAAM,EACjB,SAAS,WAAW,KACrB,OAAO,CAAC,SAAS,CASnB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GACvB,KAAK,aAAa,EAClB,OAAO,WAAW,EAClB,SAAS,WAAW,KACrB,OAAO,CAAC,qBAAqB,CAO/B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GACxB,KAAK,aAAa,EAClB,MAAM,OAAO,CAAC,SAAS,CAAC,KACzB,OAAO,CAAC,SAAS,CAQnB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GACxB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,MAAM,OAAO,CAAC,SAAS,CAAC,KACzB,OAAO,CAAC,SAAS,CAQnB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GACxB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,WAAW,MAAM,KAClB,OAAO,CAAC,aAAa,CAQvB,CAAC"}
|
package/dist/api/portfolio.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { listParams, request, requireWorkspace } from "./request.js";
|
|
2
2
|
//#region src/api/portfolio.ts
|
|
3
3
|
var baseUrl = "portfolios";
|
|
4
4
|
/**
|
|
@@ -9,20 +9,17 @@ var baseUrl = "portfolios";
|
|
|
9
9
|
* @param {AxiosInstance} api - Axios instance.
|
|
10
10
|
* @param {string} id - Portfolio identifier.
|
|
11
11
|
* @param {string} workspace - Workspace the portfolio belongs to.
|
|
12
|
-
* @
|
|
12
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
13
|
+
* @returns {Promise<Portfolio>} The fetched portfolio.
|
|
13
14
|
*
|
|
14
15
|
* @throws {Error} If the request fails.
|
|
15
16
|
*/
|
|
16
|
-
var getPortfolio = async (api, id, workspace) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching portfolio");
|
|
23
|
-
if (error instanceof Error) throw error;
|
|
24
|
-
throw new Error("Error while fetching portfolio");
|
|
25
|
-
}
|
|
17
|
+
var getPortfolio = async (api, id, workspace, signal) => {
|
|
18
|
+
requireWorkspace(workspace, "fetch a portfolio");
|
|
19
|
+
return (await request(() => api.get(`${baseUrl}/${id}`, {
|
|
20
|
+
params: { workspace },
|
|
21
|
+
signal
|
|
22
|
+
}), "Error fetching portfolio")).portfolio;
|
|
26
23
|
};
|
|
27
24
|
/**
|
|
28
25
|
* listPortfolios
|
|
@@ -31,25 +28,18 @@ var getPortfolio = async (api, id, workspace) => {
|
|
|
31
28
|
*
|
|
32
29
|
* @param {AxiosInstance} api - Axios instance.
|
|
33
30
|
* @param {QueryObject} query - Query object built via `buildQueryObject`.
|
|
31
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
|
|
34
32
|
* @returns {Promise<PortfolioListResponse>} List of portfolios.
|
|
35
33
|
*
|
|
34
|
+
* @throws {Error} If the query has no workspace filter.
|
|
36
35
|
* @throws {Error} If the request fails.
|
|
37
36
|
*/
|
|
38
|
-
var listPortfolios = async (api, query) => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
...query ? { query: JSON.stringify(query) } : {}
|
|
45
|
-
};
|
|
46
|
-
try {
|
|
47
|
-
return (await api.get(baseUrl, { params })).data;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching portfolios");
|
|
50
|
-
if (error instanceof Error) throw error;
|
|
51
|
-
throw new Error("Error while fetching portfolios");
|
|
52
|
-
}
|
|
37
|
+
var listPortfolios = async (api, query, signal) => {
|
|
38
|
+
const params = listParams(query, "list portfolios");
|
|
39
|
+
return request(() => api.get(baseUrl, {
|
|
40
|
+
params,
|
|
41
|
+
signal
|
|
42
|
+
}), "Error listing portfolios");
|
|
53
43
|
};
|
|
54
44
|
/**
|
|
55
45
|
* createPortfolio
|
|
@@ -63,15 +53,8 @@ var listPortfolios = async (api, query) => {
|
|
|
63
53
|
* @throws {Error} If the request fails.
|
|
64
54
|
*/
|
|
65
55
|
var createPortfolio = async (api, data) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
return (await api.post(baseUrl, data)).data;
|
|
70
|
-
} catch (error) {
|
|
71
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while creating portfolio");
|
|
72
|
-
if (error instanceof Error) throw error;
|
|
73
|
-
throw new Error("Error while creating portfolio");
|
|
74
|
-
}
|
|
56
|
+
requireWorkspace(data.workspace, "create a portfolio");
|
|
57
|
+
return (await request(() => api.post(baseUrl, data), "Error creating portfolio")).portfolio;
|
|
75
58
|
};
|
|
76
59
|
/**
|
|
77
60
|
* updatePortfolio
|
|
@@ -86,15 +69,8 @@ var createPortfolio = async (api, data) => {
|
|
|
86
69
|
* @throws {Error} If the request fails.
|
|
87
70
|
*/
|
|
88
71
|
var updatePortfolio = async (api, id, data) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
return (await api.put(`${baseUrl}/${id}`, data)).data;
|
|
93
|
-
} catch (error) {
|
|
94
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while updating portfolio");
|
|
95
|
-
if (error instanceof Error) throw error;
|
|
96
|
-
throw new Error("Error while updating portfolio");
|
|
97
|
-
}
|
|
72
|
+
requireWorkspace(data.workspace, "update a portfolio");
|
|
73
|
+
return (await request(() => api.put(`${baseUrl}/${id}`, data), "Error updating portfolio")).portfolio;
|
|
98
74
|
};
|
|
99
75
|
/**
|
|
100
76
|
* deletePortfolio
|
|
@@ -104,20 +80,13 @@ var updatePortfolio = async (api, id, data) => {
|
|
|
104
80
|
* @param {AxiosInstance} api - Axios instance.
|
|
105
81
|
* @param {string} id - Portfolio identifier.
|
|
106
82
|
* @param {string} workspace - Workspace the portfolio belongs to.
|
|
107
|
-
* @returns {Promise<
|
|
83
|
+
* @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.
|
|
108
84
|
*
|
|
109
85
|
* @throws {Error} If the request fails.
|
|
110
86
|
*/
|
|
111
87
|
var deletePortfolio = async (api, id, workspace) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
return (await api.delete(`${baseUrl}/${id}`, { params })).data;
|
|
116
|
-
} catch (error) {
|
|
117
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while deleting portfolio");
|
|
118
|
-
if (error instanceof Error) throw error;
|
|
119
|
-
throw new Error("Error while deleting portfolio");
|
|
120
|
-
}
|
|
88
|
+
requireWorkspace(workspace, "delete a portfolio");
|
|
89
|
+
return (await request(() => api.delete(`${baseUrl}/${id}`, { params: { workspace } }), "Error deleting portfolio")).portfolio;
|
|
121
90
|
};
|
|
122
91
|
//#endregion
|
|
123
92
|
export { createPortfolio, deletePortfolio, getPortfolio, listPortfolios, updatePortfolio };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.js","names":[],"sources":["../../src/api/portfolio.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"portfolio.js","names":[],"sources":["../../src/api/portfolio.ts"],"sourcesContent":["import type { AxiosInstance } from \"axios\";\n\nimport type {\n DeletedEntity,\n DeleteEntityResponse,\n EntitySingleResponse,\n QueryObject,\n} from \"@/types/entityQuery\";\nimport type { Portfolio, PortfolioListResponse } from \"@/types/portfolio\";\nimport { listParams, request, requireWorkspace } from \"./request\";\n\nconst baseUrl = \"portfolios\";\n\n/** The endpoint's envelopes, private: every function here returns the entity itself. */\ntype PortfolioSingleResponse = EntitySingleResponse<\"portfolio\", Portfolio>;\ntype DeletePortfolioResponse = DeleteEntityResponse<\"portfolio\">;\n\n/**\n * getPortfolio\n *\n * Fetches a single portfolio by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Portfolio identifier.\n * @param {string} workspace - Workspace the portfolio belongs to.\n * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.\n * @returns {Promise<Portfolio>} The fetched portfolio.\n *\n * @throws {Error} If the request fails.\n */\nexport const getPortfolio = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n signal?: AbortSignal,\n): Promise<Portfolio> => {\n requireWorkspace(workspace, \"fetch a portfolio\");\n\n const body = await request(\n () =>\n api.get<PortfolioSingleResponse>(`${baseUrl}/${id}`, { params: { workspace }, signal }),\n \"Error fetching portfolio\",\n );\n return body.portfolio;\n};\n\n/**\n * listPortfolios\n *\n * Fetches a list of portfolios using a query object (filters, order, pagination, etc.).\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {QueryObject} query - Query object built via `buildQueryObject`.\n * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.\n * @returns {Promise<PortfolioListResponse>} List of portfolios.\n *\n * @throws {Error} If the query has no workspace filter.\n * @throws {Error} If the request fails.\n */\nexport const listPortfolios = async (\n api: AxiosInstance,\n query: QueryObject,\n signal?: AbortSignal,\n): Promise<PortfolioListResponse> => {\n const params = listParams(query, \"list portfolios\");\n\n return request(\n () => api.get<PortfolioListResponse>(baseUrl, { params, signal }),\n \"Error listing portfolios\",\n );\n};\n\n/**\n * createPortfolio\n *\n * Creates a new portfolio.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {Partial<Portfolio>} data - Portfolio payload.\n * @returns {Promise<Portfolio>} The created portfolio.\n *\n * @throws {Error} If the request fails.\n */\nexport const createPortfolio = async (\n api: AxiosInstance,\n data: Partial<Portfolio>,\n): Promise<Portfolio> => {\n requireWorkspace(data.workspace, \"create a portfolio\");\n\n const body = await request(\n () => api.post<PortfolioSingleResponse>(baseUrl, data),\n \"Error creating portfolio\",\n );\n return body.portfolio;\n};\n\n/**\n * updatePortfolio\n *\n * Updates an existing portfolio by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Portfolio identifier.\n * @param {Partial<Portfolio>} data - Fields to update.\n * @returns {Promise<Portfolio>} The updated portfolio.\n *\n * @throws {Error} If the request fails.\n */\nexport const updatePortfolio = async (\n api: AxiosInstance,\n id: string,\n data: Partial<Portfolio>,\n): Promise<Portfolio> => {\n requireWorkspace(data.workspace, \"update a portfolio\");\n\n const body = await request(\n () => api.put<PortfolioSingleResponse>(`${baseUrl}/${id}`, data),\n \"Error updating portfolio\",\n );\n return body.portfolio;\n};\n\n/**\n * deletePortfolio\n *\n * Deletes a portfolio by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Portfolio identifier.\n * @param {string} workspace - Workspace the portfolio belongs to.\n * @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.\n *\n * @throws {Error} If the request fails.\n */\nexport const deletePortfolio = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n): Promise<DeletedEntity> => {\n requireWorkspace(workspace, \"delete a portfolio\");\n\n const body = await request(\n () => api.delete<DeletePortfolioResponse>(`${baseUrl}/${id}`, { params: { workspace } }),\n \"Error deleting portfolio\",\n );\n return body.portfolio;\n};\n"],"mappings":";;AAWA,IAAM,UAAU;;;;;;;;;;;;;;AAmBhB,IAAa,eAAe,OACxB,KACA,IACA,WACA,WACqB;CACrB,iBAAiB,WAAW,mBAAmB;CAO/C,QAAO,MALY,cAEX,IAAI,IAA6B,GAAG,QAAQ,GAAG,MAAM;EAAE,QAAQ,EAAE,UAAU;EAAG;CAAO,CAAC,GAC1F,0BACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;;AAeA,IAAa,iBAAiB,OAC1B,KACA,OACA,WACiC;CACjC,MAAM,SAAS,WAAW,OAAO,iBAAiB;CAElD,OAAO,cACG,IAAI,IAA2B,SAAS;EAAE;EAAQ;CAAO,CAAC,GAChE,0BACJ;AACJ;;;;;;;;;;;;AAaA,IAAa,kBAAkB,OAC3B,KACA,SACqB;CACrB,iBAAiB,KAAK,WAAW,oBAAoB;CAMrD,QAAO,MAJY,cACT,IAAI,KAA8B,SAAS,IAAI,GACrD,0BACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAC3B,KACA,IACA,SACqB;CACrB,iBAAiB,KAAK,WAAW,oBAAoB;CAMrD,QAAO,MAJY,cACT,IAAI,IAA6B,GAAG,QAAQ,GAAG,MAAM,IAAI,GAC/D,0BACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAC3B,KACA,IACA,cACyB;CACzB,iBAAiB,WAAW,oBAAoB;CAMhD,QAAO,MAJY,cACT,IAAI,OAAgC,GAAG,QAAQ,GAAG,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,GACvF,0BACJ,EAAA,CACY;AAChB"}
|
package/dist/api/profile.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
2
|
import type { Profile } from "../types/profile.d.ts";
|
|
3
3
|
/**
|
|
4
4
|
* DEV_PROFILE — the profile served while running the dev server.
|
|
@@ -32,9 +32,10 @@ export declare const DEV_PROFILE: Profile;
|
|
|
32
32
|
*
|
|
33
33
|
* @param {AxiosInstance} api - Axios instance.
|
|
34
34
|
* @param {Profile} [fallback] - Returned instead of calling the API, when present.
|
|
35
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
35
36
|
* @returns {Promise<Profile>} The logged user's profile.
|
|
36
37
|
*
|
|
37
38
|
* @throws {Error} If the request fails.
|
|
38
39
|
*/
|
|
39
|
-
export declare const getProfile: (api: AxiosInstance, fallback?: Profile) => Promise<Profile>;
|
|
40
|
+
export declare const getProfile: (api: AxiosInstance, fallback?: Profile, signal?: AbortSignal) => Promise<Profile>;
|
|
40
41
|
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/api/profile.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/api/profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAgB/C;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,EAAE,OAkBzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,UAAU,GACnB,KAAK,aAAa,EAClB,WAAW,OAAO,EAClB,SAAS,WAAW,KACrB,OAAO,CAAC,OAAO,CAQjB,CAAC"}
|
package/dist/api/profile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { request } from "./request.js";
|
|
2
2
|
//#region src/api/profile.ts
|
|
3
3
|
var baseUrl = "profile";
|
|
4
4
|
/**
|
|
@@ -51,19 +51,14 @@ var DEV_PROFILE = {
|
|
|
51
51
|
*
|
|
52
52
|
* @param {AxiosInstance} api - Axios instance.
|
|
53
53
|
* @param {Profile} [fallback] - Returned instead of calling the API, when present.
|
|
54
|
+
* @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
|
|
54
55
|
* @returns {Promise<Profile>} The logged user's profile.
|
|
55
56
|
*
|
|
56
57
|
* @throws {Error} If the request fails.
|
|
57
58
|
*/
|
|
58
|
-
var getProfile = async (api, fallback) => {
|
|
59
|
+
var getProfile = async (api, fallback, signal) => {
|
|
59
60
|
if (fallback) return fallback;
|
|
60
|
-
|
|
61
|
-
return (await api.get(baseUrl)).data.profile;
|
|
62
|
-
} catch (error) {
|
|
63
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching profile");
|
|
64
|
-
if (error instanceof Error) throw error;
|
|
65
|
-
throw new Error("Error while fetching profile");
|
|
66
|
-
}
|
|
61
|
+
return (await request(() => api.get(baseUrl, { signal }), "Error fetching profile")).profile;
|
|
67
62
|
};
|
|
68
63
|
//#endregion
|
|
69
64
|
export { DEV_PROFILE, getProfile };
|
package/dist/api/profile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","names":[],"sources":["../../src/api/profile.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"profile.js","names":[],"sources":["../../src/api/profile.ts"],"sourcesContent":["import type { AxiosInstance } from \"axios\";\n\nimport type { Profile } from \"@/types/profile\";\nimport { request } from \"./request\";\n\nconst baseUrl = \"profile\";\n\n/**\n * The endpoint's envelope, private: `getProfile` returns the profile itself.\n *\n * It does not follow `EntitySingleResponse`: `/api/profile` is an app-only route rather than an\n * entity, and carries a `status` beside the profile.\n */\ntype ProfileResponse = {\n status: string;\n profile: Profile;\n};\n\n/**\n * DEV_PROFILE — the profile served while running the dev server.\n *\n * `GET /api/profile` only works in production: it resolves the user from the session, and in dev\n * the Vite proxy authenticates with OAuth2 client credentials (a machine token, no logged user),\n * so the endpoint has no session to read and the request fails. This stands in for it and covers\n * every field the API returns, so a screen renders with realistic values in dev.\n *\n * The values are deliberately obvious placeholders — see `docs/development.md`.\n */\nexport const DEV_PROFILE: Profile = {\n email: \"dev@everysk.com\",\n user_type: \"USER\",\n region: \"BR\",\n company_name: \"Everysk (dev)\",\n first_name: \"Dev\",\n last_name: \"User\",\n phone: \"+55 11 0000-0000\",\n address: \"Dev address, 0\",\n billing_email: \"dev@everysk.com\",\n time_zone: \"America/Sao_Paulo\",\n company_logo: \"\",\n user_role: \"ADMIN\",\n skin_theme: \"light\",\n account_deletion_requested: false,\n asset: \"\",\n owner: true,\n auto_refresh: false,\n};\n\n/**\n * getProfile\n *\n * Fetches the profile of the logged user. The endpoint takes no parameters — the API resolves the\n * user from the session — so an app always gets whoever is using it.\n *\n * When `fallback` is given it is returned as-is and the network is never touched. That is how an\n * app serves `DEV_PROFILE` while running the dev server, where the endpoint cannot resolve.\n *\n * The template decided this itself with `if (import.meta.env.DEV) return DEV_PROFILE`. That\n * cannot live in a published package: Vite replaces `import.meta.env.DEV` with a literal at the\n * build of whoever compiles the file, so the branch would freeze to whatever the SDK's own build\n * was and stop tracking the consuming app entirely. Which environment counts as \"dev\" is the\n * app's question, so the app answers it:\n *\n * ```ts\n * useFetchProfile({ fallback: import.meta.env.DEV ? DEV_PROFILE : undefined });\n * ```\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {Profile} [fallback] - Returned instead of calling the API, when present.\n * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.\n * @returns {Promise<Profile>} The logged user's profile.\n *\n * @throws {Error} If the request fails.\n */\nexport const getProfile = async (\n api: AxiosInstance,\n fallback?: Profile,\n signal?: AbortSignal,\n): Promise<Profile> => {\n if (fallback) return fallback;\n\n const body = await request(\n () => api.get<ProfileResponse>(baseUrl, { signal }),\n \"Error fetching profile\",\n );\n return body.profile;\n};\n"],"mappings":";;AAKA,IAAM,UAAU;;;;;;;;;;;AAuBhB,IAAa,cAAuB;CAChC,OAAO;CACP,WAAW;CACX,QAAQ;CACR,cAAc;CACd,YAAY;CACZ,WAAW;CACX,OAAO;CACP,SAAS;CACT,eAAe;CACf,WAAW;CACX,cAAc;CACd,WAAW;CACX,YAAY;CACZ,4BAA4B;CAC5B,OAAO;CACP,OAAO;CACP,cAAc;AAClB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,aAAa,OACtB,KACA,UACA,WACmB;CACnB,IAAI,UAAU,OAAO;CAMrB,QAAO,MAJY,cACT,IAAI,IAAqB,SAAS,EAAE,OAAO,CAAC,GAClD,wBACJ,EAAA,CACY;AAChB"}
|