airbyte-cdk 6.15.0__py3-none-any.whl → 6.16.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -667,6 +667,28 @@ definitions:
667
667
  $parameters:
668
668
  type: object
669
669
  additionalProperties: true
670
+ CustomSchemaNormalization:
671
+ title: Custom Schema Normalization
672
+ description: Schema normalization component whose behavior is derived from a custom code implementation of the connector.
673
+ type: object
674
+ additionalProperties: true
675
+ required:
676
+ - type
677
+ - class_name
678
+ properties:
679
+ type:
680
+ type: string
681
+ enum: [ CustomSchemaNormalization ]
682
+ class_name:
683
+ title: Class Name
684
+ description: Fully-qualified name of the class that will be implementing the custom normalization. The format is `source_<name>.<package>.<class_name>`.
685
+ type: string
686
+ additionalProperties: true
687
+ examples:
688
+ - "source_amazon_seller_partner.components.LedgerDetailedViewReportsTypeTransformer"
689
+ $parameters:
690
+ type: object
691
+ additionalProperties: true
670
692
  CustomStateMigration:
671
693
  title: Custom State Migration
672
694
  description: Apply a custom transformation on the input state.
@@ -2600,7 +2622,11 @@ definitions:
2600
2622
  - "$ref": "#/definitions/CustomRecordFilter"
2601
2623
  - "$ref": "#/definitions/RecordFilter"
2602
2624
  schema_normalization:
2603
- "$ref": "#/definitions/SchemaNormalization"
2625
+ title: Schema Normalization
2626
+ description: Responsible for normalization according to the schema.
2627
+ anyOf:
2628
+ - "$ref": "#/definitions/SchemaNormalization"
2629
+ - "$ref": "#/definitions/CustomSchemaNormalization"
2604
2630
  default: None
2605
2631
  $parameters:
2606
2632
  type: object
@@ -9,8 +9,10 @@ from airbyte_cdk.sources.declarative.extractors.record_selector import RecordSel
9
9
  from airbyte_cdk.sources.declarative.extractors.response_to_file_extractor import (
10
10
  ResponseToFileExtractor,
11
11
  )
12
+ from airbyte_cdk.sources.declarative.extractors.type_transformer import TypeTransformer
12
13
 
