diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..9f74e282 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +# Task 512388: Fix eslint warnings and errors in tests +test/* \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index ebc8387a..2eaee33e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -90,8 +90,8 @@ module.exports = { } } ], - "@typescript-eslint/member-ordering": "warn", - "@typescript-eslint/naming-convention": "warn", + "@typescript-eslint/member-ordering": "off", + "@typescript-eslint/naming-convention": "off", "@typescript-eslint/no-array-constructor": "warn", "@typescript-eslint/no-empty-function": "warn", "@typescript-eslint/no-empty-interface": "warn", @@ -112,7 +112,7 @@ module.exports = { "@typescript-eslint/no-unnecessary-type-assertion": "warn", "@typescript-eslint/no-unsafe-assignment": "warn", "@typescript-eslint/no-unsafe-call": "warn", - "@typescript-eslint/no-unsafe-member-access": "warn", + "@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/no-unsafe-return": "warn", "@typescript-eslint/no-unused-expressions": "warn", "@typescript-eslint/no-unused-vars": "warn", @@ -122,7 +122,7 @@ module.exports = { "@typescript-eslint/prefer-for-of": "warn", "@typescript-eslint/prefer-function-type": "warn", "@typescript-eslint/prefer-namespace-keyword": "warn", - "@typescript-eslint/prefer-regexp-exec": "warn", + "@typescript-eslint/prefer-regexp-exec": "off", "@typescript-eslint/quotes": [ "off", { @@ -176,7 +176,6 @@ module.exports = { "Boolean", "boolean", "Undefined", - "undefined" ], "id-match": "warn", "import/order": "warn", @@ -223,7 +222,7 @@ module.exports = { "warn", "never" ], - "prefer-arrow/prefer-arrow-functions": "warn", + "prefer-arrow/prefer-arrow-functions": "off", "prefer-const": "warn", "prefer-rest-params": "warn", "quote-props": [ diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..12fbd833 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,41 @@ + + +## Security + +Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). + +If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). + +If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). + +You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). + +Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: + + * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) + * Full paths of source file(s) related to the manifestation of the issue + * The location of the affected source code (tag/branch/commit or direct URL) + * Any special configuration required to reproduce the issue + * Step-by-step instructions to reproduce the issue + * Proof-of-concept or exploit code (if possible) + * Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. + +## Preferred Languages + +We prefer all communications to be in English. + +## Policy + +Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). + + \ No newline at end of file diff --git a/dist/powerbi-client.d.ts b/dist/powerbi-client.d.ts index cd10f2e6..fc20d994 100644 --- a/dist/powerbi-client.d.ts +++ b/dist/powerbi-client.d.ts @@ -1,4 +1,4 @@ -/*! powerbi-client v2.17.1 | (c) 2016 Microsoft Corporation MIT */ +/*! powerbi-client v2.17.2 | (c) 2016 Microsoft Corporation MIT */ declare module "util" { import { HttpPostMessage } from 'http-post-message'; /** @@ -95,6 +95,7 @@ declare module "util" { export function getRandomValue(): number; /** * Returns the time interval between two dates in milliseconds + * * @export * @param {Date} start * @param {Date} end @@ -111,12 +112,12 @@ declare module "config" { export default config; } declare module "errors" { - export let APINotSupportedForRDLError: string; - export let EmbedUrlNotSupported: string; + export const APINotSupportedForRDLError = "This API is currently not supported for RDL reports"; + export const EmbedUrlNotSupported = "Embed URL is invalid for this scenario. Please use Power BI REST APIs to get the valid URL"; } declare module "embed" { - import * as service from "service"; import * as models from 'powerbi-models'; + import { Service, IEventHandler, IEvent, ICustomEvent } from "service"; global { interface Document { mozCancelFullScreen: any; @@ -144,8 +145,8 @@ declare module "embed" { export type IEmbedSettings = models.ISettings; /** @hidden */ export interface IInternalEventHandler { - test(event: service.IEvent): boolean; - handle(event: service.ICustomEvent): void; + test(event: IEvent): boolean; + handle(event: ICustomEvent): void; } /** * Base class for all Power BI embed components @@ -173,7 +174,7 @@ declare module "embed" { /** @hidden */ static maxFrontLoadTimes: number; /** @hidden */ - allowedEvents: any[]; + allowedEvents: string[]; /** * Gets or sets the event handler registered for this embed component. * @@ -187,7 +188,7 @@ declare module "embed" { * @type {service.Service} * @hidden */ - service: service.Service; + service: Service; /** * Gets or sets the HTML element that contains the Power BI embed component. * @@ -234,26 +235,31 @@ declare module "embed" { createConfig: models.IReportCreateConfiguration; /** * Url used in the load request. + * * @hidden */ loadPath: string; /** * Url used in the load request. + * * @hidden */ phasedLoadPath: string; /** * Type of embed + * * @hidden */ embedtype: string; /** * Handler function for the 'ready' event + * * @hidden */ frontLoadHandler: () => any; /** * The time the last /load request was sent + * * @hidden */ lastLoadRequest: Date; @@ -268,7 +274,7 @@ declare module "embed" { * @param {IEmbedConfigurationBase} config * @hidden */ - constructor(service: service.Service, element: HTMLElement, config: IEmbedConfigurationBase, iframe?: HTMLIFrameElement, phasedRender?: boolean, isBootstrap?: boolean); + constructor(service: Service, element: HTMLElement, config: IEmbedConfigurationBase, iframe?: HTMLIFrameElement, phasedRender?: boolean, isBootstrap?: boolean); /** * Sends createReport configuration data. * @@ -277,6 +283,7 @@ declare module "embed" { * datasetId: '5dac7a4a-4452-46b3-99f6-a25915e0fe55', * accessToken: 'eyJ0eXA ... TaE2rTSbmg', * ``` + * * @hidden * @param {models.IReportCreateConfiguration} config * @returns {Promise} @@ -328,6 +335,7 @@ declare module "embed" { * }) * .catch(error => { ... }); * ``` + * * @hidden * @param {models.ILoadConfiguration} config * @param {boolean} phasedRender @@ -353,9 +361,9 @@ declare module "embed" { * * @template T * @param {string} eventName - * @param {service.IEventHandler} [handler] + * @param {IEventHandler} [handler] */ - off(eventName: string, handler?: service.IEventHandler): void; + off(eventName: string, handler?: IEventHandler): void; /** * Adds an event handler for a specific event. * @@ -369,7 +377,7 @@ declare module "embed" { * @param {string} eventName * @param {service.IEventHandler} handler */ - on(eventName: string, handler: service.IEventHandler): void; + on(eventName: string, handler: IEventHandler): void; /** * Reloads embed using existing configuration. * E.g. For reports this effectively clears all filters and makes the first page active which simulates resetting a report back to loaded state. @@ -488,6 +496,7 @@ declare module "embed" { abstract validate(config: IEmbedConfigurationBase): models.IError[]; /** * Sets Iframe for embed + * * @hidden */ private setIframe; @@ -502,7 +511,7 @@ declare module "embed" { /** * Removes element's tabindex attribute */ - removeComponentTabIndex(tabIndex?: number): void; + removeComponentTabIndex(_tabIndex?: number): void; /** * Adds the ability to get groupId from url. * By extracting the ID we can ensure that the ID is always explicitly provided as part of the load configuration. @@ -515,6 +524,7 @@ declare module "embed" { static findGroupIdFromEmbedUrl(url: string): string; /** * Sends the config for front load calls, after 'ready' message is received from the iframe + * * @hidden */ private frontLoadSendConfig; @@ -668,6 +678,7 @@ declare module "visualDescriptor" { /** * Exports Visual data. * Can export up to 30K rows. + * * @param rows: Optional. Default value is 30K, maximum value is 30K as well. * @param exportDataType: Optional. Default is ExportDataType.Summarized. * ```javascript @@ -681,6 +692,7 @@ declare module "visualDescriptor" { /** * Set slicer state. * Works only for visuals of type slicer. + * * @param state: A new state which contains the slicer filters. * ```javascript * visual.setSlicerState() @@ -721,7 +733,7 @@ declare module "visualDescriptor" { } declare module "page" { import { IHttpPostMessageResponse } from 'http-post-message'; - import { DisplayOption, FiltersOperations, ICustomPageSize, IFilter, SectionVisibility } from 'powerbi-models'; + import { DisplayOption, FiltersOperations, ICustomPageSize, IFilter, LayoutType, SectionVisibility } from 'powerbi-models'; import { IFilterable } from "ifilterable"; import { IReportNode } from "report"; import { VisualDescriptor } from "visualDescriptor"; @@ -896,7 +908,7 @@ declare module "page" { * * @returns {(Promise)} */ - hasLayout(layoutType: any): Promise; + hasLayout(layoutType: LayoutType): Promise; } } declare module "report" { @@ -1121,8 +1133,11 @@ declare module "report" { * * ```javascript * const newSettings = { - * navContentPaneEnabled: true, - * filterPaneEnabled: false + * panes: { + * filters: { + * visible: false + * } + * } * }; * * report.updateSettings(newSettings) @@ -1232,18 +1247,18 @@ declare module "report" { } } declare module "create" { - import * as service from "service"; - import * as models from 'powerbi-models'; - import * as embed from "embed"; + import { IReportCreateConfiguration, IError } from 'powerbi-models'; + import { Service } from "service"; + import { Embed, IEmbedConfigurationBase, IEmbedConfiguration } from "embed"; /** * A Power BI Report creator component * * @export * @class Create - * @extends {embed.Embed} + * @extends {Embed} */ - export class Create extends embed.Embed { - constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfiguration | models.IReportCreateConfiguration, phasedRender?: boolean, isBootstrap?: boolean); + export class Create extends Embed { + constructor(service: Service, element: HTMLElement, config: IEmbedConfiguration | IReportCreateConfiguration, phasedRender?: boolean, isBootstrap?: boolean); /** * Gets the dataset ID from the first available location: createConfig or embed url. * @@ -1253,7 +1268,7 @@ declare module "create" { /** * Validate create report configuration. */ - validate(config: embed.IEmbedConfigurationBase): models.IError[]; + validate(config: IEmbedConfigurationBase): IError[]; /** * Handle config changes. * @@ -1291,9 +1306,9 @@ declare module "create" { } } declare module "dashboard" { - import * as service from "service"; - import * as embed from "embed"; - import * as models from 'powerbi-models'; + import { IError } from 'powerbi-models'; + import { Service, IService } from "service"; + import { Embed, IEmbedConfigurationBase } from "embed"; /** * A Dashboard node within a dashboard hierarchy * @@ -1302,18 +1317,18 @@ declare module "dashboard" { */ export interface IDashboardNode { iframe: HTMLIFrameElement; - service: service.IService; - config: embed.IEmbedConfigurationBase; + service: IService; + config: IEmbedConfigurationBase; } /** * A Power BI Dashboard embed component * * @export * @class Dashboard - * @extends {embed.Embed} + * @extends {Embed} * @implements {IDashboardNode} */ - export class Dashboard extends embed.Embed implements IDashboardNode { + export class Dashboard extends Embed implements IDashboardNode { /** @hidden */ static allowedEvents: string[]; /** @hidden */ @@ -1329,12 +1344,13 @@ declare module "dashboard" { * @hidden * @param {HTMLElement} element */ - constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean); + constructor(service: Service, element: HTMLElement, config: IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean); /** * This adds backwards compatibility for older config which used the dashboardId query param to specify dashboard id. * E.g. https://powerbi-df.analysis-df.windows.net/dashboardEmbedHost?dashboardId=e9363c62-edb6-4eac-92d3-2199c5ca2a9e * * By extracting the id we can ensure id is always explicitly provided as part of the load configuration. + * * @hidden * @static * @param {string} url @@ -1352,9 +1368,10 @@ declare module "dashboard" { * * @hidden */ - validate(baseConfig: embed.IEmbedConfigurationBase): models.IError[]; + validate(baseConfig: IEmbedConfigurationBase): IError[]; /** * Handle config changes. + * * @hidden * @returns {void} */ @@ -1365,16 +1382,17 @@ declare module "dashboard" { */ getDefaultEmbedUrlEndpoint(): string; /** - * Validate that pageView has a legal value: if page view is defined it must have one of the values defined in models.PageView + * Validate that pageView has a legal value: if page view is defined it must have one of the values defined in PageView + * * @hidden */ - private ValidatePageView; + private validatePageView; } } declare module "tile" { - import * as service from "service"; - import * as models from 'powerbi-models'; - import * as embed from "embed"; + import { IError } from 'powerbi-models'; + import { Service } from "service"; + import { Embed, IEmbedConfigurationBase } from "embed"; /** * The Power BI tile embed component * @@ -1382,7 +1400,7 @@ declare module "tile" { * @class Tile * @extends {Embed} */ - export class Tile extends embed.Embed { + export class Tile extends Embed { /** @hidden */ static type: string; /** @hidden */ @@ -1390,7 +1408,7 @@ declare module "tile" { /** * @hidden */ - constructor(service: service.Service, element: HTMLElement, baseConfig: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean); + constructor(service: Service, element: HTMLElement, baseConfig: IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean); /** * The ID of the tile * @@ -1400,7 +1418,7 @@ declare module "tile" { /** * Validate load configuration. */ - validate(config: embed.IEmbedConfigurationBase): models.IError[]; + validate(config: IEmbedConfigurationBase): IError[]; /** * Handle config changes. * @@ -1425,10 +1443,10 @@ declare module "tile" { } } declare module "qna" { - import * as service from "service"; - import * as models from 'powerbi-models'; - import * as embed from "embed"; import { IHttpPostMessageResponse } from 'http-post-message'; + import { IError } from 'powerbi-models'; + import { Embed, IEmbedConfigurationBase } from "embed"; + import { Service } from "service"; /** * The Power BI Q&A embed component * @@ -1436,7 +1454,7 @@ declare module "qna" { * @class Qna * @extends {Embed} */ - export class Qna extends embed.Embed { + export class Qna extends Embed { /** @hidden */ static type: string; /** @hidden */ @@ -1444,7 +1462,7 @@ declare module "qna" { /** * @hidden */ - constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean); + constructor(service: Service, element: HTMLElement, config: IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean); /** * The ID of the Q&A embed component * @@ -1463,7 +1481,7 @@ declare module "qna" { * * @returns {void} */ - configChanged(isBootstrap: boolean): void; + configChanged(_isBootstrap: boolean): void; /** * @hidden * @returns {string} @@ -1472,7 +1490,7 @@ declare module "qna" { /** * Validate load configuration. */ - validate(config: embed.IEmbedConfigurationBase): models.IError[]; + validate(config: IEmbedConfigurationBase): IError[]; } } declare module "visual" { @@ -1522,14 +1540,14 @@ declare module "visual" { * @param {string} pageName * @returns {Promise>} */ - setPage(pageName: string): Promise>; + setPage(_pageName: string): Promise>; /** * Render a preloaded report, using phased embedding API * * @hidden * @returns {Promise} */ - render(config?: IReportLoadConfiguration | IReportEmbedConfiguration): Promise; + render(_config?: IReportLoadConfiguration | IReportEmbedConfiguration): Promise; /** * Gets the embedded visual descriptor object that contains the visual name, type, etc. * @@ -1611,11 +1629,11 @@ declare module "visual" { } } declare module "service" { - import * as embed from "embed"; - import * as wpmp from 'window-post-message-proxy'; - import * as hpm from 'http-post-message'; - import * as router from 'powerbi-router'; - import * as models from 'powerbi-models'; + import { WindowPostMessageProxy } from 'window-post-message-proxy'; + import { HttpPostMessage } from 'http-post-message'; + import { Router } from 'powerbi-router'; + import { IReportCreateConfiguration } from 'powerbi-models'; + import { Embed, IBootstrapEmbedConfiguration, IDashboardEmbedConfiguration, IEmbedConfiguration, IEmbedConfigurationBase, IQnaEmbedConfiguration, IReportEmbedConfiguration, ITileEmbedConfiguration, IVisualEmbedConfiguration } from "embed"; export interface IEvent { type: string; id: string; @@ -1638,22 +1656,22 @@ declare module "service" { * @hidden */ export interface IHpmFactory { - (wpmp: wpmp.WindowPostMessageProxy, targetWindow?: Window, version?: string, type?: string, origin?: string): hpm.HttpPostMessage; + (wpmp: WindowPostMessageProxy, targetWindow?: Window, version?: string, type?: string, origin?: string): HttpPostMessage; } /** * @hidden */ export interface IWpmpFactory { - (name?: string, logMessages?: boolean, eventSourceOverrideWindow?: Window): wpmp.WindowPostMessageProxy; + (name?: string, logMessages?: boolean, eventSourceOverrideWindow?: Window): WindowPostMessageProxy; } /** * @hidden */ export interface IRouterFactory { - (wpmp: wpmp.WindowPostMessageProxy): router.Router; + (wpmp: WindowPostMessageProxy): Router; } export interface IPowerBiElement extends HTMLElement { - powerBiEmbed: embed.Embed; + powerBiEmbed: Embed; } export interface IDebugOptions { logMessages?: boolean; @@ -1666,9 +1684,9 @@ declare module "service" { type?: string; } export interface IService { - hpm: hpm.HttpPostMessage; + hpm: HttpPostMessage; } - export type IComponentEmbedConfiguration = embed.IReportEmbedConfiguration | embed.IDashboardEmbedConfiguration | embed.ITileEmbedConfiguration | embed.IVisualEmbedConfiguration | embed.IQnaEmbedConfiguration; + export type IComponentEmbedConfiguration = IReportEmbedConfiguration | IDashboardEmbedConfiguration | ITileEmbedConfiguration | IVisualEmbedConfiguration | IQnaEmbedConfiguration; /** * The Power BI Service embed component, which is the entry point to embed all other Power BI components into your application * @@ -1692,18 +1710,20 @@ declare module "service" { * @hidden */ accessToken: string; - /**The Configuration object for the service*/ + /** The Configuration object for the service*/ private config; /** A list of Dashboard, Report and Tile components that have been embedded using this service instance. */ private embeds; /** TODO: Look for way to make hpm private without sacrificing ease of maintenance. This should be private but in embed needs to call methods. + * * @hidden - */ - hpm: hpm.HttpPostMessage; + */ + hpm: HttpPostMessage; /** TODO: Look for way to make wpmp private. This is only public to allow stopping the wpmp in tests + * * @hidden - */ - wpmp: wpmp.WindowPostMessageProxy; + */ + wpmp: WindowPostMessageProxy; private router; private uniqueSessionId; /** @@ -1718,30 +1738,31 @@ declare module "service" { constructor(hpmFactory: IHpmFactory, wpmpFactory: IWpmpFactory, routerFactory: IRouterFactory, config?: IServiceConfiguration); /** * Creates new report + * * @param {HTMLElement} element - * @param {embed.IEmbedConfiguration} [config={}] - * @returns {embed.Embed} + * @param {IEmbedConfiguration} [config={}] + * @returns {Embed} */ - createReport(element: HTMLElement, config: embed.IEmbedConfiguration | models.IReportCreateConfiguration): embed.Embed; + createReport(element: HTMLElement, config: IEmbedConfiguration | IReportCreateConfiguration): Embed; /** * TODO: Add a description here * * @param {HTMLElement} [container] - * @param {embed.IEmbedConfiguration} [config=undefined] - * @returns {embed.Embed[]} + * @param {IEmbedConfiguration} [config=undefined] + * @returns {Embed[]} * @hidden */ - init(container?: HTMLElement, config?: embed.IEmbedConfiguration): embed.Embed[]; + init(container?: HTMLElement, config?: IEmbedConfiguration): Embed[]; /** * Given a configuration based on an HTML element, * if the component has already been created and attached to the element, reuses the component instance and existing iframe, * otherwise creates a new component instance. * * @param {HTMLElement} element - * @param {embed.IEmbedConfigurationBase} [config={}] - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} [config={}] + * @returns {Embed} */ - embed(element: HTMLElement, config?: IComponentEmbedConfiguration | embed.IEmbedConfigurationBase): embed.Embed; + embed(element: HTMLElement, config?: IComponentEmbedConfiguration | IEmbedConfigurationBase): Embed; /** * Given a configuration based on an HTML element, * if the component has already been created and attached to the element, reuses the component instance and existing iframe, @@ -1749,19 +1770,19 @@ declare module "service" { * This is used for the phased embedding API, once element is loaded successfully, one can call 'render' on it. * * @param {HTMLElement} element - * @param {embed.IEmbedConfigurationBase} [config={}] - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} [config={}] + * @returns {Embed} */ - load(element: HTMLElement, config?: IComponentEmbedConfiguration | embed.IEmbedConfigurationBase): embed.Embed; + load(element: HTMLElement, config?: IComponentEmbedConfiguration | IEmbedConfigurationBase): Embed; /** * Given an HTML element and entityType, creates a new component instance, and bootstrap the iframe for embedding. * * @param {HTMLElement} element - * @param {embed.IBootstrapEmbedConfiguration} config: a bootstrap config which is an embed config without access token. + * @param {IBootstrapEmbedConfiguration} config: a bootstrap config which is an embed config without access token. */ - bootstrap(element: HTMLElement, config: IComponentEmbedConfiguration | embed.IBootstrapEmbedConfiguration): embed.Embed; + bootstrap(element: HTMLElement, config: IComponentEmbedConfiguration | IBootstrapEmbedConfiguration): Embed; /** @hidden */ - embedInternal(element: HTMLElement, config?: IComponentEmbedConfiguration | embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean): embed.Embed; + embedInternal(element: HTMLElement, config?: IComponentEmbedConfiguration | IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean): Embed; /** @hidden */ getNumberOfComponents(): number; /** @hidden */ @@ -1771,8 +1792,8 @@ declare module "service" { * * @private * @param {IPowerBiElement} element - * @param {embed.IEmbedConfigurationBase} config - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} config + * @returns {Embed} * @hidden */ private embedNew; @@ -1781,8 +1802,8 @@ declare module "service" { * * @private * @param {IPowerBiElement} element - * @param {embed.IEmbedConfigurationBase} config - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} config + * @returns {Embed} * @hidden */ private embedExisting; @@ -1802,7 +1823,7 @@ declare module "service" { * @param {HTMLElement} element * @returns {(Report | Tile)} */ - get(element: HTMLElement): embed.Embed; + get(element: HTMLElement): Embed; /** * Finds an embed instance by the name or unique ID that is provided. * @@ -1810,7 +1831,7 @@ declare module "service" { * @returns {(Report | Tile)} * @hidden */ - find(uniqueId: string): embed.Embed; + find(uniqueId: string): Embed; /** * Removes embed components whose container element is same as the given element * @@ -1819,7 +1840,7 @@ declare module "service" { * @returns {void} * @hidden */ - addOrOverwriteEmbed(component: embed.Embed, element: HTMLElement): void; + addOrOverwriteEmbed(component: Embed, element: HTMLElement): void; /** * Given an HTML element that has a component embedded within it, removes the component from the list of embedded components, removes the association between the element and the component, and removes the iframe. * @@ -1847,17 +1868,17 @@ declare module "service" { * Use this API to preload Power BI Embedded in the background. * * @public - * @param {embed.IEmbedConfigurationBase} [config={}] + * @param {IEmbedConfigurationBase} [config={}] * @param {HTMLElement} [element=undefined] */ - preload(config: IComponentEmbedConfiguration | embed.IEmbedConfigurationBase, element?: HTMLElement): HTMLIFrameElement; + preload(config: IComponentEmbedConfiguration | IEmbedConfigurationBase, element?: HTMLElement): HTMLIFrameElement; } } declare module "bookmarksManager" { - import * as service from "service"; - import * as embed from "embed"; - import * as models from 'powerbi-models'; + import { BookmarksPlayMode, ICaptureBookmarkOptions, IReportBookmark } from 'powerbi-models'; import { IHttpPostMessageResponse } from 'http-post-message'; + import { Service } from "service"; + import { IEmbedConfigurationBase } from "embed"; /** * APIs for managing the report bookmarks. * @@ -1865,10 +1886,10 @@ declare module "bookmarksManager" { * @interface IBookmarksManager */ export interface IBookmarksManager { - getBookmarks(): Promise; + getBookmarks(): Promise; apply(bookmarkName: string): Promise>; - play(playMode: models.BookmarksPlayMode): Promise>; - capture(options?: models.ICaptureBookmarkOptions): Promise; + play(playMode: BookmarksPlayMode): Promise>; + capture(options?: ICaptureBookmarkOptions): Promise; applyState(state: string): Promise>; } /** @@ -1885,7 +1906,7 @@ declare module "bookmarksManager" { /** * @hidden */ - constructor(service: service.Service, config: embed.IEmbedConfigurationBase, iframe?: HTMLIFrameElement); + constructor(service: Service, config: IEmbedConfigurationBase, iframe?: HTMLIFrameElement); /** * Gets bookmarks that are defined in the report. * @@ -1897,9 +1918,9 @@ declare module "bookmarksManager" { * }); * ``` * - * @returns {Promise} + * @returns {Promise} */ - getBookmarks(): Promise; + getBookmarks(): Promise; /** * Apply bookmark by name. * @@ -1916,13 +1937,13 @@ declare module "bookmarksManager" { * * ```javascript * // Enter presentation mode. - * bookmarksManager.play(models.BookmarksPlayMode.Presentation) + * bookmarksManager.play(BookmarksPlayMode.Presentation) * ``` * - * @param {models.BookmarksPlayMode} playMode Play mode can be either `Presentation` or `Off` + * @param {BookmarksPlayMode} playMode Play mode can be either `Presentation` or `Off` * @returns {Promise>} */ - play(playMode: models.BookmarksPlayMode): Promise>; + play(playMode: BookmarksPlayMode): Promise>; /** * Capture bookmark from current state. * @@ -1930,10 +1951,10 @@ declare module "bookmarksManager" { * bookmarksManager.capture(options) * ``` * - * @param {models.ICaptureBookmarkOptions} [options] Options for bookmark capturing - * @returns {Promise} + * @param {ICaptureBookmarkOptions} [options] Options for bookmark capturing + * @returns {Promise} */ - capture(options?: models.ICaptureBookmarkOptions): Promise; + capture(options?: ICaptureBookmarkOptions): Promise; /** * Apply bookmark state. * @@ -1948,9 +1969,6 @@ declare module "bookmarksManager" { } } declare module "factories" { - /** - * TODO: Need to find better place for these factory functions or refactor how we handle dependency injection - */ import { IHpmFactory, IWpmpFactory, IRouterFactory } from "service"; export { IHpmFactory, IWpmpFactory, IRouterFactory }; export const hpmFactory: IHpmFactory; @@ -1961,9 +1979,9 @@ declare module "powerbi-client" { /** * @hidden */ + import * as models from 'powerbi-models'; import * as service from "service"; import * as factories from "factories"; - import * as models from 'powerbi-models'; import { IFilterable } from "ifilterable"; export { IFilterable, service, factories, models }; export { Report } from "report"; diff --git a/dist/powerbi.js b/dist/powerbi.js index 76f9d55a..5e367d45 100644 --- a/dist/powerbi.js +++ b/dist/powerbi.js @@ -1,4 +1,4 @@ -/*! powerbi-client v2.17.1 | (c) 2016 Microsoft Corporation MIT */ +/*! powerbi-client v2.17.2 | (c) 2016 Microsoft Corporation MIT */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -5758,8 +5758,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BookmarksManager = void 0; -var utils = __webpack_require__(/*! ./util */ "./src/util.ts"); -var errors = __webpack_require__(/*! ./errors */ "./src/errors.ts"); +var util_1 = __webpack_require__(/*! ./util */ "./src/util.ts"); +var errors_1 = __webpack_require__(/*! ./errors */ "./src/errors.ts"); /** * Manages report bookmarks. * @@ -5787,7 +5787,7 @@ var BookmarksManager = /** @class */ (function () { * }); * ``` * - * @returns {Promise} + * @returns {Promise} */ BookmarksManager.prototype.getBookmarks = function () { return __awaiter(this, void 0, void 0, function () { @@ -5795,8 +5795,8 @@ var BookmarksManager = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (utils.isRDLEmbed(this.config.embedUrl)) { - return [2 /*return*/, Promise.reject(errors.APINotSupportedForRDLError)]; + if (util_1.isRDLEmbed(this.config.embedUrl)) { + return [2 /*return*/, Promise.reject(errors_1.APINotSupportedForRDLError)]; } _a.label = 1; case 1: @@ -5829,8 +5829,8 @@ var BookmarksManager = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (utils.isRDLEmbed(this.config.embedUrl)) { - return [2 /*return*/, Promise.reject(errors.APINotSupportedForRDLError)]; + if (util_1.isRDLEmbed(this.config.embedUrl)) { + return [2 /*return*/, Promise.reject(errors_1.APINotSupportedForRDLError)]; } request = { name: bookmarkName @@ -5853,10 +5853,10 @@ var BookmarksManager = /** @class */ (function () { * * ```javascript * // Enter presentation mode. - * bookmarksManager.play(models.BookmarksPlayMode.Presentation) + * bookmarksManager.play(BookmarksPlayMode.Presentation) * ``` * - * @param {models.BookmarksPlayMode} playMode Play mode can be either `Presentation` or `Off` + * @param {BookmarksPlayMode} playMode Play mode can be either `Presentation` or `Off` * @returns {Promise>} */ BookmarksManager.prototype.play = function (playMode) { @@ -5865,8 +5865,8 @@ var BookmarksManager = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (utils.isRDLEmbed(this.config.embedUrl)) { - return [2 /*return*/, Promise.reject(errors.APINotSupportedForRDLError)]; + if (util_1.isRDLEmbed(this.config.embedUrl)) { + return [2 /*return*/, Promise.reject(errors_1.APINotSupportedForRDLError)]; } playBookmarkRequest = { playMode: playMode @@ -5891,8 +5891,8 @@ var BookmarksManager = /** @class */ (function () { * bookmarksManager.capture(options) * ``` * - * @param {models.ICaptureBookmarkOptions} [options] Options for bookmark capturing - * @returns {Promise} + * @param {ICaptureBookmarkOptions} [options] Options for bookmark capturing + * @returns {Promise} */ BookmarksManager.prototype.capture = function (options) { return __awaiter(this, void 0, void 0, function () { @@ -5900,8 +5900,8 @@ var BookmarksManager = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (utils.isRDLEmbed(this.config.embedUrl)) { - return [2 /*return*/, Promise.reject(errors.APINotSupportedForRDLError)]; + if (util_1.isRDLEmbed(this.config.embedUrl)) { + return [2 /*return*/, Promise.reject(errors_1.APINotSupportedForRDLError)]; } request = { options: options || {} @@ -5937,8 +5937,8 @@ var BookmarksManager = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - if (utils.isRDLEmbed(this.config.embedUrl)) { - return [2 /*return*/, Promise.reject(errors.APINotSupportedForRDLError)]; + if (util_1.isRDLEmbed(this.config.embedUrl)) { + return [2 /*return*/, Promise.reject(errors_1.APINotSupportedForRDLError)]; } request = { state: state @@ -5973,7 +5973,7 @@ exports.BookmarksManager = BookmarksManager; Object.defineProperty(exports, "__esModule", { value: true }); /** @ignore */ /** */ var config = { - version: '2.17.1', + version: '2.17.2', type: 'js' }; exports.default = config; @@ -6039,15 +6039,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Create = void 0; -var models = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); -var embed = __webpack_require__(/*! ./embed */ "./src/embed.ts"); +var powerbi_models_1 = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); +var embed_1 = __webpack_require__(/*! ./embed */ "./src/embed.ts"); var utils = __webpack_require__(/*! ./util */ "./src/util.ts"); /** * A Power BI Report creator component * * @export * @class Create - * @extends {embed.Embed} + * @extends {Embed} */ var Create = /** @class */ (function (_super) { __extends(Create, _super); @@ -6073,7 +6073,7 @@ var Create = /** @class */ (function (_super) { * Validate create report configuration. */ Create.prototype.validate = function (config) { - return models.validateCreateReport(config); + return powerbi_models_1.validateCreateReport(config); }; /** * Handle config changes. @@ -6142,7 +6142,7 @@ var Create = /** @class */ (function (_super) { return datasetId; }; return Create; -}(embed.Embed)); +}(embed_1.Embed)); exports.Create = Create; @@ -6170,14 +6170,14 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Dashboard = void 0; -var embed = __webpack_require__(/*! ./embed */ "./src/embed.ts"); -var models = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); +var powerbi_models_1 = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); +var embed_1 = __webpack_require__(/*! ./embed */ "./src/embed.ts"); /** * A Power BI Dashboard embed component * * @export * @class Dashboard - * @extends {embed.Embed} + * @extends {Embed} * @implements {IDashboardNode} */ var Dashboard = /** @class */ (function (_super) { @@ -6201,6 +6201,7 @@ var Dashboard = /** @class */ (function (_super) { * E.g. https://powerbi-df.analysis-df.windows.net/dashboardEmbedHost?dashboardId=e9363c62-edb6-4eac-92d3-2199c5ca2a9e * * By extracting the id we can ensure id is always explicitly provided as part of the load configuration. + * * @hidden * @static * @param {string} url @@ -6235,11 +6236,12 @@ var Dashboard = /** @class */ (function (_super) { */ Dashboard.prototype.validate = function (baseConfig) { var config = baseConfig; - var error = models.validateDashboardLoad(config); - return error ? error : this.ValidatePageView(config.pageView); + var error = powerbi_models_1.validateDashboardLoad(config); + return error ? error : this.validatePageView(config.pageView); }; /** * Handle config changes. + * * @hidden * @returns {void} */ @@ -6258,10 +6260,11 @@ var Dashboard = /** @class */ (function (_super) { return "dashboardEmbed"; }; /** - * Validate that pageView has a legal value: if page view is defined it must have one of the values defined in models.PageView + * Validate that pageView has a legal value: if page view is defined it must have one of the values defined in PageView + * * @hidden */ - Dashboard.prototype.ValidatePageView = function (pageView) { + Dashboard.prototype.validatePageView = function (pageView) { if (pageView && pageView !== "fitToWidth" && pageView !== "oneColumn" && pageView !== "actualSize") { return [{ message: "pageView must be one of the followings: fitToWidth, oneColumn, actualSize" }]; } @@ -6275,7 +6278,7 @@ var Dashboard = /** @class */ (function (_super) { /** @hidden */ Dashboard.type = "Dashboard"; return Dashboard; -}(embed.Embed)); +}(embed_1.Embed)); exports.Dashboard = Dashboard; @@ -6326,9 +6329,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Embed = void 0; -var utils = __webpack_require__(/*! ./util */ "./src/util.ts"); -var sdkConfig = __webpack_require__(/*! ./config */ "./src/config.ts"); var models = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); +var util_1 = __webpack_require__(/*! ./util */ "./src/util.ts"); +var sdkConfig = __webpack_require__(/*! ./config */ "./src/config.ts"); var errors_1 = __webpack_require__(/*! ./errors */ "./src/errors.ts"); /** * Base class for all Power BI embed components @@ -6353,7 +6356,7 @@ var Embed = /** @class */ (function () { function Embed(service, element, config, iframe, phasedRender, isBootstrap) { /** @hidden */ this.allowedEvents = []; - if (utils.autoAuthInEmbedUrl(config.embedUrl)) { + if (util_1.autoAuthInEmbedUrl(config.embedUrl)) { throw new Error(errors_1.EmbedUrlNotSupported); } Array.prototype.push.apply(this.allowedEvents, Embed.allowedEvents); @@ -6365,10 +6368,10 @@ var Embed = /** @class */ (function () { this.embedtype = config.type.toLowerCase(); this.populateConfig(config, isBootstrap); if (this.embedtype === 'create') { - this.setIframe(false /*set EventListener to call create() on 'load' event*/, phasedRender, isBootstrap); + this.setIframe(false /* set EventListener to call create() on 'load' event*/, phasedRender, isBootstrap); } else { - this.setIframe(true /*set EventListener to call load() on 'load' event*/, phasedRender, isBootstrap); + this.setIframe(true /* set EventListener to call load() on 'load' event*/, phasedRender, isBootstrap); } } /** @@ -6379,6 +6382,7 @@ var Embed = /** @class */ (function () { * datasetId: '5dac7a4a-4452-46b3-99f6-a25915e0fe55', * accessToken: 'eyJ0eXA ... TaE2rTSbmg', * ``` + * * @hidden * @param {models.IReportCreateConfiguration} config * @returns {Promise} @@ -6508,6 +6512,7 @@ var Embed = /** @class */ (function () { * }) * .catch(error => { ... }); * ``` + * * @hidden * @param {models.ILoadConfiguration} config * @param {boolean} phasedRender @@ -6535,7 +6540,7 @@ var Embed = /** @class */ (function () { sdkVersion: sdkConfig.default.version }; timeNow = new Date(); - if (this.lastLoadRequest && utils.getTimeDiffInMilliseconds(this.lastLoadRequest, timeNow) < 100) { + if (this.lastLoadRequest && util_1.getTimeDiffInMilliseconds(this.lastLoadRequest, timeNow) < 100) { console.debug("Power BI SDK sent more than two /report/load requests in the last 100ms interval."); return [2 /*return*/]; } @@ -6574,13 +6579,13 @@ var Embed = /** @class */ (function () { * * @template T * @param {string} eventName - * @param {service.IEventHandler} [handler] + * @param {IEventHandler} [handler] */ Embed.prototype.off = function (eventName, handler) { var _this = this; var fakeEvent = { name: eventName, type: null, id: null, value: null }; if (handler) { - utils.remove(function (eventHandler) { return eventHandler.test(fakeEvent) && (eventHandler.handle === handler); }, this.eventHandlers); + util_1.remove(function (eventHandler) { return eventHandler.test(fakeEvent) && (eventHandler.handle === handler); }, this.eventHandlers); this.element.removeEventListener(eventName, handler); } else { @@ -6588,7 +6593,7 @@ var Embed = /** @class */ (function () { .filter(function (eventHandler) { return eventHandler.test(fakeEvent); }); eventHandlersToRemove .forEach(function (eventHandlerToRemove) { - utils.remove(function (eventHandler) { return eventHandler === eventHandlerToRemove; }, _this.eventHandlers); + util_1.remove(function (eventHandler) { return eventHandler === eventHandlerToRemove; }, _this.eventHandlers); _this.element.removeEventListener(eventName, eventHandlerToRemove.handle); }); } @@ -6689,14 +6694,14 @@ var Embed = /** @class */ (function () { */ Embed.prototype.populateConfig = function (config, isBootstrap) { if (this.bootstrapConfig) { - this.config = utils.assign({}, this.bootstrapConfig, config); + this.config = util_1.assign({}, this.bootstrapConfig, config); // reset bootstrapConfig because we do not want to merge it in re-embed scenario. this.bootstrapConfig = null; } else { // Copy config - important for multiple iframe scenario. // Otherwise, if a user uses the same config twice, same unique Id which will be used in different iframes. - this.config = utils.assign({}, config); + this.config = util_1.assign({}, config); } this.config.embedUrl = this.getEmbedUrl(isBootstrap); this.config.groupId = this.getGroupId(); @@ -6725,10 +6730,10 @@ var Embed = /** @class */ (function () { } var localeSettings = config.settings.localeSettings; if (localeSettings && localeSettings.language) { - this.config.embedUrl = utils.addParamToUrl(this.config.embedUrl, 'language', localeSettings.language); + this.config.embedUrl = util_1.addParamToUrl(this.config.embedUrl, 'language', localeSettings.language); } if (localeSettings && localeSettings.formatLocale) { - this.config.embedUrl = utils.addParamToUrl(this.config.embedUrl, 'formatLocale', localeSettings.formatLocale); + this.config.embedUrl = util_1.addParamToUrl(this.config.embedUrl, 'formatLocale', localeSettings.formatLocale); } }; /** @@ -6776,7 +6781,7 @@ var Embed = /** @class */ (function () { * @hidden */ Embed.prototype.getUniqueId = function () { - return this.config.uniqueId || this.element.getAttribute(Embed.nameAttribute) || utils.createRandomString(); + return this.config.uniqueId || this.element.getAttribute(Embed.nameAttribute) || util_1.createRandomString(); }; /** * Gets the group ID from the first available location: options, embeddedUrl. @@ -6820,13 +6825,14 @@ var Embed = /** @class */ (function () { }; /** * Sets Iframe for embed + * * @hidden */ Embed.prototype.setIframe = function (isLoad, phasedRender, isBootstrap) { var _this = this; if (!this.iframe) { var iframeContent = document.createElement("iframe"); - var embedUrl = this.config.uniqueId ? utils.addParamToUrl(this.config.embedUrl, 'uid', this.config.uniqueId) : this.config.embedUrl; + var embedUrl = this.config.uniqueId ? util_1.addParamToUrl(this.config.embedUrl, 'uid', this.config.uniqueId) : this.config.embedUrl; iframeContent.style.width = '100%'; iframeContent.style.height = '100%'; iframeContent.setAttribute("src", embedUrl); @@ -6889,7 +6895,7 @@ var Embed = /** @class */ (function () { /** * Removes element's tabindex attribute */ - Embed.prototype.removeComponentTabIndex = function (tabIndex) { + Embed.prototype.removeComponentTabIndex = function (_tabIndex) { if (!this.element) { return; } @@ -6915,6 +6921,7 @@ var Embed = /** @class */ (function () { }; /** * Sends the config for front load calls, after 'ready' message is received from the iframe + * * @hidden */ Embed.prototype.frontLoadSendConfig = function (config) { @@ -6931,8 +6938,9 @@ var Embed = /** @class */ (function () { throw errors; } // contentWindow must be initialized - if (this.iframe.contentWindow == null) + if (this.iframe.contentWindow == null) { return [2 /*return*/]; + } _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); @@ -6993,26 +7001,29 @@ exports.EmbedUrlNotSupported = "Embed URL is invalid for this scenario. Please u Object.defineProperty(exports, "__esModule", { value: true }); exports.routerFactory = exports.wpmpFactory = exports.hpmFactory = void 0; +/** + * TODO: Need to find better place for these factory functions or refactor how we handle dependency injection + */ +var window_post_message_proxy_1 = __webpack_require__(/*! window-post-message-proxy */ "./node_modules/window-post-message-proxy/dist/windowPostMessageProxy.js"); +var http_post_message_1 = __webpack_require__(/*! http-post-message */ "./node_modules/http-post-message/dist/httpPostMessage.js"); +var powerbi_router_1 = __webpack_require__(/*! powerbi-router */ "./node_modules/powerbi-router/dist/router.js"); var config_1 = __webpack_require__(/*! ./config */ "./src/config.ts"); -var wpmp = __webpack_require__(/*! window-post-message-proxy */ "./node_modules/window-post-message-proxy/dist/windowPostMessageProxy.js"); -var hpm = __webpack_require__(/*! http-post-message */ "./node_modules/http-post-message/dist/httpPostMessage.js"); -var router = __webpack_require__(/*! powerbi-router */ "./node_modules/powerbi-router/dist/router.js"); var hpmFactory = function (wpmp, defaultTargetWindow, sdkVersion, sdkType) { if (sdkVersion === void 0) { sdkVersion = config_1.default.version; } if (sdkType === void 0) { sdkType = config_1.default.type; } - return new hpm.HttpPostMessage(wpmp, { + return new http_post_message_1.HttpPostMessage(wpmp, { 'x-sdk-type': sdkType, 'x-sdk-version': sdkVersion }, defaultTargetWindow); }; exports.hpmFactory = hpmFactory; var wpmpFactory = function (name, logMessages, eventSourceOverrideWindow) { - return new wpmp.WindowPostMessageProxy({ + return new window_post_message_proxy_1.WindowPostMessageProxy({ processTrackingProperties: { - addTrackingProperties: hpm.HttpPostMessage.addTrackingProperties, - getTrackingProperties: hpm.HttpPostMessage.getTrackingProperties, + addTrackingProperties: http_post_message_1.HttpPostMessage.addTrackingProperties, + getTrackingProperties: http_post_message_1.HttpPostMessage.getTrackingProperties, }, - isErrorMessage: hpm.HttpPostMessage.isErrorMessage, + isErrorMessage: http_post_message_1.HttpPostMessage.isErrorMessage, suppressWarnings: true, name: name, logMessages: logMessages, @@ -7021,7 +7032,7 @@ var wpmpFactory = function (name, logMessages, eventSourceOverrideWindow) { }; exports.wpmpFactory = wpmpFactory; var routerFactory = function (wpmp) { - return new router.Router(wpmp); + return new powerbi_router_1.Router(wpmp); }; exports.routerFactory = routerFactory; @@ -7399,12 +7410,12 @@ exports.VisualDescriptor = exports.Visual = exports.Qna = exports.Page = exports /** * @hidden */ +var models = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); +exports.models = models; var service = __webpack_require__(/*! ./service */ "./src/service.ts"); exports.service = service; var factories = __webpack_require__(/*! ./factories */ "./src/factories.ts"); exports.factories = factories; -var models = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); -exports.models = models; var report_1 = __webpack_require__(/*! ./report */ "./src/report.ts"); Object.defineProperty(exports, "Report", { enumerable: true, get: function () { return report_1.Report; } }); var dashboard_1 = __webpack_require__(/*! ./dashboard */ "./src/dashboard.ts"); @@ -7490,8 +7501,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Qna = void 0; -var models = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); -var embed = __webpack_require__(/*! ./embed */ "./src/embed.ts"); +var powerbi_models_1 = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); +var embed_1 = __webpack_require__(/*! ./embed */ "./src/embed.ts"); /** * The Power BI Q&A embed component * @@ -7552,7 +7563,7 @@ var Qna = /** @class */ (function (_super) { * * @returns {void} */ - Qna.prototype.configChanged = function (isBootstrap) { + Qna.prototype.configChanged = function (_isBootstrap) { // Nothing to do in Q&A embed. }; /** @@ -7566,14 +7577,14 @@ var Qna = /** @class */ (function (_super) { * Validate load configuration. */ Qna.prototype.validate = function (config) { - return models.validateLoadQnaConfiguration(config); + return powerbi_models_1.validateLoadQnaConfiguration(config); }; /** @hidden */ Qna.type = "Qna"; /** @hidden */ Qna.allowedEvents = ["loaded", "visualRendered"]; return Qna; -}(embed.Embed)); +}(embed_1.Embed)); exports.Qna = Qna; @@ -8093,8 +8104,11 @@ var Report = /** @class */ (function (_super) { * * ```javascript * const newSettings = { - * navContentPaneEnabled: true, - * filterPaneEnabled: false + * panes: { + * filters: { + * visible: false + * } + * } * }; * * report.updateSettings(newSettings) @@ -8437,7 +8451,7 @@ exports.Report = Report; Object.defineProperty(exports, "__esModule", { value: true }); exports.Service = void 0; -var embed = __webpack_require__(/*! ./embed */ "./src/embed.ts"); +var embed_1 = __webpack_require__(/*! ./embed */ "./src/embed.ts"); var report_1 = __webpack_require__(/*! ./report */ "./src/report.ts"); var create_1 = __webpack_require__(/*! ./create */ "./src/create.ts"); var dashboard_1 = __webpack_require__(/*! ./dashboard */ "./src/dashboard.ts"); @@ -8473,7 +8487,7 @@ var Service = /** @class */ (function () { /** * Adds handler for report events. */ - this.router.post("/reports/:uniqueId/events/:eventName", function (req, res) { + this.router.post("/reports/:uniqueId/events/:eventName", function (req, _res) { var event = { type: 'report', id: req.params.uniqueId, @@ -8482,7 +8496,7 @@ var Service = /** @class */ (function () { }; _this.handleEvent(event); }); - this.router.post("/reports/:uniqueId/pages/:pageName/events/:eventName", function (req, res) { + this.router.post("/reports/:uniqueId/pages/:pageName/events/:eventName", function (req, _res) { var event = { type: 'report', id: req.params.uniqueId, @@ -8491,7 +8505,7 @@ var Service = /** @class */ (function () { }; _this.handleEvent(event); }); - this.router.post("/reports/:uniqueId/pages/:pageName/visuals/:visualName/events/:eventName", function (req, res) { + this.router.post("/reports/:uniqueId/pages/:pageName/visuals/:visualName/events/:eventName", function (req, _res) { var event = { type: 'report', id: req.params.uniqueId, @@ -8500,7 +8514,7 @@ var Service = /** @class */ (function () { }; _this.handleEvent(event); }); - this.router.post("/dashboards/:uniqueId/events/:eventName", function (req, res) { + this.router.post("/dashboards/:uniqueId/events/:eventName", function (req, _res) { var event = { type: 'dashboard', id: req.params.uniqueId, @@ -8509,7 +8523,7 @@ var Service = /** @class */ (function () { }; _this.handleEvent(event); }); - this.router.post("/tile/:uniqueId/events/:eventName", function (req, res) { + this.router.post("/tile/:uniqueId/events/:eventName", function (req, _res) { var event = { type: 'tile', id: req.params.uniqueId, @@ -8521,7 +8535,7 @@ var Service = /** @class */ (function () { /** * Adds handler for Q&A events. */ - this.router.post("/qna/:uniqueId/events/:eventName", function (req, res) { + this.router.post("/qna/:uniqueId/events/:eventName", function (req, _res) { var event = { type: 'qna', id: req.params.uniqueId, @@ -8533,7 +8547,7 @@ var Service = /** @class */ (function () { /** * Adds handler for front load 'ready' message. */ - this.router.post("/ready/:uniqueId", function (req, res) { + this.router.post("/ready/:uniqueId", function (req, _res) { var event = { type: 'report', id: req.params.uniqueId, @@ -8551,9 +8565,10 @@ var Service = /** @class */ (function () { } /** * Creates new report + * * @param {HTMLElement} element - * @param {embed.IEmbedConfiguration} [config={}] - * @returns {embed.Embed} + * @param {IEmbedConfiguration} [config={}] + * @returns {Embed} */ Service.prototype.createReport = function (element, config) { config.type = 'create'; @@ -8567,15 +8582,15 @@ var Service = /** @class */ (function () { * TODO: Add a description here * * @param {HTMLElement} [container] - * @param {embed.IEmbedConfiguration} [config=undefined] - * @returns {embed.Embed[]} + * @param {IEmbedConfiguration} [config=undefined] + * @returns {Embed[]} * @hidden */ Service.prototype.init = function (container, config) { var _this = this; if (config === void 0) { config = undefined; } container = (container && container instanceof HTMLElement) ? container : document.body; - var elements = Array.prototype.slice.call(container.querySelectorAll("[" + embed.Embed.embedUrlAttribute + "]")); + var elements = Array.prototype.slice.call(container.querySelectorAll("[" + embed_1.Embed.embedUrlAttribute + "]")); return elements.map(function (element) { return _this.embed(element, config); }); }; /** @@ -8584,8 +8599,8 @@ var Service = /** @class */ (function () { * otherwise creates a new component instance. * * @param {HTMLElement} element - * @param {embed.IEmbedConfigurationBase} [config={}] - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} [config={}] + * @returns {Embed} */ Service.prototype.embed = function (element, config) { if (config === void 0) { config = {}; } @@ -8598,8 +8613,8 @@ var Service = /** @class */ (function () { * This is used for the phased embedding API, once element is loaded successfully, one can call 'render' on it. * * @param {HTMLElement} element - * @param {embed.IEmbedConfigurationBase} [config={}] - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} [config={}] + * @returns {Embed} */ Service.prototype.load = function (element, config) { if (config === void 0) { config = {}; } @@ -8609,7 +8624,7 @@ var Service = /** @class */ (function () { * Given an HTML element and entityType, creates a new component instance, and bootstrap the iframe for embedding. * * @param {HTMLElement} element - * @param {embed.IBootstrapEmbedConfiguration} config: a bootstrap config which is an embed config without access token. + * @param {IBootstrapEmbedConfiguration} config: a bootstrap config which is an embed config without access token. */ Service.prototype.bootstrap = function (element, config) { return this.embedInternal(element, config, /* phasedRender */ false, /* isBootstrap */ true); @@ -8646,18 +8661,18 @@ var Service = /** @class */ (function () { * * @private * @param {IPowerBiElement} element - * @param {embed.IEmbedConfigurationBase} config - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} config + * @returns {Embed} * @hidden */ Service.prototype.embedNew = function (element, config, phasedRender, isBootstrap) { - var componentType = config.type || element.getAttribute(embed.Embed.typeAttribute); + var componentType = config.type || element.getAttribute(embed_1.Embed.typeAttribute); if (!componentType) { - throw new Error("Attempted to embed using config " + JSON.stringify(config) + " on element " + element.outerHTML + ", but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '" + embed.Embed.typeAttribute + "=\"" + report_1.Report.type.toLowerCase() + "\"'."); + throw new Error("Attempted to embed using config " + JSON.stringify(config) + " on element " + element.outerHTML + ", but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '" + embed_1.Embed.typeAttribute + "=\"" + report_1.Report.type.toLowerCase() + "\"'."); } // Saves the type as part of the configuration so that it can be referenced later at a known location. config.type = componentType; - var Component = utils.find(function (component) { return componentType === component.type.toLowerCase(); }, Service.components); + var Component = utils.find(function (embedComponent) { return componentType === embedComponent.type.toLowerCase(); }, Service.components); if (!Component) { throw new Error("Attempted to embed component of type: " + componentType + " but did not find any matching component. Please verify the type you specified is intended."); } @@ -8671,8 +8686,8 @@ var Service = /** @class */ (function () { * * @private * @param {IPowerBiElement} element - * @param {embed.IEmbedConfigurationBase} config - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} config + * @returns {Embed} * @hidden */ Service.prototype.embedExisting = function (element, config, phasedRender) { @@ -8718,7 +8733,7 @@ var Service = /** @class */ (function () { */ Service.prototype.enableAutoEmbed = function () { var _this = this; - window.addEventListener('DOMContentLoaded', function (event) { return _this.init(document.body); }, false); + window.addEventListener('DOMContentLoaded', function (_event) { return _this.init(document.body); }, false); }; /** * Returns an instance of the component associated with the element. @@ -8834,7 +8849,7 @@ var Service = /** @class */ (function () { * Use this API to preload Power BI Embedded in the background. * * @public - * @param {embed.IEmbedConfigurationBase} [config={}] + * @param {IEmbedConfigurationBase} [config={}] * @param {HTMLElement} [element=undefined] */ Service.prototype.preload = function (config, element) { @@ -8905,8 +8920,8 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Tile = void 0; -var models = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); -var embed = __webpack_require__(/*! ./embed */ "./src/embed.ts"); +var powerbi_models_1 = __webpack_require__(/*! powerbi-models */ "./node_modules/powerbi-models/dist/models.js"); +var embed_1 = __webpack_require__(/*! ./embed */ "./src/embed.ts"); /** * The Power BI tile embed component * @@ -8945,7 +8960,7 @@ var Tile = /** @class */ (function (_super) { */ Tile.prototype.validate = function (config) { var embedConfig = config; - return models.validateTileLoad(embedConfig); + return powerbi_models_1.validateTileLoad(embedConfig); }; /** * Handle config changes. @@ -8989,7 +9004,7 @@ var Tile = /** @class */ (function (_super) { /** @hidden */ Tile.allowedEvents = ["tileClicked", "tileLoaded"]; return Tile; -}(embed.Embed)); +}(embed_1.Embed)); exports.Tile = Tile; @@ -9248,6 +9263,7 @@ function getRandomValue() { exports.getRandomValue = getRandomValue; /** * Returns the time interval between two dates in milliseconds + * * @export * @param {Date} start * @param {Date} end @@ -9409,7 +9425,7 @@ var Visual = /** @class */ (function (_super) { * @param {string} pageName * @returns {Promise>} */ - Visual.prototype.setPage = function (pageName) { + Visual.prototype.setPage = function (_pageName) { throw Visual.SetPageNotSupportedError; }; /** @@ -9418,7 +9434,7 @@ var Visual = /** @class */ (function (_super) { * @hidden * @returns {Promise} */ - Visual.prototype.render = function (config) { + Visual.prototype.render = function (_config) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { throw Visual.RenderNotSupportedError; @@ -9534,7 +9550,7 @@ var Visual = /** @class */ (function (_super) { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - return [4 /*yield*/, this.service.hpm.put(url, updateFiltersRequest, { uid: this.config.uniqueId }, this.iframe.contentWindow)]; + return [4 /*yield*/, this.service.hpm.post(url, updateFiltersRequest, { uid: this.config.uniqueId }, this.iframe.contentWindow)]; case 2: return [2 /*return*/, _a.sent()]; case 3: response_3 = _a.sent(); @@ -9808,6 +9824,7 @@ var VisualDescriptor = /** @class */ (function () { /** * Exports Visual data. * Can export up to 30K rows. + * * @param rows: Optional. Default value is 30K, maximum value is 30K as well. * @param exportDataType: Optional. Default is ExportDataType.Summarized. * ```javascript @@ -9845,6 +9862,7 @@ var VisualDescriptor = /** @class */ (function () { /** * Set slicer state. * Works only for visuals of type slicer. + * * @param state: A new state which contains the slicer filters. * ```javascript * visual.setSlicerState() diff --git a/dist/powerbi.min.js b/dist/powerbi.min.js index 9d57b9c1..40c9c0c5 100644 --- a/dist/powerbi.min.js +++ b/dist/powerbi.min.js @@ -1,7 +1,7 @@ -/*! powerbi-client v2.17.1 | (c) 2016 Microsoft Corporation MIT */ +/*! powerbi-client v2.17.2 | (c) 2016 Microsoft Corporation MIT */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["powerbi-client"]=e():t["powerbi-client"]=e()}(this,(function(){return function(t){var e={};function r(a){if(e[a])return e[a].exports;var i=e[a]={i:a,l:!1,exports:{}};return t[a].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(a,i,function(e){return t[e]}.bind(null,i));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=12)}([function(t,e,r){ /*! powerbi-models v1.8.0 | (c) 2016 Microsoft Corporation MIT */ -var a;a=function(){return function(t){var e={};function r(a){if(e[a])return e[a].exports;var i=e[a]={i:a,l:!1,exports:{}};return t[a].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(a,i,function(e){return t[e]}.bind(null,i));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){var a,i=this&&this.__extends||(a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.validateCustomTheme=e.validateCommandsSettings=e.validateVisualSettings=e.validateVisualHeader=e.validateExportDataRequest=e.validateQnaInterpretInputData=e.validateLoadQnaConfiguration=e.validateSaveAsParameters=e.validateUpdateFiltersRequest=e.validateFilter=e.validatePage=e.validateTileLoad=e.validateDashboardLoad=e.validateCreateReport=e.validateReportLoad=e.validateMenuGroupExtension=e.validateExtension=e.validateCustomPageSize=e.validateVisualizationsPane=e.validateSyncSlicersPane=e.validateSelectionPane=e.validatePageNavigationPane=e.validateFieldsPane=e.validateFiltersPane=e.validateBookmarksPane=e.validatePanes=e.validateSettings=e.validateCaptureBookmarkRequest=e.validateApplyBookmarkStateRequest=e.validateApplyBookmarkByNameRequest=e.validateAddBookmarkRequest=e.validatePlayBookmarkRequest=e.validateSlicerState=e.validateSlicer=e.validateVisualSelector=e.isIExtensionArray=e.isIExtensions=e.isGroupedMenuExtension=e.isFlatMenuExtension=e.VisualDataRoleKindPreference=e.VisualDataRoleKind=e.CommandDisplayOption=e.SlicerTargetSelector=e.VisualTypeSelector=e.VisualSelector=e.PageSelector=e.Selector=e.SortDirection=e.LegendPosition=e.TextAlignment=e.CommonErrorCodes=e.BookmarksPlayMode=e.ExportDataType=e.QnaMode=e.PageNavigationPosition=e.isColumnAggr=e.isHierarchyLevelAggr=e.isHierarchyLevel=e.isColumn=e.isMeasure=e.getFilterType=e.isBasicFilterWithKeys=e.isFilterKeyColumnsTarget=e.AdvancedFilter=e.TupleFilter=e.BasicFilterWithKeys=e.BasicFilter=e.RelativeTimeFilter=e.RelativeDateFilter=e.TopNFilter=e.IncludeExcludeFilter=e.NotSupportedFilter=e.Filter=e.RelativeDateOperators=e.RelativeDateFilterTimeUnit=e.FilterType=e.FiltersLevel=e.FiltersOperations=e.MenuLocation=e.ContrastMode=e.TokenType=e.ViewMode=e.Permissions=e.SectionVisibility=e.HyperlinkClickBehavior=e.LayoutType=e.VisualContainerDisplayMode=e.BackgroundType=e.DisplayOption=e.PageSizeType=e.TraceType=void 0;var o,n=r(1);!function(t){t[t.Information=0]="Information",t[t.Verbose=1]="Verbose",t[t.Warning=2]="Warning",t[t.Error=3]="Error",t[t.ExpectedError=4]="ExpectedError",t[t.UnexpectedError=5]="UnexpectedError",t[t.Fatal=6]="Fatal"}(e.TraceType||(e.TraceType={})),function(t){t[t.Widescreen=0]="Widescreen",t[t.Standard=1]="Standard",t[t.Cortana=2]="Cortana",t[t.Letter=3]="Letter",t[t.Custom=4]="Custom"}(e.PageSizeType||(e.PageSizeType={})),function(t){t[t.FitToPage=0]="FitToPage",t[t.FitToWidth=1]="FitToWidth",t[t.ActualSize=2]="ActualSize"}(e.DisplayOption||(e.DisplayOption={})),function(t){t[t.Default=0]="Default",t[t.Transparent=1]="Transparent"}(e.BackgroundType||(e.BackgroundType={})),function(t){t[t.Visible=0]="Visible",t[t.Hidden=1]="Hidden"}(e.VisualContainerDisplayMode||(e.VisualContainerDisplayMode={})),function(t){t[t.Master=0]="Master",t[t.Custom=1]="Custom",t[t.MobilePortrait=2]="MobilePortrait",t[t.MobileLandscape=3]="MobileLandscape"}(e.LayoutType||(e.LayoutType={})),function(t){t[t.Navigate=0]="Navigate",t[t.NavigateAndRaiseEvent=1]="NavigateAndRaiseEvent",t[t.RaiseEvent=2]="RaiseEvent"}(e.HyperlinkClickBehavior||(e.HyperlinkClickBehavior={})),function(t){t[t.AlwaysVisible=0]="AlwaysVisible",t[t.HiddenInViewMode=1]="HiddenInViewMode"}(e.SectionVisibility||(e.SectionVisibility={})),function(t){t[t.Read=0]="Read",t[t.ReadWrite=1]="ReadWrite",t[t.Copy=2]="Copy",t[t.Create=4]="Create",t[t.All=7]="All"}(e.Permissions||(e.Permissions={})),function(t){t[t.View=0]="View",t[t.Edit=1]="Edit"}(e.ViewMode||(e.ViewMode={})),function(t){t[t.Aad=0]="Aad",t[t.Embed=1]="Embed"}(e.TokenType||(e.TokenType={})),function(t){t[t.None=0]="None",t[t.HighContrast1=1]="HighContrast1",t[t.HighContrast2=2]="HighContrast2",t[t.HighContrastBlack=3]="HighContrastBlack",t[t.HighContrastWhite=4]="HighContrastWhite"}(e.ContrastMode||(e.ContrastMode={})),function(t){t[t.Bottom=0]="Bottom",t[t.Top=1]="Top"}(e.MenuLocation||(e.MenuLocation={})),function(t){t[t.RemoveAll=0]="RemoveAll",t[t.ReplaceAll=1]="ReplaceAll",t[t.Add=2]="Add",t[t.Replace=3]="Replace"}(e.FiltersOperations||(e.FiltersOperations={})),function(t){t[t.Report=0]="Report",t[t.Page=1]="Page",t[t.Visual=2]="Visual"}(e.FiltersLevel||(e.FiltersLevel={})),function(t){t[t.Advanced=0]="Advanced",t[t.Basic=1]="Basic",t[t.Unknown=2]="Unknown",t[t.IncludeExclude=3]="IncludeExclude",t[t.RelativeDate=4]="RelativeDate",t[t.TopN=5]="TopN",t[t.Tuple=6]="Tuple",t[t.RelativeTime=7]="RelativeTime"}(o=e.FilterType||(e.FilterType={})),function(t){t[t.Days=0]="Days",t[t.Weeks=1]="Weeks",t[t.CalendarWeeks=2]="CalendarWeeks",t[t.Months=3]="Months",t[t.CalendarMonths=4]="CalendarMonths",t[t.Years=5]="Years",t[t.CalendarYears=6]="CalendarYears",t[t.Minutes=7]="Minutes",t[t.Hours=8]="Hours"}(e.RelativeDateFilterTimeUnit||(e.RelativeDateFilterTimeUnit={})),function(t){t[t.InLast=0]="InLast",t[t.InThis=1]="InThis",t[t.InNext=2]="InNext"}(e.RelativeDateOperators||(e.RelativeDateOperators={}));var l=function(){function t(t,e){this.target=t,this.filterType=e}return t.prototype.toJSON=function(){var t={$schema:this.schemaUrl,target:this.target,filterType:this.filterType};return void 0!==this.displaySettings&&(t.displaySettings=this.displaySettings),t},t}();e.Filter=l;var s=function(t){function e(r,a,i){var n=t.call(this,r,o.Unknown)||this;return n.message=a,n.notSupportedTypeName=i,n.schemaUrl=e.schemaUrl,n}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.message=this.message,e.notSupportedTypeName=this.notSupportedTypeName,e},e.schemaUrl="http://powerbi.com/product/schema#notSupported",e}(l);e.NotSupportedFilter=s;var d=function(t){function e(r,a,i){var n=t.call(this,r,o.IncludeExclude)||this;return n.values=i,n.isExclude=a,n.schemaUrl=e.schemaUrl,n}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.isExclude=this.isExclude,e.values=this.values,e},e.schemaUrl="http://powerbi.com/product/schema#includeExclude",e}(l);e.IncludeExcludeFilter=d;var u=function(t){function e(r,a,i,n){var l=t.call(this,r,o.TopN)||this;return l.operator=a,l.itemCount=i,l.schemaUrl=e.schemaUrl,l.orderBy=n,l}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.operator=this.operator,e.itemCount=this.itemCount,e.orderBy=this.orderBy,e},e.schemaUrl="http://powerbi.com/product/schema#topN",e}(l);e.TopNFilter=u;var c=function(t){function e(r,a,i,n,l){var s=t.call(this,r,o.RelativeDate)||this;return s.operator=a,s.timeUnitsCount=i,s.timeUnitType=n,s.includeToday=l,s.schemaUrl=e.schemaUrl,s}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.operator=this.operator,e.timeUnitsCount=this.timeUnitsCount,e.timeUnitType=this.timeUnitType,e.includeToday=this.includeToday,e},e.schemaUrl="http://powerbi.com/product/schema#relativeDate",e}(l);e.RelativeDateFilter=c;var p=function(t){function e(r,a,i,n){var l=t.call(this,r,o.RelativeTime)||this;return l.operator=a,l.timeUnitsCount=i,l.timeUnitType=n,l.schemaUrl=e.schemaUrl,l}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.operator=this.operator,e.timeUnitsCount=this.timeUnitsCount,e.timeUnitType=this.timeUnitType,e},e.schemaUrl="http://powerbi.com/product/schema#relativeTime",e}(l);e.RelativeTimeFilter=p;var f=function(t){function e(r,a){for(var i=[],n=2;n0&&!i)throw new Error("You should pass the values to be filtered for each key. You passed: no values and "+n+" keys");if(0===n&&i&&i.length>0)throw new Error("You passed key values but your target object doesn't contain the keys to be filtered");for(var l=0,s=o.keyValues;l2)throw new Error("AdvancedFilters may not have more than two conditions. You passed: "+i.length);if(1===l.length&&"And"!==a)throw new Error('Logical Operator must be "And" when there is only one condition provided');return s.conditions=l,s}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.logicalOperator=this.logicalOperator,e.conditions=this.conditions,e},e.schemaUrl="http://powerbi.com/product/schema#advanced",e}(l);function m(t){if(t.filterType)return t.filterType;var e=t,r=t;return"string"==typeof e.operator&&Array.isArray(e.values)?o.Basic:"string"==typeof r.logicalOperator&&Array.isArray(r.conditions)?o.Advanced:o.Unknown}function V(t){return!(!t.table||!t.column||t.aggregationFunction)}e.AdvancedFilter=y,e.isFilterKeyColumnsTarget=function(t){return V(t)&&!!t.keys},e.isBasicFilterWithKeys=function(t){return m(t)===o.Basic&&!!t.keyValues},e.getFilterType=m,e.isMeasure=function(t){return void 0!==t.table&&void 0!==t.measure},e.isColumn=V,e.isHierarchyLevel=function(t){return!(!(t.table&&t.hierarchy&&t.hierarchyLevel)||t.aggregationFunction)},e.isHierarchyLevelAggr=function(t){return!!(t.table&&t.hierarchy&&t.hierarchyLevel&&t.aggregationFunction)},e.isColumnAggr=function(t){return!!(t.table&&t.column&&t.aggregationFunction)},function(t){t[t.Bottom=0]="Bottom",t[t.Left=1]="Left"}(e.PageNavigationPosition||(e.PageNavigationPosition={})),function(t){t[t.Interactive=0]="Interactive",t[t.ResultOnly=1]="ResultOnly"}(e.QnaMode||(e.QnaMode={})),function(t){t[t.Summarized=0]="Summarized",t[t.Underlying=1]="Underlying"}(e.ExportDataType||(e.ExportDataType={})),function(t){t[t.Off=0]="Off",t[t.Presentation=1]="Presentation"}(e.BookmarksPlayMode||(e.BookmarksPlayMode={})),e.CommonErrorCodes={TokenExpired:"TokenExpired",NotFound:"PowerBIEntityNotFound",InvalidParameters:"Invalid parameters",LoadReportFailed:"LoadReportFailed",NotAuthorized:"PowerBINotAuthorizedException",FailedToLoadModel:"ExplorationContainer_FailedToLoadModel_DefaultDetails"},e.TextAlignment={Left:"left",Center:"center",Right:"right"},e.LegendPosition={Top:"Top",Bottom:"Bottom",Right:"Right",Left:"Left",TopCenter:"TopCenter",BottomCenter:"BottomCenter",RightCenter:"RightCenter",LeftCenter:"LeftCenter"},function(t){t[t.Ascending=1]="Ascending",t[t.Descending=2]="Descending"}(e.SortDirection||(e.SortDirection={}));var g=function(){function t(t){this.$schema=t}return t.prototype.toJSON=function(){return{$schema:this.$schema}},t}();e.Selector=g;var b=function(t){function e(r){var a=t.call(this,e.schemaUrl)||this;return a.pageName=r,a}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.pageName=this.pageName,e},e.schemaUrl="http://powerbi.com/product/schema#pageSelector",e}(g);e.PageSelector=b;var w=function(t){function e(r){var a=t.call(this,e.schemaUrl)||this;return a.visualName=r,a}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.visualName=this.visualName,e},e.schemaUrl="http://powerbi.com/product/schema#visualSelector",e}(g);e.VisualSelector=w;var P=function(t){function e(e){var r=t.call(this,w.schemaUrl)||this;return r.visualType=e,r}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.visualType=this.visualType,e},e.schemaUrl="http://powerbi.com/product/schema#visualTypeSelector",e}(g);e.VisualTypeSelector=P;var _=function(t){function e(e){var r=t.call(this,w.schemaUrl)||this;return r.target=e,r}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.target=this.target,e},e.schemaUrl="http://powerbi.com/product/schema#slicerTargetSelector",e}(g);function S(t){return t&&!!t.groupName}function E(t){return Array.isArray(t)}function O(t){var e=t.message;return e||(e=t.path+" is invalid. Not meeting "+t.keyword+" constraint"),{message:e}}e.SlicerTargetSelector=_,function(t){t[t.Enabled=0]="Enabled",t[t.Disabled=1]="Disabled",t[t.Hidden=2]="Hidden"}(e.CommandDisplayOption||(e.CommandDisplayOption={})),function(t){t[t.Grouping=0]="Grouping",t[t.Measure=1]="Measure",t[t.GroupingOrMeasure=2]="GroupingOrMeasure"}(e.VisualDataRoleKind||(e.VisualDataRoleKind={})),function(t){t[t.Measure=0]="Measure",t[t.Grouping=1]="Grouping"}(e.VisualDataRoleKindPreference||(e.VisualDataRoleKindPreference={})),e.isFlatMenuExtension=function(t){return t&&!S(t)},e.isGroupedMenuExtension=S,e.isIExtensions=function(t){return t&&!E(t)},e.isIExtensionArray=E,e.validateVisualSelector=function(t){var e=n.Validators.visualSelectorValidator.validate(t);return e?e.map(O):void 0},e.validateSlicer=function(t){var e=n.Validators.slicerValidator.validate(t);return e?e.map(O):void 0},e.validateSlicerState=function(t){var e=n.Validators.slicerStateValidator.validate(t);return e?e.map(O):void 0},e.validatePlayBookmarkRequest=function(t){var e=n.Validators.playBookmarkRequestValidator.validate(t);return e?e.map(O):void 0},e.validateAddBookmarkRequest=function(t){var e=n.Validators.addBookmarkRequestValidator.validate(t);return e?e.map(O):void 0},e.validateApplyBookmarkByNameRequest=function(t){var e=n.Validators.applyBookmarkByNameRequestValidator.validate(t);return e?e.map(O):void 0},e.validateApplyBookmarkStateRequest=function(t){var e=n.Validators.applyBookmarkStateRequestValidator.validate(t);return e?e.map(O):void 0},e.validateCaptureBookmarkRequest=function(t){var e=n.Validators.captureBookmarkRequestValidator.validate(t);return e?e.map(O):void 0},e.validateSettings=function(t){var e=n.Validators.settingsValidator.validate(t);return e?e.map(O):void 0},e.validatePanes=function(t){var e=n.Validators.reportPanesValidator.validate(t);return e?e.map(O):void 0},e.validateBookmarksPane=function(t){var e=n.Validators.bookmarksPaneValidator.validate(t);return e?e.map(O):void 0},e.validateFiltersPane=function(t){var e=n.Validators.filtersPaneValidator.validate(t);return e?e.map(O):void 0},e.validateFieldsPane=function(t){var e=n.Validators.fieldsPaneValidator.validate(t);return e?e.map(O):void 0},e.validatePageNavigationPane=function(t){var e=n.Validators.pageNavigationPaneValidator.validate(t);return e?e.map(O):void 0},e.validateSelectionPane=function(t){var e=n.Validators.selectionPaneValidator.validate(t);return e?e.map(O):void 0},e.validateSyncSlicersPane=function(t){var e=n.Validators.syncSlicersPaneValidator.validate(t);return e?e.map(O):void 0},e.validateVisualizationsPane=function(t){var e=n.Validators.visualizationsPaneValidator.validate(t);return e?e.map(O):void 0},e.validateCustomPageSize=function(t){var e=n.Validators.customPageSizeValidator.validate(t);return e?e.map(O):void 0},e.validateExtension=function(t){var e=n.Validators.extensionValidator.validate(t);return e?e.map(O):void 0},e.validateMenuGroupExtension=function(t){var e=n.Validators.menuGroupExtensionValidator.validate(t);return e?e.map(O):void 0},e.validateReportLoad=function(t){var e=n.Validators.reportLoadValidator.validate(t);return e?e.map(O):void 0},e.validateCreateReport=function(t){var e=n.Validators.reportCreateValidator.validate(t);return e?e.map(O):void 0},e.validateDashboardLoad=function(t){var e=n.Validators.dashboardLoadValidator.validate(t);return e?e.map(O):void 0},e.validateTileLoad=function(t){var e=n.Validators.tileLoadValidator.validate(t);return e?e.map(O):void 0},e.validatePage=function(t){var e=n.Validators.pageValidator.validate(t);return e?e.map(O):void 0},e.validateFilter=function(t){var e=n.Validators.filterValidator.validate(t);return e?e.map(O):void 0},e.validateUpdateFiltersRequest=function(t){var e=n.Validators.updateFiltersRequestValidator.validate(t);return e?e.map(O):void 0},e.validateSaveAsParameters=function(t){var e=n.Validators.saveAsParametersValidator.validate(t);return e?e.map(O):void 0},e.validateLoadQnaConfiguration=function(t){var e=n.Validators.loadQnaValidator.validate(t);return e?e.map(O):void 0},e.validateQnaInterpretInputData=function(t){var e=n.Validators.qnaInterpretInputDataValidator.validate(t);return e?e.map(O):void 0},e.validateExportDataRequest=function(t){var e=n.Validators.exportDataRequestValidator.validate(t);return e?e.map(O):void 0},e.validateVisualHeader=function(t){var e=n.Validators.visualHeaderValidator.validate(t);return e?e.map(O):void 0},e.validateVisualSettings=function(t){var e=n.Validators.visualSettingsValidator.validate(t);return e?e.map(O):void 0},e.validateCommandsSettings=function(t){var e=n.Validators.commandsSettingsValidator.validate(t);return e?e.map(O):void 0},e.validateCustomTheme=function(t){var e=n.Validators.customThemeValidator.validate(t);return e?e.map(O):void 0}},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.Validators=void 0;var a=r(2),i=r(5),o=r(6),n=r(7),l=r(8),s=r(9),d=r(10),u=r(11),c=r(12),p=r(13),f=r(14),h=r(15),v=r(16),y=r(17),m=r(18),V=r(19),g=r(20),b=r(21),w=r(22),P=r(23),_=r(24),S=r(25),E=r(26),O=r(27),T=r(28),F=r(4);e.Validators={addBookmarkRequestValidator:new i.AddBookmarkRequestValidator,advancedFilterTypeValidator:new F.EnumValidator([0]),advancedFilterValidator:new c.AdvancedFilterValidator,anyArrayValidator:new F.ArrayValidator([new S.AnyOfValidator([new F.StringValidator,new F.NumberValidator,new F.BooleanValidator])]),anyFilterValidator:new S.AnyOfValidator([new c.BasicFilterValidator,new c.AdvancedFilterValidator,new c.IncludeExcludeFilterValidator,new c.NotSupportedFilterValidator,new c.RelativeDateFilterValidator,new c.TopNFilterValidator,new c.RelativeTimeFilterValidator]),anyValueValidator:new S.AnyOfValidator([new F.StringValidator,new F.NumberValidator,new F.BooleanValidator]),actionBarValidator:new a.ActionBarValidator,applyBookmarkByNameRequestValidator:new i.ApplyBookmarkByNameRequestValidator,applyBookmarkStateRequestValidator:new i.ApplyBookmarkStateRequestValidator,applyBookmarkValidator:new S.AnyOfValidator([new i.ApplyBookmarkByNameRequestValidator,new i.ApplyBookmarkStateRequestValidator]),backgroundValidator:new F.EnumValidator([0,1]),basicFilterTypeValidator:new F.EnumValidator([1]),basicFilterValidator:new c.BasicFilterValidator,booleanArrayValidator:new F.BooleanArrayValidator,booleanValidator:new F.BooleanValidator,bookmarksPaneValidator:new h.BookmarksPaneValidator,captureBookmarkOptionsValidator:new i.CaptureBookmarkOptionsValidator,captureBookmarkRequestValidator:new i.CaptureBookmarkRequestValidator,commandDisplayOptionValidator:new F.EnumValidator([0,1,2]),commandExtensionSelectorValidator:new S.AnyOfValidator([new g.VisualSelectorValidator,new g.VisualTypeSelectorValidator]),commandExtensionArrayValidator:new F.ArrayValidator([new u.CommandExtensionValidator]),commandExtensionValidator:new u.CommandExtensionValidator,commandsSettingsArrayValidator:new F.ArrayValidator([new o.CommandsSettingsValidator]),commandsSettingsValidator:new o.CommandsSettingsValidator,conditionItemValidator:new c.ConditionItemValidator,contrastModeValidator:new F.EnumValidator([0,1,2,3,4]),customLayoutDisplayOptionValidator:new F.EnumValidator([0,1,2]),customLayoutValidator:new p.CustomLayoutValidator,customPageSizeValidator:new f.CustomPageSizeValidator,customThemeValidator:new n.CustomThemeValidator,dashboardLoadValidator:new l.DashboardLoadValidator,datasetBindingValidator:new s.DatasetBindingValidator,displayStateModeValidator:new F.EnumValidator([0,1]),displayStateValidator:new p.DisplayStateValidator,exportDataRequestValidator:new d.ExportDataRequestValidator,extensionArrayValidator:new F.ArrayValidator([new u.ExtensionValidator]),extensionsValidator:new S.AnyOfValidator([new F.ArrayValidator([new u.ExtensionValidator]),new u.ExtensionsValidator]),extensionPointsValidator:new u.ExtensionPointsValidator,extensionValidator:new u.ExtensionValidator,fieldForbiddenValidator:new E.FieldForbiddenValidator,fieldRequiredValidator:new O.FieldRequiredValidator,fieldsPaneValidator:new h.FieldsPaneValidator,filterColumnTargetValidator:new c.FilterColumnTargetValidator,filterDisplaySettingsValidator:new c.FilterDisplaySettingsValidator,filterConditionsValidator:new F.ArrayValidator([new c.ConditionItemValidator]),filterHierarchyTargetValidator:new c.FilterHierarchyTargetValidator,filterMeasureTargetValidator:new c.FilterMeasureTargetValidator,filterTargetValidator:new S.AnyOfValidator([new c.FilterColumnTargetValidator,new c.FilterHierarchyTargetValidator,new c.FilterMeasureTargetValidator]),filterValidator:new c.FilterValidator,filterTypeValidator:new F.EnumValidator([0,1,2,3,4,5,6,7]),filtersArrayValidator:new F.ArrayValidator([new c.FilterValidator]),filtersOperationsUpdateValidator:new F.EnumValidator([1,2,3]),filtersOperationsRemoveAllValidator:new F.EnumValidator([0]),filtersPaneValidator:new h.FiltersPaneValidator,hyperlinkClickBehaviorValidator:new F.EnumValidator([0,1,2]),includeExcludeFilterValidator:new c.IncludeExcludeFilterValidator,includeExludeFilterTypeValidator:new F.EnumValidator([3]),layoutTypeValidator:new F.EnumValidator([0,1,2,3]),loadQnaValidator:new v.LoadQnaValidator,menuExtensionValidator:new S.AnyOfValidator([new u.FlatMenuExtensionValidator,new u.GroupedMenuExtensionValidator]),menuGroupExtensionArrayValidator:new F.ArrayValidator([new u.MenuGroupExtensionValidator]),menuGroupExtensionValidator:new u.MenuGroupExtensionValidator,menuLocationValidator:new F.EnumValidator([0,1]),notSupportedFilterTypeValidator:new F.EnumValidator([2]),notSupportedFilterValidator:new c.NotSupportedFilterValidator,numberArrayValidator:new F.NumberArrayValidator,numberValidator:new F.NumberValidator,pageLayoutValidator:new T.MapValidator([new F.StringValidator],[new p.VisualLayoutValidator]),pageNavigationPaneValidator:new h.PageNavigationPaneValidator,pageNavigationPositionValidator:new F.EnumValidator([0,1]),pageSizeTypeValidator:new F.EnumValidator([0,1,2,3,4,5]),pageSizeValidator:new f.PageSizeValidator,pageValidator:new f.PageValidator,pageViewFieldValidator:new f.PageViewFieldValidator,pagesLayoutValidator:new T.MapValidator([new F.StringValidator],[new p.PageLayoutValidator]),reportBarsValidator:new a.ReportBarsValidator,reportPanesValidator:new h.ReportPanesValidator,permissionsValidator:new F.EnumValidator([0,1,2,4,7]),playBookmarkRequestValidator:new i.PlayBookmarkRequestValidator,qnaInterpretInputDataValidator:new v.QnaInterpretInputDataValidator,qnaSettingValidator:new v.QnaSettingsValidator,relativeDateFilterOperatorValidator:new F.EnumValidator([0,1,2]),relativeDateFilterTimeUnitTypeValidator:new F.EnumValidator([0,1,2,3,4,5,6]),relativeDateFilterTypeValidator:new F.EnumValidator([4]),relativeDateFilterValidator:new c.RelativeDateFilterValidator,relativeTimeFilterTimeUnitTypeValidator:new F.EnumValidator([7,8]),relativeTimeFilterTypeValidator:new F.EnumValidator([7]),relativeTimeFilterValidator:new c.RelativeTimeFilterValidator,reportCreateValidator:new y.ReportCreateValidator,reportLoadValidator:new m.ReportLoadValidator,saveAsParametersValidator:new V.SaveAsParametersValidator,selectionPaneValidator:new h.SelectionPaneValidator,settingsValidator:new b.SettingsValidator,singleCommandSettingsValidator:new o.SingleCommandSettingsValidator,slicerSelectorValidator:new S.AnyOfValidator([new g.VisualSelectorValidator,new g.SlicerTargetSelectorValidator]),slicerStateValidator:new w.SlicerStateValidator,slicerTargetValidator:new S.AnyOfValidator([new c.FilterColumnTargetValidator,new c.FilterHierarchyTargetValidator,new c.FilterMeasureTargetValidator,new c.FilterKeyColumnsTargetValidator,new c.FilterKeyHierarchyTargetValidator]),slicerValidator:new w.SlicerValidator,stringArrayValidator:new F.StringArrayValidator,stringValidator:new F.StringValidator,syncSlicersPaneValidator:new h.SyncSlicersPaneValidator,tileLoadValidator:new P.TileLoadValidator,tokenTypeValidator:new F.EnumValidator([0,1]),topNFilterTypeValidator:new F.EnumValidator([5]),topNFilterValidator:new c.TopNFilterValidator,updateFiltersRequestValidator:new S.AnyOfValidator([new c.UpdateFiltersRequestValidator,new c.RemoveFiltersRequestValidator]),viewModeValidator:new F.EnumValidator([0,1]),visualCommandSelectorValidator:new S.AnyOfValidator([new g.VisualSelectorValidator,new g.VisualTypeSelectorValidator]),visualHeaderSelectorValidator:new S.AnyOfValidator([new g.VisualSelectorValidator,new g.VisualTypeSelectorValidator]),visualHeaderSettingsValidator:new _.VisualHeaderSettingsValidator,visualHeaderValidator:new _.VisualHeaderValidator,visualHeadersValidator:new F.ArrayValidator([new _.VisualHeaderValidator]),visualizationsPaneValidator:new h.VisualizationsPaneValidator,visualLayoutValidator:new p.VisualLayoutValidator,visualSelectorValidator:new g.VisualSelectorValidator,visualSettingsValidator:new _.VisualSettingsValidator,visualTypeSelectorValidator:new g.VisualTypeSelectorValidator}},function(t,e,r){var a,i=this&&this.__extends||(a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.ActionBarValidator=e.ReportBarsValidator=void 0;var o=r(3),n=r(4),l=r(1),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.validate=function(e,r,a){if(null==e)return null;var i=t.prototype.validate.call(this,e,r,a);if(i)return i;var n=[{field:"actionBar",validators:[l.Validators.actionBarValidator]}];return new o.MultipleFieldsValidator(n).validate(e,r,a)},e}(n.ObjectValidator);e.ReportBarsValidator=s;var d=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.validate=function(e,r,a){if(null==e)return null;var i=t.prototype.validate.call(this,e,r,a);if(i)return i;var n=[{field:"visible",validators:[l.Validators.booleanValidator]}];return new o.MultipleFieldsValidator(n).validate(e,r,a)},e}(n.ObjectValidator);e.ActionBarValidator=d},function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.MultipleFieldsValidator=void 0;var r=function(){function t(t){this.fieldValidatorsPairs=t}return t.prototype.validate=function(t,e,r){if(!this.fieldValidatorsPairs)return null;for(var a=e?e+"."+r:r,i=0,o=this.fieldValidatorsPairs;i0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0?"&":"?";return t+=a+e+"="+r},e.isSavedInternal=function(t,e,i){return r(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t.get("/report/hasUnsavedChanges",{uid:e},i)];case 1:return[2,!r.sent().body];case 2:throw r.sent().body;case 3:return[2]}}))}))},e.isRDLEmbed=function(t){return t.toLowerCase().indexOf("/rdlembed?")>=0},e.autoAuthInEmbedUrl=function(t){return t&&decodeURIComponent(t).toLowerCase().indexOf("autoauth=true")>=0},e.getRandomValue=o,e.getTimeDiffInMilliseconds=function(t,e){return Math.abs(t.getTime()-e.getTime())}},function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.EmbedUrlNotSupported=e.APINotSupportedForRDLError=void 0,e.APINotSupportedForRDLError="This API is currently not supported for RDL reports",e.EmbedUrlNotSupported="Embed URL is invalid for this scenario. Please use Power BI REST APIs to get the valid URL"},function(t,e,r){var a,i=this&&this.__extends||(a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__awaiter||function(t,e,r,a){return new(r||(r=Promise))((function(i,o){function n(t){try{s(a.next(t))}catch(t){o(t)}}function l(t){try{s(a.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(n,l)}s((a=a.apply(t,e||[])).next())}))},n=this&&this.__generator||function(t,e){var r,a,i,o,n={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,a&&(i=2&o[0]?a.return:o[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,o[1])).done)return i;switch(a=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,a=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if(!(i=n.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&!i)throw new Error("You should pass the values to be filtered for each key. You passed: no values and "+n+" keys");if(0===n&&i&&i.length>0)throw new Error("You passed key values but your target object doesn't contain the keys to be filtered");for(var l=0,s=o.keyValues;l2)throw new Error("AdvancedFilters may not have more than two conditions. You passed: "+i.length);if(1===l.length&&"And"!==a)throw new Error('Logical Operator must be "And" when there is only one condition provided');return s.conditions=l,s}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.logicalOperator=this.logicalOperator,e.conditions=this.conditions,e},e.schemaUrl="http://powerbi.com/product/schema#advanced",e}(l);function m(t){if(t.filterType)return t.filterType;var e=t,r=t;return"string"==typeof e.operator&&Array.isArray(e.values)?o.Basic:"string"==typeof r.logicalOperator&&Array.isArray(r.conditions)?o.Advanced:o.Unknown}function V(t){return!(!t.table||!t.column||t.aggregationFunction)}e.AdvancedFilter=y,e.isFilterKeyColumnsTarget=function(t){return V(t)&&!!t.keys},e.isBasicFilterWithKeys=function(t){return m(t)===o.Basic&&!!t.keyValues},e.getFilterType=m,e.isMeasure=function(t){return void 0!==t.table&&void 0!==t.measure},e.isColumn=V,e.isHierarchyLevel=function(t){return!(!(t.table&&t.hierarchy&&t.hierarchyLevel)||t.aggregationFunction)},e.isHierarchyLevelAggr=function(t){return!!(t.table&&t.hierarchy&&t.hierarchyLevel&&t.aggregationFunction)},e.isColumnAggr=function(t){return!!(t.table&&t.column&&t.aggregationFunction)},function(t){t[t.Bottom=0]="Bottom",t[t.Left=1]="Left"}(e.PageNavigationPosition||(e.PageNavigationPosition={})),function(t){t[t.Interactive=0]="Interactive",t[t.ResultOnly=1]="ResultOnly"}(e.QnaMode||(e.QnaMode={})),function(t){t[t.Summarized=0]="Summarized",t[t.Underlying=1]="Underlying"}(e.ExportDataType||(e.ExportDataType={})),function(t){t[t.Off=0]="Off",t[t.Presentation=1]="Presentation"}(e.BookmarksPlayMode||(e.BookmarksPlayMode={})),e.CommonErrorCodes={TokenExpired:"TokenExpired",NotFound:"PowerBIEntityNotFound",InvalidParameters:"Invalid parameters",LoadReportFailed:"LoadReportFailed",NotAuthorized:"PowerBINotAuthorizedException",FailedToLoadModel:"ExplorationContainer_FailedToLoadModel_DefaultDetails"},e.TextAlignment={Left:"left",Center:"center",Right:"right"},e.LegendPosition={Top:"Top",Bottom:"Bottom",Right:"Right",Left:"Left",TopCenter:"TopCenter",BottomCenter:"BottomCenter",RightCenter:"RightCenter",LeftCenter:"LeftCenter"},function(t){t[t.Ascending=1]="Ascending",t[t.Descending=2]="Descending"}(e.SortDirection||(e.SortDirection={}));var g=function(){function t(t){this.$schema=t}return t.prototype.toJSON=function(){return{$schema:this.$schema}},t}();e.Selector=g;var b=function(t){function e(r){var a=t.call(this,e.schemaUrl)||this;return a.pageName=r,a}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.pageName=this.pageName,e},e.schemaUrl="http://powerbi.com/product/schema#pageSelector",e}(g);e.PageSelector=b;var w=function(t){function e(r){var a=t.call(this,e.schemaUrl)||this;return a.visualName=r,a}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.visualName=this.visualName,e},e.schemaUrl="http://powerbi.com/product/schema#visualSelector",e}(g);e.VisualSelector=w;var P=function(t){function e(e){var r=t.call(this,w.schemaUrl)||this;return r.visualType=e,r}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.visualType=this.visualType,e},e.schemaUrl="http://powerbi.com/product/schema#visualTypeSelector",e}(g);e.VisualTypeSelector=P;var _=function(t){function e(e){var r=t.call(this,w.schemaUrl)||this;return r.target=e,r}return i(e,t),e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.target=this.target,e},e.schemaUrl="http://powerbi.com/product/schema#slicerTargetSelector",e}(g);function S(t){return t&&!!t.groupName}function E(t){return Array.isArray(t)}function O(t){var e=t.message;return e||(e=t.path+" is invalid. Not meeting "+t.keyword+" constraint"),{message:e}}e.SlicerTargetSelector=_,function(t){t[t.Enabled=0]="Enabled",t[t.Disabled=1]="Disabled",t[t.Hidden=2]="Hidden"}(e.CommandDisplayOption||(e.CommandDisplayOption={})),function(t){t[t.Grouping=0]="Grouping",t[t.Measure=1]="Measure",t[t.GroupingOrMeasure=2]="GroupingOrMeasure"}(e.VisualDataRoleKind||(e.VisualDataRoleKind={})),function(t){t[t.Measure=0]="Measure",t[t.Grouping=1]="Grouping"}(e.VisualDataRoleKindPreference||(e.VisualDataRoleKindPreference={})),e.isFlatMenuExtension=function(t){return t&&!S(t)},e.isGroupedMenuExtension=S,e.isIExtensions=function(t){return t&&!E(t)},e.isIExtensionArray=E,e.validateVisualSelector=function(t){var e=n.Validators.visualSelectorValidator.validate(t);return e?e.map(O):void 0},e.validateSlicer=function(t){var e=n.Validators.slicerValidator.validate(t);return e?e.map(O):void 0},e.validateSlicerState=function(t){var e=n.Validators.slicerStateValidator.validate(t);return e?e.map(O):void 0},e.validatePlayBookmarkRequest=function(t){var e=n.Validators.playBookmarkRequestValidator.validate(t);return e?e.map(O):void 0},e.validateAddBookmarkRequest=function(t){var e=n.Validators.addBookmarkRequestValidator.validate(t);return e?e.map(O):void 0},e.validateApplyBookmarkByNameRequest=function(t){var e=n.Validators.applyBookmarkByNameRequestValidator.validate(t);return e?e.map(O):void 0},e.validateApplyBookmarkStateRequest=function(t){var e=n.Validators.applyBookmarkStateRequestValidator.validate(t);return e?e.map(O):void 0},e.validateCaptureBookmarkRequest=function(t){var e=n.Validators.captureBookmarkRequestValidator.validate(t);return e?e.map(O):void 0},e.validateSettings=function(t){var e=n.Validators.settingsValidator.validate(t);return e?e.map(O):void 0},e.validatePanes=function(t){var e=n.Validators.reportPanesValidator.validate(t);return e?e.map(O):void 0},e.validateBookmarksPane=function(t){var e=n.Validators.bookmarksPaneValidator.validate(t);return e?e.map(O):void 0},e.validateFiltersPane=function(t){var e=n.Validators.filtersPaneValidator.validate(t);return e?e.map(O):void 0},e.validateFieldsPane=function(t){var e=n.Validators.fieldsPaneValidator.validate(t);return e?e.map(O):void 0},e.validatePageNavigationPane=function(t){var e=n.Validators.pageNavigationPaneValidator.validate(t);return e?e.map(O):void 0},e.validateSelectionPane=function(t){var e=n.Validators.selectionPaneValidator.validate(t);return e?e.map(O):void 0},e.validateSyncSlicersPane=function(t){var e=n.Validators.syncSlicersPaneValidator.validate(t);return e?e.map(O):void 0},e.validateVisualizationsPane=function(t){var e=n.Validators.visualizationsPaneValidator.validate(t);return e?e.map(O):void 0},e.validateCustomPageSize=function(t){var e=n.Validators.customPageSizeValidator.validate(t);return e?e.map(O):void 0},e.validateExtension=function(t){var e=n.Validators.extensionValidator.validate(t);return e?e.map(O):void 0},e.validateMenuGroupExtension=function(t){var e=n.Validators.menuGroupExtensionValidator.validate(t);return e?e.map(O):void 0},e.validateReportLoad=function(t){var e=n.Validators.reportLoadValidator.validate(t);return e?e.map(O):void 0},e.validateCreateReport=function(t){var e=n.Validators.reportCreateValidator.validate(t);return e?e.map(O):void 0},e.validateDashboardLoad=function(t){var e=n.Validators.dashboardLoadValidator.validate(t);return e?e.map(O):void 0},e.validateTileLoad=function(t){var e=n.Validators.tileLoadValidator.validate(t);return e?e.map(O):void 0},e.validatePage=function(t){var e=n.Validators.pageValidator.validate(t);return e?e.map(O):void 0},e.validateFilter=function(t){var e=n.Validators.filterValidator.validate(t);return e?e.map(O):void 0},e.validateUpdateFiltersRequest=function(t){var e=n.Validators.updateFiltersRequestValidator.validate(t);return e?e.map(O):void 0},e.validateSaveAsParameters=function(t){var e=n.Validators.saveAsParametersValidator.validate(t);return e?e.map(O):void 0},e.validateLoadQnaConfiguration=function(t){var e=n.Validators.loadQnaValidator.validate(t);return e?e.map(O):void 0},e.validateQnaInterpretInputData=function(t){var e=n.Validators.qnaInterpretInputDataValidator.validate(t);return e?e.map(O):void 0},e.validateExportDataRequest=function(t){var e=n.Validators.exportDataRequestValidator.validate(t);return e?e.map(O):void 0},e.validateVisualHeader=function(t){var e=n.Validators.visualHeaderValidator.validate(t);return e?e.map(O):void 0},e.validateVisualSettings=function(t){var e=n.Validators.visualSettingsValidator.validate(t);return e?e.map(O):void 0},e.validateCommandsSettings=function(t){var e=n.Validators.commandsSettingsValidator.validate(t);return e?e.map(O):void 0},e.validateCustomTheme=function(t){var e=n.Validators.customThemeValidator.validate(t);return e?e.map(O):void 0}},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.Validators=void 0;var a=r(2),i=r(5),o=r(6),n=r(7),l=r(8),s=r(9),d=r(10),u=r(11),c=r(12),p=r(13),f=r(14),h=r(15),v=r(16),y=r(17),m=r(18),V=r(19),g=r(20),b=r(21),w=r(22),P=r(23),_=r(24),S=r(25),E=r(26),O=r(27),T=r(28),F=r(4);e.Validators={addBookmarkRequestValidator:new i.AddBookmarkRequestValidator,advancedFilterTypeValidator:new F.EnumValidator([0]),advancedFilterValidator:new c.AdvancedFilterValidator,anyArrayValidator:new F.ArrayValidator([new S.AnyOfValidator([new F.StringValidator,new F.NumberValidator,new F.BooleanValidator])]),anyFilterValidator:new S.AnyOfValidator([new c.BasicFilterValidator,new c.AdvancedFilterValidator,new c.IncludeExcludeFilterValidator,new c.NotSupportedFilterValidator,new c.RelativeDateFilterValidator,new c.TopNFilterValidator,new c.RelativeTimeFilterValidator]),anyValueValidator:new S.AnyOfValidator([new F.StringValidator,new F.NumberValidator,new F.BooleanValidator]),actionBarValidator:new a.ActionBarValidator,applyBookmarkByNameRequestValidator:new i.ApplyBookmarkByNameRequestValidator,applyBookmarkStateRequestValidator:new i.ApplyBookmarkStateRequestValidator,applyBookmarkValidator:new S.AnyOfValidator([new i.ApplyBookmarkByNameRequestValidator,new i.ApplyBookmarkStateRequestValidator]),backgroundValidator:new F.EnumValidator([0,1]),basicFilterTypeValidator:new F.EnumValidator([1]),basicFilterValidator:new c.BasicFilterValidator,booleanArrayValidator:new F.BooleanArrayValidator,booleanValidator:new F.BooleanValidator,bookmarksPaneValidator:new h.BookmarksPaneValidator,captureBookmarkOptionsValidator:new i.CaptureBookmarkOptionsValidator,captureBookmarkRequestValidator:new i.CaptureBookmarkRequestValidator,commandDisplayOptionValidator:new F.EnumValidator([0,1,2]),commandExtensionSelectorValidator:new S.AnyOfValidator([new g.VisualSelectorValidator,new g.VisualTypeSelectorValidator]),commandExtensionArrayValidator:new F.ArrayValidator([new u.CommandExtensionValidator]),commandExtensionValidator:new u.CommandExtensionValidator,commandsSettingsArrayValidator:new F.ArrayValidator([new o.CommandsSettingsValidator]),commandsSettingsValidator:new o.CommandsSettingsValidator,conditionItemValidator:new c.ConditionItemValidator,contrastModeValidator:new F.EnumValidator([0,1,2,3,4]),customLayoutDisplayOptionValidator:new F.EnumValidator([0,1,2]),customLayoutValidator:new p.CustomLayoutValidator,customPageSizeValidator:new f.CustomPageSizeValidator,customThemeValidator:new n.CustomThemeValidator,dashboardLoadValidator:new l.DashboardLoadValidator,datasetBindingValidator:new s.DatasetBindingValidator,displayStateModeValidator:new F.EnumValidator([0,1]),displayStateValidator:new p.DisplayStateValidator,exportDataRequestValidator:new d.ExportDataRequestValidator,extensionArrayValidator:new F.ArrayValidator([new u.ExtensionValidator]),extensionsValidator:new S.AnyOfValidator([new F.ArrayValidator([new u.ExtensionValidator]),new u.ExtensionsValidator]),extensionPointsValidator:new u.ExtensionPointsValidator,extensionValidator:new u.ExtensionValidator,fieldForbiddenValidator:new E.FieldForbiddenValidator,fieldRequiredValidator:new O.FieldRequiredValidator,fieldsPaneValidator:new h.FieldsPaneValidator,filterColumnTargetValidator:new c.FilterColumnTargetValidator,filterDisplaySettingsValidator:new c.FilterDisplaySettingsValidator,filterConditionsValidator:new F.ArrayValidator([new c.ConditionItemValidator]),filterHierarchyTargetValidator:new c.FilterHierarchyTargetValidator,filterMeasureTargetValidator:new c.FilterMeasureTargetValidator,filterTargetValidator:new S.AnyOfValidator([new c.FilterColumnTargetValidator,new c.FilterHierarchyTargetValidator,new c.FilterMeasureTargetValidator]),filterValidator:new c.FilterValidator,filterTypeValidator:new F.EnumValidator([0,1,2,3,4,5,6,7]),filtersArrayValidator:new F.ArrayValidator([new c.FilterValidator]),filtersOperationsUpdateValidator:new F.EnumValidator([1,2,3]),filtersOperationsRemoveAllValidator:new F.EnumValidator([0]),filtersPaneValidator:new h.FiltersPaneValidator,hyperlinkClickBehaviorValidator:new F.EnumValidator([0,1,2]),includeExcludeFilterValidator:new c.IncludeExcludeFilterValidator,includeExludeFilterTypeValidator:new F.EnumValidator([3]),layoutTypeValidator:new F.EnumValidator([0,1,2,3]),loadQnaValidator:new v.LoadQnaValidator,menuExtensionValidator:new S.AnyOfValidator([new u.FlatMenuExtensionValidator,new u.GroupedMenuExtensionValidator]),menuGroupExtensionArrayValidator:new F.ArrayValidator([new u.MenuGroupExtensionValidator]),menuGroupExtensionValidator:new u.MenuGroupExtensionValidator,menuLocationValidator:new F.EnumValidator([0,1]),notSupportedFilterTypeValidator:new F.EnumValidator([2]),notSupportedFilterValidator:new c.NotSupportedFilterValidator,numberArrayValidator:new F.NumberArrayValidator,numberValidator:new F.NumberValidator,pageLayoutValidator:new T.MapValidator([new F.StringValidator],[new p.VisualLayoutValidator]),pageNavigationPaneValidator:new h.PageNavigationPaneValidator,pageNavigationPositionValidator:new F.EnumValidator([0,1]),pageSizeTypeValidator:new F.EnumValidator([0,1,2,3,4,5]),pageSizeValidator:new f.PageSizeValidator,pageValidator:new f.PageValidator,pageViewFieldValidator:new f.PageViewFieldValidator,pagesLayoutValidator:new T.MapValidator([new F.StringValidator],[new p.PageLayoutValidator]),reportBarsValidator:new a.ReportBarsValidator,reportPanesValidator:new h.ReportPanesValidator,permissionsValidator:new F.EnumValidator([0,1,2,4,7]),playBookmarkRequestValidator:new i.PlayBookmarkRequestValidator,qnaInterpretInputDataValidator:new v.QnaInterpretInputDataValidator,qnaSettingValidator:new v.QnaSettingsValidator,relativeDateFilterOperatorValidator:new F.EnumValidator([0,1,2]),relativeDateFilterTimeUnitTypeValidator:new F.EnumValidator([0,1,2,3,4,5,6]),relativeDateFilterTypeValidator:new F.EnumValidator([4]),relativeDateFilterValidator:new c.RelativeDateFilterValidator,relativeTimeFilterTimeUnitTypeValidator:new F.EnumValidator([7,8]),relativeTimeFilterTypeValidator:new F.EnumValidator([7]),relativeTimeFilterValidator:new c.RelativeTimeFilterValidator,reportCreateValidator:new y.ReportCreateValidator,reportLoadValidator:new m.ReportLoadValidator,saveAsParametersValidator:new V.SaveAsParametersValidator,selectionPaneValidator:new h.SelectionPaneValidator,settingsValidator:new b.SettingsValidator,singleCommandSettingsValidator:new o.SingleCommandSettingsValidator,slicerSelectorValidator:new S.AnyOfValidator([new g.VisualSelectorValidator,new g.SlicerTargetSelectorValidator]),slicerStateValidator:new w.SlicerStateValidator,slicerTargetValidator:new S.AnyOfValidator([new c.FilterColumnTargetValidator,new c.FilterHierarchyTargetValidator,new c.FilterMeasureTargetValidator,new c.FilterKeyColumnsTargetValidator,new c.FilterKeyHierarchyTargetValidator]),slicerValidator:new w.SlicerValidator,stringArrayValidator:new F.StringArrayValidator,stringValidator:new F.StringValidator,syncSlicersPaneValidator:new h.SyncSlicersPaneValidator,tileLoadValidator:new P.TileLoadValidator,tokenTypeValidator:new F.EnumValidator([0,1]),topNFilterTypeValidator:new F.EnumValidator([5]),topNFilterValidator:new c.TopNFilterValidator,updateFiltersRequestValidator:new S.AnyOfValidator([new c.UpdateFiltersRequestValidator,new c.RemoveFiltersRequestValidator]),viewModeValidator:new F.EnumValidator([0,1]),visualCommandSelectorValidator:new S.AnyOfValidator([new g.VisualSelectorValidator,new g.VisualTypeSelectorValidator]),visualHeaderSelectorValidator:new S.AnyOfValidator([new g.VisualSelectorValidator,new g.VisualTypeSelectorValidator]),visualHeaderSettingsValidator:new _.VisualHeaderSettingsValidator,visualHeaderValidator:new _.VisualHeaderValidator,visualHeadersValidator:new F.ArrayValidator([new _.VisualHeaderValidator]),visualizationsPaneValidator:new h.VisualizationsPaneValidator,visualLayoutValidator:new p.VisualLayoutValidator,visualSelectorValidator:new g.VisualSelectorValidator,visualSettingsValidator:new _.VisualSettingsValidator,visualTypeSelectorValidator:new g.VisualTypeSelectorValidator}},function(t,e,r){var a,i=this&&this.__extends||(a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.ActionBarValidator=e.ReportBarsValidator=void 0;var o=r(3),n=r(4),l=r(1),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.validate=function(e,r,a){if(null==e)return null;var i=t.prototype.validate.call(this,e,r,a);if(i)return i;var n=[{field:"actionBar",validators:[l.Validators.actionBarValidator]}];return new o.MultipleFieldsValidator(n).validate(e,r,a)},e}(n.ObjectValidator);e.ReportBarsValidator=s;var d=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.validate=function(e,r,a){if(null==e)return null;var i=t.prototype.validate.call(this,e,r,a);if(i)return i;var n=[{field:"visible",validators:[l.Validators.booleanValidator]}];return new o.MultipleFieldsValidator(n).validate(e,r,a)},e}(n.ObjectValidator);e.ActionBarValidator=d},function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.MultipleFieldsValidator=void 0;var r=function(){function t(t){this.fieldValidatorsPairs=t}return t.prototype.validate=function(t,e,r){if(!this.fieldValidatorsPairs)return null;for(var a=e?e+"."+r:r,i=0,o=this.fieldValidatorsPairs;i0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0?"&":"?";return t+=a+e+"="+r},e.isSavedInternal=function(t,e,i){return r(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t.get("/report/hasUnsavedChanges",{uid:e},i)];case 1:return[2,!r.sent().body];case 2:throw r.sent().body;case 3:return[2]}}))}))},e.isRDLEmbed=function(t){return t.toLowerCase().indexOf("/rdlembed?")>=0},e.autoAuthInEmbedUrl=function(t){return t&&decodeURIComponent(t).toLowerCase().indexOf("autoauth=true")>=0},e.getRandomValue=o,e.getTimeDiffInMilliseconds=function(t,e){return Math.abs(t.getTime()-e.getTime())}},function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.EmbedUrlNotSupported=e.APINotSupportedForRDLError=void 0,e.APINotSupportedForRDLError="This API is currently not supported for RDL reports",e.EmbedUrlNotSupported="Embed URL is invalid for this scenario. Please use Power BI REST APIs to get the valid URL"},function(t,e,r){var a,i=this&&this.__extends||(a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__awaiter||function(t,e,r,a){return new(r||(r=Promise))((function(i,o){function n(t){try{s(a.next(t))}catch(t){o(t)}}function l(t){try{s(a.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(n,l)}s((a=a.apply(t,e||[])).next())}))},n=this&&this.__generator||function(t,e){var r,a,i,o,n={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,a&&(i=2&o[0]?a.return:o[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,o[1])).done)return i;switch(a=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,a=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if(!(i=n.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1] { + if (argv.chrome) { + browser.socket.on('disconnect', function (reason) { + if (reason === "transport close" || reason === "transport error") { + done(0); + process.exit(0); + } + }); + } + }) + .start(); + if (argv.chrome) { + return watch(["src/**/*.ts", "test/**/*.ts"], function () { + runSequence('compile:spec'); + }); + } }); \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index f495d005..9efa2bd9 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -2,12 +2,17 @@ var argv = require('yargs').argv; var browserName = 'PhantomJS'; if (argv.chrome) { - browserName = 'Chrome' + browserName = 'Chrome_headless' } else if (argv.firefox) { browserName = 'Firefox' } - +const flags = [ + '--disable-extensions', + '--no-proxy-server', + '--js-flags="--max_old_space_size=6500"', + '--high-dpi-support=1', +]; module.exports = function (config) { config.set({ frameworks: ['jasmine'], @@ -18,7 +23,7 @@ module.exports = function (config) { { pattern: './test/**/*.html', served: true, included: false } ], exclude: [], - reporters: argv.debug ? ['spec'] : ['spec', 'coverage'], + reporters: argv.debug ? ['spec', 'kjhtml'] : ['spec', 'coverage', 'kjhtml'], autoWatch: true, browsers: [browserName], plugins: [ @@ -27,8 +32,15 @@ module.exports = function (config) { 'karma-jasmine', 'karma-spec-reporter', 'karma-phantomjs-launcher', - 'karma-coverage' + 'karma-coverage', + 'karma-jasmine-html-reporter' ], + customLaunchers: { + 'Chrome_headless': { + base: 'Chrome', + flags: flags.concat("--no-sandbox", "--window-size=800,800"), + }, + }, preprocessors: { './tmp/**/*.js': ['coverage'] }, coverageReporter: { reporters: [ @@ -36,8 +48,10 @@ module.exports = function (config) { { type: 'text-summary' } ] }, + retryLimit: 0, logLevel: argv.debug ? config.LOG_DEBUG : config.LOG_INFO, client: { + clearContext: false, // leave Jasmine Spec Runner output visible in browser args: argv.logMessages ? ['logMessages'] : [] } }); diff --git a/package.json b/package.json index 3af84dc8..fe7bfef4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "powerbi-client", - "version": "2.17.1", + "version": "2.17.2", "description": "JavaScript library for embedding Power BI into your apps. Provides service which makes it easy to embed different types of components and an object model which allows easy interaction with these components such as changing pages, applying filters, and responding to data selection.", "main": "dist/powerbi.js", "types": "dist/powerbi-client.d.ts", @@ -15,7 +15,8 @@ "start": "http-server ./demo", "prestart": "cd demo && npm install", "test": "gulp test", - "gulp": "gulp" + "gulp": "gulp", + "tests": "npm test -- --chrome --watch --debug" }, "keywords": [ "microsoft", @@ -54,6 +55,7 @@ "gulp-replace": "^0.5.4", "gulp-typedoc": "^2.0.0", "gulp-typescript": "^4.0.1", + "gulp-watch": "^5.0.1", "gulp4-run-sequence": "^1.0.0", "http-server": "^0.12.1", "ignore-loader": "^0.1.1", @@ -65,6 +67,7 @@ "karma-coverage": "^2.0.3", "karma-firefox-launcher": "^1.2.0", "karma-jasmine": "^0.3.8", + "karma-jasmine-html-reporter": "^0.2.2", "karma-phantomjs-launcher": "^1.0.4", "karma-spec-reporter": "0.0.32", "moment": "^2.14.1", diff --git a/src/bookmarksManager.ts b/src/bookmarksManager.ts index cd2b2434..7d5a8a12 100644 --- a/src/bookmarksManager.ts +++ b/src/bookmarksManager.ts @@ -1,9 +1,18 @@ -import * as service from './service'; -import * as embed from './embed'; -import * as models from 'powerbi-models'; -import * as utils from './util'; -import * as errors from './errors'; +import { + BookmarksPlayMode, + IApplyBookmarkByNameRequest, + IApplyBookmarkStateRequest, + ICaptureBookmarkOptions, + ICaptureBookmarkRequest, + IPlayBookmarkRequest, + IReportBookmark + +} from 'powerbi-models'; import { IHttpPostMessageResponse } from 'http-post-message'; +import { Service } from './service'; +import { IEmbedConfigurationBase } from './embed'; +import { isRDLEmbed } from './util'; +import { APINotSupportedForRDLError } from './errors'; /** * APIs for managing the report bookmarks. @@ -12,10 +21,10 @@ import { IHttpPostMessageResponse } from 'http-post-message'; * @interface IBookmarksManager */ export interface IBookmarksManager { - getBookmarks(): Promise; + getBookmarks(): Promise; apply(bookmarkName: string): Promise>; - play(playMode: models.BookmarksPlayMode): Promise>; - capture(options?: models.ICaptureBookmarkOptions): Promise; + play(playMode: BookmarksPlayMode): Promise>; + capture(options?: ICaptureBookmarkOptions): Promise; applyState(state: string): Promise>; } @@ -30,7 +39,7 @@ export class BookmarksManager implements IBookmarksManager { /** * @hidden */ - constructor(private service: service.Service, private config: embed.IEmbedConfigurationBase, private iframe?: HTMLIFrameElement) { + constructor(private service: Service, private config: IEmbedConfigurationBase, private iframe?: HTMLIFrameElement) { } /** @@ -44,15 +53,15 @@ export class BookmarksManager implements IBookmarksManager { * }); * ``` * - * @returns {Promise} + * @returns {Promise} */ - async getBookmarks(): Promise { - if (utils.isRDLEmbed(this.config.embedUrl)) { - return Promise.reject(errors.APINotSupportedForRDLError); + async getBookmarks(): Promise { + if (isRDLEmbed(this.config.embedUrl)) { + return Promise.reject(APINotSupportedForRDLError); } try { - const response = await this.service.hpm.get(`/report/bookmarks`, { uid: this.config.uniqueId }, this.iframe.contentWindow); + const response = await this.service.hpm.get(`/report/bookmarks`, { uid: this.config.uniqueId }, this.iframe.contentWindow); return response.body; } catch (response) { throw response.body; @@ -70,11 +79,11 @@ export class BookmarksManager implements IBookmarksManager { * @returns {Promise>} */ async apply(bookmarkName: string): Promise> { - if (utils.isRDLEmbed(this.config.embedUrl)) { - return Promise.reject(errors.APINotSupportedForRDLError); + if (isRDLEmbed(this.config.embedUrl)) { + return Promise.reject(APINotSupportedForRDLError); } - var request: models.IApplyBookmarkByNameRequest = { + const request: IApplyBookmarkByNameRequest = { name: bookmarkName }; @@ -90,18 +99,18 @@ export class BookmarksManager implements IBookmarksManager { * * ```javascript * // Enter presentation mode. - * bookmarksManager.play(models.BookmarksPlayMode.Presentation) + * bookmarksManager.play(BookmarksPlayMode.Presentation) * ``` * - * @param {models.BookmarksPlayMode} playMode Play mode can be either `Presentation` or `Off` + * @param {BookmarksPlayMode} playMode Play mode can be either `Presentation` or `Off` * @returns {Promise>} */ - async play(playMode: models.BookmarksPlayMode): Promise> { - if (utils.isRDLEmbed(this.config.embedUrl)) { - return Promise.reject(errors.APINotSupportedForRDLError); + async play(playMode: BookmarksPlayMode): Promise> { + if (isRDLEmbed(this.config.embedUrl)) { + return Promise.reject(APINotSupportedForRDLError); } - var playBookmarkRequest: models.IPlayBookmarkRequest = { + const playBookmarkRequest: IPlayBookmarkRequest = { playMode: playMode }; @@ -119,20 +128,20 @@ export class BookmarksManager implements IBookmarksManager { * bookmarksManager.capture(options) * ``` * - * @param {models.ICaptureBookmarkOptions} [options] Options for bookmark capturing - * @returns {Promise} + * @param {ICaptureBookmarkOptions} [options] Options for bookmark capturing + * @returns {Promise} */ - async capture(options?: models.ICaptureBookmarkOptions): Promise { - if (utils.isRDLEmbed(this.config.embedUrl)) { - return Promise.reject(errors.APINotSupportedForRDLError); + async capture(options?: ICaptureBookmarkOptions): Promise { + if (isRDLEmbed(this.config.embedUrl)) { + return Promise.reject(APINotSupportedForRDLError); } - var request: models.ICaptureBookmarkRequest = { + const request: ICaptureBookmarkRequest = { options: options || {} }; try { - const response = await this.service.hpm.post(`/report/bookmarks/capture`, request, { uid: this.config.uniqueId }, this.iframe.contentWindow); + const response = await this.service.hpm.post(`/report/bookmarks/capture`, request, { uid: this.config.uniqueId }, this.iframe.contentWindow); return response.body; } catch (response) { throw response.body; @@ -150,11 +159,11 @@ export class BookmarksManager implements IBookmarksManager { * @returns {Promise>} */ async applyState(state: string): Promise> { - if (utils.isRDLEmbed(this.config.embedUrl)) { - return Promise.reject(errors.APINotSupportedForRDLError); + if (isRDLEmbed(this.config.embedUrl)) { + return Promise.reject(APINotSupportedForRDLError); } - var request: models.IApplyBookmarkStateRequest = { + const request: IApplyBookmarkStateRequest = { state: state }; diff --git a/src/config.ts b/src/config.ts index 7a1605a9..1d6136dc 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,7 +1,7 @@ /** @ignore *//** */ const config = { - version: '2.17.1', + version: '2.17.2', type: 'js' }; -export default config; \ No newline at end of file +export default config; diff --git a/src/create.ts b/src/create.ts index 60844b80..77947399 100644 --- a/src/create.ts +++ b/src/create.ts @@ -1,6 +1,6 @@ -import * as service from './service'; -import * as models from 'powerbi-models'; -import * as embed from './embed'; +import { IReportCreateConfiguration, IError, validateCreateReport } from 'powerbi-models'; +import { Service } from './service'; +import { Embed, IEmbedConfigurationBase, IEmbedConfiguration } from './embed'; import * as utils from './util'; /** @@ -8,13 +8,13 @@ import * as utils from './util'; * * @export * @class Create - * @extends {embed.Embed} + * @extends {Embed} */ -export class Create extends embed.Embed { +export class Create extends Embed { /* * @hidden */ - constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfiguration | models.IReportCreateConfiguration, phasedRender?: boolean, isBootstrap?: boolean) { + constructor(service: Service, element: HTMLElement, config: IEmbedConfiguration | IReportCreateConfiguration, phasedRender?: boolean, isBootstrap?: boolean) { super(service, element, config, /* iframe */ undefined, phasedRender, isBootstrap); } @@ -36,13 +36,13 @@ export class Create extends embed.Embed { /** * Validate create report configuration. */ - validate(config: embed.IEmbedConfigurationBase): models.IError[] { - return models.validateCreateReport(config); + validate(config: IEmbedConfigurationBase): IError[] { + return validateCreateReport(config); } /** * Handle config changes. - * + * * @hidden * @returns {void} */ @@ -51,16 +51,16 @@ export class Create extends embed.Embed { return; } - const config = this.config; + const config = this.config as IEmbedConfiguration | IReportCreateConfiguration; this.createConfig = { - accessToken: config.accessToken, - datasetId: config.datasetId || this.getId(), - groupId: config.groupId, - settings: config.settings, - tokenType: config.tokenType, - theme: config.theme - } + accessToken: config.accessToken, + datasetId: config.datasetId || this.getId(), + groupId: config.groupId, + settings: config.settings, + tokenType: config.tokenType, + theme: config.theme + }; } /** @@ -96,14 +96,14 @@ export class Create extends embed.Embed { * @hidden */ static findIdFromEmbedUrl(url: string): string { - const datasetIdRegEx = /datasetId="?([^&]+)"?/ + const datasetIdRegEx = /datasetId="?([^&]+)"?/; const datasetIdMatch = url.match(datasetIdRegEx); - let datasetId; + let datasetId: string; if (datasetIdMatch) { datasetId = datasetIdMatch[1]; } return datasetId; } -} \ No newline at end of file +} diff --git a/src/dashboard.ts b/src/dashboard.ts index b32e54f7..0ad2b5bf 100644 --- a/src/dashboard.ts +++ b/src/dashboard.ts @@ -1,6 +1,6 @@ -import * as service from './service'; -import * as embed from './embed'; -import * as models from 'powerbi-models'; +import { IError, validateDashboardLoad, PageView } from 'powerbi-models'; +import { Service, IService } from './service'; +import { Embed, IDashboardEmbedConfiguration, IEmbedConfigurationBase } from './embed'; /** * A Dashboard node within a dashboard hierarchy @@ -9,9 +9,9 @@ import * as models from 'powerbi-models'; * @interface IDashboardNode */ export interface IDashboardNode { - iframe: HTMLIFrameElement; - service: service.IService; - config: embed.IEmbedConfigurationBase + iframe: HTMLIFrameElement; + service: IService; + config: IEmbedConfigurationBase; } /** @@ -19,112 +19,115 @@ export interface IDashboardNode { * * @export * @class Dashboard - * @extends {embed.Embed} + * @extends {Embed} * @implements {IDashboardNode} */ -export class Dashboard extends embed.Embed implements IDashboardNode { - /** @hidden */ - static allowedEvents = ["tileClicked", "error"]; - /** @hidden */ - static dashboardIdAttribute = 'powerbi-dashboard-id'; - /** @hidden */ - static typeAttribute = 'powerbi-type'; - /** @hidden */ - static type = "Dashboard"; +export class Dashboard extends Embed implements IDashboardNode { + /** @hidden */ + static allowedEvents = ["tileClicked", "error"]; + /** @hidden */ + static dashboardIdAttribute = 'powerbi-dashboard-id'; + /** @hidden */ + static typeAttribute = 'powerbi-type'; + /** @hidden */ + static type = "Dashboard"; - /** - * Creates an instance of a Power BI Dashboard. - * - * @param {service.Service} service - * @hidden - * @param {HTMLElement} element - */ - constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean) { - super(service, element, config, /* iframe */ undefined, phasedRender, isBootstrap); - this.loadPath = "/dashboard/load"; - this.phasedLoadPath = "/dashboard/prepare"; + /** + * Creates an instance of a Power BI Dashboard. + * + * @param {service.Service} service + * @hidden + * @param {HTMLElement} element + */ + constructor(service: Service, element: HTMLElement, config: IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean) { + super(service, element, config, /* iframe */ undefined, phasedRender, isBootstrap); + this.loadPath = "/dashboard/load"; + this.phasedLoadPath = "/dashboard/prepare"; - Array.prototype.push.apply(this.allowedEvents, Dashboard.allowedEvents); - } - - /** - * This adds backwards compatibility for older config which used the dashboardId query param to specify dashboard id. - * E.g. https://powerbi-df.analysis-df.windows.net/dashboardEmbedHost?dashboardId=e9363c62-edb6-4eac-92d3-2199c5ca2a9e - * - * By extracting the id we can ensure id is always explicitly provided as part of the load configuration. - * @hidden - * @static - * @param {string} url - * @returns {string} - */ - static findIdFromEmbedUrl(url: string): string { - const dashboardIdRegEx = /dashboardId="?([^&]+)"?/ - const dashboardIdMatch = url.match(dashboardIdRegEx); + Array.prototype.push.apply(this.allowedEvents, Dashboard.allowedEvents); + } - let dashboardId; - if (dashboardIdMatch) { - dashboardId = dashboardIdMatch[1]; - } + /** + * This adds backwards compatibility for older config which used the dashboardId query param to specify dashboard id. + * E.g. https://powerbi-df.analysis-df.windows.net/dashboardEmbedHost?dashboardId=e9363c62-edb6-4eac-92d3-2199c5ca2a9e + * + * By extracting the id we can ensure id is always explicitly provided as part of the load configuration. + * + * @hidden + * @static + * @param {string} url + * @returns {string} + */ + static findIdFromEmbedUrl(url: string): string { + const dashboardIdRegEx = /dashboardId="?([^&]+)"?/; + const dashboardIdMatch = url.match(dashboardIdRegEx); - return dashboardId; + let dashboardId: string; + if (dashboardIdMatch) { + dashboardId = dashboardIdMatch[1]; } - /** - * Get dashboard id from first available location: options, attribute, embed url. - * - * @returns {string} - */ - getId(): string { - let config = this.config; - const dashboardId = config.id || this.element.getAttribute(Dashboard.dashboardIdAttribute) || Dashboard.findIdFromEmbedUrl(config.embedUrl); + return dashboardId; + } - if (typeof dashboardId !== 'string' || dashboardId.length === 0) { - throw new Error(`Dashboard id is required, but it was not found. You must provide an id either as part of embed configuration or as attribute '${Dashboard.dashboardIdAttribute}'.`); - } + /** + * Get dashboard id from first available location: options, attribute, embed url. + * + * @returns {string} + */ + getId(): string { + const config = this.config as IDashboardEmbedConfiguration; + const dashboardId = config.id || this.element.getAttribute(Dashboard.dashboardIdAttribute) || Dashboard.findIdFromEmbedUrl(config.embedUrl); - return dashboardId; + if (typeof dashboardId !== 'string' || dashboardId.length === 0) { + throw new Error(`Dashboard id is required, but it was not found. You must provide an id either as part of embed configuration or as attribute '${Dashboard.dashboardIdAttribute}'.`); } - /** - * Validate load configuration. - * - * @hidden - */ - validate(baseConfig: embed.IEmbedConfigurationBase): models.IError[] { - const config = baseConfig as embed.IDashboardEmbedConfiguration; - let error = models.validateDashboardLoad(config); - return error ? error : this.ValidatePageView(config.pageView); - } + return dashboardId; + } - /** - * Handle config changes. - * @hidden - * @returns {void} - */ - configChanged(isBootstrap: boolean): void { - if (isBootstrap) { - return; - } + /** + * Validate load configuration. + * + * @hidden + */ + validate(baseConfig: IEmbedConfigurationBase): IError[] { + const config = baseConfig as IDashboardEmbedConfiguration; + const error = validateDashboardLoad(config); + return error ? error : this.validatePageView(config.pageView); + } - // Populate dashboard id into config object. - (this.config).id = this.getId(); + /** + * Handle config changes. + * + * @hidden + * @returns {void} + */ + configChanged(isBootstrap: boolean): void { + if (isBootstrap) { + return; } - /** - * @hidden - * @returns {string} - */ - getDefaultEmbedUrlEndpoint(): string { - return "dashboardEmbed"; - } + // Populate dashboard id into config object. + (this.config as IDashboardEmbedConfiguration).id = this.getId(); + } + + /** + * @hidden + * @returns {string} + */ + getDefaultEmbedUrlEndpoint(): string { + return "dashboardEmbed"; + } - /** - * Validate that pageView has a legal value: if page view is defined it must have one of the values defined in models.PageView - * @hidden - */ - private ValidatePageView(pageView: models.PageView): models.IError[] { - if (pageView && pageView !== "fitToWidth" && pageView !== "oneColumn" && pageView !== "actualSize") { - return [{message: "pageView must be one of the followings: fitToWidth, oneColumn, actualSize"}]; - } + /** + * Validate that pageView has a legal value: if page view is defined it must have one of the values defined in PageView + * + * @hidden + */ + private validatePageView(pageView: PageView): IError[] { + if (pageView && pageView !== "fitToWidth" && pageView !== "oneColumn" && pageView !== "actualSize") { + return [{ message: "pageView must be one of the followings: fitToWidth, oneColumn, actualSize" }]; } -} \ No newline at end of file + } +} diff --git a/src/embed.ts b/src/embed.ts index 69fe406e..b2a47f0b 100644 --- a/src/embed.ts +++ b/src/embed.ts @@ -1,7 +1,7 @@ -import * as utils from './util'; -import * as service from './service'; -import * as sdkConfig from './config'; import * as models from 'powerbi-models'; +import { addParamToUrl, assign, autoAuthInEmbedUrl, createRandomString, getTimeDiffInMilliseconds, remove } from './util'; +import { Service, IEventHandler, IEvent, ICustomEvent } from './service'; +import * as sdkConfig from './config'; import { EmbedUrlNotSupported } from './errors'; declare global { @@ -24,7 +24,7 @@ declare global { msRequestFullscreen: Function; // Safari Fullscreen - webkitRequestFullscreen: {(): void}; + webkitRequestFullscreen: { (): void }; } } @@ -39,7 +39,7 @@ export type IVisualEmbedConfiguration = models.IVisualEmbedConfiguration; export type IReportEmbedConfiguration = models.IReportEmbedConfiguration; -export type IDashboardEmbedConfiguration = models.IDashboardEmbedConfiguration ; +export type IDashboardEmbedConfiguration = models.IDashboardEmbedConfiguration; export type ITileEmbedConfiguration = models.ITileEmbedConfiguration; @@ -53,8 +53,8 @@ export type IEmbedSettings = models.ISettings; /** @hidden */ export interface IInternalEventHandler { - test(event: service.IEvent): boolean; - handle(event: service.ICustomEvent): void; + test(event: IEvent): boolean; + handle(event: ICustomEvent): void; } /** @@ -83,10 +83,10 @@ export abstract class Embed { static type: string; /** @hidden */ - static maxFrontLoadTimes: number = 2; + static maxFrontLoadTimes = 2; /** @hidden */ - allowedEvents = []; + allowedEvents: string[] = []; /** * Gets or sets the event handler registered for this embed component. @@ -102,7 +102,7 @@ export abstract class Embed { * @type {service.Service} * @hidden */ - service: service.Service; + service: Service; /** * Gets or sets the HTML element that contains the Power BI embed component. @@ -122,7 +122,7 @@ export abstract class Embed { /** * Saves the iframe state. Each iframe should be loaded only once. - * After first load, .embed will go into embedExisting path which will send + * After first load, .embed will go into embedExisting path which will send * a postMessage of /report/load instead of creating a new iframe. * * @type {boolean} @@ -156,30 +156,35 @@ export abstract class Embed { /** * Url used in the load request. + * * @hidden */ loadPath: string; /** * Url used in the load request. + * * @hidden */ phasedLoadPath: string; /** * Type of embed + * * @hidden */ embedtype: string; /** * Handler function for the 'ready' event + * * @hidden */ frontLoadHandler: () => any; /** * The time the last /load request was sent + * * @hidden */ lastLoadRequest: Date; @@ -195,8 +200,8 @@ export abstract class Embed { * @param {IEmbedConfigurationBase} config * @hidden */ - constructor(service: service.Service, element: HTMLElement, config: IEmbedConfigurationBase, iframe?: HTMLIFrameElement, phasedRender?: boolean, isBootstrap?: boolean) { - if (utils.autoAuthInEmbedUrl(config.embedUrl)) { + constructor(service: Service, element: HTMLElement, config: IEmbedConfigurationBase, iframe?: HTMLIFrameElement, phasedRender?: boolean, isBootstrap?: boolean) { + if (autoAuthInEmbedUrl(config.embedUrl)) { throw new Error(EmbedUrlNotSupported); } @@ -211,9 +216,9 @@ export abstract class Embed { this.populateConfig(config, isBootstrap); if (this.embedtype === 'create') { - this.setIframe(false /*set EventListener to call create() on 'load' event*/, phasedRender, isBootstrap); + this.setIframe(false /* set EventListener to call create() on 'load' event*/, phasedRender, isBootstrap); } else { - this.setIframe(true /*set EventListener to call load() on 'load' event*/, phasedRender, isBootstrap); + this.setIframe(true /* set EventListener to call load() on 'load' event*/, phasedRender, isBootstrap); } } @@ -225,6 +230,7 @@ export abstract class Embed { * datasetId: '5dac7a4a-4452-46b3-99f6-a25915e0fe55', * accessToken: 'eyJ0eXA ... TaE2rTSbmg', * ``` + * * @hidden * @param {models.IReportCreateConfiguration} config * @returns {Promise} @@ -313,6 +319,7 @@ export abstract class Embed { * }) * .catch(error => { ... }); * ``` + * * @hidden * @param {models.ILoadConfiguration} config * @param {boolean} phasedRender @@ -338,7 +345,7 @@ export abstract class Embed { }; const timeNow: Date = new Date(); - if (this.lastLoadRequest && utils.getTimeDiffInMilliseconds(this.lastLoadRequest, timeNow) < 100) { + if (this.lastLoadRequest && getTimeDiffInMilliseconds(this.lastLoadRequest, timeNow) < 100) { console.debug("Power BI SDK sent more than two /report/load requests in the last 100ms interval."); return; } @@ -372,21 +379,21 @@ export abstract class Embed { * * @template T * @param {string} eventName - * @param {service.IEventHandler} [handler] + * @param {IEventHandler} [handler] */ - off(eventName: string, handler?: service.IEventHandler): void { - const fakeEvent: service.IEvent = { name: eventName, type: null, id: null, value: null }; + off(eventName: string, handler?: IEventHandler): void { + const fakeEvent: IEvent = { name: eventName, type: null, id: null, value: null }; if (handler) { - utils.remove(eventHandler => eventHandler.test(fakeEvent) && (eventHandler.handle === handler), this.eventHandlers); + remove((eventHandler) => eventHandler.test(fakeEvent) && (eventHandler.handle === handler), this.eventHandlers); this.element.removeEventListener(eventName, handler); } else { const eventHandlersToRemove = this.eventHandlers - .filter(eventHandler => eventHandler.test(fakeEvent)); + .filter((eventHandler) => eventHandler.test(fakeEvent)); eventHandlersToRemove - .forEach(eventHandlerToRemove => { - utils.remove(eventHandler => eventHandler === eventHandlerToRemove, this.eventHandlers); + .forEach((eventHandlerToRemove) => { + remove((eventHandler) => eventHandler === eventHandlerToRemove, this.eventHandlers); this.element.removeEventListener(eventName, eventHandlerToRemove.handle); }); } @@ -405,17 +412,17 @@ export abstract class Embed { * @param {string} eventName * @param {service.IEventHandler} handler */ - on(eventName: string, handler: service.IEventHandler): void { + on(eventName: string, handler: IEventHandler): void { if (this.allowedEvents.indexOf(eventName) === -1) { throw new Error(`eventName must be one of ${this.allowedEvents}. You passed: ${eventName}`); } this.eventHandlers.push({ - test: (event: service.IEvent) => event.name === eventName, + test: (event: IEvent) => event.name === eventName, handle: handler }); - this.element.addEventListener(eventName, handler) + this.element.addEventListener(eventName, handler); } /** @@ -436,7 +443,7 @@ export abstract class Embed { * @returns {Promise} */ async setAccessToken(accessToken: string): Promise { - var embedType = this.config.type; + let embedType = this.config.type; embedType = (embedType === 'create' || embedType === 'visual' || embedType === 'qna') ? 'report' : embedType; try { const response = await this.service.hpm.post('/' + embedType + '/token', accessToken, { uid: this.config.uniqueId }, this.iframe.contentWindow); @@ -477,7 +484,7 @@ export abstract class Embed { */ populateConfig(config: IBootstrapEmbedConfiguration, isBootstrap: boolean): void { if (this.bootstrapConfig) { - this.config = utils.assign({}, this.bootstrapConfig, config); + this.config = assign({}, this.bootstrapConfig, config); // reset bootstrapConfig because we do not want to merge it in re-embed scenario. this.bootstrapConfig = null; @@ -485,7 +492,7 @@ export abstract class Embed { else { // Copy config - important for multiple iframe scenario. // Otherwise, if a user uses the same config twice, same unique Id which will be used in different iframes. - this.config = utils.assign({}, config); + this.config = assign({}, config); } this.config.embedUrl = this.getEmbedUrl(isBootstrap); @@ -516,12 +523,12 @@ export abstract class Embed { if (!config.settings) { return; } - let localeSettings = config.settings.localeSettings + const localeSettings = config.settings.localeSettings; if (localeSettings && localeSettings.language) { - this.config.embedUrl = utils.addParamToUrl(this.config.embedUrl, 'language', localeSettings.language); + this.config.embedUrl = addParamToUrl(this.config.embedUrl, 'language', localeSettings.language); } if (localeSettings && localeSettings.formatLocale) { - this.config.embedUrl = utils.addParamToUrl(this.config.embedUrl, 'formatLocale', localeSettings.formatLocale); + this.config.embedUrl = addParamToUrl(this.config.embedUrl, 'formatLocale', localeSettings.formatLocale); } } @@ -555,7 +562,7 @@ export abstract class Embed { hostname = Embed.defaultEmbedHostName; } - let endpoint = this.getDefaultEmbedUrlEndpoint(); + const endpoint = this.getDefaultEmbedUrlEndpoint(); // Trim spaces to fix user mistakes. hostname = hostname.toLowerCase().trim(); @@ -580,7 +587,7 @@ export abstract class Embed { * @hidden */ private getUniqueId(): string { - return this.config.uniqueId || this.element.getAttribute(Embed.nameAttribute) || utils.createRandomString(); + return this.config.uniqueId || this.element.getAttribute(Embed.nameAttribute) || createRandomString(); } /** @@ -652,36 +659,37 @@ export abstract class Embed { private isFullscreen(iframe: HTMLIFrameElement): boolean { const options = ['fullscreenElement', 'webkitFullscreenElement', 'mozFullscreenScreenElement', 'msFullscreenElement']; - return options.some(option => document[option] === iframe); + return options.some((option) => document[option] === iframe); } /** * Validate load and create configuration. - * + * * @hidden */ abstract validate(config: IEmbedConfigurationBase): models.IError[]; /** * Sets Iframe for embed + * * @hidden */ private setIframe(isLoad: boolean, phasedRender?: boolean, isBootstrap?: boolean): void { if (!this.iframe) { - var iframeContent = document.createElement("iframe"); - var embedUrl = this.config.uniqueId ? utils.addParamToUrl(this.config.embedUrl, 'uid', this.config.uniqueId) : this.config.embedUrl; + const iframeContent = document.createElement("iframe"); + const embedUrl = this.config.uniqueId ? addParamToUrl(this.config.embedUrl, 'uid', this.config.uniqueId) : this.config.embedUrl; iframeContent.style.width = '100%'; iframeContent.style.height = '100%'; iframeContent.setAttribute("src", embedUrl); iframeContent.setAttribute("scrolling", "no"); iframeContent.setAttribute("allowfullscreen", "true"); - var node = this.element; + const node = this.element; while (node.firstChild) { node.removeChild(node.firstChild); } node.appendChild(iframeContent); - this.iframe = node.firstChild; + this.iframe = node.firstChild as HTMLIFrameElement; } if (isLoad) { @@ -701,7 +709,7 @@ export abstract class Embed { if (this.service.getNumberOfComponents() <= Embed.maxFrontLoadTimes) { this.frontLoadHandler = () => { this.frontLoadSendConfig(this.config); - } + }; // 'ready' event is fired by the embedded element (not by the iframe) this.element.addEventListener('ready', this.frontLoadHandler, false); @@ -738,7 +746,7 @@ export abstract class Embed { /** * Removes element's tabindex attribute */ - removeComponentTabIndex(tabIndex?: number): void { + removeComponentTabIndex(_tabIndex?: number): void { if (!this.element) { return; } @@ -755,10 +763,10 @@ export abstract class Embed { * @returns {string} */ static findGroupIdFromEmbedUrl(url: string): string { - const groupIdRegEx = /groupId="?([^&]+)"?/ + const groupIdRegEx = /groupId="?([^&]+)"?/; const groupIdMatch = url.match(groupIdRegEx); - let groupId; + let groupId: string; if (groupIdMatch) { groupId = groupIdMatch[1]; } @@ -768,6 +776,7 @@ export abstract class Embed { /** * Sends the config for front load calls, after 'ready' message is received from the iframe + * * @hidden */ private async frontLoadSendConfig(config: IEmbedConfigurationBase): Promise { @@ -781,8 +790,9 @@ export abstract class Embed { } // contentWindow must be initialized - if (this.iframe.contentWindow == null) + if (this.iframe.contentWindow == null) { return; + } try { const response = await this.service.hpm.post("/frontload/config", config, { uid: this.config.uniqueId }, this.iframe.contentWindow); diff --git a/src/errors.ts b/src/errors.ts index 03c56cae..c7bf714c 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -1,4 +1,4 @@ -export let APINotSupportedForRDLError: string = "This API is currently not supported for RDL reports"; -export let EmbedUrlNotSupported = "Embed URL is invalid for this scenario. Please use Power BI REST APIs to get the valid URL"; +export const APINotSupportedForRDLError = "This API is currently not supported for RDL reports"; +export const EmbedUrlNotSupported = "Embed URL is invalid for this scenario. Please use Power BI REST APIs to get the valid URL"; diff --git a/src/factories.ts b/src/factories.ts index 65446b25..92b5a1b7 100644 --- a/src/factories.ts +++ b/src/factories.ts @@ -1,11 +1,11 @@ /** * TODO: Need to find better place for these factory functions or refactor how we handle dependency injection */ -import { IHpmFactory, IWpmpFactory, IRouterFactory } from './service'; +import { WindowPostMessageProxy } from 'window-post-message-proxy'; +import { HttpPostMessage } from 'http-post-message'; +import { Router } from 'powerbi-router'; import config from './config'; -import * as wpmp from 'window-post-message-proxy'; -import * as hpm from 'http-post-message'; -import * as router from 'powerbi-router'; +import { IHpmFactory, IWpmpFactory, IRouterFactory } from './service'; export { IHpmFactory, @@ -14,26 +14,26 @@ export { }; export const hpmFactory: IHpmFactory = (wpmp, defaultTargetWindow, sdkVersion = config.version, sdkType = config.type) => { - return new hpm.HttpPostMessage(wpmp, { + return new HttpPostMessage(wpmp, { 'x-sdk-type': sdkType, 'x-sdk-version': sdkVersion }, defaultTargetWindow); }; export const wpmpFactory: IWpmpFactory = (name?: string, logMessages?: boolean, eventSourceOverrideWindow?: Window) => { - return new wpmp.WindowPostMessageProxy({ + return new WindowPostMessageProxy({ processTrackingProperties: { - addTrackingProperties: hpm.HttpPostMessage.addTrackingProperties, - getTrackingProperties: hpm.HttpPostMessage.getTrackingProperties, + addTrackingProperties: HttpPostMessage.addTrackingProperties, + getTrackingProperties: HttpPostMessage.getTrackingProperties, }, - isErrorMessage: hpm.HttpPostMessage.isErrorMessage, + isErrorMessage: HttpPostMessage.isErrorMessage, suppressWarnings: true, - name, - logMessages, - eventSourceOverrideWindow + name: name, + logMessages: logMessages, + eventSourceOverrideWindow: eventSourceOverrideWindow }); }; export const routerFactory: IRouterFactory = (wpmp) => { - return new router.Router(wpmp); + return new Router(wpmp); }; diff --git a/src/page.ts b/src/page.ts index 00240aad..f126db6f 100644 --- a/src/page.ts +++ b/src/page.ts @@ -264,7 +264,7 @@ export class Page implements IPageNode, IFilterable { try { const response = await this.report.service.hpm.get(`/report/pages/${this.name}/visuals`, { uid: this.report.config.uniqueId }, this.report.iframe.contentWindow); return response.body - .map(visual => new VisualDescriptor(this, visual.name, visual.title, visual.type, visual.layout)); + .map((visual) => new VisualDescriptor(this, visual.name, visual.title, visual.type, visual.layout)); } catch (response) { throw response.body; } @@ -280,7 +280,7 @@ export class Page implements IPageNode, IFilterable { * * @returns {(Promise)} */ - async hasLayout(layoutType): Promise { + async hasLayout(layoutType: LayoutType): Promise { if (isRDLEmbed(this.report.config.embedUrl)) { return Promise.reject(APINotSupportedForRDLError); } diff --git a/src/powerbi-client.ts b/src/powerbi-client.ts index bff6fa8c..62eff7df 100644 --- a/src/powerbi-client.ts +++ b/src/powerbi-client.ts @@ -1,9 +1,9 @@ /** * @hidden */ +import * as models from 'powerbi-models'; import * as service from './service'; import * as factories from './factories'; -import * as models from 'powerbi-models'; import { IFilterable } from './ifilterable'; export { @@ -59,4 +59,4 @@ declare global { * Note: create an instance of the class with the default configuration for normal usage, or save the class so that you can create an instance of the service. */ var powerbi = new service.Service(factories.hpmFactory, factories.wpmpFactory, factories.routerFactory); -window.powerbi = powerbi; \ No newline at end of file +window.powerbi = powerbi; diff --git a/src/qna.ts b/src/qna.ts index 0fdd09c2..4d11f533 100644 --- a/src/qna.ts +++ b/src/qna.ts @@ -1,7 +1,7 @@ -import * as service from './service'; -import * as models from 'powerbi-models'; -import * as embed from './embed'; import { IHttpPostMessageResponse } from 'http-post-message'; +import { IError, IQnaInterpretInputData, validateLoadQnaConfiguration } from 'powerbi-models'; +import { Embed, IEmbedConfigurationBase } from './embed'; +import { Service } from './service'; /** * The Power BI Q&A embed component @@ -10,71 +10,71 @@ import { IHttpPostMessageResponse } from 'http-post-message'; * @class Qna * @extends {Embed} */ -export class Qna extends embed.Embed { - /** @hidden */ - static type = "Qna"; - /** @hidden */ - static allowedEvents = ["loaded", "visualRendered"]; +export class Qna extends Embed { + /** @hidden */ + static type = "Qna"; + /** @hidden */ + static allowedEvents = ["loaded", "visualRendered"]; - /** - * @hidden - */ - constructor(service: service.Service, element: HTMLElement, config: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean) { - super(service, element, config, /* iframe */ undefined, phasedRender, isBootstrap); + /** + * @hidden + */ + constructor(service: Service, element: HTMLElement, config: IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean) { + super(service, element, config, /* iframe */ undefined, phasedRender, isBootstrap); - this.loadPath = "/qna/load"; - this.phasedLoadPath = "/qna/prepare"; - Array.prototype.push.apply(this.allowedEvents, Qna.allowedEvents); - } + this.loadPath = "/qna/load"; + this.phasedLoadPath = "/qna/prepare"; + Array.prototype.push.apply(this.allowedEvents, Qna.allowedEvents); + } - /** - * The ID of the Q&A embed component - * - * @returns {string} - */ - getId(): string { - return null; - } + /** + * The ID of the Q&A embed component + * + * @returns {string} + */ + getId(): string { + return null; + } - /** - * Change the question of the Q&A embed component - * - * @param {string} question - question which will render Q&A data - * @returns {Promise>} - */ - async setQuestion(question: string): Promise> { - const qnaData: models.IQnaInterpretInputData = { - question: question - }; + /** + * Change the question of the Q&A embed component + * + * @param {string} question - question which will render Q&A data + * @returns {Promise>} + */ + async setQuestion(question: string): Promise> { + const qnaData: IQnaInterpretInputData = { + question: question + }; - try { - return await this.service.hpm.post('/qna/interpret', qnaData, { uid: this.config.uniqueId }, this.iframe.contentWindow); - } catch (response) { - throw response.body; - } + try { + return await this.service.hpm.post('/qna/interpret', qnaData, { uid: this.config.uniqueId }, this.iframe.contentWindow); + } catch (response) { + throw response.body; } + } - /** - * Handle config changes. - * - * @returns {void} - */ - configChanged(isBootstrap: boolean): void { - // Nothing to do in Q&A embed. - } + /** + * Handle config changes. + * + * @returns {void} + */ + configChanged(_isBootstrap: boolean): void { + // Nothing to do in Q&A embed. + } - /** - * @hidden - * @returns {string} - */ - getDefaultEmbedUrlEndpoint(): string { - return "qnaEmbed"; - } + /** + * @hidden + * @returns {string} + */ + getDefaultEmbedUrlEndpoint(): string { + return "qnaEmbed"; + } - /** - * Validate load configuration. - */ - validate(config: embed.IEmbedConfigurationBase): models.IError[] { - return models.validateLoadQnaConfiguration(config); - } -} \ No newline at end of file + /** + * Validate load configuration. + */ + validate(config: IEmbedConfigurationBase): IError[] { + return validateLoadQnaConfiguration(config); + } +} diff --git a/src/report.ts b/src/report.ts index 63d1dc79..a390ec87 100644 --- a/src/report.ts +++ b/src/report.ts @@ -71,7 +71,7 @@ export class Report extends Embed implements IReportNode, IFilterable { * @hidden */ constructor(service: Service, element: HTMLElement, baseConfig: IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean, iframe?: HTMLIFrameElement) { - const config = baseConfig; + const config = baseConfig as IReportEmbedConfiguration; super(service, element, config, iframe, phasedRender, isBootstrap); this.loadPath = "/report/load"; this.phasedLoadPath = "/report/prepare"; @@ -297,7 +297,7 @@ export class Report extends Embed implements IReportNode, IFilterable { * @returns {string} */ getId(): string { - const config = this.config; + const config = this.config as IReportEmbedConfiguration; const reportId = config.id || this.element.getAttribute(Report.reportIdAttribute) || Report.findIdFromEmbedUrl(config.embedUrl); if (typeof reportId !== 'string' || reportId.length === 0) { @@ -327,7 +327,7 @@ export class Report extends Embed implements IReportNode, IFilterable { try { const response = await this.service.hpm.get('/report/pages', { uid: this.config.uniqueId }, this.iframe.contentWindow); return response.body - .map(page => new Page(this, page.name, page.displayName, page.isActive, page.visibility, page.defaultSize, page.defaultDisplayOption)); + .map((page) => new Page(this, page.name, page.displayName, page.isActive, page.visibility, page.defaultSize, page.defaultDisplayOption)); } catch (response) { throw response.body; } @@ -402,8 +402,11 @@ export class Report extends Embed implements IReportNode, IFilterable { * * ```javascript * const newSettings = { - * navContentPaneEnabled: true, - * filterPaneEnabled: false + * panes: { + * filters: { + * visible: false + * } + * } * }; * * report.updateSettings(newSettings) @@ -440,8 +443,7 @@ export class Report extends Embed implements IReportNode, IFilterable { * @returns {void} */ configChanged(isBootstrap: boolean): void { - const config = this.config; - + const config = this.config as IReportEmbedConfiguration; if (this.isMobileSettings(config.settings)) { config.embedUrl = addParamToUrl(config.embedUrl, "isMobile", "true"); } diff --git a/src/service.ts b/src/service.ts index f89ca504..dd218c85 100644 --- a/src/service.ts +++ b/src/service.ts @@ -1,4 +1,21 @@ -import * as embed from './embed'; +/* eslint-disable @typescript-eslint/prefer-function-type */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +import { WindowPostMessageProxy } from 'window-post-message-proxy'; +import { HttpPostMessage } from 'http-post-message'; +import { Router } from 'powerbi-router'; +import { IPage, IReportCreateConfiguration } from 'powerbi-models'; +import { + Embed, + IBootstrapEmbedConfiguration, + IDashboardEmbedConfiguration, + IEmbedConfiguration, + IEmbedConfigurationBase, + IQnaEmbedConfiguration, + IReportEmbedConfiguration, + ITileEmbedConfiguration, + IVisualEmbedConfiguration, +} from './embed'; import { Report } from './report'; import { Create } from './create'; import { Dashboard } from './dashboard'; @@ -7,10 +24,6 @@ import { Page } from './page'; import { Qna } from './qna'; import { Visual } from './visual'; import * as utils from './util'; -import * as wpmp from 'window-post-message-proxy'; -import * as hpm from 'http-post-message'; -import * as router from 'powerbi-router'; -import * as models from 'powerbi-models'; export interface IEvent { type: string; @@ -37,25 +50,25 @@ export interface IEventHandler { * @hidden */ export interface IHpmFactory { - (wpmp: wpmp.WindowPostMessageProxy, targetWindow?: Window, version?: string, type?: string, origin?: string): hpm.HttpPostMessage; + (wpmp: WindowPostMessageProxy, targetWindow?: Window, version?: string, type?: string, origin?: string): HttpPostMessage; } /** * @hidden */ export interface IWpmpFactory { - (name?: string, logMessages?: boolean, eventSourceOverrideWindow?: Window): wpmp.WindowPostMessageProxy; + (name?: string, logMessages?: boolean, eventSourceOverrideWindow?: Window): WindowPostMessageProxy; } /** * @hidden */ export interface IRouterFactory { - (wpmp: wpmp.WindowPostMessageProxy): router.Router; + (wpmp: WindowPostMessageProxy): Router; } export interface IPowerBiElement extends HTMLElement { - powerBiEmbed: embed.Embed; + powerBiEmbed: Embed; } export interface IDebugOptions { @@ -71,10 +84,10 @@ export interface IServiceConfiguration extends IDebugOptions { } export interface IService { - hpm: hpm.HttpPostMessage; + hpm: HttpPostMessage; } -export type IComponentEmbedConfiguration = embed.IReportEmbedConfiguration | embed.IDashboardEmbedConfiguration | embed.ITileEmbedConfiguration| embed.IVisualEmbedConfiguration | embed.IQnaEmbedConfiguration; +export type IComponentEmbedConfiguration = IReportEmbedConfiguration | IDashboardEmbedConfiguration | ITileEmbedConfiguration | IVisualEmbedConfiguration | IQnaEmbedConfiguration; /** * The Power BI Service embed component, which is the entry point to embed all other Power BI components into your application @@ -112,21 +125,23 @@ export class Service implements IService { */ accessToken: string; - /**The Configuration object for the service*/ + /** The Configuration object for the service*/ private config: IServiceConfiguration; /** A list of Dashboard, Report and Tile components that have been embedded using this service instance. */ - private embeds: embed.Embed[]; + private embeds: Embed[]; - /** TODO: Look for way to make hpm private without sacrificing ease of maintenance. This should be private but in embed needs to call methods. + /** TODO: Look for way to make hpm private without sacrificing ease of maintenance. This should be private but in embed needs to call methods. + * * @hidden - */ - hpm: hpm.HttpPostMessage; - /** TODO: Look for way to make wpmp private. This is only public to allow stopping the wpmp in tests + */ + hpm: HttpPostMessage; + /** TODO: Look for way to make wpmp private. This is only public to allow stopping the wpmp in tests + * * @hidden - */ - wpmp: wpmp.WindowPostMessageProxy; - private router: router.Router; + */ + wpmp: WindowPostMessageProxy; + private router: Router; private uniqueSessionId: string; /** @@ -147,55 +162,55 @@ export class Service implements IService { /** * Adds handler for report events. */ - this.router.post(`/reports/:uniqueId/events/:eventName`, (req, res) => { + this.router.post(`/reports/:uniqueId/events/:eventName`, (req, _res) => { const event: IEvent = { type: 'report', - id: req.params.uniqueId, - name: req.params.eventName, + id: req.params.uniqueId as string, + name: req.params.eventName as string, value: req.body }; this.handleEvent(event); }); - this.router.post(`/reports/:uniqueId/pages/:pageName/events/:eventName`, (req, res) => { + this.router.post(`/reports/:uniqueId/pages/:pageName/events/:eventName`, (req, _res) => { const event: IEvent = { type: 'report', - id: req.params.uniqueId, - name: req.params.eventName, + id: req.params.uniqueId as string, + name: req.params.eventName as string, value: req.body }; this.handleEvent(event); }); - this.router.post(`/reports/:uniqueId/pages/:pageName/visuals/:visualName/events/:eventName`, (req, res) => { + this.router.post(`/reports/:uniqueId/pages/:pageName/visuals/:visualName/events/:eventName`, (req, _res) => { const event: IEvent = { type: 'report', - id: req.params.uniqueId, - name: req.params.eventName, + id: req.params.uniqueId as string, + name: req.params.eventName as string, value: req.body }; this.handleEvent(event); }); - this.router.post(`/dashboards/:uniqueId/events/:eventName`, (req, res) => { + this.router.post(`/dashboards/:uniqueId/events/:eventName`, (req, _res) => { const event: IEvent = { type: 'dashboard', - id: req.params.uniqueId, - name: req.params.eventName, + id: req.params.uniqueId as string, + name: req.params.eventName as string, value: req.body }; this.handleEvent(event); }); - this.router.post(`/tile/:uniqueId/events/:eventName`, (req, res) => { + this.router.post(`/tile/:uniqueId/events/:eventName`, (req, _res) => { const event: IEvent = { type: 'tile', - id: req.params.uniqueId, - name: req.params.eventName, + id: req.params.uniqueId as string, + name: req.params.eventName as string, value: req.body }; @@ -205,11 +220,11 @@ export class Service implements IService { /** * Adds handler for Q&A events. */ - this.router.post(`/qna/:uniqueId/events/:eventName`, (req, res) => { + this.router.post(`/qna/:uniqueId/events/:eventName`, (req, _res) => { const event: IEvent = { type: 'qna', - id: req.params.uniqueId, - name: req.params.eventName, + id: req.params.uniqueId as string, + name: req.params.eventName as string, value: req.body }; @@ -219,10 +234,10 @@ export class Service implements IService { /** * Adds handler for front load 'ready' message. */ - this.router.post(`/ready/:uniqueId`, (req, res) => { + this.router.post(`/ready/:uniqueId`, (req, _res) => { const event: IEvent = { type: 'report', - id: req.params.uniqueId, + id: req.params.uniqueId as string, name: 'ready', value: req.body }; @@ -242,13 +257,14 @@ export class Service implements IService { /** * Creates new report + * * @param {HTMLElement} element - * @param {embed.IEmbedConfiguration} [config={}] - * @returns {embed.Embed} + * @param {IEmbedConfiguration} [config={}] + * @returns {Embed} */ - createReport(element: HTMLElement, config: embed.IEmbedConfiguration | models.IReportCreateConfiguration): embed.Embed { + createReport(element: HTMLElement, config: IEmbedConfiguration | IReportCreateConfiguration): Embed { config.type = 'create'; - let powerBiElement = element; + const powerBiElement = element as IPowerBiElement; const component = new Create(this, powerBiElement, config); powerBiElement.powerBiEmbed = component; this.addOrOverwriteEmbed(component, element); @@ -260,15 +276,15 @@ export class Service implements IService { * TODO: Add a description here * * @param {HTMLElement} [container] - * @param {embed.IEmbedConfiguration} [config=undefined] - * @returns {embed.Embed[]} + * @param {IEmbedConfiguration} [config=undefined] + * @returns {Embed[]} * @hidden */ - init(container?: HTMLElement, config: embed.IEmbedConfiguration = undefined): embed.Embed[] { + init(container?: HTMLElement, config: IEmbedConfiguration = undefined): Embed[] { container = (container && container instanceof HTMLElement) ? container : document.body; - const elements = Array.prototype.slice.call(container.querySelectorAll(`[${embed.Embed.embedUrlAttribute}]`)); - return elements.map(element => this.embed(element, config)); + const elements = Array.prototype.slice.call(container.querySelectorAll(`[${Embed.embedUrlAttribute}]`)); + return elements.map((element) => this.embed(element, config)); } /** @@ -277,10 +293,10 @@ export class Service implements IService { * otherwise creates a new component instance. * * @param {HTMLElement} element - * @param {embed.IEmbedConfigurationBase} [config={}] - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} [config={}] + * @returns {Embed} */ - embed(element: HTMLElement, config: IComponentEmbedConfiguration | embed.IEmbedConfigurationBase = {}): embed.Embed { + embed(element: HTMLElement, config: IComponentEmbedConfiguration | IEmbedConfigurationBase = {}): Embed { return this.embedInternal(element, config); } @@ -291,10 +307,10 @@ export class Service implements IService { * This is used for the phased embedding API, once element is loaded successfully, one can call 'render' on it. * * @param {HTMLElement} element - * @param {embed.IEmbedConfigurationBase} [config={}] - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} [config={}] + * @returns {Embed} */ - load(element: HTMLElement, config: IComponentEmbedConfiguration | embed.IEmbedConfigurationBase = {}): embed.Embed { + load(element: HTMLElement, config: IComponentEmbedConfiguration | IEmbedConfigurationBase = {}): Embed { return this.embedInternal(element, config, /* phasedRender */ true, /* isBootstrap */ false); } @@ -302,16 +318,16 @@ export class Service implements IService { * Given an HTML element and entityType, creates a new component instance, and bootstrap the iframe for embedding. * * @param {HTMLElement} element - * @param {embed.IBootstrapEmbedConfiguration} config: a bootstrap config which is an embed config without access token. + * @param {IBootstrapEmbedConfiguration} config: a bootstrap config which is an embed config without access token. */ - bootstrap(element: HTMLElement, config: IComponentEmbedConfiguration | embed.IBootstrapEmbedConfiguration): embed.Embed { + bootstrap(element: HTMLElement, config: IComponentEmbedConfiguration | IBootstrapEmbedConfiguration): Embed { return this.embedInternal(element, config, /* phasedRender */ false, /* isBootstrap */ true); } /** @hidden */ - embedInternal(element: HTMLElement, config: IComponentEmbedConfiguration | embed.IEmbedConfigurationBase = {}, phasedRender?: boolean, isBootstrap?: boolean): embed.Embed { - let component: embed.Embed; - let powerBiElement = element; + embedInternal(element: HTMLElement, config: IComponentEmbedConfiguration | IEmbedConfigurationBase = {}, phasedRender?: boolean, isBootstrap?: boolean): Embed { + let component: Embed; + const powerBiElement = element as IPowerBiElement; if (powerBiElement.powerBiEmbed) { if (isBootstrap) { @@ -346,20 +362,20 @@ export class Service implements IService { * * @private * @param {IPowerBiElement} element - * @param {embed.IEmbedConfigurationBase} config - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} config + * @returns {Embed} * @hidden */ - private embedNew(element: IPowerBiElement, config: IComponentEmbedConfiguration | embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean): embed.Embed { - const componentType = config.type || element.getAttribute(embed.Embed.typeAttribute); + private embedNew(element: IPowerBiElement, config: IComponentEmbedConfiguration | IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean): Embed { + const componentType = config.type || element.getAttribute(Embed.typeAttribute); if (!componentType) { - throw new Error(`Attempted to embed using config ${JSON.stringify(config)} on element ${element.outerHTML}, but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '${embed.Embed.typeAttribute}="${Report.type.toLowerCase()}"'.`); + throw new Error(`Attempted to embed using config ${JSON.stringify(config)} on element ${element.outerHTML}, but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '${Embed.typeAttribute}="${Report.type.toLowerCase()}"'.`); } // Saves the type as part of the configuration so that it can be referenced later at a known location. config.type = componentType; - const Component = utils.find(component => componentType === component.type.toLowerCase(), Service.components); + const Component = utils.find((embedComponent) => componentType === embedComponent.type.toLowerCase(), Service.components); if (!Component) { throw new Error(`Attempted to embed component of type: ${componentType} but did not find any matching component. Please verify the type you specified is intended.`); } @@ -376,12 +392,12 @@ export class Service implements IService { * * @private * @param {IPowerBiElement} element - * @param {embed.IEmbedConfigurationBase} config - * @returns {embed.Embed} + * @param {IEmbedConfigurationBase} config + * @returns {Embed} * @hidden */ - private embedExisting(element: IPowerBiElement, config: IComponentEmbedConfiguration | embed.IEmbedConfigurationBase, phasedRender?: boolean): embed.Embed { - const component = utils.find(x => x.element === element, this.embeds); + private embedExisting(element: IPowerBiElement, config: IComponentEmbedConfiguration | IEmbedConfigurationBase, phasedRender?: boolean): Embed { + const component = utils.find((x) => x.element === element, this.embeds); if (!component) { throw new Error(`Attempted to embed using config ${JSON.stringify(config)} on element ${element.outerHTML} which already has embedded component associated, but could not find the existing component in the list of active components. This could indicate the embeds list is out of sync with the DOM, or the component is referencing the incorrect HTML element.`); } @@ -401,7 +417,7 @@ export class Service implements IService { /** * When loading report after create we want to use existing Iframe to optimize load period */ - if(config.type === "report" && component.config.type === "create") { + if (config.type === "report" && component.config.type === "create") { const report = new Report(this, element, config, /* phasedRender */ false, /* isBootstrap */ false, element.powerBiEmbed.iframe); component.populateConfig(config, /* isBootstrap */ false); report.load(); @@ -427,11 +443,11 @@ export class Service implements IService { * * Note: Only runs if `config.autoEmbedOnContentLoaded` is true when the service is created. * This handler is typically useful only for applications that are rendered on the server so that all required data is available when the handler is called. - * + * * @hidden */ enableAutoEmbed(): void { - window.addEventListener('DOMContentLoaded', (event: Event) => this.init(document.body), false); + window.addEventListener('DOMContentLoaded', (_event: Event) => this.init(document.body), false); } /** @@ -440,8 +456,8 @@ export class Service implements IService { * @param {HTMLElement} element * @returns {(Report | Tile)} */ - get(element: HTMLElement): embed.Embed { - const powerBiElement = element; + get(element: HTMLElement): Embed { + const powerBiElement = element as IPowerBiElement; if (!powerBiElement.powerBiEmbed) { throw new Error(`You attempted to get an instance of powerbi component associated with element: ${element.outerHTML} but there was no associated instance.`); @@ -457,21 +473,21 @@ export class Service implements IService { * @returns {(Report | Tile)} * @hidden */ - find(uniqueId: string): embed.Embed { - return utils.find(x => x.config.uniqueId === uniqueId, this.embeds); + find(uniqueId: string): Embed { + return utils.find((x) => x.config.uniqueId === uniqueId, this.embeds); } /** * Removes embed components whose container element is same as the given element - * - * @param {Embed} component + * + * @param {Embed} component * @param {HTMLElement} element * @returns {void} * @hidden */ - addOrOverwriteEmbed(component: embed.Embed, element: HTMLElement): void { + addOrOverwriteEmbed(component: Embed, element: HTMLElement): void { // remove embeds over the same div element. - this.embeds = this.embeds.filter(function(embed) { + this.embeds = this.embeds.filter(function (embed) { return embed.element !== element; }); @@ -485,36 +501,36 @@ export class Service implements IService { * @returns {void} */ reset(element: HTMLElement): void { - const powerBiElement = element; + const powerBiElement = element as IPowerBiElement; if (!powerBiElement.powerBiEmbed) { return; } /** Removes the element frontLoad listener if exists. */ - let embedElement = powerBiElement.powerBiEmbed; + const embedElement = powerBiElement.powerBiEmbed; if (embedElement.frontLoadHandler) { embedElement.element.removeEventListener('ready', embedElement.frontLoadHandler, false); } /** Removes all event handlers. */ - embedElement.allowedEvents.forEach(eventName => { + embedElement.allowedEvents.forEach((eventName) => { embedElement.off(eventName); }); /** Removes the component from an internal list of components. */ - utils.remove(x => x === powerBiElement.powerBiEmbed, this.embeds); + utils.remove((x) => x === powerBiElement.powerBiEmbed, this.embeds); /** Deletes a property from the HTML element. */ delete powerBiElement.powerBiEmbed; /** Removes the iframe from the element. */ const iframe = element.querySelector('iframe'); if (iframe) { - if(iframe.remove !== undefined) { + if (iframe.remove !== undefined) { iframe.remove(); } else { - /** Workaround for IE: unhandled rejection TypeError: object doesn't support property or method 'remove' */ - iframe.parentElement.removeChild(iframe); + /** Workaround for IE: unhandled rejection TypeError: object doesn't support property or method 'remove' */ + iframe.parentElement.removeChild(iframe); } } } @@ -525,10 +541,10 @@ export class Service implements IService { * @param {IEvent} event * @hidden */ - handleTileEvents (event: IEvent): void { - if (event.type === 'tile'){ - this.handleEvent(event); - } + handleTileEvents(event: IEvent): void { + if (event.type === 'tile') { + this.handleEvent(event); + } } /** @@ -548,7 +564,7 @@ export class Service implements IService { if (event.name === 'pageChanged') { const pageKey = 'newPage'; - const page: models.IPage = value[pageKey]; + const page: IPage = value[pageKey]; if (!page) { throw new Error(`Page model not found at 'event.value.${pageKey}'.`); } @@ -564,17 +580,17 @@ export class Service implements IService { * Use this API to preload Power BI Embedded in the background. * * @public - * @param {embed.IEmbedConfigurationBase} [config={}] + * @param {IEmbedConfigurationBase} [config={}] * @param {HTMLElement} [element=undefined] */ - preload(config: IComponentEmbedConfiguration | embed.IEmbedConfigurationBase, element?: HTMLElement) { - var iframeContent = document.createElement("iframe"); + preload(config: IComponentEmbedConfiguration | IEmbedConfigurationBase, element?: HTMLElement): HTMLIFrameElement { + const iframeContent = document.createElement("iframe"); iframeContent.setAttribute("style", "display:none;"); iframeContent.setAttribute("src", config.embedUrl); iframeContent.setAttribute("scrolling", "no"); iframeContent.setAttribute("allowfullscreen", "false"); - var node = element; + let node = element; if (!node) { node = document.getElementsByTagName("body")[0]; } @@ -586,4 +602,4 @@ export class Service implements IService { return iframeContent; } -} \ No newline at end of file +} diff --git a/src/tile.ts b/src/tile.ts index 45781221..3bdc2802 100644 --- a/src/tile.ts +++ b/src/tile.ts @@ -1,6 +1,6 @@ -import * as service from './service'; -import * as models from 'powerbi-models'; -import * as embed from './embed'; +import { IError, validateTileLoad } from 'powerbi-models'; +import { Service } from './service'; +import { Embed, IEmbedConfigurationBase, ITileEmbedConfiguration } from './embed'; /** * The Power BI tile embed component @@ -9,86 +9,86 @@ import * as embed from './embed'; * @class Tile * @extends {Embed} */ -export class Tile extends embed.Embed { - /** @hidden */ - static type = "Tile"; - /** @hidden */ - static allowedEvents = ["tileClicked", "tileLoaded"]; +export class Tile extends Embed { + /** @hidden */ + static type = "Tile"; + /** @hidden */ + static allowedEvents = ["tileClicked", "tileLoaded"]; - /** - * @hidden - */ - constructor(service: service.Service, element: HTMLElement, baseConfig: embed.IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean) { - let config = baseConfig; - super(service, element, config, /* iframe */ undefined, phasedRender, isBootstrap); - this.loadPath = "/tile/load"; - Array.prototype.push.apply(this.allowedEvents, Tile.allowedEvents); - } - - /** - * The ID of the tile - * - * @returns {string} - */ - getId(): string { - let config = this.config; - const tileId = config.id || Tile.findIdFromEmbedUrl(this.config.embedUrl); + /** + * @hidden + */ + constructor(service: Service, element: HTMLElement, baseConfig: IEmbedConfigurationBase, phasedRender?: boolean, isBootstrap?: boolean) { + const config = baseConfig as ITileEmbedConfiguration; + super(service, element, config, /* iframe */ undefined, phasedRender, isBootstrap); + this.loadPath = "/tile/load"; + Array.prototype.push.apply(this.allowedEvents, Tile.allowedEvents); + } - if (typeof tileId !== 'string' || tileId.length === 0) { - throw new Error(`Tile id is required, but it was not found. You must provide an id either as part of embed configuration.`); - } + /** + * The ID of the tile + * + * @returns {string} + */ + getId(): string { + const config = this.config as ITileEmbedConfiguration; + const tileId = config.id || Tile.findIdFromEmbedUrl(this.config.embedUrl); - return tileId; + if (typeof tileId !== 'string' || tileId.length === 0) { + throw new Error(`Tile id is required, but it was not found. You must provide an id either as part of embed configuration.`); } - /** - * Validate load configuration. - */ - validate(config: embed.IEmbedConfigurationBase): models.IError[] { - let embedConfig = config; - return models.validateTileLoad(embedConfig); - } + return tileId; + } - /** - * Handle config changes. - * - * @returns {void} - */ - configChanged(isBootstrap: boolean): void { - if (isBootstrap) { - return; - } + /** + * Validate load configuration. + */ + validate(config: IEmbedConfigurationBase): IError[] { + const embedConfig = config as ITileEmbedConfiguration; + return validateTileLoad(embedConfig); + } - // Populate tile id into config object. - (this.config).id = this.getId(); + /** + * Handle config changes. + * + * @returns {void} + */ + configChanged(isBootstrap: boolean): void { + if (isBootstrap) { + return; } - /** - * @hidden - * @returns {string} - */ - getDefaultEmbedUrlEndpoint(): string { - return "tileEmbed"; - } + // Populate tile id into config object. + (this.config as ITileEmbedConfiguration).id = this.getId(); + } - /** - * Adds the ability to get tileId from url. - * By extracting the ID we can ensure that the ID is always explicitly provided as part of the load configuration. - * - * @hidden - * @static - * @param {string} url - * @returns {string} - */ - static findIdFromEmbedUrl(url: string): string { - const tileIdRegEx = /tileId="?([^&]+)"?/ - const tileIdMatch = url.match(tileIdRegEx); + /** + * @hidden + * @returns {string} + */ + getDefaultEmbedUrlEndpoint(): string { + return "tileEmbed"; + } - let tileId; - if (tileIdMatch) { - tileId = tileIdMatch[1]; - } + /** + * Adds the ability to get tileId from url. + * By extracting the ID we can ensure that the ID is always explicitly provided as part of the load configuration. + * + * @hidden + * @static + * @param {string} url + * @returns {string} + */ + static findIdFromEmbedUrl(url: string): string { + const tileIdRegEx = /tileId="?([^&]+)"?/; + const tileIdMatch = url.match(tileIdRegEx); - return tileId; + let tileId: string; + if (tileIdMatch) { + tileId = tileIdMatch[1]; } -} \ No newline at end of file + + return tileId; + } +} diff --git a/src/util.ts b/src/util.ts index bc84e731..a4361eef 100644 --- a/src/util.ts +++ b/src/util.ts @@ -2,14 +2,14 @@ import { HttpPostMessage } from 'http-post-message'; /** * Raises a custom event with event data on the specified HTML element. - * + * * @export * @param {HTMLElement} element * @param {string} eventName * @param {*} eventData */ export function raiseCustomEvent(element: HTMLElement, eventName: string, eventData: any): void { - let customEvent; + let customEvent: CustomEvent; if (typeof CustomEvent === 'function') { customEvent = new CustomEvent(eventName, { detail: eventData, @@ -26,7 +26,7 @@ export function raiseCustomEvent(element: HTMLElement, eventName: string, eventD /** * Finds the index of the first value in an array that matches the specified predicate. - * + * * @export * @template T * @param {(x: T) => boolean} predicate @@ -38,7 +38,7 @@ export function findIndex(predicate: (x: T) => boolean, xs: T[]): number { throw new Error(`You attempted to call find with second parameter that was not an array. You passed: ${xs}`); } - let index; + let index: number; xs.some((x, i) => { if (predicate(x)) { index = i; @@ -51,7 +51,7 @@ export function findIndex(predicate: (x: T) => boolean, xs: T[]): number { /** * Finds the first value in an array that matches the specified predicate. - * + * * @export * @template T * @param {(x: T) => boolean} predicate @@ -72,7 +72,7 @@ export function remove(predicate: (x: T) => boolean, xs: T[]): void { // TODO: replace in favor of using polyfill /** * Copies the values of all enumerable properties from one or more source objects to a target object, and returns the target object. - * + * * @export * @param {any} args * @returns @@ -101,7 +101,7 @@ export function assign(...args) { /** * Generates a random 5 to 6 character string. - * + * * @export * @returns {string} */ @@ -111,7 +111,7 @@ export function createRandomString(): string { /** * Generates a 20 character uuid. - * + * * @export * @returns {string} */ @@ -132,7 +132,7 @@ export function generateUUID(): string { /** * Adds a parameter to the given url - * + * * @export * @param {string} url * @param {string} paramName @@ -140,14 +140,14 @@ export function generateUUID(): string { * @returns {string} */ export function addParamToUrl(url: string, paramName: string, value: string): string { - let parameterPrefix = url.indexOf('?') > 0 ? '&' : '?'; + const parameterPrefix = url.indexOf('?') > 0 ? '&' : '?'; url += parameterPrefix + paramName + '=' + value; return url; } /** * Checks if the report is saved. - * + * * @export * @param {HttpPostMessage} hpm * @param {string} uid @@ -156,7 +156,7 @@ export function addParamToUrl(url: string, paramName: string, value: string): st */ export async function isSavedInternal(hpm: HttpPostMessage, uid: string, contentWindow: Window): Promise { try { - const response = await hpm.get('/report/hasUnsavedChanges', { uid }, contentWindow); + const response = await hpm.get('/report/hasUnsavedChanges', { uid: uid }, contentWindow); return !response.body; } catch (response) { throw response.body; @@ -165,7 +165,7 @@ export async function isSavedInternal(hpm: HttpPostMessage, uid: string, content /** * Checks if the embed url is for RDL report. - * + * * @export * @param {string} embedUrl * @returns {boolean} @@ -176,7 +176,7 @@ export function isRDLEmbed(embedUrl: string): boolean { /** * Checks if the embed url contains autoAuth=true. - * + * * @export * @param {string} embedUrl * @returns {boolean} @@ -188,11 +188,11 @@ export function autoAuthInEmbedUrl(embedUrl: string): boolean { /** * Returns random number */ -export function getRandomValue() { +export function getRandomValue(): number { // window.msCrypto for IE - var cryptoObj = window.crypto || window.msCrypto; - var randomValueArray = new Uint32Array(1); + const cryptoObj = window.crypto || window.msCrypto; + const randomValueArray = new Uint32Array(1); cryptoObj.getRandomValues(randomValueArray); return randomValueArray[0]; @@ -200,6 +200,7 @@ export function getRandomValue() { /** * Returns the time interval between two dates in milliseconds + * * @export * @param {Date} start * @param {Date} end @@ -207,4 +208,4 @@ export function getRandomValue() { */ export function getTimeDiffInMilliseconds(start: Date, end: Date): number { return Math.abs(start.getTime() - end.getTime()); -} \ No newline at end of file +} diff --git a/src/visual.ts b/src/visual.ts index 3a2e7b73..fee1b254 100644 --- a/src/visual.ts +++ b/src/visual.ts @@ -133,7 +133,7 @@ export class Visual extends Report { * @param {string} pageName * @returns {Promise>} */ - setPage(pageName: string): Promise> { + setPage(_pageName: string): Promise> { throw Visual.SetPageNotSupportedError; } @@ -143,7 +143,7 @@ export class Visual extends Report { * @hidden * @returns {Promise} */ - async render(config?: IReportLoadConfiguration | IReportEmbedConfiguration): Promise { + async render(_config?: IReportLoadConfiguration | IReportEmbedConfiguration): Promise { throw Visual.RenderNotSupportedError; } @@ -232,7 +232,7 @@ export class Visual extends Report { const url: string = this.getFiltersLevelUrl(filtersLevel); try { - return await this.service.hpm.put(url, updateFiltersRequest, { uid: this.config.uniqueId }, this.iframe.contentWindow); + return await this.service.hpm.post(url, updateFiltersRequest, { uid: this.config.uniqueId }, this.iframe.contentWindow); } catch (response) { throw response.body; } diff --git a/src/visualDescriptor.ts b/src/visualDescriptor.ts index cd401cc3..1d846837 100644 --- a/src/visualDescriptor.ts +++ b/src/visualDescriptor.ts @@ -162,6 +162,7 @@ export class VisualDescriptor implements IVisualNode, IFilterable { /** * Exports Visual data. * Can export up to 30K rows. + * * @param rows: Optional. Default value is 30K, maximum value is 30K as well. * @param exportDataType: Optional. Default is ExportDataType.Summarized. * ```javascript @@ -188,6 +189,7 @@ export class VisualDescriptor implements IVisualNode, IFilterable { /** * Set slicer state. * Works only for visuals of type slicer. + * * @param state: A new state which contains the slicer filters. * ```javascript * visual.setSlicerState() diff --git a/test/test.spec.ts b/test/test.spec.ts index 1c7cfdcb..8c18544f 100644 --- a/test/test.spec.ts +++ b/test/test.spec.ts @@ -20,6 +20,8 @@ import { spyRouter } from './utility/mockRouter'; import * as util from '../src/util'; import { EmbedUrlNotSupported } from '../src/errors' +// Avoid adding new tests to this file, create another spec file instead. + declare global { interface Window { __karma__: any;