@datarecce/ui 0.1.13 → 0.1.15
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/dist/hooks.d.mts +67 -2
- package/dist/hooks.d.ts +67 -2
- package/dist/hooks.js +72 -4
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +68 -4
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +78 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/hooks.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryClient, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
-
import
|
|
2
|
+
import axios2 from 'axios';
|
|
3
3
|
import React12, { createContext, forwardRef, useRef, useImperativeHandle, useMemo, useState, Fragment as Fragment$1, useContext, useCallback, useEffect } from 'react';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import '@mui/material/Alert';
|
|
@@ -76,7 +76,7 @@ var PUBLIC_API_URL = apiUrl;
|
|
|
76
76
|
process.env.NEXT_PUBLIC_CLOUD_WEB_URL;
|
|
77
77
|
|
|
78
78
|
// recce-source/js/src/lib/api/axiosClient.ts
|
|
79
|
-
var axiosClient =
|
|
79
|
+
var axiosClient = axios2.create({
|
|
80
80
|
baseURL: PUBLIC_API_URL
|
|
81
81
|
});
|
|
82
82
|
new QueryClient();
|
|
@@ -87,17 +87,81 @@ async function getRecceInstanceInfo(client = axiosClient) {
|
|
|
87
87
|
"/api/instance-info"
|
|
88
88
|
)).data;
|
|
89
89
|
}
|
|
90
|
+
var defaultConfig = {
|
|
91
|
+
apiPrefix: "",
|
|
92
|
+
authToken: void 0,
|
|
93
|
+
baseUrl: void 0
|
|
94
|
+
};
|
|
90
95
|
var ApiConfigContext = createContext(null);
|
|
96
|
+
function createApiClient(config) {
|
|
97
|
+
const { apiPrefix, authToken, baseUrl } = config;
|
|
98
|
+
const client = axios2.create({
|
|
99
|
+
baseURL: baseUrl ?? PUBLIC_API_URL
|
|
100
|
+
});
|
|
101
|
+
client.interceptors.request.use(
|
|
102
|
+
(requestConfig) => {
|
|
103
|
+
try {
|
|
104
|
+
if (apiPrefix && requestConfig.url) {
|
|
105
|
+
if (requestConfig.url === "/api") {
|
|
106
|
+
requestConfig.url = apiPrefix;
|
|
107
|
+
} else if (requestConfig.url.startsWith("/api/")) {
|
|
108
|
+
requestConfig.url = apiPrefix + requestConfig.url.slice(4);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (authToken) {
|
|
112
|
+
requestConfig.headers.Authorization = `Bearer ${authToken}`;
|
|
113
|
+
}
|
|
114
|
+
return requestConfig;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.warn(
|
|
117
|
+
"API request interceptor error, proceeding with unmodified request:",
|
|
118
|
+
error
|
|
119
|
+
);
|
|
120
|
+
return requestConfig;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
(error) => {
|
|
124
|
+
return Promise.reject(error);
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
return client;
|
|
128
|
+
}
|
|
129
|
+
function ApiConfigProvider({
|
|
130
|
+
children,
|
|
131
|
+
apiPrefix = defaultConfig.apiPrefix,
|
|
132
|
+
authToken = defaultConfig.authToken,
|
|
133
|
+
baseUrl = defaultConfig.baseUrl
|
|
134
|
+
}) {
|
|
135
|
+
const config = useMemo(
|
|
136
|
+
() => ({ apiPrefix, authToken, baseUrl }),
|
|
137
|
+
[apiPrefix, authToken, baseUrl]
|
|
138
|
+
);
|
|
139
|
+
const apiClient = useMemo(() => createApiClient(config), [config]);
|
|
140
|
+
const contextValue = useMemo(
|
|
141
|
+
() => ({
|
|
142
|
+
...config,
|
|
143
|
+
apiClient
|
|
144
|
+
}),
|
|
145
|
+
[config, apiClient]
|
|
146
|
+
);
|
|
147
|
+
return /* @__PURE__ */ jsx(ApiConfigContext.Provider, { value: contextValue, children });
|
|
148
|
+
}
|
|
91
149
|
var defaultApiConfigContext = {
|
|
92
150
|
apiPrefix: "",
|
|
93
151
|
authToken: void 0,
|
|
94
152
|
baseUrl: void 0,
|
|
95
|
-
apiClient:
|
|
153
|
+
apiClient: axios2.create({ baseURL: PUBLIC_API_URL })
|
|
96
154
|
};
|
|
97
155
|
function useApiConfig() {
|
|
98
156
|
const context = useContext(ApiConfigContext);
|
|
99
157
|
return context ?? defaultApiConfigContext;
|
|
100
158
|
}
|
|
159
|
+
function useApiClient() {
|
|
160
|
+
return useApiConfig().apiClient;
|
|
161
|
+
}
|
|
162
|
+
function useApiConfigSafe() {
|
|
163
|
+
return useContext(ApiConfigContext);
|
|
164
|
+
}
|
|
101
165
|
|
|
102
166
|
// recce-source/js/src/lib/hooks/useRecceInstanceInfo.tsx
|
|
103
167
|
var useRecceInstanceInfo = () => {
|
|
@@ -7453,6 +7517,6 @@ function RecceContextProvider({ children }) {
|
|
|
7453
7517
|
return /* @__PURE__ */ jsx(RecceInstanceInfoProvider, { children: /* @__PURE__ */ jsx(RecceShareStateContextProvider, { children: /* @__PURE__ */ jsx(RecceQueryContextProvider, { children: /* @__PURE__ */ jsx(LineageGraphContextProvider, { children: /* @__PURE__ */ jsx(RowCountStateContextProvider, { children: /* @__PURE__ */ jsx(RecceActionContextProvider, { children: /* @__PURE__ */ jsx(RecceCheckContextProvider, { children }) }) }) }) }) }) });
|
|
7454
7518
|
}
|
|
7455
7519
|
|
|
7456
|
-
export { IdleTimeoutProvider, LineageGraphContextProvider, RecceActionContextProvider, RecceCheckContextProvider, RecceContextProvider, RecceInstanceInfoProvider, RecceQueryContextProvider, RecceShareStateContextProvider, RowCountStateContextProvider, useCheckToast, useClipBoardToast, useIdleTimeout, useLineageGraphContext, useLineageViewContext, useRecceActionContext, useRecceCheckContext, useRecceInstanceContext, useRecceInstanceInfo, useRecceQueryContext, useRecceShareStateContext, useRowCountStateContext, useRunsAggregated, useValueDiffAlertDialog_default as useValueDiffAlertDialog };
|
|
7520
|
+
export { ApiConfigProvider, IdleTimeoutProvider, LineageGraphContextProvider, RecceActionContextProvider, RecceCheckContextProvider, RecceContextProvider, RecceInstanceInfoProvider, RecceQueryContextProvider, RecceShareStateContextProvider, RowCountStateContextProvider, useApiClient, useApiConfig, useApiConfigSafe, useCheckToast, useClipBoardToast, useIdleTimeout, useLineageGraphContext, useLineageViewContext, useRecceActionContext, useRecceCheckContext, useRecceInstanceContext, useRecceInstanceInfo, useRecceQueryContext, useRecceShareStateContext, useRowCountStateContext, useRunsAggregated, useValueDiffAlertDialog_default as useValueDiffAlertDialog };
|
|
7457
7521
|
//# sourceMappingURL=hooks.mjs.map
|
|
7458
7522
|
//# sourceMappingURL=hooks.mjs.map
|