13
14
  __all__ = [
15
+ "TypeTransformer",
14
16
  "HttpSelector",
15
17
  "DpathExtractor",
16
18
  "RecordFilter",
@@ -10,16 +10,14 @@ import requests
10
10
  from airbyte_cdk.sources.declarative.extractors.http_selector import HttpSelector
11
11
  from airbyte_cdk.sources.declarative.extractors.record_extractor import RecordExtractor
12
12
  from airbyte_cdk.sources.declarative.extractors.record_filter import RecordFilter
13
+ from airbyte_cdk.sources.declarative.extractors.type_transformer import (
14
+ TypeTransformer as DeclarativeTypeTransformer,
15
+ )
13
16
  from airbyte_cdk.sources.declarative.interpolation import InterpolatedString
14
17
  from airbyte_cdk.sources.declarative.models import SchemaNormalization
15
18
  from airbyte_cdk.sources.declarative.transformations import RecordTransformation
16
19
  from airbyte_cdk.sources.types import Config, Record, StreamSlice, StreamState
17
- from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer
18
-
19
- SCHEMA_TRANSFORMER_TYPE_MAPPING = {
20
- SchemaNormalization.None_: TransformConfig.NoTransform,
21
- SchemaNormalization.Default: TransformConfig.DefaultSchemaNormalization,
22
- }
20
+ from airbyte_cdk.sources.utils.transform import TypeTransformer
23
21
 
24
22
 
25
23
  @dataclass
@@ -38,7 +36,7 @@ class RecordSelector(HttpSelector):
38
36
  extractor: RecordExtractor
39
37
  config: Config
40
38
  parameters: InitVar[Mapping[str, Any]]
41
- schema_normalization: TypeTransformer
39
+ schema_normalization: Union[TypeTransformer, DeclarativeTypeTransformer]
42
40
  name: str
43
41
  _name: Union[InterpolatedString, str] = field(init=False, repr=False, default="")
44
42
  record_filter: Optional[RecordFilter] = None
@@ -0,0 +1,55 @@
1
+ #
2
+ # Copyright (c) 2025 Airbyte, Inc., all rights reserved.
3
+ #
4
+
5
+ from abc import ABC, abstractmethod
6
+ from dataclasses import dataclass
7
+ from typing import Any, Dict, Mapping
8
+
9
+
10
+ @dataclass
11
+ class TypeTransformer(ABC):
12
+ """
13
+ Abstract base class for implementing type transformation logic.
14
+
15
+ This class provides a blueprint for defining custom transformations
16
+ on data records based on a provided schema. Implementing classes
17
+ must override the `transform` method to specify the transformation
18
+ logic.
19
+
20
+ Attributes:
21
+ None explicitly defined, as this is a dataclass intended to be
22
+ subclassed.
23
+
24
+ Methods:
25
+ transform(record: Dict[str, Any], schema: Mapping[str, Any]) -> None:
26
+ Abstract method that must be implemented by subclasses.
27
+ It performs a transformation on a given data record based
28
+ on the provided schema.
29
+
30
+ Usage:
31
+ To use this class, create a subclass that implements the
32
+ `transform` method with the desired transformation logic.
33
+ """
34
+
35
+ @abstractmethod
36
+ def transform(
37
+ self,
38
+ record: Dict[str, Any],
39
+ schema: Mapping[str, Any],
40
+ ) -> None:
41
+ """
42
+ Perform a transformation on a data record based on a given schema.
43
+
44
+ Args:
45
+ record (Dict[str, Any]): The data record to be transformed.
46
+ schema (Mapping[str, Any]): The schema that dictates how
47
+ the record should be transformed.
48
+
49
+ Returns:
50
+ None
51
+
52
+ Raises:
53
+ NotImplementedError: If the method is not implemented
54
+ by a subclass.
55
+ """
@@ -268,6 +268,22 @@ class CustomSchemaLoader(BaseModel):
268
268
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
269
269
 
270
270
 
271
+ class CustomSchemaNormalization(BaseModel):
272
+ class Config:
273
+ extra = Extra.allow
274
+
275
+ type: Literal["CustomSchemaNormalization"]
276
+ class_name: str = Field(
277
+ ...,
278
+ description="Fully-qualified name of the class that will be implementing the custom normalization. The format is `source_<name>.<package>.<class_name>`.",
279
+ examples=[
280
+ "source_amazon_seller_partner.components.LedgerDetailedViewReportsTypeTransformer"
281
+ ],
282
+ title="Class Name",
283
+ )
284
+ parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
285
+
286
+
271
287
  class CustomStateMigration(BaseModel):
272
288
  class Config:
273
289
  extra = Extra.allow
@@ -1530,7 +1546,11 @@ class RecordSelector(BaseModel):
1530
1546
  description="Responsible for filtering records to be emitted by the Source.",
1531
1547
  title="Record Filter",
1532
1548
  )
1533
- schema_normalization: Optional[SchemaNormalization] = SchemaNormalization.None_
1549
+ schema_normalization: Optional[Union[SchemaNormalization, CustomSchemaNormalization]] = Field(
1550
+ SchemaNormalization.None_,
1551
+ description="Responsible for normalization according to the schema.",
1552
+ title="Schema Normalization",
1553
+ )
1534
1554
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
1535
1555
 
1536
1556
 
@@ -82,9 +82,6 @@ from airbyte_cdk.sources.declarative.extractors import (
82
82
  from airbyte_cdk.sources.declarative.extractors.record_filter import (
83
83
  ClientSideIncrementalRecordFilterDecorator,
84
84
  )
85
- from airbyte_cdk.sources.declarative.extractors.record_selector import (
86
- SCHEMA_TRANSFORMER_TYPE_MAPPING,
87
- )
88
85
  from airbyte_cdk.sources.declarative.incremental import (
89
86
  ChildPartitionResumableFullRefreshCursor,
90
87
  CursorFactory,
@@ -100,7 +97,9 @@ from airbyte_cdk.sources.declarative.interpolation.interpolated_mapping import I
100
97
  from airbyte_cdk.sources.declarative.migrations.legacy_to_per_partition_state_migration import (
101
98
  LegacyToPerPartitionStateMigration,
102
99
  )
103
- from airbyte_cdk.sources.declarative.models import CustomStateMigration
100
+ from airbyte_cdk.sources.declarative.models import (
101
+ CustomStateMigration,
102
+ )
104
103
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
105
104
  AddedFieldDefinition as AddedFieldDefinitionModel,
106
105
  )
@@ -185,6 +184,9 @@ from airbyte_cdk.sources.declarative.models.declarative_component_schema import
185
184
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
186
185
  CustomSchemaLoader as CustomSchemaLoader,
187
186
  )
