@crowdstrike/logscale-dashboard 1.126.0--build-684--sha-1de8e2885c1117489d131c478ebf5a572b6881cf

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.
Files changed (4) hide show
  1. package/index.d.ts +553 -0
  2. package/index.js +27343 -0
  3. package/index.js.map +6 -0
  4. package/package.json +14 -0
package/index.d.ts ADDED
@@ -0,0 +1,553 @@
1
+ /**
2
+ * @crowdstrike/logscale-dashboard
3
+ *
4
+ * This packages allows you to embed a LogScale Dashboard as a WebComponent.
5
+ *
6
+ * ```ts
7
+ * // Importing the module defines the "logscale-dashboard" custom element as a side-effect.
8
+ * import * as LogScaleDashboard from "@crowdstrike/logscale-dashboard";
9
+ *
10
+ * // See documentation for `createElement`
11
+ * const element : LogScaleDashboard.Dashboard = LogScaleDashboard.createElement(options);
12
+ * document.body.appendChild(element);
13
+ * ```
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+
18
+ /** Common options shared by all LogScale Webcomponents
19
+ * @public
20
+ */
21
+ export declare interface CommonOptions {
22
+ /** The current unix time as millisecs. Defaults to `Date.now` if not set. */
23
+ currentTime?: number;
24
+ /** Allows you to open the webcomponent's internal shadow DOM.
25
+ *
26
+ * This is useful for writing E2E tests where you want to inspect the internal DOM of the WebComponent.
27
+ * Do this sparingly, since the internal DOM elements can change between releases of
28
+ * the webcomponents.
29
+ */
30
+ shadowRootMode?: "open" | "closed";
31
+ /** Names of experimental features to be enabled. The names of features are provided by LogScale on a case-by-case basis.
32
+ * Should be left empty or undefined by default.
33
+ */
34
+ featureFlags?: Array<string> | Record<string, boolean>;
35
+ }
36
+
37
+ /**
38
+ * The primary way of embedding a Dashboard.
39
+ * This function that creates a `logscale-dashboard` webcomponent and initializes it with the provided options.
40
+ *
41
+ * ```ts
42
+ * const options : Options = {
43
+ * apiURL: "https://...",
44
+ * theme: "dark",
45
+ * repoOrViewName: "my-repo",
46
+ * dashboard: { name: "my-dashboard" },
47
+ * // ...
48
+ * };
49
+ *
50
+ * const element : Dashboard = createElement(options);
51
+ * ```
52
+ *
53
+ * ## Callbacks
54
+ * Methods for registering callbacks for events happening within a LogScale Dashboard are exposed on the Dashboard class.
55
+ *
56
+ * ```ts
57
+ * element.onDashboardStateChanged((dashboardState: DashboardNavigationTargetInfo) => {
58
+ * console.log("dashboard state changed: ", dashboardState);
59
+ * });
60
+ * ```
61
+ * ## Updating the Dashboard
62
+ * A Dashboard can be updated after initialization through methods on the Dashboard class.
63
+ *
64
+ * ```ts
65
+ * // update parameter args and apply immediately, executing all dependent queries
66
+ * element.setParameterValues({method: 'POST'}, {apply: true});
67
+ * ```
68
+ *
69
+ * @public
70
+ */
71
+ export declare function createElement(options: Options): Dashboard;
72
+
73
+ /**
74
+ * Custom Link interaction type.
75
+ *
76
+ * @public
77
+ */
78
+ export declare type CustomLinkInteraction = {
79
+ type: "customLink";
80
+ urlTemplate: string;
81
+ openInNewTab?: boolean;
82
+ urlEncodeArgs?: boolean;
83
+ } & SharedInteractionProperties;
84
+
85
+ /**
86
+ * A NavigationTarget for LogScale Dashboard.
87
+ *
88
+ * @public
89
+ */
90
+ export declare type DashbboardNavigationTarget = {
91
+ type: "dashboard";
92
+ targetInfo: DashboardNavigationTargetInfo;
93
+ };
94
+
95
+ /**
96
+ * Custom element that embeds the LogScale Dashboard.
97
+ *
98
+ * @public
99
+ */
100
+ export declare class Dashboard extends WebcomponentBase<Options> {
101
+ /**
102
+ * Set parameter values on dashboard.
103
+ *
104
+ * @param parameterValues
105
+ * @param options - used to specify behaviour when setting parameters, i.e. if they should be applied immediately.
106
+ *
107
+ * @public
108
+ */
109
+ setParameterValues(parameterValues: ParameterValues, options?: SetParametersOptions): void;
110
+ /**
111
+ * Implement this hook to receive notifications about changes to the state of the Dashboard.
112
+ *
113
+ * Use this if you e.g. want to serialize / keep local state of Dashboard.
114
+ * @param callback
115
+ *
116
+ * @public
117
+ */
118
+ onDashboardStateChanged(callback: (dashboardState: DashboardNavigationTargetInfo) => void | null): void;
119
+ }
120
+
121
+ /**
122
+ * Used to prefix queries on a LogScale Dashboard.
123
+ *
124
+ * @public
125
+ */
126
+ export declare type DashboardFilter = string | {
127
+ /** Id of an existing filter on the dashboard. */
128
+ id: string;
129
+ };
130
+
131
+ /**
132
+ * Dashboard Link interaction type.
133
+ * If `onNavigationTargetChange` hook is implemented, these interactions will
134
+ * trigger a navigation target change, triggering the `onNavigationTargetChange` hook
135
+ * passing a `DashboardNavigationTarget` as the argument.
136
+ *
137
+ * @public
138
+ */
139
+ export declare type DashboardLinkInteraction = {
140
+ type: "dashboardLink";
141
+ dashboardName: string;
142
+ package?: string;
143
+ dashboardRepo?: string;
144
+ dashboardId?: string;
145
+ arguments?: Record<string, string> | null;
146
+ openInNewTab?: boolean;
147
+ useWidgetTimeWindow?: boolean;
148
+ } & SharedInteractionProperties;
149
+
150
+ /**
151
+ * The Dashboard state as set by the source of the NavigationTarget.
152
+ * This can be used to load a LogScale Dashboard in a specific state.
153
+ *
154
+ * @public
155
+ */
156
+ export declare type DashboardNavigationTargetInfo = DashboardParams & {
157
+ repoOrViewName: string;
158
+ timezone?: string;
159
+ };
160
+
161
+ /**
162
+ * Configuration of LogScale Dashboard.
163
+ * This also overlaps with `DashboardNavigationTarget.targetInfo`.
164
+ * This means that `DashboardParams` can be created from the targetInfo of a `DashboardNavigationTarget`.
165
+ *
166
+ * @public
167
+ */
168
+ export declare interface DashboardParams {
169
+ /**
170
+ * A reference to a dashboard.
171
+ */
172
+ dashboard: DashboardReference;
173
+ /** A map of arguments for dashboard parameters */
174
+ parameterArgs?: ParameterValues;
175
+ /**
176
+ * Optional filter which will prefix all dashboard queries.
177
+ */
178
+ filter?: DashboardFilter;
179
+ /**
180
+ * Start time used for dashboard queries.
181
+ * Note: this will only be used when querying if `sharedTime` is set to `true`.
182
+ */
183
+ start?: string;
184
+ /**
185
+ * End time used for dashboard queries.
186
+ * Note: this will only be used when querying if `sharedTime` is set to `true`.
187
+ */
188
+ end?: string;
189
+ /** Set to true to make the dashboard `live`. Defaults to `false` */
190
+ isLive?: boolean;
191
+ /**
192
+ * Set to `true` to make all dashboard queries use `start` and `end` as time window.
193
+ */
194
+ sharedTime?: boolean;
195
+ }
196
+
197
+ /**
198
+ * A reference to a LogScale Dashboard.
199
+ *
200
+ * @public
201
+ */
202
+ export declare type DashboardReference = {
203
+ name: string;
204
+ /**
205
+ * Package containing the dashboard. E.g. "my-org/dashboards".
206
+ * If omitted the dashboard will be found in dashboards that have no package.
207
+ */
208
+ package?: string;
209
+ } | {
210
+ id: string;
211
+ };
212
+
213
+ /**
214
+ * Search view Edit state.
215
+ * Use this when you need to load / put a LogScale Search view in an edit state to allow editing of LogScale assets
216
+ * from the Search view.
217
+ *
218
+ * @public
219
+ */
220
+ export declare type EditState = {
221
+ savedQueryId: string;
222
+ } | {
223
+ dashboardId: string;
224
+ widgetId?: string;
225
+ } | {
226
+ alertId: string;
227
+ } | {
228
+ filterAlertId: string;
229
+ } | {
230
+ scheduledSearchId: string;
231
+ };
232
+
233
+ /**
234
+ * LogScale Interactions.
235
+ * See [documentation](https://library.humio.com/data-analysis/dashboards-interactions.html) for more information.
236
+ *
237
+ * @public
238
+ */
239
+ export declare type Interaction = CustomLinkInteraction | SearchLinkInteraction | DashboardLinkInteraction | UpdateParametersInteraction;
240
+
241
+ /**
242
+ * Configure conditions to control when an interaction should be available.
243
+ *
244
+ * @public
245
+ */
246
+ export declare type InteractionCondition = {
247
+ "operator": "present" | "not-present";
248
+ "fieldName": string;
249
+ } | {
250
+ "operator": "starts-with" | "ends-with" | "equal" | "not-equal" | "contains" | "not-contains";
251
+ "fieldName": string;
252
+ "argument": string;
253
+ };
254
+
255
+ /**
256
+ * The NavigationTarget type specifies the target of a LogScale navigation event.
257
+ * These are handled by the `onNavigationTargetChange` hook. Sources of Navigation targets are:
258
+ * - Internal LogScale links
259
+ * - LogScale Interactions
260
+ *
261
+ * @public
262
+ */
263
+ export declare type NavigationTarget = SearchNavigationTarget | DashbboardNavigationTarget;
264
+
265
+ /**
266
+ * Initialization options.
267
+ *
268
+ * @public
269
+ */
270
+ export declare interface Options extends CommonOptions, DashboardParams {
271
+ /** Base URL where the LogScale cluster is accessed. */
272
+ apiURL: string;
273
+ /** Name of LogScale repository or view */
274
+ repoOrViewName: string;
275
+ /** If the LSP websocket server is accessed from a different URL than the `apiUrl`, you can set this. */
276
+ lspURL?: string;
277
+ /** If provided, this token will be passed in the Authentication header as a Bearer token.
278
+ * This can be a user's personal API token or an OICD token.
279
+ *
280
+ * This method of setting the authentication token is not recommended, since it exposes the authorization token to be read from JavaScript.
281
+ * Consider using a secure HTTP-only cookie instead.
282
+ */
283
+ authToken?: string;
284
+ /** If provided, HTTP calls will have the "X-CSRF-Token" header set to this value. */
285
+ csrfToken?: string;
286
+ /** Will initialize the webcomponent in light or dark mode. The theme can be switched through the `setTheme()` method after initialization. */
287
+ theme: 'light' | 'dark';
288
+ /** Language to start the webcomponent in. */
289
+ locale?: "jp" | "en";
290
+ /** Advanced feature: Set the language version to be used. This depends on the backend configuration and might crash if set inappropriately. */
291
+ languageVersion?: string;
292
+ /**
293
+ * Set a custom date time format to be used when formatting timestamps in Event list and Table widgets.
294
+ * See [documentation](https://library.humio.com/data-analysis/functions-formattime.html#query-function-formattime-formattime-format)
295
+ * to get more information.
296
+ *
297
+ * Defaults to `"%F %T.%L"`
298
+ */
299
+ dateTimeFormat?: string;
300
+ /**
301
+ * Set this to enable automatic links for showing events for groupBy fields.
302
+ * Default to `false`.
303
+ */
304
+ enableGroupEventInteractionInTable?: boolean;
305
+ /** Set a custom time zone. */
306
+ timezone?: TimeZone;
307
+ /**
308
+ * Set LogScale interactions to be available on widgets.
309
+ * See [interactions documentation](https://library.humio.com/data-analysis/dashboards-interactions.html) for more information.
310
+ *
311
+ * Note: `hostInteractions` can only be configured through the host application and will not be configurable through the
312
+ * interactions panel inside LogScale.
313
+ */
314
+ hostInteractions?: Array<Interaction>;
315
+ /**
316
+ * Hook for handling LogScale navigation targets, e.g. navigating from SearchView to Dashboard or vice versa.
317
+ *
318
+ * ### IMPORTANT
319
+ * #### If ommitted
320
+ * This component instance will essentially work in isolation. This means that:
321
+ * - Internal LogScale links to other views will not work.
322
+ * - Interactions with a target to another view type will be excluded.
323
+ *
324
+ * @param navigationTarget
325
+ */
326
+ onNavigationTargetChange?: (navigationTarget: NavigationTarget) => void;
327
+ /**
328
+ * Optional flag to show title bar on dashboards.
329
+ * Defaults to `false`.
330
+ * Note: this is necessary to allow editing of dashboards.
331
+ */
332
+ showTitleBar?: boolean;
333
+ }
334
+
335
+ /**
336
+ * A value for a visualization configuration option.
337
+ *
338
+ * @public
339
+ */
340
+ export declare type OptionValue = string | number | boolean | Array<OptionValue> | OptionValues;
341
+
342
+ /**
343
+ * Options for visualization configuration.
344
+ *
345
+ * @public
346
+ */
347
+ export declare type OptionValues = {
348
+ [key: string]: OptionValue;
349
+ };
350
+
351
+ /**
352
+ * LogScale parameter values is a map with parameter ids as keys,
353
+ * and either a string or a string array as single / multi value parameter args, respectively.
354
+ *
355
+ * @public
356
+ */
357
+ export declare type ParameterValues = Record<string, string | string[]>;
358
+
359
+ /**
360
+ * LogScale query.
361
+ *
362
+ * @public
363
+ */
364
+ export declare type Query = {
365
+ queryString: string;
366
+ /** Arguments for parameters in `query`. */
367
+ arguments?: {
368
+ [key: string]: string;
369
+ };
370
+ start: string;
371
+ end?: string;
372
+ isLive: boolean;
373
+ around?: QueryPaginationOptions;
374
+ };
375
+
376
+ /**
377
+ * Options to specify what events to include in a result for a query around an event.
378
+ *
379
+ * @public
380
+ */
381
+ export declare type QueryPaginationOptions = {
382
+ /** The id of the event to center query around. */
383
+ eventId: String;
384
+ /** Needs to match the @timestamp field value for the event matching `eventId`. */
385
+ timestamp: number;
386
+ /** The amound of events to query for before the event matching `eventId` */
387
+ numberOfEventsBefore: number;
388
+ /** The amound of events to query for after the event matching `eventId` */
389
+ numberOfEventsAfter: number;
390
+ };
391
+
392
+ /**
393
+ * Search Link interaction type.
394
+ * If `onNavigationTargetChange` hook is implemented, these interactions will
395
+ * trigger a navigation target change, triggering the `onNavigationTargetChange` hook
396
+ * passing a `SearchNavigationTarget` as the argument.
397
+ *
398
+ * @public
399
+ */
400
+ export declare type SearchLinkInteraction = {
401
+ type: "searchLink";
402
+ queryString: string;
403
+ repoOrViewName?: string | null;
404
+ arguments?: Record<string, string> | null;
405
+ openInNewTab?: boolean;
406
+ useWidgetTimeWindow?: boolean;
407
+ } & SharedInteractionProperties;
408
+
409
+ /**
410
+ * A NavigationTarget for LogScale Search view.
411
+ *
412
+ * @public
413
+ */
414
+ export declare type SearchNavigationTarget = {
415
+ type: "search";
416
+ targetInfo: SearchNavigationTargetInfo;
417
+ };
418
+
419
+ /**
420
+ * The Search state as set by the source of the NavigationTarget.
421
+ * This can be used to load a LogScale Search view in a specific state.
422
+ *
423
+ * @public
424
+ */
425
+ export declare type SearchNavigationTargetInfo = SearchViewParams & {
426
+ repoOrViewName: string;
427
+ timezone?: string;
428
+ };
429
+
430
+ /**
431
+ * Configuration of LogScale Search view.
432
+ * This also overlaps with `SearchNavigationTarget.targetInfo`.
433
+ * This means that `SearchViewParams` can be created from the targetInfo of a `SearchNavigationTarget`.
434
+ *
435
+ * @public
436
+ */
437
+ export declare interface SearchViewParams {
438
+ /** The query string set in the query editor. */
439
+ query?: string;
440
+ /** Start of time window used when querying. */
441
+ start?: string;
442
+ /** End of time window used when querying. */
443
+ end?: string;
444
+ /** Query for events around a certain event. */
445
+ around?: QueryPaginationOptions;
446
+ /** Set to `true` to execute query as live. Defaults to `false`. */
447
+ live?: boolean;
448
+ /**
449
+ * Set the visualisation to be used when visulising query result.
450
+ * If omitted a visualisation fitting the data in the query result will be used automatically.
451
+ */
452
+ visualization?: SearchViewVisualization;
453
+ /**
454
+ * Set LogScale interactions to be available on widgets.
455
+ * See [interactions documentation](https://library.humio.com/data-analysis/dashboards-interactions.html) for more information.
456
+ *
457
+ * Note: `dynamicInteractions` can be changed through the interaction panel inside LogScale, if enabled.
458
+ */
459
+ dynamicInteractions?: Array<Interaction>;
460
+ /**
461
+ * Set the Search view in an edit state, allowing editation of certain LogScale assets.
462
+ * This is primarily useful in conjunction with `NavigationTarget`, allowing a `NavigationTarget` to set an editState
463
+ * from a previous context.
464
+ */
465
+ editState?: EditState;
466
+ /** Arguments for parameters in `query`. */
467
+ parameterArgs?: {
468
+ [key: string]: string;
469
+ };
470
+ }
471
+
472
+ /**
473
+ * A LogScale widget with configuration.
474
+ *
475
+ * @public */
476
+ export declare type SearchViewVisualization = {
477
+ type?: WidgetType;
478
+ /** The configuration options of a LogScale visualization. */
479
+ options?: OptionValues;
480
+ };
481
+
482
+ /**
483
+ * Options to use when setting parameter args.
484
+ *
485
+ * @public
486
+ */
487
+ export declare type SetParametersOptions = {
488
+ /** Used to control whether parameters should be applied immediately. */
489
+ apply?: boolean;
490
+ };
491
+
492
+ /**
493
+ * The shared properties of all interaction types.
494
+ *
495
+ * @public
496
+ */
497
+ export declare type SharedInteractionProperties = {
498
+ name: string;
499
+ titleTemplate?: string | null;
500
+ conditions?: Array<InteractionCondition> | null;
501
+ };
502
+
503
+ /**
504
+ * `name` should be a timezone name in the format `<Continent>/<City>` (Ex: `Asia/Tokyo`).
505
+ * For timezones that are not relative to a continent, the first part is `Etc` (Ex: `Etc/GMT-3`).
506
+ *
507
+ * If the `name` is unknown to the component, then the `fallback` timezone is chosen.
508
+ *
509
+ * @public
510
+ */
511
+ export declare type TimeZone = {
512
+ name: string;
513
+ fallback: "GMT+0" | "GMT+1" | "GMT+2" | "GMT+3" | "GMT+4" | "GMT+5" | "GMT+6" | "GMT+7" | "GMT+8" | "GMT+9" | "GMT+10" | "GMT+11" | "GMT+12" | "GMT-1" | "GMT-2" | "GMT-3" | "GMT-4" | "GMT-5" | "GMT-6" | "GMT-7" | "GMT-8" | "GMT-9" | "GMT-10" | "GMT-11" | "GMT-12" | "GMT-13" | "GMT-14";
514
+ };
515
+
516
+ /**
517
+ * Update Parameters interaction type.
518
+ * If `onNavigationTargetChange` hook is implemented, these interactions will
519
+ * trigger a navigation target change, triggering the `onNavigationTargetChange` hook
520
+ * passing a `NavigationTarget` matching the LogScale component type as the argument,
521
+ * i.e. a `SearchNavigationTarget` when in Search view and a `DashboardNavigationTarget` when in Dashboard.
522
+ *
523
+ * @public
524
+ */
525
+ export declare type UpdateParametersInteraction = {
526
+ type: "updateParameters";
527
+ arguments?: Record<string, string> | null;
528
+ useWidgetTimeWindow?: boolean;
529
+ } & SharedInteractionProperties;
530
+
531
+ /** Base class for LogScale's webcomponents.
532
+ * @public */
533
+ export declare abstract class WebcomponentBase<Opts extends CommonOptions> extends HTMLElement {
534
+ /** Initializes the webcomponent with options.
535
+ *
536
+ * This should be called only once per webcomponent.
537
+ * You should not need to call this if you are using the `createElement` helper function.
538
+ * @public
539
+ */
540
+ init(options: Opts): void;
541
+ /** Set the UI theme to dark or light.
542
+ * @public */
543
+ setTheme(theme: "dark" | "light"): void;
544
+ }
545
+
546
+ /**
547
+ * LogScale widget types
548
+ *
549
+ * @public
550
+ */
551
+ export declare type WidgetType = "list-view" | "table-view" | "time-chart" | "pie-chart" | "bar-chart" | "scatter-chart" | "raw" | "world-map" | "sankey" | "heat-map" | "single-value" | "gauge";
552
+
553
+ export { }