@n8n/workflow-sdk 0.8.0 → 0.10.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 (211) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/codegen/code-generator.js +8 -8
  3. package/dist/codegen/code-generator.js.map +1 -1
  4. package/dist/codegen/subnode-generator.d.ts +4 -0
  5. package/dist/codegen/subnode-generator.js +23 -2
  6. package/dist/codegen/subnode-generator.js.map +1 -1
  7. package/dist/generate-types/generate-types.d.ts +1 -0
  8. package/dist/generate-types/generate-types.js +27 -1
  9. package/dist/generate-types/generate-types.js.map +1 -1
  10. package/dist/generate-types/generate-zod-schemas.js +1 -1
  11. package/dist/generate-types/generate-zod-schemas.js.map +1 -1
  12. package/dist/index.d.ts +3 -1
  13. package/dist/index.js +6 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/prompts/best-practices/guides/chatbot.d.ts +7 -0
  16. package/dist/prompts/best-practices/guides/chatbot.js +120 -0
  17. package/dist/prompts/best-practices/guides/chatbot.js.map +1 -0
  18. package/dist/prompts/best-practices/guides/content-generation.d.ts +7 -0
  19. package/dist/prompts/best-practices/guides/content-generation.js +117 -0
  20. package/dist/prompts/best-practices/guides/content-generation.js.map +1 -0
  21. package/dist/prompts/best-practices/guides/data-analysis.d.ts +7 -0
  22. package/dist/prompts/best-practices/guides/data-analysis.js +369 -0
  23. package/dist/prompts/best-practices/guides/data-analysis.js.map +1 -0
  24. package/dist/prompts/best-practices/guides/data-extraction.d.ts +7 -0
  25. package/dist/prompts/best-practices/guides/data-extraction.js +124 -0
  26. package/dist/prompts/best-practices/guides/data-extraction.js.map +1 -0
  27. package/dist/prompts/best-practices/guides/data-persistence.d.ts +7 -0
  28. package/dist/prompts/best-practices/guides/data-persistence.js +199 -0
  29. package/dist/prompts/best-practices/guides/data-persistence.js.map +1 -0
  30. package/dist/prompts/best-practices/guides/data-transformation.d.ts +7 -0
  31. package/dist/prompts/best-practices/guides/data-transformation.js +148 -0
  32. package/dist/prompts/best-practices/guides/data-transformation.js.map +1 -0
  33. package/dist/prompts/best-practices/guides/document-processing.d.ts +7 -0
  34. package/dist/prompts/best-practices/guides/document-processing.js +334 -0
  35. package/dist/prompts/best-practices/guides/document-processing.js.map +1 -0
  36. package/dist/prompts/best-practices/guides/enrichment.d.ts +7 -0
  37. package/dist/prompts/best-practices/guides/enrichment.js +273 -0
  38. package/dist/prompts/best-practices/guides/enrichment.js.map +1 -0
  39. package/dist/prompts/best-practices/guides/form-input.d.ts +7 -0
  40. package/dist/prompts/best-practices/guides/form-input.js +175 -0
  41. package/dist/prompts/best-practices/guides/form-input.js.map +1 -0
  42. package/dist/prompts/best-practices/guides/human-in-the-loop.d.ts +7 -0
  43. package/dist/prompts/best-practices/guides/human-in-the-loop.js +270 -0
  44. package/dist/prompts/best-practices/guides/human-in-the-loop.js.map +1 -0
  45. package/dist/prompts/best-practices/guides/knowledge-base.d.ts +7 -0
  46. package/dist/prompts/best-practices/guides/knowledge-base.js +270 -0
  47. package/dist/prompts/best-practices/guides/knowledge-base.js.map +1 -0
  48. package/dist/prompts/best-practices/guides/monitoring.d.ts +7 -0
  49. package/dist/prompts/best-practices/guides/monitoring.js +173 -0
  50. package/dist/prompts/best-practices/guides/monitoring.js.map +1 -0
  51. package/dist/prompts/best-practices/guides/notification.d.ts +7 -0
  52. package/dist/prompts/best-practices/guides/notification.js +137 -0
  53. package/dist/prompts/best-practices/guides/notification.js.map +1 -0
  54. package/dist/prompts/best-practices/guides/scheduling.d.ts +7 -0
  55. package/dist/prompts/best-practices/guides/scheduling.js +154 -0
  56. package/dist/prompts/best-practices/guides/scheduling.js.map +1 -0
  57. package/dist/prompts/best-practices/guides/scraping-and-research.d.ts +7 -0
  58. package/dist/prompts/best-practices/guides/scraping-and-research.js +160 -0
  59. package/dist/prompts/best-practices/guides/scraping-and-research.js.map +1 -0
  60. package/dist/prompts/best-practices/guides/triage.d.ts +7 -0
  61. package/dist/prompts/best-practices/guides/triage.js +151 -0
  62. package/dist/prompts/best-practices/guides/triage.js.map +1 -0
  63. package/dist/prompts/best-practices/index.d.ts +20 -0
  64. package/dist/prompts/best-practices/index.js +69 -0
  65. package/dist/prompts/best-practices/index.js.map +1 -0
  66. package/dist/prompts/best-practices/types.d.ts +25 -0
  67. package/dist/prompts/best-practices/types.js +40 -0
  68. package/dist/prompts/best-practices/types.js.map +1 -0
  69. package/dist/prompts/index.d.ts +3 -0
  70. package/dist/prompts/index.js +25 -0
  71. package/dist/prompts/index.js.map +1 -0
  72. package/dist/prompts/node-guidance/index.d.ts +3 -0
  73. package/dist/prompts/node-guidance/index.js +20 -0
  74. package/dist/prompts/node-guidance/index.js.map +1 -0
  75. package/dist/prompts/node-guidance/node-recommendations/audio-generation.d.ts +2 -0
  76. package/dist/prompts/node-guidance/node-recommendations/audio-generation.js +18 -0
  77. package/dist/prompts/node-guidance/node-recommendations/audio-generation.js.map +1 -0
  78. package/dist/prompts/node-guidance/node-recommendations/format-recommendation.d.ts +2 -0
  79. package/dist/prompts/node-guidance/node-recommendations/format-recommendation.js +27 -0
  80. package/dist/prompts/node-guidance/node-recommendations/format-recommendation.js.map +1 -0
  81. package/dist/prompts/node-guidance/node-recommendations/image-generation.d.ts +2 -0
  82. package/dist/prompts/node-guidance/node-recommendations/image-generation.js +18 -0
  83. package/dist/prompts/node-guidance/node-recommendations/image-generation.js.map +1 -0
  84. package/dist/prompts/node-guidance/node-recommendations/index.d.ts +6 -0
  85. package/dist/prompts/node-guidance/node-recommendations/index.js +17 -0
  86. package/dist/prompts/node-guidance/node-recommendations/index.js.map +1 -0
  87. package/dist/prompts/node-guidance/node-recommendations/text-manipulation.d.ts +2 -0
  88. package/dist/prompts/node-guidance/node-recommendations/text-manipulation.js +27 -0
  89. package/dist/prompts/node-guidance/node-recommendations/text-manipulation.js.map +1 -0
  90. package/dist/prompts/node-guidance/node-recommendations/types.d.ts +26 -0
  91. package/dist/prompts/node-guidance/node-recommendations/types.js +16 -0
  92. package/dist/prompts/node-guidance/node-recommendations/types.js.map +1 -0
  93. package/dist/prompts/node-guidance/node-recommendations/video-generation.d.ts +2 -0
  94. package/dist/prompts/node-guidance/node-recommendations/video-generation.js +15 -0
  95. package/dist/prompts/node-guidance/node-recommendations/video-generation.js.map +1 -0
  96. package/dist/prompts/node-guidance/node-tips/index.d.ts +3 -0
  97. package/dist/prompts/node-guidance/node-tips/index.js +8 -0
  98. package/dist/prompts/node-guidance/node-tips/index.js.map +1 -0
  99. package/dist/prompts/node-guidance/node-tips/structured-output-parser.d.ts +2 -0
  100. package/dist/prompts/node-guidance/node-tips/structured-output-parser.js +35 -0
  101. package/dist/prompts/node-guidance/node-tips/structured-output-parser.js.map +1 -0
  102. package/dist/prompts/node-guidance/node-tips/types.d.ts +7 -0
  103. package/dist/prompts/node-guidance/node-tips/types.js +3 -0
  104. package/dist/prompts/node-guidance/node-tips/types.js.map +1 -0
  105. package/dist/prompts/node-guidance/node-tips/webhook.d.ts +2 -0
  106. package/dist/prompts/node-guidance/node-tips/webhook.js +38 -0
  107. package/dist/prompts/node-guidance/node-tips/webhook.js.map +1 -0
  108. package/dist/prompts/node-guidance/parameter-guides/embedding-nodes.d.ts +2 -0
  109. package/dist/prompts/node-guidance/parameter-guides/embedding-nodes.js +70 -0
  110. package/dist/prompts/node-guidance/parameter-guides/embedding-nodes.js.map +1 -0
  111. package/dist/prompts/node-guidance/parameter-guides/gmail.d.ts +2 -0
  112. package/dist/prompts/node-guidance/parameter-guides/gmail.js +53 -0
  113. package/dist/prompts/node-guidance/parameter-guides/gmail.js.map +1 -0
  114. package/dist/prompts/node-guidance/parameter-guides/http-request.d.ts +2 -0
  115. package/dist/prompts/node-guidance/parameter-guides/http-request.js +139 -0
  116. package/dist/prompts/node-guidance/parameter-guides/http-request.js.map +1 -0
  117. package/dist/prompts/node-guidance/parameter-guides/if-node.d.ts +2 -0
  118. package/dist/prompts/node-guidance/parameter-guides/if-node.js +159 -0
  119. package/dist/prompts/node-guidance/parameter-guides/if-node.js.map +1 -0
  120. package/dist/prompts/node-guidance/parameter-guides/index.d.ts +12 -0
  121. package/dist/prompts/node-guidance/parameter-guides/index.js +26 -0
  122. package/dist/prompts/node-guidance/parameter-guides/index.js.map +1 -0
  123. package/dist/prompts/node-guidance/parameter-guides/predecessor-output.d.ts +2 -0
  124. package/dist/prompts/node-guidance/parameter-guides/predecessor-output.js +25 -0
  125. package/dist/prompts/node-guidance/parameter-guides/predecessor-output.js.map +1 -0
  126. package/dist/prompts/node-guidance/parameter-guides/resource-locator.d.ts +2 -0
  127. package/dist/prompts/node-guidance/parameter-guides/resource-locator.js +40 -0
  128. package/dist/prompts/node-guidance/parameter-guides/resource-locator.js.map +1 -0
  129. package/dist/prompts/node-guidance/parameter-guides/set-node.d.ts +2 -0
  130. package/dist/prompts/node-guidance/parameter-guides/set-node.js +94 -0
  131. package/dist/prompts/node-guidance/parameter-guides/set-node.js.map +1 -0
  132. package/dist/prompts/node-guidance/parameter-guides/switch-node.d.ts +2 -0
  133. package/dist/prompts/node-guidance/parameter-guides/switch-node.js +75 -0
  134. package/dist/prompts/node-guidance/parameter-guides/switch-node.js.map +1 -0
  135. package/dist/prompts/node-guidance/parameter-guides/system-message.d.ts +2 -0
  136. package/dist/prompts/node-guidance/parameter-guides/system-message.js +96 -0
  137. package/dist/prompts/node-guidance/parameter-guides/system-message.js.map +1 -0
  138. package/dist/prompts/node-guidance/parameter-guides/text-fields.d.ts +2 -0
  139. package/dist/prompts/node-guidance/parameter-guides/text-fields.js +31 -0
  140. package/dist/prompts/node-guidance/parameter-guides/text-fields.js.map +1 -0
  141. package/dist/prompts/node-guidance/parameter-guides/tool-nodes.d.ts +2 -0
  142. package/dist/prompts/node-guidance/parameter-guides/tool-nodes.js +76 -0
  143. package/dist/prompts/node-guidance/parameter-guides/tool-nodes.js.map +1 -0
  144. package/dist/prompts/node-guidance/parameter-guides/types.d.ts +18 -0
  145. package/dist/prompts/node-guidance/parameter-guides/types.js +3 -0
  146. package/dist/prompts/node-guidance/parameter-guides/types.js.map +1 -0
  147. package/dist/prompts/node-selection/ai-nodes.d.ts +2 -0
  148. package/dist/prompts/node-selection/ai-nodes.js +35 -0
  149. package/dist/prompts/node-selection/ai-nodes.js.map +1 -0
  150. package/dist/prompts/node-selection/connection-parameters.d.ts +1 -0
  151. package/dist/prompts/node-selection/connection-parameters.js +13 -0
  152. package/dist/prompts/node-selection/connection-parameters.js.map +1 -0
  153. package/dist/prompts/node-selection/index.d.ts +5 -0
  154. package/dist/prompts/node-selection/index.js +16 -0
  155. package/dist/prompts/node-selection/index.js.map +1 -0
  156. package/dist/prompts/node-selection/native-preference.d.ts +1 -0
  157. package/dist/prompts/node-selection/native-preference.js +18 -0
  158. package/dist/prompts/node-selection/native-preference.js.map +1 -0
  159. package/dist/prompts/node-selection/trigger-selection.d.ts +1 -0
  160. package/dist/prompts/node-selection/trigger-selection.js +23 -0
  161. package/dist/prompts/node-selection/trigger-selection.js.map +1 -0
  162. package/dist/prompts/node-selection/use-case-patterns.d.ts +2 -0
  163. package/dist/prompts/node-selection/use-case-patterns.js +58 -0
  164. package/dist/prompts/node-selection/use-case-patterns.js.map +1 -0
  165. package/dist/prompts/sdk-reference/additional-functions.d.ts +1 -0
  166. package/dist/prompts/sdk-reference/additional-functions.js +20 -0
  167. package/dist/prompts/sdk-reference/additional-functions.js.map +1 -0
  168. package/dist/prompts/sdk-reference/expressions.d.ts +1 -0
  169. package/dist/prompts/sdk-reference/expressions.js +34 -0
  170. package/dist/prompts/sdk-reference/expressions.js.map +1 -0
  171. package/dist/prompts/sdk-reference/index.d.ts +5 -0
  172. package/dist/prompts/sdk-reference/index.js +14 -0
  173. package/dist/prompts/sdk-reference/index.js.map +1 -0
  174. package/dist/prompts/sdk-reference/workflow-patterns-detailed.d.ts +1 -0
  175. package/dist/prompts/sdk-reference/workflow-patterns-detailed.js +398 -0
  176. package/dist/prompts/sdk-reference/workflow-patterns-detailed.js.map +1 -0
  177. package/dist/prompts/sdk-reference/workflow-patterns.d.ts +2 -0
  178. package/dist/prompts/sdk-reference/workflow-patterns.js +479 -0
  179. package/dist/prompts/sdk-reference/workflow-patterns.js.map +1 -0
  180. package/dist/prompts/sdk-reference/workflow-rules.d.ts +1 -0
  181. package/dist/prompts/sdk-reference/workflow-rules.js +23 -0
  182. package/dist/prompts/sdk-reference/workflow-rules.js.map +1 -0
  183. package/dist/types/base.d.ts +8 -2
  184. package/dist/types/base.js.map +1 -1
  185. package/dist/workflow-builder/constants.d.ts +13 -0
  186. package/dist/workflow-builder/constants.js +17 -1
  187. package/dist/workflow-builder/constants.js.map +1 -1
  188. package/dist/workflow-builder/layout-utils.d.ts +7 -1
  189. package/dist/workflow-builder/layout-utils.js +452 -0
  190. package/dist/workflow-builder/layout-utils.js.map +1 -1
  191. package/dist/workflow-builder/node-builders/node-builder.d.ts +1 -1
  192. package/dist/workflow-builder/node-builders/node-builder.js +7 -3
  193. package/dist/workflow-builder/node-builders/node-builder.js.map +1 -1
  194. package/dist/workflow-builder/plugins/defaults.js +1 -0
  195. package/dist/workflow-builder/plugins/defaults.js.map +1 -1
  196. package/dist/workflow-builder/plugins/serializers/json-serializer.js +12 -1
  197. package/dist/workflow-builder/plugins/serializers/json-serializer.js.map +1 -1
  198. package/dist/workflow-builder/plugins/types.d.ts +1 -0
  199. package/dist/workflow-builder/plugins/validators/expression-prefix-validator.js +3 -0
  200. package/dist/workflow-builder/plugins/validators/expression-prefix-validator.js.map +1 -1
  201. package/dist/workflow-builder/plugins/validators/filter-node-validator.d.ts +2 -0
  202. package/dist/workflow-builder/plugins/validators/filter-node-validator.js +90 -0
  203. package/dist/workflow-builder/plugins/validators/filter-node-validator.js.map +1 -0
  204. package/dist/workflow-builder/plugins/validators/index.d.ts +1 -0
  205. package/dist/workflow-builder/plugins/validators/index.js +3 -1
  206. package/dist/workflow-builder/plugins/validators/index.js.map +1 -1
  207. package/dist/workflow-builder/workflow-import.js +1 -0
  208. package/dist/workflow-builder/workflow-import.js.map +1 -1
  209. package/dist/workflow-builder.js +2 -1
  210. package/dist/workflow-builder.js.map +1 -1
  211. package/package.json +52 -5
