@nebula.js/cli-serve 3.0.4 → 3.1.0-alpha.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.
@@ -1,16 +1,23 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><base href="/"/><title>Nebula dev</title><link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet"/><link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:light" rel="stylesheet"/><link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:semibold" rel="stylesheet"/><style>html,
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><base href="/"/><title>Nebula hub</title><link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet"/><link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:light" rel="stylesheet"/><link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:semibold" rel="stylesheet"/><style>html,
2
2
  body {
3
3
  height: 100%;
4
4
  margin: 0;
5
5
  padding: 0;
6
- overflow: hidden;
6
+ overflow: auto;
7
7
  }
8
8
 
9
9
  body {
10
- background: #ddd;
11
- -webkit-font-smoothing: antialiased;
10
+ color: #404040;
12
11
  font: normal 14px/16px 'Source Sans Pro', Arial, sans-serif;
12
+ -webkit-font-smoothing: antialiased;
13
+ background: linear-gradient(110deg, #91298c 0%, #45b3b2 100%);
14
+ }
15
+ code {
16
+ background-color: rgba(0, 0, 0, 0.05);
17
+ padding: 0 2px;
18
+ font-family: Monaco, monospace;
19
+ font-size: 0.9em;
13
20
  }
14
21
  #app {
15
22
  height: 100%;
16
- }</style><link rel="icon" href="njs.png"><script defer="defer" src="eDev.js"></script></head><body dir="ltr"><div id="app"></div></body></html>
23
+ }</style><link rel="icon" href="/njs.png"><script defer="defer" src="/eHub.js"></script></head><body dir="ltr"><div id="app"></div></body></html>
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.34.0(9d278685b078158491964f8fd7ac9628fffa0f30)
3
+ * Version: 0.34.1(547870b6881302c5b4ff32173c16d06009e3588f)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------------------------*/
package/lib/serve.js CHANGED
@@ -153,6 +153,7 @@ module.exports = async (argv) => {
153
153
  port,
154
154
  disableHostCheck: serveConfig.disableHostCheck,
155
155
  enigmaConfig,
156
+ clientId: serveConfig.clientId,
156
157
  webIntegrationId: serveConfig.webIntegrationId,
157
158
  snName: serveConfig.type || snName,
158
159
  snUrl,
@@ -20,7 +20,6 @@ const cfg = ({ srcDir, distDir, dev = false, serveConfig = {} }) => {
20
20
  mode: dev ? 'development' : 'production',
21
21
  entry: {
22
22
  eRender: [path.resolve(srcDir, 'eRender')],
23
- eDev: [path.resolve(srcDir, 'eDev')],
24
23
  eHub: [path.resolve(srcDir, 'eHub')],
25
24
  fixtures: [path.resolve(__dirname, './fixtures.js')],
26
25
  },
@@ -28,6 +27,7 @@ const cfg = ({ srcDir, distDir, dev = false, serveConfig = {} }) => {
28
27
  output: {
29
28
  path: distDir,
30
29
  filename: '[name].js',
30
+ publicPath: '/',
31
31
  },
32
32
  resolve: {
33
33
  alias: {
@@ -100,14 +100,8 @@ const cfg = ({ srcDir, distDir, dev = false, serveConfig = {} }) => {
100
100
  stylesheets: serveConfig.stylesheets,
101
101
  }),
102
102
  new HtmlWebpackPlugin({
103
- template: path.resolve(srcDir, 'eDev.html'),
104
- filename: 'eDev.html',
105
- chunks: ['eDev'],
106
- favicon,
107
- }),
108
- new HtmlWebpackPlugin({
109
- template: path.resolve(srcDir, 'eHub.html'),
110
- filename: 'eHub.html',
103
+ template: path.resolve(srcDir, 'index.html'),
104
+ filename: 'index.html',
111
105
  chunks: ['eHub'],
112
106
  favicon,
113
107
  }),
@@ -58,12 +58,6 @@ const cfg = ({ srcDir = path.resolve(__dirname, '../dist'), serveConfig = {} })
58
58
  stylesheets: serveConfig.stylesheets,
59
59
  chunks: ['fixtures'],
60
60
  }),
61
- new HtmlWebpackPlugin({
62
- template: path.resolve(srcDir, 'eDev.html'),
63
- filename: 'eDev.html',
64
- inject: 'head',
65
- chunks: [],
66
- }),
67
61
  ],
68
62
  };
69
63
 
@@ -4,6 +4,7 @@ const chalk = require('chalk');
4
4
  const express = require('express');
5
5
  const fs = require('fs');
6
6
  const homedir = require('os').homedir();
7
+ const { Auth, AuthType } = require('@qlik/sdk');
7
8
 
8
9
  const webpack = require('webpack');
9
10
  const WebpackDevServer = require('webpack-dev-server');
@@ -14,11 +15,25 @@ const snapshotRouter = require('./snapshot-router');
14
15
  const httpsKeyPath = path.join(homedir, '.certs/key.pem');
15
16
  const httpsCertPath = path.join(homedir, '.certs/cert.pem');
