@ytsaurus/ui 1.21.0 → 1.22.1

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.
Files changed (55) hide show
  1. package/README.md +25 -8
  2. package/build/cjs/@types/core.d.ts +1 -1
  3. package/build/cjs/server/ServerFactory.d.ts +3 -0
  4. package/build/cjs/server/ServerFactory.js +3 -0
  5. package/build/cjs/server/ServerFactory.js.map +1 -1
  6. package/build/cjs/server/controllers/availability.js +36 -18
  7. package/build/cjs/server/controllers/availability.js.map +1 -1
  8. package/build/cjs/server/controllers/odin-proxy-api.js +3 -4
  9. package/build/cjs/server/controllers/odin-proxy-api.js.map +1 -1
  10. package/build/cjs/server/index.js +5 -0
  11. package/build/cjs/server/index.js.map +1 -1
  12. package/build/cjs/server/middlewares/check-configuration.d.ts +3 -0
  13. package/build/cjs/server/middlewares/check-configuration.js +28 -0
  14. package/build/cjs/server/middlewares/check-configuration.js.map +1 -0
  15. package/build/cjs/ui/pages/odin/_actions/odin-overview.js +1 -1
  16. package/build/cjs/ui/pages/odin/_actions/odin-overview.js.map +1 -1
  17. package/build/cjs/ui/pages/odin/controls/OdinToolbar.js +2 -1
  18. package/build/cjs/ui/pages/odin/controls/OdinToolbar.js.map +1 -1
  19. package/build/cjs/ui/pages/odin/odin-utils.d.ts +1 -1
  20. package/build/cjs/ui/pages/odin/odin-utils.js +2 -2
  21. package/build/cjs/ui/pages/odin/odin-utils.js.map +1 -1
  22. package/build/esm/@types/core.d.ts +1 -1
  23. package/build/esm/server/ServerFactory.d.ts +3 -0
  24. package/build/esm/server/ServerFactory.js +4 -0
  25. package/build/esm/server/ServerFactory.js.map +1 -1
  26. package/build/esm/server/controllers/availability.js +43 -23
  27. package/build/esm/server/controllers/availability.js.map +1 -1
  28. package/build/esm/server/controllers/odin-proxy-api.js +9 -10
  29. package/build/esm/server/controllers/odin-proxy-api.js.map +1 -1
  30. package/build/esm/server/index.js +5 -0
  31. package/build/esm/server/index.js.map +1 -1
  32. package/build/esm/server/middlewares/check-configuration.d.ts +3 -0
  33. package/build/esm/server/middlewares/check-configuration.js +20 -0
  34. package/build/esm/server/middlewares/check-configuration.js.map +1 -0
  35. package/build/esm/ui/pages/odin/_actions/odin-overview.js +1 -1
  36. package/build/esm/ui/pages/odin/_actions/odin-overview.js.map +1 -1
  37. package/build/esm/ui/pages/odin/controls/OdinToolbar.js +3 -2
  38. package/build/esm/ui/pages/odin/controls/OdinToolbar.js.map +1 -1
  39. package/build/esm/ui/pages/odin/odin-utils.d.ts +1 -1
  40. package/build/esm/ui/pages/odin/odin-utils.js +2 -2
  41. package/build/esm/ui/pages/odin/odin-utils.js.map +1 -1
  42. package/dist/public/build/assets-manifest.json +4 -4
  43. package/dist/public/build/js/main.724df837.js +3 -0
  44. package/dist/public/build/js/{main.53d3bdc5.js.map → main.724df837.js.map} +1 -1
  45. package/dist/public/build/manifest.json +2 -2
  46. package/dist/server/ServerFactory.d.ts +3 -0
  47. package/dist/server/ServerFactory.js +3 -0
  48. package/dist/server/controllers/availability.js +36 -18
  49. package/dist/server/controllers/odin-proxy-api.js +3 -4
  50. package/dist/server/index.js +5 -0
  51. package/dist/server/middlewares/check-configuration.d.ts +3 -0
  52. package/dist/server/middlewares/check-configuration.js +28 -0
  53. package/package.json +2 -2
  54. package/dist/public/build/js/main.53d3bdc5.js +0 -3
  55. /package/dist/public/build/js/{main.53d3bdc5.js.LICENSE.txt → main.724df837.js.LICENSE.txt} +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "main.css": "css/main.77009ada.css",
