@octocrawl/sdk 0.3.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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/dist/index.cjs +1278 -0
  4. package/dist/index.js +1240 -0
  5. package/dist/types/cjs/client.d.ts +362 -0
  6. package/dist/types/cjs/contracts/access.d.ts +166 -0
  7. package/dist/types/cjs/contracts/actions.d.ts +191 -0
  8. package/dist/types/cjs/contracts/api.d.ts +891 -0
  9. package/dist/types/cjs/contracts/benchmark.d.ts +116 -0
  10. package/dist/types/cjs/contracts/checkpoint.d.ts +164 -0
  11. package/dist/types/cjs/contracts/compliance.d.ts +412 -0
  12. package/dist/types/cjs/contracts/crawl.d.ts +302 -0
  13. package/dist/types/cjs/contracts/delivery.d.ts +136 -0
  14. package/dist/types/cjs/contracts/evidenceRecord.d.ts +192 -0
  15. package/dist/types/cjs/contracts/execution.d.ts +197 -0
  16. package/dist/types/cjs/contracts/extractor.d.ts +379 -0
  17. package/dist/types/cjs/contracts/file.d.ts +117 -0
  18. package/dist/types/cjs/contracts/firecrawl.d.ts +258 -0
  19. package/dist/types/cjs/contracts/groundTruth.d.ts +77 -0
  20. package/dist/types/cjs/contracts/identityBundle.d.ts +70 -0
  21. package/dist/types/cjs/contracts/index.d.ts +30 -0
  22. package/dist/types/cjs/contracts/map.d.ts +180 -0
  23. package/dist/types/cjs/contracts/monitor.d.ts +217 -0
  24. package/dist/types/cjs/contracts/monitorConfig.d.ts +9 -0
  25. package/dist/types/cjs/contracts/policy.d.ts +93 -0
  26. package/dist/types/cjs/contracts/proxy.d.ts +52 -0
  27. package/dist/types/cjs/contracts/recipe.d.ts +74 -0
  28. package/dist/types/cjs/contracts/regexSafety.d.ts +31 -0
  29. package/dist/types/cjs/contracts/result.d.ts +503 -0
  30. package/dist/types/cjs/contracts/session.d.ts +51 -0
  31. package/dist/types/cjs/contracts/ssrf.d.ts +16 -0
  32. package/dist/types/cjs/contracts/status.d.ts +27 -0
  33. package/dist/types/cjs/contracts/structured.d.ts +185 -0
  34. package/dist/types/cjs/contracts/tableMarkdown.d.ts +58 -0
  35. package/dist/types/cjs/contracts/tokens.d.ts +47 -0
  36. package/dist/types/cjs/index.d.ts +9 -0
  37. package/dist/types/cjs/package.json +1 -0
  38. package/dist/types/cjs/version.d.ts +8 -0
  39. package/dist/types/cjs/watcher.d.ts +151 -0
  40. package/dist/types/esm/client.d.ts +362 -0
  41. package/dist/types/esm/contracts/access.d.ts +166 -0
  42. package/dist/types/esm/contracts/actions.d.ts +191 -0
  43. package/dist/types/esm/contracts/api.d.ts +891 -0
  44. package/dist/types/esm/contracts/benchmark.d.ts +116 -0
  45. package/dist/types/esm/contracts/checkpoint.d.ts +164 -0
  46. package/dist/types/esm/contracts/compliance.d.ts +412 -0
  47. package/dist/types/esm/contracts/crawl.d.ts +302 -0
  48. package/dist/types/esm/contracts/delivery.d.ts +136 -0
  49. package/dist/types/esm/contracts/evidenceRecord.d.ts +192 -0
  50. package/dist/types/esm/contracts/execution.d.ts +197 -0
  51. package/dist/types/esm/contracts/extractor.d.ts +379 -0
  52. package/dist/types/esm/contracts/file.d.ts +117 -0
  53. package/dist/types/esm/contracts/firecrawl.d.ts +258 -0
  54. package/dist/types/esm/contracts/groundTruth.d.ts +77 -0
  55. package/dist/types/esm/contracts/identityBundle.d.ts +70 -0
  56. package/dist/types/esm/contracts/index.d.ts +30 -0
  57. package/dist/types/esm/contracts/map.d.ts +180 -0
  58. package/dist/types/esm/contracts/monitor.d.ts +217 -0
  59. package/dist/types/esm/contracts/monitorConfig.d.ts +9 -0
  60. package/dist/types/esm/contracts/policy.d.ts +93 -0
  61. package/dist/types/esm/contracts/proxy.d.ts +52 -0
  62. package/dist/types/esm/contracts/recipe.d.ts +74 -0
  63. package/dist/types/esm/contracts/regexSafety.d.ts +31 -0
  64. package/dist/types/esm/contracts/result.d.ts +503 -0
  65. package/dist/types/esm/contracts/session.d.ts +51 -0
  66. package/dist/types/esm/contracts/ssrf.d.ts +16 -0
  67. package/dist/types/esm/contracts/status.d.ts +27 -0
  68. package/dist/types/esm/contracts/structured.d.ts +185 -0
  69. package/dist/types/esm/contracts/tableMarkdown.d.ts +58 -0
  70. package/dist/types/esm/contracts/tokens.d.ts +47 -0
  71. package/dist/types/esm/index.d.ts +9 -0
  72. package/dist/types/esm/version.d.ts +8 -0
  73. package/dist/types/esm/watcher.d.ts +151 -0
  74. package/package.json +40 -0
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Page actions: steps the local browser runs on a page after it loads and
3
+ * before it is read, in the order given (Firecrawl v4.42.0's `actions`).
4
+ * Each step is recorded in the trace with its outcome and timing; a step
5
+ * that fails ends the pipeline, and the result keeps the page as it stood.
6
+ */
7
+ import type { ScreenshotEvidence } from './result.js';
8
+ import type { ScreenshotViewport } from './structured.js';
9
+ /** The most steps one request may run. */
10
+ export declare const MAX_ACTIONS = 50;
11
+ /** The longest a `wait` may pause, or wait for its selector, in milliseconds. */
12
+ export declare const MAX_ACTION_WAIT_MS = 60000;
13
+ /** The longest `executeJavascript` script, in characters. */
14
+ export declare const MAX_ACTION_SCRIPT_CHARS = 100000;
15
+ /** The longest `write` text, in characters. */
16
+ export declare const MAX_ACTION_TEXT_CHARS = 10000;
17
+ /** The most rounds (scrolls, clicks) a scrollToEnd or loadMore step may take, and the most pages a paginate step may read. */
18
+ export declare const MAX_LIST_ROUNDS = 200;
19
+ export declare const MAX_LIST_PAGES = 100;
20
+ /** A list step's pause after each round for the page to add what it loads, in milliseconds. */
21
+ export declare const LIST_WAIT_MS: {
22
+ readonly min: 100;
23
+ readonly max: 10000;
24
+ readonly default: 1000;
25
+ };
26
+ export declare const LIST_DEFAULTS: {
27
+ readonly maxScrolls: 50;
28
+ readonly maxClicks: 50;
29
+ readonly maxPages: 10;
30
+ };
31
+ export declare const PDF_PAPER_FORMATS: readonly ["A0", "A1", "A2", "A3", "A4", "A5", "A6", "Letter", "Legal", "Tabloid", "Ledger"];
32
+ export type PdfPaperFormat = (typeof PDF_PAPER_FORMATS)[number];
33
+ export type PageAction =
34
+ /** Pause this long. */
35
+ {
36
+ type: 'wait';
37
+ milliseconds: number;
38
+ }
39
+ /** Wait until an element matching the selector is shown on the page (at most MAX_ACTION_WAIT_MS): one that is there but hidden does not count. */
40
+ | {
41
+ type: 'wait';
42
+ selector: string;
43
+ }
44
+ /** Click the first element matching the selector; `all` (Firecrawl v1) clicks every match, in document order. */
45
+ | {
46
+ type: 'click';
47
+ selector: string;
48
+ all?: boolean;
49
+ }
50
+ /** Type into the element that has focus (click it first), as a keyboard would. */
51
+ | {
52
+ type: 'write';
53
+ text: string;
54
+ }
55
+ /** Press one key (`Enter`, `Tab`, `ArrowDown`, `a`, ...). */
56
+ | {
57
+ type: 'press';
58
+ key: string;
59
+ }
60
+ /** Scroll the page, or the element matching `selector`, one screen up or down. */
61
+ | {
62
+ type: 'scroll';
63
+ direction: 'up' | 'down';
64
+ selector?: string;
65
+ }
66
+ /** An image of the page as it stands. */
67
+ | {
68
+ type: 'screenshot';
69
+ fullPage?: boolean;
70
+ quality?: number;
71
+ viewport?: ScreenshotViewport;
72
+ }
73
+ /** The page's HTML as it stands. */
74
+ | {
75
+ type: 'scrape';
76
+ }
77
+ /** Run a script in the page; what it returns (awaited, JSON-serialisable) is kept. */
78
+ | {
79
+ type: 'executeJavascript';
80
+ script: string;
81
+ }
82
+ /** The page printed as a PDF. */
83
+ | {
84
+ type: 'pdf';
85
+ format?: PdfPaperFormat;
86
+ landscape?: boolean;
87
+ scale?: number;
88
+ }
89
+ /**
90
+ * W2L's own: scroll the page (or the element `selector` names) to its end
91
+ * again and again until a round adds nothing: neither height nor, with
92
+ * `itemSelector`, items (`end`), or `maxScrolls` rounds (default 50).
93
+ */
94
+ | {
95
+ type: 'scrollToEnd';
96
+ selector?: string;
97
+ itemSelector?: string;
98
+ maxScrolls?: number;
99
+ waitMs?: number;
100
+ }
101
+ /**
102
+ * W2L's own: click the "load more" control `selector` again and again
103
+ * until it is gone, hidden or disabled (`end`), a click adds nothing
104
+ * (`no_growth`), or `maxClicks` (default 50).
105
+ */
106
+ | {
107
+ type: 'loadMore';
108
+ selector: string;
109
+ itemSelector?: string;
110
+ maxClicks?: number;
111
+ waitMs?: number;
112
+ }
113
+ /**
114
+ * W2L's own: read the page, follow `nextSelector`, read that page, and so
115
+ * on, each page's HTML kept in `scrapes`, until there is no next control,
116
+ * it is hidden or disabled (`end`), a page repeats one already read
117
+ * (`repeat`), or `maxPages` pages were read (default 10).
118
+ */
119
+ | {
120
+ type: 'paginate';
121
+ nextSelector: string;
122
+ itemSelector?: string;
123
+ maxPages?: number;
124
+ waitMs?: number;
125
+ };
126
+ export type PageActionType = PageAction['type'];
127
+ /** Why a step failed: the pipeline stops there. */
128
+ export type ActionErrorCode =
129
+ /** No element matched the selector of a click, or of a scroll within an element. */
130
+ 'selector_not_found'
131
+ /** A `wait` for a selector timed out. */
132
+ | 'selector_timeout'
133
+ /** The script threw, or returned something that cannot be serialised. */
134
+ | 'script_error'
135
+ /** A step led the page to a URL W2L does not fetch (robots.txt, the egress policy). */
136
+ | 'navigation_refused'
137
+ /** The scrape's deadline came before the step finished. */
138
+ | 'deadline_exceeded'
139
+ /** The browser refused the step (a PDF in a headed browser, a detached element, ...). */
140
+ | 'action_error';
141
+ /** A PDF a `pdf` step printed. */
142
+ export interface ActionPdf {
143
+ contentType: 'application/pdf';
144
+ format: PdfPaperFormat;
145
+ landscape: boolean;
146
+ scale: number;
147
+ bytes: number;
148
+ sha256: string;
149
+ path: string | null;
150
+ base64: string;
151
+ }
152
+ /** Why a scrollToEnd, loadMore or paginate step stopped. `max` and `deadline` stop short of the list's end. */
153
+ export type ListStop = 'end' | 'no_growth' | 'repeat' | 'max' | 'deadline';
154
+ /** What a scrollToEnd, loadMore or paginate step did. */
155
+ export interface ListRun {
156
+ index: number;
157
+ type: 'scrollToEnd' | 'loadMore' | 'paginate';
158
+ stoppedBy: ListStop;
159
+ /** Scrolls, clicks, or pages read. */
160
+ rounds: number;
161
+ /** Elements matching `itemSelector` at the end (on the last page for paginate; summed over its pages in `itemsRead`); null without one. */
162
+ items: number | null;
163
+ /** paginate: elements matching `itemSelector` over every page read; null without one. */
164
+ itemsRead?: number | null;
165
+ }
166
+ /** What the steps produced, each list in the order of its steps. */
167
+ export interface ActionsResult {
168
+ screenshots: ScreenshotEvidence[];
169
+ /** Each page's HTML, with the index of the step that read it (a scrape step, or each page of a paginate step). */
170
+ scrapes: {
171
+ url: string;
172
+ html: string;
173
+ step?: number;
174
+ }[];
175
+ /** `type` is the JavaScript `typeof` of the value (`null` for null). */
176
+ javascriptReturns: {
177
+ type: string;
178
+ value: unknown;
179
+ }[];
180
+ pdfs: ActionPdf[];
181
+ /** What each scrollToEnd, loadMore and paginate step did, and why it stopped. */
182
+ lists: ListRun[];
183
+ /** The step that failed, when one did: the steps after it did not run. */
184
+ failed?: {
185
+ index: number;
186
+ type: PageActionType;
187
+ code: ActionErrorCode;
188
+ message: string;
189
+ };
190
+ }
191
+ //# sourceMappingURL=actions.d.ts.map