airbyte-cdk 6.21.0.dev0__py3-none-any.whl → 6.21.1.dev0__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.
@@ -1316,6 +1316,7 @@ definitions:
1316
1316
  - "$ref": "#/definitions/KeysToLower"
1317
1317
  - "$ref": "#/definitions/KeysToSnakeCase"
1318
1318
  - "$ref": "#/definitions/FlattenFields"
1319
+ - "$ref": "#/definitions/DpathFlattenFields"
1319
1320
  - "$ref": "#/definitions/KeysReplace"
1320
1321
  state_migrations:
1321
1322
  title: State Migrations
@@ -1513,7 +1514,6 @@ definitions:
1513
1514
  anyOf:
1514
1515
  - "$ref": "#/definitions/JsonDecoder"
1515
1516
  - "$ref": "#/definitions/XmlDecoder"
1516
- - "$ref": "#/definitions/CompositeRawDecoder"
1517
1517
  $parameters:
1518
1518
  type: object
1519
1519
  additionalProperties: true
@@ -1789,6 +1789,10 @@ definitions:
1789
1789
  - type: array
1790
1790
  items:
1791
1791
  type: string
1792
+ condition:
1793
+ type: string
1794
+ interpolation_context:
1795
+ - raw_schema
1792
1796
  SchemaTypeIdentifier:
1793
1797
  title: Schema Type Identifier
1794
1798
  description: (This component is experimental. Use at your own risk.) Identifies schema details for dynamic schema extraction and processing.
@@ -1862,6 +1866,7 @@ definitions:
1862
1866
  - "$ref": "#/definitions/KeysToLower"
1863
1867
  - "$ref": "#/definitions/KeysToSnakeCase"
1864
1868
  - "$ref": "#/definitions/FlattenFields"
1869
+ - "$ref": "#/definitions/DpathFlattenFields"
1865
1870
  - "$ref": "#/definitions/KeysReplace"
1866
1871
  schema_type_identifier:
1867
1872
  "$ref": "#/definitions/SchemaTypeIdentifier"
@@ -1966,6 +1971,33 @@ definitions:
1966
1971
  $parameters:
1967
1972
  type: object
1968
1973
  additionalProperties: true
1974
+ DpathFlattenFields:
1975
+ title: Dpath Flatten Fields
1976
+ description: A transformation that flatten field values to the to top of the record.
1977
+ type: object
1978
+ required:
1979
+ - type
1980
+ - field_path
1981
+ properties:
1982
+ type:
1983
+ type: string
1984
+ enum: [DpathFlattenFields]
1985
+ field_path:
1986
+ title: Field Path
1987
+ description: A path to field that needs to be flattened.
1988
+ type: array
1989
+ items:
1990
+ - type: string
1991
+ examples:
1992
+ - ["data"]
1993
+ - ["data", "*", "field"]
1994
+ delete_origin_value:
1995
+ title: Delete Origin Value
1996
+ description: Whether to delete the origin value or keep it. Default is False.
1997
+ type: boolean
1998
+ $parameters:
1999
+ type: object
2000
+ additionalProperties: true
1969
2001
  KeysReplace:
1970
2002
  title: Keys Replace
1971
2003
  description: A transformation that replaces symbols in keys.
@@ -2068,24 +2100,6 @@ definitions:
2068
2100
  $parameters:
2069
2101
  type: object
2070
2102
  additionalProperties: true
2071
- ZipfileDecoder:
2072
- title: Zipfile Decoder
2073
- description: Decoder for response data that is returned as zipfile(s).
2074
- type: object
2075
- additionalProperties: true
2076
- required:
2077
- - type
2078
- - parser
2079
- properties:
2080
- type:
2081
- type: string
2082
- enum: [ZipfileDecoder]
2083
- parser:
2084
- title: Parser
2085
- description: Parser to parse the decompressed data from the zipfile(s).
2086
- anyOf:
2087
- - "$ref": "#/definitions/GzipParser"
2088
- - "$ref": "#/definitions/JsonParser"
2089
2103
  ListPartitionRouter:
2090
2104
  title: List Partition Router
2091
2105
  description: A Partition router that specifies a list of attributes where each attribute describes a portion of the complete data set for a stream. During a sync, each value is iterated over and can be used as input to outbound API requests.
@@ -2914,7 +2928,6 @@ definitions:
2914
2928
  - "$ref": "#/definitions/XmlDecoder"
2915
2929
  - "$ref": "#/definitions/GzipJsonDecoder"
2916
2930
  - "$ref": "#/definitions/CompositeRawDecoder"
