@powerhousedao/workflow 6.2.3-dev.26 → 6.2.3-dev.28
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/{node/BlockSelector-COZm6-ev.mjs → browser/BlockSelector-D24DIiSX.js} +45 -12
- package/dist/browser/{BlockSelector-QQgOCVH3.js.map → BlockSelector-D24DIiSX.js.map} +1 -1
- package/dist/browser/{PieceMarkdown-C8Gv88TV.js → PieceMarkdown-B8EEaQgT.js} +2 -2
- package/dist/browser/{PieceMarkdown-C8Gv88TV.js.map → PieceMarkdown-B8EEaQgT.js.map} +1 -1
- package/dist/browser/{connection-form-XKR4zQgQ.js → connection-form-D-NETdDQ.js} +3 -3
- package/dist/browser/{connection-form-XKR4zQgQ.js.map → connection-form-D-NETdDQ.js.map} +1 -1
- package/dist/browser/{data-tree-DKrDFeQg.js → data-tree-DA4sc7B7.js} +2 -2
- package/dist/browser/{data-tree-DKrDFeQg.js.map → data-tree-DA4sc7B7.js.map} +1 -1
- package/dist/browser/{editor-YZw296bf.js → editor-B6N0PCuZ.js} +754 -417
- package/dist/browser/editor-B6N0PCuZ.js.map +1 -0
- package/dist/browser/{editor-C_E_JTp6.js → editor-BkdwuOC-.js} +4 -4
- package/dist/browser/{editor-C_E_JTp6.js.map → editor-BkdwuOC-.js.map} +1 -1
- package/dist/browser/{editor-fjwq-8Yq.js → editor-CZ5NvCyv.js} +4 -4
- package/dist/browser/{editor-fjwq-8Yq.js.map → editor-CZ5NvCyv.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/index.js +1 -1
- package/dist/browser/{runtime-api-xwvg5PzA.js → runtime-api-DDMQc4PB.js} +136 -40
- package/dist/browser/runtime-api-DDMQc4PB.js.map +1 -0
- package/dist/browser/{trigger-text-CdNxQOHw.js → trigger-text-CUv5Z2Uk.js} +4 -4
- package/dist/browser/{trigger-text-CdNxQOHw.js.map → trigger-text-CUv5Z2Uk.js.map} +1 -1
- package/dist/{browser/BlockSelector-QQgOCVH3.js → node/BlockSelector-CTmmpYxu.mjs} +45 -12
- package/dist/node/{BlockSelector-COZm6-ev.mjs.map → BlockSelector-CTmmpYxu.mjs.map} +1 -1
- package/dist/node/{PieceMarkdown-DIxZY5aG.mjs → PieceMarkdown-BMhBGa4t.mjs} +2 -2
- package/dist/node/{PieceMarkdown-DIxZY5aG.mjs.map → PieceMarkdown-BMhBGa4t.mjs.map} +1 -1
- package/dist/node/{connection-form-BLduFusc.mjs → connection-form-C9vbfSnA.mjs} +3 -3
- package/dist/node/{connection-form-BLduFusc.mjs.map → connection-form-C9vbfSnA.mjs.map} +1 -1
- package/dist/node/{data-tree-CmiGqG7C.mjs → data-tree-CbqpF3lC.mjs} +2 -2
- package/dist/node/{data-tree-CmiGqG7C.mjs.map → data-tree-CbqpF3lC.mjs.map} +1 -1
- package/dist/node/{editor-CN4PEGrW.mjs → editor-By9BHI8e.mjs} +4 -4
- package/dist/node/{editor-CN4PEGrW.mjs.map → editor-By9BHI8e.mjs.map} +1 -1
- package/dist/node/{editor-B2ZoeGue.mjs → editor-DP36YDk5.mjs} +754 -417
- package/dist/node/editor-DP36YDk5.mjs.map +1 -0
- package/dist/node/{editor-CyNBEKoj.mjs → editor-StBssjcQ.mjs} +4 -4
- package/dist/node/{editor-CyNBEKoj.mjs.map → editor-StBssjcQ.mjs.map} +1 -1
- package/dist/node/editors/connection-editor/module.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/reactor/descriptor.json +72 -16
- package/dist/node/pieces/reactor/index.mjs +317 -22
- package/dist/node/pieces/reactor/index.mjs.map +1 -1
- package/dist/node/{runtime-api-xwvg5PzA.mjs → runtime-api-DDMQc4PB.mjs} +136 -40
- package/dist/node/runtime-api-DDMQc4PB.mjs.map +1 -0
- package/dist/node/{trigger-text-qj_U3Qzd.mjs → trigger-text-Bzq6VfOQ.mjs} +4 -4
- package/dist/node/{trigger-text-qj_U3Qzd.mjs.map → trigger-text-Bzq6VfOQ.mjs.map} +1 -1
- package/dist/style.css +59 -3
- package/dist/types/editors/shared/controls.d.ts +8 -0
- package/dist/types/editors/shared/controls.d.ts.map +1 -1
- package/dist/types/editors/shared/icons.d.ts +2 -0
- package/dist/types/editors/shared/icons.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-api.d.ts +2 -1
- package/dist/types/editors/workflow-editor/runtime-api.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts +3 -2
- package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/blocks.d.ts +2 -0
- package/dist/types/editors/workflow-editor/ui/blocks.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/forms.d.ts +42 -5
- package/dist/types/editors/workflow-editor/ui/forms.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/piece-source.d.ts +1 -0
- package/dist/types/editors/workflow-editor/ui/piece-source.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/prop-controls.d.ts +61 -0
- package/dist/types/editors/workflow-editor/ui/prop-controls.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/ui/prop-layout.d.ts +12 -0
- package/dist/types/editors/workflow-editor/ui/prop-layout.d.ts.map +1 -0
- package/dist/types/pieces/reactor/lib/actions/document-create.d.ts +3 -1
- package/dist/types/pieces/reactor/lib/actions/document-create.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/actions/document-dispatch.d.ts +2 -1
- package/dist/types/pieces/reactor/lib/actions/document-dispatch.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/input-props.d.ts +5 -0
- package/dist/types/pieces/reactor/lib/input-props.d.ts.map +1 -0
- package/dist/types/pieces/reactor/lib/input-props.test.d.ts +2 -0
- package/dist/types/pieces/reactor/lib/input-props.test.d.ts.map +1 -0
- package/dist/types/pieces/reactor/lib/input-schema.d.ts +22 -0
- package/dist/types/pieces/reactor/lib/input-schema.d.ts.map +1 -0
- package/dist/types/pieces/reactor/lib/input-schema.test.d.ts +2 -0
- package/dist/types/pieces/reactor/lib/input-schema.test.d.ts.map +1 -0
- package/dist/types/pieces/reactor/lib/reactor.d.ts +13 -1
- package/dist/types/pieces/reactor/lib/reactor.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/schema-text.d.ts +7 -0
- package/dist/types/pieces/reactor/lib/schema-text.d.ts.map +1 -0
- package/dist/types/pieces/reactor/lib/schema-text.test.d.ts +2 -0
- package/dist/types/pieces/reactor/lib/schema-text.test.d.ts.map +1 -0
- package/dist/types/scripts/ui-stack.d.ts +22 -0
- package/dist/types/scripts/ui-stack.d.ts.map +1 -1
- package/dist/types/test/ui/harness/prop-controls.d.ts +6 -0
- package/dist/types/test/ui/harness/prop-controls.d.ts.map +1 -0
- package/dist/types/test/ui/prop-controls.spec.d.ts +2 -0
- package/dist/types/test/ui/prop-controls.spec.d.ts.map +1 -0
- package/dist/types/test/ui/reactor-steps.spec.d.ts +2 -0
- package/dist/types/test/ui/reactor-steps.spec.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/browser/editor-YZw296bf.js.map +0 -1
- package/dist/browser/runtime-api-xwvg5PzA.js.map +0 -1
- package/dist/node/editor-B2ZoeGue.mjs.map +0 -1
- package/dist/node/runtime-api-xwvg5PzA.mjs.map +0 -1
- package/dist/types/editors/workflow-editor/ui/ActionListEditor.d.ts +0 -6
- package/dist/types/editors/workflow-editor/ui/ActionListEditor.d.ts.map +0 -1
- package/dist/types/editors/workflow-editor/ui/Autocomplete.d.ts +0 -20
- package/dist/types/editors/workflow-editor/ui/Autocomplete.d.ts.map +0 -1
- package/dist/types/editors/workflow-editor/ui/action-template.d.ts +0 -2
- package/dist/types/editors/workflow-editor/ui/action-template.d.ts.map +0 -1
- package/dist/types/editors/workflow-editor/ui/action-template.test.d.ts +0 -2
- package/dist/types/editors/workflow-editor/ui/action-template.test.d.ts.map +0 -1
- package/dist/types/editors/workflow-editor/ui/reactor-piece-form.d.ts +0 -5
- package/dist/types/editors/workflow-editor/ui/reactor-piece-form.d.ts.map +0 -1
- package/dist/types/editors/workflow-editor/ui/reactor-piece-form.test.d.ts +0 -2
- package/dist/types/editors/workflow-editor/ui/reactor-piece-form.test.d.ts.map +0 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as packageFromConnectorId, o as planFromAuth, r as isConfigValueMissing, t as connectorIdForPiece } from "./piece-auth-Z4mZEOtL.mjs";
|
|
2
|
-
import { a as fetchConnections, c as fetchPieceTriggers, f as fireWorkflow, l as fetchRuns, n as checkConnection, o as fetchPieceActions, p as getBlockForm, s as fetchPieceCatalog, t as DEFAULT_RUNTIME_URL,
|
|
2
|
+
import { C as CORE_FORMS, a as fetchConnections, c as fetchPieceTriggers, f as fireWorkflow, l as fetchRuns, n as checkConnection, o as fetchPieceActions, p as getBlockForm, s as fetchPieceCatalog, t as DEFAULT_RUNTIME_URL, y as setRuntimeUrl } from "./runtime-api-DDMQc4PB.mjs";
|
|
3
3
|
import { t as Connection } from "./module-BMwJQh65.mjs";
|
|
4
4
|
import { t as Workflow } from "./module-DuxxhgKs.mjs";
|
|
5
5
|
import { t as upgradeManifests } from "./upgrade-manifests-C1sl_M-H.mjs";
|
|
@@ -21,20 +21,22 @@
|
|
|
21
21
|
"type": "SHORT_TEXT"
|
|
22
22
|
},
|
|
23
23
|
"parentId": {
|
|
24
|
-
"displayName": "Parent drive
|
|
24
|
+
"displayName": "Parent drive",
|
|
25
25
|
"required": false,
|
|
26
26
|
"refreshers": [],
|
|
27
27
|
"type": "DROPDOWN"
|
|
28
28
|
},
|
|
29
|
-
"
|
|
30
|
-
"displayName": "
|
|
31
|
-
"description": "
|
|
29
|
+
"folderId": {
|
|
30
|
+
"displayName": "Folder",
|
|
31
|
+
"description": "Omit for the drive's root",
|
|
32
32
|
"required": false,
|
|
33
|
-
"
|
|
33
|
+
"refreshers": [
|
|
34
|
+
"parentId"
|
|
35
|
+
],
|
|
36
|
+
"type": "DROPDOWN"
|
|
34
37
|
},
|
|
35
38
|
"actionType": {
|
|
36
|
-
"displayName": "
|
|
37
|
-
"description": "Suggestions for the action list above",
|
|
39
|
+
"displayName": "Type",
|
|
38
40
|
"required": false,
|
|
39
41
|
"refreshers": [
|
|
40
42
|
"documentType",
|
|
@@ -42,13 +44,43 @@
|
|
|
42
44
|
],
|
|
43
45
|
"type": "DROPDOWN"
|
|
44
46
|
},
|
|
47
|
+
"input": {
|
|
48
|
+
"displayName": "Input",
|
|
49
|
+
"required": false,
|
|
50
|
+
"refreshers": [
|
|
51
|
+
"documentType",
|
|
52
|
+
"documentId",
|
|
53
|
+
"actionType"
|
|
54
|
+
],
|
|
55
|
+
"type": "DYNAMIC"
|
|
56
|
+
},
|
|
57
|
+
"actions": {
|
|
58
|
+
"displayName": "Action list (JSON)",
|
|
59
|
+
"required": false,
|
|
60
|
+
"description": "Several actions after the create, or a payload from an earlier step: [{ \"type\": …, \"input\": … }]",
|
|
61
|
+
"advanced": true,
|
|
62
|
+
"type": "JSON"
|
|
63
|
+
},
|
|
45
64
|
"payload": {
|
|
46
65
|
"displayName": "Payload",
|
|
47
66
|
"description": "JSON {documentType, name, actions?}, e.g. {{steps.draft.output}}",
|
|
48
67
|
"required": false,
|
|
68
|
+
"advanced": true,
|
|
49
69
|
"type": "SHORT_TEXT"
|
|
50
70
|
}
|
|
51
71
|
},
|
|
72
|
+
"propertyGroups": [
|
|
73
|
+
{
|
|
74
|
+
"key": "action",
|
|
75
|
+
"display": "section",
|
|
76
|
+
"label": "Action",
|
|
77
|
+
"description": "Optional, sent right after the create. Pick a type, then fill in its input: the action needs both.",
|
|
78
|
+
"props": [
|
|
79
|
+
"actionType",
|
|
80
|
+
"input"
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
],
|
|
52
84
|
"requireAuth": false,
|
|
53
85
|
"errorHandlingOptions": {
|
|
54
86
|
"continueOnFailure": {
|
|
@@ -80,15 +112,8 @@
|
|
|
80
112
|
"refreshers": [],
|
|
81
113
|
"type": "DROPDOWN"
|
|
82
114
|
},
|
|
83
|
-
"actions": {
|
|
84
|
-
"displayName": "Actions",
|
|
85
|
-
"description": "e.g. [{ \"type\": \"SET_NAME\", \"input\": { \"name\": \"Invoice\" } }]",
|
|
86
|
-
"required": true,
|
|
87
|
-
"type": "JSON"
|
|
88
|
-
},
|
|
89
115
|
"actionType": {
|
|
90
|
-
"displayName": "
|
|
91
|
-
"description": "Suggestions for the action list above",
|
|
116
|
+
"displayName": "Type",
|
|
92
117
|
"required": false,
|
|
93
118
|
"refreshers": [
|
|
94
119
|
"documentType",
|
|
@@ -96,19 +121,50 @@
|
|
|
96
121
|
],
|
|
97
122
|
"type": "DROPDOWN"
|
|
98
123
|
},
|
|
124
|
+
"input": {
|
|
125
|
+
"displayName": "Input",
|
|
126
|
+
"required": false,
|
|
127
|
+
"refreshers": [
|
|
128
|
+
"documentType",
|
|
129
|
+
"documentId",
|
|
130
|
+
"actionType"
|
|
131
|
+
],
|
|
132
|
+
"type": "DYNAMIC"
|
|
133
|
+
},
|
|
134
|
+
"actions": {
|
|
135
|
+
"displayName": "Action list (JSON)",
|
|
136
|
+
"required": false,
|
|
137
|
+
"description": "Several actions at once, or a payload from an earlier step: [{ \"type\": …, \"input\": … }]",
|
|
138
|
+
"advanced": true,
|
|
139
|
+
"type": "JSON"
|
|
140
|
+
},
|
|
99
141
|
"allowedActions": {
|
|
100
142
|
"displayName": "Allowed action types",
|
|
101
143
|
"description": "Comma-separated whitelist; enforced when set",
|
|
102
144
|
"required": false,
|
|
145
|
+
"advanced": true,
|
|
103
146
|
"type": "SHORT_TEXT"
|
|
104
147
|
},
|
|
105
148
|
"branch": {
|
|
106
149
|
"displayName": "Branch",
|
|
107
150
|
"description": "Defaults to \"main\"",
|
|
108
151
|
"required": false,
|
|
152
|
+
"advanced": true,
|
|
109
153
|
"type": "SHORT_TEXT"
|
|
110
154
|
}
|
|
111
155
|
},
|
|
156
|
+
"propertyGroups": [
|
|
157
|
+
{
|
|
158
|
+
"key": "action",
|
|
159
|
+
"display": "section",
|
|
160
|
+
"label": "Action",
|
|
161
|
+
"description": "Sent to the document. Pick a type, then fill in its input: the action needs both.",
|
|
162
|
+
"props": [
|
|
163
|
+
"actionType",
|
|
164
|
+
"input"
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
],
|
|
112
168
|
"requireAuth": false,
|
|
113
169
|
"errorHandlingOptions": {
|
|
114
170
|
"continueOnFailure": {
|
|
@@ -164,7 +220,7 @@
|
|
|
164
220
|
"type": "DROPDOWN"
|
|
165
221
|
},
|
|
166
222
|
"parentId": {
|
|
167
|
-
"displayName": "In drive
|
|
223
|
+
"displayName": "In drive",
|
|
168
224
|
"description": "Omit for the whole reactor",
|
|
169
225
|
"required": false,
|
|
170
226
|
"refreshers": [],
|
|
@@ -2182,6 +2182,159 @@ function reactorOf(ctx) {
|
|
|
2182
2182
|
//#region pieces/reactor/lib/logo.ts
|
|
2183
2183
|
const POWERHOUSE_LOGO = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMTQgMTE0IiBmaWxsPSJub25lIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbD0iIzE2MTYxNiIgZD0iTTcxLjI5MTkgMEwyNC4zNDE1IDM4Ljg3NzJDMTcuNDU0OCA0NC41Nzk4IDE2Ljk1MzkgNTQuOTY1OSAyMy4yNiA2MS4zMDQ3TDM5LjUwMjggNzcuNjMxOEM0NC4yNjg0IDgyLjQyMjEgNDUuMjk5NiA4OS43ODM0IDQyLjAzMzUgOTUuNjk4OEwzMS45MjkgMTE0SDE1LjJDNi44MDUyNyAxMTQgMCAxMDcuMTk1IDAgOTguOFYxNS4yQzAgNi44MDUyNyA2LjgwNTI3IDAgMTUuMiAwSDcxLjI5MTlaTTgwLjExMSAwTDcxLjM0MTIgMTUuOTc1OEM2OC4xMDc4IDIxLjg2NiA2OS4xMjU1IDI5LjE4MDQgNzMuODQ0MSAzMy45NjQxTDkxLjA3NTEgNTEuNDMzMUM5Ny4zNjc0IDU3LjgxMjQgOTYuODA0NCA2OC4yMjI3IDg5Ljg2MDcgNzMuODg2MUw0MC42NzgyIDExNEg5OC44QzEwNy4xOTUgMTE0IDExNCAxMDcuMTk1IDExNCA5OC44VjE1LjJDMTE0IDYuODA1MjcgMTA3LjE5NSAwIDk4LjggMEg4MC4xMTFaIi8+PC9zdmc+";
|
|
2184
2184
|
//#endregion
|
|
2185
|
+
//#region pieces/reactor/lib/input-schema.ts
|
|
2186
|
+
const TEXT_SCALARS = /* @__PURE__ */ new Set([
|
|
2187
|
+
"String",
|
|
2188
|
+
"ID",
|
|
2189
|
+
"OID",
|
|
2190
|
+
"PHID",
|
|
2191
|
+
"OLabel",
|
|
2192
|
+
"URL",
|
|
2193
|
+
"Date",
|
|
2194
|
+
"DateTime",
|
|
2195
|
+
"EmailAddress",
|
|
2196
|
+
"EthereumAddress",
|
|
2197
|
+
"Currency"
|
|
2198
|
+
]);
|
|
2199
|
+
function rootInputName(actionType) {
|
|
2200
|
+
return `${actionType.toLowerCase().split(/[_\s]+/).filter(Boolean).map((part) => part[0].toUpperCase() + part.slice(1)).join("")}Input`;
|
|
2201
|
+
}
|
|
2202
|
+
function parseType(raw) {
|
|
2203
|
+
const trimmed = raw.trim();
|
|
2204
|
+
const required = trimmed.endsWith("!");
|
|
2205
|
+
const bare = required ? trimmed.slice(0, -1) : trimmed;
|
|
2206
|
+
const list = bare.startsWith("[");
|
|
2207
|
+
return {
|
|
2208
|
+
name: bare.replace(/[[\]!]/g, "").trim(),
|
|
2209
|
+
list,
|
|
2210
|
+
required
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
function parseFields(body) {
|
|
2214
|
+
const fields = [];
|
|
2215
|
+
let description;
|
|
2216
|
+
const lines = body.replace(/"""([\s\S]*?)"""/g, (_, text) => `"${text.trim().replace(/\s+/g, " ")}"`).split("\n");
|
|
2217
|
+
for (const rawLine of lines) {
|
|
2218
|
+
const line = rawLine.replace(/#.*$/, "").trim();
|
|
2219
|
+
if (!line) continue;
|
|
2220
|
+
const doc = /^"(.*)"$/.exec(line);
|
|
2221
|
+
if (doc) {
|
|
2222
|
+
description = doc[1].replace(/\s+/g, " ");
|
|
2223
|
+
continue;
|
|
2224
|
+
}
|
|
2225
|
+
const match = /^(\w+)\s*:\s*([\w[\]!\s]+?)(?:\s*=.*)?$/.exec(line);
|
|
2226
|
+
if (!match) continue;
|
|
2227
|
+
const [, name, type] = match;
|
|
2228
|
+
if (name !== "_") fields.push({
|
|
2229
|
+
name,
|
|
2230
|
+
type: parseType(type),
|
|
2231
|
+
...description ? { description } : {}
|
|
2232
|
+
});
|
|
2233
|
+
description = void 0;
|
|
2234
|
+
}
|
|
2235
|
+
return fields;
|
|
2236
|
+
}
|
|
2237
|
+
function parseActionInputSchema(sdl, actionType) {
|
|
2238
|
+
const inputs = /* @__PURE__ */ new Map();
|
|
2239
|
+
const enums = /* @__PURE__ */ new Map();
|
|
2240
|
+
for (const match of sdl.matchAll(/\b(input|enum)\s+(\w+)\s*\{([^}]*)\}/g)) {
|
|
2241
|
+
const [, keyword, name, body] = match;
|
|
2242
|
+
if (keyword === "input") inputs.set(name, parseFields(body));
|
|
2243
|
+
else enums.set(name, body.replace(/#.*$/gm, "").replace(/"[^"]*"/g, "").split(/[\s,]+/).filter(Boolean));
|
|
2244
|
+
}
|
|
2245
|
+
const root = inputs.get(rootInputName(actionType));
|
|
2246
|
+
return root ? {
|
|
2247
|
+
root,
|
|
2248
|
+
inputs,
|
|
2249
|
+
enums
|
|
2250
|
+
} : null;
|
|
2251
|
+
}
|
|
2252
|
+
function fieldKind(type, schema) {
|
|
2253
|
+
if (schema.inputs.has(type.name)) return "object";
|
|
2254
|
+
if (schema.enums.has(type.name)) return "enum";
|
|
2255
|
+
if (type.name === "Boolean") return "boolean";
|
|
2256
|
+
if (type.name === "Int") return "integer";
|
|
2257
|
+
if (type.name === "Float") return "number";
|
|
2258
|
+
if (TEXT_SCALARS.has(type.name)) return "text";
|
|
2259
|
+
return "json";
|
|
2260
|
+
}
|
|
2261
|
+
function humanize(name) {
|
|
2262
|
+
const spaced = name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase().trim();
|
|
2263
|
+
return spaced.charAt(0).toUpperCase() + spaced.slice(1);
|
|
2264
|
+
}
|
|
2265
|
+
//#endregion
|
|
2266
|
+
//#region pieces/reactor/lib/input-props.ts
|
|
2267
|
+
function propFor(field, schema) {
|
|
2268
|
+
const base = {
|
|
2269
|
+
displayName: humanize(field.name),
|
|
2270
|
+
required: field.type.required,
|
|
2271
|
+
...field.description ? { description: field.description } : {}
|
|
2272
|
+
};
|
|
2273
|
+
if (field.type.list) return Property.Json({
|
|
2274
|
+
...base,
|
|
2275
|
+
description: field.description ?? "A JSON list"
|
|
2276
|
+
});
|
|
2277
|
+
switch (fieldKind(field.type, schema)) {
|
|
2278
|
+
case "text": return Property.ShortText(base);
|
|
2279
|
+
case "integer":
|
|
2280
|
+
case "number": return Property.ShortText({
|
|
2281
|
+
...base,
|
|
2282
|
+
description: field.description ?? "A number"
|
|
2283
|
+
});
|
|
2284
|
+
case "boolean": return Property.StaticDropdown({
|
|
2285
|
+
...base,
|
|
2286
|
+
options: { options: [{
|
|
2287
|
+
label: "Yes",
|
|
2288
|
+
value: true
|
|
2289
|
+
}, {
|
|
2290
|
+
label: "No",
|
|
2291
|
+
value: false
|
|
2292
|
+
}] }
|
|
2293
|
+
});
|
|
2294
|
+
case "enum": return Property.StaticDropdown({
|
|
2295
|
+
...base,
|
|
2296
|
+
options: { options: (schema.enums.get(field.type.name) ?? []).map((value) => ({
|
|
2297
|
+
label: humanize(value),
|
|
2298
|
+
value
|
|
2299
|
+
})) }
|
|
2300
|
+
});
|
|
2301
|
+
default: return Property.Json(base);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
function inputProps(schema) {
|
|
2305
|
+
const props = {};
|
|
2306
|
+
for (const field of schema.root) props[field.name] = propFor(field, schema);
|
|
2307
|
+
return props;
|
|
2308
|
+
}
|
|
2309
|
+
function parseJson(value) {
|
|
2310
|
+
if (typeof value !== "string") return value;
|
|
2311
|
+
try {
|
|
2312
|
+
return JSON.parse(value);
|
|
2313
|
+
} catch {
|
|
2314
|
+
return value;
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
function coerceInput(schema, raw) {
|
|
2318
|
+
const values = typeof raw === "object" && raw !== null ? raw : {};
|
|
2319
|
+
const input = {};
|
|
2320
|
+
for (const field of schema.root) {
|
|
2321
|
+
const value = values[field.name];
|
|
2322
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
2323
|
+
if (field.type.list) {
|
|
2324
|
+
input[field.name] = parseJson(value);
|
|
2325
|
+
continue;
|
|
2326
|
+
}
|
|
2327
|
+
const kind = fieldKind(field.type, schema);
|
|
2328
|
+
if (kind === "integer" || kind === "number") {
|
|
2329
|
+
const number = typeof value === "string" ? Number(value.trim()) : value;
|
|
2330
|
+
input[field.name] = Number.isFinite(number) ? number : value;
|
|
2331
|
+
} else if (kind === "boolean") input[field.name] = value === "true" ? true : value === "false" ? false : value;
|
|
2332
|
+
else if (kind === "object" || kind === "json") input[field.name] = parseJson(value);
|
|
2333
|
+
else input[field.name] = value;
|
|
2334
|
+
}
|
|
2335
|
+
return input;
|
|
2336
|
+
}
|
|
2337
|
+
//#endregion
|
|
2185
2338
|
//#region pieces/reactor/lib/parse.ts
|
|
2186
2339
|
function unfence(text) {
|
|
2187
2340
|
return text.trim().replace(/^```(?:json)?\s*/i, "").replace(/```$/, "").trim();
|
|
@@ -2307,6 +2460,49 @@ function staticString(value) {
|
|
|
2307
2460
|
return trimmed;
|
|
2308
2461
|
}
|
|
2309
2462
|
//#endregion
|
|
2463
|
+
//#region pieces/reactor/lib/schema-text.ts
|
|
2464
|
+
function driveNodes(state) {
|
|
2465
|
+
const nodes = state?.nodes;
|
|
2466
|
+
if (!Array.isArray(nodes)) return [];
|
|
2467
|
+
return nodes.filter((node) => typeof node === "object" && node !== null && typeof node.id === "string");
|
|
2468
|
+
}
|
|
2469
|
+
function folderOptions(driveState) {
|
|
2470
|
+
const folders = driveNodes(driveState).filter((node) => node.kind === "folder");
|
|
2471
|
+
const byId = new Map(folders.map((folder) => [folder.id, folder]));
|
|
2472
|
+
const pathOf = (folder) => {
|
|
2473
|
+
const names = [];
|
|
2474
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2475
|
+
let current = folder;
|
|
2476
|
+
while (current && !seen.has(current.id)) {
|
|
2477
|
+
seen.add(current.id);
|
|
2478
|
+
names.unshift(current.name || "(unnamed)");
|
|
2479
|
+
current = current.parentFolder ? byId.get(current.parentFolder) : void 0;
|
|
2480
|
+
}
|
|
2481
|
+
return names.join(" / ");
|
|
2482
|
+
};
|
|
2483
|
+
return folders.map((folder) => ({
|
|
2484
|
+
label: pathOf(folder),
|
|
2485
|
+
value: folder.id
|
|
2486
|
+
})).sort((a, b) => a.label.localeCompare(b.label));
|
|
2487
|
+
}
|
|
2488
|
+
const DEFINITION = /\b(?:input|enum|type)\s+(\w+)/g;
|
|
2489
|
+
const SCALARS = /* @__PURE__ */ new Set([
|
|
2490
|
+
"String",
|
|
2491
|
+
"Int",
|
|
2492
|
+
"Float",
|
|
2493
|
+
"Boolean",
|
|
2494
|
+
"ID"
|
|
2495
|
+
]);
|
|
2496
|
+
function blockOf(sdl, keyword, name) {
|
|
2497
|
+
return new RegExp(`${keyword}\\s+${name}\\s*\\{[^}]*\\}`).exec(sdl)?.[0] ?? null;
|
|
2498
|
+
}
|
|
2499
|
+
function withReferencedEnums(inputSchema, stateSchema) {
|
|
2500
|
+
if (!stateSchema) return inputSchema;
|
|
2501
|
+
const defined = new Set([...inputSchema.matchAll(DEFINITION)].map((match) => match[1]));
|
|
2502
|
+
const enums = [...new Set([...inputSchema.matchAll(/:\s*\[?\s*(\w+)/g)].map((match) => match[1]).filter((name) => !defined.has(name) && !SCALARS.has(name)))].map((name) => blockOf(stateSchema, "enum", name)).filter((block) => block !== null);
|
|
2503
|
+
return enums.length ? `${inputSchema}\n\n${enums.join("\n\n")}` : inputSchema;
|
|
2504
|
+
}
|
|
2505
|
+
//#endregion
|
|
2310
2506
|
//#region pieces/reactor/lib/reactor.ts
|
|
2311
2507
|
const DRIVE_DOCUMENT_TYPE = "powerhouse/document-drive";
|
|
2312
2508
|
const SET_NAME = {
|
|
@@ -2315,12 +2511,20 @@ const SET_NAME = {
|
|
|
2315
2511
|
inputSchema: "input SetNameInput {\n name: String!\n}"
|
|
2316
2512
|
};
|
|
2317
2513
|
async function documentOptions(reactor, documentType) {
|
|
2514
|
+
const documents = await reactor.find(documentType ? { documentType } : {});
|
|
2515
|
+
const nameOf = (document) => document.name || document.slug || "(unnamed)";
|
|
2516
|
+
const seen = /* @__PURE__ */ new Map();
|
|
2517
|
+
for (const document of documents) seen.set(nameOf(document), (seen.get(nameOf(document)) ?? 0) + 1);
|
|
2318
2518
|
return {
|
|
2319
|
-
options:
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2519
|
+
options: documents.map((document) => {
|
|
2520
|
+
const name = nameOf(document);
|
|
2521
|
+
const shown = (seen.get(name) ?? 0) > 1 ? `${name} (${document.slug && document.slug !== name ? document.slug : document.documentId.slice(0, 8)})` : name;
|
|
2522
|
+
return {
|
|
2523
|
+
label: documentType ? shown : `${shown} — ${document.documentType}`,
|
|
2524
|
+
value: document.documentId
|
|
2525
|
+
};
|
|
2526
|
+
}),
|
|
2527
|
+
placeholder: documentType === DRIVE_DOCUMENT_TYPE ? "Choose a drive" : documentType ? `Documents of type ${documentType}` : "All documents on this reactor"
|
|
2324
2528
|
};
|
|
2325
2529
|
}
|
|
2326
2530
|
const documentTypeProp = (displayName = "Document type", required = false, description) => Property.Dropdown({
|
|
@@ -2352,10 +2556,32 @@ const driveProp = (displayName, description) => Property.Dropdown({
|
|
|
2352
2556
|
refreshers: [],
|
|
2353
2557
|
options: (_propsValue, ctx) => documentOptions(reactorOf(ctx), DRIVE_DOCUMENT_TYPE)
|
|
2354
2558
|
});
|
|
2355
|
-
const
|
|
2559
|
+
const folderProp = (displayName, driveProp, description) => Property.Dropdown({
|
|
2560
|
+
auth: void 0,
|
|
2356
2561
|
displayName,
|
|
2357
|
-
description
|
|
2358
|
-
required
|
|
2562
|
+
description,
|
|
2563
|
+
required: false,
|
|
2564
|
+
refreshers: [driveProp],
|
|
2565
|
+
options: async (propsValue, ctx) => {
|
|
2566
|
+
const driveId = staticString(propsValue[driveProp]);
|
|
2567
|
+
if (!driveId) return {
|
|
2568
|
+
disabled: true,
|
|
2569
|
+
options: [],
|
|
2570
|
+
placeholder: "Pick a drive first"
|
|
2571
|
+
};
|
|
2572
|
+
const drive = await reactorOf(ctx).get({ documentId: driveId });
|
|
2573
|
+
const options = folderOptions(drive.state);
|
|
2574
|
+
return {
|
|
2575
|
+
options,
|
|
2576
|
+
placeholder: options.length ? `Folders in ${drive.name || "this drive"}` : `${drive.name || "This drive"} has no folders`
|
|
2577
|
+
};
|
|
2578
|
+
}
|
|
2579
|
+
});
|
|
2580
|
+
const actionsProp = (displayName, description) => Property.Json({
|
|
2581
|
+
displayName,
|
|
2582
|
+
required: false,
|
|
2583
|
+
description,
|
|
2584
|
+
advanced: true
|
|
2359
2585
|
});
|
|
2360
2586
|
const actionTypeProp = (displayName = "Action type", required = false, description) => Property.Dropdown({
|
|
2361
2587
|
auth: void 0,
|
|
@@ -2371,19 +2597,59 @@ const actionTypeProp = (displayName = "Action type", required = false, descripti
|
|
|
2371
2597
|
if (documentId) documentType = (await reactor.get({ documentId })).documentType;
|
|
2372
2598
|
}
|
|
2373
2599
|
if (!documentType) return {
|
|
2600
|
+
disabled: true,
|
|
2374
2601
|
options: [SET_NAME],
|
|
2375
|
-
placeholder: "
|
|
2602
|
+
placeholder: "Pick a document type first"
|
|
2376
2603
|
};
|
|
2604
|
+
const model = await reactor.model(documentType);
|
|
2377
2605
|
return {
|
|
2378
|
-
options: [...
|
|
2606
|
+
options: [...model.actions.map((action) => ({
|
|
2379
2607
|
label: `${action.type} (${action.module})`,
|
|
2380
2608
|
value: action.type,
|
|
2381
|
-
|
|
2609
|
+
documentType,
|
|
2610
|
+
...action.inputSchema ? { inputSchema: withReferencedEnums(action.inputSchema, model.stateSchema) } : {}
|
|
2382
2611
|
}))],
|
|
2383
2612
|
placeholder: `Actions of ${documentType}`
|
|
2384
2613
|
};
|
|
2385
2614
|
}
|
|
2386
2615
|
});
|
|
2616
|
+
async function targetType(reactor, propsValue) {
|
|
2617
|
+
const named = staticString(propsValue.documentType);
|
|
2618
|
+
if (named) return named;
|
|
2619
|
+
const documentId = staticString(propsValue.documentId);
|
|
2620
|
+
return documentId ? (await reactor.get({ documentId })).documentType : void 0;
|
|
2621
|
+
}
|
|
2622
|
+
async function actionInputSchema(reactor, propsValue) {
|
|
2623
|
+
const actionType = staticString(propsValue.actionType);
|
|
2624
|
+
if (!actionType) return void 0;
|
|
2625
|
+
const documentType = await targetType(reactor, propsValue);
|
|
2626
|
+
if (!documentType) return void 0;
|
|
2627
|
+
const model = await reactor.model(documentType);
|
|
2628
|
+
const action = model.actions.find((entry) => entry.type === actionType);
|
|
2629
|
+
if (!action?.inputSchema) return void 0;
|
|
2630
|
+
return parseActionInputSchema(withReferencedEnums(action.inputSchema, model.stateSchema), actionType) ?? void 0;
|
|
2631
|
+
}
|
|
2632
|
+
const actionInputProp = (displayName = "Input") => Property.DynamicProperties({
|
|
2633
|
+
auth: void 0,
|
|
2634
|
+
displayName,
|
|
2635
|
+
required: false,
|
|
2636
|
+
refreshers: [
|
|
2637
|
+
"documentType",
|
|
2638
|
+
"documentId",
|
|
2639
|
+
"actionType"
|
|
2640
|
+
],
|
|
2641
|
+
props: async (propsValue, ctx) => {
|
|
2642
|
+
const schema = await actionInputSchema(reactorOf(ctx), propsValue);
|
|
2643
|
+
return schema ? inputProps(schema) : {};
|
|
2644
|
+
}
|
|
2645
|
+
});
|
|
2646
|
+
const ACTION_GROUP = (when) => ({
|
|
2647
|
+
key: "action",
|
|
2648
|
+
display: "section",
|
|
2649
|
+
label: "Action",
|
|
2650
|
+
description: `${when} Pick a type, then fill in its input: the action needs both.`,
|
|
2651
|
+
props: ["actionType", "input"]
|
|
2652
|
+
});
|
|
2387
2653
|
//#endregion
|
|
2388
2654
|
//#region pieces/reactor/lib/actions/document-create.ts
|
|
2389
2655
|
const BLOCK$1 = "document-create";
|
|
@@ -2392,19 +2658,23 @@ const documentCreateAction = createAction({
|
|
|
2392
2658
|
displayName: "Create document",
|
|
2393
2659
|
description: "Creates a Powerhouse document.",
|
|
2394
2660
|
requireAuth: false,
|
|
2661
|
+
propertyGroups: [ACTION_GROUP("Optional, sent right after the create.")],
|
|
2395
2662
|
props: {
|
|
2396
2663
|
documentType: documentTypeProp(),
|
|
2397
2664
|
name: Property.ShortText({
|
|
2398
2665
|
displayName: "Document name",
|
|
2399
2666
|
required: false
|
|
2400
2667
|
}),
|
|
2401
|
-
parentId: driveProp("Parent drive
|
|
2402
|
-
|
|
2403
|
-
actionType: actionTypeProp("
|
|
2668
|
+
parentId: driveProp("Parent drive"),
|
|
2669
|
+
folderId: folderProp("Folder", "parentId", "Omit for the drive's root"),
|
|
2670
|
+
actionType: actionTypeProp("Type", false),
|
|
2671
|
+
input: actionInputProp("Input"),
|
|
2672
|
+
actions: actionsProp("Action list (JSON)", "Several actions after the create, or a payload from an earlier step: [{ \"type\": …, \"input\": … }]"),
|
|
2404
2673
|
payload: Property.ShortText({
|
|
2405
2674
|
displayName: "Payload",
|
|
2406
2675
|
description: "JSON {documentType, name, actions?}, e.g. {{steps.draft.output}}",
|
|
2407
|
-
required: false
|
|
2676
|
+
required: false,
|
|
2677
|
+
advanced: true
|
|
2408
2678
|
})
|
|
2409
2679
|
},
|
|
2410
2680
|
run: async (ctx) => {
|
|
@@ -2417,9 +2687,21 @@ const documentCreateAction = createAction({
|
|
|
2417
2687
|
const created = await reactor.create({
|
|
2418
2688
|
documentType,
|
|
2419
2689
|
...name ? { name } : {},
|
|
2420
|
-
...config.parentId ? { parentId: config.parentId } : {}
|
|
2690
|
+
...config.folderId || config.parentId ? { parentId: config.folderId || config.parentId } : {}
|
|
2421
2691
|
});
|
|
2422
2692
|
const followUps = parseActions(config.actions ?? payload.actions, BLOCK$1);
|
|
2693
|
+
const actionType = typeof config.actionType === "string" ? config.actionType.trim() : "";
|
|
2694
|
+
if (actionType) {
|
|
2695
|
+
const schema = await actionInputSchema(reactor, {
|
|
2696
|
+
documentType,
|
|
2697
|
+
actionType
|
|
2698
|
+
});
|
|
2699
|
+
followUps.unshift({
|
|
2700
|
+
type: actionType,
|
|
2701
|
+
input: schema ? coerceInput(schema, config.input) : config.input ?? {},
|
|
2702
|
+
scope: void 0
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2423
2705
|
const document = followUps.length ? await reactor.execute({
|
|
2424
2706
|
documentId: created.documentId,
|
|
2425
2707
|
actions: followUps
|
|
@@ -2440,31 +2722,44 @@ const documentDispatchAction = createAction({
|
|
|
2440
2722
|
displayName: "Dispatch actions",
|
|
2441
2723
|
description: "Sends actions to a document.",
|
|
2442
2724
|
requireAuth: false,
|
|
2725
|
+
propertyGroups: [ACTION_GROUP("Sent to the document.")],
|
|
2443
2726
|
props: {
|
|
2444
2727
|
documentId: documentIdProp("Document id", true, "e.g. {{steps.create.output.documentId}}"),
|
|
2445
2728
|
documentType: documentTypeProp("Document type", false, "Design-time hint when the document id is an expression"),
|
|
2446
|
-
|
|
2447
|
-
|
|
2729
|
+
actionType: actionTypeProp("Type", false),
|
|
2730
|
+
input: actionInputProp("Input"),
|
|
2731
|
+
actions: actionsProp("Action list (JSON)", "Several actions at once, or a payload from an earlier step: [{ \"type\": …, \"input\": … }]"),
|
|
2448
2732
|
allowedActions: Property.ShortText({
|
|
2449
2733
|
displayName: "Allowed action types",
|
|
2450
2734
|
description: "Comma-separated whitelist; enforced when set",
|
|
2451
|
-
required: false
|
|
2735
|
+
required: false,
|
|
2736
|
+
advanced: true
|
|
2452
2737
|
}),
|
|
2453
2738
|
branch: Property.ShortText({
|
|
2454
2739
|
displayName: "Branch",
|
|
2455
2740
|
description: "Defaults to \"main\"",
|
|
2456
|
-
required: false
|
|
2741
|
+
required: false,
|
|
2742
|
+
advanced: true
|
|
2457
2743
|
})
|
|
2458
2744
|
},
|
|
2459
2745
|
run: async (ctx) => {
|
|
2460
2746
|
const config = ctx.propsValue;
|
|
2461
2747
|
const payload = parseDispatchPayload(config.actions, BLOCK);
|
|
2748
|
+
const actionType = typeof config.actionType === "string" ? config.actionType.trim() : "";
|
|
2749
|
+
if (actionType) {
|
|
2750
|
+
const schema = await actionInputSchema(reactorOf(ctx), config);
|
|
2751
|
+
payload.actions.unshift({
|
|
2752
|
+
type: actionType,
|
|
2753
|
+
input: schema ? coerceInput(schema, config.input) : config.input ?? {},
|
|
2754
|
+
scope: void 0
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2462
2757
|
const documentId = resolveDocumentId(config.documentId) ?? resolveDocumentId(payload.documentId);
|
|
2463
2758
|
if (!documentId) throw new Error(`${BLOCK}: "documentId" is required, in the config or the actions payload`);
|
|
2464
2759
|
const allowed = allowedActionTypes(config.allowedActions);
|
|
2465
2760
|
const rejected = allowed.length ? payload.actions.filter((entry) => !allowed.includes(entry.type)) : [];
|
|
2466
2761
|
if (rejected.length > 0) throw new Error(`${BLOCK}: action(s) not allowed here: ${[...new Set(rejected.map((entry) => entry.type))].join(", ")}`);
|
|
2467
|
-
if (payload.actions.length === 0) throw new Error(`${BLOCK}:
|
|
2762
|
+
if (payload.actions.length === 0) throw new Error(`${BLOCK}: choose an Action, or give a non-empty "Action list (JSON)"`);
|
|
2468
2763
|
const document = await reactorOf(ctx).execute({
|
|
2469
2764
|
documentId,
|
|
2470
2765
|
...config.branch ? { branch: config.branch } : {},
|
|
@@ -2489,7 +2784,7 @@ const documentFindAction = createAction({
|
|
|
2489
2784
|
requireAuth: false,
|
|
2490
2785
|
props: {
|
|
2491
2786
|
documentType: documentTypeProp("Document type", false, "Omit for any type"),
|
|
2492
|
-
parentId: driveProp("In drive
|
|
2787
|
+
parentId: driveProp("In drive", "Omit for the whole reactor"),
|
|
2493
2788
|
name: Property.ShortText({
|
|
2494
2789
|
displayName: "Name contains",
|
|
2495
2790
|
description: "Case-insensitive match",
|