Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
be478ae
Add dynamic schema loader
lazebnyi Dec 3, 2024
520998a
Revert imports
lazebnyi Dec 3, 2024
edb52e7
Merge branch 'main' into lazebnyi/add-dynamic-schema-loader
lazebnyi Dec 3, 2024
7387131
Auto-fix lint and format issues
Dec 3, 2024
807d23e
Fix edge case validation
lazebnyi Dec 3, 2024
59c5c7f
Fix mypy
lazebnyi Dec 3, 2024
ffee00f
Merge branch 'lazebnyi/add-dynamic-schema-loader' of github.com:airby…
lazebnyi Dec 3, 2024
13441ca
Merge branch 'main' into lazebnyi/add-dynamic-schema-loader
lazebnyi Dec 3, 2024
227325f
Update after review
lazebnyi Dec 3, 2024
fd44be1
Merge branch 'lazebnyi/add-dynamic-schema-loader' of github.com:airby…
lazebnyi Dec 3, 2024
05e4f74
Add default value for schema pointer
lazebnyi Dec 3, 2024
d41f54c
Changed helpers var name in _extract_data and typo in schema loader
lazebnyi Dec 5, 2024
4097480
Merge branch 'main' into lazebnyi/add-dynamic-schema-loader
lazebnyi Dec 5, 2024
f843c3f
Replace deprecated import
lazebnyi Dec 5, 2024
6bfdff3
Merge branch 'main' into lazebnyi/add-dynamic-schema-loader
lazebnyi Dec 5, 2024
42357e7
Merge branch 'main' into lazebnyi/add-dynamic-schema-loader
lazebnyi Dec 6, 2024
dcc6233
Chenged interpolation_content to interpolation_context
lazebnyi Dec 6, 2024
1b7c63f
Merge branch 'lazebnyi/add-dynamic-schema-loader' of github.com:airby…
lazebnyi Dec 6, 2024
9b87978
Formated with ruff
lazebnyi Dec 6, 2024
3da287a
Add DynamicSchemaLoader to DeclarativeStream schema
lazebnyi Dec 12, 2024
507afb6
Add test_dynamic_schema_loader_manifest_flow
lazebnyi Dec 12, 2024
d7e4873
Merge branch 'main' into lazebnyi/add-dynamic-schema-loader
lazebnyi Dec 12, 2024
9c29cee
Fix typo
lazebnyi Dec 12, 2024
1edb25e
Updated imports
lazebnyi Dec 12, 2024
0dbea5d
Merge branch 'lazebnyi/add-dynamic-schema-loader' of github.com:airby…
lazebnyi Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 102 additions & 17 deletions airbyte_cdk/sources/declarative/declarative_component_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,92 @@ definitions:
$parameters:
type: object
additionalProperties: true
TypesMap:
title: Types Map
description: (This component is experimental. Use at your own risk.) Represents a mapping between a current type and its corresponding target type.
type: object
required:
- target_type
- current_type
properties:
target_type:
anyOf:
- type: string
- type: array
items:
type: string
current_type:
anyOf:
- type: string
- type: array
items:
type: string
SchemaTypeIdentifier:
title: Schema Type Identifier
description: (This component is experimental. Use at your own risk.) Identifies schema details for dynamic schema extraction and processing.
type: object
required:
- key_pointer
properties:
type:
type: string
enum: [SchemaTypeIdentifier]
schema_pointer:
title: Schema Path
description: List of nested fields defining the schema field path to extract. Defaults to [].
type: array
default: []
items:
- type: string
interpolation_content:
- config
key_pointer:
title: Key Path
description: List of potentially nested fields describing the full path of the field key to extract.
type: array
items:
- type: string
interpolation_content:
- config
type_pointer:
title: Type Path
description: List of potentially nested fields describing the full path of the field type to extract.
type: array
items:
- type: string
interpolation_content:
- config
types_mapping:
type: array
items:
- "$ref": "#/definitions/TypesMap"
$parameters:
type: object
additionalProperties: true
DynamicSchemaLoader:
title: Dynamic Schema Loader
description: (This component is experimental. Use at your own risk.) Loads a schema by extracting data from retrieved records.
type: object
required:
- type
- retriever
- schema_type_identifier
properties:
type:
type: string
enum: [DynamicSchemaLoader]
retriever:
title: Retriever
description: Component used to coordinate how records are extracted across stream slices and request pages.
anyOf:
- "$ref": "#/definitions/AsyncRetriever"
- "$ref": "#/definitions/CustomRetriever"
- "$ref": "#/definitions/SimpleRetriever"
schema_type_identifier:
"$ref": "#/definitions/SchemaTypeIdentifier"
$parameters:
type: object
additionalProperties: true
InlineSchemaLoader:
title: Inline Schema Loader
description: Loads a schema that is defined directly in the manifest file.
Expand Down Expand Up @@ -2057,17 +2143,18 @@ definitions:
The DeclarativeOAuth Specific URL templated string to obtain the `access_token`, `refresh_token` etc.
The placeholders are replaced during the processing to provide neccessary values.
examples:
- 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}}}
- 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}}}
access_token_headers:
title: (Optional) DeclarativeOAuth Access Token Headers
type: object
additionalProperties: true
description: |-
The DeclarativeOAuth Specific optional headers to inject while exchanging the `auth_code` to `access_token` during `completeOAuthFlow` step.
examples:
- access_token_headers: {
"Authorization": "Basic {base64Encoder:{client_id}:{client_secret}}"
}
- access_token_headers:
{
"Authorization": "Basic {base64Encoder:{client_id}:{client_secret}}",
}
access_token_params:
title: (Optional) DeclarativeOAuth Access Token Query Params (Json Encoded)
type: object
Expand All @@ -2076,18 +2163,19 @@ definitions:
The DeclarativeOAuth Specific optional query parameters to inject while exchanging the `auth_code` to `access_token` during `completeOAuthFlow` step.
When this property is provided, the query params will be encoded as `Json` and included in the outgoing API request.
examples:
- access_token_params: {
"{auth_code_key}": "{{auth_code_key}}",
"{client_id_key}": "{{client_id_key}}",
"{client_secret_key}": "{{client_secret_key}}"
}
- access_token_params:
{
"{auth_code_key}": "{{auth_code_key}}",
"{client_id_key}": "{{client_id_key}}",
"{client_secret_key}": "{{client_secret_key}}",
}
extract_output:
title: DeclarativeOAuth Extract Output
type: array
items:
type: string
description: |-
The DeclarativeOAuth Specific list of strings to indicate which keys should be extracted and returned back to the input config.
The DeclarativeOAuth Specific list of strings to indicate which keys should be extracted and returned back to the input config.
examples:
- extract_output: ["access_token", "refresh_token", "other_field"]
state:
Expand All @@ -2099,17 +2187,14 @@ definitions:
- max
description: |-
The DeclarativeOAuth Specific object to provide the criteria of how the `state` query param should be constructed,
including length and complexity.
including length and complexity.
properties:
min:
type: integer
max:
type: integer
examples:
- state: {
"min": 7,
"max": 128,
}
- state: { "min": 7, "max": 128 }
client_id_key:
title: (Optional) DeclarativeOAuth Client ID Key Override
type: string
Expand All @@ -2135,14 +2220,14 @@ definitions:
title: (Optional) DeclarativeOAuth State Key Override
type: string
description: |-
The DeclarativeOAuth Specific optional override to provide the custom `state` key name, if required by data-provider.
The DeclarativeOAuth Specific optional override to provide the custom `state` key name, if required by data-provider.
examples:
- state_key: "my_custom_state_key_key_name"
auth_code_key:
title: (Optional) DeclarativeOAuth Auth Code Key Override
type: string
description: |-
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.
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.
examples:
- auth_code_key: "my_custom_auth_code_key_name"
redirect_uri_key:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,32 @@ class HttpResponseFilter(BaseModel):
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")


