ugcinc 4.0.2 → 4.1.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.
Files changed (154) hide show
  1. package/dist/accounts.d.ts +146 -1
  2. package/dist/automations/index.d.ts +174 -0
  3. package/dist/automations/index.js +194 -0
  4. package/dist/automations/nodes/account.d.ts +18 -0
  5. package/dist/automations/nodes/account.js +29 -0
  6. package/dist/automations/nodes/auto-caption.d.ts +64 -0
  7. package/dist/automations/nodes/auto-caption.js +46 -0
  8. package/dist/automations/nodes/auto-post.d.ts +81 -0
  9. package/dist/automations/nodes/auto-post.js +54 -0
  10. package/dist/automations/nodes/branch.d.ts +58 -0
  11. package/dist/automations/nodes/branch.js +50 -0
  12. package/dist/automations/nodes/collect.d.ts +16 -0
  13. package/dist/automations/nodes/collect.js +56 -0
  14. package/dist/automations/nodes/compose-workflow.d.ts +21 -0
  15. package/dist/automations/nodes/compose-workflow.js +42 -0
  16. package/dist/automations/nodes/create-dm.d.ts +96 -0
  17. package/dist/automations/nodes/create-dm.js +88 -0
  18. package/dist/automations/nodes/custom-model.d.ts +19 -0
  19. package/dist/automations/nodes/custom-model.js +52 -0
  20. package/dist/automations/nodes/deduplicate.d.ts +8 -0
  21. package/dist/automations/nodes/deduplicate.js +36 -0
  22. package/dist/automations/nodes/destructure.d.ts +25 -0
  23. package/dist/automations/nodes/destructure.js +65 -0
  24. package/dist/automations/nodes/for-each.d.ts +23 -0
  25. package/dist/automations/nodes/for-each.js +84 -0
  26. package/dist/automations/nodes/generate-image.d.ts +16 -0
  27. package/dist/automations/nodes/generate-image.js +45 -0
  28. package/dist/automations/nodes/generate-video.d.ts +16 -0
  29. package/dist/automations/nodes/generate-video.js +45 -0
  30. package/dist/automations/nodes/if.d.ts +22 -0
  31. package/dist/automations/nodes/if.js +44 -0
  32. package/dist/automations/nodes/image-composer.d.ts +33 -0
  33. package/dist/automations/nodes/image-composer.js +95 -0
  34. package/dist/automations/nodes/index.d.ts +20 -0
  35. package/dist/automations/nodes/index.js +93 -0
  36. package/dist/automations/nodes/llm.d.ts +27 -0
  37. package/dist/automations/nodes/llm.js +85 -0
  38. package/dist/automations/nodes/manual-trigger.d.ts +34 -0
  39. package/dist/automations/nodes/manual-trigger.js +32 -0
  40. package/dist/automations/nodes/media.d.ts +17 -0
  41. package/dist/automations/nodes/media.js +40 -0
  42. package/dist/automations/nodes/not.d.ts +6 -0
  43. package/dist/automations/nodes/not.js +35 -0
  44. package/dist/automations/nodes/output.d.ts +30 -0
  45. package/dist/automations/nodes/output.js +32 -0
  46. package/dist/automations/nodes/random-route.d.ts +52 -0
  47. package/dist/automations/nodes/random-route.js +53 -0
  48. package/dist/automations/nodes/random.d.ts +16 -0
  49. package/dist/automations/nodes/random.js +50 -0
  50. package/dist/automations/nodes/recurrence.d.ts +69 -0
  51. package/dist/automations/nodes/recurrence.js +50 -0
  52. package/dist/automations/nodes/save-to-media.d.ts +32 -0
  53. package/dist/automations/nodes/save-to-media.js +31 -0
  54. package/dist/automations/nodes/screenshot-animation.d.ts +7 -0
  55. package/dist/automations/nodes/screenshot-animation.js +36 -0
  56. package/dist/automations/nodes/social-audio.d.ts +8 -0
  57. package/dist/automations/nodes/social-audio.js +30 -0
  58. package/dist/automations/nodes/text.d.ts +7 -0
  59. package/dist/automations/nodes/text.js +41 -0
  60. package/dist/automations/nodes/transcript.d.ts +6 -0
  61. package/dist/automations/nodes/transcript.js +46 -0
  62. package/dist/automations/nodes/types.d.ts +178 -0
  63. package/dist/automations/nodes/types.js +22 -0
  64. package/dist/automations/nodes/video-composer.d.ts +25 -0
  65. package/dist/automations/nodes/video-composer.js +71 -0
  66. package/dist/automations/nodes/video-import.d.ts +27 -0
  67. package/dist/automations/nodes/video-import.js +37 -0
  68. package/dist/automations/types.d.ts +544 -0
  69. package/dist/automations/types.js +101 -0
  70. package/dist/automations.d.ts +5 -33
  71. package/dist/automations.js +6 -647
  72. package/dist/comments.d.ts +26 -1
  73. package/dist/comments.js +3 -0
  74. package/dist/graph-controller.d.ts +194 -0
  75. package/dist/graph-controller.js +623 -0
  76. package/dist/index.d.ts +38 -9
  77. package/dist/index.js +43 -23
  78. package/dist/internal-utils.d.ts +8 -0
  79. package/dist/internal-utils.js +22 -0
  80. package/dist/media.d.ts +135 -1
  81. package/dist/nodes/account.d.ts +7 -0
  82. package/dist/nodes/account.js +29 -0
  83. package/dist/nodes/auto-caption.d.ts +17 -0
  84. package/dist/nodes/auto-caption.js +46 -0
  85. package/dist/nodes/auto-post.d.ts +21 -0
  86. package/dist/nodes/auto-post.js +54 -0
  87. package/dist/nodes/branch.d.ts +12 -0
  88. package/dist/nodes/branch.js +50 -0
  89. package/dist/nodes/collect.d.ts +6 -0
  90. package/dist/nodes/collect.js +56 -0
  91. package/dist/nodes/compose-workflow.d.ts +21 -0
  92. package/dist/nodes/compose-workflow.js +42 -0
  93. package/dist/nodes/create-dm.d.ts +40 -0
  94. package/dist/nodes/create-dm.js +88 -0
  95. package/dist/nodes/custom-model.d.ts +19 -0
  96. package/dist/nodes/custom-model.js +52 -0
  97. package/dist/nodes/deduplicate.d.ts +8 -0
  98. package/dist/nodes/deduplicate.js +36 -0
  99. package/dist/nodes/destructure.d.ts +25 -0
  100. package/dist/nodes/destructure.js +65 -0
  101. package/dist/nodes/for-each.d.ts +23 -0
  102. package/dist/nodes/for-each.js +84 -0
  103. package/dist/nodes/generate-image.d.ts +16 -0
  104. package/dist/nodes/generate-image.js +45 -0
  105. package/dist/nodes/generate-video.d.ts +16 -0
  106. package/dist/nodes/generate-video.js +45 -0
  107. package/dist/nodes/if.d.ts +22 -0
  108. package/dist/nodes/if.js +44 -0
  109. package/dist/nodes/image-composer.d.ts +14 -0
  110. package/dist/nodes/image-composer.js +95 -0
  111. package/dist/nodes/index.d.ts +20 -0
  112. package/dist/nodes/index.js +93 -0
  113. package/dist/nodes/llm.d.ts +27 -0
  114. package/dist/nodes/llm.js +85 -0
  115. package/dist/nodes/manual-trigger.d.ts +16 -0
  116. package/dist/nodes/manual-trigger.js +32 -0
  117. package/dist/nodes/media.d.ts +17 -0
  118. package/dist/nodes/media.js +40 -0
  119. package/dist/nodes/not.d.ts +6 -0
  120. package/dist/nodes/not.js +35 -0
  121. package/dist/nodes/output.d.ts +9 -0
  122. package/dist/nodes/output.js +32 -0
  123. package/dist/nodes/random-route.d.ts +3 -0
  124. package/dist/nodes/random-route.js +50 -0
  125. package/dist/nodes/random.d.ts +3 -0
  126. package/dist/nodes/random.js +48 -0
  127. package/dist/nodes/recurrence.d.ts +3 -0
  128. package/dist/nodes/recurrence.js +45 -0
  129. package/dist/nodes/save-to-media.d.ts +3 -0
  130. package/dist/nodes/save-to-media.js +26 -0
  131. package/dist/nodes/screenshot-animation.d.ts +7 -0
  132. package/dist/nodes/screenshot-animation.js +36 -0
  133. package/dist/nodes/social-audio.d.ts +3 -0
  134. package/dist/nodes/social-audio.js +26 -0
  135. package/dist/nodes/text.d.ts +3 -0
  136. package/dist/nodes/text.js +38 -0
  137. package/dist/nodes/transcript.d.ts +3 -0
  138. package/dist/nodes/transcript.js +42 -0
  139. package/dist/nodes/types.d.ts +146 -0
  140. package/dist/nodes/types.js +22 -0
  141. package/dist/nodes/video-composer.d.ts +3 -0
  142. package/dist/nodes/video-composer.js +67 -0
  143. package/dist/nodes/video-import.d.ts +3 -0
  144. package/dist/nodes/video-import.js +35 -0
  145. package/dist/org.d.ts +13 -1
  146. package/dist/ports.js +3 -9
  147. package/dist/posts.d.ts +88 -1
  148. package/dist/render/compositions/IMessageDmComposition/types.d.ts +20 -20
  149. package/dist/render/types/video.d.ts +2 -2
  150. package/dist/stats.d.ts +128 -1
  151. package/dist/tasks.d.ts +20 -1
  152. package/dist/types.d.ts +1 -2216
  153. package/dist/types.js +2 -124
  154. package/package.json +1 -1
