UNPKG

xrm-mock

Version:

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

988 lines 125 kB
/// <reference types="xrm" /> declare module "xrm-mock/controls/addcontrolnotificationoptions/addcontrolnotificationoptions.mock" { export class AddControlNotificationOptionsMock implements Xrm.Controls.AddControlNotificationOptions { actions?: Xrm.Controls.ControlNotificationAction[]; messages: string[]; notificationLevel?: Xrm.Controls.NotificationLevel; uniqueId: string; constructor(components: IAddControlNotificationOptionsComponents); } export interface IAddControlNotificationOptionsComponents { actions?: Xrm.Controls.ControlNotificationAction[]; messages: string[]; notificationLevel?: Xrm.Controls.NotificationLevel; uniqueId: string; } } declare module "xrm-mock/navigation/alertstrings/alertstrings.mock" { export class AlertStringsMock implements Xrm.Navigation.AlertStrings { confirmButtonLabel?: string; text: string; constructor(text: string, confirmButtonLabel?: string); } } declare module "xrm-mock/appproperties/appproperties.mock" { export class AppPropertiesMock implements Xrm.AppProperties { appId?: string; displayName?: string; uniqueName?: string; url?: string; webResourceId?: string; webResourceName?: string; welcomePageId?: string; welcomePageName?: string; constructor(components: IAppPropertiesComponents); } export interface IAppPropertiesComponents { appId?: string; displayName?: string; uniqueName?: string; url?: string; webResourceId?: string; webResourceName?: string; welcomePageId?: string; welcomePageName?: string; } } declare module "xrm-mock/metadata/attributemetadata/attributemetadata.mock" { export class AttributeMetadataMock implements Xrm.Metadata.AttributeMetadata { DefaultFormValue: number; LogicalName: string; DisplayName: string; AttributeType: XrmEnum.AttributeTypeCode; EntityLogicalName: string; OptionSet: Xrm.Metadata.OptionMetadata[]; constructor(components: IAttributeMetadataComponents); } export interface IAttributeMetadataComponents { DefaultFormValue?: number; LogicalName?: string; DisplayName?: string; AttributeType?: XrmEnum.AttributeTypeCode; EntityLogicalName?: string; OptionSet?: Xrm.Metadata.OptionMetadata[]; } } declare module "xrm-mock-generator/helpers/array.helper" { export function findIndex(handlers: Xrm.Events.ContextSensitiveHandler[], handler: Xrm.Events.ContextSensitiveHandler): number; } declare module "xrm-mock/async/xrmpromise/xrmpromise.mock" { export class XrmPromiseMock<T> implements Xrm.Async.PromiseLike<T> { private promise; constructor(promise: Promise<T>); then<U>(onFulfilled?: (value: T) => U | Xrm.Async.PromiseLike<U>, onRejected?: (error: any) => U | Xrm.Async.PromiseLike<U> | void): Xrm.Async.PromiseLike<U>; fail<U>(onRejected?: (reason: Xrm.ErrorResponse) => U | Xrm.Async.PromiseLike<U>): Xrm.Async.PromiseLike<U>; always<U>(alwaysCallback: () => U | Xrm.Async.PromiseLike<U>): Xrm.Async.PromiseLike<U>; catch<U>(onRejected?: (reason: Xrm.ErrorResponse) => U | Xrm.Async.PromiseLike<U>): Xrm.Async.PromiseLike<U>; finally<U>(finallyCallback: () => U | Xrm.Async.PromiseLike<U>): Xrm.Async.PromiseLike<U>; /** * 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 */ static delay<T>(value: T | (() => T), timeout?: number): Xrm.Async.PromiseLike<T>; /** * 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> */ static delayVoid(action?: () => void, timeout?: number): Xrm.Async.PromiseLike<void>; } } declare module "xrm-mock/app/sidePanes.mock" { export class SidePanesMock { state: number; createPane(paneOptions?: Xrm.App.PaneOptions): Xrm.Async.PromiseLike<Xrm.App.PaneObject>; getAllPanes(): Xrm.App.PaneObject[]; getPane(panelId: string): Xrm.App.PaneObject; getSelectedPane(): Xrm.App.PaneObject; } } declare module "xrm-mock/app/app.mock" { export class AppMock implements Xrm.App { globalNotifications: { [index: string]: Xrm.App.Notification; }; private static count; constructor(); addGlobalNotification(notification: Xrm.App.Notification): Xrm.Async.PromiseLike<string>; clearGlobalNotification(uniqueId: string): Xrm.Async.PromiseLike<string>; sidePanes: { state: number; createPane(paneOptions?: Xrm.App.PaneOptions): Xrm.Async.PromiseLike<Xrm.App.PaneObject>; getAllPanes(): Xrm.App.PaneObject[]; getPane(panelId: string): Xrm.App.PaneObject | undefined; getSelectedPane(): Xrm.App.PaneObject; }; } } declare module "xrm-mock-generator/app" { import { AppMock } from "xrm-mock/app/app.mock"; export default class App { static createApp(): AppMock; } } declare module "xrm-mock-generator/form" { import * as XrmMock from "xrm-mock/index"; export default class Form { static createBlankForm(): XrmMock.FormItemMock; } } declare module "xrm-mock-generator/ui" { import * as XrmMock from "xrm-mock/index"; export default class Ui { static createUi(): XrmMock.UiMock; static createLabelElement(label: string): XrmMock.UiLabelElementMock; static createCanGetVisibleElement(isVisible: boolean): XrmMock.UiCanGetVisibleElementMock; static createStandardElement(labelElement: Xrm.Page.UiLabelElement, visibleElement: Xrm.Page.UiCanGetVisibleElement): XrmMock.UiStandardElementMock; } } declare module "xrm-mock-generator/control" { import * as XrmMock from "xrm-mock/index"; export type CreateMethods = "createBoolean" | "createDate" | "createLookup" | "createNumber" | "createOptionSet" | "createString"; export default class Control { createBoolean(components: XrmMock.IBooleanControlComponents): XrmMock.BooleanControlMock; createBoolean(attribute: XrmMock.BooleanAttributeMock, name?: string, visible?: boolean, disabled?: boolean, label?: string): XrmMock.BooleanControlMock; createDate(components: XrmMock.IDateControlComponents): XrmMock.DateControlMock; createDate(attribute: XrmMock.DateAttributeMock, name?: string, visible?: boolean, disabled?: boolean, label?: string): XrmMock.DateControlMock; createGrid(components: XrmMock.IGridControlComponents): XrmMock.GridControlMock; createGrid(name?: string, visible?: boolean, label?: string): XrmMock.GridControlMock; createLookup(components: XrmMock.ILookupControlComponents): XrmMock.LookupControlMock; createLookup(attribute: XrmMock.LookupAttributeMock, name?: string, visible?: boolean, disabled?: boolean, label?: string): XrmMock.LookupControlMock; createNumber(components: XrmMock.INumberControlComponents): XrmMock.NumberControlMock; createNumber(attribute: XrmMock.NumberAttributeMock, name?: string, visible?: boolean, disabled?: boolean, label?: string): XrmMock.NumberControlMock; createOptionSet(components: XrmMock.IOptionSetControlComponents): XrmMock.OptionSetControlMock; createOptionSet(attribute: XrmMock.OptionSetAttributeMock, name?: string, visible?: boolean, disabled?: boolean, label?: string): XrmMock.OptionSetControlMock; createString(components: XrmMock.IStringControlComponents): XrmMock.StringControlMock; createString(attribute: XrmMock.StringAttributeMock, name?: string, visible?: boolean, disabled?: boolean, label?: string): XrmMock.StringControlMock; private addControl; private createStandardComponent; } } declare module "xrm-mock-generator/attribute" { import * as XrmMock from "xrm-mock/index"; export type BooleanControlComponent = XrmMock.IAttBooleanControlComponents | XrmMock.IAttBooleanControlComponents[]; export type DateControlComponent = XrmMock.IAttDateControlComponents | XrmMock.IAttDateControlComponents[]; export type LookupControlComponent = XrmMock.IAttLookupControlComponents | XrmMock.IAttLookupControlComponents[]; export type NumberControlComponent = XrmMock.IAttNumberControlComponents | XrmMock.IAttNumberControlComponents[]; export type OptionSetControlComponent = XrmMock.IAttOptionSetControlComponents | XrmMock.IAttOptionSetControlComponents[]; export type StringControlComponent = XrmMock.IAttStringControlComponents | XrmMock.IAttStringControlComponents[]; export default class Attribute { private Control; createBoolean(attComponents: XrmMock.IBooleanAttributeComponents, controlComponents?: BooleanControlComponent): XrmMock.BooleanAttributeMock; createBoolean(name: string, value?: boolean): XrmMock.BooleanAttributeMock; createDate(attComponents: XrmMock.IDateAttributeComponents, controlComponents?: DateControlComponent): XrmMock.DateAttributeMock; createDate(name: string, value?: Date): XrmMock.DateAttributeMock; createLookup(attComponents: XrmMock.ILookupAttributeComponents, controlComponents?: LookupControlComponent): XrmMock.LookupAttributeMock; createLookup(name: string, lookup?: Xrm.LookupValue | Xrm.LookupValue[]): XrmMock.LookupAttributeMock; createNumber(attComponents: XrmMock.INumberAttributeComponents, controlComponents?: NumberControlComponent): XrmMock.NumberAttributeMock; createNumber(name: string, value?: number): XrmMock.NumberAttributeMock; createOptionSet(attComponents: XrmMock.IOptionSetAttributeComponents, controlComponents?: OptionSetControlComponent): XrmMock.OptionSetAttributeMock; createOptionSet(name: string, value?: string | number, options?: Xrm.OptionSetValue[]): XrmMock.OptionSetAttributeMock; createString(attComponents: XrmMock.IStringAttributeComponents, controlComponents?: StringControlComponent): XrmMock.StringAttributeMock; createString(name: string, value?: string): XrmMock.StringAttributeMock; private createOptionSetFromParameters; private createOptionSetFromComponents; private createStringFromParameters; private createAttribute; private addAttribute; /** * 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 */ private associateAttribute; private defaultName; private arrayify; } } declare module "xrm-mock-generator/context" { import * as XrmMock from "xrm-mock/index"; export default class Context { static createContext(client?: Xrm.Client): XrmMock.ContextMock; } } declare module "xrm-mock/device/device.mock" { export class DeviceMock implements Xrm.Device { captureAudio(): Xrm.Async.PromiseLike<Xrm.Device.CaptureFileResponse>; captureImage(imageOptions: Xrm.Device.CaptureImageOptions): Xrm.Async.PromiseLike<Xrm.Device.CaptureFileResponse>; captureVideo(): Xrm.Async.PromiseLike<Xrm.Device.CaptureFileResponse>; getBarcodeValue(): Xrm.Async.PromiseLike<string>; getCurrentPosition(): Xrm.Async.PromiseLike<Xrm.Device.GetCurrentPositionResponse>; pickFile(pickFileOptions: Xrm.Device.PickFileOptions): Xrm.Async.PromiseLike<Xrm.Device.CaptureFileResponse[]>; } } declare module "xrm-mock-generator/device" { import { DeviceMock } from "xrm-mock/device/device.mock"; export default class Device { static createDevice(): DeviceMock; } } declare module "xrm-mock/collection/itemcollection/itemcollection.mock" { export class ItemCollectionMock<T> implements Xrm.Collection.ItemCollection<T> { itemCollection: T[]; constructor(itemCollection?: T[]); forEach(delegate: Xrm.Collection.IterativeDelegate<T>): void; get(delegate: Xrm.Collection.MatchingDelegate<T>): T[]; get(item: number | string): T; get(): T[]; getLength(): number; push(item: T): void; } } declare module "xrm-mock/controls/formitem/formitem.mock" { export class FormItemMock implements Xrm.Controls.FormItem { id: string; label: string; formType: XrmEnum.FormType; currentItem: boolean; constructor(components: IFormItemComponents); getId(): string; getLabel(): string; navigate(): void; getVisible(): boolean; setVisible(value: boolean): boolean; } export interface IFormItemComponents { id: string; label: string; formType?: XrmEnum.FormType; currentItem?: boolean; } } declare module "xrm-mock/controls/formselector/formselector.mock" { import { ItemCollectionMock } from "xrm-mock/collection/itemcollection/itemcollection.mock"; import { FormItemMock } from "xrm-mock/controls/formitem/formitem.mock"; export class FormSelectorMock implements Xrm.Controls.FormSelector { items: ItemCollectionMock<FormItemMock>; constructor(items: ItemCollectionMock<FormItemMock>); getCurrentItem(): Xrm.Controls.FormItem; } } declare module "xrm-mock/ui/ui.mock" { import { FormSelectorMock } from "xrm-mock/controls/formselector/formselector.mock"; export class UiMock implements Xrm.Ui { process: Xrm.Controls.ProcessControl; controls: Xrm.Collection.ItemCollection<Xrm.Controls.Control>; footerSection: Xrm.Controls.FooterSection; formSelector: FormSelectorMock; headerSection: Xrm.Controls.HeaderSection; navigation: Xrm.Controls.Navigation; tabs: Xrm.Collection.ItemCollection<Xrm.Controls.Tab>; quickForms: Xrm.Collection.ItemCollection<Xrm.Controls.QuickFormControl>; formNotifications: [{ message: string; level: Xrm.Page.ui.FormNotificationLevel; uniqueId: string; }]; constructor(components: IUiComponents); setFormNotification(message: string, level: Xrm.Page.ui.FormNotificationLevel, uniqueId: string): boolean; clearFormNotification(uniqueId: string): boolean; close(): void; getFormType(): XrmEnum.FormType; getViewPortHeight(): number; getViewPortWidth(): number; refreshRibbon(): void; setFormEntityName(arg: string): void; addOnLoad(handler: Xrm.Events.ContextSensitiveHandler): void; removeOnLoad(handler: Xrm.Events.ContextSensitiveHandler): void; private _getFormNotificationExists; } export interface IUiComponents { process?: Xrm.Controls.ProcessControl; controls?: Xrm.Collection.ItemCollection<Xrm.Controls.Control>; footerSection?: Xrm.Controls.FooterSection; formSelector?: FormSelectorMock; headerSection?: Xrm.Controls.HeaderSection; navigation?: Xrm.Controls.Navigation; tabs?: Xrm.Collection.ItemCollection<Xrm.Controls.Tab>; quickForms?: Xrm.Collection.ItemCollection<Xrm.Controls.QuickFormControl>; } } declare module "xrm-mock-generator/formcontext" { import * as XrmMock from "xrm-mock/index"; export default class FormContext { static createFormContext(entity?: XrmMock.IEntityComponents, ui?: XrmMock.IUiComponents, process?: Xrm.ProcessFlow.ProcessManager): XrmMock.FormContextMock; } } declare module "xrm-mock-generator/eventcontext" { import * as XrmMock from "xrm-mock/index"; import Context from "xrm-mock-generator/context"; import FormContext from "xrm-mock-generator/formcontext"; export default class EventContext { static Context: Context; static FormContext: FormContext; static createEventContext(entity?: XrmMock.IEntityComponents, context?: Xrm.GlobalContext, formContext?: Xrm.FormContext, ui?: XrmMock.IUiComponents, process?: Xrm.ProcessFlow.ProcessManager): XrmMock.EventContextMock; } } declare module "xrm-mock/mobile/mobile.mock" { export class MobileMock implements Xrm.Mobile { offline: Xrm.MobileOffline; constructor(offline: Xrm.MobileOffline); } } declare module "xrm-mock/mobileoffline/mobileoffline.mock" { export class MobileOfflineMock implements Xrm.MobileOffline { isOfflineEnabled(entityType: string): boolean; createRecord(entityType: string, data: { [attributeName: string]: any; }): Xrm.Async.PromiseLike<Xrm.Async.OfflineOperationSuccessCallbackObject>; retrieveRecord(entityType: string, id: string, options: string): Xrm.Async.PromiseLike<Xrm.Async.OfflineOperationSuccessCallbackObject>; retrieveMultipleRecords(entityType: string, options: string, maxPageSize: number): Xrm.Async.PromiseLike<Array<{ [key: string]: any; }>>; updateRecord(entityType: string, id: string, data: { [attributeName: string]: any; }): Xrm.Async.PromiseLike<Xrm.Async.OfflineOperationSuccessCallbackObject>; deleteRecord(entityType: string, id: string): Xrm.Async.PromiseLike<Xrm.Async.OfflineOperationSuccessCallbackObject>; } } declare module "xrm-mock-generator/mobile" { import { MobileMock } from "xrm-mock/mobile/mobile.mock"; export default class Mobile { static createMobile(): MobileMock; } } declare module "xrm-mock-generator/navigation" { import * as XrmMock from "xrm-mock/index"; export default class Navigation { static createNavigation(client?: Xrm.Client): XrmMock.NavigationStaticMock; } } declare module "xrm-mock/controls/uicangetvisibleelement/uicangetvisibleelement.mock" { export class UiCanGetVisibleElementMock implements Xrm.Controls.UiCanGetVisibleElement { isVisible: boolean; constructor(isVisible: boolean); getVisible(): boolean; } } declare module "xrm-mock/controls/uilabelelement/uilabelelement.mock" { export class UiLabelElementMock implements Xrm.Controls.UiLabelElement { private label; constructor(label: string); getLabel(): string; setLabel(label: string): void; } } declare module "xrm-mock/controls/uistandardelement/uistandardelement.mock" { export class UiStandardElementMock implements Xrm.Controls.UiStandardElement { static create(label: string, visible?: boolean): UiStandardElementMock; uiLabelElement: Xrm.Controls.UiLabelElement; uiCanGetVisibleElement: Xrm.Controls.UiCanGetVisibleElement; constructor(uiLabelElement: Xrm.Controls.UiLabelElement, uiCanGetVisibleElement: Xrm.Controls.UiCanGetVisibleElement); setVisible(visible: boolean): void; getVisible(): boolean; getLabel(): string; setLabel(label: string): void; } } declare module "xrm-mock-generator/helpers/control.helper" { export default class ControlHelpers { static setControlsParent(controls: Xrm.Collection.ItemCollection<Xrm.Controls.Control | Xrm.Controls.Section>, parent: Xrm.Controls.Section | Xrm.Controls.Tab): void; } } declare module "xrm-mock-generator/section" { import * as XrmMock from "xrm-mock/index"; export default class 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 */ createSection(name?: string, label?: string, isVisible?: boolean, parent?: Xrm.Controls.Tab, controls?: Xrm.Collection.ItemCollection<Xrm.Controls.Control>): XrmMock.SectionMock; } } declare module "xrm-mock/controls/section/section.mock" { export class SectionMock implements Xrm.Controls.Section { controls: Xrm.Collection.ItemCollection<Xrm.Controls.Control>; parent: Xrm.Controls.Tab; private name; private uiStandardElement; constructor(name: string, parent?: Xrm.Controls.Tab, uiStandardElement?: Xrm.Controls.UiStandardElement, controls?: Xrm.Collection.ItemCollection<Xrm.Controls.Control>); getName(): string; getParent(): Xrm.Controls.Tab; setVisible(visible: boolean): void; getVisible(): boolean; getLabel(): string; setLabel(label: string): void; } } declare module "xrm-mock/controls/uifocusable/uifocusable.mock" { export class UiFocusableMock implements Xrm.Controls.UiFocusable { hasFocus: boolean; constructor(hasFocus?: boolean); setFocus(): void; } } declare module "xrm-mock/controls/tab/tab.mock" { export class TabMock implements Xrm.Controls.Tab { sections: Xrm.Collection.ItemCollection<Xrm.Controls.Section>; tabStateChangeHandlers: Xrm.Events.ContextSensitiveHandler[]; private uiStandardElement; private uiFocusableElement; private name; private parent; private displayState; constructor(components: ITabComponents); getDisplayState(): Xrm.DisplayState; getName(): string; getParent(): Xrm.Ui; setDisplayState(displayState: Xrm.DisplayState): void; setVisible(visible: boolean): void; getVisible(): boolean; getLabel(): string; setLabel(label: string): void; setFocus(): void; addTabStateChange(handler: (context: Xrm.Events.EventContext) => void): void; removeTabStateChange(handler: (context: Xrm.Events.EventContext) => void): void; } export interface ITabComponents { uiStandardElement?: Xrm.Controls.UiStandardElement; uiFocusableElement?: Xrm.Controls.UiFocusable; name?: string; parent?: Xrm.Ui; displayState?: Xrm.DisplayState; sections?: Xrm.Collection.ItemCollection<Xrm.Controls.Section>; tabStateChangeHandlers?: Xrm.Events.ContextSensitiveHandler[]; } } declare module "xrm-mock-generator/tab" { import * as XrmMock from "xrm-mock/index"; export default class Tab { /** * Creates a tab mock added to the XRM tabs collection. * The tab will be set as parent in the given sections. * Author: Yagasoft * * @param {string} [name] Logical name of the tab. * @param {string} [label] Form label of the tab. * @param {boolean} [isVisible] Is the tab visible by default? * @param {Xrm.DisplayState} [displayState] Is the tab collapsed or expanded? * @param {Xrm.ui} [parent] Parent UI. * @param {Xrm.Collection.ItemCollection<Xrm.Controls.Section>} [sections] List of sections in the tab. Created by using the Mock Generator. * @returns {XrmMock.TabMock} Tab mock. * @memberof Tab */ createTab(name?: string, label?: string, isVisible?: boolean, displayState?: Xrm.DisplayState, parent?: Xrm.Ui, sections?: Xrm.Collection.ItemCollection<Xrm.Controls.Section>): XrmMock.TabMock; } } declare module "xrm-mock/utility/utility.mock" { export class UtilityMock implements Xrm.Utility { alertDialog(message: string, onCloseCallback: () => void): void; confirmDialog(message: string, yesCloseCallback: () => void, noCloseCallback: () => void): void; isActivityType(entityType: string): boolean; openQuickCreate(entityLogicalName: string, createFromEntity?: Xrm.LookupValue, parameters?: Xrm.Utility.OpenParameters): Xrm.Async.PromiseLike<Xrm.Async.OpenQuickCreateSuccessCallbackObject>; openEntityForm(name: string, id?: string, parameters?: Xrm.Utility.FormOpenParameters, windowOptions?: Xrm.Utility.WindowOptions): void; openWebResource(webResourceName: string, webResourceData?: string, width?: number, height?: number): Window; closeProgressIndicator(): void; getAllowedStatusTransitions(entityName: string, stateCode: number): Xrm.Async.PromiseLike<any>; getEntityMetadata(entityName: string, attributes?: string[]): Xrm.Async.PromiseLike<Xrm.Metadata.EntityMetadata>; getGlobalContext(): Xrm.GlobalContext; getResourceString(webResourceName: string, key: string): string; invokeProcessAction(name: string, parameters: Xrm.Collection.Dictionary<any>): Xrm.Async.PromiseLike<any>; lookupObjects(lookupOptions: Xrm.LookupOptions): Xrm.Async.PromiseLike<Xrm.LookupValue[]>; refreshParentGrid(lookupOptions: Xrm.LookupValue): void; showProgressIndicator(message: string): void; getLearningPathAttributeName(): string; getPageContext(): any; } } declare module "xrm-mock-generator/utility" { import { UtilityMock } from "xrm-mock/utility/utility.mock"; export default class Utility { static createUtility(): UtilityMock; } } declare module "xrm-mock-generator/webapi" { import * as XrmMock from "xrm-mock/index"; export default class WebApi { static createApi(clientContext: Xrm.ClientContext): XrmMock.WebApiMock; private static createOfflineApi; private static createOnlineApi; } } declare module "xrm-mock-generator/xrm-mock-generator" { import * as XrmMock from "xrm-mock/index"; import App from "xrm-mock-generator/app"; import Attribute from "xrm-mock-generator/attribute"; import Context from "xrm-mock-generator/context"; import Control from "xrm-mock-generator/control"; import Device from "xrm-mock-generator/device"; import EventContext from "xrm-mock-generator/eventcontext"; import Form from "xrm-mock-generator/form"; import FormContext from "xrm-mock-generator/formcontext"; import Mobile from "xrm-mock-generator/mobile"; import Navigation from "xrm-mock-generator/navigation"; import Section from "xrm-mock-generator/section"; import Tab from "xrm-mock-generator/tab"; import Utility from "xrm-mock-generator/utility"; import WebApi from "xrm-mock-generator/webapi"; export class XrmMockGenerator { static EventContext: EventContext; static FormContext: FormContext; static Attribute: Attribute; static Context: Context; static Control: Control; static Device: Device; static Mobile: Mobile; static Tab: Tab; static Section: Section; static Form: Form; static Navigation: Navigation; static WebApi: WebApi; static Utility: Utility; static App: App; static context: XrmMock.ContextMock; static formContext: XrmMock.FormContextMock; static eventContext: XrmMock.EventContextMock; static initialise(components?: IXrmGeneratorComponents): XrmMock.XrmStaticMock; static getEventContext(): XrmMock.EventContextMock; static getFormContext(): XrmMock.FormContextMock; } export interface IXrmGeneratorComponents { context?: XrmMock.ContextMock; ui?: XrmMock.IUiComponents; entity?: XrmMock.IEntityComponents; process?: Xrm.ProcessFlow.ProcessManager; } } declare module "xrm-mock/controls/control/control.mock" { export class ControlMock implements Xrm.Controls.Control { controlType: Xrm.Controls.ControlType; name: string; parent: Xrm.Controls.Section; label: string; visible: boolean; constructor(components: IControlComponents); getControlType(): Xrm.Controls.ControlType | string; getName(): string; getParent(): Xrm.Controls.Section; getLabel(): string; setLabel(label: string): void; getVisible(): boolean; } export interface IControlComponents extends IAttControlComponents { name: string; } export interface IAttControlComponents { name?: string; controlType?: Xrm.Controls.ControlType; label?: string; visible?: boolean; parent?: Xrm.Controls.Section; } } declare module "xrm-mock/events/eventcontext/eventcontext.mock" { export class EventContextMock implements Xrm.Events.EventContext { context: Xrm.GlobalContext; depth: number; eventSource: Xrm.Attributes.Attribute | Xrm.Controls.Control | Xrm.Entity; formContext: Xrm.FormContext; sharedVariables: { [index: string]: any; }; constructor(components: IEventContextComponents); getContext(): Xrm.GlobalContext; getDepth(): number; setDepth(depth: number): void; getEventSource(): Xrm.Attributes.Attribute | Xrm.Controls.Control | Xrm.Entity; getFormContext(): Xrm.FormContext; getSharedVariable<T>(key: string): T; setSharedVariable<T>(key: string, value: T): void; } export interface IEventContextComponents { context?: Xrm.GlobalContext; depth?: number; eventSource?: Xrm.Attributes.Attribute | Xrm.Controls.Control | Xrm.Entity; formContext?: Xrm.FormContext; sharedVariables?: { [index: string]: any; }; } } declare module "xrm-mock/controls/standardcontrol/standardcontrol.mock" { import { AttributeMock, AttributeReturnType } from "xrm-mock/attributes/attribute/attribute.mock"; import { ControlMock, IAttControlComponents, IControlComponents } from "xrm-mock/controls/control/control.mock"; export class StandardControlMock<TControl extends StandardControlMock<TControl, TAttribute, TValue>, TAttribute extends AttributeMock<TControl, TAttribute, TValue>, TValue extends AttributeReturnType> extends ControlMock implements Xrm.Controls.StandardControl { disabled: boolean; attribute: TAttribute; protected outChangedEventHandlers: Xrm.Events.ContextSensitiveHandler[]; protected uiStandardElement: Xrm.Controls.UiStandardElement; protected uiFocusable: Xrm.Controls.UiFocusable; protected notifications: Xrm.Controls.AddControlNotificationOptions[]; constructor(components: IStandardControlComponents<TControl, TAttribute, TValue>); addNotification(notification: Xrm.Controls.AddControlNotificationOptions): void; /** * Fires the action event(s) of the first notification if it is a RECOMMENDATION notification level. * @returns true if it was able to apply the notification, false otherwise */ applyNotification(): boolean; clearNotification(uniqueId?: string): boolean; getDisabled(): boolean; getNotifications(): Xrm.Controls.AddControlNotificationOptions[]; setDisabled(disabled: boolean): void; setNotification(message: string, uniqueId: string): boolean; getAttribute(): TAttribute; getLabel(): string; setLabel(label: string): void; getVisible(): boolean; setVisible(visible: boolean): void; setFocus(): void; getOutputs(): { [index: string]: Xrm.Controls.FieldControlOutput; }; addOnOutputChange(handler: Xrm.Events.ContextSensitiveHandler): void; fireOnOutputChange(): void; removeOnOutputChange(handler: Xrm.Events.ContextSensitiveHandler): void; } export interface IStandardControlComponents<TControl extends StandardControlMock<TControl, TAttribute, TValue>, TAttribute extends AttributeMock<TControl, TAttribute, TValue>, TValue extends AttributeReturnType> extends IAttStandardControlComponents<TControl, TAttribute, TValue>, IControlComponents { attribute: TAttribute; name: string; } export interface IAttStandardControlComponents<TControl extends StandardControlMock<TControl, TAttribute, TValue>, TAttribute extends AttributeMock<TControl, TAttribute, TValue>, TValue extends AttributeReturnType> extends IAttControlComponents { disabled?: boolean; label?: string; visible?: boolean; hasFocus?: boolean; } } declare module "xrm-mock/attributes/attribute/attribute.mock" { import { ItemCollectionMock } from "xrm-mock/collection/itemcollection/itemcollection.mock"; import { StandardControlMock } from "xrm-mock/controls/standardcontrol/standardcontrol.mock"; export type AttributeReturnType = boolean | Date | number | Xrm.LookupValue[] | string | null; export class AttributeMock<TControl extends StandardControlMock<TControl, TAttribute, TValue>, TAttribute extends AttributeMock<TControl, TAttribute, TValue>, TValue extends AttributeReturnType> implements Xrm.Attributes.Attribute { attributeType: Xrm.Attributes.AttributeType; controls: ItemCollectionMock<TControl>; isDirty: boolean; name: string; requiredLevel: Xrm.Attributes.RequirementLevel; submitMode: Xrm.SubmitMode; value: TValue; format: Xrm.Attributes.AttributeFormat; eventHandlers: Xrm.Events.ContextSensitiveHandler[]; constructor(components: IAttributeComponents<TControl, TAttribute, TValue>); addOnChange(handler: Xrm.Events.ContextSensitiveHandler): void; fireOnChange(): void; getAttributeType(): Xrm.Attributes.AttributeType; getFormat(): Xrm.Attributes.AttributeFormat; getIsDirty(): boolean; getName(): string; getParent(): Xrm.Entity; getRequiredLevel(): Xrm.Attributes.RequirementLevel; getSubmitMode(): Xrm.SubmitMode; getUserPrivilege(): Xrm.Privilege; removeOnChange(handler: Xrm.Events.ContextSensitiveHandler): void; setRequiredLevel(requirementLevel: Xrm.Attributes.RequirementLevel): void; setSubmitMode(submitMode: Xrm.SubmitMode): void; getValue(): TValue; setValue(value: TValue): void; isValid(): boolean; setIsValid(valid: boolean, message: string): void; } export interface IAttributeComponents<TControl extends StandardControlMock<TControl, TAttribute, TValue>, TAttribute extends AttributeMock<TControl, TAttribute, TValue>, TValue extends AttributeReturnType> { attributeType?: Xrm.Attributes.AttributeType; controls?: ItemCollectionMock<TControl>; eventHandlers?: Xrm.Events.ContextSensitiveHandler[]; format?: Xrm.Attributes.AttributeFormat; isDirty?: boolean; name: string; requiredLevel?: Xrm.Attributes.RequirementLevel; submitMode?: Xrm.SubmitMode; value?: TValue | null; } } declare module "xrm-mock/controls/autocompletecommand/autocompletecommand.mock" { export class AutoCompleteCommandMock implements Xrm.Controls.AutoCompleteCommand { id: string; icon?: string; label: string; constructor(id: string, label: string, icon?: string, action?: () => void); action(): void; } } declare module "xrm-mock/controls/autocompleteresult/autocompleteresult.mock" { export class AutoCompleteResultMock implements Xrm.Controls.AutoCompleteResult { id: string | number; icon?: string; fields: string[]; constructor(id: string | number, fields: string[], icon?: string); } } declare module "xrm-mock/controls/autocompleteresultset/autocompleteresultset.mock" { export class AutoCompleteResultSetMock implements Xrm.Controls.AutoCompleteResultSet { results: Xrm.Controls.AutoCompleteResult[]; commands?: Xrm.Controls.AutoCompleteCommand; constructor(results: Xrm.Controls.AutoCompleteResult[], commands?: Xrm.Controls.AutoCompleteCommand); } } declare module "xrm-mock/controls/uikeypressable/uikeypressable.mock" { export class UiKeyPressableMock implements Xrm.Controls.UiKeyPressable { keyPressHandlers?: Xrm.Events.ContextSensitiveHandler[]; constructor(keyPressHandlers?: Xrm.Events.ContextSensitiveHandler[]); addOnKeyPress(handler: Xrm.Events.ContextSensitiveHandler): void; fireOnKeyPress(eventContext?: Xrm.Events.EventContext): void; removeOnKeyPress(handler: Xrm.Events.ContextSensitiveHandler): void; } } declare module "xrm-mock/controls/autolookupcontrol/autolookupcontrol.mock" { import { AttributeMock, AttributeReturnType } from "xrm-mock/attributes/attribute/attribute.mock"; import { IAttStandardControlComponents, IStandardControlComponents, StandardControlMock } from "xrm-mock/controls/standardcontrol/standardcontrol.mock"; import { UiKeyPressableMock } from "xrm-mock/controls/uikeypressable/uikeypressable.mock"; export class AutoLookupControlMock<TControl extends AutoLookupControlMock<TControl, TAttribute, TValue>, TAttribute extends AttributeMock<TControl, TAttribute, TValue>, TValue extends AttributeReturnType> extends StandardControlMock<TControl, TAttribute, TValue> implements Xrm.Controls.AutoLookupControl { uiKeyPressable: UiKeyPressableMock; /** * Allows for testing the value typed into the control, but not yet saved */ uncommittedText: string; constructor(components: IAutoLookupControlComponents<TControl, TAttribute, TValue>); getValue(): string; hideAutoComplete(): void; showAutoComplete(resultSet: Xrm.Controls.AutoCompleteResultSet): void; addOnKeyPress(handler: Xrm.Events.ContextSensitiveHandler): void; fireOnKeyPress(): void; removeOnKeyPress(handler: Xrm.Events.ContextSensitiveHandler): void; } export interface IAutoLookupControlComponents<TControl extends AutoLookupControlMock<TControl, TAttribute, TValue>, TAttribute extends AttributeMock<TControl, TAttribute, TValue>, TValue extends AttributeReturnType> extends IStandardControlComponents<TControl, TAttribute, TValue>, IAttAutoLookupControlComponents<TControl, TAttribute, TValue> { name: string; } export interface IAttAutoLookupControlComponents<TControl extends AutoLookupControlMock<TControl, TAttribute, TValue>, TAttribute extends AttributeMock<TControl, TAttribute, TValue>, TValue extends AttributeReturnType> extends IAttStandardControlComponents<TControl, TAttribute, TValue> { keyPressHandlers?: Xrm.Events.ContextSensitiveHandler[]; /** * Auto Lookup allows for getting the value that has currently been typed in, * but not necessarily saved to the attribute */ uncommittedText?: string; } } declare module "xrm-mock/controls/booleancontrol/booleancontrol.mock" { import { BooleanAttributeMock } from "xrm-mock/attributes/booleanattribute/booleanattribute.mock"; import { IAttStandardControlComponents, IStandardControlComponents, StandardControlMock } from "xrm-mock/controls/standardcontrol/standardcontrol.mock"; export class BooleanControlMock extends StandardControlMock<BooleanControlMock, BooleanAttributeMock, boolean> implements Xrm.Controls.BooleanControl { private static defaultComponents; constructor(components: IBooleanControlComponents); } export interface IBooleanControlComponents extends IStandardControlComponents<BooleanControlMock, BooleanAttributeMock, boolean>, IAttBooleanControlComponents { name: string; } export interface IAttBooleanControlComponents extends IAttStandardControlComponents<BooleanControlMock, BooleanAttributeMock, boolean> { } } declare module "xrm-mock/attributes/enumattribute/enumattribute.mock" { import { StandardControlMock } from "xrm-mock/controls/standardcontrol/standardcontrol.mock"; import { AttributeMock, IAttributeComponents } from "xrm-mock/attributes/attribute/attribute.mock"; export class EnumAttributeMock<TControl extends StandardControlMock<TControl, TAttribute, TValue>, TAttribute extends EnumAttributeMock<TControl, TAttribute, TValue>, TValue extends number | boolean> extends AttributeMock<TControl, TAttribute, TValue> implements Xrm.Attributes.EnumAttribute<TValue> { initialValue: TValue; constructor(components: IEnumAttributeComponents<TControl, TAttribute, TValue>); getInitialValue(): TValue; } export interface IEnumAttributeComponents<TControl extends StandardControlMock<TControl, TAttribute, TValue>, TAttribute extends EnumAttributeMock<TControl, TAttribute, TValue>, TValue extends number | boolean> extends IAttributeComponents<TControl, TAttribute, TValue> { initialValue?: TValue; } } declare module "xrm-mock/attributes/booleanattribute/booleanattribute.mock" { import { BooleanControlMock } from "xrm-mock/controls/booleancontrol/booleancontrol.mock"; import { EnumAttributeMock, IEnumAttributeComponents } from "xrm-mock/attributes/enumattribute/enumattribute.mock"; export class BooleanAttributeMock extends EnumAttributeMock<BooleanControlMock, BooleanAttributeMock, boolean> implements Xrm.Attributes.BooleanAttribute { static create(name: string, value?: boolean): BooleanAttributeMock; private static defaultComponents; constructor(components: IBooleanAttributeComponents); /** * Gets the attribute format. * @returns the string "boolean" */ getAttributeType(): "boolean"; } export interface IBooleanAttributeComponents extends IEnumAttributeComponents<BooleanControlMock, BooleanAttributeMock, boolean> { } } declare module "xrm-mock/calendar/calendar.mock" { export class CalendarMock implements Xrm.Calendar { MinSupportedDateTime: Date; MaxSupportedDateTime: Date; AlgorithmType: number; CalendarType: number; Eras: number[]; TwoDigitYearMax: number; IsReadOnly: boolean; constructor(components: ICalendarComponents); } export interface ICalendarComponents { MinSupportedDateTime: Date; MaxSupportedDateTime: Date; AlgorithmType: number; CalendarType: number; Eras: number[]; TwoDigitYearMax: number; IsReadOnly: boolean; } } declare module "xrm-mock/device/capturefileresponse/capturefileresponse.mock" { export class CaptureFileResponseMock implements Xrm.Device.CaptureFileResponse { fileContent: string; fileName: string; fileSize: number; mimeType: string; constructor(fileContent?: string, fileName?: string, fileSize?: number, mimeType?: string); } } declare module "xrm-mock/device/captureimageoptions/captureimageoptions.mock" { export class CaptureImageOptionsMock implements Xrm.Device.CaptureImageOptions { allowEdit: boolean; height: number; preferFrontCamera: boolean; quality: number; width: number; constructor(components: ICaptureImageOptionsComponents); } export interface ICaptureImageOptionsComponents { allowEdit?: boolean; height?: number; preferFrontCamera?: boolean; quality?: number; width?: number; } } declare module "xrm-mock/clientcontext/clientcontext.mock" { export class ClientContextMock implements Xrm.ClientContext { client: Xrm.Client; clientState: Xrm.ClientState; constructor(client: Xrm.Client, clientState: Xrm.ClientState); getClient(): Xrm.Client; getClientState(): Xrm.ClientState; getFormFactor(): XrmEnum.ClientFormFactor; isOffline(): boolean; isNetworkAvailable(): boolean; } } declare module "xrm-mock/navigation/confirmresult/confirmresult.mock" { export class ConfirmResultMock implements Xrm.Navigation.ConfirmResult { confirmed: boolean; constructor(confirmed: boolean); } } declare module "xrm-mock/navigation/confirmstrings/confirmstrings.mock" { export class ConfirmStringsMock implements Xrm.Navigation.ConfirmStrings { cancelButtonLabel?: string; confirmButtonLabel?: string; subtitle?: string; title?: string; text: string; constructor(components: IConfirmStringsComponents); } export interface IConfirmStringsComponents { cancelButtonLabel?: string; confirmButtonLabel?: string; subtitle?: string; title?: string; text: string; } } declare module "xrm-mock/globalcontext/context.mock" { export class ContextMock implements Xrm.GlobalContext { advancedConfigSetting: { [index in "MaxChildIncidentNumber" | "MaxIncidentMergeNumber"]: number; }; client: Xrm.ClientContext; clientUrl: string; currentAppName: string; currentAppProperties: Xrm.AppProperties; currentAppSettings: { [index: string]: string | number | boolean; }; currentAppUrl: string; currentTheme: Xrm.Theme; isAutoSaveEnabled: boolean; onPremise: boolean; orgLcid: number; orgUniqueName: string; organizationSettings: Xrm.OrganizationSettings; queryStringParameters: { [index: string]: any; }; timeZoneOffset: number; userId: string; userLcid: number; userName: string; userRoles: string[]; userSettings: Xrm.UserSettings; version: string; webResourceUrl: { [index: string]: string; }; constructor(components: IContextComponents); getCurrentAppSetting(settingName: string): string | number | boolean; getClientUrl(): string; getCurrentTheme(): Xrm.Theme; getIsAutoSaveEnabled(): boolean; getOrgLcid(): number; getOrgUniqueName(): string; getQueryStringParameters(): { [index: string]: any; }; getTimeZoneOffsetMinutes(): number; getUserSettings(): Xrm.UserSettings; getUserId(): string; getUserLcid(): number; getUserName(): string; getUserRoles(): string[]; getVersion(): string; prependOrgName(sPath: string): string; getAdvancedConfigSetting(setting: "MaxChildIncidentNumber" | "MaxIncidentMergeNumber"): number; getCurrentAppName(): Xrm.Async.PromiseLike<string>; getCurrentAppProperties(): Xrm.Async.PromiseLike<Xrm.AppProperties>; getCurrentAppUrl(): string; isOnPremise(): boolean; getWebResourceUrl(webResourceName: string): string; } export interface IContextComponents { advancedConfigSetting?: { [index in "MaxChildIncidentNumber" | "MaxIncidentMergeNumber"]: number; }; clientContext: Xrm.ClientContext; clientUrl?: string; currentAppName?: string; currentAppProperties?: Xrm.AppProperties; currentAppUrl?: string; currentAppSettings?: { [index: string]: string | number | boolean; }; currentTheme?: Xrm.Theme; isAutoSaveEnabled?: boolean; onPremise?: boolean; organizationSettings?: Xrm.OrganizationSettings; orgLcid?: number; orgUniqueName?: string; queryStringParameters?: { [index: string]: any; }; timeZoneOffset?: number; userSettings?: Xrm.UserSettings; userId?: string; userLcid?: number; userName?: string; userRoles?: string[]; version?: string; webResourceUrl?: { [index: string]: string; }; } } declare module "xrm-mock/controls/controlnotificationaction/controlnotificationaction.mock" { export class ControlNotificationActionMock implements Xrm.Controls.ControlNotificationAction { message?: string; actions: Array<() => void>; constructor(actions: Array<() => void>, message?: string); } }