or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-1/

Configuration File Sanitizer

A utility that sanitizes configuration data by normalizing empty and missing values before converting to property list format.

Problem Description

You are building a configuration management system that needs to handle user-provided data that may contain various empty or missing values. The system should:

  1. Accept configuration data as JavaScript objects
  2. Normalize empty values according to specific rules
  3. Convert the sanitized configuration to property list XML format
  4. Parse property list files that may contain empty elements

Requirements

Input Handling

The system must handle configuration objects that may contain:

  • Empty strings
  • Empty arrays
  • Empty objects
  • Missing or optional values

Sanitization Rules

When processing configuration data:

  • Empty strings should be preserved as empty strings
  • Empty arrays should be preserved as empty arrays
  • Empty objects should be preserved as empty objects
  • These empty values must roundtrip correctly through serialization and deserialization

Output Format

The system must produce valid property list XML that:

  • Correctly represents empty values
  • Can be parsed back to recover the original structure
  • Follows standard property list formatting conventions

Test Cases

  • It correctly handles a configuration with empty string values @test
  • It correctly handles a configuration with empty arrays @test
  • It correctly handles a configuration with empty objects @test
  • It correctly roundtrips a configuration containing mixed empty values @test

Implementation

@generates

API

/**
 * Sanitizes and converts a configuration object to property list XML format.
 * Preserves empty strings, arrays, and objects correctly.
 *
 * @param {Object} config - The configuration object to sanitize
 * @returns {string} Property list XML string
 */
function sanitizeConfig(config) {
  // IMPLEMENTATION HERE
}

/**
 * Parses a property list XML string back into a configuration object.
 * Correctly interprets empty elements.
 *
 * @param {string} xmlString - The property list XML to parse
 * @returns {Object} The parsed configuration object
 */
function parseConfig(xmlString) {
  // IMPLEMENTATION HERE
}

module.exports = {
  sanitizeConfig,
  parseConfig
};

Dependencies { .dependencies }

plist { .dependency }

Provides property list parsing and building support.