faf-cli 2.5.4 → 3.0.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/README.md +433 -246
- package/assets/AI-Context /342/232/241/357/270/217 FASF AF.png +0 -0
- package/assets/Orange-Smiley copy.png +0 -0
- package/assets/Project-DNA-for-ANY-AI-1200x630.png +0 -0
- package/assets/ai-human-balance-50-50.png +0 -0
- package/assets/prd-balance-perfect-green.png +0 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +14 -4
- package/dist/cli.js.map +1 -1
- package/dist/commands/ai-analyze.js +2 -35
- package/dist/commands/ai-analyze.js.map +1 -1
- package/dist/commands/ai-enhance.d.ts.map +1 -1
- package/dist/commands/ai-enhance.js +5 -40
- package/dist/commands/ai-enhance.js.map +1 -1
- package/dist/commands/audit.js +2 -35
- package/dist/commands/audit.js.map +1 -1
- package/dist/commands/bi-sync.d.ts +1 -1
- package/dist/commands/bi-sync.js +5 -5
- package/dist/commands/bi-sync.js.map +1 -1
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +11 -2
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/create.d.ts +13 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +78 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/edit.js +6 -6
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/enhance-real.js +13 -3
- package/dist/commands/enhance-real.js.map +1 -1
- package/dist/commands/faf-recover.js +3 -3
- package/dist/commands/faf-recover.js.map +1 -1
- package/dist/commands/init.js +3 -36
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/lint.js +4 -37
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/search.js +2 -2
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/share.js +3 -3
- package/dist/commands/share.js.map +1 -1
- package/dist/commands/show.d.ts.map +1 -1
- package/dist/commands/show.js +3 -39
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/sync.js +4 -37
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/todo.js +2 -2
- package/dist/commands/todo.js.map +1 -1
- package/dist/commands/trust.d.ts +1 -1
- package/dist/commands/trust.js +3 -3
- package/dist/commands/trust.js.map +1 -1
- package/dist/commands/validate.js +2 -35
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/verify.js +2 -2
- package/dist/commands/verify.js.map +1 -1
- package/dist/compiler/faf-compiler.js +2 -2
- package/dist/compiler/faf-compiler.js.map +1 -1
- package/dist/converters/faf-converters.js +3 -3
- package/dist/converters/faf-converters.js.map +1 -1
- package/dist/engines/c-mirror/core/claude-to-faf.js +2 -35
- package/dist/engines/c-mirror/core/claude-to-faf.js.map +1 -1
- package/dist/engines/c-mirror/core/faf-to-claude.js +2 -35
- package/dist/engines/c-mirror/core/faf-to-claude.js.map +1 -1
- package/dist/engines/c-mirror/core/mirror-engine.js +3 -3
- package/dist/engines/c-mirror/core/mirror-engine.js.map +1 -1
- package/dist/engines/c-mirror/strategies/atomic-write.d.ts +3 -3
- package/dist/engines/c-mirror/strategies/atomic-write.js +4 -4
- package/dist/engines/c-mirror/strategies/atomic-write.js.map +1 -1
- package/dist/enrichment/auto-corrector.d.ts +28 -0
- package/dist/enrichment/auto-corrector.d.ts.map +1 -0
- package/dist/enrichment/auto-corrector.js +106 -0
- package/dist/enrichment/auto-corrector.js.map +1 -0
- package/dist/enrichment/n8n-analyzer.d.ts +259 -0
- package/dist/enrichment/n8n-analyzer.d.ts.map +1 -0
- package/dist/enrichment/n8n-analyzer.js +346 -0
- package/dist/enrichment/n8n-analyzer.js.map +1 -0
- package/dist/enrichment/n8n-faf-generator.d.ts +68 -0
- package/dist/enrichment/n8n-faf-generator.d.ts.map +1 -0
- package/dist/enrichment/n8n-faf-generator.js +354 -0
- package/dist/enrichment/n8n-faf-generator.js.map +1 -0
- package/dist/enrichment/question-asker.d.ts +22 -0
- package/dist/enrichment/question-asker.d.ts.map +1 -0
- package/dist/enrichment/question-asker.js +113 -0
- package/dist/enrichment/question-asker.js.map +1 -0
- package/dist/enrichment/slot-filler.d.ts +73 -0
- package/dist/enrichment/slot-filler.d.ts.map +1 -0
- package/dist/enrichment/slot-filler.js +253 -0
- package/dist/enrichment/slot-filler.js.map +1 -0
- package/dist/fix-once/yaml.d.ts +39 -36
- package/dist/fix-once/yaml.d.ts.map +1 -1
- package/dist/fix-once/yaml.js +117 -39
- package/dist/fix-once/yaml.js.map +1 -1
- package/dist/generators/faf-generator-championship.d.ts.map +1 -1
- package/dist/generators/faf-generator-championship.js +73 -3
- package/dist/generators/faf-generator-championship.js.map +1 -1
- package/dist/utils/announcements.d.ts.map +1 -1
- package/dist/utils/announcements.js +0 -5
- package/dist/utils/announcements.js.map +1 -1
- package/dist/utils/championship-style.js +1 -1
- package/dist/utils/championship-style.js.map +1 -1
- package/dist/utils/chrome-extension-confirmer.d.ts.map +1 -1
- package/dist/utils/chrome-extension-confirmer.js +15 -0
- package/dist/utils/chrome-extension-confirmer.js.map +1 -1
- package/dist/utils/email-opt-in.d.ts.map +1 -1
- package/dist/utils/email-opt-in.js +4 -2
- package/dist/utils/email-opt-in.js.map +1 -1
- package/dist/utils/file-utils.d.ts.map +1 -1
- package/dist/utils/file-utils.js +12 -0
- package/dist/utils/file-utils.js.map +1 -1
- package/dist/utils/vibe-sync.d.ts.map +1 -1
- package/dist/utils/vibe-sync.js +2 -1
- package/dist/utils/vibe-sync.js.map +1 -1
- package/package.json +13 -14
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 🏎️ Slot Filler - The 6 W's Intelligence
|
|
4
|
+
*
|
|
5
|
+
* Takes messy natural language and fills structured context slots
|
|
6
|
+
* This is where POOR data becomes RICH data
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SlotFiller = void 0;
|
|
10
|
+
class SlotFiller {
|
|
11
|
+
/**
|
|
12
|
+
* Fill all 6 W's from user input + workflow analysis
|
|
13
|
+
*/
|
|
14
|
+
fill6Ws(useCase, other, workflow, pattern, aiModels, infrastructure) {
|
|
15
|
+
// Parse the use case into components
|
|
16
|
+
const parsed = this.parseIntent(useCase, other);
|
|
17
|
+
return {
|
|
18
|
+
who: this.fillWho(parsed, other),
|
|
19
|
+
what: this.fillWhat(parsed, pattern),
|
|
20
|
+
why: this.fillWhy(parsed),
|
|
21
|
+
where: this.fillWhere(workflow),
|
|
22
|
+
when: this.fillWhen(workflow),
|
|
23
|
+
how: this.fillHow(aiModels, infrastructure, pattern)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse natural language into intent components
|
|
28
|
+
*/
|
|
29
|
+
parseIntent(useCase, other) {
|
|
30
|
+
const text = useCase.toLowerCase();
|
|
31
|
+
return {
|
|
32
|
+
subject: this.extractSubject(useCase),
|
|
33
|
+
audience: this.extractAudience(useCase, other),
|
|
34
|
+
goal: this.extractGoal(text),
|
|
35
|
+
context: other ? other.split(/[,;]/).map(s => s.trim()).filter(Boolean) : [],
|
|
36
|
+
keywords: this.extractKeywords(text)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Extract subject (what system/framework is this about?)
|
|
41
|
+
*/
|
|
42
|
+
extractSubject(text) {
|
|
43
|
+
// Look for proper nouns, product names, frameworks
|
|
44
|
+
const patterns = [
|
|
45
|
+
/(\w+(?:'s)?\s+\$?\d+[MKB]?\s+\w+)/i, // "Hormozi's $100M Sales"
|
|
46
|
+
/(\w+\s+\w+\s+(?:system|framework|model|strategy))/i, // "Money Models system"
|
|
47
|
+
/(RAG|ETL|API)\s+(?:system|framework|workflow)/i // "RAG system"
|
|
48
|
+
];
|
|
49
|
+
for (const pattern of patterns) {
|
|
50
|
+
const match = text.match(pattern);
|
|
51
|
+
if (match) {
|
|
52
|
+
return match[1].trim();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Fallback: capitalize first few words
|
|
56
|
+
const words = text.split(' ').slice(0, 3);
|
|
57
|
+
return words.map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Extract audience (who is this for?)
|
|
61
|
+
*/
|
|
62
|
+
extractAudience(useCase, other) {
|
|
63
|
+
const text = useCase.toLowerCase();
|
|
64
|
+
const audience = [];
|
|
65
|
+
// Look for "for X" or "help X"
|
|
66
|
+
const forMatch = text.match(/for\s+([^,\.]+)/i);
|
|
67
|
+
if (forMatch) {
|
|
68
|
+
audience.push(forMatch[1].trim());
|
|
69
|
+
}
|
|
70
|
+
const helpMatch = text.match(/help\s+([^,\.]+)/i);
|
|
71
|
+
if (helpMatch && !helpMatch[1].includes('get') && !helpMatch[1].includes('with')) {
|
|
72
|
+
audience.push(helpMatch[1].trim());
|
|
73
|
+
}
|
|
74
|
+
// Check Q3 for audience specificity
|
|
75
|
+
if (other) {
|
|
76
|
+
const otherLower = other.toLowerCase();
|
|
77
|
+
if (otherLower.match(/only for|just for|specifically for|for my/i)) {
|
|
78
|
+
const specificMatch = other.match(/(?:only|just|specifically|for my)\s+(?:for\s+)?([^,\.]+)/i);
|
|
79
|
+
if (specificMatch) {
|
|
80
|
+
audience.push(specificMatch[1].trim());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return [...new Set(audience)]; // Dedupe
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Extract goal (why does this exist?)
|
|
88
|
+
*/
|
|
89
|
+
extractGoal(text) {
|
|
90
|
+
// Look for verbs indicating purpose
|
|
91
|
+
const goalPatterns = [
|
|
92
|
+
/to\s+([^,\.]+)/i,
|
|
93
|
+
/help\s+(?:people|users|them|clients)?\s*(?:to\s+)?([^,\.]+)/i,
|
|
94
|
+
/(?:provide|enable|allow|give)\s+([^,\.]+)/i,
|
|
95
|
+
/(?:get|achieve|reach)\s+([^,\.]+)/i
|
|
96
|
+
];
|
|
97
|
+
for (const pattern of goalPatterns) {
|
|
98
|
+
const match = text.match(pattern);
|
|
99
|
+
if (match && match[1]) {
|
|
100
|
+
return match[1].trim();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Fallback: look for action verbs
|
|
104
|
+
const actionMatch = text.match(/(automat\w+|process\w+|send\w+|fetch\w+|generat\w+)\s+([^,\.]+)/i);
|
|
105
|
+
if (actionMatch) {
|
|
106
|
+
return `${actionMatch[1]} ${actionMatch[2]}`.trim();
|
|
107
|
+
}
|
|
108
|
+
return 'solve user problems'; // Ultimate fallback
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Extract keywords for search
|
|
112
|
+
*/
|
|
113
|
+
extractKeywords(text) {
|
|
114
|
+
// Simple keyword extraction (stopwords filtered)
|
|
115
|
+
const stopwords = new Set([
|
|
116
|
+
'the', 'a', 'an', 'to', 'for', 'of', 'and', 'or', 'in', 'on', 'is', 'are',
|
|
117
|
+
'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'do', 'does',
|
|
118
|
+
'did', 'will', 'would', 'should', 'could', 'may', 'might', 'must', 'can',
|
|
119
|
+
'this', 'that', 'these', 'those', 'i', 'you', 'he', 'she', 'it', 'we', 'they'
|
|
120
|
+
]);
|
|
121
|
+
return text
|
|
122
|
+
.toLowerCase()
|
|
123
|
+
.replace(/[^\w\s]/g, ' ') // Remove punctuation
|
|
124
|
+
.split(/\s+/)
|
|
125
|
+
.filter(word => word.length > 3 && !stopwords.has(word))
|
|
126
|
+
.slice(0, 10);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Fill WHO slot
|
|
130
|
+
*/
|
|
131
|
+
fillWho(parsed, other) {
|
|
132
|
+
if (parsed.audience.length > 0) {
|
|
133
|
+
const primary = parsed.audience[0];
|
|
134
|
+
// Enhance with subject if available
|
|
135
|
+
if (parsed.subject && parsed.subject.length > 3) {
|
|
136
|
+
return `${primary} learning ${parsed.subject}`;
|
|
137
|
+
}
|
|
138
|
+
return primary;
|
|
139
|
+
}
|
|
140
|
+
// Check Q3 for implicit audience
|
|
141
|
+
if (other.toLowerCase().includes('my')) {
|
|
142
|
+
return 'internal team';
|
|
143
|
+
}
|
|
144
|
+
return 'users'; // Fallback
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Fill WHAT slot (infer from pattern + subject)
|
|
148
|
+
*/
|
|
149
|
+
fillWhat(parsed, pattern) {
|
|
150
|
+
let what = '';
|
|
151
|
+
// Add pattern prefix
|
|
152
|
+
if (pattern !== 'Unknown') {
|
|
153
|
+
what = `${pattern}-powered `;
|
|
154
|
+
}
|
|
155
|
+
// Add subject
|
|
156
|
+
if (parsed.subject && parsed.subject.length > 3) {
|
|
157
|
+
what += `${parsed.subject} system`;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
what += 'automation workflow';
|
|
161
|
+
}
|
|
162
|
+
return what.trim();
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Fill WHY slot
|
|
166
|
+
*/
|
|
167
|
+
fillWhy(parsed) {
|
|
168
|
+
return parsed.goal || 'automate processes';
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Fill WHERE slot (infer from workflow structure)
|
|
172
|
+
*/
|
|
173
|
+
fillWhere(workflow) {
|
|
174
|
+
// Check for webhook triggers
|
|
175
|
+
const hasWebhook = workflow.nodes.some(n => n.type.toLowerCase().includes('webhook'));
|
|
176
|
+
if (hasWebhook) {
|
|
177
|
+
return 'accessible via webhook API';
|
|
178
|
+
}
|
|
179
|
+
// Check for form triggers
|
|
180
|
+
const hasForm = workflow.nodes.some(n => n.type.toLowerCase().includes('form'));
|
|
181
|
+
if (hasForm) {
|
|
182
|
+
return 'web form interface';
|
|
183
|
+
}
|
|
184
|
+
// Check for schedule triggers
|
|
185
|
+
const hasSchedule = workflow.nodes.some(n => n.type.toLowerCase().includes('schedule') ||
|
|
186
|
+
n.type.toLowerCase().includes('cron'));
|
|
187
|
+
if (hasSchedule) {
|
|
188
|
+
return 'scheduled execution';
|
|
189
|
+
}
|
|
190
|
+
return 'n8n workflow environment';
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Fill WHEN slot (infer from triggers)
|
|
194
|
+
*/
|
|
195
|
+
fillWhen(workflow) {
|
|
196
|
+
// Check trigger types
|
|
197
|
+
const triggers = workflow.nodes.filter(n => n.type.toLowerCase().includes('trigger'));
|
|
198
|
+
if (triggers.length === 0) {
|
|
199
|
+
return 'manual execution';
|
|
200
|
+
}
|
|
201
|
+
const triggerTypes = triggers.map(t => t.type.toLowerCase());
|
|
202
|
+
if (triggerTypes.some(t => t.includes('webhook'))) {
|
|
203
|
+
return 'on-demand (webhook triggered)';
|
|
204
|
+
}
|
|
205
|
+
if (triggerTypes.some(t => t.includes('schedule') || t.includes('cron'))) {
|
|
206
|
+
return 'scheduled intervals';
|
|
207
|
+
}
|
|
208
|
+
if (triggerTypes.some(t => t.includes('form'))) {
|
|
209
|
+
return 'user form submission';
|
|
210
|
+
}
|
|
211
|
+
if (triggerTypes.some(t => t.includes('manual'))) {
|
|
212
|
+
return 'manual execution';
|
|
213
|
+
}
|
|
214
|
+
return 'event-driven';
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Fill HOW slot (tech stack summary)
|
|
218
|
+
*/
|
|
219
|
+
fillHow(aiModels, infrastructure, pattern) {
|
|
220
|
+
const components = [];
|
|
221
|
+
// Add pattern if significant
|
|
222
|
+
if (pattern === 'RAG') {
|
|
223
|
+
components.push('RAG pipeline');
|
|
224
|
+
}
|
|
225
|
+
else if (pattern === 'Multi-Agent') {
|
|
226
|
+
components.push('multi-agent coordination');
|
|
227
|
+
}
|
|
228
|
+
// Add primary AI model
|
|
229
|
+
if (aiModels.length > 0) {
|
|
230
|
+
components.push(aiModels[0]);
|
|
231
|
+
}
|
|
232
|
+
// Add key infrastructure (limit to 2)
|
|
233
|
+
if (infrastructure.length > 0) {
|
|
234
|
+
const key = infrastructure.slice(0, 2);
|
|
235
|
+
components.push(...key);
|
|
236
|
+
}
|
|
237
|
+
if (components.length === 0) {
|
|
238
|
+
return 'n8n workflow automation';
|
|
239
|
+
}
|
|
240
|
+
// Join with " with "
|
|
241
|
+
if (components.length === 1) {
|
|
242
|
+
return components[0];
|
|
243
|
+
}
|
|
244
|
+
if (components.length === 2) {
|
|
245
|
+
return components.join(' with ');
|
|
246
|
+
}
|
|
247
|
+
// For 3+: "A with B and C"
|
|
248
|
+
const last = components.pop();
|
|
249
|
+
return `${components.join(', ')} and ${last}`;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
exports.SlotFiller = SlotFiller;
|
|
253
|
+
//# sourceMappingURL=slot-filler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-filler.js","sourceRoot":"","sources":["../../src/enrichment/slot-filler.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAqBH,MAAa,UAAU;IAErB;;OAEG;IACH,OAAO,CACL,OAAe,EACf,KAAa,EACb,QAAwB,EACxB,OAAwB,EACxB,QAAkB,EAClB,cAAwB;QAGxB,qCAAqC;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAEhD,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC;YAChC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;YACpC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YACzB,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;YAC/B,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC7B,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,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ONCE ABSTRACTION
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* to bundled yaml seamlessly!
|
|
4
|
+
* ROCK SOLID YAML PARSING - FIX ONCE, DONE FOREVER
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* This module handles ALL YAML edge cases:
|
|
7
|
+
* ✅ Empty files
|
|
8
|
+
* ✅ Null/undefined content
|
|
9
|
+
* ✅ Invalid YAML syntax
|
|
10
|
+
* ✅ Type validation
|
|
11
|
+
* ✅ Corrupted files
|
|
12
|
+
* ✅ Clear error messages
|
|
13
|
+
* ✅ Primitive vs Object validation
|
|
14
|
+
*
|
|
15
|
+
* NEVER touch raw YAML parsing outside this file.
|
|
9
16
|
*/
|
|
10
17
|
import * as yaml from 'yaml';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Safe YAML parse - handles ALL edge cases
|
|
20
|
+
* ROCK SOLID - FIX ONCE, DONE FOREVER
|
|
21
|
+
*/
|
|
22
|
+
export declare function parse(content: string | null | undefined, options?: {
|
|
23
|
+
filepath?: string;
|
|
24
|
+
}): any;
|
|
25
|
+
/**
|
|
26
|
+
* Safe YAML stringify - handles edge cases
|
|
27
|
+
* ROCK SOLID - FIX ONCE, DONE FOREVER
|
|
28
|
+
*/
|
|
29
|
+
export declare function stringify(data: any, options?: any): string;
|
|
14
30
|
export declare const parseDocument: typeof yaml.parseDocument;
|
|
31
|
+
export declare const Document: typeof yaml.Document;
|
|
15
32
|
declare const _default: {
|
|
16
|
-
parse: typeof
|
|
17
|
-
stringify: typeof
|
|
33
|
+
parse: typeof parse;
|
|
34
|
+
stringify: typeof stringify;
|
|
18
35
|
Document: typeof yaml.Document;
|
|
19
36
|
parseDocument: typeof yaml.parseDocument;
|
|
20
37
|
};
|
|
21
38
|
export default _default;
|
|
22
39
|
export declare const YAML: {
|
|
23
|
-
parse: typeof
|
|
24
|
-
stringify: typeof
|
|
40
|
+
parse: typeof parse;
|
|
41
|
+
stringify: typeof stringify;
|
|
25
42
|
Document: typeof yaml.Document;
|
|
26
43
|
parseDocument: typeof yaml.parseDocument;
|
|
27
44
|
};
|
|
28
45
|
/**
|
|
29
|
-
*
|
|
30
|
-
* 1. All yaml imports go through here
|
|
31
|
-
* 2. Easy to switch to bundled version later
|
|
32
|
-
* 3. Can add logging/debugging if needed
|
|
33
|
-
* 4. Single place to manage yaml
|
|
46
|
+
* 🔥 ROCK SOLID STATUS: ACHIEVED
|
|
34
47
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* FAF YAML USAGE PATTERNS:
|
|
44
|
-
*
|
|
45
|
-
* 1. Parsing .faf files:
|
|
46
|
-
* const config = parse(fileContent);
|
|
48
|
+
* All edge cases handled:
|
|
49
|
+
* ✅ Null/undefined → Clear error
|
|
50
|
+
* ✅ Empty files → Clear error
|
|
51
|
+
* ✅ Wrong types → Clear error
|
|
52
|
+
* ✅ Invalid YAML → Wrapped error with context
|
|
53
|
+
* ✅ Primitives → Clear error (.faf must be objects)
|
|
54
|
+
* ✅ Arrays → Clear error (.faf must be objects)
|
|
47
55
|
*
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
* 3. That's literally it! We keep it simple!
|
|
52
|
-
*
|
|
53
|
-
* 🍜 NOODLE PRESERVATION STATUS: SECURED
|
|
54
|
-
*/
|
|
56
|
+
* FIX ONCE, DONE FOREVER
|
|
57
|
+
*/
|
|
55
58
|
//# sourceMappingURL=yaml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../src/fix-once/yaml.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../src/fix-once/yaml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B;;;GAGG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,CAmE9F;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,MAAM,CAmC1D;AAGD,eAAO,MAAM,aAAa,2BAAqB,CAAC;AAChD,eAAO,MAAM,QAAQ,sBAAgB,CAAC;;;;;;;AAGtC,wBAKE;AAGF,eAAO,MAAM,IAAI;;;;;CAKhB,CAAC;AAEF;;;;;;;;;;;;GAYG"}
|
package/dist/fix-once/yaml.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* 🔥 YAML FIX-ONCE ABSTRACTION
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* to bundled yaml seamlessly!
|
|
5
|
+
* ROCK SOLID YAML PARSING - FIX ONCE, DONE FOREVER
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* This module handles ALL YAML edge cases:
|
|
8
|
+
* ✅ Empty files
|
|
9
|
+
* ✅ Null/undefined content
|
|
10
|
+
* ✅ Invalid YAML syntax
|
|
11
|
+
* ✅ Type validation
|
|
12
|
+
* ✅ Corrupted files
|
|
13
|
+
* ✅ Clear error messages
|
|
14
|
+
* ✅ Primitive vs Object validation
|
|
15
|
+
*
|
|
16
|
+
* NEVER touch raw YAML parsing outside this file.
|
|
10
17
|
*/
|
|
11
18
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
19
|
if (k2 === undefined) k2 = k;
|
|
@@ -42,53 +49,124 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
42
49
|
};
|
|
43
50
|
})();
|
|
44
51
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.YAML = exports.
|
|
46
|
-
|
|
52
|
+
exports.YAML = exports.Document = exports.parseDocument = void 0;
|
|
53
|
+
exports.parse = parse;
|
|
54
|
+
exports.stringify = stringify;
|
|
47
55
|
const yaml = __importStar(require("yaml"));
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
const colors_1 = require("./colors");
|
|
57
|
+
/**
|
|
58
|
+
* Safe YAML parse - handles ALL edge cases
|
|
59
|
+
* ROCK SOLID - FIX ONCE, DONE FOREVER
|
|
60
|
+
*/
|
|
61
|
+
function parse(content, options) {
|
|
62
|
+
const filepath = options?.filepath || 'unknown file';
|
|
63
|
+
// Edge case 1: Null/undefined (CHECK FIRST before any operations)
|
|
64
|
+
if (content === null || content === undefined) {
|
|
65
|
+
throw new Error(`${colors_1.chalk.red('Empty content passed to YAML parser')}\n` +
|
|
66
|
+
`File: ${filepath}\n` +
|
|
67
|
+
`Fix: Ensure file exists and has content before parsing`);
|
|
68
|
+
}
|
|
69
|
+
// Edge case 2: Not a string (CHECK BEFORE calling string methods)
|
|
70
|
+
if (typeof content !== 'string') {
|
|
71
|
+
throw new Error(`${colors_1.chalk.red('Invalid content type passed to YAML parser')}\n` +
|
|
72
|
+
`Expected: string\n` +
|
|
73
|
+
`Got: ${typeof content}\n` +
|
|
74
|
+
`File: ${filepath}`);
|
|
75
|
+
}
|
|
76
|
+
// Edge case 3: Empty string or whitespace only
|
|
77
|
+
if (content.trim() === '') {
|
|
78
|
+
throw new Error(`${colors_1.chalk.red('Empty .faf file detected')}\n` +
|
|
79
|
+
`File: ${filepath}\n` +
|
|
80
|
+
`Fix: Run ${colors_1.chalk.cyan('faf init')} to recreate the file`);
|
|
81
|
+
}
|
|
82
|
+
// Edge case 4: Parse YAML and handle syntax errors
|
|
83
|
+
let result;
|
|
84
|
+
try {
|
|
85
|
+
result = yaml.parse(content);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
// Wrap yaml parsing errors with helpful context
|
|
89
|
+
throw new Error(`${colors_1.chalk.red('Invalid YAML syntax')}\n` +
|
|
90
|
+
`File: ${filepath}\n` +
|
|
91
|
+
`Error: ${error.message}\n` +
|
|
92
|
+
`Fix: Check file syntax or run ${colors_1.chalk.cyan('faf init --force')} to recreate`);
|
|
93
|
+
}
|
|
94
|
+
// Edge case 5: Parsed successfully but result is null/undefined
|
|
95
|
+
// (valid YAML like "null" or "~" or empty documents)
|
|
96
|
+
if (result === null || result === undefined) {
|
|
97
|
+
throw new Error(`${colors_1.chalk.red('YAML file parsed but contains no data')}\n` +
|
|
98
|
+
`File: ${filepath}\n` +
|
|
99
|
+
`Fix: Ensure file has valid YAML content or run ${colors_1.chalk.cyan('faf init')}`);
|
|
100
|
+
}
|
|
101
|
+
// Edge case 6: Parsed to primitive (not an object)
|
|
102
|
+
// .faf files must be YAML objects, not scalars
|
|
103
|
+
if (typeof result !== 'object' || Array.isArray(result)) {
|
|
104
|
+
throw new Error(`${colors_1.chalk.red('Invalid .faf structure - must be a YAML object')}\n` +
|
|
105
|
+
`File: ${filepath}\n` +
|
|
106
|
+
`Got: ${Array.isArray(result) ? 'array' : typeof result}\n` +
|
|
107
|
+
`Fix: .faf files must contain key-value pairs, not ${Array.isArray(result) ? 'lists' : 'simple values'}`);
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Safe YAML stringify - handles edge cases
|
|
113
|
+
* ROCK SOLID - FIX ONCE, DONE FOREVER
|
|
114
|
+
*/
|
|
115
|
+
function stringify(data, options) {
|
|
116
|
+
// Edge case 1: Null/undefined data
|
|
117
|
+
if (data === null || data === undefined) {
|
|
118
|
+
throw new Error(`${colors_1.chalk.red('Cannot stringify null/undefined data to YAML')}\n` +
|
|
119
|
+
`Fix: Provide valid data object`);
|
|
120
|
+
}
|
|
121
|
+
// Edge case 2: Not an object (primitives should not be stringified for .faf)
|
|
122
|
+
if (typeof data !== 'object' || Array.isArray(data)) {
|
|
123
|
+
throw new Error(`${colors_1.chalk.red('Invalid data for .faf stringify')}\n` +
|
|
124
|
+
`Expected: object\n` +
|
|
125
|
+
`Got: ${Array.isArray(data) ? 'array' : typeof data}\n` +
|
|
126
|
+
`Fix: .faf files must be objects with key-value pairs`);
|
|
127
|
+
}
|
|
128
|
+
// Edge case 3: Stringify and catch any errors
|
|
129
|
+
try {
|
|
130
|
+
const result = yaml.stringify(data, options);
|
|
131
|
+
// Edge case 4: Empty result
|
|
132
|
+
if (!result || result.trim() === '') {
|
|
133
|
+
throw new Error('Stringify produced empty output');
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
throw new Error(`${colors_1.chalk.red('Failed to convert data to YAML')}\n` +
|
|
139
|
+
`Error: ${error.message}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Export raw versions for advanced usage (use with caution)
|
|
52
143
|
exports.parseDocument = yaml.parseDocument;
|
|
144
|
+
exports.Document = yaml.Document;
|
|
53
145
|
// Re-export as default for compatibility
|
|
54
146
|
exports.default = {
|
|
55
|
-
parse
|
|
56
|
-
stringify
|
|
147
|
+
parse,
|
|
148
|
+
stringify,
|
|
57
149
|
Document: exports.Document,
|
|
58
150
|
parseDocument: exports.parseDocument
|
|
59
151
|
};
|
|
60
152
|
// Also export as YAML for compatibility
|
|
61
153
|
exports.YAML = {
|
|
62
|
-
parse
|
|
63
|
-
stringify
|
|
154
|
+
parse,
|
|
155
|
+
stringify,
|
|
64
156
|
Document: exports.Document,
|
|
65
157
|
parseDocument: exports.parseDocument
|
|
66
158
|
};
|
|
67
159
|
/**
|
|
68
|
-
*
|
|
69
|
-
* 1. All yaml imports go through here
|
|
70
|
-
* 2. Easy to switch to bundled version later
|
|
71
|
-
* 3. Can add logging/debugging if needed
|
|
72
|
-
* 4. Single place to manage yaml
|
|
160
|
+
* 🔥 ROCK SOLID STATUS: ACHIEVED
|
|
73
161
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* FAF YAML USAGE PATTERNS:
|
|
83
|
-
*
|
|
84
|
-
* 1. Parsing .faf files:
|
|
85
|
-
* const config = parse(fileContent);
|
|
162
|
+
* All edge cases handled:
|
|
163
|
+
* ✅ Null/undefined → Clear error
|
|
164
|
+
* ✅ Empty files → Clear error
|
|
165
|
+
* ✅ Wrong types → Clear error
|
|
166
|
+
* ✅ Invalid YAML → Wrapped error with context
|
|
167
|
+
* ✅ Primitives → Clear error (.faf must be objects)
|
|
168
|
+
* ✅ Arrays → Clear error (.faf must be objects)
|
|
86
169
|
*
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
*
|
|
90
|
-
* 3. That's literally it! We keep it simple!
|
|
91
|
-
*
|
|
92
|
-
* 🍜 NOODLE PRESERVATION STATUS: SECURED
|
|
93
|
-
*/
|
|
170
|
+
* FIX ONCE, DONE FOREVER
|
|
171
|
+
*/
|
|
94
172
|
//# sourceMappingURL=yaml.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../src/fix-once/yaml.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../src/fix-once/yaml.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASH,sBAmEC;AAMD,8BAmCC;AAnHD,2CAA6B;AAC7B,qCAAiC;AAEjC;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAkC,EAAE,OAA+B;IACvF,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAA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C,OAAO,IAAI,IAAI;YACvD,sDAAsD,CACvD,CAAC;IACJ,CAAC;IAED,8CAA8C;IAC9C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE7C,4BAA4B;QAC5B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,GAAG,cAAK,CAAC,GAAG,CAAC,gCAAgC,CAAC,IAAI;YAClD,UAAU,KAAK,CAAC,OAAO,EAAE,CAC1B,CAAC;IACJ,CAAC;AACH,CAAC;AAED,4DAA4D;AAC/C,QAAA,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;AACnC,QAAA,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;AAEtC,yCAAyC;AACzC,kBAAe;IACb,KAAK;IACL,SAAS;IACT,QAAQ,EAAR,gBAAQ;IACR,aAAa,EAAb,qBAAa;CACd,CAAC;AAEF,wCAAwC;AAC3B,QAAA,IAAI,GAAG;IAClB,KAAK;IACL,SAAS;IACT,QAAQ,EAAR,gBAAQ;IACR,aAAa,EAAb,qBAAa;CACd,CAAC;AAEF;;;;;;;;;;;;GAYG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faf-generator-championship.d.ts","sourceRoot":"","sources":["../../src/generators/faf-generator-championship.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"faf-generator-championship.d.ts","sourceRoot":"","sources":["../../src/generators/faf-generator-championship.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,CAAC,CAyZjB"}
|
|
@@ -203,6 +203,76 @@ async function generateFafFromProject(options) {
|
|
|
203
203
|
contextSlotsFilled['how'] = humanContext.how.value;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
+
// CLI-specific detection and smart slot reuse
|
|
207
|
+
const deps = {
|
|
208
|
+
...packageData.dependencies,
|
|
209
|
+
...packageData.devDependencies
|
|
210
|
+
};
|
|
211
|
+
const isCLI = packageData.bin ||
|
|
212
|
+
packageData.name?.includes('cli') ||
|
|
213
|
+
packageData.keywords?.includes('cli') ||
|
|
214
|
+
packageData.keywords?.includes('command-line') ||
|
|
215
|
+
deps?.commander ||
|
|
216
|
+
deps?.yargs ||
|
|
217
|
+
deps?.oclif ||
|
|
218
|
+
deps?.inquirer;
|
|
219
|
+
if (isCLI) {
|
|
220
|
+
// Smart slot reuse for CLI projects
|
|
221
|
+
contextSlotsFilled['framework'] = 'CLI'; // frontend = CLI
|
|
222
|
+
contextSlotsFilled['api_type'] = 'CLI';
|
|
223
|
+
contextSlotsFilled['hosting'] = 'npm registry';
|
|
224
|
+
contextSlotsFilled['backend'] = 'Node.js';
|
|
225
|
+
// Detect terminal UI framework
|
|
226
|
+
if (deps?.chalk)
|
|
227
|
+
contextSlotsFilled['css_framework'] = 'chalk (terminal colors)';
|
|
228
|
+
else if (deps?.colors)
|
|
229
|
+
contextSlotsFilled['css_framework'] = 'colors';
|
|
230
|
+
else if (deps?.ora)
|
|
231
|
+
contextSlotsFilled['css_framework'] = 'ora';
|
|
232
|
+
// Detect interactive framework
|
|
233
|
+
if (deps?.inquirer)
|
|
234
|
+
contextSlotsFilled['ui_library'] = 'inquirer (interactive prompts)';
|
|
235
|
+
else if (deps?.prompts)
|
|
236
|
+
contextSlotsFilled['ui_library'] = 'prompts';
|
|
237
|
+
else if (deps?.enquirer)
|
|
238
|
+
contextSlotsFilled['ui_library'] = 'enquirer';
|
|
239
|
+
// Detect CLI framework
|
|
240
|
+
if (deps?.commander)
|
|
241
|
+
contextSlotsFilled['cli_framework'] = 'commander';
|
|
242
|
+
else if (deps?.yargs)
|
|
243
|
+
contextSlotsFilled['cli_framework'] = 'yargs';
|
|
244
|
+
else if (deps?.oclif)
|
|
245
|
+
contextSlotsFilled['cli_framework'] = 'oclif';
|
|
246
|
+
// Detect runtime
|
|
247
|
+
if (packageData.engines?.node) {
|
|
248
|
+
contextSlotsFilled['runtime'] = `Node.js ${packageData.engines.node}`;
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
contextSlotsFilled['runtime'] = 'Node.js v16+';
|
|
252
|
+
}
|
|
253
|
+
// Detect build system
|
|
254
|
+
if (deps?.typescript || deps?.['@types/node']) {
|
|
255
|
+
contextSlotsFilled['build_tool'] = 'TypeScript (tsc)';
|
|
256
|
+
}
|
|
257
|
+
// Detect testing
|
|
258
|
+
if (deps?.jest)
|
|
259
|
+
contextSlotsFilled['test_framework'] = 'Jest';
|
|
260
|
+
else if (deps?.mocha)
|
|
261
|
+
contextSlotsFilled['test_framework'] = 'Mocha';
|
|
262
|
+
else if (deps?.vitest)
|
|
263
|
+
contextSlotsFilled['test_framework'] = 'Vitest';
|
|
264
|
+
// Detect CI/CD - check for .github/workflows directory
|
|
265
|
+
try {
|
|
266
|
+
const githubWorkflowsPath = path_1.default.join(projectRoot, '.github', 'workflows');
|
|
267
|
+
const githubWorkflowsExists = await fs_1.promises.access(githubWorkflowsPath).then(() => true).catch(() => false);
|
|
268
|
+
if (githubWorkflowsExists) {
|
|
269
|
+
contextSlotsFilled['cicd'] = 'GitHub Actions';
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
// Continue without CI/CD detection
|
|
274
|
+
}
|
|
275
|
+
}
|
|
206
276
|
// Override with package.json if more specific
|
|
207
277
|
if (packageData.name && !contextSlotsFilled['project_name']) {
|
|
208
278
|
contextSlotsFilled['project_name'] = packageData.name;
|
|
@@ -323,12 +393,12 @@ async function generateFafFromProject(options) {
|
|
|
323
393
|
projectGoal: contextSlotsFilled['project_goal'] || 'Build amazing software',
|
|
324
394
|
mainLanguage: contextSlotsFilled['main_language'] || 'JavaScript',
|
|
325
395
|
framework: contextSlotsFilled['framework'] || 'None',
|
|
326
|
-
cssFramework: undefined,
|
|
327
|
-
uiLibrary: undefined,
|
|
396
|
+
cssFramework: contextSlotsFilled['css_framework'] || undefined,
|
|
397
|
+
uiLibrary: contextSlotsFilled['ui_library'] || undefined,
|
|
328
398
|
stateManagement: undefined,
|
|
329
399
|
backend: contextSlotsFilled['backend'] || 'None',
|
|
330
400
|
apiType: contextSlotsFilled['api_type'] || 'REST',
|
|
331
|
-
server: contextSlotsFilled['server'] || 'None',
|
|
401
|
+
server: contextSlotsFilled['runtime'] || contextSlotsFilled['server'] || 'None',
|
|
332
402
|
database: contextSlotsFilled['database'] || 'None',
|
|
333
403
|
connection: 'None',
|
|
334
404
|
hosting: contextSlotsFilled['hosting'] || 'None',
|