Repository: meltano/sdk (python)

Issue:
[Bug]: Setting `add_record_metadata` should be surfaced as builtin target configuration
### Singer SDK Version

0.14.0

### Python Version

NA

### Bug scope

Targets (data type handling, batching, SQL object generation, etc.)

### Operating System

NA

### Description

The flag is retrieved from config in https://github.com/meltano/sdk/blob/253851e005a92549684959f4f6150abc0617264b/singer_sdk/sinks/core.py#L187-L194

and it's documented in https://github.com/meltano/sdk/blob/1576b5c290396e8875c1daca8e8d920497467486/docs/implementation/record_metadata.md?plain=1#L1-L15

but the target's config schema is not aware of the setting.

This can be fixed by implementing `append_builtin_config` in the `Target` class to include that setting.

### Code

_No response_

Pull request description:
fix: Expose `add_record_metadata` as a builtin target setting
Closes #1199 


<!-- readthedocs-preview meltano-sdk start -->
----
:books: Documentation preview :books:: https://meltano-sdk--1881.org.readthedocs.build/en/1881/

<!-- readthedocs-preview meltano-sdk end -->

Patch:
diff --git a/singer_sdk/helpers/capabilities.py b/singer_sdk/helpers/capabilities.py
index 55aff8ce..f5b5fa30 100644
--- a/singer_sdk/helpers/capabilities.py
+++ b/singer_sdk/helpers/capabilities.py
@@ -99,6 +99,13 @@ TARGET_SCHEMA_CONFIG = PropertiesList(
         description="The default target database schema name to use for all streams.",
     ),
 ).to_dict()
+ADD_RECORD_METADATA_CONFIG = PropertiesList(
+    Property(
+        "add_record_metadata",
+        BooleanType(),
+        description="Add metadata to records.",
+    ),
+).to_dict()
 
 
 class DeprecatedEnum(Enum):
diff --git a/singer_sdk/target_base.py b/singer_sdk/target_base.py
index 91bce652..a5386199 100644
--- a/singer_sdk/target_base.py
+++ b/singer_sdk/target_base.py
@@ -17,6 +17,7 @@ from singer_sdk.helpers._batch import BaseBatchFileEncoding
 from singer_sdk.helpers._classproperty import classproperty
 from singer_sdk.helpers._compat import final
 from singer_sdk.helpers.capabilities import (
+    ADD_RECORD_METADATA_CONFIG,
     BATCH_CONFIG,
     TARGET_SCHEMA_CONFIG,
     CapabilitiesEnum,
@@ -595,6 +596,8 @@ class Target(PluginBase, SingerReader, metaclass=abc.ABCMeta):
                 if k not in target_jsonschema["properties"]:
                     target_jsonschema["properties"][k] = v
 
+        _merge_missing(ADD_RECORD_METADATA_CONFIG, config_jsonschema)
+
         capabilities = cls.capabilities
 
         if PluginCapabilities.BATCH in capabilities:


Test patch:
diff --git a/tests/core/test_target_base.py b/tests/core/test_target_base.py
index f9b342d3..de344c7e 100644
--- a/tests/core/test_target_base.py
+++ b/tests/core/test_target_base.py
@@ -75,6 +75,7 @@ def test_target_about_info():
     assert "flattening_enabled" in about.settings["properties"]
     assert "flattening_max_depth" in about.settings["properties"]
     assert "batch_config" in about.settings["properties"]
+    assert "add_record_metadata" in about.settings["properties"]
 
 
 def test_sql_get_sink():