Skip to content

Commit 84abcb8

Browse files
committed
update prompt
1 parent 733b425 commit 84abcb8

File tree

1 file changed

+169
-84
lines changed

1 file changed

+169
-84
lines changed
Lines changed: 169 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
1-
# Prompt for Generating n8n SearchApi Engines from OpenAPI Specs
1+
# Generate n8n SearchApi Engine Command
22

3+
## Overview
34
You are an expert n8n node developer tasked with generating SearchApi engine files from OpenAPI specifications. Your goal is to create TypeScript files that properly integrate with the n8n SearchApi node framework.
45

5-
## Input Requirements
6-
You will be provided with:
7-
1. An OpenAPI 3.0 specification (YAML or JSON format)
8-
2. The target engine name/endpoint to generate
6+
**⚠️ CRITICAL REQUIREMENT**: You MUST run lint checks on the generated file before completing this task. The file MUST pass all lint checks.
97

10-
## Output Requirements
11-
Generate a TypeScript file following this exact structure:
8+
---
129

10+
## Task Workflow
11+
12+
### 1. Input Analysis
13+
You will receive:
14+
- An OpenAPI 3.0 specification (YAML or JSON format)
15+
- The target engine name/endpoint to generate
16+
- Look for .yaml files to get the openapi specs for the engine
17+
18+
### 2. Behavior Rules
19+
- **If engine doesn't exist**: Create it from scratch
20+
- **If engine already exists**: Act as a reviewer and ensure the code follows all guidelines
21+
22+
### 3. Final Validation (MANDATORY)
23+
1. Run `pnpm lint` to check for any linting errors
24+
2. If there are errors, run `pnpm lintfix` to automatically fix what can be fixed
25+
3. Manually fix any remaining errors that couldn't be auto-fixed
26+
4. Ensure the file passes all lint checks before completing the task
27+
28+
**DO NOT stop until the engine file passes all lint checks.**
29+
30+
---
31+
32+
## Code Structure Requirements
33+
34+
### TypeScript File Template
1335
```typescript
1436
import { INodeProperties, INodePropertyOptions } from 'n8n-workflow';
1537

@@ -34,39 +56,13 @@ export const {engine_name} = {
3456
};
3557
```
3658

37-
## How to behave
38-
39-
If the engine does not exists yet, you must create it.
40-
41-
If it already exists, you must act as a reviewer and make sure the generated code is correct and follows the guidelines.
42-
43-
## Parameter Mapping Guidelines
44-
45-
### 1. Field Type Mapping
46-
- OpenAPI `string` → n8n `'string'`
47-
- OpenAPI `integer`/`number` → n8n `'string'` (for API compatibility)
48-
- OpenAPI `boolean` → n8n `'boolean'`
49-
- OpenAPI `string` with `enum` → n8n `'options'`
50-
- OpenAPI `array` → n8n `'multiOptions'` (if applicable)
51-
52-
### 2. Display Name Rules
53-
- Always use the OpenAPI `x-display-name` if available
54-
- If no `x-display-name`, convert parameter name to human-readable format:
55-
- `q``'Query'`
56-
- `api_key``'API Key'`
57-
- `time_period``'Time Period'`
58-
- `num``'Results Per Page'`
59-
- `safe_search``'Safe Search'`
60-
- Use proper capitalization and spacing
61-
62-
### 3. Property Structure
63-
Each parameter must follow this structure:
59+
### Property Structure Template
6460
```typescript
6561
{
6662
displayName: 'Human Readable Name',
6763
name: 'parameter_name',
6864
type: 'string' | 'options' | 'boolean' | 'multiOptions',
69-
required: false, // true if the value is required, false if not
65+
required: false, // true if the value is required, false if not
7066
default: 'default_value',
7167
description: 'Clear, helpful description from OpenAPI',
7268
options: [], // For non-options types, empty array
@@ -81,46 +77,69 @@ Each parameter must follow this structure:
8177
}
8278
```
8379

84-
### 4. Options Array Rules
80+
---
81+
82+
## Parameter Mapping Rules
83+
84+
### Type Mappings
85+
| OpenAPI Type | n8n Type | Notes |
86+
|--------------|----------|-------|
87+
| `string` | `'string'` | Basic text input |
88+
| `integer` | `'string'` | For API compatibility |
89+
| `number` | `'string'` | For API compatibility |
90+
| `boolean` | `'boolean'` | Checkbox input |
91+
| `string` with `enum` | `'options'` | Dropdown selection |
92+
| `array` | `'multiOptions'` | If applicable |
8593

