@burdenoff/microfe-planmagnet 2026.1124.1 → 2026.1126.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.
@@ -1,3 +1,22 @@
1
+ /** Rows per request. Well under the engine's cap of 100 so every request is one bounded page. */
2
+ export declare const WORKFLOW_PAGE_SIZE = 50;
3
+ /** How long the search box waits after the last keystroke before it asks the server. */
4
+ export declare const WORKFLOW_SEARCH_DEBOUNCE_MS = 300;
5
+ export interface WorkflowOption {
6
+ id: string;
7
+ name: string;
8
+ workflowKey: string;
9
+ version: string;
10
+ }
11
+ /** The variables for one page of active workflows. A blank search is no search. */
12
+ export declare function workflowPageInput(search: string, offset: number): {
13
+ search?: string | undefined;
14
+ status: string;
15
+ limit: number;
16
+ offset: number;
17
+ };
18
+ /** Appends a page to the rows already shown, dropping any row a shifted offset returns twice. */
19
+ export declare function appendWorkflowPage(shown: readonly WorkflowOption[], page: readonly WorkflowOption[]): WorkflowOption[];
1
20
  export declare function WorkflowSelect({ value, onChange, }: {
2
21
  value: string;
3
22
  onChange: (workflowDefinitionId: string) => void;
@@ -1,8 +1,9 @@
1
- import { gql as e } from "@apollo/client";
2
- import { useQuery as t } from "@apollo/client/react";
3
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
1
+ import { useEffect as e, useState as t } from "react";
2
+ import { gql as n } from "@apollo/client";
3
+ import { useApolloClient as r, useQuery as i } from "@apollo/client/react";
4
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
4
5
  // src/planmagnet/automation/WorkflowSelect.tsx
5
- var i = e`
6
+ var s = n`
6
7
  query AutomationRunnableWorkflows($input: ListWorkflowDefinitionsInput!) {
7
8
  workflowDefinitions(input: $input) {
8
9
  items {
@@ -11,63 +12,136 @@ var i = e`
11
12
  workflowKey
12
13
  version
13
14
  }
14
- total
15
15
  hasMore
16
16
  }
17
17
  }
18
- `, a = 100, o = "w-full rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60";
19
- function s({ value: e, onChange: s }) {
20
- let { data: c, loading: l, error: u } = t(i, {
21
- variables: { input: {
22
- status: "ACTIVE",
23
- limit: a,
24
- offset: 0
25
- } },
18
+ `, c = n`
19
+ query AutomationSelectedWorkflow($id: ID!) {
20
+ workflowDefinition(id: $id) {
21
+ id
22
+ name
23
+ workflowKey
24
+ version
25
+ status
26
+ }
27
+ }
28
+ `;
29
+ function l(e, t) {
30
+ let n = e.trim();
31
+ return {
32
+ status: "ACTIVE",
33
+ limit: 50,
34
+ offset: t,
35
+ ...n ? { search: n } : {}
36
+ };
37
+ }
38
+ function u(e, t) {
39
+ let n = new Set(e.map((e) => e.id));
40
+ return [...e, ...t.filter((e) => !n.has(e.id))];
41
+ }
42
+ var d = "w-full rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60", f = "w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground", p = "rounded-md border border-input bg-background px-2 py-1 text-xs hover:bg-muted disabled:opacity-60";
43
+ function m(n, r) {
44
+ let [i, a] = t(n);
45
+ return e(() => {
46
+ let e = setTimeout(() => a(n), r);
47
+ return () => clearTimeout(e);
48
+ }, [n, r]), i;
49
+ }
50
+ function h({ value: e, onChange: n }) {
51
+ let h = r(), [g, _] = t(""), v = m(g, 300).trim(), [y, b] = t(null), [x, S] = t(!1), [C, w] = t(null), { data: T, loading: E, error: D } = i(s, {
52
+ variables: { input: l(v, 0) },
26
53
  fetchPolicy: "cache-and-network"
27
- }), d = c?.workflowDefinitions.items ?? [], f = e === "" || d.some((t) => t.id === e);
28
- return /* @__PURE__ */ r("div", {
54
+ }), O = y && y.search === v ? y : null, k = T?.workflowDefinitions, A = u(k?.items ?? [], O?.items ?? []), j = O ? O.hasMore : k?.hasMore ?? !1, M = O ? O.nextOffset : k?.items.length ?? 0, N = e === "" || A.some((t) => t.id === e), { data: P, error: F } = i(c, {
55
+ variables: { id: e },
56
+ skip: N || !T,
57
+ fetchPolicy: "cache-first"
58
+ }), I = N ? null : P?.workflowDefinition, L = I?.status === "ACTIVE", R = !N && (!!F || P !== void 0 && !L);
59
+ async function z() {
60
+ S(!0), w(null);
61
+ try {
62
+ let e = (await h.query({
63
+ query: s,
64
+ variables: { input: l(v, M) },
65
+ fetchPolicy: "network-only"
66
+ })).data?.workflowDefinitions;
67
+ if (!e) throw Error("The next page of workflows was empty.");
68
+ b({
69
+ search: v,
70
+ items: u(O?.items ?? [], e.items),
71
+ hasMore: e.hasMore,
72
+ nextOffset: M + e.items.length
73
+ });
74
+ } catch (e) {
75
+ w(e instanceof Error ? e.message : String(e));
76
+ } finally {
77
+ S(!1);
78
+ }
79
+ }
80
+ let B = E && !T ? "Loading workflows…" : D ? "Workflows could not be loaded" : A.length === 0 ? v ? "No active workflows match this search" : "No active workflows yet" : "Choose a workflow";
81
+ return /* @__PURE__ */ o("div", {
29
82
  className: "space-y-1",
30
- children: [/* @__PURE__ */ r("select", {
31
- "aria-label": "Workflow",
32
- "data-testid": "automation-workflow-select",
33
- className: o,
34
- value: e,
35
- onChange: (e) => s(e.target.value),
36
- children: [
37
- /* @__PURE__ */ n("option", {
38
- value: "",
39
- children: l && !c ? "Loading workflows…" : u ? "Workflows could not be loaded" : d.length === 0 ? "No active workflows yet" : "Choose a workflow"
40
- }),
41
- !f && c && /* @__PURE__ */ n("option", {
42
- value: e,
43
- children: "Unavailable workflow (no longer active)"
44
- }),
45
- d.map((e) => /* @__PURE__ */ n("option", {
46
- value: e.id,
47
- children: `${e.name} (v${e.version})`
48
- }, e.id)),
49
- c?.workflowDefinitions.hasMore && /* @__PURE__ */ n("option", {
50
- value: "",
51
- disabled: !0,
52
- children: `Only the first ${a} active workflows are listed`
53
- })
54
- ]
55
- }), u ? /* @__PURE__ */ r("p", {
56
- role: "alert",
57
- className: "text-xs text-destructive",
58
- children: ["The workflow list could not be loaded: ", u.message]
59
- }) : /* @__PURE__ */ r("p", {
60
- className: "text-xs text-muted-foreground",
61
- children: [
62
- "Starts a run of this workflow with the PlanMagnet event as its trigger data. The workflow needs a \"Trigger manually\" or \"When called by another workflow\" start node.",
63
- " ",
64
- /* @__PURE__ */ n("a", {
65
- href: "/workflows",
66
- className: "text-primary underline underline-offset-2",
67
- children: "Build and activate workflows"
68
- })
69
- ]
70
- })]
83
+ children: [
84
+ /* @__PURE__ */ a("input", {
85
+ type: "search",
86
+ "aria-label": "Search workflows",
87
+ "data-testid": "automation-workflow-search",
88
+ className: f,
89
+ placeholder: "Search active workflows by name",
90
+ value: g,
91
+ onChange: (e) => _(e.target.value)
92
+ }),
93
+ /* @__PURE__ */ o("select", {
94
+ "aria-label": "Workflow",
95
+ "data-testid": "automation-workflow-select",
96
+ className: d,
97
+ value: e,
98
+ onChange: (e) => n(e.target.value),
99
+ children: [
100
+ /* @__PURE__ */ a("option", {
101
+ value: "",
102
+ children: B
103
+ }),
104
+ !N && /* @__PURE__ */ a("option", {
105
+ value: e,
106
+ children: I && L ? `${I.name} (v${I.version})` : R ? "Unavailable workflow (no longer active)" : "Saved workflow"
107
+ }),
108
+ A.map((e) => /* @__PURE__ */ a("option", {
109
+ value: e.id,
110
+ children: `${e.name} (v${e.version})`
111
+ }, e.id))
112
+ ]
113
+ }),
114
+ j && /* @__PURE__ */ o("div", {
115
+ className: "flex items-center gap-2",
116
+ children: [/* @__PURE__ */ a("button", {
117
+ type: "button",
118
+ "data-testid": "automation-workflow-load-more",
119
+ className: p,
120
+ disabled: x,
121
+ onClick: () => void z(),
122
+ children: x ? "Loading…" : "Load more workflows"
123
+ }), /* @__PURE__ */ a("span", {
124
+ className: "text-xs text-muted-foreground",
125
+ children: `${A.length} shown. Search to find a workflow faster.`
126
+ })]
127
+ }),
128
+ D || C ? /* @__PURE__ */ o("p", {
129
+ role: "alert",
130
+ className: "text-xs text-destructive",
131
+ children: ["The workflow list could not be loaded: ", D?.message ?? C]
132
+ }) : /* @__PURE__ */ o("p", {
133
+ className: "text-xs text-muted-foreground",
134
+ children: [
135
+ "Starts a run of this workflow with the PlanMagnet event as its trigger data. The workflow needs a \"Trigger manually\" or \"When called by another workflow\" start node.",
136
+ " ",
137
+ /* @__PURE__ */ a("a", {
138
+ href: "/workflows",
139
+ className: "text-primary underline underline-offset-2",
140
+ children: "Build and activate workflows"
141
+ })
142
+ ]
143
+ })
144
+ ]
71
145
  });
72
146
  }
73
- export { s as WorkflowSelect };
147
+ export { h as WorkflowSelect, u as appendWorkflowPage, l as workflowPageInput };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-planmagnet",
3
- "version": "2026.1124.1",
3
+ "version": "2026.1126.1",
4
4
  "description": "Burdenoff PlanMagnet Microfrontend",
5
5
  "type": "module",
6
6
  "files": [