maxun-sdk 0.0.1

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 (58) hide show
  1. package/README.md +58 -0
  2. package/dist/builders/extract-builder.d.ts +34 -0
  3. package/dist/builders/extract-builder.d.ts.map +1 -0
  4. package/dist/builders/extract-builder.js +71 -0
  5. package/dist/builders/extract-builder.js.map +1 -0
  6. package/dist/builders/workflow-builder.d.ts +92 -0
  7. package/dist/builders/workflow-builder.d.ts.map +1 -0
  8. package/dist/builders/workflow-builder.js +207 -0
  9. package/dist/builders/workflow-builder.js.map +1 -0
  10. package/dist/client/maxun-client.d.ts +74 -0
  11. package/dist/client/maxun-client.d.ts.map +1 -0
  12. package/dist/client/maxun-client.js +210 -0
  13. package/dist/client/maxun-client.js.map +1 -0
  14. package/dist/extract.d.ts +54 -0
  15. package/dist/extract.d.ts.map +1 -0
  16. package/dist/extract.js +81 -0
  17. package/dist/extract.js.map +1 -0
  18. package/dist/index.d.ts +11 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +34 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/llm/index.d.ts +12 -0
  23. package/dist/llm/index.d.ts.map +1 -0
  24. package/dist/llm/index.js +32 -0
  25. package/dist/llm/index.js.map +1 -0
  26. package/dist/llm/providers/anthropic.d.ts +13 -0
  27. package/dist/llm/providers/anthropic.d.ts.map +1 -0
  28. package/dist/llm/providers/anthropic.js +61 -0
  29. package/dist/llm/providers/anthropic.js.map +1 -0
  30. package/dist/llm/providers/base.d.ts +30 -0
  31. package/dist/llm/providers/base.d.ts.map +1 -0
  32. package/dist/llm/providers/base.js +27 -0
  33. package/dist/llm/providers/base.js.map +1 -0
  34. package/dist/llm/providers/ollama.d.ts +14 -0
  35. package/dist/llm/providers/ollama.d.ts.map +1 -0
  36. package/dist/llm/providers/ollama.js +56 -0
  37. package/dist/llm/providers/ollama.js.map +1 -0
  38. package/dist/llm/providers/openai.d.ts +13 -0
  39. package/dist/llm/providers/openai.d.ts.map +1 -0
  40. package/dist/llm/providers/openai.js +58 -0
  41. package/dist/llm/providers/openai.js.map +1 -0
  42. package/dist/llm/types.d.ts +25 -0
  43. package/dist/llm/types.d.ts.map +1 -0
  44. package/dist/llm/types.js +6 -0
  45. package/dist/llm/types.js.map +1 -0
  46. package/dist/robot/robot.d.ts +82 -0
  47. package/dist/robot/robot.d.ts.map +1 -0
  48. package/dist/robot/robot.js +128 -0
  49. package/dist/robot/robot.js.map +1 -0
  50. package/dist/scrape.d.ts +30 -0
  51. package/dist/scrape.d.ts.map +1 -0
  52. package/dist/scrape.js +39 -0
  53. package/dist/scrape.js.map +1 -0
  54. package/dist/types/index.d.ts +162 -0
  55. package/dist/types/index.d.ts.map +1 -0
  56. package/dist/types/index.js +16 -0
  57. package/dist/types/index.js.map +1 -0
  58. package/package.json +41 -0
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Maxun SDK
2
+
3
+ The official Node.js SDK for [Maxun](https://maxun.dev) - turn any website into an API.
4
+
5
+ Works with both Maxun Cloud and Maxun Open Source - automatically handles the differences for you.
6
+
7
+ https://github.com/user-attachments/assets/71a6f10b-5b2a-45dd-9ef7-53d0bcf2b76d
8
+
9
+
10
+ ## What can you do with Maxun SDK?
11
+
12
+ - **Extract structured data** from any website
13
+ - **Scrape entire pages** as Markdown or HTML
14
+ - **Use AI to extract data** with natural language prompts
15
+ - **Capture screenshots** (visible area or full page)
16
+ - **Automate workflows** with clicks, form fills, and navigation
17
+ - **Schedule recurring jobs** to keep your data fresh
18
+ - **Get webhooks** when extractions complete
19
+ - **Handle pagination** automatically (scroll, click, load more)
20
+
21
+ ## Quick Start
22
+ Follow the quick-start guide here: https://docs.maxun.dev/sdk/sdk-overview
23
+
24
+ ## Table of Contents
25
+
26
+ 1. [Extract Robots](https://docs.maxun.dev/sdk/sdk-extract)
27
+ - [LLM Extraction (Beta)](https://docs.maxun.dev/sdk/sdk-extract#llm-extraction-beta)
28
+ - [Non-LLM Extraction](https://docs.maxun.dev/sdk/sdk-extract#non-llm-extraction)
29
+ - [Auto Pagination](https://docs.maxun.dev/sdk/sdk-extract#2-auto-pagination-optional)
30
+ - [Auto List Capture](https://docs.maxun.dev/sdk/sdk-extract#1-auto-list-capture)
31
+
32
+ 2. [Scrape Robots](https://docs.maxun.dev/sdk/sdk-scrape)
33
+
34
+ 3. [Robot Management](https://docs.maxun.dev/sdk/sdk-robot)
35
+ - [Scheduling](https://docs.maxun.dev/sdk/sdk-robot#scheduling)
36
+ - [Webhooks](https://docs.maxun.dev/sdk/sdk-robot#webhooks)
37
+ - [Runs](https://docs.maxun.dev/sdk/sdk-robot#running-robots)
38
+ - [Error Handling](https://docs.maxun.dev/sdk/sdk-robot#error-handling)
39
+ - [Execution History](https://docs.maxun.dev/sdk/sdk-robot#execution-history)
40
+
41
+
42
+ ## Examples
43
+
44
+ Check out the [examples](./examples) directory for complete working examples:
45
+
46
+ | Example | What it does |
47
+ |---------|-------------|
48
+ | [basic-extraction.ts](./examples/basic-extraction.ts) | Extract fields from a single page |
49
+ | [list-pagination.ts](./examples/list-pagination.ts) | Scrape lists with different pagination strategies |
50
+ | [form-fill-screenshot.ts](./examples/form-fill-screenshot.ts) | Fill forms and capture screenshots |
51
+ | [chained-extract.ts](./examples/chained-extract.ts) | Execute multiple capture actions with one robot |
52
+ | [simple-scrape.ts](./examples/simple-scrape.ts) | Convert pages to Markdown/HTML/Screenshots |
53
+ | [llm-extraction.ts](./examples/llm-extraction.ts) | AI-powered extraction with natural language |
54
+ | [scheduling.ts](./examples/scheduling.ts) | Set up robot schedules to execute runs |
55
+ | [webhooks.ts](./examples/webhooks.ts) | Configure webhook notifications |
56
+ | [robot-management.ts](./examples/robot-management.ts) | CRUD operations for robots |
57
+ | [complete-workflow.ts](./examples/complete-workflow.ts) | Create a robot combining multiple features |
58
+
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Extract-specific workflow builder
3
+ */
4
+ import { WorkflowBuilder } from './workflow-builder';
5
+ import { ExtractListConfig, ExtractFields } from '../types';
6
+ import type { Robot } from '../robot/robot';
7
+ export declare class ExtractBuilder extends WorkflowBuilder implements PromiseLike<Robot> {
8
+ private extractor;
9
+ constructor(name: string);
10
+ /**
11
+ * Set the parent extractor (called internally)
12
+ */
13
+ setExtractor(extractor: any): this;
14
+ /**
15
+ * Capture specific text fields from the page
16
+ */
17
+ captureText(fields: ExtractFields, name?: string): this;
18
+ /**
19
+ * Capture a list of items with pagination support
20
+ * All fields are automatically detected and extracted
21
+ *
22
+ * @param config - List extraction configuration
23
+ * @param config.selector - CSS selector for list items
24
+ * @param config.pagination - Optional pagination configuration
25
+ * @param config.maxItems - Maximum number of items to extract (default: 100)
26
+ * @param name - Optional action name
27
+ */
28
+ captureList(config: ExtractListConfig, name?: string): this;
29
+ /**
30
+ * Make the builder awaitable - converts builder to Robot instance
31
+ */
32
+ then<TResult1 = Robot, TResult2 = never>(onfulfilled?: ((value: Robot) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
33
+ }
34
+ //# sourceMappingURL=extract-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-builder.d.ts","sourceRoot":"","sources":["../../src/builders/extract-builder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAoB,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,qBAAa,cAAe,SAAQ,eAAgB,YAAW,WAAW,CAAC,KAAK,CAAC;IAC/E,OAAO,CAAC,SAAS,CAAW;gBAEhB,IAAI,EAAE,MAAM;IAIxB;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI;IAKlC;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAWvD;;;;;;;;;OASG;IACH,WAAW,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAsB3D;;OAEG;IACH,IAAI,CAAC,QAAQ,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EACrC,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,EACzE,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,GACtE,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;CAUpC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ /**
3
+ * Extract-specific workflow builder
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ExtractBuilder = void 0;
7
+ const workflow_builder_1 = require("./workflow-builder");
8
+ class ExtractBuilder extends workflow_builder_1.WorkflowBuilder {
9
+ constructor(name) {
10
+ super(name, 'extract');
11
+ }
12
+ /**
13
+ * Set the parent extractor (called internally)
14
+ */
15
+ setExtractor(extractor) {
16
+ this.extractor = extractor;
17
+ return this;
18
+ }
19
+ /**
20
+ * Capture specific text fields from the page
21
+ */
22
+ captureText(fields, name) {
23
+ // Pass fields directly as plain selectors
24
+ this.addAction({
25
+ action: 'scrapeSchema',
26
+ args: [fields],
27
+ name: name,
28
+ });
29
+ return this;
30
+ }
31
+ /**
32
+ * Capture a list of items with pagination support
33
+ * All fields are automatically detected and extracted
34
+ *
35
+ * @param config - List extraction configuration
36
+ * @param config.selector - CSS selector for list items
37
+ * @param config.pagination - Optional pagination configuration
38
+ * @param config.maxItems - Maximum number of items to extract (default: 100)
39
+ * @param name - Optional action name
40
+ */
41
+ captureList(config, name) {
42
+ const scrapeListConfig = {
43
+ itemSelector: config.selector,
44
+ maxItems: config.maxItems || 100
45
+ };
46
+ if (config.pagination) {
47
+ scrapeListConfig.pagination = {
48
+ type: config.pagination.type,
49
+ selector: config.pagination.selector || null
50
+ };
51
+ }
52
+ this.addAction({
53
+ action: 'scrapeList',
54
+ args: [scrapeListConfig],
55
+ name: name,
56
+ });
57
+ return this;
58
+ }
59
+ /**
60
+ * Make the builder awaitable - converts builder to Robot instance
61
+ */
62
+ then(onfulfilled, onrejected) {
63
+ if (!this.extractor) {
64
+ return Promise.reject(new Error('Builder not properly initialized. Use extractor.create() to create a builder.')).then(onfulfilled, onrejected);
65
+ }
66
+ // Build and convert to Robot
67
+ return this.extractor.build(this).then(onfulfilled, onrejected);
68
+ }
69
+ }
70
+ exports.ExtractBuilder = ExtractBuilder;
71
+ //# sourceMappingURL=extract-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-builder.js","sourceRoot":"","sources":["../../src/builders/extract-builder.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yDAAqD;AAKrD,MAAa,cAAe,SAAQ,kCAAe;IAGjD,YAAY,IAAY;QACtB,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,SAAc;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,MAAqB,EAAE,IAAa;QAC9C,0CAA0C;QAC1C,IAAI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,cAAc;YACtB,IAAI,EAAE,CAAC,MAAM,CAAC;YACd,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;OASG;IACH,WAAW,CAAC,MAAyB,EAAE,IAAa;QAClD,MAAM,gBAAgB,GAAQ;YAC5B,YAAY,EAAE,MAAM,CAAC,QAAQ;YAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,GAAG;SACjC,CAAC;QAEF,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,gBAAgB,CAAC,UAAU,GAAG;gBAC5B,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI;gBAC5B,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,IAAI,IAAI;aAC7C,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,YAAY;YACpB,IAAI,EAAE,CAAC,gBAAgB,CAAC;YACxB,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,IAAI,CACF,WAAyE,EACzE,UAAuE;QAEvE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAC3F,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAClC,CAAC;QAED,6BAA6B;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;CACF;AA7ED,wCA6EC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Base Workflow Builder
3
+ * Provides common functionality for building Maxun workflows
4
+ */
5
+ import { Workflow, WhereWhatPair, What, RobotMeta, RobotType, RobotMode, Format } from '../types';
6
+ export declare abstract class WorkflowBuilder {
7
+ protected name: string;
8
+ protected robotType: RobotType;
9
+ protected workflow: Workflow;
10
+ protected meta: Partial<RobotMeta>;
11
+ protected currentStep: WhereWhatPair | null;
12
+ private isFirstNavigation;
13
+ constructor(name: string, robotType: RobotType);
14
+ /**
15
+ * Navigate to a URL
16
+ */
17
+ navigate(url: string): this;
18
+ /**
19
+ * Click on an element
20
+ */
21
+ click(selector: string): this;
22
+ /**
23
+ * Type text into an input
24
+ * The input type will be automatically detected during validation if not provided
25
+ */
26
+ type(selector: string, text: string, inputType?: string): this;
27
+ /**
28
+ * Wait for a selector to appear
29
+ */
30
+ waitFor(selector: string, timeout?: number): this;
31
+ /**
32
+ * Wait for a specific duration
33
+ */
34
+ wait(milliseconds: number): this;
35
+ /**
36
+ * Capture a screenshot
37
+ */
38
+ captureScreenshot(name?: string, options?: {
39
+ fullPage?: boolean;
40
+ type?: 'png' | 'jpeg';
41
+ quality?: number;
42
+ timeout?: number;
43
+ caret?: 'hide' | 'initial';
44
+ scale?: 'css' | 'device';
45
+ animations?: 'disabled' | 'allow';
46
+ }): this;
47
+ /**
48
+ * Scroll the page
49
+ */
50
+ scroll(direction: 'up' | 'down' | 'top' | 'bottom', distance?: number): this;
51
+ /**
52
+ * Set cookies
53
+ */
54
+ setCookies(cookies: Array<{
55
+ name: string;
56
+ value: string;
57
+ domain?: string;
58
+ }>): this;
59
+ /**
60
+ * Set robot mode (normal or bulk)
61
+ */
62
+ mode(mode: RobotMode): this;
63
+ /**
64
+ * Set output formats
65
+ */
66
+ format(formats: Format[]): this;
67
+ /**
68
+ * Add a new step to the workflow
69
+ */
70
+ protected addStep(step: WhereWhatPair): void;
71
+ /**
72
+ * Add an action to the current step
73
+ * Actions are added to the end since what[] executes top-to-bottom
74
+ */
75
+ protected addAction(action: What): void;
76
+ /**
77
+ * Get the built workflow (array only)
78
+ */
79
+ getWorkflowArray(): Workflow;
80
+ /**
81
+ * Get the complete workflow structure with metadata
82
+ */
83
+ getWorkflow(): {
84
+ meta: Partial<RobotMeta>;
85
+ workflow: Workflow;
86
+ };
87
+ /**
88
+ * Get the robot metadata
89
+ */
90
+ getMeta(): Partial<RobotMeta>;
91
+ }
92
+ //# sourceMappingURL=workflow-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-builder.d.ts","sourceRoot":"","sources":["../../src/builders/workflow-builder.ts"],"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C,EAAE,UAAU,GAAG,OAAO,CAAC;KACnC,GAAG,IAAI;IA0BR;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ5E;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI;IAOlF;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAM3B;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAK/B;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAK5C;;;OAGG;IACH,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI;IAavC;;OAEG;IACH,gBAAgB,IAAI,QAAQ;IAI5B;;OAEG;IACH,WAAW,IAAI;QAAE,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE;IAO/D;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC;CAG9B"}
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ /**
3
+ * Base Workflow Builder
4
+ * Provides common functionality for building Maxun workflows
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.WorkflowBuilder = void 0;
8
+ class WorkflowBuilder {
9
+ constructor(name, robotType) {
10
+ this.name = name;
11
+ this.robotType = robotType;
12
+ this.workflow = [];
13
+ this.meta = {};
14
+ this.currentStep = null;
15
+ this.isFirstNavigation = true;
16
+ this.meta.name = name;
17
+ this.meta.robotType = robotType;
18
+ }
19
+ /**
20
+ * Navigate to a URL
21
+ */
22
+ navigate(url) {
23
+ // Create the main step (no goto action here)
24
+ const mainStep = {
25
+ where: { url },
26
+ what: [],
27
+ };
28
+ // Only add about:blank on FIRST navigation
29
+ if (this.isFirstNavigation) {
30
+ // Create the about:blank step
31
+ const aboutBlankStep = {
32
+ where: { url: 'about:blank' },
33
+ what: [
34
+ {
35
+ action: 'goto',
36
+ args: [url],
37
+ },
38
+ {
39
+ action: 'waitForLoadState',
40
+ args: ['networkidle'],
41
+ },
42
+ ],
43
+ };
44
+ // Add main step to front, about:blank to end (bottom)
45
+ this.workflow.unshift(mainStep);
46
+ this.workflow.push(aboutBlankStep);
47
+ this.isFirstNavigation = false;
48
+ }
49
+ else {
50
+ // Subsequent navigations: add to front
51
+ this.workflow.unshift(mainStep);
52
+ }
53
+ this.currentStep = mainStep;
54
+ return this;
55
+ }
56
+ /**
57
+ * Click on an element
58
+ */
59
+ click(selector) {
60
+ this.addAction({
61
+ action: 'click',
62
+ args: [selector],
63
+ });
64
+ return this;
65
+ }
66
+ /**
67
+ * Type text into an input
68
+ * The input type will be automatically detected during validation if not provided
69
+ */
70
+ type(selector, text, inputType) {
71
+ const args = inputType
72
+ ? [selector, text, inputType] // User specified type
73
+ : [selector, text]; // Will be auto-detected by enricher
74
+ this.addAction({
75
+ action: 'type',
76
+ args: args,
77
+ });
78
+ return this;
79
+ }
80
+ /**
81
+ * Wait for a selector to appear
82
+ */
83
+ waitFor(selector, timeout) {
84
+ this.addAction({
85
+ action: 'waitForSelector',
86
+ args: [selector, { timeout: timeout || 30000 }],
87
+ });
88
+ return this;
89
+ }
90
+ /**
91
+ * Wait for a specific duration
92
+ */
93
+ wait(milliseconds) {
94
+ this.addAction({
95
+ action: 'waitForTimeout',
96
+ args: [milliseconds],
97
+ });
98
+ return this;
99
+ }
100
+ /**
101
+ * Capture a screenshot
102
+ */
103
+ captureScreenshot(name, options) {
104
+ const screenshotArgs = options ? {
105
+ type: options.type || 'png',
106
+ caret: options.caret || 'hide',
107
+ scale: options.scale || 'device',
108
+ timeout: options.timeout || 30000,
109
+ fullPage: options.fullPage !== undefined ? options.fullPage : true,
110
+ animations: options.animations || 'allow',
111
+ ...(options.quality && { quality: options.quality })
112
+ } : {
113
+ type: 'png',
114
+ caret: 'hide',
115
+ scale: 'device',
116
+ timeout: 30000,
117
+ fullPage: true,
118
+ animations: 'allow'
119
+ };
120
+ this.addAction({
121
+ action: 'screenshot',
122
+ name: name,
123
+ args: [screenshotArgs]
124
+ });
125
+ return this;
126
+ }
127
+ /**
128
+ * Scroll the page
129
+ */
130
+ scroll(direction, distance) {
131
+ this.addAction({
132
+ action: 'scroll',
133
+ args: [{ direction, distance }],
134
+ });
135
+ return this;
136
+ }
137
+ /**
138
+ * Set cookies
139
+ */
140
+ setCookies(cookies) {
141
+ if (this.currentStep) {
142
+ this.currentStep.where.cookies = cookies;
143
+ }
144
+ return this;
145
+ }
146
+ /**
147
+ * Set robot mode (normal or bulk)
148
+ */
149
+ mode(mode) {
150
+ this.meta.mode = mode;
151
+ return this;
152
+ }
153
+ /**
154
+ * Set output formats
155
+ */
156
+ format(formats) {
157
+ this.meta.formats = formats;
158
+ return this;
159
+ }
160
+ /**
161
+ * Add a new step to the workflow
162
+ */
163
+ addStep(step) {
164
+ this.currentStep = step;
165
+ this.workflow.unshift(step);
166
+ }
167
+ /**
168
+ * Add an action to the current step
169
+ * Actions are added to the end since what[] executes top-to-bottom
170
+ */
171
+ addAction(action) {
172
+ if (!this.currentStep) {
173
+ // Create a new step if none exists
174
+ this.addStep({
175
+ where: {},
176
+ what: [action],
177
+ });
178
+ }
179
+ else {
180
+ // Use push to add to end - top-to-bottom execution
181
+ this.currentStep.what.push(action);
182
+ }
183
+ }
184
+ /**
185
+ * Get the built workflow (array only)
186
+ */
187
+ getWorkflowArray() {
188
+ return this.workflow;
189
+ }
190
+ /**
191
+ * Get the complete workflow structure with metadata
192
+ */
193
+ getWorkflow() {
194
+ return {
195
+ meta: this.meta,
196
+ workflow: this.workflow
197
+ };
198
+ }
199
+ /**
200
+ * Get the robot metadata
201
+ */
202
+ getMeta() {
203
+ return this.meta;
204
+ }
205
+ }
206
+ exports.WorkflowBuilder = WorkflowBuilder;
207
+ //# sourceMappingURL=workflow-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-builder.js","sourceRoot":"","sources":["../../src/builders/workflow-builder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAaH,MAAsB,eAAe;IAMnC,YAAsB,IAAY,EAAY,SAAoB;QAA5C,SAAI,GAAJ,IAAI,CAAQ;QAAY,cAAS,GAAT,SAAS,CAAW;QALxD,aAAQ,GAAa,EAAE,CAAC;QACxB,SAAI,GAAuB,EAAE,CAAC;QAC9B,gBAAW,GAAyB,IAAI,CAAC;QAC3C,sBAAiB,GAAY,IAAI,CAAC;QAGxC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,GAAW;QAClB,6CAA6C;QAC7C,MAAM,QAAQ,GAAkB;YAC9B,KAAK,EAAE,EAAE,GAAG,EAAE;YACd,IAAI,EAAE,EAAE;SACT,CAAC;QAEF,2CAA2C;QAC3C,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,8BAA8B;YAC9B,MAAM,cAAc,GAAkB;gBACpC,KAAK,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE;gBAC7B,IAAI,EAAE;oBACJ;wBACE,MAAM,EAAE,MAAM;wBACd,IAAI,EAAE,CAAC,GAAG,CAAC;qBACZ;oBACD;wBACE,MAAM,EAAE,kBAAkB;wBAC1B,IAAI,EAAE,CAAC,aAAa,CAAC;qBACtB;iBACF;aACF,CAAC;YAEF,sDAAsD;YACtD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,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ACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,IAAe;QAClB,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAGD;;OAEG;IACH,MAAM,CAAC,OAAiB;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACO,OAAO,CAAC,IAAmB;QACnC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACO,SAAS,CAAC,MAAY;QAC9B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,mCAAmC;YACnC,IAAI,CAAC,OAAO,CAAC;gBACX,KAAK,EAAE,EAAE;gBACT,IAAI,EAAE,CAAC,MAAM,CAAC;aACf,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,mDAAmD;YACnD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF;AA/ND,0CA+NC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Maxun API Client
3
+ * Handles all HTTP communication with the Maxun backend API
4
+ */
5
+ import { Config, RobotData, Run, RunResult, ScheduleConfig, WebhookConfig, WorkflowFile, ExecutionOptions } from '../types';
6
+ export declare class Client {
7
+ private axios;
8
+ private apiKey;
9
+ constructor(config: Config);
10
+ /**
11
+ * Handle API errors and convert to MaxunError
12
+ */
13
+ private handleError;
14
+ /**
15
+ * Get all robots for the authenticated user
16
+ */
17
+ getRobots(): Promise<RobotData[]>;
18
+ /**
19
+ * Get a specific robot by ID
20
+ */
21
+ getRobot(robotId: string): Promise<RobotData>;
22
+ /**
23
+ * Create a new robot
24
+ */
25
+ createRobot(workflowFile: WorkflowFile): Promise<RobotData>;
26
+ /**
27
+ * Update an existing robot
28
+ */
29
+ updateRobot(robotId: string, updates: Partial<WorkflowFile>): Promise<RobotData>;
30
+ /**
31
+ * Delete a robot
32
+ */
33
+ deleteRobot(robotId: string): Promise<void>;
34
+ /**
35
+ * Execute a robot and get results
36
+ */
37
+ executeRobot(robotId: string, options?: ExecutionOptions): Promise<RunResult>;
38
+ /**
39
+ * Get all runs for a robot
40
+ */
41
+ getRuns(robotId: string): Promise<Run[]>;
42
+ /**
43
+ * Get a specific run by ID
44
+ */
45
+ getRun(robotId: string, runId: string): Promise<Run>;
46
+ /**
47
+ * Abort a running or queued run
48
+ */
49
+ abortRun(robotId: string, runId: string): Promise<void>;
50
+ /**
51
+ * Schedule a robot for periodic execution
52
+ */
53
+ scheduleRobot(robotId: string, schedule: ScheduleConfig): Promise<RobotData>;
54
+ /**
55
+ * Remove schedule from a robot
56
+ */
57
+ unscheduleRobot(robotId: string): Promise<RobotData>;
58
+ /**
59
+ * Add a webhook to a robot
60
+ */
61
+ addWebhook(robotId: string, webhook: WebhookConfig): Promise<RobotData>;
62
+ /**
63
+ * LLM-based extraction - extract data using natural language prompt
64
+ */
65
+ extractWithLLM(url: string, options: {
66
+ prompt: string;
67
+ llmProvider?: 'anthropic' | 'openai' | 'ollama';
68
+ llmModel?: string;
69
+ llmApiKey?: string;
70
+ llmBaseUrl?: string;
71
+ robotName?: string;
72
+ }): Promise<any>;
73
+ }
74
+ //# sourceMappingURL=maxun-client.d.ts.map
@@ -0,0 +1 @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