@lunnoa/client 2.2.0 → 2.4.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.
package/dist/react.cjs CHANGED
@@ -604,6 +604,40 @@ function resolveActionAppId(action) {
604
604
  `Cannot infer appId for action "${id}". Pass appId explicitly.`
605
605
  );
606
606
  }
607
+ function resolveTriggerAppId(trigger) {
608
+ if (trigger.appId?.trim()) {
609
+ return trigger.appId.trim();
610
+ }
611
+ const id = trigger.id.trim();
612
+ const marker = "_trigger_";
613
+ const markerIndex = id.indexOf(marker);
614
+ if (markerIndex > 0) {
615
+ return id.slice(0, markerIndex);
616
+ }
617
+ const dot = id.indexOf(".");
618
+ if (dot > 0) {
619
+ return id.slice(0, dot);
620
+ }
621
+ throw new Error(
622
+ `Cannot infer appId for trigger "${id}". Pass appId explicitly.`
623
+ );
624
+ }
625
+ function resolveTriggerId(trigger) {
626
+ const id = trigger.id.trim();
627
+ const appId = trigger.appId?.trim();
628
+ if (appId && id.startsWith(`${appId}.`)) {
629
+ return id.slice(appId.length + 1);
630
+ }
631
+ const marker = "_trigger_";
632
+ if (id.includes(marker)) {
633
+ return id;
634
+ }
635
+ const dot = id.indexOf(".");
636
+ if (dot > 0) {
637
+ return id.slice(dot + 1);
638
+ }
639
+ return id;
640
+ }
607
641
  function resolveActionId(action) {
608
642
  const id = action.id.trim();
609
643
  const appId = action.appId?.trim();
@@ -1816,7 +1850,9 @@ function stepFromDefinition(step) {
1816
1850
  ...use.input ?? {},
1817
1851
  ...step.input ?? {}
1818
1852
  };
1853
+ const key = step.key;
1819
1854
  return {
1855
+ ...key ? { key } : {},
1820
1856
  appId: resolveActionAppId(use),
1821
1857
  actionId: resolveActionId(use),
1822
1858
  ...use.connection?.id ? { connectionId: use.connection.id } : {},
@@ -2018,9 +2054,21 @@ var WorkflowAppsResource = class {
2018
2054
  };
2019
2055
 
2020
2056
  // src/resources/workflows.ts
2057
+ function triggerToUpsertInput(trigger) {
2058
+ return {
2059
+ triggerId: resolveTriggerId(trigger),
2060
+ appId: resolveTriggerAppId(trigger),
2061
+ ...trigger.connection?.id ? { connectionId: trigger.connection.id } : {},
2062
+ ...trigger.input ? { input: trigger.input } : {},
2063
+ ...trigger.inputs?.length ? { inputs: trigger.inputs } : {},
2064
+ ...trigger.name ? { name: trigger.name } : {},
2065
+ ...trigger.description ? { description: trigger.description } : {}
2066
+ };
2067
+ }
2021
2068
  function stepToUpsertInput(step) {
2022
2069
  const use = step.use;
2023
2070
  return {
2071
+ ...step.key ? { key: step.key } : {},
2024
2072
  appId: resolveActionAppId(use),
2025
2073
  actionId: resolveActionId(use),
2026
2074
  connectionId: use.connection?.id,
@@ -2038,6 +2086,7 @@ function workflowDefinitionToUpsert(def) {
2038
2086
  name: def.name,
2039
2087
  description: def.description,
2040
2088
  isActive: def.isActive,
2089
+ ...def.trigger ? { trigger: triggerToUpsertInput(def.trigger) } : {},
2041
2090
  managedByCode: true,
2042
2091
  steps: def.steps.map(stepToUpsertInput)
2043
2092
  };