airbyte-cdk 0.72.1__py3-none-any.whl → 6.13.1.dev4106__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (517) hide show
  1. airbyte_cdk/__init__.py +355 -6
  2. airbyte_cdk/cli/__init__.py +1 -0
  3. airbyte_cdk/cli/source_declarative_manifest/__init__.py +5 -0
  4. airbyte_cdk/cli/source_declarative_manifest/_run.py +230 -0
  5. airbyte_cdk/cli/source_declarative_manifest/spec.json +17 -0
  6. airbyte_cdk/config_observation.py +29 -10
  7. airbyte_cdk/connector.py +24 -24
  8. airbyte_cdk/connector_builder/README.md +53 -0
  9. airbyte_cdk/connector_builder/connector_builder_handler.py +37 -11
  10. airbyte_cdk/connector_builder/main.py +45 -13
  11. airbyte_cdk/connector_builder/message_grouper.py +189 -50
  12. airbyte_cdk/connector_builder/models.py +3 -2
  13. airbyte_cdk/destinations/__init__.py +4 -3
  14. airbyte_cdk/destinations/destination.py +54 -20
  15. airbyte_cdk/destinations/vector_db_based/README.md +37 -0
  16. airbyte_cdk/destinations/vector_db_based/config.py +40 -17
  17. airbyte_cdk/destinations/vector_db_based/document_processor.py +56 -17
  18. airbyte_cdk/destinations/vector_db_based/embedder.py +57 -15
  19. airbyte_cdk/destinations/vector_db_based/test_utils.py +14 -4
  20. airbyte_cdk/destinations/vector_db_based/utils.py +8 -2
  21. airbyte_cdk/destinations/vector_db_based/writer.py +24 -5
  22. airbyte_cdk/entrypoint.py +153 -44
  23. airbyte_cdk/exception_handler.py +21 -3
  24. airbyte_cdk/logger.py +30 -44
  25. airbyte_cdk/models/__init__.py +13 -2
  26. airbyte_cdk/models/airbyte_protocol.py +86 -1
  27. airbyte_cdk/models/airbyte_protocol_serializers.py +44 -0
  28. airbyte_cdk/models/file_transfer_record_message.py +13 -0
  29. airbyte_cdk/models/well_known_types.py +1 -1
  30. airbyte_cdk/sources/__init__.py +5 -1
  31. airbyte_cdk/sources/abstract_source.py +125 -79
  32. airbyte_cdk/sources/concurrent_source/__init__.py +7 -2
  33. airbyte_cdk/sources/concurrent_source/concurrent_read_processor.py +102 -36
  34. airbyte_cdk/sources/concurrent_source/concurrent_source.py +29 -36
  35. airbyte_cdk/sources/concurrent_source/concurrent_source_adapter.py +94 -10
  36. airbyte_cdk/sources/concurrent_source/stream_thread_exception.py +25 -0
  37. airbyte_cdk/sources/concurrent_source/thread_pool_manager.py +20 -14
  38. airbyte_cdk/sources/config.py +3 -2
  39. airbyte_cdk/sources/connector_state_manager.py +49 -83
  40. airbyte_cdk/sources/declarative/async_job/job.py +52 -0
  41. airbyte_cdk/sources/declarative/async_job/job_orchestrator.py +497 -0
  42. airbyte_cdk/sources/declarative/async_job/job_tracker.py +75 -0
  43. airbyte_cdk/sources/declarative/async_job/repository.py +35 -0
  44. airbyte_cdk/sources/declarative/async_job/status.py +24 -0
  45. airbyte_cdk/sources/declarative/async_job/timer.py +39 -0
  46. airbyte_cdk/sources/declarative/auth/__init__.py +2 -3
  47. airbyte_cdk/sources/declarative/auth/declarative_authenticator.py +3 -1
  48. airbyte_cdk/sources/declarative/auth/jwt.py +191 -0
  49. airbyte_cdk/sources/declarative/auth/oauth.py +60 -20
  50. airbyte_cdk/sources/declarative/auth/selective_authenticator.py +10 -2
  51. airbyte_cdk/sources/declarative/auth/token.py +28 -10
  52. airbyte_cdk/sources/declarative/auth/token_provider.py +9 -8
  53. airbyte_cdk/sources/declarative/checks/check_stream.py +16 -8
  54. airbyte_cdk/sources/declarative/checks/connection_checker.py +4 -2
  55. airbyte_cdk/sources/declarative/concurrency_level/__init__.py +7 -0
  56. airbyte_cdk/sources/declarative/concurrency_level/concurrency_level.py +50 -0
  57. airbyte_cdk/sources/declarative/concurrent_declarative_source.py +421 -0
  58. airbyte_cdk/sources/declarative/datetime/datetime_parser.py +4 -0
  59. airbyte_cdk/sources/declarative/datetime/min_max_datetime.py +26 -6
  60. airbyte_cdk/sources/declarative/declarative_component_schema.yaml +1185 -85
  61. airbyte_cdk/sources/declarative/declarative_source.py +5 -2
  62. airbyte_cdk/sources/declarative/declarative_stream.py +95 -9
  63. airbyte_cdk/sources/declarative/decoders/__init__.py +23 -2
  64. airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py +97 -0
  65. airbyte_cdk/sources/declarative/decoders/decoder.py +11 -4
  66. airbyte_cdk/sources/declarative/decoders/json_decoder.py +92 -5
  67. airbyte_cdk/sources/declarative/decoders/noop_decoder.py +21 -0
  68. airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py +39 -0
  69. airbyte_cdk/sources/declarative/decoders/xml_decoder.py +98 -0
  70. airbyte_cdk/sources/declarative/extractors/__init__.py +12 -1
  71. airbyte_cdk/sources/declarative/extractors/dpath_extractor.py +29 -24
  72. airbyte_cdk/sources/declarative/extractors/http_selector.py +4 -5
  73. airbyte_cdk/sources/declarative/extractors/record_extractor.py +2 -3
  74. airbyte_cdk/sources/declarative/extractors/record_filter.py +65 -8
  75. airbyte_cdk/sources/declarative/extractors/record_selector.py +85 -26
  76. airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py +177 -0
  77. airbyte_cdk/sources/declarative/extractors/type_transformer.py +55 -0
  78. airbyte_cdk/sources/declarative/incremental/__init__.py +25 -3
  79. airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py +156 -48
  80. airbyte_cdk/sources/declarative/incremental/declarative_cursor.py +13 -0
  81. airbyte_cdk/sources/declarative/incremental/global_substream_cursor.py +350 -0
  82. airbyte_cdk/sources/declarative/incremental/per_partition_cursor.py +159 -74
  83. airbyte_cdk/sources/declarative/incremental/per_partition_with_global.py +200 -0
  84. airbyte_cdk/sources/declarative/incremental/resumable_full_refresh_cursor.py +122 -0
  85. airbyte_cdk/sources/declarative/interpolation/filters.py +27 -1
  86. airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py +23 -5
  87. airbyte_cdk/sources/declarative/interpolation/interpolated_mapping.py +12 -8
  88. airbyte_cdk/sources/declarative/interpolation/interpolated_nested_mapping.py +13 -6
  89. airbyte_cdk/sources/declarative/interpolation/interpolated_string.py +21 -6
  90. airbyte_cdk/sources/declarative/interpolation/interpolation.py +9 -3
  91. airbyte_cdk/sources/declarative/interpolation/jinja.py +72 -37
  92. airbyte_cdk/sources/declarative/interpolation/macros.py +72 -17
  93. airbyte_cdk/sources/declarative/manifest_declarative_source.py +193 -52
  94. airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py +98 -0
  95. airbyte_cdk/sources/declarative/migrations/state_migration.py +24 -0
  96. airbyte_cdk/sources/declarative/models/__init__.py +1 -1
  97. airbyte_cdk/sources/declarative/models/declarative_component_schema.py +1319 -603
  98. airbyte_cdk/sources/declarative/parsers/custom_exceptions.py +2 -2
  99. airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py +26 -4
  100. airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py +26 -15
  101. airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +1695 -225
  102. airbyte_cdk/sources/declarative/partition_routers/__init__.py +24 -4
  103. airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py +65 -0
  104. airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py +176 -0
  105. airbyte_cdk/sources/declarative/partition_routers/list_partition_router.py +39 -9
  106. airbyte_cdk/sources/declarative/partition_routers/partition_router.py +62 -0
  107. airbyte_cdk/sources/declarative/partition_routers/single_partition_router.py +15 -3
  108. airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py +222 -39
  109. airbyte_cdk/sources/declarative/requesters/error_handlers/__init__.py +19 -5
  110. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/__init__.py +3 -1
  111. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/constant_backoff_strategy.py +19 -7
  112. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/exponential_backoff_strategy.py +19 -7
  113. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/header_helper.py +4 -2
  114. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_time_from_header_backoff_strategy.py +41 -9
  115. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_until_time_from_header_backoff_strategy.py +29 -14
  116. airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategy.py +5 -13
  117. airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py +32 -16
  118. airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py +46 -56
  119. airbyte_cdk/sources/declarative/requesters/error_handlers/default_http_response_filter.py +40 -0
  120. airbyte_cdk/sources/declarative/requesters/error_handlers/error_handler.py +6 -32
  121. airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py +119 -41
  122. airbyte_cdk/sources/declarative/requesters/http_job_repository.py +228 -0
  123. airbyte_cdk/sources/declarative/requesters/http_requester.py +98 -344
  124. airbyte_cdk/sources/declarative/requesters/paginators/__init__.py +14 -3
  125. airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py +105 -46
  126. airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py +14 -8
  127. airbyte_cdk/sources/declarative/requesters/paginators/paginator.py +19 -8
  128. airbyte_cdk/sources/declarative/requesters/paginators/strategies/__init__.py +9 -3
  129. airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py +53 -21
  130. airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py +42 -19
  131. airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py +25 -12
  132. airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py +13 -10
  133. airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py +26 -13
  134. airbyte_cdk/sources/declarative/requesters/request_options/__init__.py +15 -2
  135. airbyte_cdk/sources/declarative/requesters/request_options/datetime_based_request_options_provider.py +91 -0
  136. airbyte_cdk/sources/declarative/requesters/request_options/default_request_options_provider.py +60 -0
  137. airbyte_cdk/sources/declarative/requesters/request_options/interpolated_nested_request_input_provider.py +31 -14
  138. airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_input_provider.py +27 -15
  139. airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_options_provider.py +63 -10
  140. airbyte_cdk/sources/declarative/requesters/request_options/request_options_provider.py +1 -1
  141. airbyte_cdk/sources/declarative/requesters/requester.py +9 -17
  142. airbyte_cdk/sources/declarative/resolvers/__init__.py +41 -0
  143. airbyte_cdk/sources/declarative/resolvers/components_resolver.py +55 -0
  144. airbyte_cdk/sources/declarative/resolvers/config_components_resolver.py +136 -0
  145. airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py +112 -0
  146. airbyte_cdk/sources/declarative/retrievers/__init__.py +6 -2
  147. airbyte_cdk/sources/declarative/retrievers/async_retriever.py +100 -0
  148. airbyte_cdk/sources/declarative/retrievers/retriever.py +1 -3
  149. airbyte_cdk/sources/declarative/retrievers/simple_retriever.py +228 -72
  150. airbyte_cdk/sources/declarative/schema/__init__.py +14 -1
  151. airbyte_cdk/sources/declarative/schema/default_schema_loader.py +5 -3
  152. airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py +236 -0
  153. airbyte_cdk/sources/declarative/schema/json_file_schema_loader.py +8 -8
  154. airbyte_cdk/sources/declarative/spec/spec.py +12 -5
  155. airbyte_cdk/sources/declarative/stream_slicers/__init__.py +1 -2
  156. airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py +88 -0
  157. airbyte_cdk/sources/declarative/stream_slicers/stream_slicer.py +9 -14
  158. airbyte_cdk/sources/declarative/transformations/add_fields.py +19 -11
  159. airbyte_cdk/sources/declarative/transformations/flatten_fields.py +52 -0
  160. airbyte_cdk/sources/declarative/transformations/keys_replace_transformation.py +61 -0
  161. airbyte_cdk/sources/declarative/transformations/keys_to_lower_transformation.py +22 -0
  162. airbyte_cdk/sources/declarative/transformations/keys_to_snake_transformation.py +68 -0
  163. airbyte_cdk/sources/declarative/transformations/remove_fields.py +13 -10
  164. airbyte_cdk/sources/declarative/transformations/transformation.py +5 -5
  165. airbyte_cdk/sources/declarative/types.py +19 -110
  166. airbyte_cdk/sources/declarative/yaml_declarative_source.py +31 -10
  167. airbyte_cdk/sources/embedded/base_integration.py +16 -5
  168. airbyte_cdk/sources/embedded/catalog.py +16 -4
  169. airbyte_cdk/sources/embedded/runner.py +19 -3
  170. airbyte_cdk/sources/embedded/tools.py +5 -2
  171. airbyte_cdk/sources/file_based/README.md +152 -0
  172. airbyte_cdk/sources/file_based/__init__.py +24 -0
  173. airbyte_cdk/sources/file_based/availability_strategy/__init__.py +9 -2
  174. airbyte_cdk/sources/file_based/availability_strategy/abstract_file_based_availability_strategy.py +22 -6
  175. airbyte_cdk/sources/file_based/availability_strategy/default_file_based_availability_strategy.py +46 -10
  176. airbyte_cdk/sources/file_based/config/abstract_file_based_spec.py +58 -10
  177. airbyte_cdk/sources/file_based/config/avro_format.py +2 -1
  178. airbyte_cdk/sources/file_based/config/csv_format.py +29 -10
  179. airbyte_cdk/sources/file_based/config/excel_format.py +18 -0
  180. airbyte_cdk/sources/file_based/config/file_based_stream_config.py +16 -4
  181. airbyte_cdk/sources/file_based/config/jsonl_format.py +2 -1
  182. airbyte_cdk/sources/file_based/config/parquet_format.py +2 -1
  183. airbyte_cdk/sources/file_based/config/unstructured_format.py +13 -5
  184. airbyte_cdk/sources/file_based/discovery_policy/__init__.py +6 -2
  185. airbyte_cdk/sources/file_based/discovery_policy/abstract_discovery_policy.py +2 -4
  186. airbyte_cdk/sources/file_based/discovery_policy/default_discovery_policy.py +7 -2
  187. airbyte_cdk/sources/file_based/exceptions.py +52 -15
  188. airbyte_cdk/sources/file_based/file_based_source.py +163 -33
  189. airbyte_cdk/sources/file_based/file_based_stream_reader.py +83 -5
  190. airbyte_cdk/sources/file_based/file_types/__init__.py +14 -1
  191. airbyte_cdk/sources/file_based/file_types/avro_parser.py +75 -24
  192. airbyte_cdk/sources/file_based/file_types/csv_parser.py +116 -34
  193. airbyte_cdk/sources/file_based/file_types/excel_parser.py +196 -0
  194. airbyte_cdk/sources/file_based/file_types/file_transfer.py +37 -0
  195. airbyte_cdk/sources/file_based/file_types/file_type_parser.py +4 -1
  196. airbyte_cdk/sources/file_based/file_types/jsonl_parser.py +24 -8
  197. airbyte_cdk/sources/file_based/file_types/parquet_parser.py +60 -18
  198. airbyte_cdk/sources/file_based/file_types/unstructured_parser.py +145 -41
  199. airbyte_cdk/sources/file_based/remote_file.py +1 -1
  200. airbyte_cdk/sources/file_based/schema_helpers.py +38 -10
  201. airbyte_cdk/sources/file_based/schema_validation_policies/__init__.py +3 -1
  202. airbyte_cdk/sources/file_based/schema_validation_policies/abstract_schema_validation_policy.py +3 -1
  203. airbyte_cdk/sources/file_based/schema_validation_policies/default_schema_validation_policies.py +16 -5
  204. airbyte_cdk/sources/file_based/stream/abstract_file_based_stream.py +50 -13
  205. airbyte_cdk/sources/file_based/stream/concurrent/adapters.py +67 -27
  206. airbyte_cdk/sources/file_based/stream/concurrent/cursor/__init__.py +5 -1
  207. airbyte_cdk/sources/file_based/stream/concurrent/cursor/abstract_concurrent_file_based_cursor.py +14 -23
  208. airbyte_cdk/sources/file_based/stream/concurrent/cursor/file_based_concurrent_cursor.py +54 -18
  209. airbyte_cdk/sources/file_based/stream/concurrent/cursor/file_based_final_state_cursor.py +21 -9
  210. airbyte_cdk/sources/file_based/stream/cursor/abstract_file_based_cursor.py +3 -1
  211. airbyte_cdk/sources/file_based/stream/cursor/default_file_based_cursor.py +27 -10
  212. airbyte_cdk/sources/file_based/stream/default_file_based_stream.py +175 -45
  213. airbyte_cdk/sources/http_logger.py +8 -3
  214. airbyte_cdk/sources/message/__init__.py +7 -1
  215. airbyte_cdk/sources/message/repository.py +18 -4
  216. airbyte_cdk/sources/source.py +42 -38
  217. airbyte_cdk/sources/streams/__init__.py +2 -2
  218. airbyte_cdk/sources/streams/availability_strategy.py +54 -3
  219. airbyte_cdk/sources/streams/call_rate.py +64 -21
  220. airbyte_cdk/sources/streams/checkpoint/__init__.py +26 -0
  221. airbyte_cdk/sources/streams/checkpoint/checkpoint_reader.py +335 -0
  222. airbyte_cdk/sources/{declarative/incremental → streams/checkpoint}/cursor.py +17 -14
  223. airbyte_cdk/sources/streams/checkpoint/per_partition_key_serializer.py +22 -0
  224. airbyte_cdk/sources/streams/checkpoint/resumable_full_refresh_cursor.py +51 -0
  225. airbyte_cdk/sources/streams/checkpoint/substream_resumable_full_refresh_cursor.py +110 -0
  226. airbyte_cdk/sources/streams/concurrent/README.md +7 -0
  227. airbyte_cdk/sources/streams/concurrent/abstract_stream.py +7 -2
  228. airbyte_cdk/sources/streams/concurrent/adapters.py +84 -75
  229. airbyte_cdk/sources/streams/concurrent/availability_strategy.py +30 -2
  230. airbyte_cdk/sources/streams/concurrent/cursor.py +298 -42
  231. airbyte_cdk/sources/streams/concurrent/default_stream.py +12 -3
  232. airbyte_cdk/sources/streams/concurrent/exceptions.py +3 -0
  233. airbyte_cdk/sources/streams/concurrent/helpers.py +14 -3
  234. airbyte_cdk/sources/streams/concurrent/partition_enqueuer.py +12 -3
  235. airbyte_cdk/sources/streams/concurrent/partition_reader.py +10 -3
  236. airbyte_cdk/sources/streams/concurrent/partitions/partition.py +1 -16
  237. airbyte_cdk/sources/streams/concurrent/partitions/stream_slicer.py +21 -0
  238. airbyte_cdk/sources/streams/concurrent/partitions/types.py +15 -5
  239. airbyte_cdk/sources/streams/concurrent/state_converters/abstract_stream_state_converter.py +109 -17
  240. airbyte_cdk/sources/streams/concurrent/state_converters/datetime_stream_state_converter.py +90 -72
  241. airbyte_cdk/sources/streams/core.py +412 -87
  242. airbyte_cdk/sources/streams/http/__init__.py +2 -1
  243. airbyte_cdk/sources/streams/http/availability_strategy.py +12 -101
  244. airbyte_cdk/sources/streams/http/error_handlers/__init__.py +22 -0
  245. airbyte_cdk/sources/streams/http/error_handlers/backoff_strategy.py +28 -0
  246. airbyte_cdk/sources/streams/http/error_handlers/default_backoff_strategy.py +17 -0
  247. airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py +86 -0
  248. airbyte_cdk/sources/streams/http/error_handlers/error_handler.py +42 -0
  249. airbyte_cdk/sources/streams/http/error_handlers/error_message_parser.py +19 -0
  250. airbyte_cdk/sources/streams/http/error_handlers/http_status_error_handler.py +110 -0
  251. airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py +52 -0
  252. airbyte_cdk/sources/streams/http/error_handlers/response_models.py +65 -0
  253. airbyte_cdk/sources/streams/http/exceptions.py +27 -7
  254. airbyte_cdk/sources/streams/http/http.py +369 -246
  255. airbyte_cdk/sources/streams/http/http_client.py +531 -0
  256. airbyte_cdk/sources/streams/http/rate_limiting.py +76 -12
  257. airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py +28 -9
  258. airbyte_cdk/sources/streams/http/requests_native_auth/abstract_token.py +2 -1
  259. airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py +90 -35
  260. airbyte_cdk/sources/streams/http/requests_native_auth/token.py +13 -3
  261. airbyte_cdk/sources/types.py +154 -0
  262. airbyte_cdk/sources/utils/record_helper.py +36 -21
  263. airbyte_cdk/sources/utils/schema_helpers.py +13 -6
  264. airbyte_cdk/sources/utils/slice_logger.py +4 -1
  265. airbyte_cdk/sources/utils/transform.py +54 -20
  266. airbyte_cdk/sql/_util/hashing.py +34 -0
  267. airbyte_cdk/sql/_util/name_normalizers.py +92 -0
  268. airbyte_cdk/sql/constants.py +32 -0
  269. airbyte_cdk/sql/exceptions.py +235 -0
  270. airbyte_cdk/sql/secrets.py +123 -0
  271. airbyte_cdk/sql/shared/__init__.py +15 -0
  272. airbyte_cdk/sql/shared/catalog_providers.py +145 -0
  273. airbyte_cdk/sql/shared/sql_processor.py +786 -0
  274. airbyte_cdk/sql/types.py +160 -0
  275. airbyte_cdk/test/catalog_builder.py +70 -18
  276. airbyte_cdk/test/entrypoint_wrapper.py +117 -42
  277. airbyte_cdk/test/mock_http/__init__.py +1 -1
  278. airbyte_cdk/test/mock_http/matcher.py +6 -0
  279. airbyte_cdk/test/mock_http/mocker.py +57 -10
  280. airbyte_cdk/test/mock_http/request.py +19 -3
  281. airbyte_cdk/test/mock_http/response.py +3 -1
  282. airbyte_cdk/test/mock_http/response_builder.py +32 -16
  283. airbyte_cdk/test/state_builder.py +18 -10
  284. airbyte_cdk/test/utils/__init__.py +1 -0
  285. airbyte_cdk/test/utils/data.py +24 -0
  286. airbyte_cdk/test/utils/http_mocking.py +16 -0
  287. airbyte_cdk/test/utils/manifest_only_fixtures.py +60 -0
  288. airbyte_cdk/test/utils/reading.py +26 -0
  289. airbyte_cdk/utils/__init__.py +2 -1
  290. airbyte_cdk/utils/airbyte_secrets_utils.py +5 -3
  291. airbyte_cdk/utils/analytics_message.py +10 -2
  292. airbyte_cdk/utils/datetime_format_inferrer.py +4 -1
  293. airbyte_cdk/utils/event_timing.py +10 -10
  294. airbyte_cdk/utils/mapping_helpers.py +3 -1
  295. airbyte_cdk/utils/message_utils.py +20 -11
  296. airbyte_cdk/utils/print_buffer.py +75 -0
  297. airbyte_cdk/utils/schema_inferrer.py +198 -28
  298. airbyte_cdk/utils/slice_hasher.py +30 -0
  299. airbyte_cdk/utils/spec_schema_transformations.py +6 -3
  300. airbyte_cdk/utils/stream_status_utils.py +8 -1
  301. airbyte_cdk/utils/traced_exception.py +61 -21
  302. airbyte_cdk-6.13.1.dev4106.dist-info/METADATA +109 -0
  303. airbyte_cdk-6.13.1.dev4106.dist-info/RECORD +349 -0
  304. {airbyte_cdk-0.72.1.dist-info → airbyte_cdk-6.13.1.dev4106.dist-info}/WHEEL +1 -2
  305. airbyte_cdk-6.13.1.dev4106.dist-info/entry_points.txt +3 -0
  306. airbyte_cdk/sources/declarative/create_partial.py +0 -92
  307. airbyte_cdk/sources/declarative/parsers/class_types_registry.py +0 -102
  308. airbyte_cdk/sources/declarative/parsers/default_implementation_registry.py +0 -64
  309. airbyte_cdk/sources/declarative/requesters/error_handlers/response_action.py +0 -16
  310. airbyte_cdk/sources/declarative/requesters/error_handlers/response_status.py +0 -68
  311. airbyte_cdk/sources/declarative/stream_slicers/cartesian_product_stream_slicer.py +0 -114
  312. airbyte_cdk/sources/deprecated/base_source.py +0 -94
  313. airbyte_cdk/sources/deprecated/client.py +0 -99
  314. airbyte_cdk/sources/singer/__init__.py +0 -8
  315. airbyte_cdk/sources/singer/singer_helpers.py +0 -304
  316. airbyte_cdk/sources/singer/source.py +0 -186
  317. airbyte_cdk/sources/streams/concurrent/partitions/record.py +0 -23
  318. airbyte_cdk/sources/streams/http/auth/__init__.py +0 -17
  319. airbyte_cdk/sources/streams/http/auth/core.py +0 -29
  320. airbyte_cdk/sources/streams/http/auth/oauth.py +0 -113
  321. airbyte_cdk/sources/streams/http/auth/token.py +0 -47
  322. airbyte_cdk/sources/streams/utils/stream_helper.py +0 -40
  323. airbyte_cdk/sources/utils/catalog_helpers.py +0 -22
  324. airbyte_cdk/sources/utils/schema_models.py +0 -84
  325. airbyte_cdk-0.72.1.dist-info/METADATA +0 -243
  326. airbyte_cdk-0.72.1.dist-info/RECORD +0 -466
  327. airbyte_cdk-0.72.1.dist-info/top_level.txt +0 -3
  328. source_declarative_manifest/main.py +0 -29
  329. unit_tests/connector_builder/__init__.py +0 -3
  330. unit_tests/connector_builder/test_connector_builder_handler.py +0 -871
  331. unit_tests/connector_builder/test_message_grouper.py +0 -713
  332. unit_tests/connector_builder/utils.py +0 -27
  333. unit_tests/destinations/test_destination.py +0 -243
  334. unit_tests/singer/test_singer_helpers.py +0 -56
  335. unit_tests/singer/test_singer_source.py +0 -112
  336. unit_tests/sources/__init__.py +0 -0
  337. unit_tests/sources/concurrent_source/__init__.py +0 -3
  338. unit_tests/sources/concurrent_source/test_concurrent_source_adapter.py +0 -106
  339. unit_tests/sources/declarative/__init__.py +0 -3
  340. unit_tests/sources/declarative/auth/__init__.py +0 -3
  341. unit_tests/sources/declarative/auth/test_oauth.py +0 -331
  342. unit_tests/sources/declarative/auth/test_selective_authenticator.py +0 -39
  343. unit_tests/sources/declarative/auth/test_session_token_auth.py +0 -182
  344. unit_tests/sources/declarative/auth/test_token_auth.py +0 -200
  345. unit_tests/sources/declarative/auth/test_token_provider.py +0 -73
  346. unit_tests/sources/declarative/checks/__init__.py +0 -3
  347. unit_tests/sources/declarative/checks/test_check_stream.py +0 -146
  348. unit_tests/sources/declarative/decoders/__init__.py +0 -0
  349. unit_tests/sources/declarative/decoders/test_json_decoder.py +0 -16
  350. unit_tests/sources/declarative/external_component.py +0 -13
  351. unit_tests/sources/declarative/extractors/__init__.py +0 -3
  352. unit_tests/sources/declarative/extractors/test_dpath_extractor.py +0 -55
  353. unit_tests/sources/declarative/extractors/test_record_filter.py +0 -55
  354. unit_tests/sources/declarative/extractors/test_record_selector.py +0 -179
  355. unit_tests/sources/declarative/incremental/__init__.py +0 -0
  356. unit_tests/sources/declarative/incremental/test_datetime_based_cursor.py +0 -860
  357. unit_tests/sources/declarative/incremental/test_per_partition_cursor.py +0 -406
  358. unit_tests/sources/declarative/incremental/test_per_partition_cursor_integration.py +0 -332
  359. unit_tests/sources/declarative/interpolation/__init__.py +0 -3
  360. unit_tests/sources/declarative/interpolation/test_filters.py +0 -80
  361. unit_tests/sources/declarative/interpolation/test_interpolated_boolean.py +0 -40
  362. unit_tests/sources/declarative/interpolation/test_interpolated_mapping.py +0 -35
  363. unit_tests/sources/declarative/interpolation/test_interpolated_nested_mapping.py +0 -45
  364. unit_tests/sources/declarative/interpolation/test_interpolated_string.py +0 -25
  365. unit_tests/sources/declarative/interpolation/test_jinja.py +0 -240
  366. unit_tests/sources/declarative/interpolation/test_macros.py +0 -73
  367. unit_tests/sources/declarative/parsers/__init__.py +0 -3
  368. unit_tests/sources/declarative/parsers/test_manifest_component_transformer.py +0 -406
  369. unit_tests/sources/declarative/parsers/test_manifest_reference_resolver.py +0 -139
  370. unit_tests/sources/declarative/parsers/test_model_to_component_factory.py +0 -1847
  371. unit_tests/sources/declarative/parsers/testing_components.py +0 -36
  372. unit_tests/sources/declarative/partition_routers/__init__.py +0 -3
  373. unit_tests/sources/declarative/partition_routers/test_list_partition_router.py +0 -155
  374. unit_tests/sources/declarative/partition_routers/test_single_partition_router.py +0 -14
  375. unit_tests/sources/declarative/partition_routers/test_substream_partition_router.py +0 -404
  376. unit_tests/sources/declarative/requesters/__init__.py +0 -3
  377. unit_tests/sources/declarative/requesters/error_handlers/__init__.py +0 -3
  378. unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/__init__.py +0 -3
  379. unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_constant_backoff.py +0 -34
  380. unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_exponential_backoff.py +0 -36
  381. unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_header_helper.py +0 -38
  382. unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_time_from_header.py +0 -35
  383. unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_until_time_from_header.py +0 -64
  384. unit_tests/sources/declarative/requesters/error_handlers/test_composite_error_handler.py +0 -213
  385. unit_tests/sources/declarative/requesters/error_handlers/test_default_error_handler.py +0 -178
  386. unit_tests/sources/declarative/requesters/error_handlers/test_http_response_filter.py +0 -121
  387. unit_tests/sources/declarative/requesters/error_handlers/test_response_status.py +0 -44
  388. unit_tests/sources/declarative/requesters/paginators/__init__.py +0 -3
  389. unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py +0 -64
  390. unit_tests/sources/declarative/requesters/paginators/test_default_paginator.py +0 -313
  391. unit_tests/sources/declarative/requesters/paginators/test_no_paginator.py +0 -12
  392. unit_tests/sources/declarative/requesters/paginators/test_offset_increment.py +0 -58
  393. unit_tests/sources/declarative/requesters/paginators/test_page_increment.py +0 -70
  394. unit_tests/sources/declarative/requesters/paginators/test_request_option.py +0 -43
  395. unit_tests/sources/declarative/requesters/paginators/test_stop_condition.py +0 -105
  396. unit_tests/sources/declarative/requesters/request_options/__init__.py +0 -3
  397. unit_tests/sources/declarative/requesters/request_options/test_interpolated_request_options_provider.py +0 -101
  398. unit_tests/sources/declarative/requesters/test_http_requester.py +0 -974
  399. unit_tests/sources/declarative/requesters/test_interpolated_request_input_provider.py +0 -32
  400. unit_tests/sources/declarative/retrievers/__init__.py +0 -3
  401. unit_tests/sources/declarative/retrievers/test_simple_retriever.py +0 -542
  402. unit_tests/sources/declarative/schema/__init__.py +0 -6
  403. unit_tests/sources/declarative/schema/source_test/SourceTest.py +0 -8
  404. unit_tests/sources/declarative/schema/source_test/__init__.py +0 -3
  405. unit_tests/sources/declarative/schema/test_default_schema_loader.py +0 -32
  406. unit_tests/sources/declarative/schema/test_inline_schema_loader.py +0 -19
  407. unit_tests/sources/declarative/schema/test_json_file_schema_loader.py +0 -26
  408. unit_tests/sources/declarative/states/__init__.py +0 -3
  409. unit_tests/sources/declarative/stream_slicers/__init__.py +0 -3
  410. unit_tests/sources/declarative/stream_slicers/test_cartesian_product_stream_slicer.py +0 -225
  411. unit_tests/sources/declarative/test_create_partial.py +0 -83
  412. unit_tests/sources/declarative/test_declarative_stream.py +0 -103
  413. unit_tests/sources/declarative/test_manifest_declarative_source.py +0 -1260
  414. unit_tests/sources/declarative/test_types.py +0 -39
  415. unit_tests/sources/declarative/test_yaml_declarative_source.py +0 -148
  416. unit_tests/sources/file_based/__init__.py +0 -0
  417. unit_tests/sources/file_based/availability_strategy/__init__.py +0 -0
  418. unit_tests/sources/file_based/availability_strategy/test_default_file_based_availability_strategy.py +0 -100
  419. unit_tests/sources/file_based/config/__init__.py +0 -0
  420. unit_tests/sources/file_based/config/test_abstract_file_based_spec.py +0 -28
  421. unit_tests/sources/file_based/config/test_csv_format.py +0 -34
  422. unit_tests/sources/file_based/config/test_file_based_stream_config.py +0 -84
  423. unit_tests/sources/file_based/discovery_policy/__init__.py +0 -0
  424. unit_tests/sources/file_based/discovery_policy/test_default_discovery_policy.py +0 -31
  425. unit_tests/sources/file_based/file_types/__init__.py +0 -0
  426. unit_tests/sources/file_based/file_types/test_avro_parser.py +0 -243
  427. unit_tests/sources/file_based/file_types/test_csv_parser.py +0 -546
  428. unit_tests/sources/file_based/file_types/test_jsonl_parser.py +0 -158
  429. unit_tests/sources/file_based/file_types/test_parquet_parser.py +0 -274
  430. unit_tests/sources/file_based/file_types/test_unstructured_parser.py +0 -593
  431. unit_tests/sources/file_based/helpers.py +0 -70
  432. unit_tests/sources/file_based/in_memory_files_source.py +0 -211
  433. unit_tests/sources/file_based/scenarios/__init__.py +0 -0
  434. unit_tests/sources/file_based/scenarios/avro_scenarios.py +0 -744
  435. unit_tests/sources/file_based/scenarios/check_scenarios.py +0 -220
  436. unit_tests/sources/file_based/scenarios/concurrent_incremental_scenarios.py +0 -2844
  437. unit_tests/sources/file_based/scenarios/csv_scenarios.py +0 -3105
  438. unit_tests/sources/file_based/scenarios/file_based_source_builder.py +0 -91
  439. unit_tests/sources/file_based/scenarios/incremental_scenarios.py +0 -1926
  440. unit_tests/sources/file_based/scenarios/jsonl_scenarios.py +0 -930
  441. unit_tests/sources/file_based/scenarios/parquet_scenarios.py +0 -754
  442. unit_tests/sources/file_based/scenarios/scenario_builder.py +0 -234
  443. unit_tests/sources/file_based/scenarios/unstructured_scenarios.py +0 -608
  444. unit_tests/sources/file_based/scenarios/user_input_schema_scenarios.py +0 -746
  445. unit_tests/sources/file_based/scenarios/validation_policy_scenarios.py +0 -726
  446. unit_tests/sources/file_based/stream/__init__.py +0 -0
  447. unit_tests/sources/file_based/stream/concurrent/__init__.py +0 -0
  448. unit_tests/sources/file_based/stream/concurrent/test_adapters.py +0 -362
  449. unit_tests/sources/file_based/stream/concurrent/test_file_based_concurrent_cursor.py +0 -458
  450. unit_tests/sources/file_based/stream/test_default_file_based_cursor.py +0 -310
  451. unit_tests/sources/file_based/stream/test_default_file_based_stream.py +0 -244
  452. unit_tests/sources/file_based/test_file_based_scenarios.py +0 -320
  453. unit_tests/sources/file_based/test_file_based_stream_reader.py +0 -272
  454. unit_tests/sources/file_based/test_scenarios.py +0 -253
  455. unit_tests/sources/file_based/test_schema_helpers.py +0 -346
  456. unit_tests/sources/fixtures/__init__.py +0 -3
  457. unit_tests/sources/fixtures/source_test_fixture.py +0 -153
  458. unit_tests/sources/message/__init__.py +0 -0
  459. unit_tests/sources/message/test_repository.py +0 -153
  460. unit_tests/sources/streams/__init__.py +0 -0
  461. unit_tests/sources/streams/concurrent/__init__.py +0 -3
  462. unit_tests/sources/streams/concurrent/scenarios/__init__.py +0 -3
  463. unit_tests/sources/streams/concurrent/scenarios/incremental_scenarios.py +0 -250
  464. unit_tests/sources/streams/concurrent/scenarios/stream_facade_builder.py +0 -140
  465. unit_tests/sources/streams/concurrent/scenarios/stream_facade_scenarios.py +0 -452
  466. unit_tests/sources/streams/concurrent/scenarios/test_concurrent_scenarios.py +0 -76
  467. unit_tests/sources/streams/concurrent/scenarios/thread_based_concurrent_stream_scenarios.py +0 -418
  468. unit_tests/sources/streams/concurrent/scenarios/thread_based_concurrent_stream_source_builder.py +0 -142
  469. unit_tests/sources/streams/concurrent/scenarios/utils.py +0 -55
  470. unit_tests/sources/streams/concurrent/test_adapters.py +0 -380
  471. unit_tests/sources/streams/concurrent/test_concurrent_read_processor.py +0 -684
  472. unit_tests/sources/streams/concurrent/test_cursor.py +0 -139
  473. unit_tests/sources/streams/concurrent/test_datetime_state_converter.py +0 -369
  474. unit_tests/sources/streams/concurrent/test_default_stream.py +0 -197
  475. unit_tests/sources/streams/concurrent/test_partition_enqueuer.py +0 -90
  476. unit_tests/sources/streams/concurrent/test_partition_reader.py +0 -67
  477. unit_tests/sources/streams/concurrent/test_thread_pool_manager.py +0 -106
  478. unit_tests/sources/streams/http/__init__.py +0 -0
  479. unit_tests/sources/streams/http/auth/__init__.py +0 -0
  480. unit_tests/sources/streams/http/auth/test_auth.py +0 -173
  481. unit_tests/sources/streams/http/requests_native_auth/__init__.py +0 -0
  482. unit_tests/sources/streams/http/requests_native_auth/test_requests_native_auth.py +0 -423
  483. unit_tests/sources/streams/http/test_availability_strategy.py +0 -180
  484. unit_tests/sources/streams/http/test_http.py +0 -635
  485. unit_tests/sources/streams/test_availability_strategy.py +0 -70
  486. unit_tests/sources/streams/test_call_rate.py +0 -300
  487. unit_tests/sources/streams/test_stream_read.py +0 -405
  488. unit_tests/sources/streams/test_streams_core.py +0 -184
  489. unit_tests/sources/test_abstract_source.py +0 -1442
  490. unit_tests/sources/test_concurrent_source.py +0 -112
  491. unit_tests/sources/test_config.py +0 -92
  492. unit_tests/sources/test_connector_state_manager.py +0 -482
  493. unit_tests/sources/test_http_logger.py +0 -252
  494. unit_tests/sources/test_integration_source.py +0 -86
  495. unit_tests/sources/test_source.py +0 -684
  496. unit_tests/sources/test_source_read.py +0 -460
  497. unit_tests/test/__init__.py +0 -0
  498. unit_tests/test/mock_http/__init__.py +0 -0
  499. unit_tests/test/mock_http/test_matcher.py +0 -53
  500. unit_tests/test/mock_http/test_mocker.py +0 -214
  501. unit_tests/test/mock_http/test_request.py +0 -117
  502. unit_tests/test/mock_http/test_response_builder.py +0 -177
  503. unit_tests/test/test_entrypoint_wrapper.py +0 -240
  504. unit_tests/utils/__init__.py +0 -0
  505. unit_tests/utils/test_datetime_format_inferrer.py +0 -60
  506. unit_tests/utils/test_mapping_helpers.py +0 -54
  507. unit_tests/utils/test_message_utils.py +0 -91
  508. unit_tests/utils/test_rate_limiting.py +0 -26
  509. unit_tests/utils/test_schema_inferrer.py +0 -202
  510. unit_tests/utils/test_secret_utils.py +0 -135
  511. unit_tests/utils/test_stream_status_utils.py +0 -61
  512. unit_tests/utils/test_traced_exception.py +0 -107
  513. /airbyte_cdk/sources/{deprecated → declarative/async_job}/__init__.py +0 -0
  514. {source_declarative_manifest → airbyte_cdk/sources/declarative/migrations}/__init__.py +0 -0
  515. {unit_tests/destinations → airbyte_cdk/sql}/__init__.py +0 -0
  516. {unit_tests/singer → airbyte_cdk/sql/_util}/__init__.py +0 -0
  517. {airbyte_cdk-0.72.1.dist-info → airbyte_cdk-6.13.1.dev4106.dist-info}/LICENSE.txt +0 -0
