@redhat-cloud-services/frontend-components-config-utilities 3.2.7 → 4.0.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 (59) hide show
  1. package/babel-transform-imports.js.map +1 -1
  2. package/cookieTransform.d.ts +0 -1
  3. package/cookieTransform.js +5 -1
  4. package/cookieTransform.js.map +1 -1
  5. package/extension-mapper.js.map +1 -1
  6. package/extensions-plugin.js.map +1 -1
  7. package/fec-logger.js.map +1 -1
  8. package/federated-modules.js.map +1 -1
  9. package/generate-pf-shared-assets-list.js.map +1 -1
  10. package/index.js.map +1 -1
  11. package/jsVarName.js.map +1 -1
  12. package/package.json +39 -38
  13. package/proxy.d.ts +1 -1
  14. package/proxy.js +16 -120
  15. package/proxy.js.map +1 -1
  16. package/search-ignored-styles.js.map +1 -1
  17. package/serve-federated.js.map +1 -1
  18. package/serveLocalFile.js.map +1 -1
  19. package/README.md +0 -198
  20. package/standalone/helpers/checkout.d.ts +0 -5
  21. package/standalone/helpers/checkout.js +0 -72
  22. package/standalone/helpers/checkout.js.map +0 -1
  23. package/standalone/helpers/index.d.ts +0 -8
  24. package/standalone/helpers/index.js +0 -58
  25. package/standalone/helpers/index.js.map +0 -1
  26. package/standalone/helpers/router.d.ts +0 -3
  27. package/standalone/helpers/router.js +0 -20
  28. package/standalone/helpers/router.js.map +0 -1
  29. package/standalone/index.d.ts +0 -1
  30. package/standalone/index.js +0 -18
  31. package/standalone/index.js.map +0 -1
  32. package/standalone/services/backofficeProxy.d.ts +0 -7
  33. package/standalone/services/backofficeProxy.js +0 -55
  34. package/standalone/services/backofficeProxy.js.map +0 -1
  35. package/standalone/services/default/chrome.d.ts +0 -24
  36. package/standalone/services/default/chrome.js +0 -141
  37. package/standalone/services/default/chrome.js.map +0 -1
  38. package/standalone/services/default/config.d.ts +0 -13
  39. package/standalone/services/default/config.js +0 -16
  40. package/standalone/services/default/config.js.map +0 -1
  41. package/standalone/services/default/entitlements.d.ts +0 -19
  42. package/standalone/services/default/entitlements.js +0 -46
  43. package/standalone/services/default/entitlements.js.map +0 -1
  44. package/standalone/services/default/index.d.ts +0 -56
  45. package/standalone/services/default/index.js +0 -16
  46. package/standalone/services/default/index.js.map +0 -1
  47. package/standalone/services/default/keycloak/realm_export.json +0 -4879
  48. package/standalone/services/default/landing.d.ts +0 -14
  49. package/standalone/services/default/landing.js +0 -21
  50. package/standalone/services/default/landing.js.map +0 -1
  51. package/standalone/services/index.d.ts +0 -91
  52. package/standalone/services/index.js +0 -14
  53. package/standalone/services/index.js.map +0 -1
  54. package/standalone/services/rbac.d.ts +0 -29
  55. package/standalone/services/rbac.js +0 -66
  56. package/standalone/services/rbac.js.map +0 -1
  57. package/standalone/startService.d.ts +0 -13
  58. package/standalone/startService.js +0 -86
  59. package/standalone/startService.js.map +0 -1
