@opencraw/cli 0.1.53 → 0.1.55

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/main.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { Terminal } from './terminal';
2
+ /**
3
+ * Runs one cli invocation: parses argv, dispatches to a use case, writes
4
+ * through `terminal`. Never throws; a bad command or a use case failure both
5
+ * become a non-zero return.
6
+ *
7
+ * @param argv - Arguments after the program name.
8
+ * @param terminal - Where output goes.
9
+ * @returns The process exit code.
10
+ */
11
+ export declare function main(argv: readonly string[], terminal: Terminal): Promise<number>;
12
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1,6 @@
1
+ export { probePage, probeUrl } from './probe-page.use-case';
2
+ export type { ProbeResult, ProbeOptions } from './probe-page.use-case';
3
+ export { probeReport, pdfReport, workbookReport, deckReport, jsonReport, xmlReport } from './probe-report.mapper';
4
+ export { findData } from '@opencraw/probe';
5
+ export type { ProbeFindings, JsonLdFinding, InlineJsonFinding } from '@opencraw/probe';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,65 @@
1
+ import type { AccessConfig, AccessPlugin } from '@opencraw/core';
2
+ import { findData } from '@opencraw/probe';
3
+ import type { DeckFindings, HtmlFindings, JsonFindings, PdfFindings, WorkbookFindings, XmlFindings } from '@opencraw/probe';
4
+ import type { CommonOptions } from '../arguments';
5
+ import type { Terminal } from '../terminal';
6
+ /** What fetching and, optionally, rendering a page found. */
7
+ export interface ProbeResult {
8
+ url: string;
9
+ status: number;
10
+ findings: ReturnType<typeof findData>;
11
+ /** JSON responses observed while the page rendered; empty unless `options.browser` was set. */
12
+ observed: string[];
13
+ /** Present when the URL is a PDF: its rows and likely table headers. */
14
+ pdf?: PdfFindings;
15
+ /** Present when the URL is a CSV or a spreadsheet: its sheets, rows and likely table headers. */
16
+ workbook?: WorkbookFindings;
17
+ /** Present when the URL is a presentation: its slides, table headers, charts and text-box grids. */
18
+ deck?: DeckFindings;
19
+ /** Present when the URL is JSON, JSON Lines or YAML: its structure and record lists. */
20
+ json?: JsonFindings;
21
+ /** Present for HTML: its tables' headers; for rendered Markdown also its outline and front matter. */
22
+ html?: HtmlFindings;
23
+ /** Present for XML: its namespaces, repeated elements and structure. */
24
+ xml?: XmlFindings;
25
+ }
26
+ /** How to probe: the cli's options, plus what a service probing for others sets. */
27
+ export interface ProbeOptions extends CommonOptions {
28
+ /** Also render the page and list the JSON it fetches. */
29
+ browser: boolean;
30
+ /** The only hosts the probe may reach, as `CrawlOptions.allowedHosts`; local paths and `file:` are refused. */
31
+ allowedHosts?: string[];
32
+ /** An access config already loaded, instead of `access` (a file). `accessProfile` still picks the default. */
33
+ accessConfig?: AccessConfig;
34
+ /** Access plugins already loaded, instead of those in `plugins` (a module). */
35
+ accessPlugins?: AccessPlugin[];
36
+ }
37
+ /**
38
+ * Fetches a page and finds where its data lives, through the access profile the
39
+ * options name (direct without one). With `browser: true` it also
40
+ * renders the page and lists the JSON responses seen while it settles, which
41
+ * finds endpoints a plain fetch of the initial HTML cannot. No `Terminal`
42
+ * involved: the cli's `probePage` and `@opencraw/mcp`'s probe tool both
43
+ * build on this, one printing the result, the other returning it as data.
44
+ *
45
+ * A PDF, a spreadsheet, a CSV or a presentation (by content type, or a local
46
+ * path) is read instead: its rows, and the rows that look like table headers.
47
+ *
48
+ * @param url - The page to probe, or a local file path.
49
+ * @param options - Browser path, TLS and user agent, plus whether to render.
50
+ * @returns What was found.
51
+ * @throws Error when the fetch itself fails.
52
+ */
53
+ export declare function probeUrl(url: string, options: ProbeOptions): Promise<ProbeResult>;
54
+ /**
55
+ * Fetches a page and reports where its data lives, to a `Terminal`.
56
+ *
57
+ * @param url - The page to probe.
58
+ * @param options - Browser path, TLS and user agent, plus whether to render.
59
+ * @param terminal - Where the report goes.
60
+ * @returns The exit code: 0, or 1 on a fetch failure.
61
+ */
62
+ export declare function probePage(url: string, options: {
63
+ browser: boolean;
64
+ } & CommonOptions, terminal: Terminal): Promise<number>;
65
+ //# sourceMappingURL=probe-page.use-case.d.ts.map
@@ -0,0 +1,59 @@
1
+ import type { DeckFindings, HtmlFindings, JsonFindings, PdfFindings, ProbeFindings, WorkbookFindings, XmlFindings } from '@opencraw/probe';
2
+ /**
3
+ * Renders a probe's findings as text.
4
+ *
5
+ * @param url - The URL probed.
6
+ * @param status - The HTTP status.
7
+ * @param findings - What `findData` found.
8
+ * @param observed - JSON responses a browser saw, when `--browser` was used.
9
+ * @param html - The tables (and, for Markdown, the outline and front matter) found.
10
+ * @returns The report.
11
+ */
12
+ export declare function probeReport(url: string, status: number, findings: ProbeFindings, observed?: string[], html?: HtmlFindings): string;
13
+ /**
14
+ * Renders what a probe found in a PDF as text.
15
+ *
16
+ * @param url - The URL or file probed.
17
+ * @param pdf - What `describePdf` found.
18
+ * @returns The report.
19
+ */
20
+ export declare function pdfReport(url: string, pdf: PdfFindings): string;
21
+ /**
22
+ * Formats what a probe found in a workbook (a CSV or a spreadsheet): its sheets,
23
+ * the rows that look like table headers with a selector for each, and the first
24
+ * rows.
25
+ *
26
+ * @param url - The workbook's URL.
27
+ * @param workbook - The findings.
28
+ * @returns The report.
29
+ */
30
+ export declare function workbookReport(url: string, workbook: WorkbookFindings): string;
31
+ /**
32
+ * Formats what a probe found in a deck (a presentation): its slides, the native
33
+ * tables' headers with a selector for each, its charts, and the slides whose
34
+ * text boxes look like a table.
35
+ *
36
+ * @param url - The deck's URL.
37
+ * @param deck - The findings.
38
+ * @returns The report.
39
+ */
40
+ export declare function deckReport(url: string, deck: DeckFindings): string;
41
+ /**
42
+ * Formats what a probe found in JSON data: its record lists with the path a
43
+ * `jsonpath` extract needs, then its structure.
44
+ *
45
+ * @param url - The document's URL.
46
+ * @param json - The findings.
47
+ * @returns The report.
48
+ */
49
+ export declare function jsonReport(url: string, json: JsonFindings): string;
50
+ /**
51
+ * Formats what a probe found in an XML document: its namespaces and the
52
+ * `namespaces` an `xpath` extract needs, the elements that repeat, and its structure.
53
+ *
54
+ * @param url - The document's URL.
55
+ * @param xml - The findings.
56
+ * @returns The report.
57
+ */
58
+ export declare function xmlReport(url: string, xml: XmlFindings): string;
59
+ //# sourceMappingURL=probe-report.mapper.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { readRecipeFiles } from './read-recipe-files.repository';
2
+ export type { RecipeFiles } from './read-recipe-files.repository';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,26 @@
1
+ import type { RecipeSource } from '@opencraw/core';
2
+ /** Decoded recipes, split by their `kind`. */
3
+ export interface RecipeFiles {
4
+ /** `path` is the file, `path:line` in a JSON Lines file, or a label (`recipes[0]`) for one from memory. */
5
+ outputs: {
6
+ path: string;
7
+ recipe: unknown;
8
+ }[];
9
+ inputs: {
10
+ path: string;
11
+ recipe: unknown;
12
+ }[];
13
+ /** Documents that are neither; listed so a typo in `kind` does not pass silently. */
14
+ others: string[];
15
+ }
16
+ /**
17
+ * Reads recipes, expanding directories to their `.json` and `.jsonl` files
18
+ * (sorted, not recursive), and sorts them by `kind`. The command line passes
19
+ * paths; the MCP server also passes recipes it was handed inline.
20
+ *
21
+ * @param sources - Files or directories, or any other recipe source core reads.
22
+ * @returns The decoded recipes.
23
+ * @throws Error naming a file that is not JSON or JSON Lines.
24
+ */
25
+ export declare function readRecipeFiles(sources: RecipeSource): Promise<RecipeFiles>;
26
+ //# sourceMappingURL=read-recipe-files.repository.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { runRecipes } from './run-recipes.use-case';
2
+ export { loadForRun } from './load-for-run.use-case';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { RecipeSet, RecipeSource } from '@opencraw/core';
2
+ /**
3
+ * Loads and binds the recipes `run` needs, filtered to the input ids in `only`
4
+ * when given.
5
+ *
6
+ * @param sources - Recipe files or directories (or recipes the MCP server was handed inline).
7
+ * @param only - Input recipe ids to keep; empty keeps all.
8
+ * @returns The bound set.
9
+ * @throws Error when there is not exactly one output recipe.
10
+ * @throws RecipeValidationError, RecipeBindingError on a bad recipe.
11
+ */
12
+ export declare function loadForRun(sources: RecipeSource, only: readonly string[]): Promise<RecipeSet>;
13
+ //# sourceMappingURL=load-for-run.use-case.d.ts.map
@@ -0,0 +1,17 @@
1
+ import type { Command } from '../arguments';
2
+ import type { Terminal } from '../terminal';
3
+ /**
4
+ * Crawls the recipes at `paths` and reports what happened.
5
+ *
6
+ * `--dry-run` caps every input at one record, attaches the scope each record
7
+ * was mapped from, and prints them side by side instead of writing them, so a
8
+ * recipe under construction can be checked without a full run.
9
+ *
10
+ * @param command - The parsed `run` command.
11
+ * @param terminal - Where records, the trace and errors go.
12
+ * @returns The exit code: 0, or 1 on a load failure or a recipe error.
13
+ */
14
+ export declare function runRecipes(command: Extract<Command, {
15
+ name: 'run';
16
+ }>, terminal: Terminal): Promise<number>;
17
+ //# sourceMappingURL=run-recipes.use-case.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { runStudio } from './run-studio.use-case';
2
+ export type { StudioModule } from './run-studio.use-case';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,32 @@
1
+ import { loadPlugins } from '../hooks-module';
2
+ import type { PluginModule } from '../hooks-module';
3
+ import type { Terminal } from '../terminal';
4
+ /** The one export the cli needs from `@opencraw/studio`. */
5
+ export interface StudioModule {
6
+ main: (argv: readonly string[], options?: {
7
+ plugins?: PluginModule & {
8
+ source: string;
9
+ };
10
+ open?: string;
11
+ }) => Promise<void>;
12
+ }
13
+ /**
14
+ * Runs `opencraw studio [folder]`: imports `@opencraw/studio` lazily and
15
+ * delegates to its own `main`, which starts the server, prints the URL with
16
+ * the token, and keeps running until interrupted (Ctrl+C) — the cli's own
17
+ * call does not return before that. `@opencraw/studio` is an optional peer
18
+ * dependency (`peerDependenciesMeta`), never a hard one: the cli stays light
19
+ * for callers who only need to crawl. When it is not installed, this prints
20
+ * how to add it instead of letting a raw `ERR_MODULE_NOT_FOUND` stack trace
21
+ * through.
22
+ *
23
+ * @param folder - The recipe folder to open; `@opencraw/studio`'s own default (the current directory) when omitted.
24
+ * @param terminal - Where output goes.
25
+ * @param importStudio - How the module is loaded; the real dynamic `import()` by default, replaced in tests.
26
+ * @param pluginsFile - A hooks or plugins module (`--hooks`, issue #150), loaded here, on the command line's own authority, and handed to Studio: the server never loads code itself.
27
+ * @param load - How the module is read; `loadPlugins` unless a test says otherwise.
28
+ * @param open - A folder, recipe file or document (`--open`, issue #235): the printed link opens it straight away.
29
+ * @returns The exit code: 0 once the server has stopped, 1 when `@opencraw/studio` is missing.
30
+ */
31
+ export declare function runStudio(folder: string | undefined, terminal: Terminal, importStudio?: () => Promise<StudioModule>, pluginsFile?: string, load?: typeof loadPlugins, open?: string): Promise<number>;
32
+ //# sourceMappingURL=run-studio.use-case.d.ts.map
@@ -0,0 +1,3 @@
1
+ export type { Terminal } from './terminal.contract';
2
+ export { processTerminal } from './terminal.client';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { Terminal } from './terminal.contract';
2
+ /** The process's stdout and stderr. */
3
+ export declare function processTerminal(): Terminal;
4
+ //# sourceMappingURL=terminal.client.d.ts.map
@@ -0,0 +1,6 @@
1
+ /** Where a command writes: results to `out`, diagnostics and progress to `err`. Tests capture both. */
2
+ export interface Terminal {
3
+ out: (line: string) => void;
4
+ err: (line: string) => void;
5
+ }
6
+ //# sourceMappingURL=terminal.contract.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { validateRecipes } from './validate-recipes.use-case';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { Terminal } from '../terminal';
2
+ /**
3
+ * Loads and binds recipe files, printing every problem with its JSON path.
4
+ *
5
+ * @param paths - Recipe files or directories.
6
+ * @param terminal - Where results go.
7
+ * @returns The exit code: 0 when the recipes bind cleanly, 1 otherwise.
8
+ */
9
+ export declare function validateRecipes(paths: readonly string[], terminal: Terminal): Promise<number>;
10
+ //# sourceMappingURL=validate-recipes.use-case.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencraw/cli",
3
- "version": "0.1.53",
3
+ "version": "0.1.55",
4
4
  "type": "module",
