diff --git a/cfg/config.json b/cfg/config.json index 36c90d4..73dc98c 100644 --- a/cfg/config.json +++ b/cfg/config.json @@ -95,33 +95,50 @@ "createInvoices": { "messageObject": "io.restorecommerce.order.InvoiceRequestList" }, + "restoreCommand": { "messageObject": "io.restorecommerce.commandinterface.CommandRequest" }, - "restoreResponse": { - "messageObject": "io.restorecommerce.commandinterface.CommandResponse" - }, "healthCheckCommand": { "messageObject": "io.restorecommerce.commandinterface.CommandRequest" }, + "resetCommand": { + "messageObject": "io.restorecommerce.commandinterface.CommandRequest" + }, "healthCheckResponse": { "messageObject": "io.restorecommerce.commandinterface.CommandResponse" }, + "resetResponse": { + "messageObject": "io.restorecommerce.commandinterface.CommandResponse" + }, + "restoreResponse": { + "messageObject": "io.restorecommerce.commandinterface.CommandResponse" + }, "versionCommand": { "messageObject": "io.restorecommerce.commandinterface.CommandRequest" }, "versionResponse": { "messageObject": "io.restorecommerce.commandinterface.CommandResponse" }, - "resetCommand": { + "configUpdateCommand": { "messageObject": "io.restorecommerce.commandinterface.CommandRequest" }, - "resetResponse": { + "configUpdateResponse": { + "messageObject": "io.restorecommerce.commandinterface.CommandResponse" + }, + "setApiKeyCommand": { + "messageObject": "io.restorecommerce.commandinterface.CommandRequest" + }, + "setApiKeyResponse": { "messageObject": "io.restorecommerce.commandinterface.CommandResponse" }, - "renderRequest": { - "messageObject": "io.restorecommerce.rendering.RenderRequest" + "flushCacheCommand": { + "messageObject": "io.restorecommerce.commandinterface.CommandRequest" + }, + "flushCacheResponse": { + "messageObject": "io.restorecommerce.commandinterface.CommandResponse" }, + "topics": { "command": { "topic": "io.restorecommerce.command", diff --git a/package-lock.json b/package-lock.json index 405e07c..bb86056 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,15 +9,15 @@ "version": "0.0.12", "license": "MIT", "dependencies": { - "@restorecommerce/acs-client": "^1.3.0", - "@restorecommerce/chassis-srv": "^1.4.0", + "@restorecommerce/acs-client": "^1.4.2", + "@restorecommerce/chassis-srv": "^1.4.4", "@restorecommerce/cluster-service": "^1.0.2", - "@restorecommerce/grpc-client": "^2.0.7", - "@restorecommerce/kafka-client": "^1.1.7", - "@restorecommerce/logger": "^1.2.6", - "@restorecommerce/rc-grpc-clients": "^5.1.10", - "@restorecommerce/resource-base-interface": "^1.4.0", - "@restorecommerce/service-config": "^1.0.9", + "@restorecommerce/grpc-client": "^2.0.8", + "@restorecommerce/kafka-client": "^1.1.12", + "@restorecommerce/logger": "^1.2.8", + "@restorecommerce/rc-grpc-clients": "^5.1.12", + "@restorecommerce/resource-base-interface": "^1.4.4", + "@restorecommerce/service-config": "^1.0.10", "redis": "^4.6.7" }, "devDependencies": { @@ -1254,9 +1254,9 @@ } }, "node_modules/@redis/client": { - "version": "1.5.11", - "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.5.11.tgz", - "integrity": "sha512-cV7yHcOAtNQ5x/yQl7Yw1xf53kO0FNDTdDU6bFIMbW6ljB7U7ns0YRM+QIkpoqTAt6zK5k9Fq0QWlUbLcq9AvA==", + "version": "1.5.12", + "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.5.12.tgz", + "integrity": "sha512-/ZjE18HRzMd80eXIIUIPcH81UoZpwulbo8FmbElrjPqH0QC0SeIKu1BOU49bO5trM5g895kAjhvalt5h77q+4A==", "dependencies": { "cluster-key-slot": "1.1.2", "generic-pool": "3.9.0", @@ -1272,9 +1272,9 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/@redis/graph": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.0.tgz", - "integrity": "sha512-16yZWngxyXPd+MJxeSr0dqh2AIOi8j9yXKcKCwVaKDbH3HTuETpDVPcLujhFYVPtYrngSco31BUcSa9TH31Gqg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.1.tgz", + "integrity": "sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw==", "peerDependencies": { "@redis/client": "^1.0.0" } @@ -1288,9 +1288,9 @@ } }, "node_modules/@redis/search": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/@redis/search/-/search-1.1.5.tgz", - "integrity": "sha512-hPP8w7GfGsbtYEJdn4n7nXa6xt6hVZnnDktKW4ArMaFQ/m/aR7eFvsLQmG/mn1Upq99btPJk+F27IQ2dYpCoUg==", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@redis/search/-/search-1.1.6.tgz", + "integrity": "sha512-mZXCxbTYKBQ3M2lZnEddwEAks0Kc7nauire8q20oA0oA/LoA+E/b5Y5KZn232ztPb1FkIGqo12vh3Lf+Vw5iTw==", "peerDependencies": { "@redis/client": "^1.0.0" } @@ -1304,36 +1304,36 @@ } }, "node_modules/@restorecommerce/acs-client": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@restorecommerce/acs-client/-/acs-client-1.3.0.tgz", - "integrity": "sha512-89ERbp4iLijqee6qoqFO7gDbMw8U9WSjO9RkJWVzzldokIvqVOgJJvzIuvtL38pIzgbTDN+czlBqdEQf+sUBMQ==", - "dependencies": { - "@restorecommerce/grpc-client": "^2.0.7", - "@restorecommerce/kafka-client": "^1.1.7", - "@restorecommerce/logger": "^1.2.7", - "@restorecommerce/rc-grpc-clients": "^5.1.7", - "@restorecommerce/service-config": "^1.0.9", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@restorecommerce/acs-client/-/acs-client-1.4.2.tgz", + "integrity": "sha512-8B7H373G2guJngvTG5tJmdDYwrMg6OfzXxAGpiKCC45LXN0GFI5VASc3aeVUgw4XoJ44q4whBuspJyincyealw==", + "dependencies": { + "@restorecommerce/grpc-client": "^2.0.8", + "@restorecommerce/kafka-client": "^1.1.12", + "@restorecommerce/logger": "^1.2.8", + "@restorecommerce/rc-grpc-clients": "^5.1.12", + "@restorecommerce/service-config": "^1.0.10", "lodash": "^4.17.21", - "nconf": "^0.12.0", + "nconf": "^0.12.1", "node-eval": "^2.0.0", "redis": "^4.6.10", "winston": "^3.11.0" } }, "node_modules/@restorecommerce/chassis-srv": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@restorecommerce/chassis-srv/-/chassis-srv-1.4.0.tgz", - "integrity": "sha512-FZ0WUbUvtUq1RnV+iwsGYxYQ+5a58VhlVvgSDJ5dcsEl1SycNzcaXm8X+CLZRg5IlBddI8VbSqwjEyQBsSM/Bg==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@restorecommerce/chassis-srv/-/chassis-srv-1.4.4.tgz", + "integrity": "sha512-nNSyon6a6xKJX/sUhOK4vaSYKICJHyiHogue8DSKIj6XWCQdSkbo4zohj0VayLYkeV3XM4dUbEjCtYr4MX1L+Q==", "dependencies": { - "@grpc/grpc-js": "^1.9.5", - "@restorecommerce/grpc-client": "^2.0.4", - "@restorecommerce/kafka-client": "^1.1.3", - "@restorecommerce/logger": "^1.2.5", - "@restorecommerce/protos": "^6.1.2", - "@restorecommerce/rc-grpc-clients": "^5.1.3", - "@restorecommerce/service-config": "^1.0.7", - "arangojs": "^8.4.1", - "async": "^3.2.4", + "@grpc/grpc-js": "^1.9.11", + "@restorecommerce/grpc-client": "^2.0.8", + "@restorecommerce/kafka-client": "^1.1.12", + "@restorecommerce/logger": "^1.2.8", + "@restorecommerce/protos": "^6.4.1", + "@restorecommerce/rc-grpc-clients": "^5.1.12", + "@restorecommerce/service-config": "^1.0.10", + "arangojs": "^8.6.0", + "async": "^3.2.5", "async-retry": "^1.3.3", "cache-manager": "4.1.0", "cls-hooked": "^4.2.2", @@ -1343,15 +1343,27 @@ "lodash": "^4.17.21", "long": "^5.2.3", "nedb": "^1.8.0", - "nice-grpc": "^2.1.5", - "nice-grpc-server-reflection": "^2.0.7", + "nice-grpc": "^2.1.7", + "nice-grpc-server-reflection": "^2.0.9", "protobufjs": "^7.2.5", - "redis": "^4.6.10" + "redis": "^4.6.11" }, "engines": { "node": ">= 18.0.0" } }, + "node_modules/@restorecommerce/chassis-srv/node_modules/@grpc/grpc-js": { + "version": "1.9.11", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.9.11.tgz", + "integrity": "sha512-QDhMfbTROOXUhLHMroow8f3EHiCKUOh6UwxMP5S3EuXMnWMNSVIhatGZRwkpg9OUTYdZPsDUVH3cOAkWhGFUJw==", + "dependencies": { + "@grpc/proto-loader": "^0.7.8", + "@types/node": ">=12.12.47" + }, + "engines": { + "node": "^8.13.0 || >=10.10.0" + } + }, "node_modules/@restorecommerce/cluster-service": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@restorecommerce/cluster-service/-/cluster-service-1.0.2.tgz", @@ -1399,20 +1411,20 @@ } }, "node_modules/@restorecommerce/kafka-client": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/@restorecommerce/kafka-client/-/kafka-client-1.1.7.tgz", - "integrity": "sha512-+rTJwDuBboujkXU7+XSh693LYUuS0G9ySUtLpEI9FnvQ9FU1pZnnebjew6JpzU/dmJfSLN+8bEglNZxbU9Oi+g==", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/@restorecommerce/kafka-client/-/kafka-client-1.1.12.tgz", + "integrity": "sha512-8c5ApZZ8MYjM4bGSKDnh+tHAe6YHIWDiu6eoVYPwVtZEYTtsbjYozIwgCrwkoi4LeRnipe9UXSE+E7eKZxSGwA==", "dependencies": { - "@restorecommerce/logger": "^1.2.7", - "@restorecommerce/rc-grpc-clients": "^5.1.7", - "async": "^3.2.4", + "@restorecommerce/logger": "^1.2.8", + "@restorecommerce/rc-grpc-clients": "^5.1.12", + "async": "^3.2.5", "cls-rtracer": "^2.6.3", "events": "^3.3.0", "kafkajs": "^2.2.4", "lodash": "^4.17.21", "protobufjs": "^7.2.5", "retry": "^0.13.1", - "winston": "^3.10.0" + "winston": "^3.11.0" }, "engines": { "node": ">= 12.0.0" @@ -1435,14 +1447,14 @@ } }, "node_modules/@restorecommerce/protos": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/@restorecommerce/protos/-/protos-6.2.0.tgz", - "integrity": "sha512-nUK1WVbhrIlalCh3YSy5X9gQPL/gzQFQLdjDl6LYJ8EYt455HeiwLLgG5C2OzUUz7GAZOMPs6MhioD6qMkf0vA==" + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/@restorecommerce/protos/-/protos-6.4.1.tgz", + "integrity": "sha512-zOc3mx8phmO0s3K4toVUVP4I7Q5BXBRkiN21QdTciKDHO+/Yyh7BbL94puQrlWw2bmeRxYRiRjog+K8L23cULA==" }, "node_modules/@restorecommerce/rc-grpc-clients": { - "version": "5.1.10", - "resolved": "https://registry.npmjs.org/@restorecommerce/rc-grpc-clients/-/rc-grpc-clients-5.1.10.tgz", - "integrity": "sha512-tXgqaqBAVveKz93J1rCFASExYqMstB3yppDhCoOr4w/YKBw0F4xx4UtdLKPeiRHU01J3GL1l9dxDSKt1+hWYFw==", + "version": "5.1.12", + "resolved": "https://registry.npmjs.org/@restorecommerce/rc-grpc-clients/-/rc-grpc-clients-5.1.12.tgz", + "integrity": "sha512-Zly9ooJGbH+V43VNt5r/Gpm/aGcFluD51ibOczBZozZVxI/iEy7MaN54WbYv0EYzRH2euNJdqphDz616gA9Ckw==", "dependencies": { "@grpc/grpc-js": "^1.9.11", "@restorecommerce/grpc-client": "^2.0.8", @@ -1471,29 +1483,29 @@ } }, "node_modules/@restorecommerce/resource-base-interface": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@restorecommerce/resource-base-interface/-/resource-base-interface-1.4.0.tgz", - "integrity": "sha512-J/RYhjdDxr9OD83i/91Xxq8lyXwkNktH9tHptHaDyphFKNTZr/1KjoF2ZLs/ND89/BcF1JmoRxSJCBnFj4jsSQ==", - "dependencies": { - "@restorecommerce/chassis-srv": "^1.4.0", - "@restorecommerce/grpc-client": "^2.0.4", - "@restorecommerce/kafka-client": "^1.1.3", - "@restorecommerce/rc-grpc-clients": "^5.1.3", - "@restorecommerce/service-config": "^1.0.7", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@restorecommerce/resource-base-interface/-/resource-base-interface-1.4.4.tgz", + "integrity": "sha512-bZcM5DFtHsMTSt3T5C51CSA3QHoPrs0Zl+T6AKFsCexj5VL5JKoD1LoRKIr8P5m0Hi8hyHZQHIdOPTQ/poYgGQ==", + "dependencies": { + "@restorecommerce/chassis-srv": "^1.4.4", + "@restorecommerce/grpc-client": "^2.0.8", + "@restorecommerce/kafka-client": "^1.1.12", + "@restorecommerce/rc-grpc-clients": "^5.1.12", + "@restorecommerce/service-config": "^1.0.10", "lodash": "^4.17.21", - "redis": "^4.6.10" + "redis": "^4.6.11" }, "engines": { "node": ">= 18.8.0" } }, "node_modules/@restorecommerce/service-config": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@restorecommerce/service-config/-/service-config-1.0.9.tgz", - "integrity": "sha512-DGnPkpVan2W49Ud0r9+V36Ymbp8jycyP2RG9zAjs9KQXdzVgP5jxxhdjuGW0eJbTVKiJff4DitdXa0eH+v3Upg==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@restorecommerce/service-config/-/service-config-1.0.10.tgz", + "integrity": "sha512-5pq1ErGvV31vCiyK/UsJGe8gtZcjxBEVD7TT5/M22MNY8wsU3tB821f72kQo2QbgEwGK+ujBKIlY8hAAq4SldA==", "dependencies": { - "@restorecommerce/logger": "^1.2.7", - "nconf": "^0.12.0" + "@restorecommerce/logger": "^1.2.8", + "nconf": "^0.12.1" }, "engines": { "node": ">= 12.18.0" @@ -2067,9 +2079,9 @@ } }, "node_modules/arangojs": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/arangojs/-/arangojs-8.5.0.tgz", - "integrity": "sha512-aw9WC68Gxs/d1K0d5nsgHEI/DZG+0IRlZlAd5PafWD7BjNrQ1t0zdDwdRLYq66Wx8z7y5dZDEpWitHE1k4vHRg==", + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/arangojs/-/arangojs-8.6.0.tgz", + "integrity": "sha512-w5pNwYBmzFuOEt6Z1/D7frWpcuq/35UJ2Vpx7pQM2ERAQx44nd/OADfKfR09+hE7onC4czJiFSefd4Rup6ldJQ==", "dependencies": { "@types/node": ">=14", "multi-part": "^4.0.0", @@ -2187,9 +2199,9 @@ } }, "node_modules/async": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", - "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz", + "integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==" }, "node_modules/async-cache": { "version": "1.1.0", @@ -6911,9 +6923,9 @@ "dev": true }, "node_modules/nconf": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/nconf/-/nconf-0.12.0.tgz", - "integrity": "sha512-T3fZPw3c7Dfrz8JBQEbEcZJ2s8f7cUMpKuyBtsGQe0b71pcXx6gNh4oti2xh5dxB+gO9ufNfISBlGvvWtfyMcA==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/nconf/-/nconf-0.12.1.tgz", + "integrity": "sha512-p2cfF+B3XXacQdswUYWZ0w6Vld0832A/tuqjLBu3H1sfUcby4N2oVbGhyuCkZv+t3iY3aiFEj7gZGqax9Q2c1w==", "dependencies": { "async": "^3.0.0", "ini": "^2.0.0", @@ -6974,14 +6986,14 @@ } }, "node_modules/nice-grpc-server-reflection": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/nice-grpc-server-reflection/-/nice-grpc-server-reflection-2.0.7.tgz", - "integrity": "sha512-D4opxHl68DkfGvBPUTOfyGNLTR66u28RrI2xg+iPHZs9J6OPcDc+G95mMqOFbjZUowk1fqEF7l5JxmUEu7mWXQ==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/nice-grpc-server-reflection/-/nice-grpc-server-reflection-2.0.9.tgz", + "integrity": "sha512-Q15zy2+va4KjJbAro+IGL6zcJuXs1nlJNzXtYY2aoYprOVSLQhhtL7z/YymAkb9nWoLF9gZg0o1B/GXc31fD3A==", "dependencies": { - "@grpc/grpc-js": "^1.8.18", + "@grpc/grpc-js": "^1.9.5", "@types/google-protobuf": "^3.7.4", "google-protobuf": "^3.15.6", - "nice-grpc": "^2.1.5" + "nice-grpc": "^2.1.7" } }, "node_modules/nice-try": { @@ -8466,15 +8478,15 @@ "integrity": "sha512-2FoQ1xLzMwBiWmXFlpqTjjxLssz32e8hy1GegXf+VtYpoUuW8ohH+BH0SLq+r+Gc+SDI2xbVOMUF2tygHAwQ9A==" }, "node_modules/redis": { - "version": "4.6.10", - "resolved": "https://registry.npmjs.org/redis/-/redis-4.6.10.tgz", - "integrity": "sha512-mmbyhuKgDiJ5TWUhiKhBssz+mjsuSI/lSZNPI9QvZOYzWvYGejtb+W3RlDDf8LD6Bdl5/mZeG8O1feUGhXTxEg==", + "version": "4.6.11", + "resolved": "https://registry.npmjs.org/redis/-/redis-4.6.11.tgz", + "integrity": "sha512-kg1Lt4NZLYkAjPOj/WcyIGWfZfnyfKo1Wg9YKVSlzhFwxpFIl3LYI8BWy1Ab963LLDsTz2+OwdsesHKljB3WMQ==", "dependencies": { "@redis/bloom": "1.2.0", - "@redis/client": "1.5.11", - "@redis/graph": "1.1.0", + "@redis/client": "1.5.12", + "@redis/graph": "1.1.1", "@redis/json": "1.0.6", - "@redis/search": "1.1.5", + "@redis/search": "1.1.6", "@redis/time-series": "1.0.5" } }, diff --git a/package.json b/package.json index b3c238c..895f18c 100644 --- a/package.json +++ b/package.json @@ -17,15 +17,15 @@ "srv" ], "dependencies": { - "@restorecommerce/acs-client": "^1.3.0", - "@restorecommerce/chassis-srv": "^1.4.0", + "@restorecommerce/acs-client": "^1.4.2", + "@restorecommerce/chassis-srv": "^1.4.4", "@restorecommerce/cluster-service": "^1.0.2", - "@restorecommerce/grpc-client": "^2.0.7", - "@restorecommerce/kafka-client": "^1.1.7", - "@restorecommerce/logger": "^1.2.6", - "@restorecommerce/rc-grpc-clients": "^5.1.10", - "@restorecommerce/resource-base-interface": "^1.4.0", - "@restorecommerce/service-config": "^1.0.9", + "@restorecommerce/grpc-client": "^2.0.8", + "@restorecommerce/kafka-client": "^1.1.12", + "@restorecommerce/logger": "^1.2.8", + "@restorecommerce/rc-grpc-clients": "^5.1.12", + "@restorecommerce/resource-base-interface": "^1.4.4", + "@restorecommerce/service-config": "^1.0.10", "redis": "^4.6.7" }, "devDependencies": { diff --git a/src/service.ts b/src/service.ts index 9553a43..75a4625 100644 --- a/src/service.ts +++ b/src/service.ts @@ -14,7 +14,7 @@ import { DefaultACSClientContextFactory, injects_meta_data, Operation, - DefaultResourceFacorty, + DefaultResourceFactory, DefaultMetaDataInjector, } from '@restorecommerce/acs-client'; import { @@ -1198,7 +1198,7 @@ export class OrderingService action: AuthZAction.CREATE, operation: Operation.isAllowed, context: OrderingService.ACSContextFactory, - resource: DefaultResourceFacorty('order'), + resource: DefaultResourceFactory('order'), database: 'arangoDB', useCache: true, }) @@ -1220,7 +1220,7 @@ export class OrderingService action: AuthZAction.MODIFY, operation: Operation.isAllowed, context: OrderingService.ACSContextFactory, - resource: DefaultResourceFacorty('order'), + resource: DefaultResourceFactory('order'), database: 'arangoDB', useCache: true, }) @@ -1236,7 +1236,7 @@ export class OrderingService action: AuthZAction.MODIFY, operation: Operation.isAllowed, context: OrderingService.ACSContextFactory, - resource: DefaultResourceFacorty('order'), + resource: DefaultResourceFactory('order'), database: 'arangoDB', useCache: true, }) @@ -1283,7 +1283,7 @@ export class OrderingService action: AuthZAction.EXECUTE, operation: Operation.isAllowed, context: OrderingService.ACSContextFactory, - resource: DefaultResourceFacorty('execution.submitOrders'), + resource: DefaultResourceFactory('execution.submitOrders'), database: 'arangoDB', useCache: true, }) @@ -1404,17 +1404,22 @@ export class OrderingService response.fulfillments.forEach( fulfillment => { - const order = responseMap[fulfillment.payload?.reference?.instance_id]; - if (fulfillment.status?.code !== 200 && order) { - order.payload = { - ...order.payload, - order_state: OrderState.INVALID - }; - order.status = { - ...fulfillment.status, - id: order.payload?.id ?? order.status?.id, - }; - } + fulfillment.payload?.references?.forEach( + reference => { + const order = responseMap[reference.instance_id]; + if (fulfillment.status?.code !== 200 && order) { + order.payload = { + ...order.payload, + order_state: OrderState.INVALID + }; + order.status = { + ...fulfillment.status, + id: order.payload?.id ?? order.status?.id, + }; + } + } + ); + } ); } @@ -1480,7 +1485,9 @@ export class OrderingService if (this.cleanup_fulfillments_post_submit) { const failed_fulfillment_ids = response.fulfillments.filter( - fulfillment => fulfillment.payload?.reference.instance_id in failed_order_ids + fulfillment => fulfillment.payload?.references?.find( + reference => reference.instance_id in failed_order_ids + ) ).map( fulfillment => fulfillment.payload?.id ); @@ -1552,7 +1559,7 @@ export class OrderingService action: AuthZAction.EXECUTE, operation: Operation.isAllowed, context: OrderingService.ACSContextFactory, - resource: DefaultResourceFacorty('execution.withdrawOrder'), + resource: DefaultResourceFactory('execution.withdrawOrder'), database: 'arangoDB', useCache: true, }) @@ -1572,7 +1579,7 @@ export class OrderingService action: AuthZAction.EXECUTE, operation: Operation.isAllowed, context: OrderingService.ACSContextFactory, - resource: DefaultResourceFacorty('execution.cancelOrders'), + resource: DefaultResourceFactory('execution.cancelOrders'), database: 'arangoDB', useCache: true, }) @@ -1776,14 +1783,14 @@ export class OrderingService message: `Order ${item.order_id} not found!`, } as Status; - return { + const fulfillment: FulfillmentResponse = { payload: status?.code === 200 ? { - reference: { + references: [{ instance_type: this.instanceType, instance_id: item.order_id, - }, + }], packaging: { parcels: solution.solutions[0].parcels, notify: order.payload.notification_email, @@ -1796,7 +1803,9 @@ export class OrderingService total_amounts: solution.solutions[0].amounts, } : null, status, - } as FulfillmentResponse; + }; + + return fulfillment; } ); } @@ -1805,7 +1814,7 @@ export class OrderingService action: AuthZAction.EXECUTE, operation: Operation.isAllowed, context: OrderingService.ACSContextFactory, - resource: DefaultResourceFacorty('execution.createFulfillment'), + resource: DefaultResourceFactory('execution.createFulfillment'), database: 'arangoDB', useCache: true, }) @@ -1865,7 +1874,7 @@ export class OrderingService action: AuthZAction.EXECUTE, operation: Operation.isAllowed, context: OrderingService.ACSContextFactory, - resource: DefaultResourceFacorty('execution.triggerFulfillment'), + resource: DefaultResourceFactory('execution.triggerFulfillment'), database: 'arangoDB', useCache: true, }) diff --git a/src/worker.ts b/src/worker.ts index b8c95a1..5d4f23a 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -168,8 +168,9 @@ export class Worker { ); }, handleFulfillmentSubmitted: (msg: Fulfillment, context: any, config: any, eventName: string) => { - if (msg?.reference?.instance_type !== this.orderingService.instanceType) return; - const ids = [msg?.reference?.instance_id]; + const refs = msg?.references?.filter(ref => ref.instance_type === this.orderingService.instanceType); + if (!refs?.length) return; + const ids = refs?.map(ref => ref.instance_id); const subject = {} as Subject; // System Admin? return this.orderingService?.updateState(ids, OrderState.IN_PROCESS, subject, context).then( () => this.logger.info(`Event ${eventName} handled.`), @@ -177,8 +178,9 @@ export class Worker { ); }, handleFulfillmentInvalid: (msg: Fulfillment, context: any, config: any, eventName: string) => { - if (msg?.reference?.instance_type !== this.orderingService.instanceType) return; - const ids = [msg?.reference?.instance_id]; + const refs = msg?.references?.filter(ref => ref.instance_type === this.orderingService.instanceType); + if (!refs?.length) return; + const ids = refs?.map(ref => ref.instance_id); const subject = {} as Subject; // System Admin? return this.orderingService?.updateState(ids, OrderState.INVALID, subject, context).then( () => this.logger.info(`Event ${eventName} handled.`), @@ -186,8 +188,9 @@ export class Worker { ); }, handleFulfillmentFulfilled: (msg: Fulfillment, context: any, config: any, eventName: string) => { - if (msg?.reference?.instance_type !== this.orderingService.instanceType) return; - const ids = [msg?.reference?.instance_id]; + const refs = msg?.references?.filter(ref => ref.instance_type === this.orderingService.instanceType); + if (!refs?.length) return; + const ids = refs?.map(ref => ref.instance_id); const subject = {} as Subject; // System Admin? return this.orderingService?.updateState(ids, OrderState.DONE, subject, context).then( () => this.logger.info(`Event ${eventName} handled.`), @@ -195,8 +198,9 @@ export class Worker { ); }, handleFulfillmentFailed: (msg: Fulfillment, context: any, config: any, eventName: string) => { - if (msg?.reference?.instance_type !== this.orderingService.instanceType) return; - const ids = [msg?.reference?.instance_id]; + const refs = msg?.references?.filter(ref => ref.instance_type === this.orderingService.instanceType); + if (!refs?.length) return; + const ids = refs?.map(ref => ref.instance_id); const subject = {} as Subject; // System Admin? return this.orderingService?.updateState(ids, OrderState.FAILED, subject, context).then( () => this.logger.info(`Event ${eventName} handled.`), @@ -204,8 +208,9 @@ export class Worker { ); }, handleFulfillmentWithdrawn: (msg: Fulfillment, context: any, config: any, eventName: string) => { - if (msg?.reference?.instance_type !== this.orderingService.instanceType) return; - const ids = [msg?.reference.instance_id]; + const refs = msg?.references?.filter(ref => ref.instance_type === this.orderingService.instanceType); + if (!refs?.length) return; + const ids = refs?.map(ref => ref.instance_id); const subject = {} as Subject; // System Admin? return this.orderingService?.updateState(ids, OrderState.CANCELLED, subject, context).then( () => this.logger.info(`Event ${eventName} handled.`), @@ -213,8 +218,9 @@ export class Worker { ); }, handleFulfillmentCancelled: (msg: Fulfillment, context: any, config: any, eventName: string) => { - if (msg?.reference?.instance_type !== this.orderingService.instanceType) return; - const ids = [msg?.reference.instance_id]; + const refs = msg?.references?.filter(ref => ref.instance_type === this.orderingService.instanceType); + if (!refs?.length) return; + const ids = refs?.map(ref => ref.instance_id); const subject = {} as Subject; // System Admin? return this.orderingService?.updateState(ids, OrderState.CANCELLED, subject, context).then( () => this.logger.info(`Event ${eventName} handled.`), @@ -235,7 +241,12 @@ export class Worker { async start(cfg?: ServiceConfig, logger?: Logger): Promise { // Load config this._cfg = cfg = cfg ?? createServiceConfig(process.cwd()); - this.logger = logger = logger ?? createLogger(cfg.get('logger')); + const logger_cfg = cfg.get('logger') ?? {}; + logger_cfg.esTransformer = (msg: any) => { + msg.fields = JSON.stringify(msg.fields); + return msg; + }; + this.logger = logger = logger ?? createLogger(logger_cfg); // get database connection const db = await database.get(cfg.get('database:main'), logger);