@opencraw/core 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/dist/access/access-broker.use-case.d.ts +43 -0
  2. package/dist/access/access-config.error.d.ts +5 -0
  3. package/dist/access/access-config.repository.d.ts +11 -0
  4. package/dist/access/access-json-schema.mapper.d.ts +8 -0
  5. package/dist/access/access-plugin.contract.d.ts +48 -0
  6. package/dist/access/access-preset.store.d.ts +19 -0
  7. package/dist/access/access-profile.contract.d.ts +95 -0
  8. package/dist/access/index.d.ts +11 -0
  9. package/dist/access/render-access.mapper.d.ts +41 -0
  10. package/dist/access/session-id.algorithm.d.ts +8 -0
  11. package/dist/api-steps/extract-from-document.use-case.d.ts +41 -0
  12. package/dist/api-steps/index.d.ts +4 -0
  13. package/dist/api-steps/run-api-step.use-case.d.ts +20 -0
  14. package/dist/api-steps/send-request.use-case.d.ts +23 -0
  15. package/dist/browser-session/browser-profile.store.d.ts +52 -0
  16. package/dist/browser-session/browser-session.config.d.ts +21 -0
  17. package/dist/browser-session/browser.client.d.ts +75 -0
  18. package/dist/browser-session/index.d.ts +6 -0
  19. package/dist/captcha/captcha-budget.model.d.ts +21 -0
  20. package/dist/captcha/captcha-detection.client.d.ts +28 -0
  21. package/dist/captcha/captcha-guard.use-case.d.ts +64 -0
  22. package/dist/captcha/captcha-solver-registry.store.d.ts +19 -0
  23. package/dist/captcha/captcha-solver.contract.d.ts +47 -0
  24. package/dist/captcha/captcha.error.d.ts +13 -0
  25. package/dist/captcha/index.d.ts +10 -0
  26. package/dist/captcha/resolve-captcha.use-case.d.ts +40 -0
  27. package/dist/crawl-events/crawl-event.contract.d.ts +169 -0
  28. package/dist/crawl-events/event-bus.store.d.ts +10 -0
  29. package/dist/crawl-events/index.d.ts +4 -0
  30. package/dist/crawl-events/trace-line.mapper.d.ts +14 -0
  31. package/dist/crawl-execution/bootstrap-session.use-case.d.ts +79 -0
  32. package/dist/crawl-execution/crawl-options.config.d.ts +67 -0
  33. package/dist/crawl-execution/crawl-report.model.d.ts +33 -0
  34. package/dist/crawl-execution/create-crawler.use-case.d.ts +20 -0
  35. package/dist/crawl-execution/index.d.ts +8 -0
  36. package/dist/crawl-execution/rotating-runner.use-case.d.ts +66 -0
  37. package/dist/crawl-execution/run-crawl.use-case.d.ts +17 -0
  38. package/dist/crawl-execution/run-input-recipe.use-case.d.ts +51 -0
  39. package/dist/deck-document/deck-document.model.d.ts +58 -0
  40. package/dist/deck-document/deck-table.algorithm.d.ts +35 -0
  41. package/dist/deck-document/index.d.ts +6 -0
  42. package/dist/deck-document/read-pptx.client.d.ts +16 -0
  43. package/dist/docx-document/index.d.ts +2 -0
  44. package/dist/docx-document/read-docx-html.client.d.ts +23 -0
  45. package/dist/extraction-scope/extraction-scope.model.d.ts +77 -0
  46. package/dist/extraction-scope/index.d.ts +5 -0
  47. package/dist/extraction-scope/live-element.model.d.ts +28 -0
  48. package/dist/hooks/hook-registry.store.d.ts +16 -0
  49. package/dist/hooks/hook.contract.d.ts +17 -0
  50. package/dist/hooks/hook.error.d.ts +7 -0
  51. package/dist/hooks/index.d.ts +4 -0
  52. package/dist/http-session/http-response.contract.d.ts +58 -0
  53. package/dist/http-session/http.client.d.ts +42 -0
  54. package/dist/http-session/index.d.ts +5 -0
  55. package/dist/http-session/text-decoding.algorithm.d.ts +35 -0
  56. package/dist/index.esm.js +649 -25
  57. package/dist/markdown-document/index.d.ts +3 -0
  58. package/dist/markdown-document/read-markdown.client.d.ts +39 -0
  59. package/dist/output-mapping/coerce-field.mapper.d.ts +19 -0
  60. package/dist/output-mapping/generated-field.mapper.d.ts +16 -0
  61. package/dist/output-mapping/index.d.ts +9 -0
  62. package/dist/output-mapping/map-record.use-case.d.ts +27 -0
  63. package/dist/output-mapping/mapping.error.d.ts +17 -0
  64. package/dist/output-mapping/missing-value.policy.d.ts +14 -0
  65. package/dist/output-mapping/output-field.validator.d.ts +10 -0
  66. package/dist/output-mapping/output-record.model.d.ts +20 -0
  67. package/dist/pdf-document/index.d.ts +7 -0
  68. package/dist/pdf-document/pdf-document.model.d.ts +51 -0
  69. package/dist/pdf-document/pdf-table.algorithm.d.ts +43 -0
  70. package/dist/pdf-document/read-pdf.client.d.ts +18 -0
  71. package/dist/pdf-document/row-assembly.algorithm.d.ts +26 -0
  72. package/dist/recipe-loading/index.d.ts +9 -0
  73. package/dist/recipe-loading/load-recipe-set.use-case.d.ts +45 -0
  74. package/dist/recipe-loading/read-recipe-source.use-case.d.ts +14 -0
  75. package/dist/recipe-loading/recipe-binding.error.d.ts +14 -0
  76. package/dist/recipe-loading/recipe-binding.validator.d.ts +34 -0
  77. package/dist/recipe-loading/recipe-file.repository.d.ts +11 -0
  78. package/dist/recipe-loading/recipe-set.model.d.ts +12 -0
  79. package/dist/recipe-loading/recipe-source.contract.d.ts +28 -0
  80. package/dist/recipe-loading/recipe-text.mapper.d.ts +14 -0
  81. package/dist/recipe-schema/index.d.ts +15 -0
  82. package/dist/recipe-schema/input-recipe.contract.d.ts +156 -0
  83. package/dist/recipe-schema/json-schema.mapper.d.ts +15 -0
  84. package/dist/recipe-schema/output-recipe.contract.d.ts +47 -0
  85. package/dist/recipe-schema/recipe-kind.enum.d.ts +35 -0
  86. package/dist/recipe-schema/recipe-validation.error.d.ts +17 -0
  87. package/dist/recipe-schema/recipe.validator.d.ts +28 -0
  88. package/dist/recipe-schema/step.contract.d.ts +206 -0
  89. package/dist/recipe-schema/transform-rule.contract.d.ts +120 -0
  90. package/dist/record-diff/index.d.ts +4 -0
  91. package/dist/record-diff/record-diff.algorithm.d.ts +82 -0
  92. package/dist/record-diff/records-file.repository.d.ts +10 -0
  93. package/dist/record-sink/dedupe.policy.d.ts +29 -0
  94. package/dist/record-sink/index.d.ts +9 -0
  95. package/dist/record-sink/json-lines-sink.repository.d.ts +19 -0
  96. package/dist/record-sink/memory-sink.repository.d.ts +9 -0
  97. package/dist/record-sink/record-sink.contract.d.ts +17 -0
  98. package/dist/selection/html-selector.algorithm.d.ts +19 -0
  99. package/dist/selection/index.d.ts +8 -0
  100. package/dist/selection/json-path.algorithm.d.ts +9 -0
  101. package/dist/selection/json-text.algorithm.d.ts +58 -0
  102. package/dist/selection/regex.algorithm.d.ts +12 -0
  103. package/dist/selection/take-value.mapper.d.ts +27 -0
  104. package/dist/src/api-steps/extract-from-document.use-case.d.ts +5 -5
  105. package/dist/src/docx-document/index.d.ts +2 -0
  106. package/dist/src/docx-document/read-docx-html.client.d.ts +23 -0
  107. package/dist/src/extraction-scope/extraction-scope.model.d.ts +2 -1
  108. package/dist/src/http-session/http-response.contract.d.ts +2 -1
  109. package/dist/src/index.d.ts +4 -0
  110. package/dist/src/markdown-document/index.d.ts +1 -1
  111. package/dist/src/markdown-document/read-markdown.client.d.ts +10 -0
  112. package/dist/src/recipe-schema/recipe-kind.enum.d.ts +1 -1
  113. package/dist/src/recipe-schema/step.contract.d.ts +4 -0
  114. package/dist/src/record-diff/index.d.ts +4 -0
  115. package/dist/src/record-diff/record-diff.algorithm.d.ts +82 -0
  116. package/dist/src/record-diff/records-file.repository.d.ts +10 -0
  117. package/dist/src/selection/html-selector.algorithm.d.ts +2 -1
  118. package/dist/src/xml-document/index.d.ts +6 -0
  119. package/dist/src/xml-document/xml-document.model.d.ts +13 -0
  120. package/dist/src/xml-document/xml-parser.client.d.ts +49 -0
  121. package/dist/src/xml-document/xpath.algorithm.d.ts +30 -0
  122. package/dist/step-flow/block-rule.policy.d.ts +21 -0
  123. package/dist/step-flow/blocked.error.d.ts +9 -0
  124. package/dist/step-flow/for-each.use-case.d.ts +20 -0
  125. package/dist/step-flow/host-throttle.policy.d.ts +49 -0
  126. package/dist/step-flow/index.d.ts +15 -0
  127. package/dist/step-flow/paginate.use-case.d.ts +17 -0
  128. package/dist/step-flow/retry.policy.d.ts +21 -0
  129. package/dist/step-flow/run-gate.policy.d.ts +50 -0
  130. package/dist/step-flow/run-steps.use-case.d.ts +39 -0
  131. package/dist/step-flow/step-failure.error.d.ts +14 -0
  132. package/dist/step-flow/step-runner.contract.d.ts +52 -0
  133. package/dist/step-flow/transport-retry.policy.d.ts +76 -0
  134. package/dist/template/expression.algorithm.d.ts +53 -0
  135. package/dist/template/index.d.ts +7 -0
  136. package/dist/template/template.algorithm.d.ts +53 -0
  137. package/dist/template/value-path.algorithm.d.ts +29 -0
  138. package/dist/template/value-text.algorithm.d.ts +18 -0
  139. package/dist/transformation/apply-transform-chain.use-case.d.ts +17 -0
  140. package/dist/transformation/collection.algorithm.d.ts +15 -0
  141. package/dist/transformation/currency.algorithm.d.ts +15 -0
  142. package/dist/transformation/date.algorithm.d.ts +13 -0
  143. package/dist/transformation/index.d.ts +10 -0
  144. package/dist/transformation/lookup.algorithm.d.ts +24 -0
  145. package/dist/transformation/number.algorithm.d.ts +30 -0
  146. package/dist/transformation/string.algorithm.d.ts +18 -0
  147. package/dist/transformation/transform-registry.store.d.ts +36 -0
  148. package/dist/transformation/transform.error.d.ts +8 -0
  149. package/dist/transformation/url.algorithm.d.ts +20 -0
  150. package/dist/web-steps/evaluate-script.use-case.d.ts +10 -0
  151. package/dist/web-steps/extract-from-page.use-case.d.ts +10 -0
  152. package/dist/web-steps/index.d.ts +2 -0
  153. package/dist/web-steps/interact.use-case.d.ts +36 -0
  154. package/dist/web-steps/navigate.use-case.d.ts +15 -0
  155. package/dist/web-steps/run-web-step.use-case.d.ts +37 -0
  156. package/dist/web-steps/snapshot-elements.use-case.d.ts +13 -0
  157. package/dist/workbook-document/csv-parser.algorithm.d.ts +26 -0
  158. package/dist/workbook-document/csv-workbook.mapper.d.ts +24 -0
  159. package/dist/workbook-document/grid-table.algorithm.d.ts +53 -0
  160. package/dist/workbook-document/html-tables.mapper.d.ts +14 -0
  161. package/dist/workbook-document/index.d.ts +9 -0
  162. package/dist/workbook-document/read-xlsx.client.d.ts +18 -0
  163. package/dist/workbook-document/workbook-document.model.d.ts +51 -0
  164. package/dist/xml-document/index.d.ts +6 -0
  165. package/dist/xml-document/xml-document.model.d.ts +13 -0
  166. package/dist/xml-document/xml-parser.client.d.ts +49 -0
  167. package/dist/xml-document/xpath.algorithm.d.ts +30 -0
  168. package/dist/yaml-document/index.d.ts +3 -0
  169. package/dist/yaml-document/read-yaml.client.d.ts +25 -0
  170. package/package.json +4 -2
