@pega/constellationjs 1.0.19 → 1.0.21

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 (48) hide show
  1. package/__DO_NOT_COMMIT/8.7.4-node-14.21.2/bootstrap-shell.js +1 -0
  2. package/__DO_NOT_COMMIT/8.7.4-node-14.21.2/bootstrap-shell.js.br +0 -0
  3. package/__DO_NOT_COMMIT/8.7.4-node-14.21.2/bootstrap-shell.js.gz +0 -0
  4. package/__DO_NOT_COMMIT/8.7.4-node-14.21.2/constellation-core.60079340.js +2 -0
  5. package/__DO_NOT_COMMIT/8.7.4-node-14.21.2/constellation-core.60079340.js.LICENSE.txt +124 -0
  6. package/{dist → __DO_NOT_COMMIT/8.7.4-node-14.21.2}/constellation-core.60079340.js.br +0 -0
  7. package/{dist → __DO_NOT_COMMIT/8.7.4-node-14.21.2}/constellation-core.60079340.js.gz +0 -0
  8. package/__DO_NOT_COMMIT/8.7.4-node-14.21.2/lib_asset.json +5 -0
  9. package/__DO_NOT_COMMIT/8.8.0-20221209-LPtesting/bootstrap-shell.js +1 -0
  10. package/__DO_NOT_COMMIT/8.8.0-20221209-LPtesting/bootstrap-shell.js.br +0 -0
  11. package/__DO_NOT_COMMIT/8.8.0-20221209-LPtesting/bootstrap-shell.js.gz +0 -0
  12. package/__DO_NOT_COMMIT/8.8.0-20221209-LPtesting/constellation-core.d9eb3b84.js +2 -0
  13. package/{dist/constellation-core.60079340.js.LICENSE.txt → __DO_NOT_COMMIT/8.8.0-20221209-LPtesting/constellation-core.d9eb3b84.js.LICENSE.txt} +0 -0
  14. package/__DO_NOT_COMMIT/8.8.0-20221209-LPtesting/constellation-core.d9eb3b84.js.br +0 -0
  15. package/__DO_NOT_COMMIT/8.8.0-20221209-LPtesting/constellation-core.d9eb3b84.js.gz +0 -0
  16. package/__DO_NOT_COMMIT/8.8.0-20221209-LPtesting/lib_asset.json +7 -0
  17. package/__DO_NOT_COMMIT/8.8.0-LP-fix-20221118/bootstrap-shell.js +616 -0
  18. package/__DO_NOT_COMMIT/8.8.0-LP-fix-20221118/bootstrap-shell.js.br +0 -0
  19. package/__DO_NOT_COMMIT/8.8.0-LP-fix-20221118/bootstrap-shell.js.gz +0 -0
  20. package/__DO_NOT_COMMIT/8.8.0-LP-fix-20221118/constellation-core.1fdcd53a.js +62904 -0
  21. package/__DO_NOT_COMMIT/8.8.0-LP-fix-20221118/constellation-core.1fdcd53a.js.LICENSE.txt +124 -0
  22. package/__DO_NOT_COMMIT/8.8.0-LP-fix-20221118/lib_asset.json +7 -0
  23. package/__DO_NOT_COMMIT/8.8.0-node-14.21.2/bootstrap-shell.js +1 -0
  24. package/__DO_NOT_COMMIT/8.8.0-node-14.21.2/bootstrap-shell.js.br +0 -0
  25. package/__DO_NOT_COMMIT/8.8.0-node-14.21.2/bootstrap-shell.js.gz +0 -0
  26. package/__DO_NOT_COMMIT/8.8.0-node-14.21.2/constellation-core.d9eb3b84.js +2 -0
  27. package/__DO_NOT_COMMIT/8.8.0-node-14.21.2/constellation-core.d9eb3b84.js.LICENSE.txt +124 -0
  28. package/__DO_NOT_COMMIT/8.8.0-node-14.21.2/constellation-core.d9eb3b84.js.br +0 -0
  29. package/__DO_NOT_COMMIT/8.8.0-node-14.21.2/constellation-core.d9eb3b84.js.gz +0 -0
  30. package/__DO_NOT_COMMIT/8.8.0-node-14.21.2/lib_asset.json +7 -0
  31. package/__DO_NOT_COMMIT/8.8.0-node-18.12.1/bootstrap-shell.js +1 -0
  32. package/__DO_NOT_COMMIT/8.8.0-node-18.12.1/bootstrap-shell.js.br +0 -0
  33. package/__DO_NOT_COMMIT/8.8.0-node-18.12.1/bootstrap-shell.js.gz +0 -0
  34. package/__DO_NOT_COMMIT/8.8.0-node-18.12.1/constellation-core.d9eb3b84.js +2 -0
  35. package/__DO_NOT_COMMIT/8.8.0-node-18.12.1/constellation-core.d9eb3b84.js.LICENSE.txt +124 -0
  36. package/__DO_NOT_COMMIT/8.8.0-node-18.12.1/constellation-core.d9eb3b84.js.br +0 -0
  37. package/__DO_NOT_COMMIT/8.8.0-node-18.12.1/constellation-core.d9eb3b84.js.gz +0 -0
  38. package/__DO_NOT_COMMIT/8.8.0-node-18.12.1/lib_asset.json +7 -0
  39. package/dist/bootstrap-shell.js +1 -1
  40. package/dist/bootstrap-shell.js.br +0 -0
  41. package/dist/bootstrap-shell.js.gz +0 -0
  42. package/dist/constellation-core.d9eb3b84.js +2 -0
  43. package/dist/constellation-core.d9eb3b84.js.LICENSE.txt +124 -0
  44. package/dist/constellation-core.d9eb3b84.js.br +0 -0
  45. package/dist/constellation-core.d9eb3b84.js.gz +0 -0
  46. package/dist/lib_asset.json +6 -4
  47. package/package.json +1 -1
  48. package/dist/constellation-core.60079340.js +0 -2
