ugcinc 4.1.20 → 4.1.22

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.
@@ -1,21 +1,24 @@
1
- import { type InputType } from './types';
1
+ import { type ObjectSchemaField } from './types';
2
2
  export interface BranchDefinition {
3
3
  key: string;
4
4
  }
5
5
  export interface BranchValueConfig {
6
- inputType?: InputType;
6
+ isVariable?: boolean;
7
7
  value?: unknown;
8
8
  selectedMediaIds?: string[];
9
9
  }
10
- export interface PassthroughInput {
10
+ export interface BranchPassthroughInput {
11
11
  id: string;
12
12
  type: string;
13
13
  isArray?: boolean;
14
14
  branchValues?: Record<string, BranchValueConfig>;
15
+ objectSchema?: ObjectSchemaField[];
15
16
  }
17
+ /** @deprecated Use BranchPassthroughInput instead */
18
+ export type PassthroughInput = BranchPassthroughInput;
16
19
  declare const definition: import("./types").NodeDefinition<"generator", {
17
20
  branches: BranchDefinition[];
18
- passthroughInputs: PassthroughInput[];
21
+ passthroughInputs: BranchPassthroughInput[];
19
22
  defaultBranchKey: string;
20
23
  outputMode: "per-input";
21
24
  selectionMode: null;
@@ -19,7 +19,7 @@ const definition = (0, types_1.defineNode)({
19
19
  outputMode: 'per-input',
20
20
  selectionMode: null,
21
21
  },
22
- computePorts: ({ config }) => {
22
+ computePorts: ({ config, getConnectedOutput }) => {
23
23
  const branches = config?.branches ?? [];
24
24
  const passthroughInputs = config?.passthroughInputs ?? [];
25
25
  const inputs = [];
@@ -28,18 +28,39 @@ const definition = (0, types_1.defineNode)({
28
28
  for (const passthrough of passthroughInputs) {
29
29
  const pType = passthrough.type;
30
30
  const pIsArray = passthrough.isArray ?? false;
31
+ // Track input port IDs for this passthrough to check for connected schemas
32
+ const variableInputPortIds = [];
31
33
  for (const branch of branches) {
32
34
  const branchValue = passthrough.branchValues?.[branch.key];
33
- if (branchValue?.inputType === 'variable') {
35
+ if (branchValue?.isVariable) {
36
+ const inputPortId = `${branch.key}-${passthrough.id}`;
37
+ variableInputPortIds.push(inputPortId);
34
38
  inputs.push({
35
- id: `${branch.key}-${passthrough.id}`,
39
+ id: inputPortId,
36
40
  type: pType,
37
41
  isArray: pIsArray,
38
42
  required: true,
39
43
  });
40
44
  }
41
45
  }
42
- outputs.push({ id: passthrough.id, type: pType, isArray: pIsArray, required: true });
46
+ // Get objectSchema from connected input (if any) to propagate to output
47
+ let objectSchema = passthrough.objectSchema;
48
+ if (getConnectedOutput && !objectSchema) {
49
+ for (const inputPortId of variableInputPortIds) {
50
+ const connectedOutput = getConnectedOutput(inputPortId);
51
+ if (connectedOutput?.objectSchema) {
52
+ objectSchema = connectedOutput.objectSchema;
53
+ break; // Use the first connected schema found
54
+ }
55
+ }
56
+ }
57
+ outputs.push({
58
+ id: passthrough.id,
59
+ type: pType,
60
+ isArray: pIsArray,
61
+ required: true,
62
+ objectSchema,
63
+ });
43
64
  }
44
65
  return { inputs, outputs };
45
66
  },
@@ -49,7 +49,7 @@ export declare const nodeDefinitions: {
49
49
  }, false>;
50
50
  readonly branch: NodeDefinition<"generator", {
51
51
  branches: import("./branch").BranchDefinition[];
52
- passthroughInputs: import("./branch").PassthroughInput[];
52
+ passthroughInputs: import("./branch").BranchPassthroughInput[];
53
53
  defaultBranchKey: string;
54
54
  outputMode: "per-input";
55
55
  selectionMode: null;
@@ -43,13 +43,13 @@ export declare function areTypesCompatible({ sourceType, sourceIsArray, targetTy
43
43
  * Compute ports for a node based on its type and config.
44
44
  * Uses the node definition's computePorts function.
45
45
  *
46
- * @param nodeType - The type of the node
47
- * @param config - The node's configuration object
46
+ * Accepts the full WorkflowNodeDefinition to preserve discriminated union typing.
47
+ *
48
+ * @param node - The workflow node definition
48
49
  * @param getConnectedOutput - Optional function to get connected output port info (for dynamic ports)
49
50
  */
50
- export declare function computePortsForNode({ nodeType, config, getConnectedOutput, }: {
51
- nodeType: UserCreatableNodeType;
52
- config?: Record<string, unknown>;
51
+ export declare function computePortsForNode({ node, getConnectedOutput, }: {
52
+ node: WorkflowNodeDefinition;
53
53
  getConnectedOutput?: (inputId: string) => {
54
54
  type: BasePortType | BasePortType[];
55
55
  isArray: boolean;
@@ -248,17 +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
- * @param nodeType - The type of the node
252
- * @param config - The node's configuration object
251
+ * Accepts the full WorkflowNodeDefinition to preserve discriminated union typing.
252
+ *
253
+ * @param node - The workflow node definition
253
254
  * @param getConnectedOutput - Optional function to get connected output port info (for dynamic ports)
254
255
  */
255
- function computePortsForNode({ nodeType, config, getConnectedOutput, }) {
256
- const definition = (0, nodes_1.getNodeDefinition)(nodeType);
256
+ function computePortsForNode({ node, getConnectedOutput, }) {
257
+ const definition = (0, nodes_1.getNodeDefinition)(node.type);
257
258
  if (!definition) {
258
259
  return { inputs: [], outputs: [] };
259
260
  }
260
261
  return definition.computePorts({
261
- config: config ?? definition.defaults,
262
+ config: node.config ?? definition.defaults,
262
263
  getConnectedOutput,
263
264
  });
264
265
  }
package/dist/index.d.ts CHANGED
@@ -36,7 +36,7 @@ export { prepareImageComposerInput } from './automations/nodes/image-composer';
36
36
  export type { AccountNodeConfig } from './automations/nodes/account';
37
37
  export type { AutoCaptionNodeConfig, AutoCaptionPreset, AutoCaptionFontWeight, AutoCaptionPosition, } from './automations/nodes/auto-caption';
38
38
  export type { AutoPostNodeConfig, AutoPostMode, PostSchedulingMode, } from './automations/nodes/auto-post';
39
- export type { BranchNodeConfig, BranchDefinition, PassthroughInput, } from './automations/nodes/branch';
39
+ export type { BranchNodeConfig, BranchDefinition, BranchPassthroughInput, BranchValueConfig, PassthroughInput, } from './automations/nodes/branch';
40
40
  export type { CollectNodeConfig } from './automations/nodes/collect';
41
41
  export type { ComposeWorkflowNodeConfig } from './automations/nodes/compose-workflow';
42
42
  export type { CreateDmNodeConfig, CreateDmMessage, DmPlatform, } from './automations/nodes/create-dm';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "4.1.20",
3
+ "version": "4.1.22",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",