@flowgram.ai/form-materials 0.2.17 → 0.2.18
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/esm/index.js +256 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +35 -7
- package/dist/index.d.ts +35 -7
- package/dist/index.js +295 -49
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/src/components/dynamic-value-input/index.tsx +1 -0
- package/src/components/dynamic-value-input/styles.tsx +2 -0
- package/src/components/index.ts +2 -0
- package/src/components/prompt-editor/config.json +9 -0
- package/src/components/prompt-editor/extensions/jinja.tsx +58 -0
- package/src/components/prompt-editor/extensions/language-support.tsx +19 -0
- package/src/components/prompt-editor/extensions/markdown.tsx +75 -0
- package/src/components/prompt-editor/index.tsx +43 -0
- package/src/components/prompt-editor/styles.tsx +18 -0
- package/src/components/prompt-editor/types.tsx +16 -0
- package/src/components/prompt-editor-with-variables/config.json +10 -0
- package/src/components/prompt-editor-with-variables/extensions/variable.tsx +85 -0
- package/src/components/prompt-editor-with-variables/index.tsx +17 -0
- package/src/components/variable-selector/index.tsx +2 -2
- package/src/components/variable-selector/styles.tsx +12 -1
- package/src/utils/json-schema/index.ts +16 -2
package/dist/index.js
CHANGED
|
@@ -38,6 +38,8 @@ __export(src_exports, {
|
|
|
38
38
|
DynamicValueInput: () => DynamicValueInput,
|
|
39
39
|
JsonSchemaEditor: () => JsonSchemaEditor,
|
|
40
40
|
JsonSchemaUtils: () => JsonSchemaUtils,
|
|
41
|
+
PromptEditor: () => PromptEditor,
|
|
42
|
+
PromptEditorWithVariables: () => PromptEditorWithVariables,
|
|
41
43
|
TypeSelector: () => TypeSelector,
|
|
42
44
|
VariableSelector: () => VariableSelector,
|
|
43
45
|
VariableTypeIcons: () => VariableTypeIcons,
|
|
@@ -478,7 +480,10 @@ var JsonSchemaUtils;
|
|
|
478
480
|
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0, import_lodash.get)(a?.[1], "extra.index") || 0) - ((0, import_lodash.get)(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
|
|
479
481
|
key,
|
|
480
482
|
type: schemaToAST(_property),
|
|
481
|
-
meta: {
|
|
483
|
+
meta: {
|
|
484
|
+
title: _property.title,
|
|
485
|
+
description: _property.description
|
|
486
|
+
}
|
|
482
487
|
}))
|
|
483
488
|
});
|
|
484
489
|
case "array":
|
|
@@ -534,7 +539,16 @@ var JsonSchemaUtils;
|
|
|
534
539
|
return {
|
|
535
540
|
type: "object",
|
|
536
541
|
properties: drilldown ? Object.fromEntries(
|
|
537
|
-
typeAST.properties.map((property) =>
|
|
542
|
+
typeAST.properties.map((property) => {
|
|
543
|
+
const schema = astToSchema(property.type);
|
|
544
|
+
if (property.meta?.title && schema) {
|
|
545
|
+
schema.title = property.meta.title;
|
|
546
|
+
}
|
|
547
|
+
if (property.meta?.description && schema) {
|
|
548
|
+
schema.description = property.meta.description;
|
|
549
|
+
}
|
|
550
|
+
return [property.key, schema];
|
|
551
|
+
})
|
|
538
552
|
) : {}
|
|
539
553
|
};
|
|
540
554
|
}
|
|
@@ -631,10 +645,20 @@ function useVariableTree(params) {
|
|
|
631
645
|
// src/components/variable-selector/styles.tsx
|
|
632
646
|
var import_styled_components = __toESM(require("styled-components"));
|
|
633
647
|
var import_semi_ui2 = require("@douyinfe/semi-ui");
|
|
634
|
-
var UIRootTitle = import_styled_components.default.
|
|
648
|
+
var UIRootTitle = import_styled_components.default.div`
|
|
635
649
|
margin-right: 4px;
|
|
650
|
+
min-width: 20px;
|
|
651
|
+
overflow: hidden;
|
|
652
|
+
text-overflow: ellipsis;
|
|
653
|
+
white-space: nowrap;
|
|
636
654
|
color: var(--semi-color-text-2);
|
|
637
655
|
`;
|
|
656
|
+
var UIVarName = import_styled_components.default.div`
|
|
657
|
+
overflow: hidden;
|
|
658
|
+
text-overflow: ellipsis;
|
|
659
|
+
white-space: nowrap;
|
|
660
|
+
min-width: 50%;
|
|
661
|
+
`;
|
|
638
662
|
var UITag = (0, import_styled_components.default)(import_semi_ui2.Tag)`
|
|
639
663
|
width: 100%;
|
|
640
664
|
display: flex;
|
|
@@ -735,7 +759,7 @@ var VariableSelector = ({
|
|
|
735
759
|
onClose: () => onChange(void 0)
|
|
736
760
|
},
|
|
737
761
|
/* @__PURE__ */ import_react3.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null),
|
|
738
|
-
_option.label
|
|
762
|
+
/* @__PURE__ */ import_react3.default.createElement(UIVarName, null, _option.label)
|
|
739
763
|
);
|
|
740
764
|
},
|
|
741
765
|
showClear: false,
|
|
@@ -1178,14 +1202,14 @@ function ConstantInput(props) {
|
|
|
1178
1202
|
() => [...defaultStrategies, ...extraStrategies || []],
|
|
1179
1203
|
[extraStrategies]
|
|
1180
1204
|
);
|
|
1181
|
-
const
|
|
1205
|
+
const Renderer2 = (0, import_react7.useMemo)(() => {
|
|
1182
1206
|
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1183
1207
|
return strategy?.Renderer;
|
|
1184
1208
|
}, [strategies, schema]);
|
|
1185
|
-
if (!
|
|
1209
|
+
if (!Renderer2) {
|
|
1186
1210
|
return /* @__PURE__ */ import_react7.default.createElement(import_semi_ui4.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1187
1211
|
}
|
|
1188
|
-
return /* @__PURE__ */ import_react7.default.createElement(
|
|
1212
|
+
return /* @__PURE__ */ import_react7.default.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1189
1213
|
}
|
|
1190
1214
|
|
|
1191
1215
|
// src/components/json-schema-editor/default-value.tsx
|
|
@@ -1493,6 +1517,8 @@ var UIContainer2 = import_styled_components3.default.div`
|
|
|
1493
1517
|
`;
|
|
1494
1518
|
var UIMain = import_styled_components3.default.div`
|
|
1495
1519
|
flex-grow: 1;
|
|
1520
|
+
overflow: hidden;
|
|
1521
|
+
min-width: 0;
|
|
1496
1522
|
|
|
1497
1523
|
& .semi-tree-select,
|
|
1498
1524
|
& .semi-input-number,
|
|
@@ -1522,6 +1548,7 @@ function DynamicValueInput({
|
|
|
1522
1548
|
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1523
1549
|
VariableSelector,
|
|
1524
1550
|
{
|
|
1551
|
+
style: { width: "100%" },
|
|
1525
1552
|
value: value?.content,
|
|
1526
1553
|
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
1527
1554
|
includeSchema,
|
|
@@ -1972,30 +1999,247 @@ function BatchOutputs(props) {
|
|
|
1972
1999
|
)))), /* @__PURE__ */ import_react17.default.createElement(import_semi_ui10.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons8.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
1973
2000
|
}
|
|
1974
2001
|
|
|
2002
|
+
// src/components/prompt-editor/index.tsx
|
|
2003
|
+
var import_react24 = __toESM(require("react"));
|
|
2004
|
+
var import_react25 = require("@coze-editor/editor/react");
|
|
2005
|
+
var import_preset_prompt2 = __toESM(require("@coze-editor/editor/preset-prompt"));
|
|
2006
|
+
|
|
2007
|
+
// src/components/prompt-editor/styles.tsx
|
|
2008
|
+
var import_styled_components6 = __toESM(require("styled-components"));
|
|
2009
|
+
var UIContainer4 = import_styled_components6.default.div`
|
|
2010
|
+
background-color: var(--semi-color-fill-0);
|
|
2011
|
+
padding-left: 10px;
|
|
2012
|
+
padding-right: 6px;
|
|
2013
|
+
|
|
2014
|
+
${({ $hasError }) => $hasError && import_styled_components6.css`
|
|
2015
|
+
border: 1px solid var(--semi-color-danger-6);
|
|
2016
|
+
`}
|
|
2017
|
+
`;
|
|
2018
|
+
|
|
2019
|
+
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2020
|
+
var import_react18 = require("react");
|
|
2021
|
+
var import_react19 = require("@coze-editor/editor/react");
|
|
2022
|
+
var import_editor5 = require("@coze-editor/editor");
|
|
2023
|
+
var import_view = require("@codemirror/view");
|
|
2024
|
+
function MarkdownHighlight() {
|
|
2025
|
+
const injector = (0, import_react19.useInjector)();
|
|
2026
|
+
(0, import_react18.useLayoutEffect)(
|
|
2027
|
+
() => injector.inject([
|
|
2028
|
+
import_editor5.astDecorator.whole.of((cursor) => {
|
|
2029
|
+
if (cursor.name.startsWith("ATXHeading")) {
|
|
2030
|
+
return {
|
|
2031
|
+
type: "className",
|
|
2032
|
+
className: "heading"
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
if (cursor.name === "Emphasis") {
|
|
2036
|
+
return {
|
|
2037
|
+
type: "className",
|
|
2038
|
+
className: "emphasis"
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
if (cursor.name === "StrongEmphasis") {
|
|
2042
|
+
return {
|
|
2043
|
+
type: "className",
|
|
2044
|
+
className: "strong-emphasis"
|
|
2045
|
+
};
|
|
2046
|
+
}
|
|
2047
|
+
if (cursor.name === "ListMark" || cursor.name === "QuoteMark") {
|
|
2048
|
+
return {
|
|
2049
|
+
type: "className",
|
|
2050
|
+
className: "mark"
|
|
2051
|
+
};
|
|
2052
|
+
}
|
|
2053
|
+
}),
|
|
2054
|
+
import_view.EditorView.theme({
|
|
2055
|
+
".heading": {
|
|
2056
|
+
color: "#00818C",
|
|
2057
|
+
fontWeight: "bold"
|
|
2058
|
+
},
|
|
2059
|
+
".emphasis": {
|
|
2060
|
+
fontStyle: "italic"
|
|
2061
|
+
},
|
|
2062
|
+
".strong-emphasis": {
|
|
2063
|
+
fontWeight: "bold"
|
|
2064
|
+
},
|
|
2065
|
+
".mark": {
|
|
2066
|
+
color: "#4E40E5"
|
|
2067
|
+
}
|
|
2068
|
+
})
|
|
2069
|
+
]),
|
|
2070
|
+
[injector]
|
|
2071
|
+
);
|
|
2072
|
+
return null;
|
|
2073
|
+
}
|
|
2074
|
+
var markdown_default = MarkdownHighlight;
|
|
2075
|
+
|
|
2076
|
+
// src/components/prompt-editor/extensions/language-support.tsx
|
|
2077
|
+
var import_react20 = require("react");
|
|
2078
|
+
var import_react21 = require("@coze-editor/editor/react");
|
|
2079
|
+
var import_preset_prompt = require("@coze-editor/editor/preset-prompt");
|
|
2080
|
+
function LanguageSupport() {
|
|
2081
|
+
const injector = (0, import_react21.useInjector)();
|
|
2082
|
+
(0, import_react20.useLayoutEffect)(() => injector.inject([import_preset_prompt.languageSupport]), [injector]);
|
|
2083
|
+
return null;
|
|
2084
|
+
}
|
|
2085
|
+
var language_support_default = LanguageSupport;
|
|
2086
|
+
|
|
2087
|
+
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2088
|
+
var import_react22 = require("react");
|
|
2089
|
+
var import_react23 = require("@coze-editor/editor/react");
|
|
2090
|
+
var import_editor6 = require("@coze-editor/editor");
|
|
2091
|
+
var import_view2 = require("@codemirror/view");
|
|
2092
|
+
function JinjaHighlight() {
|
|
2093
|
+
const injector = (0, import_react23.useInjector)();
|
|
2094
|
+
(0, import_react22.useLayoutEffect)(
|
|
2095
|
+
() => injector.inject([
|
|
2096
|
+
import_editor6.astDecorator.whole.of((cursor) => {
|
|
2097
|
+
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2098
|
+
return {
|
|
2099
|
+
type: "className",
|
|
2100
|
+
className: "jinja-statement-bracket"
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
if (cursor.name === "JinjaComment") {
|
|
2104
|
+
return {
|
|
2105
|
+
type: "className",
|
|
2106
|
+
className: "jinja-comment"
|
|
2107
|
+
};
|
|
2108
|
+
}
|
|
2109
|
+
if (cursor.name === "JinjaExpression") {
|
|
2110
|
+
return {
|
|
2111
|
+
type: "className",
|
|
2112
|
+
className: "jinja-expression"
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
}),
|
|
2116
|
+
import_view2.EditorView.theme({
|
|
2117
|
+
".jinja-statement-bracket": {
|
|
2118
|
+
color: "#D1009D"
|
|
2119
|
+
},
|
|
2120
|
+
".jinja-comment": {
|
|
2121
|
+
color: "#0607094D"
|
|
2122
|
+
},
|
|
2123
|
+
".jinja-expression": {
|
|
2124
|
+
color: "#4E40E5"
|
|
2125
|
+
}
|
|
2126
|
+
})
|
|
2127
|
+
]),
|
|
2128
|
+
[injector]
|
|
2129
|
+
);
|
|
2130
|
+
return null;
|
|
2131
|
+
}
|
|
2132
|
+
var jinja_default = JinjaHighlight;
|
|
2133
|
+
|
|
2134
|
+
// src/components/prompt-editor/index.tsx
|
|
2135
|
+
function PromptEditor(props) {
|
|
2136
|
+
const { value, onChange, readonly, style, hasError, children } = props || {};
|
|
2137
|
+
return /* @__PURE__ */ import_react24.default.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ import_react24.default.createElement(import_react25.EditorProvider, null, /* @__PURE__ */ import_react24.default.createElement(
|
|
2138
|
+
import_react25.Renderer,
|
|
2139
|
+
{
|
|
2140
|
+
plugins: import_preset_prompt2.default,
|
|
2141
|
+
defaultValue: String(value?.content),
|
|
2142
|
+
options: {
|
|
2143
|
+
readOnly: readonly,
|
|
2144
|
+
editable: !readonly
|
|
2145
|
+
},
|
|
2146
|
+
onChange: (e) => {
|
|
2147
|
+
onChange({ type: "template", content: e.value });
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
), /* @__PURE__ */ import_react24.default.createElement(markdown_default, null), /* @__PURE__ */ import_react24.default.createElement(language_support_default, null), /* @__PURE__ */ import_react24.default.createElement(jinja_default, null), children));
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
// src/components/prompt-editor-with-variables/index.tsx
|
|
2154
|
+
var import_react28 = __toESM(require("react"));
|
|
2155
|
+
|
|
2156
|
+
// src/components/prompt-editor-with-variables/extensions/variable.tsx
|
|
2157
|
+
var import_react26 = __toESM(require("react"));
|
|
2158
|
+
var import_semi_ui11 = require("@douyinfe/semi-ui");
|
|
2159
|
+
var import_react27 = require("@coze-editor/editor/react");
|
|
2160
|
+
function Variable() {
|
|
2161
|
+
const [posKey, setPosKey] = (0, import_react26.useState)("");
|
|
2162
|
+
const [visible, setVisible] = (0, import_react26.useState)(false);
|
|
2163
|
+
const [position, setPosition] = (0, import_react26.useState)(-1);
|
|
2164
|
+
const editor = (0, import_react27.useEditor)();
|
|
2165
|
+
function insert(variablePath) {
|
|
2166
|
+
const range = (0, import_react27.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2167
|
+
if (!range) {
|
|
2168
|
+
return;
|
|
2169
|
+
}
|
|
2170
|
+
editor.replaceText({
|
|
2171
|
+
...range,
|
|
2172
|
+
text: "{{" + variablePath + "}}"
|
|
2173
|
+
});
|
|
2174
|
+
setVisible(false);
|
|
2175
|
+
}
|
|
2176
|
+
function handleOpenChange(e) {
|
|
2177
|
+
setPosition(e.state.selection.main.head);
|
|
2178
|
+
setVisible(e.value);
|
|
2179
|
+
}
|
|
2180
|
+
(0, import_react26.useEffect)(() => {
|
|
2181
|
+
if (!editor) {
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
}, [editor, visible]);
|
|
2185
|
+
const treeData = useVariableTree({});
|
|
2186
|
+
return /* @__PURE__ */ import_react26.default.createElement(import_react26.default.Fragment, null, /* @__PURE__ */ import_react26.default.createElement(import_react27.Mention, { triggerCharacters: ["{", "{}"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react26.default.createElement(
|
|
2187
|
+
import_semi_ui11.Popover,
|
|
2188
|
+
{
|
|
2189
|
+
visible,
|
|
2190
|
+
trigger: "custom",
|
|
2191
|
+
position: "topLeft",
|
|
2192
|
+
rePosKey: posKey,
|
|
2193
|
+
content: /* @__PURE__ */ import_react26.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react26.default.createElement(
|
|
2194
|
+
import_semi_ui11.Tree,
|
|
2195
|
+
{
|
|
2196
|
+
treeData,
|
|
2197
|
+
onSelect: (v) => {
|
|
2198
|
+
insert(v);
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
))
|
|
2202
|
+
},
|
|
2203
|
+
/* @__PURE__ */ import_react26.default.createElement(
|
|
2204
|
+
import_react27.PositionMirror,
|
|
2205
|
+
{
|
|
2206
|
+
position,
|
|
2207
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
2208
|
+
}
|
|
2209
|
+
)
|
|
2210
|
+
));
|
|
2211
|
+
}
|
|
2212
|
+
var variable_default = Variable;
|
|
2213
|
+
|
|
2214
|
+
// src/components/prompt-editor-with-variables/index.tsx
|
|
2215
|
+
function PromptEditorWithVariables(props) {
|
|
2216
|
+
return /* @__PURE__ */ import_react28.default.createElement(PromptEditor, { ...props }, /* @__PURE__ */ import_react28.default.createElement(variable_default, null));
|
|
2217
|
+
}
|
|
2218
|
+
|
|
1975
2219
|
// src/effects/provide-batch-input/index.ts
|
|
1976
|
-
var
|
|
1977
|
-
var provideBatchInputEffect = (0,
|
|
2220
|
+
var import_editor7 = require("@flowgram.ai/editor");
|
|
2221
|
+
var provideBatchInputEffect = (0, import_editor7.createEffectFromVariableProvider)({
|
|
1978
2222
|
private: true,
|
|
1979
2223
|
parse: (value, ctx) => [
|
|
1980
|
-
|
|
2224
|
+
import_editor7.ASTFactory.createVariableDeclaration({
|
|
1981
2225
|
key: `${ctx.node.id}_locals`,
|
|
1982
2226
|
meta: {
|
|
1983
|
-
title: (0,
|
|
2227
|
+
title: (0, import_editor7.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1984
2228
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1985
2229
|
},
|
|
1986
|
-
type:
|
|
2230
|
+
type: import_editor7.ASTFactory.createObject({
|
|
1987
2231
|
properties: [
|
|
1988
|
-
|
|
2232
|
+
import_editor7.ASTFactory.createProperty({
|
|
1989
2233
|
key: "item",
|
|
1990
|
-
initializer:
|
|
1991
|
-
enumerateFor:
|
|
2234
|
+
initializer: import_editor7.ASTFactory.createEnumerateExpression({
|
|
2235
|
+
enumerateFor: import_editor7.ASTFactory.createKeyPathExpression({
|
|
1992
2236
|
keyPath: value.content || []
|
|
1993
2237
|
})
|
|
1994
2238
|
})
|
|
1995
2239
|
}),
|
|
1996
|
-
|
|
2240
|
+
import_editor7.ASTFactory.createProperty({
|
|
1997
2241
|
key: "index",
|
|
1998
|
-
type:
|
|
2242
|
+
type: import_editor7.ASTFactory.createNumber()
|
|
1999
2243
|
})
|
|
2000
2244
|
]
|
|
2001
2245
|
})
|
|
@@ -2004,21 +2248,21 @@ var provideBatchInputEffect = (0, import_editor5.createEffectFromVariableProvide
|
|
|
2004
2248
|
});
|
|
2005
2249
|
|
|
2006
2250
|
// src/effects/provide-batch-outputs/index.ts
|
|
2007
|
-
var
|
|
2008
|
-
var provideBatchOutputsEffect = (0,
|
|
2251
|
+
var import_editor8 = require("@flowgram.ai/editor");
|
|
2252
|
+
var provideBatchOutputsEffect = (0, import_editor8.createEffectFromVariableProvider)({
|
|
2009
2253
|
parse: (value, ctx) => [
|
|
2010
|
-
|
|
2254
|
+
import_editor8.ASTFactory.createVariableDeclaration({
|
|
2011
2255
|
key: `${ctx.node.id}`,
|
|
2012
2256
|
meta: {
|
|
2013
|
-
title: (0,
|
|
2257
|
+
title: (0, import_editor8.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
2014
2258
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
2015
2259
|
},
|
|
2016
|
-
type:
|
|
2260
|
+
type: import_editor8.ASTFactory.createObject({
|
|
2017
2261
|
properties: Object.entries(value).map(
|
|
2018
|
-
([_key, value2]) =>
|
|
2262
|
+
([_key, value2]) => import_editor8.ASTFactory.createProperty({
|
|
2019
2263
|
key: _key,
|
|
2020
|
-
initializer:
|
|
2021
|
-
wrapFor:
|
|
2264
|
+
initializer: import_editor8.ASTFactory.createWrapArrayExpression({
|
|
2265
|
+
wrapFor: import_editor8.ASTFactory.createKeyPathExpression({
|
|
2022
2266
|
keyPath: value2.content || []
|
|
2023
2267
|
})
|
|
2024
2268
|
})
|
|
@@ -2031,13 +2275,13 @@ var provideBatchOutputsEffect = (0, import_editor6.createEffectFromVariableProvi
|
|
|
2031
2275
|
|
|
2032
2276
|
// src/effects/auto-rename-ref/index.ts
|
|
2033
2277
|
var import_lodash4 = require("lodash");
|
|
2034
|
-
var
|
|
2278
|
+
var import_editor9 = require("@flowgram.ai/editor");
|
|
2035
2279
|
var autoRenameRefEffect = [
|
|
2036
2280
|
{
|
|
2037
|
-
event:
|
|
2281
|
+
event: import_editor9.DataEvent.onValueInit,
|
|
2038
2282
|
effect: (params) => {
|
|
2039
2283
|
const { context, form, name } = params;
|
|
2040
|
-
const renameService = context.node.getService(
|
|
2284
|
+
const renameService = context.node.getService(import_editor9.VariableFieldKeyRenameService);
|
|
2041
2285
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
2042
2286
|
const beforeKeyPath = [
|
|
2043
2287
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -2087,13 +2331,13 @@ function traverseRef(name, value, cb) {
|
|
|
2087
2331
|
}
|
|
2088
2332
|
|
|
2089
2333
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
2090
|
-
var
|
|
2091
|
-
var provideJsonSchemaOutputs = (0,
|
|
2334
|
+
var import_editor10 = require("@flowgram.ai/editor");
|
|
2335
|
+
var provideJsonSchemaOutputs = (0, import_editor10.createEffectFromVariableProvider)({
|
|
2092
2336
|
parse: (value, ctx) => [
|
|
2093
|
-
|
|
2337
|
+
import_editor10.ASTFactory.createVariableDeclaration({
|
|
2094
2338
|
key: `${ctx.node.id}`,
|
|
2095
2339
|
meta: {
|
|
2096
|
-
title: (0,
|
|
2340
|
+
title: (0, import_editor10.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
2097
2341
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
2098
2342
|
},
|
|
2099
2343
|
type: JsonSchemaUtils.schemaToAST(value)
|
|
@@ -2102,12 +2346,12 @@ var provideJsonSchemaOutputs = (0, import_editor8.createEffectFromVariableProvid
|
|
|
2102
2346
|
});
|
|
2103
2347
|
|
|
2104
2348
|
// src/effects/sync-variable-title/index.ts
|
|
2105
|
-
var
|
|
2349
|
+
var import_editor11 = require("@flowgram.ai/editor");
|
|
2106
2350
|
var syncVariableTitle = [
|
|
2107
2351
|
{
|
|
2108
|
-
event:
|
|
2352
|
+
event: import_editor11.DataEvent.onValueChange,
|
|
2109
2353
|
effect: ({ value, context }) => {
|
|
2110
|
-
context.node.getData(
|
|
2354
|
+
context.node.getData(import_editor11.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
2111
2355
|
_scope.output.variables.forEach((_var) => {
|
|
2112
2356
|
_var.updateMeta({
|
|
2113
2357
|
title: value || context.node.id,
|
|
@@ -2120,21 +2364,21 @@ var syncVariableTitle = [
|
|
|
2120
2364
|
];
|
|
2121
2365
|
|
|
2122
2366
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
2123
|
-
var
|
|
2124
|
-
var provideBatchOutputsEffect2 = (0,
|
|
2367
|
+
var import_editor12 = require("@flowgram.ai/editor");
|
|
2368
|
+
var provideBatchOutputsEffect2 = (0, import_editor12.createEffectFromVariableProvider)({
|
|
2125
2369
|
parse: (value, ctx) => [
|
|
2126
|
-
|
|
2370
|
+
import_editor12.ASTFactory.createVariableDeclaration({
|
|
2127
2371
|
key: `${ctx.node.id}`,
|
|
2128
2372
|
meta: {
|
|
2129
|
-
title: (0,
|
|
2373
|
+
title: (0, import_editor12.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
2130
2374
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
2131
2375
|
},
|
|
2132
|
-
type:
|
|
2376
|
+
type: import_editor12.ASTFactory.createObject({
|
|
2133
2377
|
properties: Object.entries(value).map(
|
|
2134
|
-
([_key, value2]) =>
|
|
2378
|
+
([_key, value2]) => import_editor12.ASTFactory.createProperty({
|
|
2135
2379
|
key: _key,
|
|
2136
|
-
initializer:
|
|
2137
|
-
wrapFor:
|
|
2380
|
+
initializer: import_editor12.ASTFactory.createWrapArrayExpression({
|
|
2381
|
+
wrapFor: import_editor12.ASTFactory.createKeyPathExpression({
|
|
2138
2382
|
keyPath: value2?.content || []
|
|
2139
2383
|
})
|
|
2140
2384
|
})
|
|
@@ -2144,7 +2388,7 @@ var provideBatchOutputsEffect2 = (0, import_editor10.createEffectFromVariablePro
|
|
|
2144
2388
|
})
|
|
2145
2389
|
]
|
|
2146
2390
|
});
|
|
2147
|
-
var createBatchOutputsFormPlugin = (0,
|
|
2391
|
+
var createBatchOutputsFormPlugin = (0, import_editor12.defineFormPluginCreator)({
|
|
2148
2392
|
name: "batch-outputs-plugin",
|
|
2149
2393
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
2150
2394
|
mergeEffect({
|
|
@@ -2152,7 +2396,7 @@ var createBatchOutputsFormPlugin = (0, import_editor10.defineFormPluginCreator)(
|
|
|
2152
2396
|
});
|
|
2153
2397
|
},
|
|
2154
2398
|
onInit(ctx, { outputKey }) {
|
|
2155
|
-
const chainTransformService = ctx.node.getService(
|
|
2399
|
+
const chainTransformService = ctx.node.getService(import_editor12.ScopeChainTransformService);
|
|
2156
2400
|
const batchNodeType = ctx.node.flowNodeType;
|
|
2157
2401
|
const transformerId = `${batchNodeType}-outputs`;
|
|
2158
2402
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -2162,21 +2406,21 @@ var createBatchOutputsFormPlugin = (0, import_editor10.defineFormPluginCreator)(
|
|
|
2162
2406
|
transformCovers: (covers, ctx2) => {
|
|
2163
2407
|
const node = ctx2.scope.meta?.node;
|
|
2164
2408
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
2165
|
-
return [...covers, (0,
|
|
2409
|
+
return [...covers, (0, import_editor12.getNodeScope)(node.parent)];
|
|
2166
2410
|
}
|
|
2167
2411
|
return covers;
|
|
2168
2412
|
},
|
|
2169
2413
|
transformDeps(scopes, ctx2) {
|
|
2170
2414
|
const scopeMeta = ctx2.scope.meta;
|
|
2171
|
-
if (scopeMeta?.type ===
|
|
2415
|
+
if (scopeMeta?.type === import_editor12.FlowNodeScopeType.private) {
|
|
2172
2416
|
return scopes;
|
|
2173
2417
|
}
|
|
2174
2418
|
const node = scopeMeta?.node;
|
|
2175
2419
|
if (node?.flowNodeType === batchNodeType) {
|
|
2176
2420
|
const childBlocks = node.blocks;
|
|
2177
2421
|
return [
|
|
2178
|
-
(0,
|
|
2179
|
-
...childBlocks.map((_childBlock) => (0,
|
|
2422
|
+
(0, import_editor12.getNodePrivateScope)(node),
|
|
2423
|
+
...childBlocks.map((_childBlock) => (0, import_editor12.getNodeScope)(_childBlock))
|
|
2180
2424
|
];
|
|
2181
2425
|
}
|
|
2182
2426
|
return scopes;
|
|
@@ -2194,6 +2438,8 @@ var createBatchOutputsFormPlugin = (0, import_editor10.defineFormPluginCreator)(
|
|
|
2194
2438
|
DynamicValueInput,
|
|
2195
2439
|
JsonSchemaEditor,
|
|
2196
2440
|
JsonSchemaUtils,
|
|
2441
|
+
PromptEditor,
|
|
2442
|
+
PromptEditorWithVariables,
|
|
2197
2443
|
TypeSelector,
|
|
2198
2444
|
VariableSelector,
|
|
2199
2445
|
VariableTypeIcons,
|