@everysk/apps-sdk 0.1.0 → 0.2.0
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 +104 -3
- package/dist/api/datastore.js +10 -10
- package/dist/api/datastore.js.map +1 -1
- package/dist/api/file.js +10 -10
- package/dist/api/file.js.map +1 -1
- package/dist/api/portfolio.js +10 -10
- package/dist/api/portfolio.js.map +1 -1
- package/dist/api/profile.js +2 -2
- package/dist/api/profile.js.map +1 -1
- package/dist/api/websocketsConfig.js +2 -2
- package/dist/api/websocketsConfig.js.map +1 -1
- package/dist/api/workflow.js +14 -14
- package/dist/api/workflow.js.map +1 -1
- package/dist/api/workspace.js +4 -4
- package/dist/api/workspace.js.map +1 -1
- package/package.json +6 -6
- package/src/api/datastore.ts +10 -10
- package/src/api/file.ts +10 -10
- package/src/api/portfolio.ts +10 -10
- package/src/api/profile.ts +2 -2
- package/src/api/websocketsConfig.ts +2 -2
- package/src/api/workflow.ts +14 -14
- package/src/api/workspace.ts +4 -4
package/README.md
CHANGED
|
@@ -5,16 +5,30 @@
|
|
|
5
5
|
The runtime an Everysk app bundles: the provider tree, the API layer, the entity hooks, the
|
|
6
6
|
shared components and the MUI theme. Declared as a `dependency`.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
[`@everysk/apps-
|
|
10
|
-
|
|
8
|
+
One of three: [`@everysk/apps-devkit`](https://www.npmjs.com/package/@everysk/apps-devkit) holds
|
|
9
|
+
the build presets and [`@everysk/apps-cli`](https://www.npmjs.com/package/@everysk/apps-cli) the
|
|
10
|
+
`everysk-apps` bin.
|
|
11
|
+
|
|
12
|
+
## Start with the CLI
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx @everysk/apps-cli init
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
For a new app, do this instead of installing by hand: it writes an app already wired for the
|
|
19
|
+
modules and theme you pick, including four decisions that fail *quietly* when made by hand.
|
|
20
|
+
[`@everysk/apps-cli`](https://www.npmjs.com/package/@everysk/apps-cli) lists them.
|
|
11
21
|
|
|
12
22
|
## Install
|
|
13
23
|
|
|
24
|
+
For adding the SDK to an app that already exists:
|
|
25
|
+
|
|
14
26
|
```bash
|
|
15
27
|
npm install @everysk/apps-sdk
|
|
16
28
|
```
|
|
17
29
|
|
|
30
|
+
Then `npx @everysk/apps-cli doctor` will tell you what the wiring is still missing.
|
|
31
|
+
|
|
18
32
|
`react`, `react-dom`, `@mui/material`, `@mui/x-date-pickers`, `@emotion/*`,
|
|
19
33
|
`@tanstack/react-query` and `axios` are **required** peers — npm installs them with the package,
|
|
20
34
|
and a version outside its range fails the install rather than giving the app a second copy. Two
|
|
@@ -51,6 +65,93 @@ to nested JSX in the right slot.
|
|
|
51
65
|
| `appId`, `appEnvironmentVar` | Override `window.APP_ID` / `window.APP_CONFIG`, for tests and hosts that resolve configuration themselves |
|
|
52
66
|
| `providers` | Optional providers, mounted inside the core tree |
|
|
53
67
|
|
|
68
|
+
## What it exports
|
|
69
|
+
|
|
70
|
+
Everything below comes from the package root — `import { … } from "@everysk/apps-sdk"`. A bundler
|
|
71
|
+
drops what you do not use, so there is nothing to be careful about here.
|
|
72
|
+
|
|
73
|
+
### Entity slices
|
|
74
|
+
|
|
75
|
+
Each entity is an API module, its types, and React Query hooks over them. The hooks take an
|
|
76
|
+
object and return the query result plus its `queryKey`, so a mutation can invalidate exactly what
|
|
77
|
+
a list rendered.
|
|
78
|
+
|
|
79
|
+
| Entity | One | Many | Write |
|
|
80
|
+
|---|---|---|---|
|
|
81
|
+
| Portfolio | `useFetchPortfolio` | `useFetchPortfolios` | `usePortfolioMutations` |
|
|
82
|
+
| Datastore | `useFetchDatastore` | `useFetchDatastores` | `useDatastoreMutations` |
|
|
83
|
+
| File | `useFetchFile` | `useFetchFiles` | `useFileMutations` |
|
|
84
|
+
| Workspace | `useFetchWorkspace` | `useFetchWorkspaces` | — |
|
|
85
|
+
| Profile | `useFetchProfile` | — | — |
|
|
86
|
+
| Workflow | `useFetchWorkflow` | `useFetchWorkflows` | `useRunWorkflow` |
|
|
87
|
+
|
|
88
|
+
Workflow carries four more for the run side: `useFetchWorkflowExecution(s)` and
|
|
89
|
+
`useFetchWorkerExecution(s)`.
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
const { query, queryKey } = useFetchPortfolios({
|
|
93
|
+
filters: [{ field: "workspace", value: "ws-1" }],
|
|
94
|
+
pageSize: 20,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const { remove } = usePortfolioMutations({ queryKey });
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`useFetchPortfolios` is paginated — `query` is the whole `useInfiniteQuery` result, so
|
|
101
|
+
`hasNextPage` and `fetchNextPage` are there. The single-entity hooks spread the query result
|
|
102
|
+
directly, so `const { data, isLoading, queryKey } = useFetchPortfolio({ id, workspace })`.
|
|
103
|
+
Mutations return `{ create, update, remove }`, each a React Query mutation that shows an alert on
|
|
104
|
+
success and failure through `useAppAlert`.
|
|
105
|
+
|
|
106
|
+
### Components
|
|
107
|
+
|
|
108
|
+
Five, all MUI underneath.
|
|
109
|
+
|
|
110
|
+
| Component | Props | |
|
|
111
|
+
|---|---|---|
|
|
112
|
+
| `PageContainer` | `header?`, `footer?`, `contentClassName?` | The page frame: chrome around a scrolling content area |
|
|
113
|
+
| `Toolbar` | `className?` | Top bar. Renders `EveryskIcon` and its children |
|
|
114
|
+
| `Footer` | `className?` | Bottom bar |
|
|
115
|
+
| `GlobalLoading` | `isLoading`, `backdrop?`, `message?` | Full-page spinner. `backdrop` defaults to `true` |
|
|
116
|
+
| `EveryskIcon` | every `SvgIconProps` except `color` | The brand mark |
|
|
117
|
+
|
|
118
|
+
`Toolbar`, `Footer` and `PageContainer` take a `className`, so a Tailwind utility reaches them —
|
|
119
|
+
but a utility loses to MUI's own styles in the cascade, so reach for `sx` when one is dropped.
|
|
120
|
+
`GlobalLoading` takes no `className`, and `EveryskIcon` gets one through `SvgIconProps`.
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
<PageContainer header={<Toolbar>Trade Allocation</Toolbar>} footer={<Footer />}>
|
|
124
|
+
<GlobalLoading isLoading={query.isLoading} message="Loading portfolios…" />
|
|
125
|
+
{/* the page */}
|
|
126
|
+
</PageContainer>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Contexts
|
|
130
|
+
|
|
131
|
+
| Hook | |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `useAppConfig()` | `{ appId, appEnvironmentVar }`, resolved from the page or from `EveryskApp`'s props |
|
|
134
|
+
| `useAppAlert()` | `showAlert({ message, severity, …SnackbarProps })`. The entity mutations already use it |
|
|
135
|
+
| `useAxios()` | `{ api }` — a memoised axios instance on the app's `baseURL`, defaulting to `/api` |
|
|
136
|
+
|
|
137
|
+
### Theme
|
|
138
|
+
|
|
139
|
+
`EveryskDarkTheme`, `EveryskLightTheme`, `DefaultDarkTheme`, `DefaultLightTheme` and
|
|
140
|
+
`MidnightEmberTheme`, plus `getTheme(name)` to resolve one by the name the CLI writes, and
|
|
141
|
+
`getBrandTheme(mode)` / `getDefaultTheme(mode)` for the pair. `EveryskApp` mounts the brand dark
|
|
142
|
+
theme unless given a `theme` prop.
|
|
143
|
+
|
|
144
|
+
### Query client and helpers
|
|
145
|
+
|
|
146
|
+
`createQueryClient(config?)` builds the QueryClient `EveryskApp` mounts — a factory rather than a
|
|
147
|
+
shared instance, because two apps or two tests sharing one client share its cache.
|
|
148
|
+
`getQueryFn`, `toFilterTuple`, `buildQueryObject` and `buildQueryKey` are the pieces the entity
|
|
149
|
+
hooks are built from, exported for a query the slices do not cover.
|
|
150
|
+
|
|
151
|
+
`useAxios`'s interceptor is worth knowing about if you write one of those: on `GET` and `DELETE`
|
|
152
|
+
it parses the request's query object into the shape the platform API expects. It is attached in
|
|
153
|
+
an effect and ejected on cleanup, so interceptors do not stack across renders.
|
|
154
|
+
|
|
54
155
|
## Entry points
|
|
55
156
|
|
|
56
157
|
One entry holds everything whose dependencies are required peers — the contexts, the six entity
|
package/dist/api/datastore.js
CHANGED
|
@@ -19,9 +19,9 @@ var getDatastore = async (api, id, workspace) => {
|
|
|
19
19
|
try {
|
|
20
20
|
return (await api.get(`${baseUrl}/${id}`, { params })).data.datastore;
|
|
21
21
|
} catch (error) {
|
|
22
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error fetching datastore");
|
|
22
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error fetching datastore", { cause: error });
|
|
23
23
|
if (error instanceof Error) throw error;
|
|
24
|
-
throw new Error("Error fetching datastore");
|
|
24
|
+
throw new Error("Error fetching datastore", { cause: error });
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
@@ -47,9 +47,9 @@ var listDatastores = async (api, query) => {
|
|
|
47
47
|
try {
|
|
48
48
|
return (await api.get(baseUrl, { params })).data;
|
|
49
49
|
} catch (error) {
|
|
50
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error listing datastores");
|
|
50
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error listing datastores", { cause: error });
|
|
51
51
|
if (error instanceof Error) throw error;
|
|
52
|
-
throw new Error("Error listing datastores");
|
|
52
|
+
throw new Error("Error listing datastores", { cause: error });
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
@@ -69,9 +69,9 @@ var createDatastore = async (api, data) => {
|
|
|
69
69
|
try {
|
|
70
70
|
return (await api.post(baseUrl, data)).data.datastore;
|
|
71
71
|
} catch (error) {
|
|
72
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error creating datastore");
|
|
72
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error creating datastore", { cause: error });
|
|
73
73
|
if (error instanceof Error) throw error;
|
|
74
|
-
throw new Error("Error creating datastore");
|
|
74
|
+
throw new Error("Error creating datastore", { cause: error });
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
@@ -92,9 +92,9 @@ var updateDatastore = async (api, id, data) => {
|
|
|
92
92
|
try {
|
|
93
93
|
return (await api.put(`${baseUrl}/${id}`, data)).data.datastore;
|
|
94
94
|
} catch (error) {
|
|
95
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error updating datastore");
|
|
95
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error updating datastore", { cause: error });
|
|
96
96
|
if (error instanceof Error) throw error;
|
|
97
|
-
throw new Error("Error updating datastore");
|
|
97
|
+
throw new Error("Error updating datastore", { cause: error });
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
/**
|
|
@@ -114,9 +114,9 @@ var deleteDatastore = async (api, id, workspace) => {
|
|
|
114
114
|
try {
|
|
115
115
|
return (await api.delete(`${baseUrl}/${id}`, { params })).data.datastores;
|
|
116
116
|
} catch (error) {
|
|
117
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error removing datastore");
|
|
117
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error removing datastore", { cause: error });
|
|
118
118
|
if (error instanceof Error) throw error;
|
|
119
|
-
throw new Error("Error removing datastore");
|
|
119
|
+
throw new Error("Error removing datastore", { cause: error });
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datastore.js","names":[],"sources":["../../src/api/datastore.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { DeleteEntityDefaultResponse, FilterExpression, QueryObject } from \"@/types/entityQuery\";\nimport type { Datastore, DatastoreSingleResponse, DatastoreListResponse, DeleteDatastoreResponse } from \"@/types/datastore\";\n\nconst baseUrl = \"datastores\";\n\n/**\n * getDatastore\n *\n * Fetches a single datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {string} workspace - Workspace the datastore belongs to.\n * @returns {Promise<Datastore>} The fetched datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const getDatastore = async (api: AxiosInstance, id: string, workspace: string): Promise<Datastore> => {\n const params: AnyRecord = { workspace };\n\n if (!workspace) throw new Error(\"Workspace filter is required to fetch a datastore\");\n\n try {\n const response: AxiosResponse<DatastoreSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });\n return response.data.datastore;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching datastore\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching datastore\");\n }\n};\n\n/**\n * listDatastores\n *\n * Fetches a list of datastores using a query object (filters, order, pagination, etc.).\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {AnyRecord} query - Query object built via `buildQueryObject`.\n * @returns {Promise<DatastoreListResponse>} Paginated list of datastores.\n *\n * @throws {Error} If workspace filter is missing.\n * @throws {Error} If the request fails.\n */\nexport const listDatastores = async (api: AxiosInstance, query: QueryObject): Promise<DatastoreListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) throw new Error(\"Workspace filter is required to list datastores\");\n\n const params: AnyRecord = {\n workspace,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n try {\n const response: AxiosResponse<DatastoreListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing datastores\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing datastores\");\n }\n};\n\n/**\n * createDatastore\n *\n * Creates a new datastore.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {Partial<Datastore>} data - Datastore payload.\n * @returns {Promise<Datastore>} The created datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const createDatastore = async (api: AxiosInstance, data: Partial<Datastore>): Promise<Datastore> => {\n\n const { workspace } = data;\n if (!workspace) throw new Error(\"Workspace filter is required to create a datastore\");\n\n try {\n const response: AxiosResponse<DatastoreSingleResponse> = await api.post(baseUrl, data);\n return response.data.datastore;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error creating datastore\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error creating datastore\");\n }\n};\n\n/**\n * updateDatastore\n *\n * Updates an existing datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {Partial<Datastore>} data - Fields to update.\n * @returns {Promise<Datastore>} The updated datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const updateDatastore = async (api: AxiosInstance, id: string, data: Partial<Datastore>): Promise<Datastore> => {\n\n const { workspace } = data;\n if (!workspace) throw new Error(\"Workspace filter is required to update a datastore\");\n\n try {\n const response: AxiosResponse<DatastoreSingleResponse> = await api.put(`${baseUrl}/${id}`, data);\n return response.data.datastore;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error updating datastore\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error updating datastore\");\n }\n};\n\n/**\n * deleteDatastore\n *\n * Deletes a datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {string} workspace - Workspace the datastore belongs to.\n * @returns {Promise<DeleteEntityDefaultResponse[]>} List of deleted entity records.\n *\n * @throws {Error} If the request fails.\n */\nexport const deleteDatastore = async (api: AxiosInstance, id: string, workspace: string): Promise<DeleteEntityDefaultResponse[]> => {\n const params: AnyRecord = { workspace };\n\n try {\n const response: AxiosResponse<DeleteDatastoreResponse> = await api.delete(`${baseUrl}/${id}`, { params });\n return response.data.datastores;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error removing datastore\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error removing datastore\");\n }\n};"],"mappings":";;AAMA,IAAM,UAAU;;;;;;;;;;;;;AAchB,IAAa,eAAe,OAAO,KAAoB,IAAY,cAA0C;CAC3G,MAAM,SAAoB,EAAE,UAAU;CAEtC,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,mDAAmD;CAEnF,IAAI;EAEF,QAAO,MADwD,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,EAAA,CACrF,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"datastore.js","names":[],"sources":["../../src/api/datastore.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { DeleteEntityDefaultResponse, FilterExpression, QueryObject } from \"@/types/entityQuery\";\nimport type { Datastore, DatastoreSingleResponse, DatastoreListResponse, DeleteDatastoreResponse } from \"@/types/datastore\";\n\nconst baseUrl = \"datastores\";\n\n/**\n * getDatastore\n *\n * Fetches a single datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {string} workspace - Workspace the datastore belongs to.\n * @returns {Promise<Datastore>} The fetched datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const getDatastore = async (api: AxiosInstance, id: string, workspace: string): Promise<Datastore> => {\n const params: AnyRecord = { workspace };\n\n if (!workspace) throw new Error(\"Workspace filter is required to fetch a datastore\");\n\n try {\n const response: AxiosResponse<DatastoreSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });\n return response.data.datastore;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching datastore\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching datastore\", { cause: error });\n }\n};\n\n/**\n * listDatastores\n *\n * Fetches a list of datastores using a query object (filters, order, pagination, etc.).\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {AnyRecord} query - Query object built via `buildQueryObject`.\n * @returns {Promise<DatastoreListResponse>} Paginated list of datastores.\n *\n * @throws {Error} If workspace filter is missing.\n * @throws {Error} If the request fails.\n */\nexport const listDatastores = async (api: AxiosInstance, query: QueryObject): Promise<DatastoreListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) throw new Error(\"Workspace filter is required to list datastores\");\n\n const params: AnyRecord = {\n workspace,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n try {\n const response: AxiosResponse<DatastoreListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing datastores\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing datastores\", { cause: error });\n }\n};\n\n/**\n * createDatastore\n *\n * Creates a new datastore.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {Partial<Datastore>} data - Datastore payload.\n * @returns {Promise<Datastore>} The created datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const createDatastore = async (api: AxiosInstance, data: Partial<Datastore>): Promise<Datastore> => {\n\n const { workspace } = data;\n if (!workspace) throw new Error(\"Workspace filter is required to create a datastore\");\n\n try {\n const response: AxiosResponse<DatastoreSingleResponse> = await api.post(baseUrl, data);\n return response.data.datastore;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error creating datastore\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error creating datastore\", { cause: error });\n }\n};\n\n/**\n * updateDatastore\n *\n * Updates an existing datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {Partial<Datastore>} data - Fields to update.\n * @returns {Promise<Datastore>} The updated datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const updateDatastore = async (api: AxiosInstance, id: string, data: Partial<Datastore>): Promise<Datastore> => {\n\n const { workspace } = data;\n if (!workspace) throw new Error(\"Workspace filter is required to update a datastore\");\n\n try {\n const response: AxiosResponse<DatastoreSingleResponse> = await api.put(`${baseUrl}/${id}`, data);\n return response.data.datastore;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error updating datastore\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error updating datastore\", { cause: error });\n }\n};\n\n/**\n * deleteDatastore\n *\n * Deletes a datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {string} workspace - Workspace the datastore belongs to.\n * @returns {Promise<DeleteEntityDefaultResponse[]>} List of deleted entity records.\n *\n * @throws {Error} If the request fails.\n */\nexport const deleteDatastore = async (api: AxiosInstance, id: string, workspace: string): Promise<DeleteEntityDefaultResponse[]> => {\n const params: AnyRecord = { workspace };\n\n try {\n const response: AxiosResponse<DeleteDatastoreResponse> = await api.delete(`${baseUrl}/${id}`, { params });\n return response.data.datastores;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error removing datastore\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error removing datastore\", { cause: error });\n }\n};"],"mappings":";;AAMA,IAAM,UAAU;;;;;;;;;;;;;AAchB,IAAa,eAAe,OAAO,KAAoB,IAAY,cAA0C;CAC3G,MAAM,SAAoB,EAAE,UAAU;CAEtC,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,mDAAmD;CAEnF,IAAI;EAEF,QAAO,MADwD,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,EAAA,CACrF,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC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AAO,KAAoB,IAAY,SAAiD;CAErH,MAAM,EAAE,cAAc;CACtB,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,oDAAoD;CAEpF,IAAI;EAEF,QAAO,MADwD,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,IAAI,EAAA,CAC/E,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,4BAA4B,EAAE,OAAO,MAAM,CAAC;EAG/E,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,4BAA4B,EAAE,OAAO,MAAM,CAAC;CAC9D;AACF;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAAO,KAAoB,IAAY,cAA8D;CAClI,MAAM,SAAoB,EAAE,UAAU;CAEtC,IAAI;EAEF,QAAO,MADwD,IAAI,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,EAAA,CACxF,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,4BAA4B,EAAE,OAAO,MAAM,CAAC;EAG/E,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,4BAA4B,EAAE,OAAO,MAAM,CAAC;CAC9D;AACF"}
|
package/dist/api/file.js
CHANGED
|
@@ -18,9 +18,9 @@ var getFile = async (api, id, workspace) => {
|
|
|
18
18
|
try {
|
|
19
19
|
return (await api.get(`${baseUrl}/${id}`, { params })).data.file;
|
|
20
20
|
} catch (error) {
|
|
21
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching file");
|
|
21
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching file", { cause: error });
|
|
22
22
|
if (error instanceof Error) throw error;
|
|
23
|
-
throw new Error("Error while fetching file");
|
|
23
|
+
throw new Error("Error while fetching file", { cause: error });
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
@@ -48,9 +48,9 @@ var listFiles = async (api, query) => {
|
|
|
48
48
|
try {
|
|
49
49
|
return (await api.get(baseUrl, { params })).data;
|
|
50
50
|
} catch (error) {
|
|
51
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching files");
|
|
51
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching files", { cause: error });
|
|
52
52
|
if (error instanceof Error) throw error;
|
|
53
|
-
throw new Error("Error while fetching files");
|
|
53
|
+
throw new Error("Error while fetching files", { cause: error });
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
@@ -70,9 +70,9 @@ var createFile = async (api, data) => {
|
|
|
70
70
|
try {
|
|
71
71
|
return (await api.post(baseUrl, data)).data.file;
|
|
72
72
|
} catch (error) {
|
|
73
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while creating file");
|
|
73
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while creating file", { cause: error });
|
|
74
74
|
if (error instanceof Error) throw error;
|
|
75
|
-
throw new Error("Error while creating file");
|
|
75
|
+
throw new Error("Error while creating file", { cause: error });
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
/**
|
|
@@ -93,9 +93,9 @@ var updateFile = async (api, id, data) => {
|
|
|
93
93
|
try {
|
|
94
94
|
return (await api.put(`${baseUrl}/${id}`, data)).data.file;
|
|
95
95
|
} catch (error) {
|
|
96
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while updating file");
|
|
96
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while updating file", { cause: error });
|
|
97
97
|
if (error instanceof Error) throw error;
|
|
98
|
-
throw new Error("Error while updating file");
|
|
98
|
+
throw new Error("Error while updating file", { cause: error });
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
/**
|
|
@@ -115,9 +115,9 @@ var deleteFile = async (api, id, workspace) => {
|
|
|
115
115
|
try {
|
|
116
116
|
return (await api.delete(`${baseUrl}/${id}`, { params })).data.files;
|
|
117
117
|
} catch (error) {
|
|
118
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while deleting file");
|
|
118
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while deleting file", { cause: error });
|
|
119
119
|
if (error instanceof Error) throw error;
|
|
120
|
-
throw new Error("Error while deleting file");
|
|
120
|
+
throw new Error("Error while deleting file", { cause: error });
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
123
|
//#endregion
|
package/dist/api/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","names":[],"sources":["../../src/api/file.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { DeleteFileResponse, EveryskFile, FileListResponse, FileSingleResponse } from \"@/types/file\";\nimport type { DeleteEntityDefaultResponse, FilterExpression, QueryObject } from \"@/types/entityQuery\";\n\nconst baseUrl = \"files\";\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 * @returns {Promise<EveryskFile>} The fetched file.\n *\n * @throws {Error} If the request fails.\n */\nexport const getFile = async (api: AxiosInstance, id: string, workspace: string): Promise<EveryskFile> => {\n const params: AnyRecord = { workspace };\n\n try {\n const response: AxiosResponse<FileSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });\n return response.data.file;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching file\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching file\");\n }\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 * @returns {Promise<EveryskFile[]>} List of files. Returns an empty array if none found.\n *\n * @throws {Error} If the request fails.\n */\nexport const listFiles = async (api: AxiosInstance, query: QueryObject): Promise<FileListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n \n if (!workspace) throw new Error(\"Workspace filter is required to list files\");\n\n const params: AnyRecord = {\n workspace,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n try {\n const response: AxiosResponse<FileListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching files\");\n } \n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching files\");\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.\n * @returns {Promise<EveryskFile>} The created file.\n *\n * @throws {Error} If the request fails.\n */\nexport const createFile = async (api: AxiosInstance, data: Partial<EveryskFile>): Promise<EveryskFile> => {\n\n const { workspace } = data;\n if (!workspace) throw new Error(\"Workspace filter is required to create a file\");\n\n try {\n const response: AxiosResponse<FileSingleResponse> = await api.post(baseUrl, data);\n return response.data.file;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while creating file\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while creating file\");\n }\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.\n * @returns {Promise<EveryskFile>} The updated file.\n *\n * @throws {Error} If the request fails.\n */\nexport const updateFile = async (api: AxiosInstance, id: string, data: Partial<EveryskFile>): Promise<EveryskFile> => {\n\n const { workspace } = data;\n if (!workspace) throw new Error(\"Workspace filter is required to update a file\");\n\n try {\n const response: AxiosResponse<FileSingleResponse> = await api.put(`${baseUrl}/${id}`, data);\n return response.data.file;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while updating file\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while updating file\");\n }\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<DeleteEntityDefaultResponse[]>} List of deleted entity records.\n *\n * @throws {Error} If the request fails.\n */\nexport const deleteFile = async (api: AxiosInstance, id: string, workspace: string): Promise<DeleteEntityDefaultResponse[]> => {\n const params: AnyRecord = { workspace };\n\n try {\n const response: AxiosResponse<DeleteFileResponse> = await api.delete(`${baseUrl}/${id}`, { params });\n return response.data.files;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while deleting file\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while deleting file\");\n }\n};"],"mappings":";;AAMA,IAAM,UAAU;;;;;;;;;;;;;AAchB,IAAa,UAAU,OAAO,KAAoB,IAAY,cAA4C;CACxG,MAAM,SAAoB,EAAE,UAAU;CAEtC,IAAI;EAEF,QAAO,MADmD,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,EAAA,CAChF,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAChC,MAAM,IAAI,MAAM,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"file.js","names":[],"sources":["../../src/api/file.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { DeleteFileResponse, EveryskFile, FileListResponse, FileSingleResponse } from \"@/types/file\";\nimport type { DeleteEntityDefaultResponse, FilterExpression, QueryObject } from \"@/types/entityQuery\";\n\nconst baseUrl = \"files\";\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 * @returns {Promise<EveryskFile>} The fetched file.\n *\n * @throws {Error} If the request fails.\n */\nexport const getFile = async (api: AxiosInstance, id: string, workspace: string): Promise<EveryskFile> => {\n const params: AnyRecord = { workspace };\n\n try {\n const response: AxiosResponse<FileSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });\n return response.data.file;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching file\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching file\", { cause: error });\n }\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 * @returns {Promise<EveryskFile[]>} List of files. Returns an empty array if none found.\n *\n * @throws {Error} If the request fails.\n */\nexport const listFiles = async (api: AxiosInstance, query: QueryObject): Promise<FileListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n \n if (!workspace) throw new Error(\"Workspace filter is required to list files\");\n\n const params: AnyRecord = {\n workspace,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n try {\n const response: AxiosResponse<FileListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching files\", { cause: error });\n } \n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching files\", { cause: error });\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.\n * @returns {Promise<EveryskFile>} The created file.\n *\n * @throws {Error} If the request fails.\n */\nexport const createFile = async (api: AxiosInstance, data: Partial<EveryskFile>): Promise<EveryskFile> => {\n\n const { workspace } = data;\n if (!workspace) throw new Error(\"Workspace filter is required to create a file\");\n\n try {\n const response: AxiosResponse<FileSingleResponse> = await api.post(baseUrl, data);\n return response.data.file;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while creating file\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while creating file\", { cause: error });\n }\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.\n * @returns {Promise<EveryskFile>} The updated file.\n *\n * @throws {Error} If the request fails.\n */\nexport const updateFile = async (api: AxiosInstance, id: string, data: Partial<EveryskFile>): Promise<EveryskFile> => {\n\n const { workspace } = data;\n if (!workspace) throw new Error(\"Workspace filter is required to update a file\");\n\n try {\n const response: AxiosResponse<FileSingleResponse> = await api.put(`${baseUrl}/${id}`, data);\n return response.data.file;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while updating file\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while updating file\", { cause: error });\n }\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<DeleteEntityDefaultResponse[]>} List of deleted entity records.\n *\n * @throws {Error} If the request fails.\n */\nexport const deleteFile = async (api: AxiosInstance, id: string, workspace: string): Promise<DeleteEntityDefaultResponse[]> => {\n const params: AnyRecord = { workspace };\n\n try {\n const response: AxiosResponse<DeleteFileResponse> = await api.delete(`${baseUrl}/${id}`, { params });\n return response.data.files;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while deleting file\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while deleting file\", { cause: error });\n }\n};"],"mappings":";;AAMA,IAAM,UAAU;;;;;;;;;;;;;AAchB,IAAa,UAAU,OAAO,KAAoB,IAAY,cAA4C;CACxG,MAAM,SAAoB,EAAE,UAAU;CAEtC,IAAI;EAEF,QAAO,MADmD,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,EAAA,CAChF,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAChC,MAAM,IAAI,MAAM,MAAM,WAAW,6BAA6B,EAAE,OAAO,MAAM,CAAC;EAG/E,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,6BAA6B,EAAE,OAAO,MAAM,CAAC;CAC/D;AACF;;;;;;;;;;;;;;;AAgBA,IAAa,YAAY,OAAO,KAAoB,UAAkD;CACpG,MAAM,kBAAkB,MAAM,QAAQ,MAAM,WAA6B,OAAO,OAAO,WAAW;CAClG,MAAM,YAAY,kBAAkB,gBAAgB,SAAS;CAE7D,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,4CAA4C;CAE5E,MAAM,SAAoB;EACxB;EACA,GAAI,QAAQ,EAAE,OAAO,KAAK,UAAU,KAAK,EAAE,IAAI,CAAC;CAClD;CAEA,IAAI;EAEF,QAAO,MADiD,IAAI,IAAI,SAAS,EAAE,OAAO,CAAC,EAAA,CACnE;CAClB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,8BAA8B,EAAE,OAAO,MAAM,CAAC;EAEjF,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,8BAA8B,EA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AAM;EAGR,MAAM,IAAI,MAAM,6BAA6B,EAAE,OAAO,MAAM,CAAC;CAC/D;AACF"}
|
package/dist/api/portfolio.js
CHANGED
|
@@ -19,9 +19,9 @@ var getPortfolio = async (api, id, workspace) => {
|
|
|
19
19
|
try {
|
|
20
20
|
return (await api.get(`${baseUrl}/${id}`, { params })).data;
|
|
21
21
|
} catch (error) {
|
|
22
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching portfolio");
|
|
22
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching portfolio", { cause: error });
|
|
23
23
|
if (error instanceof Error) throw error;
|
|
24
|
-
throw new Error("Error while fetching portfolio");
|
|
24
|
+
throw new Error("Error while fetching portfolio", { cause: error });
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
@@ -46,9 +46,9 @@ var listPortfolios = async (api, query) => {
|
|
|
46
46
|
try {
|
|
47
47
|
return (await api.get(baseUrl, { params })).data;
|
|
48
48
|
} catch (error) {
|
|
49
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching portfolios");
|
|
49
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching portfolios", { cause: error });
|
|
50
50
|
if (error instanceof Error) throw error;
|
|
51
|
-
throw new Error("Error while fetching portfolios");
|
|
51
|
+
throw new Error("Error while fetching portfolios", { cause: error });
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
@@ -68,9 +68,9 @@ var createPortfolio = async (api, data) => {
|
|
|
68
68
|
try {
|
|
69
69
|
return (await api.post(baseUrl, data)).data;
|
|
70
70
|
} catch (error) {
|
|
71
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while creating portfolio");
|
|
71
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while creating portfolio", { cause: error });
|
|
72
72
|
if (error instanceof Error) throw error;
|
|
73
|
-
throw new Error("Error while creating portfolio");
|
|
73
|
+
throw new Error("Error while creating portfolio", { cause: error });
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
/**
|
|
@@ -91,9 +91,9 @@ var updatePortfolio = async (api, id, data) => {
|
|
|
91
91
|
try {
|
|
92
92
|
return (await api.put(`${baseUrl}/${id}`, data)).data;
|
|
93
93
|
} catch (error) {
|
|
94
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while updating portfolio");
|
|
94
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while updating portfolio", { cause: error });
|
|
95
95
|
if (error instanceof Error) throw error;
|
|
96
|
-
throw new Error("Error while updating portfolio");
|
|
96
|
+
throw new Error("Error while updating portfolio", { cause: error });
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
/**
|
|
@@ -114,9 +114,9 @@ var deletePortfolio = async (api, id, workspace) => {
|
|
|
114
114
|
try {
|
|
115
115
|
return (await api.delete(`${baseUrl}/${id}`, { params })).data;
|
|
116
116
|
} catch (error) {
|
|
117
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while deleting portfolio");
|
|
117
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while deleting portfolio", { cause: error });
|
|
118
118
|
if (error instanceof Error) throw error;
|
|
119
|
-
throw new Error("Error while deleting portfolio");
|
|
119
|
+
throw new Error("Error while deleting portfolio", { cause: error });
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.js","names":[],"sources":["../../src/api/portfolio.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { QueryObject } from \"@/types/entityQuery\";\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { FilterExpression } from \"@/types/entityQuery\";\nimport type { Portfolio, PortfolioListResponse, PortfolioSingleResponse } from \"@/types/portfolio\";\n\nconst baseUrl = \"portfolios\";\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 * @returns {Promise<PortfolioSingleResponse>} The fetched portfolio response.\n *\n * @throws {Error} If the request fails.\n */\nexport const getPortfolio = async (api: AxiosInstance, id: string, workspace: string): Promise<PortfolioSingleResponse> => {\n const params: AnyRecord = { workspace };\n\n if(!workspace){\n throw new Error(\"Workspace is required to fetch a portfolio\");\n }\n\n try {\n const response: AxiosResponse<PortfolioSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching portfolio\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching portfolio\");\n }\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 * @returns {Promise<PortfolioListResponse>} List of portfolios.\n *\n * @throws {Error} If the request fails.\n */\nexport const listPortfolios = async (api: AxiosInstance, query: QueryObject): Promise<PortfolioListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch portfolios\");\n }\n\n const params: AnyRecord = {\n workspace,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n try {\n const response: AxiosResponse<PortfolioListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching portfolios\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching 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 (api: AxiosInstance, data: Partial<Portfolio>): Promise<Portfolio> => {\n\n const { workspace } = data;\n\n if (!workspace) {\n throw new Error(\"Workspace is required to post a portfolio\");\n }\n\n try {\n const response: AxiosResponse<Portfolio> = await api.post(baseUrl, data);\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while creating portfolio\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while creating portfolio\");\n }\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 (api: AxiosInstance, id: string, data: Partial<Portfolio>): Promise<Portfolio> => {\n\n const { workspace } = data;\n \n if(!workspace) {\n throw new Error(\"Workspace is required to delete a portfolio\");\n }\n\n try {\n const response: AxiosResponse<Portfolio> = await api.put(`${baseUrl}/${id}`, data);\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while updating portfolio\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while updating portfolio\");\n }\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<Portfolio>} The deleted portfolio.\n *\n * @throws {Error} If the request fails.\n */\nexport const deletePortfolio = async (api: AxiosInstance, id: string, workspace: string): Promise<Portfolio> => {\n \n if(!workspace) {\n throw new Error(\"Workspace is required to delete a portfolio\");\n }\n \n const params: AnyRecord = { workspace };\n\n try {\n const response: AxiosResponse<Portfolio> = await api.delete(`${baseUrl}/${id}`, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while deleting portfolio\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while deleting portfolio\");\n }\n}"],"mappings":";;AAOA,IAAM,UAAU;;;;;;;;;;;;;AAchB,IAAa,eAAe,OAAO,KAAoB,IAAY,cAAwD;CACzH,MAAM,SAAoB,EAAE,UAAU;CAEtC,IAAG,CAAC,WACF,MAAM,IAAI,MAAM,4CAA4C;CAG9D,IAAI;EAEF,QAAO,MADwD,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,EAAA,CACrF;CAClB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAChC,MAAM,IAAI,MAAM,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"portfolio.js","names":[],"sources":["../../src/api/portfolio.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { QueryObject } from \"@/types/entityQuery\";\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { FilterExpression } from \"@/types/entityQuery\";\nimport type { Portfolio, PortfolioListResponse, PortfolioSingleResponse } from \"@/types/portfolio\";\n\nconst baseUrl = \"portfolios\";\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 * @returns {Promise<PortfolioSingleResponse>} The fetched portfolio response.\n *\n * @throws {Error} If the request fails.\n */\nexport const getPortfolio = async (api: AxiosInstance, id: string, workspace: string): Promise<PortfolioSingleResponse> => {\n const params: AnyRecord = { workspace };\n\n if(!workspace){\n throw new Error(\"Workspace is required to fetch a portfolio\");\n }\n\n try {\n const response: AxiosResponse<PortfolioSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching portfolio\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching portfolio\", { cause: error });\n }\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 * @returns {Promise<PortfolioListResponse>} List of portfolios.\n *\n * @throws {Error} If the request fails.\n */\nexport const listPortfolios = async (api: AxiosInstance, query: QueryObject): Promise<PortfolioListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch portfolios\");\n }\n\n const params: AnyRecord = {\n workspace,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n try {\n const response: AxiosResponse<PortfolioListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching portfolios\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching portfolios\", { cause: error });\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 (api: AxiosInstance, data: Partial<Portfolio>): Promise<Portfolio> => {\n\n const { workspace } = data;\n\n if (!workspace) {\n throw new Error(\"Workspace is required to post a portfolio\");\n }\n\n try {\n const response: AxiosResponse<Portfolio> = await api.post(baseUrl, data);\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while creating portfolio\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while creating portfolio\", { cause: error });\n }\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 (api: AxiosInstance, id: string, data: Partial<Portfolio>): Promise<Portfolio> => {\n\n const { workspace } = data;\n \n if(!workspace) {\n throw new Error(\"Workspace is required to delete a portfolio\");\n }\n\n try {\n const response: AxiosResponse<Portfolio> = await api.put(`${baseUrl}/${id}`, data);\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while updating portfolio\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while updating portfolio\", { cause: error });\n }\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<Portfolio>} The deleted portfolio.\n *\n * @throws {Error} If the request fails.\n */\nexport const deletePortfolio = async (api: AxiosInstance, id: string, workspace: string): Promise<Portfolio> => {\n \n if(!workspace) {\n throw new Error(\"Workspace is required to delete a portfolio\");\n }\n \n const params: AnyRecord = { workspace };\n\n try {\n const response: AxiosResponse<Portfolio> = await api.delete(`${baseUrl}/${id}`, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while deleting portfolio\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while deleting portfolio\", { cause: error });\n }\n}"],"mappings":";;AAOA,IAAM,UAAU;;;;;;;;;;;;;AAchB,IAAa,eAAe,OAAO,KAAoB,IAAY,cAAwD;CACzH,MAAM,SAAoB,EAAE,UAAU;C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AM,MAAM,WAAW,kCAAkC,EAAE,OAAO,MAAM,CAAC;EAGrF,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,kCAAkC,EAAE,OAAO,MAAM,CAAC;CACpE;AACF;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAAO,KAAoB,IAAY,SAAiD;CAErH,MAAM,EAAE,cAAc;CAEtB,IAAG,CAAC,WACF,MAAM,IAAI,MAAM,6CAA6C;CAG/D,IAAI;EAEF,QAAO,MAD0C,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,IAAI,EAAA,CACjE;CAClB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,kCAAkC,EAAE,OAAO,MAAM,CAAC;EAGrF,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,kCAAkC,EAAE,OAAO,MAAM,CAAC;CACpE;AACF;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAAO,KAAoB,IAAY,cAA0C;CAE9G,IAAG,CAAC,WACF,MAAM,IAAI,MAAM,6CAA6C;CAG/D,MAAM,SAAoB,EAAE,UAAU;CAEtC,IAAI;EAEF,QAAO,MAD0C,IAAI,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,EAAA,CAC1E;CAClB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,kCAAkC,EAAE,OAAO,MAAM,CAAC;EAGrF,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,kCAAkC,EAAE,OAAO,MAAM,CAAC;CACpE;AACF"}
|
package/dist/api/profile.js
CHANGED
|
@@ -60,9 +60,9 @@ var getProfile = async (api, fallback) => {
|
|
|
60
60
|
try {
|
|
61
61
|
return (await api.get(baseUrl)).data.profile;
|
|
62
62
|
} catch (error) {
|
|
63
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching profile");
|
|
63
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching profile", { cause: error });
|
|
64
64
|
if (error instanceof Error) throw error;
|
|
65
|
-
throw new Error("Error while fetching profile");
|
|
65
|
+
throw new Error("Error while fetching profile", { cause: error });
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
//#endregion
|
package/dist/api/profile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","names":[],"sources":["../../src/api/profile.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { Profile, ProfileResponse } from \"@/types/profile\";\n\nconst baseUrl = \"profile\";\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 * @returns {Promise<Profile>} The logged user's profile.\n *\n * @throws {Error} If the request fails.\n */\nexport const getProfile = async (api: AxiosInstance, fallback?: Profile): Promise<Profile> => {\n if (fallback) return fallback;\n\n try {\n const response: AxiosResponse<ProfileResponse> = await api.get(baseUrl);\n return response.data.profile;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching profile\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching profile\");\n }\n};\n"],"mappings":";;AAKA,IAAM,UAAU;;;;;;;;;;;AAYhB,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;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAa,aAAa,OAAO,KAAoB,aAAyC;CAC1F,IAAI,UAAU,OAAO;CAErB,IAAI;EAEA,QAAO,MADgD,IAAI,IAAI,OAAO,EAAA,CACtD,KAAK;CACzB,SAAS,OAAgB;EACrB,IAAI,aAAwB,KAAK,GAC7B,MAAM,IAAI,MAAM,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"profile.js","names":[],"sources":["../../src/api/profile.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { Profile, ProfileResponse } from \"@/types/profile\";\n\nconst baseUrl = \"profile\";\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 * @returns {Promise<Profile>} The logged user's profile.\n *\n * @throws {Error} If the request fails.\n */\nexport const getProfile = async (api: AxiosInstance, fallback?: Profile): Promise<Profile> => {\n if (fallback) return fallback;\n\n try {\n const response: AxiosResponse<ProfileResponse> = await api.get(baseUrl);\n return response.data.profile;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching profile\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching profile\", { cause: error });\n }\n};\n"],"mappings":";;AAKA,IAAM,UAAU;;;;;;;;;;;AAYhB,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;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAa,aAAa,OAAO,KAAoB,aAAyC;CAC1F,IAAI,UAAU,OAAO;CAErB,IAAI;EAEA,QAAO,MADgD,IAAI,IAAI,OAAO,EAAA,CACtD,KAAK;CACzB,SAAS,OAAgB;EACrB,IAAI,aAAwB,KAAK,GAC7B,MAAM,IAAI,MAAM,MAAM,WAAW,gCAAgC,EAAE,OAAO,MAAM,CAAC;EAGrF,IAAI,iBAAiB,OACjB,MAAM;EAGV,MAAM,IAAI,MAAM,gCAAgC,EAAE,OAAO,MAAM,CAAC;CACpE;AACJ"}
|
|
@@ -14,9 +14,9 @@ var getWebsocketsConfig = async (api) => {
|
|
|
14
14
|
try {
|
|
15
15
|
return (await api.get(baseUrl)).data;
|
|
16
16
|
} catch (error) {
|
|
17
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error fetching websockets config");
|
|
17
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error fetching websockets config", { cause: error });
|
|
18
18
|
if (error instanceof Error) throw error;
|
|
19
|
-
throw new Error("Error fetching websockets config");
|
|
19
|
+
throw new Error("Error fetching websockets config", { cause: error });
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocketsConfig.js","names":[],"sources":["../../src/api/websocketsConfig.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { WebsocketsConfig } from \"@/contexts/webSocketContext/types\";\n\nconst baseUrl = \"websockets_config\";\n\n/**\n * getWebsocketsConfig\n *\n * Fetches the Socket.IO connection config for the current user/app.\n *\n * @param {AxiosInstance} api - Axios instance (from `useAxios`).\n * @returns {Promise<WebsocketsConfig>} Connection URL, channel id, and session uid.\n * @throws {Error} If the request fails.\n */\nexport const getWebsocketsConfig = async (api: AxiosInstance): Promise<WebsocketsConfig> => {\n try {\n const response: AxiosResponse<WebsocketsConfig> = await api.get(baseUrl);\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching websockets config\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching websockets config\");\n }\n};\n"],"mappings":";;AAKA,IAAM,UAAU;;;;;;;;;;AAWhB,IAAa,sBAAsB,OAAO,QAAkD;CACxF,IAAI;EAEA,QAAO,MADiD,IAAI,IAAI,OAAO,EAAA,CACvD;CACpB,SAAS,OAAgB;EACrB,IAAI,aAAwB,KAAK,GAC7B,MAAM,IAAI,MAAM,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"websocketsConfig.js","names":[],"sources":["../../src/api/websocketsConfig.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { WebsocketsConfig } from \"@/contexts/webSocketContext/types\";\n\nconst baseUrl = \"websockets_config\";\n\n/**\n * getWebsocketsConfig\n *\n * Fetches the Socket.IO connection config for the current user/app.\n *\n * @param {AxiosInstance} api - Axios instance (from `useAxios`).\n * @returns {Promise<WebsocketsConfig>} Connection URL, channel id, and session uid.\n * @throws {Error} If the request fails.\n */\nexport const getWebsocketsConfig = async (api: AxiosInstance): Promise<WebsocketsConfig> => {\n try {\n const response: AxiosResponse<WebsocketsConfig> = await api.get(baseUrl);\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching websockets config\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching websockets config\", { cause: error });\n }\n};\n"],"mappings":";;AAKA,IAAM,UAAU;;;;;;;;;;AAWhB,IAAa,sBAAsB,OAAO,QAAkD;CACxF,IAAI;EAEA,QAAO,MADiD,IAAI,IAAI,OAAO,EAAA,CACvD;CACpB,SAAS,OAAgB;EACrB,IAAI,aAAwB,KAAK,GAC7B,MAAM,IAAI,MAAM,MAAM,WAAW,oCAAoC,EAAE,OAAO,MAAM,CAAC;EAGzF,IAAI,iBAAiB,OACjB,MAAM;EAGV,MAAM,IAAI,MAAM,oCAAoC,EAAE,OAAO,MAAM,CAAC;CACxE;AACJ"}
|
package/dist/api/workflow.js
CHANGED
|
@@ -24,9 +24,9 @@ var runWorkflow = async (api, id, workspace, parameters) => {
|
|
|
24
24
|
};
|
|
25
25
|
return (await api.post(`${baseUrl}/${id}/run`, body)).data;
|
|
26
26
|
} catch (error) {
|
|
27
|
-
if (isAxiosError(error)) throw new Error(error.message || "");
|
|
27
|
+
if (isAxiosError(error)) throw new Error(error.message || "", { cause: error });
|
|
28
28
|
if (error instanceof Error) throw error;
|
|
29
|
-
throw new Error("Error while running workflow");
|
|
29
|
+
throw new Error("Error while running workflow", { cause: error });
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
@@ -148,9 +148,9 @@ var getWorkflow = async (api, id, workspace) => {
|
|
|
148
148
|
const params = { workspace };
|
|
149
149
|
return (await api.get(`${baseUrl}/${id}`, { params })).data.workflow;
|
|
150
150
|
} catch (error) {
|
|
151
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching workflow");
|
|
151
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching workflow", { cause: error });
|
|
152
152
|
if (error instanceof Error) throw error;
|
|
153
|
-
throw new Error("Error while fetching workflow");
|
|
153
|
+
throw new Error("Error while fetching workflow", { cause: error });
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
156
|
/**
|
|
@@ -171,9 +171,9 @@ var listWorkflows = async (api, workspace, pageSize, pageToken) => {
|
|
|
171
171
|
try {
|
|
172
172
|
return (await api.get(baseUrl, { params })).data;
|
|
173
173
|
} catch (error) {
|
|
174
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error listing workflows");
|
|
174
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error listing workflows", { cause: error });
|
|
175
175
|
if (error instanceof Error) throw error;
|
|
176
|
-
throw new Error("Error listing workflows");
|
|
176
|
+
throw new Error("Error listing workflows", { cause: error });
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
179
|
/**
|
|
@@ -196,9 +196,9 @@ var getWorkflowExecution = async (api, workflowId, executionId, workspace) => {
|
|
|
196
196
|
};
|
|
197
197
|
return (await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params })).data.workflow_execution;
|
|
198
198
|
} catch (error) {
|
|
199
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error fetching workflow execution");
|
|
199
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error fetching workflow execution", { cause: error });
|
|
200
200
|
if (error instanceof Error) throw error;
|
|
201
|
-
throw new Error("Error fetching workflow execution");
|
|
201
|
+
throw new Error("Error fetching workflow execution", { cause: error });
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
204
|
/**
|
|
@@ -223,9 +223,9 @@ var listWorkflowExecutions = async (api, workflowId, query) => {
|
|
|
223
223
|
};
|
|
224
224
|
return (await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params })).data;
|
|
225
225
|
} catch (error) {
|
|
226
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error listing workflow executions");
|
|
226
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error listing workflow executions", { cause: error });
|
|
227
227
|
if (error instanceof Error) throw error;
|
|
228
|
-
throw new Error("Error listing workflow executions");
|
|
228
|
+
throw new Error("Error listing workflow executions", { cause: error });
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
231
|
/**
|
|
@@ -249,9 +249,9 @@ var getWorkerExecution = async (api, workflowId, workerExecutionId, workspace) =
|
|
|
249
249
|
};
|
|
250
250
|
return (await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params })).data.worker_execution;
|
|
251
251
|
} catch (error) {
|
|
252
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error fetching worker execution");
|
|
252
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error fetching worker execution", { cause: error });
|
|
253
253
|
if (error instanceof Error) throw error;
|
|
254
|
-
throw new Error("Error fetching worker execution");
|
|
254
|
+
throw new Error("Error fetching worker execution", { cause: error });
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
257
|
/**
|
|
@@ -278,9 +278,9 @@ var listWorkerExecutions = async (api, workflowId, workflowExecutionId, query) =
|
|
|
278
278
|
};
|
|
279
279
|
return (await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params })).data;
|
|
280
280
|
} catch (error) {
|
|
281
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error listing worker executions");
|
|
281
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error listing worker executions", { cause: error });
|
|
282
282
|
if (error instanceof Error) throw error;
|
|
283
|
-
throw new Error("Error listing worker executions");
|
|
283
|
+
throw new Error("Error listing worker executions", { cause: error });
|
|
284
284
|
}
|
|
285
285
|
};
|
|
286
286
|
//#endregion
|
package/dist/api/workflow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.js","names":[],"sources":["../../src/api/workflow.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { FilterExpression, QueryObject } from \"@/types/entityQuery\";\nimport type { WorkerExecution, WorkerExecutionListResponse, WorkerExecutionSingleResponse, Workflow, WorkflowExecution, WorkflowExecutionListResponse, WorkflowExecutionSingleResponse, WorkflowListResponse, WorkflowSingleResponse } from \"@/types/workflow\";\n\nconst baseUrl = \"workflows\";\n\n/**\n * Runs a workflow asynchronously.\n *\n * Starts the workflow in a non-blocking way: the response carries a workflow execution\n * with a non-terminal status (e.g. \"RUNNING\"). Use polling to wait for the terminal state.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to run.\n * @param workspace - The workspace in which the workflow will be executed.\n * @param parameters - Key-value parameters to pass to the workflow.\n * @returns A promise that resolves with the workflow execution response data.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const runWorkflow = async (api: AxiosInstance, id: string, workspace: string, parameters: AnyRecord): Promise<AnyRecord> => {\n \n if (!workspace) {\n throw new Error(\"Workspace is required to run workflow\");\n } \n\n try {\n const body: AnyRecord = {\n workspace,\n parameters,\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const response: AxiosResponse<any> = await api.post(`${baseUrl}/${id}/run`, body);\n\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while running workflow\");\n }\n};\n\n/**\n * Run statuses that indicate a workflow execution has reached a terminal state\n * (i.e. it is no longer running and will not change again).\n *\n * Union of the backend's `WORKFLOW_EXECUTION_STATUS_FINISHED` set and the API's documented\n * terminal `run_status` values (`SUCCEEDED`/`FAILED`/`KILLED`). `KILLED` is included so a\n * killed execution is detected as terminal instead of polling until timeout.\n */\nexport const TERMINAL_RUN_STATUSES = [\"CANCELED\", \"COMPLETED\", \"SUCCEEDED\", \"FAILED\", \"KILLED\"] as const;\n\nconst isTerminalRunStatus = (runStatus: unknown): boolean =>\n TERMINAL_RUN_STATUSES.includes(String(runStatus ?? \"\").toUpperCase() as (typeof TERMINAL_RUN_STATUSES)[number]);\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nexport type PollWorkflowExecutionOptions = {\n /** Delay between status checks, in milliseconds. Defaults to 2000ms. */\n intervalMs?: number;\n /** Maximum time to wait for a terminal status before giving up, in milliseconds. Defaults to 5 minutes. */\n timeoutMs?: number;\n /** Optional abort signal to cancel polling (e.g. on unmount). */\n signal?: AbortSignal;\n};\n\n/**\n * Polls a workflow execution until it reaches a terminal run status (see {@link TERMINAL_RUN_STATUSES}).\n *\n * This is the interim, non-blocking replacement for synchronous (`synchronous: true`) execution:\n * the workflow is started asynchronously and its status is checked periodically until it completes.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the workflow.\n * @param executionId - The unique identifier of the workflow execution to poll.\n * @param workspace - The workspace in which the workflow execution resides.\n * @param options - Polling configuration (interval, timeout, abort signal).\n * @returns A promise that resolves with the terminal {@link WorkflowExecution}.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If polling is aborted via `options.signal`.\n * @throws {Error} If a terminal status is not reached before `options.timeoutMs` elapses.\n */\nexport const pollWorkflowExecution = async (\n api: AxiosInstance,\n workflowId: string,\n executionId: string,\n workspace: string,\n options: PollWorkflowExecutionOptions = {}\n): Promise<WorkflowExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to poll a workflow execution\");\n }\n\n const { intervalMs = 2000, timeoutMs = 5 * 60 * 1000, signal } = options;\n const startedAt = Date.now();\n\n while (true) {\n if (signal?.aborted) {\n throw new Error(\"Workflow execution polling was aborted\");\n }\n\n const execution = await getWorkflowExecution(api, workflowId, executionId, workspace);\n\n if (isTerminalRunStatus(execution.run_status)) {\n return execution;\n }\n\n if (Date.now() - startedAt >= timeoutMs) {\n throw new Error(\"Timed out while waiting for the workflow execution to complete\");\n }\n\n await sleep(intervalMs);\n }\n};\n\n/**\n * Starts a workflow asynchronously and polls its execution until completion.\n *\n * Interim replacement for synchronous execution: instead of holding the request open with\n * `synchronous: true`, the workflow is started in a non-blocking way and its status is polled\n * until it reaches a terminal state, at which point the final execution (with its result) is returned.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to run.\n * @param workspace - The workspace in which the workflow will be executed.\n * @param parameters - Key-value parameters to pass to the workflow.\n * @param options - Polling configuration (interval, timeout, abort signal).\n * @returns A promise that resolves with the terminal {@link WorkflowExecution}.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the run response does not contain a workflow execution id.\n * @throws {Error} If the workflow execution ends in a \"FAILED\" run status.\n * @throws {Error} If polling times out or is aborted.\n */\nconst runWorkflowAndPoll = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n parameters: AnyRecord,\n options: PollWorkflowExecutionOptions = {}\n): Promise<WorkflowExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to run workflow\");\n }\n\n // Start the workflow asynchronously (non-blocking).\n const startResponse = await runWorkflow(api, id, workspace, parameters);\n const executionId = (startResponse.workflow_execution as WorkflowExecution | undefined)?.id;\n\n if (!executionId) {\n throw new Error(\"Workflow run did not return an execution id to poll\");\n }\n\n // Poll the execution status until it completes, then consume the result.\n const execution = await pollWorkflowExecution(api, id, executionId, workspace, options);\n\n if (String(execution.run_status ?? \"\").toUpperCase() === \"FAILED\") {\n throw new Error(\"Workflow execution failed\");\n }\n\n return execution;\n};\n\n/**\n * The terminal workflow execution together with the output produced by its final (ender) worker.\n */\nexport type WorkflowResult = {\n /** The terminal workflow execution. */\n execution: WorkflowExecution;\n /** The ender worker execution, or `null` if the execution did not reference one. */\n workerExecution: WorkerExecution | null;\n /** The output data produced by the ender worker (`workerExecution.result`), or `null`. */\n result: Record<string, unknown> | null;\n};\n\n/**\n * Starts a workflow, polls it to completion, then fetches the output produced by its final worker.\n *\n * A workflow execution does not carry the output payload itself — it references the final worker via\n * `ender_worker_execution_id`, and that worker execution's `result` field holds the actual data.\n * This helper performs the full flow: start (async) → poll → fetch ender worker → return its `result`.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to run.\n * @param workspace - The workspace in which the workflow will be executed.\n * @param parameters - Key-value parameters to pass to the workflow.\n * @param options - Polling configuration (interval, timeout, abort signal).\n * @returns A promise that resolves with the {@link WorkflowResult} (execution, ender worker execution, and its result).\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the workflow execution ends in a \"FAILED\" run status.\n * @throws {Error} If polling times out or is aborted.\n */\nexport const runWorkflowAndGetResult = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n parameters: AnyRecord,\n options: PollWorkflowExecutionOptions = {}\n): Promise<WorkflowResult> => {\n const execution = await runWorkflowAndPoll(api, id, workspace, parameters, options);\n\n const enderWorkerExecutionId = execution.ender_worker_execution_id;\n if (!enderWorkerExecutionId) {\n return { execution, workerExecution: null, result: null };\n }\n\n const workerExecution = await getWorkerExecution(api, id, enderWorkerExecutionId, workspace);\n\n return { execution, workerExecution, result: workerExecution.result ?? null };\n};\n\n/**\n * Fetches a single workflow by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to fetch.\n * @param workspace - The workspace in which the workflow resides.\n * @returns A promise that resolves with the {@link Workflow} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkflow = async (api: AxiosInstance, id: string, workspace: string): Promise<Workflow> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch a workflow\");\n }\n \n try {\n const params: AnyRecord = { workspace };\n const response: AxiosResponse<WorkflowSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });\n\n return response.data.workflow;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching workflow\");\n } \n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching workflow\");\n }\n};\n\n/**\n * Fetches a paginated list of workflows using the legacy method (workspace as query param).\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workspace - Current workspace name. Sent as a query param via the legacy method, required by some API configurations.\n * @param pageSize - Number of items per page.\n * @param pageToken - Cursor token for the next page.\n * @returns A promise that resolves with a {@link WorkflowListResponse} containing the matched workflows.\n * @throws {Error} If the request fails.\n */\nexport const listWorkflows = async (api: AxiosInstance, workspace?: string, pageSize?: number, pageToken?: string): Promise<WorkflowListResponse> => {\n const params: AnyRecord = {};\n\n if (workspace) params.workspace = workspace;\n if (pageSize) params.page_size = pageSize;\n if (pageToken) params.page_token = pageToken;\n\n try {\n const response: AxiosResponse<WorkflowListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing workflows\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing workflows\");\n }\n};\n\n/**\n * Fetches a single workflow execution by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the workflow.\n * @param executionId - The unique identifier of the workflow execution to fetch.\n * @param workspace - The workspace in which the workflow execution resides.\n * @returns A promise that resolves with the {@link WorkflowExecution} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkflowExecution = async (api: AxiosInstance, workflowId: string, executionId: string, workspace: string): Promise<WorkflowExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch a workflow execution\");\n }\n\n try {\n const params: AnyRecord = { workspace, workflow_execution_id: executionId };\n const response: AxiosResponse<WorkflowExecutionSingleResponse> = await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params });\n return response.data.workflow_execution;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching workflow execution\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching workflow execution\");\n }\n};\n\n/**\n * Fetches a paginated list of workflow executions matching the given query.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the workflow whose executions to list.\n * @param query - Query object containing filters, pagination, and sorting options.\n * Must include a `workspace` filter expression.\n * @returns A promise that resolves with a {@link WorkflowExecutionListResponse} containing the matched executions.\n * @throws {Error} If the `workspace` filter is not present in `query.filters`.\n * @throws {Error} If the request fails.\n */\nexport const listWorkflowExecutions = async (api: AxiosInstance, workflowId: string, query: QueryObject): Promise<WorkflowExecutionListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) throw new Error(\"Workspace filter is required to list workflows\");\n\n try {\n const params: AnyRecord = {\n workspace,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n const response: AxiosResponse<WorkflowExecutionListResponse> = await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing workflow executions\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing workflow executions\");\n }\n};\n\n/**\n * Fetches a single worker execution by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the parent workflow.\n * @param workerExecutionId - The unique identifier of the worker execution to fetch.\n * @param workspace - The workspace in which the worker execution resides.\n * @returns A promise that resolves with the {@link WorkerExecution} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkerExecution = async (api: AxiosInstance, workflowId: string, workerExecutionId: string, workspace: string): Promise<WorkerExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch a worker execution\");\n }\n\n try {\n const params: AnyRecord = { workspace, worker_execution_id: workerExecutionId, with_result: true };\n const response: AxiosResponse<WorkerExecutionSingleResponse> = await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params });\n return response.data.worker_execution;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching worker execution\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching worker execution\");\n }\n}\n\n/**\n * Fetches a paginated list of worker executions for a given workflow.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the parent workflow.\n * @param workflowExecutionId - The unique identifier of the workflow execution to filter by.\n * @param query - Query object containing filters, pagination, and sorting options.\n * Must include a `workspace` filter expression.\n * @returns A promise that resolves with a {@link WorkerExecutionListResponse} containing the matched worker executions.\n * @throws {Error} If the `workspace` filter is not present in `query.filters`.\n * @throws {Error} If the request fails.\n */\nexport const listWorkerExecutions = async (api: AxiosInstance, workflowId: string, workflowExecutionId: string, query: QueryObject): Promise<WorkerExecutionListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) throw new Error(\"Workspace filter is required to list worker executions\");\n\n try {\n const params: AnyRecord = {\n workspace,\n workflow_execution_id: workflowExecutionId,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n const response: AxiosResponse<WorkerExecutionListResponse> = await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing worker executions\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing worker executions\");\n }\n};"],"mappings":";;AAMA,IAAM,UAAU;;;;;;;;;;;;;;;AAgBhB,IAAa,cAAc,OAAO,KAAoB,IAAY,WAAmB,eAA8C;CAEjI,IAAI,CAAC,WACH,MAAM,IAAI,MAAM,uCAAuC;CAGzD,IAAI;EACF,MAAM,OAAkB;GACtB;GACA;EACF;EAKA,QAAO,MAFoC,IAAI,KAAK,GAAG,QAAQ,GAAG,GAAG,OAAO,IAAI,EAAA,CAEhE;CAClB,SAAS,OAAgB;EACv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,SAAoB;GAAE;GAAW,qBAAqB;GAAmB,aAAa;EAAK;EAEjG,QAAO,MAD8D,IAAI,IAAI,GAAG,QAAQ,GAAG,WAAW,qBAAqB,EAAE,OAAO,CAAC,EAAA,CACrH,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,iCAAiC;EAGpE,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,iCAAiC;CACnD;AACF;;;;;;;;;;;;;AAcA,IAAa,uBAAuB,OAAO,KAAoB,YAAoB,qBAA6B,UAA6D;CAC3K,MAAM,kBAAkB,MAAM,QAAQ,MAAM,WAA6B,OAAO,OAAO,WAAW;CAClG,MAAM,YAAY,kBAAkB,gBAAgB,SAAS;CAE7D,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,wDAAwD;CAExF,IAAI;EACF,MAAM,SAAoB;GACxB;GACA,uBAAuB;GACvB,GAAI,QAAQ,EAAE,OAAO,KAAK,UAAU,KAAK,EAAE,IAAI,CAAC;EAClD;EAGA,QAAO,MAD4D,IAAI,IAAI,GAAG,QAAQ,GAAG,WAAW,qBAAqB,EAAE,OAAO,CAAC,EAAA,CACnH;CAClB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,iCAAiC;EAGpE,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,iCAAiC;CACnD;AACF"}
|
|
1
|
+
{"version":3,"file":"workflow.js","names":[],"sources":["../../src/api/workflow.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { FilterExpression, QueryObject } from \"@/types/entityQuery\";\nimport type { WorkerExecution, WorkerExecutionListResponse, WorkerExecutionSingleResponse, Workflow, WorkflowExecution, WorkflowExecutionListResponse, WorkflowExecutionSingleResponse, WorkflowListResponse, WorkflowSingleResponse } from \"@/types/workflow\";\n\nconst baseUrl = \"workflows\";\n\n/**\n * Runs a workflow asynchronously.\n *\n * Starts the workflow in a non-blocking way: the response carries a workflow execution\n * with a non-terminal status (e.g. \"RUNNING\"). Use polling to wait for the terminal state.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to run.\n * @param workspace - The workspace in which the workflow will be executed.\n * @param parameters - Key-value parameters to pass to the workflow.\n * @returns A promise that resolves with the workflow execution response data.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const runWorkflow = async (api: AxiosInstance, id: string, workspace: string, parameters: AnyRecord): Promise<AnyRecord> => {\n \n if (!workspace) {\n throw new Error(\"Workspace is required to run workflow\");\n } \n\n try {\n const body: AnyRecord = {\n workspace,\n parameters,\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const response: AxiosResponse<any> = await api.post(`${baseUrl}/${id}/run`, body);\n\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while running workflow\", { cause: error });\n }\n};\n\n/**\n * Run statuses that indicate a workflow execution has reached a terminal state\n * (i.e. it is no longer running and will not change again).\n *\n * Union of the backend's `WORKFLOW_EXECUTION_STATUS_FINISHED` set and the API's documented\n * terminal `run_status` values (`SUCCEEDED`/`FAILED`/`KILLED`). `KILLED` is included so a\n * killed execution is detected as terminal instead of polling until timeout.\n */\nexport const TERMINAL_RUN_STATUSES = [\"CANCELED\", \"COMPLETED\", \"SUCCEEDED\", \"FAILED\", \"KILLED\"] as const;\n\nconst isTerminalRunStatus = (runStatus: unknown): boolean =>\n TERMINAL_RUN_STATUSES.includes(String(runStatus ?? \"\").toUpperCase() as (typeof TERMINAL_RUN_STATUSES)[number]);\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nexport type PollWorkflowExecutionOptions = {\n /** Delay between status checks, in milliseconds. Defaults to 2000ms. */\n intervalMs?: number;\n /** Maximum time to wait for a terminal status before giving up, in milliseconds. Defaults to 5 minutes. */\n timeoutMs?: number;\n /** Optional abort signal to cancel polling (e.g. on unmount). */\n signal?: AbortSignal;\n};\n\n/**\n * Polls a workflow execution until it reaches a terminal run status (see {@link TERMINAL_RUN_STATUSES}).\n *\n * This is the interim, non-blocking replacement for synchronous (`synchronous: true`) execution:\n * the workflow is started asynchronously and its status is checked periodically until it completes.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the workflow.\n * @param executionId - The unique identifier of the workflow execution to poll.\n * @param workspace - The workspace in which the workflow execution resides.\n * @param options - Polling configuration (interval, timeout, abort signal).\n * @returns A promise that resolves with the terminal {@link WorkflowExecution}.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If polling is aborted via `options.signal`.\n * @throws {Error} If a terminal status is not reached before `options.timeoutMs` elapses.\n */\nexport const pollWorkflowExecution = async (\n api: AxiosInstance,\n workflowId: string,\n executionId: string,\n workspace: string,\n options: PollWorkflowExecutionOptions = {}\n): Promise<WorkflowExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to poll a workflow execution\");\n }\n\n const { intervalMs = 2000, timeoutMs = 5 * 60 * 1000, signal } = options;\n const startedAt = Date.now();\n\n while (true) {\n if (signal?.aborted) {\n throw new Error(\"Workflow execution polling was aborted\");\n }\n\n const execution = await getWorkflowExecution(api, workflowId, executionId, workspace);\n\n if (isTerminalRunStatus(execution.run_status)) {\n return execution;\n }\n\n if (Date.now() - startedAt >= timeoutMs) {\n throw new Error(\"Timed out while waiting for the workflow execution to complete\");\n }\n\n await sleep(intervalMs);\n }\n};\n\n/**\n * Starts a workflow asynchronously and polls its execution until completion.\n *\n * Interim replacement for synchronous execution: instead of holding the request open with\n * `synchronous: true`, the workflow is started in a non-blocking way and its status is polled\n * until it reaches a terminal state, at which point the final execution (with its result) is returned.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to run.\n * @param workspace - The workspace in which the workflow will be executed.\n * @param parameters - Key-value parameters to pass to the workflow.\n * @param options - Polling configuration (interval, timeout, abort signal).\n * @returns A promise that resolves with the terminal {@link WorkflowExecution}.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the run response does not contain a workflow execution id.\n * @throws {Error} If the workflow execution ends in a \"FAILED\" run status.\n * @throws {Error} If polling times out or is aborted.\n */\nconst runWorkflowAndPoll = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n parameters: AnyRecord,\n options: PollWorkflowExecutionOptions = {}\n): Promise<WorkflowExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to run workflow\");\n }\n\n // Start the workflow asynchronously (non-blocking).\n const startResponse = await runWorkflow(api, id, workspace, parameters);\n const executionId = (startResponse.workflow_execution as WorkflowExecution | undefined)?.id;\n\n if (!executionId) {\n throw new Error(\"Workflow run did not return an execution id to poll\");\n }\n\n // Poll the execution status until it completes, then consume the result.\n const execution = await pollWorkflowExecution(api, id, executionId, workspace, options);\n\n if (String(execution.run_status ?? \"\").toUpperCase() === \"FAILED\") {\n throw new Error(\"Workflow execution failed\");\n }\n\n return execution;\n};\n\n/**\n * The terminal workflow execution together with the output produced by its final (ender) worker.\n */\nexport type WorkflowResult = {\n /** The terminal workflow execution. */\n execution: WorkflowExecution;\n /** The ender worker execution, or `null` if the execution did not reference one. */\n workerExecution: WorkerExecution | null;\n /** The output data produced by the ender worker (`workerExecution.result`), or `null`. */\n result: Record<string, unknown> | null;\n};\n\n/**\n * Starts a workflow, polls it to completion, then fetches the output produced by its final worker.\n *\n * A workflow execution does not carry the output payload itself — it references the final worker via\n * `ender_worker_execution_id`, and that worker execution's `result` field holds the actual data.\n * This helper performs the full flow: start (async) → poll → fetch ender worker → return its `result`.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to run.\n * @param workspace - The workspace in which the workflow will be executed.\n * @param parameters - Key-value parameters to pass to the workflow.\n * @param options - Polling configuration (interval, timeout, abort signal).\n * @returns A promise that resolves with the {@link WorkflowResult} (execution, ender worker execution, and its result).\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the workflow execution ends in a \"FAILED\" run status.\n * @throws {Error} If polling times out or is aborted.\n */\nexport const runWorkflowAndGetResult = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n parameters: AnyRecord,\n options: PollWorkflowExecutionOptions = {}\n): Promise<WorkflowResult> => {\n const execution = await runWorkflowAndPoll(api, id, workspace, parameters, options);\n\n const enderWorkerExecutionId = execution.ender_worker_execution_id;\n if (!enderWorkerExecutionId) {\n return { execution, workerExecution: null, result: null };\n }\n\n const workerExecution = await getWorkerExecution(api, id, enderWorkerExecutionId, workspace);\n\n return { execution, workerExecution, result: workerExecution.result ?? null };\n};\n\n/**\n * Fetches a single workflow by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to fetch.\n * @param workspace - The workspace in which the workflow resides.\n * @returns A promise that resolves with the {@link Workflow} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkflow = async (api: AxiosInstance, id: string, workspace: string): Promise<Workflow> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch a workflow\");\n }\n \n try {\n const params: AnyRecord = { workspace };\n const response: AxiosResponse<WorkflowSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });\n\n return response.data.workflow;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching workflow\", { cause: error });\n } \n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching workflow\", { cause: error });\n }\n};\n\n/**\n * Fetches a paginated list of workflows using the legacy method (workspace as query param).\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workspace - Current workspace name. Sent as a query param via the legacy method, required by some API configurations.\n * @param pageSize - Number of items per page.\n * @param pageToken - Cursor token for the next page.\n * @returns A promise that resolves with a {@link WorkflowListResponse} containing the matched workflows.\n * @throws {Error} If the request fails.\n */\nexport const listWorkflows = async (api: AxiosInstance, workspace?: string, pageSize?: number, pageToken?: string): Promise<WorkflowListResponse> => {\n const params: AnyRecord = {};\n\n if (workspace) params.workspace = workspace;\n if (pageSize) params.page_size = pageSize;\n if (pageToken) params.page_token = pageToken;\n\n try {\n const response: AxiosResponse<WorkflowListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing workflows\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing workflows\", { cause: error });\n }\n};\n\n/**\n * Fetches a single workflow execution by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the workflow.\n * @param executionId - The unique identifier of the workflow execution to fetch.\n * @param workspace - The workspace in which the workflow execution resides.\n * @returns A promise that resolves with the {@link WorkflowExecution} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkflowExecution = async (api: AxiosInstance, workflowId: string, executionId: string, workspace: string): Promise<WorkflowExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch a workflow execution\");\n }\n\n try {\n const params: AnyRecord = { workspace, workflow_execution_id: executionId };\n const response: AxiosResponse<WorkflowExecutionSingleResponse> = await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params });\n return response.data.workflow_execution;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching workflow execution\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching workflow execution\", { cause: error });\n }\n};\n\n/**\n * Fetches a paginated list of workflow executions matching the given query.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the workflow whose executions to list.\n * @param query - Query object containing filters, pagination, and sorting options.\n * Must include a `workspace` filter expression.\n * @returns A promise that resolves with a {@link WorkflowExecutionListResponse} containing the matched executions.\n * @throws {Error} If the `workspace` filter is not present in `query.filters`.\n * @throws {Error} If the request fails.\n */\nexport const listWorkflowExecutions = async (api: AxiosInstance, workflowId: string, query: QueryObject): Promise<WorkflowExecutionListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) throw new Error(\"Workspace filter is required to list workflows\");\n\n try {\n const params: AnyRecord = {\n workspace,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n const response: AxiosResponse<WorkflowExecutionListResponse> = await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing workflow executions\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing workflow executions\", { cause: error });\n }\n};\n\n/**\n * Fetches a single worker execution by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the parent workflow.\n * @param workerExecutionId - The unique identifier of the worker execution to fetch.\n * @param workspace - The workspace in which the worker execution resides.\n * @returns A promise that resolves with the {@link WorkerExecution} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkerExecution = async (api: AxiosInstance, workflowId: string, workerExecutionId: string, workspace: string): Promise<WorkerExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch a worker execution\");\n }\n\n try {\n const params: AnyRecord = { workspace, worker_execution_id: workerExecutionId, with_result: true };\n const response: AxiosResponse<WorkerExecutionSingleResponse> = await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params });\n return response.data.worker_execution;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching worker execution\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching worker execution\", { cause: error });\n }\n}\n\n/**\n * Fetches a paginated list of worker executions for a given workflow.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the parent workflow.\n * @param workflowExecutionId - The unique identifier of the workflow execution to filter by.\n * @param query - Query object containing filters, pagination, and sorting options.\n * Must include a `workspace` filter expression.\n * @returns A promise that resolves with a {@link WorkerExecutionListResponse} containing the matched worker executions.\n * @throws {Error} If the `workspace` filter is not present in `query.filters`.\n * @throws {Error} If the request fails.\n */\nexport const listWorkerExecutions = async (api: AxiosInstance, workflowId: string, workflowExecutionId: string, query: QueryObject): Promise<WorkerExecutionListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) throw new Error(\"Workspace filter is required to list worker executions\");\n\n try {\n const params: AnyRecord = {\n workspace,\n workflow_execution_id: workflowExecutionId,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n const response: AxiosResponse<WorkerExecutionListResponse> = await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing worker executions\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing worker executions\", { cause: error });\n }\n};"],"mappings":";;AAMA,IAAM,UAAU;;;;;;;;;;;;;;;AAgBhB,IAAa,cAAc,OAAO,KAAoB,IAAY,WAAmB,eAA8C;CAEjI,IAAI,CAAC,WACH,MAAM,IAAI,MAAM,uCAAuC;CAGzD,IAAI;EACF,MAAM,OAAkB;GACtB;GACA;EACF;EAKA,QAAO,MAFoC,IAAI,KAAK,GAAG,QAAQ,GAAG,GAAG,OAAO,IAAI,EAAA,CAEhE;CAClB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,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ist/api/workspace.js
CHANGED
|
@@ -17,9 +17,9 @@ var getWorkspace = async (api, name) => {
|
|
|
17
17
|
try {
|
|
18
18
|
return (await api.get(`${baseUrl}/${name}`)).data.workspace;
|
|
19
19
|
} catch (error) {
|
|
20
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching workspace");
|
|
20
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching workspace", { cause: error });
|
|
21
21
|
if (error instanceof Error) throw error;
|
|
22
|
-
throw new Error("Error while fetching workspace");
|
|
22
|
+
throw new Error("Error while fetching workspace", { cause: error });
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
@@ -43,9 +43,9 @@ var listWorkspaces = async (api, workspace, pageSize, pageToken) => {
|
|
|
43
43
|
try {
|
|
44
44
|
return (await api.get(baseUrl, { params })).data;
|
|
45
45
|
} catch (error) {
|
|
46
|
-
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching workspaces");
|
|
46
|
+
if (isAxiosError(error)) throw new Error(error.message || "Error while fetching workspaces", { cause: error });
|
|
47
47
|
if (error instanceof Error) throw error;
|
|
48
|
-
throw new Error("Error while fetching workspaces");
|
|
48
|
+
throw new Error("Error while fetching workspaces", { cause: error });
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","names":[],"sources":["../../src/api/workspace.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { Workspace, WorkspaceListResponse, WorkspaceSingleResponse } from \"@/types/workspace\";\n\nconst baseUrl = \"workspaces\";\n\n/**\n * getWorkspace\n *\n * Fetches a single workspace by name.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} name - Workspace name.\n * @returns {Promise<Workspace>} The fetched workspace.\n *\n * @throws {Error} If the request fails.\n */\nexport const getWorkspace = async (api: AxiosInstance, name: string): Promise<Workspace> => {\n if (!name) throw new Error(\"Workspace name is required to fetch a workspace\");\n\n try {\n const response: AxiosResponse<WorkspaceSingleResponse> = await api.get(`${baseUrl}/${name}`);\n return response.data.workspace;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching workspace\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching workspace\");\n }\n};\n\n/**\n * listWorkspaces\n *\n * Fetches a list of workspaces with optional cursor-based pagination.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} [workspace] - Current workspace name. Sent as a query param via the legacy method, required by some API configurations.\n * @param {number} [pageSize] - Number of items per page.\n * @param {string} [pageToken] - Cursor token for the next page.\n * @returns {Promise<WorkspaceListResponse>} List of workspaces.\n *\n * @throws {Error} If the request fails.\n */\nexport const listWorkspaces = async (api: AxiosInstance, workspace?: string, pageSize?: number, pageToken?: string): Promise<WorkspaceListResponse> => {\n const params: AnyRecord = {};\n\n if (workspace) params.workspace = workspace;\n if (pageSize) params.page_size = pageSize;\n if (pageToken) params.page_token = pageToken;\n\n try {\n const response: AxiosResponse<WorkspaceListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching workspaces\");\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching workspaces\");\n }\n};\n"],"mappings":";;AAKA,IAAM,UAAU;;;;;;;;;;;;AAahB,IAAa,eAAe,OAAO,KAAoB,SAAqC;CAC1F,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,iDAAiD;CAE5E,IAAI;EAEF,QAAO,MADwD,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,EAAA,CAC3E,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"workspace.js","names":[],"sources":["../../src/api/workspace.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { Workspace, WorkspaceListResponse, WorkspaceSingleResponse } from \"@/types/workspace\";\n\nconst baseUrl = \"workspaces\";\n\n/**\n * getWorkspace\n *\n * Fetches a single workspace by name.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} name - Workspace name.\n * @returns {Promise<Workspace>} The fetched workspace.\n *\n * @throws {Error} If the request fails.\n */\nexport const getWorkspace = async (api: AxiosInstance, name: string): Promise<Workspace> => {\n if (!name) throw new Error(\"Workspace name is required to fetch a workspace\");\n\n try {\n const response: AxiosResponse<WorkspaceSingleResponse> = await api.get(`${baseUrl}/${name}`);\n return response.data.workspace;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching workspace\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching workspace\", { cause: error });\n }\n};\n\n/**\n * listWorkspaces\n *\n * Fetches a list of workspaces with optional cursor-based pagination.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} [workspace] - Current workspace name. Sent as a query param via the legacy method, required by some API configurations.\n * @param {number} [pageSize] - Number of items per page.\n * @param {string} [pageToken] - Cursor token for the next page.\n * @returns {Promise<WorkspaceListResponse>} List of workspaces.\n *\n * @throws {Error} If the request fails.\n */\nexport const listWorkspaces = async (api: AxiosInstance, workspace?: string, pageSize?: number, pageToken?: string): Promise<WorkspaceListResponse> => {\n const params: AnyRecord = {};\n\n if (workspace) params.workspace = workspace;\n if (pageSize) params.page_size = pageSize;\n if (pageToken) params.page_token = pageToken;\n\n try {\n const response: AxiosResponse<WorkspaceListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching workspaces\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching workspaces\", { cause: error });\n }\n};\n"],"mappings":";;AAKA,IAAM,UAAU;;;;;;;;;;;;AAahB,IAAa,eAAe,OAAO,KAAoB,SAAqC;CAC1F,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,iDAAiD;CAE5E,IAAI;EAEF,QAAO,MADwD,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,EAAA,CAC3E,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,kCAAkC,EAAE,OAAO,MAAM,CAAC;EAGrF,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,kCAAkC,EAAE,OAAO,MAAM,CAAC;CACpE;AACF;;;;;;;;;;;;;;AAeA,IAAa,iBAAiB,OAAO,KAAoB,WAAoB,UAAmB,cAAuD;CACrJ,MAAM,SAAoB,CAAC;CAE3B,IAAI,WAAW,OAAO,YAAY;CAClC,IAAI,UAAU,OAAO,YAAY;CACjC,IAAI,WAAW,OAAO,aAAa;CAEnC,IAAI;EAEF,QAAO,MADsD,IAAI,IAAI,SAAS,EAAE,OAAO,CAAC,EAAA,CACxE;CAClB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,mCAAmC,EAAE,OAAO,MAAM,CAAC;EAGtF,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,MAAM,CAAC;CACrE;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everysk/apps-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Shared runtime for Everysk client applications: EveryskApp, the contexts, entity slices, UI components and the MUI theme.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"everysk",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"react": "^19.2.7",
|
|
79
79
|
"react-dom": "^19.2.7",
|
|
80
80
|
"socket.io-client": "^4.8.3",
|
|
81
|
-
"vitest": "^
|
|
81
|
+
"vitest": "^5.0.1"
|
|
82
82
|
},
|
|
83
83
|
"peerDependenciesMeta": {
|
|
84
84
|
"@testing-library/jest-dom": {
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@emotion/react": "^11.14.0",
|
|
108
108
|
"@emotion/styled": "^11.14.1",
|
|
109
|
-
"@eslint/js": "^
|
|
109
|
+
"@eslint/js": "^10.0.1",
|
|
110
110
|
"@mui/material": "^9.0.1",
|
|
111
111
|
"@mui/x-date-pickers": "^9.3.0",
|
|
112
112
|
"@tanstack/react-query": "^5.101.0",
|
|
@@ -118,11 +118,11 @@
|
|
|
118
118
|
"@types/react": "^19.2.16",
|
|
119
119
|
"@types/react-dom": "^19.2.3",
|
|
120
120
|
"@vitejs/plugin-react": "^6.0.2",
|
|
121
|
-
"@vitest/coverage-v8": "^
|
|
121
|
+
"@vitest/coverage-v8": "^5.0.1",
|
|
122
122
|
"ag-grid-community": "^35.3.1",
|
|
123
123
|
"ag-grid-enterprise": "^35.3.1",
|
|
124
124
|
"axios": "^1.17.0",
|
|
125
|
-
"eslint": "^
|
|
125
|
+
"eslint": "^10.10.0",
|
|
126
126
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
127
127
|
"globals": "^17.6.0",
|
|
128
128
|
"jsdom": "^29.1.1",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"typescript": "^6.0.3",
|
|
134
134
|
"typescript-eslint": "^8.60.1",
|
|
135
135
|
"vite": "^8.0.16",
|
|
136
|
-
"vitest": "^
|
|
136
|
+
"vitest": "^5.0.1"
|
|
137
137
|
},
|
|
138
138
|
"publishConfig": {
|
|
139
139
|
"access": "public"
|
package/src/api/datastore.ts
CHANGED
|
@@ -28,14 +28,14 @@ export const getDatastore = async (api: AxiosInstance, id: string, workspace: st
|
|
|
28
28
|
return response.data.datastore;
|
|
29
29
|
} catch (error: unknown) {
|
|
30
30
|
if (isAxiosError<AnyRecord>(error)) {
|
|
31
|
-
throw new Error(error.message || "Error fetching datastore");
|
|
31
|
+
throw new Error(error.message || "Error fetching datastore", { cause: error });
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if (error instanceof Error) {
|
|
35
35
|
throw error;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
throw new Error("Error fetching datastore");
|
|
38
|
+
throw new Error("Error fetching datastore", { cause: error });
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
|
|
@@ -67,14 +67,14 @@ export const listDatastores = async (api: AxiosInstance, query: QueryObject): Pr
|
|
|
67
67
|
return response.data;
|
|
68
68
|
} catch (error: unknown) {
|
|
69
69
|
if (isAxiosError<AnyRecord>(error)) {
|
|
70
|
-
throw new Error(error.message || "Error listing datastores");
|
|
70
|
+
throw new Error(error.message || "Error listing datastores", { cause: error });
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
if (error instanceof Error) {
|
|
74
74
|
throw error;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
throw new Error("Error listing datastores");
|
|
77
|
+
throw new Error("Error listing datastores", { cause: error });
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
|
|
@@ -99,14 +99,14 @@ export const createDatastore = async (api: AxiosInstance, data: Partial<Datastor
|
|
|
99
99
|
return response.data.datastore;
|
|
100
100
|
} catch (error: unknown) {
|
|
101
101
|
if (isAxiosError<AnyRecord>(error)) {
|
|
102
|
-
throw new Error(error.message || "Error creating datastore");
|
|
102
|
+
throw new Error(error.message || "Error creating datastore", { cause: error });
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
if (error instanceof Error) {
|
|
106
106
|
throw error;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
throw new Error("Error creating datastore");
|
|
109
|
+
throw new Error("Error creating datastore", { cause: error });
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
|
|
@@ -132,14 +132,14 @@ export const updateDatastore = async (api: AxiosInstance, id: string, data: Part
|
|
|
132
132
|
return response.data.datastore;
|
|
133
133
|
} catch (error: unknown) {
|
|
134
134
|
if (isAxiosError<AnyRecord>(error)) {
|
|
135
|
-
throw new Error(error.message || "Error updating datastore");
|
|
135
|
+
throw new Error(error.message || "Error updating datastore", { cause: error });
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
if (error instanceof Error) {
|
|
139
139
|
throw error;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
throw new Error("Error updating datastore");
|
|
142
|
+
throw new Error("Error updating datastore", { cause: error });
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
|
|
@@ -163,13 +163,13 @@ export const deleteDatastore = async (api: AxiosInstance, id: string, workspace:
|
|
|
163
163
|
return response.data.datastores;
|
|
164
164
|
} catch (error: unknown) {
|
|
165
165
|
if (isAxiosError<AnyRecord>(error)) {
|
|
166
|
-
throw new Error(error.message || "Error removing datastore");
|
|
166
|
+
throw new Error(error.message || "Error removing datastore", { cause: error });
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
if (error instanceof Error) {
|
|
170
170
|
throw error;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
throw new Error("Error removing datastore");
|
|
173
|
+
throw new Error("Error removing datastore", { cause: error });
|
|
174
174
|
}
|
|
175
175
|
};
|
package/src/api/file.ts
CHANGED
|
@@ -26,14 +26,14 @@ export const getFile = async (api: AxiosInstance, id: string, workspace: string)
|
|
|
26
26
|
return response.data.file;
|
|
27
27
|
} catch (error: unknown) {
|
|
28
28
|
if (isAxiosError<AnyRecord>(error)) {
|
|
29
|
-
throw new Error(error.message || "Error while fetching file");
|
|
29
|
+
throw new Error(error.message || "Error while fetching file", { cause: error });
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
if (error instanceof Error) {
|
|
33
33
|
throw error;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
throw new Error("Error while fetching file");
|
|
36
|
+
throw new Error("Error while fetching file", { cause: error });
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -67,13 +67,13 @@ export const listFiles = async (api: AxiosInstance, query: QueryObject): Promise
|
|
|
67
67
|
return response.data;
|
|
68
68
|
} catch (error: unknown) {
|
|
69
69
|
if (isAxiosError<AnyRecord>(error)) {
|
|
70
|
-
throw new Error(error.message || "Error while fetching files");
|
|
70
|
+
throw new Error(error.message || "Error while fetching files", { cause: error });
|
|
71
71
|
}
|
|
72
72
|
if (error instanceof Error) {
|
|
73
73
|
throw error;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
throw new Error("Error while fetching files");
|
|
76
|
+
throw new Error("Error while fetching files", { cause: error });
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
|
|
@@ -98,14 +98,14 @@ export const createFile = async (api: AxiosInstance, data: Partial<EveryskFile>)
|
|
|
98
98
|
return response.data.file;
|
|
99
99
|
} catch (error: unknown) {
|
|
100
100
|
if (isAxiosError<AnyRecord>(error)) {
|
|
101
|
-
throw new Error(error.message || "Error while creating file");
|
|
101
|
+
throw new Error(error.message || "Error while creating file", { cause: error });
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
if (error instanceof Error) {
|
|
105
105
|
throw error;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
throw new Error("Error while creating file");
|
|
108
|
+
throw new Error("Error while creating file", { cause: error });
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
|
|
@@ -131,14 +131,14 @@ export const updateFile = async (api: AxiosInstance, id: string, data: Partial<E
|
|
|
131
131
|
return response.data.file;
|
|
132
132
|
} catch (error: unknown) {
|
|
133
133
|
if (isAxiosError<AnyRecord>(error)) {
|
|
134
|
-
throw new Error(error.message || "Error while updating file");
|
|
134
|
+
throw new Error(error.message || "Error while updating file", { cause: error });
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
if (error instanceof Error) {
|
|
138
138
|
throw error;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
throw new Error("Error while updating file");
|
|
141
|
+
throw new Error("Error while updating file", { cause: error });
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
144
|
|
|
@@ -162,13 +162,13 @@ export const deleteFile = async (api: AxiosInstance, id: string, workspace: stri
|
|
|
162
162
|
return response.data.files;
|
|
163
163
|
} catch (error: unknown) {
|
|
164
164
|
if (isAxiosError<AnyRecord>(error)) {
|
|
165
|
-
throw new Error(error.message || "Error while deleting file");
|
|
165
|
+
throw new Error(error.message || "Error while deleting file", { cause: error });
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
if (error instanceof Error) {
|
|
169
169
|
throw error;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
throw new Error("Error while deleting file");
|
|
172
|
+
throw new Error("Error while deleting file", { cause: error });
|
|
173
173
|
}
|
|
174
174
|
};
|
package/src/api/portfolio.ts
CHANGED
|
@@ -31,14 +31,14 @@ export const getPortfolio = async (api: AxiosInstance, id: string, workspace: st
|
|
|
31
31
|
return response.data;
|
|
32
32
|
} catch (error: unknown) {
|
|
33
33
|
if (isAxiosError<AnyRecord>(error)) {
|
|
34
|
-
throw new Error(error.message || "Error while fetching portfolio");
|
|
34
|
+
throw new Error(error.message || "Error while fetching portfolio", { cause: error });
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
if (error instanceof Error) {
|
|
38
38
|
throw error;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
throw new Error("Error while fetching portfolio");
|
|
41
|
+
throw new Error("Error while fetching portfolio", { cause: error });
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -71,14 +71,14 @@ export const listPortfolios = async (api: AxiosInstance, query: QueryObject): Pr
|
|
|
71
71
|
return response.data;
|
|
72
72
|
} catch (error: unknown) {
|
|
73
73
|
if (isAxiosError<AnyRecord>(error)) {
|
|
74
|
-
throw new Error(error.message || "Error while fetching portfolios");
|
|
74
|
+
throw new Error(error.message || "Error while fetching portfolios", { cause: error });
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
if (error instanceof Error) {
|
|
78
78
|
throw error;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
throw new Error("Error while fetching portfolios");
|
|
81
|
+
throw new Error("Error while fetching portfolios", { cause: error });
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -106,14 +106,14 @@ export const createPortfolio = async (api: AxiosInstance, data: Partial<Portfoli
|
|
|
106
106
|
return response.data;
|
|
107
107
|
} catch (error: unknown) {
|
|
108
108
|
if (isAxiosError<AnyRecord>(error)) {
|
|
109
|
-
throw new Error(error.message || "Error while creating portfolio");
|
|
109
|
+
throw new Error(error.message || "Error while creating portfolio", { cause: error });
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
if (error instanceof Error) {
|
|
113
113
|
throw error;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
throw new Error("Error while creating portfolio");
|
|
116
|
+
throw new Error("Error while creating portfolio", { cause: error });
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -142,14 +142,14 @@ export const updatePortfolio = async (api: AxiosInstance, id: string, data: Part
|
|
|
142
142
|
return response.data;
|
|
143
143
|
} catch (error: unknown) {
|
|
144
144
|
if (isAxiosError<AnyRecord>(error)) {
|
|
145
|
-
throw new Error(error.message || "Error while updating portfolio");
|
|
145
|
+
throw new Error(error.message || "Error while updating portfolio", { cause: error });
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
if (error instanceof Error) {
|
|
149
149
|
throw error;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
throw new Error("Error while updating portfolio");
|
|
152
|
+
throw new Error("Error while updating portfolio", { cause: error });
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -178,13 +178,13 @@ export const deletePortfolio = async (api: AxiosInstance, id: string, workspace:
|
|
|
178
178
|
return response.data;
|
|
179
179
|
} catch (error: unknown) {
|
|
180
180
|
if (isAxiosError<AnyRecord>(error)) {
|
|
181
|
-
throw new Error(error.message || "Error while deleting portfolio");
|
|
181
|
+
throw new Error(error.message || "Error while deleting portfolio", { cause: error });
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
if (error instanceof Error) {
|
|
185
185
|
throw error;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
throw new Error("Error while deleting portfolio");
|
|
188
|
+
throw new Error("Error while deleting portfolio", { cause: error });
|
|
189
189
|
}
|
|
190
190
|
}
|
package/src/api/profile.ts
CHANGED
|
@@ -68,13 +68,13 @@ export const getProfile = async (api: AxiosInstance, fallback?: Profile): Promis
|
|
|
68
68
|
return response.data.profile;
|
|
69
69
|
} catch (error: unknown) {
|
|
70
70
|
if (isAxiosError<AnyRecord>(error)) {
|
|
71
|
-
throw new Error(error.message || "Error while fetching profile");
|
|
71
|
+
throw new Error(error.message || "Error while fetching profile", { cause: error });
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
if (error instanceof Error) {
|
|
75
75
|
throw error;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
throw new Error("Error while fetching profile");
|
|
78
|
+
throw new Error("Error while fetching profile", { cause: error });
|
|
79
79
|
}
|
|
80
80
|
};
|
|
@@ -20,13 +20,13 @@ export const getWebsocketsConfig = async (api: AxiosInstance): Promise<Websocket
|
|
|
20
20
|
return response.data;
|
|
21
21
|
} catch (error: unknown) {
|
|
22
22
|
if (isAxiosError<AnyRecord>(error)) {
|
|
23
|
-
throw new Error(error.message || "Error fetching websockets config");
|
|
23
|
+
throw new Error(error.message || "Error fetching websockets config", { cause: error });
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (error instanceof Error) {
|
|
27
27
|
throw error;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
throw new Error("Error fetching websockets config");
|
|
30
|
+
throw new Error("Error fetching websockets config", { cause: error });
|
|
31
31
|
}
|
|
32
32
|
};
|
package/src/api/workflow.ts
CHANGED
|
@@ -38,14 +38,14 @@ export const runWorkflow = async (api: AxiosInstance, id: string, workspace: str
|
|
|
38
38
|
return response.data;
|
|
39
39
|
} catch (error: unknown) {
|
|
40
40
|
if (isAxiosError<AnyRecord>(error)) {
|
|
41
|
-
throw new Error(error.message || "");
|
|
41
|
+
throw new Error(error.message || "", { cause: error });
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
if (error instanceof Error) {
|
|
45
45
|
throw error;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
throw new Error("Error while running workflow");
|
|
48
|
+
throw new Error("Error while running workflow", { cause: error });
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
@@ -239,13 +239,13 @@ export const getWorkflow = async (api: AxiosInstance, id: string, workspace: str
|
|
|
239
239
|
return response.data.workflow;
|
|
240
240
|
} catch (error: unknown) {
|
|
241
241
|
if (isAxiosError<AnyRecord>(error)) {
|
|
242
|
-
throw new Error(error.message || "Error while fetching workflow");
|
|
242
|
+
throw new Error(error.message || "Error while fetching workflow", { cause: error });
|
|
243
243
|
}
|
|
244
244
|
if (error instanceof Error) {
|
|
245
245
|
throw error;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
throw new Error("Error while fetching workflow");
|
|
248
|
+
throw new Error("Error while fetching workflow", { cause: error });
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
251
|
|
|
@@ -271,14 +271,14 @@ export const listWorkflows = async (api: AxiosInstance, workspace?: string, page
|
|
|
271
271
|
return response.data;
|
|
272
272
|
} catch (error: unknown) {
|
|
273
273
|
if (isAxiosError<AnyRecord>(error)) {
|
|
274
|
-
throw new Error(error.message || "Error listing workflows");
|
|
274
|
+
throw new Error(error.message || "Error listing workflows", { cause: error });
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
if (error instanceof Error) {
|
|
278
278
|
throw error;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
throw new Error("Error listing workflows");
|
|
281
|
+
throw new Error("Error listing workflows", { cause: error });
|
|
282
282
|
}
|
|
283
283
|
};
|
|
284
284
|
|
|
@@ -304,14 +304,14 @@ export const getWorkflowExecution = async (api: AxiosInstance, workflowId: strin
|
|
|
304
304
|
return response.data.workflow_execution;
|
|
305
305
|
} catch (error: unknown) {
|
|
306
306
|
if (isAxiosError<AnyRecord>(error)) {
|
|
307
|
-
throw new Error(error.message || "Error fetching workflow execution");
|
|
307
|
+
throw new Error(error.message || "Error fetching workflow execution", { cause: error });
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
if (error instanceof Error) {
|
|
311
311
|
throw error;
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
throw new Error("Error fetching workflow execution");
|
|
314
|
+
throw new Error("Error fetching workflow execution", { cause: error });
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
|
|
@@ -342,14 +342,14 @@ export const listWorkflowExecutions = async (api: AxiosInstance, workflowId: str
|
|
|
342
342
|
return response.data;
|
|
343
343
|
} catch (error: unknown) {
|
|
344
344
|
if (isAxiosError<AnyRecord>(error)) {
|
|
345
|
-
throw new Error(error.message || "Error listing workflow executions");
|
|
345
|
+
throw new Error(error.message || "Error listing workflow executions", { cause: error });
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
if (error instanceof Error) {
|
|
349
349
|
throw error;
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
throw new Error("Error listing workflow executions");
|
|
352
|
+
throw new Error("Error listing workflow executions", { cause: error });
|
|
353
353
|
}
|
|
354
354
|
};
|
|
355
355
|
|
|
@@ -375,14 +375,14 @@ export const getWorkerExecution = async (api: AxiosInstance, workflowId: string,
|
|
|
375
375
|
return response.data.worker_execution;
|
|
376
376
|
} catch (error: unknown) {
|
|
377
377
|
if (isAxiosError<AnyRecord>(error)) {
|
|
378
|
-
throw new Error(error.message || "Error fetching worker execution");
|
|
378
|
+
throw new Error(error.message || "Error fetching worker execution", { cause: error });
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
if (error instanceof Error) {
|
|
382
382
|
throw error;
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
throw new Error("Error fetching worker execution");
|
|
385
|
+
throw new Error("Error fetching worker execution", { cause: error });
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
|
|
@@ -415,13 +415,13 @@ export const listWorkerExecutions = async (api: AxiosInstance, workflowId: strin
|
|
|
415
415
|
return response.data;
|
|
416
416
|
} catch (error: unknown) {
|
|
417
417
|
if (isAxiosError<AnyRecord>(error)) {
|
|
418
|
-
throw new Error(error.message || "Error listing worker executions");
|
|
418
|
+
throw new Error(error.message || "Error listing worker executions", { cause: error });
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
if (error instanceof Error) {
|
|
422
422
|
throw error;
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
throw new Error("Error listing worker executions");
|
|
425
|
+
throw new Error("Error listing worker executions", { cause: error });
|
|
426
426
|
}
|
|
427
427
|
};
|
package/src/api/workspace.ts
CHANGED
|
@@ -24,14 +24,14 @@ export const getWorkspace = async (api: AxiosInstance, name: string): Promise<Wo
|
|
|
24
24
|
return response.data.workspace;
|
|
25
25
|
} catch (error: unknown) {
|
|
26
26
|
if (isAxiosError<AnyRecord>(error)) {
|
|
27
|
-
throw new Error(error.message || "Error while fetching workspace");
|
|
27
|
+
throw new Error(error.message || "Error while fetching workspace", { cause: error });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
if (error instanceof Error) {
|
|
31
31
|
throw error;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
throw new Error("Error while fetching workspace");
|
|
34
|
+
throw new Error("Error while fetching workspace", { cause: error });
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -60,13 +60,13 @@ export const listWorkspaces = async (api: AxiosInstance, workspace?: string, pag
|
|
|
60
60
|
return response.data;
|
|
61
61
|
} catch (error: unknown) {
|
|
62
62
|
if (isAxiosError<AnyRecord>(error)) {
|
|
63
|
-
throw new Error(error.message || "Error while fetching workspaces");
|
|
63
|
+
throw new Error(error.message || "Error while fetching workspaces", { cause: error });
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
if (error instanceof Error) {
|
|
67
67
|
throw error;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
throw new Error("Error while fetching workspaces");
|
|
70
|
+
throw new Error("Error while fetching workspaces", { cause: error });
|
|
71
71
|
}
|
|
72
72
|
};
|