ugcinc 4.1.19 → 4.1.21
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.
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* Each node file imports from here and defines its behavior.
|
|
6
6
|
*/
|
|
7
7
|
import type { NodePort, BasePortType } from '../types';
|
|
8
|
-
|
|
9
|
-
/** Return type for computePorts - can be sync or async */
|
|
8
|
+
/** Return type for computePorts */
|
|
10
9
|
export type ComputePortsResult = {
|
|
11
10
|
inputs: NodePort[];
|
|
12
11
|
outputs: NodePort[];
|
|
@@ -152,13 +151,12 @@ export interface NodeDefinition<T extends NodeCategory = NodeCategory, TDefaults
|
|
|
152
151
|
defaults: DefaultsForCategory<T, TDefaults>;
|
|
153
152
|
computePorts: (params: {
|
|
154
153
|
config: DefaultsForCategory<T, TDefaults>;
|
|
155
|
-
client?: AutomationsClient;
|
|
156
154
|
getConnectedOutput?: (inputId: string) => {
|
|
157
155
|
type: BasePortType | BasePortType[];
|
|
158
156
|
isArray: boolean;
|
|
159
157
|
objectSchema?: ObjectSchemaField[];
|
|
160
158
|
} | null;
|
|
161
|
-
}) => ComputePortsResult
|
|
159
|
+
}) => ComputePortsResult;
|
|
162
160
|
/**
|
|
163
161
|
* Resolve preview values for this node.
|
|
164
162
|
* Converts config with refs (inputId/textInputId) to render-ready format.
|
|
@@ -186,13 +184,12 @@ export declare function defineNode<T extends NodeCategory, TCustomDefaults exten
|
|
|
186
184
|
defaults: DefaultsForCategory<T, TCustomDefaults>;
|
|
187
185
|
computePorts: (params: {
|
|
188
186
|
config: DefaultsForCategory<T, TCustomDefaults>;
|
|
189
|
-
client?: AutomationsClient;
|
|
190
187
|
getConnectedOutput?: (inputId: string) => {
|
|
191
188
|
type: BasePortType | BasePortType[];
|
|
192
189
|
isArray: boolean;
|
|
193
190
|
objectSchema?: ObjectSchemaField[];
|
|
194
191
|
} | null;
|
|
195
|
-
}) => ComputePortsResult
|
|
192
|
+
}) => ComputePortsResult;
|
|
196
193
|
/**
|
|
197
194
|
* Resolve preview values for this node.
|
|
198
195
|
* Converts config with refs (inputId/textInputId) to render-ready format.
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import type { WorkflowNodeDefinition, ComputedNode, NodePort, BasePortType, ValidationError, UserCreatableNodeType } from './automations/types';
|
|
14
14
|
import type { ObjectSchemaField, ResolvedPreview } from './automations/nodes/types';
|
|
15
|
-
import type { AutomationsClient } from './automations';
|
|
16
15
|
/**
|
|
17
16
|
* Connection extracted from embedded inputs format for internal processing
|
|
18
17
|
*/
|
|
@@ -44,33 +43,31 @@ export declare function areTypesCompatible({ sourceType, sourceIsArray, targetTy
|
|
|
44
43
|
* Compute ports for a node based on its type and config.
|
|
45
44
|
* Uses the node definition's computePorts function.
|
|
46
45
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @param
|
|
46
|
+
* Accepts the full WorkflowNodeDefinition to preserve discriminated union typing.
|
|
47
|
+
*
|
|
48
|
+
* @param node - The workflow node definition
|
|
50
49
|
* @param getConnectedOutput - Optional function to get connected output port info (for dynamic ports)
|
|
51
50
|
*/
|
|
52
|
-
export declare function computePortsForNode({
|
|
53
|
-
|
|
54
|
-
config?: Record<string, unknown>;
|
|
55
|
-
client?: AutomationsClient;
|
|
51
|
+
export declare function computePortsForNode({ node, getConnectedOutput, }: {
|
|
52
|
+
node: WorkflowNodeDefinition;
|
|
56
53
|
getConnectedOutput?: (inputId: string) => {
|
|
57
54
|
type: BasePortType | BasePortType[];
|
|
58
55
|
isArray: boolean;
|
|
59
56
|
objectSchema?: ObjectSchemaField[];
|
|
60
57
|
} | null;
|
|
61
|
-
}):
|
|
58
|
+
}): {
|
|
62
59
|
inputs: NodePort[];
|
|
63
60
|
outputs: NodePort[];
|
|
64
|
-
}
|
|
61
|
+
};
|
|
65
62
|
/**
|
|
66
63
|
* Get all available automation nodes.
|
|
67
64
|
* Converts node definitions from the registry into ComputedNode format.
|
|
68
65
|
*/
|
|
69
|
-
export declare function getAllNodes(
|
|
66
|
+
export declare function getAllNodes(): ComputedNode[];
|
|
70
67
|
/**
|
|
71
68
|
* Get a specific node by nodeId
|
|
72
69
|
*/
|
|
73
|
-
export declare function getNodeByType(nodeId: string
|
|
70
|
+
export declare function getNodeByType(nodeId: string): ComputedNode | undefined;
|
|
74
71
|
/**
|
|
75
72
|
* Get the schema of array items for a node's output port.
|
|
76
73
|
* Returns null if schema is unknown or the output is not an array.
|
|
@@ -78,15 +75,13 @@ export declare function getNodeByType(nodeId: string, client?: AutomationsClient
|
|
|
78
75
|
* @param nodeType - The type of the node (e.g., 'transcript', 'llm')
|
|
79
76
|
* @param nodeConfig - The node's configuration object
|
|
80
77
|
* @param outputPortId - The ID of the output port to get schema for
|
|
81
|
-
* @param client - Optional AutomationsClient for nodes that need to fetch data
|
|
82
78
|
* @returns The schema of array items, or null if unknown
|
|
83
79
|
*/
|
|
84
|
-
export declare function getOutputSchema({ nodeType, nodeConfig, outputPortId,
|
|
80
|
+
export declare function getOutputSchema({ nodeType, nodeConfig, outputPortId, }: {
|
|
85
81
|
nodeType: string;
|
|
86
82
|
nodeConfig: Record<string, unknown> | undefined;
|
|
87
83
|
outputPortId: string;
|
|
88
|
-
|
|
89
|
-
}): Promise<ObjectSchemaField[] | null>;
|
|
84
|
+
}): ObjectSchemaField[] | null;
|
|
90
85
|
/**
|
|
91
86
|
* Create a new node with default config from the node definition.
|
|
92
87
|
*/
|
|
@@ -177,7 +172,7 @@ export declare function checkCrossContextViolation({ sourceNodeId, targetNodeId,
|
|
|
177
172
|
*/
|
|
178
173
|
export declare function validateWorkflow({ nodes, }: {
|
|
179
174
|
nodes: WorkflowNodeDefinition[];
|
|
180
|
-
}):
|
|
175
|
+
}): ValidationError[];
|
|
181
176
|
/**
|
|
182
177
|
* Get node IDs that have errors
|
|
183
178
|
*/
|
package/dist/graph-controller.js
CHANGED
|
@@ -248,19 +248,18 @@ function areTypesCompatible({ sourceType, sourceIsArray, targetType, targetIsArr
|
|
|
248
248
|
* Compute ports for a node based on its type and config.
|
|
249
249
|
* Uses the node definition's computePorts function.
|
|
250
250
|
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* @param
|
|
251
|
+
* Accepts the full WorkflowNodeDefinition to preserve discriminated union typing.
|
|
252
|
+
*
|
|
253
|
+
* @param node - The workflow node definition
|
|
254
254
|
* @param getConnectedOutput - Optional function to get connected output port info (for dynamic ports)
|
|
255
255
|
*/
|
|
256
|
-
|
|
257
|
-
const definition = (0, nodes_1.getNodeDefinition)(
|
|
256
|
+
function computePortsForNode({ node, getConnectedOutput, }) {
|
|
257
|
+
const definition = (0, nodes_1.getNodeDefinition)(node.type);
|
|
258
258
|
if (!definition) {
|
|
259
259
|
return { inputs: [], outputs: [] };
|
|
260
260
|
}
|
|
261
|
-
return
|
|
262
|
-
config: config ?? definition.defaults,
|
|
263
|
-
client,
|
|
261
|
+
return definition.computePorts({
|
|
262
|
+
config: node.config ?? definition.defaults,
|
|
264
263
|
getConnectedOutput,
|
|
265
264
|
});
|
|
266
265
|
}
|
|
@@ -268,11 +267,11 @@ async function computePortsForNode({ nodeType, config, client, getConnectedOutpu
|
|
|
268
267
|
* Get all available automation nodes.
|
|
269
268
|
* Converts node definitions from the registry into ComputedNode format.
|
|
270
269
|
*/
|
|
271
|
-
|
|
270
|
+
function getAllNodes() {
|
|
272
271
|
const definitions = (0, nodes_1.getAllNodeDefinitions)();
|
|
273
272
|
const results = [];
|
|
274
273
|
for (const def of definitions) {
|
|
275
|
-
const { inputs, outputs } =
|
|
274
|
+
const { inputs, outputs } = def.computePorts({ config: def.defaults });
|
|
276
275
|
results.push({
|
|
277
276
|
nodeId: def.nodeId,
|
|
278
277
|
label: def.label,
|
|
@@ -291,8 +290,8 @@ async function getAllNodes(client) {
|
|
|
291
290
|
/**
|
|
292
291
|
* Get a specific node by nodeId
|
|
293
292
|
*/
|
|
294
|
-
|
|
295
|
-
const allNodes =
|
|
293
|
+
function getNodeByType(nodeId) {
|
|
294
|
+
const allNodes = getAllNodes();
|
|
296
295
|
return allNodes.find(node => node.nodeId === nodeId);
|
|
297
296
|
}
|
|
298
297
|
// ===========================================================================
|
|
@@ -305,12 +304,11 @@ async function getNodeByType(nodeId, client) {
|
|
|
305
304
|
* @param nodeType - The type of the node (e.g., 'transcript', 'llm')
|
|
306
305
|
* @param nodeConfig - The node's configuration object
|
|
307
306
|
* @param outputPortId - The ID of the output port to get schema for
|
|
308
|
-
* @param client - Optional AutomationsClient for nodes that need to fetch data
|
|
309
307
|
* @returns The schema of array items, or null if unknown
|
|
310
308
|
*/
|
|
311
|
-
|
|
309
|
+
function getOutputSchema({ nodeType, nodeConfig, outputPortId, }) {
|
|
312
310
|
// First check static node definitions
|
|
313
|
-
const nodeDefinition =
|
|
311
|
+
const nodeDefinition = getNodeByType(nodeType);
|
|
314
312
|
const outputPort = nodeDefinition?.outputs.find(o => o.id === outputPortId);
|
|
315
313
|
if (outputPort?.objectSchema) {
|
|
316
314
|
return outputPort.objectSchema;
|
|
@@ -517,7 +515,7 @@ const TERMINAL_TYPES = ['passthrough', 'auto-post', 'save-to-media'];
|
|
|
517
515
|
/**
|
|
518
516
|
* Validate workflow and return structured errors for UI highlighting
|
|
519
517
|
*/
|
|
520
|
-
|
|
518
|
+
function validateWorkflow({ nodes, }) {
|
|
521
519
|
const errors = [];
|
|
522
520
|
const connections = deriveConnectionsInternal(nodes);
|
|
523
521
|
// 1. Check for trigger node
|
|
@@ -549,7 +547,7 @@ async function validateWorkflow({ nodes, }) {
|
|
|
549
547
|
// Use node definition's computePorts if available
|
|
550
548
|
const definition = (0, nodes_1.getNodeDefinition)(node.type);
|
|
551
549
|
const inputPorts = definition
|
|
552
|
-
?
|
|
550
|
+
? definition.computePorts({ config: node.config ?? {} }).inputs
|
|
553
551
|
: [];
|
|
554
552
|
for (const port of inputPorts) {
|
|
555
553
|
if (!port.required)
|
|
@@ -571,7 +569,7 @@ async function validateWorkflow({ nodes, }) {
|
|
|
571
569
|
if (sourceNode) {
|
|
572
570
|
const sourceDefinition = (0, nodes_1.getNodeDefinition)(sourceNode.type);
|
|
573
571
|
const sourceOutputs = sourceDefinition
|
|
574
|
-
?
|
|
572
|
+
? sourceDefinition.computePorts({ config: sourceNode.config ?? {} }).outputs
|
|
575
573
|
: [];
|
|
576
574
|
const sourcePort = sourceOutputs.find(p => p.id === connection.sourceOutputId);
|
|
577
575
|
if (sourcePort) {
|