simple_foundation_api

Unified Foundation Library for Eiffel Projects

v1.0.0 MIT

Overview

simple_foundation_api is a unified facade that bundles essential foundation libraries for any Eiffel project. Instead of managing multiple library dependencies, use a single FOUNDATION class that provides access to:

Features

Base64

Standard and URL-safe Base64 encoding and decoding

Hashing

SHA-256, SHA-1, MD5, and HMAC-SHA256 algorithms

UUID

Generate v4 UUIDs in standard and compact formats

JSON

Parse, validate, and build JSON with JSONPath queries

CSV

Parse and generate CSV data with header support

Markdown

Convert Markdown to HTML with table of contents

Validation

Fluent data validation with chainable rules

Random

Generate random integers, strings, words, and UUIDs

XML

Parse, query, and build XML documents with XPath

Regex

Pattern matching, replacement, and fluent builder API

DateTime

Date/time manipulation, formatting, age and duration calculations

Logger

Structured logging with levels, fields, and JSON output

HTMX

Generate HTMX-enabled HTML components

Installation

Add simple_foundation_api to your ECF configuration file:

<library name="simple_foundation_api"
        location="$SIMPLE_FOUNDATION_API\simple_foundation_api.ecf"/>

Environment Variables

Set the following environment variables:

SIMPLE_FOUNDATION_API=path/to/simple_foundation_api
SIMPLE_BASE64=path/to/simple_base64
SIMPLE_CSV=path/to/simple_csv
SIMPLE_DATETIME=path/to/simple_datetime
SIMPLE_HASH=path/to/simple_hash
SIMPLE_HTMX=path/to/simple_htmx
SIMPLE_JSON=path/to/simple_json
SIMPLE_LOGGER=path/to/simple_logger
SIMPLE_MARKDOWN=path/to/simple_markdown
SIMPLE_PROCESS=path/to/simple_process
SIMPLE_RANDOMIZER=path/to/simple_randomizer
SIMPLE_REGEX=path/to/simple_regex
SIMPLE_UUID=path/to/simple_uuid
SIMPLE_VALIDATION=path/to/simple_validation
SIMPLE_XML=path/to/simple_xml

Quick Start

local
    foundation: FOUNDATION
do
    create foundation.make

    -- Base64 encoding
    foundation.base64_encode ("Hello")  -- "SGVsbG8="

    -- SHA-256 hashing
    foundation.sha256 ("data")

    -- UUID generation
    foundation.new_uuid  -- "550e8400-e29b-41d4-a716-446655440000"

    -- JSON parsing
    if attached foundation.parse_json ("{%"name%": %"test%"}") as json then
        ...
    end

    -- Markdown conversion
    foundation.markdown_to_html ("# Hello World")

    -- Validation
    if foundation.is_valid_email ("test@example.com") then
        ...
    end

    -- Random generation
    foundation.random_integer_in_range (1, 100)
end

API Reference

Base64 Operations

base64_encode (a_input: STRING): STRING
base64_decode (a_encoded: STRING): STRING
base64_url_encode (a_input: STRING): STRING
base64_url_decode (a_encoded: STRING): STRING

Hashing Operations

sha256 (a_input: STRING): STRING
sha1 (a_input: STRING): STRING
md5 (a_input: STRING): STRING
hmac_sha256 (a_key, a_message: STRING): STRING

UUID Operations

new_uuid: STRING
new_uuid_compact: STRING
is_valid_uuid (a_string: STRING): BOOLEAN

JSON Operations

parse_json (a_json_text: STRING_32): detachable SIMPLE_JSON_VALUE
is_valid_json (a_json_text: STRING_32): BOOLEAN
new_json_object: SIMPLE_JSON_OBJECT
new_json_array: SIMPLE_JSON_ARRAY

CSV Operations

parse_csv (a_csv_text: STRING)
csv_field (a_row, a_column: INTEGER): STRING
csv_row_count: INTEGER
csv_column_count: INTEGER

Markdown Operations

markdown_to_html (a_markdown: STRING): STRING
markdown_to_html_fragment (a_markdown: STRING): STRING

Validation Operations

new_validator: SIMPLE_VALIDATOR
is_valid_email (a_value: STRING): BOOLEAN
is_valid_url (a_value: STRING): BOOLEAN

Random Operations

random_integer_in_range (a_lower, a_upper: INTEGER): INTEGER
random_alphanumeric_string (a_length: INTEGER): STRING
random_word: STRING
random_sentence: STRING

XML Operations

parse_xml (a_xml_text: STRING): detachable SIMPLE_XML_DOCUMENT
build_xml: SIMPLE_XML_BUILDER
new_xml_document: SIMPLE_XML_DOCUMENT

Regex Operations

regex_match (a_pattern, a_subject: STRING): SIMPLE_REGEX_MATCH
regex_match_all (a_pattern, a_subject: STRING): SIMPLE_REGEX_MATCH_LIST
regex_replace_all (a_pattern, a_subject, a_replacement: STRING): STRING
regex_split (a_pattern, a_subject: STRING): ARRAYED_LIST [STRING]
new_regex_builder: SIMPLE_REGEX_BUILDER
is_valid_email_pattern (a_value: STRING): BOOLEAN
is_valid_url_pattern (a_value: STRING): BOOLEAN
is_valid_ipv4 (a_value: STRING): BOOLEAN
is_valid_uuid (a_value: STRING): BOOLEAN

DateTime Operations

new_date (a_year, a_month, a_day: INTEGER): SIMPLE_DATE
new_time (a_hour, a_minute, a_second: INTEGER): SIMPLE_TIME
new_datetime_now: SIMPLE_DATE_TIME
new_duration (a_days, a_hours, a_minutes, a_seconds: INTEGER): SIMPLE_DURATION
new_age_from_birthdate (a_birthdate: SIMPLE_DATE): SIMPLE_AGE
new_date_range (a_start, a_end: SIMPLE_DATE): SIMPLE_DATE_RANGE

Logger Operations

logger: SIMPLE_LOGGER
log_debug (a_message: STRING)
log_info (a_message: STRING)
log_warn (a_message: STRING)
log_error (a_message: STRING)

HTMX Operations

htmx: SIMPLE_HTMX
htmx_button (a_text, a_target, a_endpoint: STRING): STRING
htmx_form (a_action, a_method: STRING): STRING

Dependencies

simple_foundation_api bundles the following libraries:

Library Purpose
simple_base64 Base64 encoding and decoding
simple_csv CSV parsing and generation
simple_datetime Date, time, duration, and age calculations
simple_hash Cryptographic hash functions
simple_htmx HTMX-enabled HTML component generation
simple_json JSON parsing and building
simple_logger Structured logging with JSON output
simple_markdown Markdown to HTML conversion
simple_process Shell command execution
simple_randomizer Random data generation
simple_regex Regular expressions with fluent builder
simple_uuid UUID generation and validation
simple_validation Data validation with fluent API
simple_xml XML parsing, querying, and building