New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

pldf-interview-engine

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pldf-interview-engine

Interview wizard engine for parsed interviews from pldf-parser

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

PLDF Interview Engine

An interactive interview wizard engine that takes parsed interview data from pldf-parser and generates dynamic, user-friendly interview wizards.

Features

  • Dynamic Question Rendering: Automatically renders questions with various field types
  • State Management: Tracks user progress with auto-save to localStorage
  • Template Processing: Supports variable substitution using ${variable} syntax via pldf-template
  • Code Execution: Safely executes code blocks to compute derived values
  • Dependency Resolution: Automatically orders questions based on variable dependencies
  • Browser & Node.js: Works in both browser and Node.js environments (UMD modules)
  • Customizable Styling: Includes default CSS with easy customization options
  • Event System: Subscribe to interview events for custom integrations

Installation

npm install pldf-interview-engine

Quick Start

Browser Usage

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="node_modules/pldf-interview-engine/css/styles.css">
</head>
<body>
    <div id="interview"></div>

    <script src="node_modules/pldf-interview-engine/js/state-manager.js"></script>
    <script src="node_modules/pldf-interview-engine/js/field-renderer.js"></script>
    <script src="node_modules/pldf-interview-engine/js/code-executor.js"></script>
    <script src="node_modules/pldf-interview-engine/js/interview-wizard.js"></script>

    <script>
        // Your parsed interview data from pldf-parser
        const interview = { /* ... */ };

        const wizard = new InterviewWizard(interview, {
            container: '#interview',
            onComplete: (answers) => {
                console.log('Interview completed:', answers);
            }
        });

        wizard.initialize().then(() => wizard.start());
    </script>
</body>
</html>

Node.js Usage

const InterviewWizard = require('pldf-interview-engine');

const interview = { /* parsed interview data */ };

const wizard = new InterviewWizard(interview, {
    onComplete: (answers) => {
        console.log('Interview completed:', answers);
    }
});

wizard.start();

With pldf-parser Integration

const { DocassembleParser } = require('pldf-parser');
const InterviewWizard = require('pldf-interview-engine');

// Parse a YAML file
const interview = DocassembleParser.parseFile('interview.yml');

// Create and start the wizard
const wizard = new InterviewWizard(interview, {
    container: '#interview',
    autoSave: true,
    onComplete: (answers) => {
        console.log('Answers:', answers);
    }
});

wizard.initialize().then(() => wizard.start());

Configuration Options

new InterviewWizard(interview, {
    container: '#interview',
    autoSave: true,
    saveKey: 'pldf_interview_state',
    onComplete: (answers) => { /* ... */ },
    onBlockChange: (block, index) => { /* ... */ },
    cssPrefix: 'pldf'
});

Supported Field Types

  • text: Single-line text input
  • email: Email address input
  • number: Numeric input
  • currency: Number input with decimal precision
  • date: Date picker
  • yesno: Yes/No radio buttons
  • radio: Single selection from multiple options
  • checkboxes: Multiple selection from options
  • dropdown: Dropdown select menu
  • textarea: Multi-line text input

Interview Structure

The engine expects interview objects with this structure:

{
    filePath: 'interview.yml',
    blocks: [
        {
            blockType: 'question',
            question: 'What is your name?',
            subquestion: 'Optional additional text',
            fields: [ /* field objects */ ],
            buttons: [ /* button objects */ ],
            mandatory: false,
            variables: ['var1', 'var2']
        }
    ],
    getQuestionOrder: function(definedVars) {
        return /* ordered array of blocks */;
    }
}

This structure is automatically created by pldf-parser.

API Reference

InterviewWizard

Methods

  • initialize(): Initializes the wizard (returns Promise)
  • start(): Starts the interview
  • next(): Advances to the next question
  • previous(): Goes back to previous question
  • complete(): Marks interview as complete
  • restart(): Resets and restarts
  • getAnswers(): Returns all collected answers
  • getState(): Returns current state
  • loadState(state): Loads a saved state

Examples

See the examples/ directory for complete examples:

  • basic-usage.js: Simple Node.js example
  • with-parser.js: Integration with pldf-parser
  • demo.html: Interactive browser demo

Development

Running Tests

npm test

Running the Demo

npm start
# Then open http://localhost:3000/examples/demo.html

Integration with PLDF Ecosystem

This package is part of the PLDF ecosystem:

  • pldf-parser: Parses interview YAML files → Interview objects
  • pldf-interview-engine (this package): Interview objects → Interactive wizards
  • pldf-template: Generates documents from answers and templates

License

MIT

  • GitHub: https://github.com/step21/pldf-interview-engine
  • Issues: https://github.com/step21/pldf-interview-engine/issues
  • npm: https://www.npmjs.com/package/pldf-interview-engine

Keywords

interview

FAQs

Package last updated on 09 Dec 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