forked from microsoft/PowerBI-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.d.ts
More file actions
157 lines (157 loc) · 5.76 KB
/
service.d.ts
File metadata and controls
157 lines (157 loc) · 5.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*! powerbi-client v2.0.0-beta.12 | (c) 2016 Microsoft Corporation MIT */
import * as embed from './embed';
import { Report } from './report';
import { Tile } from './tile';
import * as wpmp from 'window-post-message-proxy';
import * as hpm from 'http-post-message';
import * as router from 'powerbi-router';
export interface IEvent<T> {
type: string;
id: string;
name: string;
value: T;
}
export interface ICustomEvent<T> extends CustomEvent {
detail: T;
}
export interface IEventHandler<T> {
(event: ICustomEvent<T>): any;
}
export interface IHpmFactory {
(wpmp: wpmp.WindowPostMessageProxy, targetWindow?: Window, version?: string, type?: string, origin?: string): hpm.HttpPostMessage;
}
export interface IWpmpFactory {
(name?: string, logMessages?: boolean, eventSourceOverrideWindow?: Window): wpmp.WindowPostMessageProxy;
}
export interface IRouterFactory {
(wpmp: wpmp.WindowPostMessageProxy): router.Router;
}
export interface IPowerBiElement extends HTMLElement {
powerBiEmbed: embed.Embed;
}
export interface IDebugOptions {
logMessages?: boolean;
wpmpName?: string;
}
export interface IServiceConfiguration extends IDebugOptions {
autoEmbedOnContentLoaded?: boolean;
onError?: (error: any) => any;
version?: string;
type?: string;
}
export interface IService {
hpm: hpm.HttpPostMessage;
}
/**
* The Power BI embed service. This is the entry point to embed Power BI components intor your application.
*
* @export
* @class Service
* @implements {IService}
*/
export declare class Service implements IService {
/**
* List of components this service can embed.
*/
private static components;
/**
* Default configuration for service.
*/
private static defaultConfig;
/**
* Gets or sets the access token as fallback/global token to use when local token for report/tile is not provided.
*
* @type {string}
*/
accessToken: string;
/** Configuration object */
private config;
/** List of components (Reports/Tiles) that have been embedded using this service instance. */
private embeds;
/** TODO: Look for way to make this private without sacraficing ease of maitenance. This should be private but in embed needs to call methods. */
hpm: hpm.HttpPostMessage;
wpmp: wpmp.WindowPostMessageProxy;
private router;
/**
* Creates an instance of Power BI embed service.
*
* @param {IHpmFactory} hpmFactory The http post message factory used in the postMessage communication layer
* @param {IWpmpFactory} wpmpFactory The window post message factory used in the postMessage communication layer
* @param {IRouterFactory} routerFactory The router factory used in the postMessage communication layer
* @param {IServiceConfiguration} [config={}]
*/
constructor(hpmFactory: IHpmFactory, wpmpFactory: IWpmpFactory, routerFactory: IRouterFactory, config?: IServiceConfiguration);
/**
* Handler for DOMContentLoaded which searches DOM for elements having 'powerbi-embed-url' attribute
* and automatically attempts to embed a powerbi component based on information from the attributes.
* Only runs if `config.autoEmbedOnContentLoaded` is true when the service is created.
*
* @param {HTMLElement} [container]
* @param {embed.IEmbedConfiguration} [config=undefined]
* @returns {embed.Embed[]}
*/
init(container?: HTMLElement, config?: embed.IEmbedConfiguration): embed.Embed[];
/**
* Given an html element embed component based on configuration.
* If component has already been created and attached to element re-use component instance and existing iframe,
* otherwise create a new component instance
*
* @param {HTMLElement} element
* @param {embed.IEmbedConfiguration} [config={}]
* @returns {embed.Embed}
*/
embed(element: HTMLElement, config?: embed.IEmbedConfiguration): embed.Embed;
/**
* Given an html element embed component base configuration.
* Save component instance on element for later lookup.
*
* @private
* @param {IPowerBiElement} element
* @param {embed.IEmbedConfiguration} config
* @returns {embed.Embed}
*/
private embedNew(element, config);
/**
* Given and element which arleady contains embed, load with new configuration
*
* @private
* @param {IPowerBiElement} element
* @param {embed.IEmbedConfiguration} config
* @returns {embed.Embed}
*/
private embedExisting(element, config);
/**
* Adds event handler for DOMContentLoaded which finds all elements in DOM with attribute powerbi-embed-url
* then attempts to initiate the embed process based on data from other powerbi-* attributes.
* (This is usually only useful for applications rendered on by the server since all the data needed will be available by the time the handler is called.)
*/
enableAutoEmbed(): void;
/**
* Returns instance of component associated with element.
*
* @param {HTMLElement} element
* @returns {(Report | Tile)}
*/
get(element: HTMLElement): Report | Tile;
/**
* Find embed instance by name / unique id provided.
*
* @param {string} uniqueId
* @returns {(Report | Tile)}
*/
find(uniqueId: string): Report | Tile;
/**
* Given an html element which has component embedded within it, remove the component from list of embeds, remove association with component, and remove the iframe.
*
* @param {HTMLElement} element
* @returns {void}
*/
reset(element: HTMLElement): void;
/**
* Given an event object, find embed with matching type and id and invoke its handleEvent method with event.
*
* @private
* @param {IEvent<any>} event
*/
private handleEvent(event);
}