ugcinc 4.1.16 → 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.
- package/dist/graph-controller.d.ts +35 -0
- package/dist/graph-controller.js +55 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -1
- package/package.json +1 -1
|
@@ -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.
|
|
@@ -87,6 +112,16 @@ export declare function getOutputSchema({ nodeType, nodeConfig, outputPortId, cl
|
|
|
87
112
|
outputPortId: string;
|
|
88
113
|
client?: AutomationsClient;
|
|
89
114
|
}): Promise<ObjectSchemaField[] | null>;
|
|
115
|
+
/**
|
|
116
|
+
* Create a new node with default config from the node definition.
|
|
117
|
+
*/
|
|
118
|
+
export declare function createNode({ type, id, name, x, y, }: {
|
|
119
|
+
type: UserCreatableNodeType;
|
|
120
|
+
id?: string;
|
|
121
|
+
name?: string;
|
|
122
|
+
x?: number;
|
|
123
|
+
y?: number;
|
|
124
|
+
}): WorkflowNodeDefinition;
|
|
90
125
|
/**
|
|
91
126
|
* Derive Connection[] array from nodes for canvas rendering
|
|
92
127
|
*
|
package/dist/graph-controller.js
CHANGED
|
@@ -13,10 +13,12 @@
|
|
|
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;
|
|
19
20
|
exports.getOutputSchema = getOutputSchema;
|
|
21
|
+
exports.createNode = createNode;
|
|
20
22
|
exports.deriveConnections = deriveConnections;
|
|
21
23
|
exports.addConnection = addConnection;
|
|
22
24
|
exports.removeConnection = removeConnection;
|
|
@@ -243,6 +245,41 @@ function areTypesCompatible({ sourceType, sourceIsArray, targetType, targetIsArr
|
|
|
243
245
|
// ===========================================================================
|
|
244
246
|
// Port Computation
|
|
245
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
|
+
}
|
|
246
283
|
/**
|
|
247
284
|
* Compute ports for a node based on its type and config.
|
|
248
285
|
* Uses the node definition's computePorts function.
|
|
@@ -325,6 +362,24 @@ async function getOutputSchema({ nodeType, nodeConfig, outputPortId, client, })
|
|
|
325
362
|
return null;
|
|
326
363
|
}
|
|
327
364
|
// ===========================================================================
|
|
365
|
+
// Node Creation
|
|
366
|
+
// ===========================================================================
|
|
367
|
+
/**
|
|
368
|
+
* Create a new node with default config from the node definition.
|
|
369
|
+
*/
|
|
370
|
+
function createNode({ type, id, name, x, y, }) {
|
|
371
|
+
const definition = nodes_1.nodeDefinitions[type];
|
|
372
|
+
return {
|
|
373
|
+
id: id ?? `${type}-${Date.now()}`,
|
|
374
|
+
type,
|
|
375
|
+
name,
|
|
376
|
+
config: structuredClone(definition.defaults),
|
|
377
|
+
inputs: {},
|
|
378
|
+
x,
|
|
379
|
+
y,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
// ===========================================================================
|
|
328
383
|
// Connection Management
|
|
329
384
|
// ===========================================================================
|
|
330
385
|
/**
|
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, 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.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,11 +36,14 @@ 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; } });
|
|
42
43
|
// Output schema
|
|
43
44
|
Object.defineProperty(exports, "getOutputSchema", { enumerable: true, get: function () { return graph_controller_1.getOutputSchema; } });
|
|
45
|
+
// Node creation
|
|
46
|
+
Object.defineProperty(exports, "createNode", { enumerable: true, get: function () { return graph_controller_1.createNode; } });
|
|
44
47
|
// Connection management
|
|
45
48
|
Object.defineProperty(exports, "deriveConnections", { enumerable: true, get: function () { return graph_controller_1.deriveConnections; } });
|
|
46
49
|
Object.defineProperty(exports, "addConnection", { enumerable: true, get: function () { return graph_controller_1.addConnection; } });
|