187
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
188
+ CustomSchemaNormalization as CustomSchemaNormalizationModel,
189
+ )
188
190
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
189
191
  CustomTransformation as CustomTransformationModel,
190
192
  )
@@ -311,6 +313,9 @@ from airbyte_cdk.sources.declarative.models.declarative_component_schema import
311
313
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
312
314
  ResponseToFileExtractor as ResponseToFileExtractorModel,
313
315
  )
316
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
317
+ SchemaNormalization as SchemaNormalizationModel,
318
+ )
314
319
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
315
320
  SchemaTypeIdentifier as SchemaTypeIdentifierModel,
316
321
  )
@@ -445,6 +450,11 @@ from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer
445
450
 
446
451
  ComponentDefinition = Mapping[str, Any]
447
452
 
453
+ SCHEMA_TRANSFORMER_TYPE_MAPPING = {
454
+ SchemaNormalizationModel.None_: TransformConfig.NoTransform,
455
+ SchemaNormalizationModel.Default: TransformConfig.DefaultSchemaNormalization,
456
+ }
457
+
448
458
 
449
459
  class ModelToComponentFactory:
450
460
  EPOCH_DATETIME_FORMAT = "%s"
@@ -493,6 +503,7 @@ class ModelToComponentFactory:
493
503
  CustomRequesterModel: self.create_custom_component,
494
504
  CustomRetrieverModel: self.create_custom_component,
495
505
  CustomSchemaLoader: self.create_custom_component,
506
+ CustomSchemaNormalizationModel: self.create_custom_component,
496
507
  CustomStateMigration: self.create_custom_component,
497
508
  CustomPaginationStrategyModel: self.create_custom_component,
498
509
  CustomPartitionRouterModel: self.create_custom_component,
@@ -1574,7 +1585,12 @@ class ModelToComponentFactory:
1574
1585
  )
1575
1586
 
1576
1587
  def create_http_requester(
1577
- self, model: HttpRequesterModel, decoder: Decoder, config: Config, *, name: str
1588
+ self,
1589
+ model: HttpRequesterModel,
1590
+ config: Config,
1591
+ decoder: Decoder = JsonDecoder(parameters={}),
1592
+ *,
1593
+ name: str,
1578
1594
  ) -> HttpRequester:
1579
1595
  authenticator = (
1580
1596
  self._create_component_from_model(
@@ -1990,12 +2006,11 @@ class ModelToComponentFactory:
1990
2006
  config: Config,
1991
2007
  *,
1992
2008
  name: str,
1993
- transformations: List[RecordTransformation],
1994
- decoder: Optional[Decoder] = None,
1995
- client_side_incremental_sync: Optional[Dict[str, Any]] = None,
2009
+ transformations: List[RecordTransformation] | None = None,
2010
+ decoder: Decoder | None = None,
2011
+ client_side_incremental_sync: Dict[str, Any] | None = None,
1996
2012
  **kwargs: Any,
1997
2013
  ) -> RecordSelector:
1998
- assert model.schema_normalization is not None # for mypy
1999
2014
  extractor = self._create_component_from_model(
2000
2015
  model=model.extractor, decoder=decoder, config=config
2001
2016
  )
@@ -2013,8 +2028,10 @@ class ModelToComponentFactory:
2013
2028
  else None,
2014
2029
  **client_side_incremental_sync,
2015
2030
  )