@@ -0,0 +1,199 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataPersistenceBestPractices = void 0;
4
+ const types_1 = require("../types");
5
+ class DataPersistenceBestPractices {
6
+ constructor() {
7
+ this.technique = types_1.WorkflowTechnique.DATA_PERSISTENCE;
8
+ this.version = '1.0.0';
9
+ this.documentation = `# Best Practices: Data Persistence
10
+
11
+ ## Overview
12
+
13
+ Data persistence involves storing, updating, or retrieving records from durable storage systems. This technique is essential when you need to maintain data beyond the lifetime of a single workflow execution, or when you need to access existing data that users have stored in their spreadsheets, tables, or databases as part of your workflow logic.
14
+
15
+ ## When to Use Data Persistence
16
+
17
+ Use data persistence when you need to:
18
+ - Store workflow results for later retrieval or audit trails
19
+ - Maintain records that multiple workflows can access and update
20
+ - Create a centralized data repository for your automation
21
+ - Archive historical data for reporting or compliance
22
+ - Build data that persists across workflow executions
23
+ - Track changes or maintain state over time
24
+ - Store raw form inputs
25
+
26
+ ## Choosing the Right Storage Node
27
+
28
+ ### Data Table (n8n-nodes-base.dataTable) - PREFERRED
29
+
30
+ **Best for:** Quick setup, small to medium amounts of data
31
+
32
+ Advantages:
33
+ - No credentials or external configuration required
34
+ - Built directly into n8n
35
+ - Fast and reliable for small to medium datasets
36
+ - Ideal for prototyping and internal workflows
37
+ - No additional costs or external dependencies
38
+
39
+ When to use:
40
+ - Internal workflow data storage
41
+ - Temporary or staging data
42
+ - Admin/audit trails
43
+ - Simple record keeping
44
+ - Development and testing
45
+
46
+ ### Google Sheets (n8n-nodes-base.googleSheets)
47
+
48
+ **Best for:** Collaboration, reporting, easy data sharing
49
+
50
+ Advantages:
51
+ - Familiar spreadsheet interface for non-technical users
52
+ - Easy to share and collaborate on data
53
+ - Built-in visualization and formula capabilities
54
+ - Good for reporting and dashboards
55
+ - Accessible from anywhere
56
+
57
+ When to use:
58
+ - Data needs to be viewed/edited by multiple people
59
+ - Non-technical users need access to data
60
+ - Integration with other Google Workspace tools
61
+ - Simple data structures without complex relationships
62
+ - Workflow needs access to existing spreadsheets in Google Sheets
63
+
64
+ Pitfalls:
65
+ - API rate limits can affect high-volume workflows
66
+ - Not suitable for frequently changing data
67
+ - Performance degrades with very large datasets (>10k rows)
68
+
69
+ ### Airtable (n8n-nodes-base.airtable)
70
+
71
+ **Best for:** Structured data with relationships, rich field types
72
+
73
+ Advantages:
74
+ - Supports relationships between tables
75
+ - Rich field types (attachments, select, links, etc.)
76
+ - Better structure than spreadsheets
77
+
78
+ When to use:
79
+ - Data has relationships or references between records
80
+ - Need structured database-like features
81
+ - Managing projects, tasks, or inventory
82
+ - Workflow needs access to existing data in Airtable
83
+
84
+ Pitfalls:
85
+ - Requires Airtable account and API key
86
+ - Schema changes require careful planning
87
+
88
+ ## Storage Patterns
89
+
90
+ ### Immediate Storage Pattern
91
+
92
+ Store data immediately after collection or generation:
93
+
94
+ \`\`\`mermaid
95
+ flowchart LR
96
+ Trigger --> Process_Data["Process Data"]
97
+ Process_Data --> Storage_Node["Storage Node"]
98
+ Storage_Node --> Continue_Workflow["Continue Workflow"]
99
+ \`\`\`
100
+
101
+ Best for: Raw data preservation, audit trails, form submissions
102
+
103
+ ### Batch Storage Pattern
104
+
105
+ Collect multiple items and store them together:
106
+
107
+ \`\`\`mermaid
108
+ flowchart LR
109
+ Trigger --> Loop_Split["Loop/Split"]
110
+ Loop_Split --> Process["Process"]
111
+ Process --> Aggregate["Aggregate"]
112
+ Aggregate --> Storage_Node["Storage Node"]
113
+ \`\`\`
114
+
115
+ Best for: Processing lists, batch operations, scheduled aggregations
116
+
117
+ ### Update Pattern
118
+
119
+ Retrieve, modify, and update existing records:
120
+
121
+ \`\`\`mermaid
122
+ flowchart LR
123
+ Trigger --> Retrieve["Retrieve from Storage"]
124
+ Retrieve --> Modify["Modify"]
125
+ Modify --> Update_Storage["Update Storage Node"]
126
+ \`\`\`
127
+
128
+ Best for: Maintaining state, updating records, tracking changes
129
+
130
+ ### Lookup Pattern
131
+
132
+ Query storage to retrieve specific records:
133
+
134
+ \`\`\`mermaid
135
+ flowchart LR
136
+ Trigger --> Query_Storage["Query Storage Node"]
137
+ Query_Storage --> Use_Data["Use Retrieved Data"]
138
+ Use_Data --> Continue_Workflow["Continue Workflow"]
139
+ \`\`\`
140
+
141
+ Best for: Enrichment, validation, conditional logic based on stored data
142
+
143
+ ## Key Considerations
144
+
145
+ ### Data Structure
146
+
147
+ - **Plan your schema ahead:** Define what fields you need before creating storage
148
+ - **Use consistent field names:** Match field names across your workflow for easy mapping
149
+ - **Consider data types:** Ensure your storage supports the data types you need
150
+ - **Think about relationships:** If data is related, consider Airtable or use multiple tables
151
+
152
+ ### Performance
153
+
154
+ - **Batch operations when possible:** Multiple small writes are slower than batch operations
155
+ - **Use appropriate operations:** Use "append" for new records, "update" for modifications
156
+ - **Consider API limits:** Google Sheets has rate limits; plan accordingly for high-volume workflows
157
+
158
+ ### Data Integrity
159
+
160
+ - **Store raw data first:** Keep unmodified input before transformations
161
+ - **Handle errors gracefully:** Use error handling to prevent data loss on failures
162
+ - **Validate before storing:** Ensure data quality before persistence
163
+ - **Avoid duplicates:** Use unique identifiers or upsert operations when appropriate
164
+
165
+ ## Referencing Documents, Sheets, or Tables
166
+
167
+ When configuring storage nodes, use ResourceLocator mode "list". This will allow users to select from existing documents, sheets, or tables rather than passing IDs dynamically.
168
+ Use modes "id", "url" or "name" only when user specifically mentions it in their prompt.
169
+
170
+ ## Important Distinctions
171
+
172
+ ### Storage vs. Transformation
173
+
174
+ - **Set/Merge nodes are NOT storage:** They transform data in memory only
175
+ - **Storage happens explicitly:** Data won't persist unless you explicitly write it to storage
176
+
177
+ ### Temporary vs. Persistent Storage
178
+
179
+ - **NOT covered by this technique:** Redis, caching, session storage, in-memory operations
180
+ - **This technique covers:** Durable storage that persists beyond workflow execution
181
+ - **Focus on permanence:** Use these nodes when you need data to survive restarts and be queryable later
182
+
183
+ ## Common Pitfalls to Avoid
184
+
185
+ ### Not Handling Duplicates
186
+
187
+ Without proper unique identifiers or upsert logic, you may create duplicate records. Use unique IDs or check for existing records before inserting.
188
+
189
+ ### Ignoring Storage Limits
190
+
191
+ Each storage system has limits (row counts, API rates, file sizes). Design your workflow to work within these constraints or implement pagination/batching.
192
+ `;
193
+ }
194
+ getDocumentation() {
195
+ return this.documentation;
196
+ }
197
+ }
198
+ exports.DataPersistenceBestPractices = DataPersistenceBestPractices;
199
+ //# sourceMappingURL=data-persistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-persistence.js","sourceRoot":"","sources":["../../../../src/prompts/best-practices/guides/data-persistence.ts"],"names":[],"mappings":";;;AACA,oCAA6C;AAE7C,MAAa,4BAA4B;IAAzC;QACU,cAAS,GAAG,yBAAiB,CAAC,gBAAgB,CAAC;QAC/C,YAAO,GAAG,OAAO,CAAC;QAEV,kBAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuLjC,CAAC;IAKF,CAAC;IAHA,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AAhMD,oEAgMC"}
@@ -0,0 +1,7 @@
1
+ import type { BestPracticesDocument } from '../types';
2
+ export declare class DataTransformationBestPractices implements BestPracticesDocument {
3
+ readonly technique: "data_transformation";
4
+ readonly version = "1.0.0";
5
+ private readonly documentation;
6
+ getDocumentation(): string;
7
+ }
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataTransformationBestPractices = void 0;
4
+ const types_1 = require("../types");
5
+ class DataTransformationBestPractices {
6
+ constructor() {
7
+ this.technique = types_1.WorkflowTechnique.DATA_TRANSFORMATION;
8
+ this.version = '1.0.0';
9
+ this.documentation = `# Best Practices: Data Transformation
10
+
11
+ ## Workflow Design
12
+
13
+ ### Core Principles
14
+ - **Structure**: Always follow Input → Transform → Output pattern
15
+ - **Optimization**: Filter and reduce data early to improve performance
16
+
17
+ ### Design Best Practices
18
+ - Plan transformation requirements in plain language before building
19
+ - Use Modular Design: Create reusable sub-workflows for common tasks like "Data Cleaning" or "Error Handler"
20
+ - Batch datasets over 100 items using Split In Batches node to prevent timeouts
21
+
22
+ ## Recommended Nodes
23
+
24
+ ### Essential Transformation Nodes
25
+
26
+ #### Edit Fields (Set) (n8n-nodes-base.set)
27
+
28
+ **Purpose**: Create, modify, rename fields; change data types
29
+
30
+ **Key Setting**: "Keep Only Set" - drops all fields not explicitly defined (default: disabled)
31
+
32
+ **Use Cases**:
33
+ - Extract specific columns
34
+ - Add calculated fields
35
+ - Convert data types (string to number)
36
+ - Format dates using expressions
37
+
38
+ **Pitfalls**:
39
+ - Not understanding "Keep Only Set" behavior can lead to data loss
40
+ - Enabled: Drops all fields not explicitly defined (data loss risk)
41
+ - Disabled: Carries forward all fields (potential bloat)
42
+ - Always verify output structure after configuration
43
+
44
+ **Testing tip**: When transforming data from a workflow trigger, you can set values with a fallback default e.g. set name to {{$json.name || 'Jane Doe'}} to help test the workflow.
45
+
46
+ #### IF/Filter Nodes
47
+
48
+ **IF Node** (n8n-nodes-base.if):
49
+ - **Purpose**: Conditional processing and routing
50
+ - **Best Practice**: Use early to validate inputs and remove bad data
51
+ - **Example**: Check if required fields exist before processing
52
+
53
+ **Filter Node** (n8n-nodes-base.filter):
54
+ - **Purpose**: Filter items based on conditions
55
+ - **Best Practice**: Use early in workflow to reduce data volume
56
+
57
+ #### Merge Node (n8n-nodes-base.merge)
58
+
59
+ **Purpose**: Combine two data streams
60
+
61
+ **Modes**:
62
+ - Merge by Key (like database join)
63
+ - Merge by Index
64
+ - Append
65
+
66
+ **Pitfalls**:
67
+ - **Missing Keys**: Trying to merge on non-existent fields
68
+ - **Field Name Mismatch**: Different field names in sources
69
+ - **Solution**: Use Edit Fields node to normalize field names before merging
70
+
71
+ #### Code Node (n8n-nodes-base.code)
72
+
73
+ **Execution Modes**:
74
+ - "Run Once per Item": Process each item independently
75
+ - "Run Once for All Items": Access entire dataset (for aggregation)
76
+
77
+ **Return Format**: Must return array of objects with json property
78
+ \`\`\`javascript
79
+ return items; // or return [{ json: {...} }];
80
+ \`\`\`
81
+
82
+ **Pitfalls**:
83
+ - Wrong return format: Not returning array of objects with json property
84
+ - Overly complex: Stuffing entire workflow logic in one Code node
85
+ - Keep code nodes focused on single transformation aspect
86
+
87
+ #### Summarize Node (n8n-nodes-base.summarize)
88
+
89
+ **Purpose**: Pivot table-style aggregations (count, sum, average, min/max)
90
+
91
+ **Configuration**:
92
+ - Fields to Summarize: Choose aggregation function
93
+ - Fields to Split By: Grouping keys
94
+
95
+ **Output**: Single item with summary or multiple items per group
96
+
97
+ ### Data Restructuring Nodes
98
+
99
+ - **Split Out** (n8n-nodes-base.splitOut): Convert single item with array into multiple items
100
+ - **Aggregate** (n8n-nodes-base.aggregate): Combine multiple items into one
101
+ - **Remove Duplicates** (n8n-nodes-base.removeDuplicates): Delete duplicate items based on field criteria
102
+ - **Sort** (n8n-nodes-base.sort): Order items alphabetically/numerically
103
+ - **Limit** (n8n-nodes-base.limit): Trim to maximum number of items
104
+
105
+ ### Batch Processing
106
+
107
+ **Split In Batches** (n8n-nodes-base.splitInBatches):
108
+ - **Purpose**: Process large datasets in chunks
109
+ - **Use When**: Handling 100+ items with expensive operations (API calls, AI)
110
+
111
+ ## Input Data Validation
112
+ - Validate external data before processing: check for nulls, empty values, and edge cases (special chars, empty arrays)
113
+
114
+ ## Common Pitfalls to Avoid
115
+
116
+ ### Critical Mistakes
117
+
118
+ #### Edit Fields Node Issues
119
+ - **Mistake**: Not understanding "Keep Only Set" behavior
120
+ - Enabled: Drops all fields not explicitly defined (data loss risk)
121
+ - Disabled: Carries forward all fields (potential bloat)
122
+ - **Solution**: Always verify output structure after configuration
123
+
124
+ #### Code Node Errors
125
+ - **Wrong Return Format**: Not returning array of objects with json property
126
+ - **Fix**: Always return \`items\` or \`[{ json: {...} }]\`
127
+ - **Overly Complex**: Stuffing entire workflow logic in one Code node
128
+ - **Fix**: Keep code nodes focused on single transformation aspect
129
+
130
+ #### Merge Node Problems
131
+ - **Field Name Mismatch**: Different field names in sources
132
+ - **Fix**: Normalize field names with Edit Fields before merging
133
+
134
+ ### Performance Pitfalls
135
+ - Processing large datasets without batching → timeouts
136
+ - Not filtering early → unnecessary processing overhead
137
+ - Excessive node chaining → visual clutter and slow execution
138
+
139
+ ### Data Validation Pitfalls
140
+ - Assuming input data is always perfect → runtime errors
141
+ `;
142
+ }
143
+ getDocumentation() {
144
+ return this.documentation;
145
+ }
146
+ }
147
+ exports.DataTransformationBestPractices = DataTransformationBestPractices;
148
+ //# sourceMappingURL=data-transformation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-transformation.js","sourceRoot":"","sources":["../../../../src/prompts/best-practices/guides/data-transformation.ts"],"names":[],"mappings":";;;AACA,oCAA6C;AAE7C,MAAa,+BAA+B;IAA5C;QACU,cAAS,GAAG,yBAAiB,CAAC,mBAAmB,CAAC;QAClD,YAAO,GAAG,OAAO,CAAC;QAEV,kBAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoIjC,CAAC;IAKF,CAAC;IAHA,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AA7ID,0EA6IC"}
@@ -0,0 +1,7 @@
1
+ import type { BestPracticesDocument } from '../types';
2
+ export declare class DocumentProcessingBestPractices implements BestPracticesDocument {
3
+ readonly technique: "document_processing";
4
+ readonly version = "1.0.0";
5
+ private readonly documentation;
6
+ getDocumentation(): string;
7
+ }