πŸš€ DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

@adminide-stack/form-builder-core

Package Overview
Dependencies
Maintainers
16
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adminide-stack/form-builder-core

latest
npmnpm
Version
5.1.4-alpha.82
Version published
Maintainers
16
Created
Source

JavaScript Autocomplete Integration for Inngest Steps

Complete integration of intelligent JavaScript autocompletion in step function editors.

Overview

This integration connects Monaco Editor with the js-autocomplete-extension to provide:

  • Context-aware JavaScript completions using Tern.js
  • Type information on hover
  • Step-specific completions for Inngest workflows
  • Library support (lodash, moment, etc.)
  • Dynamic completions based on execution context

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         CodeEditor Component                     β”‚
β”‚  (Monaco Editor Instance)                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β”‚ User types code
                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    monacoAutocompleteIntegration.ts             β”‚
β”‚  - setupMonacoAutocomplete()                    β”‚
β”‚  - setupStepAutocomplete()                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β”‚ services.commands.executeCommand()
                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       js-autocomplete-extension                  β”‚
β”‚  - jsAutocomplete.getCompletions                β”‚
β”‚  - jsAutocomplete.getTypeInfo                   β”‚
β”‚  - jsAutocomplete.installLibrary                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β”‚ code.javascript.* API
                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    JavaScript Worker (Tern.js)                  β”‚
β”‚  - Type inference                                β”‚
β”‚  - Library definitions                           β”‚
β”‚  - Scope analysis                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Files Created

1. stepGenerator.ts (Updated)

Added completion support functions:

  • getStepCompletionScope() - Returns available scope variables
  • getStepTypeDefinitions() - Returns TypeScript definitions for Inngest API
  • getStepTypeCompletions() - Returns step-type-specific completions
  • extractVariablesFromCode() - Extracts variables from code for context
  • getStepCompletionContext() - Gets complete completion context for a step

2. monacoAutocompleteIntegration.ts (New)

Monaco Editor integration layer:

  • setupMonacoAutocomplete() - Setup general JS/TS autocomplete
  • setupStepAutocomplete() - Setup step-specific autocomplete
  • installLibraryForAutocomplete() - Install library definitions
  • updateAutocompleteConfig() - Update autocomplete settings
  • getAvailableDefinitions() - Get loaded type definitions

Uses your command execution pattern:

await services.commands.executeCommand({
    command: 'jsAutocomplete.getCompletions',
    arguments: [text, position, scope],
});

Usage in CodeEditor

Basic Integration

import { setupMonacoAutocomplete } from '@form-builder/core/inngest/monacoAutocompleteIntegration';

const CodeEditor: React.FC<CodeEditorProps> = ({ value, onChange, services }) => {
    const handleEditorWillMount = async (monaco: any) => {
        // Setup autocomplete
        if (services?.commands) {
            await setupMonacoAutocomplete(
                monaco,
                {
                    enableInngestContext: true,
                    customScope: ['step', 'event'],
                    enableHoverInfo: true,
                    commandService: services.commands,
                },
                services.commands,
            );
        }

        // Rest of your setup...
    };

    return <Editor beforeMount={handleEditorWillMount} />;
};

Step-Specific Integration

import { setupStepAutocomplete } from '@form-builder/core/inngest/monacoAutocompleteIntegration';

const handleEditorWillMount = async (monaco: any) => {
    if (services?.commands && currentStep) {
        // Provides step-type-specific completions
        await setupStepAutocomplete(monaco, currentStep, code, services.commands);
    }
};

Extension Commands

All extension commands follow your command execution pattern:

Get Completions

const result = await services.commands.executeCommand({
    command: 'jsAutocomplete.getCompletions',
    arguments: [
        text, // Full source code
        position, // Cursor offset
        ['step', 'event', 'myVar'], // Optional scope
    ],
});

// Returns:
// {
//     completions: [
//         { name: 'run', type: 'fn(id: string, fn: function): Promise', doc: '...' },
//         { name: 'sleep', type: 'fn(id: string, duration: string): Promise', doc: '...' }
//     ],
//     isIncomplete: false
// }

Get Type Info

const typeInfo = await services.commands.executeCommand({
    command: 'jsAutocomplete.getTypeInfo',
    arguments: ['step', ['event', 'step']],
});

// Returns:
// {
//     type: 'object with methods run, sleep, sendEvent, waitForEvent',
//     doc: 'Inngest step API for workflow orchestration',
//     url: 'https://docs.inngest.com'
// }

Install Library

await services.commands.executeCommand({
    command: 'jsAutocomplete.installLibrary',
    arguments: ['https://cdn.jsdelivr.net/npm/@types/lodash/index.d.ts', ['_', 'lodash']],
});

