@xplortech/insights-elements 0.0.1-draft.7729525
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/cjs/apollo-data.esm-by4pfDU4.js +30 -0
- package/dist/cjs/apollo-data.esm-by4pfDU4.js.map +1 -0
- package/dist/cjs/app-globals-D-MP41KM.js +62 -0
- package/dist/cjs/app-globals-D-MP41KM.js.map +1 -0
- package/dist/cjs/index-CyoztwkV.js +40 -0
- package/dist/cjs/index-CyoztwkV.js.map +1 -0
- package/dist/cjs/index-DtrFwwSq.js +1472 -0
- package/dist/cjs/index-DtrFwwSq.js.map +1 -0
- package/dist/cjs/index.cjs.js +8 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/insights-bar-chart.cjs.entry.js +42 -0
- package/dist/cjs/insights-bar-chart.entry.cjs.js.map +1 -0
- package/dist/cjs/insights-chart-base-D6QbrWmD.js +102 -0
- package/dist/cjs/insights-chart-base-D6QbrWmD.js.map +1 -0
- package/dist/cjs/insights-donut-chart.cjs.entry.js +42 -0
- package/dist/cjs/insights-donut-chart.entry.cjs.js.map +1 -0
- package/dist/cjs/insights-elements.cjs.js +26 -0
- package/dist/cjs/insights-elements.cjs.js.map +1 -0
- package/dist/cjs/insights-wrapper.cjs.entry.js +1087 -0
- package/dist/cjs/insights-wrapper.entry.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +14 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/collection/collection-manifest.json +15 -0
- package/dist/collection/components/insights-bar-chart/insights-bar-chart.css +87 -0
- package/dist/collection/components/insights-bar-chart/insights-bar-chart.js +51 -0
- package/dist/collection/components/insights-bar-chart/insights-bar-chart.js.map +1 -0
- package/dist/collection/components/insights-chart-base.js +213 -0
- package/dist/collection/components/insights-chart-base.js.map +1 -0
- package/dist/collection/components/insights-donut-chart/insights-donut-chart.css +87 -0
- package/dist/collection/components/insights-donut-chart/insights-donut-chart.js +51 -0
- package/dist/collection/components/insights-donut-chart/insights-donut-chart.js.map +1 -0
- package/dist/collection/components/insights-wrapper/insights-wrapper.css +17 -0
- package/dist/collection/components/insights-wrapper/insights-wrapper.js +402 -0
- package/dist/collection/components/insights-wrapper/insights-wrapper.js.map +1 -0
- package/dist/collection/global/app.js +35 -0
- package/dist/collection/global/app.js.map +1 -0
- package/dist/collection/index.js +12 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/utils/chart-types.js +16 -0
- package/dist/collection/utils/chart-types.js.map +1 -0
- package/dist/collection/utils/code-generator.js +201 -0
- package/dist/collection/utils/code-generator.js.map +1 -0
- package/dist/collection/utils/insights-context.js +33 -0
- package/dist/collection/utils/insights-context.js.map +1 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.js +44 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/insights-bar-chart.d.ts +11 -0
- package/dist/components/insights-bar-chart.js +73 -0
- package/dist/components/insights-bar-chart.js.map +1 -0
- package/dist/components/insights-donut-chart.d.ts +11 -0
- package/dist/components/insights-donut-chart.js +73 -0
- package/dist/components/insights-donut-chart.js.map +1 -0
- package/dist/components/insights-wrapper.d.ts +11 -0
- package/dist/components/insights-wrapper.js +1123 -0
- package/dist/components/insights-wrapper.js.map +1 -0
- package/dist/components/p-CSTD3N9t.js +37 -0
- package/dist/components/p-CSTD3N9t.js.map +1 -0
- package/dist/components/p-DFvs3VMW.js +1195 -0
- package/dist/components/p-DFvs3VMW.js.map +1 -0
- package/dist/components/p-DHA6uI9u.js +9 -0
- package/dist/components/p-DHA6uI9u.js.map +1 -0
- package/dist/components/p-Dv82-c17.js +100 -0
- package/dist/components/p-Dv82-c17.js.map +1 -0
- package/dist/esm/apollo-data.esm-DHA6uI9u.js +9 -0
- package/dist/esm/apollo-data.esm-DHA6uI9u.js.map +1 -0
- package/dist/esm/app-globals-BtE_P06_.js +41 -0
- package/dist/esm/app-globals-BtE_P06_.js.map +1 -0
- package/dist/esm/index-BAqvP5--.js +1447 -0
- package/dist/esm/index-BAqvP5--.js.map +1 -0
- package/dist/esm/index-CSTD3N9t.js +37 -0
- package/dist/esm/index-CSTD3N9t.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/insights-bar-chart.entry.js +40 -0
- package/dist/esm/insights-bar-chart.entry.js.map +1 -0
- package/dist/esm/insights-chart-base-uNbdsloe.js +100 -0
- package/dist/esm/insights-chart-base-uNbdsloe.js.map +1 -0
- package/dist/esm/insights-donut-chart.entry.js +40 -0
- package/dist/esm/insights-donut-chart.entry.js.map +1 -0
- package/dist/esm/insights-elements.js +22 -0
- package/dist/esm/insights-elements.js.map +1 -0
- package/dist/esm/insights-wrapper.entry.js +1085 -0
- package/dist/esm/insights-wrapper.entry.js.map +1 -0
- package/dist/esm/loader.js +12 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/insights-elements/index.esm.js +2 -0
- package/dist/insights-elements/index.esm.js.map +1 -0
- package/dist/insights-elements/insights-bar-chart.entry.esm.js.map +1 -0
- package/dist/insights-elements/insights-donut-chart.entry.esm.js.map +1 -0
- package/dist/insights-elements/insights-elements.esm.js +2 -0
- package/dist/insights-elements/insights-elements.esm.js.map +1 -0
- package/dist/insights-elements/insights-wrapper.entry.esm.js.map +1 -0
- package/dist/insights-elements/loader.esm.js.map +1 -0
- package/dist/insights-elements/p-247183e1.entry.js +2 -0
- package/dist/insights-elements/p-247183e1.entry.js.map +1 -0
- package/dist/insights-elements/p-29ce0a90.entry.js +2 -0
- package/dist/insights-elements/p-29ce0a90.entry.js.map +1 -0
- package/dist/insights-elements/p-BAqvP5--.js +3 -0
- package/dist/insights-elements/p-BAqvP5--.js.map +1 -0
- package/dist/insights-elements/p-CSTD3N9t.js +2 -0
- package/dist/insights-elements/p-CSTD3N9t.js.map +1 -0
- package/dist/insights-elements/p-DE0h_D1B.js +2 -0
- package/dist/insights-elements/p-DE0h_D1B.js.map +1 -0
- package/dist/insights-elements/p-DHA6uI9u.js +3 -0
- package/dist/insights-elements/p-DHA6uI9u.js.map +1 -0
- package/dist/insights-elements/p-DVNwzSpV.js +2 -0
- package/dist/insights-elements/p-DVNwzSpV.js.map +1 -0
- package/dist/insights-elements/p-e48a7068.entry.js +2 -0
- package/dist/insights-elements/p-e48a7068.entry.js.map +1 -0
- package/dist/types/components/insights-bar-chart/insights-bar-chart.d.ts +9 -0
- package/dist/types/components/insights-chart-base.d.ts +54 -0
- package/dist/types/components/insights-donut-chart/insights-donut-chart.d.ts +9 -0
- package/dist/types/components/insights-wrapper/insights-wrapper.d.ts +46 -0
- package/dist/types/components.d.ts +201 -0
- package/dist/types/global/app.d.ts +6 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/stencil-public-runtime.d.ts +1756 -0
- package/dist/types/utils/chart-types.d.ts +53 -0
- package/dist/types/utils/code-generator.d.ts +31 -0
- package/dist/types/utils/insights-context.d.ts +39 -0
- package/insights-loader/cdn.js +1 -0
- package/insights-loader/index.cjs.js +1 -0
- package/insights-loader/index.d.ts +24 -0
- package/insights-loader/index.es2017.js +1 -0
- package/insights-loader/index.js +2 -0
- package/loader/index.cjs.js +8 -0
- package/loader/index.d.ts +5 -0
- package/loader/index.js +7 -0
- package/package.json +92 -0
|
@@ -0,0 +1,1087 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-DtrFwwSq.js');
|
|
4
|
+
var index$1 = require('./index-CyoztwkV.js');
|
|
5
|
+
|
|
6
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
7
|
+
|
|
8
|
+
function getDefaultExportFromCjs (x) {
|
|
9
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var browserPonyfill = {exports: {}};
|
|
13
|
+
|
|
14
|
+
var hasRequiredBrowserPonyfill;
|
|
15
|
+
|
|
16
|
+
function requireBrowserPonyfill () {
|
|
17
|
+
if (hasRequiredBrowserPonyfill) return browserPonyfill.exports;
|
|
18
|
+
hasRequiredBrowserPonyfill = 1;
|
|
19
|
+
(function (module, exports) {
|
|
20
|
+
// Save global object in a variable
|
|
21
|
+
var __global__ =
|
|
22
|
+
(typeof globalThis !== 'undefined' && globalThis) ||
|
|
23
|
+
(typeof self !== 'undefined' && self) ||
|
|
24
|
+
(typeof commonjsGlobal !== 'undefined' && commonjsGlobal);
|
|
25
|
+
// Create an object that extends from __global__ without the fetch function
|
|
26
|
+
var __globalThis__ = (function () {
|
|
27
|
+
function F() {
|
|
28
|
+
this.fetch = false;
|
|
29
|
+
this.DOMException = __global__.DOMException;
|
|
30
|
+
}
|
|
31
|
+
F.prototype = __global__; // Needed for feature detection on whatwg-fetch's code
|
|
32
|
+
return new F();
|
|
33
|
+
})();
|
|
34
|
+
// Wraps whatwg-fetch with a function scope to hijack the global object
|
|
35
|
+
// "globalThis" that's going to be patched
|
|
36
|
+
(function(globalThis) {
|
|
37
|
+
|
|
38
|
+
((function (exports) {
|
|
39
|
+
|
|
40
|
+
/* eslint-disable no-prototype-builtins */
|
|
41
|
+
var g =
|
|
42
|
+
(typeof globalThis !== 'undefined' && globalThis) ||
|
|
43
|
+
(typeof self !== 'undefined' && self) ||
|
|
44
|
+
// eslint-disable-next-line no-undef
|
|
45
|
+
(typeof commonjsGlobal !== 'undefined' && commonjsGlobal) ||
|
|
46
|
+
{};
|
|
47
|
+
|
|
48
|
+
var support = {
|
|
49
|
+
searchParams: 'URLSearchParams' in g,
|
|
50
|
+
iterable: 'Symbol' in g && 'iterator' in Symbol,
|
|
51
|
+
blob:
|
|
52
|
+
'FileReader' in g &&
|
|
53
|
+
'Blob' in g &&
|
|
54
|
+
(function() {
|
|
55
|
+
try {
|
|
56
|
+
new Blob();
|
|
57
|
+
return true
|
|
58
|
+
} catch (e) {
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
})(),
|
|
62
|
+
formData: 'FormData' in g,
|
|
63
|
+
arrayBuffer: 'ArrayBuffer' in g
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function isDataView(obj) {
|
|
67
|
+
return obj && DataView.prototype.isPrototypeOf(obj)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (support.arrayBuffer) {
|
|
71
|
+
var viewClasses = [
|
|
72
|
+
'[object Int8Array]',
|
|
73
|
+
'[object Uint8Array]',
|
|
74
|
+
'[object Uint8ClampedArray]',
|
|
75
|
+
'[object Int16Array]',
|
|
76
|
+
'[object Uint16Array]',
|
|
77
|
+
'[object Int32Array]',
|
|
78
|
+
'[object Uint32Array]',
|
|
79
|
+
'[object Float32Array]',
|
|
80
|
+
'[object Float64Array]'
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
var isArrayBufferView =
|
|
84
|
+
ArrayBuffer.isView ||
|
|
85
|
+
function(obj) {
|
|
86
|
+
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function normalizeName(name) {
|
|
91
|
+
if (typeof name !== 'string') {
|
|
92
|
+
name = String(name);
|
|
93
|
+
}
|
|
94
|
+
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
|
|
95
|
+
throw new TypeError('Invalid character in header field name: "' + name + '"')
|
|
96
|
+
}
|
|
97
|
+
return name.toLowerCase()
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function normalizeValue(value) {
|
|
101
|
+
if (typeof value !== 'string') {
|
|
102
|
+
value = String(value);
|
|
103
|
+
}
|
|
104
|
+
return value
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Build a destructive iterator for the value list
|
|
108
|
+
function iteratorFor(items) {
|
|
109
|
+
var iterator = {
|
|
110
|
+
next: function() {
|
|
111
|
+
var value = items.shift();
|
|
112
|
+
return {done: value === undefined, value: value}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (support.iterable) {
|
|
117
|
+
iterator[Symbol.iterator] = function() {
|
|
118
|
+
return iterator
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return iterator
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function Headers(headers) {
|
|
126
|
+
this.map = {};
|
|
127
|
+
|
|
128
|
+
if (headers instanceof Headers) {
|
|
129
|
+
headers.forEach(function(value, name) {
|
|
130
|
+
this.append(name, value);
|
|
131
|
+
}, this);
|
|
132
|
+
} else if (Array.isArray(headers)) {
|
|
133
|
+
headers.forEach(function(header) {
|
|
134
|
+
if (header.length != 2) {
|
|
135
|
+
throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
|
|
136
|
+
}
|
|
137
|
+
this.append(header[0], header[1]);
|
|
138
|
+
}, this);
|
|
139
|
+
} else if (headers) {
|
|
140
|
+
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
|
141
|
+
this.append(name, headers[name]);
|
|
142
|
+
}, this);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
Headers.prototype.append = function(name, value) {
|
|
147
|
+
name = normalizeName(name);
|
|
148
|
+
value = normalizeValue(value);
|
|
149
|
+
var oldValue = this.map[name];
|
|
150
|
+
this.map[name] = oldValue ? oldValue + ', ' + value : value;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
Headers.prototype['delete'] = function(name) {
|
|
154
|
+
delete this.map[normalizeName(name)];
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
Headers.prototype.get = function(name) {
|
|
158
|
+
name = normalizeName(name);
|
|
159
|
+
return this.has(name) ? this.map[name] : null
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
Headers.prototype.has = function(name) {
|
|
163
|
+
return this.map.hasOwnProperty(normalizeName(name))
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
Headers.prototype.set = function(name, value) {
|
|
167
|
+
this.map[normalizeName(name)] = normalizeValue(value);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
Headers.prototype.forEach = function(callback, thisArg) {
|
|
171
|
+
for (var name in this.map) {
|
|
172
|
+
if (this.map.hasOwnProperty(name)) {
|
|
173
|
+
callback.call(thisArg, this.map[name], name, this);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
Headers.prototype.keys = function() {
|
|
179
|
+
var items = [];
|
|
180
|
+
this.forEach(function(value, name) {
|
|
181
|
+
items.push(name);
|
|
182
|
+
});
|
|
183
|
+
return iteratorFor(items)
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
Headers.prototype.values = function() {
|
|
187
|
+
var items = [];
|
|
188
|
+
this.forEach(function(value) {
|
|
189
|
+
items.push(value);
|
|
190
|
+
});
|
|
191
|
+
return iteratorFor(items)
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
Headers.prototype.entries = function() {
|
|
195
|
+
var items = [];
|
|
196
|
+
this.forEach(function(value, name) {
|
|
197
|
+
items.push([name, value]);
|
|
198
|
+
});
|
|
199
|
+
return iteratorFor(items)
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
if (support.iterable) {
|
|
203
|
+
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function consumed(body) {
|
|
207
|
+
if (body._noBody) return
|
|
208
|
+
if (body.bodyUsed) {
|
|
209
|
+
return Promise.reject(new TypeError('Already read'))
|
|
210
|
+
}
|
|
211
|
+
body.bodyUsed = true;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function fileReaderReady(reader) {
|
|
215
|
+
return new Promise(function(resolve, reject) {
|
|
216
|
+
reader.onload = function() {
|
|
217
|
+
resolve(reader.result);
|
|
218
|
+
};
|
|
219
|
+
reader.onerror = function() {
|
|
220
|
+
reject(reader.error);
|
|
221
|
+
};
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function readBlobAsArrayBuffer(blob) {
|
|
226
|
+
var reader = new FileReader();
|
|
227
|
+
var promise = fileReaderReady(reader);
|
|
228
|
+
reader.readAsArrayBuffer(blob);
|
|
229
|
+
return promise
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function readBlobAsText(blob) {
|
|
233
|
+
var reader = new FileReader();
|
|
234
|
+
var promise = fileReaderReady(reader);
|
|
235
|
+
var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
|
|
236
|
+
var encoding = match ? match[1] : 'utf-8';
|
|
237
|
+
reader.readAsText(blob, encoding);
|
|
238
|
+
return promise
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function readArrayBufferAsText(buf) {
|
|
242
|
+
var view = new Uint8Array(buf);
|
|
243
|
+
var chars = new Array(view.length);
|
|
244
|
+
|
|
245
|
+
for (var i = 0; i < view.length; i++) {
|
|
246
|
+
chars[i] = String.fromCharCode(view[i]);
|
|
247
|
+
}
|
|
248
|
+
return chars.join('')
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function bufferClone(buf) {
|
|
252
|
+
if (buf.slice) {
|
|
253
|
+
return buf.slice(0)
|
|
254
|
+
} else {
|
|
255
|
+
var view = new Uint8Array(buf.byteLength);
|
|
256
|
+
view.set(new Uint8Array(buf));
|
|
257
|
+
return view.buffer
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function Body() {
|
|
262
|
+
this.bodyUsed = false;
|
|
263
|
+
|
|
264
|
+
this._initBody = function(body) {
|
|
265
|
+
/*
|
|
266
|
+
fetch-mock wraps the Response object in an ES6 Proxy to
|
|
267
|
+
provide useful test harness features such as flush. However, on
|
|
268
|
+
ES5 browsers without fetch or Proxy support pollyfills must be used;
|
|
269
|
+
the proxy-pollyfill is unable to proxy an attribute unless it exists
|
|
270
|
+
on the object before the Proxy is created. This change ensures
|
|
271
|
+
Response.bodyUsed exists on the instance, while maintaining the
|
|
272
|
+
semantic of setting Request.bodyUsed in the constructor before
|
|
273
|
+
_initBody is called.
|
|
274
|
+
*/
|
|
275
|
+
// eslint-disable-next-line no-self-assign
|
|
276
|
+
this.bodyUsed = this.bodyUsed;
|
|
277
|
+
this._bodyInit = body;
|
|
278
|
+
if (!body) {
|
|
279
|
+
this._noBody = true;
|
|
280
|
+
this._bodyText = '';
|
|
281
|
+
} else if (typeof body === 'string') {
|
|
282
|
+
this._bodyText = body;
|
|
283
|
+
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
|
284
|
+
this._bodyBlob = body;
|
|
285
|
+
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
|
|
286
|
+
this._bodyFormData = body;
|
|
287
|
+
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
288
|
+
this._bodyText = body.toString();
|
|
289
|
+
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
|
290
|
+
this._bodyArrayBuffer = bufferClone(body.buffer);
|
|
291
|
+
// IE 10-11 can't handle a DataView body.
|
|
292
|
+
this._bodyInit = new Blob([this._bodyArrayBuffer]);
|
|
293
|
+
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
|
294
|
+
this._bodyArrayBuffer = bufferClone(body);
|
|
295
|
+
} else {
|
|
296
|
+
this._bodyText = body = Object.prototype.toString.call(body);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (!this.headers.get('content-type')) {
|
|
300
|
+
if (typeof body === 'string') {
|
|
301
|
+
this.headers.set('content-type', 'text/plain;charset=UTF-8');
|
|
302
|
+
} else if (this._bodyBlob && this._bodyBlob.type) {
|
|
303
|
+
this.headers.set('content-type', this._bodyBlob.type);
|
|
304
|
+
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
305
|
+
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
if (support.blob) {
|
|
311
|
+
this.blob = function() {
|
|
312
|
+
var rejected = consumed(this);
|
|
313
|
+
if (rejected) {
|
|
314
|
+
return rejected
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (this._bodyBlob) {
|
|
318
|
+
return Promise.resolve(this._bodyBlob)
|
|
319
|
+
} else if (this._bodyArrayBuffer) {
|
|
320
|
+
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
|
|
321
|
+
} else if (this._bodyFormData) {
|
|
322
|
+
throw new Error('could not read FormData body as blob')
|
|
323
|
+
} else {
|
|
324
|
+
return Promise.resolve(new Blob([this._bodyText]))
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
this.arrayBuffer = function() {
|
|
330
|
+
if (this._bodyArrayBuffer) {
|
|
331
|
+
var isConsumed = consumed(this);
|
|
332
|
+
if (isConsumed) {
|
|
333
|
+
return isConsumed
|
|
334
|
+
} else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
|
|
335
|
+
return Promise.resolve(
|
|
336
|
+
this._bodyArrayBuffer.buffer.slice(
|
|
337
|
+
this._bodyArrayBuffer.byteOffset,
|
|
338
|
+
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
339
|
+
)
|
|
340
|
+
)
|
|
341
|
+
} else {
|
|
342
|
+
return Promise.resolve(this._bodyArrayBuffer)
|
|
343
|
+
}
|
|
344
|
+
} else if (support.blob) {
|
|
345
|
+
return this.blob().then(readBlobAsArrayBuffer)
|
|
346
|
+
} else {
|
|
347
|
+
throw new Error('could not read as ArrayBuffer')
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
this.text = function() {
|
|
352
|
+
var rejected = consumed(this);
|
|
353
|
+
if (rejected) {
|
|
354
|
+
return rejected
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (this._bodyBlob) {
|
|
358
|
+
return readBlobAsText(this._bodyBlob)
|
|
359
|
+
} else if (this._bodyArrayBuffer) {
|
|
360
|
+
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
|
|
361
|
+
} else if (this._bodyFormData) {
|
|
362
|
+
throw new Error('could not read FormData body as text')
|
|
363
|
+
} else {
|
|
364
|
+
return Promise.resolve(this._bodyText)
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
if (support.formData) {
|
|
369
|
+
this.formData = function() {
|
|
370
|
+
return this.text().then(decode)
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
this.json = function() {
|
|
375
|
+
return this.text().then(JSON.parse)
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
return this
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// HTTP methods whose capitalization should be normalized
|
|
382
|
+
var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
|
|
383
|
+
|
|
384
|
+
function normalizeMethod(method) {
|
|
385
|
+
var upcased = method.toUpperCase();
|
|
386
|
+
return methods.indexOf(upcased) > -1 ? upcased : method
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function Request(input, options) {
|
|
390
|
+
if (!(this instanceof Request)) {
|
|
391
|
+
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
options = options || {};
|
|
395
|
+
var body = options.body;
|
|
396
|
+
|
|
397
|
+
if (input instanceof Request) {
|
|
398
|
+
if (input.bodyUsed) {
|
|
399
|
+
throw new TypeError('Already read')
|
|
400
|
+
}
|
|
401
|
+
this.url = input.url;
|
|
402
|
+
this.credentials = input.credentials;
|
|
403
|
+
if (!options.headers) {
|
|
404
|
+
this.headers = new Headers(input.headers);
|
|
405
|
+
}
|
|
406
|
+
this.method = input.method;
|
|
407
|
+
this.mode = input.mode;
|
|
408
|
+
this.signal = input.signal;
|
|
409
|
+
if (!body && input._bodyInit != null) {
|
|
410
|
+
body = input._bodyInit;
|
|
411
|
+
input.bodyUsed = true;
|
|
412
|
+
}
|
|
413
|
+
} else {
|
|
414
|
+
this.url = String(input);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
this.credentials = options.credentials || this.credentials || 'same-origin';
|
|
418
|
+
if (options.headers || !this.headers) {
|
|
419
|
+
this.headers = new Headers(options.headers);
|
|
420
|
+
}
|
|
421
|
+
this.method = normalizeMethod(options.method || this.method || 'GET');
|
|
422
|
+
this.mode = options.mode || this.mode || null;
|
|
423
|
+
this.signal = options.signal || this.signal || (function () {
|
|
424
|
+
if ('AbortController' in g) {
|
|
425
|
+
var ctrl = new AbortController();
|
|
426
|
+
return ctrl.signal;
|
|
427
|
+
}
|
|
428
|
+
}());
|
|
429
|
+
this.referrer = null;
|
|
430
|
+
|
|
431
|
+
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
|
432
|
+
throw new TypeError('Body not allowed for GET or HEAD requests')
|
|
433
|
+
}
|
|
434
|
+
this._initBody(body);
|
|
435
|
+
|
|
436
|
+
if (this.method === 'GET' || this.method === 'HEAD') {
|
|
437
|
+
if (options.cache === 'no-store' || options.cache === 'no-cache') {
|
|
438
|
+
// Search for a '_' parameter in the query string
|
|
439
|
+
var reParamSearch = /([?&])_=[^&]*/;
|
|
440
|
+
if (reParamSearch.test(this.url)) {
|
|
441
|
+
// If it already exists then set the value with the current time
|
|
442
|
+
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
|
|
443
|
+
} else {
|
|
444
|
+
// Otherwise add a new '_' parameter to the end with the current time
|
|
445
|
+
var reQueryString = /\?/;
|
|
446
|
+
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
Request.prototype.clone = function() {
|
|
453
|
+
return new Request(this, {body: this._bodyInit})
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
function decode(body) {
|
|
457
|
+
var form = new FormData();
|
|
458
|
+
body
|
|
459
|
+
.trim()
|
|
460
|
+
.split('&')
|
|
461
|
+
.forEach(function(bytes) {
|
|
462
|
+
if (bytes) {
|
|
463
|
+
var split = bytes.split('=');
|
|
464
|
+
var name = split.shift().replace(/\+/g, ' ');
|
|
465
|
+
var value = split.join('=').replace(/\+/g, ' ');
|
|
466
|
+
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
return form
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function parseHeaders(rawHeaders) {
|
|
473
|
+
var headers = new Headers();
|
|
474
|
+
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
|
475
|
+
// https://tools.ietf.org/html/rfc7230#section-3.2
|
|
476
|
+
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
|
|
477
|
+
// Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
|
|
478
|
+
// https://github.com/github/fetch/issues/748
|
|
479
|
+
// https://github.com/zloirock/core-js/issues/751
|
|
480
|
+
preProcessedHeaders
|
|
481
|
+
.split('\r')
|
|
482
|
+
.map(function(header) {
|
|
483
|
+
return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
|
|
484
|
+
})
|
|
485
|
+
.forEach(function(line) {
|
|
486
|
+
var parts = line.split(':');
|
|
487
|
+
var key = parts.shift().trim();
|
|
488
|
+
if (key) {
|
|
489
|
+
var value = parts.join(':').trim();
|
|
490
|
+
try {
|
|
491
|
+
headers.append(key, value);
|
|
492
|
+
} catch (error) {
|
|
493
|
+
console.warn('Response ' + error.message);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
return headers
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
Body.call(Request.prototype);
|
|
501
|
+
|
|
502
|
+
function Response(bodyInit, options) {
|
|
503
|
+
if (!(this instanceof Response)) {
|
|
504
|
+
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
|
|
505
|
+
}
|
|
506
|
+
if (!options) {
|
|
507
|
+
options = {};
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
this.type = 'default';
|
|
511
|
+
this.status = options.status === undefined ? 200 : options.status;
|
|
512
|
+
if (this.status < 200 || this.status > 599) {
|
|
513
|
+
throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
|
|
514
|
+
}
|
|
515
|
+
this.ok = this.status >= 200 && this.status < 300;
|
|
516
|
+
this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
|
|
517
|
+
this.headers = new Headers(options.headers);
|
|
518
|
+
this.url = options.url || '';
|
|
519
|
+
this._initBody(bodyInit);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
Body.call(Response.prototype);
|
|
523
|
+
|
|
524
|
+
Response.prototype.clone = function() {
|
|
525
|
+
return new Response(this._bodyInit, {
|
|
526
|
+
status: this.status,
|
|
527
|
+
statusText: this.statusText,
|
|
528
|
+
headers: new Headers(this.headers),
|
|
529
|
+
url: this.url
|
|
530
|
+
})
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
Response.error = function() {
|
|
534
|
+
var response = new Response(null, {status: 200, statusText: ''});
|
|
535
|
+
response.ok = false;
|
|
536
|
+
response.status = 0;
|
|
537
|
+
response.type = 'error';
|
|
538
|
+
return response
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
var redirectStatuses = [301, 302, 303, 307, 308];
|
|
542
|
+
|
|
543
|
+
Response.redirect = function(url, status) {
|
|
544
|
+
if (redirectStatuses.indexOf(status) === -1) {
|
|
545
|
+
throw new RangeError('Invalid status code')
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return new Response(null, {status: status, headers: {location: url}})
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
exports.DOMException = g.DOMException;
|
|
552
|
+
try {
|
|
553
|
+
new exports.DOMException();
|
|
554
|
+
} catch (err) {
|
|
555
|
+
exports.DOMException = function(message, name) {
|
|
556
|
+
this.message = message;
|
|
557
|
+
this.name = name;
|
|
558
|
+
var error = Error(message);
|
|
559
|
+
this.stack = error.stack;
|
|
560
|
+
};
|
|
561
|
+
exports.DOMException.prototype = Object.create(Error.prototype);
|
|
562
|
+
exports.DOMException.prototype.constructor = exports.DOMException;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function fetch(input, init) {
|
|
566
|
+
return new Promise(function(resolve, reject) {
|
|
567
|
+
var request = new Request(input, init);
|
|
568
|
+
|
|
569
|
+
if (request.signal && request.signal.aborted) {
|
|
570
|
+
return reject(new exports.DOMException('Aborted', 'AbortError'))
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
var xhr = new XMLHttpRequest();
|
|
574
|
+
|
|
575
|
+
function abortXhr() {
|
|
576
|
+
xhr.abort();
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
xhr.onload = function() {
|
|
580
|
+
var options = {
|
|
581
|
+
statusText: xhr.statusText,
|
|
582
|
+
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
583
|
+
};
|
|
584
|
+
// This check if specifically for when a user fetches a file locally from the file system
|
|
585
|
+
// Only if the status is out of a normal range
|
|
586
|
+
if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {
|
|
587
|
+
options.status = 200;
|
|
588
|
+
} else {
|
|
589
|
+
options.status = xhr.status;
|
|
590
|
+
}
|
|
591
|
+
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
|
592
|
+
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
593
|
+
setTimeout(function() {
|
|
594
|
+
resolve(new Response(body, options));
|
|
595
|
+
}, 0);
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
xhr.onerror = function() {
|
|
599
|
+
setTimeout(function() {
|
|
600
|
+
reject(new TypeError('Network request failed'));
|
|
601
|
+
}, 0);
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
xhr.ontimeout = function() {
|
|
605
|
+
setTimeout(function() {
|
|
606
|
+
reject(new TypeError('Network request timed out'));
|
|
607
|
+
}, 0);
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
xhr.onabort = function() {
|
|
611
|
+
setTimeout(function() {
|
|
612
|
+
reject(new exports.DOMException('Aborted', 'AbortError'));
|
|
613
|
+
}, 0);
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
function fixUrl(url) {
|
|
617
|
+
try {
|
|
618
|
+
return url === '' && g.location.href ? g.location.href : url
|
|
619
|
+
} catch (e) {
|
|
620
|
+
return url
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
xhr.open(request.method, fixUrl(request.url), true);
|
|
625
|
+
|
|
626
|
+
if (request.credentials === 'include') {
|
|
627
|
+
xhr.withCredentials = true;
|
|
628
|
+
} else if (request.credentials === 'omit') {
|
|
629
|
+
xhr.withCredentials = false;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if ('responseType' in xhr) {
|
|
633
|
+
if (support.blob) {
|
|
634
|
+
xhr.responseType = 'blob';
|
|
635
|
+
} else if (
|
|
636
|
+
support.arrayBuffer
|
|
637
|
+
) {
|
|
638
|
+
xhr.responseType = 'arraybuffer';
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {
|
|
643
|
+
var names = [];
|
|
644
|
+
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
|
|
645
|
+
names.push(normalizeName(name));
|
|
646
|
+
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
|
|
647
|
+
});
|
|
648
|
+
request.headers.forEach(function(value, name) {
|
|
649
|
+
if (names.indexOf(name) === -1) {
|
|
650
|
+
xhr.setRequestHeader(name, value);
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
} else {
|
|
654
|
+
request.headers.forEach(function(value, name) {
|
|
655
|
+
xhr.setRequestHeader(name, value);
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (request.signal) {
|
|
660
|
+
request.signal.addEventListener('abort', abortXhr);
|
|
661
|
+
|
|
662
|
+
xhr.onreadystatechange = function() {
|
|
663
|
+
// DONE (success or failure)
|
|
664
|
+
if (xhr.readyState === 4) {
|
|
665
|
+
request.signal.removeEventListener('abort', abortXhr);
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
|
|
671
|
+
})
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
fetch.polyfill = true;
|
|
675
|
+
|
|
676
|
+
if (!g.fetch) {
|
|
677
|
+
g.fetch = fetch;
|
|
678
|
+
g.Headers = Headers;
|
|
679
|
+
g.Request = Request;
|
|
680
|
+
g.Response = Response;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
exports.Headers = Headers;
|
|
684
|
+
exports.Request = Request;
|
|
685
|
+
exports.Response = Response;
|
|
686
|
+
exports.fetch = fetch;
|
|
687
|
+
|
|
688
|
+
return exports;
|
|
689
|
+
|
|
690
|
+
}))({});
|
|
691
|
+
})(__globalThis__);
|
|
692
|
+
// This is a ponyfill, so...
|
|
693
|
+
__globalThis__.fetch.ponyfill = true;
|
|
694
|
+
delete __globalThis__.fetch.polyfill;
|
|
695
|
+
// Choose between native implementation (__global__) or custom implementation (__globalThis__)
|
|
696
|
+
var ctx = __global__.fetch ? __global__ : __globalThis__;
|
|
697
|
+
exports = ctx.fetch; // To enable: import fetch from 'cross-fetch'
|
|
698
|
+
exports.default = ctx.fetch; // For TypeScript consumers without esModuleInterop.
|
|
699
|
+
exports.fetch = ctx.fetch; // To enable: import {fetch} from 'cross-fetch'
|
|
700
|
+
exports.Headers = ctx.Headers;
|
|
701
|
+
exports.Request = ctx.Request;
|
|
702
|
+
exports.Response = ctx.Response;
|
|
703
|
+
module.exports = exports;
|
|
704
|
+
} (browserPonyfill, browserPonyfill.exports));
|
|
705
|
+
return browserPonyfill.exports;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
var browserPonyfillExports = requireBrowserPonyfill();
|
|
709
|
+
var h = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfillExports);
|
|
710
|
+
|
|
711
|
+
class c {
|
|
712
|
+
/**
|
|
713
|
+
* Create a ResultSet
|
|
714
|
+
* @param {object} data - Raw data from API response
|
|
715
|
+
*/
|
|
716
|
+
constructor(e) {
|
|
717
|
+
this.rawData = e;
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Get all data rows as an array
|
|
721
|
+
* @returns {Array<object>} Array of data rows
|
|
722
|
+
*/
|
|
723
|
+
getData() {
|
|
724
|
+
return this.rawData.data || [];
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Get total count of records
|
|
728
|
+
* @returns {number} Total number of records matching the query
|
|
729
|
+
*/
|
|
730
|
+
getCount() {
|
|
731
|
+
return this.rawData.meta?.count || 0;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Get calculated totals
|
|
735
|
+
* @returns {object|null} Totals object
|
|
736
|
+
*/
|
|
737
|
+
getTotals() {
|
|
738
|
+
return this.rawData.totals || null;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Get pagination information
|
|
742
|
+
* @returns {object} Object containing limit and offset
|
|
743
|
+
*/
|
|
744
|
+
getPagination() {
|
|
745
|
+
return {
|
|
746
|
+
limit: this.rawData.meta?.limit || 0,
|
|
747
|
+
offset: this.rawData.meta?.offset || 0
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Get raw response data
|
|
752
|
+
* @returns {object} Raw API response
|
|
753
|
+
*/
|
|
754
|
+
getRawData() {
|
|
755
|
+
return this.rawData;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Get raw sql query if available
|
|
759
|
+
* @returns {(string|undefined)} Raw SQL query if available
|
|
760
|
+
*/
|
|
761
|
+
getRawSQL() {
|
|
762
|
+
return this.rawData.meta?.sql;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Convert data to a tabular format with specified columns
|
|
766
|
+
* @param {Array<string>} columns - Array of column names to include
|
|
767
|
+
* @returns {Array<object>} Array of rows with only specified columns
|
|
768
|
+
*/
|
|
769
|
+
tablePivot(e) {
|
|
770
|
+
const t = this.getData();
|
|
771
|
+
return !e || e.length === 0 ? t : t.map((r) => {
|
|
772
|
+
const a = {};
|
|
773
|
+
return e.forEach((n) => {
|
|
774
|
+
a[n] = r[n];
|
|
775
|
+
}), a;
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Convert data to series format for charting libraries
|
|
780
|
+
* @param {string} xAxis - Column to use for x-axis
|
|
781
|
+
* @param {Array<string>} yAxes - Columns to use for y-axes
|
|
782
|
+
* @returns {Array<object>} Array of series with x and y values
|
|
783
|
+
*/
|
|
784
|
+
chartPivot(e, t) {
|
|
785
|
+
const r = this.getData();
|
|
786
|
+
return t.map((a) => ({
|
|
787
|
+
key: a,
|
|
788
|
+
title: a,
|
|
789
|
+
series: r.map((n) => ({
|
|
790
|
+
x: n[e],
|
|
791
|
+
y: n[a]
|
|
792
|
+
}))
|
|
793
|
+
}));
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
const p = "0.1.6";
|
|
797
|
+
class l {
|
|
798
|
+
constructor(e, t) {
|
|
799
|
+
this.apiToken = e, this.apiUrl = t.apiUrl.endsWith("/") ? t.apiUrl.slice(0, -1) : t.apiUrl;
|
|
800
|
+
}
|
|
801
|
+
_getDefaultHeaders() {
|
|
802
|
+
const e = {
|
|
803
|
+
"Content-Type": "application/json",
|
|
804
|
+
"x-insights-sdk-version": p
|
|
805
|
+
};
|
|
806
|
+
return this.apiToken && (e.Authorization = `Bearer ${this.apiToken}`), e;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Get a report by name with specified query parameters
|
|
810
|
+
* @param {string} reportName - The name of the report to fetch
|
|
811
|
+
* @param {(Object|Array)} query - The query parameters
|
|
812
|
+
* @param {Object} [options] - Additional options
|
|
813
|
+
* @param {boolean} [options.sql=false] - Include generated SQL in response
|
|
814
|
+
* @returns {Promise<ResultSet>}
|
|
815
|
+
*/
|
|
816
|
+
async getReport(e, t = {}, r = {}) {
|
|
817
|
+
if (!e)
|
|
818
|
+
throw new Error("Report name is required");
|
|
819
|
+
const a = new URL(`${this.apiUrl}/reports/${e}`);
|
|
820
|
+
(Array.isArray(t) ? t : [t]).forEach((u) => {
|
|
821
|
+
Object.keys(u).length > 0 && a.searchParams.append("query", JSON.stringify(u));
|
|
822
|
+
}), r.sql && a.searchParams.append("sql", "true");
|
|
823
|
+
const s = await h(a.toString(), {
|
|
824
|
+
headers: this._getDefaultHeaders()
|
|
825
|
+
});
|
|
826
|
+
if (!s.ok) {
|
|
827
|
+
const u = await s.text();
|
|
828
|
+
throw new Error(
|
|
829
|
+
`API request failed: ${s.status} ${s.statusText}. ${u}`
|
|
830
|
+
);
|
|
831
|
+
}
|
|
832
|
+
const i = await s.json();
|
|
833
|
+
return Array.isArray(i) ? i.map((u) => new c(u)) : new c(i);
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Get metadata for a specific report
|
|
837
|
+
* @param {string} reportName - The name of the report
|
|
838
|
+
* @returns {Promise<object>} Report metadata
|
|
839
|
+
*/
|
|
840
|
+
async getReportMeta(e) {
|
|
841
|
+
if (!e)
|
|
842
|
+
throw new Error("Report name is required");
|
|
843
|
+
const t = `${this.apiUrl}/reports/${e}/meta`, r = await h(t, {
|
|
844
|
+
headers: this._getDefaultHeaders()
|
|
845
|
+
});
|
|
846
|
+
if (!r.ok) {
|
|
847
|
+
const a = await r.text();
|
|
848
|
+
throw new Error(
|
|
849
|
+
`API request failed: ${r.status} ${r.statusText}. ${a}`
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
return r.json();
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Get a list of all available reports
|
|
856
|
+
* @returns {Promise<object>} List of available reports
|
|
857
|
+
*/
|
|
858
|
+
async listReports() {
|
|
859
|
+
const e = `${this.apiUrl}/reports`, t = await h(e, {
|
|
860
|
+
headers: this._getDefaultHeaders()
|
|
861
|
+
});
|
|
862
|
+
if (!t.ok) {
|
|
863
|
+
const r = await t.text();
|
|
864
|
+
throw new Error(
|
|
865
|
+
`API request failed: ${t.status} ${t.statusText}. ${r}`
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
return t.json();
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Export a report in a specific format (default is CSV)
|
|
872
|
+
* @param {string} reportName - The name of the report to export
|
|
873
|
+
* @param {object} query - Optional query parameters
|
|
874
|
+
* @param {string} [type="csv"] - The export format (e.g., "csv", "json")
|
|
875
|
+
* @returns {Promise<string>} The exported report content as string
|
|
876
|
+
*/
|
|
877
|
+
async exportReport(e, t = {}, r = "csv") {
|
|
878
|
+
if (!e)
|
|
879
|
+
throw new Error("Report name is required");
|
|
880
|
+
if (r !== "csv")
|
|
881
|
+
throw new Error("Only csv is supported");
|
|
882
|
+
const a = new URL(`${this.apiUrl}/reports/${e}/export`);
|
|
883
|
+
(Array.isArray(t) ? t : [t]).forEach((i) => {
|
|
884
|
+
Object.keys(i).length > 0 && a.searchParams.append("query", JSON.stringify(i));
|
|
885
|
+
});
|
|
886
|
+
const s = await h(a.toString(), {
|
|
887
|
+
headers: this._getDefaultHeaders()
|
|
888
|
+
});
|
|
889
|
+
if (!s.ok) {
|
|
890
|
+
const i = await s.text();
|
|
891
|
+
throw new Error(
|
|
892
|
+
`Export request failed: ${s.status} ${s.statusText}. ${i}`
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
return s.text();
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
function f(o, e) {
|
|
899
|
+
if (typeof o == "object" && o !== null) {
|
|
900
|
+
const { token: t, ...r } = o;
|
|
901
|
+
return new l(t, r);
|
|
902
|
+
}
|
|
903
|
+
return new l(o, e || { apiUrl: "" });
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
const insightsWrapperCss = ":host{display:block}.insights-wrapper{width:100%;height:100%}.loading{display:flex;align-items:center;justify-content:center;padding:20px;color:#666;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif}";
|
|
907
|
+
|
|
908
|
+
const InsightsWrapper = class {
|
|
909
|
+
constructor(hostRef) {
|
|
910
|
+
index.registerInstance(this, hostRef);
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Name of the configuration to use from setupConfiguration
|
|
914
|
+
* Defaults to 'default' if not provided
|
|
915
|
+
*/
|
|
916
|
+
configName;
|
|
917
|
+
/**
|
|
918
|
+
* API URL for the insights service (alternative to using configName)
|
|
919
|
+
*/
|
|
920
|
+
apiUrl;
|
|
921
|
+
/**
|
|
922
|
+
* Authentication token (optional if using configName)
|
|
923
|
+
*/
|
|
924
|
+
token;
|
|
925
|
+
/**
|
|
926
|
+
* Callback to refresh the token (can override configuration)
|
|
927
|
+
*/
|
|
928
|
+
onRefreshTokenCallback;
|
|
929
|
+
/**
|
|
930
|
+
* Callback for error and warning events (can override configuration)
|
|
931
|
+
*/
|
|
932
|
+
onEventEmittedCallback;
|
|
933
|
+
initialized = false;
|
|
934
|
+
insightsClient;
|
|
935
|
+
currentConfig;
|
|
936
|
+
componentWillLoad() {
|
|
937
|
+
this.initializeClient();
|
|
938
|
+
}
|
|
939
|
+
handlePropsChange() {
|
|
940
|
+
this.initializeClient();
|
|
941
|
+
}
|
|
942
|
+
async initializeClient() {
|
|
943
|
+
try {
|
|
944
|
+
let apiUrl;
|
|
945
|
+
let authToken;
|
|
946
|
+
let refreshTokenCallback;
|
|
947
|
+
let onEventEmittedCallback;
|
|
948
|
+
// Check if using configName or direct props
|
|
949
|
+
if (this.configName || (!this.apiUrl && !this.token)) {
|
|
950
|
+
// Using named configuration
|
|
951
|
+
const config = index$1.getConfiguration(this.configName);
|
|
952
|
+
if (!config) {
|
|
953
|
+
const configNameToUse = this.configName || 'default';
|
|
954
|
+
const errorMsg = `Configuration '${configNameToUse}' not found. Please call setupConfiguration() first.`;
|
|
955
|
+
console.error(errorMsg);
|
|
956
|
+
throw new Error(errorMsg);
|
|
957
|
+
}
|
|
958
|
+
apiUrl = config.apiUrl;
|
|
959
|
+
authToken = config.token;
|
|
960
|
+
// Props override configuration
|
|
961
|
+
refreshTokenCallback = this.onRefreshTokenCallback || config.refreshToken;
|
|
962
|
+
onEventEmittedCallback = this.onEventEmittedCallback || config.onEventEmitted;
|
|
963
|
+
// Store config for later use
|
|
964
|
+
this.currentConfig = {
|
|
965
|
+
apiUrl: config.apiUrl,
|
|
966
|
+
refreshToken: refreshTokenCallback,
|
|
967
|
+
onEventEmitted: onEventEmittedCallback,
|
|
968
|
+
};
|
|
969
|
+
// Get initial token from refreshToken callback if provided
|
|
970
|
+
if (refreshTokenCallback) {
|
|
971
|
+
authToken = typeof refreshTokenCallback === 'function' ? await refreshTokenCallback() : refreshTokenCallback;
|
|
972
|
+
}
|
|
973
|
+
// Emit warning through callback if no token
|
|
974
|
+
if (!authToken && onEventEmittedCallback) {
|
|
975
|
+
onEventEmittedCallback({ eventType: 'warning', data: { message: 'No token provided for configuration' } });
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
else {
|
|
979
|
+
// Using direct props (backwards compatible)
|
|
980
|
+
if (!this.apiUrl) {
|
|
981
|
+
const errorMsg = 'apiUrl is required when not using configName';
|
|
982
|
+
console.error(errorMsg);
|
|
983
|
+
throw new Error(errorMsg);
|
|
984
|
+
}
|
|
985
|
+
apiUrl = this.apiUrl;
|
|
986
|
+
authToken = this.token;
|
|
987
|
+
refreshTokenCallback = this.onRefreshTokenCallback;
|
|
988
|
+
onEventEmittedCallback = this.onEventEmittedCallback;
|
|
989
|
+
// Store config for later use even with direct props
|
|
990
|
+
this.currentConfig = {
|
|
991
|
+
apiUrl: this.apiUrl,
|
|
992
|
+
refreshToken: refreshTokenCallback,
|
|
993
|
+
onEventEmitted: onEventEmittedCallback,
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
// Create the insights client
|
|
997
|
+
this.insightsClient = f(authToken, {
|
|
998
|
+
apiUrl: apiUrl,
|
|
999
|
+
});
|
|
1000
|
+
this.initialized = true;
|
|
1001
|
+
}
|
|
1002
|
+
catch (error) {
|
|
1003
|
+
const errorMsg = error instanceof Error ? error.message : 'Failed to initialize insights client';
|
|
1004
|
+
// Emit error through callback if configured
|
|
1005
|
+
if (this.currentConfig?.onEventEmitted) {
|
|
1006
|
+
this.currentConfig.onEventEmitted({ eventType: 'error', data: { message: errorMsg, error } });
|
|
1007
|
+
}
|
|
1008
|
+
console.error('Error initializing insights client:', error);
|
|
1009
|
+
throw error;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
async handleTokenExpired() {
|
|
1013
|
+
// Auto-refresh token if refreshToken callback is configured
|
|
1014
|
+
if (this.currentConfig?.refreshToken) {
|
|
1015
|
+
try {
|
|
1016
|
+
await this.initializeClient();
|
|
1017
|
+
}
|
|
1018
|
+
catch (error) {
|
|
1019
|
+
console.error('Failed to refresh token:', error);
|
|
1020
|
+
if (this.currentConfig?.onEventEmitted) {
|
|
1021
|
+
this.currentConfig.onEventEmitted({ eventType: 'error', data: { message: 'Failed to refresh token', error } });
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
else {
|
|
1026
|
+
if (this.currentConfig?.onEventEmitted) {
|
|
1027
|
+
this.currentConfig.onEventEmitted({ eventType: 'warning', data: { message: 'Token expired but no refreshToken callback configured' } });
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Public method to fetch data for charts
|
|
1033
|
+
* This can be called by child chart components
|
|
1034
|
+
*/
|
|
1035
|
+
async fetchData(reportName, query) {
|
|
1036
|
+
try {
|
|
1037
|
+
const response = await this.insightsClient.getReport(reportName, query);
|
|
1038
|
+
return response;
|
|
1039
|
+
}
|
|
1040
|
+
catch (error) {
|
|
1041
|
+
// Check if error is token expiration
|
|
1042
|
+
if (error.message && error.message.includes('401')) {
|
|
1043
|
+
await this.handleTokenExpired();
|
|
1044
|
+
// Retry fetching data after token refresh
|
|
1045
|
+
const response = await this.insightsClient.getReport(reportName, query);
|
|
1046
|
+
return response;
|
|
1047
|
+
}
|
|
1048
|
+
throw error;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Helper method to build query from filters
|
|
1053
|
+
*/
|
|
1054
|
+
async buildQuery(filters, getQueryByFilters) {
|
|
1055
|
+
if (getQueryByFilters) {
|
|
1056
|
+
return getQueryByFilters(filters);
|
|
1057
|
+
}
|
|
1058
|
+
// Default query builder
|
|
1059
|
+
return {
|
|
1060
|
+
columns: ['*'],
|
|
1061
|
+
...filters,
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Manually refresh the token using the refreshToken callback from configuration
|
|
1066
|
+
*/
|
|
1067
|
+
async manualRefreshToken() {
|
|
1068
|
+
if (!this.currentConfig?.refreshToken) {
|
|
1069
|
+
throw new Error('No refreshToken callback configured');
|
|
1070
|
+
}
|
|
1071
|
+
await this.initializeClient();
|
|
1072
|
+
}
|
|
1073
|
+
render() {
|
|
1074
|
+
return (index.h("div", { key: '8a00c399458b7dff7dff0ac7e50a6217d7c2ad3d', class: "insights-wrapper" }, this.initialized && index.h("slot", { key: '85f26cab746e109f97ef29288b57377c449b7429' }), !this.initialized && index.h("div", { key: 'a59a48e70a8ff0258d5112aafeca6bc5a4a620ac', class: "loading" }, "Initializing Insights...")));
|
|
1075
|
+
}
|
|
1076
|
+
static get watchers() { return {
|
|
1077
|
+
"configName": ["handlePropsChange"],
|
|
1078
|
+
"apiUrl": ["handlePropsChange"],
|
|
1079
|
+
"token": ["handlePropsChange"],
|
|
1080
|
+
"onRefreshTokenCallback": ["handlePropsChange"],
|
|
1081
|
+
"onEventEmittedCallback": ["handlePropsChange"]
|
|
1082
|
+
}; }
|
|
1083
|
+
};
|
|
1084
|
+
InsightsWrapper.style = insightsWrapperCss;
|
|
1085
|
+
|
|
1086
|
+
exports.insights_wrapper = InsightsWrapper;
|
|
1087
|
+
//# sourceMappingURL=insights-wrapper.entry.cjs.js.map
|