airbyte-cdk 6.7.0rc3__py3-none-any.whl → 6.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airbyte_cdk/cli/source_declarative_manifest/_run.py +2 -1
- airbyte_cdk/config_observation.py +2 -1
- airbyte_cdk/connector.py +1 -0
- airbyte_cdk/connector_builder/connector_builder_handler.py +1 -1
- airbyte_cdk/connector_builder/main.py +2 -1
- airbyte_cdk/destinations/destination.py +2 -1
- airbyte_cdk/destinations/vector_db_based/config.py +2 -1
- airbyte_cdk/destinations/vector_db_based/document_processor.py +4 -3
- airbyte_cdk/destinations/vector_db_based/embedder.py +5 -4
- airbyte_cdk/entrypoint.py +3 -2
- airbyte_cdk/logger.py +2 -1
- airbyte_cdk/models/__init__.py +2 -0
- airbyte_cdk/models/airbyte_protocol.py +2 -1
- airbyte_cdk/sources/concurrent_source/concurrent_read_processor.py +3 -3
- airbyte_cdk/sources/concurrent_source/concurrent_source.py +1 -1
- airbyte_cdk/sources/config.py +2 -1
- airbyte_cdk/sources/declarative/auth/jwt.py +1 -0
- airbyte_cdk/sources/declarative/auth/oauth.py +1 -0
- airbyte_cdk/sources/declarative/auth/selective_authenticator.py +1 -0
- airbyte_cdk/sources/declarative/auth/token.py +2 -1
- airbyte_cdk/sources/declarative/auth/token_provider.py +3 -2
- airbyte_cdk/sources/declarative/concurrent_declarative_source.py +24 -54
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml +167 -0
- airbyte_cdk/sources/declarative/decoders/json_decoder.py +3 -2
- airbyte_cdk/sources/declarative/decoders/noop_decoder.py +1 -0
- airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py +1 -0
- airbyte_cdk/sources/declarative/decoders/xml_decoder.py +1 -0
- airbyte_cdk/sources/declarative/extractors/dpath_extractor.py +1 -0
- airbyte_cdk/sources/declarative/extractors/http_selector.py +1 -0
- airbyte_cdk/sources/declarative/extractors/record_filter.py +6 -48
- airbyte_cdk/sources/declarative/extractors/record_selector.py +32 -4
- airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py +2 -1
- airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py +2 -1
- airbyte_cdk/sources/declarative/incremental/global_substream_cursor.py +5 -2
- airbyte_cdk/sources/declarative/incremental/per_partition_cursor.py +5 -2
- airbyte_cdk/sources/declarative/incremental/per_partition_with_global.py +1 -3
- airbyte_cdk/sources/declarative/interpolation/jinja.py +5 -4
- airbyte_cdk/sources/declarative/manifest_declarative_source.py +4 -3
- airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py +1 -1
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py +122 -0
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +26 -17
- airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py +1 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/constant_backoff_strategy.py +1 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/exponential_backoff_strategy.py +1 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_time_from_header_backoff_strategy.py +1 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_until_time_from_header_backoff_strategy.py +1 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py +1 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py +1 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/default_http_response_filter.py +1 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py +1 -0
- airbyte_cdk/sources/declarative/requesters/http_job_repository.py +2 -1
- airbyte_cdk/sources/declarative/requesters/http_requester.py +1 -0
- airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py +1 -0
- airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py +1 -0
- airbyte_cdk/sources/declarative/requesters/paginators/paginator.py +1 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py +1 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py +1 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py +1 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py +1 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py +9 -3
- airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_options_provider.py +2 -1
- airbyte_cdk/sources/declarative/requesters/requester.py +1 -0
- airbyte_cdk/sources/declarative/retrievers/async_retriever.py +2 -1
- airbyte_cdk/sources/declarative/retrievers/simple_retriever.py +12 -4
- airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py +7 -4
- airbyte_cdk/sources/declarative/transformations/add_fields.py +1 -0
- airbyte_cdk/sources/declarative/transformations/remove_fields.py +1 -0
- airbyte_cdk/sources/declarative/yaml_declarative_source.py +1 -0
- airbyte_cdk/sources/embedded/tools.py +1 -0
- airbyte_cdk/sources/file_based/config/abstract_file_based_spec.py +2 -1
- airbyte_cdk/sources/file_based/config/avro_format.py +2 -1
- airbyte_cdk/sources/file_based/config/csv_format.py +2 -1
- airbyte_cdk/sources/file_based/config/excel_format.py +2 -1
- airbyte_cdk/sources/file_based/config/file_based_stream_config.py +2 -1
- airbyte_cdk/sources/file_based/config/jsonl_format.py +2 -1
- airbyte_cdk/sources/file_based/config/parquet_format.py +2 -1
- airbyte_cdk/sources/file_based/config/unstructured_format.py +2 -1
- airbyte_cdk/sources/file_based/file_based_source.py +2 -1
- airbyte_cdk/sources/file_based/file_based_stream_reader.py +2 -1
- airbyte_cdk/sources/file_based/file_types/avro_parser.py +1 -0
- airbyte_cdk/sources/file_based/file_types/csv_parser.py +2 -1
- airbyte_cdk/sources/file_based/file_types/excel_parser.py +5 -5
- airbyte_cdk/sources/file_based/file_types/jsonl_parser.py +2 -1
- airbyte_cdk/sources/file_based/file_types/parquet_parser.py +2 -1
- airbyte_cdk/sources/file_based/file_types/unstructured_parser.py +9 -8
- airbyte_cdk/sources/file_based/stream/abstract_file_based_stream.py +2 -1
- airbyte_cdk/sources/file_based/stream/concurrent/adapters.py +5 -4
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/abstract_concurrent_file_based_cursor.py +1 -1
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/file_based_concurrent_cursor.py +1 -1
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/file_based_final_state_cursor.py +1 -1
- airbyte_cdk/sources/http_logger.py +1 -0
- airbyte_cdk/sources/streams/call_rate.py +1 -2
- airbyte_cdk/sources/streams/concurrent/abstract_stream.py +2 -1
- airbyte_cdk/sources/streams/concurrent/adapters.py +8 -4
- airbyte_cdk/sources/streams/concurrent/availability_strategy.py +2 -1
- airbyte_cdk/sources/streams/concurrent/cursor.py +30 -6
- airbyte_cdk/sources/streams/concurrent/partitions/partition.py +1 -1
- airbyte_cdk/sources/streams/concurrent/partitions/types.py +1 -1
- airbyte_cdk/sources/streams/concurrent/state_converters/datetime_stream_state_converter.py +1 -1
- airbyte_cdk/sources/streams/core.py +2 -1
- airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py +2 -1
- airbyte_cdk/sources/streams/http/error_handlers/http_status_error_handler.py +1 -0
- airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py +1 -0
- airbyte_cdk/sources/streams/http/error_handlers/response_models.py +2 -1
- airbyte_cdk/sources/streams/http/http.py +3 -2
- airbyte_cdk/sources/streams/http/http_client.py +49 -2
- airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py +2 -1
- airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py +1 -0
- airbyte_cdk/sources/types.py +14 -1
- airbyte_cdk/sources/utils/schema_helpers.py +3 -2
- airbyte_cdk/sql/secrets.py +2 -1
- airbyte_cdk/sql/shared/sql_processor.py +8 -6
- airbyte_cdk/test/entrypoint_wrapper.py +4 -3
- airbyte_cdk/test/mock_http/mocker.py +1 -0
- airbyte_cdk/utils/schema_inferrer.py +2 -1
- airbyte_cdk/utils/slice_hasher.py +1 -1
- airbyte_cdk/utils/traced_exception.py +2 -1
- {airbyte_cdk-6.7.0rc3.dist-info → airbyte_cdk-6.7.1.dist-info}/METADATA +9 -2
- {airbyte_cdk-6.7.0rc3.dist-info → airbyte_cdk-6.7.1.dist-info}/RECORD +122 -123
- airbyte_cdk/sources/streams/concurrent/partitions/record.py +0 -35
- {airbyte_cdk-6.7.0rc3.dist-info → airbyte_cdk-6.7.1.dist-info}/LICENSE.txt +0 -0
- {airbyte_cdk-6.7.0rc3.dist-info → airbyte_cdk-6.7.1.dist-info}/WHEEL +0 -0
- {airbyte_cdk-6.7.0rc3.dist-info → airbyte_cdk-6.7.1.dist-info}/entry_points.txt +0 -0
@@ -25,6 +25,8 @@ from datetime import datetime
|
|
25
25
|
from pathlib import Path
|
26
26
|
from typing import Any, cast
|
27
27
|
|
28
|
+
from orjson import orjson
|
29
|
+
|
28
30
|
from airbyte_cdk.entrypoint import AirbyteEntrypoint, launch
|
29
31
|
from airbyte_cdk.models import (
|
30
32
|
AirbyteErrorTraceMessage,
|
@@ -42,7 +44,6 @@ from airbyte_cdk.sources.declarative.concurrent_declarative_source import (
|
|
42
44
|
)
|
43
45
|
from airbyte_cdk.sources.declarative.yaml_declarative_source import YamlDeclarativeSource
|
44
46
|
from airbyte_cdk.sources.source import TState
|
45
|
-
from orjson import orjson
|
46
47
|
|
47
48
|
|
48
49
|
class SourceLocalYaml(YamlDeclarativeSource):
|
@@ -10,6 +10,8 @@ import time
|
|
10
10
|
from copy import copy
|
11
11
|
from typing import Any, List, MutableMapping
|
12
12
|
|
13
|
+
from orjson import orjson
|
14
|
+
|
13
15
|
from airbyte_cdk.models import (
|
14
16
|
AirbyteControlConnectorConfigMessage,
|
15
17
|
AirbyteControlMessage,
|
@@ -18,7 +20,6 @@ from airbyte_cdk.models import (
|
|
18
20
|
OrchestratorType,
|
19
21
|
Type,
|
20
22
|
)
|
21
|
-
from orjson import orjson
|
22
23
|
|
23
24
|
|
24
25
|
class ObservedDict(dict): # type: ignore # disallow_any_generics is set to True, and dict is equivalent to dict[Any]
|
airbyte_cdk/connector.py
CHANGED
@@ -12,8 +12,8 @@ from airbyte_cdk.models import (
|
|
12
12
|
AirbyteRecordMessage,
|
13
13
|
AirbyteStateMessage,
|
14
14
|
ConfiguredAirbyteCatalog,
|
15
|
+
Type,
|
15
16
|
)
|
16
|
-
from airbyte_cdk.models import Type
|
17
17
|
from airbyte_cdk.models import Type as MessageType
|
18
18
|
from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource
|
19
19
|
from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource
|
@@ -6,6 +6,8 @@
|
|
6
6
|
import sys
|
7
7
|
from typing import Any, List, Mapping, Optional, Tuple
|
8
8
|
|
9
|
+
from orjson import orjson
|
10
|
+
|
9
11
|
from airbyte_cdk.connector import BaseConnector
|
10
12
|
from airbyte_cdk.connector_builder.connector_builder_handler import (
|
11
13
|
TestReadLimits,
|
@@ -25,7 +27,6 @@ from airbyte_cdk.models import (
|
|
25
27
|
from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource
|
26
28
|
from airbyte_cdk.sources.source import Source
|
27
29
|
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
|
28
|
-
from orjson import orjson
|
29
30
|
|
30
31
|
|
31
32
|
def get_config_and_catalog_from_args(
|
@@ -9,6 +9,8 @@ import sys
|
|
9
9
|
from abc import ABC, abstractmethod
|
10
10
|
from typing import Any, Iterable, List, Mapping
|
11
11
|
|
12
|
+
from orjson import orjson
|
13
|
+
|
12
14
|
from airbyte_cdk.connector import Connector
|
13
15
|
from airbyte_cdk.exception_handler import init_uncaught_exception_handler
|
14
16
|
from airbyte_cdk.models import (
|
@@ -20,7 +22,6 @@ from airbyte_cdk.models import (
|
|
20
22
|
)
|
21
23
|
from airbyte_cdk.sources.utils.schema_helpers import check_config_against_spec_or_exit
|
22
24
|
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
|
23
|
-
from orjson import orjson
|
24
25
|
|
25
26
|
logger = logging.getLogger("airbyte")
|
26
27
|
|
@@ -5,9 +5,10 @@
|
|
5
5
|
from typing import Any, Dict, List, Literal, Optional, Union
|
6
6
|
|
7
7
|
import dpath
|
8
|
+
from pydantic.v1 import BaseModel, Field
|
9
|
+
|
8
10
|
from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig
|
9
11
|
from airbyte_cdk.utils.spec_schema_transformations import resolve_refs
|
10
|
-
from pydantic.v1 import BaseModel, Field
|
11
12
|
|
12
13
|
|
13
14
|
class SeparatorSplitterConfigModel(BaseModel):
|
@@ -8,6 +8,10 @@ from dataclasses import dataclass
|
|
8
8
|
from typing import Any, Dict, List, Mapping, Optional, Tuple
|
9
9
|
|
10
10
|
import dpath
|
11
|
+
from langchain.text_splitter import Language, RecursiveCharacterTextSplitter
|
12
|
+
from langchain.utils import stringify_dict
|
13
|
+
from langchain_core.documents.base import Document
|
14
|
+
|
11
15
|
from airbyte_cdk.destinations.vector_db_based.config import (
|
12
16
|
ProcessingConfigModel,
|
13
17
|
SeparatorSplitterConfigModel,
|
@@ -21,9 +25,6 @@ from airbyte_cdk.models import (
|
|
21
25
|
DestinationSyncMode,
|
22
26
|
)
|
23
27
|
from airbyte_cdk.utils.traced_exception import AirbyteTracedException, FailureType
|
24
|
-
from langchain.text_splitter import Language, RecursiveCharacterTextSplitter
|
25
|
-
from langchain.utils import stringify_dict
|
26
|
-
from langchain_core.documents.base import Document
|
27
28
|
|
28
29
|
METADATA_STREAM_FIELD = "_ab_stream"
|
29
30
|
METADATA_RECORD_ID_FIELD = "_ab_record_id"
|
@@ -7,6 +7,11 @@ from abc import ABC, abstractmethod
|
|
7
7
|
from dataclasses import dataclass
|
8
8
|
from typing import List, Optional, Union, cast
|
9
9
|
|
10
|
+
from langchain.embeddings.cohere import CohereEmbeddings
|
11
|
+
from langchain.embeddings.fake import FakeEmbeddings
|
12
|
+
from langchain.embeddings.localai import LocalAIEmbeddings
|
13
|
+
from langchain.embeddings.openai import OpenAIEmbeddings
|
14
|
+
|
10
15
|
from airbyte_cdk.destinations.vector_db_based.config import (
|
11
16
|
AzureOpenAIEmbeddingConfigModel,
|
12
17
|
CohereEmbeddingConfigModel,
|
@@ -19,10 +24,6 @@ from airbyte_cdk.destinations.vector_db_based.config import (
|
|
19
24
|
from airbyte_cdk.destinations.vector_db_based.utils import create_chunks, format_exception
|
20
25
|
from airbyte_cdk.models import AirbyteRecordMessage
|
21
26
|
from airbyte_cdk.utils.traced_exception import AirbyteTracedException, FailureType
|
22
|
-
from langchain.embeddings.cohere import CohereEmbeddings
|
23
|
-
from langchain.embeddings.fake import FakeEmbeddings
|
24
|
-
from langchain.embeddings.localai import LocalAIEmbeddings
|
25
|
-
from langchain.embeddings.openai import OpenAIEmbeddings
|
26
27
|
|
27
28
|
|
28
29
|
@dataclass
|
airbyte_cdk/entrypoint.py
CHANGED
@@ -16,6 +16,9 @@ from typing import Any, DefaultDict, Iterable, List, Mapping, Optional
|
|
16
16
|
from urllib.parse import urlparse
|
17
17
|
|
18
18
|
import requests
|
19
|
+
from orjson import orjson
|
20
|
+
from requests import PreparedRequest, Response, Session
|
21
|
+
|
19
22
|
from airbyte_cdk.connector import TConfig
|
20
23
|
from airbyte_cdk.exception_handler import init_uncaught_exception_handler
|
21
24
|
from airbyte_cdk.logger import init_logger
|
@@ -38,8 +41,6 @@ from airbyte_cdk.utils import is_cloud_environment, message_utils
|
|
38
41
|
from airbyte_cdk.utils.airbyte_secrets_utils import get_secrets, update_secrets
|
39
42
|
from airbyte_cdk.utils.constants import ENV_REQUEST_CACHE_PATH
|
40
43
|
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
|
41
|
-
from orjson import orjson
|
42
|
-
from requests import PreparedRequest, Response, Session
|
43
44
|
|
44
45
|
logger = init_logger("airbyte")
|
45
46
|
|
airbyte_cdk/logger.py
CHANGED
@@ -7,6 +7,8 @@ import logging
|
|
7
7
|
import logging.config
|
8
8
|
from typing import Any, Callable, Mapping, Optional, Tuple
|
9
9
|
|
10
|
+
from orjson import orjson
|
11
|
+
|
10
12
|
from airbyte_cdk.models import (
|
11
13
|
AirbyteLogMessage,
|
12
14
|
AirbyteMessage,
|
@@ -15,7 +17,6 @@ from airbyte_cdk.models import (
|
|
15
17
|
Type,
|
16
18
|
)
|
17
19
|
from airbyte_cdk.utils.airbyte_secrets_utils import filter_secrets
|
18
|
-
from orjson import orjson
|
19
20
|
|
20
21
|
LOGGING_CONFIG = {
|
21
22
|
"version": 1,
|
airbyte_cdk/models/__init__.py
CHANGED
@@ -5,10 +5,11 @@
|
|
5
5
|
from dataclasses import InitVar, dataclass
|
6
6
|
from typing import Annotated, Any, Dict, List, Mapping, Optional, Union
|
7
7
|
|
8
|
-
from airbyte_cdk.models.file_transfer_record_message import AirbyteFileTransferRecordMessage
|
9
8
|
from airbyte_protocol_dataclasses.models import * # noqa: F403 # Allow '*'
|
10
9
|
from serpyco_rs.metadata import Alias
|
11
10
|
|
11
|
+
from airbyte_cdk.models.file_transfer_record_message import AirbyteFileTransferRecordMessage
|
12
|
+
|
12
13
|
# ruff: noqa: F405 # ignore fuzzy import issues with 'import *'
|
13
14
|
|
14
15
|
|
@@ -17,8 +17,8 @@ from airbyte_cdk.sources.streams.concurrent.abstract_stream import AbstractStrea
|
|
17
17
|
from airbyte_cdk.sources.streams.concurrent.partition_enqueuer import PartitionEnqueuer
|
18
18
|
from airbyte_cdk.sources.streams.concurrent.partition_reader import PartitionReader
|
19
19
|
from airbyte_cdk.sources.streams.concurrent.partitions.partition import Partition
|
20
|
-
from airbyte_cdk.sources.streams.concurrent.partitions.record import Record
|
21
20
|
from airbyte_cdk.sources.streams.concurrent.partitions.types import PartitionCompleteSentinel
|
21
|
+
from airbyte_cdk.sources.types import Record
|
22
22
|
from airbyte_cdk.sources.utils.record_helper import stream_data_to_airbyte_message
|
23
23
|
from airbyte_cdk.sources.utils.slice_logger import SliceLogger
|
24
24
|
from airbyte_cdk.utils import AirbyteTracedException
|
@@ -147,11 +147,11 @@ class ConcurrentReadProcessor:
|
|
147
147
|
# AbstractStreams are expected to return data as they are expected.
|
148
148
|
# Any transformation on the data should be done before reaching this point
|
149
149
|
message = stream_data_to_airbyte_message(
|
150
|
-
stream_name=record.
|
150
|
+
stream_name=record.stream_name,
|
151
151
|
data_or_message=record.data,
|
152
152
|
is_file_transfer_message=record.is_file_transfer_message,
|
153
153
|
)
|
154
|
-
stream = self._stream_name_to_instance[record.
|
154
|
+
stream = self._stream_name_to_instance[record.stream_name]
|
155
155
|
|
156
156
|
if message.type == MessageType.RECORD:
|
157
157
|
if self._record_counter[stream.name] == 0:
|
@@ -18,11 +18,11 @@ from airbyte_cdk.sources.streams.concurrent.abstract_stream import AbstractStrea
|
|
18
18
|
from airbyte_cdk.sources.streams.concurrent.partition_enqueuer import PartitionEnqueuer
|
19
19
|
from airbyte_cdk.sources.streams.concurrent.partition_reader import PartitionReader
|
20
20
|
from airbyte_cdk.sources.streams.concurrent.partitions.partition import Partition
|
21
|
-
from airbyte_cdk.sources.streams.concurrent.partitions.record import Record
|
22
21
|
from airbyte_cdk.sources.streams.concurrent.partitions.types import (
|
23
22
|
PartitionCompleteSentinel,
|
24
23
|
QueueItem,
|
25
24
|
)
|
25
|
+
from airbyte_cdk.sources.types import Record
|
26
26
|
from airbyte_cdk.sources.utils.slice_logger import DebugSliceLogger, SliceLogger
|
27
27
|
|
28
28
|
|
airbyte_cdk/sources/config.py
CHANGED
@@ -4,9 +4,10 @@
|
|
4
4
|
|
5
5
|
from typing import Any, Dict
|
6
6
|
|
7
|
-
from airbyte_cdk.sources.utils.schema_helpers import expand_refs, rename_key
|
8
7
|
from pydantic.v1 import BaseModel
|
9
8
|
|
9
|
+
from airbyte_cdk.sources.utils.schema_helpers import expand_refs, rename_key
|
10
|
+
|
10
11
|
|
11
12
|
class BaseConfig(BaseModel):
|
12
13
|
"""Base class for connector spec, adds the following behaviour:
|
@@ -8,6 +8,7 @@ from datetime import datetime
|
|
8
8
|
from typing import Any, Mapping, Optional, Union
|
9
9
|
|
10
10
|
import jwt
|
11
|
+
|
11
12
|
from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
|
12
13
|
from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean
|
13
14
|
from airbyte_cdk.sources.declarative.interpolation.interpolated_mapping import InterpolatedMapping
|
@@ -6,6 +6,7 @@ from dataclasses import InitVar, dataclass, field
|
|
6
6
|
from typing import Any, List, Mapping, Optional, Union
|
7
7
|
|
8
8
|
import pendulum
|
9
|
+
|
9
10
|
from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
|
10
11
|
from airbyte_cdk.sources.declarative.interpolation.interpolated_mapping import InterpolatedMapping
|
11
12
|
from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString
|
@@ -8,6 +8,8 @@ from dataclasses import InitVar, dataclass
|
|
8
8
|
from typing import Any, Mapping, Union
|
9
9
|
|
10
10
|
import requests
|
11
|
+
from cachetools import TTLCache, cached
|
12
|
+
|
11
13
|
from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
|
12
14
|
from airbyte_cdk.sources.declarative.auth.token_provider import TokenProvider
|
13
15
|
from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString
|
@@ -16,7 +18,6 @@ from airbyte_cdk.sources.declarative.requesters.request_option import (
|
|
16
18
|
RequestOptionType,
|
17
19
|
)
|
18
20
|
from airbyte_cdk.sources.types import Config
|
19
|
-
from cachetools import TTLCache, cached
|
20
21
|
|
21
22
|
|
22
23
|
@dataclass
|
@@ -10,6 +10,9 @@ from typing import Any, List, Mapping, Optional, Union
|
|
10
10
|
|
11
11
|
import dpath
|
12
12
|
import pendulum
|
13
|
+
from isodate import Duration
|
14
|
+
from pendulum import DateTime
|
15
|
+
|
13
16
|
from airbyte_cdk.sources.declarative.decoders.decoder import Decoder
|
14
17
|
from airbyte_cdk.sources.declarative.decoders.json_decoder import JsonDecoder
|
15
18
|
from airbyte_cdk.sources.declarative.exceptions import ReadException
|
@@ -18,8 +21,6 @@ from airbyte_cdk.sources.declarative.requesters.requester import Requester
|
|
18
21
|
from airbyte_cdk.sources.http_logger import format_http_message
|
19
22
|
from airbyte_cdk.sources.message import MessageRepository, NoopMessageRepository
|
20
23
|
from airbyte_cdk.sources.types import Config
|
21
|
-
from isodate import Duration
|
22
|
-
from pendulum import DateTime
|
23
24
|
|
24
25
|
|
25
26
|
class TokenProvider:
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
|
5
5
|
import logging
|
6
|
-
from typing import Any, Generic, Iterator, List, Mapping, Optional, Tuple, Union
|
6
|
+
from typing import Any, Callable, Generic, Iterator, List, Mapping, Optional, Tuple, Union
|
7
7
|
|
8
8
|
from airbyte_cdk.models import (
|
9
9
|
AirbyteCatalog,
|
@@ -27,14 +27,16 @@ from airbyte_cdk.sources.declarative.models.declarative_component_schema import
|
|
27
27
|
)
|
28
28
|
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
|
29
29
|
DatetimeBasedCursor as DatetimeBasedCursorModel,
|
30
|
+
)
|
31
|
+
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
|
30
32
|
DeclarativeStream as DeclarativeStreamModel,
|
31
33
|
)
|
32
34
|
from airbyte_cdk.sources.declarative.parsers.model_to_component_factory import (
|
33
|
-
ModelToComponentFactory,
|
34
35
|
ComponentDefinition,
|
36
|
+
ModelToComponentFactory,
|
35
37
|
)
|
36
38
|
from airbyte_cdk.sources.declarative.requesters import HttpRequester
|
37
|
-
from airbyte_cdk.sources.declarative.retrievers import
|
39
|
+
from airbyte_cdk.sources.declarative.retrievers import Retriever, SimpleRetriever
|
38
40
|
from airbyte_cdk.sources.declarative.stream_slicers.declarative_partition_generator import (
|
39
41
|
DeclarativePartitionFactory,
|
40
42
|
StreamSlicerPartitionGenerator,
|
@@ -42,15 +44,14 @@ from airbyte_cdk.sources.declarative.stream_slicers.declarative_partition_genera
|
|
42
44
|
from airbyte_cdk.sources.declarative.transformations.add_fields import AddFields
|
43
45
|
from airbyte_cdk.sources.declarative.types import ConnectionDefinition
|
44
46
|
from airbyte_cdk.sources.source import TState
|
45
|
-
from airbyte_cdk.sources.types import Config, StreamState
|
46
47
|
from airbyte_cdk.sources.streams import Stream
|
47
48
|
from airbyte_cdk.sources.streams.concurrent.abstract_stream import AbstractStream
|
48
49
|
from airbyte_cdk.sources.streams.concurrent.availability_strategy import (
|
49
50
|
AlwaysAvailableAvailabilityStrategy,
|
50
51
|
)
|
51
|
-
from airbyte_cdk.sources.streams.concurrent.cursor import Cursor, FinalStateCursor
|
52
52
|
from airbyte_cdk.sources.streams.concurrent.default_stream import DefaultStream
|
53
53
|
from airbyte_cdk.sources.streams.concurrent.helpers import get_primary_key_from_stream
|
54
|
+
from airbyte_cdk.sources.types import Config, StreamState
|
54
55
|
|
55
56
|
|
56
57
|
class ConcurrentDeclarativeSource(ManifestDeclarativeSource, Generic[TState]):
|
@@ -194,44 +195,31 @@ class ConcurrentDeclarativeSource(ManifestDeclarativeSource, Generic[TState]):
|
|
194
195
|
declarative_stream.name
|
195
196
|
].get("incremental_sync")
|
196
197
|
|
197
|
-
|
198
|
+
if (
|
198
199
|
datetime_based_cursor_component_definition
|
199
|
-
|
200
|
-
|
201
|
-
.
|
202
|
-
|
203
|
-
)
|
204
|
-
is_datetime_incremental_without_partition_routing = (
|
205
|
-
self._is_datetime_incremental_without_partition_routing(
|
206
|
-
datetime_based_cursor_component_definition, declarative_stream
|
200
|
+
and datetime_based_cursor_component_definition.get("type", "")
|
201
|
+
== DatetimeBasedCursorModel.__name__
|
202
|
+
and self._stream_supports_concurrent_partition_processing(
|
203
|
+
declarative_stream=declarative_stream
|
207
204
|
)
|
208
|
-
|
209
|
-
|
210
|
-
is_without_partition_router_nor_cursor
|
211
|
-
or is_datetime_incremental_without_partition_routing
|
205
|
+
and hasattr(declarative_stream.retriever, "stream_slicer")
|
206
|
+
and isinstance(declarative_stream.retriever.stream_slicer, DatetimeBasedCursor)
|
212
207
|
):
|
213
208
|
stream_state = state_manager.get_stream_state(
|
214
209
|
stream_name=declarative_stream.name, namespace=declarative_stream.namespace
|
215
210
|
)
|
216
211
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
stream_state=stream_state,
|
227
|
-
)
|
228
|
-
)
|
229
|
-
else:
|
230
|
-
cursor = FinalStateCursor(
|
231
|
-
declarative_stream.name,
|
232
|
-
declarative_stream.namespace,
|
233
|
-
self.message_repository,
|
212
|
+
cursor, connector_state_converter = (
|
213
|
+
self._constructor.create_concurrent_cursor_from_datetime_based_cursor(
|
214
|
+
state_manager=state_manager,
|
215
|
+
model_type=DatetimeBasedCursorModel,
|
216
|
+
component_definition=datetime_based_cursor_component_definition,
|
217
|
+
stream_name=declarative_stream.name,
|
218
|
+
stream_namespace=declarative_stream.namespace,
|
219
|
+
config=config or {},
|
220
|
+
stream_state=stream_state,
|
234
221
|
)
|
222
|
+
)
|
235
223
|
|
236
224
|
partition_generator = StreamSlicerPartitionGenerator(
|
237
225
|
DeclarativePartitionFactory(
|
@@ -254,9 +242,7 @@ class ConcurrentDeclarativeSource(ManifestDeclarativeSource, Generic[TState]):
|
|
254
242
|
json_schema=declarative_stream.get_json_schema(),
|
255
243
|
availability_strategy=AlwaysAvailableAvailabilityStrategy(),
|
256
244
|
primary_key=get_primary_key_from_stream(declarative_stream.primary_key),
|
257
|
-
cursor_field=cursor.cursor_field.cursor_field_key
|
258
|
-
if hasattr(cursor, "cursor_field")
|
259
|
-
else None,
|
245
|
+
cursor_field=cursor.cursor_field.cursor_field_key,
|
260
246
|
logger=self.logger,
|
261
247
|
cursor=cursor,
|
262
248
|
)
|
@@ -268,22 +254,6 @@ class ConcurrentDeclarativeSource(ManifestDeclarativeSource, Generic[TState]):
|
|
268
254
|
|
269
255
|
return concurrent_streams, synchronous_streams
|
270
256
|
|
271
|
-
def _is_datetime_incremental_without_partition_routing(
|
272
|
-
self,
|
273
|
-
datetime_based_cursor_component_definition: Mapping[str, Any],
|
274
|
-
declarative_stream: DeclarativeStream,
|
275
|
-
) -> bool:
|
276
|
-
return (
|
277
|
-
bool(datetime_based_cursor_component_definition)
|
278
|
-
and datetime_based_cursor_component_definition.get("type", "")
|
279
|
-
== DatetimeBasedCursorModel.__name__
|
280
|
-
and self._stream_supports_concurrent_partition_processing(
|
281
|
-
declarative_stream=declarative_stream
|
282
|
-
)
|
283
|
-
and hasattr(declarative_stream.retriever, "stream_slicer")
|
284
|
-
and isinstance(declarative_stream.retriever.stream_slicer, DatetimeBasedCursor)
|
285
|
-
)
|
286
|
-
|
287
257
|
def _stream_supports_concurrent_partition_processing(
|
288
258
|
self, declarative_stream: DeclarativeStream
|
289
259
|
) -> bool:
|
@@ -1972,6 +1972,173 @@ definitions:
|
|
1972
1972
|
- app_id:
|
1973
1973
|
type: string
|
1974
1974
|
path_in_connector_config: ["info", "app_id"]
|
1975
|
+
oauth_connector_input_specification:
|
1976
|
+
title: DeclarativeOAuth Connector Specification
|
1977
|
+
description: |-
|
1978
|
+
The DeclarativeOAuth specific blob.
|
1979
|
+
Pertains to the fields defined by the connector relating to the OAuth flow.
|
1980
|
+
|
1981
|
+
Interpolation capabilities:
|
1982
|
+
- The variables placeholders are declared as `{my_var}`.
|
1983
|
+
- The nested resolution variables like `{{my_nested_var}}` is allowed as well.
|
1984
|
+
|
1985
|
+
- The allowed interpolation context is:
|
1986
|
+
+ base64Encoder - encode to `base64`, {base64Encoder:{my_var_a}:{my_var_b}}
|
1987
|
+
+ base64Decorer - decode from `base64` encoded string, {base64Decoder:{my_string_variable_or_string_value}}
|
1988
|
+
+ urlEncoder - encode the input string to URL-like format, {urlEncoder:https://test.host.com/endpoint}
|
1989
|
+
+ urlDecorer - decode the input url-encoded string into text format, {urlDecoder:https%3A%2F%2Fairbyte.io}
|
1990
|
+
+ codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {codeChallengeS256:{state_value}}
|
1991
|
+
|
1992
|
+
Examples:
|
1993
|
+
- The TikTok Marketing DeclarativeOAuth spec:
|
1994
|
+
{
|
1995
|
+
"oauth_connector_input_specification": {
|
1996
|
+
"type": "object",
|
1997
|
+
"additionalProperties": false,
|
1998
|
+
"properties": {
|
1999
|
+
"consent_url": "https://ads.tiktok.com/marketing_api/auth?{client_id_key}={{client_id_key}}&{redirect_uri_key}={urlEncoder:{{redirect_uri_key}}}&{state_key}={{state_key}}",
|
2000
|
+
"access_token_url": "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/",
|
2001
|
+
"access_token_params": {
|
2002
|
+
"{auth_code_key}": "{{auth_code_key}}",
|
2003
|
+
"{client_id_key}": "{{client_id_key}}",
|
2004
|
+
"{client_secret_key}": "{{client_secret_key}}"
|
2005
|
+
},
|
2006
|
+
"access_token_headers": {
|
2007
|
+
"Content-Type": "application/json",
|
2008
|
+
"Accept": "application/json"
|
2009
|
+
},
|
2010
|
+
"extract_output": ["data.access_token"],
|
2011
|
+
"client_id_key": "app_id",
|
2012
|
+
"client_secret_key": "secret",
|
2013
|
+
"auth_code_key": "auth_code"
|
2014
|
+
}
|
2015
|
+
}
|
2016
|
+
}
|
2017
|
+
type: object
|
2018
|
+
additionalProperties: true
|
2019
|
+
required:
|
2020
|
+
- consent_url
|
2021
|
+
- access_token_url
|
2022
|
+
- extract_output
|
2023
|
+
properties:
|
2024
|
+
consent_url:
|
2025
|
+
title: DeclarativeOAuth Consent URL
|
2026
|
+
type: string
|
2027
|
+
description: |-
|
2028
|
+
The DeclarativeOAuth Specific string URL string template to initiate the authentication.
|
2029
|
+
The placeholders are replaced during the processing to provide neccessary values.
|
2030
|
+
examples:
|
2031
|
+
- consent_url: https://domain.host.com/marketing_api/auth?{client_id_key}={{client_id_key}}&{redirect_uri_key}={urlEncoder:{{redirect_uri_key}}}&{state_key}={{state_key}}
|
2032
|
+
- consent_url: https://endpoint.host.com/oauth2/authorize?{client_id_key}={{client_id_key}}&{redirect_uri_key}={urlEncoder:{{redirect_uri_key}}}&{scope_key}={urlEncoder:{{scope_key}}}&{state_key}={{state_key}}&subdomain={subdomain}
|
2033
|
+
scope:
|
2034
|
+
title: (Optional) DeclarativeOAuth Scope
|
2035
|
+
type: string
|
2036
|
+
description: |-
|
2037
|
+
The DeclarativeOAuth Specific string of the scopes needed to be grant for authenticated user.
|
2038
|
+
examples:
|
2039
|
+
- scope: user:read user:read_orders workspaces:read
|
2040
|
+
access_token_url:
|
2041
|
+
title: DeclarativeOAuth Access Token URL
|
2042
|
+
type: string
|
2043
|
+
description: |-
|
2044
|
+
The DeclarativeOAuth Specific URL templated string to obtain the `access_token`, `refresh_token` etc.
|
2045
|
+
The placeholders are replaced during the processing to provide neccessary values.
|
2046
|
+
examples:
|
2047
|
+
- access_token_url: https://auth.host.com/oauth2/token?{client_id_key}={{client_id_key}}&{client_secret_key}={{client_secret_key}}&{auth_code_key}={{auth_code_key}}&{redirect_uri_key}={urlEncoder:{{redirect_uri_key}}}
|
2048
|
+
access_token_headers:
|
2049
|
+
title: (Optional) DeclarativeOAuth Access Token Headers
|
2050
|
+
type: object
|
2051
|
+
additionalProperties: true
|
2052
|
+
description: |-
|
2053
|
+
The DeclarativeOAuth Specific optional headers to inject while exchanging the `auth_code` to `access_token` during `completeOAuthFlow` step.
|
2054
|
+
examples:
|
2055
|
+
- access_token_headers: {
|
2056
|
+
"Authorization": "Basic {base64Encoder:{client_id}:{client_secret}}"
|
2057
|
+
}
|
2058
|
+
access_token_params:
|
2059
|
+
title: (Optional) DeclarativeOAuth Access Token Query Params (Json Encoded)
|
2060
|
+
type: object
|
2061
|
+
additionalProperties: true
|
2062
|
+
description: |-
|
2063
|
+
The DeclarativeOAuth Specific optional query parameters to inject while exchanging the `auth_code` to `access_token` during `completeOAuthFlow` step.
|
2064
|
+
When this property is provided, the query params will be encoded as `Json` and included in the outgoing API request.
|
2065
|
+
examples:
|
2066
|
+
- access_token_params: {
|
2067
|
+
"{auth_code_key}": "{{auth_code_key}}",
|
2068
|
+
"{client_id_key}": "{{client_id_key}}",
|
2069
|
+
"{client_secret_key}": "{{client_secret_key}}"
|
2070
|
+
}
|
2071
|
+
extract_output:
|
2072
|
+
title: DeclarativeOAuth Extract Output
|
2073
|
+
type: array
|
2074
|
+
items:
|
2075
|
+
type: string
|
2076
|
+
description: |-
|
2077
|
+
The DeclarativeOAuth Specific list of strings to indicate which keys should be extracted and returned back to the input config.
|
2078
|
+
examples:
|
2079
|
+
- extract_output: ["access_token", "refresh_token", "other_field"]
|
2080
|
+
state:
|
2081
|
+
title: (Optional) DeclarativeOAuth Configurable State Query Param
|
2082
|
+
type: object
|
2083
|
+
additionalProperties: true
|
2084
|
+
required:
|
2085
|
+
- min
|
2086
|
+
- max
|
2087
|
+
description: |-
|
2088
|
+
The DeclarativeOAuth Specific object to provide the criteria of how the `state` query param should be constructed,
|
2089
|
+
including length and complexity.
|
2090
|
+
properties:
|
2091
|
+
min:
|
2092
|
+
type: integer
|
2093
|
+
max:
|
2094
|
+
type: integer
|
2095
|
+
examples:
|
2096
|
+
- state: {
|
2097
|
+
"min": 7,
|
2098
|
+
"max": 128,
|
2099
|
+
}
|
2100
|
+
client_id_key:
|
2101
|
+
title: (Optional) DeclarativeOAuth Client ID Key Override
|
2102
|
+
type: string
|
2103
|
+
description: |-
|
2104
|
+
The DeclarativeOAuth Specific optional override to provide the custom `client_id` key name, if required by data-provider.
|
2105
|
+
examples:
|
2106
|
+
- client_id_key: "my_custom_client_id_key_name"
|
2107
|
+
client_secret_key:
|
2108
|
+
title: (Optional) DeclarativeOAuth Client Secret Key Override
|
2109
|
+
type: string
|
2110
|
+
description: |-
|
2111
|
+
The DeclarativeOAuth Specific optional override to provide the custom `client_secret` key name, if required by data-provider.
|
2112
|
+
examples:
|
2113
|
+
- client_secret_key: "my_custom_client_secret_key_name"
|
2114
|
+
scope_key:
|
2115
|
+
title: (Optional) DeclarativeOAuth Scope Key Override
|
2116
|
+
type: string
|
2117
|
+
description: |-
|
2118
|
+
The DeclarativeOAuth Specific optional override to provide the custom `scope` key name, if required by data-provider.
|
2119
|
+
examples:
|
2120
|
+
- scope_key: "my_custom_scope_key_key_name"
|
2121
|
+
state_key:
|
2122
|
+
title: (Optional) DeclarativeOAuth State Key Override
|
2123
|
+
type: string
|
2124
|
+
description: |-
|
2125
|
+
The DeclarativeOAuth Specific optional override to provide the custom `state` key name, if required by data-provider.
|
2126
|
+
examples:
|
2127
|
+
- state_key: "my_custom_state_key_key_name"
|
2128
|
+
auth_code_key:
|
2129
|
+
title: (Optional) DeclarativeOAuth Auth Code Key Override
|
2130
|
+
type: string
|
2131
|
+
description: |-
|
2132
|
+
The DeclarativeOAuth Specific optional override to provide the custom `code` key name to something like `auth_code` or `custom_auth_code`, if required by data-provider.
|
2133
|
+
examples:
|
2134
|
+
- auth_code_key: "my_custom_auth_code_key_name"
|
2135
|
+
redirect_uri_key:
|
2136
|
+
title: (Optional) DeclarativeOAuth Redirect URI Key Override
|
2137
|
+
type: string
|
2138
|
+
description: |-
|
2139
|
+
The DeclarativeOAuth Specific optional override to provide the custom `redirect_uri` key name to something like `callback_uri`, if required by data-provider.
|
2140
|
+
examples:
|
2141
|
+
- redirect_uri_key: "my_custom_redirect_uri_key_name"
|
1975
2142
|
complete_oauth_output_specification:
|
1976
2143
|
title: "OAuth output specification"
|
1977
2144
|
description: |-
|
@@ -5,11 +5,12 @@ import codecs
|
|
5
5
|
import logging
|
6
6
|
from dataclasses import InitVar, dataclass
|
7
7
|
from gzip import decompress
|
8
|
-
from typing import Any, Generator, Mapping, MutableMapping,
|
8
|
+
from typing import Any, Generator, List, Mapping, MutableMapping, Optional
|
9
9
|
|
10
|
+
import orjson
|
10
11
|
import requests
|
12
|
+
|
11
13
|
from airbyte_cdk.sources.declarative.decoders.decoder import Decoder
|
12
|
-
import orjson
|
13
14
|
|
14
15
|
logger = logging.getLogger("airbyte")
|
15
16
|
|