@adminide-stack/form-builder-core 5.1.4-alpha.81 → 6.0.1-alpha.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.
- package/LICENSE +30 -21
- package/lib/index.js +1 -1
- package/lib/inngest/generateFunctionCode.d.ts +1 -0
- package/lib/inngest/generateFunctionCode.d.ts.map +1 -1
- package/lib/inngest/generateFunctionCode.js +72 -3
- package/lib/inngest/generateFunctionCode.js.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -56
- package/rollup.config.mjs +0 -33
- package/src/index.ts +0 -5
- package/src/inngest/MONACO_INTEGRATION_EXAMPLE.md +0 -406
- package/src/inngest/README_AUTOCOMPLETE.md +0 -380
- package/src/inngest/generateFunctionCode.ts +0 -151
- package/src/inngest/interfaces/index.ts +0 -1
- package/src/inngest/interfaces/types.ts +0 -63
- package/src/inngest/monacoAutocompleteIntegration.ts +0 -432
- package/src/inngest/stepGenerator.ts +0 -538
- package/src/utils/json.ts +0 -50
- package/tsconfig.json +0 -14
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Monaco Editor Integration for JavaScript Autocomplete
|
|
3
|
-
*
|
|
4
|
-
* Integrates with the js-autocomplete-extension via command execution
|
|
5
|
-
* to provide intelligent code completions in step function editors.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { getStepCompletionContext, getStepTypeDefinitions } from './stepGenerator';
|
|
9
|
-
import type { InngestStep } from './interfaces/types';
|
|
10
|
-
|
|
11
|
-
export interface MonacoAutocompleteOptions {
|
|
12
|
-
/** Enable Inngest step functions context */
|
|
13
|
-
enableInngestContext?: boolean;
|
|
14
|
-
/** Custom scope variables */
|
|
15
|
-
customScope?: string[];
|
|
16
|
-
/** Enable type info on hover */
|
|
17
|
-
enableHoverInfo?: boolean;
|
|
18
|
-
/** Command service for executing extension commands */
|
|
19
|
-
commandService?: any;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Setup JavaScript autocomplete for Monaco Editor using extension commands
|
|
24
|
-
*
|
|
25
|
-
* @param monaco Monaco editor instance
|
|
26
|
-
* @param options Configuration options
|
|
27
|
-
* @param commandService Service for executing extension commands
|
|
28
|
-
*/
|
|
29
|
-
export async function setupMonacoAutocomplete(
|
|
30
|
-
monaco: any,
|
|
31
|
-
options: MonacoAutocompleteOptions = {},
|
|
32
|
-
commandService?: any,
|
|
33
|
-
) {
|
|
34
|
-
const { enableInngestContext = true, customScope = [], enableHoverInfo = true } = options;
|
|
35
|
-
|
|
36
|
-
const commands = commandService || options.commandService;
|
|
37
|
-
|
|
38
|
-
if (!commands) {
|
|
39
|
-
console.warn('No command service provided, autocomplete will not be available');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Build scope context
|
|
44
|
-
const scope = [...customScope];
|
|
45
|
-
if (enableInngestContext) {
|
|
46
|
-
scope.push('step', 'event', 'run', 'sleep', 'sendEvent', 'waitForEvent');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Configure TypeScript/JavaScript compiler options to prevent worker errors
|
|
50
|
-
const compilerOptions = {
|
|
51
|
-
target: monaco.languages.typescript.ScriptTarget.ES2020,
|
|
52
|
-
allowNonTsExtensions: true,
|
|
53
|
-
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
|
|
54
|
-
module: monaco.languages.typescript.ModuleKind.CommonJS,
|
|
55
|
-
noEmit: true,
|
|
56
|
-
esModuleInterop: true,
|
|
57
|
-
allowJs: true,
|
|
58
|
-
checkJs: false,
|
|
59
|
-
noSemanticValidation: false,
|
|
60
|
-
noSyntaxValidation: false,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// Set compiler options for both JavaScript and TypeScript
|
|
64
|
-
monaco.languages.typescript.javascriptDefaults.setCompilerOptions(compilerOptions);
|
|
65
|
-
monaco.languages.typescript.typescriptDefaults.setCompilerOptions(compilerOptions);
|
|
66
|
-
|
|
67
|
-
// Configure diagnostics options to prevent unnecessary worker calls
|
|
68
|
-
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
|
69
|
-
noSemanticValidation: false,
|
|
70
|
-
noSyntaxValidation: false,
|
|
71
|
-
diagnosticCodesToIgnore: [1108], // Ignore "A 'return' statement can only be used within a function body"
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
75
|
-
noSemanticValidation: false,
|
|
76
|
-
noSyntaxValidation: false,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// Disable eager model sync to prevent worker trying to access non-existent models
|
|
80
|
-
monaco.languages.typescript.javascriptDefaults.setEagerModelSync(false);
|
|
81
|
-
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(false);
|
|
82
|
-
|
|
83
|
-
// Register completion provider for JavaScript
|
|
84
|
-
monaco.languages.registerCompletionItemProvider('javascript', {
|
|
85
|
-
triggerCharacters: ['.', ' '],
|
|
86
|
-
|
|
87
|
-
provideCompletionItems: async (model: any, position: any) => {
|
|
88
|
-
try {
|
|
89
|
-
const text = model.getValue();
|
|
90
|
-
const offset = model.getOffsetAt(position);
|
|
91
|
-
|
|
92
|
-
// Call the autocomplete extension command
|
|
93
|
-
const result = await commands.executeCommand({
|
|
94
|
-
command: 'jsAutocomplete.getCompletions',
|
|
95
|
-
arguments: [text, offset, scope.length > 0 ? scope : undefined],
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
if (!result || !result.completions) {
|
|
99
|
-
return { suggestions: [] };
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Convert to Monaco completion items
|
|
103
|
-
const suggestions = result.completions.map((completion: any) => ({
|
|
104
|
-
label: completion.name,
|
|
105
|
-
kind: determineCompletionKind(completion.type, monaco),
|
|
106
|
-
documentation: formatDocumentation(completion),
|
|
107
|
-
insertText: completion.name,
|
|
108
|
-
detail: completion.type || 'any',
|
|
109
|
-
sortText: getSortText(completion),
|
|
110
|
-
}));
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
suggestions,
|
|
114
|
-
incomplete: result.isIncomplete || false,
|
|
115
|
-
};
|
|
116
|
-
} catch (error) {
|
|
117
|
-
console.error('Autocomplete error:', error);
|
|
118
|
-
return { suggestions: [] };
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
resolveCompletionItem: async (item: any) => {
|
|
123
|
-
if (!enableHoverInfo) {
|
|
124
|
-
return item;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
try {
|
|
128
|
-
// Get detailed type info for the completion
|
|
129
|
-
const typeInfo = await commands.executeCommand({
|
|
130
|
-
command: 'jsAutocomplete.getTypeInfo',
|
|
131
|
-
arguments: [item.label, scope.length > 0 ? scope : undefined],
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
if (typeInfo) {
|
|
135
|
-
item.documentation = {
|
|
136
|
-
value: formatDetailedDocumentation(item.label, typeInfo),
|
|
137
|
-
isTrusted: true,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
} catch (error) {
|
|
141
|
-
console.error('Type info resolution error:', error);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return item;
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
// Register completion provider for TypeScript
|
|
149
|
-
monaco.languages.registerCompletionItemProvider('typescript', {
|
|
150
|
-
triggerCharacters: ['.', ' '],
|
|
151
|
-
|
|
152
|
-
provideCompletionItems: async (model: any, position: any) => {
|
|
153
|
-
try {
|
|
154
|
-
const text = model.getValue();
|
|
155
|
-
const offset = model.getOffsetAt(position);
|
|
156
|
-
|
|
157
|
-
// Call the autocomplete extension command
|
|
158
|
-
const result = await commands.executeCommand({
|
|
159
|
-
command: 'jsAutocomplete.getCompletions',
|
|
160
|
-
arguments: [text, offset, scope.length > 0 ? scope : undefined],
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
if (!result || !result.completions) {
|
|
164
|
-
return { suggestions: [] };
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Convert to Monaco completion items
|
|
168
|
-
const suggestions = result.completions.map((completion: any) => ({
|
|
169
|
-
label: completion.name,
|
|
170
|
-
kind: determineCompletionKind(completion.type, monaco),
|
|
171
|
-
documentation: formatDocumentation(completion),
|
|
172
|
-
insertText: completion.name,
|
|
173
|
-
detail: completion.type || 'any',
|
|
174
|
-
sortText: getSortText(completion),
|
|
175
|
-
}));
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
suggestions,
|
|
179
|
-
incomplete: result.isIncomplete || false,
|
|
180
|
-
};
|
|
181
|
-
} catch (error) {
|
|
182
|
-
console.error('TypeScript autocomplete error:', error);
|
|
183
|
-
return { suggestions: [] };
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
// Register hover provider for type information
|
|
189
|
-
if (enableHoverInfo) {
|
|
190
|
-
monaco.languages.registerHoverProvider('javascript', {
|
|
191
|
-
provideHover: async (model: any, position: any) => {
|
|
192
|
-
try {
|
|
193
|
-
const word = model.getWordAtPosition(position);
|
|
194
|
-
if (!word) {
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Get type info via extension command
|
|
199
|
-
const typeInfo = await commands.executeCommand({
|
|
200
|
-
command: 'jsAutocomplete.getTypeInfo',
|
|
201
|
-
arguments: [word.word, scope.length > 0 ? scope : undefined],
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
if (!typeInfo) {
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return {
|
|
209
|
-
range: new monaco.Range(
|
|
210
|
-
position.lineNumber,
|
|
211
|
-
word.startColumn,
|
|
212
|
-
position.lineNumber,
|
|
213
|
-
word.endColumn,
|
|
214
|
-
),
|
|
215
|
-
contents: [
|
|
216
|
-
{ value: `**${word.word}**: \`${typeInfo.type || 'any'}\`` },
|
|
217
|
-
{ value: typeInfo.doc || 'No documentation available' },
|
|
218
|
-
],
|
|
219
|
-
};
|
|
220
|
-
} catch (error) {
|
|
221
|
-
console.error('Hover provider error:', error);
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
monaco.languages.registerHoverProvider('typescript', {
|
|
228
|
-
provideHover: async (model: any, position: any) => {
|
|
229
|
-
try {
|
|
230
|
-
const word = model.getWordAtPosition(position);
|
|
231
|
-
if (!word) {
|
|
232
|
-
return null;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const typeInfo = await commands.executeCommand({
|
|
236
|
-
command: 'jsAutocomplete.getTypeInfo',
|
|
237
|
-
arguments: [word.word, scope.length > 0 ? scope : undefined],
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
if (!typeInfo) {
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return {
|
|
245
|
-
range: new monaco.Range(
|
|
246
|
-
position.lineNumber,
|
|
247
|
-
word.startColumn,
|
|
248
|
-
position.lineNumber,
|
|
249
|
-
word.endColumn,
|
|
250
|
-
),
|
|
251
|
-
contents: [
|
|
252
|
-
{ value: `**${word.word}**: \`${typeInfo.type || 'any'}\`` },
|
|
253
|
-
{ value: typeInfo.doc || 'No documentation available' },
|
|
254
|
-
],
|
|
255
|
-
};
|
|
256
|
-
} catch (error) {
|
|
257
|
-
console.error('TypeScript hover provider error:', error);
|
|
258
|
-
return null;
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
console.log('Monaco autocomplete integration setup complete');
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Setup autocomplete for a specific Inngest step
|
|
269
|
-
* Provides step-specific context and completions
|
|
270
|
-
*/
|
|
271
|
-
export async function setupStepAutocomplete(monaco: any, step: InngestStep, code: string, commandService: any) {
|
|
272
|
-
const context = getStepCompletionContext(step, code);
|
|
273
|
-
|
|
274
|
-
await setupMonacoAutocomplete(
|
|
275
|
-
monaco,
|
|
276
|
-
{
|
|
277
|
-
enableInngestContext: true,
|
|
278
|
-
customScope: [...context.scope, ...context.variables],
|
|
279
|
-
enableHoverInfo: true,
|
|
280
|
-
commandService,
|
|
281
|
-
},
|
|
282
|
-
commandService,
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
// Add step-specific type definitions
|
|
286
|
-
const typeDefinitions = getStepTypeDefinitions();
|
|
287
|
-
monaco.languages.typescript.javascriptDefaults.addExtraLib(typeDefinitions, 'file:///inngest-step-types.d.ts');
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Install a library for autocomplete
|
|
292
|
-
*/
|
|
293
|
-
export async function installLibraryForAutocomplete(
|
|
294
|
-
commandService: any,
|
|
295
|
-
url: string,
|
|
296
|
-
accessors: string[],
|
|
297
|
-
): Promise<boolean> {
|
|
298
|
-
try {
|
|
299
|
-
await commandService.executeCommand({
|
|
300
|
-
command: 'jsAutocomplete.installLibrary',
|
|
301
|
-
arguments: [url, accessors],
|
|
302
|
-
});
|
|
303
|
-
console.log(`Library installed: ${accessors.join(', ')}`);
|
|
304
|
-
return true;
|
|
305
|
-
} catch (error) {
|
|
306
|
-
console.error('Failed to install library:', error);
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Update autocomplete configuration
|
|
313
|
-
*/
|
|
314
|
-
export async function updateAutocompleteConfig(
|
|
315
|
-
commandService: any,
|
|
316
|
-
config: {
|
|
317
|
-
includeDefaults?: boolean;
|
|
318
|
-
includeLibraries?: boolean;
|
|
319
|
-
enableDynamicLibraries?: boolean;
|
|
320
|
-
customDefinitions?: string[];
|
|
321
|
-
},
|
|
322
|
-
): Promise<boolean> {
|
|
323
|
-
try {
|
|
324
|
-
await commandService.executeCommand({
|
|
325
|
-
command: 'jsAutocomplete.updateConfig',
|
|
326
|
-
arguments: [config],
|
|
327
|
-
});
|
|
328
|
-
console.log('Autocomplete config updated');
|
|
329
|
-
return true;
|
|
330
|
-
} catch (error) {
|
|
331
|
-
console.error('Failed to update autocomplete config:', error);
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Get available type definitions
|
|
338
|
-
*/
|
|
339
|
-
export async function getAvailableDefinitions(commandService: any): Promise<string[]> {
|
|
340
|
-
try {
|
|
341
|
-
const definitions = await commandService.executeCommand({
|
|
342
|
-
command: 'jsAutocomplete.getAvailableDefinitions',
|
|
343
|
-
arguments: [],
|
|
344
|
-
});
|
|
345
|
-
return definitions || [];
|
|
346
|
-
} catch (error) {
|
|
347
|
-
console.error('Failed to get available definitions:', error);
|
|
348
|
-
return [];
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Helper functions
|
|
353
|
-
|
|
354
|
-
function determineCompletionKind(type: string | undefined, monaco: any): number {
|
|
355
|
-
if (!type) {
|
|
356
|
-
return monaco.languages.CompletionItemKind.Variable;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (type.includes('fn(') || type.includes('=>')) {
|
|
360
|
-
return monaco.languages.CompletionItemKind.Function;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (type.startsWith('class ') || type.includes('{}')) {
|
|
364
|
-
return monaco.languages.CompletionItemKind.Class;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (type.includes('[]')) {
|
|
368
|
-
return monaco.languages.CompletionItemKind.Field;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (type === 'number' || type === 'string' || type === 'boolean') {
|
|
372
|
-
return monaco.languages.CompletionItemKind.Keyword;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return monaco.languages.CompletionItemKind.Variable;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function formatDocumentation(completion: { name: string; type?: string; doc?: string; url?: string }): string {
|
|
379
|
-
const parts: string[] = [];
|
|
380
|
-
|
|
381
|
-
if (completion.type) {
|
|
382
|
-
parts.push(`\`${completion.type}\``);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (completion.doc) {
|
|
386
|
-
parts.push(completion.doc);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
if (completion.url) {
|
|
390
|
-
parts.push(`[Documentation](${completion.url})`);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
return parts.join('\n\n') || completion.name;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function formatDetailedDocumentation(name: string, typeInfo: { type?: string; doc?: string; url?: string }): string {
|
|
397
|
-
const parts: string[] = [];
|
|
398
|
-
|
|
399
|
-
parts.push(`## ${name}`);
|
|
400
|
-
parts.push('');
|
|
401
|
-
|
|
402
|
-
if (typeInfo.type) {
|
|
403
|
-
parts.push('```typescript');
|
|
404
|
-
parts.push(typeInfo.type);
|
|
405
|
-
parts.push('```');
|
|
406
|
-
parts.push('');
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (typeInfo.doc) {
|
|
410
|
-
parts.push(typeInfo.doc);
|
|
411
|
-
parts.push('');
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
if (typeInfo.url) {
|
|
415
|
-
parts.push(`[View Documentation](${typeInfo.url})`);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
return parts.join('\n');
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
function getSortText(completion: { name: string; type?: string }): string {
|
|
422
|
-
// Prioritize functions and commonly used types
|
|
423
|
-
if (completion.type?.includes('fn(') || completion.type?.includes('=>')) {
|
|
424
|
-
return `0_${completion.name}`;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
if (completion.type?.startsWith('class ')) {
|
|
428
|
-
return `1_${completion.name}`;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return `2_${completion.name}`;
|
|
432
|
-
}
|