|
| 1 | +<script type="text/html" data-template-name="seqera-workflow-poll"> |
| 2 | + <!-- Seqera config and node name --> |
| 3 | + <div class="form-row"> |
| 4 | + <label for="node-input-seqera"><i class="icon-globe"></i> Seqera config</label> |
| 5 | + <input type="text" id="node-input-seqera" data-type="seqera-config" /> |
| 6 | + </div> |
| 7 | + <div class="form-row"> |
| 8 | + <label for="node-input-name"><i class="fa fa-tag"></i> Node Name</label> |
| 9 | + <input type="text" id="node-input-name" /> |
| 10 | + </div> |
| 11 | + |
| 12 | + <!-- Polling specific --> |
| 13 | + <div class="form-row"> |
| 14 | + <label for="node-input-pollFrequency"><i class="fa fa-clock-o"></i> Poll frequency</label> |
| 15 | + <input type="text" id="node-input-pollFrequency" style="text-align:end; width:50px !important" /> |
| 16 | + <select id="node-input-pollUnits" style="width:120px !important"> |
| 17 | + <option value="seconds">Seconds</option> |
| 18 | + <option value="minutes">Minutes</option> |
| 19 | + <option value="hours">Hours</option> |
| 20 | + <option value="days">Days</option> |
| 21 | + </select> |
| 22 | + </div> |
| 23 | + |
| 24 | + <!-- Workflow filter parameters --> |
| 25 | + <div class="form-row"> |
| 26 | + <label for="node-input-search"><i class="fa fa-search"></i> Search</label> |
| 27 | + <input type="text" id="node-input-search" /> |
| 28 | + </div> |
| 29 | + <div class="form-row"> |
| 30 | + <label for="node-input-maxResults"><i class="fa fa-sort-numeric-asc"></i> Max results</label> |
| 31 | + <input type="text" id="node-input-maxResults" /> |
| 32 | + </div> |
| 33 | + <div class="form-row"> |
| 34 | + <label for="node-input-workspaceId"><i class="icon-tasks"></i> Workspace ID</label> |
| 35 | + <input type="text" id="node-input-workspaceId" /> |
| 36 | + </div> |
| 37 | +</script> |
| 38 | + |
| 39 | +<!-- prettier-ignore --> |
| 40 | +<script type="text/markdown" data-help-name="seqera-workflow-poll"> |
| 41 | +Polls Seqera Platform for workflow runs at a fixed interval and emits messages when new workflows are detected. |
| 42 | + |
| 43 | +### Inputs |
| 44 | + |
| 45 | +This node has no inputs – it starts polling automatically when the flow is deployed. |
| 46 | + |
| 47 | +: pollFrequency (number) : Poll frequency (default `1 minute`). Can be configured in seconds, minutes, hours, or days. |
| 48 | +: search (string) : Optional search filter for workflow names. Leave blank to include all workflows. |
| 49 | +: maxResults (number) : Maximum number of workflow runs to fetch per poll (default 50). |
| 50 | +: workspaceId (string) : Override the workspace ID from the config node. |
| 51 | + |
| 52 | +All input properties support msg._, flow._, global.\*, env, or JSONata expressions via the **typedInput**. |
| 53 | + |
| 54 | +### Outputs |
| 55 | + |
| 56 | +The node has two outputs that fire at different times: |
| 57 | + |
| 58 | +1. **All results** – Emitted every poll with the full list of workflows. |
| 59 | +2. **New workflows** – Emitted once per new workflow detected since the previous poll. |
| 60 | + |
| 61 | +**Output 1 (All results):** |
| 62 | + |
| 63 | +: payload.workflows (array) : Full list of workflow objects from the API. |
| 64 | +: payload.nextPoll (string) : ISO timestamp of the next scheduled poll. |
| 65 | +: workflowIds (array) : Convenience array of workflow IDs (strings). |
| 66 | + |
| 67 | +**Output 2 (New workflows - one message per workflow):** |
| 68 | + |
| 69 | +: payload.workflow (object) : Single workflow object from the API. |
| 70 | +: workflowId (string) : The workflow ID. |
| 71 | + |
| 72 | +If 3 new workflows are detected, output 2 will fire 3 separate times with 3 individual messages. |
| 73 | + |
| 74 | +### Details |
| 75 | + |
| 76 | +The node tracks seen workflow IDs in its context storage. On each poll: |
| 77 | + |
| 78 | +1. Fetch the current list of workflows from Seqera Platform |
| 79 | +2. Compare against the list from the previous poll |
| 80 | +3. For each new workflow ID, emit a separate message on output 2 |
| 81 | +4. Update the stored list for the next comparison |
| 82 | + |
| 83 | +The comparison is based on the workflow ID. The very first poll after the node is created does not emit new results (it initializes the tracking state). |
| 84 | + |
| 85 | +### Required permissions |
| 86 | + |
| 87 | +Minimum required role: **View** |
| 88 | + |
| 89 | +See the [configuration documentation](configuration.md#required-token-permissions) for a full table of required permissions for all nodes. |
| 90 | + |
| 91 | +### Example usage |
| 92 | + |
| 93 | +See the [Poll Workflows documentation](https://seqeralabs.github.io/node-red-seqera/seqera_nodes/poll_workflows/) for detailed examples. |
| 94 | + |
| 95 | +### Notes |
| 96 | + |
| 97 | +- The first poll after deployment/restart does **not** emit to the "New workflows" output |
| 98 | +- The tracking is reset on each Node-RED restart or flow redeployment |
| 99 | +- Very frequent polling (< 30 seconds) may impact API rate limits |
| 100 | +- Custom message properties are preserved in outputs (e.g., `msg._context`) |
| 101 | +</script> |
| 102 | + |
| 103 | +<script type="text/javascript"> |
| 104 | + RED.nodes.registerType("seqera-workflow-poll", { |
| 105 | + category: "seqera", |
| 106 | + color: "#A9A1C6", |
| 107 | + inputs: 0, |
| 108 | + outputs: 2, |
| 109 | + icon: "icons/pipeline.svg", |
| 110 | + align: "left", |
| 111 | + paletteLabel: "Poll wfs", |
| 112 | + label: function () { |
| 113 | + return this.name || "Poll workflows"; |
| 114 | + }, |
| 115 | + outputLabels: ["All workflows", "New workflows"], |
| 116 | + defaults: { |
| 117 | + name: { value: "" }, |
| 118 | + seqera: { value: "", type: "seqera-config" }, |
| 119 | + search: { value: "" }, |
| 120 | + searchType: { value: "str" }, |
| 121 | + maxResults: { value: "50" }, |
| 122 | + maxResultsType: { value: "num" }, |
| 123 | + workspaceId: { value: "" }, |
| 124 | + workspaceIdType: { value: "str" }, |
| 125 | + pollFrequency: { value: "1" }, |
| 126 | + pollUnits: { value: "minutes" }, |
| 127 | + }, |
| 128 | + oneditprepare: function () { |
| 129 | + function ti(id, val, type, def = "str") { |
| 130 | + const types = ["str", "msg", "flow", "global", "env", "jsonata"]; |
| 131 | + if (def === "num") types.splice(0, 1, "num"); |
| 132 | + $(id).typedInput({ default: def, types }); |
| 133 | + $(id).typedInput("value", val); |
| 134 | + $(id).typedInput("type", type); |
| 135 | + } |
| 136 | + |
| 137 | + ti("#node-input-search", this.search || "", this.searchType || "str"); |
| 138 | + ti("#node-input-maxResults", this.maxResults || "50", this.maxResultsType || "num", "num"); |
| 139 | + ti("#node-input-workspaceId", this.workspaceId || "", this.workspaceIdType || "str"); |
| 140 | + |
| 141 | + // Poll frequency – simple number input with units |
| 142 | + $("#node-input-pollFrequency").val(this.pollFrequency || "1"); |
| 143 | + $("#node-input-pollUnits").val(this.pollUnits || "minutes"); |
| 144 | + }, |
| 145 | + oneditsave: function () { |
| 146 | + function save(id, prop, propType) { |
| 147 | + this[prop] = $(id).typedInput("value"); |
| 148 | + this[propType] = $(id).typedInput("type"); |
| 149 | + } |
| 150 | + save.call(this, "#node-input-search", "search", "searchType"); |
| 151 | + save.call(this, "#node-input-maxResults", "maxResults", "maxResultsType"); |
| 152 | + save.call(this, "#node-input-workspaceId", "workspaceId", "workspaceIdType"); |
| 153 | + |
| 154 | + // Save poll frequency and units |
| 155 | + this.pollFrequency = $("#node-input-pollFrequency").val(); |
| 156 | + this.pollUnits = $("#node-input-pollUnits").val(); |
| 157 | + }, |
| 158 | + }); |
| 159 | +</script> |
0 commit comments