2016
- schema_normalization = TypeTransformer(
2017
- SCHEMA_TRANSFORMER_TYPE_MAPPING[model.schema_normalization]
2031
+ schema_normalization = (
2032
+ TypeTransformer(SCHEMA_TRANSFORMER_TYPE_MAPPING[model.schema_normalization])
2033
+ if isinstance(model.schema_normalization, SchemaNormalizationModel)
2034
+ else self._create_component_from_model(model.schema_normalization, config=config) # type: ignore[arg-type] # custom normalization model expected here
2018
2035
  )
2019
2036
 
2020
2037
  return RecordSelector(
@@ -2022,7 +2039,7 @@ class ModelToComponentFactory:
2022
2039
  name=name,
2023
2040
  config=config,
2024
2041
  record_filter=record_filter,
2025
- transformations=transformations,
2042
+ transformations=transformations or [],
2026
2043
  schema_normalization=schema_normalization,
2027
2044
  parameters=model.parameters or {},
2028
2045
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: airbyte-cdk
3
- Version: 6.15.0
3
+ Version: 6.16.0
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  Home-page: https://airbyte.com
6
6
  License: MIT
@@ -66,7 +66,7 @@ airbyte_cdk/sources/declarative/concurrent_declarative_source.py,sha256=PxP4p268
66
66
  airbyte_cdk/sources/declarative/datetime/__init__.py,sha256=l9LG7Qm6e5r_qgqfVKnx3mXYtg1I9MmMjomVIPfU4XA,177
67
67
  airbyte_cdk/sources/declarative/datetime/datetime_parser.py,sha256=SX9JjdesN1edN2WVUVMzU_ptqp2QB1OnsnjZ4mwcX7w,2579
68
68
  airbyte_cdk/sources/declarative/datetime/min_max_datetime.py,sha256=0BHBtDNQZfvwM45-tY5pNlTcKAFSGGNxemoi0Jic-0E,5785
69
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=W8H8rYMEJihZBY3VgGUo-lo4OfCze9Rli2NorehDr38,131973
69
+ airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=inomzf30NXQINy4c21hwL0Cya4Ee-YNy20h9P-D42rk,132996
70
70
  airbyte_cdk/sources/declarative/declarative_source.py,sha256=nF7wBqFd3AQmEKAm4CnIo29CJoQL562cJGSCeL8U8bA,1531
71
71
  airbyte_cdk/sources/declarative/declarative_stream.py,sha256=JRyNeOIpsFu4ztVZsN6sncqUEIqIE-bUkD2TPgbMgk0,10375
72
72
  airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=edGj4fGxznBk4xzRQyCA1rGfbpqe7z-RE0K3kQQWbgA,858
@@ -77,13 +77,14 @@ airbyte_cdk/sources/declarative/decoders/noop_decoder.py,sha256=iZh0yKY_JzgBnJWi
77
77
  airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py,sha256=ZVBZhAOl0I0MymXN5CKTC-kIXG4GuUQAEyn0XpUDuSE,1081
78
78
  airbyte_cdk/sources/declarative/decoders/xml_decoder.py,sha256=EU-7t-5vIGRHZ14h-f0GUE4V5-eTM9Flux-A8xgI1Rc,3117
79
79
  airbyte_cdk/sources/declarative/exceptions.py,sha256=kTPUA4I2NV4J6HDz-mKPGMrfuc592akJnOyYx38l_QM,176
80
- airbyte_cdk/sources/declarative/extractors/__init__.py,sha256=J1WeMqtvGq7TwW7Ajc46S5jLcv22ptqmSuUXqUB9YG0,643
80
+ airbyte_cdk/sources/declarative/extractors/__init__.py,sha256=RmV-IkO1YLj0PSOrrqC9AV1gO8-90t8UTDVfJGshN9E,754
81
81
  airbyte_cdk/sources/declarative/extractors/dpath_extractor.py,sha256=wR4Ol4MG2lt5UlqXF5EU_k7qa5cN4_-luu3PJ1PlO3A,3131
82
82
  airbyte_cdk/sources/declarative/extractors/http_selector.py,sha256=2zWZ4ewTqQC8VwkjS0xD_u350Km3SiYP7hpOOgiLg5o,1169
83
83
  airbyte_cdk/sources/declarative/extractors/record_extractor.py,sha256=XJELMjahAsaomlvQgN2zrNO0DJX0G0fr9r682gUz7Pg,691
84
84
  airbyte_cdk/sources/declarative/extractors/record_filter.py,sha256=OJ9xmhNWNwwzxYOeIrDy1GINb1zH9MBy6suC5tm2LSk,3545
85
- airbyte_cdk/sources/declarative/extractors/record_selector.py,sha256=AkXPOWyp741cpYLBl9AbmVmOQmQ2BzZ2XjgsMEB6gGc,6583
85
+ airbyte_cdk/sources/declarative/extractors/record_selector.py,sha256=tjNwcURmlyD-TGCScXvW95ThNKyPGcx2SiWbG1-H-sc,6552
86
86
  airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py,sha256=LhqGDfX06_dDYLKsIVnwQ_nAWCln-v8PV7Wgt_QVeTI,6533
87
+ airbyte_cdk/sources/declarative/extractors/type_transformer.py,sha256=d6Y2Rfg8pMVEEnHllfVksWZdNVOU55yk34O03dP9muY,1626
87
88
  airbyte_cdk/sources/declarative/incremental/__init__.py,sha256=huRz3KQJSUFmJCg5GPE9TckEBsB5TMsCa_THhJAhPVI,1037
88
89
  airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py,sha256=_UzUnSIUsDbRgbFTXgSyZEFb4ws-KdhdQPWO8mFbV7U,22028
89
90
  airbyte_cdk/sources/declarative/incremental/declarative_cursor.py,sha256=5Bhw9VRPyIuCaD0wmmq_L3DZsa-rJgtKSEUzSd8YYD0,536
@@ -105,12 +106,12 @@ airbyte_cdk/sources/declarative/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW
105
106
  airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py,sha256=iemy3fKLczcU0-Aor7tx5jcT6DRedKMqyK7kCOp01hg,3924
106
107
  airbyte_cdk/sources/declarative/migrations/state_migration.py,sha256=KWPjealMLKSMtajXgkdGgKg7EmTLR-CqqD7UIh0-eDU,794
107
108
  airbyte_cdk/sources/declarative/models/__init__.py,sha256=nUFxNCiKeYRVXuZEKA7GD-lTHxsiKcQ8FitZjKhPIvE,100
108
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=U64qHqBut90L29EuUJ2_4OdY6eCMZIL2MH4DqGYhifQ,92340
109
+ airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=-V0knL97aS3sxEEmQclzFo_v8j3syD4vpoQKD0DoaEY,93092
109
110
  airbyte_cdk/sources/declarative/parsers/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
110
111
  airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
111
112
  airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=CXwTfD3wSQq3okcqwigpprbHhSURUokh4GK2OmOyKC8,9132
112
113
  airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=IWUOdF03o-aQn0Occo1BJCxU0Pz-QILk5L67nzw2thw,6803
113
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=xNrr3RuD2dd-u5Ryfv3Wf1bEYC3uYoSzntgCiAQXy84,108538
114
+ airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=hrFO0Xcx7Z_pzT-0farwQwZ-Wxp0AZX1SD-qPn7GVto,109244
114
115
  airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=HJ-Syp3p7RpyR_OK0X_a2kSyISfu3W-PKrRI16iY0a8,957
115
116
  airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=n82J15S8bjeMZ5uROu--P3hnbQoxkY5v7RPHYx7g7ro,2929
116
117
  airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=c5cuVFM6NFkuQqG8Z5IwkBuwDrvXZN1CunUOM_L0ezg,6892
@@ -341,8 +342,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=-pHexlNYoWYPnXNH-M7HEbjmeJe9Zk7SJijdQ7d
341
342
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
342
343
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
343
344
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
344
- airbyte_cdk-6.15.0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
345
- airbyte_cdk-6.15.0.dist-info/METADATA,sha256=aIk10nM3OL1ldN48mbZAdfd8mOWeSyVfeJMwHYMos8s,5988
346
- airbyte_cdk-6.15.0.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
347
- airbyte_cdk-6.15.0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
348
- airbyte_cdk-6.15.0.dist-info/RECORD,,
345
+ airbyte_cdk-6.16.0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
346
+ airbyte_cdk-6.16.0.dist-info/METADATA,sha256=F18qVp9kQZ-lm_5nGIFbfCYYGwhr6j8DfHNaOrTo_Eo,5988
347
+ airbyte_cdk-6.16.0.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
348
+ airbyte_cdk-6.16.0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
349
+ airbyte_cdk-6.16.0.dist-info/RECORD,,