airbyte-cdk 6.21.0__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
@@ -1866,6 +1866,7 @@ definitions:
1866
1866
  - "$ref": "#/definitions/KeysToLower"
1867
1867
  - "$ref": "#/definitions/KeysToSnakeCase"
1868
1868
  - "$ref": "#/definitions/FlattenFields"
1869
+ - "$ref": "#/definitions/DpathFlattenFields"
1869
1870
  - "$ref": "#/definitions/KeysReplace"
1870
1871
  schema_type_identifier:
1871
1872
  "$ref": "#/definitions/SchemaTypeIdentifier"
@@ -1970,6 +1971,33 @@ definitions:
1970
1971
  $parameters:
1971
1972
  type: object
1972
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
1973
2001
  KeysReplace:
1974
2002
  title: Keys Replace
1975
2003
  description: A transformation that replaces symbols in keys.
@@ -2072,26 +2100,6 @@ definitions:
2072
2100
  $parameters:
2073
2101
  type: object
2074
2102
  additionalProperties: true
2075
- ZipfileDecoder:
2076
- title: Zipfile Decoder
2077
- description: Decoder for response data that is returned as zipfile(s).
2078
- type: object
2079
- additionalProperties: true
2080
- required:
2081
- - type
2082
- - parser
2083
- properties:
2084
- type:
2085
- type: string
2086
- enum: [ZipfileDecoder]
2087
- parser:
2088
- title: Parser
2089
- description: Parser to parse the decompressed data from the zipfile(s).
2090
- anyOf:
2091
- - "$ref": "#/definitions/GzipParser"
2092
- - "$ref": "#/definitions/JsonParser"
2093
- - "$ref": "#/definitions/JsonLineParser"
2094
- - "$ref": "#/definitions/CsvParser"
2095
2103
  ListPartitionRouter:
2096
2104
  title: List Partition Router
2097
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.
@@ -2920,7 +2928,6 @@ definitions:
2920
2928
  - "$ref": "#/definitions/XmlDecoder"
2921
2929
  - "$ref": "#/definitions/GzipJsonDecoder"
2922
2930
  - "$ref": "#/definitions/CompositeRawDecoder"
2923
- - "$ref": "#/definitions/ZipfileDecoder"
2924
2931
  $parameters:
2925
2932
  type: object
2926
2933
  additionalProperties: true
@@ -3119,8 +3126,6 @@ definitions:
3119
3126
  - "$ref": "#/definitions/IterableDecoder"
3120
3127
  - "$ref": "#/definitions/XmlDecoder"
3121
3128
  - "$ref": "#/definitions/GzipJsonDecoder"
3122
- - "$ref": "#/definitions/CompositeRawDecoder"
3123
- - "$ref": "#/definitions/ZipfileDecoder"
3124
3129
  download_decoder:
3125
3130
  title: Download Decoder
3126
3131
  description: Component decoding the download response so records can be extracted.
@@ -3131,8 +3136,6 @@ definitions:
3131
3136
  - "$ref": "#/definitions/IterableDecoder"
3132
3137
  - "$ref": "#/definitions/XmlDecoder"
3133
3138
  - "$ref": "#/definitions/GzipJsonDecoder"
3134
- - "$ref": "#/definitions/CompositeRawDecoder"
3135
- - "$ref": "#/definitions/ZipfileDecoder"
3136
3139
  $parameters:
3137
3140
  type: object
3138
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
  ]
@@ -792,6 +792,25 @@ class FlattenFields(BaseModel):
792
792
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
793
793
 
794
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
+
795
814
  class KeysReplace(BaseModel):
796
815
  type: Literal["KeysReplace"]
797
816
  old: str = Field(
@@ -1223,6 +1242,9 @@ class LegacySessionTokenAuthenticator(BaseModel):
1223
1242
 
1224
1243
 
1225
1244
  class JsonParser(BaseModel):
1245
+ class Config:
1246
+ extra = Extra.allow
1247
+
1226
1248
  type: Literal["JsonParser"]
1227
1249
  encoding: Optional[str] = "utf-8"
1228
1250
 
@@ -1658,18 +1680,6 @@ class CompositeErrorHandler(BaseModel):
1658
1680
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
1659
1681
 
1660
1682
 
1661
- class ZipfileDecoder(BaseModel):
1662
- class Config:
1663
- extra = Extra.allow
1664
-
1665
- type: Literal["ZipfileDecoder"]
1666
- parser: Union[GzipParser, JsonParser, JsonLineParser, CsvParser] = Field(
1667
- ...,
1668
- description="Parser to parse the decompressed data from the zipfile(s).",
1669
- title="Parser",
1670
- )
1671
-
1672
-
1673
1683
  class CompositeRawDecoder(BaseModel):
1674
1684
  type: Literal["CompositeRawDecoder"]
1675
1685
  parser: Union[GzipParser, JsonParser, JsonLineParser, CsvParser]
@@ -1819,6 +1829,7 @@ class DeclarativeStream(BaseModel):
1819
1829
  KeysToLower,
1820
1830
  KeysToSnakeCase,
1821
1831
  FlattenFields,
1832
+ DpathFlattenFields,
1822
1833
  KeysReplace,
1823
1834
  ]