@@ -0,0 +1,544 @@
1
+ /**
2
+ * Automation Types
3
+ *
4
+ * Core types for the automation system including ports, selection, and output modes.
5
+ */
6
+ import type { ObjectSchemaField } from './nodes/types';
7
+ import type { VideoEditorNodeConfig, ImageEditorNodeConfig } from '../render/types';
8
+ import type { ManualTriggerNodeConfig } from './nodes/manual-trigger';
9
+ import type { RecurrenceNodeConfig } from './nodes/recurrence';
10
+ import type { OutputNodeConfig } from './nodes/output';
11
+ import type { AccountNodeConfig } from './nodes/account';
12
+ import type { AutoPostNodeConfig } from './nodes/auto-post';
13
+ import type { SaveToMediaNodeConfig } from './nodes/save-to-media';
14
+ import type { VideoImportNodeConfig } from './nodes/video-import';
15
+ import type { RandomRouteNodeConfig } from './nodes/random-route';
16
+ import type { BranchNodeConfig } from './nodes/branch';
17
+ import type { AutoCaptionNodeConfig } from './nodes/auto-caption';
18
+ import type { ScreenshotAnimationConfig } from './nodes/screenshot-animation';
19
+ import type { CreateDmNodeConfig } from './nodes/create-dm';
20
+ import type { CollectNodeConfig } from './nodes/collect';
21
+ /**
22
+ * Media type for automation nodes
23
+ */
24
+ export type MediaType = 'video' | 'image' | 'audio' | 'text';
25
+ /**
26
+ * Base port type - all possible value types without array modifier
27
+ */
28
+ export type BasePortType = 'image' | 'video' | 'audio' | 'text' | 'number' | 'boolean' | 'object' | 'account' | 'date' | 'social_audio' | 'enum';
29
+ /**
30
+ * Option for enum port types
31
+ */
32
+ export interface EnumOption {
33
+ label: string;
34
+ value: string;
35
+ }
36
+ /**
37
+ * Format a port type for display (e.g., 'image' with isArray=true -> 'image[]')
38
+ */
39
+ export declare function formatPortType(type: BasePortType | BasePortType[], isArray: boolean): string;
40
+ /**
41
+ * Selection order configuration for media nodes
42
+ */
43
+ export type SelectionMode = 'random' | 'sequential';
44
+ export type ExhaustionBehavior = 'restart' | 'error';
45
+ export interface SelectionConfig {
46
+ mode?: SelectionMode;
47
+ enforceUniqueness?: boolean;
48
+ exhaustionBehavior?: ExhaustionBehavior;
49
+ }
50
+ export interface SelectionState {
51
+ usedIndices: number[];
52
+ currentIndex: number;
53
+ }
54
+ /**
55
+ * Output mode for source nodes (image, video, audio, text)
56
+ * - 'per-input': Generate a unique value for each consumer input (default)
57
+ * - 'single': Use the same value for all consumer inputs
58
+ */
59
+ export type OutputMode = 'per-input' | 'single';
60
+ /**
61
+ * Standard node output format.
62
+ * All nodes output their values in the _values array.
63
+ * - For per-input mode: _values contains N values (one per consumer)
64
+ * - For single mode: _values contains 1 value
65
+ *
66
+ * Downstream nodes always read from _values using resolveValueAtIteration().
67
+ */
68
+ export interface NodeOutputValues {
69
+ _values: unknown[];
70
+ _outputMode: OutputMode;
71
+ }
72
+ export interface NodePort {
73
+ id: string;
74
+ type: BasePortType | BasePortType[];
75
+ isArray: boolean;
76
+ required: boolean;
77
+ /** Schema of object properties (when this port outputs an object) */
78
+ objectSchema?: ObjectSchemaField[];
79
+ /** Options for enum port types */
80
+ enumOptions?: EnumOption[];
81
+ }
82
+ /**
83
+ * Port definition for resolved/dynamic ports.
84
+ * Stored in node config when the automation is saved.
85
+ */
86
+ export interface ResolvedPort {
87
+ id: string;
88
+ type: BasePortType | BasePortType[];
89
+ isArray: boolean;
90
+ required: boolean;
91
+ /** Schema of object properties (when this port outputs an object) */
92
+ objectSchema?: ObjectSchemaField[];
93
+ }
94
+ /**
95
+ * Resolved ports for nodes with dynamic inputs/outputs.
96
+ * Stored in node config when the automation is saved, allowing validation
97
+ * without needing to resolve ports at validation time.
98
+ * Note: Uses simplified ResolvedPort type for database compatibility.
99
+ */
100
+ export interface ResolvedPorts {
101
+ inputs: ResolvedPort[];
102
+ outputs: ResolvedPort[];
103
+ }
104
+ /**
105
+ * Node types array for runtime use
106
+ */
107
+ export declare const NodeTypes: readonly ["social-audio", "text", "media", "video-import", "image-composer", "video-composer", "generate-image", "generate-video", "custom-model", "llm", "passthrough", "manual-trigger", "recurrence", "compose-workflow", "account", "auto-post", "save-to-media", "deduplicate", "for-each", "for-each-value", "transcript", "auto-caption", "screenshot-animation", "random", "random-route", "branch", "if", "not", "create-dm", "collect", "destructure"];
108
+ /**
109
+ * Node type enum derived from NodeTypes const array
110
+ * This is the canonical type - use this instead of the string union NodeTypeEnum
111
+ */
112
+ export type NodeType = typeof NodeTypes[number];
113
+ /**
114
+ * User-creatable node types (excludes internal executor types like 'for-each-value')
115
+ * These are the nodes that appear in the node picker and have definitions.
116
+ */
117
+ export declare const UserCreatableNodeTypes: readonly ["social-audio", "text", "media", "video-import", "image-composer", "video-composer", "generate-image", "generate-video", "custom-model", "llm", "passthrough", "manual-trigger", "recurrence", "compose-workflow", "account", "auto-post", "save-to-media", "deduplicate", "for-each", "transcript", "auto-caption", "screenshot-animation", "random", "random-route", "branch", "if", "not", "create-dm", "collect", "destructure"];
118
+ /**
119
+ * Type for user-creatable nodes only
120
+ */
121
+ export type UserCreatableNodeType = typeof UserCreatableNodeTypes[number];
122
+ /**
123
+ * @deprecated Use NodeType instead - this is a duplicate string union
124
+ */
125
+ export type NodeTypeEnum = 'social-audio' | 'text' | 'media' | 'video-import' | 'image-composer' | 'video-composer' | 'generate-image' | 'generate-video' | 'custom-model' | 'llm' | 'passthrough' | 'manual-trigger' | 'recurrence' | 'compose-workflow' | 'account' | 'auto-post' | 'save-to-media' | 'deduplicate' | 'for-each' | 'for-each-value' | 'random' | 'random-route' | 'branch' | 'if' | 'not' | 'transcript' | 'auto-caption' | 'screenshot-animation' | 'create-dm' | 'collect' | 'destructure';
126
+ /**
127
+ * Functional category for automation nodes
128
+ * - trigger: Nodes that start an automation (manual-trigger, recurrence)
129
+ * - source: Nodes that provide input data (image, video, audio, social-audio, text, account)
130
+ * - generator: Nodes that transform or generate content (image-composer, video-composer, generate-image, llm, compose-workflow)
131
+ * - terminal: Nodes that end an automation (output, auto-post, save-to-media)
132
+ */
133
+ export type NodeCategory = 'trigger' | 'source' | 'generator' | 'terminal';
134
+ export interface NodeControlConfig {
135
+ /** Node type identifier (e.g., 'collect', 'for-each', 'llm') */
136
+ nodeId: string;
137
+ /** Display label for the node */
138
+ label: string;
139
+ /** Description shown in add node modal */
140
+ description: string;
141
+ /** UI display category for grouping in add node modal */
142
+ category: string;
143
+ /** Functional type for node behavior classification */
144
+ type: NodeCategory;
145
+ inputs: NodePort[];
146
+ outputs: NodePort[];
147
+ /** Available output modes, or null if not applicable */
148
+ outputModes: OutputMode[] | null;
149
+ /** Available selection modes, or null if not applicable */
150
+ selectionModes: SelectionMode[] | null;
151
+ /** Default config values for this node */
152
+ defaults: Record<string, unknown>;
153
+ }
154
+ /**
155
+ * Node definition for the centralized graph controller.
156
+ * Each node type defines its default config and port computation logic.
157
+ */
158
+ export interface NodeDefinition {
159
+ /** Node type identifier - must match UserCreatableNodeType (e.g., 'collect', 'for-each', 'llm') */
160
+ nodeId: UserCreatableNodeType;
161
+ /** Display label for the node */
162
+ label: string;
163
+ /** Description shown in add node modal */
164
+ description: string;
165
+ /** Functional type for node behavior classification */
166
+ type: NodeCategory;
167
+ /** UI display category for grouping in add node modal */
168
+ category: string;
169
+ /**
170
+ * If true, this node supports generating multiple unique outputs per run
171
+ * when outputMode is 'per-input'. Used for source nodes like media, text.
172
+ */
173
+ supportsPerInputMode?: boolean;
174
+ /**
175
+ * Returns the default configuration when a node of this type is created.
176
+ * Should return a valid config that produces valid ports.
177
+ */
178
+ getDefaultConfig: () => Record<string, unknown>;
179
+ /**
180
+ * Computes the input and output ports for this node based on its config.
181
+ *
182
+ * @param config - The node's current configuration
183
+ * @param getConnectedOutput - Optional callback to get the output port of a connected source node.
184
+ * Used for objectSchema propagation through passthrough nodes.
185
+ * @returns The computed input and output ports
186
+ */
187
+ computePorts: (params: {
188
+ config: Record<string, unknown>;
189
+ getConnectedOutput?: (inputId: string) => {
190
+ type: BasePortType | BasePortType[];
191
+ isArray: boolean;
192
+ objectSchema?: ObjectSchemaField[];
193
+ } | null;
194
+ }) => {
195
+ inputs: NodePort[];
196
+ outputs: NodePort[];
197
+ };
198
+ }
199
+ export interface OutputSchemaProperty {
200
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object';
201
+ items?: 'string' | 'number' | 'boolean';
202
+ properties?: Record<string, OutputSchemaProperty>;
203
+ }
204
+ export interface WorkflowNodeDefinition {
205
+ id: string;
206
+ type: NodeTypeEnum;
207
+ name?: string;
208
+ x?: number;
209
+ y?: number;
210
+ inputs: Record<string, {
211
+ sourceNodeId: string;
212
+ sourceOutputId: string;
213
+ }>;
214
+ config?: {
215
+ urls?: string[];
216
+ selectionConfig?: SelectionConfig;
217
+ selectionState?: SelectionState;
218
+ outputMode?: OutputMode;
219
+ outputs?: Array<{
220
+ id: string;
221
+ type: string;
222
+ isArray: boolean;
223
+ selectedMediaIds: string[];
224
+ }>;
225
+ textOptions?: string[];
226
+ videoEditor?: VideoEditorNodeConfig;
227
+ imageEditor?: ImageEditorNodeConfig;
228
+ outputSchema?: Record<string, OutputSchemaProperty>;
229
+ provider?: 'groq' | 'openai' | 'claude' | 'gemini';
230
+ model?: string;
231
+ temperature?: number;
232
+ maxTokens?: number;
233
+ useWebSearch?: boolean;
234
+ useStructuredOutput?: boolean;
235
+ manualTriggerConfig?: ManualTriggerNodeConfig;
236
+ recurrenceConfig?: RecurrenceNodeConfig;
237
+ workflowTemplateId?: string;
238
+ workflowVariableNameToIdMap?: Record<string, string>;
239
+ /** Resolved ports from the sub-workflow template (for validation) */
240
+ resolvedPorts?: ResolvedPorts;
241
+ outputConfig?: OutputNodeConfig;
242
+ accountConfig?: AccountNodeConfig;
243
+ autoPostConfig?: AutoPostNodeConfig;
244
+ saveToMediaConfig?: SaveToMediaNodeConfig;
245
+ videoImportConfig?: VideoImportNodeConfig;
246
+ randomRouteConfig?: RandomRouteNodeConfig;
247
+ branchConfig?: BranchNodeConfig;
248
+ autoCaptionConfig?: AutoCaptionNodeConfig;
249
+ screenshotAnimationConfig?: ScreenshotAnimationConfig;
250
+ createDmConfig?: CreateDmNodeConfig;
251
+ collectConfig?: CollectNodeConfig;
252
+ };
253
+ }
254
+ export interface CanvasState {
255
+ zoom: number;
256
+ panX: number;
257
+ panY: number;
258
+ }
259
+ export interface WorkflowDefinition {
260
+ nodes: WorkflowNodeDefinition[];
261
+ canvasState?: CanvasState;
262
+ }
263
+ /**
264
+ * Template node as stored in the database
265
+ */
266
+ export interface TemplateNode {
267
+ id: string;
268
+ template_id: string;
269
+ node_id: string;
270
+ type: NodeTypeEnum;
271
+ name: string | null;
272
+ x: number;
273
+ y: number;
274
+ inputs: Record<string, {
275
+ sourceNodeId: string;
276
+ sourceOutputId: string;
277
+ }>;
278
+ config: WorkflowNodeDefinition['config'] | null;
279
+ cached_output: Record<string, unknown> | null;
280
+ cached_at: string | null;
281
+ cached_run_id: string | null;
282
+ cached_variable_inputs: Record<string, string> | null;
283
+ preview_outputs: Record<string, string> | null;
284
+ created_at: string;
285
+ updated_at: string;
286
+ }
287
+ export interface AutomationTemplate {
288
+ id: string;
289
+ org_id: string;
290
+ name: string;
291
+ description: string | null;
292
+ canvas_state: CanvasState | null;
293
+ nodes: TemplateNode[];
294
+ preview_output: string | null;
295
+ output_schema: Record<string, {
296
+ type: string;
297
+ }> | null;
298
+ recurrence_enabled: boolean;
299
+ next_run_at: string | null;
300
+ last_run_at: string | null;
301
+ created_at: string;
302
+ updated_at: string;
303
+ }
304
+ export interface AutomationRun {
305
+ id: string;
306
+ template_id: string;
307
+ org_id: string;
308
+ tag: string | null;
309
+ status: 'pending' | 'running' | 'completed' | 'failed';
310
+ variable_inputs: Record<string, string> | null;
311
+ save_as_preview: boolean | null;
312
+ create_post: boolean | null;
313
+ require_review: boolean | null;
314
+ review_status: 'pending_review' | 'approved' | 'rejected' | null;
315
+ created_at: string;
316
+ completed_at: string | null;
317
+ }
318
+ /**
319
+ * Executor node from the edge-based execution model.
320
+ * Each executor represents one instance of a template node during execution.
321
+ */
322
+ export interface ExecutorNode {
323
+ id: string;
324
+ template_node_id: string;
325
+ executor_index: number;
326
+ type: NodeTypeEnum;
327
+ status: 'pending' | 'running' | 'completed' | 'failed';
328
+ output_value: unknown | null;
329
+ error_message: string | null;
330
+ created_at: string;
331
+ completed_at: string | null;
332
+ }
333
+ /**
334
+ * Execution edge from the edge-based execution model.
335
+ * Represents a data flow connection between two executors.
336
+ */
337
+ export interface ExecutionEdge {
338
+ id: string;
339
+ source_executor_id: string;
340
+ source_port: string;
341
+ target_executor_id: string;
342
+ target_port: string;
343
+ value: unknown | null;
344
+ }
345
+ /**
346
+ * Account object that flows through edges for posting
347
+ */
348
+ export interface AccountData {
349
+ id: string;
350
+ username: string;
351
+ platform: 'tiktok';
352
+ displayName?: string;
353
+ profilePicUrl?: string;
354
+ metadata?: Record<string, unknown>;
355
+ }
356
+ /**
357
+ * Output structure for flow control nodes (if, random-route).
358
+ * Contains values for selected ports and list of skipped port IDs.
359
+ */
360
+ export interface FlowControlOutput {
361
+ values: Record<string, unknown>;
362
+ skippedPorts: string[];
363
+ }
364
+ /**
365
+ * Context passed to executor-based node execution.
366
+ * Replaces the complex outputMap/iteration/portOffsets pattern with simple inputs.
367
+ */
368
+ export interface ExecutorContext {
369
+ /** Database ID of this executor */
370
+ executorId: string;
371
+ /** Run ID this executor belongs to */
372
+ runId: string;
373
+ /** Template node ID this executor was created from */
374
+ templateNodeId: string;
375
+ /** Index of this executor (0, 1, 2...) for the same template node */
376
+ executorIndex: number;
377
+ /** Node type */
378
+ type: NodeType;
379
+ /** Node config (includes assignedValue for source nodes) */
380
+ config: Record<string, unknown>;
381
+ /** Input values read from incoming edges (portId -> value) */
382
+ inputs: Record<string, unknown>;
383
+ }
384
+ /**
385
+ * Executor for synchronous nodes.
386
+ * Much simpler than the old NodeControlConfig - just takes context and returns output.
387
+ */
388
+ export interface NodeExecutor<TOutput = unknown> {
389
+ type: NodeType;
390
+ /**
391
+ * Execute the node and return a single output value.
392
+ * For multi-output nodes (like LLM), return an object with output fields.
393
+ */
394
+ execute: (ctx: ExecutorContext) => Promise<TOutput>;
395
+ }
396
+ /**
397
+ * Async job status for executor-based async nodes
398
+ */
399
+ export type ExecutorAsyncJobStatus<TOutput = unknown> = {
400
+ status: 'pending';
401
+ } | {
402
+ status: 'completed';
403
+ output: TOutput;
404
+ } | {
405
+ status: 'failed';
406
+ error: string;
407
+ };
408
+ /**
409
+ * Executor for asynchronous nodes (video-editor, generate-image, workflow).
410
+ * Uses submit/poll pattern for durable workflows.
411
+ */
412
+ export interface AsyncNodeExecutor<TOutput = unknown> extends Omit<NodeExecutor<TOutput>, 'execute'> {
413
+ isAsync: true;
414
+ /** Submit job - returns job ID for polling */
415
+ submitJob: (ctx: ExecutorContext) => Promise<{
416
+ jobId: string;
417
+ }>;
418
+ /** Check job status - called by orchestrator with workflow sleep between calls */
419
+ checkStatus: (jobId: string, ctx: ExecutorContext) => Promise<ExecutorAsyncJobStatus<TOutput>>;
420
+ }
421
+ /**
422
+ * Type guard to check if an executor is async
423
+ */
424
+ export declare function isAsyncExecutor<T>(executor: NodeExecutor<T> | AsyncNodeExecutor<T>): executor is AsyncNodeExecutor<T>;
425
+ /**
426
+ * Validation error types for automation workflows
427
+ */
428
+ export type ValidationErrorType = 'missing_trigger' | 'missing_terminal' | 'missing_required_input' | 'type_mismatch' | 'empty_media_pool' | 'empty_account_pool';
429
+ /**
430
+ * Structured validation error with location info for UI highlighting
431
+ */
432
+ export interface ValidationError {
433
+ type: ValidationErrorType;
434
+ nodeId?: string;
435
+ portId?: string;
436
+ message: string;
437
+ }
438
+ /**
439
+ * Exported node representation for debugging
440
+ */
441
+ export interface ExportedNode {
442
+ nodeId: string;
443
+ type: string;
444
+ name: string | null;
445
+ position: {
446
+ x: number;
447
+ y: number;
448
+ };
449
+ inputs: Record<string, {
450
+ sourceNodeId: string;
451
+ sourceOutputId: string;
452
+ }>;
453
+ config: Record<string, unknown>;
454
+ }
455
+ /**
456
+ * Exported connection representation
457
+ */
458
+ export interface ExportedConnection {
459
+ from: {
460
+ nodeId: string;
461
+ port: string;
462
+ };
463
+ to: {
464
+ nodeId: string;
465
+ port: string;
466
+ };
467
+ }
468
+ /**
469
+ * Exported template data
470
+ */
471
+ export interface ExportedTemplate {
472
+ id: string;
473
+ name: string;
474
+ description: string | null;
475
+ canvasState: {
476
+ zoom: number;
477
+ panX: number;
478
+ panY: number;
479
+ } | null;
480
+ outputSchema: Record<string, {
481
+ type: string;
482
+ }> | null;
483
+ createdAt: string;
484
+ updatedAt: string;
485
+ }
486
+ /**
487
+ * Full automation export (template + nodes + connections)
488
+ */
489
+ export interface AutomationExport {
490
+ template: ExportedTemplate;
491
+ nodes: ExportedNode[];
492
+ connections: ExportedConnection[];
493
+ }
494
+ /**
495
+ * Exported executor data
496
+ */
497
+ export interface ExportedExecutor {
498
+ id: string;
499
+ nodeTemplateId: string;
500
+ executorIndex: number;
501
+ type: string;
502
+ status: string;
503
+ outputValue: unknown;
504
+ errorMessage: string | null;
505
+ createdAt: string;
506
+ completedAt: string | null;
507
+ }
508
+ /**
509
+ * Exported edge data
510
+ */
511
+ export interface ExportedEdge {
512
+ sourceExecutorId: string;
513
+ sourceNodeId: string;
514
+ sourcePort: string;
515
+ targetExecutorId: string;
516
+ targetNodeId: string;
517
+ targetPort: string;
518
+ value: unknown;
519
+ }
520
+ /**
521
+ * Exported run data
522
+ */
523
+ export interface ExportedRun {
524
+ id: string;
525
+ templateId: string;
526
+ templateName: string;
527
+ status: string;
528
+ variableInputs: Record<string, string> | null;
529
+ createdAt: string;
530
+ completedAt: string | null;
531
+ }
532
+ /**
533
+ * Full automation run export
534
+ */
535
+ export interface AutomationRunExport {
536
+ run: ExportedRun;
537
+ template: ExportedTemplate;
538
+ nodes: ExportedNode[];
539
+ connections: ExportedConnection[];
540
+ execution: {
541
+ executors: ExportedExecutor[];
542
+ edges: ExportedEdge[];
543
+ };
544
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ /**
3
+ * Automation Types
4
+ *
5
+ * Core types for the automation system including ports, selection, and output modes.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.UserCreatableNodeTypes = exports.NodeTypes = void 0;
9
+ exports.formatPortType = formatPortType;
10
+ exports.isAsyncExecutor = isAsyncExecutor;
11
+ /**
12
+ * Format a port type for display (e.g., 'image' with isArray=true -> 'image[]')
13
+ */
14
+ function formatPortType(type, isArray) {
15
+ if (Array.isArray(type)) {
16
+ const types = type.map(t => isArray ? `${t}[]` : t);
17
+ return types.join(' | ');
18
+ }
19
+ return isArray ? `${type}[]` : type;
20
+ }
21
+ // =============================================================================
22
+ // Node Type Enums
23
+ // =============================================================================
24
+ /**
25
+ * Node types array for runtime use
26
+ */
27
+ exports.NodeTypes = [
28
+ 'social-audio',
29
+ 'text',
30
+ 'media',
31
+ 'video-import',
32
+ 'image-composer',
33
+ 'video-composer',
34
+ 'generate-image',
35
+ 'generate-video',
36
+ 'custom-model',
37
+ 'llm',
38
+ 'passthrough',
39
+ 'manual-trigger',
40
+ 'recurrence',
41
+ 'compose-workflow',
42
+ 'account',
43
+ 'auto-post',
44
+ 'save-to-media',
45
+ 'deduplicate',
46
+ 'for-each',
47
+ 'for-each-value',
48
+ 'transcript',
49
+ 'auto-caption',
50
+ 'screenshot-animation',
51
+ 'random',
52
+ 'random-route',
53
+ 'branch',
54
+ 'if',
55
+ 'not',
56
+ 'create-dm',
57
+ 'collect',
58
+ 'destructure',
59
+ ];
60
+ /**
61
+ * User-creatable node types (excludes internal executor types like 'for-each-value')
62
+ * These are the nodes that appear in the node picker and have definitions.
63
+ */
64
+ exports.UserCreatableNodeTypes = [
65
+ 'social-audio',
66
+ 'text',
67
+ 'media',
68
+ 'video-import',
69
+ 'image-composer',
70
+ 'video-composer',
71
+ 'generate-image',
72
+ 'generate-video',
73
+ 'custom-model',
74
+ 'llm',
75
+ 'passthrough',
76
+ 'manual-trigger',
77
+ 'recurrence',
78
+ 'compose-workflow',
79
+ 'account',
80
+ 'auto-post',
81
+ 'save-to-media',
82
+ 'deduplicate',
83
+ 'for-each',
84
+ 'transcript',
85
+ 'auto-caption',
86
+ 'screenshot-animation',
87
+ 'random',
88
+ 'random-route',
89
+ 'branch',
90
+ 'if',
91
+ 'not',
92
+ 'create-dm',
93
+ 'collect',
94
+ 'destructure',
95
+ ];
96
+ /**
97
+ * Type guard to check if an executor is async
98
+ */
99
+ function isAsyncExecutor(executor) {
100
+ return 'isAsync' in executor && executor.isAsync === true;
101
+ }
@@ -1,20 +1,11 @@
1
- import type { NodeControlConfig, NodeCategory, MediaType, NodePort, NodeTypeEnum, PortType, WorkflowDefinition, AutomationTemplate, AutomationRun, ExecutorNode, ExecutionEdge, ApiResponse, AutomationExport, AutomationRunExport, PropertySchema } from './types';
2
- import { BaseClient } from './base';
3
1
  /**
4
- * Check if two port types are compatible for connection
5
- * A connection is valid if:
6
- * 1. The types match exactly (same base type and same isArray), OR
7
- * 2. The source is an array type and target is 'object' (non-array), OR
8
- * 3. The source is a PortType[] and includes a compatible type, OR
9
- * 4. The target is a PortType[] and includes a compatible type, OR
10
- * 5. Both are PortType[] and have at least one common compatible type
2
+ * Automations API Client
11
3
  *
12
- * Note: Array inputs are strict - they only accept exact matches
4
+ * Provides methods to interact with the UGC Inc Automations API.
5
+ * For graph logic (validation, port computation, connections), use graph-controller.ts
13
6
  */
14
- export declare function areTypesCompatible({ sourceType, targetType, }: {
15
- sourceType: PortType | PortType[];
16
- targetType: PortType | PortType[];
17
- }): boolean;
7
+ import type { WorkflowDefinition, AutomationTemplate, AutomationRun, ExecutorNode, ExecutionEdge, ApiResponse, AutomationExport, AutomationRunExport } from './types';
8
+ import { BaseClient } from './base';
18
9
  export declare class AutomationsClient extends BaseClient {
19
10
  /**
20
11
  * List all automation templates for an organization
@@ -180,22 +171,3 @@ export declare class AutomationsClient extends BaseClient {
180
171
  runIds: string[];
181
172
  }>>;
182
173
  }
183
- /**
184
- * Get all available automation nodes
185
- */
186
- export declare function getAllNodes(): NodeControlConfig[];
187
- /**
188
- * Get a specific node by type
189
- */
190
- export declare function getNodeByType(type: string): NodeControlConfig | undefined;
191
- /**
192
- * Get the schema of array items for a node's output port.
193
- * Returns null if schema is unknown or the output is not an array.
194
- *
195
- * @param nodeType - The type of the node (e.g., 'transcript', 'llm')
196
- * @param nodeConfig - The node's configuration object
197
- * @param outputPortId - The ID of the output port to get schema for
198
- * @returns The schema of array items, or null if unknown
199
- */
200
- export declare function getOutputSchema(nodeType: string, nodeConfig: Record<string, unknown> | undefined, outputPortId: string): Record<string, PropertySchema> | null;
201
- export type { NodeControlConfig, NodeCategory, MediaType, NodePort, NodeTypeEnum, PropertySchema };