airbyte-cdk 6.18.0.dev0__py3-none-any.whl → 6.18.0.dev1__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.
@@ -7,6 +7,7 @@ from dataclasses import dataclass
7
7
  from io import BufferedIOBase, TextIOWrapper
8
8
  from typing import Any, Generator, MutableMapping, Optional
9
9
 
10
+ import orjson
10
11
  import requests
11
12
 
12
13
  from airbyte_cdk.models import FailureType
@@ -46,30 +47,27 @@ class GzipParser(Parser):
46
47
 
47
48
  @dataclass
48
49
  class JsonParser(Parser):
49
- """
50
- Parser strategy for converting JSON-structure str, bytes, or bytearray data into MutableMapping[str, Any].
51
- """
52
-
53
50
  encoding: str = "utf-8"
54
51
 
55
52
  def parse(self, data: BufferedIOBase) -> Generator[MutableMapping[str, Any], None, None]:
56
53
  raw_data = data.read()
57
54
  try:
58
- body_json = json.loads(raw_data.decode(self.encoding))
59
- except json.JSONDecodeError as exc:
60
- raise AirbyteTracedException(
61
- message="JSON data failed to be parsed. See logs for more inforation.",
62
- internal_message=f"JSON data faild to be parsed: {exc=}",
63
- failure_type=FailureType.system_error,
64
- exception=exc,
65
- )
66
-
67
- if not isinstance(body_json, list):
68
- body_json = [body_json]
69
- if len(body_json) == 0:
70
- yield {}
71
- else:
55
+ body_json = orjson.loads(raw_data.decode(self.encoding))
56
+ except Exception:
57
+ try:
58
+ body_json = json.loads(raw_data.decode(self.encoding))
59
+ except Exception as exc:
60
+ raise AirbyteTracedException(
61
+ message="Response JSON data failed to be parsed. See logs for more inforation.",
62
+ internal_message=f"Response JSON data faild to be parsed: {exc=}, {raw_data=}",
63
+ failure_type=FailureType.system_error,
64
+ exception=exc,
65
+ )
66
+
67
+ if isinstance(body_json, list):
72
68
  yield from body_json
69
+ else:
70
+ yield from [body_json]
73
71
 
74
72
 
75
73
  @dataclass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: airbyte-cdk
3
- Version: 6.18.0.dev0
3
+ Version: 6.18.0.dev1
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  License: MIT
6
6
  Keywords: airbyte,connector-development-kit,cdk
@@ -70,7 +70,7 @@ airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=QDqDyKm
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
73
- airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py,sha256=aOpNp0zvWmRoLWLvQoal43yW6IlwWyw4fjjzFDT8Anc,3774
73
+ airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py,sha256=rSvqdGsVgBT3ZfY_bthjZl_OmxY84iKz8g9GQIWyq8k,3766
74
74
  airbyte_cdk/sources/declarative/decoders/decoder.py,sha256=sl-Gt8lXi7yD2Q-sD8je5QS2PbgrgsYjxRLWsay7DMc,826
75
75
  airbyte_cdk/sources/declarative/decoders/json_decoder.py,sha256=qdbjeR6RffKaah_iWvMsOcDolYuxJY5DaI3b9AMTZXg,3327
76
76
  airbyte_cdk/sources/declarative/decoders/noop_decoder.py,sha256=iZh0yKY_JzgBnJWiubEusf5c0o6Khd-8EWFWT-8EgFo,542
@@ -342,8 +342,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=-pHexlNYoWYPnXNH-M7HEbjmeJe9Zk7SJijdQ7d
342
342
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
343
343
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
344
344
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
345
- airbyte_cdk-6.18.0.dev0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
346
- airbyte_cdk-6.18.0.dev0.dist-info/METADATA,sha256=eRBuLAkh7PsLINmAM7gR8ifGRteBHgmJD0zYa61sbxU,6005
347
- airbyte_cdk-6.18.0.dev0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
348
- airbyte_cdk-6.18.0.dev0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
349
- airbyte_cdk-6.18.0.dev0.dist-info/RECORD,,
345
+ airbyte_cdk-6.18.0.dev1.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
346
+ airbyte_cdk-6.18.0.dev1.dist-info/METADATA,sha256=ALXOgvI3pTcF2tNmvbQ9S8fG424n229th_tx1u2uSCo,6005
347
+ airbyte_cdk-6.18.0.dev1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
348
+ airbyte_cdk-6.18.0.dev1.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
349
+ airbyte_cdk-6.18.0.dev1.dist-info/RECORD,,