@opencraw/core 0.1.0 → 0.1.2
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/README.md +5 -2
- package/dist/index.esm.js +2648 -447
- package/dist/src/api-steps/extract-from-document.use-case.d.ts +16 -2
- package/dist/src/api-steps/index.d.ts +1 -1
- package/dist/src/api-steps/send-request.use-case.d.ts +2 -2
- package/dist/src/captcha/captcha-budget.model.d.ts +21 -0
- package/dist/src/captcha/captcha-detection.client.d.ts +28 -0
- package/dist/src/captcha/captcha-guard.use-case.d.ts +64 -0
- package/dist/src/captcha/captcha-solver-registry.store.d.ts +19 -0
- package/dist/src/captcha/captcha-solver.contract.d.ts +47 -0
- package/dist/src/captcha/captcha.error.d.ts +13 -0
- package/dist/src/captcha/index.d.ts +10 -0
- package/dist/src/captcha/resolve-captcha.use-case.d.ts +40 -0
- package/dist/src/crawl-events/crawl-event.contract.d.ts +41 -0
- package/dist/src/crawl-execution/bootstrap-session.use-case.d.ts +5 -2
- package/dist/src/crawl-execution/crawl-options.config.d.ts +3 -0
- package/dist/src/crawl-execution/crawl-report.model.d.ts +8 -0
- package/dist/src/crawl-execution/create-crawler.use-case.d.ts +2 -1
- package/dist/src/crawl-execution/run-input-recipe.use-case.d.ts +3 -0
- package/dist/src/deck-document/deck-document.model.d.ts +58 -0
- package/dist/src/deck-document/deck-table.algorithm.d.ts +35 -0
- package/dist/src/deck-document/index.d.ts +6 -0
- package/dist/src/deck-document/read-pptx.client.d.ts +16 -0
- package/dist/src/extraction-scope/extraction-scope.model.d.ts +4 -1
- package/dist/src/http-session/http-response.contract.d.ts +14 -1
- package/dist/src/http-session/text-decoding.algorithm.d.ts +35 -0
- package/dist/src/index.d.ts +11 -1
- package/dist/src/markdown-document/index.d.ts +3 -0
- package/dist/src/markdown-document/read-markdown.client.d.ts +29 -0
- package/dist/src/pdf-document/index.d.ts +7 -0
- package/dist/src/pdf-document/pdf-document.model.d.ts +51 -0
- package/dist/src/pdf-document/pdf-table.algorithm.d.ts +43 -0
- package/dist/src/pdf-document/read-pdf.client.d.ts +18 -0
- package/dist/src/pdf-document/row-assembly.algorithm.d.ts +26 -0
- package/dist/src/recipe-loading/recipe-binding.validator.d.ts +3 -1
- package/dist/src/recipe-schema/index.d.ts +2 -2
- package/dist/src/recipe-schema/input-recipe.contract.d.ts +33 -3
- package/dist/src/recipe-schema/recipe-kind.enum.d.ts +7 -3
- package/dist/src/recipe-schema/step.contract.d.ts +52 -2
- package/dist/src/selection/index.d.ts +1 -1
- package/dist/src/selection/json-text.algorithm.d.ts +30 -3
- package/dist/src/web-steps/run-web-step.use-case.d.ts +10 -2
- package/dist/src/workbook-document/csv-parser.algorithm.d.ts +26 -0
- package/dist/src/workbook-document/csv-workbook.mapper.d.ts +24 -0
- package/dist/src/workbook-document/grid-table.algorithm.d.ts +53 -0
- package/dist/src/workbook-document/html-tables.mapper.d.ts +14 -0
- package/dist/src/workbook-document/index.d.ts +9 -0
- package/dist/src/workbook-document/read-xlsx.client.d.ts +18 -0
- package/dist/src/workbook-document/workbook-document.model.d.ts +51 -0
- package/dist/src/yaml-document/index.d.ts +3 -0
- package/dist/src/yaml-document/read-yaml.client.d.ts +25 -0
- package/package.json +17 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WorkbookDocument } from './workbook-document.model.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads an `.xlsx` workbook into a workbook document, through
|
|
4
|
+
* `@opencraw/office-reader`: every worksheet's cells, with hidden sheets,
|
|
5
|
+
* hidden rows and merged ranges. Numbers and booleans keep their type (a
|
|
6
|
+
* cell's `13955.625` is unambiguous; as text, a locale guess could read it as
|
|
7
|
+
* thirteen million), dates become ISO text, errors their text, empty cells
|
|
8
|
+
* `''`. Formulas give their cached value. The reader is imported on first use,
|
|
9
|
+
* so recipes that never read a spreadsheet never load it.
|
|
10
|
+
*
|
|
11
|
+
* @param bytes - The file.
|
|
12
|
+
* @param source - Where it came from, for messages.
|
|
13
|
+
* @returns The workbook.
|
|
14
|
+
* @throws Error naming the source, and saying what to do, for a file that is
|
|
15
|
+
* not a readable workbook (a legacy `.xls`, a password-protected file, an `.ods`…).
|
|
16
|
+
*/
|
|
17
|
+
export declare function readXlsxWorkbook(bytes: Uint8Array, source: string): Promise<WorkbookDocument>;
|
|
18
|
+
//# sourceMappingURL=read-xlsx.client.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A cell: text, or, from a spreadsheet, the number or boolean it holds
|
|
3
|
+
* (`13955.625` stays a number, so no locale guess can misread it). Dates are
|
|
4
|
+
* ISO text (`2026-06-01`, `2026-06-01T09:30:00`), errors their text
|
|
5
|
+
* (`#DIV/0!`), an empty cell `''`. A CSV's cells are all text.
|
|
6
|
+
*/
|
|
7
|
+
export type WorkbookCell = string | number | boolean;
|
|
8
|
+
/** One sheet of a workbook. A CSV is a workbook of one sheet. */
|
|
9
|
+
export interface Sheet {
|
|
10
|
+
name: string;
|
|
11
|
+
/** Top to bottom; a row holds as many cells as were read (rows can be ragged). */
|
|
12
|
+
rows: WorkbookCell[][];
|
|
13
|
+
/** A sheet hidden in the workbook: `table` skips it unless `includeHidden`. */
|
|
14
|
+
hidden?: boolean;
|
|
15
|
+
/** Rows hidden in the sheet (0-based): `table` skips them unless `includeHidden`. */
|
|
16
|
+
hiddenRows?: number[];
|
|
17
|
+
/**
|
|
18
|
+
* Merged ranges as A1 references (`B10:B13`). The value of a merged range
|
|
19
|
+
* sits in its top-left cell only, as the file stores it; `table` copies it
|
|
20
|
+
* into every cell the range covers.
|
|
21
|
+
*/
|
|
22
|
+
merges?: string[];
|
|
23
|
+
}
|
|
24
|
+
/** How a CSV was read, for a probe to report. */
|
|
25
|
+
export interface CsvFormat {
|
|
26
|
+
encoding: string;
|
|
27
|
+
delimiter: string;
|
|
28
|
+
}
|
|
29
|
+
/** A spreadsheet or a CSV read into sheets of cells: what `extract` works on. */
|
|
30
|
+
export interface WorkbookDocument {
|
|
31
|
+
kind: 'workbook';
|
|
32
|
+
sheets: Sheet[];
|
|
33
|
+
/** Present when the workbook came from a CSV. */
|
|
34
|
+
csv?: CsvFormat;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The text a `regex` extract reads: the visible rows of the visible sheets,
|
|
38
|
+
* cells separated by a tab, sheets separated by a blank line.
|
|
39
|
+
*
|
|
40
|
+
* @param document - The workbook.
|
|
41
|
+
* @returns The text.
|
|
42
|
+
*/
|
|
43
|
+
export declare function workbookText(document: WorkbookDocument): string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether a value bound in scope is a read workbook (so `extract … from` can take it).
|
|
46
|
+
*
|
|
47
|
+
* @param value - Anything.
|
|
48
|
+
* @returns Whether it is a {@link WorkbookDocument}.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isWorkbookDocument(value: unknown): value is WorkbookDocument;
|
|
51
|
+
//# sourceMappingURL=workbook-document.model.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** How YAML scalars are read: typed as YAML 1.2 types them, or as the text written. */
|
|
2
|
+
export type YamlScalars = 'typed' | 'text';
|
|
3
|
+
/** A YAML text, read. */
|
|
4
|
+
export interface YamlRead {
|
|
5
|
+
/** The document's value; several documents (`---`) give an array of their values. */
|
|
6
|
+
data: unknown;
|
|
7
|
+
documents: number;
|
|
8
|
+
/** What the parser noticed but read anyway: an unknown tag (`!!js/function`) is kept as its plain value. */
|
|
9
|
+
warnings: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parses YAML with the `yaml` package, imported on first use. The version is
|
|
13
|
+
* pinned to YAML 1.2 (core schema) whatever the document declares: under a
|
|
14
|
+
* `%YAML 1.1` directive, `NO` would read as `false` and `0123` as octal `83`.
|
|
15
|
+
* Merge keys (`<<: *base`) are applied, duplicate keys are an error, aliases
|
|
16
|
+
* are capped, and custom tags never build values: nothing in the text runs.
|
|
17
|
+
*
|
|
18
|
+
* @param text - The YAML.
|
|
19
|
+
* @param source - Where it came from, for messages.
|
|
20
|
+
* @param scalars - `typed` (default), or `text` to keep every scalar as written (`0123` stays `"0123"`).
|
|
21
|
+
* @returns The data, the number of documents and the warnings.
|
|
22
|
+
* @throws Error naming the source, with the line and column, for YAML that does not parse.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readYaml(text: string, source: string, scalars?: YamlScalars): Promise<YamlRead>;
|
|
25
|
+
//# sourceMappingURL=read-yaml.client.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencraw/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.esm.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -20,10 +20,14 @@
|
|
|
20
20
|
"!**/*.js.map"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@opencraw/office-reader": "^0.0.2",
|
|
23
24
|
"cheerio": "^1.2.0",
|
|
24
25
|
"domhandler": "^6.0.1",
|
|
25
26
|
"jsonpath-plus": "^10.4.0",
|
|
27
|
+
"marked": "^18.0.14",
|
|
28
|
+
"pdfjs-dist": "^6.3.289",
|
|
26
29
|
"playwright": "^1.63.0",
|
|
30
|
+
"yaml": "^2.9.1",
|
|
27
31
|
"zod": "^4.6.5"
|
|
28
32
|
},
|
|
29
33
|
"publishConfig": {
|
|
@@ -53,7 +57,8 @@
|
|
|
53
57
|
"e2e": {
|
|
54
58
|
"executor": "nx:run-commands",
|
|
55
59
|
"dependsOn": [
|
|
56
|
-
"build"
|
|
60
|
+
"build",
|
|
61
|
+
"^build"
|
|
57
62
|
],
|
|
58
63
|
"options": {
|
|
59
64
|
"command": "tsc -p tsconfig.e2e.json && jest --config jest.e2e.config.cts",
|
|
@@ -69,6 +74,16 @@
|
|
|
69
74
|
"command": "node tools/emit-json-schemas.mjs",
|
|
70
75
|
"cwd": "packages/core"
|
|
71
76
|
}
|
|
77
|
+
},
|
|
78
|
+
"typecheck": {
|
|
79
|
+
"dependsOn": [
|
|
80
|
+
"^build"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"lint": {
|
|
84
|
+
"dependsOn": [
|
|
85
|
+
"^build"
|
|
86
|
+
]
|
|
72
87
|
}
|
|
73
88
|
}
|
|
74
89
|
}
|