2917
- - "$ref": "#/definitions/ZipfileDecoder"
2918
2931
  $parameters:
2919
2932
  type: object
2920
2933
  additionalProperties: true
@@ -3113,8 +3126,6 @@ definitions:
3113
3126
  - "$ref": "#/definitions/IterableDecoder"
3114
3127
  - "$ref": "#/definitions/XmlDecoder"
3115
3128
  - "$ref": "#/definitions/GzipJsonDecoder"
3116
- - "$ref": "#/definitions/CompositeRawDecoder"
3117
- - "$ref": "#/definitions/ZipfileDecoder"
3118
3129
  download_decoder:
3119
3130
  title: Download Decoder
3120
3131
  description: Component decoding the download response so records can be extracted.
@@ -3125,8 +3136,6 @@ definitions:
3125
3136
  - "$ref": "#/definitions/IterableDecoder"
3126
3137
  - "$ref": "#/definitions/XmlDecoder"
3127
3138
  - "$ref": "#/definitions/GzipJsonDecoder"
3128
- - "$ref": "#/definitions/CompositeRawDecoder"
3129
- - "$ref": "#/definitions/ZipfileDecoder"
3130
3139
  $parameters:
3131
3140
  type: object
3132
3141
  additionalProperties: true
@@ -2,12 +2,7 @@
2
2
  # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
3
  #
4
4
 
5
- from airbyte_cdk.sources.declarative.decoders.composite_raw_decoder import (
6
- CompositeRawDecoder,
7
- GzipParser,
8
- JsonParser,
9
- Parser,
10
- )
5
+ from airbyte_cdk.sources.declarative.decoders.composite_raw_decoder import CompositeRawDecoder
11
6
  from airbyte_cdk.sources.declarative.decoders.decoder import Decoder
12
7
  from airbyte_cdk.sources.declarative.decoders.json_decoder import (
13
8
  GzipJsonDecoder,
@@ -20,18 +15,15 @@ from airbyte_cdk.sources.declarative.decoders.pagination_decoder_decorator impor
20
15
  PaginationDecoderDecorator,
21
16
  )
22
17
  from airbyte_cdk.sources.declarative.decoders.xml_decoder import XmlDecoder
23
- from airbyte_cdk.sources.declarative.decoders.zipfile_decoder import ZipfileDecoder
24
18
 
25
19
  __all__ = [
26
20
  "Decoder",
27
21
  "CompositeRawDecoder",
28
22
  "JsonDecoder",
29
- "JsonParser",
30
23
  "JsonlDecoder",
31
24
  "IterableDecoder",
32
25
  "GzipJsonDecoder",
33
26
  "NoopDecoder",
34
27
  "PaginationDecoderDecorator",
35
28
  "XmlDecoder",
36
- "ZipfileDecoder",
37
29
  ]
@@ -719,6 +719,7 @@ class HttpResponseFilter(BaseModel):
719
719
  class TypesMap(BaseModel):
720
720
  target_type: Union[str, List[str]]
721
721
  current_type: Union[str, List[str]]
722
+ condition: Optional[str]
722
723
 
723
724
 
724
725
  class SchemaTypeIdentifier(BaseModel):
@@ -791,6 +792,25 @@ class FlattenFields(BaseModel):
791
792
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
792
793
 
793
794
 
795
+ class DpathFlattenFields(BaseModel):
796
+ type: Literal["DpathFlattenFields"]
797
+ field_path: List[str] = Field(
798
+ ...,
799
+ description="A path to field that needs to be flattened.",
800
+ examples=[
801
+ ["data"],
802
+ ["data", "*", "field"],
803
+ ],
804
+ title="Field Path",
805
+ )
806
+ delete_origin_value: Optional[bool] = Field(
807
+ False,
808
+ description="Whether to delete the origin value or keep it. Default is False.",
809
+ title="Delete Origin Value",
810
+ )
811
+ parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
812
+
813
+
794
814
  class KeysReplace(BaseModel):
795
815
  type: Literal["KeysReplace"]