3
- "main.js": "js/main.53d3bdc5.js",
3
+ "main.js": "js/main.724df837.js",
4
4
  "runtime.js": "js/runtime.22e88c00.js",
5
5
  "css/861.c5a67589.chunk.css": "css/861.c5a67589.chunk.css",
6
6
  "js/861.a0939319.chunk.js": "js/861.a0939319.chunk.js",
@@ -52,7 +52,7 @@
52
52
  "assets/images/ui.jpg": "assets/images/ui.bab31938.jpg",
53
53
  "assets/images/cluster-2x.svg": "assets/images/cluster-2x.e53788d6.svg",
54
54
  "main.77009ada.css.map": "css/main.77009ada.css.map",
55
- "main.53d3bdc5.js.map": "js/main.53d3bdc5.js.map",
55
+ "main.724df837.js.map": "js/main.724df837.js.map",
56
56
  "runtime.22e88c00.js.map": "js/runtime.22e88c00.js.map",
57
57
  "861.c5a67589.chunk.css.map": "css/861.c5a67589.chunk.css.map",
58
58
  "861.a0939319.chunk.js.map": "js/861.a0939319.chunk.js.map",
@@ -8,6 +8,9 @@ export interface ServerFactory {
8
8
  renderLayout(params: AppLayoutConfig, req: Request, res: Response): Promise<string>;
9
9
  }
10
10
  export declare function rememberApp(v: ExpressKit): void;
11
+ /**
12
+ * @deprecated use req.ctx.config instead of App().config
13
+ */
11
14
  export declare function getApp(): ExpressKit;
12
15
  export declare function configureServerFactory(overrides: Partial<ServerFactory>): void;
13
16
  declare const _default: ServerFactory;
@@ -16,6 +16,9 @@ function rememberApp(v) {
16
16
  app = v;
17
17
  }
18
18
  exports.rememberApp = rememberApp;
19
+ /**
20
+ * @deprecated use req.ctx.config instead of App().config
21
+ */
19
22
  function getApp() {
20
23
  return app;
21
24
  }
@@ -8,7 +8,6 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const utils_1 = require("../components/utils");
10
10
  const utils_2 = require("../utils");
11
- const ServerFactory_1 = require("../ServerFactory");
12
11
  function getClusterAvailability(clusterConfig, odinPath) {
13
12
  const ODIN_PERIOD = 5;
14
13
  const ODIN_METRIC = 'master';
@@ -28,38 +27,57 @@ function getClusterAvailability(clusterConfig, odinPath) {
28
27
  return response.data;
29
28
  });
30
29
  }
