UNPKG

@viewdo/dxp-story-cli

Version:

DXP Story Management CLI

102 lines 4.02 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PreviewConfiguration = void 0; const class_transformer_1 = require("class-transformer"); const DisplayType_1 = require("./support/DisplayType"); /** * DXP PREVIEW CONFIG: * ----------------------------------------------------- * This file defines configurable experience settings while previewing this story. * */ class PreviewConfiguration { constructor() { /** * DXP model-type (read-only) */ this.kind = "Experience"; /** * API version, model location (read-only) */ this.apiVersion = "xapi.view.do/v1"; /** * The pretend key for this model in the DXP platform * @pattern ^[A-Za-z0-9-$]{1,16}$ */ this.key = "fake-xid"; /** * This is the data that will be used while previewing this experience. * * */ this.data = {}; /** * The user model, if we need to preview user data rendering. */ this.user = {}; /** @ignore */ this.currentEpisodeKey = null; /** * Change the child-entity type here to render specific entities. */ this.childEntityKey = null; } setup(story_config, org_config) { story_config.inputs.forEach((input) => { this.data[input.key] = this._getDefaultInputValue(input); }); this.childEntityKey = org_config ? org_config.entities && org_config.entities.length ? org_config.entities[0].key : undefined : undefined; this.key = story_config.host == "Hosted" ? "fake-xid" : "$example"; return this; } _getDefaultInputValue(input) { switch (input.display) { case DisplayType_1.DisplayType.TextShort: case DisplayType_1.DisplayType.TextMedium: case DisplayType_1.DisplayType.TextLarge: case DisplayType_1.DisplayType.TextArea: return input.value || "Text"; case DisplayType_1.DisplayType.Checkbox: return input.value || false; case DisplayType_1.DisplayType.Number: return input.value || 0; case DisplayType_1.DisplayType.Date: case DisplayType_1.DisplayType.DateTime: return input.value || new Date(); default: return input.value || null; } } } exports.PreviewConfiguration = PreviewConfiguration; PreviewConfiguration.file_name = "preview-config"; __decorate([ (0, class_transformer_1.Exclude)(), __metadata("design:type", String) ], PreviewConfiguration.prototype, "currentEpisodeKey", void 0); __decorate([ (0, class_transformer_1.Exclude)(), __metadata("design:type", Object) ], PreviewConfiguration.prototype, "story", void 0); __decorate([ (0, class_transformer_1.Exclude)(), __metadata("design:type", Object) ], PreviewConfiguration.prototype, "organization", void 0); __decorate([ (0, class_transformer_1.Exclude)(), __metadata("design:type", String) ], PreviewConfiguration, "file_name", void 0); //# sourceMappingURL=PreviewConfiguration.js.map