796
816
  old: str = Field(
@@ -1222,6 +1242,9 @@ class LegacySessionTokenAuthenticator(BaseModel):
1222
1242
 
1223
1243
 
1224
1244
  class JsonParser(BaseModel):
1245
+ class Config:
1246
+ extra = Extra.allow
1247
+
1225
1248
  type: Literal["JsonParser"]
1226
1249
  encoding: Optional[str] = "utf-8"
1227
1250
 
@@ -1657,18 +1680,6 @@ class CompositeErrorHandler(BaseModel):
1657
1680
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
1658
1681
 
1659
1682
 
1660
- class ZipfileDecoder(BaseModel):
1661
- class Config:
1662
- extra = Extra.allow
1663
-
1664
- type: Literal["ZipfileDecoder"]
1665
- parser: Union[GzipParser, JsonParser] = Field(
1666
- ...,
1667
- description="Parser to parse the decompressed data from the zipfile(s).",
1668
- title="Parser",
1669
- )
1670
-
1671
-
1672
1683
  class CompositeRawDecoder(BaseModel):
1673
1684
  type: Literal["CompositeRawDecoder"]
1674
1685
  parser: Union[GzipParser, JsonParser, JsonLineParser, CsvParser]
@@ -1818,6 +1829,7 @@ class DeclarativeStream(BaseModel):
1818
1829
  KeysToLower,
1819
1830
  KeysToSnakeCase,
1820
1831
  FlattenFields,
1832
+ DpathFlattenFields,
1821
1833
  KeysReplace,
1822
1834
  ]
1823
1835
  ]
@@ -1874,7 +1886,7 @@ class SessionTokenAuthenticator(BaseModel):
1874
1886
  description="Authentication method to use for requests sent to the API, specifying how to inject the session token.",
1875
1887
  title="Data Request Authentication",
1876
1888
  )
1877
- decoder: Optional[Union[JsonDecoder, XmlDecoder, CompositeRawDecoder]] = Field(
1889
+ decoder: Optional[Union[JsonDecoder, XmlDecoder]] = Field(
1878
1890
  None, description="Component used to decode the response.", title="Decoder"
1879
1891
  )
1880
1892
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
@@ -1993,6 +2005,7 @@ class DynamicSchemaLoader(BaseModel):
1993
2005
  KeysToLower,
1994
2006
  KeysToSnakeCase,
1995
2007
  FlattenFields,
2008
+ DpathFlattenFields,
1996
2009
  KeysReplace,
1997
2010
  ]
1998
2011
  ]
@@ -2079,7 +2092,6 @@ class SimpleRetriever(BaseModel):
2079
2092
  XmlDecoder,
2080
2093
  GzipJsonDecoder,
2081
2094
  CompositeRawDecoder,
2082
- ZipfileDecoder,
2083
2095
  ]
2084
2096
  ] = Field(
2085
2097
  None,
@@ -2156,8 +2168,6 @@ class AsyncRetriever(BaseModel):
2156
2168
  IterableDecoder,
2157
2169
  XmlDecoder,
2158
2170
  GzipJsonDecoder,
2159
- CompositeRawDecoder,
2160
- ZipfileDecoder,
2161
2171
  ]
2162
2172
  ] = Field(
2163
2173
  None,
@@ -2172,8 +2182,6 @@ class AsyncRetriever(BaseModel):
2172
2182
  IterableDecoder,
2173
2183
  XmlDecoder,
2174
2184
  GzipJsonDecoder,
2175
- CompositeRawDecoder,
2176
- ZipfileDecoder,
2177
2185
  ]
2178
2186
  ] = Field(
2179
2187
  None,
@@ -66,7 +66,6 @@ from airbyte_cdk.sources.declarative.decoders import (
66
66
  JsonlDecoder,
67
67
  PaginationDecoderDecorator,
68
68
  XmlDecoder,
69
- ZipfileDecoder,
70
69
  )
71
70
  from airbyte_cdk.sources.declarative.decoders.composite_raw_decoder import (
72
71
  CompositeRawDecoder,
@@ -211,6 +210,9 @@ from airbyte_cdk.sources.declarative.models.declarative_component_schema import
211
210
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
212
211
  DpathExtractor as DpathExtractorModel,
213
212
  )
213
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
214
+ DpathFlattenFields as DpathFlattenFieldsModel,
215
+ )
214
216
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
215
217
  DynamicSchemaLoader as DynamicSchemaLoaderModel,
216
218
  )
@@ -357,9 +359,6 @@ from airbyte_cdk.sources.declarative.models.declarative_component_schema import
357
359
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
358
360
  XmlDecoder as XmlDecoderModel,
359
361
  )