5
5
  "main": "./dist/index.esm.js",
6
6
  "module": "./dist/index.esm.js",
@@ -24,12 +24,12 @@
24
24
  "!**/*.js.map"
25
25
  ],
26
26
  "dependencies": {
27
- "@opencraw/core": "^0.1.47",
28
- "@opencraw/probe": "^0.0.30",
27
+ "@opencraw/core": "^0.2.0",
28
+ "@opencraw/probe": "^0.0.32",
29
29
  "playwright": "^1.63.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@opencraw/studio": "^0.0.42"
32
+ "@opencraw/studio": "^0.0.1"
33
33
  },
34
34
  "peerDependenciesMeta": {
35
35
  "@opencraw/studio": {
@@ -56,39 +56,11 @@
56
56
  "node": ">=22"
57
57
  },
58
58
  "sideEffects": false,
59
- "nx": {
60
- "targets": {
61
- "typecheck": {
62
- "dependsOn": [
63
- "^build"
64
- ]
65
- },
66
- "lint": {
67
- "dependsOn": [
68
- "^build"
69
- ]
70
- },
71
- "e2e": {
72
- "executor": "nx:run-commands",
73
- "dependsOn": [
74
- "build",
75
- {
76
- "projects": [
77
- "@opencraw/core"
78
- ],
79
- "target": "e2e"
80
- }
81
- ],
82
- "inputs": [
83
- "default",
84
- "^production",
85
- "{workspaceRoot}/packages/core/e2e/**"
86
- ],
87
- "options": {
88
- "command": "tsc -p tsconfig.e2e.json && jest --config jest.e2e.config.cts",
89
- "cwd": "packages/cli"
90
- }
91
- }
92
- }
59
+ "scripts": {
60
+ "build": "esbuild src/index.ts --bundle --packages=external --format=esm --outfile=dist/index.esm.js --sourcemap && tsc -p tsconfig.lib.json --emitDeclarationOnly --declaration --declarationDir dist/src --tsBuildInfoFile dist/src/tsconfig.lib.tsbuildinfo && node ../../declaration-specifiers.mjs dist/src",
61
+ "e2e": "tsc -p tsconfig.e2e.json && jest --config jest.e2e.config.cts",
62
+ "lint": "eslint .",
63
+ "test": "jest",
64
+ "typecheck": "tsc --build tsconfig.json --emitDeclarationOnly"
93
65
  }
94
66
  }