Data Models & Typings
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The flext-target-oracle-wms project utilizes a structured hierarchy of Pydantic models and specialized utility classes to facilitate the transfer of Singer-compliant data into Oracle WMS (Warehouse Management System). This module serves as the core schema definition and validation layer, ensuring that incoming messages (SCHEMA, RECORD, STATE) are correctly parsed, validated against business rules, and transformed into Oracle-compatible formats.
The data models are organized within the FlextTargetOracleWmsModels namespace, which inherits from canonical Meltano models and WMS-specific entity types. This architecture supports complex data flows, including type conversion for scalar values and the mapping of stream-based schemas to Oracle-friendly database structures.
Sources: src/flext_target_oracle_wms/models.py:1-25, src/flext_target_oracle_wms/_utilities/helpers.py:1-15
Target Configuration Models
The primary entry point for configuring the target is the WmsTargetConfig class. This model encapsulates authentication settings, stream mappings, and runtime processing parameters such as batch sizes and load methods.
WmsTargetConfig Attributes
| Field | Type | Default | Description |
|---|---|---|---|
wms_auth | WmsAuthenticationConfig | Required | Authentication and endpoint settings for Oracle WMS. |
stream_maps | MutableMapping[str, t.StrMapping] | {} | Singer stream map configurations. |
batch_size | t.BatchSize | DEFAULT_BATCH_SIZE | Number of records per batch write. |
load_method | str | "APPEND_ONLY" | Load strategy (e.g., APPEND_ONLY, UPSERT). |
validate_records | bool | True | Whether to validate records before writing. |
Sources: src/flext_target_oracle_wms/models.py:53-75
Authentication Configuration
The WmsAuthenticationConfig model defines the connection parameters required to interact with the Oracle WMS REST API. It supports multiple authentication methods including OAuth2, Basic, and API Key.
class WmsAuthenticationConfig(meltano_m.ArbitraryTypesModel):
base_url: Annotated[str, u.Field(description="Oracle WMS REST API base URL.")]
auth_method: Annotated[Literal["oauth2", "basic", "api_key"], u.Field(...)] = "oauth2"
username: str | None = None
password: t.SecretStr | None = None
company_code: str = "DEFAULT"
facility_code: str = "MAIN"
Sources: src/flext_target_oracle_wms/models.py:31-51
Schema & Message Models
The system defines specific models for handling Singer protocol messages and their internal JSON schemas. These models allow the target to interpret incoming property definitions and map them to physical storage requirements.
Class Diagram: Message Structure
The following diagram illustrates the relationship between the target configuration and the schema parsing components.
Transformation & Helper Logic
Data transformation is handled by specialized utility classes that manage the lifecycle of a record from its arrival as a Singer message to its preparation for the Oracle WMS API.
WMS Data Transformer
The WMSDataTransformer class is responsible for converting incoming RECORD messages. A key characteristic of this transformation is that it uppercases all field keys to align with Oracle naming conventions.
- Key Behavior: Iterates through record items, resolves the expected type from the schema, and uses a
WMSTypeConverterto finalize the value. - Key Output: Returns a transformed
SingerRecordMessagewith uppercased keys.
Sources: src/flext_target_oracle_wms/_utilities/helpers.py:64-106, tests/unit/test_sinks.py:73-83
WMS Type Converter
The WMSTypeConverter handles the scalar conversion of data types.
| Singer Type | Logic | Output |
|---|---|---|
object / array | JSON serialization | Stringified JSON |
integer / number | Numeric casting with fallback | int or float |
boolean | String representation | "True" or "False" |
string | Identity / Stringification | str |
Sources: src/flext_target_oracle_wms/_utilities/helpers.py:38-60, tests/unit/test_wms_patterns.py:59-75
Data Flow: Record Processing
The following sequence shows how a record is processed through the utility helpers.
Validation & Constraints
The WmsTargetConfig model includes built-in validation methods to ensure runtime integrity before processing begins.
- validate_business_rules: Checks if the
load_methodis within theVALID_LOAD_METHODSset (e.g., "APPEND_ONLY", "UPSERT", "MERGE") and ensures thebatch_sizeis positive. - Validation Helper: A static helper
validate_wms_target_configensures that the mandatory fields (base_url,username,password) are present in the provided settings dictionary.
Sources: src/flext_target_oracle_wms/models.py:77-90, src/flext_target_oracle_wms/_utilities/helpers.py:20-36, tests/unit/test_quality.py:53-57
Summary
The Data Models & Typings system provides a robust framework for handling Oracle WMS integration. By leveraging Pydantic models for configuration and specialized helper classes for data transformation, the project ensures that data transferred via the Singer protocol is strictly validated and correctly formatted for enterprise-grade warehouse management systems. Key components like the WMSDataTransformer and WMSTypeConverter maintain the necessary abstraction between source data formats and the target's Oracle-specific requirements.