Skip to content

Commit bf913dd

Browse files
committed
Rollback properties for objects
1 parent d181da3 commit bf913dd

File tree

6 files changed

+65
-153
lines changed

6 files changed

+65
-153
lines changed

airbyte_cdk/sources/declarative/declarative_component_schema.yaml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,26 +1800,6 @@ definitions:
18001800
$parameters:
18011801
type: object
18021802
additionalProperties: true
1803-
1804-
PropertyTypesMap:
1805-
title: Types Map
1806-
description: (This component is experimental. Use at your own risk.) Represents a mapping between a current type and its corresponding target type for property.
1807-
type: object
1808-
required:
1809-
- property_name
1810-
- property_type_pointer
1811-
- type_mapping
1812-
properties:
1813-
property_name:
1814-
type: string
1815-
property_type_pointer:
1816-
title: Key Path
1817-
description: List of potentially nested fields describing the full path of the property type to extract.
1818-
type: array
1819-
items:
1820-
- type: string
1821-
type_mapping:
1822-
"$ref": "#/definitions/TypesMap"
18231803
ItemsTypeMap:
18241804
title: Types Map
18251805
description: (This component is experimental. Use at your own risk.) Represents a mapping between a current type and its corresponding target type for property.
@@ -1864,10 +1844,6 @@ definitions:
18641844
- raw_schema
18651845
items_type:
18661846
"$ref": "#/definitions/ItemsTypeMap"
1867-
properties_types:
1868-
type: array
1869-
items:
1870-
- "$ref": "#/definitions/PropertyTypesMap"
18711847
SchemaTypeIdentifier:
18721848
title: Schema Type Identifier
18731849
description: (This component is experimental. Use at your own risk.) Identifies schema details for dynamic schema extraction and processing.

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 60 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,9 @@ class OAuthAuthenticator(BaseModel):
604604
scopes: Optional[List[str]] = Field(
605605
None,
606606
description="List of scopes that should be granted to the access token.",
607-
examples=[["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]],
607+
examples=[
608+
["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]
609+
],
608610
title="Scopes",
609611
)
610612
token_expiry_date: Optional[str] = Field(
@@ -1008,24 +1010,28 @@ class OAuthConfigSpecification(BaseModel):
10081010
class Config:
10091011
extra = Extra.allow
10101012

1011-
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = Field(
1012-
None,
1013-
description="OAuth specific blob. This is a Json Schema used to validate Json configurations used as input to OAuth.\nMust be a valid non-nested JSON that refers to properties from ConnectorSpecification.connectionSpecification\nusing special annotation 'path_in_connector_config'.\nThese are input values the user is entering through the UI to authenticate to the connector, that might also shared\nas inputs for syncing data via the connector.\nExamples:\nif no connector values is shared during oauth flow, oauth_user_input_from_connector_config_specification=[]\nif connector values such as 'app_id' inside the top level are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['app_id']\n }\n }\nif connector values such as 'info.app_id' nested inside another object are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['info', 'app_id']\n }\n }",
1014-
examples=[
1015-
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1016-
{
1017-
"app_id": {
1018-
"type": "string",
1019-
"path_in_connector_config": ["info", "app_id"],
1020-
}
1021-
},
1022-
],
1023-
title="OAuth user input",
1013+
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = (
1014+
Field(
1015+
None,
1016+
description="OAuth specific blob. This is a Json Schema used to validate Json configurations used as input to OAuth.\nMust be a valid non-nested JSON that refers to properties from ConnectorSpecification.connectionSpecification\nusing special annotation 'path_in_connector_config'.\nThese are input values the user is entering through the UI to authenticate to the connector, that might also shared\nas inputs for syncing data via the connector.\nExamples:\nif no connector values is shared during oauth flow, oauth_user_input_from_connector_config_specification=[]\nif connector values such as 'app_id' inside the top level are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['app_id']\n }\n }\nif connector values such as 'info.app_id' nested inside another object are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['info', 'app_id']\n }\n }",
1017+
examples=[
1018+
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1019+
{
1020+
"app_id": {
1021+
"type": "string",
1022+
"path_in_connector_config": ["info", "app_id"],
1023+
}
1024+
},
1025+
],
1026+
title="OAuth user input",
1027+
)
10241028
)
1025-
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = Field(
1026-
None,
1027-
description='The DeclarativeOAuth specific blob.\nPertains to the fields defined by the connector relating to the OAuth flow.\n\nInterpolation capabilities:\n- The variables placeholders are declared as `{{my_var}}`.\n- The nested resolution variables like `{{ {{my_nested_var}} }}` is allowed as well.\n\n- The allowed interpolation context is:\n + base64Encoder - encode to `base64`, {{ {{my_var_a}}:{{my_var_b}} | base64Encoder }}\n + base64Decorer - decode from `base64` encoded string, {{ {{my_string_variable_or_string_value}} | base64Decoder }}\n + urlEncoder - encode the input string to URL-like format, {{ https://test.host.com/endpoint | urlEncoder}}\n + urlDecorer - decode the input url-encoded string into text format, {{ urlDecoder:https%3A%2F%2Fairbyte.io | urlDecoder}}\n + codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {{ {{state_value}} | codeChallengeS256 }}\n\nExamples:\n - The TikTok Marketing DeclarativeOAuth spec:\n {\n "oauth_connector_input_specification": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "consent_url": "https://ads.tiktok.com/marketing_api/auth?{{client_id_key}}={{client_id_value}}&{{redirect_uri_key}}={{ {{redirect_uri_value}} | urlEncoder}}&{{state_key}}={{state_value}}",\n "access_token_url": "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/",\n "access_token_params": {\n "{{ auth_code_key }}": "{{ auth_code_value }}",\n "{{ client_id_key }}": "{{ client_id_value }}",\n "{{ client_secret_key }}": "{{ client_secret_value }}"\n },\n "access_token_headers": {\n "Content-Type": "application/json",\n "Accept": "application/json"\n },\n "extract_output": ["data.access_token"],\n "client_id_key": "app_id",\n "client_secret_key": "secret",\n "auth_code_key": "auth_code"\n }\n }\n }',
1028-
title="DeclarativeOAuth Connector Specification",
1029+
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = (
1030+
Field(
1031+
None,
1032+
description='The DeclarativeOAuth specific blob.\nPertains to the fields defined by the connector relating to the OAuth flow.\n\nInterpolation capabilities:\n- The variables placeholders are declared as `{{my_var}}`.\n- The nested resolution variables like `{{ {{my_nested_var}} }}` is allowed as well.\n\n- The allowed interpolation context is:\n + base64Encoder - encode to `base64`, {{ {{my_var_a}}:{{my_var_b}} | base64Encoder }}\n + base64Decorer - decode from `base64` encoded string, {{ {{my_string_variable_or_string_value}} | base64Decoder }}\n + urlEncoder - encode the input string to URL-like format, {{ https://test.host.com/endpoint | urlEncoder}}\n + urlDecorer - decode the input url-encoded string into text format, {{ urlDecoder:https%3A%2F%2Fairbyte.io | urlDecoder}}\n + codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {{ {{state_value}} | codeChallengeS256 }}\n\nExamples:\n - The TikTok Marketing DeclarativeOAuth spec:\n {\n "oauth_connector_input_specification": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "consent_url": "https://ads.tiktok.com/marketing_api/auth?{{client_id_key}}={{client_id_value}}&{{redirect_uri_key}}={{ {{redirect_uri_value}} | urlEncoder}}&{{state_key}}={{state_value}}",\n "access_token_url": "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/",\n "access_token_params": {\n "{{ auth_code_key }}": "{{ auth_code_value }}",\n "{{ client_id_key }}": "{{ client_id_value }}",\n "{{ client_secret_key }}": "{{ client_secret_value }}"\n },\n "access_token_headers": {\n "Content-Type": "application/json",\n "Accept": "application/json"\n },\n "extract_output": ["data.access_token"],\n "client_id_key": "app_id",\n "client_secret_key": "secret",\n "auth_code_key": "auth_code"\n }\n }\n }',
1033+
title="DeclarativeOAuth Connector Specification",
1034+
)
10291035
)
10301036
complete_oauth_output_specification: Optional[Dict[str, Any]] = Field(
10311037
None,
@@ -1043,7 +1049,9 @@ class Config:
10431049
complete_oauth_server_input_specification: Optional[Dict[str, Any]] = Field(
10441050
None,
10451051
description="OAuth specific blob. This is a Json Schema used to validate Json configurations persisted as Airbyte Server configurations.\nMust be a valid non-nested JSON describing additional fields configured by the Airbyte Instance or Workspace Admins to be used by the\nserver when completing an OAuth flow (typically exchanging an auth code for refresh token).\nExamples:\n complete_oauth_server_input_specification={\n client_id: {\n type: string\n },\n client_secret: {\n type: string\n }\n }",
1046-
examples=[{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}],
1052+
examples=[
1053+
{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}
1054+
],
10471055
title="OAuth input specification",
10481056
)
10491057
complete_oauth_server_output_specification: Optional[Dict[str, Any]] = Field(
@@ -1629,7 +1637,9 @@ class RecordSelector(BaseModel):
16291637
description="Responsible for filtering records to be emitted by the Source.",
16301638
title="Record Filter",
16311639
)
1632-
schema_normalization: Optional[Union[SchemaNormalization, CustomSchemaNormalization]] = Field(
1640+
schema_normalization: Optional[
1641+
Union[SchemaNormalization, CustomSchemaNormalization]
1642+
] = Field(
16331643
SchemaNormalization.None_,
16341644
description="Responsible for normalization according to the schema.",
16351645
title="Schema Normalization",
@@ -1803,12 +1813,16 @@ class Config:
18031813
description="Component used to coordinate how records are extracted across stream slices and request pages.",
18041814
title="Retriever",
18051815
)
1806-
incremental_sync: Optional[Union[CustomIncrementalSync, DatetimeBasedCursor]] = Field(
1807-
None,
1808-
description="Component used to fetch data incrementally based on a time field in the data.",
1809-
title="Incremental Sync",
1816+
incremental_sync: Optional[Union[CustomIncrementalSync, DatetimeBasedCursor]] = (
1817+
Field(
1818+
None,
1819+
description="Component used to fetch data incrementally based on a time field in the data.",
1820+
title="Incremental Sync",
1821+
)
1822+
)
1823+
name: Optional[str] = Field(
1824+
"", description="The stream name.", example=["Users"], title="Name"
18101825
)
1811-
name: Optional[str] = Field("", description="The stream name.", example=["Users"], title="Name")
18121826
primary_key: Optional[PrimaryKey] = Field(
18131827
"", description="The primary key of the stream.", title="Primary Key"
18141828
)
@@ -1993,20 +2007,10 @@ class HttpRequester(BaseModel):
19932007
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
19942008

19952009

1996-
class PropertyTypesMap(BaseModel):
1997-
property_name: str
1998-
property_type_pointer: Optional[List[str]] = Field(
1999-
None,
2000-
description="List of potentially nested fields describing the full path of the property type to extract.",
2001-
title="Key Path",
2002-
)
2003-
type_mapping: TypesMap
2004-
2005-
20062010
class ItemsTypeMap(BaseModel):
20072011
property_name: Optional[str] = None
2008-
items_type_pointer: Optional[List[str]] = Field(
2009-
None,
2012+
items_type_pointer: List[str] = Field(
2013+
...,
20102014
description="List of potentially nested fields describing the full path of the items type to extract.",
20112015
title="Items Type Path",
20122016
)
@@ -2018,7 +2022,6 @@ class TypesMap(BaseModel):
20182022
current_type: Union[str, List[str]]
20192023
condition: Optional[str] = None
20202024
items_type: Optional[ItemsTypeMap] = None
2021-
properties_types: Optional[List[PropertyTypesMap]] = None
20222025

20232026

20242027
class SchemaTypeIdentifier(BaseModel):
@@ -2129,7 +2132,11 @@ class SimpleRetriever(BaseModel):
21292132
CustomPartitionRouter,
21302133
ListPartitionRouter,
21312134
SubstreamPartitionRouter,
2132-
List[Union[CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter]],
2135+
List[
2136+
Union[
2137+
CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter
2138+
]
2139+
],
21332140
]
21342141
] = Field(
21352142
[],
@@ -2173,7 +2180,9 @@ class AsyncRetriever(BaseModel):
21732180
)
21742181
download_extractor: Optional[
21752182
Union[CustomRecordExtractor, DpathExtractor, ResponseToFileExtractor]
2176-
] = Field(None, description="Responsible for fetching the records from provided urls.")
2183+
] = Field(
2184+
None, description="Responsible for fetching the records from provided urls."
2185+
)
21772186
creation_requester: Union[CustomRequester, HttpRequester] = Field(
21782187
...,
21792188
description="Requester component that describes how to prepare HTTP requests to send to the source API to create the async server-side job.",
@@ -2207,7 +2216,11 @@ class AsyncRetriever(BaseModel):
22072216
CustomPartitionRouter,
22082217
ListPartitionRouter,
22092218
SubstreamPartitionRouter,
2210-
List[Union[CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter]],
2219+
List[
2220+
Union[
2221+
CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter
2222+
]
2223+
],
22112224
]
22122225
] = Field(
22132226
[],
@@ -2275,10 +2288,12 @@ class DynamicDeclarativeStream(BaseModel):
22752288
stream_template: DeclarativeStream = Field(
22762289
..., description="Reference to the stream template.", title="Stream Template"
22772290
)
2278-
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = Field(
2279-
...,
2280-
description="Component resolve and populates stream templates with components values.",
2281-
title="Components Resolver",
2291+
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = (
2292+
Field(
2293+
...,
2294+
description="Component resolve and populates stream templates with components values.",
2295+
title="Components Resolver",
2296+
)
22822297
)
22832298

22842299

@@ -2288,7 +2303,6 @@ class DynamicDeclarativeStream(BaseModel):
22882303
SelectiveAuthenticator.update_forward_refs()
22892304
DeclarativeStream.update_forward_refs()
22902305
SessionTokenAuthenticator.update_forward_refs()
2291-
PropertyTypesMap.update_forward_refs()
22922306
ItemsTypeMap.update_forward_refs()
22932307
DynamicSchemaLoader.update_forward_refs()
22942308
SimpleRetriever.update_forward_refs()

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,6 @@
313313
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
314314
ParentStreamConfig as ParentStreamConfigModel,
315315
)
316-
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
317-
PropertyTypesMap as PropertyTypesMapModel,
318-
)
319316
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
320317
RecordFilter as RecordFilterModel,
321318
)
@@ -440,7 +437,6 @@
440437
InlineSchemaLoader,
441438
ItemsTypeMap,
442439
JsonFileSchemaLoader,
443-
PropertyTypesMap,
444440
SchemaTypeIdentifier,
445441
TypesMap,
446442
)
@@ -580,7 +576,6 @@ def _init_mappings(self) -> None:
580576
DynamicSchemaLoaderModel: self.create_dynamic_schema_loader,
581577
SchemaTypeIdentifierModel: self.create_schema_type_identifier,
582578
TypesMapModel: self.create_types_map,
583-
PropertyTypesMapModel: self.create_property_types_map,
584579
ItemsTypeMapModel: self.create_items_type_map,
585580
JwtAuthenticatorModel: self.create_jwt_authenticator,
586581
LegacyToPerPartitionStateMigrationModel: self.create_legacy_to_per_partition_state_migration,
@@ -1904,19 +1899,6 @@ def create_inline_schema_loader(
19041899
) -> InlineSchemaLoader:
19051900
return InlineSchemaLoader(schema=model.schema_ or {}, parameters={})
19061901

1907-
def create_property_types_map(
1908-
self, model: PropertyTypesMapModel, config: Config, **kwargs: Any
1909-
) -> PropertyTypesMap:
1910-
type_mapping = self._create_component_from_model(model=model.type_mapping, config=config)
1911-
model_property_type_pointer: List[Union[InterpolatedString, str]] = (
1912-
[x for x in model.property_type_pointer] if model.property_type_pointer else []
1913-
)
1914-
return PropertyTypesMap(
1915-
property_name=model.property_name,
1916-
property_type_pointer=model_property_type_pointer,
1917-
type_mapping=type_mapping,
1918-
)
1919-
19201902
def create_items_type_map(
19211903
self, model: ItemsTypeMapModel, config: Config, **kwargs: Any
19221904
) -> ItemsTypeMap:
@@ -1933,21 +1915,11 @@ def create_types_map(self, model: TypesMapModel, config: Config, **kwargs: Any)
19331915
else None
19341916
)
19351917

1936-
properties_types = []
1937-
if model.properties_types:
1938-
properties_types.extend(
1939-
[
1940-
self._create_component_from_model(property_type, config=config)
1941-
for property_type in model.properties_types
1942-
]
1943-
)
1944-
19451918
return TypesMap(
19461919
target_type=model.target_type,
19471920
current_type=model.current_type,
19481921
condition=model.condition if model.condition is not None else "True",
19491922
items_type=items_type,
1950-
properties_types=properties_types,
19511923
)
19521924

19531925
def create_schema_type_identifier(

airbyte_cdk/sources/declarative/schema/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from airbyte_cdk.sources.declarative.schema.dynamic_schema_loader import (
77
DynamicSchemaLoader,
88
ItemsTypeMap,
9-
PropertyTypesMap,
109
SchemaTypeIdentifier,
1110
TypesMap,
1211
)
@@ -21,7 +20,6 @@
2120
"InlineSchemaLoader",
2221
"DynamicSchemaLoader",
2322
"TypesMap",
24-
"PropertyTypesMap",
2523
"ItemsTypeMap",
2624
"SchemaTypeIdentifier",
2725
]

0 commit comments

Comments
 (0)