@alexkroman1/aai-ui 6.4.0 → 6.5.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/index.js CHANGED
@@ -1068,7 +1068,7 @@ function useWorkflows(opts = {}) {
1068
1068
  * so this is invisible to every form that has none — including one whose values
1069
1069
  * are not an object at all, which `submit` accepts.
1070
1070
  */
1071
- async function uploadFiles(api, input, report) {
1071
+ async function uploadFiles(api, input, report, parallel) {
1072
1072
  if (!isRecord(input)) return input;
1073
1073
  const entries = Object.entries(input);
1074
1074
  const count = entries.reduce((total, [, value]) => total + filesOf(value).length, 0);
@@ -1080,10 +1080,13 @@ async function uploadFiles(api, input, report) {
1080
1080
  index,
1081
1081
  count
1082
1082
  };
1083
- return (await api.upload(file, { onProgress: (progress) => report({
1084
- ...position,
1085
- ...progress
1086
- }) })).id;
1083
+ return (await api.upload(file, {
1084
+ onProgress: (progress) => report({
1085
+ ...position,
1086
+ ...progress
1087
+ }),
1088
+ ...omitUndefined({ parallel })
1089
+ })).id;
1087
1090
  };
1088
1091
  const out = {};
1089
1092
  for (const [name, value] of entries) {
@@ -1128,7 +1131,7 @@ async function uploadFiles(api, input, report) {
1128
1131
  * @public
1129
1132
  */
1130
1133
  function useWorkflowSubmit(workflow, opts = {}) {
1131
- const { api, key, wait, intervalMs } = opts;
1134
+ const { api, key, wait, intervalMs, parallel } = opts;
1132
1135
  const [runId, setRunId] = useState(void 0);
1133
1136
  const [starting, setStarting] = useState(false);
1134
1137
  const [startError, setStartError] = useState(void 0);
@@ -1146,7 +1149,7 @@ function useWorkflowSubmit(workflow, opts = {}) {
1146
1149
  setRunId(void 0);
1147
1150
  try {
1148
1151
  const options = omitUndefined({ key });
1149
- const started = await uploadFiles(client, input, setUpload);
1152
+ const started = await uploadFiles(client, input, setUpload, parallel);
1150
1153
  setRunId(wait === void 0 ? await client.start(workflow, started, options) : (await client.startAndWait(workflow, started, {
1151
1154
  ...options,
1152
1155
  wait
@@ -1161,6 +1164,7 @@ function useWorkflowSubmit(workflow, opts = {}) {
1161
1164
  workflow,
1162
1165
  key,
1163
1166
  wait,
1167
+ parallel,
1164
1168
  getClient
1165
1169
  ]),
1166
1170
  reset: useCallback(() => {
@@ -1859,7 +1863,7 @@ function useWorkflowRuns(workflow, opts = {}) {
1859
1863
  * @public
1860
1864
  */
1861
1865
  function useWorkflowStream(workflow, opts = {}) {
1862
- const { api, key, intervalMs } = opts;
1866
+ const { api, key, intervalMs, parallel } = opts;
1863
1867
  const [runId, setRunId] = useState(void 0);
1864
1868
  const [starting, setStarting] = useState(false);
1865
1869
  const [startError, setStartError] = useState(void 0);
@@ -1894,7 +1898,8 @@ function useWorkflowStream(workflow, opts = {}) {
1894
1898
  name: chosen.name,
1895
1899
  index: 1,
1896
1900
  count: 1
1897
- })
1901
+ }),
1902
+ ...omitUndefined({ parallel })
1898
1903
  });
1899
1904
  await client.wake(started).catch(() => void 0);
1900
1905
  } catch (err) {
@@ -1907,6 +1912,7 @@ function useWorkflowStream(workflow, opts = {}) {
1907
1912
  }, [
1908
1913
  workflow,
1909
1914
  key,
1915
+ parallel,
1910
1916
  getClient
1911
1917
  ]),
1912
1918
  reset: useCallback(() => {
@@ -33,7 +33,7 @@
33
33
  * followed from the same id either way.
34
34
  */
35
35
  import { type WorkflowSummary } from "@alexkroman1/aai";
36
- import type { UploadProgress } from "@alexkroman1/aai/workflow-api";
36
+ import type { UploadParallel, UploadProgress } from "@alexkroman1/aai/workflow-api";
37
37
  import type { WorkflowApi, WorkflowRun } from "./workflow-client.ts";
38
38
  /** Options for {@link useWorkflows}. */
39
39
  export type UseWorkflowsOptions = {
@@ -138,6 +138,18 @@ export type UseWorkflowSubmitOptions = {
138
138
  wait?: number;
139
139
  /** How often the fallback poll re-reads a live run. */
140
140
  intervalMs?: number;
141
+ /**
142
+ * Send each chosen file as concurrent parts instead of in one request.
143
+ *
144
+ * `true` for the defaults, or `{ partBytes, concurrency }` to tune them. This is
145
+ * the wait a form with a recording in it actually spends: the run does not exist
146
+ * until its input is stored, so until the last byte lands there is no run to
147
+ * watch and nothing for `<WorkflowProgress>` to say. Splitting the file across
148
+ * connections is what makes that stretch shorter, and it degrades to the single
149
+ * request wherever it would not help — a small file, an older agent — so turning
150
+ * it on is safe for every form. See `UploadOptions.parallel`.
151
+ */
152
+ parallel?: UploadParallel;
141
153
  };
142
154
  /**
143
155
  * Start a workflow from a form, and follow the run it creates.
@@ -57,6 +57,7 @@
57
57
  * thrown away with the run; a caller who wants to resume instead drives
58
58
  * `api.uploadStream` and `api.uploadInfo` directly.
59
59
  */
60
+ import type { UploadParallel } from "@alexkroman1/aai/workflow-api";
60
61
  import type { UploadStatus } from "./use-workflow-form.ts";
61
62
  import type { WorkflowApi, WorkflowRun } from "./workflow-client.ts";
62
63
  /** Options for {@link useWorkflowStream}. */
@@ -67,6 +68,19 @@ export type UseWorkflowStreamOptions = {
67
68
  key?: string;
68
69
  /** How often the fallback poll re-reads a live run. */
69
70
  intervalMs?: number;
71
+ /**
72
+ * Send the file as concurrent parts instead of in one streaming request.
73
+ *
74
+ * It COMPOSES with what this hook is for rather than competing with it: the run
75
+ * still starts before the bytes, and the store still publishes how far the file
76
+ * is readable — that number is the CONTIGUOUS prefix, so a run reading ahead of
77
+ * the uplink sees the same growing file whether one connection or four are
78
+ * filling it. What changes is only how fast it grows.
79
+ *
80
+ * `true` for the defaults, or `{ partBytes, concurrency }` to tune them. See
81
+ * `UploadOptions.parallel`.
82
+ */
83
+ parallel?: UploadParallel;
70
84
  };
71
85
  /** What {@link useWorkflowStream} returns. */
72
86
  export type WorkflowStreamSubmission<R = unknown> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexkroman1/aai-ui",
3
- "version": "6.4.0",
3
+ "version": "6.5.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -29,7 +29,7 @@
29
29
  "remark-gfm": "^4.0.1",
30
30
  "use-stick-to-bottom": "^1.1.6",
31
31
  "use-sync-external-store": "^1.6.0",
32
- "@alexkroman1/aai": "6.4.0"
32
+ "@alexkroman1/aai": "6.5.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^19.0.0",