mx-cloud 0.0.19 → 0.0.20

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 (2) hide show
  1. package/build/interpret.js +32 -21
  2. package/package.json +1 -1
@@ -360,11 +360,20 @@ class Interpreter extends events_1.EventEmitter {
360
360
  this.options.debugChannel.setActionType("screenshot");
361
361
  }
362
362
  const screenshotBuffer = yield page.screenshot(Object.assign(Object.assign({}, params), { path: undefined }));
363
- const baseName = nameOverride || "Screenshot";
364
- // Use the typed class property
365
- this.screenshotCounter += 1;
366
- const screenshotName = `${baseName} ${this.screenshotCounter}`;
367
- // ✅ Pass structured metadata to binaryCallback
363
+ // Prefer explicit nameOverride (from workflow step.name or computed action name)
364
+ // If nameOverride is provided (non-empty) use it *as-is*.
365
+ // Only use counter-appended name when no nameOverride is available.
366
+ const explicitName = (typeof nameOverride === 'string' && nameOverride.trim().length > 0) ? nameOverride.trim() : null;
367
+ let screenshotName;
368
+ if (explicitName) {
369
+ screenshotName = explicitName;
370
+ }
371
+ else {
372
+ // If no explicit name, produce a readable generated name with a counter
373
+ this.screenshotCounter += 1;
374
+ screenshotName = `Screenshot ${this.screenshotCounter}`;
375
+ }
376
+ // Pass structured metadata (name included) to binaryCallback
368
377
  yield this.options.binaryCallback({
369
378
  name: screenshotName,
370
379
  data: screenshotBuffer,
@@ -471,20 +480,13 @@ class Interpreter extends events_1.EventEmitter {
471
480
  if (!this.namedResults[actionType])
472
481
  this.namedResults[actionType] = {};
473
482
  this.namedResults[actionType][actionName] = this.cumulativeResults;
474
- if (!this.serializableDataByType[actionType])
475
- this.serializableDataByType[actionType] = {};
476
483
  if (!this.serializableDataByType[actionType])
477
484
  this.serializableDataByType[actionType] = {};
478
485
  if (!this.serializableDataByType[actionType][actionName]) {
479
- this.serializableDataByType[actionType][actionName] = {};
480
- }
481
- for (const row of this.cumulativeResults) {
482
- for (const [key, value] of Object.entries(row)) {
483
- if (value !== undefined) {
484
- this.serializableDataByType[actionType][actionName][key] = value;
485
- }
486
- }
486
+ this.serializableDataByType[actionType][actionName] = [];
487
487
  }
488
+ // Store as array (matching cumulativeResults structure)
489
+ this.serializableDataByType[actionType][actionName] = [...this.cumulativeResults];
488
490
  // now emit full structured object
489
491
  yield this.options.serializableCallback({
490
492
  scrapeList: this.serializableDataByType.scrapeList,
@@ -552,7 +554,13 @@ class Interpreter extends events_1.EventEmitter {
552
554
  if (!this.namedResults[actionType])
553
555
  this.namedResults[actionType] = {};
554
556
  this.namedResults[actionType][actionName] = [];
555
- yield this.options.serializableCallback(this.namedResults);
557
+ if (!this.serializableDataByType[actionType])
558
+ this.serializableDataByType[actionType] = {};
559
+ this.serializableDataByType[actionType][actionName] = [];
560
+ yield this.options.serializableCallback({
561
+ scrapeList: this.serializableDataByType.scrapeList,
562
+ scrapeSchema: this.serializableDataByType.scrapeSchema
563
+ });
556
564
  }
557
565
  }),
558
566
  scrapeListAuto: (config) => __awaiter(this, void 0, void 0, function* () {
@@ -625,25 +633,22 @@ class Interpreter extends events_1.EventEmitter {
625
633
  return;
626
634
  }
627
635
  this.log(`Launching ${String(step.action)}`, logger_1.Level.LOG);
636
+ let stepName = null;
628
637
  try {
629
638
  const debug = this.options.debugChannel;
630
639
  if (debug === null || debug === void 0 ? void 0 : debug.setActionType) {
631
640
  debug.setActionType(String(step.action));
632
641
  }
633
642
  // Safely extract name for this step
634
- let stepName = null;
635
- // If the workflow step itself has a name
636
643
  if (step === null || step === void 0 ? void 0 : step.name) {
637
644
  stepName = step.name;
638
645
  }
639
- // If the first arg is an object with a __name property
640
646
  else if (Array.isArray(step === null || step === void 0 ? void 0 : step.args) &&
641
647
  step.args.length > 0 &&
642
648
  typeof step.args[0] === "object" &&
643
649
  "__name" in step.args[0]) {
644
650
  stepName = step.args[0].__name;
645
651
  }
646
- // If args itself is an object with a __name property
647
652
  else if (typeof (step === null || step === void 0 ? void 0 : step.args) === "object" &&
648
653
  (step === null || step === void 0 ? void 0 : step.args) !== null &&
649
654
  "__name" in step.args) {
@@ -664,7 +669,13 @@ class Interpreter extends events_1.EventEmitter {
664
669
  if (step.action in wawActions) {
665
670
  // "Arrayifying" here should not be needed (TS + syntax checker - only arrays; but why not)
666
671
  const params = !step.args || Array.isArray(step.args) ? step.args : [step.args];
667
- yield wawActions[step.action](...(params !== null && params !== void 0 ? params : []));
672
+ if (step.action === 'screenshot') {
673
+ // call the screenshot handler directly to allow the extra name parameter
674
+ yield wawActions.screenshot(...(params !== null && params !== void 0 ? params : []), stepName !== null && stepName !== void 0 ? stepName : undefined);
675
+ }
676
+ else {
677
+ yield wawActions[step.action](...(params !== null && params !== void 0 ? params : []));
678
+ }
668
679
  }
669
680
  else {
670
681
  if ((_a = this.options.debugChannel) === null || _a === void 0 ? void 0 : _a.setActionType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mx-cloud",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "mx cloud",
5
5
  "main": "build/index.js",
6
6
  "typings": "build/index.d.ts",