spl2dql 0.1.0 → 0.1.1
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/dist/inputs.js +5 -2
- package/dist/main.js +2 -1
- package/dist/mapping.js +12 -13
- package/dist/safe-fs.d.ts +11 -0
- package/dist/safe-fs.js +33 -1
- package/dist/serve/server.js +13 -4
- package/package.json +4 -4
- package/web/THIRD-PARTY-NOTICES.txt +1 -1
- package/web/assets/{BatchView-CJw9TDhQ.js → BatchView-CIkOhHdk.js} +1 -1
- package/web/assets/{DashboardsView-gW0FEoq7.js → DashboardsView-CCo2UqSu.js} +1 -1
- package/web/assets/{DropZone-CIbk77sc.js → DropZone-Cm1HZT4A.js} +1 -1
- package/web/assets/{MappingView-Co21Vkp_.js → MappingView-Co7N_18o.js} +1 -1
- package/web/assets/{ReferenceView-S1R-kCt6.js → ReferenceView-BMehx7sH.js} +1 -1
- package/web/assets/{index-BO3AM1fZ.js → index-Dox0eScg.js} +4 -4
- package/web/assets/{mapping-text-B64_Oh2A.js → mapping-text-DAJ9FWwj.js} +1 -1
- package/web/assets/{translate.worker-C2M3Sf23.js → translate.worker-B0yZ5sFl.js} +1 -1
- package/web/index.html +1 -1
- package/web/sw.js +2 -2
package/dist/inputs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { lstatSync, readdirSync
|
|
1
|
+
import { lstatSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { basename, extname, join, relative, resolve, sep } from 'node:path';
|
|
3
3
|
import { configKind, InputError, parseCsvSearches, parseSavedSearches, safeFileName, } from '@spl2dql/core';
|
|
4
|
+
import { readRegularFile } from './safe-fs.js';
|
|
4
5
|
export { InputError, safeFileName };
|
|
5
6
|
const MAX_FILE = 10 * 1024 * 1024;
|
|
6
7
|
const MAX_FILES = 50_000;
|
|
@@ -82,7 +83,9 @@ export function readInputs(paths, cwd, maxTotalBytes = MAX_TOTAL_BYTES) {
|
|
|
82
83
|
}
|
|
83
84
|
let text;
|
|
84
85
|
try {
|
|
85
|
-
|
|
86
|
+
// Read through one handle, so a name that changed after the checks above cannot bring in a
|
|
87
|
+
// link's target or a larger file.
|
|
88
|
+
text = readRegularFile(path, MAX_FILE).toString('utf8');
|
|
86
89
|
}
|
|
87
90
|
catch (e) {
|
|
88
91
|
bytes -= st.size;
|
package/dist/main.js
CHANGED
|
@@ -8,7 +8,8 @@ import { loadMapping, loadMappingFile, MappingError, validateMapping } from './m
|
|
|
8
8
|
import { boardDetailSize, CONFIDENCE_WORD, detailSize, dropBoardDetail, dropDetail, htmlReport, jsonReport, reportBoard, reportResult, shown, summary, } from './report.js';
|
|
9
9
|
import { prepareOutDir, writeInside } from './safe-fs.js';
|
|
10
10
|
export const EXIT = { ok: 0, confidence: 1, usage: 2 };
|
|
11
|
-
|
|
11
|
+
/** Printed by --version. A test keeps it equal to the version in package.json. */
|
|
12
|
+
const VERSION = '0.1.1';
|
|
12
13
|
const MAX_STDIN = 10 * 1024 * 1024;
|
|
13
14
|
/** DQL one run may write, dashboards included (ADR-029). */
|
|
14
15
|
export const MAX_RUN_OUTPUT = 200 * 1024 * 1024;
|
package/dist/mapping.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { existsSync, lstatSync, readFileSync } from 'node:fs';
|
|
2
1
|
import { resolve } from 'node:path';
|
|
3
2
|
import { parseMappingConfig } from '@spl2dql/core';
|
|
4
3
|
import { parse as parseYaml } from 'yaml';
|
|
4
|
+
import { FileRefused, readRegularFile } from './safe-fs.js';
|
|
5
5
|
export class MappingError extends Error {
|
|
6
6
|
issues;
|
|
7
7
|
constructor(message, issues = []) {
|
|
@@ -34,23 +34,22 @@ export function parseMappingText(text, name) {
|
|
|
34
34
|
/** Loads --mapping, or spl2dql.mapping.yaml from the working directory when present. */
|
|
35
35
|
export function loadMappingFile(path, cwd) {
|
|
36
36
|
const file = path ? resolve(cwd, path) : resolve(cwd, DEFAULT_FILE);
|
|
37
|
-
|
|
38
|
-
return undefined;
|
|
39
|
-
let size;
|
|
37
|
+
let text;
|
|
40
38
|
try {
|
|
41
|
-
|
|
42
|
-
if (!st.isFile())
|
|
43
|
-
throw new MappingError(`${file} is not a regular file.`);
|
|
44
|
-
size = st.size;
|
|
39
|
+
text = readRegularFile(file, MAX_MAPPING).toString('utf8');
|
|
45
40
|
}
|
|
46
41
|
catch (e) {
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
// The default file is optional; one that was named has to be there.
|
|
43
|
+
if (!path && e.code === 'ENOENT')
|
|
44
|
+
return undefined;
|
|
45
|
+
if (e instanceof FileRefused)
|
|
46
|
+
throw new MappingError(e.reason === 'too large' ? `${file} is larger than 5 MB.` : `${file} is not a regular file.`);
|
|
47
|
+
// A symbolic link is not followed: ELOOP on Linux and macOS.
|
|
48
|
+
if (e.code === 'ELOOP')
|
|
49
|
+
throw new MappingError(`${file} is not a regular file.`);
|
|
49
50
|
throw new MappingError(`Cannot read the mapping file ${file}.`);
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
throw new MappingError(`${file} is larger than 5 MB.`);
|
|
53
|
-
const data = readMappingText(readFileSync(file, 'utf8'), file);
|
|
52
|
+
const data = readMappingText(text, file);
|
|
54
53
|
const mapping = validateMapping(data, file);
|
|
55
54
|
return { file, data: data, mapping };
|
|
56
55
|
}
|
package/dist/safe-fs.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/** Why `readRegularFile` refused a file that could be opened. */
|
|
2
|
+
export declare class FileRefused extends Error {
|
|
3
|
+
readonly reason: 'not a regular file' | 'too large';
|
|
4
|
+
constructor(reason: 'not a regular file' | 'too large');
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Reads a file through one open handle: the file that is checked (a regular file of at most
|
|
8
|
+
* `maxBytes`) is the file that is read, whatever happens to the name in the meantime. A symbolic
|
|
9
|
+
* link at `path` is not followed. Throws `FileRefused`, or the system's error when it cannot open.
|
|
10
|
+
*/
|
|
11
|
+
export declare function readRegularFile(path: string, maxBytes: number): Buffer;
|
|
1
12
|
/** Creates the output directory (and parents) and returns its real path. */
|
|
2
13
|
export declare function prepareOutDir(dir: string): string;
|
|
3
14
|
/**
|
package/dist/safe-fs.js
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
|
-
import { closeSync, constants, existsSync, fstatSync, lstatSync, mkdirSync, openSync, realpathSync, unlinkSync, writeSync } from 'node:fs';
|
|
1
|
+
import { closeSync, constants, existsSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, unlinkSync, writeSync } from 'node:fs';
|
|
2
2
|
import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
3
|
+
/** Why `readRegularFile` refused a file that could be opened. */
|
|
4
|
+
export class FileRefused extends Error {
|
|
5
|
+
reason;
|
|
6
|
+
constructor(reason) {
|
|
7
|
+
super(reason);
|
|
8
|
+
this.reason = reason;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Reads a file through one open handle: the file that is checked (a regular file of at most
|
|
13
|
+
* `maxBytes`) is the file that is read, whatever happens to the name in the meantime. A symbolic
|
|
14
|
+
* link at `path` is not followed. Throws `FileRefused`, or the system's error when it cannot open.
|
|
15
|
+
*/
|
|
16
|
+
export function readRegularFile(path, maxBytes) {
|
|
17
|
+
// O_NONBLOCK: opening a pipe that somebody put at this name must not wait for a writer.
|
|
18
|
+
const fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
19
|
+
try {
|
|
20
|
+
const st = fstatSync(fd);
|
|
21
|
+
if (!st.isFile())
|
|
22
|
+
throw new FileRefused('not a regular file');
|
|
23
|
+
if (st.size > maxBytes)
|
|
24
|
+
throw new FileRefused('too large');
|
|
25
|
+
const data = readFileSync(fd);
|
|
26
|
+
// The file can grow between the size check and the end of the read.
|
|
27
|
+
if (data.length > maxBytes)
|
|
28
|
+
throw new FileRefused('too large');
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
closeSync(fd);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
3
35
|
/** Creates the output directory (and parents) and returns its real path. */
|
|
4
36
|
export function prepareOutDir(dir) {
|
|
5
37
|
mkdirSync(dir, { recursive: true });
|
package/dist/serve/server.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { existsSync, readdirSync, readFileSync
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { createServer } from 'node:http';
|
|
3
3
|
import { extname, join, relative, sep } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { readRegularFile } from '../safe-fs.js';
|
|
5
6
|
export class ServeError extends Error {
|
|
6
7
|
}
|
|
7
8
|
const LOOPBACK = new Set(['127.0.0.1', '::1', 'localhost']);
|
|
@@ -165,7 +166,8 @@ export async function startServer(options) {
|
|
|
165
166
|
};
|
|
166
167
|
}
|
|
167
168
|
const FALLBACK_PAGE = `<!doctype html><html lang="en"><head><meta charset="utf-8"><title>spl2dql</title></head><body><p>The web app is not built. Run <code>pnpm build</code> in the repository.</p></body></html>`;
|
|
168
|
-
|
|
169
|
+
const MAX_STATIC_FILE = 20_000_000 - 1;
|
|
170
|
+
/** Reads the built web app once. Symbolic links, unknown file types and files of 20 MB or more are skipped. */
|
|
169
171
|
function loadStatic(dir) {
|
|
170
172
|
const out = new Map();
|
|
171
173
|
if (!existsSync(dir)) {
|
|
@@ -179,11 +181,18 @@ function loadStatic(dir) {
|
|
|
179
181
|
continue;
|
|
180
182
|
if (entry.isDirectory())
|
|
181
183
|
walk(full);
|
|
182
|
-
else if (entry.isFile()
|
|
184
|
+
else if (entry.isFile()) {
|
|
183
185
|
const type = MIME[extname(entry.name).toLowerCase()];
|
|
184
186
|
if (!type)
|
|
185
187
|
continue;
|
|
186
|
-
|
|
188
|
+
let body;
|
|
189
|
+
try {
|
|
190
|
+
body = readRegularFile(full, MAX_STATIC_FILE);
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
continue; // too large, or no longer a regular file
|
|
194
|
+
}
|
|
195
|
+
out.set(`/${relative(dir, full).split(sep).join('/')}`, { body, type });
|
|
187
196
|
}
|
|
188
197
|
}
|
|
189
198
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spl2dql",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Move a Splunk app to Dynatrace: SPL searches to DQL queries, dashboards to Dynatrace dashboards — offline, from the terminal.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"node": ">=24"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@spl2dql/core": "0.1.
|
|
53
|
-
"commander": "^15.
|
|
52
|
+
"@spl2dql/core": "0.1.1",
|
|
53
|
+
"commander": "^15.1.0",
|
|
54
54
|
"yaml": "^2.9.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@spl2dql/web": "0.1.
|
|
57
|
+
"@spl2dql/web": "0.1.1"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
@@ -511,7 +511,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
511
511
|
SOFTWARE.
|
|
512
512
|
|
|
513
513
|
------------------------------------------------------------------------------
|
|
514
|
-
lucide-react 1.
|
|
514
|
+
lucide-react 1.71.0
|
|
515
515
|
Licence: ISC
|
|
516
516
|
Source: https://github.com/lucide-icons/lucide
|
|
517
517
|
------------------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,a as t,c as n,f as r,i,m as a,r as o,t as s}from"./index-
|
|
1
|
+
import{C as e,a as t,c as n,f as r,i,m as a,r as o,t as s}from"./index-Dox0eScg.js";import{a as c,n as l,t as u}from"./DropZone-Cm1HZT4A.js";import{a as d,n as f,t as p}from"./jsx-runtime-Wy9s6hX0.js";var m=d(f(),1),h=p();function g(e){let t=[];return e.disabled&&t.push(`Switched off in Splunk`),(e.earliest!==void 0||e.latest!==void 0)&&t.push(`${e.earliest??`…`} to ${e.latest??`now`}`),e.schedule!==void 0&&t.push(`runs ${e.schedule}`),t.join(` · `)}var _={high:`mark-exact`,review:`mark-check`,low:`mark-untranslated`,none:`mark-untranslated`},v={high:`●`,review:`▲`,low:`■`,none:`■`},y=[`none`,`low`,`review`,`high`];function b(){let d=a(e=>e.batch),f=a(e=>e.setSpl),p=a(e=>e.setView),[b,x]=(0,m.useState)(`all`),S=(0,m.useMemo)(()=>d.filter(e=>b===`all`||e.result.confidence===b).sort((e,t)=>y.indexOf(e.result.confidence)-y.indexOf(t.result.confidence)||(e.name<t.name?-1:1)),[d,b]),C=()=>{let t=new Set([`report.json`]),n={},r=new TextEncoder,i=d.map(i=>{let a=`${e(i.name,t)}.dql`;return n[a]=r.encode(`${i.result.dql}\n`),{name:i.name,origin:i.origin,file:a,confidence:i.result.confidence,...i.earliest===void 0?{}:{earliest:i.earliest},...i.latest===void 0?{}:{latest:i.latest},...i.schedule===void 0?{}:{schedule:i.schedule},...i.disabled?{disabled:!0}:{},spl:i.spl,dql:i.result.dql,notes:i.result.diagnostics}});n[`report.json`]=r.encode(`${JSON.stringify({searches:i},null,2)}\n`);let a=new Blob([s(n)],{type:`application/zip`}),o=document.createElement(`a`);o.href=URL.createObjectURL(a),o.download=`spl2dql-results.zip`,o.click(),setTimeout(()=>URL.revokeObjectURL(o.href),1e3)},w=(0,m.useMemo)(()=>{let e={high:0,review:0,low:0,none:0};for(let t of d)e[t.result.confidence]++;return e},[d]);return(0,h.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,h.jsxs)(`div`,{className:`mx-auto max-w-5xl px-4 py-6`,children:[(0,h.jsx)(u,{title:`Drop saved searches here`,compact:d.length>0,sample:d.length===0,children:(0,h.jsx)(`p`,{children:`.spl and .txt files (one search each), savedsearches.conf with each search's saved time range, CSV files with a "search" column — or a whole Splunk app folder. macros.conf, props.conf, eventtypes.conf and tags.conf in the same drop are read into the mapping first. Files are read in this browser and never uploaded.`})}),(0,h.jsx)(l,{here:`batch`}),d.length>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-3`,children:[(0,h.jsxs)(`p`,{className:`text-sm`,children:[d.length,` searches: `,w.high,` exact, `,w.review,` need review, `,w.low,` incomplete, `,w.none,` not translated`]}),(0,h.jsxs)(`label`,{className:`ml-auto flex items-center gap-2 text-sm`,children:[`Show`,(0,h.jsxs)(`select`,{className:`field`,value:b,onChange:e=>x(e.target.value),children:[(0,h.jsx)(`option`,{value:`all`,children:`All`}),y.map(e=>(0,h.jsx)(`option`,{value:e,children:n[e]},e))]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`control primary`,onClick:C,children:[(0,h.jsx)(c,{size:16,"aria-hidden":!0}),`Download results`]})]}),(0,h.jsxs)(`table`,{className:`mt-3 w-full border-collapse bg-surface text-sm`,"data-testid":`batch-table`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`text-left`,children:[(0,h.jsx)(`th`,{className:`border-b border-line px-3 py-2`,children:`Search`}),(0,h.jsx)(`th`,{className:`border-b border-line px-3 py-2`,children:`Confidence`}),(0,h.jsx)(`th`,{className:`hidden border-b border-line px-3 py-2 min-[600px]:table-cell`,children:`Notes`}),(0,h.jsx)(`th`,{className:`border-b border-line px-3 py-2`,children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,h.jsx)(`tbody`,{children:t(S,o.batch).map(e=>(0,h.jsxs)(`tr`,{children:[(0,h.jsxs)(`td`,{className:`border-b border-line px-3 py-2 [overflow-wrap:anywhere]`,children:[e.name,(0,h.jsx)(`span`,{className:`block text-xs text-muted`,children:e.origin}),g(e)!==``&&(0,h.jsx)(`span`,{className:`block text-xs text-muted`,children:g(e)})]}),(0,h.jsxs)(`td`,{className:`border-b border-line px-3 py-2 min-[600px]:whitespace-nowrap`,children:[(0,h.jsxs)(`span`,{className:_[e.result.confidence],"aria-hidden":`true`,children:[v[e.result.confidence],` `]}),n[e.result.confidence]]}),(0,h.jsx)(`td`,{className:`hidden border-b border-line px-3 py-2 min-[600px]:table-cell`,children:r(e.result.diagnostics)}),(0,h.jsx)(`td`,{className:`border-b border-line px-3 py-2 text-right`,children:(0,h.jsx)(`button`,{type:`button`,className:`control`,onClick:()=>{f(e.spl),p(`translate`)},children:`Open`})})]},e.origin))})]}),(0,h.jsx)(i,{total:S.length,limit:o.batch,noun:S.length===1?`search`:`searches`,download:!0,className:`mt-3`})]})]})})}export{b as BatchView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,a as t,d as n,i as r,l as i,m as a,o,p as s,r as c,s as l,t as u,u as d}from"./index-BO3AM1fZ.js";import{a as f,n as p,t as m}from"./DropZone-CIbk77sc.js";import{a as h,n as g,t as _}from"./jsx-runtime-Wy9s6hX0.js";var v={name:`chart-area`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z`,key:`q0gr47`}]],aliases:[`area-chart`]};v.node;var y=l(v),b={name:`chart-bar`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M7 16h8`,key:`srdodz`}],[`path`,{d:`M7 11h12`,key:`127s9w`}],[`path`,{d:`M7 6h3`,key:`w9rmul`}]],aliases:[`bar-chart-horizontal`]};b.node;var x=l(b),S={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};S.node;var C=l(S),w={name:`chart-line`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`m19 9-5 5-4-4-3 3`,key:`2osh9i`}]],aliases:[`line-chart`]};w.node;var T=l(w),E={name:`chart-pie`,size:24,node:[[`path`,{d:`M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]],aliases:[`pie-chart`]};E.node;var D=l(E),O={name:`chart-scatter`,size:24,node:[[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}],[`circle`,{cx:`18.5`,cy:`5.5`,r:`.5`,fill:`currentColor`,key:`lysivs`}],[`circle`,{cx:`11.5`,cy:`11.5`,r:`.5`,fill:`currentColor`,key:`byv1b8`}],[`circle`,{cx:`7.5`,cy:`16.5`,r:`.5`,fill:`currentColor`,key:`nkw3mc`}],[`circle`,{cx:`17.5`,cy:`14.5`,r:`.5`,fill:`currentColor`,key:`1gjh6j`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}]],aliases:[`scatter-chart`]};O.node;var k=l(O),A={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};A.node;var j=l(A),M={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};M.node;var N=l(M),P={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};P.node;var F=l(P),I={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};I.node;var L=l(I),R={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};R.node;var z=l(R),B=h(g(),1),V=_(),H={lineChart:T,areaChart:y,barChart:C,categoricalBarChart:x,pieChart:D,scatterplot:k,gauge:N,singleValue:F,table:L};function U(e){return e.outcome===`manual`?z:e.outcome===`text`?j:H[e.visualization??``]??L}function W(e,t,n){let r=document.createElement(`a`);r.href=URL.createObjectURL(new Blob([t],{type:n})),r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(r.href),1e3)}function G(t,n){return`${e(t.conversion.title,n)}.json`}function K(){let e=a(e=>e.dashboards),[n,i]=(0,B.useState)(0),[o,s]=(0,B.useState)(),l=e[Math.min(n,e.length-1)];return(0,B.useEffect)(()=>{i(0)},[e]),(0,B.useEffect)(()=>{let e=l?.conversion.tiles??[];s((e.find(e=>e.outcome===`manual`)??e.find(e=>e.outcome===`live`)??e[0])?.id)},[l]),(0,V.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,V.jsxs)(`div`,{className:`mx-auto max-w-6xl px-4 py-6`,children:[(0,V.jsxs)(m,{title:`Drop Splunk dashboards here`,compact:e.length>0,sample:e.length===0,children:[(0,V.jsx)(`p`,{children:`Simple XML and Dashboard Studio files, or a whole Splunk app folder. A panel becomes a live tile only when its search translated completely; otherwise the tile keeps the Splunk search and says what is missing. Inputs become dashboard variables.`}),e.length===0&&(0,V.jsx)(`p`,{className:`mt-2`,children:`Add savedsearches.conf and macros.conf from the same app so panels that use them resolve. Files are read in this browser and never uploaded.`})]}),(0,V.jsx)(p,{here:`dashboards`}),l&&(0,V.jsxs)(`div`,{className:`mt-6 grid gap-6 min-[900px]:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,V.jsxs)(`nav`,{"aria-label":`Converted dashboards`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsxs)(`h2`,{className:`whitespace-nowrap text-sm font-semibold`,children:[e.length,` dashboard`,e.length===1?``:`s`]}),e.length>1&&(0,V.jsxs)(`button`,{type:`button`,className:`control ml-auto`,onClick:()=>{let t=new Set,n={},r=new TextEncoder;for(let i of e)n[G(i,t)]=r.encode(`${JSON.stringify(i.conversion.dashboard,null,2)}\n`);W(`spl2dql-dashboards.zip`,u(n),`application/zip`)},children:[(0,V.jsx)(f,{size:16,"aria-hidden":!0}),`Download all`]})]}),(0,V.jsx)(`ul`,{className:`mt-2 flex gap-1 overflow-x-auto min-[900px]:flex-col min-[900px]:overflow-visible`,"data-testid":`dashboard-list`,children:t(e,c.dashboards).map((e,t)=>{let n=e.conversion.counts;return(0,V.jsx)(`li`,{className:`shrink-0`,children:(0,V.jsxs)(`button`,{type:`button`,className:`w-full border px-3 py-2 text-left text-sm ${e===l?`border-exact bg-surface`:`border-transparent hover:border-line`}`,"aria-current":e===l?`true`:void 0,onClick:()=>i(t),children:[(0,V.jsx)(`span`,{className:`block font-semibold`,children:e.conversion.title}),(0,V.jsxs)(`span`,{className:`block text-xs text-muted`,children:[(0,V.jsx)(`span`,{className:`mark-exact`,"aria-hidden":`true`,children:`●`}),` `,n.live,` converted`,n.manual>0&&(0,V.jsxs)(V.Fragment,{children:[` `,(0,V.jsx)(`span`,{className:`mark-untranslated`,"aria-hidden":`true`,children:`■`}),` `,n.manual,` manual`]})]})]})},e.origin)})}),(0,V.jsx)(r,{total:e.length,limit:c.dashboards,noun:`dashboards`,download:!0,className:`mt-2`})]}),(0,V.jsx)(q,{row:l,tileId:o,onTile:s})]})]})})}function q(e){let{conversion:a}=e.row,o=a.counts,l=a.tiles.find(t=>t.id===e.tileId),u=a.dashboard.content.layouts,p=G(e.row,new Set);return(0,V.jsxs)(`section`,{"aria-label":a.title,className:`min-w-0`,"data-testid":`dashboard-detail`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold`,children:a.title}),(0,V.jsxs)(`p`,{className:`text-sm`,"data-testid":`dashboard-counts`,children:[o.live,` converted · `,o.manual,` need manual work · `,o.text,` text · `,a.variables.length,` variable`,a.variables.length===1?``:`s`]})]}),(0,V.jsxs)(`button`,{type:`button`,className:`control primary ml-auto`,onClick:()=>W(p,`${JSON.stringify(a.dashboard,null,2)}\n`,`application/json`),children:[(0,V.jsx)(f,{size:16,"aria-hidden":!0}),`Download dashboard`]})]}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-muted`,children:[`Import `,(0,V.jsx)(`span`,{className:`font-code`,children:p}),` in the Dynatrace Dashboards app, or run `,(0,V.jsxs)(`span`,{className:`font-code`,children:[`dtctl apply -f `,p]})]}),(0,V.jsx)(`ul`,{className:`tile-grid mt-4`,"aria-label":`Tiles, laid out as in the converted dashboard`,"data-testid":`tile-grid`,children:t(a.tiles,c.tiles).map(t=>{let r=u[t.id];if(!r)return null;let a=s(t),o=U(t);return(0,V.jsx)(`li`,{style:{gridColumn:`${r.x+1} / span ${r.w}`,gridRow:`${r.y+1} / span ${r.h}`},className:`min-h-0 min-w-0`,children:(0,V.jsxs)(`button`,{type:`button`,className:`tile ${t.id===e.tileId?`selected`:``}`,"aria-pressed":t.id===e.tileId,onClick:()=>e.onTile(t.id),children:[(0,V.jsxs)(`span`,{className:`block truncate font-semibold`,children:[(0,V.jsxs)(`span`,{className:i[a],"aria-hidden":`true`,children:[d[a],` `]}),t.title||`Untitled`]}),r.h>1?(0,V.jsxs)(`span`,{className:`block truncate text-muted`,children:[n[a],t.visualization?` · ${t.visualization}`:``]}):(0,V.jsx)(`span`,{className:`sr-only`,children:n[a]}),r.h>=4&&(0,V.jsx)(`span`,{className:`tile-figure`,"aria-hidden":`true`,children:(0,V.jsx)(o,{size:28,strokeWidth:1.5})})]})},t.id)})}),(0,V.jsx)(r,{total:a.tiles.length,limit:c.tiles,noun:`tiles`,download:!0,className:`mt-2`}),l&&(0,V.jsx)(X,{tile:l}),a.variables.length>0&&(0,V.jsxs)(`div`,{className:`mt-6`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Variables`}),(0,V.jsx)(`ul`,{className:`mt-2 border-t border-line bg-surface text-sm`,"data-testid":`variables`,children:t(a.variables,c.list).map(e=>(0,V.jsxs)(`li`,{className:`border-b border-line px-3 py-2`,children:[(0,V.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,V.jsxs)(`span`,{className:`font-code font-semibold`,children:[`$`,e.key]}),(0,V.jsx)(`span`,{children:J[e.type]}),(0,V.jsxs)(`span`,{className:`text-muted`,children:[`replaces `,(0,V.jsxs)(`span`,{className:`font-code`,children:[`$`,e.token,`$`]})]})]}),e.notes.length>0&&(0,V.jsx)(`div`,{className:`mt-1`,children:(0,V.jsx)(Y,{notes:e.notes})})]},e.key))}),(0,V.jsx)(r,{total:a.variables.length,limit:c.list,noun:`variables`,download:!0,className:`mt-2`})]}),a.notes.length>0&&(0,V.jsxs)(`div`,{className:`mt-6`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Left out of this dashboard`}),(0,V.jsx)(`div`,{className:`mt-1 text-sm`,children:(0,V.jsx)(Y,{notes:a.notes})})]})]})}var J={query:`Filled by a query`,csv:`Fixed list`,text:`Free text`};function Y(e){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`ul`,{className:`space-y-1`,children:t(e.notes,c.list).map(t=>(0,V.jsxs)(`li`,{className:`flex gap-2`,children:[(0,V.jsx)(`span`,{className:e.blocking?`mark-untranslated`:`mark-check`,"aria-hidden":`true`,children:e.blocking?`■`:`▲`}),(0,V.jsx)(`span`,{children:t})]},t))}),(0,V.jsx)(r,{total:e.notes.length,limit:c.list,noun:`notes`,className:`mt-1`})]})}function X(e){let{tile:t}=e,r=a(e=>e.setSpl),c=a(e=>e.setView),[l,u]=(0,B.useState)(!1),f=s(t),p=t.result?.dql??``,m=async()=>{try{await navigator.clipboard.writeText(p),u(!0),setTimeout(()=>u(!1),1500)}catch{}};return(0,V.jsxs)(`div`,{className:`mt-4 border border-line bg-surface p-4`,"data-testid":`tile-detail`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`h3`,{className:`font-semibold`,children:t.title||`Untitled`}),(0,V.jsxs)(`span`,{className:`text-sm`,children:[(0,V.jsxs)(`span`,{className:i[f],"aria-hidden":`true`,children:[d[f],` `]}),n[f],t.visualization?` · shown as ${t.visualization}`:``]}),t.spl!==void 0&&(0,V.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-2`,children:[t.outcome===`live`&&(0,V.jsxs)(`button`,{type:`button`,className:`control`,onClick:()=>void m(),children:[(0,V.jsx)(o,{size:16,"aria-hidden":!0}),l?`Copied`:`Copy DQL`]}),(0,V.jsx)(`button`,{type:`button`,className:`control`,onClick:()=>{r(t.spl??``),c(`translate`)},children:`Open in Translate`})]})]}),t.spl!==void 0&&(0,V.jsxs)(`div`,{className:`mt-3 grid gap-4 min-[760px]:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h4`,{className:`text-xs font-semibold text-muted`,children:`Splunk SPL`}),(0,V.jsx)(`pre`,{className:`code-block`,children:t.spl})]}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h4`,{className:`text-xs font-semibold text-muted`,children:t.outcome===`live`?`Dynatrace DQL`:`DQL so far`}),(0,V.jsx)(`pre`,{className:`code-block`,children:p===``?`Nothing could be translated.`:p})]})]}),t.notes.length>0&&(0,V.jsxs)(`div`,{className:`mt-3 text-sm`,children:[(0,V.jsx)(`h4`,{className:`text-xs font-semibold text-muted`,children:t.outcome===`manual`?`What is missing`:`To check`}),(0,V.jsx)(`div`,{className:`mt-1`,children:(0,V.jsx)(Y,{notes:t.notes,blocking:t.outcome===`manual`})})]}),t.outcome===`text`&&t.notes.length===0&&(0,V.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:`A text panel, carried over as a Markdown tile.`})]})}export{K as DashboardsView};
|
|
1
|
+
import{C as e,a as t,d as n,i as r,l as i,m as a,o,p as s,r as c,s as l,t as u,u as d}from"./index-Dox0eScg.js";import{a as f,n as p,t as m}from"./DropZone-Cm1HZT4A.js";import{a as h,n as g,t as _}from"./jsx-runtime-Wy9s6hX0.js";var v={name:`chart-area`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z`,key:`q0gr47`}]],aliases:[`area-chart`]};v.node;var y=l(v),b={name:`chart-bar`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M7 16h8`,key:`srdodz`}],[`path`,{d:`M7 11h12`,key:`127s9w`}],[`path`,{d:`M7 6h3`,key:`w9rmul`}]],aliases:[`bar-chart-horizontal`]};b.node;var x=l(b),S={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};S.node;var C=l(S),w={name:`chart-line`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`m19 9-5 5-4-4-3 3`,key:`2osh9i`}]],aliases:[`line-chart`]};w.node;var T=l(w),E={name:`chart-pie`,size:24,node:[[`path`,{d:`M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]],aliases:[`pie-chart`]};E.node;var D=l(E),O={name:`chart-scatter`,size:24,node:[[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}],[`circle`,{cx:`18.5`,cy:`5.5`,r:`.5`,fill:`currentColor`,key:`lysivs`}],[`circle`,{cx:`11.5`,cy:`11.5`,r:`.5`,fill:`currentColor`,key:`byv1b8`}],[`circle`,{cx:`7.5`,cy:`16.5`,r:`.5`,fill:`currentColor`,key:`nkw3mc`}],[`circle`,{cx:`17.5`,cy:`14.5`,r:`.5`,fill:`currentColor`,key:`1gjh6j`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}]],aliases:[`scatter-chart`]};O.node;var k=l(O),A={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};A.node;var j=l(A),M={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};M.node;var N=l(M),P={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};P.node;var F=l(P),I={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};I.node;var L=l(I),R={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};R.node;var z=l(R),B=h(g(),1),V=_(),H={lineChart:T,areaChart:y,barChart:C,categoricalBarChart:x,pieChart:D,scatterplot:k,gauge:N,singleValue:F,table:L};function U(e){return e.outcome===`manual`?z:e.outcome===`text`?j:H[e.visualization??``]??L}function W(e,t,n){let r=document.createElement(`a`);r.href=URL.createObjectURL(new Blob([t],{type:n})),r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(r.href),1e3)}function G(t,n){return`${e(t.conversion.title,n)}.json`}function K(){let e=a(e=>e.dashboards),[n,i]=(0,B.useState)(0),[o,s]=(0,B.useState)(),l=e[Math.min(n,e.length-1)];return(0,B.useEffect)(()=>{i(0)},[e]),(0,B.useEffect)(()=>{let e=l?.conversion.tiles??[];s((e.find(e=>e.outcome===`manual`)??e.find(e=>e.outcome===`live`)??e[0])?.id)},[l]),(0,V.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,V.jsxs)(`div`,{className:`mx-auto max-w-6xl px-4 py-6`,children:[(0,V.jsxs)(m,{title:`Drop Splunk dashboards here`,compact:e.length>0,sample:e.length===0,children:[(0,V.jsx)(`p`,{children:`Simple XML and Dashboard Studio files, or a whole Splunk app folder. A panel becomes a live tile only when its search translated completely; otherwise the tile keeps the Splunk search and says what is missing. Inputs become dashboard variables.`}),e.length===0&&(0,V.jsx)(`p`,{className:`mt-2`,children:`Add savedsearches.conf and macros.conf from the same app so panels that use them resolve. Files are read in this browser and never uploaded.`})]}),(0,V.jsx)(p,{here:`dashboards`}),l&&(0,V.jsxs)(`div`,{className:`mt-6 grid gap-6 min-[900px]:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,V.jsxs)(`nav`,{"aria-label":`Converted dashboards`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsxs)(`h2`,{className:`whitespace-nowrap text-sm font-semibold`,children:[e.length,` dashboard`,e.length===1?``:`s`]}),e.length>1&&(0,V.jsxs)(`button`,{type:`button`,className:`control ml-auto`,onClick:()=>{let t=new Set,n={},r=new TextEncoder;for(let i of e)n[G(i,t)]=r.encode(`${JSON.stringify(i.conversion.dashboard,null,2)}\n`);W(`spl2dql-dashboards.zip`,u(n),`application/zip`)},children:[(0,V.jsx)(f,{size:16,"aria-hidden":!0}),`Download all`]})]}),(0,V.jsx)(`ul`,{className:`mt-2 flex gap-1 overflow-x-auto min-[900px]:flex-col min-[900px]:overflow-visible`,"data-testid":`dashboard-list`,children:t(e,c.dashboards).map((e,t)=>{let n=e.conversion.counts;return(0,V.jsx)(`li`,{className:`shrink-0`,children:(0,V.jsxs)(`button`,{type:`button`,className:`w-full border px-3 py-2 text-left text-sm ${e===l?`border-exact bg-surface`:`border-transparent hover:border-line`}`,"aria-current":e===l?`true`:void 0,onClick:()=>i(t),children:[(0,V.jsx)(`span`,{className:`block font-semibold`,children:e.conversion.title}),(0,V.jsxs)(`span`,{className:`block text-xs text-muted`,children:[(0,V.jsx)(`span`,{className:`mark-exact`,"aria-hidden":`true`,children:`●`}),` `,n.live,` converted`,n.manual>0&&(0,V.jsxs)(V.Fragment,{children:[` `,(0,V.jsx)(`span`,{className:`mark-untranslated`,"aria-hidden":`true`,children:`■`}),` `,n.manual,` manual`]})]})]})},e.origin)})}),(0,V.jsx)(r,{total:e.length,limit:c.dashboards,noun:`dashboards`,download:!0,className:`mt-2`})]}),(0,V.jsx)(q,{row:l,tileId:o,onTile:s})]})]})})}function q(e){let{conversion:a}=e.row,o=a.counts,l=a.tiles.find(t=>t.id===e.tileId),u=a.dashboard.content.layouts,p=G(e.row,new Set);return(0,V.jsxs)(`section`,{"aria-label":a.title,className:`min-w-0`,"data-testid":`dashboard-detail`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold`,children:a.title}),(0,V.jsxs)(`p`,{className:`text-sm`,"data-testid":`dashboard-counts`,children:[o.live,` converted · `,o.manual,` need manual work · `,o.text,` text · `,a.variables.length,` variable`,a.variables.length===1?``:`s`]})]}),(0,V.jsxs)(`button`,{type:`button`,className:`control primary ml-auto`,onClick:()=>W(p,`${JSON.stringify(a.dashboard,null,2)}\n`,`application/json`),children:[(0,V.jsx)(f,{size:16,"aria-hidden":!0}),`Download dashboard`]})]}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-muted`,children:[`Import `,(0,V.jsx)(`span`,{className:`font-code`,children:p}),` in the Dynatrace Dashboards app, or run `,(0,V.jsxs)(`span`,{className:`font-code`,children:[`dtctl apply -f `,p]})]}),(0,V.jsx)(`ul`,{className:`tile-grid mt-4`,"aria-label":`Tiles, laid out as in the converted dashboard`,"data-testid":`tile-grid`,children:t(a.tiles,c.tiles).map(t=>{let r=u[t.id];if(!r)return null;let a=s(t),o=U(t);return(0,V.jsx)(`li`,{style:{gridColumn:`${r.x+1} / span ${r.w}`,gridRow:`${r.y+1} / span ${r.h}`},className:`min-h-0 min-w-0`,children:(0,V.jsxs)(`button`,{type:`button`,className:`tile ${t.id===e.tileId?`selected`:``}`,"aria-pressed":t.id===e.tileId,onClick:()=>e.onTile(t.id),children:[(0,V.jsxs)(`span`,{className:`block truncate font-semibold`,children:[(0,V.jsxs)(`span`,{className:i[a],"aria-hidden":`true`,children:[d[a],` `]}),t.title||`Untitled`]}),r.h>1?(0,V.jsxs)(`span`,{className:`block truncate text-muted`,children:[n[a],t.visualization?` · ${t.visualization}`:``]}):(0,V.jsx)(`span`,{className:`sr-only`,children:n[a]}),r.h>=4&&(0,V.jsx)(`span`,{className:`tile-figure`,"aria-hidden":`true`,children:(0,V.jsx)(o,{size:28,strokeWidth:1.5})})]})},t.id)})}),(0,V.jsx)(r,{total:a.tiles.length,limit:c.tiles,noun:`tiles`,download:!0,className:`mt-2`}),l&&(0,V.jsx)(X,{tile:l}),a.variables.length>0&&(0,V.jsxs)(`div`,{className:`mt-6`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Variables`}),(0,V.jsx)(`ul`,{className:`mt-2 border-t border-line bg-surface text-sm`,"data-testid":`variables`,children:t(a.variables,c.list).map(e=>(0,V.jsxs)(`li`,{className:`border-b border-line px-3 py-2`,children:[(0,V.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,V.jsxs)(`span`,{className:`font-code font-semibold`,children:[`$`,e.key]}),(0,V.jsx)(`span`,{children:J[e.type]}),(0,V.jsxs)(`span`,{className:`text-muted`,children:[`replaces `,(0,V.jsxs)(`span`,{className:`font-code`,children:[`$`,e.token,`$`]})]})]}),e.notes.length>0&&(0,V.jsx)(`div`,{className:`mt-1`,children:(0,V.jsx)(Y,{notes:e.notes})})]},e.key))}),(0,V.jsx)(r,{total:a.variables.length,limit:c.list,noun:`variables`,download:!0,className:`mt-2`})]}),a.notes.length>0&&(0,V.jsxs)(`div`,{className:`mt-6`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Left out of this dashboard`}),(0,V.jsx)(`div`,{className:`mt-1 text-sm`,children:(0,V.jsx)(Y,{notes:a.notes})})]})]})}var J={query:`Filled by a query`,csv:`Fixed list`,text:`Free text`};function Y(e){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`ul`,{className:`space-y-1`,children:t(e.notes,c.list).map(t=>(0,V.jsxs)(`li`,{className:`flex gap-2`,children:[(0,V.jsx)(`span`,{className:e.blocking?`mark-untranslated`:`mark-check`,"aria-hidden":`true`,children:e.blocking?`■`:`▲`}),(0,V.jsx)(`span`,{children:t})]},t))}),(0,V.jsx)(r,{total:e.notes.length,limit:c.list,noun:`notes`,className:`mt-1`})]})}function X(e){let{tile:t}=e,r=a(e=>e.setSpl),c=a(e=>e.setView),[l,u]=(0,B.useState)(!1),f=s(t),p=t.result?.dql??``,m=async()=>{try{await navigator.clipboard.writeText(p),u(!0),setTimeout(()=>u(!1),1500)}catch{}};return(0,V.jsxs)(`div`,{className:`mt-4 border border-line bg-surface p-4`,"data-testid":`tile-detail`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`h3`,{className:`font-semibold`,children:t.title||`Untitled`}),(0,V.jsxs)(`span`,{className:`text-sm`,children:[(0,V.jsxs)(`span`,{className:i[f],"aria-hidden":`true`,children:[d[f],` `]}),n[f],t.visualization?` · shown as ${t.visualization}`:``]}),t.spl!==void 0&&(0,V.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-2`,children:[t.outcome===`live`&&(0,V.jsxs)(`button`,{type:`button`,className:`control`,onClick:()=>void m(),children:[(0,V.jsx)(o,{size:16,"aria-hidden":!0}),l?`Copied`:`Copy DQL`]}),(0,V.jsx)(`button`,{type:`button`,className:`control`,onClick:()=>{r(t.spl??``),c(`translate`)},children:`Open in Translate`})]})]}),t.spl!==void 0&&(0,V.jsxs)(`div`,{className:`mt-3 grid gap-4 min-[760px]:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h4`,{className:`text-xs font-semibold text-muted`,children:`Splunk SPL`}),(0,V.jsx)(`pre`,{className:`code-block`,children:t.spl})]}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h4`,{className:`text-xs font-semibold text-muted`,children:t.outcome===`live`?`Dynatrace DQL`:`DQL so far`}),(0,V.jsx)(`pre`,{className:`code-block`,children:p===``?`Nothing could be translated.`:p})]})]}),t.notes.length>0&&(0,V.jsxs)(`div`,{className:`mt-3 text-sm`,children:[(0,V.jsx)(`h4`,{className:`text-xs font-semibold text-muted`,children:t.outcome===`manual`?`What is missing`:`To check`}),(0,V.jsx)(`div`,{className:`mt-1`,children:(0,V.jsx)(Y,{notes:t.notes,blocking:t.outcome===`manual`})})]}),t.outcome===`text`&&t.notes.length===0&&(0,V.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:`A text panel, carried over as a Markdown tile.`})]})}export{K as DashboardsView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-Wy9s6hX0.js";import{S as r,_ as i,a,b as o,g as s,h as c,i as l,m as u,r as d,s as f,v as p,y as m}from"./index-
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-Wy9s6hX0.js";import{S as r,_ as i,a,b as o,g as s,h as c,i as l,m as u,r as d,s as f,v as p,y as m}from"./index-Dox0eScg.js";import{n as h}from"./mapping-text-DAJ9FWwj.js";var g={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};g.node;var _=f(g),v={name:`folder-open`,size:24,node:[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]};v.node;var y=f(v),b={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};b.node;var x=f(b),S=e(t(),1),C=2e3;function w(e){return{path:e.webkitRelativePath||e.name,size:e.size,blob:e}}function T(e){if(e.length>2e3)throw new r(`Choose at most ${C} files at once.`);let t=0;for(let n of e)t+=n.size;if(t>104857600)throw new r(`These files add up to more than 100 MB. Choose fewer files at once.`)}var E=5e7;function D(){let e=globalThis.__spl2dqlKeepLimit;return typeof e==`number`&&e>=0?Math.min(e,E):E}async function O(e,t={}){T(e);let n;try{n=await m(e)}catch(e){throw e instanceof s?new r(`These files took too long to read and were stopped. Choose fewer files at once.`):e}let a={searches:n.searches.length,dashboards:0,added:0,skipped:[],problems:[]};if(n.searches.length===0&&n.dashboards.length===0&&n.configs.length===0)throw new r(`None of these files is a search, a Splunk dashboard or a Splunk configuration file.`);let l=t.sample===!0&&c(u.getState().mappingText);if(a.example=l,n.configs.length>0&&!l){let e=u.getState(),t=await p(n.configs,{own:e.mappingText});if(t){a.skipped=t.skipped.map(e=>({name:`${e.section}: ${e.name}`,reason:e.reason}));let n=h(e.mappingText,t.sections);n?(a.added=n.added,n.added>0&&e.setMappingText(n.text)):a.problems.push(`The mapping file has a YAML problem, so nothing was added to it. Fix it on the Mapping page and choose the files again.`)}}let{mappingText:d,earliest:f}=u.getState(),g=l?{example:!0}:{own:d},_={mapping:g,timeRange:f?{earliest:f}:{}},v=D(),y=!1,b={searches:[],dashboards:[]};if(n.searches.length>0)try{let{kept:e,spent:t}=await o(n.searches.map(e=>({spl:e.spl,...e.earliest===void 0?{}:{earliest:e.earliest},...e.latest===void 0?{}:{latest:e.latest}})),{..._,budget:v});v-=t;let r=e.map((e,t)=>({...n.searches[t],result:e}));for(let t of n.searches.slice(e.length))b.searches.push(t.name);e.length<n.searches.length&&(y=!0),a.searches=r.length,u.getState().setBatch(r)}catch(e){if(!(e instanceof s))throw e;a.searches=0,a.problems.push(`The searches took too long to translate and were stopped. Choose fewer files at once.`)}if(n.dashboards.length>0){let e=new Map;for(let t of[...u.getState().batch,...n.searches])e.set(t.name,{spl:t.spl,...t.earliest===void 0?{}:{earliest:t.earliest},...t.latest===void 0?{}:{latest:t.latest}});let t=[];for(let r of n.dashboards){if(y){b.dashboards.push(r.name);continue}let n=await i(r,{mapping:g,savedSearches:[...e],budget:v});n.ok?(t.push({origin:n.name,conversion:n.conversion}),v-=n.cost):n.overBudget?(b.dashboards.push(r.name),y=!0):a.problems.push(n.error)}a.dashboards=t.length,t.length>0&&u.getState().setDashboards(t)}if((b.searches.length>0||b.dashboards.length>0)&&(a.overBudget=b),t.sample){let e=n.searches.map(e=>e.spl);for(let t of u.getState().dashboards)for(let n of t.conversion.tiles)n.spl&&e.push(n.spl);u.getState().addExamples(e)}return n.ignored.length>0&&a.problems.push(`${n.ignored.length} file(s) were not read: ${n.ignored.slice(0,3).join(`, `)}${n.ignored.length>3?` …`:``}`),u.getState().setIngestNote(a),a}var k=`<dashboard version="2" theme="light">
|
|
2
2
|
<label>Security posture</label>
|
|
3
3
|
<description>Failed sign-ins and blocked traffic.</description>
|
|
4
4
|
<definition><![CDATA[
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,m as n,n as r,r as i,w as a,x as o}from"./index-BO3AM1fZ.js";import{t as s}from"./dict-9ToLi8Te.js";import{a as c,i as l,n as u,r as d,t as f}from"./DropZone-CIbk77sc.js";import{a as p,n as m,t as h}from"./jsx-runtime-Wy9s6hX0.js";import{c as g,i as _,l as v,o as y,r as ee,s as te,t as b,u as x}from"./mapping-text-B64_Oh2A.js";var S=Object.freeze(Object.assign(Object.create(null),{append:[],data:[`json`],dedup:[`direction`,`filterPushThrough`,`limit`,`sort`],describe:[],expand:[`limit`],fetch:[`bucket`,`from`,`samplingRatio`,`scanLimitGBytes`,`timeframe`,`to`],fields:[],fieldsAdd:[],fieldsFlatten:[`depth`,`fields`,`prefix`],fieldsKeep:[],fieldsRemove:[],fieldsRename:[],fieldsSnapshot:[`bucket`,`by`],fieldsSummary:[`extrapolateSamples`,`topValues`],filter:[],filterOut:[],join:[`broadcast`,`executionOrder`,`fields`,`kind`,`on`,`prefix`],joinNested:[`broadcast`,`executionOrder`,`fields`,`on`],limit:[],load:[`offset`],lookup:[`broadcast`,`executionOrder`,`fields`,`lookupField`,`prefix`,`sourceField`],makeTimeseries:[`bins`,`by`,`default`,`from`,`interval`,`nonempty`,`rate`,`spread`,`time`,`timeframe`,`to`],metrics:[`bucket`,`from`,`timeframe`,`to`],parse:[`baseTime`,`parsingPrerequisite`,`preserveFieldsOnFailure`],search:[`caseSensitive`,`scope`],smartscapeEdges:[`from`,`timeframe`,`to`],smartscapeNodes:[`from`,`timeframe`,`to`],sort:[`direction`],summarize:[`by`],timeseries:[`bins`,`bucket`,`by`,`default`,`filter`,`from`,`interval`,`nonempty`,`rate`,`rollup`,`shift`,`timeframe`,`to`,`union`],traverse:[`direction`,`fieldsKeep`,`nodeId`]})),C=Object.freeze(Object.assign(Object.create(null),{abs:[],acos:[],array:[],arrayAvg:[],arrayConcat:[],arrayCumulativeSum:[],arrayDelta:[],arrayDiff:[],arrayDistinct:[],arrayElement:[],arrayFirst:[],arrayFlatten:[],arrayIndexOf:[],arrayLast:[],arrayLastIndexOf:[],arrayMax:[],arrayMedian:[],arrayMin:[],arrayMovingAvg:[],arrayMovingMax:[],arrayMovingMin:[],arrayMovingSum:[],arrayPercentile:[],arrayRemoveNulls:[],arrayReverse:[],arraySize:[],arraySlice:[`from`,`to`],arraySort:[`direction`],arraySum:[],arrayToString:[`delimiter`],asArray:[],asBinary:[],asBoolean:[],asDouble:[],asDuration:[],asIp:[],asLong:[],asNumber:[],asRecord:[],asSmartscapeId:[],asString:[],asTimeframe:[],asTimestamp:[],asUid:[],asin:[],atan:[],atan2:[],avg:[`default`,`filter`,`rate`,`rollup`,`scalar`],bin:[`at`],bitwiseAnd:[],bitwiseCountOnes:[],bitwiseNot:[],bitwiseOr:[],bitwiseShiftLeft:[],bitwiseShiftRight:[`ignoreSign`],bitwiseXor:[],cbrt:[],ceil:[],classicEntitySelector:[],coalesce:[],collectArray:[`expand`,`maxLength`],collectDistinct:[`expand`,`maxLength`],concat:[`delimiter`],contains:[`caseSensitive`],correlation:[],cos:[],cosh:[],count:[`default`,`filter`,`rate`,`scalar`],countDistinct:[`default`,`filter`,`precision`,`rate`,`scalar`],countDistinctApprox:[`default`,`precision`,`rate`,`scalar`],countDistinctExact:[`default`,`rate`,`scalar`],countIf:[`default`,`rate`,`scalar`],decodeBase16ToBinary:[],decodeBase16ToString:[],decodeBase64ToBinary:[],decodeBase64ToString:[],decodeUrl:[],degreeToRadian:[],duration:[],e:[],encodeBase16:[],encodeBase64:[],encodeUrl:[],end:[],endsWith:[`caseSensitive`],entityAttr:[`type`],entityName:[`type`],escape:[],exists:[],exp:[],floor:[],formatTimestamp:[`format`,`interval`,`locale`,`timezone`],getCharacter:[],getDayOfMonth:[`timezone`],getDayOfWeek:[`timezone`],getDayOfYear:[`timezone`],getEnd:[],getHighBits:[],getHour:[`timezone`],getLowBits:[],getMinute:[`timezone`],getMonth:[`timezone`],getNodeField:[],getNodeName:[],getSecond:[`timezone`],getStart:[],getWeekOfYear:[`timezone`],getYear:[`timezone`],hashCrc32:[],hashMd5:[],hashSha1:[],hashSha256:[],hashSha512:[],hashXxHash32:[],hashXxHash64:[],hexStringToNumber:[],hypotenuse:[],iAny:[],iCollectArray:[],iIndex:[],if:[`else`],in:[],indexOf:[`from`],ip:[],ipIn:[],ipIsLinkLocal:[],ipIsLoopback:[],ipIsPrivate:[],ipIsPublic:[],ipMask:[`ipv6MaskBits`],isFalseOrNull:[],isIp:[],isIpV4:[],isIpV6:[],isNotNull:[],isNull:[],isTrueOrNull:[],isUid128:[],isUid64:[],isUuid:[],jsonField:[`seek`],jsonPath:[`seek`],lastIndexOf:[`from`],levenshteinDistance:[],like:[],log:[],log10:[],log1p:[],lookup:[`broadcast`,`executionOrder`,`lookupField`,`sourceField`],lower:[],matchesPattern:[],matchesPhrase:[`caseSensitive`,`wildcard`],matchesRegex:[],matchesValue:[`caseSensitive`,`wildcard`],max:[`default`,`filter`,`rate`,`rollup`,`scalar`],median:[`default`,`filter`,`rate`,`rollup`,`scalar`,`weight`],min:[`default`,`filter`,`rate`,`rollup`,`scalar`],now:[],numberToHexString:[`minLength`],parse:[`baseTime`],parseAll:[`baseTime`],percentRank:[`default`,`filter`,`rate`,`rollup`,`scalar`],percentile:[`default`,`filter`,`rate`,`rollup`,`scalar`,`weight`],percentileFromSamples:[`default`,`originalCount`,`rate`,`scalar`],percentiles:[`weight`],pi:[],power:[],punctuation:[`count`,`withSpace`],radianToDegree:[],random:[],range:[`at`],record:[],replacePattern:[],replaceString:[],round:[`decimals`],signum:[],sin:[],sinh:[],smartscapeId:[],splitByPattern:[],splitString:[],sqrt:[],start:[],startsWith:[`caseSensitive`],stddev:[],stringLength:[],substring:[`from`,`to`],sum:[`default`,`filter`,`rate`,`rollup`,`scalar`],takeAny:[],takeFirst:[],takeLast:[],takeMax:[],takeMin:[],tan:[],tanh:[],timeframe:[`to`],timestamp:[`micros`,`millis`,`nanos`,`timezone`],timestampFromUnixMillis:[],timestampFromUnixNanos:[],timestampFromUnixSeconds:[],toArray:[],toBoolean:[],toDouble:[],toDuration:[],toIp:[],toLong:[],toSmartscapeId:[],toString:[],toTimeframe:[],toTimestamp:[],toUid:[],toVariant:[],trim:[],type:[`withSubtype`],uid128:[],uid64:[],unescape:[],unescapeHtml:[],unixMillisFromTimestamp:[],unixNanosFromTimestamp:[],unixSecondsFromTimestamp:[],upper:[],uuid:[],variance:[],vectorCosineDistance:[],vectorInnerProductDistance:[],vectorL1Distance:[],vectorL2Distance:[]})),w=256,T=1e6;function E(e){return D(e,e=>{e.expr(),e.expectEof()})}function D(e,t){let n={commands:[],calls:[]};if(e.length>T)return n.error={message:`The query is too long.`,span:{start:0,end:0}},n;let r=new ne(a(e).filter(e=>e.type!==`comment`),n);try{t(r)}catch(e){if(!(e instanceof O))throw e;n.error={message:e.message,span:e.span}}return n}var O=class extends Error{span;constructor(e,t){super(e),this.span=t}},ne=class e{i=0;depth=0;tokens;out;constructor(e,t){this.tokens=e,this.out=t}get t(){return this.tokens[this.i]??this.tokens[this.tokens.length-1]}peek(e=1){return this.tokens[this.i+e]??this.tokens[this.tokens.length-1]}is(e){return this.t.type===`punct`&&this.t.text===e}isWord(e){return this.t.type===`ident`&&this.t.text===e}next(){let e=this.t;if(e.type===`error`)throw new O(k(e),e.span);return this.i++,e}expect(e){return this.is(e)||this.fail(`Expected "${e}"`),this.next()}fail(e){let t=this.t;throw t.type===`error`?new O(k(t),t.span):new O(`${e}, found ${t.type===`eof`?`end of query`:`"${t.text}"`}.`,t.span)}enter(){if(++this.depth>w)throw new O(`The query is nested too deeply.`,this.t.span)}leave(){this.depth--}expectEof(){this.t.type!==`eof`&&this.fail(`Unexpected text`)}query(){for(this.command();this.is(`|`);)this.next(),this.command()}command(){this.t.type!==`ident`&&this.fail(`Expected a command name`);let e=this.next(),t={name:e.text,span:e.span,named:[]};if(this.out.commands.push(t),!this.atArgsEnd()){for(this.argument(t.named);this.is(`,`);)this.next(),this.argument(t.named);this.atArgsEnd()||this.fail(`Expected "," or "|"`)}}atArgsEnd(){return this.t.type===`eof`||this.is(`|`)||this.is(`]`)}argument(e){if(this.t.type===`ident`&&this.peek().type===`punct`&&this.peek().text===`:`){let t=this.next();e.push({name:t.text,span:t.span}),this.next(),this.valueWithDirection()}else this.valueWithDirection()}valueWithDirection(){this.assignOrExpr(),(this.isWord(`asc`)||this.isWord(`desc`))&&this.next()}assignOrExpr(){let e=this.i;if(this.t.type===`backtick`||this.t.type===`ident`){for(this.next();this.is(`.`)&&(this.peek().type===`ident`||this.peek().type===`backtick`);)this.next(),this.next();if(this.is(`=`)){this.next(),this.expr();return}this.i=e}this.expr()}expr(){this.enter(),this.binary(0),this.leave()}static LEVELS=[[`or`],[`xor`],[`and`],[`==`,`!=`,`<`,`<=`,`>`,`>=`,`in`],[`+`,`-`],[`*`,`/`,`%`]];binary(t){let n=e.LEVELS[t];if(!n)this.unary();else if(t===3)this.notLevel();else for(this.binary(t+1);this.isOp(n);)this.next(),this.binary(t+1)}notLevel(){if(this.isWord(`not`)){this.next(),this.enter(),this.notLevel(),this.leave();return}this.binary(4);let t=e.LEVELS[3]??[];for(;this.isOp(t);)this.next(),this.binary(4)}isOp(e){let t=this.t;return t.type===`punct`||t.type===`ident`?e.includes(t.text):!1}unary(){this.is(`-`)||this.is(`+`)?(this.next(),this.enter(),this.unary(),this.leave()):this.postfix()}postfix(){for(this.primary();;)if(this.is(`[`))this.next(),this.is(`]`)||this.expr(),this.expect(`]`);else if(this.t.type===`align`)this.next();else return}primary(){let e=this.t;switch(e.type){case`number`:case`duration`:case`string`:case`align`:this.next();return;case`backtick`:this.next();return;case`ident`:if(this.peek().type===`punct`&&this.peek().text===`(`){this.call();return}for(this.next();this.is(`.`)&&(this.peek().type===`ident`||this.peek().type===`backtick`);)this.next(),this.next();return;case`punct`:if(e.text===`(`){this.next(),this.expr(),this.expect(`)`);return}if(e.text===`{`){if(this.next(),this.enter(),!this.is(`}`))for(this.valueWithDirection();this.is(`,`);)this.next(),this.valueWithDirection();this.expect(`}`),this.leave();return}if(e.text===`[`){this.next(),this.enter(),this.query(),this.leave(),this.expect(`]`);return}this.fail(`Expected a value`);return;default:this.fail(`Expected a value`)}}call(){let e=this.next(),t={fn:e.text,span:e.span,named:[]};if(this.out.calls.push(t),this.expect(`(`),this.enter(),!this.is(`)`))for(this.callArg(t);this.is(`,`);)this.next(),this.callArg(t);this.leave(),this.expect(`)`)}callArg(e){if(this.t.type===`ident`&&this.peek().type===`punct`&&this.peek().text===`:`){let t=this.next();e.named.push({name:t.text,span:t.span}),this.next()}this.assignOrExpr()}};function k(e){return e.text.startsWith(`"`)||e.text.startsWith(`'`)?`A string is not closed.`:e.text.startsWith("`")?`A backtick-quoted name is not closed.`:`Unexpected character "${e.text}".`}function A(e){let t=M(E(e)),n=a(e).find(e=>e.type===`comment`);return n?{ok:!1,issues:[...t.issues,{severity:`error`,message:`Comments are not allowed here.`,span:n.span}]}:t}var j=s({});function M(e){let t=[];e.error&&t.push({severity:`error`,message:e.error.message,span:e.error.span});for(let n of e.commands){let e=Object.hasOwn(S,n.name)?S[n.name]:void 0;if(!e)t.push({severity:`error`,message:`Unknown command "${n.name}".`,span:n.span});else for(let r of n.named)e.includes(r.name)||t.push({severity:`error`,message:`"${n.name}" has no parameter "${r.name}".`,span:r.span})}for(let n of e.calls){if(!Object.hasOwn(C,n.fn)){t.push({severity:`error`,message:`Unknown function "${n.fn}".`,span:n.span});continue}let e=[...C[n.fn]??[],...j[n.fn]??[]];for(let r of n.named)e.includes(r.name)||t.push({severity:`error`,message:`"${n.fn}" has no parameter "${r.name}".`,span:r.span})}return t.sort((e,t)=>e.span.start-t.span.start),{ok:!t.some(e=>e.severity===`error`),issues:t}}function N(){return{version:1,defaults:{dataObject:`logs`,timezone:`UTC`},indexes:new Map,sourcetypes:new Map,fields:new Map,fieldTypes:new Map,extractions:new Map,macros:new Map,lookups:new Map,eventtypes:new Map,tags:new Map,metrics:new Map,datamodels:new Map}}var P=[`version`,`defaults`,`indexes`,`sourcetypes`,`fields`,`fieldTypes`,`extractions`,`macros`,`lookups`,`eventtypes`,`tags`,`metrics`,`datamodels`],F=/^[a-z][a-z0-9_.]{0,63}$/,I=/^[A-Za-z0-9_-]{1,128}$/,L=/^[A-Za-z_@][A-Za-z0-9_.:@-]{0,255}$/,R=/^\/lookups\/[A-Za-z0-9_.-]+(\/[A-Za-z0-9_.-]+)*$/,z=/^[^\s`"|[\]]{1,256}$/,B=/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*){0,7}$/,V=/^-?\d+(s|m|h|d|w|M|q|y)(@[a-zA-Z0-9]+)?$/,H=[`number`,`string`,`time`,`duration`,`boolean`,`ip`],U=1e4,W=1e4;function G(e){let t=[],n=N(),r=new K(t);if(!q(e))return{ok:!1,issues:[{path:``,message:`The mapping file must be a map of sections.`}]};for(let n of Object.keys(e))P.includes(n)||t.push({path:`/${J(n)}`,message:`Unknown section "${n}".`});e.version!==1&&t.push({path:`/version`,message:`Set "version: 1".`});let i=e.defaults;return i!==void 0&&r.record(i,`/defaults`,[`dataObject`,`timeframe`,`timezone`])&&(i.dataObject!==void 0&&r.pattern(i.dataObject,`/defaults/dataObject`,F,`a data object name such as "logs"`)&&(n.defaults.dataObject=i.dataObject),i.timeframe!==void 0&&i.timeframe!==null&&r.pattern(i.timeframe,`/defaults/timeframe`,V,`a relative time such as "-24h"`)&&(n.defaults.timeframe=i.timeframe),i.timezone!==void 0&&(r.string(i.timezone,`/defaults/timezone`)&&re(i.timezone)?n.defaults.timezone=i.timezone:typeof i.timezone==`string`&&t.push({path:`/defaults/timezone`,message:`"${i.timezone}" is not a known time zone.`}))),n.indexes=r.section(e.indexes,`/indexes`,z,(e,t)=>{if(!r.record(e,t,[`dataObject`,`buckets`,`filter`]))return;let i={dataObject:n.defaults.dataObject,buckets:[]};if(e.dataObject!==void 0&&r.pattern(e.dataObject,`${t}/dataObject`,F,`a data object name such as "logs"`)&&(i.dataObject=e.dataObject),e.buckets!==void 0&&(i.buckets=r.stringList(e.buckets,`${t}/buckets`,I,`a bucket name`)),e.filter!==void 0){let n=r.dqlFilter(e.filter,`${t}/filter`);n!==void 0&&(i.filter=n)}return i}),n.sourcetypes=r.section(e.sourcetypes,`/sourcetypes`,z,(e,t)=>{if(!r.record(e,t,[`filter`,`extractions`]))return;let n={extractions:[]};if(e.filter!==void 0){let i=r.dqlFilter(e.filter,`${t}/filter`);i!==void 0&&(n.filter=i)}return e.extractions!==void 0&&(n.extractions=r.stringList(e.extractions,`${t}/extractions`,z,`a field name`)),n}),n.fields=r.section(e.fields,`/fields`,z,(e,t)=>r.pattern(e,t,L,`a Grail field name such as "host.name"`)?e:void 0),n.fieldTypes=r.section(e.fieldTypes,`/fieldTypes`,L,(e,n)=>{if(typeof e==`string`&&H.includes(e))return e;t.push({path:n,message:`Use one of: ${H.join(`, `)}.`})}),n.extractions=r.section(e.extractions,`/extractions`,z,(e,t)=>{if(!r.record(e,t,[`from`,`dpl`]))return;let n=e.from===void 0?`content`:e.from;if(r.pattern(n,`${t}/from`,L,`a Grail field name`)&&r.text(e.dpl,`${t}/dpl`))return{from:n,dpl:e.dpl}}),n.macros=r.section(e.macros,`/macros`,/^[A-Za-z0-9_.:-]+(\(\d{1,2}\))?$/,(e,n,i)=>{let a=typeof e==`string`?e:q(e)?e.definition:void 0;if(q(e)&&!r.record(e,n,[`args`,`definition`])||!r.text(a,typeof e==`string`?n:`${n}/definition`))return;let o=q(e)&&e.args!==void 0?r.stringList(e.args,`${n}/args`,/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,`an argument name`):[],s=/\((\d+)\)$/.exec(i),c=s?Number(s[1]):0;if(c!==o.length)t.push({path:n,message:`The macro name says ${c} argument(s) but "args" lists ${o.length}.`});else return{args:o,definition:a}}),n.lookups=r.section(e.lookups,`/lookups`,z,(e,n)=>{if(!r.record(e,n,[`path`,`key`,`columns`])||!r.pattern(e.path,`${n}/path`,R,`a Grail file path starting with "/lookups/"`))return;if(e.path.includes(`..`)){t.push({path:`${n}/path`,message:`The path must not contain "..".`});return}let i={path:e.path};return e.key!==void 0&&r.pattern(e.key,`${n}/key`,L,`a column name`)&&(i.key=e.key),e.columns!==void 0&&(i.columns=r.stringList(e.columns,`${n}/columns`,L,`a column name`)),i}),n.eventtypes=r.section(e.eventtypes,`/eventtypes`,z,(e,t)=>r.dqlFilter(e,t)),n.tags=r.section(e.tags,`/tags`,z,(e,t)=>r.dqlFilter(e,t)),n.metrics=r.section(e.metrics,`/metrics`,z,(e,t)=>r.pattern(e,t,L,`a metric key such as "dt.host.cpu.usage"`)?e:void 0),n.datamodels=r.section(e.datamodels,`/datamodels`,B,(e,t)=>{if(!r.record(e,t,[`dataObject`,`buckets`,`filter`,`fields`]))return;let i=n.defaults.dataObject;e.dataObject!==void 0&&r.pattern(e.dataObject,`${t}/dataObject`,F,`a data object name such as "logs"`)&&(i=e.dataObject);let a=e.buckets===void 0?[]:r.stringList(e.buckets,`${t}/buckets`,I,`a bucket name`),o=r.section(e.fields,`${t}/fields`,z,(e,t)=>r.pattern(e,t,L,`a Grail field name such as "user.name"`)?e:void 0),s={dataObject:i,buckets:a,fields:o};if(e.filter!==void 0){let n=r.dqlFilter(e.filter,`${t}/filter`);n!==void 0&&(s.filter=n)}return s}),t.length>0?{ok:!1,issues:t}:{ok:!0,value:n}}var K=class{issues;constructor(e){this.issues=e}record(e,t,n){if(!q(e))return this.issues.push({path:t,message:`Expected a map.`}),!1;for(let r of Object.keys(e))n.includes(r)||this.issues.push({path:`${t}/${J(r)}`,message:`Unknown key "${r}". Allowed: ${n.join(`, `)}.`});return!0}string(e,t){return typeof e==`string`||(this.issues.push({path:t,message:`Expected text.`}),!1)}text(e,t){return this.string(e,t)?e.length===0||e.length>W?(this.issues.push({path:t,message:`Expected 1 to ${W} characters.`}),!1):!0:!1}pattern(e,t,n,r){return typeof e!=`string`||!n.test(e)?(this.issues.push({path:t,message:`Expected ${r}.`}),!1):!0}stringList(e,t,n,r){if(!Array.isArray(e))return this.issues.push({path:t,message:`Expected a list.`}),[];if(e.length>U)return this.issues.push({path:t,message:`At most ${U} entries.`}),[];let i=[];return e.forEach((e,a)=>{this.pattern(e,`${t}/${a}`,n,r)&&i.push(e)}),i}dqlFilter(e,t){if(!this.text(e,t))return;let n=A(e);if(n.ok)return e;{let e=n.issues[0];this.issues.push({path:t,message:`Not a valid DQL condition: ${e?.message??`syntax error`}`})}}section(e,t,n,r){let i=new Map;if(e==null)return i;if(!q(e))return this.issues.push({path:t,message:`Expected a map.`}),i;let a=Object.keys(e);if(a.length>U)return this.issues.push({path:t,message:`At most ${U} entries.`}),i;for(let o of a){let a=`${t}/${J(o)}`;if(!n.test(o)){this.issues.push({path:a,message:`"${o}" is not a valid name here.`});continue}let s=r(e[o],a,o);s!==void 0&&i.set(o,s)}return i}};function q(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function J(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}var Y=/^(UTC|Z|[+-]\d{2}:\d{2})$/;function re(e){if(Y.test(e))return!0;if(!/^[A-Za-z_]+(\/[A-Za-z0-9_+-]+){0,2}$/.test(e))return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}),!0}catch{return!1}}var X=p(m(),1),ie=`
|
|
1
|
+
import{a as e,i as t,m as n,n as r,r as i,w as a,x as o}from"./index-Dox0eScg.js";import{t as s}from"./dict-9ToLi8Te.js";import{a as c,i as l,n as u,r as d,t as f}from"./DropZone-Cm1HZT4A.js";import{a as p,n as m,t as h}from"./jsx-runtime-Wy9s6hX0.js";import{c as g,i as _,l as v,o as y,r as ee,s as te,t as b,u as x}from"./mapping-text-DAJ9FWwj.js";var S=Object.freeze(Object.assign(Object.create(null),{append:[],data:[`json`],dedup:[`direction`,`filterPushThrough`,`limit`,`sort`],describe:[],expand:[`limit`],fetch:[`bucket`,`from`,`samplingRatio`,`scanLimitGBytes`,`timeframe`,`to`],fields:[],fieldsAdd:[],fieldsFlatten:[`depth`,`fields`,`prefix`],fieldsKeep:[],fieldsRemove:[],fieldsRename:[],fieldsSnapshot:[`bucket`,`by`],fieldsSummary:[`extrapolateSamples`,`topValues`],filter:[],filterOut:[],join:[`broadcast`,`executionOrder`,`fields`,`kind`,`on`,`prefix`],joinNested:[`broadcast`,`executionOrder`,`fields`,`on`],limit:[],load:[`offset`],lookup:[`broadcast`,`executionOrder`,`fields`,`lookupField`,`prefix`,`sourceField`],makeTimeseries:[`bins`,`by`,`default`,`from`,`interval`,`nonempty`,`rate`,`spread`,`time`,`timeframe`,`to`],metrics:[`bucket`,`from`,`timeframe`,`to`],parse:[`baseTime`,`parsingPrerequisite`,`preserveFieldsOnFailure`],search:[`caseSensitive`,`scope`],smartscapeEdges:[`from`,`timeframe`,`to`],smartscapeNodes:[`from`,`timeframe`,`to`],sort:[`direction`],summarize:[`by`],timeseries:[`bins`,`bucket`,`by`,`default`,`filter`,`from`,`interval`,`nonempty`,`rate`,`rollup`,`shift`,`timeframe`,`to`,`union`],traverse:[`direction`,`fieldsKeep`,`nodeId`]})),C=Object.freeze(Object.assign(Object.create(null),{abs:[],acos:[],array:[],arrayAvg:[],arrayConcat:[],arrayCumulativeSum:[],arrayDelta:[],arrayDiff:[],arrayDistinct:[],arrayElement:[],arrayFirst:[],arrayFlatten:[],arrayIndexOf:[],arrayLast:[],arrayLastIndexOf:[],arrayMax:[],arrayMedian:[],arrayMin:[],arrayMovingAvg:[],arrayMovingMax:[],arrayMovingMin:[],arrayMovingSum:[],arrayPercentile:[],arrayRemoveNulls:[],arrayReverse:[],arraySize:[],arraySlice:[`from`,`to`],arraySort:[`direction`],arraySum:[],arrayToString:[`delimiter`],asArray:[],asBinary:[],asBoolean:[],asDouble:[],asDuration:[],asIp:[],asLong:[],asNumber:[],asRecord:[],asSmartscapeId:[],asString:[],asTimeframe:[],asTimestamp:[],asUid:[],asin:[],atan:[],atan2:[],avg:[`default`,`filter`,`rate`,`rollup`,`scalar`],bin:[`at`],bitwiseAnd:[],bitwiseCountOnes:[],bitwiseNot:[],bitwiseOr:[],bitwiseShiftLeft:[],bitwiseShiftRight:[`ignoreSign`],bitwiseXor:[],cbrt:[],ceil:[],classicEntitySelector:[],coalesce:[],collectArray:[`expand`,`maxLength`],collectDistinct:[`expand`,`maxLength`],concat:[`delimiter`],contains:[`caseSensitive`],correlation:[],cos:[],cosh:[],count:[`default`,`filter`,`rate`,`scalar`],countDistinct:[`default`,`filter`,`precision`,`rate`,`scalar`],countDistinctApprox:[`default`,`precision`,`rate`,`scalar`],countDistinctExact:[`default`,`rate`,`scalar`],countIf:[`default`,`rate`,`scalar`],decodeBase16ToBinary:[],decodeBase16ToString:[],decodeBase64ToBinary:[],decodeBase64ToString:[],decodeUrl:[],degreeToRadian:[],duration:[],e:[],encodeBase16:[],encodeBase64:[],encodeUrl:[],end:[],endsWith:[`caseSensitive`],entityAttr:[`type`],entityName:[`type`],escape:[],exists:[],exp:[],floor:[],formatTimestamp:[`format`,`interval`,`locale`,`timezone`],getCharacter:[],getDayOfMonth:[`timezone`],getDayOfWeek:[`timezone`],getDayOfYear:[`timezone`],getEnd:[],getHighBits:[],getHour:[`timezone`],getLowBits:[],getMinute:[`timezone`],getMonth:[`timezone`],getNodeField:[],getNodeName:[],getSecond:[`timezone`],getStart:[],getWeekOfYear:[`timezone`],getYear:[`timezone`],hashCrc32:[],hashMd5:[],hashSha1:[],hashSha256:[],hashSha512:[],hashXxHash32:[],hashXxHash64:[],hexStringToNumber:[],hypotenuse:[],iAny:[],iCollectArray:[],iIndex:[],if:[`else`],in:[],indexOf:[`from`],ip:[],ipIn:[],ipIsLinkLocal:[],ipIsLoopback:[],ipIsPrivate:[],ipIsPublic:[],ipMask:[`ipv6MaskBits`],isFalseOrNull:[],isIp:[],isIpV4:[],isIpV6:[],isNotNull:[],isNull:[],isTrueOrNull:[],isUid128:[],isUid64:[],isUuid:[],jsonField:[`seek`],jsonPath:[`seek`],lastIndexOf:[`from`],levenshteinDistance:[],like:[],log:[],log10:[],log1p:[],lookup:[`broadcast`,`executionOrder`,`lookupField`,`sourceField`],lower:[],matchesPattern:[],matchesPhrase:[`caseSensitive`,`wildcard`],matchesRegex:[],matchesValue:[`caseSensitive`,`wildcard`],max:[`default`,`filter`,`rate`,`rollup`,`scalar`],median:[`default`,`filter`,`rate`,`rollup`,`scalar`,`weight`],min:[`default`,`filter`,`rate`,`rollup`,`scalar`],now:[],numberToHexString:[`minLength`],parse:[`baseTime`],parseAll:[`baseTime`],percentRank:[`default`,`filter`,`rate`,`rollup`,`scalar`],percentile:[`default`,`filter`,`rate`,`rollup`,`scalar`,`weight`],percentileFromSamples:[`default`,`originalCount`,`rate`,`scalar`],percentiles:[`weight`],pi:[],power:[],punctuation:[`count`,`withSpace`],radianToDegree:[],random:[],range:[`at`],record:[],replacePattern:[],replaceString:[],round:[`decimals`],signum:[],sin:[],sinh:[],smartscapeId:[],splitByPattern:[],splitString:[],sqrt:[],start:[],startsWith:[`caseSensitive`],stddev:[],stringLength:[],substring:[`from`,`to`],sum:[`default`,`filter`,`rate`,`rollup`,`scalar`],takeAny:[],takeFirst:[],takeLast:[],takeMax:[],takeMin:[],tan:[],tanh:[],timeframe:[`to`],timestamp:[`micros`,`millis`,`nanos`,`timezone`],timestampFromUnixMillis:[],timestampFromUnixNanos:[],timestampFromUnixSeconds:[],toArray:[],toBoolean:[],toDouble:[],toDuration:[],toIp:[],toLong:[],toSmartscapeId:[],toString:[],toTimeframe:[],toTimestamp:[],toUid:[],toVariant:[],trim:[],type:[`withSubtype`],uid128:[],uid64:[],unescape:[],unescapeHtml:[],unixMillisFromTimestamp:[],unixNanosFromTimestamp:[],unixSecondsFromTimestamp:[],upper:[],uuid:[],variance:[],vectorCosineDistance:[],vectorInnerProductDistance:[],vectorL1Distance:[],vectorL2Distance:[]})),w=256,T=1e6;function E(e){return D(e,e=>{e.expr(),e.expectEof()})}function D(e,t){let n={commands:[],calls:[]};if(e.length>T)return n.error={message:`The query is too long.`,span:{start:0,end:0}},n;let r=new ne(a(e).filter(e=>e.type!==`comment`),n);try{t(r)}catch(e){if(!(e instanceof O))throw e;n.error={message:e.message,span:e.span}}return n}var O=class extends Error{span;constructor(e,t){super(e),this.span=t}},ne=class e{i=0;depth=0;tokens;out;constructor(e,t){this.tokens=e,this.out=t}get t(){return this.tokens[this.i]??this.tokens[this.tokens.length-1]}peek(e=1){return this.tokens[this.i+e]??this.tokens[this.tokens.length-1]}is(e){return this.t.type===`punct`&&this.t.text===e}isWord(e){return this.t.type===`ident`&&this.t.text===e}next(){let e=this.t;if(e.type===`error`)throw new O(k(e),e.span);return this.i++,e}expect(e){return this.is(e)||this.fail(`Expected "${e}"`),this.next()}fail(e){let t=this.t;throw t.type===`error`?new O(k(t),t.span):new O(`${e}, found ${t.type===`eof`?`end of query`:`"${t.text}"`}.`,t.span)}enter(){if(++this.depth>w)throw new O(`The query is nested too deeply.`,this.t.span)}leave(){this.depth--}expectEof(){this.t.type!==`eof`&&this.fail(`Unexpected text`)}query(){for(this.command();this.is(`|`);)this.next(),this.command()}command(){this.t.type!==`ident`&&this.fail(`Expected a command name`);let e=this.next(),t={name:e.text,span:e.span,named:[]};if(this.out.commands.push(t),!this.atArgsEnd()){for(this.argument(t.named);this.is(`,`);)this.next(),this.argument(t.named);this.atArgsEnd()||this.fail(`Expected "," or "|"`)}}atArgsEnd(){return this.t.type===`eof`||this.is(`|`)||this.is(`]`)}argument(e){if(this.t.type===`ident`&&this.peek().type===`punct`&&this.peek().text===`:`){let t=this.next();e.push({name:t.text,span:t.span}),this.next(),this.valueWithDirection()}else this.valueWithDirection()}valueWithDirection(){this.assignOrExpr(),(this.isWord(`asc`)||this.isWord(`desc`))&&this.next()}assignOrExpr(){let e=this.i;if(this.t.type===`backtick`||this.t.type===`ident`){for(this.next();this.is(`.`)&&(this.peek().type===`ident`||this.peek().type===`backtick`);)this.next(),this.next();if(this.is(`=`)){this.next(),this.expr();return}this.i=e}this.expr()}expr(){this.enter(),this.binary(0),this.leave()}static LEVELS=[[`or`],[`xor`],[`and`],[`==`,`!=`,`<`,`<=`,`>`,`>=`,`in`],[`+`,`-`],[`*`,`/`,`%`]];binary(t){let n=e.LEVELS[t];if(!n)this.unary();else if(t===3)this.notLevel();else for(this.binary(t+1);this.isOp(n);)this.next(),this.binary(t+1)}notLevel(){if(this.isWord(`not`)){this.next(),this.enter(),this.notLevel(),this.leave();return}this.binary(4);let t=e.LEVELS[3]??[];for(;this.isOp(t);)this.next(),this.binary(4)}isOp(e){let t=this.t;return t.type===`punct`||t.type===`ident`?e.includes(t.text):!1}unary(){this.is(`-`)||this.is(`+`)?(this.next(),this.enter(),this.unary(),this.leave()):this.postfix()}postfix(){for(this.primary();;)if(this.is(`[`))this.next(),this.is(`]`)||this.expr(),this.expect(`]`);else if(this.t.type===`align`)this.next();else return}primary(){let e=this.t;switch(e.type){case`number`:case`duration`:case`string`:case`align`:this.next();return;case`backtick`:this.next();return;case`ident`:if(this.peek().type===`punct`&&this.peek().text===`(`){this.call();return}for(this.next();this.is(`.`)&&(this.peek().type===`ident`||this.peek().type===`backtick`);)this.next(),this.next();return;case`punct`:if(e.text===`(`){this.next(),this.expr(),this.expect(`)`);return}if(e.text===`{`){if(this.next(),this.enter(),!this.is(`}`))for(this.valueWithDirection();this.is(`,`);)this.next(),this.valueWithDirection();this.expect(`}`),this.leave();return}if(e.text===`[`){this.next(),this.enter(),this.query(),this.leave(),this.expect(`]`);return}this.fail(`Expected a value`);return;default:this.fail(`Expected a value`)}}call(){let e=this.next(),t={fn:e.text,span:e.span,named:[]};if(this.out.calls.push(t),this.expect(`(`),this.enter(),!this.is(`)`))for(this.callArg(t);this.is(`,`);)this.next(),this.callArg(t);this.leave(),this.expect(`)`)}callArg(e){if(this.t.type===`ident`&&this.peek().type===`punct`&&this.peek().text===`:`){let t=this.next();e.named.push({name:t.text,span:t.span}),this.next()}this.assignOrExpr()}};function k(e){return e.text.startsWith(`"`)||e.text.startsWith(`'`)?`A string is not closed.`:e.text.startsWith("`")?`A backtick-quoted name is not closed.`:`Unexpected character "${e.text}".`}function A(e){let t=M(E(e)),n=a(e).find(e=>e.type===`comment`);return n?{ok:!1,issues:[...t.issues,{severity:`error`,message:`Comments are not allowed here.`,span:n.span}]}:t}var j=s({});function M(e){let t=[];e.error&&t.push({severity:`error`,message:e.error.message,span:e.error.span});for(let n of e.commands){let e=Object.hasOwn(S,n.name)?S[n.name]:void 0;if(!e)t.push({severity:`error`,message:`Unknown command "${n.name}".`,span:n.span});else for(let r of n.named)e.includes(r.name)||t.push({severity:`error`,message:`"${n.name}" has no parameter "${r.name}".`,span:r.span})}for(let n of e.calls){if(!Object.hasOwn(C,n.fn)){t.push({severity:`error`,message:`Unknown function "${n.fn}".`,span:n.span});continue}let e=[...C[n.fn]??[],...j[n.fn]??[]];for(let r of n.named)e.includes(r.name)||t.push({severity:`error`,message:`"${n.fn}" has no parameter "${r.name}".`,span:r.span})}return t.sort((e,t)=>e.span.start-t.span.start),{ok:!t.some(e=>e.severity===`error`),issues:t}}function N(){return{version:1,defaults:{dataObject:`logs`,timezone:`UTC`},indexes:new Map,sourcetypes:new Map,fields:new Map,fieldTypes:new Map,extractions:new Map,macros:new Map,lookups:new Map,eventtypes:new Map,tags:new Map,metrics:new Map,datamodels:new Map}}var P=[`version`,`defaults`,`indexes`,`sourcetypes`,`fields`,`fieldTypes`,`extractions`,`macros`,`lookups`,`eventtypes`,`tags`,`metrics`,`datamodels`],F=/^[a-z][a-z0-9_.]{0,63}$/,I=/^[A-Za-z0-9_-]{1,128}$/,L=/^[A-Za-z_@][A-Za-z0-9_.:@-]{0,255}$/,R=/^\/lookups\/[A-Za-z0-9_.-]+(\/[A-Za-z0-9_.-]+)*$/,z=/^[^\s`"|[\]]{1,256}$/,B=/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*){0,7}$/,V=/^-?\d+(s|m|h|d|w|M|q|y)(@[a-zA-Z0-9]+)?$/,H=[`number`,`string`,`time`,`duration`,`boolean`,`ip`],U=1e4,W=1e4;function G(e){let t=[],n=N(),r=new K(t);if(!q(e))return{ok:!1,issues:[{path:``,message:`The mapping file must be a map of sections.`}]};for(let n of Object.keys(e))P.includes(n)||t.push({path:`/${J(n)}`,message:`Unknown section "${n}".`});e.version!==1&&t.push({path:`/version`,message:`Set "version: 1".`});let i=e.defaults;return i!==void 0&&r.record(i,`/defaults`,[`dataObject`,`timeframe`,`timezone`])&&(i.dataObject!==void 0&&r.pattern(i.dataObject,`/defaults/dataObject`,F,`a data object name such as "logs"`)&&(n.defaults.dataObject=i.dataObject),i.timeframe!==void 0&&i.timeframe!==null&&r.pattern(i.timeframe,`/defaults/timeframe`,V,`a relative time such as "-24h"`)&&(n.defaults.timeframe=i.timeframe),i.timezone!==void 0&&(r.string(i.timezone,`/defaults/timezone`)&&re(i.timezone)?n.defaults.timezone=i.timezone:typeof i.timezone==`string`&&t.push({path:`/defaults/timezone`,message:`"${i.timezone}" is not a known time zone.`}))),n.indexes=r.section(e.indexes,`/indexes`,z,(e,t)=>{if(!r.record(e,t,[`dataObject`,`buckets`,`filter`]))return;let i={dataObject:n.defaults.dataObject,buckets:[]};if(e.dataObject!==void 0&&r.pattern(e.dataObject,`${t}/dataObject`,F,`a data object name such as "logs"`)&&(i.dataObject=e.dataObject),e.buckets!==void 0&&(i.buckets=r.stringList(e.buckets,`${t}/buckets`,I,`a bucket name`)),e.filter!==void 0){let n=r.dqlFilter(e.filter,`${t}/filter`);n!==void 0&&(i.filter=n)}return i}),n.sourcetypes=r.section(e.sourcetypes,`/sourcetypes`,z,(e,t)=>{if(!r.record(e,t,[`filter`,`extractions`]))return;let n={extractions:[]};if(e.filter!==void 0){let i=r.dqlFilter(e.filter,`${t}/filter`);i!==void 0&&(n.filter=i)}return e.extractions!==void 0&&(n.extractions=r.stringList(e.extractions,`${t}/extractions`,z,`a field name`)),n}),n.fields=r.section(e.fields,`/fields`,z,(e,t)=>r.pattern(e,t,L,`a Grail field name such as "host.name"`)?e:void 0),n.fieldTypes=r.section(e.fieldTypes,`/fieldTypes`,L,(e,n)=>{if(typeof e==`string`&&H.includes(e))return e;t.push({path:n,message:`Use one of: ${H.join(`, `)}.`})}),n.extractions=r.section(e.extractions,`/extractions`,z,(e,t)=>{if(!r.record(e,t,[`from`,`dpl`]))return;let n=e.from===void 0?`content`:e.from;if(r.pattern(n,`${t}/from`,L,`a Grail field name`)&&r.text(e.dpl,`${t}/dpl`))return{from:n,dpl:e.dpl}}),n.macros=r.section(e.macros,`/macros`,/^[A-Za-z0-9_.:-]+(\(\d{1,2}\))?$/,(e,n,i)=>{let a=typeof e==`string`?e:q(e)?e.definition:void 0;if(q(e)&&!r.record(e,n,[`args`,`definition`])||!r.text(a,typeof e==`string`?n:`${n}/definition`))return;let o=q(e)&&e.args!==void 0?r.stringList(e.args,`${n}/args`,/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,`an argument name`):[],s=/\((\d+)\)$/.exec(i),c=s?Number(s[1]):0;if(c!==o.length)t.push({path:n,message:`The macro name says ${c} argument(s) but "args" lists ${o.length}.`});else return{args:o,definition:a}}),n.lookups=r.section(e.lookups,`/lookups`,z,(e,n)=>{if(!r.record(e,n,[`path`,`key`,`columns`])||!r.pattern(e.path,`${n}/path`,R,`a Grail file path starting with "/lookups/"`))return;if(e.path.includes(`..`)){t.push({path:`${n}/path`,message:`The path must not contain "..".`});return}let i={path:e.path};return e.key!==void 0&&r.pattern(e.key,`${n}/key`,L,`a column name`)&&(i.key=e.key),e.columns!==void 0&&(i.columns=r.stringList(e.columns,`${n}/columns`,L,`a column name`)),i}),n.eventtypes=r.section(e.eventtypes,`/eventtypes`,z,(e,t)=>r.dqlFilter(e,t)),n.tags=r.section(e.tags,`/tags`,z,(e,t)=>r.dqlFilter(e,t)),n.metrics=r.section(e.metrics,`/metrics`,z,(e,t)=>r.pattern(e,t,L,`a metric key such as "dt.host.cpu.usage"`)?e:void 0),n.datamodels=r.section(e.datamodels,`/datamodels`,B,(e,t)=>{if(!r.record(e,t,[`dataObject`,`buckets`,`filter`,`fields`]))return;let i=n.defaults.dataObject;e.dataObject!==void 0&&r.pattern(e.dataObject,`${t}/dataObject`,F,`a data object name such as "logs"`)&&(i=e.dataObject);let a=e.buckets===void 0?[]:r.stringList(e.buckets,`${t}/buckets`,I,`a bucket name`),o=r.section(e.fields,`${t}/fields`,z,(e,t)=>r.pattern(e,t,L,`a Grail field name such as "user.name"`)?e:void 0),s={dataObject:i,buckets:a,fields:o};if(e.filter!==void 0){let n=r.dqlFilter(e.filter,`${t}/filter`);n!==void 0&&(s.filter=n)}return s}),t.length>0?{ok:!1,issues:t}:{ok:!0,value:n}}var K=class{issues;constructor(e){this.issues=e}record(e,t,n){if(!q(e))return this.issues.push({path:t,message:`Expected a map.`}),!1;for(let r of Object.keys(e))n.includes(r)||this.issues.push({path:`${t}/${J(r)}`,message:`Unknown key "${r}". Allowed: ${n.join(`, `)}.`});return!0}string(e,t){return typeof e==`string`||(this.issues.push({path:t,message:`Expected text.`}),!1)}text(e,t){return this.string(e,t)?e.length===0||e.length>W?(this.issues.push({path:t,message:`Expected 1 to ${W} characters.`}),!1):!0:!1}pattern(e,t,n,r){return typeof e!=`string`||!n.test(e)?(this.issues.push({path:t,message:`Expected ${r}.`}),!1):!0}stringList(e,t,n,r){if(!Array.isArray(e))return this.issues.push({path:t,message:`Expected a list.`}),[];if(e.length>U)return this.issues.push({path:t,message:`At most ${U} entries.`}),[];let i=[];return e.forEach((e,a)=>{this.pattern(e,`${t}/${a}`,n,r)&&i.push(e)}),i}dqlFilter(e,t){if(!this.text(e,t))return;let n=A(e);if(n.ok)return e;{let e=n.issues[0];this.issues.push({path:t,message:`Not a valid DQL condition: ${e?.message??`syntax error`}`})}}section(e,t,n,r){let i=new Map;if(e==null)return i;if(!q(e))return this.issues.push({path:t,message:`Expected a map.`}),i;let a=Object.keys(e);if(a.length>U)return this.issues.push({path:t,message:`At most ${U} entries.`}),i;for(let o of a){let a=`${t}/${J(o)}`;if(!n.test(o)){this.issues.push({path:a,message:`"${o}" is not a valid name here.`});continue}let s=r(e[o],a,o);s!==void 0&&i.set(o,s)}return i}};function q(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function J(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}var Y=/^(UTC|Z|[+-]\d{2}:\d{2})$/;function re(e){if(Y.test(e))return!0;if(!/^[A-Za-z_]+(\/[A-Za-z0-9_+-]+){0,2}$/.test(e))return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}),!0}catch{return!1}}var X=p(m(),1),ie=`
|
|
2
2
|
fields:
|
|
3
3
|
level: loglevel
|
|
4
4
|
duration: duration
|