@powerhousedao/workflow 6.2.3-dev.82 → 6.2.3-dev.84
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/dist/browser/{BlockSelector-DHVzUGjW.js → BlockSelector-CtoMNZ9A.js} +4 -3
- package/dist/browser/BlockSelector-CtoMNZ9A.js.map +1 -0
- package/dist/browser/{connection-form-D2qAEHsl.js → connection-form-_H-tP2Vk.js} +2 -2
- package/dist/browser/{connection-form-D2qAEHsl.js.map → connection-form-_H-tP2Vk.js.map} +1 -1
- package/dist/browser/{data-tree-BOuPR-2J.js → data-tree-CjWQllC7.js} +2 -2
- package/dist/browser/{data-tree-BOuPR-2J.js.map → data-tree-CjWQllC7.js.map} +1 -1
- package/dist/browser/{editor-BD-5ClkW.js → editor-B1AzXxaF.js} +207 -33
- package/dist/browser/editor-B1AzXxaF.js.map +1 -0
- package/dist/browser/{editor--59WtNaj.js → editor-B9069RYZ.js} +9 -2535
- package/dist/browser/editor-B9069RYZ.js.map +1 -0
- package/dist/browser/{editor-0XPrGeLT.js → editor-DgdTF2up.js} +3 -3
- package/dist/browser/{editor-0XPrGeLT.js.map → editor-DgdTF2up.js.map} +1 -1
- package/dist/browser/editors/connection-editor/module.js +1 -1
- package/dist/browser/editors/workflow-editor/module.js +1 -1
- package/dist/browser/editors/workflow-studio/module.js +1 -1
- package/dist/browser/trigger-text-BgpPIXEJ.js +3040 -0
- package/dist/browser/trigger-text-BgpPIXEJ.js.map +1 -0
- package/dist/node/{BlockSelector-D2UAnFpN.mjs → BlockSelector-CbdgYJfp.mjs} +5 -4
- package/dist/node/BlockSelector-CbdgYJfp.mjs.map +1 -0
- package/dist/node/{connection-form-Btmejfyn.mjs → connection-form-DPbyrUIm.mjs} +3 -3
- package/dist/node/{connection-form-Btmejfyn.mjs.map → connection-form-DPbyrUIm.mjs.map} +1 -1
- package/dist/node/{data-tree-rZiK2Ev-.mjs → data-tree-CXa2kEuD.mjs} +2 -2
- package/dist/node/{data-tree-rZiK2Ev-.mjs.map → data-tree-CXa2kEuD.mjs.map} +1 -1
- package/dist/node/{editor-U6trS0QO.mjs → editor-BGz1Ljdk.mjs} +9 -2534
- package/dist/node/editor-BGz1Ljdk.mjs.map +1 -0
- package/dist/node/{editor-C_eWGGi8.mjs → editor-D3MlbYBN.mjs} +207 -34
- package/dist/node/editor-D3MlbYBN.mjs.map +1 -0
- package/dist/node/{editor-ChJMxbeM.mjs → editor-DzxyNgYk.mjs} +4 -4
- package/dist/node/{editor-ChJMxbeM.mjs.map → editor-DzxyNgYk.mjs.map} +1 -1
- package/dist/node/editors/connection-editor/module.mjs +1 -1
- package/dist/node/editors/runtime/index.mjs +1 -1
- package/dist/node/editors/workflow-editor/module.mjs +1 -1
- package/dist/node/editors/workflow-studio/module.mjs +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/node/pieces/ai/descriptor.json +1 -1
- package/dist/node/pieces/ai/package.json +1 -1
- package/dist/node/pieces/reactor/descriptor.json +1 -1
- package/dist/node/pieces/reactor/package.json +1 -1
- package/dist/node/{runtime-queries-CmrHBPRw.mjs → runtime-queries-CatdoDey.mjs} +155 -4
- package/dist/node/runtime-queries-CatdoDey.mjs.map +1 -0
- package/dist/node/trigger-text-yNCaB6pd.mjs +3040 -0
- package/dist/node/trigger-text-yNCaB6pd.mjs.map +1 -0
- package/dist/powerhouse.manifest.json +2 -2
- package/dist/style.css +1 -1
- package/dist/types/editors/shared/controls.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/manual-inputs.d.ts +7 -0
- package/dist/types/editors/workflow-editor/ui/manual-inputs.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/ui/manual-inputs.test.d.ts +2 -0
- package/dist/types/editors/workflow-editor/ui/manual-inputs.test.d.ts.map +1 -0
- package/dist/types/editors/workflow-studio/components/RunDialog.d.ts +7 -0
- package/dist/types/editors/workflow-studio/components/RunDialog.d.ts.map +1 -0
- package/dist/types/editors/workflow-studio/components/RunsView.d.ts +3 -1
- package/dist/types/editors/workflow-studio/components/RunsView.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/WorkflowStudio.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/run-dialog.test.d.ts +2 -0
- package/dist/types/editors/workflow-studio/components/run-dialog.test.d.ts.map +1 -0
- package/dist/types/test/graphql-server.d.ts +9 -0
- package/dist/types/test/graphql-server.d.ts.map +1 -0
- package/dist/types/test/ui/manual-inputs.spec.d.ts +2 -0
- package/dist/types/test/ui/manual-inputs.spec.d.ts.map +1 -0
- package/package.json +9 -9
- package/dist/browser/BlockSelector-DHVzUGjW.js.map +0 -1
- package/dist/browser/editor--59WtNaj.js.map +0 -1
- package/dist/browser/editor-BD-5ClkW.js.map +0 -1
- package/dist/browser/trigger-text-Co-dn9x-.js +0 -513
- package/dist/browser/trigger-text-Co-dn9x-.js.map +0 -1
- package/dist/node/BlockSelector-D2UAnFpN.mjs.map +0 -1
- package/dist/node/editor-C_eWGGi8.mjs.map +0 -1
- package/dist/node/editor-U6trS0QO.mjs.map +0 -1
- package/dist/node/runtime-queries-CmrHBPRw.mjs.map +0 -1
- package/dist/node/trigger-text-CAiRCG2X.mjs +0 -512
- package/dist/node/trigger-text-CAiRCG2X.mjs.map +0 -1
|
@@ -2,15 +2,15 @@ import { i as __toESM, r as __require, t as __commonJSMin } from "./rolldown-run
|
|
|
2
2
|
import { h as REACTOR_CONNECTOR_ID, x as actions } from "./module-BEEASith.mjs";
|
|
3
3
|
import { t as useConnectionDocumentById } from "./connection-BZxipUlb.mjs";
|
|
4
4
|
import { i as connectorIdForPiece, l as planFromAuth, s as packageFromConnectorId } from "./piece-auth-C0u0XTO8.mjs";
|
|
5
|
-
import { at as sameBlock, bt as
|
|
6
|
-
import { $ as useTestStepRunner, At as IconButton, B as useBlockForms, Bt as Icon, Dt as FieldError, E as formatDuration, Et as Button, F as toneOf, G as useDesignTime, H as useBlockResolutions, Ht as DocumentErrorBoundary, J as useDynamicPrefetch,
|
|
5
|
+
import { Ct as parseScheduleConfig, at as sameBlock, bt as knownPorts, ct as triggerBlock, et as STEP_PRESETS, f as stepOutputTreeQuery, h as blockRefKey, i as outputTreeQuery, lt as triggerFields, n as catalogQuery, ot as stepBlock, rt as isCoreBlock, st as stepFields, tt as TRIGGER_PRESETS, u as runsQuery, v as TEST_TRIGGER_KIND, vt as flowPorts, wt as scheduleConfigIssue, y as realRuns } from "./runtime-queries-CatdoDey.mjs";
|
|
6
|
+
import { $ as useTestStepRunner, At as IconButton, B as useBlockForms, Bt as Icon, Dt as FieldError, E as formatDuration, Et as Button, F as toneOf, G as useDesignTime, H as useBlockResolutions, Ht as DocumentErrorBoundary, J as useDynamicPrefetch, L as DesignTimeProvider, Mt as Select, Nt as Switch, Ot as FieldLabel, Pt as Tabs, Q as useRunById, R as useBlockForm, Rt as textAreaClass, S as TONE_TEXT, T as formatAbsolute, U as useCachedBlockForm, V as useBlockPorts, W as useConnectionList, Y as useLatestRun, a as BlockResolutionsProvider, bt as useRuntime, c as runsDifferentVersion, ct as storedSchema, d as versionBadge, et as useTestTrigger, ft as workflowReadiness, g as usePieceLogos, h as useBlockMeta, i as PickerPopover, it as isPropVisible, jt as Segmented, k as formatWhen, kt as Hint, l as updateVersion, m as pieceLogo, n as BlockSelector, nt as blockMissing, o as VersionSummary, ot as resolverInputFor, p as pieceDisplayName, pt as WorkflowRuntimeProvider, q as useDynamicLookup, r as PICKER_SIZE, s as resolutionText, st as settingFor, t as BlockLogo, tt as useWebhookEndpoint, u as useResolution, ut as undeclaredPortIssues, wt as useSearchParam, x as TONE_DOT, xt as useRuntimeActions, y as RUN_TONE, yt as useRunsQuery, z as useBlockFormLoader, zt as textInputClass } from "./BlockSelector-CbdgYJfp.mjs";
|
|
7
7
|
import { y as actions$1 } from "./module-D9Zx5Zow.mjs";
|
|
8
8
|
import { t as useSelectedWorkflowDocument } from "./workflow-DqF9VsBQ.mjs";
|
|
9
|
-
import { a as useSignInGate, f as connectionCallbacks, g as newUndoGroup, h as groupedAction, i as useReactorAccessDenial, l as reactorConnections, m as UndoRedo, n as SignInPrompt, o as missingInPublished, p as BackButton, r as usePublisher, s as runsAsText, t as ConnectionForm } from "./connection-form-
|
|
10
|
-
import { _ as
|
|
9
|
+
import { a as useSignInGate, f as connectionCallbacks, g as newUndoGroup, h as groupedAction, i as useReactorAccessDenial, l as reactorConnections, m as UndoRedo, n as SignInPrompt, o as missingInPublished, p as BackButton, r as usePublisher, s as runsAsText, t as ConnectionForm } from "./connection-form-DPbyrUIm.mjs";
|
|
10
|
+
import { A as VARIABLE_TYPE_LABEL, B as lacksDefaults, C as useExpressionField, D as EMPTY_SCOPE, E as menuPosition, F as stateFieldsFromSdl, I as STEP_PARAM, L as VARIABLES_VIEW, M as parseTypedValue, N as valueMismatch, O as buildExpressionScope, P as documentShape, R as hasDraftChanges, S as ExpressionTokenLine, T as menuHeight, V as withPropDefaults, _ as usePublish, a as AvailableSoon, b as ExpressionScopeSourceProvider, c as usePendingEcho, d as ManagedBanner, f as PublishButton, g as StatusToggle, h as ReactorDenialNote, i as DataViewer, j as convertVariableValue, k as VARIABLE_TYPES, l as StepError, m as PublishedMissingNote, n as describeSchedule, o as PropertyForm, p as PublishState, r as describeTrigger, s as useSecretRef, t as describeCron, u as DraftBanner, v as ExpressionPickerButton, w as contextMenuItems, x as ExpressionTargetProvider, y as ExpressionPickerPopup, z as uniqueStepKey } from "./trigger-text-yNCaB6pd.mjs";
|
|
11
11
|
import { addDocument, dispatchActions, useDocumentModelModules, useDocumentSafe, useFileNodesInSelectedDrive, useSelectedDriveId } from "@powerhousedao/reactor-browser";
|
|
12
12
|
import { generateId } from "document-model";
|
|
13
|
-
import React, {
|
|
13
|
+
import React, { createContext, forwardRef, memo, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
14
14
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
import { createPortal } from "react-dom";
|
|
16
16
|
import { Modal } from "@powerhousedao/design-system/connect";
|
|
@@ -30,23 +30,6 @@ const WORKFLOW_UNDO = {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
//#endregion
|
|
33
|
-
//#region editors/workflow-editor/ui/prop-defaults.ts
|
|
34
|
-
function asRecord(value) {
|
|
35
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
36
|
-
}
|
|
37
|
-
function withPropDefaults(props, config) {
|
|
38
|
-
const next = { ...asRecord(config) };
|
|
39
|
-
for (const prop of props) {
|
|
40
|
-
if (prop.type === "MARKDOWN" || prop.defaultValue === void 0) continue;
|
|
41
|
-
if (next[prop.name] === void 0) next[prop.name] = prop.defaultValue;
|
|
42
|
-
}
|
|
43
|
-
return next;
|
|
44
|
-
}
|
|
45
|
-
function lacksDefaults(props, config) {
|
|
46
|
-
const record = asRecord(config);
|
|
47
|
-
return props.some((prop) => prop.type !== "MARKDOWN" && prop.defaultValue !== void 0 && record[prop.name] === void 0);
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
33
|
//#region editors/workflow-editor/ui/add-follow-up.ts
|
|
51
34
|
function followUpConfig(form, config) {
|
|
52
35
|
return lacksDefaults(form.props, config) ? withPropDefaults(form.props, config) : null;
|
|
@@ -396,795 +379,6 @@ function findBlock(state, added) {
|
|
|
396
379
|
config: step.config
|
|
397
380
|
} : void 0;
|
|
398
381
|
}
|
|
399
|
-
//#endregion
|
|
400
|
-
//#region editors/workflow-editor/ui/document-shape.ts
|
|
401
|
-
const MAX_DEPTH$1 = 6;
|
|
402
|
-
const normalize = (name) => name.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
403
|
-
function typeName(node, kind) {
|
|
404
|
-
if (node.kind === kind.NON_NULL_TYPE) {
|
|
405
|
-
const inner = typeName(node.type, kind);
|
|
406
|
-
return {
|
|
407
|
-
name: inner.name,
|
|
408
|
-
display: `${inner.display}!`
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
if (node.kind === kind.LIST_TYPE) {
|
|
412
|
-
const inner = typeName(node.type, kind);
|
|
413
|
-
return {
|
|
414
|
-
name: inner.name,
|
|
415
|
-
display: `[${inner.display}]`
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
return {
|
|
419
|
-
name: node.name.value,
|
|
420
|
-
display: node.name.value
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
async function stateFieldsFromSdl(model) {
|
|
424
|
-
if (!model.schema) return {};
|
|
425
|
-
const { Kind, parse } = await import("./graphql-D76E1YiQ.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
426
|
-
let definitions;
|
|
427
|
-
try {
|
|
428
|
-
definitions = parse(model.schema).definitions;
|
|
429
|
-
} catch {
|
|
430
|
-
return {};
|
|
431
|
-
}
|
|
432
|
-
const types = /* @__PURE__ */ new Map();
|
|
433
|
-
for (const def of definitions) {
|
|
434
|
-
if (def.kind !== Kind.OBJECT_TYPE_DEFINITION && def.kind !== Kind.INPUT_OBJECT_TYPE_DEFINITION) continue;
|
|
435
|
-
types.set(normalize(def.name.value), (def.fields ?? []).map((field) => ({
|
|
436
|
-
name: field.name.value,
|
|
437
|
-
type: field.type
|
|
438
|
-
})));
|
|
439
|
-
}
|
|
440
|
-
const root = [`${normalize(model.name)}state`, `${normalize(model.name)}globalstate`].map((candidate) => types.get(candidate)).find((fields) => fields !== void 0);
|
|
441
|
-
const build = (fields, depth) => Object.fromEntries(fields.map((field) => {
|
|
442
|
-
const { name, display } = typeName(field.type, Kind);
|
|
443
|
-
const inner = types.get(normalize(name));
|
|
444
|
-
return [field.name, inner && inner.length > 0 && depth < MAX_DEPTH$1 ? build(inner, depth + 1) : display];
|
|
445
|
-
}));
|
|
446
|
-
return root ? build(root, 0) : {};
|
|
447
|
-
}
|
|
448
|
-
function documentShape(reference, globalState) {
|
|
449
|
-
return {
|
|
450
|
-
header: {
|
|
451
|
-
id: reference.documentId,
|
|
452
|
-
documentType: reference.documentType,
|
|
453
|
-
name: "String",
|
|
454
|
-
slug: "String",
|
|
455
|
-
branch: reference.branch,
|
|
456
|
-
revision: reference.revision,
|
|
457
|
-
createdAtUtcIso: "DateTime!",
|
|
458
|
-
lastModifiedAtUtcIso: "DateTime!"
|
|
459
|
-
},
|
|
460
|
-
state: { global: globalState }
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
//#endregion
|
|
464
|
-
//#region editors/workflow-editor/ui/variable-types.ts
|
|
465
|
-
const VARIABLE_TYPE_LABEL = {
|
|
466
|
-
TEXT: "Text",
|
|
467
|
-
NUMBER: "Number",
|
|
468
|
-
BOOLEAN: "True or false",
|
|
469
|
-
JSON: "JSON",
|
|
470
|
-
SECRET: "Secret"
|
|
471
|
-
};
|
|
472
|
-
const VARIABLE_TYPES = Object.keys(VARIABLE_TYPE_LABEL);
|
|
473
|
-
const DECIMAL$1 = /^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
|
|
474
|
-
function parseTypedValue(type, raw) {
|
|
475
|
-
const trimmed = raw.trim();
|
|
476
|
-
switch (type) {
|
|
477
|
-
case "TEXT": return {
|
|
478
|
-
ok: true,
|
|
479
|
-
value: raw === "" ? null : raw
|
|
480
|
-
};
|
|
481
|
-
case "NUMBER":
|
|
482
|
-
if (trimmed === "") return {
|
|
483
|
-
ok: true,
|
|
484
|
-
value: null
|
|
485
|
-
};
|
|
486
|
-
return DECIMAL$1.test(trimmed) ? {
|
|
487
|
-
ok: true,
|
|
488
|
-
value: Number(trimmed)
|
|
489
|
-
} : {
|
|
490
|
-
ok: false,
|
|
491
|
-
error: "Not a number"
|
|
492
|
-
};
|
|
493
|
-
case "BOOLEAN":
|
|
494
|
-
if (trimmed === "true") return {
|
|
495
|
-
ok: true,
|
|
496
|
-
value: true
|
|
497
|
-
};
|
|
498
|
-
if (trimmed === "false") return {
|
|
499
|
-
ok: true,
|
|
500
|
-
value: false
|
|
501
|
-
};
|
|
502
|
-
return {
|
|
503
|
-
ok: false,
|
|
504
|
-
error: "Not true or false"
|
|
505
|
-
};
|
|
506
|
-
case "JSON":
|
|
507
|
-
if (trimmed === "") return {
|
|
508
|
-
ok: true,
|
|
509
|
-
value: null
|
|
510
|
-
};
|
|
511
|
-
try {
|
|
512
|
-
return {
|
|
513
|
-
ok: true,
|
|
514
|
-
value: JSON.parse(trimmed)
|
|
515
|
-
};
|
|
516
|
-
} catch (error) {
|
|
517
|
-
return {
|
|
518
|
-
ok: false,
|
|
519
|
-
error: `Not valid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
case "SECRET": return {
|
|
523
|
-
ok: false,
|
|
524
|
-
error: "Secrets are set through the secret field"
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
function valueMismatch(type, value) {
|
|
529
|
-
if (value === null || value === void 0) return null;
|
|
530
|
-
switch (type) {
|
|
531
|
-
case "TEXT": return typeof value === "string" ? null : "Not text";
|
|
532
|
-
case "NUMBER": return typeof value === "number" ? null : "Not a number";
|
|
533
|
-
case "BOOLEAN": return typeof value === "boolean" ? null : "Not true or false";
|
|
534
|
-
case "JSON": return null;
|
|
535
|
-
case "SECRET": return typeof value === "string" ? null : "Not a secret reference";
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
function convertVariableValue(value, from, to) {
|
|
539
|
-
if (from === to) return value;
|
|
540
|
-
if (from === "SECRET" || to === "SECRET") return null;
|
|
541
|
-
if (to === "JSON" || value === null || value === void 0) return value ?? null;
|
|
542
|
-
if (to === "TEXT") return typeof value === "string" ? value : JSON.stringify(value);
|
|
543
|
-
if (typeof value === "string") {
|
|
544
|
-
const parsed = parseTypedValue(to, value);
|
|
545
|
-
if (parsed.ok) return parsed.value;
|
|
546
|
-
}
|
|
547
|
-
return value;
|
|
548
|
-
}
|
|
549
|
-
//#endregion
|
|
550
|
-
//#region editors/workflow-editor/ui/expression-scope.ts
|
|
551
|
-
const EMPTY_SCOPE = {
|
|
552
|
-
value: {},
|
|
553
|
-
captions: {}
|
|
554
|
-
};
|
|
555
|
-
const MAX_DEPTH = 6;
|
|
556
|
-
const MAX_ARRAY_ITEMS = 25;
|
|
557
|
-
function capValue(value, depth = 0) {
|
|
558
|
-
if (value === null || typeof value !== "object") return value;
|
|
559
|
-
if (depth >= MAX_DEPTH) return Array.isArray(value) ? "[…]" : "{…}";
|
|
560
|
-
if (Array.isArray(value)) return value.slice(0, MAX_ARRAY_ITEMS).map((item) => capValue(item, depth + 1));
|
|
561
|
-
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, capValue(entry, depth + 1)]));
|
|
562
|
-
}
|
|
563
|
-
function upstreamStepIds(model, stepId) {
|
|
564
|
-
const incoming = /* @__PURE__ */ new Map();
|
|
565
|
-
for (const edge of model.edges) incoming.set(edge.to, [...incoming.get(edge.to) ?? [], edge.from]);
|
|
566
|
-
const upstream = /* @__PURE__ */ new Set();
|
|
567
|
-
const queue = [stepId];
|
|
568
|
-
while (queue.length > 0) for (const from of incoming.get(queue.pop()) ?? []) if (!upstream.has(from)) {
|
|
569
|
-
upstream.add(from);
|
|
570
|
-
queue.push(from);
|
|
571
|
-
}
|
|
572
|
-
return upstream;
|
|
573
|
-
}
|
|
574
|
-
function formatRunTime(startedAt, now = /* @__PURE__ */ new Date()) {
|
|
575
|
-
const date = new Date(startedAt);
|
|
576
|
-
if (Number.isNaN(date.getTime())) return startedAt;
|
|
577
|
-
const sameDay = date.toDateString() === now.toDateString();
|
|
578
|
-
const time = date.toLocaleTimeString([], {
|
|
579
|
-
hour: "2-digit",
|
|
580
|
-
minute: "2-digit"
|
|
581
|
-
});
|
|
582
|
-
return sameDay ? time : `${date.toLocaleDateString([], {
|
|
583
|
-
month: "short",
|
|
584
|
-
day: "numeric"
|
|
585
|
-
})} ${time}`;
|
|
586
|
-
}
|
|
587
|
-
const hasOutput = (step) => (step.status === "SUCCEEDED" || step.status === "REPLAYED") && step.output !== void 0 && step.output !== null;
|
|
588
|
-
async function withDocuments(value, documentOutput) {
|
|
589
|
-
const references = documentRefsIn(value);
|
|
590
|
-
if (references.length === 0) return value;
|
|
591
|
-
const key = (reference) => `${reference.branch}:${reference.documentId}`;
|
|
592
|
-
const shapeOf = async (reference) => {
|
|
593
|
-
try {
|
|
594
|
-
if (documentOutput) return await documentOutput(reference);
|
|
595
|
-
} catch {}
|
|
596
|
-
return documentShape(reference, {});
|
|
597
|
-
};
|
|
598
|
-
const shapes = new Map(await Promise.all(references.map(async (reference) => [key(reference), await shapeOf(reference)])));
|
|
599
|
-
return expandDocumentRefs(value, (reference) => shapes.get(key(reference)));
|
|
600
|
-
}
|
|
601
|
-
async function buildExpressionScope(options) {
|
|
602
|
-
const { model, latestRun } = options;
|
|
603
|
-
const documents = (value) => withDocuments(value, options.documentOutput);
|
|
604
|
-
const runCaption = latestRun ? `from run ${formatRunTime(latestRun.startedAt, options.now)}` : void 0;
|
|
605
|
-
const runSteps = new Map((latestRun?.steps ?? []).filter(hasOutput).map((step) => [step.stepKey, step]));
|
|
606
|
-
const value = {};
|
|
607
|
-
const captions = {};
|
|
608
|
-
const testCaption = (sample) => `from test ${formatRunTime(sample.testedAt, options.now)}`;
|
|
609
|
-
const tested = async (block) => block.lastTest && options.testOutput ? options.testOutput(block.id).catch(() => void 0) : void 0;
|
|
610
|
-
if (model.trigger) {
|
|
611
|
-
const sample = await tested(model.trigger);
|
|
612
|
-
if (sample) {
|
|
613
|
-
value.trigger = { payload: capValue(await documents(sample.value)) };
|
|
614
|
-
captions["trigger.payload"] = testCaption(sample);
|
|
615
|
-
} else if (runCaption && latestRun?.triggerPayload !== void 0 && latestRun.triggerPayload !== null) {
|
|
616
|
-
value.trigger = { payload: capValue(await documents(latestRun.triggerPayload)) };
|
|
617
|
-
captions["trigger.payload"] = runCaption;
|
|
618
|
-
} else {
|
|
619
|
-
value.trigger = { payload: await options.authoredOutput(triggerBlock(model.trigger), model.trigger.config) };
|
|
620
|
-
captions["trigger.payload"] = "declared type";
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
const upstream = upstreamStepIds(model, options.stepId);
|
|
624
|
-
const steps = {};
|
|
625
|
-
await Promise.all(model.steps.filter((step) => upstream.has(step.id)).map(async (step) => {
|
|
626
|
-
const sample = await tested(step);
|
|
627
|
-
if (sample) {
|
|
628
|
-
steps[step.key] = { output: capValue(await documents(sample.value)) };
|
|
629
|
-
captions[`steps.${step.key}.output`] = testCaption(sample);
|
|
630
|
-
return;
|
|
631
|
-
}
|
|
632
|
-
const journaled = runSteps.get(step.key);
|
|
633
|
-
if (runCaption && journaled && journaled.pieceName === step.pieceName && journaled.blockName === step.actionName) {
|
|
634
|
-
steps[step.key] = { output: capValue(await documents(journaled.output)) };
|
|
635
|
-
captions[`steps.${step.key}.output`] = runCaption;
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
steps[step.key] = { output: await options.authoredOutput(stepBlock(step), step.config) };
|
|
639
|
-
captions[`steps.${step.key}.output`] = "declared type";
|
|
640
|
-
}));
|
|
641
|
-
if (Object.keys(steps).length > 0) value.steps = steps;
|
|
642
|
-
if (model.variables.length > 0) {
|
|
643
|
-
value.variables = Object.fromEntries(model.variables.map((variable) => [variable.key, variable.type === "SECRET" ? "secret" : variable.value ?? null]));
|
|
644
|
-
captions.variables = "workflow variables";
|
|
645
|
-
for (const variable of model.variables) if (variable.type) captions[`variables.${variable.key}`] = VARIABLE_TYPE_LABEL[variable.type].toLowerCase();
|
|
646
|
-
}
|
|
647
|
-
return {
|
|
648
|
-
value,
|
|
649
|
-
captions
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
653
|
-
function childPath(parent, key, parentIsArray) {
|
|
654
|
-
if (parentIsArray) return `${parent}[${key}]`;
|
|
655
|
-
if (!parent) return key;
|
|
656
|
-
return IDENTIFIER.test(key) ? `${parent}.${key}` : `${parent}[${JSON.stringify(key)}]`;
|
|
657
|
-
}
|
|
658
|
-
//#endregion
|
|
659
|
-
//#region editors/workflow-editor/ui/canvas-menu.ts
|
|
660
|
-
function hasNextPort(model, id, portsOf) {
|
|
661
|
-
if (model.trigger?.id === id) return true;
|
|
662
|
-
const step = model.steps.find((entry) => entry.id === id);
|
|
663
|
-
return step ? portsOf(stepBlock(step))?.includes("next") ?? false : false;
|
|
664
|
-
}
|
|
665
|
-
function contextMenuItems(target, model, portsOf) {
|
|
666
|
-
switch (target.kind) {
|
|
667
|
-
case "step": {
|
|
668
|
-
const skipped = model.steps.find((entry) => entry.id === target.id)?.skip === true;
|
|
669
|
-
return [
|
|
670
|
-
{
|
|
671
|
-
id: "open",
|
|
672
|
-
label: "Open settings"
|
|
673
|
-
},
|
|
674
|
-
{
|
|
675
|
-
id: "addBelow",
|
|
676
|
-
label: "Add step below",
|
|
677
|
-
disabled: !hasNextPort(model, target.id, portsOf)
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
id: "duplicate",
|
|
681
|
-
label: "Duplicate step"
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
id: "toggleSkip",
|
|
685
|
-
label: skipped ? "Stop skipping this step" : "Skip this step"
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
id: "removeStep",
|
|
689
|
-
label: "Remove step"
|
|
690
|
-
}
|
|
691
|
-
];
|
|
692
|
-
}
|
|
693
|
-
case "trigger": return [
|
|
694
|
-
{
|
|
695
|
-
id: "open",
|
|
696
|
-
label: "Open settings"
|
|
697
|
-
},
|
|
698
|
-
{
|
|
699
|
-
id: "addBelow",
|
|
700
|
-
label: "Add step below",
|
|
701
|
-
disabled: !model.trigger
|
|
702
|
-
},
|
|
703
|
-
{
|
|
704
|
-
id: "changeTrigger",
|
|
705
|
-
label: "Change trigger"
|
|
706
|
-
},
|
|
707
|
-
{
|
|
708
|
-
id: "removeTrigger",
|
|
709
|
-
label: "Remove trigger"
|
|
710
|
-
}
|
|
711
|
-
];
|
|
712
|
-
case "edge": return [{
|
|
713
|
-
id: "insertStep",
|
|
714
|
-
label: "Insert step here"
|
|
715
|
-
}, {
|
|
716
|
-
id: "removeEdge",
|
|
717
|
-
label: "Remove edge"
|
|
718
|
-
}];
|
|
719
|
-
case "pane": return [
|
|
720
|
-
{
|
|
721
|
-
id: "addStep",
|
|
722
|
-
label: "Add step here"
|
|
723
|
-
},
|
|
724
|
-
{
|
|
725
|
-
id: "selectAll",
|
|
726
|
-
label: "Select all steps",
|
|
727
|
-
disabled: model.steps.length === 0
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
id: "fitView",
|
|
731
|
-
label: "Fit view"
|
|
732
|
-
}
|
|
733
|
-
];
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
const MENU_ITEM_HEIGHT = 28;
|
|
737
|
-
const VIEWPORT_MARGIN = 8;
|
|
738
|
-
function menuHeight(items) {
|
|
739
|
-
return items * MENU_ITEM_HEIGHT + 8;
|
|
740
|
-
}
|
|
741
|
-
function clampToViewport(at, extent, available) {
|
|
742
|
-
return Math.max(VIEWPORT_MARGIN, Math.min(at, available - extent - VIEWPORT_MARGIN));
|
|
743
|
-
}
|
|
744
|
-
function menuPosition(point, size, viewport) {
|
|
745
|
-
const place = (at, extent, available) => clampToViewport(at + extent > available - VIEWPORT_MARGIN ? at - extent : at, extent, available);
|
|
746
|
-
return {
|
|
747
|
-
x: place(point.x, size.width, viewport.width),
|
|
748
|
-
y: place(point.y, size.height, viewport.height)
|
|
749
|
-
};
|
|
750
|
-
}
|
|
751
|
-
const ANCHOR_GAP = 8;
|
|
752
|
-
function anchorLeftPosition(anchor, size, viewport) {
|
|
753
|
-
const left = anchor.left - ANCHOR_GAP - size.width;
|
|
754
|
-
return {
|
|
755
|
-
x: clampToViewport(left >= VIEWPORT_MARGIN ? left : anchor.right + ANCHOR_GAP, size.width, viewport.width),
|
|
756
|
-
y: clampToViewport(anchor.top, size.height, viewport.height)
|
|
757
|
-
};
|
|
758
|
-
}
|
|
759
|
-
//#endregion
|
|
760
|
-
//#region editors/workflow-editor/ui/expression-tokens.ts
|
|
761
|
-
const EMBEDDED_EXPRESSION = /(?<!\\)\{\{\s*([^{}]+?)\s*\}\}/g;
|
|
762
|
-
function splitExpressionTokens(value) {
|
|
763
|
-
const tokens = [];
|
|
764
|
-
let last = 0;
|
|
765
|
-
for (const match of value.matchAll(EMBEDDED_EXPRESSION)) {
|
|
766
|
-
const index = match.index;
|
|
767
|
-
if (index > last) tokens.push({
|
|
768
|
-
kind: "text",
|
|
769
|
-
text: value.slice(last, index)
|
|
770
|
-
});
|
|
771
|
-
tokens.push({
|
|
772
|
-
kind: "expression",
|
|
773
|
-
text: match[0],
|
|
774
|
-
expression: match[1]
|
|
775
|
-
});
|
|
776
|
-
last = index + match[0].length;
|
|
777
|
-
}
|
|
778
|
-
if (last < value.length) tokens.push({
|
|
779
|
-
kind: "text",
|
|
780
|
-
text: value.slice(last)
|
|
781
|
-
});
|
|
782
|
-
return tokens;
|
|
783
|
-
}
|
|
784
|
-
function hasExpressions(value) {
|
|
785
|
-
return typeof value === "string" && new RegExp(EMBEDDED_EXPRESSION).test(value);
|
|
786
|
-
}
|
|
787
|
-
function describeExpression(expression) {
|
|
788
|
-
const terms = expression.split("||");
|
|
789
|
-
const path = terms[0].trim();
|
|
790
|
-
const hasFallback = terms.length > 1;
|
|
791
|
-
const segments = path.split(".");
|
|
792
|
-
switch (segments[0]) {
|
|
793
|
-
case "steps": return {
|
|
794
|
-
root: "steps",
|
|
795
|
-
stepKey: segments[1] ?? "",
|
|
796
|
-
rest: segments.slice(2).join("."),
|
|
797
|
-
hasFallback
|
|
798
|
-
};
|
|
799
|
-
case "trigger": return {
|
|
800
|
-
root: "trigger",
|
|
801
|
-
rest: segments.slice(1).join("."),
|
|
802
|
-
hasFallback
|
|
803
|
-
};
|
|
804
|
-
case "variables": return {
|
|
805
|
-
root: "variables",
|
|
806
|
-
rest: segments.slice(1).join("."),
|
|
807
|
-
hasFallback
|
|
808
|
-
};
|
|
809
|
-
default: return {
|
|
810
|
-
root: "other",
|
|
811
|
-
rest: path,
|
|
812
|
-
hasFallback
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
//#endregion
|
|
817
|
-
//#region editors/workflow-editor/ui/ExpressionPicker.tsx
|
|
818
|
-
const ScopeSourceContext = createContext(void 0);
|
|
819
|
-
const ExpressionScopeSourceProvider = ScopeSourceContext.Provider;
|
|
820
|
-
function useScopeSource() {
|
|
821
|
-
return useContext(ScopeSourceContext);
|
|
822
|
-
}
|
|
823
|
-
const TargetContext = createContext(null);
|
|
824
|
-
function ExpressionTargetProvider(props) {
|
|
825
|
-
const [target, setTarget] = useState(null);
|
|
826
|
-
const value = useMemo(() => ({
|
|
827
|
-
target,
|
|
828
|
-
setTarget,
|
|
829
|
-
stepBlocks: props.stepBlocks,
|
|
830
|
-
triggerBlock: props.triggerBlock
|
|
831
|
-
}), [
|
|
832
|
-
target,
|
|
833
|
-
props.stepBlocks,
|
|
834
|
-
props.triggerBlock
|
|
835
|
-
]);
|
|
836
|
-
return /* @__PURE__ */ jsx(TargetContext.Provider, {
|
|
837
|
-
value,
|
|
838
|
-
children: props.children
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
function useExpressionTarget() {
|
|
842
|
-
return useContext(TargetContext);
|
|
843
|
-
}
|
|
844
|
-
function fieldAnchor(element) {
|
|
845
|
-
const rect = (element?.closest("label,div") ?? element)?.getBoundingClientRect();
|
|
846
|
-
if (!rect) return {
|
|
847
|
-
left: window.innerWidth,
|
|
848
|
-
right: window.innerWidth,
|
|
849
|
-
top: 0
|
|
850
|
-
};
|
|
851
|
-
return {
|
|
852
|
-
left: rect.left,
|
|
853
|
-
right: rect.right,
|
|
854
|
-
top: rect.top
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
|
-
function useExpressionField(options) {
|
|
858
|
-
const id = useId();
|
|
859
|
-
const context = useExpressionTarget();
|
|
860
|
-
const insertRef = useRef(options.insert);
|
|
861
|
-
useEffect(() => {
|
|
862
|
-
insertRef.current = options.insert;
|
|
863
|
-
});
|
|
864
|
-
const { stepId, label } = options;
|
|
865
|
-
return {
|
|
866
|
-
active: context?.target?.id === id,
|
|
867
|
-
focus: (event) => {
|
|
868
|
-
context?.setTarget({
|
|
869
|
-
id,
|
|
870
|
-
stepId,
|
|
871
|
-
label,
|
|
872
|
-
anchor: fieldAnchor(event?.currentTarget),
|
|
873
|
-
insert: (expression) => insertRef.current(expression)
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
function preview(value) {
|
|
879
|
-
if (value === null) return "null";
|
|
880
|
-
if (value === void 0) return "";
|
|
881
|
-
if (Array.isArray(value)) return `[${value.length}]`;
|
|
882
|
-
if (typeof value === "object") return "{…}";
|
|
883
|
-
const text = typeof value === "string" ? value : JSON.stringify(value) ?? "";
|
|
884
|
-
return text.length > 28 ? `${text.slice(0, 28)}…` : text;
|
|
885
|
-
}
|
|
886
|
-
function isExpandable(value) {
|
|
887
|
-
return value !== null && typeof value === "object" && Object.keys(value).length > 0;
|
|
888
|
-
}
|
|
889
|
-
function entriesOf(value) {
|
|
890
|
-
if (Array.isArray(value)) return value.map((item, i) => [String(i), item]);
|
|
891
|
-
if (value !== null && typeof value === "object") return Object.entries(value);
|
|
892
|
-
return [];
|
|
893
|
-
}
|
|
894
|
-
function Caption(props) {
|
|
895
|
-
if (!props.text) return null;
|
|
896
|
-
return /* @__PURE__ */ jsx("span", {
|
|
897
|
-
className: "ml-auto shrink-0 pl-2 text-[10px] italic text-muted-foreground/80",
|
|
898
|
-
children: props.text
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
function ValueNode(props) {
|
|
902
|
-
const context = useExpressionTarget();
|
|
903
|
-
const [open, setOpen] = useState(props.depth < 2);
|
|
904
|
-
const expandable = isExpandable(props.value);
|
|
905
|
-
const stepKey = /^steps\.([^.]+)$/.exec(props.path)?.[1];
|
|
906
|
-
const nodeBlock = stepKey ? context?.stepBlocks[stepKey] : props.path === "trigger" ? context?.triggerBlock : void 0;
|
|
907
|
-
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
908
|
-
className: "flex items-center gap-1 rounded px-1 py-0.5 hover:bg-muted/50",
|
|
909
|
-
style: { paddingLeft: props.depth * 14 + 4 },
|
|
910
|
-
children: [
|
|
911
|
-
expandable ? /* @__PURE__ */ jsx("button", {
|
|
912
|
-
type: "button",
|
|
913
|
-
className: "w-3 shrink-0 text-[10px] text-muted-foreground/80",
|
|
914
|
-
onClick: () => setOpen((value) => !value),
|
|
915
|
-
children: open ? "▾" : "▸"
|
|
916
|
-
}) : /* @__PURE__ */ jsx("span", { className: "w-3 shrink-0" }),
|
|
917
|
-
/* @__PURE__ */ jsxs("button", {
|
|
918
|
-
type: "button",
|
|
919
|
-
className: "flex min-w-0 flex-1 items-baseline gap-2 text-left",
|
|
920
|
-
title: `{{${props.path}}}`,
|
|
921
|
-
onClick: () => props.onPick(props.path),
|
|
922
|
-
children: [nodeBlock ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(BlockLogo, {
|
|
923
|
-
block: nodeBlock,
|
|
924
|
-
size: 16
|
|
925
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
926
|
-
className: "shrink-0 text-xs font-medium text-foreground",
|
|
927
|
-
children: blockMeta(nodeBlock).displayName
|
|
928
|
-
})] }) : /* @__PURE__ */ jsx("span", {
|
|
929
|
-
className: "shrink-0 font-mono text-xs text-foreground",
|
|
930
|
-
children: props.name
|
|
931
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
932
|
-
className: "truncate text-[11px] text-muted-foreground/80",
|
|
933
|
-
children: preview(props.value)
|
|
934
|
-
})]
|
|
935
|
-
}),
|
|
936
|
-
/* @__PURE__ */ jsx(Caption, { text: props.captions[props.path] })
|
|
937
|
-
]
|
|
938
|
-
}), expandable && open ? entriesOf(props.value).map(([key, child]) => /* @__PURE__ */ jsx(ValueNode, {
|
|
939
|
-
name: key,
|
|
940
|
-
path: childPath(props.path, key, Array.isArray(props.value)),
|
|
941
|
-
value: child,
|
|
942
|
-
depth: props.depth + 1,
|
|
943
|
-
captions: props.captions,
|
|
944
|
-
onPick: props.onPick
|
|
945
|
-
}, key)) : null] });
|
|
946
|
-
}
|
|
947
|
-
const SEARCH_DEPTH = 6;
|
|
948
|
-
const SEARCH_LIMIT = 200;
|
|
949
|
-
function flatten(value, path, depth, out) {
|
|
950
|
-
for (const [key, child] of entriesOf(value)) {
|
|
951
|
-
const nested = childPath(path, key, Array.isArray(value));
|
|
952
|
-
out.push({
|
|
953
|
-
path: nested,
|
|
954
|
-
value: child
|
|
955
|
-
});
|
|
956
|
-
if (depth < SEARCH_DEPTH && isExpandable(child)) flatten(child, nested, depth + 1, out);
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
function SearchResults(props) {
|
|
960
|
-
const matches = useMemo(() => {
|
|
961
|
-
const all = [];
|
|
962
|
-
flatten(props.scope.value, "", 0, all);
|
|
963
|
-
const lowered = props.query.toLowerCase();
|
|
964
|
-
return all.filter((entry) => entry.path.toLowerCase().includes(lowered)).slice(0, SEARCH_LIMIT);
|
|
965
|
-
}, [props.scope, props.query]);
|
|
966
|
-
if (matches.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
967
|
-
className: "px-2 py-1 text-xs text-muted-foreground/80",
|
|
968
|
-
children: "No matches"
|
|
969
|
-
});
|
|
970
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children: matches.map((entry) => /* @__PURE__ */ jsxs("button", {
|
|
971
|
-
type: "button",
|
|
972
|
-
className: "flex w-full items-baseline gap-2 rounded px-2 py-0.5 text-left hover:bg-muted/50",
|
|
973
|
-
title: `{{${entry.path}}}`,
|
|
974
|
-
onClick: () => props.onPick(entry.path),
|
|
975
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
976
|
-
className: "min-w-0 truncate font-mono text-[11px] text-foreground",
|
|
977
|
-
children: entry.path
|
|
978
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
979
|
-
className: "truncate text-[10px] text-muted-foreground/80",
|
|
980
|
-
children: preview(entry.value)
|
|
981
|
-
})]
|
|
982
|
-
}, entry.path)) });
|
|
983
|
-
}
|
|
984
|
-
const POPUP_SIZE = {
|
|
985
|
-
width: 420,
|
|
986
|
-
height: 520
|
|
987
|
-
};
|
|
988
|
-
function ExpressionPickerPopup() {
|
|
989
|
-
const context = useExpressionTarget();
|
|
990
|
-
const target = context?.target ?? null;
|
|
991
|
-
const [query, setQuery] = useState("");
|
|
992
|
-
const [state, setState] = useState({ kind: "idle" });
|
|
993
|
-
const scopeSource = useScopeSource();
|
|
994
|
-
const containerRef = useRef(null);
|
|
995
|
-
const stepId = target?.stepId;
|
|
996
|
-
const hasTarget = target !== null;
|
|
997
|
-
useEffect(() => {
|
|
998
|
-
if (!hasTarget || !scopeSource) return;
|
|
999
|
-
let alive = true;
|
|
1000
|
-
setState((current) => current.kind === "ready" && current.stepId === stepId ? current : { kind: "loading" });
|
|
1001
|
-
scopeSource.load({ stepId }).then((scope) => {
|
|
1002
|
-
if (alive) setState({
|
|
1003
|
-
kind: "ready",
|
|
1004
|
-
scope,
|
|
1005
|
-
stepId
|
|
1006
|
-
});
|
|
1007
|
-
}, (error) => {
|
|
1008
|
-
if (alive) setState({
|
|
1009
|
-
kind: "error",
|
|
1010
|
-
message: error instanceof Error ? error.message : String(error)
|
|
1011
|
-
});
|
|
1012
|
-
});
|
|
1013
|
-
return () => {
|
|
1014
|
-
alive = false;
|
|
1015
|
-
};
|
|
1016
|
-
}, [
|
|
1017
|
-
hasTarget,
|
|
1018
|
-
stepId,
|
|
1019
|
-
scopeSource
|
|
1020
|
-
]);
|
|
1021
|
-
const targetId = target?.id;
|
|
1022
|
-
useEffect(() => setQuery(""), [targetId]);
|
|
1023
|
-
const close = context?.setTarget;
|
|
1024
|
-
useEffect(() => {
|
|
1025
|
-
if (!hasTarget || !close) return;
|
|
1026
|
-
const dismiss = () => close(null);
|
|
1027
|
-
const outside = (event) => !containerRef.current?.contains(event.target);
|
|
1028
|
-
const onMouseDown = (event) => {
|
|
1029
|
-
if (outside(event)) dismiss();
|
|
1030
|
-
};
|
|
1031
|
-
const onKeyDown = (event) => {
|
|
1032
|
-
if (event.key === "Escape") dismiss();
|
|
1033
|
-
};
|
|
1034
|
-
const onScroll = (event) => {
|
|
1035
|
-
if (outside(event)) dismiss();
|
|
1036
|
-
};
|
|
1037
|
-
window.addEventListener("mousedown", onMouseDown);
|
|
1038
|
-
window.addEventListener("keydown", onKeyDown);
|
|
1039
|
-
window.addEventListener("scroll", onScroll, true);
|
|
1040
|
-
return () => {
|
|
1041
|
-
window.removeEventListener("mousedown", onMouseDown);
|
|
1042
|
-
window.removeEventListener("keydown", onKeyDown);
|
|
1043
|
-
window.removeEventListener("scroll", onScroll, true);
|
|
1044
|
-
};
|
|
1045
|
-
}, [hasTarget, close]);
|
|
1046
|
-
if (!context || !scopeSource || !target) return null;
|
|
1047
|
-
const pick = (path) => {
|
|
1048
|
-
target.insert(`{{${path}}}`);
|
|
1049
|
-
context.setTarget(null);
|
|
1050
|
-
};
|
|
1051
|
-
const scope = state.kind === "ready" && state.stepId === stepId ? state.scope : EMPTY_SCOPE;
|
|
1052
|
-
const empty = entriesOf(scope.value).length === 0;
|
|
1053
|
-
const position = anchorLeftPosition(target.anchor, POPUP_SIZE, {
|
|
1054
|
-
width: window.innerWidth,
|
|
1055
|
-
height: window.innerHeight
|
|
1056
|
-
});
|
|
1057
|
-
return createPortal(/* @__PURE__ */ jsxs("div", {
|
|
1058
|
-
ref: containerRef,
|
|
1059
|
-
className: "workflow-expression-popup fixed flex flex-col rounded-md border border-solid border-foreground/10 bg-card shadow-lg",
|
|
1060
|
-
onMouseDown: (event) => {
|
|
1061
|
-
if (!(event.target instanceof HTMLInputElement)) event.preventDefault();
|
|
1062
|
-
},
|
|
1063
|
-
style: {
|
|
1064
|
-
left: position.x,
|
|
1065
|
-
top: position.y,
|
|
1066
|
-
width: POPUP_SIZE.width,
|
|
1067
|
-
maxHeight: POPUP_SIZE.height
|
|
1068
|
-
},
|
|
1069
|
-
children: [
|
|
1070
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1071
|
-
className: "flex items-center gap-2 px-3 py-1.5",
|
|
1072
|
-
children: [
|
|
1073
|
-
/* @__PURE__ */ jsx("span", {
|
|
1074
|
-
className: "font-mono text-[11px] text-muted-foreground",
|
|
1075
|
-
children: "{}"
|
|
1076
|
-
}),
|
|
1077
|
-
/* @__PURE__ */ jsxs("span", {
|
|
1078
|
-
className: "min-w-0 truncate text-xs text-muted-foreground",
|
|
1079
|
-
children: [
|
|
1080
|
-
"Insert into",
|
|
1081
|
-
" ",
|
|
1082
|
-
/* @__PURE__ */ jsx("span", {
|
|
1083
|
-
className: "font-semibold text-foreground",
|
|
1084
|
-
children: target.label
|
|
1085
|
-
})
|
|
1086
|
-
]
|
|
1087
|
-
}),
|
|
1088
|
-
/* @__PURE__ */ jsx("button", {
|
|
1089
|
-
type: "button",
|
|
1090
|
-
className: "ml-auto text-[11px] text-muted-foreground/80 hover:text-muted-foreground",
|
|
1091
|
-
title: "Close",
|
|
1092
|
-
onClick: () => context.setTarget(null),
|
|
1093
|
-
children: "✕"
|
|
1094
|
-
})
|
|
1095
|
-
]
|
|
1096
|
-
}),
|
|
1097
|
-
/* @__PURE__ */ jsx("div", {
|
|
1098
|
-
className: "px-3 pb-1.5",
|
|
1099
|
-
children: /* @__PURE__ */ jsx("input", {
|
|
1100
|
-
className: "w-full rounded border border-foreground/10 px-2 py-1.5 text-sm",
|
|
1101
|
-
placeholder: "Search paths…",
|
|
1102
|
-
value: query,
|
|
1103
|
-
onChange: (event) => setQuery(event.target.value)
|
|
1104
|
-
})
|
|
1105
|
-
}),
|
|
1106
|
-
/* @__PURE__ */ jsx("div", {
|
|
1107
|
-
className: "min-h-0 flex-1 overflow-y-auto px-1 pb-1",
|
|
1108
|
-
children: state.kind === "error" ? /* @__PURE__ */ jsx("div", {
|
|
1109
|
-
className: "px-2 py-1 text-xs text-wf-fail",
|
|
1110
|
-
children: state.message
|
|
1111
|
-
}) : state.kind === "loading" ? /* @__PURE__ */ jsx("div", {
|
|
1112
|
-
className: "px-2 py-1 text-xs text-muted-foreground/80",
|
|
1113
|
-
children: "Loading…"
|
|
1114
|
-
}) : empty ? /* @__PURE__ */ jsx("div", {
|
|
1115
|
-
className: "px-2 py-1 text-xs text-muted-foreground/80",
|
|
1116
|
-
children: "No values available for this field yet."
|
|
1117
|
-
}) : query.trim() ? /* @__PURE__ */ jsx(SearchResults, {
|
|
1118
|
-
scope,
|
|
1119
|
-
query: query.trim(),
|
|
1120
|
-
onPick: pick
|
|
1121
|
-
}) : entriesOf(scope.value).map(([key, value]) => /* @__PURE__ */ jsx(ValueNode, {
|
|
1122
|
-
name: key,
|
|
1123
|
-
path: key,
|
|
1124
|
-
value,
|
|
1125
|
-
depth: 0,
|
|
1126
|
-
captions: scope.captions,
|
|
1127
|
-
onPick: pick
|
|
1128
|
-
}, key))
|
|
1129
|
-
})
|
|
1130
|
-
]
|
|
1131
|
-
}), document.body);
|
|
1132
|
-
}
|
|
1133
|
-
function ExpressionPickerButton(props) {
|
|
1134
|
-
if (!useScopeSource()) return null;
|
|
1135
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
1136
|
-
type: "button",
|
|
1137
|
-
title: "Insert data from the trigger or an earlier step",
|
|
1138
|
-
className: `inline-flex h-6 shrink-0 items-center gap-1 rounded-md px-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 ${props.active ? "bg-wf-run/10 text-wf-run" : "text-muted-foreground opacity-0 hover:bg-accent hover:text-foreground focus-visible:opacity-100 group-focus-within/field:opacity-100 group-hover/field:opacity-100 [@media(hover:none)]:opacity-100"}`,
|
|
1139
|
-
onClick: props.onFocusField,
|
|
1140
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
1141
|
-
name: "braces",
|
|
1142
|
-
className: "h-3.5 w-3.5"
|
|
1143
|
-
}), "Insert data"]
|
|
1144
|
-
});
|
|
1145
|
-
}
|
|
1146
|
-
function Chip(props) {
|
|
1147
|
-
const ref = describeExpression(props.expression);
|
|
1148
|
-
const block = ref.stepKey ? props.stepBlocks[ref.stepKey] : void 0;
|
|
1149
|
-
const head = ref.root === "steps" ? ref.stepKey : ref.root === "trigger" ? "trigger" : ref.root === "variables" ? "var" : "";
|
|
1150
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
1151
|
-
className: "inline-flex max-w-full items-center gap-1 rounded border border-solid border-wf-run/20 bg-wf-run/10 px-1 py-px font-mono text-[11px] text-wf-run",
|
|
1152
|
-
title: `{{${props.expression}}}`,
|
|
1153
|
-
children: [
|
|
1154
|
-
block ? /* @__PURE__ */ jsx(BlockLogo, {
|
|
1155
|
-
block,
|
|
1156
|
-
size: 12
|
|
1157
|
-
}) : null,
|
|
1158
|
-
head ? /* @__PURE__ */ jsx("span", {
|
|
1159
|
-
className: "font-semibold",
|
|
1160
|
-
children: head
|
|
1161
|
-
}) : null,
|
|
1162
|
-
/* @__PURE__ */ jsx("span", {
|
|
1163
|
-
className: "truncate",
|
|
1164
|
-
children: ref.root === "other" ? ref.rest : ref.rest || "*"
|
|
1165
|
-
}),
|
|
1166
|
-
ref.hasFallback ? /* @__PURE__ */ jsx("span", {
|
|
1167
|
-
className: "text-wf-run",
|
|
1168
|
-
children: "||…"
|
|
1169
|
-
}) : null
|
|
1170
|
-
]
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
function ExpressionTokenLine(props) {
|
|
1174
|
-
const context = useExpressionTarget();
|
|
1175
|
-
const tokens = splitExpressionTokens(props.value);
|
|
1176
|
-
if (!tokens.some((token) => token.kind === "expression")) return null;
|
|
1177
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1178
|
-
className: "mt-1.5 flex flex-wrap items-center gap-1 text-xs text-muted-foreground",
|
|
1179
|
-
children: tokens.map((token, index) => token.kind === "text" ? /* @__PURE__ */ jsx("span", {
|
|
1180
|
-
className: "max-w-40 truncate whitespace-pre",
|
|
1181
|
-
children: token.text
|
|
1182
|
-
}, index) : /* @__PURE__ */ jsx(Chip, {
|
|
1183
|
-
expression: token.expression,
|
|
1184
|
-
stepBlocks: context?.stepBlocks ?? {}
|
|
1185
|
-
}, index))
|
|
1186
|
-
});
|
|
1187
|
-
}
|
|
1188
382
|
const PANEL_DEFAULT_WIDTH = 416;
|
|
1189
383
|
const PANEL_MAX_SHARE = .7;
|
|
1190
384
|
const KEY_STEP = 16;
|
|
@@ -2009,1726 +1203,6 @@ function ReactorConnectionField(props) {
|
|
|
2009
1203
|
}) : null]
|
|
2010
1204
|
});
|
|
2011
1205
|
}
|
|
2012
|
-
//#endregion
|
|
2013
|
-
//#region editors/shared/pending-echo.ts
|
|
2014
|
-
function keyOf(value) {
|
|
2015
|
-
return JSON.stringify(value, (_, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))) : entry);
|
|
2016
|
-
}
|
|
2017
|
-
function usePendingEcho(saved, onChange) {
|
|
2018
|
-
const savedKey = keyOf(saved);
|
|
2019
|
-
const [sent, setSent] = useState([]);
|
|
2020
|
-
const [seen, setSeen] = useState(savedKey);
|
|
2021
|
-
let pending = sent;
|
|
2022
|
-
if (seen !== savedKey) {
|
|
2023
|
-
const echo = sent.findIndex((value) => keyOf(value) === savedKey);
|
|
2024
|
-
pending = echo === -1 ? [] : sent.slice(echo + 1);
|
|
2025
|
-
setSeen(savedKey);
|
|
2026
|
-
setSent(pending);
|
|
2027
|
-
}
|
|
2028
|
-
const value = pending.length > 0 ? pending[pending.length - 1] : saved;
|
|
2029
|
-
return {
|
|
2030
|
-
value,
|
|
2031
|
-
commit: (next) => {
|
|
2032
|
-
if (keyOf(next) === keyOf(value)) return;
|
|
2033
|
-
setSent([...pending, next]);
|
|
2034
|
-
onChange(next, value);
|
|
2035
|
-
},
|
|
2036
|
-
onBlur: (event) => {
|
|
2037
|
-
const inside = event.currentTarget.contains(event.relatedTarget);
|
|
2038
|
-
if (pending.length > 0 && !inside && keyOf(value) === savedKey) setSent([]);
|
|
2039
|
-
}
|
|
2040
|
-
};
|
|
2041
|
-
}
|
|
2042
|
-
//#endregion
|
|
2043
|
-
//#region editors/workflow-editor/ui/secret-ref.ts
|
|
2044
|
-
const SECRET_REF_PREFIX = "secret://v1:";
|
|
2045
|
-
function useSecretRef(options) {
|
|
2046
|
-
const { secrets } = options;
|
|
2047
|
-
const ref = typeof options.value === "string" ? options.value : "";
|
|
2048
|
-
const managed = ref.startsWith(SECRET_REF_PREFIX);
|
|
2049
|
-
const [draft, setDraft] = useState("");
|
|
2050
|
-
const [busy, setBusy] = useState(false);
|
|
2051
|
-
const [error, setError] = useState(null);
|
|
2052
|
-
const [stat, setStat] = useState(null);
|
|
2053
|
-
useEffect(() => {
|
|
2054
|
-
setStat(null);
|
|
2055
|
-
if (!managed || !secrets) return;
|
|
2056
|
-
let cancelled = false;
|
|
2057
|
-
secrets.stat(ref).then((result) => {
|
|
2058
|
-
if (!cancelled) setStat(result);
|
|
2059
|
-
}, () => void 0);
|
|
2060
|
-
return () => {
|
|
2061
|
-
cancelled = true;
|
|
2062
|
-
};
|
|
2063
|
-
}, [
|
|
2064
|
-
ref,
|
|
2065
|
-
managed,
|
|
2066
|
-
secrets
|
|
2067
|
-
]);
|
|
2068
|
-
const commit = () => {
|
|
2069
|
-
if (draft === "" || busy || !secrets) return;
|
|
2070
|
-
setBusy(true);
|
|
2071
|
-
setError(null);
|
|
2072
|
-
secrets.save({
|
|
2073
|
-
ref: managed ? ref : void 0,
|
|
2074
|
-
value: draft,
|
|
2075
|
-
label: options.label
|
|
2076
|
-
}).then((result) => {
|
|
2077
|
-
setDraft("");
|
|
2078
|
-
if (result.ref !== ref) options.onCommit(result.ref);
|
|
2079
|
-
else setStat(result);
|
|
2080
|
-
}).catch((requestError) => {
|
|
2081
|
-
setError(requestError instanceof Error ? requestError.message : String(requestError));
|
|
2082
|
-
}).finally(() => setBusy(false));
|
|
2083
|
-
};
|
|
2084
|
-
return {
|
|
2085
|
-
ref,
|
|
2086
|
-
managed,
|
|
2087
|
-
draft,
|
|
2088
|
-
setDraft,
|
|
2089
|
-
busy,
|
|
2090
|
-
error,
|
|
2091
|
-
stat,
|
|
2092
|
-
commit
|
|
2093
|
-
};
|
|
2094
|
-
}
|
|
2095
|
-
//#endregion
|
|
2096
|
-
//#region editors/workflow-editor/ui/prop-controls.tsx
|
|
2097
|
-
const CALLOUT = {
|
|
2098
|
-
INFO: { box: "rounded bg-muted px-2 py-1.5" },
|
|
2099
|
-
WARNING: {
|
|
2100
|
-
box: "rounded border border-solid border-wf-warn/40 bg-wf-warn/10 px-2 py-1.5",
|
|
2101
|
-
icon: "alert"
|
|
2102
|
-
},
|
|
2103
|
-
TIP: {
|
|
2104
|
-
box: "rounded border border-solid border-wf-ok/30 bg-wf-ok/10 px-2 py-1.5",
|
|
2105
|
-
icon: "bolt"
|
|
2106
|
-
},
|
|
2107
|
-
BORDERLESS: { box: "" }
|
|
2108
|
-
};
|
|
2109
|
-
/** A MARKDOWN prop's text, styled by the piece's `variant` (INFO default). */
|
|
2110
|
-
function MarkdownCallout(props) {
|
|
2111
|
-
const callout = CALLOUT[props.variant ?? "INFO"] ?? CALLOUT.INFO;
|
|
2112
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2113
|
-
className: `flex gap-2 ${callout.box}`,
|
|
2114
|
-
"data-variant": props.variant ?? "INFO",
|
|
2115
|
-
children: [callout.icon ? /* @__PURE__ */ jsx(Icon, {
|
|
2116
|
-
name: callout.icon,
|
|
2117
|
-
className: `mt-0.5 h-3.5 w-3.5 shrink-0 ${callout.icon === "alert" ? "text-wf-warn" : "text-wf-ok"}`
|
|
2118
|
-
}) : null, /* @__PURE__ */ jsx("div", {
|
|
2119
|
-
className: "min-w-0 flex-1",
|
|
2120
|
-
children: props.children
|
|
2121
|
-
})]
|
|
2122
|
-
});
|
|
2123
|
-
}
|
|
2124
|
-
/** An option's icon, when the piece names one this editor draws. */
|
|
2125
|
-
function optionIcon(name) {
|
|
2126
|
-
return isIconName(name) ? /* @__PURE__ */ jsx(Icon, {
|
|
2127
|
-
name,
|
|
2128
|
-
className: "h-3.5 w-3.5 shrink-0 text-muted-foreground"
|
|
2129
|
-
}) : void 0;
|
|
2130
|
-
}
|
|
2131
|
-
/** STATIC_DROPDOWN with `display: 'cards'`: one selectable card per option. */
|
|
2132
|
-
function OptionCards(props) {
|
|
2133
|
-
const current = props.keyOf(props.value);
|
|
2134
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2135
|
-
id: props.id,
|
|
2136
|
-
role: "radiogroup",
|
|
2137
|
-
className: `grid grid-cols-2 gap-2 ${props.invalid ? "rounded-md ring-1 ring-wf-warn/60" : ""}`,
|
|
2138
|
-
children: props.options.map((option) => {
|
|
2139
|
-
const key = props.keyOf(option.value);
|
|
2140
|
-
const selected = key === current;
|
|
2141
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
2142
|
-
type: "button",
|
|
2143
|
-
role: "radio",
|
|
2144
|
-
"aria-checked": selected,
|
|
2145
|
-
className: `flex min-w-0 flex-col items-start gap-1 rounded-lg border border-solid p-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 ${selected ? "border-foreground/40 bg-accent" : "border-foreground/10 hover:border-foreground/25"}`,
|
|
2146
|
-
onClick: () => props.onChange(selected && props.clearable ? void 0 : option.value),
|
|
2147
|
-
children: [/* @__PURE__ */ jsxs("span", {
|
|
2148
|
-
className: "flex items-center gap-1.5 text-[13px] font-medium text-foreground",
|
|
2149
|
-
children: [optionIcon(option.icon), option.label]
|
|
2150
|
-
}), option.description ? /* @__PURE__ */ jsx("span", {
|
|
2151
|
-
className: "text-xs leading-snug text-muted-foreground",
|
|
2152
|
-
children: option.description
|
|
2153
|
-
}) : null]
|
|
2154
|
-
}, key);
|
|
2155
|
-
})
|
|
2156
|
-
});
|
|
2157
|
-
}
|
|
2158
|
-
/** The declared bounds, for the hint and the check: "Between 0 and 5". */
|
|
2159
|
-
function numberRangeText(min, max) {
|
|
2160
|
-
if (min !== void 0 && max !== void 0) return `Between ${min} and ${max}`;
|
|
2161
|
-
if (min !== void 0) return `At least ${min}`;
|
|
2162
|
-
if (max !== void 0) return `At most ${max}`;
|
|
2163
|
-
return null;
|
|
2164
|
-
}
|
|
2165
|
-
function numberRangeError(value, min, max) {
|
|
2166
|
-
if (typeof value !== "number") return null;
|
|
2167
|
-
if (min !== void 0 && value < min || max !== void 0 && value > max) return `${numberRangeText(min, max)}.`;
|
|
2168
|
-
return null;
|
|
2169
|
-
}
|
|
2170
|
-
/** NUMBER with `display: 'stepper'`: − value +, still accepting expressions. */
|
|
2171
|
-
function NumberStepper(props) {
|
|
2172
|
-
const step = props.step ?? 1;
|
|
2173
|
-
const numeric = typeof props.value === "number" ? props.value : void 0;
|
|
2174
|
-
const clamp = (next) => Math.min(props.max ?? Infinity, Math.max(props.min ?? -Infinity, next));
|
|
2175
|
-
const bump = (direction) => props.onCommit(clamp((numeric ?? props.min ?? 0) + direction * step));
|
|
2176
|
-
const text = props.value === void 0 || props.value === null ? "" : String(props.value);
|
|
2177
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2178
|
-
className: "flex items-center gap-1",
|
|
2179
|
-
children: [
|
|
2180
|
-
/* @__PURE__ */ jsx(IconButton, {
|
|
2181
|
-
icon: "minus",
|
|
2182
|
-
label: "Decrease",
|
|
2183
|
-
disabled: numeric !== void 0 && props.min !== void 0 && numeric <= props.min,
|
|
2184
|
-
onClick: () => bump(-1)
|
|
2185
|
-
}),
|
|
2186
|
-
/* @__PURE__ */ jsx("input", {
|
|
2187
|
-
id: props.id,
|
|
2188
|
-
className: `${textInputClass} w-24 text-center tabular-nums ${props.invalid ? invalidClass : ""}`,
|
|
2189
|
-
defaultValue: text,
|
|
2190
|
-
inputMode: "decimal",
|
|
2191
|
-
spellCheck: false,
|
|
2192
|
-
onFocus: props.onFocus,
|
|
2193
|
-
onBlur: (event) => props.onCommitText(event.target.value)
|
|
2194
|
-
}, text),
|
|
2195
|
-
/* @__PURE__ */ jsx(IconButton, {
|
|
2196
|
-
icon: "plus",
|
|
2197
|
-
label: "Increase",
|
|
2198
|
-
disabled: numeric !== void 0 && props.max !== void 0 && numeric >= props.max,
|
|
2199
|
-
onClick: () => bump(1)
|
|
2200
|
-
})
|
|
2201
|
-
]
|
|
2202
|
-
});
|
|
2203
|
-
}
|
|
2204
|
-
const DATE_PRESETS = Object.entries({
|
|
2205
|
-
any_time: "Any time",
|
|
2206
|
-
last_24_hours: "Last 24 hours",
|
|
2207
|
-
last_7_days: "Last 7 days",
|
|
2208
|
-
last_30_days: "Last 30 days",
|
|
2209
|
-
last_90_days: "Last 90 days",
|
|
2210
|
-
this_month: "This month",
|
|
2211
|
-
custom: "Custom"
|
|
2212
|
-
}).map(([value, label]) => ({
|
|
2213
|
-
value,
|
|
2214
|
-
label
|
|
2215
|
-
}));
|
|
2216
|
-
function toLocalInput(iso) {
|
|
2217
|
-
if (!iso) return "";
|
|
2218
|
-
const date = new Date(iso);
|
|
2219
|
-
if (Number.isNaN(date.getTime())) return "";
|
|
2220
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
2221
|
-
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
2222
|
-
}
|
|
2223
|
-
function fromLocalInput(local) {
|
|
2224
|
-
if (!local) return void 0;
|
|
2225
|
-
const date = new Date(local);
|
|
2226
|
-
return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
2227
|
-
}
|
|
2228
|
-
function asDateRange(value) {
|
|
2229
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
2230
|
-
}
|
|
2231
|
-
function DateRangeField(props) {
|
|
2232
|
-
const range = asDateRange(props.value);
|
|
2233
|
-
const setPreset = (preset) => props.onCommit(preset === "" ? void 0 : preset === "custom" ? {
|
|
2234
|
-
preset,
|
|
2235
|
-
after: range.after,
|
|
2236
|
-
before: range.before
|
|
2237
|
-
} : { preset });
|
|
2238
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2239
|
-
className: "flex flex-col gap-2",
|
|
2240
|
-
children: [props.dropdown ? /* @__PURE__ */ jsx(Select, {
|
|
2241
|
-
id: props.id,
|
|
2242
|
-
options: DATE_PRESETS,
|
|
2243
|
-
value: range.preset ?? "",
|
|
2244
|
-
onChange: setPreset,
|
|
2245
|
-
invalid: props.invalid,
|
|
2246
|
-
clearable: props.clearable,
|
|
2247
|
-
placeholder: "Choose a range"
|
|
2248
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
2249
|
-
id: props.id,
|
|
2250
|
-
role: "radiogroup",
|
|
2251
|
-
className: "flex flex-wrap gap-1.5",
|
|
2252
|
-
children: DATE_PRESETS.map((preset) => {
|
|
2253
|
-
const selected = range.preset === preset.value;
|
|
2254
|
-
return /* @__PURE__ */ jsx("button", {
|
|
2255
|
-
type: "button",
|
|
2256
|
-
role: "radio",
|
|
2257
|
-
"aria-checked": selected,
|
|
2258
|
-
className: `h-7 rounded-full border border-solid px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 ${selected ? "border-foreground bg-foreground text-background" : "border-foreground/15 text-muted-foreground hover:text-foreground"}`,
|
|
2259
|
-
onClick: () => setPreset(selected && props.clearable ? "" : preset.value),
|
|
2260
|
-
children: preset.label
|
|
2261
|
-
}, preset.value);
|
|
2262
|
-
})
|
|
2263
|
-
}), range.preset === "custom" ? /* @__PURE__ */ jsx("div", {
|
|
2264
|
-
className: "grid grid-cols-2 gap-2",
|
|
2265
|
-
children: ["after", "before"].map((edge) => /* @__PURE__ */ jsxs("label", {
|
|
2266
|
-
className: "flex flex-col gap-1 text-xs text-muted-foreground",
|
|
2267
|
-
children: [edge === "after" ? "From" : "To", /* @__PURE__ */ jsx("input", {
|
|
2268
|
-
type: "datetime-local",
|
|
2269
|
-
className: textInputClass,
|
|
2270
|
-
defaultValue: toLocalInput(range[edge]),
|
|
2271
|
-
onBlur: (event) => props.onCommit({
|
|
2272
|
-
...range,
|
|
2273
|
-
[edge]: fromLocalInput(event.target.value)
|
|
2274
|
-
})
|
|
2275
|
-
})]
|
|
2276
|
-
}, edge))
|
|
2277
|
-
}) : null]
|
|
2278
|
-
});
|
|
2279
|
-
}
|
|
2280
|
-
const HEX = /^#[0-9a-f]{6}$/i;
|
|
2281
|
-
/** COLOR: a swatch picker beside a text field that also takes expressions. */
|
|
2282
|
-
function ColorField(props) {
|
|
2283
|
-
const text = typeof props.value === "string" ? props.value : "";
|
|
2284
|
-
const [draft, setDraft] = useState(null);
|
|
2285
|
-
const swatchRef = useRef(null);
|
|
2286
|
-
const onCommit = props.onCommit;
|
|
2287
|
-
useEffect(() => {
|
|
2288
|
-
const swatch = swatchRef.current;
|
|
2289
|
-
if (!swatch) return;
|
|
2290
|
-
const commit = () => {
|
|
2291
|
-
setDraft(null);
|
|
2292
|
-
onCommit(swatch.value);
|
|
2293
|
-
};
|
|
2294
|
-
swatch.addEventListener("change", commit);
|
|
2295
|
-
return () => swatch.removeEventListener("change", commit);
|
|
2296
|
-
}, [onCommit]);
|
|
2297
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2298
|
-
className: "flex items-center gap-2",
|
|
2299
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
2300
|
-
ref: swatchRef,
|
|
2301
|
-
type: "color",
|
|
2302
|
-
"aria-label": "Pick a colour",
|
|
2303
|
-
className: "h-9 w-10 shrink-0 cursor-pointer rounded-md border border-solid border-foreground/15 bg-card p-1",
|
|
2304
|
-
value: draft ?? (HEX.test(text) ? text : "#000000"),
|
|
2305
|
-
onChange: (event) => setDraft(event.target.value)
|
|
2306
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
2307
|
-
id: props.id,
|
|
2308
|
-
className: `${textInputClass} font-mono text-xs ${props.invalid ? invalidClass : ""}`,
|
|
2309
|
-
defaultValue: text,
|
|
2310
|
-
placeholder: "#1d63d6 or {{steps.…}}",
|
|
2311
|
-
spellCheck: false,
|
|
2312
|
-
onFocus: props.onFocus,
|
|
2313
|
-
onBlur: (event) => {
|
|
2314
|
-
const raw = event.target.value.trim();
|
|
2315
|
-
props.onCommit(raw === "" ? void 0 : raw);
|
|
2316
|
-
}
|
|
2317
|
-
}, text)]
|
|
2318
|
-
});
|
|
2319
|
-
}
|
|
2320
|
-
function richTextMode(format) {
|
|
2321
|
-
if (format === "html") return "html";
|
|
2322
|
-
if (format === "markdown" || format === "md") return "markdown";
|
|
2323
|
-
return "plain";
|
|
2324
|
-
}
|
|
2325
|
-
//#endregion
|
|
2326
|
-
//#region editors/workflow-editor/ui/prop-layout.tsx
|
|
2327
|
-
const PLACED = /* @__PURE__ */ new Set([
|
|
2328
|
-
"section",
|
|
2329
|
-
"tabs",
|
|
2330
|
-
"builder",
|
|
2331
|
-
"footer"
|
|
2332
|
-
]);
|
|
2333
|
-
function chipText(value) {
|
|
2334
|
-
if (typeof value === "string") return value;
|
|
2335
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
2336
|
-
if (Array.isArray(value)) return value.map(chipText).join(", ");
|
|
2337
|
-
return "set";
|
|
2338
|
-
}
|
|
2339
|
-
/** Consecutive `width: 'half'` fields share a row, two at a time. */
|
|
2340
|
-
function Rows(props) {
|
|
2341
|
-
const rows = [];
|
|
2342
|
-
let pending = null;
|
|
2343
|
-
const flush = () => {
|
|
2344
|
-
if (pending) rows.push(/* @__PURE__ */ jsx(Fragment, { children: pending.node }, pending.prop.name));
|
|
2345
|
-
pending = null;
|
|
2346
|
-
};
|
|
2347
|
-
for (const item of props.items) {
|
|
2348
|
-
if (item.prop.width !== "half") {
|
|
2349
|
-
flush();
|
|
2350
|
-
rows.push(/* @__PURE__ */ jsx(Fragment, { children: item.node }, item.prop.name));
|
|
2351
|
-
continue;
|
|
2352
|
-
}
|
|
2353
|
-
if (!pending) {
|
|
2354
|
-
pending = item;
|
|
2355
|
-
continue;
|
|
2356
|
-
}
|
|
2357
|
-
const first = pending;
|
|
2358
|
-
pending = null;
|
|
2359
|
-
rows.push(/* @__PURE__ */ jsxs("div", {
|
|
2360
|
-
className: "grid grid-cols-1 gap-4 min-[420px]:grid-cols-2",
|
|
2361
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2362
|
-
className: "min-w-0",
|
|
2363
|
-
children: first.node
|
|
2364
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
2365
|
-
className: "min-w-0",
|
|
2366
|
-
children: item.node
|
|
2367
|
-
})]
|
|
2368
|
-
}, `${first.prop.name}+${item.prop.name}`));
|
|
2369
|
-
}
|
|
2370
|
-
flush();
|
|
2371
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children: rows });
|
|
2372
|
-
}
|
|
2373
|
-
function RevealCard(props) {
|
|
2374
|
-
const open = props.layout.values[props.checkbox.name] === true;
|
|
2375
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2376
|
-
className: "flex flex-col gap-4",
|
|
2377
|
-
children: [props.layout.renderField(props.checkbox), open && props.revealed.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
2378
|
-
className: "flex flex-col gap-4 border-l-2 border-solid border-foreground/10 pl-3",
|
|
2379
|
-
children: /* @__PURE__ */ jsx(Rows, { items: props.revealed.map((prop) => ({
|
|
2380
|
-
prop,
|
|
2381
|
-
node: props.layout.renderField(prop)
|
|
2382
|
-
})) })
|
|
2383
|
-
}) : null]
|
|
2384
|
-
});
|
|
2385
|
-
}
|
|
2386
|
-
function FieldList(props) {
|
|
2387
|
-
const byName = new Map(props.members.map((prop) => [prop.name, prop]));
|
|
2388
|
-
const revealedBy = /* @__PURE__ */ new Map();
|
|
2389
|
-
for (const prop of props.members) for (const name of prop.reveals ?? []) if (byName.has(name)) revealedBy.set(name, prop);
|
|
2390
|
-
const items = props.members.filter((prop) => !revealedBy.has(prop.name)).map((prop) => {
|
|
2391
|
-
const revealed = (prop.reveals ?? []).map((name) => byName.get(name)).filter((entry) => entry !== void 0);
|
|
2392
|
-
return {
|
|
2393
|
-
prop,
|
|
2394
|
-
node: revealed.length > 0 ? /* @__PURE__ */ jsx(RevealCard, {
|
|
2395
|
-
checkbox: prop,
|
|
2396
|
-
revealed,
|
|
2397
|
-
layout: props.layout
|
|
2398
|
-
}) : props.layout.renderField(prop)
|
|
2399
|
-
};
|
|
2400
|
-
});
|
|
2401
|
-
return /* @__PURE__ */ jsx(Rows, { items });
|
|
2402
|
-
}
|
|
2403
|
-
function GroupHeading(props) {
|
|
2404
|
-
const { group } = props;
|
|
2405
|
-
if (!group.label && !group.description) return null;
|
|
2406
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2407
|
-
className: "flex flex-col gap-0.5",
|
|
2408
|
-
children: [group.label ? /* @__PURE__ */ jsxs("span", {
|
|
2409
|
-
className: "flex items-center gap-1.5 text-[13px] font-semibold text-foreground",
|
|
2410
|
-
children: [isIconName(group.icon) ? /* @__PURE__ */ jsx(Icon, {
|
|
2411
|
-
name: group.icon,
|
|
2412
|
-
className: "h-3.5 w-3.5 text-muted-foreground"
|
|
2413
|
-
}) : null, group.label]
|
|
2414
|
-
}) : null, group.description ? /* @__PURE__ */ jsx("span", {
|
|
2415
|
-
className: "text-xs text-muted-foreground",
|
|
2416
|
-
children: group.description
|
|
2417
|
-
}) : null]
|
|
2418
|
-
});
|
|
2419
|
-
}
|
|
2420
|
-
function Section$1(props) {
|
|
2421
|
-
return /* @__PURE__ */ jsxs("section", {
|
|
2422
|
-
"aria-label": props.group.label,
|
|
2423
|
-
className: "flex flex-col gap-4 rounded-lg border border-solid border-foreground/10 p-4",
|
|
2424
|
-
children: [/* @__PURE__ */ jsx(GroupHeading, { group: props.group }), /* @__PURE__ */ jsx(FieldList, {
|
|
2425
|
-
members: props.members,
|
|
2426
|
-
layout: props.layout
|
|
2427
|
-
})]
|
|
2428
|
-
});
|
|
2429
|
-
}
|
|
2430
|
-
function TabbedGroup(props) {
|
|
2431
|
-
const [active, setActive] = useState(props.members[0]?.name ?? "");
|
|
2432
|
-
const current = props.members.find((prop) => prop.name === active) ?? props.members[0];
|
|
2433
|
-
if (!current) return null;
|
|
2434
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2435
|
-
className: "flex flex-col gap-3",
|
|
2436
|
-
children: [
|
|
2437
|
-
/* @__PURE__ */ jsx(GroupHeading, { group: props.group }),
|
|
2438
|
-
/* @__PURE__ */ jsx("div", {
|
|
2439
|
-
className: "border-b border-solid border-foreground/10",
|
|
2440
|
-
children: /* @__PURE__ */ jsx(Tabs, {
|
|
2441
|
-
value: current.name,
|
|
2442
|
-
onChange: setActive,
|
|
2443
|
-
tabs: props.members.map((prop) => ({
|
|
2444
|
-
value: prop.name,
|
|
2445
|
-
label: prop.displayName,
|
|
2446
|
-
badge: isEmptyValue(props.layout.values[prop.name]) ? void 0 : /* @__PURE__ */ jsx("span", {
|
|
2447
|
-
"aria-label": "has a value",
|
|
2448
|
-
className: "h-1.5 w-1.5 rounded-full bg-wf-run"
|
|
2449
|
-
})
|
|
2450
|
-
}))
|
|
2451
|
-
})
|
|
2452
|
-
}),
|
|
2453
|
-
props.layout.renderField(current)
|
|
2454
|
-
]
|
|
2455
|
-
});
|
|
2456
|
-
}
|
|
2457
|
-
function BuilderGroups(props) {
|
|
2458
|
-
const members = props.groups.flatMap((group) => group.props.map((name) => props.byName.get(name)).filter((prop) => prop !== void 0));
|
|
2459
|
-
const [added, setAdded] = useState([]);
|
|
2460
|
-
const inUse = members.filter((prop) => prop.required || added.includes(prop.name) || !isEmptyValue(props.layout.values[prop.name]));
|
|
2461
|
-
const available = members.filter((prop) => !inUse.includes(prop));
|
|
2462
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2463
|
-
className: "flex flex-col gap-3",
|
|
2464
|
-
children: [
|
|
2465
|
-
props.groups.map((group) => /* @__PURE__ */ jsx(GroupHeading, { group }, group.key)),
|
|
2466
|
-
inUse.map((prop) => /* @__PURE__ */ jsxs("div", {
|
|
2467
|
-
className: "flex items-start gap-1",
|
|
2468
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2469
|
-
className: "min-w-0 flex-1",
|
|
2470
|
-
children: props.layout.renderField(prop)
|
|
2471
|
-
}), prop.required ? null : /* @__PURE__ */ jsx(IconButton, {
|
|
2472
|
-
icon: "close",
|
|
2473
|
-
label: `Remove ${prop.displayName}`,
|
|
2474
|
-
className: "mt-7",
|
|
2475
|
-
onClick: () => {
|
|
2476
|
-
setAdded((names) => names.filter((name) => name !== prop.name));
|
|
2477
|
-
props.layout.onCommit(prop.name, void 0);
|
|
2478
|
-
}
|
|
2479
|
-
})]
|
|
2480
|
-
}, prop.name)),
|
|
2481
|
-
available.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
2482
|
-
className: "max-w-60",
|
|
2483
|
-
children: /* @__PURE__ */ jsx(Select, {
|
|
2484
|
-
options: available.map((prop) => ({
|
|
2485
|
-
value: prop.name,
|
|
2486
|
-
label: prop.displayName,
|
|
2487
|
-
description: prop.description
|
|
2488
|
-
})),
|
|
2489
|
-
value: "",
|
|
2490
|
-
placeholder: "Add filter",
|
|
2491
|
-
onChange: (name) => {
|
|
2492
|
-
if (name) setAdded((names) => [...names, name]);
|
|
2493
|
-
}
|
|
2494
|
-
})
|
|
2495
|
-
}) : null
|
|
2496
|
-
]
|
|
2497
|
-
});
|
|
2498
|
-
}
|
|
2499
|
-
function Summary(props) {
|
|
2500
|
-
const set = props.members.filter((prop) => !isEmptyValue(props.layout.values[prop.name]));
|
|
2501
|
-
if (set.length === 0) return null;
|
|
2502
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2503
|
-
className: "flex flex-wrap gap-1.5",
|
|
2504
|
-
"aria-label": "Filters in use",
|
|
2505
|
-
children: set.map((prop) => /* @__PURE__ */ jsxs("span", {
|
|
2506
|
-
className: "inline-flex h-6 max-w-full items-center gap-1 rounded-full bg-muted pl-2.5 pr-1 text-xs text-foreground",
|
|
2507
|
-
children: [/* @__PURE__ */ jsxs("span", {
|
|
2508
|
-
className: "truncate",
|
|
2509
|
-
children: [
|
|
2510
|
-
prop.displayName,
|
|
2511
|
-
": ",
|
|
2512
|
-
chipText(props.layout.values[prop.name])
|
|
2513
|
-
]
|
|
2514
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
2515
|
-
type: "button",
|
|
2516
|
-
"aria-label": `Clear ${prop.displayName}`,
|
|
2517
|
-
className: "flex h-4 w-4 items-center justify-center rounded-full text-muted-foreground hover:bg-foreground/10 hover:text-foreground",
|
|
2518
|
-
onClick: () => props.layout.onCommit(prop.name, void 0),
|
|
2519
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
2520
|
-
name: "close",
|
|
2521
|
-
className: "h-3 w-3"
|
|
2522
|
-
})
|
|
2523
|
-
})]
|
|
2524
|
-
}, prop.name))
|
|
2525
|
-
});
|
|
2526
|
-
}
|
|
2527
|
-
function PropLayout(props) {
|
|
2528
|
-
const groups = (props.groups ?? []).filter((group) => PLACED.has(group.display) || group.display === "summary");
|
|
2529
|
-
const byName = new Map(props.props.map((prop) => [prop.name, prop]));
|
|
2530
|
-
const groupOf = /* @__PURE__ */ new Map();
|
|
2531
|
-
for (const group of groups) {
|
|
2532
|
-
if (!PLACED.has(group.display)) continue;
|
|
2533
|
-
for (const name of group.props) if (byName.has(name) && !groupOf.has(name)) groupOf.set(name, group);
|
|
2534
|
-
}
|
|
2535
|
-
const membersOf = (group) => group.props.map((name) => byName.get(name)).filter((prop) => prop !== void 0);
|
|
2536
|
-
const builderGroups = groups.filter((group) => group.display === "builder");
|
|
2537
|
-
const summaries = groups.filter((group) => group.display === "summary");
|
|
2538
|
-
const sectionMembers = groups.filter((group) => group.display === "section").flatMap(membersOf);
|
|
2539
|
-
const blocks = [];
|
|
2540
|
-
let loose = [];
|
|
2541
|
-
const flushLoose = () => {
|
|
2542
|
-
if (loose.length === 0) return;
|
|
2543
|
-
blocks.push(/* @__PURE__ */ jsx(FieldList, {
|
|
2544
|
-
members: loose,
|
|
2545
|
-
layout: props
|
|
2546
|
-
}, `loose:${loose[0].name}`));
|
|
2547
|
-
loose = [];
|
|
2548
|
-
};
|
|
2549
|
-
const summarised = summaries.length > 0 && sectionMembers.length > 0;
|
|
2550
|
-
const placed = /* @__PURE__ */ new Set();
|
|
2551
|
-
for (const prop of props.props) {
|
|
2552
|
-
const group = groupOf.get(prop.name);
|
|
2553
|
-
if (!group) {
|
|
2554
|
-
loose.push(prop);
|
|
2555
|
-
continue;
|
|
2556
|
-
}
|
|
2557
|
-
const key = group.display === "builder" ? "builder" : group.key;
|
|
2558
|
-
if (placed.has(key)) continue;
|
|
2559
|
-
placed.add(key);
|
|
2560
|
-
flushLoose();
|
|
2561
|
-
if (group.display === "builder") blocks.push(/* @__PURE__ */ jsx(BuilderGroups, {
|
|
2562
|
-
groups: builderGroups,
|
|
2563
|
-
byName,
|
|
2564
|
-
layout: props
|
|
2565
|
-
}, "builder"));
|
|
2566
|
-
else if (group.display === "tabs") blocks.push(/* @__PURE__ */ jsx(TabbedGroup, {
|
|
2567
|
-
group,
|
|
2568
|
-
members: membersOf(group),
|
|
2569
|
-
layout: props
|
|
2570
|
-
}, group.key));
|
|
2571
|
-
else if (group.display === "footer") blocks.push(/* @__PURE__ */ jsxs("div", {
|
|
2572
|
-
className: "flex flex-col gap-4 border-t border-solid border-foreground/10 pt-4",
|
|
2573
|
-
children: [/* @__PURE__ */ jsx(GroupHeading, { group }), /* @__PURE__ */ jsx(FieldList, {
|
|
2574
|
-
members: membersOf(group),
|
|
2575
|
-
layout: props
|
|
2576
|
-
})]
|
|
2577
|
-
}, group.key));
|
|
2578
|
-
else {
|
|
2579
|
-
if (summarised && !placed.has("summary")) {
|
|
2580
|
-
placed.add("summary");
|
|
2581
|
-
blocks.push(/* @__PURE__ */ jsx(Summary, {
|
|
2582
|
-
members: sectionMembers,
|
|
2583
|
-
layout: props
|
|
2584
|
-
}, "summary"));
|
|
2585
|
-
}
|
|
2586
|
-
blocks.push(/* @__PURE__ */ jsx(Section$1, {
|
|
2587
|
-
group,
|
|
2588
|
-
members: membersOf(group),
|
|
2589
|
-
layout: props
|
|
2590
|
-
}, group.key));
|
|
2591
|
-
}
|
|
2592
|
-
}
|
|
2593
|
-
flushLoose();
|
|
2594
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children: blocks });
|
|
2595
|
-
}
|
|
2596
|
-
//#endregion
|
|
2597
|
-
//#region editors/workflow-editor/ui/PropertyForm.tsx
|
|
2598
|
-
function insertAtCursor$1(element, text) {
|
|
2599
|
-
const start = element.selectionStart ?? element.value.length;
|
|
2600
|
-
const end = element.selectionEnd ?? start;
|
|
2601
|
-
element.value = element.value.slice(0, start) + text + element.value.slice(end);
|
|
2602
|
-
return element.value;
|
|
2603
|
-
}
|
|
2604
|
-
const WHOLE_EXPRESSION = /^\{\{\s*[^{}]+?\s*\}\}$/;
|
|
2605
|
-
const DECIMAL = /^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
|
|
2606
|
-
function parseDecimal(raw) {
|
|
2607
|
-
const trimmed = raw.trim();
|
|
2608
|
-
return DECIMAL.test(trimmed) ? Number(trimmed) : void 0;
|
|
2609
|
-
}
|
|
2610
|
-
function stringifyValue$1(value) {
|
|
2611
|
-
if (value === void 0 || value === null) return "";
|
|
2612
|
-
if (typeof value === "string") return value;
|
|
2613
|
-
try {
|
|
2614
|
-
return JSON.stringify(value, null, 2);
|
|
2615
|
-
} catch {
|
|
2616
|
-
return String(value);
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
function parseDropdownResult(result) {
|
|
2620
|
-
const record = result;
|
|
2621
|
-
if (!record || !Array.isArray(record.options)) throw new Error("Unexpected options result");
|
|
2622
|
-
return {
|
|
2623
|
-
options: record.options.map((option) => ({
|
|
2624
|
-
label: stringifyValue$1(option.label ?? option.value),
|
|
2625
|
-
value: option.value,
|
|
2626
|
-
...typeof option.description === "string" && option.description ? { description: option.description } : {},
|
|
2627
|
-
...typeof option.icon === "string" ? { icon: option.icon } : {}
|
|
2628
|
-
})),
|
|
2629
|
-
placeholder: record.placeholder,
|
|
2630
|
-
disabled: record.disabled
|
|
2631
|
-
};
|
|
2632
|
-
}
|
|
2633
|
-
const RELOAD_DEBOUNCE_MS = 400;
|
|
2634
|
-
const PieceMarkdown = lazy(() => import("./PieceMarkdown-DwpCBISY.mjs"));
|
|
2635
|
-
const NO_ENDPOINT = "[no endpoint yet — see Endpoint URL above]";
|
|
2636
|
-
function fillPiecePlaceholders(text, values) {
|
|
2637
|
-
return text.replace(/\{\{\s*webhookUrl\s*\}\}/g, values.webhookUrl ?? NO_ENDPOINT).replace(/\{\{\s*webhookTimeoutSeconds\s*\}\}/g, values.webhookTimeoutSeconds === void 0 ? "{{webhookTimeoutSeconds}}" : String(values.webhookTimeoutSeconds));
|
|
2638
|
-
}
|
|
2639
|
-
function AvailableSoon(props) {
|
|
2640
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
2641
|
-
className: "inline-flex items-center gap-1 rounded-full bg-wf-warn/10 px-2 py-0.5 text-[11px] font-medium normal-case tracking-normal text-wf-warn",
|
|
2642
|
-
title: "Not supported by the runtime yet",
|
|
2643
|
-
children: ["Available soon", props.children ? /* @__PURE__ */ jsxs("span", { children: [": ", props.children] }) : null]
|
|
2644
|
-
});
|
|
2645
|
-
}
|
|
2646
|
-
function FieldShell(props) {
|
|
2647
|
-
const { prop } = props;
|
|
2648
|
-
const LabelTag = props.htmlFor ? "label" : "span";
|
|
2649
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2650
|
-
className: "group/field",
|
|
2651
|
-
children: [
|
|
2652
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2653
|
-
className: "mb-1.5 flex min-h-6 items-center justify-between gap-2",
|
|
2654
|
-
children: [/* @__PURE__ */ jsxs(LabelTag, {
|
|
2655
|
-
htmlFor: props.htmlFor,
|
|
2656
|
-
className: "flex min-w-0 items-baseline gap-1.5 text-[13px] font-medium text-foreground",
|
|
2657
|
-
children: [
|
|
2658
|
-
optionIcon(prop.icon),
|
|
2659
|
-
/* @__PURE__ */ jsx("span", {
|
|
2660
|
-
className: "truncate",
|
|
2661
|
-
children: prop.displayName
|
|
2662
|
-
}),
|
|
2663
|
-
!prop.required ? /* @__PURE__ */ jsx("span", {
|
|
2664
|
-
className: "shrink-0 text-xs font-normal text-muted-foreground",
|
|
2665
|
-
children: "Optional"
|
|
2666
|
-
}) : null,
|
|
2667
|
-
props.invalid ? /* @__PURE__ */ jsx("span", {
|
|
2668
|
-
className: "shrink-0 text-xs font-normal text-wf-warn",
|
|
2669
|
-
children: "Needs a value"
|
|
2670
|
-
}) : null
|
|
2671
|
-
]
|
|
2672
|
-
}), props.picker ? /* @__PURE__ */ jsx("span", {
|
|
2673
|
-
className: "flex shrink-0 items-center gap-0.5",
|
|
2674
|
-
children: props.picker
|
|
2675
|
-
}) : null]
|
|
2676
|
-
}),
|
|
2677
|
-
props.children,
|
|
2678
|
-
/* @__PURE__ */ jsx(FieldError, { children: props.error }),
|
|
2679
|
-
/* @__PURE__ */ jsx(Hint, { text: prop.description })
|
|
2680
|
-
]
|
|
2681
|
-
});
|
|
2682
|
-
}
|
|
2683
|
-
function OptionList(props) {
|
|
2684
|
-
const keyOf = (value) => stringifyValue$1(value);
|
|
2685
|
-
const byKey = new Map(props.options.map((option) => [keyOf(option.value), option]));
|
|
2686
|
-
return /* @__PURE__ */ jsx(Select, {
|
|
2687
|
-
id: props.id,
|
|
2688
|
-
multiple: true,
|
|
2689
|
-
options: props.options.map((option) => ({
|
|
2690
|
-
value: keyOf(option.value),
|
|
2691
|
-
label: option.label
|
|
2692
|
-
})),
|
|
2693
|
-
value: props.selected.map(keyOf),
|
|
2694
|
-
onChange: (keys) => props.onChange(keys.map((key) => byKey.get(key)?.value ?? key)),
|
|
2695
|
-
invalid: props.invalid,
|
|
2696
|
-
loading: props.loading,
|
|
2697
|
-
onRefresh: props.onRefresh,
|
|
2698
|
-
placeholder: props.placeholder ?? "Choose any"
|
|
2699
|
-
});
|
|
2700
|
-
}
|
|
2701
|
-
function OptionSelect(props) {
|
|
2702
|
-
const keyOf = (value) => stringifyValue$1(value);
|
|
2703
|
-
const byKey = new Map(props.options.map((option) => [keyOf(option.value), option]));
|
|
2704
|
-
return /* @__PURE__ */ jsx(Select, {
|
|
2705
|
-
id: props.id,
|
|
2706
|
-
options: props.options.map((option) => ({
|
|
2707
|
-
value: keyOf(option.value),
|
|
2708
|
-
label: option.label,
|
|
2709
|
-
description: option.description,
|
|
2710
|
-
icon: optionIcon(option.icon)
|
|
2711
|
-
})),
|
|
2712
|
-
value: keyOf(props.value),
|
|
2713
|
-
onChange: (key) => props.onChange(key === "" ? void 0 : byKey.get(key)?.value ?? key),
|
|
2714
|
-
invalid: props.invalid,
|
|
2715
|
-
placeholder: props.placeholder,
|
|
2716
|
-
loading: props.loading,
|
|
2717
|
-
disabled: props.disabled,
|
|
2718
|
-
onRefresh: props.onRefresh,
|
|
2719
|
-
clearable: props.clearable,
|
|
2720
|
-
emptyText: props.emptyText,
|
|
2721
|
-
searchable: props.searchable,
|
|
2722
|
-
actions: props.actions,
|
|
2723
|
-
onQueryChange: props.onQueryChange
|
|
2724
|
-
});
|
|
2725
|
-
}
|
|
2726
|
-
const SUMMARY_CHARS = 60;
|
|
2727
|
-
function itemSummary(fields, row) {
|
|
2728
|
-
const parts = [];
|
|
2729
|
-
for (const field of fields) {
|
|
2730
|
-
const value = row[field.name];
|
|
2731
|
-
if (value === true) {
|
|
2732
|
-
parts.push(field.displayName.toLowerCase());
|
|
2733
|
-
continue;
|
|
2734
|
-
}
|
|
2735
|
-
if (value === void 0 || value === null || value === false) continue;
|
|
2736
|
-
const option = field.staticOptions?.find((o) => o.value === value);
|
|
2737
|
-
const text = option ? option.label : stringifyValue$1(value).trim();
|
|
2738
|
-
if (!text) continue;
|
|
2739
|
-
parts.push(text.length > SUMMARY_CHARS ? `${text.slice(0, SUMMARY_CHARS)}…` : text);
|
|
2740
|
-
}
|
|
2741
|
-
return parts.join(" · ");
|
|
2742
|
-
}
|
|
2743
|
-
function ArrayRows(props) {
|
|
2744
|
-
const fields = props.prop.properties ?? [];
|
|
2745
|
-
const rows = Array.isArray(props.value) ? props.value.map((item) => item !== null && typeof item === "object" ? item : {}) : [];
|
|
2746
|
-
const [open, setOpen] = useState(() => /* @__PURE__ */ new Set());
|
|
2747
|
-
const toggle = (index) => setOpen((current) => {
|
|
2748
|
-
const next = new Set(current);
|
|
2749
|
-
if (!next.delete(index)) next.add(index);
|
|
2750
|
-
return next;
|
|
2751
|
-
});
|
|
2752
|
-
const update = (next) => props.onCommit(next.length > 0 ? next : void 0);
|
|
2753
|
-
const remove = (index) => {
|
|
2754
|
-
update(rows.filter((_, i) => i !== index));
|
|
2755
|
-
setOpen((current) => new Set([...current].filter((i) => i !== index).map((i) => i > index ? i - 1 : i)));
|
|
2756
|
-
};
|
|
2757
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2758
|
-
className: `flex flex-col gap-1.5 ${props.invalid ? "rounded-md ring-1 ring-wf-warn/50" : ""}`,
|
|
2759
|
-
children: [rows.map((row, index) => {
|
|
2760
|
-
const expanded = open.has(index);
|
|
2761
|
-
const summary = itemSummary(fields, row);
|
|
2762
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2763
|
-
className: "rounded-md border border-solid border-foreground/10 bg-muted/40",
|
|
2764
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
2765
|
-
className: "flex items-center gap-1 py-1 pl-1 pr-1",
|
|
2766
|
-
children: [/* @__PURE__ */ jsxs("button", {
|
|
2767
|
-
type: "button",
|
|
2768
|
-
"aria-expanded": expanded,
|
|
2769
|
-
onClick: () => toggle(index),
|
|
2770
|
-
className: "flex min-w-0 flex-1 items-center gap-1.5 rounded px-1 py-0.5 text-left text-[13px] hover:bg-foreground/5",
|
|
2771
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
2772
|
-
name: expanded ? "chevronDown" : "chevron",
|
|
2773
|
-
className: "h-3.5 w-3.5 shrink-0 text-muted-foreground"
|
|
2774
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
2775
|
-
className: `truncate ${summary ? "text-foreground" : "text-muted-foreground"}`,
|
|
2776
|
-
children: summary || `Item ${index + 1}`
|
|
2777
|
-
})]
|
|
2778
|
-
}), /* @__PURE__ */ jsx(IconButton, {
|
|
2779
|
-
icon: "trash",
|
|
2780
|
-
label: `Remove item ${index + 1}`,
|
|
2781
|
-
onClick: () => remove(index)
|
|
2782
|
-
})]
|
|
2783
|
-
}), expanded ? /* @__PURE__ */ jsx("div", {
|
|
2784
|
-
className: "border-t border-solid border-foreground/10 px-3 pb-3 pt-2",
|
|
2785
|
-
children: /* @__PURE__ */ jsx(PropertyForm, {
|
|
2786
|
-
props: fields,
|
|
2787
|
-
value: row,
|
|
2788
|
-
onChange: (next) => update(rows.map((entry, i) => i === index ? next : entry)),
|
|
2789
|
-
scopeStepId: props.scopeStepId,
|
|
2790
|
-
nested: true
|
|
2791
|
-
})
|
|
2792
|
-
}) : null]
|
|
2793
|
-
}, index);
|
|
2794
|
-
}), /* @__PURE__ */ jsxs(Button, {
|
|
2795
|
-
size: "sm",
|
|
2796
|
-
className: "self-start",
|
|
2797
|
-
onClick: () => {
|
|
2798
|
-
update([...rows, withPropDefaults(fields, {})]);
|
|
2799
|
-
setOpen((current) => new Set(current).add(rows.length));
|
|
2800
|
-
},
|
|
2801
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
2802
|
-
name: "plus",
|
|
2803
|
-
className: "h-3.5 w-3.5"
|
|
2804
|
-
}), "Add item"]
|
|
2805
|
-
})]
|
|
2806
|
-
});
|
|
2807
|
-
}
|
|
2808
|
-
function rowsOf(value) {
|
|
2809
|
-
return Object.entries(value).map(([key, entry]) => ({
|
|
2810
|
-
key,
|
|
2811
|
-
value: stringifyValue$1(entry)
|
|
2812
|
-
}));
|
|
2813
|
-
}
|
|
2814
|
-
function recordOf(rows) {
|
|
2815
|
-
const record = {};
|
|
2816
|
-
for (const row of rows) if (row.key.trim() !== "") record[row.key.trim()] = row.value;
|
|
2817
|
-
return record;
|
|
2818
|
-
}
|
|
2819
|
-
function ObjectRows(props) {
|
|
2820
|
-
const [rows, setRows] = useState(() => rowsOf(props.value));
|
|
2821
|
-
const valueKey = keyOf(props.value);
|
|
2822
|
-
const [seen, setSeen] = useState(valueKey);
|
|
2823
|
-
if (seen !== valueKey) {
|
|
2824
|
-
setSeen(valueKey);
|
|
2825
|
-
if (keyOf(recordOf(rows)) !== valueKey) setRows(rowsOf(props.value));
|
|
2826
|
-
}
|
|
2827
|
-
const commit = (next) => {
|
|
2828
|
-
setRows(next);
|
|
2829
|
-
const record = recordOf(next);
|
|
2830
|
-
props.onCommit(Object.keys(record).length > 0 ? record : void 0);
|
|
2831
|
-
};
|
|
2832
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2833
|
-
className: `flex flex-col gap-1.5 ${props.invalid ? "rounded-md ring-1 ring-wf-warn/50" : ""}`,
|
|
2834
|
-
children: [rows.map((row, index) => /* @__PURE__ */ jsxs("div", {
|
|
2835
|
-
className: "flex items-center gap-1",
|
|
2836
|
-
children: [
|
|
2837
|
-
/* @__PURE__ */ jsx("input", {
|
|
2838
|
-
className: `${textInputClass} font-mono text-xs`,
|
|
2839
|
-
placeholder: "Key",
|
|
2840
|
-
value: row.key,
|
|
2841
|
-
onChange: (event) => setRows(rows.map((entry, i) => i === index ? {
|
|
2842
|
-
...entry,
|
|
2843
|
-
key: event.target.value
|
|
2844
|
-
} : entry)),
|
|
2845
|
-
onBlur: () => commit(rows)
|
|
2846
|
-
}),
|
|
2847
|
-
/* @__PURE__ */ jsx("input", {
|
|
2848
|
-
className: `${textInputClass} font-mono text-xs`,
|
|
2849
|
-
placeholder: "Value",
|
|
2850
|
-
value: row.value,
|
|
2851
|
-
onChange: (event) => setRows(rows.map((entry, i) => i === index ? {
|
|
2852
|
-
...entry,
|
|
2853
|
-
value: event.target.value
|
|
2854
|
-
} : entry)),
|
|
2855
|
-
onBlur: () => commit(rows)
|
|
2856
|
-
}),
|
|
2857
|
-
/* @__PURE__ */ jsx(IconButton, {
|
|
2858
|
-
icon: "close",
|
|
2859
|
-
label: "Remove entry",
|
|
2860
|
-
onClick: () => commit(rows.filter((_, i) => i !== index))
|
|
2861
|
-
})
|
|
2862
|
-
]
|
|
2863
|
-
}, index)), /* @__PURE__ */ jsxs(Button, {
|
|
2864
|
-
size: "sm",
|
|
2865
|
-
className: "self-start",
|
|
2866
|
-
onClick: () => setRows([...rows, {
|
|
2867
|
-
key: "",
|
|
2868
|
-
value: ""
|
|
2869
|
-
}]),
|
|
2870
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
2871
|
-
name: "plus",
|
|
2872
|
-
className: "h-3.5 w-3.5"
|
|
2873
|
-
}), "Add entry"]
|
|
2874
|
-
})]
|
|
2875
|
-
});
|
|
2876
|
-
}
|
|
2877
|
-
function isoToLocalInput(value) {
|
|
2878
|
-
if (typeof value !== "string" || value === "") return "";
|
|
2879
|
-
const date = new Date(value);
|
|
2880
|
-
if (Number.isNaN(date.getTime())) return "";
|
|
2881
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
2882
|
-
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
2883
|
-
}
|
|
2884
|
-
function localInputToIso(value) {
|
|
2885
|
-
if (value === "") return void 0;
|
|
2886
|
-
const date = new Date(value);
|
|
2887
|
-
return Number.isNaN(date.getTime()) ? value : date.toISOString();
|
|
2888
|
-
}
|
|
2889
|
-
function isDropdownType(type) {
|
|
2890
|
-
return type === "DROPDOWN" || type === "MULTI_SELECT_DROPDOWN";
|
|
2891
|
-
}
|
|
2892
|
-
const SEARCH_DEBOUNCE_MS = 300;
|
|
2893
|
-
const FLIPS_TO_TEXT = /* @__PURE__ */ new Set([
|
|
2894
|
-
"DATE_TIME",
|
|
2895
|
-
"OBJECT",
|
|
2896
|
-
"DROPDOWN",
|
|
2897
|
-
"CHECKBOX",
|
|
2898
|
-
"NUMBER"
|
|
2899
|
-
]);
|
|
2900
|
-
const TEXT_MODE_TYPES = /* @__PURE__ */ new Set([
|
|
2901
|
-
"SHORT_TEXT",
|
|
2902
|
-
"LONG_TEXT",
|
|
2903
|
-
"NUMBER",
|
|
2904
|
-
"SECRET_TEXT",
|
|
2905
|
-
"FILE",
|
|
2906
|
-
"JSON",
|
|
2907
|
-
"DATE_TIME",
|
|
2908
|
-
"OBJECT",
|
|
2909
|
-
"DROPDOWN",
|
|
2910
|
-
"CHECKBOX"
|
|
2911
|
-
]);
|
|
2912
|
-
function SecretRefField(props) {
|
|
2913
|
-
const { secrets } = props;
|
|
2914
|
-
const fieldId = useId();
|
|
2915
|
-
const { ref, managed, draft, setDraft, busy, error, stat, commit } = useSecretRef({
|
|
2916
|
-
value: props.value,
|
|
2917
|
-
secrets,
|
|
2918
|
-
label: props.prop.displayName,
|
|
2919
|
-
onCommit: props.onCommit
|
|
2920
|
-
});
|
|
2921
|
-
if (!secrets) return /* @__PURE__ */ jsx(FieldShell, {
|
|
2922
|
-
htmlFor: fieldId,
|
|
2923
|
-
prop: props.prop,
|
|
2924
|
-
invalid: props.invalid,
|
|
2925
|
-
children: /* @__PURE__ */ jsx("p", {
|
|
2926
|
-
className: "text-xs text-muted-foreground",
|
|
2927
|
-
children: "Managed secrets are unavailable in this session."
|
|
2928
|
-
})
|
|
2929
|
-
});
|
|
2930
|
-
return /* @__PURE__ */ jsxs(FieldShell, {
|
|
2931
|
-
htmlFor: fieldId,
|
|
2932
|
-
prop: props.prop,
|
|
2933
|
-
invalid: props.invalid,
|
|
2934
|
-
error,
|
|
2935
|
-
children: [managed ? /* @__PURE__ */ jsxs("p", {
|
|
2936
|
-
className: "mb-1.5 flex items-center gap-1.5 text-xs text-muted-foreground",
|
|
2937
|
-
children: [
|
|
2938
|
-
/* @__PURE__ */ jsx("span", {
|
|
2939
|
-
className: "font-medium text-foreground",
|
|
2940
|
-
children: stat?.label ?? ref
|
|
2941
|
-
}),
|
|
2942
|
-
stat ? /* @__PURE__ */ jsxs("span", { children: ["version ", stat.version] }) : null,
|
|
2943
|
-
stat?.status === "DELETED" ? /* @__PURE__ */ jsx("span", {
|
|
2944
|
-
className: "font-medium text-wf-fail",
|
|
2945
|
-
children: "deleted"
|
|
2946
|
-
}) : null
|
|
2947
|
-
]
|
|
2948
|
-
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
2949
|
-
className: "flex items-center gap-1",
|
|
2950
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
2951
|
-
id: fieldId,
|
|
2952
|
-
className: `${textInputClass} ${props.invalid ? invalidClass : ""}`,
|
|
2953
|
-
type: "password",
|
|
2954
|
-
value: draft,
|
|
2955
|
-
disabled: busy,
|
|
2956
|
-
placeholder: managed ? "Paste a new value to replace it" : "Paste the secret value",
|
|
2957
|
-
autoComplete: "off",
|
|
2958
|
-
spellCheck: false,
|
|
2959
|
-
onChange: (event) => setDraft(event.target.value),
|
|
2960
|
-
onKeyDown: (event) => {
|
|
2961
|
-
if (event.key === "Enter") commit();
|
|
2962
|
-
},
|
|
2963
|
-
onBlur: commit
|
|
2964
|
-
}), ref ? /* @__PURE__ */ jsx(IconButton, {
|
|
2965
|
-
icon: "close",
|
|
2966
|
-
label: "Remove secret",
|
|
2967
|
-
onClick: () => props.onCommit(void 0)
|
|
2968
|
-
}) : null]
|
|
2969
|
-
})]
|
|
2970
|
-
});
|
|
2971
|
-
}
|
|
2972
|
-
function ModeButton(props) {
|
|
2973
|
-
return /* @__PURE__ */ jsx("button", {
|
|
2974
|
-
type: "button",
|
|
2975
|
-
className: "inline-flex h-6 shrink-0 items-center rounded-md px-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground",
|
|
2976
|
-
onClick: props.onClick,
|
|
2977
|
-
children: props.label
|
|
2978
|
-
});
|
|
2979
|
-
}
|
|
2980
|
-
function PropField(props) {
|
|
2981
|
-
const { prop, value } = props;
|
|
2982
|
-
const fieldId = useId();
|
|
2983
|
-
const optionsUnavailable = Boolean(props.nested && prop.hasDynamicResolver && !props.loadOptions);
|
|
2984
|
-
const fieldRef = useRef(null);
|
|
2985
|
-
const invalid = prop.required && prop.type !== "MARKDOWN" && isEmptyValue(value);
|
|
2986
|
-
const [draft, setDraft] = useState(() => stringifyValue$1(value));
|
|
2987
|
-
const [prevValue, setPrevValue] = useState(value);
|
|
2988
|
-
if (value !== prevValue) {
|
|
2989
|
-
setPrevValue(value);
|
|
2990
|
-
setDraft(stringifyValue$1(value));
|
|
2991
|
-
}
|
|
2992
|
-
const [jsonError, setJsonError] = useState(null);
|
|
2993
|
-
const [textMode, setTextMode] = useState(props.mode === "EXPRESSION");
|
|
2994
|
-
const [prevMode, setPrevMode] = useState(props.mode);
|
|
2995
|
-
if (props.mode !== prevMode) {
|
|
2996
|
-
setPrevMode(props.mode);
|
|
2997
|
-
if (props.mode) setTextMode(props.mode === "EXPRESSION");
|
|
2998
|
-
}
|
|
2999
|
-
const onCommit = (next, mode) => props.onCommit(next, mode ?? (textMode ? "EXPRESSION" : "MANUAL"));
|
|
3000
|
-
const toMode = (expression) => {
|
|
3001
|
-
setTextMode(expression);
|
|
3002
|
-
props.onMode?.(expression ? "EXPRESSION" : "MANUAL");
|
|
3003
|
-
};
|
|
3004
|
-
const [numberError, setNumberError] = useState(null);
|
|
3005
|
-
const commitsOnInsert = prop.type !== "JSON";
|
|
3006
|
-
const field = useExpressionField({
|
|
3007
|
-
stepId: props.scopeStepId,
|
|
3008
|
-
label: prop.displayName,
|
|
3009
|
-
insert: (expression) => {
|
|
3010
|
-
if (FLIPS_TO_TEXT.has(prop.type) && !textMode) {
|
|
3011
|
-
setTextMode(true);
|
|
3012
|
-
setDraft(expression);
|
|
3013
|
-
setNumberError(null);
|
|
3014
|
-
onCommit(expression, "EXPRESSION");
|
|
3015
|
-
return;
|
|
3016
|
-
}
|
|
3017
|
-
if (!fieldRef.current) return;
|
|
3018
|
-
const next = insertAtCursor$1(fieldRef.current, expression);
|
|
3019
|
-
setDraft(next);
|
|
3020
|
-
if (commitsOnInsert) onCommit(next);
|
|
3021
|
-
}
|
|
3022
|
-
});
|
|
3023
|
-
const picker = TEXT_MODE_TYPES.has(prop.type) ? /* @__PURE__ */ jsx(ExpressionPickerButton, {
|
|
3024
|
-
active: field.active,
|
|
3025
|
-
onFocusField: field.focus
|
|
3026
|
-
}) : void 0;
|
|
3027
|
-
const dynamicLoad = props.loadOptions && prop.hasDynamicResolver && !props.optionsBlocked ? () => props.loadOptions(prop.name) : void 0;
|
|
3028
|
-
const isDropdown = prop.type === "DROPDOWN" || prop.type === "MULTI_SELECT_DROPDOWN";
|
|
3029
|
-
const dropdown = useResolvedProp({
|
|
3030
|
-
kind: "options",
|
|
3031
|
-
input: props.resolverInput,
|
|
3032
|
-
load: isDropdown ? dynamicLoad : void 0,
|
|
3033
|
-
parse: parseDropdownResult,
|
|
3034
|
-
debounceMs: RELOAD_DEBOUNCE_MS
|
|
3035
|
-
});
|
|
3036
|
-
const dynamic = useResolvedProp({
|
|
3037
|
-
kind: "dynamic",
|
|
3038
|
-
input: props.resolverInput,
|
|
3039
|
-
load: prop.type === "DYNAMIC" ? dynamicLoad : void 0,
|
|
3040
|
-
parse: parsePropList,
|
|
3041
|
-
debounceMs: RELOAD_DEBOUNCE_MS
|
|
3042
|
-
});
|
|
3043
|
-
const dynamicFields = dynamic.state.kind === "ready" ? dynamic.state.result : null;
|
|
3044
|
-
useEffect(() => {
|
|
3045
|
-
if (value !== void 0 || !dynamicFields) return;
|
|
3046
|
-
if (lacksDefaults(dynamicFields, {})) props.onCommit(withPropDefaults(dynamicFields, {}), "MANUAL");
|
|
3047
|
-
}, [dynamicFields]);
|
|
3048
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
3049
|
-
const [picked, setPicked] = useState(null);
|
|
3050
|
-
const loadOptions = props.loadOptions;
|
|
3051
|
-
const searchable = Boolean(prop.refreshOnSearch && loadOptions);
|
|
3052
|
-
const searchResult = useOptionSearch({
|
|
3053
|
-
input: props.resolverInput,
|
|
3054
|
-
query: searchQuery,
|
|
3055
|
-
load: searchable && loadOptions ? (searchValue) => loadOptions(prop.name, searchValue) : void 0,
|
|
3056
|
-
parse: parseDropdownResult,
|
|
3057
|
-
debounceMs: SEARCH_DEBOUNCE_MS
|
|
3058
|
-
});
|
|
3059
|
-
const onSearch = searchable ? setSearchQuery : void 0;
|
|
3060
|
-
const retryButton = (state, reload) => /* @__PURE__ */ jsx(IconButton, {
|
|
3061
|
-
icon: "retry",
|
|
3062
|
-
label: "Reload",
|
|
3063
|
-
disabled: state.kind === "loading",
|
|
3064
|
-
onClick: reload
|
|
3065
|
-
});
|
|
3066
|
-
const blocked = prop.hasDynamicResolver ? props.optionsBlocked : void 0;
|
|
3067
|
-
const loadError = (state) => blocked ?? (state.kind === "error" ? props.explainOptionsError?.(state.message) ?? state.message : null);
|
|
3068
|
-
const textInput = (extra) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
3069
|
-
className: "flex items-center gap-1",
|
|
3070
|
-
children: /* @__PURE__ */ jsx("input", {
|
|
3071
|
-
id: fieldId,
|
|
3072
|
-
ref: fieldRef,
|
|
3073
|
-
type: extra.type ?? "text",
|
|
3074
|
-
className: `${textInputClass} ${extra.mono ? "font-mono text-xs" : ""} ${invalid ? invalidClass : ""}`,
|
|
3075
|
-
defaultValue: stringifyValue$1(value),
|
|
3076
|
-
placeholder: extra.placeholder ?? prop.placeholder,
|
|
3077
|
-
spellCheck: false,
|
|
3078
|
-
onFocus: field.focus,
|
|
3079
|
-
onChange: (event) => setDraft(event.target.value),
|
|
3080
|
-
onBlur: (event) => extra.commit(event.target.value)
|
|
3081
|
-
})
|
|
3082
|
-
}), extra.type === "password" ? null : /* @__PURE__ */ jsx(ExpressionTokenLine, { value: draft })] });
|
|
3083
|
-
switch (prop.type) {
|
|
3084
|
-
case "PH_SECRET_REF": return /* @__PURE__ */ jsx(SecretRefField, {
|
|
3085
|
-
prop,
|
|
3086
|
-
value,
|
|
3087
|
-
onCommit,
|
|
3088
|
-
invalid,
|
|
3089
|
-
secrets: props.secrets
|
|
3090
|
-
});
|
|
3091
|
-
case "MARKDOWN": {
|
|
3092
|
-
const markdown = fillPiecePlaceholders(stringifyValue$1(prop.description ?? prop.defaultValue ?? prop.displayName), { webhookUrl: props.webhookUrl });
|
|
3093
|
-
return /* @__PURE__ */ jsx(MarkdownCallout, {
|
|
3094
|
-
variant: prop.variant,
|
|
3095
|
-
children: /* @__PURE__ */ jsx(Suspense, {
|
|
3096
|
-
fallback: /* @__PURE__ */ jsx("p", {
|
|
3097
|
-
className: "whitespace-pre-wrap text-xs text-muted-foreground",
|
|
3098
|
-
children: markdown
|
|
3099
|
-
}),
|
|
3100
|
-
children: /* @__PURE__ */ jsx(PieceMarkdown, { text: markdown })
|
|
3101
|
-
})
|
|
3102
|
-
});
|
|
3103
|
-
}
|
|
3104
|
-
case "CHECKBOX":
|
|
3105
|
-
if (textMode) return /* @__PURE__ */ jsx(FieldShell, {
|
|
3106
|
-
htmlFor: fieldId,
|
|
3107
|
-
prop,
|
|
3108
|
-
invalid,
|
|
3109
|
-
picker: /* @__PURE__ */ jsxs(Fragment$1, { children: [picker, /* @__PURE__ */ jsx(ModeButton, {
|
|
3110
|
-
label: "Use a switch",
|
|
3111
|
-
onClick: () => {
|
|
3112
|
-
setTextMode(false);
|
|
3113
|
-
onCommit(void 0, "MANUAL");
|
|
3114
|
-
}
|
|
3115
|
-
})] }),
|
|
3116
|
-
children: textInput({
|
|
3117
|
-
mono: true,
|
|
3118
|
-
placeholder: "{{steps.…}} yielding true or false",
|
|
3119
|
-
commit: (raw) => {
|
|
3120
|
-
const trimmed = raw.trim();
|
|
3121
|
-
if (trimmed === "") {
|
|
3122
|
-
setTextMode(false);
|
|
3123
|
-
return onCommit(void 0, "MANUAL");
|
|
3124
|
-
}
|
|
3125
|
-
onCommit(trimmed, "EXPRESSION");
|
|
3126
|
-
}
|
|
3127
|
-
})
|
|
3128
|
-
});
|
|
3129
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3130
|
-
className: "group/field flex items-start gap-1",
|
|
3131
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
3132
|
-
className: "min-w-0 flex-1",
|
|
3133
|
-
children: /* @__PURE__ */ jsx(Switch, {
|
|
3134
|
-
checked: value === true,
|
|
3135
|
-
onChange: (checked) => onCommit(checked, "MANUAL"),
|
|
3136
|
-
label: prop.displayName,
|
|
3137
|
-
description: prop.description
|
|
3138
|
-
})
|
|
3139
|
-
}), picker]
|
|
3140
|
-
});
|
|
3141
|
-
case "NUMBER": {
|
|
3142
|
-
const rangeError = numberRangeError(value, prop.min, prop.max);
|
|
3143
|
-
const commitNumber = (raw) => {
|
|
3144
|
-
const trimmed = raw.trim();
|
|
3145
|
-
if (trimmed === "") {
|
|
3146
|
-
setNumberError(null);
|
|
3147
|
-
if (!textMode) return onCommit(void 0);
|
|
3148
|
-
setTextMode(false);
|
|
3149
|
-
return onCommit(void 0, "MANUAL");
|
|
3150
|
-
}
|
|
3151
|
-
if (textMode || hasExpressions(trimmed)) {
|
|
3152
|
-
setNumberError(null);
|
|
3153
|
-
setTextMode(true);
|
|
3154
|
-
return onCommit(trimmed, "EXPRESSION");
|
|
3155
|
-
}
|
|
3156
|
-
const parsed = parseDecimal(trimmed);
|
|
3157
|
-
if (parsed === void 0) {
|
|
3158
|
-
setNumberError("Not a number");
|
|
3159
|
-
return;
|
|
3160
|
-
}
|
|
3161
|
-
setNumberError(null);
|
|
3162
|
-
onCommit(parsed);
|
|
3163
|
-
};
|
|
3164
|
-
if (prop.display === "stepper" && !textMode) return /* @__PURE__ */ jsx(FieldShell, {
|
|
3165
|
-
htmlFor: fieldId,
|
|
3166
|
-
prop,
|
|
3167
|
-
invalid,
|
|
3168
|
-
picker,
|
|
3169
|
-
error: numberError ?? rangeError,
|
|
3170
|
-
children: /* @__PURE__ */ jsx(NumberStepper, {
|
|
3171
|
-
id: fieldId,
|
|
3172
|
-
value,
|
|
3173
|
-
min: prop.min,
|
|
3174
|
-
max: prop.max,
|
|
3175
|
-
step: prop.step,
|
|
3176
|
-
invalid: invalid || rangeError !== null || numberError !== null,
|
|
3177
|
-
onCommit: (next) => {
|
|
3178
|
-
setNumberError(null);
|
|
3179
|
-
onCommit(next);
|
|
3180
|
-
},
|
|
3181
|
-
onCommitText: commitNumber,
|
|
3182
|
-
onFocus: field.focus
|
|
3183
|
-
})
|
|
3184
|
-
});
|
|
3185
|
-
return /* @__PURE__ */ jsx(FieldShell, {
|
|
3186
|
-
htmlFor: fieldId,
|
|
3187
|
-
prop,
|
|
3188
|
-
invalid,
|
|
3189
|
-
picker,
|
|
3190
|
-
error: numberError ?? (textMode ? null : rangeError),
|
|
3191
|
-
children: textInput({
|
|
3192
|
-
mono: textMode,
|
|
3193
|
-
placeholder: textMode ? "{{expression}} yielding a number" : prop.placeholder ?? numberRangeText(prop.min, prop.max) ?? void 0,
|
|
3194
|
-
commit: commitNumber
|
|
3195
|
-
})
|
|
3196
|
-
});
|
|
3197
|
-
}
|
|
3198
|
-
case "SECRET_TEXT": return /* @__PURE__ */ jsx(FieldShell, {
|
|
3199
|
-
htmlFor: fieldId,
|
|
3200
|
-
prop,
|
|
3201
|
-
invalid,
|
|
3202
|
-
picker,
|
|
3203
|
-
children: textInput({
|
|
3204
|
-
type: "password",
|
|
3205
|
-
commit: (raw) => onCommit(raw === "" ? void 0 : raw)
|
|
3206
|
-
})
|
|
3207
|
-
});
|
|
3208
|
-
case "FILE": return /* @__PURE__ */ jsx(FieldShell, {
|
|
3209
|
-
htmlFor: fieldId,
|
|
3210
|
-
prop,
|
|
3211
|
-
invalid,
|
|
3212
|
-
picker,
|
|
3213
|
-
children: textInput({
|
|
3214
|
-
mono: true,
|
|
3215
|
-
placeholder: prop.placeholder ?? "https://… or data:…;base64,…",
|
|
3216
|
-
commit: (raw) => onCommit(raw.trim() === "" ? void 0 : raw.trim())
|
|
3217
|
-
})
|
|
3218
|
-
});
|
|
3219
|
-
case "DATE_TIME":
|
|
3220
|
-
if (textMode) return /* @__PURE__ */ jsx(FieldShell, {
|
|
3221
|
-
htmlFor: fieldId,
|
|
3222
|
-
prop,
|
|
3223
|
-
invalid,
|
|
3224
|
-
picker,
|
|
3225
|
-
children: textInput({
|
|
3226
|
-
mono: true,
|
|
3227
|
-
placeholder: "ISO 8601 or {{expression}}",
|
|
3228
|
-
commit: (raw) => {
|
|
3229
|
-
const trimmed = raw.trim();
|
|
3230
|
-
if (trimmed === "") {
|
|
3231
|
-
setTextMode(false);
|
|
3232
|
-
return onCommit(void 0, "MANUAL");
|
|
3233
|
-
}
|
|
3234
|
-
onCommit(hasExpressions(trimmed) ? trimmed : localInputToIso(trimmed));
|
|
3235
|
-
}
|
|
3236
|
-
})
|
|
3237
|
-
});
|
|
3238
|
-
return /* @__PURE__ */ jsx(FieldShell, {
|
|
3239
|
-
htmlFor: fieldId,
|
|
3240
|
-
prop,
|
|
3241
|
-
invalid,
|
|
3242
|
-
picker,
|
|
3243
|
-
children: /* @__PURE__ */ jsx("input", {
|
|
3244
|
-
id: fieldId,
|
|
3245
|
-
type: "datetime-local",
|
|
3246
|
-
className: `${textInputClass} ${invalid ? invalidClass : ""}`,
|
|
3247
|
-
defaultValue: isoToLocalInput(value),
|
|
3248
|
-
onFocus: field.focus,
|
|
3249
|
-
onBlur: (event) => onCommit(localInputToIso(event.target.value))
|
|
3250
|
-
})
|
|
3251
|
-
});
|
|
3252
|
-
case "STATIC_DROPDOWN": {
|
|
3253
|
-
const options = prop.staticOptions ?? [];
|
|
3254
|
-
if (prop.display === "cards") return /* @__PURE__ */ jsx(FieldShell, {
|
|
3255
|
-
htmlFor: fieldId,
|
|
3256
|
-
prop,
|
|
3257
|
-
invalid,
|
|
3258
|
-
children: /* @__PURE__ */ jsx(OptionCards, {
|
|
3259
|
-
id: fieldId,
|
|
3260
|
-
options,
|
|
3261
|
-
value,
|
|
3262
|
-
keyOf: stringifyValue$1,
|
|
3263
|
-
onChange: onCommit,
|
|
3264
|
-
invalid,
|
|
3265
|
-
clearable: !prop.required
|
|
3266
|
-
})
|
|
3267
|
-
});
|
|
3268
|
-
if (!prop.staticDisabled && prop.required !== true && prop.defaultValue !== void 0 && options.length >= 2 && options.length <= 3 && options.every((option) => option.label.length <= 22)) return /* @__PURE__ */ jsx(FieldShell, {
|
|
3269
|
-
htmlFor: fieldId,
|
|
3270
|
-
prop,
|
|
3271
|
-
invalid: false,
|
|
3272
|
-
children: /* @__PURE__ */ jsx(Segmented, {
|
|
3273
|
-
value: stringifyValue$1(value),
|
|
3274
|
-
options: options.map((option) => ({
|
|
3275
|
-
value: stringifyValue$1(option.value),
|
|
3276
|
-
label: option.label
|
|
3277
|
-
})),
|
|
3278
|
-
onChange: (key) => onCommit(options.find((option) => stringifyValue$1(option.value) === key)?.value ?? key)
|
|
3279
|
-
})
|
|
3280
|
-
});
|
|
3281
|
-
return /* @__PURE__ */ jsx(FieldShell, {
|
|
3282
|
-
htmlFor: fieldId,
|
|
3283
|
-
prop,
|
|
3284
|
-
invalid,
|
|
3285
|
-
children: /* @__PURE__ */ jsx(OptionSelect, {
|
|
3286
|
-
id: fieldId,
|
|
3287
|
-
options: prop.staticOptions ?? [],
|
|
3288
|
-
value,
|
|
3289
|
-
onChange: onCommit,
|
|
3290
|
-
invalid,
|
|
3291
|
-
placeholder: prop.staticPlaceholder ?? prop.placeholder,
|
|
3292
|
-
disabled: prop.staticDisabled && isEmptyValue(value),
|
|
3293
|
-
clearable: !prop.required
|
|
3294
|
-
})
|
|
3295
|
-
});
|
|
3296
|
-
}
|
|
3297
|
-
case "STATIC_MULTI_SELECT_DROPDOWN": return /* @__PURE__ */ jsx(FieldShell, {
|
|
3298
|
-
htmlFor: fieldId,
|
|
3299
|
-
prop,
|
|
3300
|
-
invalid,
|
|
3301
|
-
children: /* @__PURE__ */ jsx(OptionList, {
|
|
3302
|
-
id: fieldId,
|
|
3303
|
-
options: prop.staticOptions ?? [],
|
|
3304
|
-
selected: Array.isArray(value) ? value : [],
|
|
3305
|
-
onChange: (next) => onCommit(next.length > 0 ? next : void 0),
|
|
3306
|
-
invalid
|
|
3307
|
-
})
|
|
3308
|
-
});
|
|
3309
|
-
case "DROPDOWN": {
|
|
3310
|
-
if (textMode) return /* @__PURE__ */ jsx(FieldShell, {
|
|
3311
|
-
htmlFor: fieldId,
|
|
3312
|
-
prop,
|
|
3313
|
-
invalid,
|
|
3314
|
-
picker: /* @__PURE__ */ jsxs(Fragment$1, { children: [picker, /* @__PURE__ */ jsx(ModeButton, {
|
|
3315
|
-
label: "Pick from list",
|
|
3316
|
-
onClick: () => {
|
|
3317
|
-
if (hasExpressions(value)) {
|
|
3318
|
-
setTextMode(false);
|
|
3319
|
-
onCommit(void 0, "MANUAL");
|
|
3320
|
-
} else toMode(false);
|
|
3321
|
-
}
|
|
3322
|
-
})] }),
|
|
3323
|
-
children: textInput({
|
|
3324
|
-
mono: true,
|
|
3325
|
-
placeholder: "{{steps.…}} or an id",
|
|
3326
|
-
commit: (raw) => onCommit(raw.trim() === "" ? void 0 : raw)
|
|
3327
|
-
})
|
|
3328
|
-
});
|
|
3329
|
-
const result = searchResult ?? (dropdown.state.kind === "ready" ? dropdown.state.result : null);
|
|
3330
|
-
const listed = result?.options ?? [];
|
|
3331
|
-
const options = picked !== null && stringifyValue$1(picked.value) === stringifyValue$1(value) && !listed.some((option) => stringifyValue$1(option.value) === stringifyValue$1(value)) ? [...listed, picked] : listed;
|
|
3332
|
-
return /* @__PURE__ */ jsx(FieldShell, {
|
|
3333
|
-
htmlFor: fieldId,
|
|
3334
|
-
prop,
|
|
3335
|
-
invalid,
|
|
3336
|
-
error: loadError(dropdown.state),
|
|
3337
|
-
picker: optionsUnavailable ? /* @__PURE__ */ jsx(AvailableSoon, {}) : picker,
|
|
3338
|
-
children: /* @__PURE__ */ jsx(OptionSelect, {
|
|
3339
|
-
id: fieldId,
|
|
3340
|
-
options,
|
|
3341
|
-
value,
|
|
3342
|
-
onChange: (next) => {
|
|
3343
|
-
setPicked(listed.find((option) => stringifyValue$1(option.value) === stringifyValue$1(next)) ?? null);
|
|
3344
|
-
onCommit(next);
|
|
3345
|
-
},
|
|
3346
|
-
invalid,
|
|
3347
|
-
loading: dropdown.state.kind === "loading",
|
|
3348
|
-
disabled: result?.disabled && !stringifyValue$1(value) || optionsUnavailable,
|
|
3349
|
-
onRefresh: dynamicLoad ? dropdown.reload : void 0,
|
|
3350
|
-
clearable: !prop.required,
|
|
3351
|
-
searchable: true,
|
|
3352
|
-
onQueryChange: onSearch,
|
|
3353
|
-
actions: [{
|
|
3354
|
-
label: "Use data from an earlier step",
|
|
3355
|
-
icon: "braces",
|
|
3356
|
-
onSelect: () => {
|
|
3357
|
-
toMode(true);
|
|
3358
|
-
field.focus();
|
|
3359
|
-
}
|
|
3360
|
-
}],
|
|
3361
|
-
emptyText: result?.placeholder ?? "Nothing to choose from yet. Some lists need a connection first.",
|
|
3362
|
-
placeholder: optionsUnavailable ? "Options for nested fields are available soon" : dropdown.syncing ? "Waiting for the Switchboard…" : result?.placeholder ?? prop.placeholder ?? "Choose…"
|
|
3363
|
-
})
|
|
3364
|
-
});
|
|
3365
|
-
}
|
|
3366
|
-
case "MULTI_SELECT_DROPDOWN": {
|
|
3367
|
-
const result = dropdown.state.kind === "ready" ? dropdown.state.result : null;
|
|
3368
|
-
const selected = Array.isArray(value) ? value : [];
|
|
3369
|
-
const listed = new Set((result?.options ?? []).map((o) => stringifyValue$1(o.value)));
|
|
3370
|
-
const extra = selected.filter((entry) => !listed.has(stringifyValue$1(entry))).map((entry) => ({
|
|
3371
|
-
label: stringifyValue$1(entry),
|
|
3372
|
-
value: entry
|
|
3373
|
-
}));
|
|
3374
|
-
return /* @__PURE__ */ jsx(FieldShell, {
|
|
3375
|
-
htmlFor: fieldId,
|
|
3376
|
-
prop,
|
|
3377
|
-
invalid,
|
|
3378
|
-
error: loadError(dropdown.state),
|
|
3379
|
-
picker: optionsUnavailable ? /* @__PURE__ */ jsx(AvailableSoon, {}) : void 0,
|
|
3380
|
-
children: optionsUnavailable ? /* @__PURE__ */ jsx("p", {
|
|
3381
|
-
className: "text-xs text-muted-foreground",
|
|
3382
|
-
children: "Options for nested fields are available soon."
|
|
3383
|
-
}) : /* @__PURE__ */ jsx(OptionList, {
|
|
3384
|
-
id: fieldId,
|
|
3385
|
-
options: [...extra, ...result?.options ?? []],
|
|
3386
|
-
selected,
|
|
3387
|
-
onChange: (next) => onCommit(next.length > 0 ? next : void 0),
|
|
3388
|
-
invalid,
|
|
3389
|
-
loading: dropdown.state.kind === "loading",
|
|
3390
|
-
onRefresh: dynamicLoad ? dropdown.reload : void 0,
|
|
3391
|
-
placeholder: result?.placeholder ?? prop.placeholder
|
|
3392
|
-
})
|
|
3393
|
-
});
|
|
3394
|
-
}
|
|
3395
|
-
case "DYNAMIC": {
|
|
3396
|
-
const fields = dynamic.state.kind === "ready" ? dynamic.state.result : null;
|
|
3397
|
-
const record = value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
3398
|
-
return /* @__PURE__ */ jsx(FieldShell, {
|
|
3399
|
-
htmlFor: fieldId,
|
|
3400
|
-
prop,
|
|
3401
|
-
invalid: invalid && fields !== null && fields.length > 0,
|
|
3402
|
-
error: loadError(dynamic.state),
|
|
3403
|
-
picker: optionsUnavailable ? /* @__PURE__ */ jsx(AvailableSoon, {}) : dynamicLoad ? retryButton(dynamic.state, dynamic.reload) : void 0,
|
|
3404
|
-
children: optionsUnavailable ? /* @__PURE__ */ jsx("p", {
|
|
3405
|
-
className: "text-xs text-muted-foreground",
|
|
3406
|
-
children: "Nested dynamic properties are available soon."
|
|
3407
|
-
}) : dynamic.state.kind === "loading" && !fields ? /* @__PURE__ */ jsx("p", {
|
|
3408
|
-
className: "text-xs text-muted-foreground",
|
|
3409
|
-
children: "Resolving properties…"
|
|
3410
|
-
}) : !dynamicLoad ? /* @__PURE__ */ jsx("p", {
|
|
3411
|
-
className: "text-xs text-muted-foreground",
|
|
3412
|
-
children: "Properties resolve once the runtime is reachable."
|
|
3413
|
-
}) : fields && fields.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
3414
|
-
className: "rounded-lg border border-solid border-foreground/10 bg-muted/40 p-3",
|
|
3415
|
-
children: /* @__PURE__ */ jsx(PropertyForm, {
|
|
3416
|
-
props: fields,
|
|
3417
|
-
value: record,
|
|
3418
|
-
onChange: (next) => onCommit(Object.keys(next).length > 0 ? next : void 0),
|
|
3419
|
-
scopeStepId: props.scopeStepId,
|
|
3420
|
-
nested: true
|
|
3421
|
-
})
|
|
3422
|
-
}) : fields ? /* @__PURE__ */ jsx("p", {
|
|
3423
|
-
className: "text-xs text-muted-foreground",
|
|
3424
|
-
children: props.waitingOn ? `Pick ${props.waitingOn} first; its fields show here.` : "No properties for the current selection."
|
|
3425
|
-
}) : null
|
|
3426
|
-
});
|
|
3427
|
-
}
|
|
3428
|
-
case "ARRAY": {
|
|
3429
|
-
if (prop.properties && prop.properties.length > 0) return /* @__PURE__ */ jsx(FieldShell, {
|
|
3430
|
-
htmlFor: fieldId,
|
|
3431
|
-
prop,
|
|
3432
|
-
invalid,
|
|
3433
|
-
children: /* @__PURE__ */ jsx(ArrayRows, {
|
|
3434
|
-
prop,
|
|
3435
|
-
value,
|
|
3436
|
-
onCommit,
|
|
3437
|
-
scopeStepId: props.scopeStepId,
|
|
3438
|
-
invalid
|
|
3439
|
-
})
|
|
3440
|
-
});
|
|
3441
|
-
if (textMode) return /* @__PURE__ */ jsx(FieldShell, {
|
|
3442
|
-
htmlFor: fieldId,
|
|
3443
|
-
prop,
|
|
3444
|
-
invalid,
|
|
3445
|
-
picker: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ExpressionPickerButton, {
|
|
3446
|
-
active: field.active,
|
|
3447
|
-
onFocusField: field.focus
|
|
3448
|
-
}), /* @__PURE__ */ jsx(ModeButton, {
|
|
3449
|
-
label: "Enter items",
|
|
3450
|
-
onClick: () => {
|
|
3451
|
-
setTextMode(false);
|
|
3452
|
-
const bound = stringifyValue$1(value).trim();
|
|
3453
|
-
onCommit(bound ? [bound] : void 0, "MANUAL");
|
|
3454
|
-
}
|
|
3455
|
-
})] }),
|
|
3456
|
-
children: textInput({
|
|
3457
|
-
mono: true,
|
|
3458
|
-
placeholder: "{{steps.…}} yielding a list",
|
|
3459
|
-
commit: (raw) => onCommit(raw.trim() === "" ? void 0 : raw.trim(), "EXPRESSION")
|
|
3460
|
-
})
|
|
3461
|
-
});
|
|
3462
|
-
const lines = Array.isArray(value) ? value.map((item) => stringifyValue$1(item)).join("\n") : stringifyValue$1(value);
|
|
3463
|
-
return /* @__PURE__ */ jsxs(FieldShell, {
|
|
3464
|
-
htmlFor: fieldId,
|
|
3465
|
-
prop,
|
|
3466
|
-
invalid,
|
|
3467
|
-
picker: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ExpressionPickerButton, {
|
|
3468
|
-
active: field.active,
|
|
3469
|
-
onFocusField: field.focus
|
|
3470
|
-
}), /* @__PURE__ */ jsx(ModeButton, {
|
|
3471
|
-
label: "Bind the whole list",
|
|
3472
|
-
onClick: () => {
|
|
3473
|
-
setTextMode(true);
|
|
3474
|
-
onCommit(void 0, "EXPRESSION");
|
|
3475
|
-
}
|
|
3476
|
-
})] }),
|
|
3477
|
-
children: [/* @__PURE__ */ jsx("textarea", {
|
|
3478
|
-
id: fieldId,
|
|
3479
|
-
ref: fieldRef,
|
|
3480
|
-
className: `${textAreaClass} font-mono text-xs ${invalid ? invalidClass : ""}`,
|
|
3481
|
-
defaultValue: lines,
|
|
3482
|
-
placeholder: prop.placeholder ?? "One item per line",
|
|
3483
|
-
spellCheck: false,
|
|
3484
|
-
onFocus: field.focus,
|
|
3485
|
-
onChange: (event) => setDraft(event.target.value),
|
|
3486
|
-
onBlur: (event) => {
|
|
3487
|
-
const items = event.target.value.split("\n").map((line) => line.trim()).filter((line) => line !== "");
|
|
3488
|
-
if (items.length === 0) return onCommit(void 0);
|
|
3489
|
-
onCommit(items);
|
|
3490
|
-
}
|
|
3491
|
-
}), /* @__PURE__ */ jsx(ExpressionTokenLine, { value: draft })]
|
|
3492
|
-
});
|
|
3493
|
-
}
|
|
3494
|
-
case "OBJECT":
|
|
3495
|
-
if (textMode) return /* @__PURE__ */ jsx(FieldShell, {
|
|
3496
|
-
htmlFor: fieldId,
|
|
3497
|
-
prop,
|
|
3498
|
-
invalid,
|
|
3499
|
-
picker,
|
|
3500
|
-
children: textInput({
|
|
3501
|
-
mono: true,
|
|
3502
|
-
placeholder: "{{expression}} yielding an object",
|
|
3503
|
-
commit: (raw) => {
|
|
3504
|
-
const trimmed = raw.trim();
|
|
3505
|
-
if (trimmed === "") {
|
|
3506
|
-
setTextMode(false);
|
|
3507
|
-
return onCommit(void 0, "MANUAL");
|
|
3508
|
-
}
|
|
3509
|
-
onCommit(trimmed);
|
|
3510
|
-
}
|
|
3511
|
-
})
|
|
3512
|
-
});
|
|
3513
|
-
return /* @__PURE__ */ jsx(FieldShell, {
|
|
3514
|
-
htmlFor: fieldId,
|
|
3515
|
-
prop,
|
|
3516
|
-
invalid,
|
|
3517
|
-
picker,
|
|
3518
|
-
children: /* @__PURE__ */ jsx(ObjectRows, {
|
|
3519
|
-
value: value !== null && typeof value === "object" && !Array.isArray(value) ? value : {},
|
|
3520
|
-
onCommit,
|
|
3521
|
-
invalid
|
|
3522
|
-
})
|
|
3523
|
-
});
|
|
3524
|
-
case "DATE_RANGE": return /* @__PURE__ */ jsx(FieldShell, {
|
|
3525
|
-
htmlFor: fieldId,
|
|
3526
|
-
prop,
|
|
3527
|
-
invalid,
|
|
3528
|
-
children: /* @__PURE__ */ jsx(DateRangeField, {
|
|
3529
|
-
id: fieldId,
|
|
3530
|
-
value,
|
|
3531
|
-
dropdown: prop.display === "dropdown",
|
|
3532
|
-
invalid,
|
|
3533
|
-
clearable: !prop.required,
|
|
3534
|
-
onCommit
|
|
3535
|
-
})
|
|
3536
|
-
});
|
|
3537
|
-
case "COLOR": return /* @__PURE__ */ jsx(FieldShell, {
|
|
3538
|
-
htmlFor: fieldId,
|
|
3539
|
-
prop,
|
|
3540
|
-
invalid,
|
|
3541
|
-
picker,
|
|
3542
|
-
children: /* @__PURE__ */ jsx(ColorField, {
|
|
3543
|
-
id: fieldId,
|
|
3544
|
-
value,
|
|
3545
|
-
invalid,
|
|
3546
|
-
onCommit,
|
|
3547
|
-
onFocus: field.focus
|
|
3548
|
-
})
|
|
3549
|
-
});
|
|
3550
|
-
case "RICH_TEXT":
|
|
3551
|
-
case "LONG_TEXT":
|
|
3552
|
-
case "CUSTOM":
|
|
3553
|
-
case "JSON": {
|
|
3554
|
-
const isJson = prop.type === "JSON" || prop.type === "CUSTOM";
|
|
3555
|
-
const mode = prop.type === "RICH_TEXT" ? richTextMode(prop.formatProperty ? props.config?.[prop.formatProperty] : "") : null;
|
|
3556
|
-
return /* @__PURE__ */ jsxs(FieldShell, {
|
|
3557
|
-
htmlFor: fieldId,
|
|
3558
|
-
prop,
|
|
3559
|
-
invalid,
|
|
3560
|
-
picker: mode ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
3561
|
-
className: "rounded bg-muted px-1.5 text-[11px] text-muted-foreground",
|
|
3562
|
-
children: mode === "html" ? "HTML" : mode === "markdown" ? "Markdown" : "Plain text"
|
|
3563
|
-
}), picker] }) : picker,
|
|
3564
|
-
error: jsonError,
|
|
3565
|
-
children: [/* @__PURE__ */ jsx("textarea", {
|
|
3566
|
-
id: fieldId,
|
|
3567
|
-
ref: fieldRef,
|
|
3568
|
-
className: `${textAreaClass} ${isJson || mode === "html" || prop.display === "code" ? "font-mono text-xs" : ""} ${mode ? "min-h-32" : ""} ${invalid ? invalidClass : ""}`,
|
|
3569
|
-
defaultValue: stringifyValue$1(value),
|
|
3570
|
-
placeholder: prop.placeholder,
|
|
3571
|
-
spellCheck: false,
|
|
3572
|
-
onFocus: field.focus,
|
|
3573
|
-
onChange: (event) => setDraft(event.target.value),
|
|
3574
|
-
onBlur: (event) => {
|
|
3575
|
-
const raw = event.target.value;
|
|
3576
|
-
if (!isJson) return onCommit(raw === "" ? void 0 : raw);
|
|
3577
|
-
const trimmed = raw.trim();
|
|
3578
|
-
if (trimmed === "") {
|
|
3579
|
-
setJsonError(null);
|
|
3580
|
-
return onCommit(void 0);
|
|
3581
|
-
}
|
|
3582
|
-
if (WHOLE_EXPRESSION.test(trimmed)) {
|
|
3583
|
-
setJsonError(null);
|
|
3584
|
-
return onCommit(trimmed);
|
|
3585
|
-
}
|
|
3586
|
-
try {
|
|
3587
|
-
onCommit(JSON.parse(trimmed));
|
|
3588
|
-
setJsonError(null);
|
|
3589
|
-
} catch {
|
|
3590
|
-
setJsonError("Not valid JSON, so it wasn't saved.");
|
|
3591
|
-
}
|
|
3592
|
-
}
|
|
3593
|
-
}), /* @__PURE__ */ jsx(ExpressionTokenLine, { value: draft })]
|
|
3594
|
-
});
|
|
3595
|
-
}
|
|
3596
|
-
default: return /* @__PURE__ */ jsxs(FieldShell, {
|
|
3597
|
-
htmlFor: fieldId,
|
|
3598
|
-
prop,
|
|
3599
|
-
invalid,
|
|
3600
|
-
picker,
|
|
3601
|
-
children: [prop.emptyChoice && value === "" ? null : textInput({ commit: (raw) => onCommit(raw === "" ? void 0 : raw) }), prop.emptyChoice ? /* @__PURE__ */ jsxs("label", {
|
|
3602
|
-
className: "mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",
|
|
3603
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
3604
|
-
type: "checkbox",
|
|
3605
|
-
className: "h-3.5 w-3.5 accent-current",
|
|
3606
|
-
checked: value === "",
|
|
3607
|
-
onChange: (event) => onCommit(event.target.checked ? "" : void 0, "MANUAL")
|
|
3608
|
-
}), prop.emptyChoice]
|
|
3609
|
-
}) : null]
|
|
3610
|
-
});
|
|
3611
|
-
}
|
|
3612
|
-
}
|
|
3613
|
-
const NO_BLOCK = {
|
|
3614
|
-
pieceName: "",
|
|
3615
|
-
pieceVersion: "",
|
|
3616
|
-
kind: "action",
|
|
3617
|
-
name: ""
|
|
3618
|
-
};
|
|
3619
|
-
function PropertyForm(props) {
|
|
3620
|
-
const echo = usePendingEcho({
|
|
3621
|
-
value: props.value,
|
|
3622
|
-
settings: props.settings ?? null
|
|
3623
|
-
}, (next, shown) => {
|
|
3624
|
-
if (next.settings !== shown.settings) props.onChange(next.value, next.settings ?? []);
|
|
3625
|
-
else props.onChange(next.value);
|
|
3626
|
-
});
|
|
3627
|
-
const { value: current, settings } = echo.value;
|
|
3628
|
-
const tracksSettings = props.writesSettings === true;
|
|
3629
|
-
const readDynamic = useDynamicCache();
|
|
3630
|
-
const withResolvedSchemas = (list, config) => {
|
|
3631
|
-
let next = list;
|
|
3632
|
-
for (const prop of props.props) {
|
|
3633
|
-
if (prop.type !== "DYNAMIC") continue;
|
|
3634
|
-
if (settingFor(next, prop.name)?.mode === "EXPRESSION") continue;
|
|
3635
|
-
const fields = readDynamic(resolverInputFor(props.block ?? NO_BLOCK, prop, config, props.connectionId, props.reactorConnectionId));
|
|
3636
|
-
if (!fields) continue;
|
|
3637
|
-
const schema = stripOptions(fields);
|
|
3638
|
-
const stored = settingFor(next, prop.name)?.schema ?? null;
|
|
3639
|
-
if (JSON.stringify(stored) === JSON.stringify(schema)) continue;
|
|
3640
|
-
next = withSetting(next, prop.name, { schema });
|
|
3641
|
-
}
|
|
3642
|
-
return next;
|
|
3643
|
-
};
|
|
3644
|
-
const commitField = (name, value, mode) => {
|
|
3645
|
-
const next = { ...current };
|
|
3646
|
-
if (value === void 0) delete next[name];
|
|
3647
|
-
else next[name] = value;
|
|
3648
|
-
let nextSettings = settings;
|
|
3649
|
-
const nextMode = mode ?? settingFor(settings, name)?.mode ?? "MANUAL";
|
|
3650
|
-
if (tracksSettings && settingFor(settings, name)?.mode !== nextMode) nextSettings = withSetting(nextSettings, name, { mode: nextMode });
|
|
3651
|
-
if (value !== current[name]) for (const dependent of props.props) {
|
|
3652
|
-
if (!dependent.refreshers?.includes(name)) continue;
|
|
3653
|
-
if (isDropdownType(dependent.type)) delete next[dependent.name];
|
|
3654
|
-
if (tracksSettings && dependent.type === "DYNAMIC" && settingFor(nextSettings, dependent.name)?.schema != null) nextSettings = withSetting(nextSettings, dependent.name, { schema: null });
|
|
3655
|
-
}
|
|
3656
|
-
if (tracksSettings) nextSettings = withResolvedSchemas(nextSettings, next);
|
|
3657
|
-
echo.commit({
|
|
3658
|
-
value: next,
|
|
3659
|
-
settings: nextSettings
|
|
3660
|
-
});
|
|
3661
|
-
};
|
|
3662
|
-
const setMode = (name, mode) => {
|
|
3663
|
-
if (!tracksSettings || settingFor(settings, name)?.mode === mode) return;
|
|
3664
|
-
echo.commit({
|
|
3665
|
-
value: current,
|
|
3666
|
-
settings: withResolvedSchemas(withSetting(settings, name, { mode }), current)
|
|
3667
|
-
});
|
|
3668
|
-
};
|
|
3669
|
-
const visible = props.props.filter((prop) => isPropVisible(prop, current));
|
|
3670
|
-
const essential = visible.filter((prop) => !prop.advanced);
|
|
3671
|
-
const advanced = visible.filter((prop) => prop.advanced);
|
|
3672
|
-
const [showAdvanced, setShowAdvanced] = useState(false);
|
|
3673
|
-
const advancedSet = advanced.filter((prop) => current[prop.name] !== void 0).length;
|
|
3674
|
-
const field = (prop) => /* @__PURE__ */ jsx(PropField, {
|
|
3675
|
-
prop,
|
|
3676
|
-
value: current[prop.name],
|
|
3677
|
-
onCommit: (value, mode) => commitField(prop.name, value, mode),
|
|
3678
|
-
mode: settingFor(settings, prop.name)?.mode,
|
|
3679
|
-
onMode: (mode) => setMode(prop.name, mode),
|
|
3680
|
-
loadOptions: props.loadOptions ? (propName, searchValue) => props.loadOptions(propName, current, searchValue) : void 0,
|
|
3681
|
-
config: current,
|
|
3682
|
-
secrets: props.secrets,
|
|
3683
|
-
scopeStepId: props.scopeStepId,
|
|
3684
|
-
optionsBlocked: props.optionsBlocked,
|
|
3685
|
-
explainOptionsError: props.explainOptionsError,
|
|
3686
|
-
resolverInput: resolverInputFor(props.block ?? NO_BLOCK, prop, current, props.connectionId, props.reactorConnectionId),
|
|
3687
|
-
waitingOn: props.props.find((sibling) => prop.refreshers?.includes(sibling.name) && isEmptyValue(current[sibling.name]))?.displayName,
|
|
3688
|
-
nested: props.nested,
|
|
3689
|
-
webhookUrl: props.webhookUrl
|
|
3690
|
-
}, prop.name);
|
|
3691
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3692
|
-
className: `flex flex-col ${props.nested ? "gap-3" : "gap-5"}`,
|
|
3693
|
-
onBlur: echo.onBlur,
|
|
3694
|
-
children: [/* @__PURE__ */ jsx(PropLayout, {
|
|
3695
|
-
props: essential,
|
|
3696
|
-
groups: props.groups,
|
|
3697
|
-
values: current,
|
|
3698
|
-
renderField: field,
|
|
3699
|
-
onCommit: commitField
|
|
3700
|
-
}), advanced.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
3701
|
-
className: "flex flex-col gap-5 border-t border-solid border-foreground/10 pt-4",
|
|
3702
|
-
children: [/* @__PURE__ */ jsxs("button", {
|
|
3703
|
-
type: "button",
|
|
3704
|
-
className: "-mx-1 flex items-center gap-1.5 self-start rounded px-1 text-[13px] font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
|
|
3705
|
-
"aria-expanded": showAdvanced,
|
|
3706
|
-
onClick: () => setShowAdvanced((open) => !open),
|
|
3707
|
-
children: [
|
|
3708
|
-
/* @__PURE__ */ jsx(Icon, {
|
|
3709
|
-
name: "chevron",
|
|
3710
|
-
className: `h-3.5 w-3.5 transition-transform ${showAdvanced ? "rotate-90" : ""}`
|
|
3711
|
-
}),
|
|
3712
|
-
"More options",
|
|
3713
|
-
/* @__PURE__ */ jsx("span", {
|
|
3714
|
-
className: "font-normal",
|
|
3715
|
-
children: advancedSet > 0 ? `${advanced.length} fields, ${advancedSet} set` : `${advanced.length} fields`
|
|
3716
|
-
})
|
|
3717
|
-
]
|
|
3718
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
3719
|
-
hidden: !showAdvanced,
|
|
3720
|
-
className: "flex flex-col gap-5",
|
|
3721
|
-
children: /* @__PURE__ */ jsx(PropLayout, {
|
|
3722
|
-
props: advanced,
|
|
3723
|
-
groups: props.groups,
|
|
3724
|
-
values: current,
|
|
3725
|
-
renderField: field,
|
|
3726
|
-
onCommit: commitField
|
|
3727
|
-
})
|
|
3728
|
-
})]
|
|
3729
|
-
}) : null]
|
|
3730
|
-
});
|
|
3731
|
-
}
|
|
3732
1206
|
const DEFAULT_RETRY = {
|
|
3733
1207
|
maxAttempts: 3,
|
|
3734
1208
|
backoff: "EXPONENTIAL",
|
|
@@ -17887,10 +15361,11 @@ function WorkflowEditor() {
|
|
|
17887
15361
|
}, block, config),
|
|
17888
15362
|
documentOutput: async (reference) => {
|
|
17889
15363
|
const referenced = modules?.filter((module) => module.documentModel.global.id === reference.documentType).sort((a, b) => (b.version ?? 1) - (a.version ?? 1)).at(0)?.documentModel.global;
|
|
17890
|
-
|
|
15364
|
+
const global = referenced ? await stateFieldsFromSdl({
|
|
17891
15365
|
name: referenced.name,
|
|
17892
15366
|
schema: referenced.specifications.at(-1)?.state.global.schema ?? null
|
|
17893
|
-
}) : {}
|
|
15367
|
+
}) : {};
|
|
15368
|
+
return documentShape(reference, global);
|
|
17894
15369
|
},
|
|
17895
15370
|
testOutput: async (blockId) => {
|
|
17896
15371
|
const block = model.trigger?.id === blockId ? model.trigger : model.steps.find((step) => step.id === blockId);
|
|
@@ -17938,4 +15413,4 @@ function Editor({ document }) {
|
|
|
17938
15413
|
//#endregion
|
|
17939
15414
|
export { Editor as default };
|
|
17940
15415
|
|
|
17941
|
-
//# sourceMappingURL=editor-
|
|
15416
|
+
//# sourceMappingURL=editor-BGz1Ljdk.mjs.map
|