airbyte-cdk 6.25.1.dev0__py3-none-any.whl → 6.26.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.
@@ -1800,6 +1800,19 @@ definitions:
1800
1800
  $parameters:
1801
1801
  type: object
1802
1802
  additionalProperties: true
1803
+ ComplexFieldType:
1804
+ title: Schema Field Type
1805
+ description: (This component is experimental. Use at your own risk.) Represents a complex field type.
1806
+ type: object
1807
+ required:
1808
+ - field_type
1809
+ properties:
1810
+ field_type:
1811
+ type: string
1812
+ items:
1813
+ anyOf:
1814
+ - type: string
1815
+ - "$ref": "#/definitions/ComplexFieldType"
1803
1816
  TypesMap:
1804
1817
  title: Types Map
1805
1818
  description: (This component is experimental. Use at your own risk.) Represents a mapping between a current type and its corresponding target type.
@@ -1814,6 +1827,7 @@ definitions:
1814
1827
  - type: array
1815
1828
  items:
1816
1829
  type: string
1830
+ - "$ref": "#/definitions/ComplexFieldType"
1817
1831
  current_type:
1818
1832
  anyOf:
1819
1833
  - type: string
@@ -736,8 +736,13 @@ class HttpResponseFilter(BaseModel):
736
736
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
737
737
 
738
738
 
739
+ class ComplexFieldType(BaseModel):
740
+ field_type: str
741
+ items: Optional[Union[str, ComplexFieldType]] = None
742
+
743
+
739
744
  class TypesMap(BaseModel):
740
- target_type: Union[str, List[str]]
745
+ target_type: Union[str, List[str], ComplexFieldType]
741
746
  current_type: Union[str, List[str]]
742
747
  condition: Optional[str] = None
743
748
 
@@ -2260,6 +2265,7 @@ class DynamicDeclarativeStream(BaseModel):
2260
2265
  )
2261
2266
 
2262
2267
 
2268
+ ComplexFieldType.update_forward_refs()
2263
2269
  CompositeErrorHandler.update_forward_refs()
2264
2270
  DeclarativeSource1.update_forward_refs()
2265
2271
  DeclarativeSource2.update_forward_refs()
@@ -133,6 +133,9 @@ from airbyte_cdk.sources.declarative.models.declarative_component_schema import
133
133
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
134
134
  CheckStream as CheckStreamModel,
135
135
  )
136
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
137
+ ComplexFieldType as ComplexFieldTypeModel,
138
+ )
136
139
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
137
140
  ComponentMappingDefinition as ComponentMappingDefinitionModel,
138
141
  )
@@ -429,6 +432,7 @@ from airbyte_cdk.sources.declarative.retrievers import (
429
432
  SimpleRetrieverTestReadDecorator,
430
433
  )
431
434
  from airbyte_cdk.sources.declarative.schema import (
435
+ ComplexFieldType,
432
436
  DefaultSchemaLoader,
433
437
  DynamicSchemaLoader,
434
438
  InlineSchemaLoader,
@@ -572,6 +576,7 @@ class ModelToComponentFactory:
572
576
  DynamicSchemaLoaderModel: self.create_dynamic_schema_loader,
573
577
  SchemaTypeIdentifierModel: self.create_schema_type_identifier,
574
578
  TypesMapModel: self.create_types_map,
579
+ ComplexFieldTypeModel: self.create_complex_field_type,
575
580
  JwtAuthenticatorModel: self.create_jwt_authenticator,
576
581
  LegacyToPerPartitionStateMigrationModel: self.create_legacy_to_per_partition_state_migration,
577
582
  ListPartitionRouterModel: self.create_list_partition_router,
@@ -1894,10 +1899,26 @@ class ModelToComponentFactory:
1894
1899
  ) -> InlineSchemaLoader:
1895
1900
  return InlineSchemaLoader(schema=model.schema_ or {}, parameters={})
1896
1901
 