360
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
361
- ZipfileDecoder as ZipfileDecoderModel,
362
- )
363
362
  from airbyte_cdk.sources.declarative.partition_routers import (
364
363
  CartesianProductStreamSlicer,
365
364
  ListPartitionRouter,
@@ -434,6 +433,9 @@ from airbyte_cdk.sources.declarative.transformations import (
434
433
  RemoveFields,
435
434
  )
436
435
  from airbyte_cdk.sources.declarative.transformations.add_fields import AddedFieldDefinition
436
+ from airbyte_cdk.sources.declarative.transformations.dpath_flatten_fields import (
437
+ DpathFlattenFields,
438
+ )
437
439
  from airbyte_cdk.sources.declarative.transformations.flatten_fields import (
438
440
  FlattenFields,
439
441
  )
@@ -542,6 +544,7 @@ class ModelToComponentFactory:
542
544
  KeysToSnakeCaseModel: self.create_keys_to_snake_transformation,
543
545
  KeysReplaceModel: self.create_keys_replace_transformation,
544
546
  FlattenFieldsModel: self.create_flatten_fields,
547
+ DpathFlattenFieldsModel: self.create_dpath_flatten_fields,
545
548
  IterableDecoderModel: self.create_iterable_decoder,
546
549
  XmlDecoderModel: self.create_xml_decoder,
547
550
  JsonFileSchemaLoaderModel: self.create_json_file_schema_loader,
@@ -575,7 +578,6 @@ class ModelToComponentFactory:
575
578
  ConfigComponentsResolverModel: self.create_config_components_resolver,
576
579
  StreamConfigModel: self.create_stream_config,
577
580
  ComponentMappingDefinitionModel: self.create_components_mapping_definition,
578
- ZipfileDecoderModel: self.create_zipfile_decoder,
579
581
  }
580
582
 
581
583
  # Needed for the case where we need to perform a second parse on the fields of a custom component
@@ -677,6 +679,19 @@ class ModelToComponentFactory:
677
679
  flatten_lists=model.flatten_lists if model.flatten_lists is not None else True
678
680
  )
679
681
 
682
+ def create_dpath_flatten_fields(
683
+ self, model: DpathFlattenFieldsModel, config: Config, **kwargs: Any
684
+ ) -> DpathFlattenFields:
685
+ model_field_path: List[Union[InterpolatedString, str]] = [x for x in model.field_path]
686
+ return DpathFlattenFields(
687
+ config=config,
688
+ field_path=model_field_path,
689
+ delete_origin_value=model.delete_origin_value
690
+ if model.delete_origin_value is not None
691
+ else False,
692
+ parameters=model.parameters or {},
693
+ )
694
+
680
695
  @staticmethod
681
696
  def _json_schema_type_name_to_type(value_type: Optional[ValueType]) -> Optional[Type[Any]]:
682
697
  if not value_type:
@@ -1701,7 +1716,11 @@ class ModelToComponentFactory:
1701
1716
 
1702
1717
  @staticmethod
1703
1718
  def create_types_map(model: TypesMapModel, **kwargs: Any) -> TypesMap:
1704
- return TypesMap(target_type=model.target_type, current_type=model.current_type)
1719
+ return TypesMap(
1720
+ target_type=model.target_type,
1721
+ current_type=model.current_type,
1722
+ condition=model.condition if model.condition is not None else "True",
1723
+ )
1705
1724
 
1706
1725
  def create_schema_type_identifier(
1707
1726
  self, model: SchemaTypeIdentifierModel, config: Config, **kwargs: Any
@@ -1801,12 +1820,6 @@ class ModelToComponentFactory:
1801
1820
  ) -> GzipJsonDecoder:
1802
1821
  return GzipJsonDecoder(parameters={}, encoding=model.encoding)
1803
1822
 
1804
- def create_zipfile_decoder(
1805
- self, model: ZipfileDecoderModel, config: Config, **kwargs: Any
1806
- ) -> ZipfileDecoder:
1807
- parser = self._create_component_from_model(model=model.parser, config=config)
1808
- return ZipfileDecoder(parser=parser)
1809
-
1810
1823
  def create_gzip_parser(
1811
1824
  self, model: GzipParserModel, config: Config, **kwargs: Any
1812
1825
  ) -> GzipParser:
@@ -10,6 +10,7 @@ from typing import Any, List, Mapping, MutableMapping, Optional, Union
10
10
  import dpath
11
11
  from typing_extensions import deprecated
12
12
 
13
+ from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean
13
14
  from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString
14
15
  from airbyte_cdk.sources.declarative.retrievers.retriever import Retriever
15
16
  from airbyte_cdk.sources.declarative.schema.schema_loader import SchemaLoader
@@ -53,6 +54,7 @@ class TypesMap:
53
54
 
54
55
  target_type: Union[List[str], str]
55
56
  current_type: Union[List[str], str]
57
+ condition: Optional[str]
56
58
 
57
59
 