@@ -0,0 +1,7 @@
1
+ {
2
+ "isSdk": true,
3
+ "isDevServerMode": false,
4
+ "externals": [],
5
+ "entry": [],
6
+ "prerequisite": [{ "constellation-core.d9eb3b84.js": "" }]
7
+ }
@@ -0,0 +1,616 @@
1
+ const rootContainerWithHybrid = {
2
+ type: 'RootContainer',
3
+ config: {
4
+ renderingMode: 'hybrid'
5
+ },
6
+ children: [
7
+ {
8
+ type: 'HybridViewContainer',
9
+ config: {
10
+ routingInfo: '@ROUTING_INFO',
11
+ name: 'primary',
12
+ contextName: 'app'
13
+ },
14
+ children: []
15
+ }
16
+ ]
17
+ };
18
+
19
+ const buildSemanticUrl = (constellationPathInfo, queryParams, noPortal, restServer, viewName) => {
20
+ const urlSearchParams = new URLSearchParams(queryParams);
21
+
22
+ let isNoPortalParam = false;
23
+ if (noPortal === 'true') {
24
+ isNoPortalParam = true;
25
+ }
26
+
27
+ let caseOrPageName = null;
28
+ let caseWork = null;
29
+ if (constellationPathInfo) {
30
+ if (constellationPathInfo.startsWith('/')) {
31
+ constellationPathInfo = constellationPathInfo.substring(1);
32
+ }
33
+ const pathTokens = constellationPathInfo.split('/');
34
+ if (pathTokens.length > 0 && pathTokens[0]) {
35
+ caseOrPageName = pathTokens[0];
36
+ }
37
+ if (pathTokens.length > 1 && pathTokens[1]) {
38
+ caseWork = pathTokens[1];
39
+ }
40
+ } else {
41
+ isNoPortalParam = false;
42
+ }
43
+
44
+ let constellationUrl = restServer;
45
+ if (caseOrPageName) {
46
+ constellationUrl = `${constellationUrl}/${caseOrPageName}`;
47
+ }
48
+ if (caseWork) {
49
+ constellationUrl = `${constellationUrl}/${caseWork}`;
50
+ }
51
+
52
+ if (isNoPortalParam) {
53
+ !urlSearchParams.has('noPortal') && urlSearchParams.append('noPortal', true);
54
+ if (caseWork && viewName) {
55
+ urlSearchParams.append('view', viewName);
56
+ }
57
+ }
58
+ const searchParamsString = urlSearchParams.toString();
59
+ constellationUrl += searchParamsString ? `?${searchParamsString}` : '';
60
+
61
+ return constellationUrl;
62
+ };
63
+
64
+ let containerCount = 0;
65
+
66
+ const loadView = (
67
+ targetDom,
68
+ viewMetadata,
69
+ preLoadComponents = [],
70
+ runtimeParams,
71
+ portalTarget,
72
+ styleSheetTarget,
73
+ containerTargetName
74
+ ) => {
75
+ // eslint-disable-next-line no-plusplus
76
+ const targetName = containerTargetName === 'hybrid' ? `hybrid_${++containerCount}` : containerTargetName;
77
+ const containerName = targetName || `mashup${++containerCount}`;
78
+ const rootContainer = {
79
+ type: 'RootContainer',
80
+ config: {
81
+ renderingMode: 'portal',
82
+ viewConfig: '@P .viewConfig',
83
+ name: containerName
84
+ }
85
+ };
86
+ window.PCore.getRuntimeParamsAPI().setRuntimeParams(runtimeParams);
87
+ constellationCore
88
+ .loadRootComponent(targetDom, rootContainer, preLoadComponents, portalTarget, styleSheetTarget)
89
+ .then(() => {
90
+ return constellationCore.updateStoreWithUiRoot(viewMetadata, containerName);
91
+ });
92
+ };
93
+
94
+ const loadPortal = (targetDom, portalName, preLoadComponents = [], containerTargetName) => {
95
+ const containerName = containerTargetName || `portal${++containerCount}`;
96
+ const rootContainer = {
97
+ type: 'RootContainer',
98
+ config: {
99
+ viewConfig: '@P .viewConfig',
100
+ renderingMode: 'portal',
101
+ skeleton: 'LoadingComponent',
102
+ name: containerName
103
+ }
104
+ };
105
+ preLoadComponents.push(rootContainer.config.skeleton);
106
+ PCore.getEnvironmentInfo().isPortalLoaded = true;
107
+ constellationCore.loadRootComponent(targetDom, rootContainer, preLoadComponents).then(() => {
108
+ return constellationCore.loadPortalView(portalName, containerName);
109
+ });
110
+ };
111
+
112
+ const loadComponent = (targetDom, componentMetadata, preLoadComponents) => {
113
+ return constellationCore.loadComponent(componentMetadata, targetDom, preLoadComponents);
114
+ };
115
+
116
+ /**
117
+ * Loads the view with the viewName under the targetDom
118
+ * @param {string} targetDom
119
+ * @param {string} viewName
120
+ * @param portalName
121
+ * @param viewClass
122
+ * @param additionalComponents
123
+ * @param portalTarget
124
+ * @param styleSheetTarget
125
+ * @param containerTargetName
126
+ */
127
+ const loadViewByName = (
128
+ targetDom,
129
+ viewName,
130
+ portalName,
131
+ viewClass,
132
+ additionalComponents,
133
+ portalTarget,
134
+ styleSheetTarget,
135
+ containerTargetName
136
+ ) => {
137
+ const containerName = containerTargetName || `mashup${++containerCount}`;
138
+ const rootContainer = {
139
+ type: 'RootContainer',
140
+ config: {
141
+ viewConfig: '@P .viewConfig',
142
+ renderingMode: 'view',
143
+ name: containerName
144
+ }
145
+ };
146
+ constellationCore
147
+ .loadRootComponent(targetDom, rootContainer, additionalComponents, portalTarget, styleSheetTarget)
148
+ .then(() => {
149
+ return constellationCore.loadViewByName(viewName, portalName, viewClass, containerName);
150
+ });
151
+ };
152
+
153
+ const loadMashup = (targetDom, usePegaMashupStyling = true) => {
154
+ const rootMashUp = {
155
+ type: 'RootContainer',
156
+ config: {
157
+ renderingMode: 'noPortal'
158
+ },
159
+ children: [
160
+ {
161
+ type: 'ViewContainer',
162
+ config: {
163
+ routingInfo: '@ROUTING_INFO',
164
+ name: 'primary'
165
+ }
166
+ }
167
+ ]
168
+ };
169
+
170
+ // NOTE: We CANNOT force other consumers (ex: Quasar Mashup) to use this styling
171
+ if (usePegaMashupStyling) {
172
+ const targetDomElement =
173
+ document.getElementsByTagName(targetDom)[0] && document.getElementsByTagName(targetDom)[0].parentNode;
174
+ if (targetDomElement) {
175
+ const mashupStyle = document.createElement('style');
176
+ mashupStyle.setAttribute('id', 'portal-less-styles');
177
+ mashupStyle.innerHTML = `app-root.mashup > .case-view, app-root.mashup > .page-view { min-height: 0px !important; }`;
178
+ targetDomElement.appendChild(mashupStyle);
179
+ }
180
+ }
181
+
182
+ constellationCore.loadRootComponent(targetDom, rootMashUp, ['View', 'ViewContainer']);
183
+
184
+ /* US-350587 : Support the resize desktop action in mashup */
185
+ if (window.parent !== window) {
186
+ import(
187
+ `${constellationCore.PCoreInstance.getAssetLoader().getStaticServerUrl()}constellation-mashup-bridge.js`
188
+ ).then((mod) => {
189
+ mod.mashup.init({
190
+ resizing: 'stretch'
191
+ });
192
+ });
193
+ }
194
+ };
195
+
196
+ const loadCase = (targetDom, caseId, preLoadComponents = [], portalTarget, styleSheetTarget) => {
197
+ preLoadComponents.push('HybridViewContainer', 'View');
198
+ constellationCore
199
+ .loadRootComponent(targetDom, rootContainerWithHybrid, preLoadComponents, portalTarget, styleSheetTarget)
200
+ .then(() => {
201
+ return constellationCore.getCaseApi().openCase(caseId, 'app', 'primary');
202
+ });
203
+ };
204
+
205
+ const createCase = (targetDom, caseId, preLoadComponents = [], portalTarget, styleSheetTarget) => {
206
+ preLoadComponents.push('HybridViewContainer', 'View');
207
+ constellationCore
208
+ .loadRootComponent(targetDom, rootContainerWithHybrid, preLoadComponents, portalTarget, styleSheetTarget)
209
+ .then(() => {
210
+ return constellationCore.getCaseApi().createCase(caseId, 'app', 'primary');
211
+ });
212
+ };
213
+
214
+ const loadAssignment = (targetDom, assignmentId, preLoadComponents = [], portalTarget, styleSheetTarget) => {
215
+ preLoadComponents.push('HybridViewContainer', 'View');
216
+ constellationCore
217
+ .loadRootComponent(targetDom, rootContainerWithHybrid, preLoadComponents, portalTarget, styleSheetTarget)
218
+ .then(() => {
219
+ return constellationCore.getCaseApi().openAssignment(assignmentId, 'app', 'primary');
220
+ });
221
+ };
222
+
223
+ const initCoreConfig = (config) => {
224
+ const {
225
+ routingInfo,
226
+ actionModel,
227
+ serviceConfig,
228
+ additionalHeaders,
229
+ tokens,
230
+ semanticUrl,
231
+ queryParams,
232
+ noPortal,
233
+ timezone,
234
+ noHistory,
235
+ viewName,
236
+ theme,
237
+ fieldDefaults,
238
+ restServerConfig,
239
+ dynamicLoadComponents = true,
240
+ dynamicSemanticUrl = true,
241
+ enableRouting = true,
242
+ locale,
243
+ environmentInfo,
244
+ renderingMode = 'FULL_PORTAL',
245
+ remoteCaseMapping = {}
246
+ } = config;
247
+ const {
248
+ appAlias,
249
+ googleMapKey,
250
+ staticContentServer,
251
+ appStaticContentServer = null,
252
+ contextPath,
253
+ messagingService = null
254
+ } = serviceConfig;
255
+
256
+ const envInfo = { ...environmentInfo, renderingMode };
257
+
258
+ // eslint-disable-next-line no-restricted-globals
259
+ let restServer = location.origin;
260
+ const behaviorOverrides = {}; // Used below to set/check Mashup settings that will change bootstrap behavior
261
+
262
+ // config.restServerConfig can be specified to override the default rest server
263
+ if (undefined !== restServerConfig) {
264
+ // Mashup (Quasar) usage - use provided override in restServerConfig
265
+ restServer = restServerConfig;
266
+ }
267
+
268
+ if (contextPath) {
269
+ restServer = `${restServer}${contextPath}`;
270
+ }
271
+ if (appAlias) {
272
+ restServer = `${restServer}/${appAlias}`;
273
+ }
274
+
275
+ // Set up behaviorOverrides as specified in config for Mashup (Quasar) usage
276
+ // Note that, for normal use, dynamicSemanticUrl, dynamicLoadComponents
277
+ // and dynamicSetCookie default to true
278
+ if (dynamicSemanticUrl === true) {
279
+ // Standard usage - no override
280
+ const semUrl = buildSemanticUrl(semanticUrl, queryParams, noPortal, restServer, viewName);
281
+ // Do not push history state for bridge cases in infinity
282
+ if (!noHistory && semUrl) {
283
+ // eslint-disable-next-line no-restricted-globals
284
+ history.pushState({}, 'home', semUrl);
285
+ }
286
+ } else if (!(renderingMode === 'HYBRID')) {
287
+ // Mashup (Quasar) usage
288
+ let redirectUrl = window.location.href;
289
+ if (redirectUrl.indexOf('?') > 0) {
290
+ redirectUrl = redirectUrl.substring(0, redirectUrl.indexOf('?'));
291
+ // eslint-disable-next-line no-restricted-globals
292
+ history.pushState({}, 'home', redirectUrl);
293
+ }
294
+ // make as override, so npm-core/src/router/app-router.js doesn't create semantic url
295
+ behaviorOverrides.dynamicSemanticUrl = false;
296
+ }
297
+
298
+ if (dynamicLoadComponents !== true) {
299
+ // Mashup (Quasar) usage
300
+ behaviorOverrides.dynamicLoadComponents = false;
301
+ }
302
+
303
+ // remaining use of appAlias is setting up the calls to the c11n service
304
+ // these calls should not be prepended with any form of additional servlet; app/{app-alias} only. bug-627186
305
+ let appAliasNarrow = null;
306
+ if (appAlias) {
307
+ const idx = appAlias.indexOf('/app/');
308
+ appAliasNarrow = idx >= 0 ? appAlias.substring(idx + 1) : appAlias;
309
+ }
310
+
311
+ constellationCore.enableAppRouting(enableRouting);
312
+
313
+ if (Object.keys(behaviorOverrides).length > 0) {
314
+ // set it here, since it came in as false
315
+ PCore.setBehaviorOverrides(behaviorOverrides);
316
+ }
317
+
318
+ constellationCore.initStore();
319
+
320
+ /* Set Theme overrides to the instance */
321
+ if (theme) {
322
+ let themeObj = typeof theme === 'object' ? theme : null;
323
+ if (themeObj === null) {
324
+ try {
325
+ themeObj = JSON.parse(theme);
326
+ } catch {
327
+ themeObj = {};
328
+ }
329
+ }
330
+ PCore.getEnvironmentInfo().setTheme(themeObj);
331
+ }
332
+ /* Set default field configs */
333
+ constellationCore.setFieldsDefaultConfigs(fieldDefaults);
334
+ /* Set default headers */
335
+ constellationCore.setFetchDefaultHeaders(additionalHeaders);
336
+
337
+ const advRoutingInfo = {
338
+ ...routingInfo,
339
+ domain: `${window.location.protocol}//${window.location.host}`,
340
+ searchParams: window.location.search
341
+ };
342
+ /* Initialize server config */
343
+ constellationCore.initAppShell(advRoutingInfo, actionModel, { server: restServer });
344
+ constellationCore.setAppAlias(appAliasNarrow);
345
+ constellationCore.setGoogleMapsAPIKey(googleMapKey);
346
+ constellationCore.setStaticServerUrl(staticContentServer, appStaticContentServer, tokens.C11NB2S);
347
+ constellationCore.PCoreInstance.getLocaleUtils().setTimezone(timezone);
348
+
349
+ PCore.getEnvironmentInfo().setLocale(locale);
350
+ PCore.getRemoteCaseUtils().setRemoteCaseMapping(remoteCaseMapping);
351
+ PCore.getEnvironmentInfo().setEnvironmentInfo(envInfo);
352
+ PCore.getMessagingServiceManager().setConnectionConfig({ messagingService });
353
+ PCore.getNavigationUtils().init();
354
+ };
355
+
356
+ const importConstellationCore = async (staticContentServer, assets) => {
357
+ const { isDevServerMode, isSdk } = assets;
358
+ const { prerequisite } = assets;
359
+ if (prerequisite && prerequisite.length > 0) {
360
+ const corePrerequisite = prerequisite[0];
361
+ let serviceUrl;
362
+ const coreFileName = Object.keys(corePrerequisite)[0];
363
+ if (isDevServerMode) {
364
+ const coreDevServerUrl = Object.values(corePrerequisite)[0];
365
+ serviceUrl = coreDevServerUrl.endsWith('/')
366
+ ? `${coreDevServerUrl}prerequisite/${coreFileName}`
367
+ : `${coreDevServerUrl}/prerequisite/${coreFileName}`;
368
+ } else {
369
+ serviceUrl = staticContentServer.endsWith('/')
370
+ ? `${staticContentServer}prerequisite/${coreFileName}`
371
+ : `${staticContentServer}/prerequisite/${coreFileName}`;
372
+ }
373
+
374
+ if (isSdk) {
375
+ // SDKs only load the given constellation-core file from their own staticContentServer,
376
+ // so we need to override some of the processing here (for normal Constellation service)
377
+ // To accomplish this, SDKs will add isSdk: true to lib_asset.json.
378
+ // Not specifying isSdk (or setting to false) will leave normal Cosmos React import unaffected.
379
+ // Also, staticContentServer already ends with a slash serviceURl seems to start with a slash
380
+ // so we need to collapse those to a single slash
381
+ const staticContentServerNoTrailingSlash = staticContentServer.endsWith('/')
382
+ ? staticContentServer.slice(0, -1)
383
+ : staticContentServer;
384
+ const coreFileNoLeadingSlash = coreFileName.startsWith('/') ? coreFileName.slice(1) : coreFileName;
385
+ //
386
+ serviceUrl = `${staticContentServerNoTrailingSlash}/prerequisite/${coreFileNoLeadingSlash}`;
387
+ }
388
+
389
+ return import(serviceUrl).then((mod) => {
390
+ window.constellationCore = mod;
391
+ constellationCore.setStaticServerUrl(staticContentServer, 'no-appstatic');
392
+
393
+ /* Set up PCore object (public API used by Nebula) - remove if once code merged in constellationUI repo */
394
+ if (window.constellationCore.PCoreInstance !== undefined) {
395
+ window.PCore = window.constellationCore.PCoreInstance;
396
+ }
397
+ for (let i = 1; i < prerequisite.length; i += 1) {
398
+ const prerequisiteItem = prerequisite[i];
399
+ const prerequisiteItemFileName = Object.keys(prerequisiteItem)[0];
400
+ if (isDevServerMode) {
401
+ const prerequisiteItemDevServerUrl = Object.values(prerequisiteItem)[0];
402
+ import(`${prerequisiteItemDevServerUrl}prerequisite/${prerequisiteItemFileName}`).then((module) => {
403
+ console.log(module);
404
+ });
405
+ } else {
406
+ import(`${staticContentServer}prerequisite/${prerequisiteItemFileName}`).then((module) => {
407
+ console.log(module);
408
+ });
409
+ }
410
+ }
411
+ });
412
+ }
413
+ return null;
414
+ };
415
+
416
+ const importExternals = async (assets) => {
417
+ const { isDevServerMode } = assets;
418
+ const pCore = constellationCore.PCoreInstance;
419
+ await pCore.getAssetLoader().loadAssets(assets.externals, {
420
+ isDevServerMode
421
+ });
422
+ await pCore.getAssetLoader().loadAssets(assets.entry, {
423
+ isDevServerMode
424
+ });
425
+ // Get the generic locale bundle
426
+ const userLocale = pCore.getEnvironmentInfo().getLocale();
427
+ if (userLocale !== 'en-US') {
428
+ try {
429
+ const genericLocaleRule = pCore.getLocaleUtils().GENERIC_BUNDLE_KEY;
430
+ const genericLocaleRes = await pCore.getAssetLoader().getSvcLocale(userLocale, `${genericLocaleRule}.json`);
431
+ if (genericLocaleRes.ok) {
432
+ const genericLocaleJson = await genericLocaleRes.json();
433
+ pCore.getLocaleUtils().setLocaleForRule(genericLocaleJson, genericLocaleRule);
434
+ }
435
+ } catch (e) {
436
+ console.warn(e);
437
+ }
438
+ }
439
+ };
440
+
441
+ const importAssetsJson = async (staticContentServer) => {
442
+ const randomHash = new Date().getTime(); /* Math.floor(100 + Math.random() * 900); */
443
+ return fetch(`${staticContentServer}lib_asset.json?v=${randomHash}`).then((res) => res.json());
444
+ };
445
+
446
+ const importReactRoot = async () => {
447
+ const promises = [];
448
+ PCore.getComponentsRegistry()
449
+ .getComponent('ReactRoot')
450
+ .modules.forEach((module) => {
451
+ promises.push(module());
452
+ });
453
+ return Promise.allSettled(promises);
454
+ };
455
+
456
+ // callback is optional, recommended way is to handle the promise returned
457
+ const bootstrap = async (config, callback) => {
458
+ // this to be dynamic eventually; switch between rect and vue and ?, prod and debug builds
459
+ // config.serviceConfig.staticContentServer = "https://localhost:3002/";
460
+ // if (config.serviceConfig.appStaticContentServer) config.serviceConfig.staticContentServer += "prod/"
461
+
462
+ const bootStrapingFn = async (resolve, reject) => {
463
+ try {
464
+ const { staticContentServer } = config.serviceConfig;
465
+ const assets = await importAssetsJson(staticContentServer);
466
+ await importConstellationCore(staticContentServer, assets);
467
+ initCoreConfig(config);
468
+ const loadReactRoot = async () => {
469
+ await importReactRoot();
470
+ if (callback) callback();
471
+ resolve(true);
472
+ };
473
+ PCore.getPubSubUtils().subscribe('component-map-loaded', loadReactRoot);
474
+ await importExternals(assets);
475
+ // Resolve promise if "ReactRoot" is loaded (Hybrid scenario)
476
+ if ('ReactRoot' in PCore.getComponentsRegistry().getLazyMap()) {
477
+ resolve(true);
478
+ }
479
+ } catch (error) {
480
+ reject(error);
481
+ }
482
+ };
483
+
484
+ return new Promise(bootStrapingFn);
485
+ };
486
+
487
+ const getBootstrapConfig = async (restServerUrl, authorizationHeader) => {
488
+ return fetch(`${restServerUrl}/api/application/v2/data_views/D_pxBootstrapConfig`, {
489
+ method: 'GET',
490
+ headers: new Headers({
491
+ Authorization: authorizationHeader
492
+ })
493
+ }).then((response) => response.json());
494
+ };
495
+
496
+ const loadRootContainer = (targetDom, preLoadComponents = [], portalTarget, styleSheetTarget) => {
497
+ preLoadComponents.push('HybridViewContainer', 'View');
498
+ return constellationCore.loadRootComponent(
499
+ targetDom,
500
+ rootContainerWithHybrid,
501
+ preLoadComponents,
502
+ portalTarget,
503
+ styleSheetTarget
504
+ );
505
+ };
506
+
507
+ const bootstrapWithAuthHeader = async (config, target, preLoadComponents = [], portalTarget, styleSheetTarget) => {
508
+ // Adding restServerConfig, dynamicLoadComponents, dynamicSemanticUrl, and dynamicSetCookie needed for Mashup (Quasar) usage
509
+ const {
510
+ restServerUrl,
511
+ customRendering = false,
512
+ onPCoreReadyCallback,
513
+ staticContentServerUrl,
514
+ dynamicSetCookie = false,
515
+ authInfo = {},
516
+ theme = {},
517
+ renderingMode
518
+ } = config;
519
+ let { authorizationHeader, appAlias } = config;
520
+
521
+ let bootRes;
522
+ if (authorizationHeader && Object.keys(authInfo).length === 0) {
523
+ // custom authentication
524
+ authInfo.authType = 'custom';
525
+ }
526
+ if (!authorizationHeader && authInfo.tokenInfo) {
527
+ const { tokenInfo } = authInfo;
528
+ authorizationHeader = `${tokenInfo.token_type} ${tokenInfo.access_token}`;
529
+ }
530
+ if (appAlias) {
531
+ appAlias = appAlias.indexOf('/') !== -1 ? appAlias : `app/${appAlias}`;
532
+ bootRes = await getBootstrapConfig(`${restServerUrl}/${appAlias}`, authorizationHeader);
533
+ } else {
534
+ bootRes = await getBootstrapConfig(`${restServerUrl}`, authorizationHeader);
535
+ }
536
+ const bootConfig = JSON.parse(bootRes.pyConfigJSON);
537
+ bootConfig.restServerConfig = restServerUrl;
538
+ bootConfig.dynamicSemanticUrl = false;
539
+ bootConfig.dynamicSetCookie = dynamicSetCookie;
540
+ bootConfig.enableRouting = false;
541
+ bootConfig.serviceConfig.contextPath = '';
542
+ bootConfig.serviceConfig.appAlias = appAlias;
543
+ bootConfig.additionalHeaders = {
544
+ Authorization: authorizationHeader
545
+ };
546
+
547
+ bootConfig.dynamicLoadComponents = !customRendering;
548
+ bootConfig.dynamicSemanticUrl = !customRendering;
549
+ bootConfig.noHistory = true;
550
+ bootConfig.theme = theme ?? {};
551
+ bootConfig.renderingMode = renderingMode ?? bootConfig.renderingMode;
552
+
553
+ const staticContentServer = staticContentServerUrl || bootConfig.serviceConfig.staticContentServer;
554
+ /**
555
+ * updating bootconfig to make sure staticContentServerUrl is not overridden again through bootConfig
556
+ */
557
+ bootConfig.serviceConfig.staticContentServer = staticContentServer;
558
+
559
+ const assets = await importAssetsJson(staticContentServer);
560
+ await importConstellationCore(staticContentServer, assets);
561
+ initCoreConfig(bootConfig);
562
+ if (onPCoreReadyCallback) {
563
+ window.PCore.onPCoreReady(onPCoreReadyCallback);
564
+ }
565
+ if (authInfo && ['OAuth2.0', 'custom'].includes(authInfo?.authType)) {
566
+ constellationCore.setFetchAuthInfo(authInfo);
567
+ }
568
+
569
+ if (!customRendering) {
570
+ const bootstrapingFn = async (resolve, reject) => {
571
+ try {
572
+ const loadReactRoot = async () => {
573
+ await importReactRoot();
574
+ resolve(true);
575
+ };
576
+ PCore.getPubSubUtils().subscribe('component-map-loaded', loadReactRoot);
577
+ await importExternals(assets);
578
+ // Resolve promise if "ReactRoot" is loaded (Hybrid scenario)
579
+ if ('ReactRoot' in PCore.getComponentsRegistry().getLazyMap()) {
580
+ resolve(true);
581
+ }
582
+ } catch (error) {
583
+ reject(error);
584
+ }
585
+ };
586
+
587
+ const tempPromise = new Promise(bootstrapingFn);
588
+ await tempPromise;
589
+ await loadRootContainer(target, preLoadComponents, portalTarget, styleSheetTarget);
590
+ }
591
+ };
592
+ const initConstellationCore = async (staticContentServer) => {
593
+ // const { staticContentServer } = config.serviceConfig;
594
+ const assets = await importAssetsJson(staticContentServer);
595
+ await importConstellationCore(staticContentServer, assets);
596
+ };
597
+
598
+ const isNewUnifiedBuild = () => {
599
+ /* TEMP will remove it */
600
+ return false;
601
+ };
602
+
603
+ export {
604
+ bootstrap,
605
+ loadView,
606
+ loadPortal,
607
+ loadComponent,
608
+ loadMashup,
609
+ loadViewByName,
610
+ loadCase,
611
+ createCase,
612
+ loadAssignment,
613
+ bootstrapWithAuthHeader,
614
+ initConstellationCore,
615
+ isNewUnifiedBuild
616
+ };