16
17
 
18
+ let authInstance = null;
19
+ const getAuthInstance = (returnToOrigin, host, clientId) => {
20
+ if (authInstance) return authInstance;
21
+
22
+ authInstance = new Auth({
23
+ authType: AuthType.OAuth2,
24
+ host,
25
+ clientId,
26
+ redirectUri: `${returnToOrigin}/login/callback`,
27
+ });
28
+ return authInstance;
29
+ };
30
+
17
31
  module.exports = async ({
18
32
  host,
19
33
  port,
20
34
  disableHostCheck,
21
35
  enigmaConfig,
36
+ clientId,
22
37
  webIntegrationId,
23
38
  snName,
24
39
  snUrl,
@@ -93,9 +108,7 @@ module.exports = async ({
93
108
  port,
94
109
  allowedHosts: disableHostCheck ? 'all' : 'auto',
95
110
  open,
96
- historyApiFallback: {
97
- index: '/eHub.html',
98
- },
111
+ historyApiFallback: true,
99
112
  // Disable nebula serve dev env when in MFE mode
100
113
  static: !serveConfig.mfe && {
101
114
  directory: contentBase,
@@ -142,7 +155,10 @@ module.exports = async ({
142
155
  res.set(devServer.options.headers);
143
156
  res.json({
144
157
  enigma: enigmaConfig,
158
+ clientId,
145
159
  webIntegrationId,
160
+ isClientIdProvided: Boolean(clientId),
161
+ isWebIntegrationIdProvided: Boolean(webIntegrationId),
146
162
  supernova: {
147
163
  name: snName,
148
164
  url: snUrl,
@@ -157,6 +173,95 @@ module.exports = async ({
157
173
  });
158
174
  });
159
175
 
176
+ let cachedHost = null;
177
+ let cachedClientId = null;
178
+
179
+ app.get('/oauth', async (req, res) => {
180
+ const { host: qHost, clientId: qClientId } = req.query;
181
+ if (!cachedHost && !cachedClientId) {
182
+ cachedHost = qHost;
183
+ cachedClientId = qClientId;
184
+ }
185
+
186
+ const returnTo = `${req.protocol}://${req.get('host')}`;
187
+ const instacne = getAuthInstance(returnTo, qHost, qClientId);
188
+ const isAuthorized = await instacne.isAuthorized();
189
+ if (!isAuthorized) {
190
+ const { url: redirectUrl } = await instacne.generateAuthorizationUrl();
191
+ res.status(200).json({ redirectUrl });
192
+ } else {
193
+ const redirectUrl = `${req.protocol}://${req.get(
194
+ 'host'
195
+ )}/app-list?engine_url=wss://${cachedHost}&qlik-client-id=${cachedClientId}&shouldFetchAppList=true`;
196
+ cachedHost = null;
197
+ cachedClientId = null;
198
+ res.redirect(redirectUrl);
199
+ }
200
+ });
201
+
202
+ app.get('/login/callback', async (req, res) => {
203
+ const authLink = new URL(req.url, `http://${req.headers.host}`).href;
204
+ try {
205
+ // TODO:
206
+ // this is a temp fix in front end side
207
+ // (temp workaround of not presisting origin while backend tries to authorize user)
208
+ // they need to handle this in qlik-sdk-typescript repo
209
+ // and will notify us about when they got fixed it,
210
+ // but until then, we need to take care of it here!
211
+ authInstance.rest.interceptors.request.use((_req) => {
212
+ // eslint-disable-next-line no-param-reassign, dot-notation
213
+ _req[1]['headers'] = { origin: 'http://localhost:8000' };
214
+ return _req;
215
+ });
216
+ await authInstance.authorize(authLink);
217
+ res.redirect(301, '/oauth/');
218
+ } catch (err) {
219
+ console.log({ err });
220
+ res.status(401).send(JSON.stringify(err, null, 2));
221
+ }
222
+ });
223
+
224
+ app.get('/getSocketUrl/:appId', async (req, res) => {
225
+ const { appId } = req.params;
226
+ const webSocketUrl = await authInstance.generateWebsocketUrl(appId, true);
227
+ res.status(200).json({ webSocketUrl });
228
+ });
229
+
230
+ app.get('/deauthorize', async (req, res) => {
231
+ try {
232
+ await authInstance.deauthorize();
233
+ res.status(200).json({
234
+ deauthorize: true,
235
+ });
236
+ } catch (error) {
237
+ console.log({ error });
238
+ }
239
+ });
240
+
241
+ app.get('/isAuthorized', async (req, res) => {
242
+ if (!authInstance) {
243
+ res.status(200).json({
244
+ isAuthorized: false,
245
+ });
246
+ } else {
247
+ const isAuthorized = await authInstance.isAuthorized();
248
+ res.status(200).json({
249
+ isAuthorized,
250
+ });
251
+ }
252
+ });
253
+
254
+ app.get('/apps', async (req, res) => {
255
+ const appsListUrl = `/items?resourceType=app&limit=30&sort=-updatedAt`;
256
+ const { data = [] } = await (await authInstance.rest(appsListUrl)).json();
257
+ res.status(200).json(
258
+ data.map((d) => ({
259
+ qDocId: d.resourceId,
260
+ qTitle: d.name,
261
+ }))
262
+ );
263
+ });
264
+
160
265
  if (serveConfig.resources) {
161
266
  app.use('/resources', express.static(serveConfig.resources));
162
267
  }
@@ -170,12 +275,6 @@ module.exports = async ({
170
275
  ignorePath: true,
171
276
  logLevel: 'error',
172
277
  },
173
- {
174
- context: '/dev',
175
- target: `${url}/eDev.html`,
176
- ignorePath: true,
177
- logLevel: 'error',
178
- },
179
278
  ],
180
279
  server: HTTPS
181
280
  ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebula.js/cli-serve",
3
- "version": "3.0.4",
3
+ "version": "3.1.0-alpha.1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "QlikTech International AB",
@@ -20,6 +20,9 @@
20
20
  "dist",
21
21
  "lib"
22
22
  ],
23
+ "engines": {
24
+ "node": ">=18.10.0"
25
+ },
23
26
  "scripts": {
24
27
  "build": "cross-env NODE_ENV=production DEFAULTS=true webpack --config ./lib/webpack.build.js",
25
28
  "build:dev": "cross-env NODE_ENV=development DEFAULTS=true webpack --config ./lib/webpack.build.js",
@@ -27,46 +30,48 @@
27
30
  "prepublishOnly": "rm -rf dist && yarn run build"
28
31
  },
29
32
  "dependencies": {
30
- "@nebula.js/cli-build": "^3.0.4",
31
- "body-parser": "1.20.0",
33
+ "@nebula.js/cli-build": "^3.1.0-alpha.1",
34
+ "body-parser": "1.20.1",
32
35
  "chalk": "4.1.2",
33
36
  "chokidar": "3.5.3",
34
37
  "cross-env": "7.0.3",
35
- "express": "4.18.1",
38
+ "express": "4.18.2",
36
39
  "extend": "3.0.2",
37
40
  "html-webpack-plugin": "5.5.0",
38
41
  "portfinder": "1.0.32",
39
42
  "puppeteer": "14.4.1",
40
- "regenerator-runtime": "0.13.9",
41
- "source-map-loader": "4.0.0",
43
+ "regenerator-runtime": "0.13.10",
44
+ "source-map-loader": "4.0.1",
42
45
  "webpack": "5.74.0",
43
46
  "webpack-dev-server": "4.11.1",
44
- "ws": "8.9.0",
47
+ "ws": "8.10.0",
45
48
  "yargs": "17.6.0"
46
49
  },
47
50
  "devDependencies": {
48
- "@babel/core": "7.19.3",
49
- "@babel/preset-env": "7.19.3",
51
+ "@babel/core": "7.19.6",
52
+ "@babel/preset-env": "7.19.4",
50
53
  "@babel/preset-react": "7.18.6",
51
- "@mui/material": "^5.10.8",
52
- "@nebula.js/enigma-mocker": "^3.0.4",
53
- "@nebula.js/nucleus": "^3.0.4",
54
- "@nebula.js/snapshooter": "^3.0.4",
55
- "@nebula.js/stardust": "^3.0.4",
56
- "@nebula.js/ui": "^3.0.4",
57
- "@qlik/sdk": "^0.10.2",
54
+ "@mui/material": "^5.10.12",
55
+ "@mui/system": "^5.10.12",
56
+ "@nebula.js/enigma-mocker": "^3.1.0-alpha.1",
57
+ "@nebula.js/nucleus": "^3.1.0-alpha.1",
58
+ "@nebula.js/snapshooter": "^3.1.0-alpha.1",
59
+ "@nebula.js/stardust": "^3.1.0-alpha.1",
60
+ "@nebula.js/ui": "^3.1.0-alpha.1",
61
+ "@qlik/sdk": "^0.14.3",
58
62
  "autosuggest-highlight": "3.3.4",
59
- "babel-loader": "8.2.5",
63
+ "babel-loader": "9.1.0",
60
64
  "d3-require": "1.3.0",
61
65
  "enigma.js": "2.10.0",
62
66
  "eslint-import-resolver-alias": "1.1.2",
63
67
  "eslint-import-resolver-webpack": "0.13.2",
64
68
  "file-loader": "^6.2.0",
65
- "monaco-editor": "0.34.0",
69
+ "monaco-editor": "0.34.1",
66
70
  "monaco-editor-webpack-plugin": "7.0.1",
67
71
  "react": "18.2.0",
68
72
  "react-dom": "18.2.0",
73
+ "react-router-dom": "6.4.2",
69
74
  "webpack-cli": "4.10.0"
70
75
  },
71
- "gitHead": "419f994f8f5e15235fa20057bc9085b03a9a904b"
76
+ "gitHead": "62d1862cc80fca13ab2753702ce2c396fed4b9d8"
72
77
  }