ugcinc 4.1.18 → 4.1.20

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.
@@ -15,47 +15,16 @@ const definition = (0, types_1.defineNode)({
15
15
  outputMode: 'per-input',
16
16
  selectionMode: null,
17
17
  },
18
- computePorts: async ({ config, client }) => {
19
- // Use cached resolved ports if available
18
+ computePorts: ({ config }) => {
19
+ // Return cached resolved ports - fetching/updating happens in the UI
20
20
  if (config?.resolvedPorts) {
21
21
  return {
22
22
  inputs: config.resolvedPorts.inputs ?? [],
23
23
  outputs: config.resolvedPorts.outputs ?? [],
24
24
  };
25
25
  }
26
- // If no templateId selected, return empty ports
27
- const templateId = config?.workflowTemplateId;
28
- if (!templateId || !client) {
29
- return { inputs: [], outputs: [] };
30
- }
31
- // Fetch the sub-workflow template
32
- const response = await client.getTemplate({ templateId });
33
- if (!response.ok) {
34
- return { inputs: [], outputs: [] };
35
- }
36
- const template = response.data;
37
- // Find the manual-trigger node to get input definitions
38
- const manualTrigger = template.nodes.find(n => n.type === 'manual-trigger');
39
- const triggerOutputs = manualTrigger?.type === 'manual-trigger'
40
- ? (manualTrigger.config?.outputs ?? [])
41
- : [];
42
- // Convert trigger outputs to compose-workflow inputs
43
- const inputs = triggerOutputs.map(output => ({
44
- id: output.id,
45
- type: output.type,
46
- isArray: output.isArray ?? false,
47
- required: true,
48
- ...(output.type === 'enum' && output.enumOptions ? { enumOptions: output.enumOptions } : {}),
49
- }));
50
- // Use template's output_schema for outputs
51
- const outputSchema = template.output_schema ?? {};
52
- const outputs = Object.entries(outputSchema).map(([id, schema]) => ({
53
- id,
54
- type: schema.type,
55
- isArray: false,
56
- required: true,
57
- }));
58
- return { inputs, outputs };
26
+ // No cached ports yet - UI will fetch and update
27
+ return { inputs: [], outputs: [] };
59
28
  },
60
29
  });
61
30
  exports.default = definition;
@@ -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
- import type { AutomationsClient } from '../index';
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 | Promise<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 | Promise<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
  */
@@ -40,62 +39,35 @@ export declare function areTypesCompatible({ sourceType, sourceIsArray, targetTy
40
39
  targetType: BasePortType | BasePortType[];
41
40
  targetIsArray: boolean;
42
41
  }): boolean;
43
- /**
44
- * Compute ports for a node synchronously.
45
- *
46
- * Most nodes have sync computePorts functions. For async nodes (like compose-workflow),
47
- * this falls back to cached resolvedPorts from the config, or returns empty arrays.
48
- *
49
- * Use this in UI contexts where you can't await (e.g., React useMemo).
50
- * For server-side or async contexts, use computePortsForNode instead.
51
- *
52
- * @param nodeType - The type of the node
53
- * @param config - The node's configuration object (should include resolvedPorts for async nodes)
54
- * @param getConnectedOutput - Optional function to get connected output port info (for dynamic ports)
55
- */
56
- export declare function computePortsSync({ nodeType, config, getConnectedOutput, }: {
57
- nodeType: UserCreatableNodeType;
58
- config?: Record<string, unknown>;
59
- getConnectedOutput?: (inputId: string) => {
60
- type: BasePortType | BasePortType[];
61
- isArray: boolean;
62
- objectSchema?: ObjectSchemaField[];
63
- } | null;
64
- }): {
65
- inputs: NodePort[];
66
- outputs: NodePort[];
67
- };
68
42
  /**
69
43
  * Compute ports for a node based on its type and config.
70
44
  * Uses the node definition's computePorts function.
71
45
  *
72
46
  * @param nodeType - The type of the node
73
47
  * @param config - The node's configuration object
74
- * @param client - Optional AutomationsClient for nodes that need to fetch data
75
48
  * @param getConnectedOutput - Optional function to get connected output port info (for dynamic ports)
76
49
  */
77
- export declare function computePortsForNode({ nodeType, config, client, getConnectedOutput, }: {
50
+ export declare function computePortsForNode({ nodeType, config, getConnectedOutput, }: {
78
51
  nodeType: UserCreatableNodeType;
79
52
  config?: Record<string, unknown>;
80
- client?: AutomationsClient;
81
53
  getConnectedOutput?: (inputId: string) => {
82
54
  type: BasePortType | BasePortType[];
83
55
  isArray: boolean;
84
56
  objectSchema?: ObjectSchemaField[];
85
57
  } | null;
86
- }): Promise<{
58
+ }): {
87
59
  inputs: NodePort[];
88
60
  outputs: NodePort[];
89
- }>;
61
+ };
90
62
  /**
91
63
  * Get all available automation nodes.
92
64
  * Converts node definitions from the registry into ComputedNode format.
93
65
  */
