ugcinc 3.18.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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "3.18.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",