UNPKG

3.61 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6const types_1 = __importDefault(require("../types"));
7const middleware_component_1 = require("../middleware/middleware-component");
8const webapp_component_1 = require("../webapp/webapp-component");
9const libs_1 = require("../libs");
10const iso_plugin_1 = require("./iso-plugin");
11const webapp_plugin_1 = require("../webapp/webapp-plugin");
12const environment_plugin_1 = require("../environment/environment-plugin");
13const datalayer_plugin_1 = require("../datalayer/datalayer-plugin");
14const identity_plugin_1 = require("../identity/identity-plugin");
15const authentication_plugin_1 = require("../authentication/authentication-plugin");
16const datalayer_component_1 = require("../datalayer/datalayer-component");
17const service_plugin_1 = require("../service/service-plugin");
18const service_component_1 = require("../service/service-component");
19exports.ISOMORPHIC_INSTANCE_TYPE = "IsomorphicComponent";
20/**
21 * The IsomorphicApp is an infrastructure and must implement [[IInfrastructure]]
22 *
23 * @param props
24 */
25exports.default = (props) => {
26 //console.log ("isomorphic: ",props );
27 const infProps = {
28 // allows to identify this component as Infrastructure
29 infrastructureType: types_1.default.INFRASTRUCTURE_TYPE_CONFIGURATION,
30 instanceId: props.stackName,
31 instanceType: exports.ISOMORPHIC_INSTANCE_TYPE,
32 // only load plugins during compilation
33 createPlugins: (configPath, stage, parserMode) => props.infrastructureMode === "COMPILATION" ? [
34 // be able to process IsomorphicApps (as top-level-node)
35 iso_plugin_1.IsoPlugin({
36 parserMode: parserMode,
37 buildPath: props.buildPath,
38 configFilePath: configPath
39 }),
40 datalayer_plugin_1.DataLayerPlugin({
41 buildPath: props.buildPath,
42 configFilePath: configPath,
43 }),
44 // isomorphic apps can have webapps (i.e. clients!)
45 webapp_plugin_1.WebAppPlugin({
46 parserMode: parserMode,
47 buildPath: props.buildPath,
48 configFilePath: configPath,
49 assetsPath: props.assetsPath
50 }),
51 service_plugin_1.ServicePlugin({}),
52 // isomorphic apps can have different environments
53 environment_plugin_1.EnvironmentPlugin({
54 stage: stage,
55 parserMode: parserMode
56 }),
57 identity_plugin_1.IdentityPlugin({}),
58 authentication_plugin_1.AuthenticationPlugin({})
59 ] : []
60 };
61 const isoProps = {
62 middlewares: libs_1.findComponentRecursively(props.children, middleware_component_1.isMiddleware),
63 webApps: libs_1.findComponentRecursively(props.children, webapp_component_1.isWebApp),
64 services: libs_1.findComponentRecursively(props.children, service_component_1.isService),
65 dataLayerId: libs_1.findComponentRecursively(props.children, datalayer_component_1.isDataLayer).reduce((res, dl) => res ? res : dl.id, undefined)
66 };
67 //console.log("webapps: ", isoProps.webApps)
68 return Object.assign(props, infProps, isoProps);
69};
70function isIsomorphicApp(component) {
71 return component !== undefined &&
72 component.instanceType === exports.ISOMORPHIC_INSTANCE_TYPE;
73}
74exports.isIsomorphicApp = isIsomorphicApp;
75//# sourceMappingURL=iso-component.js.map
\No newline at end of file