Update Configuration

await services.commands.executeCommand({
    command: 'jsAutocomplete.updateConfig',
    arguments: [
        {
            includeDefaults: true,
            includeLibraries: true,
            enableDynamicLibraries: true,
            customDefinitions: ['lodash', 'moment'],
        },
    ],
});

Step-Specific Completions

The integration provides context-aware completions based on step type:

Sleep Step

step.sleep('step-id', '5s'); // Completions show duration formats: "5s", "1m", "1h"

Send Event Step

step.sendEvent('step-id', {
    name: 'my.event', // Completions suggest event patterns
    data: {}, // Type-aware data completions
});

Wait For Event Step

step.waitForEvent('step-id', {
    event: '', // Event name completions
    timeout: '', // Duration completions
});

Run Step

step.run('step-id', async (event, step) => {
    event.   // Completions for event properties
    step.    // Completions for step methods
})

Type Definitions

The integration includes comprehensive type definitions:

declare const step: {
    run<T>(id: string, fn: (event: any, step: any) => Promise<T> | T): Promise<T>;
    sendEvent(id: string, input: { name: string; data?: any }): Promise<void>;
    waitForEvent<T = any>(id: string, opts: { event: string; timeout?: string | number }): Promise<T>;
    sleep(id: string, ms: string | number): Promise<void>;
};

declare const event: {
    data: any;
    id: string;
    name: string;
    ts: number;
};

Features

1. Context-Aware Completions

  • Knows about step, event, and local variables
  • Provides method completions based on type inference
  • Suggests relevant APIs for current step type

2. Hover Type Information

  • Hover over any symbol to see its type
  • View documentation inline
  • Links to external documentation

3. Library Support

  • Automatically includes installed libraries
  • Dynamic library detection from execution context
  • Custom library definitions

4. Scope Analysis

  • Extracts variables from code
  • Maintains scope context across edits
  • Provides completions for local variables

5. Snippets Integration

  • Works alongside your existing Monaco snippets
  • Doesn't conflict with manual completions
  • Combines template snippets with intelligent completions

Configuration

Users can configure autocomplete behavior:

{
    "jsAutocomplete.includeDefaults": true,        // ECMAScript definitions
    "jsAutocomplete.includeLibraries": true,       // Installed libraries
    "jsAutocomplete.enableDynamicLibraries": true, // Runtime detection
    "jsAutocomplete.customDefinitions": []         // Custom type defs
}

Testing

Test Extension Availability

React.useEffect(() => {
    if (services?.commands) {
        services.commands
            .executeCommand({
                command: 'jsAutocomplete.getAvailableDefinitions',
                arguments: [],
            })
            .then((defs) => {
                console.log('Extension loaded, definitions:', defs);
            })
            .catch((err) => {
                console.error('Extension not available:', err);
            });
    }
}, [services]);

Test Completions

const testCompletions = async () => {
    const result = await services.commands.executeCommand({
        command: 'jsAutocomplete.getCompletions',
        arguments: ['step.', 5, ['step', 'event']],
    });

    console.log('Completions:', result.completions);
    // Should show: run, sleep, sendEvent, waitForEvent
};

Troubleshooting

No Completions Showing

  • βœ… Check extension is activated in console
  • βœ… Verify services.commands is available
  • βœ… Test command execution manually
  • βœ… Check Monaco provider was registered

Wrong Completions

  • βœ… Verify scope context is correct
  • βœ… Check step type is properly set
  • βœ… Try resetting context: jsAutocomplete.resetContext

Type Info Not Showing

  • βœ… Ensure enableHoverInfo: true
  • βœ… Check hover provider is registered
  • βœ… Test getTypeInfo command manually

Performance

  • Lazy Loading: Type definitions loaded on-demand
  • Caching: Tern.js caches type information
  • Incremental: Updates as code changes
  • Worker-Based: Runs in separate thread

Future Enhancements

  • Signature help for function parameters
  • Definition provider (Go to Definition)
  • References provider (Find All References)
  • Rename provider
  • Code actions (quick fixes)
  • Import statement generation
  • JSDoc parsing and display
  • Multi-step context awareness

Benefits

βœ… Intelligent Completions - Context-aware suggestions using Tern.js
βœ… Type Information - Hover to see types and documentation
βœ… Library Support - Completions for installed libraries
βœ… Step-Specific - Tailored completions for each step type
βœ… Works with Existing Code - Integrates with your snippets
βœ… Command Pattern - Uses your existing command execution
βœ… Performance - Worker-based, doesn't block UI

License

MIT

FAQs

Package last updated on 25 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts