diff --git a/airbyte-integrations/connectors/source-commercetools/integration_tests/configured_catalog.json b/airbyte-integrations/connectors/source-commercetools/integration_tests/configured_catalog.json index 0f93ffc16bfaa..cf83410ff1765 100644 --- a/airbyte-integrations/connectors/source-commercetools/integration_tests/configured_catalog.json +++ b/airbyte-integrations/connectors/source-commercetools/integration_tests/configured_catalog.json @@ -251,6 +251,34 @@ }, "sync_id": null, "sync_mode": "full_refresh" + }, + { + "cursor_field": null, + "destination_sync_mode": "append", + "generation_id": null, + "minimum_generation_id": null, + "primary_key": null, + "stream": { + "default_cursor_field": [ + "lastModifiedAt" + ], + "is_resumable": true, + "json_schema": {}, + "name": "cart-discounts", + "namespace": null, + "source_defined_cursor": true, + "source_defined_primary_key": [ + [ + "id" + ] + ], + "supported_sync_modes": [ + "full_refresh", + "incremental" + ] + }, + "sync_id": null, + "sync_mode": "full_refresh" } ] } \ No newline at end of file diff --git a/airbyte-integrations/connectors/source-commercetools/source_commercetools/manifest.yaml b/airbyte-integrations/connectors/source-commercetools/source_commercetools/manifest.yaml index 2165948317fdd..dfa30ec359433 100644 --- a/airbyte-integrations/connectors/source-commercetools/source_commercetools/manifest.yaml +++ b/airbyte-integrations/connectors/source-commercetools/source_commercetools/manifest.yaml @@ -138,6 +138,12 @@ definitions: name: "product-discounts" path: "product-discounts" + cart-discounts_stream: + $ref: "#/definitions/base_stream" + $parameters: + name: "cart-discounts" + path: "cart-discounts" + streams: - "#/definitions/customers_stream" @@ -149,6 +155,7 @@ streams: - "#/definitions/inventory_stream" - "#/definitions/standalone-prices_stream" - "#/definitions/product-discounts_stream" + - "#/definitions/cart-discounts_stream" spec: documentation_url: https://docs.airbyte.com/integrations/sources/commercetools diff --git a/airbyte-integrations/connectors/source-commercetools/source_commercetools/schemas/cart-discounts.json b/airbyte-integrations/connectors/source-commercetools/source_commercetools/schemas/cart-discounts.json new file mode 100644 index 0000000000000..5b0c8d0dc7077 --- /dev/null +++ b/airbyte-integrations/connectors/source-commercetools/source_commercetools/schemas/cart-discounts.json @@ -0,0 +1,226 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": true, + "properties": { + "cartPredicate": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "createdBy": { + "additionalProperties": true, + "properties": { + "clientId": { + "type": "string" + }, + "isPlatformClient": { + "type": "boolean" + }, + "user": { + "additionalProperties": true, + "properties": { + "id": { + "type": "string" + }, + "typeId": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "description": { + "additionalProperties": true, + "properties": { + "en-CA": { + "type": "string" + }, + "en-US": { + "type": "string" + }, + "es-MX": { + "type": "string" + }, + "fr-CA": { + "type": "string" + } + }, + "type": "object" + }, + "id": { + "type": "string" + }, + "isActive": { + "type": "boolean" + }, + "key": { + "type": "string" + }, + "lastMessageSequenceNumber": { + "type": "integer" + }, + "lastModifiedAt": { + "type": "string" + }, + "lastModifiedBy": { + "additionalProperties": true, + "properties": { + "clientId": { + "type": "string" + }, + "isPlatformClient": { + "type": "boolean" + }, + "user": { + "additionalProperties": true, + "properties": { + "id": { + "type": "string" + }, + "typeId": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "name": { + "additionalProperties": true, + "properties": { + "en-CA": { + "type": "string" + }, + "en-US": { + "type": "string" + }, + "es-MX": { + "type": "string" + }, + "fr-CA": { + "type": "string" + } + }, + "type": "object" + }, + "references": { + "type": "array" + }, + "requiresDiscountCode": { + "type": "boolean" + }, + "sortOrder": { + "type": "string" + }, + "stackingMode": { + "type": "string" + }, + "stores": { + "items": { + "additionalProperties": true, + "properties": { + "key": { + "type": "string" + }, + "typeId": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "target": { + "additionalProperties": true, + "properties": { + "predicate": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "type": "object" + }, + "validFrom": { + "type": "string" + }, + "validUntil": { + "type": "string" + }, + "value": { + "additionalProperties": true, + "properties": { + "applicationMode": { + "type": "string" + }, + "money": { + "items": { + "additionalProperties": true, + "properties": { + "centAmount": { + "type": "integer" + }, + "currencyCode": { + "type": "string" + }, + "fractionDigits": { + "type": "integer" + }, + "type": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "permyriad": { + "type": "integer" + }, + "product": { + "additionalProperties": true, + "properties": { + "id": { + "type": "string" + }, + "typeId": { + "type": "string" + } + }, + "type": "object" + }, + "supplyChannel": { + "additionalProperties": true, + "properties": { + "id": { + "type": "string" + }, + "typeId": { + "type": "string" + } + }, + "type": "object" + }, + "type": { + "type": "string" + }, + "variantId": { + "type": "integer" + } + }, + "type": "object" + }, + "version": { + "type": "integer" + }, + "versionModifiedAt": { + "type": "string" + } + }, + "type": "object" +} \ No newline at end of file diff --git a/tools/bin/reactor-refresh-schema-source.sh b/tools/bin/reactor-refresh-schema-source.sh new file mode 100755 index 0000000000000..29b19156fc879 --- /dev/null +++ b/tools/bin/reactor-refresh-schema-source.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +which schema_generator > /dev/null +if [ $? != 0 ];then + echo "schema_generator is not installed. See https://github.com/airbytehq/airbyte/tree/master/tools/schema_generator/ for installation instructions" +fi +root=$(git rev-parse --show-toplevel 2>> /dev/null) +source=$1 +airbyte_config=$2 +source_root="${root}/airbyte-integrations/connectors/source-${source}" +if [ ! --d "${source_root}" ];then + echo "Invalid source specified . Source folder not found at ${source_root}" + exit 1 +fi + +if [ -z "${airbyte_config}" ];then + echo "airbyte config must be provided" + exit 1 +fi +if [ ! -f "${airbyte_config}" ];then + echo "${airbyte_config} is not a valid path" + exit 1 +fi +pushd $PWD > /dev/null +cd $source_root +echo "refreshing catalog for source" +python main.py discover --config $airbyte_config | schema_generator --configure-catalog + + +echo "refreshing schemas for source. (note: This is fetching live data using the provided credentials. it may take a while." +cd source_commercetools +python ../main.py read --config $airbyte_config --catalog ../integration_tests/configured_catalog.json | schema_generator --infer-schemas +echo "Finished refreshing schemas. NOTE: Some schemas have been tweaked and standardized by hand. You probably only want to check in the new schema for the no stream that was added." +echo "$source_root/integration_tests/configured_catalog.json should be checked in along with any new schemas found at $source_root/source_${source}/schemas/" +popd > /dev/null \ No newline at end of file