UNPKG

xrm-mock

Version:

A fake implementation of the Xrm object model. Used for testing Dynamics 365 client-side scripts.

1,044 lines 243 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; define("xrm-mock/controls/addcontrolnotificationoptions/addcontrolnotificationoptions.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AddControlNotificationOptionsMock = void 0; var AddControlNotificationOptionsMock = /** @class */ (function () { function AddControlNotificationOptionsMock(components) { this.actions = components.actions; this.messages = components.messages; this.notificationLevel = components.notificationLevel; this.uniqueId = components.uniqueId; } return AddControlNotificationOptionsMock; }()); exports.AddControlNotificationOptionsMock = AddControlNotificationOptionsMock; }); define("xrm-mock/navigation/alertstrings/alertstrings.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AlertStringsMock = void 0; var AlertStringsMock = /** @class */ (function () { function AlertStringsMock(text, confirmButtonLabel) { this.text = text; this.confirmButtonLabel = confirmButtonLabel; } return AlertStringsMock; }()); exports.AlertStringsMock = AlertStringsMock; }); define("xrm-mock/appproperties/appproperties.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppPropertiesMock = void 0; var AppPropertiesMock = /** @class */ (function () { function AppPropertiesMock(components) { this.appId = components.appId; this.displayName = components.displayName; this.uniqueName = components.uniqueName; this.url = components.url; this.webResourceId = components.webResourceId; this.webResourceName = components.webResourceName; this.welcomePageId = components.welcomePageId; this.welcomePageName = components.welcomePageName; } return AppPropertiesMock; }()); exports.AppPropertiesMock = AppPropertiesMock; }); define("xrm-mock/metadata/attributemetadata/attributemetadata.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AttributeMetadataMock = void 0; var AttributeMetadataMock = /** @class */ (function () { function AttributeMetadataMock(components) { this.DefaultFormValue = components.DefaultFormValue; this.LogicalName = components.LogicalName; this.DisplayName = components.DisplayName; this.AttributeType = components.AttributeType; this.EntityLogicalName = components.EntityLogicalName; this.OptionSet = components.OptionSet; } return AttributeMetadataMock; }()); exports.AttributeMetadataMock = AttributeMetadataMock; }); define("xrm-mock-generator/helpers/array.helper", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findIndex = void 0; function findIndex(handlers, handler) { return handlers.findIndex(function (item) { return item.name === handler.name; }); } exports.findIndex = findIndex; }); define("xrm-mock/async/xrmpromise/xrmpromise.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.XrmPromiseMock = void 0; var XrmPromiseMock = /** @class */ (function () { function XrmPromiseMock(promise) { this.promise = promise; } XrmPromiseMock.prototype.then = function (onFulfilled, onRejected) { return new XrmPromiseMock(this.promise.then(onFulfilled, onRejected)); }; XrmPromiseMock.prototype.fail = function (onRejected) { return new XrmPromiseMock(this.promise.catch(onRejected)); }; XrmPromiseMock.prototype.always = function (alwaysCallback) { return new XrmPromiseMock(this.promise.finally(alwaysCallback)); }; XrmPromiseMock.prototype.catch = function (onRejected) { return new XrmPromiseMock(this.promise.catch(onRejected)); }; XrmPromiseMock.prototype.finally = function (finallyCallback) { return new XrmPromiseMock(this.promise.finally(finallyCallback)); }; /** * Creates a PromiseLike<T> that is resolved with the given value or the result of calling the given function, after a timeout. * @param value value or function that returns a value to resolve the PromiseLike<T> with. * @param timeout The time to wait before resolving the PromiseLike<T> with the value (in milliseconds). Defaults to 1. * @returns PromiseLike<T> for the given value */ XrmPromiseMock.delay = function (value, timeout) { return new XrmPromiseMock(new Promise(function (resolve) { setTimeout(function () { if (typeof value === "function") { value = value(); } resolve(value); }, timeout !== null && timeout !== void 0 ? timeout : 1); })); }; /** * Creates a PromiseLike<void> that is resolved after a timeout. * @param action The action to perform after the timeout. * @param timeout The time to wait before calling the action, and resolving the PromiseLike<void>. Defaults to 1. * @returns PromiseLike<void> */ XrmPromiseMock.delayVoid = function (action, timeout) { return new XrmPromiseMock(new Promise(function (resolve) { setTimeout(function () { if (action) { action(); } resolve(); }, timeout !== null && timeout !== void 0 ? timeout : 1); })); }; return XrmPromiseMock; }()); exports.XrmPromiseMock = XrmPromiseMock; }); define("xrm-mock/app/sidePanes.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SidePanesMock = void 0; var SidePanesMock = /** @class */ (function () { function SidePanesMock() { } SidePanesMock.prototype.createPane = function (paneOptions) { throw new Error("Method not implemented."); }; ; SidePanesMock.prototype.getAllPanes = function () { throw new Error("Method not implemented."); }; ; SidePanesMock.prototype.getPane = function (panelId) { throw new Error("Method not implemented."); }; ; SidePanesMock.prototype.getSelectedPane = function () { throw new Error("Method not implemented."); }; ; return SidePanesMock; }()); exports.SidePanesMock = SidePanesMock; }); define("xrm-mock/app/app.mock", ["require", "exports", "xrm-mock/async/xrmpromise/xrmpromise.mock", "xrm-mock/app/sidePanes.mock"], function (require, exports, xrmpromise_mock_1, sidePanes_mock_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppMock = void 0; var AppMock = /** @class */ (function () { function AppMock() { this.globalNotifications = {}; this.sidePanes = new sidePanes_mock_1.SidePanesMock(); } AppMock.prototype.addGlobalNotification = function (notification) { AppMock.count += 1; var id = "00000000-0000-0000-0000-" + AppMock.count.toString().padStart(12, "0"); this.globalNotifications[id] = notification; return new xrmpromise_mock_1.XrmPromiseMock(Promise.resolve(id)); }; AppMock.prototype.clearGlobalNotification = function (uniqueId) { delete this.globalNotifications[uniqueId]; return new xrmpromise_mock_1.XrmPromiseMock(Promise.resolve(uniqueId)); }; AppMock.count = 0; return AppMock; }()); exports.AppMock = AppMock; }); define("xrm-mock-generator/app", ["require", "exports", "xrm-mock/app/app.mock"], function (require, exports, app_mock_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var App = /** @class */ (function () { function App() { } App.createApp = function () { var app = new app_mock_1.AppMock(); return app; }; return App; }()); exports.default = App; }); define("xrm-mock-generator/form", ["require", "exports", "xrm-mock/index"], function (require, exports, XrmMock) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Form = /** @class */ (function () { function Form() { } Form.createBlankForm = function () { var formItem = new XrmMock.FormItemMock({ currentItem: true, formType: 1, id: "{00000000-0000-0000-0000-000000000000}", label: "", }); return formItem; }; return Form; }()); exports.default = Form; }); define("xrm-mock-generator/ui", ["require", "exports", "xrm-mock/index", "xrm-mock-generator/form"], function (require, exports, XrmMock, form_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Ui = /** @class */ (function () { function Ui() { } Ui.createUi = function () { var ui = new XrmMock.UiMock({ controls: new XrmMock.ItemCollectionMock([]), formSelector: new XrmMock.FormSelectorMock(new XrmMock.ItemCollectionMock([form_1.default.createBlankForm()])), tabs: new XrmMock.ItemCollectionMock([]), }); return ui; }; Ui.createLabelElement = function (label) { return new XrmMock.UiLabelElementMock(label); }; Ui.createCanGetVisibleElement = function (isVisible) { return new XrmMock.UiCanGetVisibleElementMock(isVisible); }; Ui.createStandardElement = function (labelElement, visibleElement) { return new XrmMock.UiStandardElementMock(labelElement, visibleElement); }; return Ui; }()); exports.default = Ui; }); define("xrm-mock-generator/control", ["require", "exports", "xrm-mock/index"], function (require, exports, XrmMock) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Control = /** @class */ (function () { function Control() { } Control.prototype.createBoolean = function (attributeOrComponents, name, visible, disabled, label) { if (visible === void 0) { visible = true; } if (disabled === void 0) { disabled = false; } var components = this.createStandardComponent(attributeOrComponents, name, visible, disabled, label); return this.addControl(new XrmMock.BooleanControlMock(components)); }; Control.prototype.createDate = function (attributeOrComponents, name, visible, disabled, label) { if (visible === void 0) { visible = true; } if (disabled === void 0) { disabled = false; } var components = this.createStandardComponent(attributeOrComponents, name, visible, disabled, label); return this.addControl(new XrmMock.DateControlMock(components)); }; Control.prototype.createGrid = function (nameOrComponents, visible, label) { if (visible === void 0) { visible = true; } var components = nameOrComponents.name ? nameOrComponents : { label: label, name: nameOrComponents, visible: visible }; return this.addControl(new XrmMock.GridControlMock(components)); }; Control.prototype.createLookup = function (attributeOrComponents, name, visible, disabled, label) { if (visible === void 0) { visible = true; } if (disabled === void 0) { disabled = false; } var components = this.createStandardComponent(attributeOrComponents, name, visible, disabled, label); return this.addControl(new XrmMock.LookupControlMock(components)); }; Control.prototype.createNumber = function (attributeOrComponents, name, visible, disabled, label) { if (visible === void 0) { visible = true; } if (disabled === void 0) { disabled = false; } var components = this.createStandardComponent(attributeOrComponents, name, visible, disabled, label); return this.addControl(new XrmMock.NumberControlMock(components)); }; Control.prototype.createOptionSet = function (attributeOrComponents, name, visible, disabled, label) { if (visible === void 0) { visible = true; } if (disabled === void 0) { disabled = false; } var components = this.createStandardComponent(attributeOrComponents, name, visible, disabled, label); return this.addControl(new XrmMock.OptionSetControlMock(components)); }; Control.prototype.createString = function (attributeOrComponents, name, visible, disabled, label) { var components = this.createStandardComponent(attributeOrComponents, name, visible, disabled, label); return this.addControl(new XrmMock.StringControlMock(components)); }; Control.prototype.addControl = function (control) { Xrm.Page.ui.controls.push(control); return control; }; Control.prototype.createStandardComponent = function (attributeOrComponents, name, visible, disabled, label) { var att = attributeOrComponents; return att.controls && att.eventHandlers ? { attribute: attributeOrComponents, disabled: disabled, label: label || name, name: name, visible: visible, } : attributeOrComponents; }; return Control; }()); exports.default = Control; }); define("xrm-mock-generator/attribute", ["require", "exports", "xrm-mock/index", "xrm-mock-generator/control"], function (require, exports, XrmMock, control_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Attribute = /** @class */ (function () { function Attribute() { this.Control = new control_1.default(); } Attribute.prototype.createBoolean = function (nameOrComponents, valueOrControlComponents) { if (typeof (nameOrComponents) === "string") { var components = { name: nameOrComponents, value: valueOrControlComponents }; var controls = [{ name: nameOrComponents }]; return this.associateAttribute(new XrmMock.BooleanAttributeMock(components), controls, "createBoolean"); } else { return this.associateAttribute(new XrmMock.BooleanAttributeMock(nameOrComponents), this.arrayify(valueOrControlComponents), "createBoolean"); } }; Attribute.prototype.createDate = function (nameOrComponents, valueOrControlComponents) { if (typeof (nameOrComponents) === "string") { var components = { name: nameOrComponents, value: valueOrControlComponents }; var controls = [{ name: nameOrComponents }]; return this.associateAttribute(new XrmMock.DateAttributeMock(components), controls, "createDate"); } else { return this.associateAttribute(new XrmMock.DateAttributeMock(nameOrComponents), this.arrayify(valueOrControlComponents), "createDate"); } }; Attribute.prototype.createLookup = function (nameOrComponents, valueOrControlComponents) { if (typeof (nameOrComponents) === "string") { var components = { isPartyList: valueOrControlComponents && Array.isArray(valueOrControlComponents), name: nameOrComponents, value: valueOrControlComponents ? this.arrayify(valueOrControlComponents) : null }; var controls = [{ name: nameOrComponents }]; return this.associateAttribute(new XrmMock.LookupAttributeMock(components), controls, "createLookup"); } else { return this.associateAttribute(new XrmMock.LookupAttributeMock(nameOrComponents), this.arrayify(valueOrControlComponents), "createLookup"); } }; Attribute.prototype.createNumber = function (nameOrComponents, valueOrControlComponents) { if (typeof (nameOrComponents) === "string") { var components = { name: nameOrComponents, value: valueOrControlComponents }; var controls = [{ name: nameOrComponents }]; return this.associateAttribute(new XrmMock.NumberAttributeMock(components), controls, "createNumber"); } else { return this.associateAttribute(new XrmMock.NumberAttributeMock(nameOrComponents), this.arrayify(valueOrControlComponents), "createNumber"); } }; Attribute.prototype.createOptionSet = function (nameOrComponents, valueOrControlComponents, options) { return typeof (nameOrComponents) === "string" ? this.createOptionSetFromParameters(nameOrComponents, valueOrControlComponents, options) : this.createOptionSetFromComponents(nameOrComponents, this.arrayify(valueOrControlComponents)); }; Attribute.prototype.createString = function (nameOrComponents, valueOrControlComponents) { if (valueOrControlComponents === void 0) { valueOrControlComponents = null; } if (typeof (nameOrComponents) === "string") { var components = { name: nameOrComponents, value: valueOrControlComponents }; var controls = [{ name: nameOrComponents }]; return this.associateAttribute(new XrmMock.StringAttributeMock(components), controls, "createString"); } else { return this.associateAttribute(new XrmMock.StringAttributeMock(nameOrComponents), this.arrayify(valueOrControlComponents), "createString"); } }; Attribute.prototype.createOptionSetFromParameters = function (name, value, options) { var num; if (value !== null && value !== undefined) { if (!options) { options = [typeof value === "string" ? { text: value, value: 0 } : { text: value.toString(), value: value }]; } if (typeof value === "string") { var option = options.filter(function (o) { return o.text === value; })[0]; num = option.value; } else { num = value; } } else { num = undefined; } var components = { name: name, options: options, }; if (num || num === 0) { components.value = num; } var controls = [{ name: name, options: options }]; return this.associateAttribute(new XrmMock.OptionSetAttributeMock(components), controls, "createOptionSet"); }; Attribute.prototype.createOptionSetFromComponents = function (components, controls) { if (components.options && components.options.length > 0) { controls.filter(function (c) { return !c.options; }) .forEach(function (c) { c.options = components.options; }); } return this.associateAttribute(new XrmMock.OptionSetAttributeMock(components), controls, "createOptionSet"); }; Attribute.prototype.createStringFromParameters = function (name, value) { var components = { name: name, value: value }; var controls = [{ name: name }]; return this.associateAttribute(new XrmMock.StringAttributeMock(components), controls, "createString"); }; Attribute.prototype.createAttribute = function (name, value) { var attribute = new XrmMock.AttributeMock({ isDirty: false, name: name, submitMode: "dirty", value: value, }); return attribute; }; Attribute.prototype.addAttribute = function (attribute) { Xrm.Page.data.entity.attributes.push(attribute); }; /** * Creates the given attribute, as well as the controls for the attribute defined by the components * @param attribute The newly created attribute to be added to the page colleciton of attributes * @param controls Array of Control Components to create controls for the given attribute * @param controlCreateFunction the name of the Control function to call to create the correct type of control */ Attribute.prototype.associateAttribute = function (attribute, controls, controlCreateFunction) { var _this = this; this.addAttribute(attribute); controls.forEach(function (c) { c.attribute = attribute; _this.defaultName(c, attribute); _this.Control[controlCreateFunction](c); }); return attribute; }; Attribute.prototype.defaultName = function (control, attribute) { var names = []; attribute.controls.forEach(function (c) { names.push(c.getName()); }); if (!control.name) { control.name = attribute.getName(); } else if (names.indexOf(control.name) >= 0) { throw new Error("Name ".concat(control.name, " has already been defined for a control for attribute ").concat(attribute.getName())); } var i = 1; while (names.indexOf(control.name) >= 0) { control.name = attribute.getName() + i++; } }; Attribute.prototype.arrayify = function (possibleArray) { if (!possibleArray) { return []; } else if (possibleArray instanceof Array) { return possibleArray; } else { return [possibleArray]; } }; return Attribute; }()); exports.default = Attribute; }); define("xrm-mock-generator/context", ["require", "exports", "xrm-mock/index"], function (require, exports, XrmMock) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Context = /** @class */ (function () { function Context() { } Context.createContext = function (client) { var context = new XrmMock.ContextMock({ clientContext: new XrmMock.ClientContextMock(client || "Web", "Online"), orgUniqueName: "", userSettings: new XrmMock.UserSettingsMock({ isGuidedHelpEnabled: false, isHighContrastEnabled: false, isRTL: false, securityRolePrivileges: [], securityRoles: [], userId: "{00000000-0000-0000-0000-000000000000}", userName: "jdoe", }), }); return context; }; return Context; }()); exports.default = Context; }); define("xrm-mock/device/device.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeviceMock = void 0; var DeviceMock = /** @class */ (function () { function DeviceMock() { } DeviceMock.prototype.captureAudio = function () { throw new Error("Not implemented."); }; DeviceMock.prototype.captureImage = function (imageOptions) { throw new Error("Not implemented."); }; DeviceMock.prototype.captureVideo = function () { throw new Error("Not implemented."); }; DeviceMock.prototype.getBarcodeValue = function () { throw new Error("Not implemented."); }; DeviceMock.prototype.getCurrentPosition = function () { throw new Error("Not implemented."); }; DeviceMock.prototype.pickFile = function (pickFileOptions) { throw new Error("Not implemented."); }; return DeviceMock; }()); exports.DeviceMock = DeviceMock; }); define("xrm-mock-generator/device", ["require", "exports", "xrm-mock/device/device.mock"], function (require, exports, device_mock_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Device = /** @class */ (function () { function Device() { } Device.createDevice = function () { var device = new device_mock_1.DeviceMock(); return device; }; return Device; }()); exports.default = Device; }); define("xrm-mock/collection/itemcollection/itemcollection.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ItemCollectionMock = void 0; var ItemCollectionMock = /** @class */ (function () { function ItemCollectionMock(itemCollection) { this.itemCollection = itemCollection || []; } ItemCollectionMock.prototype.forEach = function (delegate) { this.itemCollection.map(delegate); }; ItemCollectionMock.prototype.get = function (param) { if (param === undefined || param === null) { return this.itemCollection; } else if (typeof param === "string") { var attribute = void 0; for (var _i = 0, _a = this.itemCollection; _i < _a.length; _i++) { var item = _a[_i]; if (item.getName !== undefined && item.getName() === param) { attribute = item; break; } else if (item.getId !== undefined && item.getId() === param) { attribute = item; break; } } return attribute || null; } else if (typeof param === "number") { return this.itemCollection[param] || null; } else { return this.itemCollection.filter(param); } }; ItemCollectionMock.prototype.getLength = function () { return this.itemCollection.length; }; ItemCollectionMock.prototype.push = function (item) { this.itemCollection.push(item); }; return ItemCollectionMock; }()); exports.ItemCollectionMock = ItemCollectionMock; }); define("xrm-mock/controls/formitem/formitem.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FormItemMock = void 0; var FormItemMock = /** @class */ (function () { function FormItemMock(components) { this.id = components.id; this.label = components.label; this.formType = components.formType; this.currentItem = components.currentItem; } FormItemMock.prototype.getId = function () { return this.id; }; FormItemMock.prototype.getLabel = function () { return this.label; }; FormItemMock.prototype.navigate = function () { throw new Error("Form navigation not implemented."); }; FormItemMock.prototype.getVisible = function () { throw new Error("getVisible not implemented."); }; FormItemMock.prototype.setVisible = function (value) { throw new Error("setVisible not implemented."); }; return FormItemMock; }()); exports.FormItemMock = FormItemMock; }); define("xrm-mock/controls/formselector/formselector.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FormSelectorMock = void 0; var FormSelectorMock = /** @class */ (function () { function FormSelectorMock(items) { this.items = items; } FormSelectorMock.prototype.getCurrentItem = function () { var currentItem; if (this.items.itemCollection && this.items.itemCollection.length) { currentItem = this.items.itemCollection.filter(function (i) { return i.currentItem; })[0] || null; } return currentItem; }; return FormSelectorMock; }()); exports.FormSelectorMock = FormSelectorMock; }); define("xrm-mock/ui/ui.mock", ["require", "exports", "xrm-mock/collection/itemcollection/itemcollection.mock"], function (require, exports, itemcollection_mock_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UiMock = void 0; var UiMock = /** @class */ (function () { function UiMock(components) { this.process = components.process; this.controls = components.controls || new itemcollection_mock_1.ItemCollectionMock([]); this.footerSection = components.footerSection; this.formSelector = components.formSelector; this.headerSection = components.headerSection; this.navigation = components.navigation; this.tabs = components.tabs || new itemcollection_mock_1.ItemCollectionMock([]); this.quickForms = components.quickForms || new itemcollection_mock_1.ItemCollectionMock([]); } UiMock.prototype.setFormNotification = function (message, level, uniqueId) { var formNotificationAlreadyExists = false; if (this.formNotifications && this.formNotifications.length) { formNotificationAlreadyExists = this._getFormNotificationExists(this.formNotifications, uniqueId); } if (formNotificationAlreadyExists) { return false; } else { if (this.formNotifications && this.formNotifications.length) { this.formNotifications.push({ message: message, level: level, uniqueId: uniqueId }); } else { this.formNotifications = [{ message: message, level: level, uniqueId: uniqueId }]; } return true; } }; UiMock.prototype.clearFormNotification = function (uniqueId) { if (this.formNotifications && this.formNotifications.length) { var matchingNotificationsById = this.formNotifications.filter(function (item) { return item.uniqueId === uniqueId; }); if (matchingNotificationsById && matchingNotificationsById.length) { var index = this.formNotifications.indexOf(matchingNotificationsById[0]); this.formNotifications.splice(index, 1); return true; } else { return false; } } return false; }; UiMock.prototype.close = function () { throw new Error(("close not implemented")); }; UiMock.prototype.getFormType = function () { if (this.formSelector) { var currentForm = this.formSelector.getCurrentItem(); if (currentForm) { return currentForm.formType; } } else { return 0 /* XrmEnum.FormType.Undefined */; } }; UiMock.prototype.getViewPortHeight = function () { throw new Error(("getViewPortHeight not implemented")); }; UiMock.prototype.getViewPortWidth = function () { throw new Error(("getViewPortWidth not implemented")); }; UiMock.prototype.refreshRibbon = function () { throw new Error(("refreshRibbon not implemented")); }; UiMock.prototype.setFormEntityName = function (arg) { throw new Error(("setFormEntityName not implemented")); }; UiMock.prototype.addOnLoad = function (handler) { throw new Error(("addOnLoad not implemented")); }; UiMock.prototype.removeOnLoad = function (handler) { throw new Error(("removeOnLoad not implemented")); }; UiMock.prototype._getFormNotificationExists = function (notifications, uniqueId) { var matchingNotificationsById = notifications.filter(function (item) { return item.uniqueId === uniqueId; }); return matchingNotificationsById && matchingNotificationsById.length ? true : false; }; return UiMock; }()); exports.UiMock = UiMock; }); define("xrm-mock-generator/formcontext", ["require", "exports", "xrm-mock/index", "xrm-mock-generator/ui"], function (require, exports, XrmMock, ui_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var FormContext = /** @class */ (function () { function FormContext() { } FormContext.createFormContext = function (entity, ui, process) { return new XrmMock.FormContextMock(new XrmMock.DataMock(new XrmMock.EntityMock(entity), process), ui || ui_1.default.createUi()); }; return FormContext; }()); exports.default = FormContext; }); define("xrm-mock-generator/eventcontext", ["require", "exports", "xrm-mock/index", "xrm-mock-generator/context", "xrm-mock-generator/formcontext"], function (require, exports, XrmMock, context_1, formcontext_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var EventContext = /** @class */ (function () { function EventContext() { } EventContext.createEventContext = function (entity, context, formContext, ui, process) { var eventContext = new XrmMock.EventContextMock({ context: context || context_1.default.createContext(), formContext: formContext || formcontext_1.default.createFormContext(entity, ui, process), }); return eventContext; }; EventContext.Context = new context_1.default(); EventContext.FormContext = new formcontext_1.default(); return EventContext; }()); exports.default = EventContext; }); define("xrm-mock/mobile/mobile.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MobileMock = void 0; var MobileMock = /** @class */ (function () { function MobileMock(offline) { this.offline = offline; } return MobileMock; }()); exports.MobileMock = MobileMock; }); define("xrm-mock/mobileoffline/mobileoffline.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MobileOfflineMock = void 0; var MobileOfflineMock = /** @class */ (function () { function MobileOfflineMock() { } MobileOfflineMock.prototype.isOfflineEnabled = function (entityType) { throw new Error(("not implemented")); }; MobileOfflineMock.prototype.createRecord = function (entityType, data) { throw new Error(("not implemented")); }; MobileOfflineMock.prototype.retrieveRecord = function (entityType, id, options) { throw new Error(("not implemented")); }; MobileOfflineMock.prototype.retrieveMultipleRecords = function (entityType, options, maxPageSize) { throw new Error(("not implemented")); }; MobileOfflineMock.prototype.updateRecord = function (entityType, id, data) { throw new Error(("not implemented")); }; MobileOfflineMock.prototype.deleteRecord = function (entityType, id) { throw new Error(("not implemented")); }; return MobileOfflineMock; }()); exports.MobileOfflineMock = MobileOfflineMock; }); define("xrm-mock-generator/mobile", ["require", "exports", "xrm-mock/mobile/mobile.mock", "xrm-mock/mobileoffline/mobileoffline.mock"], function (require, exports, mobile_mock_1, mobileoffline_mock_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Mobile = /** @class */ (function () { function Mobile() { } Mobile.createMobile = function () { var mobile = new mobile_mock_1.MobileMock(new mobileoffline_mock_1.MobileOfflineMock()); return mobile; }; return Mobile; }()); exports.default = Mobile; }); define("xrm-mock-generator/navigation", ["require", "exports", "xrm-mock/index"], function (require, exports, XrmMock) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Navigation = /** @class */ (function () { function Navigation() { } Navigation.createNavigation = function (client) { var navigation = new XrmMock.NavigationStaticMock(); return navigation; }; return Navigation; }()); exports.default = Navigation; }); define("xrm-mock/controls/uicangetvisibleelement/uicangetvisibleelement.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UiCanGetVisibleElementMock = void 0; var UiCanGetVisibleElementMock = /** @class */ (function () { function UiCanGetVisibleElementMock(isVisible) { this.isVisible = isVisible; } UiCanGetVisibleElementMock.prototype.getVisible = function () { return this.isVisible; }; return UiCanGetVisibleElementMock; }()); exports.UiCanGetVisibleElementMock = UiCanGetVisibleElementMock; }); define("xrm-mock/controls/uilabelelement/uilabelelement.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UiLabelElementMock = void 0; var UiLabelElementMock = /** @class */ (function () { function UiLabelElementMock(label) { this.label = label; } UiLabelElementMock.prototype.getLabel = function () { return this.label; }; UiLabelElementMock.prototype.setLabel = function (label) { this.label = label; }; return UiLabelElementMock; }()); exports.UiLabelElementMock = UiLabelElementMock; }); define("xrm-mock/controls/uistandardelement/uistandardelement.mock", ["require", "exports", "xrm-mock/controls/uicangetvisibleelement/uicangetvisibleelement.mock", "xrm-mock/controls/uilabelelement/uilabelelement.mock"], function (require, exports, uicangetvisibleelement_mock_1, uilabelelement_mock_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UiStandardElementMock = void 0; var UiStandardElementMock = /** @class */ (function () { function UiStandardElementMock(uiLabelElement, uiCanGetVisibleElement) { this.uiLabelElement = uiLabelElement; this.uiCanGetVisibleElement = uiCanGetVisibleElement; } UiStandardElementMock.create = function (label, visible) { if (visible === void 0) { visible = true; } return new UiStandardElementMock(new uilabelelement_mock_1.UiLabelElementMock(label), new uicangetvisibleelement_mock_1.UiCanGetVisibleElementMock(visible)); }; UiStandardElementMock.prototype.setVisible = function (visible) { this.uiCanGetVisibleElement.getVisible = function () { return visible; }; }; UiStandardElementMock.prototype.getVisible = function () { return this.uiCanGetVisibleElement.getVisible(); }; UiStandardElementMock.prototype.getLabel = function () { return this.uiLabelElement.getLabel(); }; UiStandardElementMock.prototype.setLabel = function (label) { this.uiLabelElement.setLabel(label); }; return UiStandardElementMock; }()); exports.UiStandardElementMock = UiStandardElementMock; }); define("xrm-mock-generator/helpers/control.helper", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ControlHelpers = /** @class */ (function () { function ControlHelpers() { } ControlHelpers.setControlsParent = function (controls, parent) { controls.forEach(function (control) { control.parent = parent; }); }; return ControlHelpers; }()); exports.default = ControlHelpers; }); define("xrm-mock-generator/section", ["require", "exports", "xrm-mock/controls/uicangetvisibleelement/uicangetvisibleelement.mock", "xrm-mock/controls/uilabelelement/uilabelelement.mock", "xrm-mock/controls/uistandardelement/uistandardelement.mock", "xrm-mock/index", "xrm-mock-generator/helpers/control.helper"], function (require, exports, uicangetvisibleelement_mock_2, uilabelelement_mock_2, uistandardelement_mock_1, XrmMock, control_helper_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Section = /** @class */ (function () { function Section() { } /** * Creates a section mock added to the XRM parent tab collection. * The section will be added to the parent tab given. * The section will be set as parent in the given controls. * Author: Yagasoft * * @param {string} [name] Logical name of the section. * @param {string} [label] Form label of the section. * @param {boolean} [isVisible] Is the section visible by default? * @param {Xrm.Controls.Tab} [parent] Parent tab. * @param {Xrm.Collection.ItemCollection<Xrm.Controls.Control>} [controls] List of controls in the section. Created by using the Mock Generator. * @returns {XrmMock.SectionMock} Section mock. * @memberof Section */ Section.prototype.createSection = function (name, label, isVisible, parent, controls) { var section = new XrmMock.SectionMock(name, parent, new uistandardelement_mock_1.UiStandardElementMock(new uilabelelement_mock_2.UiLabelElementMock(label), new uicangetvisibleelement_mock_2.UiCanGetVisibleElementMock(isVisible)), controls); if (controls) { control_helper_1.default.setControlsParent(controls, section); } return section; }; return Section; }()); exports.default = Section; }); define("xrm-mock/controls/section/section.mock", ["require", "exports", "xrm-mock/collection/itemcollection/itemcollection.mock", "xrm-mock/controls/uicangetvisibleelement/uicangetvisibleelement.mock", "xrm-mock/controls/uilabelelement/uilabelelement.mock", "xrm-mock/controls/uistandardelement/uistandardelement.mock"], function (require, exports, itemcollection_mock_2, uicangetvisibleelement_mock_3, uilabelelement_mock_3, uistandardelement_mock_2) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SectionMock = void 0; var SectionMock = /** @class */ (function () { function SectionMock(name, parent, uiStandardElement, controls) { this.name = name; this.parent = parent; if (this.parent && this.parent.sections.get(name) == null) { var sections = this.parent.sections; if (sections) { sections.push(this); } } this.uiStandardElement = uiStandardElement || new uistandardelement_mock_2.UiStandardElementMock(new uilabelelement_mock_3.UiLabelElementMock(name), new uicangetvisibleelement_mock_3.UiCanGetVisibleElementMock(true)); this.controls = controls || new itemcollection_mock_2.ItemCollectionMock(); } SectionMock.prototype.getName = function () { return this.name; }; SectionMock.prototype.getParent = function () { return this.parent; }; SectionMock.prototype.setVisible = function (visible) { this.uiStandardElement.setVisible(visible); }; SectionMock.prototype.getVisible = function () { return this.uiStandardElement.getVisible(); }; SectionMock.prototype.getLabel = function () { return this.uiStandardElement.getLabel(); }; SectionMock.prototype.setLabel = function (label) { this.uiStandardElement.setLabel(label); }; return SectionMock; }()); exports.SectionMock = SectionMock; }); define("xrm-mock/controls/uifocusable/uifocusable.mock", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UiFocusableMock = void 0; var UiFocusableMock = /** @class */ (function () { function UiFocusableMock(hasFocus) { if (hasFocus === void 0) { hasFocus = false; } this.hasFocus = hasFocus; } UiFocusableMock.prototype.setFocus = function () { this.hasFocus = true; }; return UiFocusableMock; }()); exports.UiFocusableMock = UiFocusab