1897
- @staticmethod
1898
- def create_types_map(model: TypesMapModel, **kwargs: Any) -> TypesMap:
1902
+ def create_complex_field_type(
1903
+ self, model: ComplexFieldTypeModel, config: Config, **kwargs: Any
1904
+ ) -> ComplexFieldType:
1905
+ items = (
1906
+ self._create_component_from_model(model=model.items, config=config)
1907
+ if isinstance(model.items, ComplexFieldTypeModel)
1908
+ else model.items
1909
+ )
1910
+
1911
+ return ComplexFieldType(field_type=model.field_type, items=items)
1912
+
1913
+ def create_types_map(self, model: TypesMapModel, config: Config, **kwargs: Any) -> TypesMap:
1914
+ target_type = (
1915
+ self._create_component_from_model(model=model.target_type, config=config)
1916
+ if isinstance(model.target_type, ComplexFieldTypeModel)
1917
+ else model.target_type
1918
+ )
1919
+
1899
1920
  return TypesMap(
1900
- target_type=model.target_type,
1921
+ target_type=target_type,
1901
1922
  current_type=model.current_type,
1902
1923
  condition=model.condition if model.condition is not None else "True",
1903
1924
  )
@@ -4,6 +4,7 @@
4
4
 
5
5
  from airbyte_cdk.sources.declarative.schema.default_schema_loader import DefaultSchemaLoader