@@ -4,15 +4,44 @@
4
4
 
5
5
  from __future__ import annotations
6
6
 
7
+ import datetime
7
8
  import importlib
8
9
  import inspect
9
10
  import re
10
- from typing import Any, Callable, List, Mapping, Optional, Type, Union, get_args, get_origin, get_type_hints
11
+ from functools import partial
12
+ from typing import (
13
+ Any,
14
+ Callable,
15
+ Dict,
16
+ List,
17
+ Mapping,
18
+ MutableMapping,
19
+ Optional,
20
+ Type,
21
+ Union,
22
+ get_args,
23
+ get_origin,
24
+ get_type_hints,
25
+ )
11
26
 
12
- from airbyte_cdk.models import Level
13
- from airbyte_cdk.sources.declarative.auth import DeclarativeOauth2Authenticator
14
- from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator, NoAuth
15
- from airbyte_cdk.sources.declarative.auth.oauth import DeclarativeSingleUseRefreshTokenOauth2Authenticator
27
+ from isodate import parse_duration
28
+ from pydantic.v1 import BaseModel
29
+
30
+ from airbyte_cdk.models import FailureType, Level
31
+ from airbyte_cdk.sources.connector_state_manager import ConnectorStateManager
32
+ from airbyte_cdk.sources.declarative.async_job.job_orchestrator import AsyncJobOrchestrator
33
+ from airbyte_cdk.sources.declarative.async_job.job_tracker import JobTracker
34
+ from airbyte_cdk.sources.declarative.async_job.repository import AsyncJobRepository
35
+ from airbyte_cdk.sources.declarative.async_job.status import AsyncJobStatus
36
+ from airbyte_cdk.sources.declarative.auth import DeclarativeOauth2Authenticator, JwtAuthenticator
37
+ from airbyte_cdk.sources.declarative.auth.declarative_authenticator import (
38
+ DeclarativeAuthenticator,
39
+ NoAuth,
40
+ )
41
+ from airbyte_cdk.sources.declarative.auth.jwt import JwtAlgorithm
42
+ from airbyte_cdk.sources.declarative.auth.oauth import (
43
+ DeclarativeSingleUseRefreshTokenOauth2Authenticator,
44
+ )
16
45
  from airbyte_cdk.sources.declarative.auth.selective_authenticator import SelectiveAuthenticator
