@xeplr/actions 1.4.4 → 1.4.5
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/README.md +3 -1
- package/lib/builtins/data-operation.js +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -191,7 +191,7 @@ await runAction({ name: 'data-operation', input: {
|
|
|
191
191
|
sort: '-late',
|
|
192
192
|
format: true, title: 'Overdue'
|
|
193
193
|
} })
|
|
194
|
-
// → { rows, count, html, text }
|
|
194
|
+
// → { rows, count, columns, html, text }
|
|
195
195
|
```
|
|
196
196
|
|
|
197
197
|
**Rows and a rendering, both.** `rows` and `count` are always there; `html`
|
|
@@ -199,6 +199,8 @@ and `text` only when `format` is on, because building a table for ten
|
|
|
199
199
|
thousand rows nobody renders is work done and stored on every run. Neither is
|
|
200
200
|
privileged — the next step binds whichever it wants.
|
|
201
201
|
|
|
202
|
+
**`columns` says the order and the headings** (`[{ key, header }]`, the visible ones), in `export-table`'s column shape, so a workflow writes `document: { columns: "{steps.overdue.output.columns}" }`. Why: a step's output is stored as JSONB, which reorders a row's keys (shortest first), so the next step cannot read the column order off a row. A file exported without it came out as `late, amount, invoice, customer`.
|
|
203
|
+
|
|
202
204
|
**`count` is the point of the step as often as `rows` is**: it is what lets
|
|
203
205
|
the step after it branch on *nothing to report* instead of sending an empty
|
|
204
206
|
email.
|
|
@@ -106,7 +106,9 @@ module.exports = {
|
|
|
106
106
|
{ name: 'rows', type: 'array', description: 'What is left, with the columns asked for.' },
|
|
107
107
|
{ name: 'count', type: 'number', description: 'How many rows — so the next step can branch on none.' },
|
|
108
108
|
{ name: 'html', type: 'string', description: 'A table of the visible columns. Only when `format` is on.' },
|
|
109
|
-
{ name: 'text', type: 'string', description: 'The same, as plain text, for a mail client that refuses HTML.' }
|
|
109
|
+
{ name: 'text', type: 'string', description: 'The same, as plain text, for a mail client that refuses HTML.' },
|
|
110
|
+
{ name: 'columns', type: 'array', description: 'The visible columns, in order: [{ key, header }]. Give it to export-table ' +
|
|
111
|
+
'as document.columns: a step\'s stored output does not keep its fields in order.' }
|
|
110
112
|
],
|
|
111
113
|
|
|
112
114
|
// The same call every action gets from runAction: { input, system }. It
|
|
@@ -183,7 +185,15 @@ module.exports = {
|
|
|
183
185
|
});
|
|
184
186
|
}
|
|
185
187
|
|
|
186
|
-
|
|
188
|
+
// THE ORDER AND THE HEADINGS, said out loud. A step's output is stored
|
|
189
|
+
// as JSONB, which reorders an object's keys (shortest first), so the next
|
|
190
|
+
// step cannot read the column order off a row. This is export-table's
|
|
191
|
+
// column shape, so it is handed over as it is.
|
|
192
|
+
var result = {
|
|
193
|
+
rows: rows,
|
|
194
|
+
count: rows.length,
|
|
195
|
+
columns: computed.filter(function(c) { return !c.hidden; }).map(function(c) { return { key: c.name, header: c.label }; })
|
|
196
|
+
};
|
|
187
197
|
|
|
188
198
|
if (input.format) {
|
|
189
199
|
// THE VISIBLE COLUMNS ONLY. A column kept for the next step but not
|
package/package.json
CHANGED