feat: add host config to config and galaxy (#1628)

* feat: add host config to config and galaxy

* chore: externalize qmfe-api in systemjs package

* fix: config

* fix: update tests

* chore: update comment and add qlik/api to externals
This commit is contained in:
Tobias Åström
2024-10-15 10:29:46 +02:00
committed by GitHub
parent 5aeae2db53
commit 71e053bff7
5 changed files with 25 additions and 1 deletions

View File

@@ -116,6 +116,7 @@ describe('nucleus', () => {
test('should initiate types with a public galaxy interface', () => { test('should initiate types with a public galaxy interface', () => {
Nuked('app', { Nuked('app', {
hostConfig: 'HOST',
anything: { anything: {
some: 'thing', some: 'thing',
}, },
@@ -127,6 +128,7 @@ describe('nucleus', () => {
}, },
flags: 'flags', flags: 'flags',
deviceType: 'desktop', deviceType: 'desktop',
hostConfig: 'HOST',
translator, translator,
}); });
}); });

View File

@@ -88,6 +88,7 @@ const DEFAULT_SNAPSHOT_CONFIG = /** @lends SnapshotConfiguration */ {
* @property {Context=} context Settings for the rendering instance * @property {Context=} context Settings for the rendering instance
* @property {Array<TypeInfo>=} types Visualization types to register * @property {Array<TypeInfo>=} types Visualization types to register
* @property {Array<ThemeInfo>=} themes Themes to register * @property {Array<ThemeInfo>=} themes Themes to register
* @property {object=} hostConfig Qlik api compatible host config, see https://github.com/qlik-oss/qlik-api-ts/blob/main/docs/authentication.md#the-host-config
* @property {object=} anything * @property {object=} anything
* @example * @example
* import { embed } from '@nebula.js/stardust' * import { embed } from '@nebula.js/stardust'
@@ -183,6 +184,7 @@ const mergeConfigs = (base, c) => ({
types: mergeArray(base.types, c.types), types: mergeArray(base.types, c.types),
themes: mergeArray(base.themes, c.themes), themes: mergeArray(base.themes, c.themes),
flags: mergeObj(base.flags, c.flags), flags: mergeObj(base.flags, c.flags),
hostConfig: c.hostConfig || base.hostConfig,
anything: mergeObj(base.anything, c.anything), anything: mergeObj(base.anything, c.anything),
}); });
@@ -243,6 +245,8 @@ function nuked(configuration = {}) {
/** @type {string} */ /** @type {string} */
deviceType: deviceTypeFn(configuration.context.deviceType), deviceType: deviceTypeFn(configuration.context.deviceType),
/** @type {object} */ /** @type {object} */
hostConfig: configuration.hostConfig,
/** @type {object} */
anything: configuration.anything, anything: configuration.anything,
}, },
theme: appTheme.externalAPI, theme: appTheme.externalAPI,

View File

@@ -706,6 +706,11 @@
"type": "#/definitions/ThemeInfo" "type": "#/definitions/ThemeInfo"
} }
}, },
"hostConfig": {
"description": "a qlik api compatible host config, see https://github.com/qlik-oss/qlik-api-ts/blob/main/docs/authentication.md#the-host-config",
"optional": true,
"type": "object"
},
"anything": { "anything": {
"optional": true, "optional": true,
"type": "object" "type": "object"
@@ -774,6 +779,9 @@
"deviceType": { "deviceType": {
"type": "string" "type": "string"
}, },
"hostConfig": {
"type": "object"
},
"anything": { "anything": {
"type": "object" "type": "object"
} }

View File

@@ -247,6 +247,7 @@ declare namespace stardust {
context?: stardust.Context; context?: stardust.Context;
types?: stardust.TypeInfo[]; types?: stardust.TypeInfo[];
themes?: stardust.ThemeInfo[]; themes?: stardust.ThemeInfo[];
hostConfig?: object;
anything?: object; anything?: object;
} }
@@ -265,6 +266,7 @@ declare namespace stardust {
translator: stardust.Translator; translator: stardust.Translator;
flags: stardust.Flags; flags: stardust.Flags;
deviceType: string; deviceType: string;
hostConfig: object;
anything: object; anything: object;
} }

View File

@@ -1,6 +1,14 @@
const systemjsBehaviours = { const systemjsBehaviours = {
getExternal: ({ config: cfg }) => { getExternal: ({ config: cfg }) => {
const defaultExternal = ['@nebula.js/stardust', 'picasso.js', 'picasso-plugin-q', 'react', 'react-dom']; const defaultExternal = [
'@nebula.js/stardust',
'picasso.js',
'picasso-plugin-q',
'react',
'react-dom',
'@qlik-trial/qmfe-api',
'@qlik/api',
];
const { external } = cfg.systemjs || {}; const { external } = cfg.systemjs || {};
return Array.isArray(external) ? external : defaultExternal; return Array.isArray(external) ? external : defaultExternal;
}, },