17
46
  from airbyte_cdk.sources.declarative.auth.token import (
18
47
  ApiKeyAuthenticator,
@@ -20,86 +49,336 @@ from airbyte_cdk.sources.declarative.auth.token import (
20
49
  BearerAuthenticator,
21
50
  LegacySessionTokenAuthenticator,
22
51
  )
23
- from airbyte_cdk.sources.declarative.auth.token_provider import InterpolatedStringTokenProvider, SessionTokenProvider, TokenProvider
52
+ from airbyte_cdk.sources.declarative.auth.token_provider import (
53
+ InterpolatedStringTokenProvider,
54
+ SessionTokenProvider,
55
+ TokenProvider,
56
+ )
24
57
  from airbyte_cdk.sources.declarative.checks import CheckStream
58
+ from airbyte_cdk.sources.declarative.concurrency_level import ConcurrencyLevel
25
59
  from airbyte_cdk.sources.declarative.datetime import MinMaxDatetime
26
60
  from airbyte_cdk.sources.declarative.declarative_stream import DeclarativeStream
27
- from airbyte_cdk.sources.declarative.decoders import JsonDecoder
28
- from airbyte_cdk.sources.declarative.extractors import DpathExtractor, RecordFilter, RecordSelector
29
- from airbyte_cdk.sources.declarative.extractors.record_selector import SCHEMA_TRANSFORMER_TYPE_MAPPING
30
- from airbyte_cdk.sources.declarative.incremental import Cursor, CursorFactory, DatetimeBasedCursor, PerPartitionCursor
61
+ from airbyte_cdk.sources.declarative.decoders import (
62
+ Decoder,
63
+ GzipJsonDecoder,
64
+ IterableDecoder,
65
+ JsonDecoder,
66
+ JsonlDecoder,
67
+ PaginationDecoderDecorator,
68
+ XmlDecoder,
69
+ )
70
+ from airbyte_cdk.sources.declarative.decoders.composite_raw_decoder import (
71
+ CompositeRawDecoder,
72
+ CsvParser,
73
+ GzipParser,
74
+ JsonLineParser,
75
+ )
76
+ from airbyte_cdk.sources.declarative.extractors import (
77
+ DpathExtractor,
78
+ RecordFilter,
79
+ RecordSelector,
80
+ ResponseToFileExtractor,
81
+ )
82
+ from airbyte_cdk.sources.declarative.extractors.record_filter import (
83
+ ClientSideIncrementalRecordFilterDecorator,
84
+ )
85
+ from airbyte_cdk.sources.declarative.incremental import (
86
+ ChildPartitionResumableFullRefreshCursor,
87
+ CursorFactory,
88
+ DatetimeBasedCursor,
89
+ DeclarativeCursor,
90
+ GlobalSubstreamCursor,
91
+ PerPartitionCursor,
92
+ PerPartitionWithGlobalCursor,
93
+ ResumableFullRefreshCursor,
94
+ )
31
95
  from airbyte_cdk.sources.declarative.interpolation import InterpolatedString
32
96
  from airbyte_cdk.sources.declarative.interpolation.interpolated_mapping import InterpolatedMapping
33
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import AddedFieldDefinition as AddedFieldDefinitionModel
34
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import AddFields as AddFieldsModel
35
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import ApiKeyAuthenticator as ApiKeyAuthenticatorModel
36
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import BasicHttpAuthenticator as BasicHttpAuthenticatorModel
37
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import BearerAuthenticator as BearerAuthenticatorModel
38
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CheckStream as CheckStreamModel
39
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CompositeErrorHandler as CompositeErrorHandlerModel
40
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import ConstantBackoffStrategy as ConstantBackoffStrategyModel
41
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CursorPagination as CursorPaginationModel
42
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomAuthenticator as CustomAuthenticatorModel
43
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomBackoffStrategy as CustomBackoffStrategyModel
44
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomErrorHandler as CustomErrorHandlerModel
45
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomIncrementalSync as CustomIncrementalSyncModel
46
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomPaginationStrategy as CustomPaginationStrategyModel
47
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomPartitionRouter as CustomPartitionRouterModel
48
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomRecordExtractor as CustomRecordExtractorModel
49
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomRecordFilter as CustomRecordFilterModel
50
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomRequester as CustomRequesterModel
51
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomRetriever as CustomRetrieverModel
52
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomSchemaLoader as CustomSchemaLoader
53
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import CustomTransformation as CustomTransformationModel
54
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import DatetimeBasedCursor as DatetimeBasedCursorModel
55
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import DeclarativeStream as DeclarativeStreamModel
56
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import DefaultErrorHandler as DefaultErrorHandlerModel
57
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import DefaultPaginator as DefaultPaginatorModel
58
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import DpathExtractor as DpathExtractorModel
97
+ from airbyte_cdk.sources.declarative.migrations.legacy_to_per_partition_state_migration import (
98
+ LegacyToPerPartitionStateMigration,
99
+ )
100
+ from airbyte_cdk.sources.declarative.models import (
101
+ CustomStateMigration,
102
+ )
103
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
104
+ AddedFieldDefinition as AddedFieldDefinitionModel,
105
+ )
106
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
107
+ AddFields as AddFieldsModel,
108
+ )
109
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
110
+ ApiKeyAuthenticator as ApiKeyAuthenticatorModel,
111
+ )
112
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
113
+ AsyncJobStatusMap as AsyncJobStatusMapModel,
114
+ )
115
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
116
+ AsyncRetriever as AsyncRetrieverModel,
117
+ )
118
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
119
+ BasicHttpAuthenticator as BasicHttpAuthenticatorModel,
120
+ )
121
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
122
+ BearerAuthenticator as BearerAuthenticatorModel,
123
+ )
124
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
125
+ CheckStream as CheckStreamModel,
126
+ )
127
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
128
+ ComponentMappingDefinition as ComponentMappingDefinitionModel,
129
+ )
130
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
131
+ CompositeErrorHandler as CompositeErrorHandlerModel,
132
+ )
133
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
134
+ CompositeRawDecoder as CompositeRawDecoderModel,
135
+ )
136
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
137
+ ConcurrencyLevel as ConcurrencyLevelModel,
138
+ )
139
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
140
+ ConfigComponentsResolver as ConfigComponentsResolverModel,
141
+ )
142
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
143
+ ConstantBackoffStrategy as ConstantBackoffStrategyModel,
144
+ )
145
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
146
+ CsvParser as CsvParserModel,
147
+ )
148
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
149
+ CursorPagination as CursorPaginationModel,
150
+ )
151
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
152
+ CustomAuthenticator as CustomAuthenticatorModel,
153
+ )
154
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
155
+ CustomBackoffStrategy as CustomBackoffStrategyModel,
156
+ )
157
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
158
+ CustomDecoder as CustomDecoderModel,
159
+ )
160
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
161
+ CustomErrorHandler as CustomErrorHandlerModel,
162
+ )
163
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
164
+ CustomIncrementalSync as CustomIncrementalSyncModel,
165
+ )
166
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
167
+ CustomPaginationStrategy as CustomPaginationStrategyModel,
168
+ )
169
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
170
+ CustomPartitionRouter as CustomPartitionRouterModel,
171
+ )
172
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
173
+ CustomRecordExtractor as CustomRecordExtractorModel,
174
+ )
175
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
176
+ CustomRecordFilter as CustomRecordFilterModel,
177
+ )
178
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
179
+ CustomRequester as CustomRequesterModel,
180
+ )
181
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
182
+ CustomRetriever as CustomRetrieverModel,
183
+ )
184
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
185
+ CustomSchemaLoader as CustomSchemaLoader,
186
+ )
187
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
188
+ CustomSchemaNormalization as CustomSchemaNormalizationModel,
189
+ )
190
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
191
+ CustomTransformation as CustomTransformationModel,
192
+ )
193
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
194
+ DatetimeBasedCursor as DatetimeBasedCursorModel,
195
+ )
196
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
197
+ DeclarativeStream as DeclarativeStreamModel,
198
+ )
199
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
200
+ DefaultErrorHandler as DefaultErrorHandlerModel,
201
+ )
202
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
203
+ DefaultPaginator as DefaultPaginatorModel,
204
+ )
205
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
206
+ DpathExtractor as DpathExtractorModel,
207
+ )
208
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
209
+ DynamicSchemaLoader as DynamicSchemaLoaderModel,
210
+ )
59
211
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
60
212
  ExponentialBackoffStrategy as ExponentialBackoffStrategyModel,
61
213
  )
62
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import HttpRequester as HttpRequesterModel
63
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import HttpResponseFilter as HttpResponseFilterModel
64
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import InlineSchemaLoader as InlineSchemaLoaderModel
65
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import JsonDecoder as JsonDecoderModel
66
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import JsonFileSchemaLoader as JsonFileSchemaLoaderModel
214
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
215
+ FlattenFields as FlattenFieldsModel,
216
+ )
217
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
218
+ GzipJsonDecoder as GzipJsonDecoderModel,
219
+ )
220
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
221
+ GzipParser as GzipParserModel,
222
+ )
223
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
224
+ HttpComponentsResolver as HttpComponentsResolverModel,
225
+ )
226
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
227
+ HttpRequester as HttpRequesterModel,
228
+ )
229
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
230
+ HttpResponseFilter as HttpResponseFilterModel,
231
+ )
232
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
233
+ InlineSchemaLoader as InlineSchemaLoaderModel,
234
+ )
235
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
236
+ IterableDecoder as IterableDecoderModel,
237
+ )
238
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
239
+ JsonDecoder as JsonDecoderModel,
240
+ )
241
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
242
+ JsonFileSchemaLoader as JsonFileSchemaLoaderModel,
243
+ )
244
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
245
+ JsonlDecoder as JsonlDecoderModel,
246
+ )
247
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
248
+ JsonLineParser as JsonLineParserModel,
249
+ )
250
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
251
+ JwtAuthenticator as JwtAuthenticatorModel,
252
+ )
253
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
254
+ JwtHeaders as JwtHeadersModel,
255
+ )
256
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
257
+ JwtPayload as JwtPayloadModel,
258
+ )
259
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
260
+ KeysReplace as KeysReplaceModel,
261
+ )
262
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
263
+ KeysToLower as KeysToLowerModel,
264
+ )
265
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
266
+ KeysToSnakeCase as KeysToSnakeCaseModel,
267
+ )
67
268
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
68
269
  LegacySessionTokenAuthenticator as LegacySessionTokenAuthenticatorModel,
69
270
  )
70
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import ListPartitionRouter as ListPartitionRouterModel
71
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import MinMaxDatetime as MinMaxDatetimeModel
72
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import NoAuth as NoAuthModel
73
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import NoPagination as NoPaginationModel
74
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import OAuthAuthenticator as OAuthAuthenticatorModel
75
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import OffsetIncrement as OffsetIncrementModel
76
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import PageIncrement as PageIncrementModel
77
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import ParentStreamConfig as ParentStreamConfigModel
78
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import RecordFilter as RecordFilterModel
79
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import RecordSelector as RecordSelectorModel
80
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import RemoveFields as RemoveFieldsModel
81
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import RequestOption as RequestOptionModel
82
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import RequestPath as RequestPathModel
83
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import SelectiveAuthenticator as SelectiveAuthenticatorModel
84
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import SessionTokenAuthenticator as SessionTokenAuthenticatorModel
85
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import SimpleRetriever as SimpleRetrieverModel
271
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
272
+ LegacyToPerPartitionStateMigration as LegacyToPerPartitionStateMigrationModel,
273
+ )
274
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
275
+ ListPartitionRouter as ListPartitionRouterModel,
276
+ )
277
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
278
+ MinMaxDatetime as MinMaxDatetimeModel,
279
+ )
280
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
281
+ NoAuth as NoAuthModel,
282
+ )
283
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
284
+ NoPagination as NoPaginationModel,
285
+ )
286
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
287
+ OAuthAuthenticator as OAuthAuthenticatorModel,
288
+ )
289
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
290
+ OffsetIncrement as OffsetIncrementModel,
291
+ )
292
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
293
+ PageIncrement as PageIncrementModel,
294
+ )
295
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
296
+ ParentStreamConfig as ParentStreamConfigModel,
297
+ )
298
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
299
+ RecordFilter as RecordFilterModel,
300
+ )
301
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
302
+ RecordSelector as RecordSelectorModel,
303
+ )
304
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
305
+ RemoveFields as RemoveFieldsModel,
306
+ )
307
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
308
+ RequestOption as RequestOptionModel,
309
+ )
310
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
311
+ RequestPath as RequestPathModel,
312
+ )
313
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
314
+ ResponseToFileExtractor as ResponseToFileExtractorModel,
315
+ )
316
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
317
+ SchemaNormalization as SchemaNormalizationModel,
318
+ )
319
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
320
+ SchemaTypeIdentifier as SchemaTypeIdentifierModel,
321
+ )
322
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
323
+ SelectiveAuthenticator as SelectiveAuthenticatorModel,
324
+ )
325
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
326
+ SessionTokenAuthenticator as SessionTokenAuthenticatorModel,
327
+ )
328
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
329
+ SimpleRetriever as SimpleRetrieverModel,
330
+ )
86
331
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import Spec as SpecModel
87
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import SubstreamPartitionRouter as SubstreamPartitionRouterModel
332
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
333
+ StreamConfig as StreamConfigModel,
334
+ )
335
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
336
+ SubstreamPartitionRouter as SubstreamPartitionRouterModel,
337
+ )
338
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
339
+ TypesMap as TypesMapModel,
340
+ )
88
341
  from airbyte_cdk.sources.declarative.models.declarative_component_schema import ValueType
89
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import WaitTimeFromHeader as WaitTimeFromHeaderModel
90
- from airbyte_cdk.sources.declarative.models.declarative_component_schema import WaitUntilTimeFromHeader as WaitUntilTimeFromHeaderModel
91
- from airbyte_cdk.sources.declarative.partition_routers import ListPartitionRouter, SinglePartitionRouter, SubstreamPartitionRouter
92
- from airbyte_cdk.sources.declarative.partition_routers.substream_partition_router import ParentStreamConfig
342
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
343
+ WaitTimeFromHeader as WaitTimeFromHeaderModel,
344
+ )
345
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
346
+ WaitUntilTimeFromHeader as WaitUntilTimeFromHeaderModel,
347
+ )
348
+ from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
349
+ XmlDecoder as XmlDecoderModel,
350
+ )
351
+ from airbyte_cdk.sources.declarative.partition_routers import (
352
+ CartesianProductStreamSlicer,
353
+ ListPartitionRouter,
354
+ PartitionRouter,
355
+ SinglePartitionRouter,
356
+ SubstreamPartitionRouter,
357
+ )
358
+ from airbyte_cdk.sources.declarative.partition_routers.async_job_partition_router import (
359
+ AsyncJobPartitionRouter,
360
+ )
361
+ from airbyte_cdk.sources.declarative.partition_routers.substream_partition_router import (
362
+ ParentStreamConfig,
363
+ )
93
364
  from airbyte_cdk.sources.declarative.requesters import HttpRequester, RequestOption
94
- from airbyte_cdk.sources.declarative.requesters.error_handlers import CompositeErrorHandler, DefaultErrorHandler, HttpResponseFilter
365
+ from airbyte_cdk.sources.declarative.requesters.error_handlers import (
366
+ CompositeErrorHandler,
367
+ DefaultErrorHandler,
368
+ HttpResponseFilter,
369
+ )
95
370
  from airbyte_cdk.sources.declarative.requesters.error_handlers.backoff_strategies import (
96
371
  ConstantBackoffStrategy,
97
372
  ExponentialBackoffStrategy,
98
373
  WaitTimeFromHeaderBackoffStrategy,
99
374
  WaitUntilTimeFromHeaderBackoffStrategy,
100
375
  )
