Skip to content

Commit

Permalink
fix(field_handlers): reconfigure fieldHandlers, get requiredFields to…
Browse files Browse the repository at this point in the history
… work use resourceName

not collectionName!
  • Loading branch information
Gerald Baulig committed Nov 14, 2024
1 parent c349065 commit 4e285b9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 59 deletions.
94 changes: 38 additions & 56 deletions cfg/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,6 @@
"direction": "outbound",
"toVerticeName": "templates"
}
],
"currency": [
{
"edgeName": "currency_has_countries",
"from": "id",
"to": "country_ids",
"direction": "outbound",
"toVerticeName": "countries"
}
]
},
"edgeDefinitions": [
Expand Down Expand Up @@ -300,11 +291,6 @@
"collection": "customer_has_templates",
"from": "customers",
"to": "templates"
},
{
"collection": "currency_has_countries",
"from": "currencies",
"to": "countrys"
}
]
},
Expand Down Expand Up @@ -388,10 +374,6 @@
"resourceName": "tax_type",
"collectionName": "tax_types"
},
{
"resourceName": "tax_type",
"collectionName": "tax_types"
},
{
"resourceName": "template",
"collectionName": "templates"
Expand Down Expand Up @@ -555,14 +537,14 @@
},
"fieldHandlers": {
"bufferFields": {
"organizations": [
"organization": [
"data"
],
"locations": [
"location": [
"data"
],
"credentials": [
"credentials"
"credential": [
"credential"
]
},
"timeStampFields": [
Expand All @@ -572,72 +554,72 @@
"meta.modified"
],
"entities": [
"commands",
"addresss",
"contact_point_types",
"countrys",
"contact_points",
"credentials",
"locales",
"locations",
"notifications",
"notification_channels",
"organizations",
"taxs",
"tax_types",
"timezones",
"customers",
"shops",
"unit_codes",
"templates",
"settings",
"currencies"
"command",
"address",
"contact_point_type",
"country",
"contact_point",
"credential",
"locale",
"location",
"notification",
"notification_channel",
"organization",
"tax",
"tax_type",
"timezone",
"customer",
"shop",
"unit_code",
"template",
"setting",
"currency"
]
}
],
"requiredFields": {
"organizations": [
"organization": [
"name"
],
"contact_point_types": [
"contact_point_type": [
"type"
],
"credentials": [
"credential": [
"name"
],
"addresss": [
"address": [
"postcode",
"country_id",
"locality",
"street",
"region"
],
"countrys": [
"name",
"country_code"
],
"contact_points": [
"contact_point": [
"physical_address_id",
"contact_point_type_id",
"email",
"telephone"
],
"locations": [
"location": [
"name"
],
"taxs": [
"tax": [
"country_id",
"rate"
],
"tax_types": [
"tax_type": [
"type",
"description"
],
"templates": [
"template": [
"name"
],
"settings": [
"setting": [
"name"
],
"currency": [
"name",
"symbol"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@restorecommerce/rc-grpc-clients": "5.1.42",
"@restorecommerce/resource-base-interface": "1.6.4",
"@restorecommerce/service-config": "1.0.16",
"@restorecommerce/logger": "^1.3.2",
"lodash-es": "^4.17.21",
"redis": "^4.6.14",
"uuid": "11.0.3"
Expand All @@ -33,7 +34,6 @@
"@commitlint/config-conventional": "19.5.0",
"@grpc/proto-loader": "^0.7.13",
"@restorecommerce/dev": "0.0.13",
"@restorecommerce/logger": "^1.3.1",
"@semantic-release-plus/docker": "^3.1.3",
"@types/lodash-es": "^4.17.12",
"@types/mocha": "10.0.9",
Expand Down
4 changes: 2 additions & 2 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ export class Worker {
if (cfg.get('fieldHandlers:timeStampFields')) {
resourceFieldConfig.timeStampFields = [];
for (const timeStampFiledConfig of cfg.get('fieldHandlers:timeStampFields')) {
if (timeStampFiledConfig.entities.includes(collectionName)) {
if (timeStampFiledConfig.entities.includes(resourceName)) {
resourceFieldConfig.timeStampFields.push(...timeStampFiledConfig.fields);
}
}
}
// requiredFields handler
if (requiredFieldsConfig && (collectionName in requiredFieldsConfig)) {
if (requiredFieldsConfig && (resourceName in requiredFieldsConfig)) {
resourceFieldConfig.requiredFields = requiredFieldsConfig;
}
logger.info(`Setting up ${resourceName} resource service`);
Expand Down

0 comments on commit 4e285b9

Please sign in to comment.