@@ -0,0 +1,17 @@
1
+ import type { TransformRule } from '../recipe-schema/index.js';
2
+ import type { TransformContext } from './transform-registry.store.js';
3
+ /**
4
+ * Applies a chain of transforms in order. A scalar op applied to a list runs
5
+ * on every item; a list op runs on the list itself. A missing value (`undefined`
6
+ * or `null`) passes through every op except `default`, `template` and `hook`,
7
+ * so a missing source reaches the missing-value policy untouched. Async because
8
+ * a `hook` may be.
9
+ *
10
+ * @param value - The resolved source value(s).
11
+ * @param rules - The chain.
12
+ * @param context - Lookup, hooks and the base URL.
13
+ * @returns The transformed value.
14
+ * @throws TransformError (or whatever a hook throws) when a step cannot apply.
15
+ */
16
+ export declare function applyTransformChain(value: unknown, rules: readonly TransformRule[], context: TransformContext): Promise<unknown>;
17
+ //# sourceMappingURL=apply-transform-chain.use-case.d.ts.map
@@ -0,0 +1,15 @@
1
+ /** The input as a list: a list as is, a missing value as empty; anything else fails the op. */
2
+ export declare function asList(op: string, value: unknown): unknown[];
3
+ export declare function first(value: unknown): unknown;
4
+ export declare function last(value: unknown): unknown;
5
+ export declare function nth(value: unknown, index: number): unknown;
6
+ export declare function slice(value: unknown, start: number, end?: number): unknown[];
7
+ export declare function join(value: unknown, separator: string): string;
8
+ export declare function concat(value: unknown, separator?: string): string;
9
+ /** The first value that is not `undefined`, `null` or blank text. */
10
+ export declare function coalesce(value: unknown): unknown;
11
+ export declare function flatten(value: unknown): unknown[];
12
+ export declare function unique(value: unknown): unknown[];
13
+ export declare function sum(value: unknown): number;
14
+ export declare function count(value: unknown): number;
15
+ //# sourceMappingURL=collection.algorithm.d.ts.map
@@ -0,0 +1,15 @@
1
+ /** A money amount with its ISO 4217 code, when known. */
2
+ export interface Money {
3
+ amount: number;
4
+ currency?: string;
5
+ }
6
+ /**
7
+ * Parses a price. The currency comes from the explicit code, else a code or symbol in the text.
8
+ *
9
+ * @param value - Text such as `1.299,00 €` or a number.
10
+ * @param locale - The locale the text is written in.
11
+ * @param currency - An explicit ISO 4217 code that wins over anything in the text.
12
+ * @returns The money value.
13
+ */
14
+ export declare function parseCurrency(value: unknown, locale?: string, currency?: string): Money;
15
+ //# sourceMappingURL=currency.algorithm.d.ts.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Parses a date or instant.
3
+ *
4
+ * @param value - Text, a number (epoch milliseconds) or a Date.
5
+ * @param format - Tokens `YYYY MM DD HH mm ss`, e.g. `DD/MM/YYYY`; without one the text must be ISO 8601 or otherwise `Date.parse`-able.
6
+ * @param timezone - An IANA zone the text is written in when it carries no offset; default UTC.
7
+ * @returns The instant.
8
+ * @throws TransformError when the text cannot be read.
9
+ */
10
+ export declare function parseDate(value: unknown, format?: string, timezone?: string): Date;
11
+ /** `YYYY-MM-DD` of an instant, in UTC. */
12
+ export declare function toIsoDate(date: Date): string;
13
+ //# sourceMappingURL=date.algorithm.d.ts.map
@@ -0,0 +1,10 @@
1
+ export { applyTransformChain } from './apply-transform-chain.use-case.js';
2
+ export { BUILT_IN_TRANSFORMS } from './transform-registry.store.js';
3
+ export type { TransformContext } from './transform-registry.store.js';
4
+ export { TransformError } from './transform.error.js';
5
+ export { parseNumber, parseInteger, parseBoolean } from './number.algorithm.js';
6
+ export { parseCurrency } from './currency.algorithm.js';
7
+ export type { Money } from './currency.algorithm.js';
8
+ export { parseDate, toIsoDate } from './date.algorithm.js';
9
+ export { absoluteUrl } from './url.algorithm.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The first item of a table whose `key` path equals a value, compared as text
3
+ * so `"3"` finds `3`. The table is whatever a bound id holds: data, JSON text
4
+ * or a list of JSON texts (a `data-*` attribute per element).
5
+ *
6
+ * @param value - The value to find.
7
+ * @param table - The table, as bound in scope.
8
+ * @param key - A dotted path inside each item.
9
+ * @param pick - A dotted path to return from the item; the item itself when omitted.
10
+ * @returns The picked value, or `undefined` when nothing matches.
11
+ */
12
+ export declare function lookup(value: unknown, table: unknown, key: string, pick?: string): unknown;
13
+ /**
14
+ * Groups a list by a path, keeping first-seen order.
15
+ *
16
+ * @param items - The list.
17
+ * @param by - A dotted path inside each item; items without one group under `null`.
18
+ * @returns One `{ key, items }` per distinct key.
19
+ */
20
+ export declare function group(items: unknown[], by: string): {
21
+ key: unknown;
22
+ items: unknown[];
23
+ }[];
24
+ //# sourceMappingURL=lookup.algorithm.d.ts.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The decimal and group separators a locale uses.
3
+ *
4
+ * @param locale - A BCP 47 tag; `undefined` means "guess from the text".
5
+ * @returns The two separators.
6
+ */
7
+ export declare function separatorsOf(locale: string): {
8
+ decimal: string;
9
+ group: string;
10
+ };
11
+ /**
12
+ * Parses a number from text, tolerating currency symbols, spaces and locale separators.
13
+ *
14
+ * @param value - Text or a number.
15
+ * @param locale - The locale the text is written in. Without one, the last separator is the decimal one when
16
+ * it is followed by 1 or 2 digits, otherwise it is a group separator.
17
+ * @returns The number.
18
+ * @throws TransformError when no number can be read.
19
+ */
20
+ export declare function parseNumber(value: unknown, locale?: string): number;
21
+ export declare function parseInteger(value: unknown, locale?: string): number;
22
+ /**
23
+ * Reads a boolean the way a recipe means it.
24
+ *
25
+ * @param value - Any value.
26
+ * @param truthy - Phrases that mean `true` (case-insensitive, matched as a substring); default: yes/true/1/on/in stock/available.
27
+ * @returns The boolean.
28
+ */
29
+ export declare function parseBoolean(value: unknown, truthy?: readonly string[]): boolean;
30
+ //# sourceMappingURL=number.algorithm.d.ts.map
@@ -0,0 +1,18 @@
1
+ /** A short description of a value for error messages. */
2
+ export declare function describe(value: unknown): string;
3
+ export declare function trim(value: unknown): string;
4
+ export declare function lowercase(value: unknown): string;
5
+ export declare function uppercase(value: unknown): string;
6
+ export declare function replace(value: unknown, pattern: string, replacement: string, flags?: string): string;
7
+ /**
8
+ * The first match of a pattern.
9
+ *
10
+ * @param value - The text.
11
+ * @param pattern - A regular expression source.
12
+ * @param group - The capture group to return; default: group 1 when the pattern has one, else the whole match.
13
+ * @param flags - Regular expression flags.
14
+ * @returns The captured text, or `undefined` when nothing matches.
15
+ */
16
+ export declare function regex(value: unknown, pattern: string, group?: number, flags?: string): string | undefined;
17
+ export declare function split(value: unknown, separator: string): string[];
18
+ //# sourceMappingURL=string.algorithm.d.ts.map
@@ -0,0 +1,36 @@
1
+ import type { HookRegistry } from '../hooks/index.js';
2
+ import type { TransformOp, TransformRule } from '../recipe-schema/index.js';
3
+ import type { Lookup } from '../template/index.js';
4
+ /** What a transform may need besides its input. */
5
+ export interface TransformContext {
6
+ recipeId: string;
7
+ /** Resolves template paths against the current scope. */
8
+ lookup: Lookup;
9
+ /** The scope snapshot, for hooks. */
10
+ scope: Record<string, unknown>;
11
+ hooks: HookRegistry;
12
+ /** The current page URL; `absoluteUrl` resolves against it by default. */
13
+ baseUrl?: string;
14
+ log: (level: 'debug' | 'info' | 'warn' | 'error', message: string, meta?: Record<string, unknown>) => void;
15
+ }
16
+ type RuleOf<Op extends TransformOp> = Extract<TransformRule, {
17
+ op: Op;
18
+ }>;
19
+ /** One registered operation. `elementwise` ops apply to each item when the input is a list. */
20
+ interface Registered<Op extends TransformOp = TransformOp> {
21
+ elementwise: boolean;
22
+ apply: (value: unknown, rule: RuleOf<Op>, context: TransformContext) => unknown;
23
+ }
24
+ /** The closed set of built-in transforms, one per `TransformRule` op. */
25
+ export declare const BUILT_IN_TRANSFORMS: {
26
+ [Op in TransformOp]: Registered<Op>;
27
+ };
28
+ /**
29
+ * Looks up the implementation of a rule.
30
+ *
31
+ * @param rule - A transform rule from a recipe.
32
+ * @returns The registered operation.
33
+ */
34
+ export declare function transformFor(rule: TransformRule): Registered;
35
+ export {};
36
+ //# sourceMappingURL=transform-registry.store.d.ts.map
@@ -0,0 +1,8 @@
1
+ /** A transform that could not be applied to its input. */
2
+ export declare class TransformError extends Error {
3
+ readonly op: string;
4
+ readonly input?: unknown;
5
+ readonly name = "TransformError";
6
+ constructor(op: string, reason: string, input?: unknown);
7
+ }
8
+ //# sourceMappingURL=transform.error.d.ts.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Percent-encodes a value for one URL component (a path segment, a query
3
+ * value), with `encodeURIComponent`'s rules: everything but letters, digits
4
+ * and `-_.!~*'()` is encoded, non-ASCII as UTF-8.
5
+ *
6
+ * @param value - Text, a number or a boolean.
7
+ * @returns The encoded text.
8
+ * @throws TransformError for anything else.
9
+ */
10
+ export declare function urlEncode(value: unknown): string;
11
+ /**
12
+ * Resolves a possibly relative URL.
13
+ *
14
+ * @param value - The URL text.
15
+ * @param base - What relative URLs resolve against; usually the page URL.
16
+ * @returns The absolute URL.
17
+ * @throws TransformError when the result is not a valid URL.
18
+ */
19
+ export declare function absoluteUrl(value: unknown, base?: string): string;
20
+ //# sourceMappingURL=url.algorithm.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { Page } from 'playwright';
2
+ import type { ExtractionScope } from '../extraction-scope/index.js';
3
+ import type { EvaluateStep } from '../recipe-schema/index.js';
4
+ /**
5
+ * Runs an `evaluate` step: the script is evaluated in the page as an expression
6
+ * (a function expression is called), and its JSON-serialisable result is bound
7
+ * under the step id. Trusted recipes only: this is arbitrary code in the page.
8
+ */
9
+ export declare function evaluateScript(step: EvaluateStep, page: Page, scope: ExtractionScope): Promise<void>;
10
+ //# sourceMappingURL=evaluate-script.use-case.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { Page } from 'playwright';
2
+ import type { ExtractionScope } from '../extraction-scope/index.js';
3
+ import type { ExtractStep } from '../recipe-schema/index.js';
4
+ /**
5
+ * Runs an `extract` step on the live page (css or xpath through locators, one
6
+ * round trip for all matches). With `from`, it reads a fragment bound earlier
7
+ * instead, the same way api mode reads a fetched document.
8
+ */
9
+ export declare function extractFromPage(step: ExtractStep, page: Page, scope: ExtractionScope): Promise<void>;
10
+ //# sourceMappingURL=extract-from-page.use-case.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { WebStepRunner } from './run-web-step.use-case.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,36 @@
1
+ import type { Locator, Page } from 'playwright';
2
+ import type { ExtractionScope } from '../extraction-scope/index.js';
3
+ import type { ClickStep, FillStep, PressStep, ScreenshotStep, ScrollStep, SelectStep, TargetFields, WaitStep } from '../recipe-schema/index.js';
4
+ /**
5
+ * The element an interaction lands on: the first match of `selector`, or what
6
+ * `target` renders to - a live element (re-resolved by selector and index, so a
7
+ * re-render since the loop started does not matter) or a selector string.
8
+ *
9
+ * @param step - A step with `selector` or `target`.
10
+ * @param page - The page.
11
+ * @param scope - Where `target` is resolved.
12
+ * @returns The locator.
13
+ * @throws Error when `target` renders to something that is neither.
14
+ */
15
+ export declare function targetOf(step: TargetFields, page: Page, scope: ExtractionScope): Locator;
16
+ export declare function click(step: ClickStep, page: Page, scope: ExtractionScope): Promise<void>;
17
+ export declare function fill(step: FillStep, page: Page, scope: ExtractionScope): Promise<void>;
18
+ export declare function press(step: PressStep, page: Page, scope: ExtractionScope): Promise<void>;
19
+ /** Picks an option of a `<select>` by value, label or index; each is a template. */
20
+ export declare function select(step: SelectStep, page: Page, scope: ExtractionScope): Promise<void>;
21
+ /**
22
+ * Scrolls to the bottom (or to an element) `times` times; with `untilStable`
23
+ * it keeps going until the page stops growing, which is how infinite lists end.
24
+ */
25
+ export declare function scroll(step: ScrollStep, page: Page): Promise<void>;
26
+ export declare function wait(step: WaitStep, page: Page): Promise<void>;
27
+ /**
28
+ * Whether a locator becomes visible within a timeout. Never throws.
29
+ *
30
+ * @param target - The locator.
31
+ * @param timeout - Milliseconds to wait.
32
+ * @returns `true` when visible in time.
33
+ */
34
+ export declare function appears(target: Locator, timeout: number): Promise<boolean>;
35
+ export declare function screenshot(step: ScreenshotStep, page: Page, scope: ExtractionScope): Promise<void>;
36
+ //# sourceMappingURL=interact.use-case.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { Page } from 'playwright';
2
+ import type { EventBus } from '../crawl-events/index.js';
3
+ import type { ExtractionScope } from '../extraction-scope/index.js';
4
+ import type { GotoStep, InputRecipe } from '../recipe-schema/index.js';
5
+ import type { RunGate } from '../step-flow/index.js';
6
+ /**
7
+ * Runs a `goto` step: renders the URL (relative to the current page), waits for
8
+ * the gate's throttle (`delayMs`), navigates (again, after a pause, while it
9
+ * fails in passing: `limits.retry`), records the page's real URL in the scope,
10
+ * and checks the response against the recipe's block rule.
11
+ *
12
+ * @throws BlockedError when the response is a block.
13
+ */
14
+ export declare function navigate(step: GotoStep, page: Page, scope: ExtractionScope, recipe: InputRecipe, gate: RunGate, events: EventBus): Promise<void>;
15
+ //# sourceMappingURL=navigate.use-case.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { BrowserSession } from '../browser-session/index.js';
2
+ import type { CaptchaGuard } from '../captcha/index.js';
3
+ import type { EventBus } from '../crawl-events/index.js';
4
+ import type { ExtractionScope, LiveElement } from '../extraction-scope/index.js';
5
+ import type { InputRecipe, PaginateNext, Step } from '../recipe-schema/index.js';
6
+ import { RunGate } from '../step-flow/index.js';
7
+ import type { NextPageResult, StepRunner } from '../step-flow/index.js';
8
+ /**
9
+ * Runs web-mode leaf steps on a browser page. With a captcha guard, a page a
10
+ * navigation, click or key press leads to is checked for a challenge, solved
11
+ * before the next step runs.
12
+ */
13
+ export declare class WebStepRunner implements StepRunner {
14
+ private readonly session;
15
+ private readonly recipe;
16
+ private readonly events;
17
+ private readonly gate;
18
+ private readonly captcha?;
19
+ private readonly page;
20
+ constructor(session: BrowserSession, recipe: InputRecipe, events: EventBus, gate?: RunGate, captcha?: CaptchaGuard | undefined);
21
+ /** Clicks and key presses can navigate; keep `page.url` honest after every leaf step. */
22
+ private trackUrl;
23
+ /** Navigates; a block page showing a captcha is solved under `onBlock.solve`, and a page reached is checked for one. */
24
+ private visit;
25
+ runLeaf(step: Step, scope: ExtractionScope): Promise<void>;
26
+ nextPage(next: PaginateNext, scope: ExtractionScope): Promise<NextPageResult>;
27
+ /**
28
+ * A runner on a new tab of the same context, for one parallel iteration:
29
+ * it shares cookies, the gate and the captcha guard; disposing it closes the tab only.
30
+ *
31
+ * @returns The forked runner.
32
+ */
33
+ fork(): Promise<WebStepRunner>;
34
+ elements(selector: string): Promise<LiveElement[]>;
35
+ dispose(): Promise<void>;
36
+ }
37
+ //# sourceMappingURL=run-web-step.use-case.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { Page } from 'playwright';
2
+ import type { LiveElement } from '../extraction-scope/index.js';
3
+ /**
4
+ * Snapshots every element a selector matches, in one round trip, for a
5
+ * `forEach` over `selector`. Each snapshot carries the selector and its index
6
+ * so a later `target` can find the element again, even after a re-render.
7
+ *
8
+ * @param selector - A css selector (or `xpath=...`), already rendered.
9
+ * @param page - The page.
10
+ * @returns One snapshot per match, in document order.
11
+ */
12
+ export declare function snapshotElements(selector: string, page: Page): Promise<LiveElement[]>;
13
+ //# sourceMappingURL=snapshot-elements.use-case.d.ts.map
@@ -0,0 +1,26 @@
1
+ /** The delimiters detection chooses between, in order of preference on a tie. */
2
+ export declare const CSV_DELIMITERS: readonly [',', ';', '\t', '|'];
3
+ /**
4
+ * Parses CSV text (RFC 4180, tolerant): a field in double quotes may hold the
5
+ * delimiter, line breaks and `""` for a quote; a quote inside an unquoted
6
+ * field is taken literally (`1.0 Hybrid "Cross"`); CRLF, LF and CR all end a
7
+ * record. Rows are kept as read: ragged rows stay ragged, nothing is trimmed.
8
+ *
9
+ * @param text - The decoded file.
10
+ * @param delimiter - One character.
11
+ * @returns The rows; a trailing empty line adds no row.
12
+ */
13
+ export declare function parseCsv(text: string, delimiter: string): string[][];
14
+ /**
15
+ * Chooses the delimiter of a CSV: the candidate whose field count (above one)
16
+ * is the most consistent over the first lines, so a title line or two above
17
+ * the header does not mislead it. A file of one column gets `,`.
18
+ *
19
+ * `;` with decimal commas (`Panda;15.950,00`), the usual European export,
20
+ * scores `;`: a comma split gives rows of uneven width.
21
+ *
22
+ * @param text - The decoded file.
23
+ * @returns The delimiter.
24
+ */
25
+ export declare function detectDelimiter(text: string): string;
26
+ //# sourceMappingURL=csv-parser.algorithm.d.ts.map
@@ -0,0 +1,24 @@
1
+ import type { WorkbookDocument } from './workbook-document.model.js';
2
+ /**
3
+ * Reads decoded CSV text into a workbook of one sheet, named after the file.
4
+ *
5
+ * @param text - The decoded file.
6
+ * @param options - The sheet name, the encoding it was decoded from (for a
7
+ * probe to report) and a delimiter; without one it is detected.
8
+ * @returns The workbook.
9
+ * @throws Error when the delimiter given is not one character.
10
+ */
11
+ export declare function csvWorkbook(text: string, options: {
12
+ name: string;
13
+ encoding: string;
14
+ delimiter?: string;
15
+ }): WorkbookDocument;
16
+ /**
17
+ * The name a CSV's sheet takes: the file name without its extension
18
+ * (`…/prezzo_alle_8.csv` → `prezzo_alle_8`), else `csv`.
19
+ *
20
+ * @param url - Where the file came from.
21
+ * @returns The name.
22
+ */
23
+ export declare function sheetNameOf(url: string): string;
24
+ //# sourceMappingURL=csv-workbook.mapper.d.ts.map
@@ -0,0 +1,53 @@
1
+ import type { WorkbookCell, WorkbookDocument } from './workbook-document.model.js';
2
+ /** What a table extract looks for in a workbook. */
3
+ export interface GridTableQuery {
4
+ /** Matches a table's (first) header row: its non-empty cells joined by spaces, whitespace collapsed. */
5
+ header: RegExp;
6
+ /** Matches the row that ends a table; a table also ends at the next header or the sheet's end. `^$` ends it at the first empty row. */
7
+ until?: RegExp;
8
+ /** Output key -> a pattern for that column's header; unmatched columns are dropped. Without it, the headers are the keys. */
9
+ columns?: Record<string, RegExp>;
10
+ /** Matches the names of the sheets to read; default every sheet. */
11
+ sheet?: RegExp;
12
+ /** How many rows the header spans (default 1): a column's key joins its header texts. */
13
+ headerRows?: number;
14
+ /** Output keys whose empty cells take the value of the row above. */
15
+ fillDown?: string[];
16
+ /** Read hidden sheets and hidden rows too. */
17
+ includeHidden?: boolean;
18
+ }
19
+ /** One table found in a workbook. */
20
+ export interface GridTable {
21
+ sheet: string;
22
+ /** The first header cell: the table's name when it has one. */
23
+ title: string;
24
+ /** The column keys, left to right. */
25
+ header: string[];
26
+ /** One object per row, keyed by column; text trimmed, numbers and booleans as they are. */
27
+ rows: Record<string, WorkbookCell>[];
28
+ }
29
+ /**
30
+ * Finds every table whose header row matches, in every sheet the query
31
+ * selects, and reads its rows by column. Unlike a PDF, a grid needs no
32
+ * geometry: column *i* of a row belongs to header *i*.
33
+ *
34
+ * Merged ranges are filled first (the file stores their value in the top-left
35
+ * cell only), so a brand merged down its models' rows reads on every row, and
36
+ * a group header merged across its sub-columns names each of them. Empty rows
37
+ * are skipped.
38
+ *
39
+ * @param document - The workbook.
40
+ * @param query - Which tables, and how to name their columns.
41
+ * @returns The tables, sheet by sheet, top to bottom.
42
+ */
43
+ export declare function findGridTables(document: WorkbookDocument, query: GridTableQuery): GridTable[];
44
+ /**
45
+ * Fills blank cells in the given columns with the value of the row above,
46
+ * within one table: pivot exports write a group's name on its first row only.
47
+ *
48
+ * @param rows - The table's rows, in order.
49
+ * @param keys - The columns to fill.
50
+ * @returns The rows, filled (new objects; the input is not changed).
51
+ */
52
+ export declare function fillDown<Row extends Record<string, unknown>>(rows: readonly Row[], keys: readonly string[]): Row[];
53
+ //# sourceMappingURL=grid-table.algorithm.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { Sheet } from './workbook-document.model.js';
2
+ /**
3
+ * Every `<table>` of an HTML document as a sheet (`table 1`, `table 2`…, in
4
+ * document order), so the workbook table reader works on web pages and
5
+ * rendered Markdown: rows in order (`thead`, `tbody`, `tfoot` alike), `th` and
6
+ * `td` alike, cell text with whitespace collapsed, `colspan` and `rowspan` as
7
+ * merged ranges. A table inside a table is a sheet of its own, and its rows
8
+ * are not its parent's.
9
+ *
10
+ * @param html - The document.
11
+ * @returns The tables.
12
+ */
13
+ export declare function htmlTableSheets(html: string): Sheet[];
14
+ //# sourceMappingURL=html-tables.mapper.d.ts.map
@@ -0,0 +1,9 @@
1
+ export { workbookText, isWorkbookDocument } from './workbook-document.model.js';
2
+ export type { WorkbookDocument, Sheet, CsvFormat, WorkbookCell } from './workbook-document.model.js';
3
+ export { parseCsv, detectDelimiter, CSV_DELIMITERS } from './csv-parser.algorithm.js';
4
+ export { csvWorkbook, sheetNameOf } from './csv-workbook.mapper.js';
5
+ export { readXlsxWorkbook } from './read-xlsx.client.js';
6
+ export { findGridTables, fillDown } from './grid-table.algorithm.js';
7
+ export { htmlTableSheets } from './html-tables.mapper.js';
8
+ export type { GridTable, GridTableQuery } from './grid-table.algorithm.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -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,6 @@
1
+ export type { XmlDocument } from './xml-document.model.js';
2
+ export { isXmlDocument } from './xml-document.model.js';
3
+ export { parseXml, htmlAsXml, withoutNamespaces, serializeXml, gunzipIfNeeded } from './xml-parser.client.js';
4
+ export { selectXpath, takeFromXml } from './xpath.algorithm.js';
5
+ export type { XpathValue, XpathOptions } from './xpath.algorithm.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,13 @@
1
+ /** A fetched XML document: a feed, a sitemap, an open-data export. Kept as text; queries parse it once. */
2
+ export interface XmlDocument {
3
+ kind: 'xml';
4
+ xml: string;
5
+ }
6
+ /**
7
+ * Whether a value is a read XML document.
8
+ *
9
+ * @param value - Anything bound in a scope.
10
+ * @returns `true` for an `XmlDocument`.
11
+ */
12
+ export declare function isXmlDocument(value: unknown): value is XmlDocument;
13
+ //# sourceMappingURL=xml-document.model.d.ts.map
@@ -0,0 +1,49 @@
1
+ /** A parsed document, as the XPath engine sees it. */
2
+ export type XmlNode = Node;
3
+ /**
4
+ * Parses XML strictly but safely: a malformed document is an error naming
5
+ * the URL and the line; entities a DOCTYPE declares are never expanded (no
6
+ * "billion laughs") and nothing external is ever fetched (no XXE), they stay
7
+ * as they are.
8
+ *
9
+ * @param xml - The document text.
10
+ * @param where - The URL or id, for messages.
11
+ * @returns The document.
12
+ * @throws Error when the text is not well-formed XML.
13
+ */
14
+ export declare function parseXml(xml: string, where: string): Document;
15
+ /**
16
+ * HTML as an XML document, for XPath on fetched pages: parsed the way a
17
+ * browser parses it (a forgiving HTML5 parser that inserts `<tbody>` and
18
+ * closes what the page left open), without namespaces, so `//table/tbody/tr`
19
+ * finds what it finds on the live page.
20
+ *
21
+ * @param html - A page or a fragment.
22
+ * @returns The document.
23
+ */
24
+ export declare function htmlAsXml(html: string): Document;
25
+ /**
26
+ * A copy of a document with every namespace dropped: elements and attributes
27
+ * keep their local names, `xmlns` declarations go. What `ignoreNamespaces`
28
+ * queries run on: `//entry/title` instead of `//atom:entry/atom:title`.
29
+ *
30
+ * @param document - A parsed document.
31
+ * @returns The copy.
32
+ */
33
+ export declare function withoutNamespaces(document: Document): Document;
34
+ /**
35
+ * A node as markup: the element with its children (`outer`), or its children only.
36
+ *
37
+ * @param node - A node.
38
+ * @param outer - Whether to include the node itself.
39
+ * @returns The markup.
40
+ */
41
+ export declare function serializeXml(node: Node, outer: boolean): string;
42
+ /**
43
+ * The text of an XML body, gunzipped first when it is gzip (a `sitemap.xml.gz`).
44
+ *
45
+ * @param bytes - The body.
46
+ * @returns The bytes to decode.
47
+ */
48
+ export declare function gunzipIfNeeded(bytes: Uint8Array): Uint8Array;
49
+ //# sourceMappingURL=xml-parser.client.d.ts.map