94+
### Display Name Conventions
95+
- **Priority**: Use OpenAPI `x-display-name` if available
96+
- **Fallback**: Convert parameter names to human-readable format
97+
98+
Common conversions:
99+
- `q``'Query'`
100+
- `api_key``'API Key'`
101+
- `time_period``'Time Period'`
102+
- `num``'Results Per Page'`
103+
- `safe_search``'Safe Search'`
104+
- `video_id``'Video ID'`
105+
- Always use proper capitalization and spacing
86106

87-
- For enum parameters, create options with proper capitalization:
107+
### Engine Naming Rules
108+
- **Value**: Use snake_case (e.g., `google_search`, `bing_news`, `youtube_transcripts`)
109+
- **Display Name**: Use Title Case (e.g., `Google Search`, `Bing News`, `YouTube Transcripts`)
110+
- Must match the OpenAPI operationId or endpoint purpose
111+
112+
---
113+
114+
## Special Parameter Handling
115+
116+
### Excluded Parameters
117+
Skip these parameters (handled by node framework):
118+
- `api_key`
119+
- `engine`
120+
121+
### Required vs Optional Parameters
122+
- Mark truly required parameters with `required: true`
123+
- Use reasonable defaults for optional parameters
124+
- Optional parameters should have sensible `default` values
125+
126+
### Options/Enum Parameters
88127
```typescript
89128
options: [
90129
{ name: 'Desktop', value: 'desktop' },
91130
{ name: 'Mobile', value: 'mobile' },
92131
{ name: 'Tablet', value: 'tablet' },
93132
]
94133
```
95-
- The options must be correctly sorted in alphabetic order
96-
- And the names must always be human readable
134+
Requirements:
135+
- Options must be sorted alphabetically by name
136+
- Names must be human-readable with proper capitalization
137+
- Values should match the API's expected format
97138

98-
### 5. Required Parameters
99-
- Skip `api_key` and `engine` parameters (handled by node framework)
100-
- Mark truly required parameters appropriately
101-
- Use reasonable defaults for optional parameters
139+
### Parameter Grouping
140+
Use collections to group related parameters:
102141

103-
### 6. Description Guidelines
104-
- Use the OpenAPI description as-is but ensure it's clear and helpful
105-
- Add context about parameter usage when beneficial
106-
- Include examples or format specifications when provided in OpenAPI
107-
- Maintain markdown formatting for better readability
108-
109-
### 7. Special Parameter Handling
110-
- **Location/Geographic**: Use appropriate defaults and clear descriptions
111-
- **Language/Locale**: Provide comprehensive option lists with proper names
112-
- **Pagination**: Default to reasonable values (`page: '1'`, `num: '10'`)
113-
- **Date/Time**: Include format specifications and validation hints
114-
- **Enum Arrays**: Convert to proper option arrays with human-readable names
115-
116-
### 8. Property Grouping
117-
- **Collection Type**: Use `'collection'` type to group optional parameters that users can choose to add
118-
- **Fixed Collection Type**: Use `'fixedCollection'` type to group semantically related parameters
119-
- Group related parameters by category (e.g., "Search Options", "Pagination", "Location Settings", "Date Filters")
120-
- Use meaningful group names that describe the parameter category
121-
- Parameters within the same logical group should use the same `displayOptions` conditions
122-
123-
Example collection structure:
142+
#### Collection Type (for optional parameter groups)
124143
```typescript
125144
{
126145
displayName: 'Search Options',
@@ -135,30 +154,82 @@ Example collection structure:
135154
}
136155
```
137156