package/README.md DELETED
@@ -1,198 +0,0 @@
1
- # RedHat Cloud Services frontend components - webpack config utilities
2
-
3
- [![npm version](https://badge.fury.io/js/%40redhat-cloud-services%2Ffrontend-components-config-utilities.svg)](https://badge.fury.io/js/%40redhat-cloud-services%2Ffrontend-components-config-utilities)
4
-
5
- - [RedHat Cloud Services frontend components - webpack config utilities](#redhat-cloud-services-frontend-components---webpack-config-utilities)
6
- - [Chrome render loader](#chrome-render-loader)
7
- - [Disable chrome 2](#disable-chrome-2)
8
- - [Chunk mapper](#chunk-mapper)
9
- - [Federated modules](#federated-modules)
10
- - [Override container ports](#override-container-ports)
11
- - [List of shared deps](#list-of-shared-deps)
12
- - [Extensions plugin](#extensions-plugin)
13
- - [Arguments](#arguments)
14
- - [`pluginConfig`](#pluginconfig)
15
- - [extension object](#extension-object)
16
-
17
- ## Chrome render loader
18
-
19
- When using chrome 2 and user refreshes a page on your application you may end up with 2 instances of your application in virtual DOM. This loader prevents it by wrapping your app in condition to check if chrome 2 config is enabled.
20
-
21
- The appName should be same as is `insights.appname` in your `package.json`.
22
-
23
- ```JS
24
- {
25
- module: {
26
- rules: [{
27
- test: new RegExp(appEntry),
28
- loader: path.resolve(__dirname, './chrome-render-loader.js'),
29
- options: {
30
- appName: 'name-of-your-app',
31
- }
32
- }]
33
- }
34
- }
35
- ```
36
-
37
- ### Disable chrome 2
38
-
39
- When migrating application to chrome 2 you may want to disable this for some time, otherwise you'll have to sync pushes to all branches with [CSC](https://github.com/RedHatInsights/cloud-services-config).
40
-
41
- ```JS
42
- {
43
- module: {
44
- rules: [{
45
- test: new RegExp(appEntry),
46
- loader: '@redhat-cloud-services/frontend-components-config-utilities/chrome-render-loader',
47
- options: {
48
- appName: 'name-of-your-app',
49
- skipChrome2: true
50
- }
51
- }]
52
- }
53
- }
54
- ```
55
-
56
- ## Chunk mapper
57
-
58
- To properly load files in chrome 2 you have to generate mapper to each exported chunk. This webpack plugin will do that for you.
59
-
60
- ```JS
61
- const ChunkMapper = require('@redhat-cloud-services/frontend-components-config-utilities/chunk-mapper');
62
-
63
- {
64
- plugins: [
65
- new ChunkMapper({
66
- // prefix: '/some-path/', // optional - defaults to output.publicPath
67
- modules: [], //required
68
- })
69
- ]
70
- }
71
- ```
72
-
73
- * `prefix` - if you have your federated modules files located under some different path than `output.publicPath`
74
- * `modules` - either string or an array of strings to indicate which generated files should be picked up (generally your `insights.appname` - if you have dashes in your name replace them with cammel case)
75
-
76
- ## Federated modules
77
- If you don't want to dig trough webpack's [module-federation/](https://webpack.js.org/concepts/module-federation/) and write custom generator you can use this wrapper.
78
-
79
- ```JS
80
- plugins.push(
81
- require('@redhat-cloud-services/frontend-components-config/federated-modules')({
82
- root: resolve(__dirname, '../'),
83
- // exposes: { './RootApp': './src/AppEntry.js' },
84
- // shared: [{ react: { singleton: true, requiredVersion: 17.0.0 } }],
85
- // debug: true,
86
- // moduleName: 'someAppName',
87
- // useFileHash: false,
88
- // exclude: ['react']
89
- })
90
- );
91
- ```
92
-
93
- We've aimed for easy plug and play, but feel free to override any fed mods partials with these arguments:
94
-
95
- * `root` - root of you application (to find out `package.json`)
96
- * `exposes` - which files and modules should be exposed
97
- * `shared` - federated modules allow for sharing of dependencies, we've added some general dependencies, but feel free to expand them via this prop
98
- * `debug` - to see full output what is going to be used
99
- * `moduleName` - used to generate the file under this name (generally your `insights.appname` - if you have dashes in your name replace them with cammel case)
100
- * `useFileHash` - in order to prevent caching we are using file hashes, you might want to turn this off in your dev env
101
- * `exclude` - if you want to exclude any shared module you can do it trough here (even for general dependencies added by us)
102
- * `eager` - if set to `true`, turns eager fetch for shared modules on
103
-
104
- ### Override container ports
105
- The default ports for the RBAC server(**4012**) and/or the Keycloak server(**4001**) can be overridden using a corresponding variable in the environment.
106
-
107
- Bash examples:
108
-
109
- export KEYCLOAK_PORT=4020
110
- export RBAC_PORT=5000
111
-
112
-
113
- #### List of shared deps
114
-
115
- This packages exposes these federated shared dependencies
116
- * `lodash` - version taken from your `package.json`
117
- * `axios` - version taken from your `package.json`
118
- * `redux` - version taken from your `package.json`
119
- * `react` - version taken from your `package.json`, treated as singleton
120
- * `react-dom` - version taken from your `package.json`, treated as singleton
121
- * `react-router-dom` - version taken from your `package.json`
122
- * `react-redux` - version taken from your `package.json`
123
- * `redux-promise-middleware` - version taken from your `package.json`
124
- * `@patternfly/react-table` - version taken from your `package.json`
125
- * `@patternfly/react-core` - version taken from your `package.json`
126
- * `@patternfly/react-icons` - version taken from your `package.json`
127
- * `@patternfly/react-tokens` - version taken from your `package.json`
128
- * `@redhat-cloud-services/frontend-components` - version taken from your `package.json`
129
- * `@redhat-cloud-services/frontend-components-utilities` - version taken from your `package.json`
130
- * `@redhat-cloud-services/frontend-components-notifications` - version taken from your `package.json`
131
-
132
- ## Extensions plugin
133
-
134
- In order to share some code into extension points or to add new extension point we can use `ExtensionsPlugin`
135
-
136
- Simply import it in your webpack config and add it to your plugins
137
-
138
- ```JS
139
- const { resolve } = require('path');
140
- const config = require('@redhat-cloud-services/frontend-components-config');
141
- const ExtensionsPlugin = require('@redhat-cloud-services/frontend-components-config/extensions-plugin');
142
-
143
- const { config: webpackConfig, plugins } = config({
144
- rootFolder: resolve(__dirname, '../'),
145
- ...(process.env.BETA && { deployment: 'beta/apps' }),
146
- });
147
-
148
- plugins.push(
149
- require('@redhat-cloud-services/frontend-components-config/federated-modules')({
150
- root: resolve(__dirname, '../'),
151
- }),
152
- new ExtensionsPlugin({})
153
- );
154
-
155
- module.exports = {
156
- ...webpackConfig,
157
- plugins
158
- }
159
- ```
160
-
161
- ### Arguments
162
-
163
- There are three arguments `ExtensionsPlugin` constructor accepts:
164
- * `pluginConfig`
165
- * `fedModuleConfig`
166
- * `options`
167
-
168
- ### `pluginConfig`
169
-
170
- This config contains information about extensions, plugin requirements, its name and description. Most of it (name, description and version) is calculated from your root `package.json`. But you can override these values:
171
-
172
- * `name` - plugin name (pulled from `package.json`)
173
- * `version` - version of the plugin
174
- * `displayName` - display name of the plugin
175
- * `description` - description of the plugin (pulled from `package.json`)
176
- * `dependencies` - object of dependencies which will be passed down to module federation (no need to list general react dependencies)
177
- * `disableStaticPlugins` - list of static plugins this plugin disables on load
178
- * `extensions` - list of extension objects.
179
-
180
- #### extension object
181
-
182
- Each extension object requires a `type` and `properties`. The type can be either custom extension or one of predefined:
183
-
184
- * `console.navigation/section` - a section in navigation (identifies secondary nav)
185
- * `properties`
186
- * `id` - id of the section
187
- * `name` - name of the section, this will be shown in the UI
188
- * `console.page/route` - route passed to react-router
189
- * `properties` - in theory any react-router path prop can be used here
190
- * `path` - (string, or array) path on which the component will be rendered
191
- * `component`
192
- * `$codeRef` - federated module used to render on the route
193
- * `console.navigation/href` - navigation href, used to render leafs of navigation
194
- * `properties`
195
- * `id` - id of the href
196
- * `section` - (optional) used to group nav items under section (omit for flat nav)
197
- * `name` - name of the href, thiw will be shown in the UI
198
- * `href` - used to mutate the URL
@@ -1,5 +0,0 @@
1
- export declare function checkoutRepo({ repo, reposDir, overwrite }: {
2
- repo: string;
3
- reposDir: string;
4
- overwrite?: boolean;
5
- }): string;
@@ -1,72 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.checkoutRepo = void 0;
30
- var path_1 = __importDefault(require("path"));
31
- var fs_1 = __importDefault(require("fs"));
32
- var child_process = __importStar(require("child_process"));
33
- var execSync = child_process.execSync;
34
- function checkoutRepo(_a) {
35
- var repo = _a.repo, reposDir = _a.reposDir, overwrite = _a.overwrite;
36
- if (!fs_1.default.existsSync(reposDir)) {
37
- console.log('Making repos dir', reposDir);
38
- fs_1.default.mkdirSync(reposDir);
39
- }
40
- var _b = repo.split('#'), remote = _b[0], _c = _b[1], branch = _c === void 0 ? 'master' : _c;
41
- if (remote.includes('insights-chrome-build') && branch.includes('stage-')) {
42
- branch = branch.replace('stage-', 'qa-');
43
- }
44
- var split = remote.split('/');
45
- var toDir = split[split.length - 1];
46
- var repoPath = path_1.default.join(reposDir, toDir);
47
- if (!fs_1.default.existsSync(repoPath)) {
48
- console.log('cloning', branch, 'branch of', remote);
49
- execSync("git clone --depth 1 --branch ".concat(branch, " ").concat(remote), { cwd: reposDir });
50
- }
51
- else if (overwrite) {
52
- console.log('checking out', branch, 'branch of', remote);
53
- try {
54
- execSync("git fetch --depth 1 origin --force ".concat(branch, ":refs/remotes/origin/").concat(branch), { cwd: repoPath });
55
- }
56
- catch (e) {
57
- console.error("Could not fetch remote, maybe you're offline?", e.toString());
58
- }
59
- try {
60
- execSync("git checkout -B ".concat(branch, " origin/").concat(branch), { cwd: repoPath });
61
- }
62
- catch (e) {
63
- console.error("Could not checkout ".concat(branch, ", maybe you're offline and haven't fetched it before?"), e.toString());
64
- }
65
- }
66
- else {
67
- console.log('skipping', branch, 'branch of', repo, "since its user-managed. you'll have to checkout the correct code yourself");
68
- }
69
- return repoPath;
70
- }
71
- exports.checkoutRepo = checkoutRepo;
72
- //# sourceMappingURL=checkout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/standalone/helpers/checkout.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAAwB;AACxB,0CAAoB;AACpB,2DAA+C;AACvC,IAAA,QAAQ,GAAK,aAAa,SAAlB,CAAmB;AAEnC,SAAgB,YAAY,CAAC,EAAsF;QAApF,IAAI,UAAA,EAAE,QAAQ,cAAA,EAAE,SAAS,eAAA;IACtD,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAC1C,YAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;KACxB;IAGG,IAAA,KAA8B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAA5C,MAAM,QAAA,EAAE,UAAiB,EAAjB,MAAM,mBAAG,QAAQ,KAAmB,CAAC;IAMlD,IAAI,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAC,IAAI,MAAM,CAAC,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AAM,EAAE,WAAW,EAAE,IAAI,EAAE,2EAA2E,CAAC,CAAC;KACjI;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAzCD,oCAyCC"}
@@ -1,8 +0,0 @@
1
- export declare function getExposedPorts(args: string | string[]): number[] | null;
2
- export declare function getExposedPort(args: any | any[]): number | null;
3
- export declare function isGitUrl(pathOrUrl: string): boolean;
4
- export declare function resolvePath(reposDir: string, pathOrUrl: string): string;
5
- export declare function getConfig(standalone: boolean | Record<string, any>, localChrome?: string, env?: string, port?: number): {
6
- [key: string]: any;
7
- };
8
- export declare const NET = "clouddot_net";
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NET = exports.getConfig = exports.resolvePath = exports.isGitUrl = exports.getExposedPort = exports.getExposedPorts = void 0;
7
- var path_1 = __importDefault(require("path"));
8
- var default_1 = __importDefault(require("../services/default"));
9
- function getExposedPorts(args) {
10
- if (!Array.isArray(args)) {
11
- return null;
12
- }
13
- var portArg = args
14
- .filter(function (arg) { return typeof arg === 'string'; })
15
- .map(function (arg) { return arg.trimStart(); })
16
- .find(function (arg) { return arg.startsWith('-p'); });
17
- if (portArg) {
18
- var matches = Array.from(portArg.matchAll(/(\d+):/g));
19
- if (matches.length > 0) {
20
- return matches.map(function (match) { return Number(match[1]); }).filter(function (port) { return !isNaN(port); });
21
- }
22
- }
23
- return null;
24
- }
25
- exports.getExposedPorts = getExposedPorts;
26
- function getExposedPort(args) {
27
- var ports = getExposedPorts(args);
28
- if (ports) {
29
- return ports[0];
30
- }
31
- return null;
32
- }
33
- exports.getExposedPort = getExposedPort;
34
- function isGitUrl(pathOrUrl) {
35
- return /(https?:\/\/|git@)/.test(pathOrUrl);
36
- }
37
- exports.isGitUrl = isGitUrl;
38
- function resolvePath(reposDir, pathOrUrl) {
39
- var split = pathOrUrl.split('/');
40
- return isGitUrl(pathOrUrl) ? path_1.default.join(reposDir, split[split.length - 1]) : pathOrUrl;
41
- }
42
- exports.resolvePath = resolvePath;
43
- function getConfig(standalone, localChrome, env, port) {
44
- var res = typeof standalone === 'object' ? standalone : default_1.default;
45
- Object.keys(res || {})
46
- .filter(function (key) { return typeof res[key] === 'function'; })
47
- .forEach(function (key) { return (res[key] = res[key]({ env: env, port: port })); });
48
- if (localChrome && typeof standalone === 'object') {
49
- standalone.chrome.path = localChrome;
50
- }
51
- if (res.chrome && !res.chrome.keycloakUri.includes('localhost')) {
52
- delete res.chrome.services;
53
- }
54
- return res;
55
- }
56
- exports.getConfig = getConfig;
57
- exports.NET = 'clouddot_net';
58
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/standalone/helpers/index.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAwB;AACxB,gEAAkD;AAIlD,SAAgB,eAAe,CAAC,IAAuB;IACrD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IACD,IAAM,OAAO,GAAuB,IAAI;SACrC,MAAM,CAAC,UAAC,GAAG,IAAK,OAAA,OAAO,GAAG,KAAK,QAAQ,EAAvB,CAAuB,CAAC;SACxC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,SAAS,EAAE,EAAf,CAAe,CAAC;SAC7B,IAAI,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC,CAAC;IACvC,IAAI,OAAO,EAAE;QACX,IAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACxD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACtB,OAAO,OAAO,CAAC,GAAG,CAAC,UAAC,KAAK,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IAAK,OAAA,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,KAAA,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC,EAApC,CAAoC,CAAC,CAAC;IAG1D,IAAI,WAAW,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QACjD,UAAU,CAAC,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC;KACtC;IAGD,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QAC/D,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;KAC5B;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAnBD,8BAmBC;AAEY,QAAA,GAAG,GAAG,cAAc,CAAC"}
@@ -1,3 +0,0 @@
1
- type Router = import('http-proxy-middleware').Options['router'];
2
- declare const router: (target: string, useCloud: boolean) => Router;
3
- export default router;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var router = function (target, useCloud) {
4
- return function (req) {
5
- switch (req.hostname) {
6
- case 'ci.foo.redhat.com':
7
- return "https://ci.".concat(useCloud ? 'cloud' : 'console', ".redhat.com/");
8
- case 'qa.foo.redhat.com':
9
- return "https://qa.".concat(useCloud ? 'cloud' : 'console', ".redhat.com/");
10
- case 'stage.foo.redhat.com':
11
- return "https://".concat(useCloud ? 'cloud' : 'console', ".stage.redhat.com/");
12
- case 'prod.foo.redhat.com':
13
- return "https://".concat(useCloud ? 'cloud' : 'console', ".redhat.com/");
14
- default:
15
- return target;
16
- }
17
- };
18
- };
19
- exports.default = router;
20
- //# sourceMappingURL=router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/standalone/helpers/router.ts"],"names":[],"mappings":";;AAIA,IAAM,MAAM,GAAkD,UAAC,MAAc,EAAE,QAAkB;IAC/F,OAAO,UAAC,GAAY;QAClB,QAAQ,GAAG,CAAC,QAAQ,EAAE;YACpB,KAAK,mBAAmB;gBACtB,OAAO,qBAAc,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,iBAAc,CAAC;YACpE,KAAK,mBAAmB;gBACtB,OAAO,qBAAc,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,iBAAc,CAAC;YACpE,KAAK,sBAAsB;gBACzB,OAAO,kBAAW,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,uBAAoB,CAAC;YACvE,KAAK,qBAAqB;gBACxB,OAAO,kBAAW,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,iBAAc,CAAC;YACjE;gBACE,OAAO,MAAM,CAAC;SACjB;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
@@ -1 +0,0 @@
1
- export * from './services';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./services"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/standalone/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
@@ -1,7 +0,0 @@
1
- import express from 'express';
2
- declare const backOfficeProxy: {
3
- register({ app }: {
4
- app: express.Application;
5
- }): void;
6
- };
7
- export default backOfficeProxy;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var express_1 = __importDefault(require("express"));
7
- var realm_export_json_1 = __importDefault(require("./default/keycloak/realm_export.json"));
8
- var internalRealms = realm_export_json_1.default;
9
- var users = internalRealms === null || internalRealms === void 0 ? void 0 : internalRealms.find(function (f) { return f.id === 'redhat-external'; }).users;
10
- var backOfficeProxy = {
11
- register: function (_a) {
12
- var app = _a.app;
13
- app.get('/api/insights-services', function (_, res) { return res.json({ message: 'success' }); });
14
- app.use('/api/insights-services/v1', express_1.default.json());
15
- app.post('/api/insights-services/v1/sendEmails', function (req, res) {
16
- if (!req.body.emails || !Array.isArray(req.body.emails) || req.body.emails.length === 0) {
17
- res.status(400).json('Missing emails field');
18
- }
19
- console.log('mocking sending', req.body.emails.length, 'emails');
20
- res.json({ message: 'success' });
21
- });
22
- app.post('/api/insights-services/v1/users', function (req, res) {
23
- var queryBy = req.query.queryBy && req.query.queryBy === 'userId' ? 'userId' : 'principal';
24
- if (queryBy !== 'userId') {
25
- console.log(1);
26
- res.status(400).json({ message: 'idk how to query by principal' });
27
- }
28
- if (!(req.body && Array.isArray(req.body.users) && req.body.users.length > 0)) {
29
- console.log(2, req.body);
30
- res.status(400).json({ message: 'must include users to query' });
31
- }
32
- var filteredUsers = users
33
- .filter(function (u) { return req.body.users.includes(u.attributes.account_id[0]); })
34
- .map(function (u) { return ({
35
- id: +u.attributes.account_id[0],
36
- username: u.username,
37
- email: u.email,
38
- first_name: u.firstName,
39
- last_name: u.lastName,
40
- account_number: u.attributes.account_number[0],
41
- address_string: "".concat(u.username, "'s address that isn't in keycloak"),
42
- is_active: true,
43
- is_org_admin: u.attributes.is_org_admin[0] === 'true',
44
- is_internal: u.attributes.is_internal[0] === 'true',
45
- locale: 'en_US',
46
- org_id: +u.attributes.org_id[0],
47
- display_name: 'Display name?',
48
- type: 'system',
49
- }); });
50
- res.json(filteredUsers);
51
- });
52
- },
53
- };
54
- exports.default = backOfficeProxy;
55
- //# sourceMappingURL=backofficeProxy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"backofficeProxy.js","sourceRoot":"","sources":["../../src/standalone/services/backofficeProxy.ts"],"names":[],"mappings":";;;;;AAAA,oDAA8B;AAC9B,2FAA0D;AAC1D,IAAM,cAAc,GAAmC,2BAAM,CAAC;AAE9D,IAAM,KAAK,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAE,KAAK,iBAAiB,EAA1B,CAA0B,EAAE,KAAK,CAAC;AAI5E,IAAM,eAAe,GAAG;IACtB,QAAQ,YAAC,EAAqC;YAAnC,GAAG,SAAA;QACZ,GAAG,CAAC,GAAG,CAAC,wBAAwB,EAAE,UAAC,CAAC,EAAE,GAAG,IAAK,OAAA,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAhC,CAAgC,CAAC,CAAC;QAChF,GAAG,CAAC,GAAG,CAAC,2BAA2B,EAAE,iBAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACrD,GAAG,CAAC,IAAI,CAAC,sCAAsC,EAAE,UAAC,GAAG,EAAE,GAAG;YACxD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;gBACvF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,C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E,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC;gBACX,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;gBAC/B,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,UAAU,EAAE,CAAC,CAAC,SAAS;gBACvB,SAAS,EAAE,CAAC,CAAC,QAAQ;gBACrB,cAAc,EAAE,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;gBAC9C,cAAc,EAAE,UAAG,CAAC,CAAC,QAAQ,sCAAmC;gBAChE,SAAS,EAAE,IAAI;gBACf,YAAY,EAAE,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,MAAM;gBACrD,WAAW,EAAE,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,MAAM;gBACnD,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC/B,YAAY,EAAE,eAAe;gBAC7B,IAAI,EAAE,QAAQ;aACf,CAAC,EAfU,CAeV,CAAC,CAAC;YAEN,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,kBAAe,eAAe,CAAC"}
@@ -1,24 +0,0 @@
1
- import path from 'path';
2
- import { Application } from 'express';
3
- declare const _default: ({ port }: {
4
- path?: string | undefined;
5
- port?: number | undefined;
6
- }) => {
7
- services: {
8
- keycloak: {
9
- args: string[];
10
- };
11
- };
12
- path: string;
13
- keycloakUri: string;
14
- context: string[];
15
- target: string;
16
- };
17
- export default _default;
18
- export declare const registerChrome: ({ app, chromePath, keycloakUri, https, proxyVerbose, }: {
19
- app: Application;
20
- chromePath: string;
21
- keycloakUri?: string | undefined;
22
- https?: boolean | undefined;
23
- proxyVerbose?: boolean | undefined;
24
- }) => void;
@@ -1,141 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.registerChrome = void 0;
30
- var fs_1 = __importDefault(require("fs"));
31
- var path_1 = __importDefault(require("path"));
32
- var glob = __importStar(require("glob"));
33
- var keycloakPort = process.env['KEYCLOAK_PORT'] ? process.env['KEYCLOAK_PORT'] : 4001;
34
- exports.default = (function (_a) {
35
- var port = _a.port;
36
- return ({
37
- services: {
38
- keycloak: {
39
- args: [
40
- "-p ".concat(keycloakPort, ":8080"),
41
- '-e KEYCLOAK_USER=admin',
42
- '-e KEYCLOAK_PASSWORD=admin',
43
- '-e DB_VENDOR=h2',
44
- "-v ".concat(path_1.default.join(__dirname, 'keycloak/realm_export.json'), ":/tmp/realm_export.json"),
45
- 'jboss/keycloak',
46
- '-Dkeycloak.migration.action=import',
47
- '-Dkeycloak.migration.provider=singleFile',
48
- '-Dkeycloak.migration.file=/tmp/realm_export.json',
49
- '-Dkeycloak.migration.strategy=OVERWRITE_EXISTING',
50
- ],
51
- },
52
- },
53
- path: 'https://github.com/redhatinsights/insights-chrome-build',
54
- keycloakUri: "http://localhost:".concat(port),
55
- context: ['/auth'],
56
- target: "http://localhost:".concat(keycloakPort),
57
- });
58
- });
59
- var registerChrome = function (_a) {
60
- var app = _a.app, chromePath = _a.chromePath, keycloakUri = _a.keycloakUri, https = _a.https, proxyVerbose = _a.proxyVerbose;
61
- var esiRegex = /<\s*esi:include\s+src\s*=\s*"([^"]+)"\s*\/\s*>/gm;
62
- app.use(function (req, res, next) {
63
- var ext = path_1.default.extname(req.url.replace(/\?.*/, ''));
64
- if (req.method === 'GET' && ['', '.hmt', '.html'].includes(ext)) {
65
- delete req.headers['accept-encoding'];
66
- var oldWrite_1 = res.write.bind(res);
67
- var oldEnd_1 = res.end.bind(res);
68
- function writeOrEnd(chunk, encoding, callback, oldFn) {
69
- var ctype = res.getHeader('Content-Type');
70
- if (typeof ctype === 'string' && ctype.includes('text/html') && !res.headersSent && !res.writableEnded) {
71
- if (chunk instanceof Buffer) {
72
- chunk = chunk.toString();
73
- }
74
- if (typeof chunk === 'string') {
75
- var hasEsi_1 = false;
76
- chunk = chunk.replace(esiRegex, function (_match, file) {
77
- if (!file) {
78
- throw new Error("Can't resolve request file");
79
- }
80
- file = file.split('/').pop();
81
- var snippet = path_1.default.resolve(chromePath, 'snippets', file);
82
- if (proxyVerbose) {
83
- console.log('esi', req.url, file);
84
- }
85
- hasEsi_1 = true;
86
- return fs_1.default.readFileSync(snippet, { encoding: 'utf-8' });
87
- });
88
- if (hasEsi_1) {
89
- res.setHeader('Content-Length', chunk.length);
90
- }
91
- }
92
- }
93
- return oldFn(chunk, encoding, callback);
94
- }
95
- res.write = function (chunk, encoding, callback) { return writeOrEnd(chunk, encoding, callback, oldWrite_1); };
96
- res.end = function (chunk, encoding, callback) { return writeOrEnd(chunk, encoding, callback, oldEnd_1); };
97
- }
98
- next();
99
- });
100
- app.get('(/beta)?/apps/chrome/*', function (req, res, next) {
101
- var fileReq = req.url.replace('/beta', '').replace('/apps/chrome', '');
102
- var diskPath = path_1.default.join(chromePath, fileReq);
103
- if (!fs_1.default.existsSync(diskPath)) {
104
- if (diskPath.match(/\/[^/]+\.[^/]+\.[^/]+$/)) {
105
- diskPath = diskPath.replace(/\w+\.(\w+)$/, function (_, m) { return "*".concat(m); });
106
- }
107
- var localFiles = glob.sync(diskPath);
108
- if (localFiles.length === 1) {
109
- diskPath = localFiles[0];
110
- if (proxyVerbose) {
111
- console.log('localChrome', req.url, '->', diskPath);
112
- }
113
- }
114
- else if (proxyVerbose) {
115
- console.log('not using localChrome for', req.url, "(could not find ".concat(diskPath, ")"));
116
- return next();
117
- }
118
- }
119
- if (req.url.endsWith('.js')) {
120
- var fileString = fs_1.default.readFileSync(diskPath, 'utf8');
121
- if (!https) {
122
- if (proxyVerbose) {
123
- console.log('remove https', req.url);
124
- }
125
- fileString = fileString.replace(/secure=true;/gm, '').replace(/https:\/\//gm, 'http://');
126
- }
127
- if (keycloakUri) {
128
- if (proxyVerbose) {
129
- console.log('inject keycloak', req.url);
130
- }
131
- fileString = fileString.replace(/https?:\/\/sso.qa.redhat.com/gm, keycloakUri);
132
- }
133
- res.end(fileString);
134
- }
135
- else {
136
- res.sendFile(diskPath);
137
- }
138
- });
139
- };
140
- exports.registerChrome = registerChrome;
141
- //# sourceMappingURL=chrome.js.map