@objectstack/service-automation 9.8.0 → 9.9.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.
package/dist/index.cjs CHANGED
@@ -765,7 +765,7 @@ var _AutomationEngine = class _AutomationEngine {
765
765
  if (!skipBubble) {
766
766
  await this.bubbleToParent(run, output);
767
767
  }
768
- return { success: true, output, durationMs };
768
+ return { success: true, output, durationMs, successMessage: flow.successMessage };
769
769
  } catch (err) {
770
770
  if (isSuspendSignal(err)) {
771
771
  const durationMs2 = Date.now() - run.startTime;
@@ -814,7 +814,7 @@ var _AutomationEngine = class _AutomationEngine {
814
814
  if (!skipBubble) {
815
815
  await this.failAncestors(run.context, errorMessage);
816
816
  }
817
- return { success: false, error: errorMessage, durationMs };
817
+ return { success: false, error: errorMessage, durationMs, errorMessage: flow.errorMessage };
818
818
  }
819
819
  } finally {
820
820
  this.resuming.delete(runId);
@@ -2388,8 +2388,34 @@ function registerScreenNodes(engine, ctx) {
2388
2388
  supportsPause: true,
2389
2389
  isAsync: true
2390
2390
  }),
2391
- async execute(node, _variables, _context) {
2391
+ async execute(node, variables, context) {
2392
2392
  const cfg = node.config ?? {};
2393
+ const interp = (v) => {
2394
+ if (v == null) return void 0;
2395
+ const r = interpolate(v, variables, context);
2396
+ return r == null ? void 0 : String(r);
2397
+ };
2398
+ const objectName = typeof cfg.objectName === "string" && cfg.objectName.trim() ? cfg.objectName.trim() : void 0;
2399
+ if (objectName) {
2400
+ const defaults = cfg.defaults && typeof cfg.defaults === "object" ? interpolate(cfg.defaults, variables, context) : void 0;
2401
+ const idVariable = typeof cfg.idVariable === "string" && cfg.idVariable.trim() ? cfg.idVariable.trim() : void 0;
2402
+ return {
2403
+ success: true,
2404
+ suspend: true,
2405
+ screen: {
2406
+ nodeId: node.id,
2407
+ kind: "object-form",
2408
+ title: interp(cfg.title) ?? node.label ?? objectName,
2409
+ description: interp(cfg.description),
2410
+ objectName,
2411
+ mode: cfg.mode === "edit" ? "edit" : "create",
2412
+ recordId: cfg.recordId != null ? interp(cfg.recordId) : void 0,
2413
+ defaults,
2414
+ idVariable,
2415
+ fields: []
2416
+ }
2417
+ };
2418
+ }
2393
2419
  const rawFields = Array.isArray(cfg.fields) ? cfg.fields : [];
2394
2420
  const hasFields = rawFields.length > 0;
2395
2421
  const shouldPause = cfg.waitForInput === true || hasFields && cfg.waitForInput !== false;
@@ -2402,7 +2428,7 @@ function registerScreenNodes(engine, ctx) {
2402
2428
  type: f.type != null ? String(f.type) : void 0,
2403
2429
  required: f.required === true,
2404
2430
  options: Array.isArray(f.options) ? f.options : void 0,
2405
- defaultValue: f.defaultValue,
2431
+ defaultValue: f.defaultValue !== void 0 ? interpolate(f.defaultValue, variables, context) : void 0,
2406
2432
  placeholder: f.placeholder != null ? String(f.placeholder) : void 0
2407
2433
  })).filter((f) => f.name.length > 0);
2408
2434
  return {
@@ -2410,8 +2436,8 @@ function registerScreenNodes(engine, ctx) {
2410
2436
  suspend: true,
2411
2437
  screen: {
2412
2438
  nodeId: node.id,
2413
- title: cfg.title ?? node.label ?? "Input",
2414
- description: cfg.description,
2439
+ title: interp(cfg.title) ?? node.label ?? "Input",
2440
+ description: interp(cfg.description),
2415
2441
  fields
2416
2442
  }
2417
2443
  };