@flowrunner/cli 0.1.3 → 0.1.5-dev.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/ai-docs/instructions/service-code-format/02-zod-types.md +20 -14
- package/ai-docs/instructions/service-code-format/08-polling-triggers.md +2 -2
- package/dist/cli.js +49 -31
- package/dist/cli.js.map +3 -3
- package/dist/index.js +14 -7
- package/dist/index.js.map +2 -2
- package/dist/types/shared/src/constants/docs.d.ts +4 -0
- package/dist/types/shared/src/constants/error-codes.d.ts +1 -0
- package/dist/types/shared/src/constants/index.d.ts +1 -0
- package/dist/types/shared/src/constants/knowledge-base.d.ts +1 -0
- package/dist/types/shared/src/constants/notification-types.d.ts +95 -22
- package/dist/types/shared/src/constants/shared-extensions.d.ts +9 -0
- package/dist/types/shared/src/errors/k8s.d.ts +10 -0
- package/dist/types/shared/src/scheme/crm/dto.d.ts +2 -2
- package/dist/types/shared/src/scheme/flowrunner/custom-elements.d.ts +20 -29
- package/dist/types/shared/src/scheme/integration-connection/dto.d.ts +2 -2
- package/dist/types/shared/src/scheme/knowledge-base/dto.d.ts +80 -0
- package/dist/types/shared/src/scheme/notifications/dto.d.ts +3 -0
- package/dist/types/shared/src/scheme/notifications/rest.d.ts +6 -0
- package/dist/types/shared/src/scheme/shared-extensions/config.d.ts +20 -20
- package/dist/types/shared/src/scheme/shared-extensions/custom-extensions.d.ts +30 -36
- package/dist/types/shared/src/scheme/shared-extensions/extension.d.ts +40 -40
- package/dist/types/shared/src/scheme/shared-extensions/index.d.ts +1 -0
- package/dist/types/shared/src/scheme/shared-extensions/resolve.d.ts +15 -24
- package/dist/types/shared/src/scheme/shared-extensions/search.d.ts +10 -10
- package/dist/types/shared/src/scheme/shared-extensions/workspace-stack.d.ts +44 -0
- package/dist/types/shared/src/scheme/workspace/dto.d.ts +1 -1
- package/package.json +4 -1
- package/runtime/index.js +14 -7
- package/runtime/index.js.map +2 -2
- package/runtime/types/shared/src/constants/docs.d.ts +4 -0
- package/runtime/types/shared/src/constants/error-codes.d.ts +1 -0
- package/runtime/types/shared/src/constants/index.d.ts +1 -0
- package/runtime/types/shared/src/constants/knowledge-base.d.ts +1 -0
- package/runtime/types/shared/src/constants/notification-types.d.ts +95 -22
- package/runtime/types/shared/src/constants/shared-extensions.d.ts +9 -0
- package/runtime/types/shared/src/errors/k8s.d.ts +10 -0
- package/runtime/types/shared/src/scheme/flowrunner/custom-elements.d.ts +20 -29
- package/runtime/types/shared/src/scheme/integration-connection/dto.d.ts +2 -2
- package/runtime/types/shared/src/scheme/knowledge-base/dto.d.ts +80 -0
- package/runtime/types/shared/src/scheme/notifications/dto.d.ts +3 -0
- package/runtime/types/shared/src/scheme/notifications/rest.d.ts +6 -0
- package/runtime/types/shared/src/scheme/shared-extensions/config.d.ts +20 -20
- package/runtime/types/shared/src/scheme/shared-extensions/custom-extensions.d.ts +30 -36
- package/runtime/types/shared/src/scheme/shared-extensions/extension.d.ts +40 -40
- package/runtime/types/shared/src/scheme/shared-extensions/index.d.ts +1 -0
- package/runtime/types/shared/src/scheme/shared-extensions/resolve.d.ts +15 -24
- package/runtime/types/shared/src/scheme/shared-extensions/search.d.ts +10 -10
- package/runtime/types/shared/src/scheme/shared-extensions/workspace-stack.d.ts +44 -0
|
@@ -21,8 +21,10 @@ and behaviors.
|
|
|
21
21
|
|
|
22
22
|
Notes:
|
|
23
23
|
|
|
24
|
-
- **The Widget column
|
|
25
|
-
|
|
24
|
+
- **The Widget column applies to config fields too** — the configuration form is drawn from the same
|
|
25
|
+
declaration, so `z.number()` gets a numeric input there as it does for a param. What is smaller for a
|
|
26
|
+
config field is the `type` it **publishes**: a closed set in which `z.number()` lands on `string`. That is
|
|
27
|
+
what a test asserts, not what the form renders. See
|
|
26
28
|
[Config fields publish a smaller set of types](#config-fields-publish-a-smaller-set-of-types).
|
|
27
29
|
- **Required is the default** — mark optional fields with `.optional()`.
|
|
28
30
|
- `.shared()` marks a config field as a **shared** (global) config value rather than per-app — used for
|
|
@@ -174,25 +176,29 @@ See [16-gotchas.md](16-gotchas.md) for the rest of that trap.
|
|
|
174
176
|
|
|
175
177
|
## Config fields publish a smaller set of types
|
|
176
178
|
|
|
177
|
-
A `configItems` field is drawn from its declaration
|
|
178
|
-
`z.enum([...])` a dropdown, `z.text()` a textarea
|
|
179
|
-
|
|
179
|
+
A `configItems` field is **drawn from its declaration**, exactly as a param is — `z.boolean()` is a
|
|
180
|
+
toggle, `z.enum([...])` a dropdown, `z.text()` a textarea, `z.number()` a numeric input. But alongside the
|
|
181
|
+
declaration the platform also publishes a flat, **smaller, closed vocabulary** of config `type` strings, and
|
|
182
|
+
anything outside it lands on `string`:
|
|
180
183
|
|
|
181
|
-
| Declared in `configItems` | Published `type` | Control |
|
|
184
|
+
| Declared in `configItems` | Published `type` | Control in the configuration form |
|
|
182
185
|
|---|---|---|
|
|
183
186
|
| `z.string()` | `string` | single-line text |
|
|
184
187
|
| `z.text()` | `text` | textarea |
|
|
185
188
|
| `z.boolean()` | `bool` | checkbox |
|
|
186
189
|
| `z.enum([...])` | `choice` | dropdown |
|
|
187
190
|
| `z.date()` | `date` | date picker |
|
|
188
|
-
| **`z.number()`** | **`string`** | **
|
|
189
|
-
|
|
190
|
-
`z.number()` is the one that surprises
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
| **`z.number()`** | **`string`** | **numeric input — there is no numeric config `type`, but the form reads the declaration** |
|
|
192
|
+
|
|
193
|
+
`z.number()` is the one that surprises, and it surprises in one place only: **`getServiceConfigItems()`
|
|
194
|
+
reports `type: "string"` for it**, because that vocabulary has no number in it. A test asserting the
|
|
195
|
+
published config items must expect `"string"`.
|
|
196
|
+
|
|
197
|
+
That published string is **not** what the user sees. The configuration form renders from the declared
|
|
198
|
+
schema, so a `z.number()` config field is a real numeric input, and **your handler still receives a
|
|
199
|
+
number** — the declared type is what the value is converted to before validation (see below). Declare
|
|
200
|
+
`z.number()` when the value is a number: it is what gives you the control, the conversion and the
|
|
201
|
+
validation, and nothing needs converting by hand.
|
|
196
202
|
|
|
197
203
|
The two other differences are structural:
|
|
198
204
|
|
|
@@ -21,7 +21,7 @@ Declare **exactly one** mechanism.
|
|
|
21
21
|
|
|
22
22
|
| Mechanism | Config | Runtime behavior |
|
|
23
23
|
|---|---|---|
|
|
24
|
-
| `dedupe` (seen-set) | `item => id` (or field path); or `{ by, stateKey='seen', max=500 }` | Keeps
|
|
24
|
+
| `dedupe` (seen-set) | `item => id` (or field path); or `{ by, stateKey='seen', max=500 }` | Keeps the last `max` ids it has seen under `stateKey`, oldest first, and forgets the oldest when full (an id still in the feed counts as just seen); emits items whose id is new. Covers new-by-id + stateless-newest (head-only `fetch`). |
|
|
25
25
|
| `watermark` (marker) | `{ by, stateKey='watermark', sortedDesc? }` — `by` = field path or `(item,{params})=>value` | Stores newest marker, emits items past it, advances. `sortedDesc:true` stops at the first non-newer item — **only for a strictly newest-first feed**, see below. Covers new-by-date + new-or-updated. |
|
|
26
26
|
| `poll` (escape hatch) | fn (above) | Full control; author owns `state` shape. Covers overlap-window+dedup, lag-held cursor, consuming/offset feeds. |
|
|
27
27
|
|
|
@@ -29,7 +29,7 @@ Declare **exactly one** mechanism.
|
|
|
29
29
|
|
|
30
30
|
| Phase | `dedupe` | `watermark` | `poll` |
|
|
31
31
|
|---|---|---|---|
|
|
32
|
-
| start (no state) | `null → { seen:
|
|
32
|
+
| start (no state) | `null → { seen:[…] }` \| `[]` (seed) | `null → { <marker> }` \| `[]` (seed) | `null → seeded` \| `[]` (seed yourself) |
|
|
33
33
|
| learningMode | `null → null` \| everything `fetch` returned | `null → null` \| everything `fetch` returned | **no handling** — whatever you return |
|
|
34
34
|
| timer | `{seen} → {seen+new}` \| `[new]` | `{marker} → {advanced}` \| `[past marker]` | yours → yours \| your delta |
|
|
35
35
|
|
package/dist/cli.js
CHANGED
|
@@ -4185,10 +4185,13 @@ var require_package = __commonJS({
|
|
|
4185
4185
|
"package.json"(exports2, module2) {
|
|
4186
4186
|
module2.exports = {
|
|
4187
4187
|
name: "@flowrunner/cli",
|
|
4188
|
+
version: "0.1.5-dev.1",
|
|
4188
4189
|
publishConfig: {
|
|
4189
4190
|
access: "public"
|
|
4190
4191
|
},
|
|
4191
|
-
|
|
4192
|
+
engines: {
|
|
4193
|
+
node: ">=20"
|
|
4194
|
+
},
|
|
4192
4195
|
description: "Flowrunner CLI for deploying Custom Extensions",
|
|
4193
4196
|
bin: {
|
|
4194
4197
|
flowrunner: "./bin/flowrunner.js"
|
|
@@ -4669,7 +4672,7 @@ function stripConditionals(source, answers, origin) {
|
|
|
4669
4672
|
throw new Error(`Unknown flag "${name}" in {{#if}} at ${origin}:${index + 1}`);
|
|
4670
4673
|
}
|
|
4671
4674
|
const matches = expected === void 0 ? Boolean(answers[name]) : String(answers[name]) === expected;
|
|
4672
|
-
stack.push({ name, keep: matches && stack.every((
|
|
4675
|
+
stack.push({ name, keep: matches && stack.every((frame) => frame.keep) });
|
|
4673
4676
|
continue;
|
|
4674
4677
|
}
|
|
4675
4678
|
if (IF_CLOSE.test(line)) {
|
|
@@ -4678,7 +4681,7 @@ function stripConditionals(source, answers, origin) {
|
|
|
4678
4681
|
}
|
|
4679
4682
|
continue;
|
|
4680
4683
|
}
|
|
4681
|
-
if (stack.every((
|
|
4684
|
+
if (stack.every((frame) => frame.keep)) {
|
|
4682
4685
|
output.push(line);
|
|
4683
4686
|
}
|
|
4684
4687
|
}
|
|
@@ -7762,17 +7765,24 @@ var DedupeMechanism = class extends FetchingMechanism {
|
|
|
7762
7765
|
delta(items, state) {
|
|
7763
7766
|
const currentIds = items.map(this.#by).map((id) => `${id}`);
|
|
7764
7767
|
if (!state?.[this.#stateKey]) {
|
|
7765
|
-
return { events: [], state: { [this.#stateKey]: this.#buildSeen(currentIds) } };
|
|
7768
|
+
return { events: [], state: { [this.#stateKey]: this.#buildSeen([], currentIds) } };
|
|
7766
7769
|
}
|
|
7767
|
-
const seen = state[this.#stateKey];
|
|
7768
|
-
const
|
|
7769
|
-
|
|
7770
|
+
const seen = toSeenList(state[this.#stateKey]);
|
|
7771
|
+
const seenSet = new Set(seen);
|
|
7772
|
+
const events = items.filter((_item, index) => !seenSet.has(currentIds[index]));
|
|
7773
|
+
return { events, state: { [this.#stateKey]: this.#buildSeen(seen, currentIds) } };
|
|
7770
7774
|
}
|
|
7771
|
-
// Bounded id
|
|
7772
|
-
|
|
7773
|
-
|
|
7775
|
+
// Bounded id list, oldest first, keeping the most-recent `max` ids. An id fetched again moves to the end,
|
|
7776
|
+
// so an item that is still in the feed is never the one evicted. It is a list, not an `{ id: 1 }` map: a
|
|
7777
|
+
// map orders integer-like keys numerically, which evicted the SMALLEST id instead of the oldest one.
|
|
7778
|
+
#buildSeen(seen, currentIds) {
|
|
7779
|
+
const fetched = new Set(currentIds);
|
|
7780
|
+
return [...seen.filter((id) => !fetched.has(id)), ...fetched].slice(-this.#max);
|
|
7774
7781
|
}
|
|
7775
7782
|
};
|
|
7783
|
+
var toSeenList = (value) => {
|
|
7784
|
+
return Array.isArray(value) ? value.map((id) => `${id}`) : Object.keys(value);
|
|
7785
|
+
};
|
|
7776
7786
|
var isNewer = (value, marker) => value > marker;
|
|
7777
7787
|
var WatermarkMechanism = class extends FetchingMechanism {
|
|
7778
7788
|
constructor(fetch2, config) {
|
|
@@ -9923,6 +9933,7 @@ async function interactiveLogin(gap) {
|
|
|
9923
9933
|
|
|
9924
9934
|
// src/cli/prompts/select-list.ts
|
|
9925
9935
|
var import_node_readline = __toESM(require("node:readline"));
|
|
9936
|
+
var import_node_util = require("node:util");
|
|
9926
9937
|
function canRenderList() {
|
|
9927
9938
|
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
9928
9939
|
}
|
|
@@ -9963,46 +9974,52 @@ var SHOW_CURSOR = "\x1B[?25h";
|
|
|
9963
9974
|
function styling() {
|
|
9964
9975
|
return process.env.NO_COLOR ? { dim: "", bold: "", reset: "" } : { dim: "\x1B[2m", bold: "\x1B[1m", reset: "\x1B[0m" };
|
|
9965
9976
|
}
|
|
9966
|
-
function
|
|
9967
|
-
|
|
9968
|
-
return plainLength <= width ? line : `${line.slice(0, line.length - (plainLength - width) - 1)}\u2026`;
|
|
9977
|
+
function terminalColumns() {
|
|
9978
|
+
return process.stdout.columns || 80;
|
|
9969
9979
|
}
|
|
9970
|
-
function
|
|
9980
|
+
function renderFrame(choices, selected, columns) {
|
|
9971
9981
|
const { dim, bold, reset } = styling();
|
|
9972
|
-
const
|
|
9982
|
+
const rows = [];
|
|
9973
9983
|
for (const [index, choice] of choices.entries()) {
|
|
9974
9984
|
const active = index === selected;
|
|
9975
|
-
|
|
9976
|
-
const label = active ? `${bold}${choice.label}${reset}` : choice.label;
|
|
9977
|
-
lines.push(fit(`${pointer} ${label}`, `${pointer} ${choice.label}`.length));
|
|
9985
|
+
rows.push({ prefix: active ? "\u276F " : " ", text: choice.label, style: active ? bold : "" });
|
|
9978
9986
|
if (choice.description) {
|
|
9979
|
-
|
|
9987
|
+
rows.push({ prefix: " ", text: choice.description, style: dim });
|
|
9980
9988
|
}
|
|
9981
9989
|
}
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9990
|
+
rows.push({ prefix: "", text: "", style: "" });
|
|
9991
|
+
rows.push({ prefix: " ", text: "\u2191/\u2193 to move \xB7 enter to select \xB7 esc to cancel", style: dim });
|
|
9992
|
+
const width = columns - 1;
|
|
9993
|
+
return rows.map(({ prefix, text: text2, style }) => {
|
|
9994
|
+
const room = width - prefix.length;
|
|
9995
|
+
const fitted = text2.length <= room ? text2 : `${text2.slice(0, Math.max(room - 1, 0))}\u2026`;
|
|
9996
|
+
return style && fitted ? `${prefix}${style}${fitted}${reset}` : `${prefix}${fitted}`;
|
|
9997
|
+
});
|
|
9998
|
+
}
|
|
9999
|
+
function rowsOccupied(lines, columns) {
|
|
10000
|
+
return lines.reduce((total, line) => {
|
|
10001
|
+
const visible = (0, import_node_util.stripVTControlCharacters)(line).length;
|
|
10002
|
+
return total + Math.max(1, Math.ceil(visible / columns));
|
|
10003
|
+
}, 0);
|
|
9988
10004
|
}
|
|
9989
10005
|
function selectFromList(title, choices, startAt = 0) {
|
|
9990
10006
|
const { stdin, stdout } = process;
|
|
9991
10007
|
return new Promise((resolve, reject) => {
|
|
9992
10008
|
let selected = Math.min(Math.max(startAt, 0), choices.length - 1);
|
|
9993
|
-
let painted =
|
|
10009
|
+
let painted = [];
|
|
9994
10010
|
const draw = () => {
|
|
9995
|
-
|
|
9996
|
-
|
|
10011
|
+
const columns = terminalColumns();
|
|
10012
|
+
if (painted.length > 0) {
|
|
10013
|
+
import_node_readline.default.moveCursor(stdout, 0, -rowsOccupied(painted, columns));
|
|
9997
10014
|
import_node_readline.default.clearScreenDown(stdout);
|
|
9998
10015
|
}
|
|
9999
|
-
|
|
10000
|
-
stdout.write(`${
|
|
10016
|
+
painted = renderFrame(choices, selected, columns);
|
|
10017
|
+
stdout.write(`${painted.join("\n")}
|
|
10001
10018
|
`);
|
|
10002
|
-
painted = lines.length;
|
|
10003
10019
|
};
|
|
10004
10020
|
const cleanup = () => {
|
|
10005
10021
|
stdin.off("keypress", onKeypress);
|
|
10022
|
+
stdout.off("resize", draw);
|
|
10006
10023
|
if (stdin.isTTY) {
|
|
10007
10024
|
stdin.setRawMode(false);
|
|
10008
10025
|
}
|
|
@@ -10034,6 +10051,7 @@ ${title}
|
|
|
10034
10051
|
stdin.setRawMode(true);
|
|
10035
10052
|
stdin.resume();
|
|
10036
10053
|
stdin.on("keypress", onKeypress);
|
|
10054
|
+
stdout.on("resize", draw);
|
|
10037
10055
|
draw();
|
|
10038
10056
|
});
|
|
10039
10057
|
}
|