Skip to content

Commit afc8e5e

Browse files
authored
Merge pull request microsoft#396 from tappan-ajmera/tappanajmera-microsoft-sdk-mirror-release
Mirror 2.25.0
2 parents db73ce7 + dda4b41 commit afc8e5e

10 files changed

Lines changed: 1737 additions & 1896 deletions

File tree

‎dist/powerbi-client.d.ts‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// powerbi-client v2.23.10
1+
// powerbi-client v2.25.0
22
// Copyright (c) Microsoft Corporation.
33
// Licensed under the MIT License.
44
declare module "config" {
@@ -158,6 +158,7 @@ declare module "embed" {
158158
export type IQnaEmbedConfiguration = models.IQnaEmbedConfiguration;
159159
export type IQuickCreateConfiguration = models.IQuickCreateConfiguration;
160160
export type IReportCreateConfiguration = models.IReportCreateConfiguration;
161+
export type IReportCreateFromDefinitionConfiguration = models.IReportCreateFromDefinitionConfiguration;
161162
export type ILocaleSettings = models.ILocaleSettings;
162163
export type IQnaSettings = models.IQnaSettings;
163164
export type IEmbedSettings = models.ISettings;
@@ -1673,7 +1674,7 @@ declare module "report" {
16731674
}
16741675
}
16751676
declare module "create" {
1676-
import { IReportCreateConfiguration, IError } from 'powerbi-models';
1677+
import { IError, IReportCreateConfiguration, IReportCreateFromDefinitionConfiguration } from 'powerbi-models';
16771678
import { Service } from "service";
16781679
import { Embed, IEmbedConfigurationBase, IEmbedConfiguration } from "embed";
16791680
/**
@@ -1687,11 +1688,11 @@ declare module "create" {
16871688
/**
16881689
* Gets or sets the configuration settings for creating report.
16891690
*
1690-
* @type {IReportCreateConfiguration}
1691+
* @type {IReportCreateConfiguration | IReportCreateFromDefinitionConfiguration}
16911692
* @hidden
16921693
*/
1693-
createConfig: IReportCreateConfiguration;
1694-
constructor(service: Service, element: HTMLElement, config: IEmbedConfiguration | IReportCreateConfiguration, phasedRender?: boolean, isBootstrap?: boolean);
1694+
createConfig: IReportCreateConfiguration | IReportCreateFromDefinitionConfiguration;
1695+
constructor(service: Service, element: HTMLElement, config: IEmbedConfiguration | IReportCreateConfiguration | IReportCreateFromDefinitionConfiguration, phasedRender?: boolean, isBootstrap?: boolean);
16951696
/**
16961697
* Gets the dataset ID from the first available location: createConfig or embed url.
16971698
*
@@ -2137,7 +2138,7 @@ declare module "service" {
21372138
import { WindowPostMessageProxy } from 'window-post-message-proxy';
21382139
import { HttpPostMessage } from 'http-post-message';
21392140
import { Router, IExtendedRequest, Response as IExtendedResponse } from 'powerbi-router';
2140-
import { IQuickCreateConfiguration, IReportCreateConfiguration } from 'powerbi-models';
2141+
import { IQuickCreateConfiguration, IReportCreateConfiguration, IReportCreateFromDefinitionConfiguration } from 'powerbi-models';
21412142
import { Embed, IBootstrapEmbedConfiguration, IDashboardEmbedConfiguration, IEmbedConfiguration, IEmbedConfigurationBase, IQnaEmbedConfiguration, IReportEmbedConfiguration, ITileEmbedConfiguration, IVisualEmbedConfiguration } from "embed";
21422143
export interface IEvent<T> {
21432144
type: string;
@@ -2257,7 +2258,7 @@ declare module "service" {
22572258
* @param {IEmbedConfiguration} [config={}]
22582259
* @returns {Embed}
22592260
*/
2260-
createReport(element: HTMLElement, config: IEmbedConfiguration | IReportCreateConfiguration): Embed;
2261+
createReport(element: HTMLElement, config: IEmbedConfiguration | IReportCreateConfiguration | IReportCreateFromDefinitionConfiguration): Embed;
22612262
/**
22622263
* Creates new dataset
22632264
*
@@ -2967,7 +2968,7 @@ declare module "powerbi-client" {
29672968
export { Report } from "report";
29682969
export { Dashboard } from "dashboard";
29692970
export { Tile } from "tile";
2970-
export { IEmbedConfiguration, IQnaEmbedConfiguration, IVisualEmbedConfiguration, IReportEmbedConfiguration, IDashboardEmbedConfiguration, ITileEmbedConfiguration, IQuickCreateConfiguration, IReportCreateConfiguration, Embed, ILocaleSettings, IEmbedSettings, IQnaSettings, } from "embed";
2971+
export { IEmbedConfiguration, IQnaEmbedConfiguration, IVisualEmbedConfiguration, IReportEmbedConfiguration, IDashboardEmbedConfiguration, ITileEmbedConfiguration, IQuickCreateConfiguration, IReportCreateConfiguration, IReportCreateFromDefinitionConfiguration, Embed, ILocaleSettings, IEmbedSettings, IQnaSettings, } from "embed";
29712972
export { Page } from "page";
29722973
export { Qna } from "qna";
29732974
export { Visual } from "visual";

‎dist/powerbi.js‎

Lines changed: 1653 additions & 1875 deletions
Large diffs are not rendered by default.

‎dist/powerbi.min.js‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "powerbi-client",
3-
"version": "2.23.10",
3+
"version": "2.25.0",
44
"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.",
55
"main": "dist/powerbi.js",
66
"types": "dist/powerbi-client.d.ts",
@@ -78,7 +78,7 @@
7878
},
7979
"dependencies": {
8080
"http-post-message": "^0.3.0",
81-
"powerbi-models": "^2.0.1",
81+
"powerbi-models": "^2.2.0",
8282
"powerbi-router": "^0.1",
8383
"window-post-message-proxy": "^0.3.0"
8484
},

‎src/config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/** @ignore *//** */
55
const config = {
6-
version: '2.23.10',
6+
version: '2.25.0',
77
type: 'js'
88
};
99

‎src/create.ts‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
import { IReportCreateConfiguration, IError, validateCreateReport } from 'powerbi-models';
4+
import {
5+
IError,
6+
IReportCreateConfiguration,
7+
IReportCreateFromDefinitionConfiguration,
8+
validateCreateReport,
9+
validateCreateReportFromDefinition
10+
} from 'powerbi-models';
511
import { Service } from './service';
612
import { Embed, IEmbedConfigurationBase, IEmbedConfiguration, ISessionHeaders } from './embed';
713
import * as utils from './util';
814

15+
function isReportCreateFromDefinitionConfiguration(config: IEmbedConfigurationBase): config is IReportCreateFromDefinitionConfiguration {
16+
return "reportDefinition" in config;
17+
}
18+
919
/**
1020
* A Power BI Report creator component
1121
*
@@ -17,15 +27,21 @@ export class Create extends Embed {
1727
/**
1828
* Gets or sets the configuration settings for creating report.
1929
*
20-
* @type {IReportCreateConfiguration}
30+
* @type {IReportCreateConfiguration | IReportCreateFromDefinitionConfiguration}
2131
* @hidden
2232
*/
23-
createConfig: IReportCreateConfiguration;
33+
createConfig: IReportCreateConfiguration | IReportCreateFromDefinitionConfiguration;
2434

2535
/*
2636
* @hidden
2737
*/
28-
constructor(service: Service, element: HTMLElement, config: IEmbedConfiguration | IReportCreateConfiguration, phasedRender?: boolean, isBootstrap?: boolean) {
38+
constructor(
39+
service: Service,
40+
element: HTMLElement,
41+
config: IEmbedConfiguration | IReportCreateConfiguration | IReportCreateFromDefinitionConfiguration,
42+
phasedRender?: boolean,
43+
isBootstrap?: boolean
44+
) {
2945
super(service, element, config, /* iframe */ undefined, phasedRender, isBootstrap);
3046
}
3147

@@ -48,7 +64,9 @@ export class Create extends Embed {
4864
* Validate create report configuration.
4965
*/
5066
validate(config: IEmbedConfigurationBase): IError[] {
51-
return validateCreateReport(config);
67+
return isReportCreateFromDefinitionConfiguration(config)
68+
? validateCreateReportFromDefinition(config)
69+
: validateCreateReport(config);
5270
}
5371

5472
/**
@@ -64,14 +82,18 @@ export class Create extends Embed {
6482

6583
const config = this.config as IEmbedConfiguration | IReportCreateConfiguration;
6684

67-
this.createConfig = {
85+
const createConfig: IReportCreateConfiguration = {
6886
accessToken: config.accessToken,
6987
datasetId: config.datasetId || this.getId(),
7088
groupId: config.groupId,
7189
settings: config.settings,
7290
tokenType: config.tokenType,
7391
theme: config.theme
7492
};
93+
94+
this.createConfig = isReportCreateFromDefinitionConfiguration(this.config)
95+
? { ...createConfig, reportDefinition: this.config.reportDefinition }
96+
: createConfig;
7597
}
7698

7799
/**

‎src/embed.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export type IQuickCreateConfiguration = models.IQuickCreateConfiguration;
5252

5353
export type IReportCreateConfiguration = models.IReportCreateConfiguration;
5454

55+
export type IReportCreateFromDefinitionConfiguration = models.IReportCreateFromDefinitionConfiguration;
56+
5557
export type ILocaleSettings = models.ILocaleSettings;
5658

5759
export type IQnaSettings = models.IQnaSettings;

‎src/powerbi-client.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export {
3333
ITileEmbedConfiguration,
3434
IQuickCreateConfiguration,
3535
IReportCreateConfiguration,
36+
IReportCreateFromDefinitionConfiguration,
3637
Embed,
3738
ILocaleSettings,
3839
IEmbedSettings,

‎src/service.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { WindowPostMessageProxy } from 'window-post-message-proxy';
88
import { HttpPostMessage } from 'http-post-message';
99
import { Router, IExtendedRequest, Response as IExtendedResponse } from 'powerbi-router';
10-
import { IPage, IQuickCreateConfiguration, IReportCreateConfiguration } from 'powerbi-models';
10+
import { IPage, IQuickCreateConfiguration, IReportCreateConfiguration, IReportCreateFromDefinitionConfiguration } from 'powerbi-models';
1111
import {
1212
Embed,
1313
IBootstrapEmbedConfiguration,
@@ -279,7 +279,10 @@ export class Service implements IService {
279279
* @param {IEmbedConfiguration} [config={}]
280280
* @returns {Embed}
281281
*/
282-
createReport(element: HTMLElement, config: IEmbedConfiguration | IReportCreateConfiguration): Embed {
282+
createReport(
283+
element: HTMLElement,
284+
config: IEmbedConfiguration | IReportCreateConfiguration | IReportCreateFromDefinitionConfiguration
285+
): Embed {
283286
config.type = 'create';
284287
const powerBiElement = element as IPowerBiElement;
285288
const component = new Create(this, powerBiElement, config);

‎test/service.spec.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,40 @@ describe('service', function () {
698698
// Assert
699699
expect(report.createConfig.theme).toBeUndefined();
700700
});
701+
702+
it('reportDefinition should be in create config if exists in embedConfig', function () {
703+
// Arrange
704+
const testDatasetId = "ABC123";
705+
const accessToken = 'ABC123';
706+
const reportDefinition = { definition: '{"version":"2.0.0"}' };
707+
const embedUrl = `https://app.powerbi.com/reportEmbed?datasetId=${testDatasetId}`;
708+
const $reportContainer = $(`<div powerbi-embed-url="${embedUrl}"</div>`)
709+
.appendTo('#powerbi-fixture');
710+
711+
// Act
712+
const report = powerbi.createReport($reportContainer[0], { embedUrl: embedUrl, accessToken: accessToken, datasetId: testDatasetId, reportDefinition: reportDefinition }) as create.Create;
713+
714+
// Assert
715+
expect("reportDefinition" in report.createConfig).toBe(true);
716+
if ("reportDefinition" in report.createConfig) {
717+
expect(report.createConfig.reportDefinition).toEqual(reportDefinition);
718+
}
719+
});
720+
721+
it('reportDefinition should be undefined in create config if not exists in embedConfig', function () {
722+
// Arrange
723+
const testDatasetId = "ABC123";
724+
const accessToken = 'ABC123';
725+
const embedUrl = `https://app.powerbi.com/reportEmbed?datasetId=${testDatasetId}`;
726+
const $reportContainer = $(`<div powerbi-embed-url="${embedUrl}"</div>`)
727+
.appendTo('#powerbi-fixture');
728+
729+
// Act
730+
const report = powerbi.createReport($reportContainer[0], { embedUrl: embedUrl, accessToken: accessToken }) as create.Create;
731+
732+
// Assert
733+
expect("reportDefinition" in report.createConfig).toBe(false);
734+
});
701735
});
702736

703737
describe('reports', function () {

0 commit comments

Comments
 (0)