@lunnoa/client 2.2.0 → 2.3.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();
@@ -2018,6 +2052,17 @@ var WorkflowAppsResource = class {
2018
2052
  };
2019
2053
 
2020
2054
  // src/resources/workflows.ts
2055
+ function triggerToUpsertInput(trigger) {
2056
+ return {
2057
+ triggerId: resolveTriggerId(trigger),
2058
+ appId: resolveTriggerAppId(trigger),
2059
+ ...trigger.connection?.id ? { connectionId: trigger.connection.id } : {},
2060
+ ...trigger.input ? { input: trigger.input } : {},
2061
+ ...trigger.inputs?.length ? { inputs: trigger.inputs } : {},
2062
+ ...trigger.name ? { name: trigger.name } : {},
2063
+ ...trigger.description ? { description: trigger.description } : {}
2064
+ };
2065
+ }
2021
2066
  function stepToUpsertInput(step) {
2022
2067
  const use = step.use;
2023
2068
  return {
@@ -2038,6 +2083,7 @@ function workflowDefinitionToUpsert(def) {
2038
2083
  name: def.name,
2039
2084
  description: def.description,
2040
2085
  isActive: def.isActive,
2086
+ ...def.trigger ? { trigger: triggerToUpsertInput(def.trigger) } : {},
2041
2087
  managedByCode: true,
2042
2088
  steps: def.steps.map(stepToUpsertInput)
2043
2089
  };