94
- export declare function getAllNodes(client?: AutomationsClient): Promise<ComputedNode[]>;
66
+ export declare function getAllNodes(): ComputedNode[];
95
67
  /**
96
68
  * Get a specific node by nodeId
97
69
  */
98
- export declare function getNodeByType(nodeId: string, client?: AutomationsClient): Promise<ComputedNode | undefined>;
70
+ export declare function getNodeByType(nodeId: string): ComputedNode | undefined;
99
71
  /**
100
72
  * Get the schema of array items for a node's output port.
101
73
  * Returns null if schema is unknown or the output is not an array.
@@ -103,15 +75,13 @@ export declare function getNodeByType(nodeId: string, client?: AutomationsClient
103
75
  * @param nodeType - The type of the node (e.g., 'transcript', 'llm')
104
76
  * @param nodeConfig - The node's configuration object
105
77
  * @param outputPortId - The ID of the output port to get schema for
106
- * @param client - Optional AutomationsClient for nodes that need to fetch data
107
78
  * @returns The schema of array items, or null if unknown
108
79
  */
109
- export declare function getOutputSchema({ nodeType, nodeConfig, outputPortId, client, }: {
80
+ export declare function getOutputSchema({ nodeType, nodeConfig, outputPortId, }: {
110
81
  nodeType: string;
111
82
  nodeConfig: Record<string, unknown> | undefined;
112
83
  outputPortId: string;
113
- client?: AutomationsClient;
114
- }): Promise<ObjectSchemaField[] | null>;
84
+ }): ObjectSchemaField[] | null;
115
85
  /**
116
86
  * Create a new node with default config from the node definition.
117
87
  */
@@ -202,7 +172,7 @@ export declare function checkCrossContextViolation({ sourceNodeId, targetNodeId,
202
172
  */
203
173
  export declare function validateWorkflow({ nodes, }: {
204
174
  nodes: WorkflowNodeDefinition[];
205
- }): Promise<ValidationError[]>;
175
+ }): ValidationError[];
206
176
  /**
207
177
  * Get node IDs that have errors
208
178
  */
@@ -13,7 +13,6 @@
13
13
  */
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.areTypesCompatible = areTypesCompatible;
16
- exports.computePortsSync = computePortsSync;
17
16
  exports.computePortsForNode = computePortsForNode;
18
17
  exports.getAllNodes = getAllNodes;
19
18
  exports.getNodeByType = getNodeByType;
