@chrismo/superkit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +29 -0
- package/README.md +26 -0
- package/dist/cli/pager.d.ts +6 -0
- package/dist/cli/pager.d.ts.map +1 -0
- package/dist/cli/pager.js +21 -0
- package/dist/cli/pager.js.map +1 -0
- package/dist/cli/skdoc.d.ts +3 -0
- package/dist/cli/skdoc.d.ts.map +1 -0
- package/dist/cli/skdoc.js +42 -0
- package/dist/cli/skdoc.js.map +1 -0
- package/dist/cli/skgrok.d.ts +3 -0
- package/dist/cli/skgrok.d.ts.map +1 -0
- package/dist/cli/skgrok.js +21 -0
- package/dist/cli/skgrok.js.map +1 -0
- package/dist/cli/skops.d.ts +3 -0
- package/dist/cli/skops.d.ts.map +1 -0
- package/dist/cli/skops.js +32 -0
- package/dist/cli/skops.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/docs.d.ts +11 -0
- package/dist/lib/docs.d.ts.map +1 -0
- package/dist/lib/docs.js +29 -0
- package/dist/lib/docs.js.map +1 -0
- package/dist/lib/expert-sections.d.ts +32 -0
- package/dist/lib/expert-sections.d.ts.map +1 -0
- package/dist/lib/expert-sections.js +130 -0
- package/dist/lib/expert-sections.js.map +1 -0
- package/dist/lib/grok.d.ts +15 -0
- package/dist/lib/grok.d.ts.map +1 -0
- package/dist/lib/grok.js +57 -0
- package/dist/lib/grok.js.map +1 -0
- package/dist/lib/help.d.ts +20 -0
- package/dist/lib/help.d.ts.map +1 -0
- package/dist/lib/help.js +163 -0
- package/dist/lib/help.js.map +1 -0
- package/dist/lib/recipes.d.ts +29 -0
- package/dist/lib/recipes.d.ts.map +1 -0
- package/dist/lib/recipes.js +133 -0
- package/dist/lib/recipes.js.map +1 -0
- package/dist/superkit.tar.gz +0 -0
- package/docs/grok-patterns.sup +89 -0
- package/docs/recipes/array.md +66 -0
- package/docs/recipes/array.spq +31 -0
- package/docs/recipes/character.md +110 -0
- package/docs/recipes/character.spq +57 -0
- package/docs/recipes/escape.md +159 -0
- package/docs/recipes/escape.spq +102 -0
- package/docs/recipes/format.md +51 -0
- package/docs/recipes/format.spq +24 -0
- package/docs/recipes/index.md +23 -0
- package/docs/recipes/integer.md +101 -0
- package/docs/recipes/integer.spq +53 -0
- package/docs/recipes/records.md +84 -0
- package/docs/recipes/records.spq +61 -0
- package/docs/recipes/string.md +177 -0
- package/docs/recipes/string.spq +105 -0
- package/docs/superdb-expert.md +929 -0
- package/docs/tutorials/bash_to_sup.md +123 -0
- package/docs/tutorials/chess-tiebreaks.md +233 -0
- package/docs/tutorials/debug.md +439 -0
- package/docs/tutorials/fork_for_window.md +296 -0
- package/docs/tutorials/grok.md +166 -0
- package/docs/tutorials/index.md +10 -0
- package/docs/tutorials/joins.md +79 -0
- package/docs/tutorials/moar_subqueries.md +35 -0
- package/docs/tutorials/subqueries.md +236 -0
- package/docs/tutorials/sup_to_bash.md +164 -0
- package/docs/tutorials/super_db_update.md +34 -0
- package/docs/tutorials/unnest.md +113 -0
- package/docs/zq-to-super-upgrades.md +549 -0
- package/package.json +46 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD-3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Chris Morris and contributors
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# SuperKit
|
|
2
|
+
|
|
3
|
+
Documentation, tutorials, and recipes for [SuperDB](https://superdb.org/).
|
|
4
|
+
|
|
5
|
+
**Website:** [chrismo.github.io/superkit](https://chrismo.github.io/superkit/)
|
|
6
|
+
|
|
7
|
+
## Content
|
|
8
|
+
|
|
9
|
+
- **Expert Guide** — Comprehensive SuperSQL syntax reference
|
|
10
|
+
- **Upgrade Guide** — Migration guide from zq to SuperDB
|
|
11
|
+
- **Tutorials** — Step-by-step guides for common patterns
|
|
12
|
+
|
|
13
|
+
## How it works
|
|
14
|
+
|
|
15
|
+
Content is authored in [superdb-mcp](https://github.com/chrismo/superdb-mcp) and auto-synced here via GitHub Action. The site is built with Jekyll using the [Just the Docs](https://just-the-docs.com/) theme and deployed via GitHub Pages.
|
|
16
|
+
|
|
17
|
+
`changelog.jsup` is kept for historical reference from the original SuperKit project.
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
SuperKit is licensed under the [BSD-3-Clause License](LICENSE.txt).
|
|
22
|
+
|
|
23
|
+
SuperKit is an independent project that documents and provides recipes for
|
|
24
|
+
[SuperDB](https://github.com/brimdata/super), which is licensed under the
|
|
25
|
+
[SuperDB Source Available License](https://github.com/brimdata/super/blob/main/LICENSE.md).
|
|
26
|
+
SuperKit does not distribute SuperDB source code or binaries.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pager.d.ts","sourceRoot":"","sources":["../../src/cli/pager.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAcxC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
import { writeFileSync } from 'fs';
|
|
3
|
+
import { tmpdir } from 'os';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
/**
|
|
6
|
+
* Pipe text through $PAGER (defaults to `less -FRX`).
|
|
7
|
+
* Falls back to stdout if no pager available or not a TTY.
|
|
8
|
+
*/
|
|
9
|
+
export function pager(text) {
|
|
10
|
+
if (!process.stdout.isTTY) {
|
|
11
|
+
process.stdout.write(text);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const pagerCmd = process.env.PAGER || 'less';
|
|
15
|
+
const args = pagerCmd === 'less' ? ['-FRX'] : [];
|
|
16
|
+
// Write to a temp file so the pager can seek
|
|
17
|
+
const tmp = join(tmpdir(), `skdoc-${process.pid}.txt`);
|
|
18
|
+
writeFileSync(tmp, text);
|
|
19
|
+
spawnSync(pagerCmd, [...args, tmp], { stdio: 'inherit' });
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=pager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pager.js","sourceRoot":"","sources":["../../src/cli/pager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,IAAY;IAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,MAAM,CAAC;IAC7C,MAAM,IAAI,GAAG,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEjD,6CAA6C;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,SAAS,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;IACvD,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAEzB,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skdoc.d.ts","sourceRoot":"","sources":["../../src/cli/skdoc.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { superHelp } from '../lib/help.js';
|
|
3
|
+
import { pager } from './pager.js';
|
|
4
|
+
const topic = process.argv[2];
|
|
5
|
+
if (!topic) {
|
|
6
|
+
const result = superHelp('expert');
|
|
7
|
+
if (!result.success) {
|
|
8
|
+
console.error(result.error);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
const lines = [
|
|
12
|
+
'SuperKit Documentation Browser',
|
|
13
|
+
'',
|
|
14
|
+
'Usage: skdoc <topic>',
|
|
15
|
+
'',
|
|
16
|
+
'Topics:',
|
|
17
|
+
' expert Expert guide overview (sections listed below)',
|
|
18
|
+
' expert:all Full expert guide',
|
|
19
|
+
' expert:<section> Specific expert section',
|
|
20
|
+
' upgrade SuperDB upgrade/migration guide',
|
|
21
|
+
' tutorials List available tutorials',
|
|
22
|
+
' tutorial:<name> Specific tutorial',
|
|
23
|
+
'',
|
|
24
|
+
];
|
|
25
|
+
if (result.sections) {
|
|
26
|
+
lines.push('Expert guide sections:');
|
|
27
|
+
for (const s of result.sections) {
|
|
28
|
+
lines.push(` expert:${s.slug.padEnd(24)} ${s.title}`);
|
|
29
|
+
}
|
|
30
|
+
lines.push('');
|
|
31
|
+
}
|
|
32
|
+
pager(lines.join('\n'));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const result = superHelp(topic);
|
|
36
|
+
if (!result.success) {
|
|
37
|
+
console.error(result.error);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
pager(result.content);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=skdoc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skdoc.js","sourceRoot":"","sources":["../../src/cli/skdoc.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI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|
|
1
|
+
{"version":3,"file":"skgrok.d.ts","sourceRoot":"","sources":["../../src/cli/skgrok.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { superGrokPatterns } from '../lib/grok.js';
|
|
3
|
+
import { pager } from './pager.js';
|
|
4
|
+
const query = process.argv[2];
|
|
5
|
+
const result = superGrokPatterns(query);
|
|
6
|
+
if (!result.success) {
|
|
7
|
+
console.error(result.error);
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
if (result.count === 0) {
|
|
11
|
+
console.error(query ? `No grok patterns matching "${query}"` : 'No grok patterns found');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const maxName = Math.max(...result.patterns.map(p => p.pattern_name.length));
|
|
15
|
+
const lines = result.patterns.map(p => {
|
|
16
|
+
const name = p.pattern_name.padEnd(maxName + 2);
|
|
17
|
+
const regex = p.regex.length > 80 ? p.regex.slice(0, 77) + '...' : p.regex;
|
|
18
|
+
return `${name}${regex}`;
|
|
19
|
+
});
|
|
20
|
+
pager(lines.join('\n') + '\n');
|
|
21
|
+
//# sourceMappingURL=skgrok.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skgrok.js","sourceRoot":"","sources":["../../src/cli/skgrok.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9B,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAExC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;IACvB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,8BAA8B,KAAK,GAAG,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC;IACzF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7E,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;IACpC,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC3E,OAAO,GAAG,IAAI,GAAG,KAAK,EAAE,CAAC;AAC3B,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skops.d.ts","sourceRoot":"","sources":["../../src/cli/skops.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { superRecipes } from '../lib/recipes.js';
|
|
3
|
+
import { pager } from './pager.js';
|
|
4
|
+
const query = process.argv[2];
|
|
5
|
+
const result = superRecipes(query);
|
|
6
|
+
if (!result.success) {
|
|
7
|
+
console.error(result.error);
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
if (result.count === 0) {
|
|
11
|
+
console.error(query ? `No recipes matching "${query}"` : 'No recipes found');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const lines = [];
|
|
15
|
+
for (const r of result.recipes) {
|
|
16
|
+
const argStr = r.args.length > 0
|
|
17
|
+
? r.args.map(a => a.name).join(', ')
|
|
18
|
+
: '';
|
|
19
|
+
const sig = r.type === 'op'
|
|
20
|
+
? `op ${r.name} ${argStr}`
|
|
21
|
+
: `${r.name}(${argStr})`;
|
|
22
|
+
lines.push(`${sig}`);
|
|
23
|
+
lines.push(` ${r.description}`);
|
|
24
|
+
if (r.examples.length > 0) {
|
|
25
|
+
for (const ex of r.examples) {
|
|
26
|
+
lines.push(` ${ex.i} => ${ex.o}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
lines.push('');
|
|
30
|
+
}
|
|
31
|
+
pager(lines.join('\n'));
|
|
32
|
+
//# sourceMappingURL=skops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skops.js","sourceRoot":"","sources":["../../src/cli/skops.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9B,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AAEnC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;IACvB,OAAO,CAAC,K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
export { getDocsDir, getRecipeFiles } from './lib/docs.js';
|
|
2
|
+
export { superHelp } from './lib/help.js';
|
|
3
|
+
export type { HelpResult } from './lib/help.js';
|
|
4
|
+
export { getExpertDoc, buildOverview, parseExpertDoc, clearExpertCache, SECTION_SLUGS } from './lib/expert-sections.js';
|
|
5
|
+
export type { ExpertSection, ParsedExpertDoc } from './lib/expert-sections.js';
|
|
6
|
+
export { superGrokPatterns } from './lib/grok.js';
|
|
7
|
+
export type { GrokPattern, GrokPatternsResult } from './lib/grok.js';
|
|
8
|
+
export { superRecipes } from './lib/recipes.js';
|
|
9
|
+
export type { RecipeFunction, RecipeArg, RecipeExample, RecipesResult } from './lib/recipes.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACxH,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Content resolution
|
|
2
|
+
export { getDocsDir, getRecipeFiles } from './lib/docs.js';
|
|
3
|
+
// Help / documentation
|
|
4
|
+
export { superHelp } from './lib/help.js';
|
|
5
|
+
// Expert guide sections
|
|
6
|
+
export { getExpertDoc, buildOverview, parseExpertDoc, clearExpertCache, SECTION_SLUGS } from './lib/expert-sections.js';
|
|
7
|
+
// Grok patterns
|
|
8
|
+
export { superGrokPatterns } from './lib/grok.js';
|
|
9
|
+
// Recipes
|
|
10
|
+
export { superRecipes } from './lib/recipes.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE3D,uBAAuB;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,wBAAwB;AACxB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGxH,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,UAAU;AACV,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the docs/ directory path.
|
|
3
|
+
* Works whether superkit is installed globally (CLI) or in node_modules (MCP dependency).
|
|
4
|
+
*/
|
|
5
|
+
export declare function getDocsDir(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Get paths to all recipe .spq files.
|
|
8
|
+
* Useful for building -I flags when wrapping the super binary.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRecipeFiles(): string[];
|
|
11
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/lib/docs.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAUzC"}
|
package/dist/lib/docs.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readdirSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = dirname(__filename);
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the docs/ directory path.
|
|
8
|
+
* Works whether superkit is installed globally (CLI) or in node_modules (MCP dependency).
|
|
9
|
+
*/
|
|
10
|
+
export function getDocsDir() {
|
|
11
|
+
return join(__dirname, '../../docs');
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get paths to all recipe .spq files.
|
|
15
|
+
* Useful for building -I flags when wrapping the super binary.
|
|
16
|
+
*/
|
|
17
|
+
export function getRecipeFiles() {
|
|
18
|
+
const recipesDir = join(getDocsDir(), 'recipes');
|
|
19
|
+
try {
|
|
20
|
+
return readdirSync(recipesDir)
|
|
21
|
+
.filter(f => f.endsWith('.spq'))
|
|
22
|
+
.sort()
|
|
23
|
+
.map(f => join(recipesDir, f));
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/lib/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,EAAE,SAAS,CAAC,CAAC;IACjD,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,UAAU,CAAC;aAC3B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;aAC/B,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface ExpertSection {
|
|
2
|
+
slug: string;
|
|
3
|
+
title: string;
|
|
4
|
+
content: string;
|
|
5
|
+
lines: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ParsedExpertDoc {
|
|
8
|
+
preamble: string;
|
|
9
|
+
sections: ExpertSection[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Explicit slug map for intuitive, stable slugs.
|
|
13
|
+
* Keys are the exact ## heading text (without the ## prefix).
|
|
14
|
+
*/
|
|
15
|
+
export declare const SECTION_SLUGS: Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Parse the expert markdown into preamble + sections split on ## headings.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseExpertDoc(markdown: string): ParsedExpertDoc;
|
|
20
|
+
/**
|
|
21
|
+
* Build the overview: preamble + inline sections (warning, core) + section index table.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildOverview(doc: ParsedExpertDoc): string;
|
|
24
|
+
/**
|
|
25
|
+
* Get the parsed expert doc, lazily reading and caching the file.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getExpertDoc(): ParsedExpertDoc;
|
|
28
|
+
/**
|
|
29
|
+
* Clear the cached expert doc (for tests).
|
|
30
|
+
*/
|
|
31
|
+
export declare function clearExpertCache(): void;
|
|
32
|
+
//# sourceMappingURL=expert-sections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expert-sections.d.ts","sourceRoot":"","sources":["../../src/lib/expert-sections.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAchD,CAAC;AAyBF;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAqChE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA0B1D;AAKD;;GAEG;AACH,wBAAgB,YAAY,IAAI,eAAe,CAO9C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { getDocsDir } from './docs.js';
|
|
4
|
+
/**
|
|
5
|
+
* Explicit slug map for intuitive, stable slugs.
|
|
6
|
+
* Keys are the exact ## heading text (without the ## prefix).
|
|
7
|
+
*/
|
|
8
|
+
export const SECTION_SLUGS = {
|
|
9
|
+
'Note on Zed/zq Compatibility': 'warning',
|
|
10
|
+
'Core Knowledge': 'core',
|
|
11
|
+
'Language Syntax Reference': 'syntax',
|
|
12
|
+
'PostgreSQL Compatibility & Traditional SQL': 'sql',
|
|
13
|
+
'Practical Query Patterns': 'patterns',
|
|
14
|
+
'Advanced SuperDB Features': 'advanced',
|
|
15
|
+
'Debugging Tips': 'debugging',
|
|
16
|
+
'Format Conversions': 'formats',
|
|
17
|
+
'Key Differences from SQL': 'differences',
|
|
18
|
+
'Pragmas': 'pragmas',
|
|
19
|
+
'SuperDB Quoting Rules (Bash Integration)': 'quoting',
|
|
20
|
+
'SuperDB Array Filtering (Critical Pattern)': 'arrays',
|
|
21
|
+
'Aggregate Functions': 'aggregates',
|
|
22
|
+
};
|
|
23
|
+
/** Slugs that are always included inline in the overview. */
|
|
24
|
+
const OVERVIEW_SLUGS = ['warning', 'core'];
|
|
25
|
+
/**
|
|
26
|
+
* Generate a slug from a heading by lowercasing and replacing non-alphanumeric runs with hyphens.
|
|
27
|
+
*/
|
|
28
|
+
function autoSlug(heading) {
|
|
29
|
+
return heading
|
|
30
|
+
.toLowerCase()
|
|
31
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
32
|
+
.replace(/^-|-$/g, '');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Strip YAML frontmatter (--- delimited) from markdown content.
|
|
36
|
+
*/
|
|
37
|
+
function stripFrontmatter(markdown) {
|
|
38
|
+
if (!markdown.startsWith('---'))
|
|
39
|
+
return markdown;
|
|
40
|
+
const endIdx = markdown.indexOf('---', 3);
|
|
41
|
+
if (endIdx === -1)
|
|
42
|
+
return markdown;
|
|
43
|
+
return markdown.slice(endIdx + 3).replace(/^\n+/, '');
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parse the expert markdown into preamble + sections split on ## headings.
|
|
47
|
+
*/
|
|
48
|
+
export function parseExpertDoc(markdown) {
|
|
49
|
+
const stripped = stripFrontmatter(markdown);
|
|
50
|
+
const lines = stripped.split('\n');
|
|
51
|
+
let preamble = '';
|
|
52
|
+
const sections = [];
|
|
53
|
+
let currentTitle = null;
|
|
54
|
+
let currentLines = [];
|
|
55
|
+
for (const line of lines) {
|
|
56
|
+
const match = line.match(/^## (.+)$/);
|
|
57
|
+
if (match) {
|
|
58
|
+
if (currentTitle !== null) {
|
|
59
|
+
const content = currentLines.join('\n').trim();
|
|
60
|
+
const title = currentTitle;
|
|
61
|
+
const slug = SECTION_SLUGS[title] ?? autoSlug(title);
|
|
62
|
+
sections.push({ slug, title, content: `## ${title}\n\n${content}`, lines: content.split('\n').length });
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
preamble = currentLines.join('\n').trim();
|
|
66
|
+
}
|
|
67
|
+
currentTitle = match[1];
|
|
68
|
+
currentLines = [];
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
currentLines.push(line);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (currentTitle !== null) {
|
|
75
|
+
const content = currentLines.join('\n').trim();
|
|
76
|
+
const title = currentTitle;
|
|
77
|
+
const slug = SECTION_SLUGS[title] ?? autoSlug(title);
|
|
78
|
+
sections.push({ slug, title, content: `## ${title}\n\n${content}`, lines: content.split('\n').length });
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
preamble = currentLines.join('\n').trim();
|
|
82
|
+
}
|
|
83
|
+
return { preamble, sections };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build the overview: preamble + inline sections (warning, core) + section index table.
|
|
87
|
+
*/
|
|
88
|
+
export function buildOverview(doc) {
|
|
89
|
+
const parts = [];
|
|
90
|
+
if (doc.preamble) {
|
|
91
|
+
parts.push(doc.preamble);
|
|
92
|
+
}
|
|
93
|
+
for (const slug of OVERVIEW_SLUGS) {
|
|
94
|
+
const section = doc.sections.find(s => s.slug === slug);
|
|
95
|
+
if (section) {
|
|
96
|
+
parts.push(section.content);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const remaining = doc.sections.filter(s => !OVERVIEW_SLUGS.includes(s.slug));
|
|
100
|
+
if (remaining.length > 0) {
|
|
101
|
+
parts.push('## Available Sections\n');
|
|
102
|
+
parts.push('Use `super_help` with topic `"expert:<slug>"` to read a specific section.\n');
|
|
103
|
+
parts.push('| Slug | Section | Lines |');
|
|
104
|
+
parts.push('|---|---|---|');
|
|
105
|
+
for (const section of remaining) {
|
|
106
|
+
parts.push(`| \`expert:${section.slug}\` | ${section.title} | ${section.lines} |`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return parts.join('\n\n');
|
|
110
|
+
}
|
|
111
|
+
// Lazy-cached parsed doc
|
|
112
|
+
let cachedDoc = null;
|
|
113
|
+
/**
|
|
114
|
+
* Get the parsed expert doc, lazily reading and caching the file.
|
|
115
|
+
*/
|
|
116
|
+
export function getExpertDoc() {
|
|
117
|
+
if (!cachedDoc) {
|
|
118
|
+
const filepath = join(getDocsDir(), 'superdb-expert.md');
|
|
119
|
+
const markdown = readFileSync(filepath, 'utf-8');
|
|
120
|
+
cachedDoc = parseExpertDoc(markdown);
|
|
121
|
+
}
|
|
122
|
+
return cachedDoc;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Clear the cached expert doc (for tests).
|
|
126
|
+
*/
|
|
127
|
+
export function clearExpertCache() {
|
|
128
|
+
cachedDoc = null;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=expert-sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expert-sections.js","sourceRoot":"","sources":["../../src/lib/expert-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAcvC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,8B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I,CAAC,eAAe,CAAC,CAAC;QAC5B,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,cAAc,OAAO,CAAC,IAAI,QAAQ,OAAO,CAAC,KAAK,MAAM,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED,yBAAyB;AACzB,IAAI,SAAS,GAA2B,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,EAAE,EAAE,mBAAmB,CAAC,CAAC;QACzD,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjD,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,SAAS,GAAG,IAAI,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface GrokPattern {
|
|
2
|
+
pattern_name: string;
|
|
3
|
+
regex: string;
|
|
4
|
+
}
|
|
5
|
+
export interface GrokPatternsResult {
|
|
6
|
+
success: boolean;
|
|
7
|
+
patterns: GrokPattern[];
|
|
8
|
+
count: number;
|
|
9
|
+
error: string | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Search/filter grok patterns by name or regex content.
|
|
13
|
+
*/
|
|
14
|
+
export declare function superGrokPatterns(query?: string): GrokPatternsResult;
|
|
15
|
+
//# sourceMappingURL=grok.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grok.d.ts","sourceRoot":"","sources":["../../src/lib/grok.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAuBD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAkCpE"}
|
package/dist/lib/grok.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { getDocsDir } from './docs.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parse the grok patterns .sup file into structured objects.
|
|
6
|
+
* Each line is a SUP record like: {pattern_name:"FOO",regex:"bar"}
|
|
7
|
+
*/
|
|
8
|
+
function loadGrokPatterns() {
|
|
9
|
+
const grokPatternsPath = join(getDocsDir(), 'grok-patterns.sup');
|
|
10
|
+
const content = readFileSync(grokPatternsPath, 'utf-8');
|
|
11
|
+
const lines = content.trim().split('\n').filter(Boolean);
|
|
12
|
+
return lines.map(line => {
|
|
13
|
+
const nameMatch = line.match(/pattern_name:"([^"]+)"/);
|
|
14
|
+
const regexMatch = line.match(/regex:"((?:[^"\\]|\\.)*)"/);
|
|
15
|
+
if (!nameMatch || !regexMatch) {
|
|
16
|
+
throw new Error(`Failed to parse grok pattern line: ${line}`);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
pattern_name: nameMatch[1],
|
|
20
|
+
regex: regexMatch[1],
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Search/filter grok patterns by name or regex content.
|
|
26
|
+
*/
|
|
27
|
+
export function superGrokPatterns(query) {
|
|
28
|
+
try {
|
|
29
|
+
const allPatterns = loadGrokPatterns();
|
|
30
|
+
if (!query) {
|
|
31
|
+
return {
|
|
32
|
+
success: true,
|
|
33
|
+
patterns: allPatterns,
|
|
34
|
+
count: allPatterns.length,
|
|
35
|
+
error: null,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const q = query.toLowerCase();
|
|
39
|
+
const filtered = allPatterns.filter(p => p.pattern_name.toLowerCase().includes(q) ||
|
|
40
|
+
p.regex.toLowerCase().includes(q));
|
|
41
|
+
return {
|
|
42
|
+
success: true,
|
|
43
|
+
patterns: filtered,
|
|
44
|
+
count: filtered.length,
|
|
45
|
+
error: null,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
patterns: [],
|
|
52
|
+
count: 0,
|
|
53
|
+
error: e instanceof Error ? e.message : String(e),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=grok.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grok.js","sourceRoot":"","sources":["../../src/lib/grok.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAcvC;;;GAGG;AACH,SAAS,gBAAgB;IACvB,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,EAAE,EAAE,mBAAmB,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzD,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACtB,MAAM,SAAS,GAA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EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;SAClD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface HelpResult {
|
|
2
|
+
success: boolean;
|
|
3
|
+
topic: string;
|
|
4
|
+
content: string;
|
|
5
|
+
sections?: Array<{
|
|
6
|
+
slug: string;
|
|
7
|
+
title: string;
|
|
8
|
+
lines: number;
|
|
9
|
+
}>;
|
|
10
|
+
web_url?: string;
|
|
11
|
+
error: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get help documentation by topic.
|
|
15
|
+
*
|
|
16
|
+
* Topics: expert, expert:all, expert:<slug>, upgrade, upgrade-guide, migration,
|
|
17
|
+
* tutorials, tutorial:<name>
|
|
18
|
+
*/
|
|
19
|
+
export declare function superHelp(topic: string): HelpResult;
|
|
20
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/lib/help.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AA2BD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAwInD"}
|