101
- from airbyte_cdk.sources.declarative.requesters.error_handlers.response_action import ResponseAction
102
- from airbyte_cdk.sources.declarative.requesters.paginators import DefaultPaginator, NoPagination, PaginatorTestReadDecorator
376
+ from airbyte_cdk.sources.declarative.requesters.http_job_repository import AsyncHttpJobRepository
377
+ from airbyte_cdk.sources.declarative.requesters.paginators import (
378
+ DefaultPaginator,
379
+ NoPagination,
380
+ PaginatorTestReadDecorator,
381
+ )
103
382
  from airbyte_cdk.sources.declarative.requesters.paginators.strategies import (
104
383
  CursorPaginationStrategy,
105
384
  CursorStopCondition,
@@ -108,34 +387,86 @@ from airbyte_cdk.sources.declarative.requesters.paginators.strategies import (
108
387
  StopConditionPaginationStrategyDecorator,
109
388
  )
110
389
  from airbyte_cdk.sources.declarative.requesters.request_option import RequestOptionType
111
- from airbyte_cdk.sources.declarative.requesters.request_options import InterpolatedRequestOptionsProvider
390
+ from airbyte_cdk.sources.declarative.requesters.request_options import (
391
+ DatetimeBasedRequestOptionsProvider,
392
+ DefaultRequestOptionsProvider,
393
+ InterpolatedRequestOptionsProvider,
394
+ RequestOptionsProvider,
395
+ )
112
396
  from airbyte_cdk.sources.declarative.requesters.request_path import RequestPath
113
397
  from airbyte_cdk.sources.declarative.requesters.requester import HttpMethod
114
- from airbyte_cdk.sources.declarative.retrievers import SimpleRetriever, SimpleRetrieverTestReadDecorator
115
- from airbyte_cdk.sources.declarative.schema import DefaultSchemaLoader, InlineSchemaLoader, JsonFileSchemaLoader
398
+ from airbyte_cdk.sources.declarative.resolvers import (
399
+ ComponentMappingDefinition,
400
+ ConfigComponentsResolver,
401
+ HttpComponentsResolver,
402
+ StreamConfig,
403
+ )
404
+ from airbyte_cdk.sources.declarative.retrievers import (
405
+ AsyncRetriever,
406
+ SimpleRetriever,
407
+ SimpleRetrieverTestReadDecorator,
408
+ )
409
+ from airbyte_cdk.sources.declarative.schema import (
410
+ DefaultSchemaLoader,
411
+ DynamicSchemaLoader,
412
+ InlineSchemaLoader,
413
+ JsonFileSchemaLoader,
414
+ SchemaTypeIdentifier,
415
+ TypesMap,
416
+ )
116
417
  from airbyte_cdk.sources.declarative.spec import Spec
117
- from airbyte_cdk.sources.declarative.stream_slicers import CartesianProductStreamSlicer, StreamSlicer
118
- from airbyte_cdk.sources.declarative.transformations import AddFields, RecordTransformation, RemoveFields
418
+ from airbyte_cdk.sources.declarative.stream_slicers import StreamSlicer
419
+ from airbyte_cdk.sources.declarative.transformations import (
420
+ AddFields,
421
+ RecordTransformation,
422
+ RemoveFields,
423
+ )
119
424
  from airbyte_cdk.sources.declarative.transformations.add_fields import AddedFieldDefinition
120
- from airbyte_cdk.sources.declarative.types import Config
121
- from airbyte_cdk.sources.message import InMemoryMessageRepository, LogAppenderMessageRepositoryDecorator, MessageRepository
122
- from airbyte_cdk.sources.utils.transform import TypeTransformer
123
- from isodate import parse_duration
124
- from pydantic import BaseModel
425
+ from airbyte_cdk.sources.declarative.transformations.flatten_fields import (
426
+ FlattenFields,
427
+ )
428
+ from airbyte_cdk.sources.declarative.transformations.keys_replace_transformation import (
429
+ KeysReplaceTransformation,
430
+ )
431
+ from airbyte_cdk.sources.declarative.transformations.keys_to_lower_transformation import (
432
+ KeysToLowerTransformation,
433
+ )
434
+ from airbyte_cdk.sources.declarative.transformations.keys_to_snake_transformation import (
435
+ KeysToSnakeCaseTransformation,
436
+ )
437
+ from airbyte_cdk.sources.message import (
438
+ InMemoryMessageRepository,
439
+ LogAppenderMessageRepositoryDecorator,
440
+ MessageRepository,
441
+ )
442
+ from airbyte_cdk.sources.streams.concurrent.cursor import ConcurrentCursor, CursorField
443
+ from airbyte_cdk.sources.streams.concurrent.state_converters.datetime_stream_state_converter import (
444
+ CustomFormatConcurrentStreamStateConverter,
445
+ DateTimeStreamStateConverter,
446
+ )
447
+ from airbyte_cdk.sources.streams.http.error_handlers.response_models import ResponseAction
448
+ from airbyte_cdk.sources.types import Config
449
+ from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer
125
450
 
126
451
  ComponentDefinition = Mapping[str, Any]
127
452
 
128
-
129
- DEFAULT_BACKOFF_STRATEGY = ExponentialBackoffStrategy
453
+ SCHEMA_TRANSFORMER_TYPE_MAPPING = {
454
+ SchemaNormalizationModel.None_: TransformConfig.NoTransform,
455
+ SchemaNormalizationModel.Default: TransformConfig.DefaultSchemaNormalization,
456
+ }
130
457
 
131
458
 
132
459
  class ModelToComponentFactory:
460
+ EPOCH_DATETIME_FORMAT = "%s"
461
+
133
462
  def __init__(
134
463
  self,
135
464
  limit_pages_fetched_per_slice: Optional[int] = None,
136
465
  limit_slices_fetched: Optional[int] = None,
137
466
  emit_connector_builder_messages: bool = False,
138
467
  disable_retries: bool = False,
468
+ disable_cache: bool = False,
469
+ disable_resumable_full_refresh: bool = False,
139
470
  message_repository: Optional[MessageRepository] = None,
140
471
  ):
141
472
  self._init_mappings()
@@ -143,7 +474,9 @@ class ModelToComponentFactory:
143
474
  self._limit_slices_fetched = limit_slices_fetched
144
475
  self._emit_connector_builder_messages = emit_connector_builder_messages
145
476
  self._disable_retries = disable_retries
146
- self._message_repository = message_repository or InMemoryMessageRepository( # type: ignore
477
+ self._disable_cache = disable_cache
478
+ self._disable_resumable_full_refresh = disable_resumable_full_refresh
479
+ self._message_repository = message_repository or InMemoryMessageRepository(
147
480
  self._evaluate_log_level(emit_connector_builder_messages)
148
481
  )
149
482
 
@@ -156,10 +489,13 @@ class ModelToComponentFactory:
156
489
  BearerAuthenticatorModel: self.create_bearer_authenticator,
157
490
  CheckStreamModel: self.create_check_stream,
158
491
  CompositeErrorHandlerModel: self.create_composite_error_handler,
492
+ CompositeRawDecoderModel: self.create_composite_raw_decoder,
493
+ ConcurrencyLevelModel: self.create_concurrency_level,
159
494
  ConstantBackoffStrategyModel: self.create_constant_backoff_strategy,
160
495
  CursorPaginationModel: self.create_cursor_pagination,
161
496
  CustomAuthenticatorModel: self.create_custom_component,
162
497
  CustomBackoffStrategyModel: self.create_custom_component,
498
+ CustomDecoderModel: self.create_custom_component,
163
499
  CustomErrorHandlerModel: self.create_custom_component,
164
500
  CustomIncrementalSyncModel: self.create_custom_component,
165
501
  CustomRecordExtractorModel: self.create_custom_component,
@@ -167,6 +503,8 @@ class ModelToComponentFactory:
167
503
  CustomRequesterModel: self.create_custom_component,
168
504
  CustomRetrieverModel: self.create_custom_component,
169
505
  CustomSchemaLoader: self.create_custom_component,
506
+ CustomSchemaNormalizationModel: self.create_custom_component,
507
+ CustomStateMigration: self.create_custom_component,
170
508
  CustomPaginationStrategyModel: self.create_custom_component,
171
509
  CustomPartitionRouterModel: self.create_custom_component,
172
510
  CustomTransformationModel: self.create_custom_component,
@@ -175,13 +513,29 @@ class ModelToComponentFactory:
175
513
  DefaultErrorHandlerModel: self.create_default_error_handler,
176
514
  DefaultPaginatorModel: self.create_default_paginator,
177
515
  DpathExtractorModel: self.create_dpath_extractor,
516
+ ResponseToFileExtractorModel: self.create_response_to_file_extractor,
178
517
  ExponentialBackoffStrategyModel: self.create_exponential_backoff_strategy,
179
518
  SessionTokenAuthenticatorModel: self.create_session_token_authenticator,
180
519
  HttpRequesterModel: self.create_http_requester,
181
520
  HttpResponseFilterModel: self.create_http_response_filter,
182
521
  InlineSchemaLoaderModel: self.create_inline_schema_loader,
183
522
  JsonDecoderModel: self.create_json_decoder,
523
+ JsonlDecoderModel: self.create_jsonl_decoder,
524
+ JsonLineParserModel: self.create_json_line_parser,
525
+ GzipJsonDecoderModel: self.create_gzipjson_decoder,
526
+ GzipParserModel: self.create_gzip_parser,
527
+ KeysToLowerModel: self.create_keys_to_lower_transformation,
528
+ KeysToSnakeCaseModel: self.create_keys_to_snake_transformation,
529
+ KeysReplaceModel: self.create_keys_replace_transformation,
530
+ FlattenFieldsModel: self.create_flatten_fields,
531
+ IterableDecoderModel: self.create_iterable_decoder,
532
+ XmlDecoderModel: self.create_xml_decoder,
184
533
  JsonFileSchemaLoaderModel: self.create_json_file_schema_loader,
534
+ DynamicSchemaLoaderModel: self.create_dynamic_schema_loader,
535
+ SchemaTypeIdentifierModel: self.create_schema_type_identifier,
536
+ TypesMapModel: self.create_types_map,
537
+ JwtAuthenticatorModel: self.create_jwt_authenticator,
538
+ LegacyToPerPartitionStateMigrationModel: self.create_legacy_to_per_partition_state_migration,
185
539
  ListPartitionRouterModel: self.create_list_partition_router,
186
540
  MinMaxDatetimeModel: self.create_min_max_datetime,
187
541
  NoAuthModel: self.create_no_auth,
@@ -202,13 +556,22 @@ class ModelToComponentFactory:
202
556
  SubstreamPartitionRouterModel: self.create_substream_partition_router,
203
557
  WaitTimeFromHeaderModel: self.create_wait_time_from_header,
204
558
  WaitUntilTimeFromHeaderModel: self.create_wait_until_time_from_header,
559
+ AsyncRetrieverModel: self.create_async_retriever,
560
+ HttpComponentsResolverModel: self.create_http_components_resolver,
561
+ ConfigComponentsResolverModel: self.create_config_components_resolver,
562
+ StreamConfigModel: self.create_stream_config,
563
+ ComponentMappingDefinitionModel: self.create_components_mapping_definition,
205
564
  }
206
565
 
207
566
  # Needed for the case where we need to perform a second parse on the fields of a custom component
208
567
  self.TYPE_NAME_TO_MODEL = {cls.__name__: cls for cls in self.PYDANTIC_MODEL_TO_CONSTRUCTOR}
209
568
 
210
569
  def create_component(
211
- self, model_type: Type[BaseModel], component_definition: ComponentDefinition, config: Config, **kwargs: Any
570
+ self,
571
+ model_type: Type[BaseModel],
572
+ component_definition: ComponentDefinition,
573
+ config: Config,
574
+ **kwargs: Any,
212
575
  ) -> Any:
213
576
  """
214
577
  Takes a given Pydantic model type and Mapping representing a component definition and creates a declarative component and
@@ -223,26 +586,38 @@ class ModelToComponentFactory:
223
586
 
224
587
  component_type = component_definition.get("type")
225
588
  if component_definition.get("type") != model_type.__name__:
226
- raise ValueError(f"Expected manifest component of type {model_type.__name__}, but received {component_type} instead")
589
+ raise ValueError(
590
+ f"Expected manifest component of type {model_type.__name__}, but received {component_type} instead"
591
+ )
227
592
 
228
593
  declarative_component_model = model_type.parse_obj(component_definition)
229
594
 
230
595
  if not isinstance(declarative_component_model, model_type):
231
- raise ValueError(f"Expected {model_type.__name__} component, but received {declarative_component_model.__class__.__name__}")
596
+ raise ValueError(
597
+ f"Expected {model_type.__name__} component, but received {declarative_component_model.__class__.__name__}"
598
+ )
232
599
 
233
- return self._create_component_from_model(model=declarative_component_model, config=config, **kwargs)
600
+ return self._create_component_from_model(
601
+ model=declarative_component_model, config=config, **kwargs
602
+ )
234
603
 
235
604
  def _create_component_from_model(self, model: BaseModel, config: Config, **kwargs: Any) -> Any:
236
605
  if model.__class__ not in self.PYDANTIC_MODEL_TO_CONSTRUCTOR:
237
- raise ValueError(f"{model.__class__} with attributes {model} is not a valid component type")
606
+ raise ValueError(
607
+ f"{model.__class__} with attributes {model} is not a valid component type"
608
+ )
238
609
  component_constructor = self.PYDANTIC_MODEL_TO_CONSTRUCTOR.get(model.__class__)
239
610
  if not component_constructor:
240
611
  raise ValueError(f"Could not find constructor for {model.__class__}")
241
612
  return component_constructor(model=model, config=config, **kwargs)
242
613
 
243
614
  @staticmethod
244
- def create_added_field_definition(model: AddedFieldDefinitionModel, config: Config, **kwargs: Any) -> AddedFieldDefinition:
245
- interpolated_value = InterpolatedString.create(model.value, parameters=model.parameters or {})
615
+ def create_added_field_definition(
616
+ model: AddedFieldDefinitionModel, config: Config, **kwargs: Any
617
+ ) -> AddedFieldDefinition:
618
+ interpolated_value = InterpolatedString.create(
619
+ model.value, parameters=model.parameters or {}
620
+ )
246
621
  return AddedFieldDefinition(
247
622
  path=model.path,
248
623
  value=interpolated_value,
@@ -254,13 +629,39 @@ class ModelToComponentFactory:
254
629
  added_field_definitions = [
255
630
  self._create_component_from_model(
256
631
  model=added_field_definition_model,
257
- value_type=ModelToComponentFactory._json_schema_type_name_to_type(added_field_definition_model.value_type),
632
+ value_type=ModelToComponentFactory._json_schema_type_name_to_type(
633
+ added_field_definition_model.value_type
634
+ ),
258
635
  config=config,
259
636
  )
260
637
  for added_field_definition_model in model.fields
261
638
  ]
262
639
  return AddFields(fields=added_field_definitions, parameters=model.parameters or {})
263
640
 
641
+ def create_keys_to_lower_transformation(
642
+ self, model: KeysToLowerModel, config: Config, **kwargs: Any
643
+ ) -> KeysToLowerTransformation:
644
+ return KeysToLowerTransformation()
645
+
646
+ def create_keys_to_snake_transformation(
647
+ self, model: KeysToSnakeCaseModel, config: Config, **kwargs: Any
648
+ ) -> KeysToSnakeCaseTransformation:
649
+ return KeysToSnakeCaseTransformation()
650
+
651
+ def create_keys_replace_transformation(
652
+ self, model: KeysReplaceModel, config: Config, **kwargs: Any
653
+ ) -> KeysReplaceTransformation:
654
+ return KeysReplaceTransformation(
655
+ old=model.old, new=model.new, parameters=model.parameters or {}
656
+ )
657
+
658
+ def create_flatten_fields(
659
+ self, model: FlattenFieldsModel, config: Config, **kwargs: Any
660
+ ) -> FlattenFields:
661
+ return FlattenFields(
662
+ flatten_lists=model.flatten_lists if model.flatten_lists is not None else True
663
+ )
664
+
264
665
  @staticmethod
265
666
  def _json_schema_type_name_to_type(value_type: Optional[ValueType]) -> Optional[Type[Any]]:
266
667
  if not value_type:
@@ -275,16 +676,25 @@ class ModelToComponentFactory:
275
676
 
276
677
  @staticmethod
277
678
  def create_api_key_authenticator(
278
- model: ApiKeyAuthenticatorModel, config: Config, token_provider: Optional[TokenProvider] = None, **kwargs: Any
679
+ model: ApiKeyAuthenticatorModel,
680
+ config: Config,
681
+ token_provider: Optional[TokenProvider] = None,
682
+ **kwargs: Any,
279
683
  ) -> ApiKeyAuthenticator:
280
684
  if model.inject_into is None and model.header is None:
281
- raise ValueError("Expected either inject_into or header to be set for ApiKeyAuthenticator")
685
+ raise ValueError(
686
+ "Expected either inject_into or header to be set for ApiKeyAuthenticator"
687
+ )
282
688
 
283
689
  if model.inject_into is not None and model.header is not None:
284
- raise ValueError("inject_into and header cannot be set both for ApiKeyAuthenticator - remove the deprecated header option")
690
+ raise ValueError(
691
+ "inject_into and header cannot be set both for ApiKeyAuthenticator - remove the deprecated header option"
692
+ )
285
693
 
286
694
  if token_provider is not None and model.api_token != "":
287
- raise ValueError("If token_provider is set, api_token is ignored and has to be set to empty string.")
695
+ raise ValueError(
696
+ "If token_provider is set, api_token is ignored and has to be set to empty string."
697
+ )
288
698
 
289
699
  request_option = (
290
700
  RequestOption(
@@ -300,54 +710,128 @@ class ModelToComponentFactory:
300
710
  )
301
711
  )
302
712
  return ApiKeyAuthenticator(
303
- token_provider=token_provider
304
- if token_provider is not None
305
- else InterpolatedStringTokenProvider(api_token=model.api_token or "", config=config, parameters=model.parameters or {}),
713
+ token_provider=(
714
+ token_provider
715
+ if token_provider is not None
716
+ else InterpolatedStringTokenProvider(
717
+ api_token=model.api_token or "",
718
+ config=config,
719
+ parameters=model.parameters or {},
720
+ )
721
+ ),
306
722
  request_option=request_option,
307
723
  config=config,
308
724
  parameters=model.parameters or {},
309
725
  )
310
726
 
727
+ def create_legacy_to_per_partition_state_migration(
728
+ self,
729
+ model: LegacyToPerPartitionStateMigrationModel,
730
+ config: Mapping[str, Any],
731
+ declarative_stream: DeclarativeStreamModel,
732
+ ) -> LegacyToPerPartitionStateMigration:
733
+ retriever = declarative_stream.retriever
734
+ if not isinstance(retriever, SimpleRetrieverModel):
735
+ raise ValueError(
736
+ f"LegacyToPerPartitionStateMigrations can only be applied on a DeclarativeStream with a SimpleRetriever. Got {type(retriever)}"
737
+ )
738
+ partition_router = retriever.partition_router
739
+ if not isinstance(
740
+ partition_router, (SubstreamPartitionRouterModel, CustomPartitionRouterModel)
741
+ ):
742
+ raise ValueError(
743
+ f"LegacyToPerPartitionStateMigrations can only be applied on a SimpleRetriever with a Substream partition router. Got {type(partition_router)}"
744
+ )
745
+ if not hasattr(partition_router, "parent_stream_configs"):
746
+ raise ValueError(
747
+ "LegacyToPerPartitionStateMigrations can only be applied with a parent stream configuration."
748
+ )
749
+
750
+ if not hasattr(declarative_stream, "incremental_sync"):
751
+ raise ValueError(
752
+ "LegacyToPerPartitionStateMigrations can only be applied with an incremental_sync configuration."
753
+ )
754
+
755
+ return LegacyToPerPartitionStateMigration(
756
+ partition_router, # type: ignore # was already checked above
757
+ declarative_stream.incremental_sync, # type: ignore # was already checked. Migration can be applied only to incremental streams.
758
+ config,
759
+ declarative_stream.parameters, # type: ignore # different type is expected here Mapping[str, Any], got Dict[str, Any]
760
+ )
761
+
311
762
  def create_session_token_authenticator(
312
763
  self, model: SessionTokenAuthenticatorModel, config: Config, name: str, **kwargs: Any
313
764
  ) -> Union[ApiKeyAuthenticator, BearerAuthenticator]:
314
- login_requester = self._create_component_from_model(model=model.login_requester, config=config, name=f"{name}_login_requester")
765
+ decoder = (
766
+ self._create_component_from_model(model=model.decoder, config=config)
767
+ if model.decoder
768
+ else JsonDecoder(parameters={})
769
+ )
770
+ login_requester = self._create_component_from_model(
771
+ model=model.login_requester,
772
+ config=config,
773
+ name=f"{name}_login_requester",
774
+ decoder=decoder,
775
+ )
315
776
  token_provider = SessionTokenProvider(
316
777
  login_requester=login_requester,
317
778
  session_token_path=model.session_token_path,
318
- expiration_duration=parse_duration(model.expiration_duration) if model.expiration_duration else None,
779
+ expiration_duration=parse_duration(model.expiration_duration)
780
+ if model.expiration_duration
781
+ else None,
319
782
  parameters=model.parameters or {},
320
783
  message_repository=self._message_repository,
784
+ decoder=decoder,
321
785
  )
322
786
  if model.request_authentication.type == "Bearer":
323
787
  return ModelToComponentFactory.create_bearer_authenticator(
324
788
  BearerAuthenticatorModel(type="BearerAuthenticator", api_token=""), # type: ignore # $parameters has a default value
325
789
  config,
326
- token_provider=token_provider, # type: ignore # $parameters defaults to None
790
+ token_provider=token_provider,
327
791
  )
328
792
  else:
329
793
  return ModelToComponentFactory.create_api_key_authenticator(
330
- ApiKeyAuthenticatorModel(type="ApiKeyAuthenticator", api_token="", inject_into=model.request_authentication.inject_into), # type: ignore # $parameters and headers default to None
794
+ ApiKeyAuthenticatorModel(
795
+ type="ApiKeyAuthenticator",
796
+ api_token="",
797
+ inject_into=model.request_authentication.inject_into,
798
+ ), # type: ignore # $parameters and headers default to None
331
799
  config=config,
332
800
  token_provider=token_provider,
333
801
  )
334
802
 
335
803
  @staticmethod
336
- def create_basic_http_authenticator(model: BasicHttpAuthenticatorModel, config: Config, **kwargs: Any) -> BasicHttpAuthenticator:
804
+ def create_basic_http_authenticator(
805
+ model: BasicHttpAuthenticatorModel, config: Config, **kwargs: Any
806
+ ) -> BasicHttpAuthenticator:
337
807
  return BasicHttpAuthenticator(
338
- password=model.password or "", username=model.username, config=config, parameters=model.parameters or {}
808
+ password=model.password or "",
809
+ username=model.username,
810
+ config=config,
811
+ parameters=model.parameters or {},
339
812
  )
340
813
 
341
814
  @staticmethod
342
815
  def create_bearer_authenticator(
343
- model: BearerAuthenticatorModel, config: Config, token_provider: Optional[TokenProvider] = None, **kwargs: Any
816
+ model: BearerAuthenticatorModel,
817
+ config: Config,
818
+ token_provider: Optional[TokenProvider] = None,
819
+ **kwargs: Any,
344
820
  ) -> BearerAuthenticator:
345
821
  if token_provider is not None and model.api_token != "":
346
- raise ValueError("If token_provider is set, api_token is ignored and has to be set to empty string.")
822
+ raise ValueError(
823
+ "If token_provider is set, api_token is ignored and has to be set to empty string."
824
+ )
347
825
  return BearerAuthenticator(
348
- token_provider=token_provider
349
- if token_provider is not None
350
- else InterpolatedStringTokenProvider(api_token=model.api_token or "", config=config, parameters=model.parameters or {}),
826
+ token_provider=(
827
+ token_provider
828
+ if token_provider is not None
829
+ else InterpolatedStringTokenProvider(
830
+ api_token=model.api_token or "",
831
+ config=config,
832
+ parameters=model.parameters or {},
833
+ )
834
+ ),
351
835
  config=config,
352
836
  parameters=model.parameters or {},
353
837
  )
@@ -356,29 +840,213 @@ class ModelToComponentFactory:
356
840
  def create_check_stream(model: CheckStreamModel, config: Config, **kwargs: Any) -> CheckStream:
357
841
  return CheckStream(stream_names=model.stream_names, parameters={})
358
842
 
359
- def create_composite_error_handler(self, model: CompositeErrorHandlerModel, config: Config, **kwargs: Any) -> CompositeErrorHandler:
843
+ def create_composite_error_handler(
844
+ self, model: CompositeErrorHandlerModel, config: Config, **kwargs: Any
845
+ ) -> CompositeErrorHandler:
360
846
  error_handlers = [
361
- self._create_component_from_model(model=error_handler_model, config=config) for error_handler_model in model.error_handlers
847
+ self._create_component_from_model(model=error_handler_model, config=config)
848
+ for error_handler_model in model.error_handlers
362
849
  ]
363
- return CompositeErrorHandler(error_handlers=error_handlers, parameters=model.parameters or {})
850
+ return CompositeErrorHandler(
851
+ error_handlers=error_handlers, parameters=model.parameters or {}
852
+ )
364
853
 
365
854
  @staticmethod
366
- def create_constant_backoff_strategy(model: ConstantBackoffStrategyModel, config: Config, **kwargs: Any) -> ConstantBackoffStrategy:
855
+ def create_concurrency_level(
856
+ model: ConcurrencyLevelModel, config: Config, **kwargs: Any
857
+ ) -> ConcurrencyLevel:
858
+ return ConcurrencyLevel(
859
+ default_concurrency=model.default_concurrency,
860
+ max_concurrency=model.max_concurrency,
861
+ config=config,
862
+ parameters={},
863
+ )
864
+
865
+ def create_concurrent_cursor_from_datetime_based_cursor(
866
+ self,
867
+ state_manager: ConnectorStateManager,
868
+ model_type: Type[BaseModel],
869
+ component_definition: ComponentDefinition,
870
+ stream_name: str,
871
+ stream_namespace: Optional[str],
872
+ config: Config,
873
+ stream_state: MutableMapping[str, Any],
874
+ **kwargs: Any,
875
+ ) -> ConcurrentCursor:
876
+ component_type = component_definition.get("type")
877
+ if component_definition.get("type") != model_type.__name__:
878
+ raise ValueError(
879
+ f"Expected manifest component of type {model_type.__name__}, but received {component_type} instead"
880
+ )
881
+
882
+ datetime_based_cursor_model = model_type.parse_obj(component_definition)
883
+
884
+ if not isinstance(datetime_based_cursor_model, DatetimeBasedCursorModel):
885
+ raise ValueError(
886
+ f"Expected {model_type.__name__} component, but received {datetime_based_cursor_model.__class__.__name__}"
887
+ )
888
+
889
+ interpolated_cursor_field = InterpolatedString.create(
890
+ datetime_based_cursor_model.cursor_field,
891
+ parameters=datetime_based_cursor_model.parameters or {},
892
+ )
893
+ cursor_field = CursorField(interpolated_cursor_field.eval(config=config))
894
+
895
+ interpolated_partition_field_start = InterpolatedString.create(
896
+ datetime_based_cursor_model.partition_field_start or "start_time",
897
+ parameters=datetime_based_cursor_model.parameters or {},
898
+ )
899
+ interpolated_partition_field_end = InterpolatedString.create(
900
+ datetime_based_cursor_model.partition_field_end or "end_time",
901
+ parameters=datetime_based_cursor_model.parameters or {},
902
+ )
903
+
904
+ slice_boundary_fields = (
905
+ interpolated_partition_field_start.eval(config=config),
906
+ interpolated_partition_field_end.eval(config=config),
907
+ )
908
+
909
+ datetime_format = datetime_based_cursor_model.datetime_format
910
+
911
+ cursor_granularity = (
912
+ parse_duration(datetime_based_cursor_model.cursor_granularity)
913
+ if datetime_based_cursor_model.cursor_granularity
914
+ else None
915
+ )
916
+
917
+ lookback_window = None
918
+ interpolated_lookback_window = (
919
+ InterpolatedString.create(
920
+ datetime_based_cursor_model.lookback_window,
921
+ parameters=datetime_based_cursor_model.parameters or {},
922
+ )
923
+ if datetime_based_cursor_model.lookback_window
924
+ else None
925
+ )
926
+ if interpolated_lookback_window:
927
+ evaluated_lookback_window = interpolated_lookback_window.eval(config=config)
928
+ if evaluated_lookback_window:
929
+ lookback_window = parse_duration(evaluated_lookback_window)
930
+
931
+ connector_state_converter: DateTimeStreamStateConverter
932
+ connector_state_converter = CustomFormatConcurrentStreamStateConverter(
933
+ datetime_format=datetime_format,
934
+ input_datetime_formats=datetime_based_cursor_model.cursor_datetime_formats,
935
+ is_sequential_state=True,
936
+ cursor_granularity=cursor_granularity,
937
+ )
938
+
939
+ start_date_runtime_value: Union[InterpolatedString, str, MinMaxDatetime]
940
+ if isinstance(datetime_based_cursor_model.start_datetime, MinMaxDatetimeModel):
941
+ start_date_runtime_value = self.create_min_max_datetime(
942
+ model=datetime_based_cursor_model.start_datetime, config=config
943
+ )
944
+ else:
945
+ start_date_runtime_value = datetime_based_cursor_model.start_datetime
946
+
947
+ end_date_runtime_value: Optional[Union[InterpolatedString, str, MinMaxDatetime]]
948
+ if isinstance(datetime_based_cursor_model.end_datetime, MinMaxDatetimeModel):
949
+ end_date_runtime_value = self.create_min_max_datetime(
950
+ model=datetime_based_cursor_model.end_datetime, config=config
951
+ )
952
+ else:
953
+ end_date_runtime_value = datetime_based_cursor_model.end_datetime
954
+
955
+ interpolated_start_date = MinMaxDatetime.create(
956
+ interpolated_string_or_min_max_datetime=start_date_runtime_value,
957
+ parameters=datetime_based_cursor_model.parameters,
958
+ )
959
+ interpolated_end_date = (
960
+ None
961
+ if not end_date_runtime_value
962
+ else MinMaxDatetime.create(
963
+ end_date_runtime_value, datetime_based_cursor_model.parameters
964
+ )
965
+ )
966
+
967
+ # If datetime format is not specified then start/end datetime should inherit it from the stream slicer
968
+ if not interpolated_start_date.datetime_format:
969
+ interpolated_start_date.datetime_format = datetime_format
970
+ if interpolated_end_date and not interpolated_end_date.datetime_format:
971
+ interpolated_end_date.datetime_format = datetime_format
972
+
973
+ start_date = interpolated_start_date.get_datetime(config=config)
974
+ end_date_provider = (
975
+ partial(interpolated_end_date.get_datetime, config)
976
+ if interpolated_end_date
977
+ else connector_state_converter.get_end_provider()
978
+ )
979
+
980
+ if (
981
+ datetime_based_cursor_model.step and not datetime_based_cursor_model.cursor_granularity
982
+ ) or (
983
+ not datetime_based_cursor_model.step and datetime_based_cursor_model.cursor_granularity
984
+ ):
985
+ raise ValueError(
986
+ f"If step is defined, cursor_granularity should be as well and vice-versa. "
987
+ f"Right now, step is `{datetime_based_cursor_model.step}` and cursor_granularity is `{datetime_based_cursor_model.cursor_granularity}`"
988
+ )
989
+
990
+ # When step is not defined, default to a step size from the starting date to the present moment
991
+ step_length = datetime.timedelta.max
992
+ interpolated_step = (
993
+ InterpolatedString.create(
994
+ datetime_based_cursor_model.step,
995
+ parameters=datetime_based_cursor_model.parameters or {},
996
+ )
997
+ if datetime_based_cursor_model.step
998
+ else None
999
+ )
1000
+ if interpolated_step:
1001
+ evaluated_step = interpolated_step.eval(config)
1002
+ if evaluated_step:
1003
+ step_length = parse_duration(evaluated_step)
1004
+
1005
+ return ConcurrentCursor(
1006
+ stream_name=stream_name,
1007
+ stream_namespace=stream_namespace,
1008
+ stream_state=stream_state,
1009
+ message_repository=self._message_repository,
1010
+ connector_state_manager=state_manager,
1011
+ connector_state_converter=connector_state_converter,
1012
+ cursor_field=cursor_field,
1013
+ slice_boundary_fields=slice_boundary_fields,
1014
+ start=start_date, # type: ignore # Having issues w/ inspection for GapType and CursorValueType as shown in existing tests. Confirmed functionality is working in practice
1015
+ end_provider=end_date_provider, # type: ignore # Having issues w/ inspection for GapType and CursorValueType as shown in existing tests. Confirmed functionality is working in practice
1016
+ lookback_window=lookback_window,
1017
+ slice_range=step_length,
1018
+ cursor_granularity=cursor_granularity,
1019
+ )
1020
+
1021
+ @staticmethod
1022
+ def create_constant_backoff_strategy(
1023
+ model: ConstantBackoffStrategyModel, config: Config, **kwargs: Any
1024
+ ) -> ConstantBackoffStrategy:
367
1025
  return ConstantBackoffStrategy(
368
1026
  backoff_time_in_seconds=model.backoff_time_in_seconds,
369
1027
  config=config,
370
1028
  parameters=model.parameters or {},
371
1029
  )
372
1030
 
373
- def create_cursor_pagination(self, model: CursorPaginationModel, config: Config, **kwargs: Any) -> CursorPaginationStrategy:
374
- if model.decoder:
375
- decoder = self._create_component_from_model(model=model.decoder, config=config)
1031
+ def create_cursor_pagination(
1032
+ self, model: CursorPaginationModel, config: Config, decoder: Decoder, **kwargs: Any
1033
+ ) -> CursorPaginationStrategy:
1034
+ if isinstance(decoder, PaginationDecoderDecorator):
1035
+ if not isinstance(decoder.decoder, (JsonDecoder, XmlDecoder)):
1036
+ raise ValueError(
1037
+ f"Provided decoder of {type(decoder.decoder)=} is not supported. Please set JsonDecoder or XmlDecoder instead."
1038
+ )
1039
+ decoder_to_use = decoder
376
1040
  else:
377
- decoder = JsonDecoder(parameters=model.parameters or {})
1041
+ if not isinstance(decoder, (JsonDecoder, XmlDecoder)):
1042
+ raise ValueError(
1043
+ f"Provided decoder of {type(decoder)=} is not supported. Please set JsonDecoder or XmlDecoder instead."
1044
+ )
1045
+ decoder_to_use = PaginationDecoderDecorator(decoder=decoder)
378
1046
 
379
1047
  return CursorPaginationStrategy(
380
1048
  cursor_value=model.cursor_value,
381
- decoder=decoder,
1049
+ decoder=decoder_to_use,
382
1050
  page_size=model.page_size,
383
1051
  stop_condition=model.stop_condition,
384
1052
  config=config,
@@ -409,18 +1077,28 @@ class ModelToComponentFactory:
409
1077
  # the custom component and this code performs a second parse to convert the sub-fields first into models, then declarative components
410
1078
  for model_field, model_value in model_args.items():
411
1079
  # If a custom component field doesn't have a type set, we try to use the type hints to infer the type
412
- if isinstance(model_value, dict) and "type" not in model_value and model_field in component_fields:
413
- derived_type = self._derive_component_type_from_type_hints(component_fields.get(model_field))
1080
+ if (
1081
+ isinstance(model_value, dict)
1082
+ and "type" not in model_value
1083
+ and model_field in component_fields
1084
+ ):
1085
+ derived_type = self._derive_component_type_from_type_hints(
1086
+ component_fields.get(model_field)
1087
+ )
414
1088
  if derived_type:
415
1089
  model_value["type"] = derived_type
416
1090
 
417
1091
  if self._is_component(model_value):
418
- model_args[model_field] = self._create_nested_component(model, model_field, model_value, config)
1092
+ model_args[model_field] = self._create_nested_component(
1093
+ model, model_field, model_value, config
1094
+ )
419
1095
  elif isinstance(model_value, list):
420
1096
  vals = []
421
1097
  for v in model_value:
422
1098
  if isinstance(v, dict) and "type" not in v and model_field in component_fields:
423
- derived_type = self._derive_component_type_from_type_hints(component_fields.get(model_field))
1099
+ derived_type = self._derive_component_type_from_type_hints(
1100
+ component_fields.get(model_field)
1101
+ )
424
1102
  if derived_type:
425
1103
  v["type"] = derived_type
426
1104
  if self._is_component(v):
@@ -429,7 +1107,11 @@ class ModelToComponentFactory:
429
1107
  vals.append(v)
430
1108
  model_args[model_field] = vals
431
1109
 
432
- kwargs = {class_field: model_args[class_field] for class_field in component_fields.keys() if class_field in model_args}
1110
+ kwargs = {
1111
+ class_field: model_args[class_field]
1112
+ for class_field in component_fields.keys()
1113
+ if class_field in model_args
1114
+ }
433
1115
  return custom_component_class(**kwargs)
434
1116
 
435
1117
  @staticmethod
@@ -473,7 +1155,9 @@ class ModelToComponentFactory:
473
1155
  else:
474
1156
  return []
475
1157
 
476
- def _create_nested_component(self, model: Any, model_field: str, model_value: Any, config: Config) -> Any:
1158
+ def _create_nested_component(
1159
+ self, model: Any, model_field: str, model_value: Any, config: Config
1160
+ ) -> Any:
477
1161
  type_name = model_value.get("type", None)
478
1162
  if not type_name:
479
1163
  # If no type is specified, we can assume this is a dictionary object which can be returned instead of a subcomponent
@@ -492,16 +1176,29 @@ class ModelToComponentFactory:
492
1176
  model_constructor = self.PYDANTIC_MODEL_TO_CONSTRUCTOR.get(parsed_model.__class__)
493
1177
  constructor_kwargs = inspect.getfullargspec(model_constructor).kwonlyargs
494
1178
  model_parameters = model_value.get("$parameters", {})
495
- matching_parameters = {kwarg: model_parameters[kwarg] for kwarg in constructor_kwargs if kwarg in model_parameters}
496
- return self._create_component_from_model(model=parsed_model, config=config, **matching_parameters)
1179
+ matching_parameters = {
1180
+ kwarg: model_parameters[kwarg]
1181
+ for kwarg in constructor_kwargs
1182
+ if kwarg in model_parameters
1183
+ }
1184
+ return self._create_component_from_model(
1185
+ model=parsed_model, config=config, **matching_parameters
1186
+ )
497
1187
  except TypeError as error:
498
1188
  missing_parameters = self._extract_missing_parameters(error)
499
1189
  if missing_parameters:
500
1190
  raise ValueError(
501
1191
  f"Error creating component '{type_name}' with parent custom component {model.class_name}: Please provide "
502
- + ", ".join((f"{type_name}.$parameters.{parameter}" for parameter in missing_parameters))
1192
+ + ", ".join(
1193
+ (
1194
+ f"{type_name}.$parameters.{parameter}"
1195
+ for parameter in missing_parameters
1196
+ )
1197
+ )
503
1198
  )
504
- raise TypeError(f"Error creating component '{type_name}' with parent custom component {model.class_name}: {error}")
1199
+ raise TypeError(
1200
+ f"Error creating component '{type_name}' with parent custom component {model.class_name}: {error}"
1201
+ )
505
1202
  else:
506
1203
  raise ValueError(
507
1204
  f"Error creating custom component {model.class_name}. Subcomponent creation has not been implemented for '{type_name}'"
@@ -511,16 +1208,26 @@ class ModelToComponentFactory:
511
1208
  def _is_component(model_value: Any) -> bool:
512
1209
  return isinstance(model_value, dict) and model_value.get("type") is not None
513
1210
 
514
- def create_datetime_based_cursor(self, model: DatetimeBasedCursorModel, config: Config, **kwargs: Any) -> DatetimeBasedCursor:
1211
+ def create_datetime_based_cursor(
1212
+ self, model: DatetimeBasedCursorModel, config: Config, **kwargs: Any
1213
+ ) -> DatetimeBasedCursor:
515
1214
  start_datetime: Union[str, MinMaxDatetime] = (
516
- model.start_datetime if isinstance(model.start_datetime, str) else self.create_min_max_datetime(model.start_datetime, config)
1215
+ model.start_datetime
1216
+ if isinstance(model.start_datetime, str)
1217
+ else self.create_min_max_datetime(model.start_datetime, config)
517
1218
  )
518
1219
  end_datetime: Union[str, MinMaxDatetime, None] = None
519
1220
  if model.is_data_feed and model.end_datetime:
520
1221
  raise ValueError("Data feed does not support end_datetime")
1222
+ if model.is_data_feed and model.is_client_side_incremental:
1223
+ raise ValueError(
1224
+ "`Client side incremental` cannot be applied with `data feed`. Choose only 1 from them."
1225
+ )
521
1226
  if model.end_datetime:
522
1227
  end_datetime = (
523
- model.end_datetime if isinstance(model.end_datetime, str) else self.create_min_max_datetime(model.end_datetime, config)
1228
+ model.end_datetime
1229
+ if isinstance(model.end_datetime, str)
1230
+ else self.create_min_max_datetime(model.end_datetime, config)
524
1231
  )
525
1232
 
526
1233
  end_time_option = (
@@ -544,7 +1251,9 @@ class ModelToComponentFactory:
544
1251
 
545
1252
  return DatetimeBasedCursor(
546
1253
  cursor_field=model.cursor_field,
547
- cursor_datetime_formats=model.cursor_datetime_formats if model.cursor_datetime_formats else [],
1254
+ cursor_datetime_formats=model.cursor_datetime_formats
1255
+ if model.cursor_datetime_formats
1256
+ else [],
548
1257
  cursor_granularity=model.cursor_granularity,
549
1258
  datetime_format=model.datetime_format,
550
1259
  end_datetime=end_datetime,
@@ -556,11 +1265,14 @@ class ModelToComponentFactory:
556
1265
  partition_field_end=model.partition_field_end,
557
1266
  partition_field_start=model.partition_field_start,
558
1267
  message_repository=self._message_repository,
1268
+ is_compare_strictly=model.is_compare_strictly,
559
1269
  config=config,
560
1270
  parameters=model.parameters or {},
561
1271
  )
562
1272
 
563
- def create_declarative_stream(self, model: DeclarativeStreamModel, config: Config, **kwargs: Any) -> DeclarativeStream:
1273
+ def create_declarative_stream(
1274
+ self, model: DeclarativeStreamModel, config: Config, **kwargs: Any
1275
+ ) -> DeclarativeStream:
564
1276
  # When constructing a declarative stream, we assemble the incremental_sync component and retriever's partition_router field
565
1277
  # components if they exist into a single CartesianProductStreamSlicer. This is then passed back as an argument when constructing the
566
1278
  # Retriever. This is done in the declarative stream not the retriever to support custom retrievers. The custom create methods in
@@ -569,25 +1281,102 @@ class ModelToComponentFactory:
569
1281
 
570
1282
  primary_key = model.primary_key.__root__ if model.primary_key else None
571
1283
  stop_condition_on_cursor = (
572
- model.incremental_sync and hasattr(model.incremental_sync, "is_data_feed") and model.incremental_sync.is_data_feed
1284
+ model.incremental_sync
1285
+ and hasattr(model.incremental_sync, "is_data_feed")
1286
+ and model.incremental_sync.is_data_feed
573
1287
  )
1288
+ client_side_incremental_sync = None
1289
+ if (
1290
+ model.incremental_sync
1291
+ and hasattr(model.incremental_sync, "is_client_side_incremental")
1292
+ and model.incremental_sync.is_client_side_incremental
1293
+ ):
1294
+ supported_slicers = (
1295
+ DatetimeBasedCursor,
1296
+ GlobalSubstreamCursor,
1297
+ PerPartitionWithGlobalCursor,
1298
+ )
1299
+ if combined_slicers and not isinstance(combined_slicers, supported_slicers):
1300
+ raise ValueError(
1301
+ "Unsupported Slicer is used. PerPartitionWithGlobalCursor should be used here instead"
1302
+ )
1303
+ client_side_incremental_sync = {
1304
+ "date_time_based_cursor": self._create_component_from_model(
1305
+ model=model.incremental_sync, config=config
1306
+ ),
1307
+ "substream_cursor": (
1308
+ combined_slicers
1309
+ if isinstance(
1310
+ combined_slicers, (PerPartitionWithGlobalCursor, GlobalSubstreamCursor)
1311
+ )
1312
+ else None
1313
+ ),
1314
+ }
1315
+
1316
+ if model.incremental_sync and isinstance(model.incremental_sync, DatetimeBasedCursorModel):
1317
+ cursor_model = model.incremental_sync
1318
+
1319
+ end_time_option = (
1320
+ RequestOption(
1321
+ inject_into=RequestOptionType(cursor_model.end_time_option.inject_into.value),
1322
+ field_name=cursor_model.end_time_option.field_name,
1323
+ parameters=cursor_model.parameters or {},
1324
+ )
1325
+ if cursor_model.end_time_option
1326
+ else None
1327
+ )
1328
+ start_time_option = (
1329
+ RequestOption(
1330
+ inject_into=RequestOptionType(cursor_model.start_time_option.inject_into.value),
1331
+ field_name=cursor_model.start_time_option.field_name,
1332
+ parameters=cursor_model.parameters or {},
1333
+ )
1334
+ if cursor_model.start_time_option
1335
+ else None
1336
+ )
1337
+
1338
+ request_options_provider = DatetimeBasedRequestOptionsProvider(
1339
+ start_time_option=start_time_option,
1340
+ end_time_option=end_time_option,
1341
+ partition_field_start=cursor_model.partition_field_end,
1342
+ partition_field_end=cursor_model.partition_field_end,
1343
+ config=config,
1344
+ parameters=model.parameters or {},
1345
+ )
1346
+ else:
1347
+ request_options_provider = None
1348
+
574
1349
  transformations = []
575
1350
  if model.transformations:
576
1351
  for transformation_model in model.transformations:
577
- transformations.append(self._create_component_from_model(model=transformation_model, config=config))
1352
+ transformations.append(
1353
+ self._create_component_from_model(model=transformation_model, config=config)
1354
+ )
578
1355
  retriever = self._create_component_from_model(
579
1356
  model=model.retriever,
580
1357
  config=config,
581
1358
  name=model.name,
582
1359
  primary_key=primary_key,
583
1360
  stream_slicer=combined_slicers,
1361
+ request_options_provider=request_options_provider,
584
1362
  stop_condition_on_cursor=stop_condition_on_cursor,
1363
+ client_side_incremental_sync=client_side_incremental_sync,
585
1364
  transformations=transformations,
586
1365
  )
587
1366
  cursor_field = model.incremental_sync.cursor_field if model.incremental_sync else None
588
1367
 
1368
+ if model.state_migrations:
1369
+ state_transformations = [
1370
+ self._create_component_from_model(state_migration, config, declarative_stream=model)
1371
+ for state_migration in model.state_migrations
1372
+ ]
1373
+ else:
1374
+ state_transformations = []
1375
+
589
1376
  if model.schema_loader:
590
- schema_loader = self._create_component_from_model(model=model.schema_loader, config=config)
1377
+ schema_loader = self._create_component_from_model(
1378
+ model=model.schema_loader, config=config
1379
+ )
591
1380
  else:
592
1381
  options = model.parameters or {}
593
1382
  if "name" not in options:
@@ -600,58 +1389,113 @@ class ModelToComponentFactory:
600
1389
  retriever=retriever,
601
1390
  schema_loader=schema_loader,
602
1391
  stream_cursor_field=cursor_field or "",
1392
+ state_migrations=state_transformations,
603
1393
  config=config,
604
1394
  parameters=model.parameters or {},
605
1395
  )
606
1396
 
607
- def _merge_stream_slicers(self, model: DeclarativeStreamModel, config: Config) -> Optional[StreamSlicer]:
608
- stream_slicer = None
609
- if hasattr(model.retriever, "partition_router") and model.retriever.partition_router:
610
- stream_slicer_model = model.retriever.partition_router
1397
+ def _build_stream_slicer_from_partition_router(
1398
+ self,
1399
+ model: Union[AsyncRetrieverModel, CustomRetrieverModel, SimpleRetrieverModel],
1400
+ config: Config,
1401
+ ) -> Optional[PartitionRouter]:
1402
+ if (
1403
+ hasattr(model, "partition_router")
1404
+ and isinstance(model, SimpleRetrieverModel)
1405
+ and model.partition_router
1406
+ ):
1407
+ stream_slicer_model = model.partition_router
1408
+
611
1409
  if isinstance(stream_slicer_model, list):
612
- stream_slicer = CartesianProductStreamSlicer(
613
- [self._create_component_from_model(model=slicer, config=config) for slicer in stream_slicer_model], parameters={}
1410
+ return CartesianProductStreamSlicer(
1411
+ [
1412
+ self._create_component_from_model(model=slicer, config=config)
1413
+ for slicer in stream_slicer_model
1414
+ ],
1415
+ parameters={},
614
1416
  )
615
1417
  else:
616
- stream_slicer = self._create_component_from_model(model=stream_slicer_model, config=config)
1418
+ return self._create_component_from_model(model=stream_slicer_model, config=config) # type: ignore[no-any-return]
1419
+ # Will be created PartitionRouter as stream_slicer_model is model.partition_router
1420
+ return None
1421
+
1422
+ def _build_resumable_cursor_from_paginator(
1423
+ self,
1424
+ model: Union[AsyncRetrieverModel, CustomRetrieverModel, SimpleRetrieverModel],
1425
+ stream_slicer: Optional[StreamSlicer],
1426
+ ) -> Optional[StreamSlicer]:
1427
+ if hasattr(model, "paginator") and model.paginator and not stream_slicer:
1428
+ # For the regular Full-Refresh streams, we use the high level `ResumableFullRefreshCursor`
1429
+ return ResumableFullRefreshCursor(parameters={})
1430
+ return None
1431
+
1432
+ def _merge_stream_slicers(
1433
+ self, model: DeclarativeStreamModel, config: Config
1434
+ ) -> Optional[StreamSlicer]:
1435
+ stream_slicer = self._build_stream_slicer_from_partition_router(model.retriever, config)
617
1436
 
618
1437
  if model.incremental_sync and stream_slicer:
619
1438
  incremental_sync_model = model.incremental_sync
620
- return PerPartitionCursor(
621
- cursor_factory=CursorFactory(
622
- lambda: self._create_component_from_model(model=incremental_sync_model, config=config),
623
- ),
624
- partition_router=stream_slicer,
625
- )
1439
+ if (
1440
+ hasattr(incremental_sync_model, "global_substream_cursor")
1441
+ and incremental_sync_model.global_substream_cursor
1442
+ ):
1443
+ cursor_component = self._create_component_from_model(
1444
+ model=incremental_sync_model, config=config
1445
+ )
1446
+ return GlobalSubstreamCursor(
1447
+ stream_cursor=cursor_component, partition_router=stream_slicer
1448
+ )
1449
+ else:
1450
+ cursor_component = self._create_component_from_model(
1451
+ model=incremental_sync_model, config=config
1452
+ )
1453
+ return PerPartitionWithGlobalCursor(
1454
+ cursor_factory=CursorFactory(
1455
+ lambda: self._create_component_from_model(
1456
+ model=incremental_sync_model, config=config
1457
+ ),
1458
+ ),
1459
+ partition_router=stream_slicer,
1460
+ stream_cursor=cursor_component,
1461
+ )
626
1462
  elif model.incremental_sync:
627
- return self._create_component_from_model(model=model.incremental_sync, config=config) if model.incremental_sync else None
628
- elif stream_slicer:
1463
+ return (
1464
+ self._create_component_from_model(model=model.incremental_sync, config=config)
1465
+ if model.incremental_sync
1466
+ else None
1467
+ )
1468
+ elif self._disable_resumable_full_refresh:
629
1469
  return stream_slicer
630
- else:
631
- return None
1470
+ elif stream_slicer:
1471
+ # For the Full-Refresh sub-streams, we use the nested `ChildPartitionResumableFullRefreshCursor`
1472
+ return PerPartitionCursor(
1473
+ cursor_factory=CursorFactory(
1474
+ create_function=partial(ChildPartitionResumableFullRefreshCursor, {})
1475
+ ),
1476
+ partition_router=stream_slicer,
1477
+ )
1478
+ return self._build_resumable_cursor_from_paginator(model.retriever, stream_slicer)
632
1479
 
633
- def create_default_error_handler(self, model: DefaultErrorHandlerModel, config: Config, **kwargs: Any) -> DefaultErrorHandler:
1480
+ def create_default_error_handler(
1481
+ self, model: DefaultErrorHandlerModel, config: Config, **kwargs: Any
1482
+ ) -> DefaultErrorHandler:
634
1483
  backoff_strategies = []
635
1484
  if model.backoff_strategies:
636
1485
  for backoff_strategy_model in model.backoff_strategies:
637
- backoff_strategies.append(self._create_component_from_model(model=backoff_strategy_model, config=config))
638
- else:
639
- backoff_strategies.append(DEFAULT_BACKOFF_STRATEGY(config=config, parameters=model.parameters or {}))
1486
+ backoff_strategies.append(
1487
+ self._create_component_from_model(model=backoff_strategy_model, config=config)
1488
+ )
640
1489
 
641
1490
  response_filters = []
642
1491
  if model.response_filters:
643
1492
  for response_filter_model in model.response_filters:
644
- response_filters.append(self._create_component_from_model(model=response_filter_model, config=config))
645
- else:
646
- response_filters.append(
647
- HttpResponseFilter(
648
- ResponseAction.RETRY,
649
- http_codes=HttpResponseFilter.DEFAULT_RETRIABLE_ERRORS,
650
- config=config,
651
- parameters=model.parameters or {},
1493
+ response_filters.append(
1494
+ self._create_component_from_model(model=response_filter_model, config=config)
652
1495
  )
653
- )
654
- response_filters.append(HttpResponseFilter(ResponseAction.IGNORE, config=config, parameters=model.parameters or {}))
1496
+ response_filters.append(
1497
+ HttpResponseFilter(config=config, parameters=model.parameters or {})
1498
+ )
655
1499
 
656
1500
  return DefaultErrorHandler(
657
1501
  backoff_strategies=backoff_strategies,
@@ -662,23 +1506,41 @@ class ModelToComponentFactory:
662
1506
  )
663
1507
 
664
1508
  def create_default_paginator(
665
- self, model: DefaultPaginatorModel, config: Config, *, url_base: str, cursor_used_for_stop_condition: Optional[Cursor] = None
1509
+ self,
1510
+ model: DefaultPaginatorModel,
1511
+ config: Config,
1512
+ *,
1513
+ url_base: str,
1514
+ decoder: Optional[Decoder] = None,
1515
+ cursor_used_for_stop_condition: Optional[DeclarativeCursor] = None,
666
1516
  ) -> Union[DefaultPaginator, PaginatorTestReadDecorator]:
667
- decoder = self._create_component_from_model(model=model.decoder, config=config) if model.decoder else JsonDecoder(parameters={})
1517
+ if decoder:
1518
+ if not isinstance(decoder, (JsonDecoder, XmlDecoder)):
1519
+ raise ValueError(
1520
+ f"Provided decoder of {type(decoder)=} is not supported. Please set JsonDecoder or XmlDecoder instead."
1521
+ )
1522
+ decoder_to_use = PaginationDecoderDecorator(decoder=decoder)
1523
+ else:
1524
+ decoder_to_use = PaginationDecoderDecorator(decoder=JsonDecoder(parameters={}))
668
1525
  page_size_option = (
669
- self._create_component_from_model(model=model.page_size_option, config=config) if model.page_size_option else None
1526
+ self._create_component_from_model(model=model.page_size_option, config=config)
1527
+ if model.page_size_option
1528
+ else None
670
1529
  )
671
1530
  page_token_option = (
672
- self._create_component_from_model(model=model.page_token_option, config=config) if model.page_token_option else None
1531
+ self._create_component_from_model(model=model.page_token_option, config=config)
1532
+ if model.page_token_option
1533
+ else None
1534
+ )
1535
+ pagination_strategy = self._create_component_from_model(
1536
+ model=model.pagination_strategy, config=config, decoder=decoder_to_use
673
1537
  )
674
- pagination_strategy = self._create_component_from_model(model=model.pagination_strategy, config=config)
675
1538
  if cursor_used_for_stop_condition:
676
1539
  pagination_strategy = StopConditionPaginationStrategyDecorator(
677
1540
  pagination_strategy, CursorStopCondition(cursor_used_for_stop_condition)
678
1541
  )
679
-
680
1542
  paginator = DefaultPaginator(
681
- decoder=decoder,
1543
+ decoder=decoder_to_use,
682
1544
  page_size_option=page_size_option,
683
1545
  page_token_option=page_token_option,
684
1546
  pagination_strategy=pagination_strategy,
@@ -690,25 +1552,68 @@ class ModelToComponentFactory:
690
1552
  return PaginatorTestReadDecorator(paginator, self._limit_pages_fetched_per_slice)
691
1553
  return paginator
692
1554
 
693
- def create_dpath_extractor(self, model: DpathExtractorModel, config: Config, **kwargs: Any) -> DpathExtractor:
694
- decoder = self._create_component_from_model(model.decoder, config=config) if model.decoder else JsonDecoder(parameters={})
1555
+ def create_dpath_extractor(
1556
+ self,
1557
+ model: DpathExtractorModel,
1558
+ config: Config,
1559
+ decoder: Optional[Decoder] = None,
1560
+ **kwargs: Any,
1561
+ ) -> DpathExtractor:
1562
+ if decoder:
1563
+ decoder_to_use = decoder
1564
+ else:
1565
+ decoder_to_use = JsonDecoder(parameters={})
695
1566
  model_field_path: List[Union[InterpolatedString, str]] = [x for x in model.field_path]
696
- return DpathExtractor(decoder=decoder, field_path=model_field_path, config=config, parameters=model.parameters or {})
1567
+ return DpathExtractor(
1568
+ decoder=decoder_to_use,
1569
+ field_path=model_field_path,
1570
+ config=config,
1571
+ parameters=model.parameters or {},
1572
+ )
1573
+
1574
+ def create_response_to_file_extractor(
1575
+ self,
1576
+ model: ResponseToFileExtractorModel,
1577
+ **kwargs: Any,
1578
+ ) -> ResponseToFileExtractor:
1579
+ return ResponseToFileExtractor(parameters=model.parameters or {})
697
1580
 
698
1581
  @staticmethod
699
- def create_exponential_backoff_strategy(model: ExponentialBackoffStrategyModel, config: Config) -> ExponentialBackoffStrategy:
700
- return ExponentialBackoffStrategy(factor=model.factor or 5, parameters=model.parameters or {}, config=config)
1582
+ def create_exponential_backoff_strategy(
1583
+ model: ExponentialBackoffStrategyModel, config: Config
1584
+ ) -> ExponentialBackoffStrategy:
1585
+ return ExponentialBackoffStrategy(
1586
+ factor=model.factor or 5, parameters=model.parameters or {}, config=config
1587
+ )
701
1588
 
702
- def create_http_requester(self, model: HttpRequesterModel, config: Config, *, name: str) -> HttpRequester:
1589
+ def create_http_requester(
1590
+ self,
1591
+ model: HttpRequesterModel,
1592
+ config: Config,
1593
+ decoder: Decoder = JsonDecoder(parameters={}),
1594
+ *,
1595
+ name: str,
1596
+ ) -> HttpRequester:
703
1597
  authenticator = (
704
- self._create_component_from_model(model=model.authenticator, config=config, url_base=model.url_base, name=name)
1598
+ self._create_component_from_model(
1599
+ model=model.authenticator,
1600
+ config=config,
1601
+ url_base=model.url_base,
1602
+ name=name,
1603
+ decoder=decoder,
1604
+ )
705
1605
  if model.authenticator
706
1606
  else None
707
1607
  )
708
1608
  error_handler = (
709
1609
  self._create_component_from_model(model=model.error_handler, config=config)
710
1610
  if model.error_handler
711
- else DefaultErrorHandler(backoff_strategies=[], response_filters=[], config=config, parameters=model.parameters or {})
1611
+ else DefaultErrorHandler(
1612
+ backoff_strategies=[],
1613
+ response_filters=[],
1614
+ config=config,
1615
+ parameters=model.parameters or {},
1616
+ )
712
1617
  )
713
1618
 
714
1619
  request_options_provider = InterpolatedRequestOptionsProvider(
@@ -723,7 +1628,7 @@ class ModelToComponentFactory:
723
1628
  assert model.use_cache is not None # for mypy
724
1629
  assert model.http_method is not None # for mypy
725
1630
 
726
- assert model.use_cache is not None # for mypy
1631
+ use_cache = model.use_cache and not self._disable_cache
727
1632
 
728
1633
  return HttpRequester(
729
1634
  name=name,
@@ -737,18 +1642,29 @@ class ModelToComponentFactory:
737
1642
  disable_retries=self._disable_retries,
738
1643
  parameters=model.parameters or {},
739
1644
  message_repository=self._message_repository,
740
- use_cache=model.use_cache,
1645
+ use_cache=use_cache,
1646
+ decoder=decoder,
1647
+ stream_response=decoder.is_stream_response() if decoder else False,
741
1648
  )
742
1649
 
743
1650
  @staticmethod
744
- def create_http_response_filter(model: HttpResponseFilterModel, config: Config, **kwargs: Any) -> HttpResponseFilter:
745
- action = ResponseAction(model.action.value)
1651
+ def create_http_response_filter(
1652
+ model: HttpResponseFilterModel, config: Config, **kwargs: Any
1653
+ ) -> HttpResponseFilter:
1654
+ if model.action:
1655
+ action = ResponseAction(model.action.value)
1656
+ else:
1657
+ action = None
1658
+
1659
+ failure_type = FailureType(model.failure_type.value) if model.failure_type else None
1660
+
746
1661
  http_codes = (
747
1662
  set(model.http_codes) if model.http_codes else set()
748
1663
  ) # JSON schema notation has no set data type. The schema enforces an array of unique elements
749
1664
 
750
1665
  return HttpResponseFilter(
751
1666
  action=action,
1667
+ failure_type=failure_type,
752
1668
  error_message=model.error_message or "",
753
1669
  error_message_contains=model.error_message_contains or "",
754
1670
  http_codes=http_codes,
@@ -758,19 +1674,160 @@ class ModelToComponentFactory:
758
1674
  )
759
1675
 
760
1676
  @staticmethod
761
- def create_inline_schema_loader(model: InlineSchemaLoaderModel, config: Config, **kwargs: Any) -> InlineSchemaLoader:
1677
+ def create_inline_schema_loader(
1678
+ model: InlineSchemaLoaderModel, config: Config, **kwargs: Any
1679
+ ) -> InlineSchemaLoader:
762
1680
  return InlineSchemaLoader(schema=model.schema_ or {}, parameters={})
763
1681
 
1682
+ @staticmethod
1683
+ def create_types_map(model: TypesMapModel, **kwargs: Any) -> TypesMap:
1684
+ return TypesMap(target_type=model.target_type, current_type=model.current_type)
1685
+
1686
+ def create_schema_type_identifier(
1687
+ self, model: SchemaTypeIdentifierModel, config: Config, **kwargs: Any
1688
+ ) -> SchemaTypeIdentifier:
1689
+ types_mapping = []
1690
+ if model.types_mapping:
1691
+ types_mapping.extend(
1692
+ [
1693
+ self._create_component_from_model(types_map, config=config)
1694
+ for types_map in model.types_mapping
1695
+ ]
1696
+ )
1697
+ model_schema_pointer: List[Union[InterpolatedString, str]] = (
1698
+ [x for x in model.schema_pointer] if model.schema_pointer else []
1699
+ )
1700
+ model_key_pointer: List[Union[InterpolatedString, str]] = [x for x in model.key_pointer]
1701
+ model_type_pointer: Optional[List[Union[InterpolatedString, str]]] = (
1702
+ [x for x in model.type_pointer] if model.type_pointer else None
1703
+ )
1704
+
1705
+ return SchemaTypeIdentifier(
1706
+ schema_pointer=model_schema_pointer,
1707
+ key_pointer=model_key_pointer,
1708
+ type_pointer=model_type_pointer,
1709
+ types_mapping=types_mapping,
1710
+ parameters=model.parameters or {},
1711
+ )
1712
+
1713
+ def create_dynamic_schema_loader(
1714
+ self, model: DynamicSchemaLoaderModel, config: Config, **kwargs: Any
1715
+ ) -> DynamicSchemaLoader:
1716
+ stream_slicer = self._build_stream_slicer_from_partition_router(model.retriever, config)
1717
+ combined_slicers = self._build_resumable_cursor_from_paginator(
1718
+ model.retriever, stream_slicer
1719
+ )
1720
+
1721
+ schema_transformations = []
1722
+ if model.schema_transformations:
1723
+ for transformation_model in model.schema_transformations:
1724
+ schema_transformations.append(
1725
+ self._create_component_from_model(model=transformation_model, config=config)
1726
+ )
1727
+
1728
+ retriever = self._create_component_from_model(
1729
+ model=model.retriever,
1730
+ config=config,
1731
+ name="",
1732
+ primary_key=None,
1733
+ stream_slicer=combined_slicers,
1734
+ transformations=[],
1735
+ )
1736
+ schema_type_identifier = self._create_component_from_model(
1737
+ model.schema_type_identifier, config=config, parameters=model.parameters or {}
1738
+ )
1739
+ return DynamicSchemaLoader(
1740
+ retriever=retriever,
1741
+ config=config,
1742
+ schema_transformations=schema_transformations,
1743
+ schema_type_identifier=schema_type_identifier,
1744
+ parameters=model.parameters or {},
1745
+ )
1746
+
764
1747
  @staticmethod
765
1748
  def create_json_decoder(model: JsonDecoderModel, config: Config, **kwargs: Any) -> JsonDecoder:
766
1749
  return JsonDecoder(parameters={})
767
1750
 
768
1751
  @staticmethod
769
- def create_json_file_schema_loader(model: JsonFileSchemaLoaderModel, config: Config, **kwargs: Any) -> JsonFileSchemaLoader:
770
- return JsonFileSchemaLoader(file_path=model.file_path or "", config=config, parameters=model.parameters or {})
1752
+ def create_jsonl_decoder(
1753
+ model: JsonlDecoderModel, config: Config, **kwargs: Any
1754
+ ) -> JsonlDecoder:
1755
+ return JsonlDecoder(parameters={})
1756
+
1757
+ @staticmethod
1758
+ def create_json_line_parser(
1759
+ model: JsonLineParserModel, config: Config, **kwargs: Any
1760
+ ) -> JsonLineParser:
1761
+ return JsonLineParser(encoding=model.encoding)
1762
+
1763
+ @staticmethod
1764
+ def create_iterable_decoder(
1765
+ model: IterableDecoderModel, config: Config, **kwargs: Any
1766
+ ) -> IterableDecoder:
1767
+ return IterableDecoder(parameters={})
1768
+
1769
+ @staticmethod
1770
+ def create_xml_decoder(model: XmlDecoderModel, config: Config, **kwargs: Any) -> XmlDecoder:
1771
+ return XmlDecoder(parameters={})
1772
+
1773
+ @staticmethod
1774
+ def create_gzipjson_decoder(
1775
+ model: GzipJsonDecoderModel, config: Config, **kwargs: Any
1776
+ ) -> GzipJsonDecoder:
1777
+ return GzipJsonDecoder(parameters={}, encoding=model.encoding)
1778
+
1779
+ def create_gzip_parser(
1780
+ self, model: GzipParserModel, config: Config, **kwargs: Any
1781
+ ) -> GzipParser:
1782
+ inner_parser = self._create_component_from_model(model=model.inner_parser, config=config)
1783
+ return GzipParser(inner_parser=inner_parser)
1784
+
1785
+ @staticmethod
1786
+ def create_csv_parser(model: CsvParserModel, config: Config, **kwargs: Any) -> CsvParser:
1787
+ return CsvParser(encoding=model.encoding, delimiter=model.delimiter)
1788
+
1789
+ def create_composite_raw_decoder(
1790
+ self, model: CompositeRawDecoderModel, config: Config, **kwargs: Any
1791
+ ) -> CompositeRawDecoder:
1792
+ parser = self._create_component_from_model(model=model.parser, config=config)
1793
+ return CompositeRawDecoder(parser=parser)
1794
+
1795
+ @staticmethod
1796
+ def create_json_file_schema_loader(
1797
+ model: JsonFileSchemaLoaderModel, config: Config, **kwargs: Any
1798
+ ) -> JsonFileSchemaLoader:
1799
+ return JsonFileSchemaLoader(
1800
+ file_path=model.file_path or "", config=config, parameters=model.parameters or {}
1801
+ )
1802
+
1803
+ @staticmethod
1804
+ def create_jwt_authenticator(
1805
+ model: JwtAuthenticatorModel, config: Config, **kwargs: Any
1806
+ ) -> JwtAuthenticator:
1807
+ jwt_headers = model.jwt_headers or JwtHeadersModel(kid=None, typ="JWT", cty=None)
1808
+ jwt_payload = model.jwt_payload or JwtPayloadModel(iss=None, sub=None, aud=None)
1809
+ return JwtAuthenticator(
1810
+ config=config,
1811
+ parameters=model.parameters or {},
1812
+ algorithm=JwtAlgorithm(model.algorithm.value),
1813
+ secret_key=model.secret_key,
1814
+ base64_encode_secret_key=model.base64_encode_secret_key,
1815
+ token_duration=model.token_duration,
1816
+ header_prefix=model.header_prefix,
1817
+ kid=jwt_headers.kid,
1818
+ typ=jwt_headers.typ,
1819
+ cty=jwt_headers.cty,
1820
+ iss=jwt_payload.iss,
1821
+ sub=jwt_payload.sub,
1822
+ aud=jwt_payload.aud,
1823
+ additional_jwt_headers=model.additional_jwt_headers,
1824
+ additional_jwt_payload=model.additional_jwt_payload,
1825
+ )
771
1826
 
772
1827
  @staticmethod
773
- def create_list_partition_router(model: ListPartitionRouterModel, config: Config, **kwargs: Any) -> ListPartitionRouter:
1828
+ def create_list_partition_router(
1829
+ model: ListPartitionRouterModel, config: Config, **kwargs: Any
1830
+ ) -> ListPartitionRouter:
774
1831
  request_option = (
775
1832
  RequestOption(
776
1833
  inject_into=RequestOptionType(model.request_option.inject_into.value),
@@ -789,7 +1846,9 @@ class ModelToComponentFactory:
789
1846
  )
790
1847
 
791
1848
  @staticmethod
792
- def create_min_max_datetime(model: MinMaxDatetimeModel, config: Config, **kwargs: Any) -> MinMaxDatetime:
1849
+ def create_min_max_datetime(
1850
+ model: MinMaxDatetimeModel, config: Config, **kwargs: Any
1851
+ ) -> MinMaxDatetime:
793
1852
  return MinMaxDatetime(
794
1853
  datetime=model.datetime,
795
1854
  datetime_format=model.datetime_format or "",
@@ -803,29 +1862,44 @@ class ModelToComponentFactory:
803
1862
  return NoAuth(parameters=model.parameters or {})
804
1863
 
805
1864
  @staticmethod
806
- def create_no_pagination(model: NoPaginationModel, config: Config, **kwargs: Any) -> NoPagination:
1865
+ def create_no_pagination(
1866
+ model: NoPaginationModel, config: Config, **kwargs: Any
1867
+ ) -> NoPagination:
807
1868
  return NoPagination(parameters={})
808
1869
 
809
- def create_oauth_authenticator(self, model: OAuthAuthenticatorModel, config: Config, **kwargs: Any) -> DeclarativeOauth2Authenticator:
1870
+ def create_oauth_authenticator(
1871
+ self, model: OAuthAuthenticatorModel, config: Config, **kwargs: Any
1872
+ ) -> DeclarativeOauth2Authenticator:
810
1873
  if model.refresh_token_updater:
811
1874
  # ignore type error because fixing it would have a lot of dependencies, revisit later
812
1875
  return DeclarativeSingleUseRefreshTokenOauth2Authenticator( # type: ignore
813
1876
  config,
814
- InterpolatedString.create(model.token_refresh_endpoint, parameters=model.parameters or {}).eval(config),
1877
+ InterpolatedString.create(
1878
+ model.token_refresh_endpoint, # type: ignore
1879
+ parameters=model.parameters or {},
1880
+ ).eval(config),
815
1881
  access_token_name=InterpolatedString.create(
816
1882
  model.access_token_name or "access_token", parameters=model.parameters or {}
817
1883
  ).eval(config),
818
1884
  refresh_token_name=model.refresh_token_updater.refresh_token_name,
819
- expires_in_name=InterpolatedString.create(model.expires_in_name or "expires_in", parameters=model.parameters or {}).eval(
820
- config
821
- ),
822
- client_id=InterpolatedString.create(model.client_id, parameters=model.parameters or {}).eval(config),
823
- client_secret=InterpolatedString.create(model.client_secret, parameters=model.parameters or {}).eval(config),
1885
+ expires_in_name=InterpolatedString.create(
1886
+ model.expires_in_name or "expires_in", parameters=model.parameters or {}
1887
+ ).eval(config),
1888
+ client_id=InterpolatedString.create(
1889
+ model.client_id, parameters=model.parameters or {}
1890
+ ).eval(config),
1891
+ client_secret=InterpolatedString.create(
1892
+ model.client_secret, parameters=model.parameters or {}
1893
+ ).eval(config),
824
1894
  access_token_config_path=model.refresh_token_updater.access_token_config_path,
825
1895
  refresh_token_config_path=model.refresh_token_updater.refresh_token_config_path,
826
1896
  token_expiry_date_config_path=model.refresh_token_updater.token_expiry_date_config_path,
827
- grant_type=InterpolatedString.create(model.grant_type or "refresh_token", parameters=model.parameters or {}).eval(config),
828
- refresh_request_body=InterpolatedMapping(model.refresh_request_body or {}, parameters=model.parameters or {}).eval(config),
1897
+ grant_type=InterpolatedString.create(
1898
+ model.grant_type or "refresh_token", parameters=model.parameters or {}
1899
+ ).eval(config),
1900
+ refresh_request_body=InterpolatedMapping(
1901
+ model.refresh_request_body or {}, parameters=model.parameters or {}
1902
+ ).eval(config),
829
1903
  scopes=model.scopes,
830
1904
  token_expiry_date_format=model.token_expiry_date_format,
831
1905
  message_repository=self._message_repository,
@@ -836,6 +1910,7 @@ class ModelToComponentFactory:
836
1910
  # ignore type error because fixing it would have a lot of dependencies, revisit later
837
1911
  return DeclarativeOauth2Authenticator( # type: ignore
838
1912
  access_token_name=model.access_token_name or "access_token",
1913
+ access_token_value=model.access_token_value,
839
1914
  client_id=model.client_id,
840
1915
  client_secret=model.client_secret,
841
1916
  expires_in_name=model.expires_in_name or "expires_in",
@@ -844,7 +1919,7 @@ class ModelToComponentFactory:
844
1919
  refresh_token=model.refresh_token,
845
1920
  scopes=model.scopes,
846
1921
  token_expiry_date=model.token_expiry_date,
847
- token_expiry_date_format=model.token_expiry_date_format, # type: ignore
1922
+ token_expiry_date_format=model.token_expiry_date_format,
848
1923
  token_expiry_is_time_of_expiration=bool(model.token_expiry_date_format),
849
1924
  token_refresh_endpoint=model.token_refresh_endpoint,
850
1925
  config=config,
@@ -853,16 +1928,33 @@ class ModelToComponentFactory:
853
1928
  )
854
1929
 
855
1930
  @staticmethod
856
- def create_offset_increment(model: OffsetIncrementModel, config: Config, **kwargs: Any) -> OffsetIncrement:
1931
+ def create_offset_increment(
1932
+ model: OffsetIncrementModel, config: Config, decoder: Decoder, **kwargs: Any
1933
+ ) -> OffsetIncrement:
1934
+ if isinstance(decoder, PaginationDecoderDecorator):
1935
+ if not isinstance(decoder.decoder, (JsonDecoder, XmlDecoder)):
1936
+ raise ValueError(
1937
+ f"Provided decoder of {type(decoder.decoder)=} is not supported. Please set JsonDecoder or XmlDecoder instead."
1938
+ )
1939
+ decoder_to_use = decoder
1940
+ else:
1941
+ if not isinstance(decoder, (JsonDecoder, XmlDecoder)):
1942
+ raise ValueError(
1943
+ f"Provided decoder of {type(decoder)=} is not supported. Please set JsonDecoder or XmlDecoder instead."
1944
+ )
1945
+ decoder_to_use = PaginationDecoderDecorator(decoder=decoder)
857
1946
  return OffsetIncrement(
858
1947
  page_size=model.page_size,
859
1948
  config=config,
1949
+ decoder=decoder_to_use,
860
1950
  inject_on_first_request=model.inject_on_first_request or False,
861
1951
  parameters=model.parameters or {},
862
1952
  )
863
1953
 
864
1954
  @staticmethod
865
- def create_page_increment(model: PageIncrementModel, config: Config, **kwargs: Any) -> PageIncrement:
1955
+ def create_page_increment(
1956
+ model: PageIncrementModel, config: Config, **kwargs: Any
1957
+ ) -> PageIncrement:
866
1958
  return PageIncrement(
867
1959
  page_size=model.page_size,
868
1960
  config=config,
@@ -871,28 +1963,42 @@ class ModelToComponentFactory:
871
1963
  parameters=model.parameters or {},
872
1964
  )
873
1965
 
874
- def create_parent_stream_config(self, model: ParentStreamConfigModel, config: Config, **kwargs: Any) -> ParentStreamConfig:
1966
+ def create_parent_stream_config(
1967
+ self, model: ParentStreamConfigModel, config: Config, **kwargs: Any
1968
+ ) -> ParentStreamConfig:
875
1969
  declarative_stream = self._create_component_from_model(model.stream, config=config)
876
- request_option = self._create_component_from_model(model.request_option, config=config) if model.request_option else None
1970
+ request_option = (
1971
+ self._create_component_from_model(model.request_option, config=config)
1972
+ if model.request_option
1973
+ else None
1974
+ )
877
1975
  return ParentStreamConfig(
878
1976
  parent_key=model.parent_key,
879
1977
  request_option=request_option,
880
1978
  stream=declarative_stream,
881
1979
  partition_field=model.partition_field,
882
1980
  config=config,
1981
+ incremental_dependency=model.incremental_dependency or False,
883
1982
  parameters=model.parameters or {},
1983
+ extra_fields=model.extra_fields,
884
1984
  )
885
1985
 
886
1986
  @staticmethod
887
- def create_record_filter(model: RecordFilterModel, config: Config, **kwargs: Any) -> RecordFilter:
888
- return RecordFilter(condition=model.condition or "", config=config, parameters=model.parameters or {})
1987
+ def create_record_filter(
1988
+ model: RecordFilterModel, config: Config, **kwargs: Any
1989
+ ) -> RecordFilter:
1990
+ return RecordFilter(
1991
+ condition=model.condition or "", config=config, parameters=model.parameters or {}
1992
+ )
889
1993
 
890
1994
  @staticmethod
891
1995
  def create_request_path(model: RequestPathModel, config: Config, **kwargs: Any) -> RequestPath:
892
1996
  return RequestPath(parameters={})
893
1997
 
894
1998
  @staticmethod
895
- def create_request_option(model: RequestOptionModel, config: Config, **kwargs: Any) -> RequestOption:
1999
+ def create_request_option(
2000
+ model: RequestOptionModel, config: Config, **kwargs: Any
2001
+ ) -> RequestOption:
896
2002
  inject_into = RequestOptionType(model.inject_into.value)
897
2003
  return RequestOption(field_name=model.field_name, inject_into=inject_into, parameters={})
898
2004
 
@@ -901,29 +2007,60 @@ class ModelToComponentFactory:
901
2007
  model: RecordSelectorModel,
902
2008
  config: Config,
903
2009
  *,
904
- transformations: List[RecordTransformation],
2010
+ name: str,
2011
+ transformations: List[RecordTransformation] | None = None,
2012
+ decoder: Decoder | None = None,
2013
+ client_side_incremental_sync: Dict[str, Any] | None = None,
905
2014
  **kwargs: Any,
906
2015
  ) -> RecordSelector:
907
- assert model.schema_normalization is not None # for mypy
908
- extractor = self._create_component_from_model(model=model.extractor, config=config)
909
- record_filter = self._create_component_from_model(model.record_filter, config=config) if model.record_filter else None
910
- schema_normalization = TypeTransformer(SCHEMA_TRANSFORMER_TYPE_MAPPING[model.schema_normalization])
2016
+ extractor = self._create_component_from_model(
2017
+ model=model.extractor, decoder=decoder, config=config
2018
+ )
2019
+ record_filter = (
2020
+ self._create_component_from_model(model.record_filter, config=config)
2021
+ if model.record_filter
2022
+ else None
2023
+ )
2024
+ if client_side_incremental_sync:
2025
+ record_filter = ClientSideIncrementalRecordFilterDecorator(
2026
+ config=config,
2027
+ parameters=model.parameters,
2028
+ condition=model.record_filter.condition
2029
+ if (model.record_filter and hasattr(model.record_filter, "condition"))
2030
+ else None,
2031
+ **client_side_incremental_sync,
2032
+ )
2033
+ schema_normalization = (
2034
+ TypeTransformer(SCHEMA_TRANSFORMER_TYPE_MAPPING[model.schema_normalization])
2035
+ if isinstance(model.schema_normalization, SchemaNormalizationModel)
2036
+ else self._create_component_from_model(model.schema_normalization, config=config) # type: ignore[arg-type] # custom normalization model expected here
2037
+ )
911
2038
 
912
2039
  return RecordSelector(
913
2040
  extractor=extractor,
2041
+ name=name,
914
2042
  config=config,
915
2043
  record_filter=record_filter,
916
- transformations=transformations,
2044
+ transformations=transformations or [],
917
2045
  schema_normalization=schema_normalization,
918
2046
  parameters=model.parameters or {},
919
2047
  )
920
2048
 
921
2049
  @staticmethod
922
- def create_remove_fields(model: RemoveFieldsModel, config: Config, **kwargs: Any) -> RemoveFields:
923
- return RemoveFields(field_pointers=model.field_pointers, condition=model.condition or "", parameters={})
2050
+ def create_remove_fields(
2051
+ model: RemoveFieldsModel, config: Config, **kwargs: Any
2052
+ ) -> RemoveFields:
2053
+ return RemoveFields(
2054
+ field_pointers=model.field_pointers, condition=model.condition or "", parameters={}
2055
+ )
924
2056
 
925
- def create_selective_authenticator(self, model: SelectiveAuthenticatorModel, config: Config, **kwargs: Any) -> DeclarativeAuthenticator:
926
- authenticators = {name: self._create_component_from_model(model=auth, config=config) for name, auth in model.authenticators.items()}
2057
+ def create_selective_authenticator(
2058
+ self, model: SelectiveAuthenticatorModel, config: Config, **kwargs: Any
2059
+ ) -> DeclarativeAuthenticator:
2060
+ authenticators = {
2061
+ name: self._create_component_from_model(model=auth, config=config)
2062
+ for name, auth in model.authenticators.items()
2063
+ }
927
2064
  # SelectiveAuthenticator will return instance of DeclarativeAuthenticator or raise ValueError error
928
2065
  return SelectiveAuthenticator( # type: ignore[abstract]
929
2066
  config=config,
@@ -957,14 +2094,49 @@ class ModelToComponentFactory:
957
2094
  name: str,
958
2095
  primary_key: Optional[Union[str, List[str], List[List[str]]]],
959
2096
  stream_slicer: Optional[StreamSlicer],
2097
+ request_options_provider: Optional[RequestOptionsProvider] = None,
960
2098
  stop_condition_on_cursor: bool = False,
2099
+ client_side_incremental_sync: Optional[Dict[str, Any]] = None,
961
2100
  transformations: List[RecordTransformation],
962
2101
  ) -> SimpleRetriever:
963
- requester = self._create_component_from_model(model=model.requester, config=config, name=name)
964
- record_selector = self._create_component_from_model(model=model.record_selector, config=config, transformations=transformations)
965
- url_base = model.requester.url_base if hasattr(model.requester, "url_base") else requester.get_url_base()
2102
+ decoder = (
2103
+ self._create_component_from_model(model=model.decoder, config=config)
2104
+ if model.decoder
2105
+ else JsonDecoder(parameters={})
2106
+ )
2107
+ requester = self._create_component_from_model(
2108
+ model=model.requester, decoder=decoder, config=config, name=name
2109
+ )
2110
+ record_selector = self._create_component_from_model(
2111
+ model=model.record_selector,
2112
+ name=name,
2113
+ config=config,
2114
+ decoder=decoder,
2115
+ transformations=transformations,
2116
+ client_side_incremental_sync=client_side_incremental_sync,
2117
+ )
2118
+ url_base = (
2119
+ model.requester.url_base
2120
+ if hasattr(model.requester, "url_base")
2121
+ else requester.get_url_base()
2122
+ )
2123
+
2124
+ # Define cursor only if per partition or common incremental support is needed
2125
+ cursor = stream_slicer if isinstance(stream_slicer, DeclarativeCursor) else None
2126
+
2127
+ if (
2128
+ not isinstance(stream_slicer, DatetimeBasedCursor)
2129
+ or type(stream_slicer) is not DatetimeBasedCursor
2130
+ ):
2131
+ # Many of the custom component implementations of DatetimeBasedCursor override get_request_params() (or other methods).
2132
+ # Because we're decoupling RequestOptionsProvider from the Cursor, custom components will eventually need to reimplement
2133
+ # their own RequestOptionsProvider. However, right now the existing StreamSlicer/Cursor still can act as the SimpleRetriever's
2134
+ # request_options_provider
2135
+ request_options_provider = stream_slicer or DefaultRequestOptionsProvider(parameters={})
2136
+ elif not request_options_provider:
2137
+ request_options_provider = DefaultRequestOptionsProvider(parameters={})
2138
+
966
2139
  stream_slicer = stream_slicer or SinglePartitionRouter(parameters={})
967
- cursor = stream_slicer if isinstance(stream_slicer, Cursor) else None
968
2140
 
969
2141
  cursor_used_for_stop_condition = cursor if stop_condition_on_cursor else None
970
2142
  paginator = (
@@ -972,13 +2144,16 @@ class ModelToComponentFactory:
972
2144
  model=model.paginator,
973
2145
  config=config,
974
2146
  url_base=url_base,
2147
+ decoder=decoder,
975
2148
  cursor_used_for_stop_condition=cursor_used_for_stop_condition,
976
2149
  )
977
2150
  if model.paginator
978
2151
  else NoPagination(parameters={})
979
2152
  )
980
2153
 
981
- ignore_stream_slicer_parameters_on_paginated_requests = model.ignore_stream_slicer_parameters_on_paginated_requests or False
2154
+ ignore_stream_slicer_parameters_on_paginated_requests = (
2155
+ model.ignore_stream_slicer_parameters_on_paginated_requests or False
2156
+ )
982
2157
 
983
2158
  if self._limit_slices_fetched or self._emit_connector_builder_messages:
984
2159
  return SimpleRetrieverTestReadDecorator(
@@ -988,6 +2163,7 @@ class ModelToComponentFactory:
988
2163
  requester=requester,
989
2164
  record_selector=record_selector,
990
2165
  stream_slicer=stream_slicer,
2166
+ request_option_provider=request_options_provider,
991
2167
  cursor=cursor,
992
2168
  config=config,
993
2169
  maximum_number_of_slices=self._limit_slices_fetched or 5,
@@ -1001,12 +2177,192 @@ class ModelToComponentFactory:
1001
2177
  requester=requester,
1002
2178
  record_selector=record_selector,
1003
2179
  stream_slicer=stream_slicer,
2180
+ request_option_provider=request_options_provider,
1004
2181
  cursor=cursor,
1005
2182
  config=config,
1006
2183
  ignore_stream_slicer_parameters_on_paginated_requests=ignore_stream_slicer_parameters_on_paginated_requests,
1007
2184
  parameters=model.parameters or {},
1008
2185
  )
1009
2186
 
2187
+ def _create_async_job_status_mapping(
2188
+ self, model: AsyncJobStatusMapModel, config: Config, **kwargs: Any
2189
+ ) -> Mapping[str, AsyncJobStatus]:
2190
+ api_status_to_cdk_status = {}
2191
+ for cdk_status, api_statuses in model.dict().items():
2192
+ if cdk_status == "type":
2193
+ # This is an element of the dict because of the typing of the CDK but it is not a CDK status
2194
+ continue
2195
+
2196
+ for status in api_statuses:
2197
+ if status in api_status_to_cdk_status:
2198
+ raise ValueError(
2199
+ f"API status {status} is already set for CDK status {cdk_status}. Please ensure API statuses are only provided once"
2200
+ )
2201
+ api_status_to_cdk_status[status] = self._get_async_job_status(cdk_status)
2202
+ return api_status_to_cdk_status
2203
+
2204
+ def _get_async_job_status(self, status: str) -> AsyncJobStatus:
2205
+ match status:
2206
+ case "running":
2207
+ return AsyncJobStatus.RUNNING
2208
+ case "completed":
2209
+ return AsyncJobStatus.COMPLETED
2210
+ case "failed":
2211
+ return AsyncJobStatus.FAILED
2212
+ case "timeout":
2213
+ return AsyncJobStatus.TIMED_OUT
2214
+ case _:
2215
+ raise ValueError(f"Unsupported CDK status {status}")
2216
+
2217
+ def create_async_retriever(
2218
+ self,
2219
+ model: AsyncRetrieverModel,
2220
+ config: Config,
2221
+ *,
2222
+ name: str,
2223
+ primary_key: Optional[
2224
+ Union[str, List[str], List[List[str]]]
2225
+ ], # this seems to be needed to match create_simple_retriever
2226
+ stream_slicer: Optional[StreamSlicer],
2227
+ client_side_incremental_sync: Optional[Dict[str, Any]] = None,
2228
+ transformations: List[RecordTransformation],
2229
+ **kwargs: Any,
2230
+ ) -> AsyncRetriever:
2231
+ decoder = (
2232
+ self._create_component_from_model(model=model.decoder, config=config)
2233
+ if model.decoder
2234
+ else JsonDecoder(parameters={})
2235
+ )
2236
+ record_selector = self._create_component_from_model(
2237
+ model=model.record_selector,
2238
+ config=config,
2239
+ decoder=decoder,
2240
+ name=name,
2241
+ transformations=transformations,
2242
+ client_side_incremental_sync=client_side_incremental_sync,
2243
+ )
2244
+ stream_slicer = stream_slicer or SinglePartitionRouter(parameters={})
2245
+ creation_requester = self._create_component_from_model(
2246
+ model=model.creation_requester,
2247
+ decoder=decoder,
2248
+ config=config,
2249
+ name=f"job creation - {name}",
2250
+ )
2251
+ polling_requester = self._create_component_from_model(
2252
+ model=model.polling_requester,
2253
+ decoder=decoder,
2254
+ config=config,
2255
+ name=f"job polling - {name}",
2256
+ )
2257
+ job_download_components_name = f"job download - {name}"
2258
+ download_decoder = (
2259
+ self._create_component_from_model(model=model.download_decoder, config=config)
2260
+ if model.download_decoder
2261
+ else JsonDecoder(parameters={})
2262
+ )
2263
+ download_extractor = (
2264
+ self._create_component_from_model(
2265
+ model=model.download_extractor,
2266
+ config=config,
2267
+ decoder=download_decoder,
2268
+ parameters=model.parameters,
2269
+ )
2270
+ if model.download_extractor
2271
+ else DpathExtractor(
2272
+ [],
2273
+ config=config,
2274
+ decoder=download_decoder,
2275
+ parameters=model.parameters or {},
2276
+ )
2277
+ )
2278
+ download_requester = self._create_component_from_model(
2279
+ model=model.download_requester,
2280
+ decoder=download_decoder,
2281
+ config=config,
2282
+ name=job_download_components_name,
2283
+ )
2284
+ download_retriever = SimpleRetriever(
2285
+ requester=download_requester,
2286
+ record_selector=RecordSelector(
2287
+ extractor=download_extractor,
2288
+ name=name,
2289
+ record_filter=None,
2290
+ transformations=[],
2291
+ schema_normalization=TypeTransformer(TransformConfig.NoTransform),
2292
+ config=config,
2293
+ parameters={},
2294
+ ),
2295
+ primary_key=None,
2296
+ name=job_download_components_name,
2297
+ paginator=(
2298
+ self._create_component_from_model(
2299
+ model=model.download_paginator, decoder=decoder, config=config, url_base=""
2300
+ )
2301
+ if model.download_paginator
2302
+ else NoPagination(parameters={})
2303
+ ),
2304
+ config=config,
2305
+ parameters={},
2306
+ )
2307
+ abort_requester = (
2308
+ self._create_component_from_model(
2309
+ model=model.abort_requester,
2310
+ decoder=decoder,
2311
+ config=config,
2312
+ name=f"job abort - {name}",
2313
+ )
2314
+ if model.abort_requester
2315
+ else None
2316
+ )
2317
+ delete_requester = (
2318
+ self._create_component_from_model(
2319
+ model=model.delete_requester,
2320
+ decoder=decoder,
2321
+ config=config,
2322
+ name=f"job delete - {name}",
2323
+ )
2324
+ if model.delete_requester
2325
+ else None
2326
+ )
2327
+ status_extractor = self._create_component_from_model(
2328
+ model=model.status_extractor, decoder=decoder, config=config, name=name
2329
+ )
2330
+ urls_extractor = self._create_component_from_model(
2331
+ model=model.urls_extractor, decoder=decoder, config=config, name=name
2332
+ )
2333
+ job_repository: AsyncJobRepository = AsyncHttpJobRepository(
2334
+ creation_requester=creation_requester,
2335
+ polling_requester=polling_requester,
2336
+ download_retriever=download_retriever,
2337
+ abort_requester=abort_requester,
2338
+ delete_requester=delete_requester,
2339
+ status_extractor=status_extractor,
2340
+ status_mapping=self._create_async_job_status_mapping(model.status_mapping, config),
2341
+ urls_extractor=urls_extractor,
2342
+ )
2343
+
2344
+ async_job_partition_router = AsyncJobPartitionRouter(
2345
+ job_orchestrator_factory=lambda stream_slices: AsyncJobOrchestrator(
2346
+ job_repository,
2347
+ stream_slices,
2348
+ JobTracker(1),
2349
+ # FIXME eventually make the number of concurrent jobs in the API configurable. Until then, we limit to 1
2350
+ self._message_repository,
2351
+ has_bulk_parent=False,
2352
+ # FIXME work would need to be done here in order to detect if a stream as a parent stream that is bulk
2353
+ ),
2354
+ stream_slicer=stream_slicer,
2355
+ config=config,
2356
+ parameters=model.parameters or {},
2357
+ )
2358
+
2359
+ return AsyncRetriever(
2360
+ record_selector=record_selector,
2361
+ stream_slicer=async_job_partition_router,
2362
+ config=config,
2363
+ parameters=model.parameters or {},
2364
+ )
2365
+
1010
2366
  @staticmethod
1011
2367
  def create_spec(model: SpecModel, config: Config, **kwargs: Any) -> Spec:
1012
2368
  return Spec(
@@ -1023,19 +2379,28 @@ class ModelToComponentFactory:
1023
2379
  if model.parent_stream_configs:
1024
2380
  parent_stream_configs.extend(
1025
2381
  [
1026
- self._create_message_repository_substream_wrapper(model=parent_stream_config, config=config)
2382
+ self._create_message_repository_substream_wrapper(
2383
+ model=parent_stream_config, config=config
2384
+ )
1027
2385
  for parent_stream_config in model.parent_stream_configs
1028
2386
  ]
1029
2387
  )
1030
2388
 
1031
- return SubstreamPartitionRouter(parent_stream_configs=parent_stream_configs, parameters=model.parameters or {}, config=config)
2389
+ return SubstreamPartitionRouter(
2390
+ parent_stream_configs=parent_stream_configs,
2391
+ parameters=model.parameters or {},
2392
+ config=config,
2393
+ )
1032
2394
 
1033
- def _create_message_repository_substream_wrapper(self, model: ParentStreamConfigModel, config: Config) -> Any:
2395
+ def _create_message_repository_substream_wrapper(
2396
+ self, model: ParentStreamConfigModel, config: Config
2397
+ ) -> Any:
1034
2398
  substream_factory = ModelToComponentFactory(
1035
2399
  limit_pages_fetched_per_slice=self._limit_pages_fetched_per_slice,
1036
2400
  limit_slices_fetched=self._limit_slices_fetched,
1037
2401
  emit_connector_builder_messages=self._emit_connector_builder_messages,
1038
2402
  disable_retries=self._disable_retries,
2403
+ disable_cache=self._disable_cache,
1039
2404
  message_repository=LogAppenderMessageRepositoryDecorator(
1040
2405
  {"airbyte_cdk": {"stream": {"is_substream": True}}, "http": {"is_auxiliary": True}},
1041
2406
  self._message_repository,
@@ -1045,15 +2410,29 @@ class ModelToComponentFactory:
1045
2410
  return substream_factory._create_component_from_model(model=model, config=config)
1046
2411
 
1047
2412
  @staticmethod
1048
- def create_wait_time_from_header(model: WaitTimeFromHeaderModel, config: Config, **kwargs: Any) -> WaitTimeFromHeaderBackoffStrategy:
1049
- return WaitTimeFromHeaderBackoffStrategy(header=model.header, parameters=model.parameters or {}, config=config, regex=model.regex)
2413
+ def create_wait_time_from_header(
2414
+ model: WaitTimeFromHeaderModel, config: Config, **kwargs: Any
2415
+ ) -> WaitTimeFromHeaderBackoffStrategy:
2416
+ return WaitTimeFromHeaderBackoffStrategy(
2417
+ header=model.header,
2418
+ parameters=model.parameters or {},
2419
+ config=config,
2420
+ regex=model.regex,
2421
+ max_waiting_time_in_seconds=model.max_waiting_time_in_seconds
2422
+ if model.max_waiting_time_in_seconds is not None
2423
+ else None,
2424
+ )
1050
2425
 
1051
2426
  @staticmethod
1052
2427
  def create_wait_until_time_from_header(
1053
2428
  model: WaitUntilTimeFromHeaderModel, config: Config, **kwargs: Any
1054
2429
  ) -> WaitUntilTimeFromHeaderBackoffStrategy:
1055
2430
  return WaitUntilTimeFromHeaderBackoffStrategy(
1056
- header=model.header, parameters=model.parameters or {}, config=config, min_wait=model.min_wait, regex=model.regex
2431
+ header=model.header,
2432
+ parameters=model.parameters or {},
2433
+ config=config,
2434
+ min_wait=model.min_wait,
2435
+ regex=model.regex,
1057
2436
  )
1058
2437
 
1059
2438
  def get_message_repository(self) -> MessageRepository:
@@ -1061,3 +2440,94 @@ class ModelToComponentFactory:
1061
2440
 
1062
2441
  def _evaluate_log_level(self, emit_connector_builder_messages: bool) -> Level:
1063
2442
  return Level.DEBUG if emit_connector_builder_messages else Level.INFO
2443
+
2444
+ @staticmethod
2445
+ def create_components_mapping_definition(
2446
+ model: ComponentMappingDefinitionModel, config: Config, **kwargs: Any
2447
+ ) -> ComponentMappingDefinition:
2448
+ interpolated_value = InterpolatedString.create(
2449
+ model.value, parameters=model.parameters or {}
2450
+ )
2451
+ field_path = [
2452
+ InterpolatedString.create(path, parameters=model.parameters or {})
2453
+ for path in model.field_path
2454
+ ]
2455
+ return ComponentMappingDefinition(
2456
+ field_path=field_path, # type: ignore[arg-type] # field_path can be str and InterpolatedString
2457
+ value=interpolated_value,
2458
+ value_type=ModelToComponentFactory._json_schema_type_name_to_type(model.value_type),
2459
+ parameters=model.parameters or {},
2460
+ )
2461
+
2462
+ def create_http_components_resolver(
2463
+ self, model: HttpComponentsResolverModel, config: Config
2464
+ ) -> Any:
2465
+ stream_slicer = self._build_stream_slicer_from_partition_router(model.retriever, config)
2466
+ combined_slicers = self._build_resumable_cursor_from_paginator(
2467
+ model.retriever, stream_slicer
2468
+ )
2469
+
2470
+ retriever = self._create_component_from_model(
2471
+ model=model.retriever,
2472
+ config=config,
2473
+ name="",
2474
+ primary_key=None,
2475
+ stream_slicer=stream_slicer if stream_slicer else combined_slicers,
2476
+ transformations=[],
2477
+ )
2478
+
2479
+ components_mapping = [
2480
+ self._create_component_from_model(
2481
+ model=components_mapping_definition_model,
2482
+ value_type=ModelToComponentFactory._json_schema_type_name_to_type(
2483
+ components_mapping_definition_model.value_type
2484
+ ),
2485
+ config=config,
2486
+ )
2487
+ for components_mapping_definition_model in model.components_mapping
2488
+ ]
2489
+
2490
+ return HttpComponentsResolver(
2491
+ retriever=retriever,
2492
+ config=config,
2493
+ components_mapping=components_mapping,
2494
+ parameters=model.parameters or {},
2495
+ )
2496
+
2497
+ @staticmethod
2498
+ def create_stream_config(
2499
+ model: StreamConfigModel, config: Config, **kwargs: Any
2500
+ ) -> StreamConfig:
2501
+ model_configs_pointer: List[Union[InterpolatedString, str]] = (
2502
+ [x for x in model.configs_pointer] if model.configs_pointer else []
2503
+ )
2504
+
2505
+ return StreamConfig(
2506
+ configs_pointer=model_configs_pointer,
2507
+ parameters=model.parameters or {},
2508
+ )
2509
+
2510
+ def create_config_components_resolver(
2511
+ self, model: ConfigComponentsResolverModel, config: Config
2512
+ ) -> Any:
2513
+ stream_config = self._create_component_from_model(
2514
+ model.stream_config, config=config, parameters=model.parameters or {}
2515
+ )
2516
+
2517
+ components_mapping = [
2518
+ self._create_component_from_model(
2519
+ model=components_mapping_definition_model,
2520
+ value_type=ModelToComponentFactory._json_schema_type_name_to_type(
2521
+ components_mapping_definition_model.value_type
2522
+ ),
2523
+ config=config,
2524
+ )
2525
+ for components_mapping_definition_model in model.components_mapping
2526
+ ]
2527
+
2528
+ return ConfigComponentsResolver(
2529
+ stream_config=stream_config,
2530
+ config=config,
2531
+ components_mapping=components_mapping,
2532
+ parameters=model.parameters or {},
2533
+ )