58
60
  @deprecated("This class is experimental. Use at your own risk.", category=ExperimentalClassWarning)
@@ -177,7 +179,7 @@ class DynamicSchemaLoader(SchemaLoader):
177
179
  if field_type_path
178
180
  else "string"
179
181
  )
180
- mapped_field_type = self._replace_type_if_not_valid(raw_field_type)
182
+ mapped_field_type = self._replace_type_if_not_valid(raw_field_type, raw_schema)
181
183
  if (
182
184
  isinstance(mapped_field_type, list)
183
185
  and len(mapped_field_type) == 2
@@ -194,14 +196,22 @@ class DynamicSchemaLoader(SchemaLoader):
194
196
  )
195
197
 
196
198
  def _replace_type_if_not_valid(
197
- self, field_type: Union[List[str], str]
199
+ self,
200
+ field_type: Union[List[str], str],
201
+ raw_schema: MutableMapping[str, Any],
198
202
  ) -> Union[List[str], str]:
199
203
  """
200
204
  Replaces a field type if it matches a type mapping in `types_map`.
201
205
  """
202
206
  if self.schema_type_identifier.types_mapping:
203
207
  for types_map in self.schema_type_identifier.types_mapping:
204
- if field_type == types_map.current_type:
208
+ # conditional is optional param, setting to true if not provided
209
+ condition = InterpolatedBoolean(
210
+ condition=types_map.condition if types_map.condition is not None else "True",
211
+ parameters={},
212
+ ).eval(config=self.config, raw_schema=raw_schema)
213
+
214
+ if field_type == types_map.current_type and condition:
205
215
  return types_map.target_type
206
216
  return field_type
207
217
 
@@ -0,0 +1,55 @@
1
+ from dataclasses import InitVar, dataclass
2
+ from typing import Any, Dict, List, Mapping, Optional, Union
3
+
4
+ import dpath
5
+
6
+ from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString
7
+ from airbyte_cdk.sources.declarative.transformations import RecordTransformation
8
+ from airbyte_cdk.sources.types import Config, StreamSlice, StreamState
9
+
10
+
11
+ @dataclass
12
+ class DpathFlattenFields(RecordTransformation):
13
+ """
14
+ Flatten fields only for provided path.
15
+
16
+ field_path: List[Union[InterpolatedString, str]] path to the field to flatten.
17
+ delete_origin_value: bool = False whether to delete origin field or keep it. Default is False.
18
+
19
+ """
20
+
21
+ config: Config
22
+ field_path: List[Union[InterpolatedString, str]]
23
+ parameters: InitVar[Mapping[str, Any]]
24
+ delete_origin_value: bool = False
25
+
26
+ def __post_init__(self, parameters: Mapping[str, Any]) -> None:
27
+ self._field_path = [
28
+ InterpolatedString.create(path, parameters=parameters) for path in self.field_path
29
+ ]
30
+ for path_index in range(len(self.field_path)):
31
+ if isinstance(self.field_path[path_index], str):
32
+ self._field_path[path_index] = InterpolatedString.create(
33
+ self.field_path[path_index], parameters=parameters
34
+ )
35
+
36
+ def transform(
37
+ self,
38
+ record: Dict[str, Any],
39
+ config: Optional[Config] = None,
40
+ stream_state: Optional[StreamState] = None,
41
+ stream_slice: Optional[StreamSlice] = None,
42
+ ) -> None:
43
+ path = [path.eval(self.config) for path in self._field_path]
44
+ if "*" in path:
45
+ matched = dpath.values(record, path)
46
+ extracted = matched[0] if matched else None
47
+ else:
48
+ extracted = dpath.get(record, path, default=[])
49
+
50
+ if isinstance(extracted, dict):
51
+ conflicts = set(extracted.keys()) & set(record.keys())
52
+ if not conflicts:
53
+ if self.delete_origin_value:
54
+ dpath.delete(record, path)
55
+ record.update(extracted)
@@ -9,6 +9,7 @@ from typing import Any, Callable, Dict, Generator, Mapping, Optional, cast
9
9
 
10
10
  from jsonschema import Draft7Validator, RefResolver, ValidationError, Validator, validators
11
11
 
