ugcinc 4.1.17 → 4.1.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.
@@ -40,6 +40,31 @@ export declare function areTypesCompatible({ sourceType, sourceIsArray, targetTy
40
40
  targetType: BasePortType | BasePortType[];
41
41
  targetIsArray: boolean;
42
42
  }): 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
+ };
43
68
  /**
44
69
  * Compute ports for a node based on its type and config.
45
70
  * Uses the node definition's computePorts function.
@@ -13,6 +13,7 @@
13
13
  */
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.areTypesCompatible = areTypesCompatible;
16
+ exports.computePortsSync = computePortsSync;
16
17
  exports.computePortsForNode = computePortsForNode;
17
18
  exports.getAllNodes = getAllNodes;
18
19
  exports.getNodeByType = getNodeByType;
@@ -244,6 +245,41 @@ function areTypesCompatible({ sourceType, sourceIsArray, targetType, targetIsArr
244
245
  // ===========================================================================
245
246
  // Port Computation
246
247
  // ===========================================================================
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
+ }
247
283
  /**
248
284
  * Compute ports for a node based on its type and config.
249
285
  * Uses the node definition's computePorts function.
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, 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, 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';
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.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.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;
9
9
  // =============================================================================
10
10
  // Client Exports
11
11
  // =============================================================================
@@ -36,6 +36,7 @@ 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; } });
39
40
  Object.defineProperty(exports, "computePortsForNode", { enumerable: true, get: function () { return graph_controller_1.computePortsForNode; } });
40
41
  Object.defineProperty(exports, "getAllNodes", { enumerable: true, get: function () { return graph_controller_1.getAllNodes; } });
41
42
  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.17",
3
+ "version": "4.1.18",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",