@burdenoff/fluidgrids-fe-sdk 2026.1031.4 → 2026.1031.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ExecutionDetailPage-GKX4OUUR.js +23 -0
- package/dist/{WorkflowsList-BZXBTGNL.js → ExecutionsListPage-ZZOUZQBS.js} +9 -8
- package/dist/{TemplateDetailPanel-MTKW3SPM.js → TemplateDetailPanel-WH74G7PF.js} +18 -7
- package/dist/{WorkflowBuilder-N3ZUYFRK.js → WorkflowBuilder-4QEJNKVE.js} +12 -11
- package/dist/{ExecutionsListPage-AYDGFU6W.js → WorkflowsList-4CTHUYM7.js} +9 -8
- package/dist/{chunk-VJWJGSRS.js → chunk-34HHBNZE.js} +1 -1
- package/dist/{chunk-P3TGCUXP.js → chunk-34XK5BC7.js} +5 -37
- package/dist/{chunk-JFQGODKK.js → chunk-35N3PEO6.js} +1 -1
- package/dist/{chunk-DHR2YURL.js → chunk-3KKGE7CE.js} +164 -9
- package/dist/{chunk-XX6D7IND.js → chunk-5XQMYHJ7.js} +2 -2
- package/dist/{chunk-OGYAC7QW.js → chunk-AHDYETEE.js} +1 -1
- package/dist/{chunk-WHPQRYZD.js → chunk-CAZHE2MQ.js} +6 -5
- package/dist/{chunk-GV5RJ6BU.js → chunk-E7AQAPZN.js} +33 -22
- package/dist/{chunk-6PGLJWIC.js → chunk-EPYTVCYH.js} +30 -188
- package/dist/{chunk-DJAGZUHW.js → chunk-FUYHCONW.js} +1257 -34
- package/dist/{chunk-ADTEMSJI.js → chunk-GMVXPC5N.js} +849 -4
- package/dist/{chunk-IGROOI7E.js → chunk-GREPXIXS.js} +2 -2
- package/dist/{chunk-PTROESUB.js → chunk-HCKYGGUU.js} +4 -4
- package/dist/{chunk-Z3FYBDE3.js → chunk-HQX7JZLY.js} +33 -1
- package/dist/{chunk-QKQOTEAB.js → chunk-I5BPMBIV.js} +1 -1
- package/dist/{chunk-R4Q37Q4X.js → chunk-IJBT25CS.js} +3 -3
- package/dist/{chunk-44KAAKFK.js → chunk-JUHSLK7C.js} +5 -5
- package/dist/{chunk-AW3UXMNI.js → chunk-KEYKB4E7.js} +12 -1
- package/dist/{chunk-P2VAHDGO.js → chunk-NLRQSHRS.js} +2 -2
- package/dist/{chunk-BHD4CDLL.js → chunk-P4R4ACCC.js} +1 -1
- package/dist/{chunk-CIR7WF4W.js → chunk-PP62ABIG.js} +1 -1
- package/dist/{chunk-Q3HKE627.js → chunk-RYUSWVIR.js} +3 -3
- package/dist/{chunk-INMYNHJL.js → chunk-TVOXRODW.js} +34 -2
- package/dist/{chunk-PKG6BCHB.js → chunk-VWFA3RQR.js} +2 -2
- package/dist/{chunk-475XP5J7.js → chunk-ZEHMJURX.js} +6 -5
- package/dist/chunk-ZUVFD5KV.js +186 -0
- package/dist/executions.js +13 -12
- package/dist/history.js +5 -4
- package/dist/index.d.ts +741 -4
- package/dist/index.js +45 -40
- package/dist/nodes.js +2 -2
- package/dist/observability.js +7 -6
- package/dist/settings.js +7 -6
- package/dist/templates.js +11 -10
- package/dist/workflow-builder.js +13 -12
- package/dist/workflows-list.js +9 -8
- package/package.json +1 -1
- package/dist/ExecutionDetailPage-WOOORXXU.js +0 -22
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useEntityTags, useTagEntity, useUntagEntity } from './chunk-
|
|
1
|
+
import { useEntityTags, useTagEntity, useUntagEntity } from './chunk-TVOXRODW.js';
|
|
2
2
|
import { notifyFluidGridsAiCreditsUpdated } from './chunk-Y53CVZVV.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ErrorType } from './chunk-HQX7JZLY.js';
|
|
4
|
+
import { throwIfResultError, describeOperationError, signalPayloadCard, components_default, isForbiddenError, payloadFromCardValues, parseRawSignalPayload } from './chunk-EPYTVCYH.js';
|
|
4
5
|
import { getFluidGridsConfig } from './chunk-6AMNEX2Y.js';
|
|
5
|
-
import { TerminateWorkflowRunDocument, WorkflowRunHistoryDocument, RunEventAppendedDocument, WorkflowProposalDocument, ProposeRunFixDocument, ProposeWorkflowChangeDocument, ApplyWorkflowProposalDocument, RejectWorkflowProposalDocument, CancelWorkflowProposalDocument, DurableRunFieldsDocument, WorkflowRunDeterminismStatusDocument, WorkflowRunStackTraceDocument, SignalWorkflowRunDocument } from './chunk-
|
|
6
|
+
import { TerminateWorkflowRunDocument, WorkflowRunHistoryDocument, RunEventAppendedDocument, WorkflowProposalDocument, ProposeRunFixDocument, ProposeWorkflowChangeDocument, ApplyWorkflowProposalDocument, RejectWorkflowProposalDocument, CancelWorkflowProposalDocument, WorkflowTestCasesDocument, WorkflowTestRunsDocument, WorkflowTestRunDocument, CreateWorkflowTestCaseDocument, UpdateWorkflowTestCaseDocument, DeleteWorkflowTestCaseDocument, RunWorkflowTestsDocument, CreateWorkflowTestCaseFromRunDocument, DurableRunFieldsDocument, WorkflowRunDeterminismStatusDocument, WorkflowRunStackTraceDocument, SignalWorkflowRunDocument } from './chunk-KEYKB4E7.js';
|
|
6
7
|
import { useTr } from './chunk-UULVIT25.js';
|
|
7
8
|
import { getFluidGridsClient, getFluidGridsClientSafe } from './chunk-NTWG3CJX.js';
|
|
8
9
|
import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
|
|
@@ -1780,4 +1781,848 @@ function WorkflowProposalCard({
|
|
|
1780
1781
|
);
|
|
1781
1782
|
}
|
|
1782
1783
|
|
|
1783
|
-
|
|
1784
|
+
// src/builder/lib/assert-rules.ts
|
|
1785
|
+
var ASSERT_OPERATORS = [
|
|
1786
|
+
{
|
|
1787
|
+
wire: "equals",
|
|
1788
|
+
value: "EQUALS" /* Equals */,
|
|
1789
|
+
operand: "expected",
|
|
1790
|
+
label: "equals"
|
|
1791
|
+
},
|
|
1792
|
+
{
|
|
1793
|
+
wire: "notEquals",
|
|
1794
|
+
value: "NOT_EQUALS" /* NotEquals */,
|
|
1795
|
+
operand: "expected",
|
|
1796
|
+
label: "does not equal"
|
|
1797
|
+
},
|
|
1798
|
+
{
|
|
1799
|
+
wire: "contains",
|
|
1800
|
+
value: "CONTAINS" /* Contains */,
|
|
1801
|
+
operand: "expected",
|
|
1802
|
+
label: "contains"
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
wire: "notContains",
|
|
1806
|
+
value: "NOT_CONTAINS" /* NotContains */,
|
|
1807
|
+
operand: "expected",
|
|
1808
|
+
label: "does not contain"
|
|
1809
|
+
},
|
|
1810
|
+
{
|
|
1811
|
+
wire: "matches",
|
|
1812
|
+
value: "MATCHES" /* Matches */,
|
|
1813
|
+
operand: "expected",
|
|
1814
|
+
label: "matches regex"
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
wire: "jsonSchema",
|
|
1818
|
+
value: "JSON_SCHEMA" /* JsonSchema */,
|
|
1819
|
+
operand: "expected",
|
|
1820
|
+
label: "matches JSON Schema"
|
|
1821
|
+
},
|
|
1822
|
+
{
|
|
1823
|
+
wire: "between",
|
|
1824
|
+
value: "BETWEEN" /* Between */,
|
|
1825
|
+
operand: "range",
|
|
1826
|
+
label: "is between"
|
|
1827
|
+
},
|
|
1828
|
+
{
|
|
1829
|
+
wire: "itemCount",
|
|
1830
|
+
value: "ITEM_COUNT" /* ItemCount */,
|
|
1831
|
+
operand: "range",
|
|
1832
|
+
label: "has item count"
|
|
1833
|
+
},
|
|
1834
|
+
{
|
|
1835
|
+
wire: "exists",
|
|
1836
|
+
value: "EXISTS" /* Exists */,
|
|
1837
|
+
operand: "none",
|
|
1838
|
+
label: "exists"
|
|
1839
|
+
},
|
|
1840
|
+
{
|
|
1841
|
+
wire: "notExists",
|
|
1842
|
+
value: "NOT_EXISTS" /* NotExists */,
|
|
1843
|
+
operand: "none",
|
|
1844
|
+
label: "does not exist"
|
|
1845
|
+
}
|
|
1846
|
+
];
|
|
1847
|
+
var MAX_REGEX_LENGTH = 500;
|
|
1848
|
+
var MAX_RULES = 50;
|
|
1849
|
+
function operatorSpec(value) {
|
|
1850
|
+
if (typeof value !== "string") return null;
|
|
1851
|
+
return ASSERT_OPERATORS.find(
|
|
1852
|
+
(spec) => spec.wire === value || spec.value === value
|
|
1853
|
+
) ?? null;
|
|
1854
|
+
}
|
|
1855
|
+
function isRecord2(value) {
|
|
1856
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1857
|
+
}
|
|
1858
|
+
function optionalNumber(value) {
|
|
1859
|
+
if (value === void 0 || value === null) return void 0;
|
|
1860
|
+
return typeof value === "number" && Number.isFinite(value) ? value : false;
|
|
1861
|
+
}
|
|
1862
|
+
function normaliseAssertRule(raw, index) {
|
|
1863
|
+
if (!isRecord2(raw)) return { problem: { code: "notObject", index } };
|
|
1864
|
+
const spec = operatorSpec(raw.operator);
|
|
1865
|
+
if (!spec)
|
|
1866
|
+
return {
|
|
1867
|
+
problem: {
|
|
1868
|
+
code: "unknownOperator",
|
|
1869
|
+
index,
|
|
1870
|
+
operator: String(raw.operator ?? "")
|
|
1871
|
+
}
|
|
1872
|
+
};
|
|
1873
|
+
const rule = { operator: spec.wire };
|
|
1874
|
+
if (raw.path !== void 0 && raw.path !== null && raw.path !== "") {
|
|
1875
|
+
if (typeof raw.path !== "string")
|
|
1876
|
+
return { problem: { code: "pathInvalid", index } };
|
|
1877
|
+
rule.path = raw.path;
|
|
1878
|
+
}
|
|
1879
|
+
if (raw.message !== void 0 && raw.message !== null && raw.message !== "") {
|
|
1880
|
+
if (typeof raw.message !== "string")
|
|
1881
|
+
return { problem: { code: "messageInvalid", index } };
|
|
1882
|
+
rule.message = raw.message;
|
|
1883
|
+
}
|
|
1884
|
+
if (spec.operand === "expected") {
|
|
1885
|
+
if (!("expected" in raw))
|
|
1886
|
+
return { problem: { code: "expectedRequired", index } };
|
|
1887
|
+
if (spec.wire === "matches") {
|
|
1888
|
+
if (typeof raw.expected !== "string")
|
|
1889
|
+
return { problem: { code: "regexInvalid", index } };
|
|
1890
|
+
if (raw.expected.length > MAX_REGEX_LENGTH)
|
|
1891
|
+
return { problem: { code: "regexTooLong", index } };
|
|
1892
|
+
try {
|
|
1893
|
+
new RegExp(raw.expected);
|
|
1894
|
+
} catch {
|
|
1895
|
+
return { problem: { code: "regexInvalid", index } };
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
if (spec.wire === "jsonSchema" && !isRecord2(raw.expected))
|
|
1899
|
+
return { problem: { code: "schemaInvalid", index } };
|
|
1900
|
+
rule.expected = raw.expected;
|
|
1901
|
+
}
|
|
1902
|
+
if (spec.operand === "range") {
|
|
1903
|
+
const min = optionalNumber(raw.min);
|
|
1904
|
+
const max = optionalNumber(raw.max);
|
|
1905
|
+
if (min === false || max === false)
|
|
1906
|
+
return { problem: { code: "rangeInvalid", index } };
|
|
1907
|
+
if (min === void 0 && max === void 0)
|
|
1908
|
+
return { problem: { code: "rangeRequired", index } };
|
|
1909
|
+
if (min !== void 0 && max !== void 0 && min > max)
|
|
1910
|
+
return { problem: { code: "rangeInvalid", index } };
|
|
1911
|
+
if (min !== void 0) rule.min = min;
|
|
1912
|
+
if (max !== void 0) rule.max = max;
|
|
1913
|
+
}
|
|
1914
|
+
return { rule };
|
|
1915
|
+
}
|
|
1916
|
+
function normaliseAssertRules(raw) {
|
|
1917
|
+
if (raw.length === 0) return { problem: { code: "empty" } };
|
|
1918
|
+
if (raw.length > MAX_RULES)
|
|
1919
|
+
return { problem: { code: "tooMany", count: raw.length } };
|
|
1920
|
+
const rules = [];
|
|
1921
|
+
for (const [index, item] of raw.entries()) {
|
|
1922
|
+
const result = normaliseAssertRule(item, index);
|
|
1923
|
+
if ("problem" in result) return result;
|
|
1924
|
+
rules.push(result.rule);
|
|
1925
|
+
}
|
|
1926
|
+
return { rules };
|
|
1927
|
+
}
|
|
1928
|
+
function describeAssertRuleProblem(problem) {
|
|
1929
|
+
const at = "index" in problem ? `Rule ${problem.index + 1}: ` : "";
|
|
1930
|
+
switch (problem.code) {
|
|
1931
|
+
case "notObject":
|
|
1932
|
+
return {
|
|
1933
|
+
key: "fluidgrids.builder.assertRules.notObject",
|
|
1934
|
+
fallback: `${at}a rule must be an object.`
|
|
1935
|
+
};
|
|
1936
|
+
case "unknownOperator":
|
|
1937
|
+
return {
|
|
1938
|
+
key: "fluidgrids.builder.assertRules.unknownOperator",
|
|
1939
|
+
fallback: `${at}unknown operator "${problem.operator}". Use ${ASSERT_OPERATORS.map((spec) => spec.wire).join(", ")}.`
|
|
1940
|
+
};
|
|
1941
|
+
case "expectedRequired":
|
|
1942
|
+
return {
|
|
1943
|
+
key: "fluidgrids.builder.assertRules.expectedRequired",
|
|
1944
|
+
fallback: `${at}this operator needs an expected value.`
|
|
1945
|
+
};
|
|
1946
|
+
case "rangeRequired":
|
|
1947
|
+
return {
|
|
1948
|
+
key: "fluidgrids.builder.assertRules.rangeRequired",
|
|
1949
|
+
fallback: `${at}set a minimum, a maximum or both.`
|
|
1950
|
+
};
|
|
1951
|
+
case "rangeInvalid":
|
|
1952
|
+
return {
|
|
1953
|
+
key: "fluidgrids.builder.assertRules.rangeInvalid",
|
|
1954
|
+
fallback: `${at}minimum and maximum must be numbers, with the minimum not above the maximum.`
|
|
1955
|
+
};
|
|
1956
|
+
case "regexInvalid":
|
|
1957
|
+
return {
|
|
1958
|
+
key: "fluidgrids.builder.assertRules.regexInvalid",
|
|
1959
|
+
fallback: `${at}the expected value is not a valid regular expression.`
|
|
1960
|
+
};
|
|
1961
|
+
case "regexTooLong":
|
|
1962
|
+
return {
|
|
1963
|
+
key: "fluidgrids.builder.assertRules.regexTooLong",
|
|
1964
|
+
fallback: `${at}a regular expression may have at most ${MAX_REGEX_LENGTH} characters.`
|
|
1965
|
+
};
|
|
1966
|
+
case "schemaInvalid":
|
|
1967
|
+
return {
|
|
1968
|
+
key: "fluidgrids.builder.assertRules.schemaInvalid",
|
|
1969
|
+
fallback: `${at}the expected value must be a JSON Schema object.`
|
|
1970
|
+
};
|
|
1971
|
+
case "pathInvalid":
|
|
1972
|
+
return {
|
|
1973
|
+
key: "fluidgrids.builder.assertRules.pathInvalid",
|
|
1974
|
+
fallback: `${at}the path must be text.`
|
|
1975
|
+
};
|
|
1976
|
+
case "messageInvalid":
|
|
1977
|
+
return {
|
|
1978
|
+
key: "fluidgrids.builder.assertRules.messageInvalid",
|
|
1979
|
+
fallback: `${at}the message must be text.`
|
|
1980
|
+
};
|
|
1981
|
+
case "tooMany":
|
|
1982
|
+
return {
|
|
1983
|
+
key: "fluidgrids.builder.assertRules.tooMany",
|
|
1984
|
+
fallback: `At most ${MAX_RULES} rules (found ${problem.count}).`
|
|
1985
|
+
};
|
|
1986
|
+
case "empty":
|
|
1987
|
+
return {
|
|
1988
|
+
key: "fluidgrids.builder.assertRules.empty",
|
|
1989
|
+
fallback: "Add at least one rule."
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
function readAssertRulesSetting(value) {
|
|
1994
|
+
if (value === void 0 || value === null || value === "") return [];
|
|
1995
|
+
if (Array.isArray(value)) return value;
|
|
1996
|
+
if (typeof value !== "string") return null;
|
|
1997
|
+
try {
|
|
1998
|
+
const parsed = JSON.parse(value);
|
|
1999
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
2000
|
+
} catch {
|
|
2001
|
+
return null;
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
function emptyAssertRuleRow() {
|
|
2005
|
+
return {
|
|
2006
|
+
path: "",
|
|
2007
|
+
operator: "equals",
|
|
2008
|
+
expected: "",
|
|
2009
|
+
min: "",
|
|
2010
|
+
max: "",
|
|
2011
|
+
message: ""
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
function rowNumber(value) {
|
|
2015
|
+
return typeof value === "number" && Number.isFinite(value) ? String(value) : "";
|
|
2016
|
+
}
|
|
2017
|
+
function rowExpected(operator, value) {
|
|
2018
|
+
if (value === void 0) return "";
|
|
2019
|
+
if (operator === "matches" && typeof value === "string") return value;
|
|
2020
|
+
return JSON.stringify(value);
|
|
2021
|
+
}
|
|
2022
|
+
function rowsFromRules(rules) {
|
|
2023
|
+
return rules.map((raw) => {
|
|
2024
|
+
const rule = isRecord2(raw) ? raw : {};
|
|
2025
|
+
const operator = operatorSpec(rule.operator)?.wire ?? (typeof rule.operator === "string" ? rule.operator : "equals");
|
|
2026
|
+
return {
|
|
2027
|
+
path: typeof rule.path === "string" ? rule.path : "",
|
|
2028
|
+
operator,
|
|
2029
|
+
expected: rowExpected(operator, rule.expected),
|
|
2030
|
+
min: rowNumber(rule.min),
|
|
2031
|
+
max: rowNumber(rule.max),
|
|
2032
|
+
message: typeof rule.message === "string" ? rule.message : ""
|
|
2033
|
+
};
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
function parseExpected(operator, text) {
|
|
2037
|
+
if (operator === "matches") return text;
|
|
2038
|
+
try {
|
|
2039
|
+
return JSON.parse(text);
|
|
2040
|
+
} catch {
|
|
2041
|
+
return text;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
function parseRowNumber(text) {
|
|
2045
|
+
const trimmed = text.trim();
|
|
2046
|
+
if (trimmed === "") return void 0;
|
|
2047
|
+
const value = Number(trimmed);
|
|
2048
|
+
return Number.isFinite(value) ? value : trimmed;
|
|
2049
|
+
}
|
|
2050
|
+
function ruleFromRow(row) {
|
|
2051
|
+
const spec = operatorSpec(row.operator);
|
|
2052
|
+
const rule = { operator: row.operator };
|
|
2053
|
+
if (row.path.trim()) rule.path = row.path.trim();
|
|
2054
|
+
if (spec?.operand === "expected" && (row.expected !== "" || spec.wire === "matches"))
|
|
2055
|
+
rule.expected = parseExpected(spec.wire, row.expected);
|
|
2056
|
+
if (spec?.operand === "range") {
|
|
2057
|
+
const min = parseRowNumber(row.min);
|
|
2058
|
+
const max = parseRowNumber(row.max);
|
|
2059
|
+
if (min !== void 0) rule.min = min;
|
|
2060
|
+
if (max !== void 0) rule.max = max;
|
|
2061
|
+
}
|
|
2062
|
+
if (row.message.trim()) rule.message = row.message.trim();
|
|
2063
|
+
return rule;
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
// src/builder/lib/workflow-tests.ts
|
|
2067
|
+
var MAX_TEST_CASES = 50;
|
|
2068
|
+
var MAX_CASE_JSON_BYTES = 256 * 1024;
|
|
2069
|
+
var MAX_CASE_ENTRIES = 100;
|
|
2070
|
+
var MAX_CASE_NAME = 200;
|
|
2071
|
+
function emptyTestCaseDraft() {
|
|
2072
|
+
return {
|
|
2073
|
+
name: "",
|
|
2074
|
+
description: "",
|
|
2075
|
+
enabled: true,
|
|
2076
|
+
expectedStatus: "COMPLETED" /* Completed */,
|
|
2077
|
+
triggerNodeId: "",
|
|
2078
|
+
triggerData: "{}",
|
|
2079
|
+
pinnedOutputs: "{}",
|
|
2080
|
+
connectionMocks: "[]",
|
|
2081
|
+
expectations: "{}"
|
|
2082
|
+
};
|
|
2083
|
+
}
|
|
2084
|
+
function pretty(value) {
|
|
2085
|
+
return JSON.stringify(value, null, 2);
|
|
2086
|
+
}
|
|
2087
|
+
function isRecord3(value) {
|
|
2088
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2089
|
+
}
|
|
2090
|
+
function wireRule(rule) {
|
|
2091
|
+
const wire = {
|
|
2092
|
+
operator: operatorSpec(rule.operator)?.wire ?? String(rule.operator)
|
|
2093
|
+
};
|
|
2094
|
+
if (rule.path) wire.path = rule.path;
|
|
2095
|
+
if (rule.expected !== null && rule.expected !== void 0)
|
|
2096
|
+
wire.expected = rule.expected;
|
|
2097
|
+
if (rule.min !== null && rule.min !== void 0) wire.min = rule.min;
|
|
2098
|
+
if (rule.max !== null && rule.max !== void 0) wire.max = rule.max;
|
|
2099
|
+
if (rule.message) wire.message = rule.message;
|
|
2100
|
+
return wire;
|
|
2101
|
+
}
|
|
2102
|
+
function draftFromTestCase(testCase) {
|
|
2103
|
+
const expectations = {};
|
|
2104
|
+
for (const expectation of testCase.expectations)
|
|
2105
|
+
expectations[expectation.nodeId] = expectation.rules.map(wireRule);
|
|
2106
|
+
const mocks = testCase.connectionMocks.map((mock) => {
|
|
2107
|
+
const entry = { nodeId: mock.nodeId };
|
|
2108
|
+
if (mock.operation) entry.operation = mock.operation;
|
|
2109
|
+
if (mock.error) {
|
|
2110
|
+
entry.error = mock.error.errorType ? { message: mock.error.message, errorType: mock.error.errorType } : { message: mock.error.message };
|
|
2111
|
+
} else {
|
|
2112
|
+
entry.response = mock.response ?? {};
|
|
2113
|
+
}
|
|
2114
|
+
return entry;
|
|
2115
|
+
});
|
|
2116
|
+
return {
|
|
2117
|
+
name: testCase.name,
|
|
2118
|
+
description: testCase.description ?? "",
|
|
2119
|
+
enabled: testCase.enabled,
|
|
2120
|
+
expectedStatus: testCase.expectedStatus,
|
|
2121
|
+
triggerNodeId: testCase.triggerNodeId ?? "",
|
|
2122
|
+
triggerData: pretty(testCase.triggerData ?? {}),
|
|
2123
|
+
pinnedOutputs: pretty(testCase.pinnedOutputs ?? {}),
|
|
2124
|
+
connectionMocks: pretty(mocks),
|
|
2125
|
+
expectations: pretty(expectations)
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
function pinnedOutputsFromCanvas(pinned) {
|
|
2129
|
+
const outputs = {};
|
|
2130
|
+
for (const [nodeId, entry] of Object.entries(pinned ?? {})) {
|
|
2131
|
+
if (entry && isRecord3(entry.data)) outputs[nodeId] = { data: entry.data };
|
|
2132
|
+
}
|
|
2133
|
+
return outputs;
|
|
2134
|
+
}
|
|
2135
|
+
function parseJson(text, field, label) {
|
|
2136
|
+
const source = text.trim();
|
|
2137
|
+
if (source === "") return { value: void 0 };
|
|
2138
|
+
try {
|
|
2139
|
+
return { value: JSON.parse(source) };
|
|
2140
|
+
} catch (err) {
|
|
2141
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
2142
|
+
return {
|
|
2143
|
+
error: {
|
|
2144
|
+
field,
|
|
2145
|
+
key: "fluidgrids.builder.workflowTests.invalidJson",
|
|
2146
|
+
fallback: `${label} is not valid JSON: ${reason}`
|
|
2147
|
+
}
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
function fieldError(field, key, fallback) {
|
|
2152
|
+
return {
|
|
2153
|
+
error: { field, key: `fluidgrids.builder.workflowTests.${key}`, fallback }
|
|
2154
|
+
};
|
|
2155
|
+
}
|
|
2156
|
+
function parseTriggerData(text) {
|
|
2157
|
+
const parsed = parseJson(text, "triggerData", "Trigger data");
|
|
2158
|
+
if ("error" in parsed) return parsed;
|
|
2159
|
+
if (parsed.value === void 0) return { value: {} };
|
|
2160
|
+
if (!isRecord3(parsed.value))
|
|
2161
|
+
return fieldError(
|
|
2162
|
+
"triggerData",
|
|
2163
|
+
"triggerDataShape",
|
|
2164
|
+
"Trigger data must be a JSON object."
|
|
2165
|
+
);
|
|
2166
|
+
return { value: parsed.value };
|
|
2167
|
+
}
|
|
2168
|
+
function parsePinnedOutputs(text) {
|
|
2169
|
+
const parsed = parseJson(text, "pinnedOutputs", "Pinned outputs");
|
|
2170
|
+
if ("error" in parsed) return parsed;
|
|
2171
|
+
if (parsed.value === void 0) return { value: {} };
|
|
2172
|
+
if (!isRecord3(parsed.value))
|
|
2173
|
+
return fieldError(
|
|
2174
|
+
"pinnedOutputs",
|
|
2175
|
+
"pinnedShape",
|
|
2176
|
+
'Pinned outputs must be an object of { "nodeId": { "data": { ... } } }.'
|
|
2177
|
+
);
|
|
2178
|
+
const entries = Object.entries(parsed.value);
|
|
2179
|
+
if (entries.length > MAX_CASE_ENTRIES)
|
|
2180
|
+
return fieldError(
|
|
2181
|
+
"pinnedOutputs",
|
|
2182
|
+
"pinnedTooMany",
|
|
2183
|
+
`At most ${MAX_CASE_ENTRIES} pinned nodes.`
|
|
2184
|
+
);
|
|
2185
|
+
const outputs = {};
|
|
2186
|
+
for (const [nodeId, entry] of entries) {
|
|
2187
|
+
if (!isRecord3(entry) || !isRecord3(entry.data))
|
|
2188
|
+
return fieldError(
|
|
2189
|
+
"pinnedOutputs",
|
|
2190
|
+
"pinnedShape",
|
|
2191
|
+
`Pinned output "${nodeId}" must be { "data": { ... } }.`
|
|
2192
|
+
);
|
|
2193
|
+
outputs[nodeId] = { data: entry.data };
|
|
2194
|
+
}
|
|
2195
|
+
return { value: outputs };
|
|
2196
|
+
}
|
|
2197
|
+
var ERROR_TYPES = new Set(Object.values(ErrorType));
|
|
2198
|
+
function isErrorType(value) {
|
|
2199
|
+
return ERROR_TYPES.has(value);
|
|
2200
|
+
}
|
|
2201
|
+
function parseConnectionMocks(text) {
|
|
2202
|
+
const parsed = parseJson(text, "connectionMocks", "Connection mocks");
|
|
2203
|
+
if ("error" in parsed) return parsed;
|
|
2204
|
+
if (parsed.value === void 0) return { value: [] };
|
|
2205
|
+
if (!Array.isArray(parsed.value))
|
|
2206
|
+
return fieldError(
|
|
2207
|
+
"connectionMocks",
|
|
2208
|
+
"mocksShape",
|
|
2209
|
+
'Connection mocks must be an array of { "nodeId", "response" } or { "nodeId", "error" }.'
|
|
2210
|
+
);
|
|
2211
|
+
if (parsed.value.length > MAX_CASE_ENTRIES)
|
|
2212
|
+
return fieldError(
|
|
2213
|
+
"connectionMocks",
|
|
2214
|
+
"mocksTooMany",
|
|
2215
|
+
`At most ${MAX_CASE_ENTRIES} connection mocks.`
|
|
2216
|
+
);
|
|
2217
|
+
const mocks = [];
|
|
2218
|
+
for (const [index, raw] of parsed.value.entries()) {
|
|
2219
|
+
const at = `Mock ${index + 1}`;
|
|
2220
|
+
if (!isRecord3(raw) || typeof raw.nodeId !== "string" || !raw.nodeId)
|
|
2221
|
+
return fieldError(
|
|
2222
|
+
"connectionMocks",
|
|
2223
|
+
"mockNodeRequired",
|
|
2224
|
+
`${at} needs a "nodeId".`
|
|
2225
|
+
);
|
|
2226
|
+
if (raw.operation !== void 0 && raw.operation !== null && typeof raw.operation !== "string")
|
|
2227
|
+
return fieldError(
|
|
2228
|
+
"connectionMocks",
|
|
2229
|
+
"mockOperationInvalid",
|
|
2230
|
+
`${at}: "operation" must be text.`
|
|
2231
|
+
);
|
|
2232
|
+
const hasResponse = raw.response !== void 0 && raw.response !== null;
|
|
2233
|
+
const hasError = raw.error !== void 0 && raw.error !== null;
|
|
2234
|
+
if (hasResponse === hasError)
|
|
2235
|
+
return fieldError(
|
|
2236
|
+
"connectionMocks",
|
|
2237
|
+
"mockResponseOrError",
|
|
2238
|
+
`${at} must set exactly one of "response" and "error".`
|
|
2239
|
+
);
|
|
2240
|
+
const mock = { nodeId: raw.nodeId };
|
|
2241
|
+
if (typeof raw.operation === "string" && raw.operation)
|
|
2242
|
+
mock.operation = raw.operation;
|
|
2243
|
+
if (hasResponse) {
|
|
2244
|
+
mock.response = jsonScalar(raw.response);
|
|
2245
|
+
} else {
|
|
2246
|
+
const error = raw.error;
|
|
2247
|
+
if (!isRecord3(error) || typeof error.message !== "string")
|
|
2248
|
+
return fieldError(
|
|
2249
|
+
"connectionMocks",
|
|
2250
|
+
"mockErrorShape",
|
|
2251
|
+
`${at}: "error" must be { "message": "...", "errorType"?: "..." }.`
|
|
2252
|
+
);
|
|
2253
|
+
const errorType = error.errorType;
|
|
2254
|
+
if (errorType !== void 0 && errorType !== null) {
|
|
2255
|
+
if (typeof errorType !== "string" || !isErrorType(errorType))
|
|
2256
|
+
return fieldError(
|
|
2257
|
+
"connectionMocks",
|
|
2258
|
+
"mockErrorType",
|
|
2259
|
+
`${at}: "errorType" must be one of ${[...ERROR_TYPES].join(", ")}.`
|
|
2260
|
+
);
|
|
2261
|
+
mock.error = { message: error.message, errorType };
|
|
2262
|
+
} else {
|
|
2263
|
+
mock.error = { message: error.message };
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
mocks.push(mock);
|
|
2267
|
+
}
|
|
2268
|
+
return { value: mocks };
|
|
2269
|
+
}
|
|
2270
|
+
function jsonScalar(value) {
|
|
2271
|
+
return value;
|
|
2272
|
+
}
|
|
2273
|
+
function ruleInput(rule) {
|
|
2274
|
+
const spec = operatorSpec(rule.operator);
|
|
2275
|
+
if (!spec) return [];
|
|
2276
|
+
const input = { operator: spec.value };
|
|
2277
|
+
if (rule.path !== void 0) input.path = rule.path;
|
|
2278
|
+
if (rule.expected !== void 0) input.expected = jsonScalar(rule.expected);
|
|
2279
|
+
if (rule.min !== void 0) input.min = rule.min;
|
|
2280
|
+
if (rule.max !== void 0) input.max = rule.max;
|
|
2281
|
+
if (rule.message !== void 0) input.message = rule.message;
|
|
2282
|
+
return [input];
|
|
2283
|
+
}
|
|
2284
|
+
function expectationEntries(value) {
|
|
2285
|
+
if (isRecord3(value)) return Object.entries(value);
|
|
2286
|
+
if (Array.isArray(value)) {
|
|
2287
|
+
const entries = [];
|
|
2288
|
+
for (const item of value) {
|
|
2289
|
+
if (!isRecord3(item)) return null;
|
|
2290
|
+
entries.push([item.nodeId, item.rules]);
|
|
2291
|
+
}
|
|
2292
|
+
return entries;
|
|
2293
|
+
}
|
|
2294
|
+
return null;
|
|
2295
|
+
}
|
|
2296
|
+
function parseExpectations(text) {
|
|
2297
|
+
const parsed = parseJson(text, "expectations", "Expectations");
|
|
2298
|
+
if ("error" in parsed) return parsed;
|
|
2299
|
+
if (parsed.value === void 0) return { value: [] };
|
|
2300
|
+
const entries = expectationEntries(parsed.value);
|
|
2301
|
+
if (!entries)
|
|
2302
|
+
return fieldError(
|
|
2303
|
+
"expectations",
|
|
2304
|
+
"expectationsShape",
|
|
2305
|
+
'Expectations must be an object of { "nodeId": [rules] }.'
|
|
2306
|
+
);
|
|
2307
|
+
if (entries.length > MAX_CASE_ENTRIES)
|
|
2308
|
+
return fieldError(
|
|
2309
|
+
"expectations",
|
|
2310
|
+
"expectationsTooMany",
|
|
2311
|
+
`At most ${MAX_CASE_ENTRIES} checked nodes.`
|
|
2312
|
+
);
|
|
2313
|
+
const expectations = [];
|
|
2314
|
+
for (const [nodeId, rules] of entries) {
|
|
2315
|
+
if (typeof nodeId !== "string" || !nodeId || !Array.isArray(rules))
|
|
2316
|
+
return fieldError(
|
|
2317
|
+
"expectations",
|
|
2318
|
+
"expectationsShape",
|
|
2319
|
+
'Expectations must be an object of { "nodeId": [rules] }.'
|
|
2320
|
+
);
|
|
2321
|
+
const result = normaliseAssertRules(rules);
|
|
2322
|
+
if ("problem" in result) {
|
|
2323
|
+
const problem = describeAssertRuleProblem(result.problem);
|
|
2324
|
+
return {
|
|
2325
|
+
error: {
|
|
2326
|
+
field: "expectations",
|
|
2327
|
+
key: problem.key,
|
|
2328
|
+
fallback: `${nodeId}: ${problem.fallback}`
|
|
2329
|
+
}
|
|
2330
|
+
};
|
|
2331
|
+
}
|
|
2332
|
+
expectations.push({ nodeId, rules: result.rules.flatMap(ruleInput) });
|
|
2333
|
+
}
|
|
2334
|
+
return { value: expectations };
|
|
2335
|
+
}
|
|
2336
|
+
function draftToInput(draft, sortOrder) {
|
|
2337
|
+
const name = draft.name.trim();
|
|
2338
|
+
if (!name)
|
|
2339
|
+
return fieldError("name", "nameRequired", "Give the test case a name.");
|
|
2340
|
+
if (name.length > MAX_CASE_NAME)
|
|
2341
|
+
return fieldError(
|
|
2342
|
+
"name",
|
|
2343
|
+
"nameTooLong",
|
|
2344
|
+
`A name may have at most ${MAX_CASE_NAME} characters.`
|
|
2345
|
+
);
|
|
2346
|
+
const triggerData = parseTriggerData(draft.triggerData);
|
|
2347
|
+
if ("error" in triggerData) return triggerData;
|
|
2348
|
+
const pinnedOutputs = parsePinnedOutputs(draft.pinnedOutputs);
|
|
2349
|
+
if ("error" in pinnedOutputs) return pinnedOutputs;
|
|
2350
|
+
const connectionMocks = parseConnectionMocks(draft.connectionMocks);
|
|
2351
|
+
if ("error" in connectionMocks) return connectionMocks;
|
|
2352
|
+
const expectations = parseExpectations(draft.expectations);
|
|
2353
|
+
if ("error" in expectations) return expectations;
|
|
2354
|
+
const bytes = new TextEncoder().encode(
|
|
2355
|
+
JSON.stringify([
|
|
2356
|
+
triggerData.value,
|
|
2357
|
+
pinnedOutputs.value,
|
|
2358
|
+
connectionMocks.value,
|
|
2359
|
+
expectations.value
|
|
2360
|
+
])
|
|
2361
|
+
).length;
|
|
2362
|
+
if (bytes > MAX_CASE_JSON_BYTES)
|
|
2363
|
+
return fieldError(
|
|
2364
|
+
"size",
|
|
2365
|
+
"tooLarge",
|
|
2366
|
+
`The case holds ${Math.ceil(bytes / 1024)} KiB of JSON; the limit is ${MAX_CASE_JSON_BYTES / 1024} KiB.`
|
|
2367
|
+
);
|
|
2368
|
+
const description = draft.description.trim();
|
|
2369
|
+
const input = {
|
|
2370
|
+
name,
|
|
2371
|
+
description: description || null,
|
|
2372
|
+
triggerNodeId: draft.triggerNodeId || null,
|
|
2373
|
+
triggerData: triggerData.value,
|
|
2374
|
+
pinnedOutputs: pinnedOutputs.value,
|
|
2375
|
+
connectionMocks: connectionMocks.value,
|
|
2376
|
+
expectedStatus: draft.expectedStatus,
|
|
2377
|
+
expectations: expectations.value,
|
|
2378
|
+
enabled: draft.enabled
|
|
2379
|
+
};
|
|
2380
|
+
if (sortOrder !== void 0) input.sortOrder = sortOrder;
|
|
2381
|
+
return { input };
|
|
2382
|
+
}
|
|
2383
|
+
function isTestRunOpen(status) {
|
|
2384
|
+
return status === "PENDING" /* Pending */ || status === "RUNNING" /* Running */;
|
|
2385
|
+
}
|
|
2386
|
+
function testStatusTone(status) {
|
|
2387
|
+
switch (status) {
|
|
2388
|
+
case "PASSED" /* Passed */:
|
|
2389
|
+
return "success";
|
|
2390
|
+
case "FAILED" /* Failed */:
|
|
2391
|
+
return "error";
|
|
2392
|
+
case "ERROR" /* Error */:
|
|
2393
|
+
return "warning";
|
|
2394
|
+
default:
|
|
2395
|
+
return "pending";
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
var TEST_STATUS_TONE_CLASS = {
|
|
2399
|
+
success: "border-[var(--color-status-success-border)] bg-[var(--color-status-success-bg-subtle)] text-[var(--color-status-success-text)]",
|
|
2400
|
+
error: "border-[var(--color-status-error-border)] bg-[var(--color-status-error-bg-subtle)] text-[var(--color-status-error-text)]",
|
|
2401
|
+
warning: "border-[var(--color-status-warning-border)] bg-[var(--color-status-warning-bg-subtle)] text-[var(--color-status-warning-text)]",
|
|
2402
|
+
pending: "border-border bg-muted text-muted-foreground"
|
|
2403
|
+
};
|
|
2404
|
+
function testStatusLabel(status) {
|
|
2405
|
+
const fallback = {
|
|
2406
|
+
["PENDING" /* Pending */]: "Pending",
|
|
2407
|
+
["RUNNING" /* Running */]: "Running",
|
|
2408
|
+
["PASSED" /* Passed */]: "Passed",
|
|
2409
|
+
["FAILED" /* Failed */]: "Failed",
|
|
2410
|
+
["ERROR" /* Error */]: "Error"
|
|
2411
|
+
};
|
|
2412
|
+
return {
|
|
2413
|
+
key: `fluidgrids.builder.workflowTests.status.${status.toLowerCase()}`,
|
|
2414
|
+
fallback: fallback[status]
|
|
2415
|
+
};
|
|
2416
|
+
}
|
|
2417
|
+
function testRunSummaryText(summary) {
|
|
2418
|
+
const parts = [`${summary.passed} passed`];
|
|
2419
|
+
if (summary.failed) parts.push(`${summary.failed} failed`);
|
|
2420
|
+
if (summary.errored) parts.push(`${summary.errored} errored`);
|
|
2421
|
+
if (summary.pending) parts.push(`${summary.pending} running`);
|
|
2422
|
+
return `${parts.join(" \xB7 ")} of ${summary.total}`;
|
|
2423
|
+
}
|
|
2424
|
+
function enabledCaseIds(cases) {
|
|
2425
|
+
return cases.filter((testCase) => testCase.enabled).map((c) => c.id);
|
|
2426
|
+
}
|
|
2427
|
+
function nextSortOrder(cases) {
|
|
2428
|
+
return cases.reduce((max, c) => Math.max(max, c.sortOrder + 1), 0);
|
|
2429
|
+
}
|
|
2430
|
+
var SAVEABLE_RUN_STATUSES = /* @__PURE__ */ new Set([
|
|
2431
|
+
"COMPLETED",
|
|
2432
|
+
"FAILED"
|
|
2433
|
+
]);
|
|
2434
|
+
function canSaveRunAsTestCase(run) {
|
|
2435
|
+
return SAVEABLE_RUN_STATUSES.has(run.status) && !!run.workflowKey && !run.isDurable;
|
|
2436
|
+
}
|
|
2437
|
+
var TEST_RUN_POLL_INTERVAL_MS = 2e3;
|
|
2438
|
+
var TEST_RUN_HISTORY_LIMIT = 10;
|
|
2439
|
+
function messageOf2(error) {
|
|
2440
|
+
return error instanceof Error ? error.message : String(error);
|
|
2441
|
+
}
|
|
2442
|
+
function upsertRun(runs, run) {
|
|
2443
|
+
return [run, ...runs.filter((item) => item.id !== run.id)].slice(
|
|
2444
|
+
0,
|
|
2445
|
+
TEST_RUN_HISTORY_LIMIT
|
|
2446
|
+
);
|
|
2447
|
+
}
|
|
2448
|
+
function useWorkflowTests(workflowKey, enabled) {
|
|
2449
|
+
const [cases, setCases] = useState([]);
|
|
2450
|
+
const [runs, setRuns] = useState([]);
|
|
2451
|
+
const [activeRunId, setActiveRunId] = useState(null);
|
|
2452
|
+
const [loading, setLoading] = useState(false);
|
|
2453
|
+
const [error, setError] = useState(null);
|
|
2454
|
+
const [forbidden, setForbidden] = useState(false);
|
|
2455
|
+
const [pollTick, setPollTick] = useState(0);
|
|
2456
|
+
const keyRef = useRef(workflowKey);
|
|
2457
|
+
const refetch = useCallback(async () => {
|
|
2458
|
+
if (!enabled || !workflowKey) return;
|
|
2459
|
+
setLoading(true);
|
|
2460
|
+
setError(null);
|
|
2461
|
+
try {
|
|
2462
|
+
const client = getFluidGridsClient();
|
|
2463
|
+
const [caseResult, runResult] = await Promise.all([
|
|
2464
|
+
client.query({
|
|
2465
|
+
query: WorkflowTestCasesDocument,
|
|
2466
|
+
variables: { workflowKey },
|
|
2467
|
+
fetchPolicy: "network-only"
|
|
2468
|
+
}),
|
|
2469
|
+
client.query({
|
|
2470
|
+
query: WorkflowTestRunsDocument,
|
|
2471
|
+
variables: { workflowKey, limit: TEST_RUN_HISTORY_LIMIT },
|
|
2472
|
+
fetchPolicy: "network-only"
|
|
2473
|
+
})
|
|
2474
|
+
]);
|
|
2475
|
+
throwIfResultError(caseResult);
|
|
2476
|
+
throwIfResultError(runResult);
|
|
2477
|
+
if (keyRef.current !== workflowKey) return;
|
|
2478
|
+
setCases(caseResult.data?.workflowTestCases ?? []);
|
|
2479
|
+
setRuns(runResult.data?.workflowTestRuns ?? []);
|
|
2480
|
+
setForbidden(false);
|
|
2481
|
+
} catch (err) {
|
|
2482
|
+
if (keyRef.current !== workflowKey) return;
|
|
2483
|
+
if (isForbiddenError(err)) setForbidden(true);
|
|
2484
|
+
else setError(messageOf2(err));
|
|
2485
|
+
} finally {
|
|
2486
|
+
if (keyRef.current === workflowKey) setLoading(false);
|
|
2487
|
+
}
|
|
2488
|
+
}, [enabled, workflowKey]);
|
|
2489
|
+
useEffect(() => {
|
|
2490
|
+
keyRef.current = workflowKey;
|
|
2491
|
+
setCases([]);
|
|
2492
|
+
setRuns([]);
|
|
2493
|
+
setActiveRunId(null);
|
|
2494
|
+
setForbidden(false);
|
|
2495
|
+
setError(null);
|
|
2496
|
+
}, [workflowKey]);
|
|
2497
|
+
const activeRun = (activeRunId ? runs.find((run) => run.id === activeRunId) : runs[0]) ?? null;
|
|
2498
|
+
const followedId = activeRun && isTestRunOpen(activeRun.status) ? activeRun.id : null;
|
|
2499
|
+
useEffect(() => {
|
|
2500
|
+
if (!enabled || !followedId) return;
|
|
2501
|
+
let cancelled = false;
|
|
2502
|
+
const key = workflowKey;
|
|
2503
|
+
const timer = setTimeout(() => {
|
|
2504
|
+
void (async () => {
|
|
2505
|
+
try {
|
|
2506
|
+
const result = await getFluidGridsClient().query({
|
|
2507
|
+
query: WorkflowTestRunDocument,
|
|
2508
|
+
variables: { id: followedId },
|
|
2509
|
+
fetchPolicy: "network-only"
|
|
2510
|
+
});
|
|
2511
|
+
throwIfResultError(result);
|
|
2512
|
+
const run = result.data?.workflowTestRun;
|
|
2513
|
+
if (cancelled || keyRef.current !== key || !run) return;
|
|
2514
|
+
setRuns((current) => upsertRun(current, run));
|
|
2515
|
+
if (!isTestRunOpen(run.status)) await refetchCases(key);
|
|
2516
|
+
} catch (err) {
|
|
2517
|
+
if (!cancelled && keyRef.current === key) setError(messageOf2(err));
|
|
2518
|
+
} finally {
|
|
2519
|
+
if (!cancelled) setPollTick((tick) => tick + 1);
|
|
2520
|
+
}
|
|
2521
|
+
})();
|
|
2522
|
+
}, TEST_RUN_POLL_INTERVAL_MS);
|
|
2523
|
+
async function refetchCases(forKey) {
|
|
2524
|
+
const result = await getFluidGridsClient().query({
|
|
2525
|
+
query: WorkflowTestCasesDocument,
|
|
2526
|
+
variables: { workflowKey: forKey },
|
|
2527
|
+
fetchPolicy: "network-only"
|
|
2528
|
+
});
|
|
2529
|
+
throwIfResultError(result);
|
|
2530
|
+
if (!cancelled && keyRef.current === forKey)
|
|
2531
|
+
setCases(result.data?.workflowTestCases ?? []);
|
|
2532
|
+
}
|
|
2533
|
+
return () => {
|
|
2534
|
+
cancelled = true;
|
|
2535
|
+
clearTimeout(timer);
|
|
2536
|
+
};
|
|
2537
|
+
}, [enabled, followedId, workflowKey, pollTick]);
|
|
2538
|
+
const createCase = useCallback(
|
|
2539
|
+
async (input) => {
|
|
2540
|
+
const result = await getFluidGridsClient().mutate({
|
|
2541
|
+
mutation: CreateWorkflowTestCaseDocument,
|
|
2542
|
+
variables: { workflowKey, input }
|
|
2543
|
+
});
|
|
2544
|
+
throwIfResultError(result);
|
|
2545
|
+
const created = result.data?.createWorkflowTestCase;
|
|
2546
|
+
if (!created) throw new Error("The test case was not saved.");
|
|
2547
|
+
await refetch();
|
|
2548
|
+
return created;
|
|
2549
|
+
},
|
|
2550
|
+
[workflowKey, refetch]
|
|
2551
|
+
);
|
|
2552
|
+
const updateCase = useCallback(
|
|
2553
|
+
async (id, input) => {
|
|
2554
|
+
const result = await getFluidGridsClient().mutate({
|
|
2555
|
+
mutation: UpdateWorkflowTestCaseDocument,
|
|
2556
|
+
variables: { id, input }
|
|
2557
|
+
});
|
|
2558
|
+
throwIfResultError(result);
|
|
2559
|
+
const updated = result.data?.updateWorkflowTestCase;
|
|
2560
|
+
if (!updated) throw new Error("The test case was not saved.");
|
|
2561
|
+
await refetch();
|
|
2562
|
+
return updated;
|
|
2563
|
+
},
|
|
2564
|
+
[refetch]
|
|
2565
|
+
);
|
|
2566
|
+
const deleteCase = useCallback(
|
|
2567
|
+
async (id) => {
|
|
2568
|
+
const result = await getFluidGridsClient().mutate({
|
|
2569
|
+
mutation: DeleteWorkflowTestCaseDocument,
|
|
2570
|
+
variables: { id }
|
|
2571
|
+
});
|
|
2572
|
+
throwIfResultError(result);
|
|
2573
|
+
await refetch();
|
|
2574
|
+
},
|
|
2575
|
+
[refetch]
|
|
2576
|
+
);
|
|
2577
|
+
const runTests = useCallback(
|
|
2578
|
+
async (options = {}) => {
|
|
2579
|
+
const result = await getFluidGridsClient().mutate({
|
|
2580
|
+
mutation: RunWorkflowTestsDocument,
|
|
2581
|
+
variables: {
|
|
2582
|
+
input: {
|
|
2583
|
+
workflowKey,
|
|
2584
|
+
source: "UI" /* Ui */,
|
|
2585
|
+
...options.version ? { version: options.version } : {},
|
|
2586
|
+
...options.caseIds ? { caseIds: options.caseIds } : {}
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
});
|
|
2590
|
+
throwIfResultError(result);
|
|
2591
|
+
const run = result.data?.runWorkflowTests;
|
|
2592
|
+
if (!run) throw new Error("The test run did not start.");
|
|
2593
|
+
setRuns((current) => upsertRun(current, run));
|
|
2594
|
+
setActiveRunId(run.id);
|
|
2595
|
+
return run;
|
|
2596
|
+
},
|
|
2597
|
+
[workflowKey]
|
|
2598
|
+
);
|
|
2599
|
+
return {
|
|
2600
|
+
cases,
|
|
2601
|
+
runs,
|
|
2602
|
+
activeRun,
|
|
2603
|
+
loading,
|
|
2604
|
+
error,
|
|
2605
|
+
forbidden,
|
|
2606
|
+
refetch,
|
|
2607
|
+
createCase,
|
|
2608
|
+
updateCase,
|
|
2609
|
+
deleteCase,
|
|
2610
|
+
runTests
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
async function saveRunAsTestCase(runId, name, description) {
|
|
2614
|
+
const result = await getFluidGridsClient().mutate({
|
|
2615
|
+
mutation: CreateWorkflowTestCaseFromRunDocument,
|
|
2616
|
+
variables: {
|
|
2617
|
+
runId,
|
|
2618
|
+
name,
|
|
2619
|
+
...description ? { description } : {}
|
|
2620
|
+
}
|
|
2621
|
+
});
|
|
2622
|
+
throwIfResultError(result);
|
|
2623
|
+
const created = result.data?.createWorkflowTestCaseFromRun;
|
|
2624
|
+
if (!created) throw new Error("The test case was not saved.");
|
|
2625
|
+
return created;
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
export { ASSERT_OPERATORS, EntityTagPicker, MAX_CASE_NAME, MAX_TEST_CASES, RunHistoryView, SignalRunDialog, TEST_STATUS_TONE_CLASS, WorkflowProposalCard, canSaveRunAsTestCase, describeAssertRuleProblem, draftFromTestCase, draftToInput, emptyAssertRuleRow, emptyTestCaseDraft, enabledCaseIds, isTestRunOpen, nextSortOrder, normaliseAssertRules, operatorSpec, pinnedOutputsFromCanvas, readAssertRulesSetting, rowsFromRules, ruleFromRow, saveRunAsTestCase, terminateDurableRun, testRunSummaryText, testStatusLabel, testStatusTone, useDeterminismStatus, useDurableRunFields, useRunHistory, useRunStackTrace, useWorkflowProposal, useWorkflowTests };
|