class TypesMap(BaseModel):
target_type: Union[str, List[str]]
current_type: Union[str, List[str]]


class SchemaTypeIdentifier(BaseModel):
type: Optional[Literal["SchemaTypeIdentifier"]] = None
schema_pointer: Optional[List[str]] = Field(
[],
description="List of nested fields defining the schema field path to extract. Defaults to [].",
title="Schema Path",
)
key_pointer: List[str] = Field(
...,
description="List of potentially nested fields describing the full path of the field key to extract.",
title="Key Path",
)
type_pointer: Optional[List[str]] = Field(
None,
description="List of potentially nested fields describing the full path of the field type to extract.",
title="Type Path",
)
types_mapping: Optional[List[TypesMap]] = None
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")


class InlineSchemaLoader(BaseModel):
type: Literal["InlineSchemaLoader"]
schema_: Optional[Dict[str, Any]] = Field(
Expand Down Expand Up @@ -822,13 +848,13 @@ class Config:
)
extract_output: List[str] = Field(
...,
description="The DeclarativeOAuth Specific list of strings to indicate which keys should be extracted and returned back to the input config. ",
description="The DeclarativeOAuth Specific list of strings to indicate which keys should be extracted and returned back to the input config.",
examples=[{"extract_output": ["access_token", "refresh_token", "other_field"]}],
title="DeclarativeOAuth Extract Output",
)
state: Optional[State] = Field(
None,
description="The DeclarativeOAuth Specific object to provide the criteria of how the `state` query param should be constructed,\nincluding length and complexity. ",
description="The DeclarativeOAuth Specific object to provide the criteria of how the `state` query param should be constructed,\nincluding length and complexity.",
examples=[{"state": {"min": 7, "max": 128}}],
title="(Optional) DeclarativeOAuth Configurable State Query Param",
)
Expand All @@ -852,13 +878,13 @@ class Config:
)
state_key: Optional[str] = Field(
None,
description="The DeclarativeOAuth Specific optional override to provide the custom `state` key name, if required by data-provider. ",
description="The DeclarativeOAuth Specific optional override to provide the custom `state` key name, if required by data-provider.",
examples=[{"state_key": "my_custom_state_key_key_name"}],
title="(Optional) DeclarativeOAuth State Key Override",
)
auth_code_key: Optional[str] = Field(
None,
description="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. ",
description="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.",
examples=[{"auth_code_key": "my_custom_auth_code_key_name"}],
title="(Optional) DeclarativeOAuth Auth Code Key Override",
)
Expand Down Expand Up @@ -1705,6 +1731,17 @@ class HttpRequester(BaseModel):
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")


