utils.ts

Overview

The utils.ts file contains utility functions that facilitate data transformation related to the BeginQuery interface. Its primary purpose is to convert an object with keyed entries into an array of BeginQuery objects, each augmented with its corresponding key. This transformation is useful for cases where an object-based representation needs to be converted into a list format, which is often easier to iterate over or process in workflows such as querying, UI rendering, or data manipulation.


Functions

buildBeginInputListFromObject

function buildBeginInputListFromObject(
  inputs: Record<string, Omit<BeginQuery, 'key'>>
): BeginQuery[]

Description

Transforms an object whose keys are strings and values are partial BeginQuery objects (without the key property) into an array of complete BeginQuery objects, each including the original key as the key property.

Parameters

Returns

Usage Example

import { buildBeginInputListFromObject } from './utils';
import { BeginQuery } from '../../interface';

const inputObject = {
  first: { param1: 'value1', param2: 123 },
  second: { param1: 'value2', param2: 456 },
};

const result = buildBeginInputListFromObject(inputObject);
/*
result = [
  { key: 'first', param1: 'value1', param2: 123 },
  { key: 'second', param1: 'value2', param2: 456 }
]
*/

Implementation Details


Interaction with Other Parts of the System


Mermaid Diagram

flowchart TD
    A[buildBeginInputListFromObject] --> B[inputs: Record<string, Omit<BeginQuery, 'key'>>]
    A --> C[returns: BeginQuery[]]
    B --> D{Object.entries(inputs)}
    D --> E[Iterate over [key, value]]
    E --> F[Create BeginQuery object with key]
    F --> G[Push to results array]
    G --> C

Summary

The utils.ts file is a focused utility module that provides a single, well-defined function for transforming an object of partial BeginQuery entries into a complete array of BeginQuery objects. This transformation is essential for workflows that require list-based data manipulation and enhances type safety and consistency across the system by enforcing inclusion of the key property.


End of Documentation for utils.ts