1824
1835
  ]
@@ -1875,7 +1886,7 @@ class SessionTokenAuthenticator(BaseModel):
1875
1886
  description="Authentication method to use for requests sent to the API, specifying how to inject the session token.",
1876
1887
  title="Data Request Authentication",
1877
1888
  )
1878
- decoder: Optional[Union[JsonDecoder, XmlDecoder, CompositeRawDecoder]] = Field(
1889
+ decoder: Optional[Union[JsonDecoder, XmlDecoder]] = Field(
1879
1890
  None, description="Component used to decode the response.", title="Decoder"
1880
1891
  )
1881
1892
  parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
@@ -1994,6 +2005,7 @@ class DynamicSchemaLoader(BaseModel):
1994
2005
  KeysToLower,
1995
2006
  KeysToSnakeCase,
1996
2007
  FlattenFields,
2008
+ DpathFlattenFields,
1997
2009
  KeysReplace,
1998
2010
  ]
1999
2011
  ]
@@ -2080,7 +2092,6 @@ class SimpleRetriever(BaseModel):
2080
2092
  XmlDecoder,
2081
2093
  GzipJsonDecoder,
2082
2094
  CompositeRawDecoder,
2083
- ZipfileDecoder,
2084
2095
  ]
2085
2096
  ] = Field(
2086
2097
  None,
@@ -2157,8 +2168,6 @@ class AsyncRetriever(BaseModel):
2157
2168
  IterableDecoder,
2158
2169
  XmlDecoder,
2159
2170
  GzipJsonDecoder,
2160
- CompositeRawDecoder,
2161
- ZipfileDecoder,
2162
2171
  ]
2163
2172
  ] = Field(
2164
2173
  None,
@@ -2173,8 +2182,6 @@ class AsyncRetriever(BaseModel):
2173
2182
  IterableDecoder,
2174
2183
  XmlDecoder,
2175
2184
  GzipJsonDecoder,
2176
- CompositeRawDecoder,
2177
- ZipfileDecoder,
2178
2185
  ]
2179
2186
  ] = Field(
2180
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:
@@ -1805,12 +1820,6 @@ class ModelToComponentFactory:
1805
1820
  ) -> GzipJsonDecoder:
1806
1821
  return GzipJsonDecoder(parameters={}, encoding=model.encoding)
1807
1822
 
1808
- def create_zipfile_decoder(
1809
- self, model: ZipfileDecoderModel, config: Config, **kwargs: Any
1810
- ) -> ZipfileDecoder:
1811
- parser = self._create_component_from_model(model=model.parser, config=config)
1812
- return ZipfileDecoder(parser=parser)
1813
-
1814
1823
  def create_gzip_parser(
1815
1824
  self, model: GzipParserModel, config: Config, **kwargs: Any
1816
1825
  ) -> GzipParser:
@@ -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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: airbyte-cdk
3
- Version: 6.21.0
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=PxY_V8vGyNdUMw3vjhqFbqjRNgYs_-0-0xeSTGkLSBw,137031
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=OTGeNh-Zkab9JwCTgiHtLH1IS6PiVO9jnr82c0vrHbw,2269
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=57IP4WKtwsoVvWpJKFTTsWMR58nzPIwVvzAehYJ0BrA,96250
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=ZIl9MKlzOPzo-iMWwcJorGboWuCi8ZMy65YW04TS6UM,112776
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
@@ -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
@@ -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.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
349
- airbyte_cdk-6.21.0.dist-info/METADATA,sha256=6djJTSQ0PJieSZE0V6_FAaDKlwVCELJ0_YyMsez9oLE,6000
350
- airbyte_cdk-6.21.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
351
- airbyte_cdk-6.21.0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
352
- airbyte_cdk-6.21.0.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,59 +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
- with zipfile.ZipFile(BytesIO(response.content)) as zip_file:
36
- for file_name in zip_file.namelist():
37
- unzipped_content = zip_file.read(file_name)
38
- buffered_content = BytesIO(unzipped_content)
39
- try:
40
- yield from self.parser.parse(buffered_content)
41
- except Exception as e:
42
- logger.error(
43
- f"Failed to parse file: {file_name} from zip file: {response.request.url} with exception {e}."
44
- )
45
- raise AirbyteTracedException(
46
- message=f"Failed to parse file: {file_name} from zip file.",
47
- internal_message=f"Failed to parse file: {file_name} from zip file: {response.request.url}.",
48
- failure_type=FailureType.system_error,
49
- ) from e
50
- except zipfile.BadZipFile as e:
51
- logger.error(
52
- f"Received an invalid zip file in response to URL: {response.request.url}. "
53
- f"The size of the response body is: {len(response.content)}"
54
- )
55
- raise AirbyteTracedException(
56
- message="Received an invalid zip file in response.",
57
- internal_message=f"Received an invalid zip file in response to URL: {response.request.url}.",
58
- failure_type=FailureType.system_error,
59
- ) from e