class DynamicSchemaLoader(BaseModel):
type: Literal["DynamicSchemaLoader"]
retriever: Union[AsyncRetriever, CustomRetriever, SimpleRetriever] = Field(
...,
description="Component used to coordinate how records are extracted across stream slices and request pages.",
title="Retriever",
)
schema_type_identifier: SchemaTypeIdentifier
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")


class ParentStreamConfig(BaseModel):
type: Literal["ParentStreamConfig"]
parent_key: str = Field(
Expand Down Expand Up @@ -1888,5 +1925,6 @@ class SubstreamPartitionRouter(BaseModel):
SelectiveAuthenticator.update_forward_refs()
DeclarativeStream.update_forward_refs()
SessionTokenAuthenticator.update_forward_refs()
DynamicSchemaLoader.update_forward_refs()
SimpleRetriever.update_forward_refs()
AsyncRetriever.update_forward_refs()
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
"AddFields.fields": "AddedFieldDefinition",
# CustomPartitionRouter
"CustomPartitionRouter.parent_stream_configs": "ParentStreamConfig",
# DynamicSchemaLoader
"DynamicSchemaLoader.retriever": "SimpleRetriever",
# SchemaTypeIdentifier
"SchemaTypeIdentifier.types_map": "TypesMap",
}

# We retain a separate registry for custom components to automatically insert the type if it is missing. This is intended to
Expand Down
Loading
Loading