6
6
  from airbyte_cdk.sources.declarative.schema.dynamic_schema_loader import (
7
+ ComplexFieldType,
7
8
  DynamicSchemaLoader,
8
9
  SchemaTypeIdentifier,
9
10
  TypesMap,
@@ -18,6 +19,7 @@ __all__ = [
18
19
  "SchemaLoader",
19
20
  "InlineSchemaLoader",
20
21
  "DynamicSchemaLoader",
22
+ "ComplexFieldType",
21
23
  "TypesMap",
22
24
  "SchemaTypeIdentifier",
23
25
  ]
@@ -18,7 +18,7 @@ from airbyte_cdk.sources.declarative.transformations import RecordTransformation
18
18
  from airbyte_cdk.sources.source import ExperimentalClassWarning
19
19
  from airbyte_cdk.sources.types import Config, StreamSlice, StreamState
20
20
 
21
- AIRBYTE_DATA_TYPES: Mapping[str, Mapping[str, Any]] = {
21
+ AIRBYTE_DATA_TYPES: Mapping[str, MutableMapping[str, Any]] = {
22
22
  "string": {"type": ["null", "string"]},
23
23
  "boolean": {"type": ["null", "boolean"]},
24
24
  "date": {"type": ["null", "string"], "format": "date"},
@@ -45,6 +45,25 @@ AIRBYTE_DATA_TYPES: Mapping[str, Mapping[str, Any]] = {
45
45
  }
46
46
 
47
47
 
48
+ @deprecated("This class is experimental. Use at your own risk.", category=ExperimentalClassWarning)
49
+ @dataclass(frozen=True)
50
+ class ComplexFieldType:
51
+ """
52
+ Identifies complex field type
53
+ """
54
+
55
+ field_type: str
56
+ items: Optional[Union[str, "ComplexFieldType"]] = None
57
+
58
+ def __post_init__(self) -> None:
59
+ """
60
+ Enforces that `items` is only used when `field_type` is a array
61
+ """
62
+ # `items_type` is valid only for array target types
63
+ if self.items and self.field_type != "array":
64
+ raise ValueError("'items' can only be used when 'field_type' is an array.")
65
+
66
+
48
67
  @deprecated("This class is experimental. Use at your own risk.", category=ExperimentalClassWarning)
49
68
  @dataclass(frozen=True)
50
69
  class TypesMap:
@@ -52,7 +71,7 @@ class TypesMap:
52
71
  Represents a mapping between a current type and its corresponding target type.
53
72
  """
54
73
 
55
- target_type: Union[List[str], str]
74
+ target_type: Union[List[str], str, ComplexFieldType]
56
75
  current_type: Union[List[str], str]
57
76
  condition: Optional[str]
58
77
 
@@ -135,8 +154,9 @@ class DynamicSchemaLoader(SchemaLoader):
135
154
  transformed_properties = self._transform(properties, {})
136
155
 
137
156
  return {
138
- "$schema": "http://json-schema.org/draft-07/schema#",
157
+ "$schema": "https://json-schema.org/draft-07/schema#",
139
158
  "type": "object",
159
+ "additionalProperties": True,
140
160
  "properties": transformed_properties,
141
161
  }
142
162
 
@@ -188,18 +208,36 @@ class DynamicSchemaLoader(SchemaLoader):
188
208
  first_type = self._get_airbyte_type(mapped_field_type[0])
189
209
  second_type = self._get_airbyte_type(mapped_field_type[1])
190
210
  return {"oneOf": [first_type, second_type]}
211
+
191
212
  elif isinstance(mapped_field_type, str):
192
213
  return self._get_airbyte_type(mapped_field_type)
214
+
215
+ elif isinstance(mapped_field_type, ComplexFieldType):
216
+ return self._resolve_complex_type(mapped_field_type)
217
+
193
218
  else:
194
219
  raise ValueError(
195
220
  f"Invalid data type. Available string or two items list of string. Got {mapped_field_type}."
196
221
  )
197
222
 
223
+ def _resolve_complex_type(self, complex_type: ComplexFieldType) -> Mapping[str, Any]:
224
+ if not complex_type.items:
225
+ return self._get_airbyte_type(complex_type.field_type)
226
+
227
+ field_type = self._get_airbyte_type(complex_type.field_type)
228
+ field_type["items"] = (
229
+ self._get_airbyte_type(complex_type.items)
230
+ if isinstance(complex_type.items, str)
231
+ else self._resolve_complex_type(complex_type.items)
232
+ )
233
+
234
+ return field_type
235
+
198
236
  def _replace_type_if_not_valid(
199
237
  self,
200
238
  field_type: Union[List[str], str],
201
239
  raw_schema: MutableMapping[str, Any],
202
- ) -> Union[List[str], str]:
240
+ ) -> Union[List[str], str, ComplexFieldType]:
203
241
  """
204
242
  Replaces a field type if it matches a type mapping in `types_map`.
205
243
  """
@@ -216,7 +254,7 @@ class DynamicSchemaLoader(SchemaLoader):
216
254
  return field_type
217
255
 
218
256
  @staticmethod
219
- def _get_airbyte_type(field_type: str) -> Mapping[str, Any]:
257
+ def _get_airbyte_type(field_type: str) -> MutableMapping[str, Any]:
220
258
  """
221
259
  Maps a field type to its corresponding Airbyte type definition.
222
260
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: airbyte-cdk
3
- Version: 6.25.1.dev0
3
+ Version: 6.26.0
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  License: MIT
6
6
  Keywords: airbyte,connector-development-kit,cdk
@@ -67,7 +67,7 @@ airbyte_cdk/sources/declarative/concurrent_declarative_source.py,sha256=wbfk5udu
67
67
  airbyte_cdk/sources/declarative/datetime/__init__.py,sha256=l9LG7Qm6e5r_qgqfVKnx3mXYtg1I9MmMjomVIPfU4XA,177
68
68
  airbyte_cdk/sources/declarative/datetime/datetime_parser.py,sha256=SX9JjdesN1edN2WVUVMzU_ptqp2QB1OnsnjZ4mwcX7w,2579
69
69
  airbyte_cdk/sources/declarative/datetime/min_max_datetime.py,sha256=0BHBtDNQZfvwM45-tY5pNlTcKAFSGGNxemoi0Jic-0E,5785
70
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=40Ts1-r0UnF3AhAj9pXE2pf6Y8WBqRAksjTaBiCuxq0,139243
70
+ airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=yHOfjvrxDVnQmMi-mrdM27Y0Uqk4fYMmp9Rwdbq6-7s,139662
71
71
  airbyte_cdk/sources/declarative/declarative_source.py,sha256=nF7wBqFd3AQmEKAm4CnIo29CJoQL562cJGSCeL8U8bA,1531
72
72
  airbyte_cdk/sources/declarative/declarative_stream.py,sha256=JRyNeOIpsFu4ztVZsN6sncqUEIqIE-bUkD2TPgbMgk0,10375
73
73
  airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=KSpQetKGqPCv-38QgcVJ5kzM5nzbFldTSsYDCS3Xf0Y,1035
@@ -109,13 +109,13 @@ airbyte_cdk/sources/declarative/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW
109
109
  airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py,sha256=iemy3fKLczcU0-Aor7tx5jcT6DRedKMqyK7kCOp01hg,3924
110
110
  airbyte_cdk/sources/declarative/migrations/state_migration.py,sha256=KWPjealMLKSMtajXgkdGgKg7EmTLR-CqqD7UIh0-eDU,794
111
111
  airbyte_cdk/sources/declarative/models/__init__.py,sha256=nUFxNCiKeYRVXuZEKA7GD-lTHxsiKcQ8FitZjKhPIvE,100
112
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=9SHqGpoMDIysyFLzkZoAehbsroHQKYPctIwXmSqO4Zw,97888
112
+ airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=68JPw6bLHnTh7zGN3CC8B6b9NI4hxvSPOyLyY8TVRqk,98059
113
113
  airbyte_cdk/sources/declarative/parsers/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
114
114
  airbyte_cdk/sources/declarative/parsers/custom_code_compiler.py,sha256=958MMX6_ZOJUlDDdNr9Krosgi2bCKGx2Z765M2Woz18,5505
115
115
  airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
116
116
  airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=CXwTfD3wSQq3okcqwigpprbHhSURUokh4GK2OmOyKC8,9132
117
117
  airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=IWUOdF03o-aQn0Occo1BJCxU0Pz-QILk5L67nzw2thw,6803
118
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=a96vNwEc3J8S99KGtSt2G147leh8GADfkTrejVCBXzs,122064
118
+ airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=zfWJLlopJklDK1xvoUy2qMFcnSklmQ7wwEbdWVxYlw0,122917
119
119
  airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=HJ-Syp3p7RpyR_OK0X_a2kSyISfu3W-PKrRI16iY0a8,957
120
120
  airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=n82J15S8bjeMZ5uROu--P3hnbQoxkY5v7RPHYx7g7ro,2929
121
121
  airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=c5cuVFM6NFkuQqG8Z5IwkBuwDrvXZN1CunUOM_L0ezg,6892
@@ -168,9 +168,9 @@ airbyte_cdk/sources/declarative/retrievers/__init__.py,sha256=ix9m1dkR69DcXCXUKC
168
168
  airbyte_cdk/sources/declarative/retrievers/async_retriever.py,sha256=kX9ltelK2xLIBWDJBK2ucrvVe5tc5xmhdbVbgsjvlxY,3696
169
169
  airbyte_cdk/sources/declarative/retrievers/retriever.py,sha256=XPLs593Xv8c5cKMc37XzUAYmzlXd1a7eSsspM-CMuWA,1696
170
170
  airbyte_cdk/sources/declarative/retrievers/simple_retriever.py,sha256=kgnhVQxRlFqJs2-rDu2-QH-p-GzQU3nKmSp6_aq8u0s,24550
171
- airbyte_cdk/sources/declarative/schema/__init__.py,sha256=HztgVVaZdil5UfgUZcv_Hyy84r89_EKRwyO2hoewNVg,749
171
+ airbyte_cdk/sources/declarative/schema/__init__.py,sha256=xU45UvM5O4c1PSM13UHpCdh5hpW3HXy9vRRGEiAC1rg,795
172
172
  airbyte_cdk/sources/declarative/schema/default_schema_loader.py,sha256=KTACrIE23a83wsm3Rd9Eb4K6-20lrGqYxTHNp9yxsso,1820
173
- airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py,sha256=sa99VqU1U45fgZL2qEdw8ueX1tPTPfGxibQ-ZFePjSM,9361
173
+ airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py,sha256=d8tfDiDcJiunvN_Yalyfx5ISY5A-iIW3HbPwX2Hagh4,10702
174
174
  airbyte_cdk/sources/declarative/schema/inline_schema_loader.py,sha256=bVETE10hRsatRJq3R3BeyRR0wIoK3gcP1gcpVRQ_P5U,464
175
175
  airbyte_cdk/sources/declarative/schema/json_file_schema_loader.py,sha256=5Wl-fqW-pVf_dxJ4yGHMAFfC4JjKHYJhqFJT1xA57F4,4177
176
176
  airbyte_cdk/sources/declarative/schema/schema_loader.py,sha256=kjt8v0N5wWKA5zyLnrDLxf1PJKdUqvQq2RVnAOAzNSY,379
@@ -350,8 +350,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=-pHexlNYoWYPnXNH-M7HEbjmeJe9Zk7SJijdQ7d
350
350
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
351
351
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
352
352
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
353
- airbyte_cdk-6.25.1.dev0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
354
- airbyte_cdk-6.25.1.dev0.dist-info/METADATA,sha256=nuDFdgfVcmN3GzFLJL6lPfup9DciE9TN99UWQpfKT3E,6001
355
- airbyte_cdk-6.25.1.dev0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
356
- airbyte_cdk-6.25.1.dev0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
357
- airbyte_cdk-6.25.1.dev0.dist-info/RECORD,,
353
+ airbyte_cdk-6.26.0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
354
+ airbyte_cdk-6.26.0.dist-info/METADATA,sha256=tzGmGFZqFNZ_5jEwuijPrrzH5z1d5ITGm2VdZV9TzTk,5996
355
+ airbyte_cdk-6.26.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
356
+ airbyte_cdk-6.26.0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
357
+ airbyte_cdk-6.26.0.dist-info/RECORD,,