@nebula.js/cli-create 5.10.1 → 5.12.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebula.js/cli-create",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "QlikTech International AB",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"fs-extra": "11.3.0",
|
|
28
28
|
"inquirer": "8.2.6"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "e3e6eb02c838a34142a46396d9eaa46e14a2a131"
|
|
31
31
|
}
|
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import {
|
|
3
|
-
import embed from '
|
|
4
|
-
import
|
|
2
|
+
import { auth, qix } from '@qlik/api';
|
|
3
|
+
import { embed } from '@nebula.js/stardust';
|
|
4
|
+
import barchart from '@nebula.js/sn-bar-chart';
|
|
5
5
|
|
|
6
6
|
async function run() {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const appId = '<App id>';
|
|
8
|
+
// https://github.com/qlik-oss/qlik-api-ts/blob/main/docs/authentication.md
|
|
9
|
+
const hostConfig = {
|
|
10
|
+
authType: '<AuthenticationType: ex "oauth2" or "cookie"',
|
|
11
|
+
host: '<URL>',
|
|
12
|
+
// connection config based on authType
|
|
13
|
+
webIntegrationId: '<Qlik web integration id>', // cookie
|
|
14
|
+
clientId: '<Qlik OAuth client id>', // oauth2
|
|
15
|
+
accessTokenStorage: 'session', // for oauth2
|
|
16
|
+
};
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
webIntegrationId: '<Qlik web integration id>',
|
|
16
|
-
});
|
|
18
|
+
auth.setDefaultHostConfig(hostConfig);
|
|
19
|
+
const appSession = qix.openAppSession(appId);
|
|
20
|
+
const app = await appSession.getDoc();
|
|
17
21
|
|
|
18
|
-
const
|
|
22
|
+
const nebula = embed(app, {
|
|
23
|
+
context: {
|
|
24
|
+
theme: 'light',
|
|
25
|
+
language: 'en-US',
|
|
26
|
+
},
|
|
27
|
+
types: [
|
|
28
|
+
{
|
|
29
|
+
name: 'barchart',
|
|
30
|
+
load: () => Promise.resolve(barchart),
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
});
|
|
19
34
|
|
|
20
|
-
(await
|
|
35
|
+
(await nebula.selections()).mount(document.querySelector('.toolbar'));
|
|
21
36
|
|
|
22
|
-
//
|
|
37
|
+
// nebula.render({ element: document.querySelector('.object'), id: "" });
|
|
23
38
|
}
|
|
24
39
|
|
|
25
40
|
run();
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import enigma from 'enigma.js';
|
|
2
|
-
import schema from 'enigma.js/schemas/12.2015.0.json';
|
|
3
|
-
import { Auth, AuthType } from '@qlik/sdk';
|
|
4
|
-
|
|
5
|
-
export default class Authenticator {
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {String} appId - application id from sense client
|
|
9
|
-
* @param {Strign} url - tenant url
|
|
10
|
-
*/
|
|
11
|
-
constructor({ appId, url }) {
|
|
12
|
-
this.authInstance = null;
|
|
13
|
-
this.appId = appId;
|
|
14
|
-
this.host = url.replace(/^https?:\/\//, '').replace(/\/?/, '');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* gets you the promise of enigma instance for your app
|
|
19
|
-
* based on webIntegrationId
|
|
20
|
-
* @param {Strign} webIntegrationId - your web Integration Id from managment console
|
|
21
|
-
* @returns {Promise<IEnigmaClass>} enigma app promise
|
|
22
|
-
*/
|
|
23
|
-
async AuthenticateWithWebIntegrationId({ webIntegrationId }) {
|
|
24
|
-
this.authInstance = new Auth({
|
|
25
|
-
authType: AuthType.WebIntegration,
|
|
26
|
-
autoRedirect: true,
|
|
27
|
-
host: this.host,
|
|
28
|
-
webIntegrationId,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
if (!this.authInstance.isAuthenticated()) {
|
|
32
|
-
this.authInstance.authenticate();
|
|
33
|
-
} else return this.getEnigmaApp();
|
|
34
|
-
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* gets you the promise of enigma instance for your app
|
|
40
|
-
* based on clientId
|
|
41
|
-
* @param {Strign} clientId - your client Id from managment console
|
|
42
|
-
* @param {Strign} redirectUri - the redirect url while bringing you the code + state, default is `window.location.origin`
|
|
43
|
-
* @returns {Promise<IEnigmaClass>} enigma app promise
|
|
44
|
-
*/
|
|
45
|
-
async AuthenticateWithOAuth({ clientId, redirectUri }) {
|
|
46
|
-
this.authInstance = new Auth({
|
|
47
|
-
authType: AuthType.OAuth2,
|
|
48
|
-
host: this.host,
|
|
49
|
-
redirectUri: redirectUri || window.location.origin,
|
|
50
|
-
clientId,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
54
|
-
if (urlParams.get('code')) {
|
|
55
|
-
try {
|
|
56
|
-
await this.authInstance.authorize(window.location.href);
|
|
57
|
-
const url = new URL(window.location);
|
|
58
|
-
url.searchParams.delete('code');
|
|
59
|
-
url.searchParams.delete('state');
|
|
60
|
-
window.history.replaceState(null, null, url);
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.error({ error });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return this.getEnigmaApp();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (!(await this.authInstance.isAuthorized())) {
|
|
69
|
-
const { url } = await this.authInstance.generateAuthorizationUrl();
|
|
70
|
-
const protocol = url.includes('https://') ? 'https' : 'http';
|
|
71
|
-
window.location = `${protocol}://${url}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* returns a promise of enigma instance
|
|
79
|
-
* @returns {Promise<IEnigmaClass>} enigma app instance promise
|
|
80
|
-
*/
|
|
81
|
-
async getEnigmaApp() {
|
|
82
|
-
const url = await this.authInstance.generateWebsocketUrl(this.appId);
|
|
83
|
-
const enigmaGlobal = await enigma.create({ schema, url }).open();
|
|
84
|
-
return enigmaGlobal.openDoc(this.appId);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { embed } from '@nebula.js/stardust';
|
|
2
|
-
|
|
3
|
-
import barchart from '@nebula.js/sn-bar-chart';
|
|
4
|
-
|
|
5
|
-
const n = embed.createConfiguration({
|
|
6
|
-
context: {
|
|
7
|
-
theme: 'light',
|
|
8
|
-
language: 'en-US',
|
|
9
|
-
},
|
|
10
|
-
types: [
|
|
11
|
-
{
|
|
12
|
-
name: 'barchart',
|
|
13
|
-
load: () => Promise.resolve(barchart),
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export default n;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { AuthType } from '@qlik/sdk';
|
|
2
|
-
import Authenticator from './Authenticator';
|
|
3
|
-
|
|
4
|
-
async function connect({ connectionType, url, appId, ...rest }) {
|
|
5
|
-
const AuthenticatorInstance = new Authenticator({
|
|
6
|
-
url,
|
|
7
|
-
appId,
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
switch (connectionType) {
|
|
11
|
-
case AuthType.WebIntegration: {
|
|
12
|
-
return AuthenticatorInstance.AuthenticateWithWebIntegrationId({
|
|
13
|
-
...rest,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
case AuthType.OAuth2: {
|
|
18
|
-
return AuthenticatorInstance.AuthenticateWithOAuth({ ...rest });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
default:
|
|
22
|
-
throw new Error('Please Provide a `connectionType` to proceed!');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default connect;
|