ugcinc 3.17.0 → 3.19.0

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,4 +1,4 @@
1
- import type { NodeControlConfig, NodeCategory, MediaType, NodePort, NodeTypeEnum, WorkflowDefinition, AutomationTemplate, AutomationRun, ExecutorNode, ExecutionEdge, ApiResponse, AutomationExport, AutomationRunExport } from './types';
1
+ import type { NodeControlConfig, NodeCategory, MediaType, NodePort, NodeTypeEnum, WorkflowDefinition, AutomationTemplate, AutomationRun, ExecutorNode, ExecutionEdge, ApiResponse, AutomationExport, AutomationRunExport, PropertySchema } from './types';
2
2
  import { BaseClient } from './base';
3
3
  export declare class AutomationsClient extends BaseClient {
4
4
  /**
@@ -135,4 +135,14 @@ export declare function getAllNodes(): NodeControlConfig[];
135
135
  * Get a specific node by type
136
136
  */
137
137
  export declare function getNodeByType(type: string): NodeControlConfig | undefined;
138
- export type { NodeControlConfig, NodeCategory, MediaType, NodePort, NodeTypeEnum };
138
+ /**
139
+ * Get the schema of array items for a node's output port.
140
+ * Returns null if schema is unknown or the output is not an array.
141
+ *
142
+ * @param nodeType - The type of the node (e.g., 'transcript', 'text-generation')
143
+ * @param nodeConfig - The node's configuration object
144
+ * @param outputPortId - The ID of the output port to get schema for
145
+ * @returns The schema of array items, or null if unknown
146
+ */
147
+ export declare function getOutputSchema(nodeType: string, nodeConfig: Record<string, unknown> | undefined, outputPortId: string): Record<string, PropertySchema> | null;
148
+ export type { NodeControlConfig, NodeCategory, MediaType, NodePort, NodeTypeEnum, PropertySchema };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AutomationsClient = void 0;
4
4
  exports.getAllNodes = getAllNodes;
5
5
  exports.getNodeByType = getNodeByType;
6
+ exports.getOutputSchema = getOutputSchema;
6
7
  const base_1 = require("./base");
7
8
  class AutomationsClient extends base_1.BaseClient {
8
9
  /**
@@ -526,6 +527,11 @@ function getAllNodes() {
526
527
  id: "segments",
527
528
  type: "object",
528
529
  required: true,
530
+ itemSchema: {
531
+ text: { type: 'string' },
532
+ start: { type: 'number' },
533
+ end: { type: 'number' },
534
+ },
529
535
  },
530
536
  ],
531
537
  },
@@ -559,3 +565,71 @@ function getAllNodes() {
559
565
  function getNodeByType(type) {
560
566
  return getAllNodes().find(node => node.type === type);
561
567
  }
568
+ /**
569
+ * Convert LLM output field type to PropertySchema type
570
+ */
571
+ function llmTypeToSchemaType(type) {
572
+ if (type === 'string')
573
+ return 'string';
574
+ if (type === 'number')
575
+ return 'number';
576
+ if (type === 'boolean')
577
+ return 'boolean';
578
+ return 'object';
579
+ }
580
+ /**
581
+ * Convert LLM objectSchema to PropertySchema record
582
+ */
583
+ function llmObjectSchemaToPropertySchema(fields) {
584
+ const result = {};
585
+ for (const field of fields) {
586
+ if (field.type === 'array' && field.items === 'object' && field.objectSchema) {
587
+ // Nested array of objects
588
+ result[field.name] = {
589
+ type: 'object',
590
+ itemSchema: llmObjectSchemaToPropertySchema(field.objectSchema),
591
+ };
592
+ }
593
+ else if (field.type === 'array' && field.items) {
594
+ // Array of primitives
595
+ result[field.name] = {
596
+ type: 'object', // Arrays are represented as 'object' type
597
+ };
598
+ }
599
+ else {
600
+ result[field.name] = {
601
+ type: llmTypeToSchemaType(field.type),
602
+ };
603
+ }
604
+ }
605
+ return result;
606
+ }
607
+ /**
608
+ * Get the schema of array items for a node's output port.
609
+ * Returns null if schema is unknown or the output is not an array.
610
+ *
611
+ * @param nodeType - The type of the node (e.g., 'transcript', 'text-generation')
612
+ * @param nodeConfig - The node's configuration object
613
+ * @param outputPortId - The ID of the output port to get schema for
614
+ * @returns The schema of array items, or null if unknown
615
+ */
616
+ function getOutputSchema(nodeType, nodeConfig, outputPortId) {
617
+ // First check static node definitions
618
+ const nodeDefinition = getNodeByType(nodeType);
619
+ const outputPort = nodeDefinition?.outputs.find(o => o.id === outputPortId);
620
+ if (outputPort?.itemSchema) {
621
+ return outputPort.itemSchema;
622
+ }
623
+ // For text-generation (LLM) nodes, derive from outputFields config
624
+ if (nodeType === 'text-generation' && nodeConfig) {
625
+ const llmConfig = nodeConfig.llm;
626
+ const outputFields = llmConfig?.outputFields;
627
+ if (outputFields) {
628
+ const field = outputFields.find(f => f.name === outputPortId);
629
+ if (field?.type === 'array' && field.items === 'object' && field.objectSchema) {
630
+ return llmObjectSchemaToPropertySchema(field.objectSchema);
631
+ }
632
+ }
633
+ }
634
+ return null;
635
+ }
package/dist/index.d.ts CHANGED
@@ -10,7 +10,8 @@ export { PostsClient } from './posts';
10
10
  export { StatsClient } from './stats';
11
11
  export { OrganizationClient } from './org';
12
12
  export { RenderClient } from './render';
13
- export { AutomationsClient, getAllNodes, getNodeByType } from './automations';
13
+ export { AutomationsClient, getAllNodes, getNodeByType, getOutputSchema } from './automations';
14
+ export type { PropertySchema } from './automations';
14
15
  export { portId, isValidPortId, portIdToTitle, normalizeToPortId, PortIdSchema } from './port-id';
15
16
  export type { PortId } from './port-id';
16
17
  export { MediaClient } from './media';
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.CommentsClient = exports.MediaClient = exports.PortIdSchema = exports.normalizeToPortId = exports.portIdToTitle = exports.isValidPortId = exports.portId = exports.getNodeByType = exports.getAllNodes = exports.AutomationsClient = exports.RenderClient = exports.OrganizationClient = exports.StatsClient = exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
8
+ exports.CommentsClient = exports.MediaClient = exports.PortIdSchema = exports.normalizeToPortId = exports.portIdToTitle = exports.isValidPortId = exports.portId = exports.getOutputSchema = exports.getNodeByType = exports.getAllNodes = exports.AutomationsClient = exports.RenderClient = exports.OrganizationClient = exports.StatsClient = exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
9
9
  var client_1 = require("./client");
10
10
  Object.defineProperty(exports, "UGCClient", { enumerable: true, get: function () { return client_1.UGCClient; } });
11
11
  var accounts_1 = require("./accounts");
@@ -24,6 +24,7 @@ var automations_1 = require("./automations");
24
24
  Object.defineProperty(exports, "AutomationsClient", { enumerable: true, get: function () { return automations_1.AutomationsClient; } });
25
25
  Object.defineProperty(exports, "getAllNodes", { enumerable: true, get: function () { return automations_1.getAllNodes; } });
26
26
  Object.defineProperty(exports, "getNodeByType", { enumerable: true, get: function () { return automations_1.getNodeByType; } });
27
+ Object.defineProperty(exports, "getOutputSchema", { enumerable: true, get: function () { return automations_1.getOutputSchema; } });
27
28
  var port_id_1 = require("./port-id");
28
29
  Object.defineProperty(exports, "portId", { enumerable: true, get: function () { return port_id_1.portId; } });
29
30
  Object.defineProperty(exports, "isValidPortId", { enumerable: true, get: function () { return port_id_1.isValidPortId; } });
package/dist/types.d.ts CHANGED
@@ -788,10 +788,19 @@ export interface NodeOutputValues {
788
788
  _values: unknown[];
789
789
  _outputMode: OutputMode;
790
790
  }
791
+ /**
792
+ * Schema definition for a property within an array item
793
+ */
794
+ export interface PropertySchema {
795
+ type: 'string' | 'number' | 'boolean' | 'object';
796
+ itemSchema?: Record<string, PropertySchema>;
797
+ }
791
798
  export interface NodePort {
792
799
  id: string;
793
800
  type: PortType | PortType[];
794
801
  required: boolean;
802
+ /** Schema of array items (when this port outputs an array) */
803
+ itemSchema?: Record<string, PropertySchema>;
795
804
  }
796
805
  /**
797
806
  * Functional category for automation nodes
@@ -1006,35 +1015,29 @@ export interface ManualTriggerNodeConfig {
1006
1015
  export type DayOfWeek = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
1007
1016
  /**
1008
1017
  * Recurrence media output port definition
1009
- * Each output is a named port with a specific media type
1018
+ * Each output is a named port with a specific media type and its own selection config
1010
1019
  */
1011
1020
  export interface RecurrenceMediaOutput {
1012
1021
  /** Unique ID for this output port (e.g., "background-image", "overlay") */
1013
1022
  id: string;
1014
1023
  /** Media type for this port */
1015
1024
  type: 'image' | 'video' | 'audio' | 'text' | 'social_audio';
1025
+ /** Selection mode for this output's media source */
1026
+ selectionMode: 'specific' | 'by-tag';
1027
+ /** Media IDs for this output (used when selectionMode is 'specific') */
1028
+ selectedMediaIds?: string[];
1029
+ /** Tag to query media by at runtime (used when selectionMode is 'by-tag') */
1030
+ mediaTag?: string;
1016
1031
  }
1017
1032
  /**
1018
1033
  * Media input configuration for recurrence nodes
1019
- * Allows selecting media by specific IDs or by tag (queried at runtime)
1034
+ * Each output has its own selection configuration
1020
1035
  */
1021
1036
  export interface RecurrenceMediaConfig {
1022
1037
  /** Whether media input is enabled */
1023
1038
  enabled: boolean;
1024
- /** Named output ports - each gets a random item from the pool */
1039
+ /** Named output ports - each has its own selection config */
1025
1040
  outputs: RecurrenceMediaOutput[];
1026
- /** Selection mode: 'specific' uses selectedMediaIds, 'by-tag' queries at runtime */
1027
- selectionMode: CollectionSelectionMode;
1028
- /** Media IDs per type (used when selectionMode is 'specific') */
1029
- selectedMediaIds?: {
1030
- image?: string[];
1031
- video?: string[];
1032
- audio?: string[];
1033
- text?: string[];
1034
- social_audio?: string[];
1035
- };
1036
- /** Tag to query media by at runtime (used when selectionMode is 'by-tag') */
1037
- mediaTag?: string;
1038
1041
  }
1039
1042
  /**
1040
1043
  * Recurrence node configuration - defines when the automation runs on a schedule
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "3.17.0",
3
+ "version": "3.19.0",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",