Merged PR 275402: New API setSdkInfo in service + version bump 2.21.1

sdkType tells us which SDK wrapper performs the actions, e.g: powerbi-client-react, powerbi-client-angular...

To update it we should pass the type in the header 'x-sdk-type` which is populated in the service constructor. Therefore, each wrapper needs to pass the correct sdkType when initiating the service (see example: [Pull Request 274150](https://dev.azure.com/powerbi/Embedded/_git/powerbi-client-react/pullrequest/274150)).

**What is the problem?** if user injects a new powerbi service to the wrapper and doesn't use the default service, the sdkType won't be populated.
As a result, I created new API in the service, so we could update in each wrapper the sdk type after the service is created.

In addition, create new header `x-sdk-wrapper-version`.
This commit is contained in:
Or Shemesh 2022-06-28 09:03:15 +00:00
Родитель c1188f085b
Коммит 8c2d12d0eb
7 изменённых файлов: 49 добавлений и 14 удалений

11
dist/powerbi-client.d.ts поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
// powerbi-client v2.21.0
// powerbi-client v2.21.1
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
declare module "config" {
@ -2057,6 +2057,7 @@ declare module "service" {
onError?: (error: any) => any;
version?: string;
type?: string;
sdkWrapperVersion?: string;
}
export interface IService {
hpm: HttpPostMessage;
@ -2254,6 +2255,14 @@ declare module "service" {
* @param {HTMLElement} [element=undefined]
*/
preload(config: IComponentEmbedConfiguration | IEmbedConfigurationBase, element?: HTMLElement): HTMLIFrameElement;
/**
* Use this API to set SDK info
*
* @hidden
* @param {string} type
* @returns {void}
*/
setSdkInfo(type: string, version: string): void;
}
}
declare module "bookmarksManager" {

22
dist/powerbi.js поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
// powerbi-client v2.21.0
// powerbi-client v2.21.1
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
(function webpackUniversalModuleDefinition(root, factory) {
@ -8931,7 +8931,7 @@ exports.BookmarksManager = BookmarksManager;
Object.defineProperty(exports, "__esModule", { value: true });
/** @ignore */ /** */
var config = {
version: '2.21.0',
version: '2.21.1',
type: 'js'
};
exports.default = config;
@ -10044,12 +10044,13 @@ var window_post_message_proxy_1 = __webpack_require__(/*! window-post-message-pr
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 hpmFactory = function (wpmp, defaultTargetWindow, sdkVersion, sdkType) {
var hpmFactory = function (wpmp, defaultTargetWindow, sdkVersion, sdkType, sdkWrapperVersion) {
if (sdkVersion === void 0) { sdkVersion = config_1.default.version; }
if (sdkType === void 0) { sdkType = config_1.default.type; }
return new http_post_message_1.HttpPostMessage(wpmp, {
'x-sdk-type': sdkType,
'x-sdk-version': sdkVersion
'x-sdk-version': sdkVersion,
'x-sdk-wrapper-version': sdkWrapperVersion,
}, defaultTargetWindow);
};
exports.hpmFactory = hpmFactory;
@ -12410,7 +12411,7 @@ var Service = /** @class */ (function () {
if (config === void 0) { config = {}; }
var _this = this;
this.wpmp = wpmpFactory(config.wpmpName, config.logMessages);
this.hpm = hpmFactory(this.wpmp, null, config.version, config.type);
this.hpm = hpmFactory(this.wpmp, null, config.version, config.type, config.sdkWrapperVersion);
this.router = routerFactory(this.wpmp);
this.uniqueSessionId = utils.generateUUID();
/**
@ -12836,6 +12837,17 @@ var Service = /** @class */ (function () {
};
return iframeContent;
};
/**
* Use this API to set SDK info
*
* @hidden
* @param {string} type
* @returns {void}
*/
Service.prototype.setSdkInfo = function (type, version) {
this.hpm.defaultHeaders['x-sdk-type'] = type;
this.hpm.defaultHeaders['x-sdk-wrapper-version'] = version;
};
/**
* A list of components that this service can embed
*/

6
dist/powerbi.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "powerbi-client",
"version": "2.21.0",
"version": "2.21.1",
"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",

Просмотреть файл

@ -3,7 +3,7 @@
/** @ignore *//** */
const config = {
version: '2.21.0',
version: '2.21.1',
type: 'js'
};

Просмотреть файл

@ -16,10 +16,11 @@ export {
IRouterFactory
};
export const hpmFactory: IHpmFactory = (wpmp, defaultTargetWindow, sdkVersion = config.version, sdkType = config.type) => {
export const hpmFactory: IHpmFactory = (wpmp, defaultTargetWindow, sdkVersion = config.version, sdkType = config.type, sdkWrapperVersion?: string) => {
return new HttpPostMessage(wpmp, {
'x-sdk-type': sdkType,
'x-sdk-version': sdkVersion
'x-sdk-version': sdkVersion,
'x-sdk-wrapper-version': sdkWrapperVersion,
}, defaultTargetWindow);
};

Просмотреть файл

@ -85,6 +85,7 @@ export interface IServiceConfiguration extends IDebugOptions {
onError?: (error: any) => any;
version?: string;
type?: string;
sdkWrapperVersion?: string;
}
export interface IService {
@ -159,7 +160,7 @@ export class Service implements IService {
*/
constructor(hpmFactory: IHpmFactory, wpmpFactory: IWpmpFactory, routerFactory: IRouterFactory, config: IServiceConfiguration = {}) {
this.wpmp = wpmpFactory(config.wpmpName, config.logMessages);
this.hpm = hpmFactory(this.wpmp, null, config.version, config.type);
this.hpm = hpmFactory(this.wpmp, null, config.version, config.type, config.sdkWrapperVersion);
this.router = routerFactory(this.wpmp);
this.uniqueSessionId = utils.generateUUID();
@ -632,4 +633,16 @@ export class Service implements IService {
return iframeContent;
}
/**
* Use this API to set SDK info
*
* @hidden
* @param {string} type
* @returns {void}
*/
setSdkInfo(type: string, version: string): void {
this.hpm.defaultHeaders['x-sdk-type'] = type;
this.hpm.defaultHeaders['x-sdk-wrapper-version'] = version;
}
}