138-
### 9. Engine Name Conventions
139-
- Use snake_case for the engine value (e.g., `google_search`, `bing_news`)
140-
- Use Title Case for the display name (e.g., `Google Search`, `Bing News`)
141-
- Ensure the engine name matches the OpenAPI operationId or endpoint purpose
157+
#### Fixed Collection Type (for required parameter groups)
158+
```typescript
159+
{
160+
displayName: 'Required Settings',
161+
name: 'requiredSettings',
162+
type: 'fixedCollection',
163+
default: {},
164+
options: [
165+
// Related parameters go here
166+
],
167+
displayOptions,
168+
}
169+
```
170+
171+
Group categories examples:
172+
- "Search Options"
173+
- "Pagination"
174+
- "Location Settings"
175+
- "Date Filters"
176+
- "Transcript Options"
177+
- "Advanced Settings"
178+
179+
---
180+
181+
## Content Guidelines
182+
183+
### Descriptions
184+
- Use the OpenAPI description as-is when clear and helpful
185+
- Add context about parameter usage when beneficial
186+
- Include format specifications when provided
187+
- Maintain markdown formatting for readability
188+
- End descriptions with periods for consistency
189+
190+
### Default Values
191+
Common defaults by type:
192+
- Pagination: `page: '1'`, `num: '10'`
193+
- Language: `'en'`
194+
- Boolean flags: `false`
195+
- Location: Appropriate regional defaults
196+
197+
---
142198

143199
## Quality Checklist
144-
Before finalizing, ensure:
145-
- [ ] All parameter names are human-readable
146-
- [ ] All enum options are properly capitalized
147-
- [ ] Default values are sensible and useful
148-
- [ ] Descriptions are clear and informative
200+
201+
Before finalizing, verify:
202+
203+
### Code Quality
149204
- [ ] TypeScript syntax is correct
150205
- [ ] Import statements are included
151206
- [ ] Export structure matches the pattern
152-
- [ ] Required parameters are properly handled
207+
- [ ] No TypeScript errors
208+
209+
### Parameter Quality
210+
- [ ] All parameter names are human-readable
211+
- [ ] All enum options are properly capitalized and sorted
212+
- [ ] Default values are sensible and useful
213+
- [ ] Descriptions are clear and informative
214+
- [ ] Required parameters are properly marked
153215
- [ ] Optional parameters have appropriate defaults
154-
- [ ] No API keys or sensitive parameters are exposed
155-
- [ ] Related parameters are grouped using collection or fixedCollection types
216+
217+
### Structure Quality
218+
- [ ] Related parameters are grouped using collections
156219
- [ ] Group names are meaningful and descriptive
157-
- [ ] Parameters within the same group have consistent displayOptions
158-
- [ ] Run "pnpm lintfix" and fix all errors it does not fix automatically
220+
- [ ] Parameters within groups have consistent displayOptions
221+
- [ ] No API keys or sensitive parameters are exposed
222+
223+
### Linting (MANDATORY)
224+
- [ ] Run `pnpm lint` - no errors
225+
- [ ] Run `pnpm lintfix` if needed
226+
- [ ] All lint errors resolved
227+
228+
---
159229

160230
## Example Transformation
161-
Given an OpenAPI parameter like:
231+
232+
### OpenAPI Input:
162233
```yaml
163234
device:
164235
name: device
@@ -172,7 +243,7 @@ device:
172243
x-display-name: "Device Type"
173244
```
174245
175-
Transform to:
246+
### n8n Output:
176247
```typescript
177248
{
178249
displayName: 'Device Type',
@@ -196,12 +267,26 @@ Transform to:
196267
}
197268
```
198269

270+
---
271+
272+
## Completion Criteria
273+
274+
The task is **ONLY** complete when:
275+
276+
1. ✅ The engine file has been generated or reviewed
277+
2.`pnpm lint` has been run on the file
278+
3. ✅ All linting errors have been fixed
279+
4. ✅ The file passes all lint checks without errors
280+
281+
**🛑 STOP**: Do NOT mark this task as complete until the lint check passes!
282+
283+
---
284+
199285
## Additional Notes
200-
- Always prioritize user experience with clear, intuitive parameter names
286+
287+
- Prioritize user experience with clear, intuitive parameter names
201288
- Follow n8n's established patterns for consistency
202289
- Test the generated code for TypeScript compatibility
203290
- Consider parameter interdependencies and validation
204291
- Ensure the generated engine integrates seamlessly with the SearchApi node framework
205-
- Look for .yaml files to get the openapi specs for the engine
206-
207-
Generate the complete TypeScript engine file following these guidelines exactly.
292+
- To save tokens, when reading the yaml files, you can read everything that is inside the "parameters" key, and everything that is inside the "request" key. As it is the only thing that is needed to generate the engine.

0 commit comments

Comments
 (0)