UNPKG

infrastructure-components

Version:

Infrastructure-Components configure the infrastructure of your React-App as part of your React-Components.

45 lines 1.74 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const types_1 = __importDefault(require("../types")); const middleware_component_1 = require("../middleware/middleware-component"); const index_1 = require("../index"); const storage_libs_1 = require("./storage-libs"); exports.STORAGE_INSTANCE_TYPE = "StorageComponent"; /** * identifies a component as a DataLayer * * @param component to be tested */ function isStorage(component) { return component !== undefined && component.instanceType === exports.STORAGE_INSTANCE_TYPE; } exports.isStorage = isStorage; exports.default = (props) => { const componentProps = { infrastructureType: types_1.default.INFRASTRUCTURE_TYPE_COMPONENT, instanceType: exports.STORAGE_INSTANCE_TYPE, instanceId: props.id, insulatesChildComponent: (child) => { // a webapp insulates (handles itself) middlewares and routes and does not privide to higher levels return middleware_component_1.isMiddleware(child); } }; const storageProps = { middlewares: index_1.getChildrenArray(props.children) .filter(child => middleware_component_1.isMiddleware(child)) .concat([ storage_libs_1.listMiddleware(props.id), storage_libs_1.uploadMiddleware(props.id) ]), setDataLayerId: (dataLayerId) => { props.dataLayerId = dataLayerId; }, method: "POST" }; return Object.assign(props, componentProps, storageProps); }; //# sourceMappingURL=storage-component.js.map