31
- function getAvailability(req, clusters, odinPath) {
32
- const url = `${odinPath}/is_alive`;
33
- return axios_1.default
34
- .request({ url, responseType: 'json' })
35
- .then((res) => {
36
- if (res.data !== true) {
30
+ function getAvailability(req, clusters) {
31
+ const odinBaseUrl = req.ctx.config.odinBaseUrl;
32
+ const isMultiOdinBaseUrl = 'string' !== typeof odinBaseUrl;
33
+ const makeOdinIsAliveUrl = (odinBaseUrl) => `${odinBaseUrl}/is_alive`;
34
+ const commonIsAlive = isMultiOdinBaseUrl
35
+ ? Promise.resolve({ data: true })
36
+ : axios_1.default.request({ url: makeOdinIsAliveUrl(odinBaseUrl) });
37
+ return commonIsAlive
38
+ .then(({ data: commonAlive }) => {
39
+ if (!commonAlive) {
37
40
  return [];
38
41
  }
39
42
  return Promise.all(lodash_1.default.map(clusters, (clusterConfig) => {
40
- const id = clusterConfig.id;
41
- return getClusterAvailability(clusterConfig, odinPath)
42
- .then((availability) => ({ id, availability }))
43
- .catch((error) => {
44
- req.ctx.logError('getAvailability error', error);
45
- return { id };
43
+ const odinPath = isMultiOdinBaseUrl
44
+ ? odinBaseUrl === null || odinBaseUrl === void 0 ? void 0 : odinBaseUrl[clusterConfig.id]
45
+ : odinBaseUrl;
46
+ if (!odinPath) {
47
+ return {};
48
+ }
49
+ const alive = isMultiOdinBaseUrl
50
+ ? axios_1.default.get(makeOdinIsAliveUrl(odinPath)).catch((e) => {
51
+ req.ctx.logError(`Error of getting ${odinPath}`, e);
52
+ return { data: false };
53
+ })
54
+ : Promise.resolve({ data: true });
55
+ return alive.then(({ data }) => {
56
+ if (data != true) {
57
+ return {};
58
+ }
59
+ return getClusterAvailability(clusterConfig, odinPath)
60
+ .then((availability) => ({ id: clusterConfig.id, availability }))
61
+ .catch((error) => {
62
+ req.ctx.logError('getAvailability error', error);
63
+ return {};
64
+ });
46
65
  });
47
66
  }));
48
67
  })
49
68
  .catch((e) => {
50
- req.ctx.logError(`Error of getting ${url}`, e);
69
+ req.ctx.logError(`Error of getting ${odinBaseUrl}`, e);
51
70
  return [];
52
71
  });
53
72
  }
54
73
  async function getClustersAvailability(req, res) {
55
- var _a;
56
- const odinPath = (_a = (0, ServerFactory_1.getApp)().config) === null || _a === void 0 ? void 0 : _a.odinBaseUrl;
57
- if (!odinPath) {
74
+ const odinBaseUrl = req.ctx.config.odinBaseUrl;
75
+ if (!odinBaseUrl) {
58
76
  (0, utils_2.sendAndLogError)(req.ctx, res, 500, new Error('odin base url is not configured'));
59
77
  return;
60
78
  }
61
79
  const clusters = (0, utils_1.getClustersFromConfig)();
62
- await getAvailability(req, clusters, odinPath)
80
+ await getAvailability(req, clusters)
63
81
  .then((data) => (0, utils_2.sendResponse)(res, data))
64
82
  .catch((error) => (0, utils_2.sendError)(res, error));
65
83
  }
@@ -8,7 +8,6 @@ const lodash_1 = __importDefault(require("lodash"));
8
8
  const axios_1 = __importDefault(require("axios"));
9
9
  const qs_1 = __importDefault(require("qs"));
10
10
  const utils_1 = require("../utils");
11
- const ServerFactory_1 = require("../ServerFactory");
12
11
  async function odinProxyApi(req, res) {
13
12
  try {
14
13
  await odinProxyApiImpl(req, res);
@@ -23,14 +22,14 @@ async function odinProxyApi(req, res) {
23
22
  }
24
23
  exports.odinProxyApi = odinProxyApi;
25
24
  async function odinProxyApiImpl(req, res) {
26
- var _a;
27
- const odinPath = (_a = (0, ServerFactory_1.getApp)().config) === null || _a === void 0 ? void 0 : _a.odinBaseUrl;
25
+ const { action, ytAuthCluster: cluster } = req.params;
26
+ const { odinBaseUrl } = req.ctx.config;
27
+ const odinPath = typeof odinBaseUrl === 'string' ? odinBaseUrl : odinBaseUrl === null || odinBaseUrl === void 0 ? void 0 : odinBaseUrl[cluster];
28
28
  if (!odinPath) {
29
29
  return (0, utils_1.sendAndLogError)(req.ctx, res, 500, new Error('Odin base url is not configured'));
30
30
  }
31
31
  const { ctx, query } = req;
32
32
  const search = lodash_1.default.isEmpty(query) ? '' : `?${qs_1.default.stringify(query)}`;
33
- const { action, ytAuthCluster: cluster } = req.params;
34
33
  const allowedActionsUrls = {
35
34
  service_list: `${odinPath}/service_list`,
36
35
  exists: `${odinPath}/${action}/${cluster}`,
@@ -13,6 +13,7 @@ const routes_1 = __importDefault(require("./routes"));
13
13
  const oauth_1 = require("./middlewares/oauth");
14
14
  const authorization_1 = require("./middlewares/authorization");
15
15
  const authorization_2 = require("./utils/authorization");
16
+ const check_configuration_1 = require("./middlewares/check-configuration");
16
17
  const nodekit = new nodekit_1.NodeKit({ configsPath: path_1.default.resolve(__dirname, './configs') });
17
18
  const { appName, appEnv, appInstallation, appDevMode } = nodekit.config;
18
19
  nodekit.ctx.log('AppConfig details', {
@@ -37,6 +38,10 @@ if (authMiddlewares.length) {
37
38
  nodekit.config.appAuthHandler = (0, authorization_1.createAuthMiddleware)();
38
39
  }
39
40
  (_b = (_a = nodekit.config).adjustAppConfig) === null || _b === void 0 ? void 0 : _b.call(_a, nodekit);
41
+ const configurationErrors = (0, check_configuration_1.createConfigurationErrorsMidleware)(nodekit.config);
42
+ if (configurationErrors) {
43
+ nodekit.config.appBeforeAuthMiddleware = [configurationErrors];
44
+ }
40
45
  const app = new expresskit_1.ExpressKit(nodekit, routes_1.default);
41
46
  (0, configure_app_1.configureApp)(app);
42
47
  if (require.main === module) {
@@ -0,0 +1,3 @@
1
+ import { AppMiddleware } from '@gravity-ui/expresskit';
2
+ import { AppConfig } from '@gravity-ui/nodekit';
3
+ export declare function createConfigurationErrorsMidleware(config: AppConfig): AppMiddleware | undefined;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createConfigurationErrorsMidleware = void 0;
4
+ function checkConfigurationMiddleware(errors) {
5
+ return function checkConfiguration(_req, res) {
6
+ res.setHeader('Content-Type', 'text/html; charset=utf-8');
7
+ const body = `Please fix the problems below:<br>
8
+ <ol>
9
+ ${errors.map((i) => `<li>${i}</li>`).join('\n')}
10
+ </ol>
11
+ Please refer to the <a target='_blank' href='https://github.com/ytsaurus/ytsaurus-ui/tree/main/packages/ui#migration'>migration notices<a/> for more details.
12
+ `;
13
+ res.status(500).end(body);
14
+ };
15
+ }
16
+ function createConfigurationErrorsMidleware(config) {
17
+ const configurationErrors = [];
18
+ if (process.env.YT_AUTH_CLUSTER_ID) {
19
+ configurationErrors.push('The YT_AUTH_CLUSTER_ID environment variable is no longer supported, please replace it with ALLOW_PASSWORD_AUTH');
20
+ }
21
+ if ('ytAuthCluster' in config) {
22
+ configurationErrors.push('The config setting `config.ytAuthCluster` is no longer supported, please replace it with `config.allowPasswordAuth` or use ALLOW_PASSWORD_AUTH environment variable');
23
+ }
24
+ return configurationErrors.length > 0
25
+ ? checkConfigurationMiddleware([...configurationErrors])
26
+ : undefined;
27
+ }
28
+ exports.createConfigurationErrorsMidleware = createConfigurationErrorsMidleware;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ytsaurus/ui",
3
- "version": "1.21.0",
3
+ "version": "1.22.1",
4
4
  "repository": {
5
5
  "type": "github",
6
6
  "url": "https://github.com/YTsaurus/ytsaurus-ui/tree/main/packages/ui"
@@ -186,7 +186,7 @@
186
186
  "engines": {
187
187
  "node": ">=18"
188
188
  },
189
- "gitHead": "02a00348a20fe6173f4d11026d4dac02a3bdd468",
189
+ "gitHead": "0b406a4e7f0d5f7def958b64b92c278b6afa57eb",
190
190
  "overrides": {
191
191
  "react-split-pane": {
192
192
  "react": "$react",