Skip to content

Commit

Permalink
ACC-7752
Browse files Browse the repository at this point in the history
- adding cart-discounts stream
- adding helper script for refreshing catalog and schemas with some basic checks.
  • Loading branch information
mattjwinslow committed Feb 14, 2025
1 parent 6decd17 commit 996c81a
Show file tree
Hide file tree
Showing 4 changed files with 296 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
35 changes: 35 additions & 0 deletions tools/bin/reactor-refresh-schema-source.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 996c81a

Please sign in to comment.