@@ -245,58 +244,21 @@ function areTypesCompatible({ sourceType, sourceIsArray, targetType, targetIsArr
245
244
  // ===========================================================================
246
245
  // Port Computation
247
246
  // ===========================================================================
248
- /**
249
- * Compute ports for a node synchronously.
250
- *
251
- * Most nodes have sync computePorts functions. For async nodes (like compose-workflow),
252
- * this falls back to cached resolvedPorts from the config, or returns empty arrays.
253
- *
254
- * Use this in UI contexts where you can't await (e.g., React useMemo).
255
- * For server-side or async contexts, use computePortsForNode instead.
256
- *
257
- * @param nodeType - The type of the node
258
- * @param config - The node's configuration object (should include resolvedPorts for async nodes)
259
- * @param getConnectedOutput - Optional function to get connected output port info (for dynamic ports)
260
- */
261
- function computePortsSync({ nodeType, config, getConnectedOutput, }) {
262
- const definition = (0, nodes_1.getNodeDefinition)(nodeType);
263
- if (!definition) {
264
- return { inputs: [], outputs: [] };
265
- }
266
- const result = definition.computePorts({
267
- config: config ?? definition.defaults,
268
- getConnectedOutput,
269
- });
270
- // If the result is a Promise, fall back to cached resolvedPorts or empty arrays
271
- if (result instanceof Promise) {
272
- const resolvedPorts = config?.resolvedPorts;
273
- if (resolvedPorts) {
274
- return {
275
- inputs: resolvedPorts.inputs,
276
- outputs: resolvedPorts.outputs,
277
- };
278
- }
279
- return { inputs: [], outputs: [] };
280
- }
281
- return result;
282
- }
283
247
  /**
284
248
  * Compute ports for a node based on its type and config.
285
249
  * Uses the node definition's computePorts function.
286
250
  *
287
251
  * @param nodeType - The type of the node
288
252
  * @param config - The node's configuration object
289
- * @param client - Optional AutomationsClient for nodes that need to fetch data
290
253
  * @param getConnectedOutput - Optional function to get connected output port info (for dynamic ports)
291
254
  */
292
- async function computePortsForNode({ nodeType, config, client, getConnectedOutput, }) {
255
+ function computePortsForNode({ nodeType, config, getConnectedOutput, }) {
293
256
  const definition = (0, nodes_1.getNodeDefinition)(nodeType);
294
257
  if (!definition) {
295
258
  return { inputs: [], outputs: [] };
296
259
  }
297
- return await definition.computePorts({
260
+ return definition.computePorts({
298
261
  config: config ?? definition.defaults,
299
- client,
300
262
  getConnectedOutput,
301
263
  });
302
264
  }
@@ -304,11 +266,11 @@ async function computePortsForNode({ nodeType, config, client, getConnectedOutpu
304
266
  * Get all available automation nodes.
305
267
  * Converts node definitions from the registry into ComputedNode format.
306
268
  */
307
- async function getAllNodes(client) {
269
+ function getAllNodes() {
308
270
  const definitions = (0, nodes_1.getAllNodeDefinitions)();
309
271
  const results = [];
310
272
  for (const def of definitions) {
311
- const { inputs, outputs } = await def.computePorts({ config: def.defaults, client });
273
+ const { inputs, outputs } = def.computePorts({ config: def.defaults });
312
274
  results.push({
313
275
  nodeId: def.nodeId,
314
276
  label: def.label,
@@ -327,8 +289,8 @@ async function getAllNodes(client) {
327
289
  /**
328
290
  * Get a specific node by nodeId
329
291
  */
330
- async function getNodeByType(nodeId, client) {
331
- const allNodes = await getAllNodes(client);
292
+ function getNodeByType(nodeId) {
293
+ const allNodes = getAllNodes();
332
294
  return allNodes.find(node => node.nodeId === nodeId);
333
295
  }
334
296
  // ===========================================================================
@@ -341,12 +303,11 @@ async function getNodeByType(nodeId, client) {
341
303
  * @param nodeType - The type of the node (e.g., 'transcript', 'llm')
342
304
  * @param nodeConfig - The node's configuration object
343
305
  * @param outputPortId - The ID of the output port to get schema for
344
- * @param client - Optional AutomationsClient for nodes that need to fetch data
345
306
  * @returns The schema of array items, or null if unknown
346
307
  */
347
- async function getOutputSchema({ nodeType, nodeConfig, outputPortId, client, }) {
308
+ function getOutputSchema({ nodeType, nodeConfig, outputPortId, }) {
348
309
  // First check static node definitions
349
- const nodeDefinition = await getNodeByType(nodeType, client);
310
+ const nodeDefinition = getNodeByType(nodeType);
350
311
  const outputPort = nodeDefinition?.outputs.find(o => o.id === outputPortId);
351
312
  if (outputPort?.objectSchema) {
352
313
  return outputPort.objectSchema;
@@ -553,7 +514,7 @@ const TERMINAL_TYPES = ['passthrough', 'auto-post', 'save-to-media'];
553
514
  /**
554
515
  * Validate workflow and return structured errors for UI highlighting
555
516
  */
556
- async function validateWorkflow({ nodes, }) {
517
+ function validateWorkflow({ nodes, }) {
557
518
  const errors = [];
558
519
  const connections = deriveConnectionsInternal(nodes);
559
520
  // 1. Check for trigger node
@@ -585,7 +546,7 @@ async function validateWorkflow({ nodes, }) {
585
546
  // Use node definition's computePorts if available
586
547
  const definition = (0, nodes_1.getNodeDefinition)(node.type);
587
548
  const inputPorts = definition
588
- ? (await definition.computePorts({ config: node.config ?? {} })).inputs
549
+ ? definition.computePorts({ config: node.config ?? {} }).inputs
589
550
  : [];
590
551
  for (const port of inputPorts) {
591
552
  if (!port.required)
@@ -607,7 +568,7 @@ async function validateWorkflow({ nodes, }) {
607
568
  if (sourceNode) {
608
569
  const sourceDefinition = (0, nodes_1.getNodeDefinition)(sourceNode.type);
609
570
  const sourceOutputs = sourceDefinition
610
- ? (await sourceDefinition.computePorts({ config: sourceNode.config ?? {} })).outputs
571
+ ? sourceDefinition.computePorts({ config: sourceNode.config ?? {} }).outputs
611
572
  : [];
612
573
  const sourcePort = sourceOutputs.find(p => p.id === connection.sourceOutputId);
613
574
  if (sourcePort) {
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export { RenderClient } from './render';
13
13
  export { AutomationsClient } from './automations';
14
14
  export { MediaClient } from './media';
15
15
  export { CommentsClient } from './comments';
16
- export { areTypesCompatible, computePortsSync, computePortsForNode, getAllNodes, getNodeByType, getOutputSchema, createNode, deriveConnections, addConnection, removeConnection, removeNodeConnections, cleanupStaleConnections, getForEachContext, checkCrossContextViolation, validateWorkflow, getErrorNodeIds, getPortErrorsForNode, hasMissingTriggerError, hasMissingTerminalError, getWorkflowOutputSchema, type WorkflowOutputSchemaEntry, resolveNodePreview, } from './graph-controller';
16
+ export { areTypesCompatible, computePortsForNode, getAllNodes, getNodeByType, getOutputSchema, createNode, deriveConnections, addConnection, removeConnection, removeNodeConnections, cleanupStaleConnections, getForEachContext, checkCrossContextViolation, validateWorkflow, getErrorNodeIds, getPortErrorsForNode, hasMissingTriggerError, hasMissingTerminalError, getWorkflowOutputSchema, type WorkflowOutputSchemaEntry, resolveNodePreview, } from './graph-controller';
17
17
  export { nodeDefinitions, internalNodeTypes, isAsyncExecutor, formatPortType } from './automations/types';
18
18
  export { isEditModel } from './automations/nodes/generate-image';
19
19
  export { isImageToVideoModel } from './automations/nodes/generate-video';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Official TypeScript/JavaScript client for the UGC Inc API
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.prepareVideoComposerInput = exports.LLMProviders = exports.IfLogicOperators = exports.indexExpressionToIndexes = exports.prepareImageComposerInput = exports.extractTemplateVariables = exports.PortIdSchema = exports.normalizeToPortId = exports.portIdToTitle = exports.isValidPortId = exports.portId = exports.selectFromPool = exports.isImageToVideoModel = exports.isEditModel = exports.formatPortType = exports.isAsyncExecutor = exports.internalNodeTypes = exports.nodeDefinitions = exports.resolveNodePreview = exports.getWorkflowOutputSchema = exports.hasMissingTerminalError = exports.hasMissingTriggerError = exports.getPortErrorsForNode = exports.getErrorNodeIds = exports.validateWorkflow = exports.checkCrossContextViolation = exports.getForEachContext = exports.cleanupStaleConnections = exports.removeNodeConnections = exports.removeConnection = exports.addConnection = exports.deriveConnections = exports.createNode = exports.getOutputSchema = exports.getNodeByType = exports.getAllNodes = exports.computePortsForNode = exports.computePortsSync = exports.areTypesCompatible = exports.CommentsClient = exports.MediaClient = exports.AutomationsClient = exports.RenderClient = exports.OrganizationClient = exports.StatsClient = exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
8
+ exports.prepareVideoComposerInput = exports.LLMProviders = exports.IfLogicOperators = exports.indexExpressionToIndexes = exports.prepareImageComposerInput = exports.extractTemplateVariables = exports.PortIdSchema = exports.normalizeToPortId = exports.portIdToTitle = exports.isValidPortId = exports.portId = exports.selectFromPool = exports.isImageToVideoModel = exports.isEditModel = exports.formatPortType = exports.isAsyncExecutor = exports.internalNodeTypes = exports.nodeDefinitions = exports.resolveNodePreview = exports.getWorkflowOutputSchema = exports.hasMissingTerminalError = exports.hasMissingTriggerError = exports.getPortErrorsForNode = exports.getErrorNodeIds = exports.validateWorkflow = exports.checkCrossContextViolation = exports.getForEachContext = exports.cleanupStaleConnections = exports.removeNodeConnections = exports.removeConnection = exports.addConnection = exports.deriveConnections = exports.createNode = exports.getOutputSchema = exports.getNodeByType = exports.getAllNodes = exports.computePortsForNode = exports.areTypesCompatible = exports.CommentsClient = exports.MediaClient = exports.AutomationsClient = exports.RenderClient = exports.OrganizationClient = exports.StatsClient = exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
9
9
  // =============================================================================
10
10
  // Client Exports
11
11
  // =============================================================================
@@ -36,7 +36,6 @@ var graph_controller_1 = require("./graph-controller");
36
36
  // Type compatibility
37
37
  Object.defineProperty(exports, "areTypesCompatible", { enumerable: true, get: function () { return graph_controller_1.areTypesCompatible; } });
38
38
  // Port computation
39
- Object.defineProperty(exports, "computePortsSync", { enumerable: true, get: function () { return graph_controller_1.computePortsSync; } });
40
39
  Object.defineProperty(exports, "computePortsForNode", { enumerable: true, get: function () { return graph_controller_1.computePortsForNode; } });
41
40
  Object.defineProperty(exports, "getAllNodes", { enumerable: true, get: function () { return graph_controller_1.getAllNodes; } });
42
41
  Object.defineProperty(exports, "getNodeByType", { enumerable: true, get: function () { return graph_controller_1.getNodeByType; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "4.1.18",
3
+ "version": "4.1.20",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",