mx-cloud 0.0.20 → 0.0.22

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.
@@ -1,4 +1,4 @@
1
- import { Page } from 'playwright';
1
+ import { Page } from 'playwright-core';
2
2
  import { EventEmitter } from 'events';
3
3
  import { WorkflowFile, ParamType } from './types/workflow';
4
4
  /**
@@ -61,6 +61,7 @@ export default class Interpreter extends EventEmitter {
61
61
  private autohealFailures;
62
62
  private namedResults;
63
63
  private screenshotCounter;
64
+ private scrapeListCounter;
64
65
  private serializableDataByType;
65
66
  constructor(workflow: WorkflowFile, options?: Partial<InterpreterOptions>);
66
67
  trackAutohealFailure(error: string): void;
@@ -69,6 +69,7 @@ class Interpreter extends events_1.EventEmitter {
69
69
  this.autohealFailures = [];
70
70
  this.namedResults = {};
71
71
  this.screenshotCounter = 0;
72
+ this.scrapeListCounter = 0;
72
73
  this.serializableDataByType = {
73
74
  scrapeList: {},
74
75
  scrapeSchema: {}
@@ -513,6 +514,7 @@ class Interpreter extends events_1.EventEmitter {
513
514
  this.options.debugChannel.incrementScrapeListIndex();
514
515
  }
515
516
  let scrapeResults = [];
517
+ let paginationUsed = false;
516
518
  if (!config.pagination) {
517
519
  scrapeResults = yield page.evaluate((cfg) => {
518
520
  try {
@@ -525,6 +527,7 @@ class Interpreter extends events_1.EventEmitter {
525
527
  }, config);
526
528
  }
527
529
  else {
530
+ paginationUsed = true;
528
531
  scrapeResults = yield this.handlePagination(page, config);
529
532
  }
530
533
  // Ensure we always have an array
@@ -532,19 +535,28 @@ class Interpreter extends events_1.EventEmitter {
532
535
  scrapeResults = [];
533
536
  }
534
537
  console.log(`ScrapeList completed with ${scrapeResults.length} results`);
535
- // Append list results under "scrapeList" name
536
- const actionType = "scrapeList";
537
- const actionName = config.__name || "List";
538
- if (!this.serializableDataByType[actionType])
539
- this.serializableDataByType[actionType] = {};
540
- if (!this.serializableDataByType[actionType][actionName]) {
541
- this.serializableDataByType[actionType][actionName] = [];
538
+ // Only process and callback if pagination wasn't used
539
+ // (handlePagination already handles storage and callbacks internally)
540
+ if (!paginationUsed) {
541
+ // ✅ Append list results under "scrapeList" → name
542
+ const actionType = "scrapeList";
543
+ let actionName = config.__name || "";
544
+ // If no name provided, generate a unique one
545
+ if (!actionName || actionName.trim() === "") {
546
+ this.scrapeListCounter++;
547
+ actionName = `List ${this.scrapeListCounter}`;
548
+ }
549
+ if (!this.serializableDataByType[actionType])
550
+ this.serializableDataByType[actionType] = {};
551
+ if (!this.serializableDataByType[actionType][actionName]) {
552
+ this.serializableDataByType[actionType][actionName] = [];
553
+ }
554
+ this.serializableDataByType[actionType][actionName].push(...scrapeResults);
555
+ yield this.options.serializableCallback({
556
+ scrapeList: this.serializableDataByType.scrapeList,
557
+ scrapeSchema: this.serializableDataByType.scrapeSchema
558
+ });
542
559
  }
543
- this.serializableDataByType[actionType][actionName].push(...scrapeResults);
544
- yield this.options.serializableCallback({
545
- scrapeList: this.serializableDataByType.scrapeList,
546
- scrapeSchema: this.serializableDataByType.scrapeSchema
547
- });
548
560
  }
549
561
  catch (error) {
550
562
  console.error('ScrapeList action failed completely:', error.message);
@@ -739,6 +751,20 @@ class Interpreter extends events_1.EventEmitter {
739
751
  this.log('Workflow aborted, stopping pagination', logger_1.Level.WARN);
740
752
  return [];
741
753
  }
754
+ // Generate action name for this scrapeList
755
+ const actionType = "scrapeList";
756
+ let actionName = config.__name || "";
757
+ if (!actionName || actionName.trim() === "") {
758
+ this.scrapeListCounter++;
759
+ actionName = `List ${this.scrapeListCounter}`;
760
+ }
761
+ // Initialize storage for this action
762
+ if (!this.serializableDataByType[actionType]) {
763
+ this.serializableDataByType[actionType] = {};
764
+ }
765
+ if (!this.serializableDataByType[actionType][actionName]) {
766
+ this.serializableDataByType[actionType][actionName] = [];
767
+ }
742
768
  let allResults = [];
743
769
  let previousHeight = 0;
744
770
  let scrapedItems = new Set();
@@ -775,7 +801,12 @@ class Interpreter extends events_1.EventEmitter {
775
801
  });
776
802
  allResults = allResults.concat(newResults);
777
803
  debugLog("Results collected:", allResults.length);
778
- yield this.options.serializableCallback(allResults);
804
+ // Store in serializableDataByType and send structured callback
805
+ this.serializableDataByType[actionType][actionName] = [...allResults];
806
+ yield this.options.serializableCallback({
807
+ scrapeList: this.serializableDataByType.scrapeList,
808
+ scrapeSchema: this.serializableDataByType.scrapeSchema
809
+ });
779
810
  });
780
811
  const checkLimit = () => {
781
812
  if (config.limit && allResults.length >= config.limit) {
@@ -1062,7 +1093,7 @@ class Interpreter extends events_1.EventEmitter {
1062
1093
  }).catch(e => {
1063
1094
  throw e;
1064
1095
  }),
1065
- button.click()
1096
+ page.locator(workingSelector).first().click()
1066
1097
  ]);
1067
1098
  debugLog("Navigation successful after regular click");
1068
1099
  yield page.waitForTimeout(2000);
@@ -1078,7 +1109,7 @@ class Interpreter extends events_1.EventEmitter {
1078
1109
  }).catch(e => {
1079
1110
  throw e;
1080
1111
  }),
1081
- button.dispatchEvent('click')
1112
+ page.locator(workingSelector).first().dispatchEvent('click')
1082
1113
  ]);
1083
1114
  debugLog("Navigation successful after dispatch event");
1084
1115
  yield page.waitForTimeout(2000);
@@ -1086,11 +1117,11 @@ class Interpreter extends events_1.EventEmitter {
1086
1117
  }
1087
1118
  catch (dispatchNavError) {
1088
1119
  try {
1089
- yield button.click();
1120
+ yield page.locator(workingSelector).first().click();
1090
1121
  yield page.waitForTimeout(2000);
1091
1122
  }
1092
1123
  catch (clickError) {
1093
- yield button.dispatchEvent('click');
1124
+ yield page.locator(workingSelector).first().dispatchEvent('click');
1094
1125
  yield page.waitForTimeout(2000);
1095
1126
  }
1096
1127
  }
@@ -1,4 +1,4 @@
1
- import { ElementHandle, Page } from "playwright";
1
+ import { ElementHandle, Page } from "playwright-core";
2
2
  export declare const generateSelectors: (page: Page, elementHandle: ElementHandle) => Promise<{
3
3
  id: any;
4
4
  generalSelector: any;
@@ -1,4 +1,4 @@
1
- import { Page } from 'playwright';
1
+ import { Page } from 'playwright-core';
2
2
  import { naryOperators, unaryOperators, operators, meta } from './logic';
3
3
  export type Operator = typeof operators[number];
4
4
  export type UnaryOperator = typeof unaryOperators[number];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mx-cloud",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "mx cloud",
5
5
  "main": "build/index.js",
6
6
  "typings": "build/index.d.ts",
@@ -20,8 +20,6 @@
20
20
  "cross-fetch": "^4.0.0",
21
21
  "joi": "^17.6.0",
22
22
  "nodemailer": "^6.10.0",
23
- "playwright": "^1.50.0",
24
- "playwright-extra": "^4.3.6",
25
- "puppeteer-extra-plugin-stealth": "^2.11.2"
23
+ "playwright-core": "^1.57.0"
26
24
  }
27
25
  }