ugcinc 4.1.31 → 4.1.33
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/automations/types.d.ts +21 -0
- package/dist/graph-controller.d.ts +34 -7
- package/dist/graph-controller.js +46 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/package.json +1 -1
|
@@ -144,6 +144,27 @@ export interface NodePort {
|
|
|
144
144
|
/** Options for enum port types */
|
|
145
145
|
enumOptions?: EnumOption[];
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* NodePort with preview value attached.
|
|
149
|
+
* Used by computePortsWithPreviews to include resolved preview data
|
|
150
|
+
* directly on input ports, eliminating separate previewMap lookups.
|
|
151
|
+
*/
|
|
152
|
+
export interface NodePortWithPreview extends NodePort {
|
|
153
|
+
/**
|
|
154
|
+
* The preview value flowing into this input port.
|
|
155
|
+
* Type depends on the port type:
|
|
156
|
+
* - image: ImageValue
|
|
157
|
+
* - video: VideoValue
|
|
158
|
+
* - audio: AudioValue
|
|
159
|
+
* - text: string
|
|
160
|
+
* - account: AccountData
|
|
161
|
+
* - etc.
|
|
162
|
+
*
|
|
163
|
+
* null if no connection or source has no preview.
|
|
164
|
+
* undefined if not computed (shouldn't happen with computePortsWithPreviews).
|
|
165
|
+
*/
|
|
166
|
+
previewValue?: PortValue | PortValue[] | null;
|
|
167
|
+
}
|
|
147
168
|
/**
|
|
148
169
|
* Port definition for resolved/dynamic ports.
|
|
149
170
|
* Stored in node config when the automation is saved.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* All functions work with WorkflowNodeDefinition[] (embedded connection format).
|
|
12
12
|
*/
|
|
13
|
-
import type { WorkflowNodeDefinition, ComputedNode, NodePort, BasePortType, ValidationError, UserCreatableNodeType, PortValue, AccountData } from './automations/types';
|
|
13
|
+
import type { WorkflowNodeDefinition, ComputedNode, NodePort, NodePortWithPreview, BasePortType, ValidationError, UserCreatableNodeType, PortValue, AccountData } from './automations/types';
|
|
14
14
|
import type { ObjectSchemaField, ResolvedPreview } from './automations/nodes/types';
|
|
15
15
|
import type { Media } from './media';
|
|
16
16
|
/**
|
|
@@ -71,6 +71,29 @@ export declare function computePortsForNode({ node, getConnectedOutput, }: {
|
|
|
71
71
|
inputs: NodePort[];
|
|
72
72
|
outputs: NodePort[];
|
|
73
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Compute ports for a node with preview values attached to input ports.
|
|
76
|
+
* Combines port computation with preview lookup for a single source of truth.
|
|
77
|
+
*
|
|
78
|
+
* Each input port will have a `previewValue` property containing the resolved
|
|
79
|
+
* preview value from its connected source node (or null if no connection).
|
|
80
|
+
*
|
|
81
|
+
* @param node - The workflow node definition
|
|
82
|
+
* @param previewMap - The computed preview map (from computePreviewMap)
|
|
83
|
+
* @param getConnectedOutput - Optional function to get connected output port info
|
|
84
|
+
*/
|
|
85
|
+
export declare function computePortsWithPreviews({ node, previewMap, getConnectedOutput, }: {
|
|
86
|
+
node: WorkflowNodeDefinition;
|
|
87
|
+
previewMap: PreviewMap;
|
|
88
|
+
getConnectedOutput?: (inputId: string) => {
|
|
89
|
+
type: BasePortType | BasePortType[];
|
|
90
|
+
isArray: boolean;
|
|
91
|
+
objectSchema?: ObjectSchemaField[];
|
|
92
|
+
} | null;
|
|
93
|
+
}): {
|
|
94
|
+
inputs: NodePortWithPreview[];
|
|
95
|
+
outputs: NodePort[];
|
|
96
|
+
};
|
|
74
97
|
/**
|
|
75
98
|
* Get all available automation nodes.
|
|
76
99
|
* Converts node definitions from the registry into ComputedNode format.
|
|
@@ -354,18 +377,22 @@ export declare function updatePreviewMapForConnection({ nodes, media, accounts,
|
|
|
354
377
|
accounts: AccountData[];
|
|
355
378
|
}): PreviewMap;
|
|
356
379
|
/**
|
|
357
|
-
* Re-generate preview
|
|
380
|
+
* Re-generate preview values for a source node and update all connections from it.
|
|
358
381
|
* Used for "shuffle" functionality in the editor.
|
|
359
382
|
*
|
|
360
|
-
* @param
|
|
383
|
+
* @param nodes - All workflow nodes
|
|
384
|
+
* @param sourceNodeId - The node to shuffle (typically a source node with a pool)
|
|
361
385
|
* @param shuffleCount - The shuffle index (0 = first pick, 1 = second pick, etc.)
|
|
362
386
|
* @param media - Media library for source nodes
|
|
363
387
|
* @param accounts - Account list for account nodes
|
|
364
|
-
* @
|
|
388
|
+
* @param currentPreviewMap - The current preview map to update
|
|
389
|
+
* @returns Updated preview map with new values for all connections from the source node
|
|
365
390
|
*/
|
|
366
|
-
export declare function shuffleNodePreview({
|
|
367
|
-
|
|
391
|
+
export declare function shuffleNodePreview({ nodes, sourceNodeId, shuffleCount, media, accounts, currentPreviewMap, }: {
|
|
392
|
+
nodes: WorkflowNodeDefinition[];
|
|
393
|
+
sourceNodeId: string;
|
|
368
394
|
shuffleCount: number;
|
|
369
395
|
media: Media[];
|
|
370
396
|
accounts: AccountData[];
|
|
371
|
-
|
|
397
|
+
currentPreviewMap: PreviewMap;
|
|
398
|
+
}): PreviewMap;
|
package/dist/graph-controller.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.areTypesCompatible = areTypesCompatible;
|
|
16
16
|
exports.computePortsForNode = computePortsForNode;
|
|
17
|
+
exports.computePortsWithPreviews = computePortsWithPreviews;
|
|
17
18
|
exports.getAllNodes = getAllNodes;
|
|
18
19
|
exports.getNodeByType = getNodeByType;
|
|
19
20
|
exports.getOutputSchema = getOutputSchema;
|
|
@@ -268,6 +269,26 @@ function computePortsForNode({ node, getConnectedOutput, }) {
|
|
|
268
269
|
}
|
|
269
270
|
return definition.computePortsFromNode(node, getConnectedOutput);
|
|
270
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Compute ports for a node with preview values attached to input ports.
|
|
274
|
+
* Combines port computation with preview lookup for a single source of truth.
|
|
275
|
+
*
|
|
276
|
+
* Each input port will have a `previewValue` property containing the resolved
|
|
277
|
+
* preview value from its connected source node (or null if no connection).
|
|
278
|
+
*
|
|
279
|
+
* @param node - The workflow node definition
|
|
280
|
+
* @param previewMap - The computed preview map (from computePreviewMap)
|
|
281
|
+
* @param getConnectedOutput - Optional function to get connected output port info
|
|
282
|
+
*/
|
|
283
|
+
function computePortsWithPreviews({ node, previewMap, getConnectedOutput, }) {
|
|
284
|
+
const { inputs, outputs } = computePortsForNode({ node, getConnectedOutput });
|
|
285
|
+
// Augment each input port with its preview value
|
|
286
|
+
const inputsWithPreviews = inputs.map(port => ({
|
|
287
|
+
...port,
|
|
288
|
+
previewValue: previewMap[`${node.id}:${port.id}`] ?? null,
|
|
289
|
+
}));
|
|
290
|
+
return { inputs: inputsWithPreviews, outputs };
|
|
291
|
+
}
|
|
271
292
|
/**
|
|
272
293
|
* Get all available automation nodes.
|
|
273
294
|
* Converts node definitions from the registry into ComputedNode format.
|
|
@@ -981,19 +1002,24 @@ function updatePreviewMapForConnection({ nodes, media, accounts, }) {
|
|
|
981
1002
|
return computePreviewMap({ nodes, media, accounts });
|
|
982
1003
|
}
|
|
983
1004
|
/**
|
|
984
|
-
* Re-generate preview
|
|
1005
|
+
* Re-generate preview values for a source node and update all connections from it.
|
|
985
1006
|
* Used for "shuffle" functionality in the editor.
|
|
986
1007
|
*
|
|
987
|
-
* @param
|
|
1008
|
+
* @param nodes - All workflow nodes
|
|
1009
|
+
* @param sourceNodeId - The node to shuffle (typically a source node with a pool)
|
|
988
1010
|
* @param shuffleCount - The shuffle index (0 = first pick, 1 = second pick, etc.)
|
|
989
1011
|
* @param media - Media library for source nodes
|
|
990
1012
|
* @param accounts - Account list for account nodes
|
|
991
|
-
* @
|
|
1013
|
+
* @param currentPreviewMap - The current preview map to update
|
|
1014
|
+
* @returns Updated preview map with new values for all connections from the source node
|
|
992
1015
|
*/
|
|
993
|
-
function shuffleNodePreview({
|
|
994
|
-
const
|
|
1016
|
+
function shuffleNodePreview({ nodes, sourceNodeId, shuffleCount, media, accounts, currentPreviewMap, }) {
|
|
1017
|
+
const sourceNode = nodes.find(n => n.id === sourceNodeId);
|
|
1018
|
+
if (!sourceNode)
|
|
1019
|
+
return currentPreviewMap;
|
|
1020
|
+
const definition = nodes_1.nodeDefinitions[sourceNode.type];
|
|
995
1021
|
if (!definition)
|
|
996
|
-
return
|
|
1022
|
+
return currentPreviewMap;
|
|
997
1023
|
// Build context with shuffleCount as consumedCount
|
|
998
1024
|
const ctx = {
|
|
999
1025
|
inputPreviews: {},
|
|
@@ -1001,8 +1027,18 @@ function shuffleNodePreview({ node, shuffleCount, media, accounts, }) {
|
|
|
1001
1027
|
accounts,
|
|
1002
1028
|
selectionState: { consumedCount: shuffleCount },
|
|
1003
1029
|
};
|
|
1004
|
-
//
|
|
1005
|
-
const
|
|
1006
|
-
|
|
1007
|
-
|
|
1030
|
+
// Generate new outputs for this node
|
|
1031
|
+
const newOutputs = definition.generatePreviewFromNode(sourceNode, ctx, sourceNode.preview_outputs ?? null);
|
|
1032
|
+
if (!newOutputs)
|
|
1033
|
+
return currentPreviewMap;
|
|
1034
|
+
// Find all connections from this source and update their preview values
|
|
1035
|
+
const connections = deriveConnectionsInternal(nodes);
|
|
1036
|
+
const newMap = { ...currentPreviewMap };
|
|
1037
|
+
for (const conn of connections) {
|
|
1038
|
+
if (conn.sourceNodeId === sourceNodeId) {
|
|
1039
|
+
const key = `${conn.targetNodeId}:${conn.targetInputId}`;
|
|
1040
|
+
newMap[key] = newOutputs[conn.sourceOutputId] ?? null;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
return newMap;
|
|
1008
1044
|
}
|
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, computeAllNodePreviews, computePreviewMap, updatePreviewMapForConnection, removePreviewForConnection, getPreviewValue, shuffleNodePreview, type PreviewMap, type NodePreviewOutputs, type Connection, generateNodeName, extractWorkflowConfig, type WorkflowTemplateData, } from './graph-controller';
|
|
16
|
+
export { areTypesCompatible, computePortsForNode, computePortsWithPreviews, getAllNodes, getNodeByType, getOutputSchema, createNode, deriveConnections, addConnection, removeConnection, removeNodeConnections, cleanupStaleConnections, getForEachContext, checkCrossContextViolation, validateWorkflow, getErrorNodeIds, getPortErrorsForNode, hasMissingTriggerError, hasMissingTerminalError, getWorkflowOutputSchema, type WorkflowOutputSchemaEntry, resolveNodePreview, computeAllNodePreviews, computePreviewMap, updatePreviewMapForConnection, removePreviewForConnection, getPreviewValue, shuffleNodePreview, type PreviewMap, type NodePreviewOutputs, type Connection, generateNodeName, extractWorkflowConfig, type WorkflowTemplateData, } from './graph-controller';
|
|
17
17
|
export { nodeDefinitions, internalNodeTypes, isAsyncExecutor, formatPortType } from './automations/types';
|
|
18
18
|
export { getNodeDefinition } from './automations/nodes';
|
|
19
19
|
export { isEditModel, ALL_IMAGE_MODELS, IMAGE_ASPECT_RATIOS } from './automations/nodes/generate-image';
|
|
@@ -68,7 +68,7 @@ export type { TranscriptNodeConfig } from './automations/nodes/transcript';
|
|
|
68
68
|
export type { VideoComposerNodeConfig, VideoComposerRenderInput } from './automations/nodes/video-composer';
|
|
69
69
|
export { prepareVideoComposerInput } from './automations/nodes/video-composer';
|
|
70
70
|
export type { VideoImportNodeConfig, VideoImportPlatform, VideoImportQuality, } from './automations/nodes/video-import';
|
|
71
|
-
export type { MediaType, BasePortType, EnumOption, ImageValue, VideoValue, AudioValue, TextValue, NumberValue, BooleanValue, DateValue, EnumValue, SocialAudioValue, ObjectValue, PortValueFor, PortValue, NodeOutputValues, NodePort, ResolvedPort, ResolvedPorts, ComputedNode, OutputSchemaProperty, WorkflowNodeDefinition, CanvasState, WorkflowDefinition, TemplateNode, AutomationTemplate, AutomationRun, ExecutorNode, ExecutionEdge, AccountData, FlowControlOutput, ExecutorContext, NodeExecutor, AsyncNodeExecutor, AnyNodeExecutor, AnyAsyncNodeExecutor, ExecutorAsyncJobStatus, ValidationErrorType, ValidationError, ExportedNode, ExportedConnection, ExportedTemplate, AutomationExport, ExportedExecutor, ExportedEdge, ExportedRun, AutomationRunExport, InternalWorkflowConfig, AllWorkflowConfig, } from './automations/types';
|
|
71
|
+
export type { MediaType, BasePortType, EnumOption, ImageValue, VideoValue, AudioValue, TextValue, NumberValue, BooleanValue, DateValue, EnumValue, SocialAudioValue, ObjectValue, PortValueFor, PortValue, NodeOutputValues, NodePort, NodePortWithPreview, ResolvedPort, ResolvedPorts, ComputedNode, OutputSchemaProperty, WorkflowNodeDefinition, CanvasState, WorkflowDefinition, TemplateNode, AutomationTemplate, AutomationRun, ExecutorNode, ExecutionEdge, AccountData, FlowControlOutput, ExecutorContext, NodeExecutor, AsyncNodeExecutor, AnyNodeExecutor, AnyAsyncNodeExecutor, ExecutorAsyncJobStatus, ValidationErrorType, ValidationError, ExportedNode, ExportedConnection, ExportedTemplate, AutomationExport, ExportedExecutor, ExportedEdge, ExportedRun, AutomationRunExport, InternalWorkflowConfig, AllWorkflowConfig, } from './automations/types';
|
|
72
72
|
export type { NodeDefinition, NodeType, UserCreatableNodeType, NodeConfig, WorkflowConfig, InternalNodeType, } from './automations/nodes';
|
|
73
73
|
export type { SelectionMode, ExhaustionBehavior, SelectionConfig, SelectionState, OutputMode, NodeCategory, TriggerIterationMode, IterationExhaustionBehavior, CollectionSelectionMode, TriggerCollectionConfig, ObjectSchemaField, MediaItemType, MediaNodeSelectionType, ResolvedPreview, PreviewSelectionState, PreviewContext, NullableOutputs, } from './automations/nodes/types';
|
|
74
74
|
export type { SuccessResponse, ErrorResponse, ApiResponse, } from './types';
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Official TypeScript/JavaScript client for the UGC Inc API
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
9
|
-
exports.prepareVideoComposerInput = exports.LLMProviders = exports.IfLogicOperators = exports.indexExpressionToIndexes = exports.prepareImageComposerInput = exports.extractTemplateVariables = exports.PortIdSchema = exports.normalizeToPortId = exports.portIdToTitle = exports.isValidPortId = exports.portId = exports.selectFromPool = void 0;
|
|
8
|
+
exports.getModelAspectRatios = exports.ALL_VIDEO_MODELS = exports.isImageToVideoModel = exports.IMAGE_ASPECT_RATIOS = exports.ALL_IMAGE_MODELS = exports.isEditModel = exports.getNodeDefinition = exports.formatPortType = exports.isAsyncExecutor = exports.internalNodeTypes = exports.nodeDefinitions = exports.extractWorkflowConfig = exports.generateNodeName = exports.shuffleNodePreview = exports.getPreviewValue = exports.removePreviewForConnection = exports.updatePreviewMapForConnection = exports.computePreviewMap = exports.computeAllNodePreviews = 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.computePortsWithPreviews = 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
|
+
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.getModelDurations = void 0;
|
|
10
10
|
// =============================================================================
|
|
11
11
|
// Client Exports
|
|
12
12
|
// =============================================================================
|
|
@@ -38,6 +38,7 @@ var graph_controller_1 = require("./graph-controller");
|
|
|
38
38
|
Object.defineProperty(exports, "areTypesCompatible", { enumerable: true, get: function () { return graph_controller_1.areTypesCompatible; } });
|
|
39
39
|
// Port computation
|
|
40
40
|
Object.defineProperty(exports, "computePortsForNode", { enumerable: true, get: function () { return graph_controller_1.computePortsForNode; } });
|
|
41
|
+
Object.defineProperty(exports, "computePortsWithPreviews", { enumerable: true, get: function () { return graph_controller_1.computePortsWithPreviews; } });
|
|
41
42
|
Object.defineProperty(exports, "getAllNodes", { enumerable: true, get: function () { return graph_controller_1.getAllNodes; } });
|
|
42
43
|
Object.defineProperty(exports, "getNodeByType", { enumerable: true, get: function () { return graph_controller_1.getNodeByType; } });
|
|
43
44
|
// Output schema
|