ugcinc 4.0.2 → 4.1.1
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/accounts.d.ts +146 -1
- package/dist/automations/index.d.ts +174 -0
- package/dist/automations/index.js +194 -0
- package/dist/automations/nodes/account.d.ts +6 -0
- package/dist/automations/nodes/account.js +28 -0
- package/dist/automations/nodes/auto-caption.d.ts +23 -0
- package/dist/automations/nodes/auto-caption.js +49 -0
- package/dist/automations/nodes/auto-post.d.ts +22 -0
- package/dist/automations/nodes/auto-post.js +52 -0
- package/dist/automations/nodes/branch.d.ts +21 -0
- package/dist/automations/nodes/branch.js +46 -0
- package/dist/automations/nodes/collect.d.ts +7 -0
- package/dist/automations/nodes/collect.js +51 -0
- package/dist/automations/nodes/compose-workflow.d.ts +8 -0
- package/dist/automations/nodes/compose-workflow.js +61 -0
- package/dist/automations/nodes/create-dm.d.ts +35 -0
- package/dist/automations/nodes/create-dm.js +86 -0
- package/dist/automations/nodes/custom-model.d.ts +18 -0
- package/dist/automations/nodes/custom-model.js +52 -0
- package/dist/automations/nodes/deduplicate.d.ts +7 -0
- package/dist/automations/nodes/deduplicate.js +36 -0
- package/dist/automations/nodes/destructure.d.ts +25 -0
- package/dist/automations/nodes/destructure.js +65 -0
- package/dist/automations/nodes/for-each.d.ts +22 -0
- package/dist/automations/nodes/for-each.js +84 -0
- package/dist/automations/nodes/generate-image.d.ts +15 -0
- package/dist/automations/nodes/generate-image.js +45 -0
- package/dist/automations/nodes/generate-video.d.ts +15 -0
- package/dist/automations/nodes/generate-video.js +45 -0
- package/dist/automations/nodes/if.d.ts +21 -0
- package/dist/automations/nodes/if.js +44 -0
- package/dist/automations/nodes/image-composer.d.ts +46 -0
- package/dist/automations/nodes/image-composer.js +135 -0
- package/dist/automations/nodes/index.d.ts +312 -0
- package/dist/automations/nodes/index.js +92 -0
- package/dist/automations/nodes/internal.d.ts +8 -0
- package/dist/automations/nodes/internal.js +10 -0
- package/dist/automations/nodes/llm.d.ts +26 -0
- package/dist/automations/nodes/llm.js +85 -0
- package/dist/automations/nodes/manual-trigger.d.ts +14 -0
- package/dist/automations/nodes/manual-trigger.js +32 -0
- package/dist/automations/nodes/media.d.ts +13 -0
- package/dist/automations/nodes/media.js +40 -0
- package/dist/automations/nodes/not.d.ts +5 -0
- package/dist/automations/nodes/not.js +35 -0
- package/dist/automations/nodes/output.d.ts +16 -0
- package/dist/automations/nodes/output.js +32 -0
- package/dist/automations/nodes/random-route.d.ts +24 -0
- package/dist/automations/nodes/random-route.js +53 -0
- package/dist/automations/nodes/random.d.ts +16 -0
- package/dist/automations/nodes/random.js +50 -0
- package/dist/automations/nodes/recurrence.d.ts +29 -0
- package/dist/automations/nodes/recurrence.js +50 -0
- package/dist/automations/nodes/save-to-media.d.ts +15 -0
- package/dist/automations/nodes/save-to-media.js +31 -0
- package/dist/automations/nodes/screenshot-animation.d.ts +6 -0
- package/dist/automations/nodes/screenshot-animation.js +36 -0
- package/dist/automations/nodes/social-audio.d.ts +7 -0
- package/dist/automations/nodes/social-audio.js +30 -0
- package/dist/automations/nodes/text.d.ts +6 -0
- package/dist/automations/nodes/text.js +41 -0
- package/dist/automations/nodes/transcript.d.ts +5 -0
- package/dist/automations/nodes/transcript.js +46 -0
- package/dist/automations/nodes/types.d.ts +202 -0
- package/dist/automations/nodes/types.js +22 -0
- package/dist/automations/nodes/video-composer.d.ts +16 -0
- package/dist/automations/nodes/video-composer.js +117 -0
- package/dist/automations/nodes/video-import.d.ts +9 -0
- package/dist/automations/nodes/video-import.js +23 -0
- package/dist/automations/types.d.ts +431 -0
- package/dist/automations/types.js +29 -0
- package/dist/automations.d.ts +5 -33
- package/dist/automations.js +6 -647
- package/dist/comments.d.ts +26 -1
- package/dist/comments.js +3 -0
- package/dist/graph-controller.d.ts +211 -0
- package/dist/graph-controller.js +656 -0
- package/dist/index.d.ts +22 -9
- package/dist/index.js +47 -24
- package/dist/internal-utils.d.ts +8 -0
- package/dist/internal-utils.js +22 -0
- package/dist/media.d.ts +135 -1
- package/dist/nodes/account.d.ts +7 -0
- package/dist/nodes/account.js +29 -0
- package/dist/nodes/auto-caption.d.ts +17 -0
- package/dist/nodes/auto-caption.js +46 -0
- package/dist/nodes/auto-post.d.ts +21 -0
- package/dist/nodes/auto-post.js +54 -0
- package/dist/nodes/branch.d.ts +12 -0
- package/dist/nodes/branch.js +50 -0
- package/dist/nodes/collect.d.ts +6 -0
- package/dist/nodes/collect.js +56 -0
- package/dist/nodes/compose-workflow.d.ts +21 -0
- package/dist/nodes/compose-workflow.js +42 -0
- package/dist/nodes/create-dm.d.ts +40 -0
- package/dist/nodes/create-dm.js +88 -0
- package/dist/nodes/custom-model.d.ts +19 -0
- package/dist/nodes/custom-model.js +52 -0
- package/dist/nodes/deduplicate.d.ts +8 -0
- package/dist/nodes/deduplicate.js +36 -0
- package/dist/nodes/destructure.d.ts +25 -0
- package/dist/nodes/destructure.js +65 -0
- package/dist/nodes/for-each.d.ts +23 -0
- package/dist/nodes/for-each.js +84 -0
- package/dist/nodes/generate-image.d.ts +16 -0
- package/dist/nodes/generate-image.js +45 -0
- package/dist/nodes/generate-video.d.ts +16 -0
- package/dist/nodes/generate-video.js +45 -0
- package/dist/nodes/if.d.ts +22 -0
- package/dist/nodes/if.js +44 -0
- package/dist/nodes/image-composer.d.ts +14 -0
- package/dist/nodes/image-composer.js +95 -0
- package/dist/nodes/index.d.ts +20 -0
- package/dist/nodes/index.js +93 -0
- package/dist/nodes/llm.d.ts +27 -0
- package/dist/nodes/llm.js +85 -0
- package/dist/nodes/manual-trigger.d.ts +16 -0
- package/dist/nodes/manual-trigger.js +32 -0
- package/dist/nodes/media.d.ts +17 -0
- package/dist/nodes/media.js +40 -0
- package/dist/nodes/not.d.ts +6 -0
- package/dist/nodes/not.js +35 -0
- package/dist/nodes/output.d.ts +9 -0
- package/dist/nodes/output.js +32 -0
- package/dist/nodes/random-route.d.ts +3 -0
- package/dist/nodes/random-route.js +50 -0
- package/dist/nodes/random.d.ts +3 -0
- package/dist/nodes/random.js +48 -0
- package/dist/nodes/recurrence.d.ts +3 -0
- package/dist/nodes/recurrence.js +45 -0
- package/dist/nodes/save-to-media.d.ts +3 -0
- package/dist/nodes/save-to-media.js +26 -0
- package/dist/nodes/screenshot-animation.d.ts +7 -0
- package/dist/nodes/screenshot-animation.js +36 -0
- package/dist/nodes/social-audio.d.ts +3 -0
- package/dist/nodes/social-audio.js +26 -0
- package/dist/nodes/text.d.ts +3 -0
- package/dist/nodes/text.js +38 -0
- package/dist/nodes/transcript.d.ts +3 -0
- package/dist/nodes/transcript.js +42 -0
- package/dist/nodes/types.d.ts +146 -0
- package/dist/nodes/types.js +22 -0
- package/dist/nodes/video-composer.d.ts +3 -0
- package/dist/nodes/video-composer.js +67 -0
- package/dist/nodes/video-import.d.ts +3 -0
- package/dist/nodes/video-import.js +35 -0
- package/dist/org.d.ts +13 -1
- package/dist/ports.js +3 -9
- package/dist/posts.d.ts +88 -1
- package/dist/render/compositions/IMessageDmComposition/types.d.ts +24 -24
- package/dist/render/compositions/ImageEditorComposition.js +2 -8
- package/dist/render/compositions/VideoEditorComposition.js +2 -24
- package/dist/render/types/element.d.ts +0 -33
- package/dist/render/types/index.d.ts +1 -1
- package/dist/render/types/video.d.ts +2 -2
- package/dist/render.d.ts +2 -1
- package/dist/stats.d.ts +128 -1
- package/dist/tasks.d.ts +20 -1
- package/dist/types.d.ts +1 -2216
- package/dist/types.js +2 -124
- package/package.json +1 -1
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automation Types
|
|
3
|
+
*
|
|
4
|
+
* Core types for the automation system including ports, selection, and output modes.
|
|
5
|
+
*/
|
|
6
|
+
import type { ObjectSchemaField, SelectionMode, OutputMode, NodeCategory } from './nodes/types';
|
|
7
|
+
import type { NodeType, UserCreatableNodeType, WorkflowConfig, InternalNodeType } from './nodes';
|
|
8
|
+
/**
|
|
9
|
+
* Media type for automation nodes
|
|
10
|
+
*/
|
|
11
|
+
export type MediaType = 'video' | 'image' | 'audio' | 'text';
|
|
12
|
+
/**
|
|
13
|
+
* Base port type - all possible value types without array modifier
|
|
14
|
+
*/
|
|
15
|
+
export type BasePortType = 'image' | 'video' | 'audio' | 'text' | 'number' | 'boolean' | 'object' | 'account' | 'date' | 'social_audio' | 'enum';
|
|
16
|
+
/**
|
|
17
|
+
* Option for enum port types
|
|
18
|
+
*/
|
|
19
|
+
export interface EnumOption {
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Format a port type for display (e.g., 'image' with isArray=true -> 'image[]')
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatPortType(type: BasePortType | BasePortType[], isArray: boolean): string;
|
|
27
|
+
/**
|
|
28
|
+
* Standard node output format.
|
|
29
|
+
* All nodes output their values in the _values array.
|
|
30
|
+
* - For per-input mode: _values contains N values (one per consumer)
|
|
31
|
+
* - For single mode: _values contains 1 value
|
|
32
|
+
*
|
|
33
|
+
* Downstream nodes always read from _values using resolveValueAtIteration().
|
|
34
|
+
*/
|
|
35
|
+
export interface NodeOutputValues {
|
|
36
|
+
_values: unknown[];
|
|
37
|
+
_outputMode: OutputMode;
|
|
38
|
+
}
|
|
39
|
+
export interface NodePort {
|
|
40
|
+
id: string;
|
|
41
|
+
type: BasePortType | BasePortType[];
|
|
42
|
+
isArray: boolean;
|
|
43
|
+
required: boolean;
|
|
44
|
+
/** Schema of object properties (when this port outputs an object) */
|
|
45
|
+
objectSchema?: ObjectSchemaField[];
|
|
46
|
+
/** Options for enum port types */
|
|
47
|
+
enumOptions?: EnumOption[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Port definition for resolved/dynamic ports.
|
|
51
|
+
* Stored in node config when the automation is saved.
|
|
52
|
+
*/
|
|
53
|
+
export interface ResolvedPort {
|
|
54
|
+
id: string;
|
|
55
|
+
type: BasePortType | BasePortType[];
|
|
56
|
+
isArray: boolean;
|
|
57
|
+
required: boolean;
|
|
58
|
+
/** Schema of object properties (when this port outputs an object) */
|
|
59
|
+
objectSchema?: ObjectSchemaField[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolved ports for nodes with dynamic inputs/outputs.
|
|
63
|
+
* Stored in node config when the automation is saved, allowing validation
|
|
64
|
+
* without needing to resolve ports at validation time.
|
|
65
|
+
* Note: Uses simplified ResolvedPort type for database compatibility.
|
|
66
|
+
*/
|
|
67
|
+
export interface ResolvedPorts {
|
|
68
|
+
inputs: ResolvedPort[];
|
|
69
|
+
outputs: ResolvedPort[];
|
|
70
|
+
}
|
|
71
|
+
export type { NodeType, UserCreatableNodeType, NodeConfig, WorkflowConfig, InternalNodeType, NodeDefinition } from './nodes';
|
|
72
|
+
export { nodeDefinitions, internalNodeTypes } from './nodes';
|
|
73
|
+
/**
|
|
74
|
+
* Pre-computed node definition with static ports.
|
|
75
|
+
* Returned by getAllNodes() and getNodeByType() for consumer convenience.
|
|
76
|
+
* Ports are pre-computed from the node's defaults - consumers don't need to call computePorts.
|
|
77
|
+
*/
|
|
78
|
+
export interface ComputedNode {
|
|
79
|
+
/** Node type identifier (e.g., 'collect', 'for-each', 'llm') */
|
|
80
|
+
nodeId: string;
|
|
81
|
+
/** Display label for the node */
|
|
82
|
+
label: string;
|
|
83
|
+
/** Description shown in add node modal */
|
|
84
|
+
description: string;
|
|
85
|
+
/** UI display category for grouping in add node modal */
|
|
86
|
+
category: string;
|
|
87
|
+
/** Functional type for node behavior classification */
|
|
88
|
+
type: NodeCategory;
|
|
89
|
+
/** Pre-computed input ports based on defaults */
|
|
90
|
+
inputs: NodePort[];
|
|
91
|
+
/** Pre-computed output ports based on defaults */
|
|
92
|
+
outputs: NodePort[];
|
|
93
|
+
/** Available output modes, or null if not applicable */
|
|
94
|
+
outputModes: OutputMode[] | null;
|
|
95
|
+
/** Available selection modes, or null if not applicable */
|
|
96
|
+
selectionModes: SelectionMode[] | null;
|
|
97
|
+
/** Default config values for this node */
|
|
98
|
+
defaults: Record<string, unknown>;
|
|
99
|
+
}
|
|
100
|
+
export interface OutputSchemaProperty {
|
|
101
|
+
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
102
|
+
items?: 'string' | 'number' | 'boolean';
|
|
103
|
+
properties?: Record<string, OutputSchemaProperty>;
|
|
104
|
+
}
|
|
105
|
+
/** Base fields shared by all workflow nodes */
|
|
106
|
+
type WorkflowNodeDefinitionBase = {
|
|
107
|
+
id: string;
|
|
108
|
+
name?: string;
|
|
109
|
+
x?: number;
|
|
110
|
+
y?: number;
|
|
111
|
+
inputs: Record<string, {
|
|
112
|
+
sourceNodeId: string;
|
|
113
|
+
sourceOutputId: string;
|
|
114
|
+
}>;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Discriminated union of workflow node definitions.
|
|
118
|
+
* Each node type has its specific config type, enabling automatic type narrowing.
|
|
119
|
+
*/
|
|
120
|
+
export type WorkflowNodeDefinition = {
|
|
121
|
+
[K in UserCreatableNodeType]: WorkflowNodeDefinitionBase & {
|
|
122
|
+
type: K;
|
|
123
|
+
config: WorkflowConfig[K];
|
|
124
|
+
};
|
|
125
|
+
}[UserCreatableNodeType];
|
|
126
|
+
export interface CanvasState {
|
|
127
|
+
zoom: number;
|
|
128
|
+
panX: number;
|
|
129
|
+
panY: number;
|
|
130
|
+
}
|
|
131
|
+
export interface WorkflowDefinition {
|
|
132
|
+
nodes: WorkflowNodeDefinition[];
|
|
133
|
+
canvasState?: CanvasState;
|
|
134
|
+
}
|
|
135
|
+
/** Base fields shared by all template nodes */
|
|
136
|
+
type TemplateNodeBase = {
|
|
137
|
+
id: string;
|
|
138
|
+
template_id: string;
|
|
139
|
+
node_id: string;
|
|
140
|
+
name: string | null;
|
|
141
|
+
x: number;
|
|
142
|
+
y: number;
|
|
143
|
+
inputs: Record<string, {
|
|
144
|
+
sourceNodeId: string;
|
|
145
|
+
sourceOutputId: string;
|
|
146
|
+
}>;
|
|
147
|
+
cached_output: Record<string, unknown> | null;
|
|
148
|
+
cached_at: string | null;
|
|
149
|
+
cached_run_id: string | null;
|
|
150
|
+
cached_variable_inputs: Record<string, string> | null;
|
|
151
|
+
preview_outputs: Record<string, string> | null;
|
|
152
|
+
created_at: string;
|
|
153
|
+
updated_at: string;
|
|
154
|
+
};
|
|
155
|
+
/** User-creatable template nodes have typed config */
|
|
156
|
+
type UserCreatableTemplateNode = {
|
|
157
|
+
[K in UserCreatableNodeType]: TemplateNodeBase & {
|
|
158
|
+
type: K;
|
|
159
|
+
config: WorkflowConfig[K] | null;
|
|
160
|
+
};
|
|
161
|
+
}[UserCreatableNodeType];
|
|
162
|
+
/** Internal template nodes (created during execution) have no config */
|
|
163
|
+
type InternalTemplateNode = {
|
|
164
|
+
[K in InternalNodeType]: TemplateNodeBase & {
|
|
165
|
+
type: K;
|
|
166
|
+
config: null;
|
|
167
|
+
};
|
|
168
|
+
}[InternalNodeType];
|
|
169
|
+
/**
|
|
170
|
+
* Template node as stored in the database.
|
|
171
|
+
* Discriminated union enabling automatic type narrowing based on node type.
|
|
172
|
+
*/
|
|
173
|
+
export type TemplateNode = UserCreatableTemplateNode | InternalTemplateNode;
|
|
174
|
+
export interface AutomationTemplate {
|
|
175
|
+
id: string;
|
|
176
|
+
org_id: string;
|
|
177
|
+
name: string;
|
|
178
|
+
description: string | null;
|
|
179
|
+
canvas_state: CanvasState | null;
|
|
180
|
+
nodes: TemplateNode[];
|
|
181
|
+
preview_output: string | null;
|
|
182
|
+
output_schema: Record<string, {
|
|
183
|
+
type: string;
|
|
184
|
+
}> | null;
|
|
185
|
+
recurrence_enabled: boolean;
|
|
186
|
+
next_run_at: string | null;
|
|
187
|
+
last_run_at: string | null;
|
|
188
|
+
created_at: string;
|
|
189
|
+
updated_at: string;
|
|
190
|
+
}
|
|
191
|
+
export interface AutomationRun {
|
|
192
|
+
id: string;
|
|
193
|
+
template_id: string;
|
|
194
|
+
org_id: string;
|
|
195
|
+
tag: string | null;
|
|
196
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
197
|
+
variable_inputs: Record<string, string> | null;
|
|
198
|
+
save_as_preview: boolean | null;
|
|
199
|
+
create_post: boolean | null;
|
|
200
|
+
require_review: boolean | null;
|
|
201
|
+
review_status: 'pending_review' | 'approved' | 'rejected' | null;
|
|
202
|
+
created_at: string;
|
|
203
|
+
completed_at: string | null;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Executor node from the edge-based execution model.
|
|
207
|
+
* Each executor represents one instance of a template node during execution.
|
|
208
|
+
*/
|
|
209
|
+
export interface ExecutorNode {
|
|
210
|
+
id: string;
|
|
211
|
+
template_node_id: string;
|
|
212
|
+
executor_index: number;
|
|
213
|
+
type: NodeType;
|
|
214
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
215
|
+
output_value: unknown | null;
|
|
216
|
+
error_message: string | null;
|
|
217
|
+
created_at: string;
|
|
218
|
+
completed_at: string | null;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Execution edge from the edge-based execution model.
|
|
222
|
+
* Represents a data flow connection between two executors.
|
|
223
|
+
*/
|
|
224
|
+
export interface ExecutionEdge {
|
|
225
|
+
id: string;
|
|
226
|
+
source_executor_id: string;
|
|
227
|
+
source_port: string;
|
|
228
|
+
target_executor_id: string;
|
|
229
|
+
target_port: string;
|
|
230
|
+
value: unknown | null;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Account object that flows through edges for posting
|
|
234
|
+
*/
|
|
235
|
+
export interface AccountData {
|
|
236
|
+
id: string;
|
|
237
|
+
username: string;
|
|
238
|
+
platform: 'tiktok';
|
|
239
|
+
displayName?: string;
|
|
240
|
+
profilePicUrl?: string;
|
|
241
|
+
metadata?: Record<string, unknown>;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Output structure for flow control nodes (if, random-route).
|
|
245
|
+
* Contains values for selected ports and list of skipped port IDs.
|
|
246
|
+
*/
|
|
247
|
+
export interface FlowControlOutput {
|
|
248
|
+
values: Record<string, unknown>;
|
|
249
|
+
skippedPorts: string[];
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Context passed to executor-based node execution.
|
|
253
|
+
* Replaces the complex outputMap/iteration/portOffsets pattern with simple inputs.
|
|
254
|
+
*/
|
|
255
|
+
export interface ExecutorContext {
|
|
256
|
+
/** Database ID of this executor */
|
|
257
|
+
executorId: string;
|
|
258
|
+
/** Run ID this executor belongs to */
|
|
259
|
+
runId: string;
|
|
260
|
+
/** Template node ID this executor was created from */
|
|
261
|
+
templateNodeId: string;
|
|
262
|
+
/** Index of this executor (0, 1, 2...) for the same template node */
|
|
263
|
+
executorIndex: number;
|
|
264
|
+
/** Node type */
|
|
265
|
+
type: NodeType;
|
|
266
|
+
/** Node config (includes assignedValue for source nodes) */
|
|
267
|
+
config: Record<string, unknown>;
|
|
268
|
+
/** Input values read from incoming edges (portId -> value) */
|
|
269
|
+
inputs: Record<string, unknown>;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Executor for synchronous nodes.
|
|
273
|
+
* Much simpler than the old NodeControlConfig - just takes context and returns output.
|
|
274
|
+
*/
|
|
275
|
+
export interface NodeExecutor<TOutput = unknown> {
|
|
276
|
+
type: NodeType;
|
|
277
|
+
/**
|
|
278
|
+
* Execute the node and return a single output value.
|
|
279
|
+
* For multi-output nodes (like LLM), return an object with output fields.
|
|
280
|
+
*/
|
|
281
|
+
execute: (ctx: ExecutorContext) => Promise<TOutput>;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Async job status for executor-based async nodes
|
|
285
|
+
*/
|
|
286
|
+
export type ExecutorAsyncJobStatus<TOutput = unknown> = {
|
|
287
|
+
status: 'pending';
|
|
288
|
+
} | {
|
|
289
|
+
status: 'completed';
|
|
290
|
+
output: TOutput;
|
|
291
|
+
} | {
|
|
292
|
+
status: 'failed';
|
|
293
|
+
error: string;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Executor for asynchronous nodes (video-editor, generate-image, workflow).
|
|
297
|
+
* Uses submit/poll pattern for durable workflows.
|
|
298
|
+
*/
|
|
299
|
+
export interface AsyncNodeExecutor<TOutput = unknown> extends Omit<NodeExecutor<TOutput>, 'execute'> {
|
|
300
|
+
isAsync: true;
|
|
301
|
+
/** Submit job - returns job ID for polling */
|
|
302
|
+
submitJob: (ctx: ExecutorContext) => Promise<{
|
|
303
|
+
jobId: string;
|
|
304
|
+
}>;
|
|
305
|
+
/** Check job status - called by orchestrator with workflow sleep between calls */
|
|
306
|
+
checkStatus: (jobId: string, ctx: ExecutorContext) => Promise<ExecutorAsyncJobStatus<TOutput>>;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Type guard to check if an executor is async
|
|
310
|
+
*/
|
|
311
|
+
export declare function isAsyncExecutor<T>(executor: NodeExecutor<T> | AsyncNodeExecutor<T>): executor is AsyncNodeExecutor<T>;
|
|
312
|
+
/**
|
|
313
|
+
* Validation error types for automation workflows
|
|
314
|
+
*/
|
|
315
|
+
export type ValidationErrorType = 'missing_trigger' | 'missing_terminal' | 'missing_required_input' | 'type_mismatch' | 'empty_media_pool' | 'empty_account_pool';
|
|
316
|
+
/**
|
|
317
|
+
* Structured validation error with location info for UI highlighting
|
|
318
|
+
*/
|
|
319
|
+
export interface ValidationError {
|
|
320
|
+
type: ValidationErrorType;
|
|
321
|
+
nodeId?: string;
|
|
322
|
+
portId?: string;
|
|
323
|
+
message: string;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Exported node representation for debugging
|
|
327
|
+
*/
|
|
328
|
+
export interface ExportedNode {
|
|
329
|
+
nodeId: string;
|
|
330
|
+
type: string;
|
|
331
|
+
name: string | null;
|
|
332
|
+
position: {
|
|
333
|
+
x: number;
|
|
334
|
+
y: number;
|
|
335
|
+
};
|
|
336
|
+
inputs: Record<string, {
|
|
337
|
+
sourceNodeId: string;
|
|
338
|
+
sourceOutputId: string;
|
|
339
|
+
}>;
|
|
340
|
+
config: Record<string, unknown>;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Exported connection representation
|
|
344
|
+
*/
|
|
345
|
+
export interface ExportedConnection {
|
|
346
|
+
from: {
|
|
347
|
+
nodeId: string;
|
|
348
|
+
port: string;
|
|
349
|
+
};
|
|
350
|
+
to: {
|
|
351
|
+
nodeId: string;
|
|
352
|
+
port: string;
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Exported template data
|
|
357
|
+
*/
|
|
358
|
+
export interface ExportedTemplate {
|
|
359
|
+
id: string;
|
|
360
|
+
name: string;
|
|
361
|
+
description: string | null;
|
|
362
|
+
canvasState: {
|
|
363
|
+
zoom: number;
|
|
364
|
+
panX: number;
|
|
365
|
+
panY: number;
|
|
366
|
+
} | null;
|
|
367
|
+
outputSchema: Record<string, {
|
|
368
|
+
type: string;
|
|
369
|
+
}> | null;
|
|
370
|
+
createdAt: string;
|
|
371
|
+
updatedAt: string;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Full automation export (template + nodes + connections)
|
|
375
|
+
*/
|
|
376
|
+
export interface AutomationExport {
|
|
377
|
+
template: ExportedTemplate;
|
|
378
|
+
nodes: ExportedNode[];
|
|
379
|
+
connections: ExportedConnection[];
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Exported executor data
|
|
383
|
+
*/
|
|
384
|
+
export interface ExportedExecutor {
|
|
385
|
+
id: string;
|
|
386
|
+
nodeTemplateId: string;
|
|
387
|
+
executorIndex: number;
|
|
388
|
+
type: string;
|
|
389
|
+
status: string;
|
|
390
|
+
outputValue: unknown;
|
|
391
|
+
errorMessage: string | null;
|
|
392
|
+
createdAt: string;
|
|
393
|
+
completedAt: string | null;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Exported edge data
|
|
397
|
+
*/
|
|
398
|
+
export interface ExportedEdge {
|
|
399
|
+
sourceExecutorId: string;
|
|
400
|
+
sourceNodeId: string;
|
|
401
|
+
sourcePort: string;
|
|
402
|
+
targetExecutorId: string;
|
|
403
|
+
targetNodeId: string;
|
|
404
|
+
targetPort: string;
|
|
405
|
+
value: unknown;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Exported run data
|
|
409
|
+
*/
|
|
410
|
+
export interface ExportedRun {
|
|
411
|
+
id: string;
|
|
412
|
+
templateId: string;
|
|
413
|
+
templateName: string;
|
|
414
|
+
status: string;
|
|
415
|
+
variableInputs: Record<string, string> | null;
|
|
416
|
+
createdAt: string;
|
|
417
|
+
completedAt: string | null;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Full automation run export
|
|
421
|
+
*/
|
|
422
|
+
export interface AutomationRunExport {
|
|
423
|
+
run: ExportedRun;
|
|
424
|
+
template: ExportedTemplate;
|
|
425
|
+
nodes: ExportedNode[];
|
|
426
|
+
connections: ExportedConnection[];
|
|
427
|
+
execution: {
|
|
428
|
+
executors: ExportedExecutor[];
|
|
429
|
+
edges: ExportedEdge[];
|
|
430
|
+
};
|
|
431
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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.internalNodeTypes = exports.nodeDefinitions = 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
|
+
var nodes_1 = require("./nodes");
|
|
22
|
+
Object.defineProperty(exports, "nodeDefinitions", { enumerable: true, get: function () { return nodes_1.nodeDefinitions; } });
|
|
23
|
+
Object.defineProperty(exports, "internalNodeTypes", { enumerable: true, get: function () { return nodes_1.internalNodeTypes; } });
|
|
24
|
+
/**
|
|
25
|
+
* Type guard to check if an executor is async
|
|
26
|
+
*/
|
|
27
|
+
function isAsyncExecutor(executor) {
|
|
28
|
+
return 'isAsync' in executor && executor.isAsync === true;
|
|
29
|
+
}
|
package/dist/automations.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
15
|
-
|
|
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 };
|