n8n-nodes-comfyui-all 2.4.1 → 2.4.2

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,163 +1,72 @@
1
1
  "use strict";
2
+ /**
3
+ * Workflow Configuration Utilities
4
+ *
5
+ * This module provides utilities for handling ComfyUI workflows.
6
+ * All workflows must be provided by the user - there are no built-in templates.
7
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IMAGE_TO_IMAGE_WORKFLOW_TEMPLATE = exports.DEFAULT_WORKFLOW_TEMPLATE = void 0;
4
- exports.getWorkflowTemplate = getWorkflowTemplate;
9
+ exports.parseWorkflow = parseWorkflow;
10
+ exports.findNodesByClassType = findNodesByClassType;
11
+ exports.getAllNodeIds = getAllNodeIds;
12
+ exports.getWorkflowClassTypes = getWorkflowClassTypes;
5
13
  const validation_1 = require("./validation");
6
14
  /**
7
- * Default workflow template for text-to-image generation
8
- * This is a basic Stable Diffusion workflow that can be customized
15
+ * Validate and parse user-provided workflow JSON
16
+ * @param workflowJson - Workflow JSON string or object
17
+ * @returns Parsed workflow object
18
+ * @throws Error if workflow is invalid
9
19
  */
10
- exports.DEFAULT_WORKFLOW_TEMPLATE = {
11
- "3": {
12
- "inputs": {
13
- "seed": 0,
14
- "steps": 20,
15
- "cfg": 8,
16
- "sampler_name": "euler",
17
- "scheduler": "normal",
18
- "denoise": 1,
19
- "model": ["4", 0],
20
- "positive": ["6", 0],
21
- "negative": ["7", 0],
22
- "latent_image": ["5", 0]
23
- },
24
- "class_type": "KSampler"
25
- },
26
- "4": {
27
- "inputs": {
28
- "ckpt_name": "v1-5-pruned-emaonly.ckpt"
29
- },
30
- "class_type": "CheckpointLoaderSimple"
31
- },
32
- "5": {
33
- "inputs": {
34
- "width": 512,
35
- "height": 512,
36
- "batch_size": 1
37
- },
38
- "class_type": "EmptyLatentImage"
39
- },
40
- "6": {
41
- "inputs": {
42
- "text": "",
43
- "clip": ["4", 1]
44
- },
45
- "class_type": "CLIPTextEncode"
46
- },
47
- "7": {
48
- "inputs": {
49
- "text": "ugly, blurry, low quality",
50
- "clip": ["4", 1]
51
- },
52
- "class_type": "CLIPTextEncode"
53
- },
54
- "8": {
55
- "inputs": {
56
- "samples": ["3", 0],
57
- "vae": ["4", 2]
58
- },
59
- "class_type": "VAEDecode"
60
- },
61
- "9": {
62
- "inputs": {
63
- "filename_prefix": "ComfyUI",
64
- "images": ["8", 0]
65
- },
66
- "class_type": "SaveImage"
20
+ function parseWorkflow(workflowJson) {
21
+ if (typeof workflowJson === 'string') {
22
+ if (!workflowJson.trim()) {
23
+ throw new Error('Workflow JSON is empty. Please provide a valid ComfyUI workflow.');
24
+ }
25
+ return (0, validation_1.safeJsonParse)(workflowJson, 'Workflow JSON');
67
26
  }
68
- };
27
+ if (typeof workflowJson === 'object' && workflowJson !== null) {
28
+ if (Object.keys(workflowJson).length === 0) {
29
+ throw new Error('Workflow object is empty. Please provide a valid ComfyUI workflow.');
30
+ }
31
+ return workflowJson;
32
+ }
33
+ throw new Error('Invalid workflow format. Expected JSON string or object.');
34
+ }
69
35
  /**
70
- * Default workflow template for image-to-image generation
71
- * This workflow takes an input image and generates a new image based on the prompt
36
+ * Check if a workflow has a specific node type
37
+ * @param workflow - ComfyUI workflow object
38
+ * @param classType - Node class type to search for
39
+ * @returns Array of node IDs that match the class type
72
40
  */
73
- exports.IMAGE_TO_IMAGE_WORKFLOW_TEMPLATE = {
74
- "3": {
75
- "inputs": {
76
- "seed": 0,
77
- "steps": 20,
78
- "cfg": 8,
79
- "sampler_name": "euler",
80
- "scheduler": "normal",
81
- "denoise": 0.75,
82
- "model": ["4", 0],
83
- "positive": ["6", 0],
84
- "negative": ["7", 0],
85
- "latent_image": ["10", 0]
86
- },
87
- "class_type": "KSampler"
88
- },
89
- "4": {
90
- "inputs": {
91
- "ckpt_name": "v1-5-pruned-emaonly.ckpt"
92
- },
93
- "class_type": "CheckpointLoaderSimple"
94
- },
95
- "5": {
96
- "inputs": {
97
- "image": "input_image.png",
98
- "upload": "image"
99
- },
100
- "class_type": "LoadImage"
101
- },
102
- "6": {
103
- "inputs": {
104
- "text": "",
105
- "clip": ["4", 1]
106
- },
107
- "class_type": "CLIPTextEncode"
108
- },
109
- "7": {
110
- "inputs": {
111
- "text": "ugly, blurry, low quality",
112
- "clip": ["4", 1]
113
- },
114
- "class_type": "CLIPTextEncode"
115
- },
116
- "10": {
117
- "inputs": {
118
- "pixels": ["5", 0],
119
- "vae": ["4", 2]
120
- },
121
- "class_type": "VAEEncode"
122
- },
123
- "8": {
124
- "inputs": {
125
- "samples": ["3", 0],
126
- "vae": ["4", 2]
127
- },
128
- "class_type": "VAEDecode"
129
- },
130
- "9": {
131
- "inputs": {
132
- "filename_prefix": "ComfyUI",
133
- "images": ["8", 0]
134
- },
135
- "class_type": "SaveImage"
41
+ function findNodesByClassType(workflow, classType) {
42
+ const matchingNodes = [];
43
+ for (const nodeId in workflow) {
44
+ if (workflow[nodeId] && workflow[nodeId].class_type === classType) {
45
+ matchingNodes.push(nodeId);
46
+ }
136
47
  }
137
- };
48
+ return matchingNodes;
49
+ }
138
50
  /**
139
- * Get workflow template based on configuration
140
- * @param config - Workflow configuration
141
- * @returns Workflow template
51
+ * Get all node IDs from a workflow
52
+ * @param workflow - ComfyUI workflow object
53
+ * @returns Array of node IDs
142
54
  */
143
- function getWorkflowTemplate(config) {
144
- // If custom template is provided, try to parse it
145
- if (config?.customTemplate) {
146
- try {
147
- return (0, validation_1.safeJsonParse)(config.customTemplate, 'Custom workflow template');
148
- }
149
- catch (error) {
150
- // Silently fall back to default template on error
55
+ function getAllNodeIds(workflow) {
56
+ return Object.keys(workflow);
57
+ }
58
+ /**
59
+ * Get all class types used in a workflow
60
+ * @param workflow - ComfyUI workflow object
61
+ * @returns Array of unique class types
62
+ */
63
+ function getWorkflowClassTypes(workflow) {
64
+ const classTypes = new Set();
65
+ for (const nodeId in workflow) {
66
+ if (workflow[nodeId] && workflow[nodeId].class_type) {
67
+ classTypes.add(workflow[nodeId].class_type);
151
68
  }
152
69
  }
153
- // Check if template is a valid non-empty object
154
- if (config?.template && typeof config.template === 'object' && Object.keys(config.template).length > 0) {
155
- return config.template;
156
- }
157
- // Return template based on mode
158
- if (config?.mode === 'image-to-image') {
159
- return exports.IMAGE_TO_IMAGE_WORKFLOW_TEMPLATE;
160
- }
161
- return exports.DEFAULT_WORKFLOW_TEMPLATE;
70
+ return Array.from(classTypes);
162
71
  }
163
72
  //# sourceMappingURL=workflowConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflowConfig.js","sourceRoot":"","sources":["../../nodes/workflowConfig.ts"],"names":[],"mappings":";;;AA8IA,kDAqBC;AAlKD,6CAA6C;AAE7C;;;GAGG;AACU,QAAA,yBAAyB,GAAa;IACjD,GAAG,EAAE;QACH,QAAQ,EAAE;YACR,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,CAAC;YACR,cAAc,EAAE,OAAO;YACvB,WAAW,EAAE,QAAQ;YACrB,SAAS,EAAE,CAAC;YACZ,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;YACjB,UAAU,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;YACpB,UAAU,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;YACpB,cAAc,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;SACzB;QACD,YAAY,EAAE,UAAU;KACzB;IACD,GAAG,EAAE;QACH,QAAQ,EAAE;YACR,WAAW,EAAE,0BAA0B;SACxC;QACD,YAAY,EAAE,wBAAwB;KACvC;IACD,GAAG,EAAE;QACH,QAAQ,EAAE;YACR,OAAO,EAAE,GAAG;YACZ,QAAQ,EAAE,GAAG;YACb,YAAY,EAAE,CAAC;SAChB;QACD,YAAY,EAAE,kBAAkB;KACjC;IACD,GAAG,EAAE;QACH,QAAQ,EAAE;YACR,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,CAAC,GAAG,EAAE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AAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,QAAkB;IAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,QAAkB;IACtD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IAErC,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;YACpD,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-comfyui-all",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "description": "n8n community nodes for ComfyUI workflow execution with dynamic parameter support",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",