12
+ MAX_NESTING_DEPTH = 3
12
13
  json_to_python_simple = {
13
14
  "string": str,
14
15
  "number": float,
@@ -225,6 +226,31 @@ class TypeTransformer:
225
226
  logger.warning(self.get_error_message(e))
226
227
 
227
228
  def get_error_message(self, e: ValidationError) -> str:
228
- instance_json_type = python_to_json[type(e.instance)]
229
- key_path = "." + ".".join(map(str, e.path))
230
- return f"Failed to transform value {repr(e.instance)} of type '{instance_json_type}' to '{e.validator_value}', key path: '{key_path}'"
229
+ """
230
+ Construct a sanitized error message from a ValidationError instance.
231
+ """
232
+ field_path = ".".join(map(str, e.path))
233
+ type_structure = self._get_type_structure(e.instance)
234
+
235
+ return f"Failed to transform value from type '{type_structure}' to type '{e.validator_value}' at path: '{field_path}'"
236
+
237
+ def _get_type_structure(self, input_data: Any, current_depth: int = 0) -> Any:
238
+ """
239
+ Get the structure of a given input data for use in error message construction.
240
+ """
241
+ # Handle null values
242
+ if input_data is None:
243
+ return "null"
244
+
245
+ # Avoid recursing too deep
246
+ if current_depth >= MAX_NESTING_DEPTH:
247
+ return "object" if isinstance(input_data, dict) else python_to_json[type(input_data)]
248
+
249
+ if isinstance(input_data, dict):
250
+ return {
251
+ key: self._get_type_structure(field_value, current_depth + 1)
252
+ for key, field_value in input_data.items()
253
+ }
254
+
255
+ else:
256
+ return python_to_json[type(input_data)]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: airbyte-cdk
3
- Version: 6.21.0.dev0
3
+ Version: 6.21.1.dev0
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  License: MIT
6
6
  Keywords: airbyte,connector-development-kit,cdk
@@ -67,17 +67,16 @@ airbyte_cdk/sources/declarative/concurrent_declarative_source.py,sha256=tSTCSmyM
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=7gJ3TfTU5m4WkBw_KOooYPfegjvuGhIwyuCXSEhpMZo,136842
70
+ airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=6I_DmzMwyAmVir2402ps6QPv1gf_7prGxFUIa1YmWbY,136990
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
- airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=KSpQetKGqPCv-38QgcVJ5kzM5nzbFldTSsYDCS3Xf0Y,1035
73
+ airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=edGj4fGxznBk4xzRQyCA1rGfbpqe7z-RE0K3kQQWbgA,858
74
74
  airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py,sha256=kQfUVMVhChKe5OngwIQrs0F9KGnRUN-CKVFakCU23DQ,4354
75
75
  airbyte_cdk/sources/declarative/decoders/decoder.py,sha256=sl-Gt8lXi7yD2Q-sD8je5QS2PbgrgsYjxRLWsay7DMc,826
76
76
  airbyte_cdk/sources/declarative/decoders/json_decoder.py,sha256=qdbjeR6RffKaah_iWvMsOcDolYuxJY5DaI3b9AMTZXg,3327
77
77
  airbyte_cdk/sources/declarative/decoders/noop_decoder.py,sha256=iZh0yKY_JzgBnJWiubEusf5c0o6Khd-8EWFWT-8EgFo,542
78
78
  airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py,sha256=ZVBZhAOl0I0MymXN5CKTC-kIXG4GuUQAEyn0XpUDuSE,1081
79
79
  airbyte_cdk/sources/declarative/decoders/xml_decoder.py,sha256=EU-7t-5vIGRHZ14h-f0GUE4V5-eTM9Flux-A8xgI1Rc,3117
80
- airbyte_cdk/sources/declarative/decoders/zipfile_decoder.py,sha256=zF1Zu1hhjbLvrCl69z0v-j8FPnfHX1KLK3KgyxnTb78,1607
81
80
  airbyte_cdk/sources/declarative/exceptions.py,sha256=kTPUA4I2NV4J6HDz-mKPGMrfuc592akJnOyYx38l_QM,176
82
81
  airbyte_cdk/sources/declarative/extractors/__init__.py,sha256=RmV-IkO1YLj0PSOrrqC9AV1gO8-90t8UTDVfJGshN9E,754
83
82
  airbyte_cdk/sources/declarative/extractors/dpath_extractor.py,sha256=wR4Ol4MG2lt5UlqXF5EU_k7qa5cN4_-luu3PJ1PlO3A,3131
@@ -108,12 +107,12 @@ airbyte_cdk/sources/declarative/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW
108
107
  airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py,sha256=iemy3fKLczcU0-Aor7tx5jcT6DRedKMqyK7kCOp01hg,3924
109
108
  airbyte_cdk/sources/declarative/migrations/state_migration.py,sha256=KWPjealMLKSMtajXgkdGgKg7EmTLR-CqqD7UIh0-eDU,794
110
109
  airbyte_cdk/sources/declarative/models/__init__.py,sha256=nUFxNCiKeYRVXuZEKA7GD-lTHxsiKcQ8FitZjKhPIvE,100
111
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=CDcYWVUIQoT50X1j1Zb_bejerg1rMxZjVcNa6rJ5JMA,96194
110
+ airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=5OC6heHHLNss132yuDLtKlfzNvWLT0y55PK5ZZHlgug,96464
112
111
  airbyte_cdk/sources/declarative/parsers/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
113
112
  airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
114
113
  airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=CXwTfD3wSQq3okcqwigpprbHhSURUokh4GK2OmOyKC8,9132
115
114
  airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=IWUOdF03o-aQn0Occo1BJCxU0Pz-QILk5L67nzw2thw,6803
116
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=L8iHeRywEPZ4mDUK8oh3A7Vn6-d-6MHyLBWxlLyKVTc,112659
115
+ airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=-CGUEiNli79cXUK8kxH-VqF8vPKkkPB-ZrdGAzfqRg8,113154
117
116
  airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=HJ-Syp3p7RpyR_OK0X_a2kSyISfu3W-PKrRI16iY0a8,957
118
117
  airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=n82J15S8bjeMZ5uROu--P3hnbQoxkY5v7RPHYx7g7ro,2929
119
118
  airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=c5cuVFM6NFkuQqG8Z5IwkBuwDrvXZN1CunUOM_L0ezg,6892
@@ -168,7 +167,7 @@ airbyte_cdk/sources/declarative/retrievers/retriever.py,sha256=XPLs593Xv8c5cKMc3
168
167
  airbyte_cdk/sources/declarative/retrievers/simple_retriever.py,sha256=jxQ_9xcVD07r9PKhofitAqMkdX1k8ZNyy50qz5NwkFs,24540
169
168
  airbyte_cdk/sources/declarative/schema/__init__.py,sha256=HztgVVaZdil5UfgUZcv_Hyy84r89_EKRwyO2hoewNVg,749
170
169
  airbyte_cdk/sources/declarative/schema/default_schema_loader.py,sha256=KTACrIE23a83wsm3Rd9Eb4K6-20lrGqYxTHNp9yxsso,1820
171
- airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py,sha256=H6A3NQ6kPPM-cUNPmdvDPc9xNzR1rQNrK95GbgCW334,8822
170
+ airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py,sha256=sa99VqU1U45fgZL2qEdw8ueX1tPTPfGxibQ-ZFePjSM,9361
172
171
  airbyte_cdk/sources/declarative/schema/inline_schema_loader.py,sha256=bVETE10hRsatRJq3R3BeyRR0wIoK3gcP1gcpVRQ_P5U,464
173
172
  airbyte_cdk/sources/declarative/schema/json_file_schema_loader.py,sha256=5Wl-fqW-pVf_dxJ4yGHMAFfC4JjKHYJhqFJT1xA57F4,4177
174
173
  airbyte_cdk/sources/declarative/schema/schema_loader.py,sha256=kjt8v0N5wWKA5zyLnrDLxf1PJKdUqvQq2RVnAOAzNSY,379
@@ -179,6 +178,7 @@ airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.p
179
178
  airbyte_cdk/sources/declarative/stream_slicers/stream_slicer.py,sha256=SOkIPBi2Wu7yxIvA15yFzUAB95a3IzA8LPq5DEqHQQc,725
180
179
  airbyte_cdk/sources/declarative/transformations/__init__.py,sha256=CPJ8TlMpiUmvG3624VYu_NfTzxwKcfBjM2Q2wJ7fkSA,919
181
180
  airbyte_cdk/sources/declarative/transformations/add_fields.py,sha256=r4YdAuAk2bQtNWJMztIIy2CC-NglD9NeK1s1TeO9wkw,5027
181
+ airbyte_cdk/sources/declarative/transformations/dpath_flatten_fields.py,sha256=1A-DWGjMqY4ggzRUZsZ3Sjrt-xsNgwUo5c72sSc5OZ0,2077
182
182
  airbyte_cdk/sources/declarative/transformations/flatten_fields.py,sha256=yT3owG6rMKaRX-LJ_T-jSTnh1B5NoAHyH4YZN9yOvE8,1758
183
183
  airbyte_cdk/sources/declarative/transformations/keys_replace_transformation.py,sha256=vbIn6ump-Ut6g20yMub7PFoPBhOKVtrHSAUdcOUdLfw,1999
184
184
  airbyte_cdk/sources/declarative/transformations/keys_to_lower_transformation.py,sha256=RTs5KX4V3hM7A6QN1WlGF21YccTIyNH6qQI9IMb__hw,670
@@ -301,7 +301,7 @@ airbyte_cdk/sources/utils/casing.py,sha256=QC-gV1O4e8DR4-bhdXieUPKm_JamzslVyfABL
301
301
  airbyte_cdk/sources/utils/record_helper.py,sha256=jeB0mucudzna7Zvj-pCBbwFrbLJ36SlAWZTh5O4Fb9Y,2168
302
302
  airbyte_cdk/sources/utils/schema_helpers.py,sha256=bR3I70-e11S6B8r6VK-pthQXtcYrXojgXFvuK7lRrpg,8545
303
303
  airbyte_cdk/sources/utils/slice_logger.py,sha256=qWWeFLAvigFz0b4O1_O3QDM1cy8PqZAMMgVPR2hEeb8,1778
304
- airbyte_cdk/sources/utils/transform.py,sha256=zXlZ00akGt0OpiuYQf6FCDL0eI_Qdo1tWPKxA88RTwk,10168
304
+ airbyte_cdk/sources/utils/transform.py,sha256=Sks6kiRbef1W-5I6PRqnFxksJe2NOPKCRXQLudaltf8,11015
305
305
  airbyte_cdk/sources/utils/types.py,sha256=41ZQR681t5TUnOScij58d088sb99klH_ZENFcaYro_g,175
306
306
  airbyte_cdk/sql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
307
307
  airbyte_cdk/sql/_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -345,8 +345,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=-pHexlNYoWYPnXNH-M7HEbjmeJe9Zk7SJijdQ7d
345
345
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
346
346
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
347
347
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
348
- airbyte_cdk-6.21.0.dev0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
349
- airbyte_cdk-6.21.0.dev0.dist-info/METADATA,sha256=dv48GD8Zw_hcpqCpeJZsMd2pKjnSVxtT0S4z3JcAb84,6005
350
- airbyte_cdk-6.21.0.dev0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
351
- airbyte_cdk-6.21.0.dev0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
352
- airbyte_cdk-6.21.0.dev0.dist-info/RECORD,,
348
+ airbyte_cdk-6.21.1.dev0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
349
+ airbyte_cdk-6.21.1.dev0.dist-info/METADATA,sha256=rLLcg1ZkBdUIIOMKVg4fimX2xMBsH_zK4CxXaLdCBrU,6005
350
+ airbyte_cdk-6.21.1.dev0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
351
+ airbyte_cdk-6.21.1.dev0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
352
+ airbyte_cdk-6.21.1.dev0.dist-info/RECORD,,
@@ -1,50 +0,0 @@
1
- #
2
- # Copyright (c) 2024 Airbyte, Inc., all rights reserved.
3
- #
4
-
5
- import logging
6
- import zipfile
7
- from dataclasses import dataclass
8
- from io import BytesIO
9
- from typing import Any, Generator, MutableMapping
10
-
11
- import orjson
12
- import requests
13
-
14
- from airbyte_cdk.models import FailureType
15
- from airbyte_cdk.sources.declarative.decoders import Decoder
16
- from airbyte_cdk.sources.declarative.decoders.composite_raw_decoder import (
17
- Parser,
18
- )
19
- from airbyte_cdk.utils import AirbyteTracedException
20
-
21
- logger = logging.getLogger("airbyte")
22
-
23
-
24
- @dataclass
25
- class ZipfileDecoder(Decoder):
26
- parser: Parser
27
-
28
- def is_stream_response(self) -> bool:
29
- return False
30
-
31
- def decode(
32
- self, response: requests.Response
33
- ) -> Generator[MutableMapping[str, Any], None, None]:
34
- try:
35
- zip_file = zipfile.ZipFile(BytesIO(response.content))
36
- except zipfile.BadZipFile as e:
37
- logger.error(
38
- f"Received an invalid zip file in response to URL: {response.request.url}. "
39
- f"The size of the response body is: {len(response.content)}"
40
- )
41
- raise AirbyteTracedException(
42
- message="Received an invalid zip file in response.",
43
- internal_message=f"Received an invalid zip file in response to URL: {response.request.url}.",
44
- failure_type=FailureType.system_error,
45
- ) from e
46
-
47
- for file_name in zip_file.namelist():
48
- unzipped_content = zip_file.read(file_name)
49
- buffered_content = BytesIO(unzipped_content)
50
- yield from self.parser.parse(buffered_content)