diff --git a/README.md b/README.md index a643fba4..314aa23f 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,6 @@ Welcome to Adobe Commerce Integration Starter Kit. Integrating an e-commerce platform with your ERP, OMS, or CRM is a mission-critical requirement. Companies can spend tens of thousands of dollars building these integrations. To reduce the cost of integrating with Enterprise Resource Planning (ERP) solutions and to improve the reliability of real-time connections, Adobe is introducing an integration starter kit for back-office integrations using Adobe Developer App Builder. The kit includes reference integrations for commonly used commerce data like orders, products, and customers. It also includes a standardized architecture for developers to build on following best practices. -The public documentation can be found at [Adobe Developer Starter Kit docs](https://developer.adobe.com/commerce/extensibility/starter-kit/integration/). - ![Architecture Diagram](architecture.png "Architecture Diagram") ## Prerequisites @@ -328,6 +326,7 @@ The starter kit comes with predefined events for each entity. Sometimes, you may final: true ``` - Deploy the changes: `aio app deploy` +- Reinstall the application in App Management so the new event is wired up. With these steps, you can consume the new event you added to the project. If you want to change an existing event, make the changes in the same places: diff --git a/app.commerce.config.ts b/app.commerce.config.ts index 7059528c..c4d45cf7 100644 --- a/app.commerce.config.ts +++ b/app.commerce.config.ts @@ -23,8 +23,9 @@ export default defineConfig({ events: [ { name: "observer.catalog_product_delete_commit_after", - label: "Observer catalog product delete commit after", - description: "Observer catalog product delete commit after", + label: "Product Deleted", + description: + "Fires after a product is deleted in Commerce, used to sync the deletion to external systems", fields: [ field("id"), field("sku"), @@ -37,8 +38,9 @@ export default defineConfig({ }, { name: "observer.catalog_product_save_commit_after", - label: "Observer catalog product save commit after", - description: "Observer catalog product save commit after", + label: "Product Created or Updated", + description: + "Fires after a product is created or updated in Commerce, used to sync product changes to external systems", fields: [ field("id"), field("sku"), @@ -54,8 +56,9 @@ export default defineConfig({ }, { name: "observer.customer_save_commit_after", - label: "Observer customer save commit after", - description: "Observer customer save commit after", + label: "Customer Created or Updated", + description: + "Fires after a customer is created or updated in Commerce, used to sync customer changes to external systems", fields: [ field("id"), field("firstname"), @@ -71,8 +74,9 @@ export default defineConfig({ }, { name: "observer.customer_delete_commit_after", - label: "Observer customer delete commit after", - description: "Observer customer delete commit after", + label: "Customer Deleted", + description: + "Fires after a customer is deleted in Commerce, used to sync the deletion to external systems", fields: [ field("id"), field("firstname"), @@ -83,8 +87,9 @@ export default defineConfig({ }, { name: "observer.customer_group_save_commit_after", - label: "Observer customer group save commit after", - description: "Observer customer group save commit after", + label: "Customer Group Created or Updated", + description: + "Fires after a customer group is created or updated in Commerce, used to sync group changes to external systems", fields: [ field("customer_group_code"), field("tax_class_id"), @@ -95,8 +100,9 @@ export default defineConfig({ }, { name: "observer.customer_group_delete_commit_after", - label: "Observer customer group delete commit after", - description: "Observer customer group delete commit after", + label: "Customer Group Deleted", + description: + "Fires after a customer group is deleted in Commerce, used to sync the deletion to external systems", fields: [ field("customer_group_code"), field("customer_group_id"), @@ -106,8 +112,9 @@ export default defineConfig({ }, { name: "observer.sales_order_save_commit_after", - label: "Observer sales order save commit after", - description: "Observer sales order save commit after", + label: "Sales Order Created or Updated", + description: + "Fires after a sales order is created or updated in Commerce, used to sync order changes to external systems", fields: [ field("id"), field("increment_id"), @@ -121,9 +128,9 @@ export default defineConfig({ }, { name: "observer.cataloginventory_stock_item_save_commit_after", - label: "Observer cataloginventory stock item save commit after", + label: "Stock Item Updated", description: - "Observer cataloginventory stock item save commit after", + "Fires after inventory data for a stock item is created or updated in Commerce, used to sync stock levels to external systems", fields: [ field("item_id"), field("product_id"), @@ -172,80 +179,93 @@ export default defineConfig({ events: [ { name: "be-observer.catalog_product_create", - label: "Be observer catalog product create", - description: "Be observer catalog product create", + label: "Backoffice Product Created", + description: + "Notifies Commerce that a product was created in the backoffice system", runtimeActions: ["product-backoffice/created"], }, { name: "be-observer.catalog_product_update", - label: "Be observer catalog product update", - description: "Be observer catalog product update", + label: "Backoffice Product Updated", + description: + "Notifies Commerce that a product was updated in the backoffice system", runtimeActions: ["product-backoffice/updated"], }, { name: "be-observer.catalog_product_delete", - label: "Be observer catalog product delete", - description: "Be observer catalog product delete", + label: "Backoffice Product Deleted", + description: + "Notifies Commerce that a product was deleted in the backoffice system", runtimeActions: ["product-backoffice/deleted"], }, { name: "be-observer.customer_create", - label: "Be observer customer create", - description: "Be observer customer create", + label: "Backoffice Customer Created", + description: + "Notifies Commerce that a customer was created in the backoffice system", runtimeActions: ["customer-backoffice/created"], }, { name: "be-observer.customer_update", - label: "Be observer customer update", - description: "Be observer customer update", + label: "Backoffice Customer Updated", + description: + "Notifies Commerce that a customer was updated in the backoffice system", runtimeActions: ["customer-backoffice/updated"], }, { name: "be-observer.customer_delete", - label: "Be observer customer delete", - description: "Be observer customer delete", + label: "Backoffice Customer Deleted", + description: + "Notifies Commerce that a customer was deleted in the backoffice system", runtimeActions: ["customer-backoffice/deleted"], }, { name: "be-observer.customer_group_create", - label: "Be observer customer group create", - description: "Be observer customer group create", + label: "Backoffice Customer Group Created", + description: + "Notifies Commerce that a customer group was created in the backoffice system", runtimeActions: ["customer-backoffice/group-created"], }, { name: "be-observer.customer_group_update", - label: "Be observer customer group update", - description: "Be observer customer group update", + label: "Backoffice Customer Group Updated", + description: + "Notifies Commerce that a customer group was updated in the backoffice system", runtimeActions: ["customer-backoffice/group-updated"], }, { name: "be-observer.customer_group_delete", - label: "Be observer customer group delete", - description: "Be observer customer group delete", + label: "Backoffice Customer Group Deleted", + description: + "Notifies Commerce that a customer group was deleted in the backoffice system", runtimeActions: ["customer-backoffice/group-deleted"], }, { name: "be-observer.sales_order_status_update", - label: "Be observer sales order status update", - description: "Be observer sales order status update", + label: "Backoffice Order Status Updated", + description: + "Notifies Commerce that a sales order status was updated in the backoffice system", runtimeActions: ["order-backoffice/updated"], }, { name: "be-observer.sales_order_shipment_create", - label: "Be observer sales order shipment create", - description: "Be observer sales order shipment create", + label: "Backoffice Order Shipment Created", + description: + "Notifies Commerce that a shipment was created for a sales order in the backoffice system", runtimeActions: ["order-backoffice/shipment-created"], }, { name: "be-observer.sales_order_shipment_update", - label: "Be observer sales order shipment update", - description: "Be observer sales order shipment update", + label: "Backoffice Order Shipment Updated", + description: + "Notifies Commerce that a shipment was updated for a sales order in the backoffice system", runtimeActions: ["order-backoffice/shipment-updated"], }, { name: "be-observer.catalog_stock_update", - label: "Be observer catalog stock update", - description: "Be observer catalog stock update", + label: "Backoffice Stock Updated", + description: + "Notifies Commerce that stock levels were updated in the backoffice system", runtimeActions: ["stock-backoffice/updated"], }, ], diff --git a/package-lock.json b/package-lock.json index 1dafee2e..970c6452 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,8 @@ "dependencies": { "@adobe/aio-commerce-lib-app": "^1.8.0-beta-20260714082406", "@adobe/aio-commerce-sdk": "^1.4.0-beta-20260714082406", + "@adobe/aio-lib-core-logging": "^3.0.2", "@adobe/aio-lib-telemetry": "^1.0.0", - "@adobe/aio-sdk": "^6.0.0", "ajv": "^8.16.0", "graphql-request": "^7.1.2" }, @@ -261,47 +261,6 @@ } } }, - "node_modules/@adobe/aio-lib-analytics": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@adobe/aio-lib-analytics/-/aio-lib-analytics-4.0.2.tgz", - "integrity": "sha512-/arNqy84uKTTgd99sf2ANejiIuka31T2x8eH8hkdnozGl4nuuhnRqYKI+BnrEet017aha7s/FbNe3rUdNs4a2Q==", - "dependencies": { - "@adobe/aio-lib-core-errors": "^4", - "@adobe/aio-lib-core-logging": "^3", - "swagger-client": "^3.35.6" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@adobe/aio-lib-campaign-standard": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@adobe/aio-lib-campaign-standard/-/aio-lib-campaign-standard-4.0.3.tgz", - "integrity": "sha512-ZP6MO5inVM3QVEOj9GoBXkeM/xoFDlRUN8O0GSawxZAfUU25hDwqNz37r+ZJ4xvGz9TfEKDZFVZjYJKYefn+tw==", - "license": "Apache-2.0", - "dependencies": { - "@adobe/aio-lib-core-errors": "^4", - "@adobe/aio-lib-core-logging": "^3", - "@adobe/aio-lib-core-networking": "^5", - "swagger-client": "^3.36.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@adobe/aio-lib-core-auth": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@adobe/aio-lib-core-auth/-/aio-lib-core-auth-1.1.0.tgz", - "integrity": "sha512-q+o/xHXdJaH4tcLlfiklQWF3LNrlerCdPKhci0svpcDjV3QuTr8eeXf8C+gOhyxhqM60TQt1kDzfKMkiMN3P8Q==", - "license": "Apache-2.0", - "dependencies": { - "@adobe/aio-lib-core-errors": "^4.0.0", - "@isaacs/ttlcache": "^2.1.4" - }, - "engines": { - "node": ">=20" - } - }, "node_modules/@adobe/aio-lib-core-config": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@adobe/aio-lib-core-config/-/aio-lib-core-config-5.0.1.tgz", @@ -387,36 +346,6 @@ "node": ">=18" } }, - "node_modules/@adobe/aio-lib-customer-profile": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@adobe/aio-lib-customer-profile/-/aio-lib-customer-profile-3.0.2.tgz", - "integrity": "sha512-me1VM2RJzT2TwW6U74dDKqjAvh/IudZEHUcECwYN/WtcN8kbn2cuW5QB5e8SY7b6yVV52hovzpaJirW2MnKfhA==", - "license": "Apache-2.0", - "dependencies": { - "@adobe/aio-lib-core-errors": "^4", - "@adobe/aio-lib-core-logging": "^3", - "change-case": "^4.1.1", - "swagger-client": "^3.35.6", - "uuid": "^9.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@adobe/aio-lib-customer-profile/node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/@adobe/aio-lib-env": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@adobe/aio-lib-env/-/aio-lib-env-3.0.1.tgz", @@ -430,27 +359,6 @@ "node": ">=18" } }, - "node_modules/@adobe/aio-lib-events": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@adobe/aio-lib-events/-/aio-lib-events-4.1.0.tgz", - "integrity": "sha512-pLuDYtFBTpmKq6zRwXtkwJb6yJMMbCpqVsX4kCAiC2QZWjo/IulhLL86s4kXUAsh+YaA1TyY6YMaW2ck6b3FpA==", - "license": "Apache-2.0", - "dependencies": { - "@adobe/aio-lib-core-errors": "^4", - "@adobe/aio-lib-core-logging": "^3", - "@adobe/aio-lib-core-networking": "^5", - "@adobe/aio-lib-env": "^3", - "@adobe/aio-lib-state": "^5.3.1", - "crypto-js": "^4.0.0", - "http-link-header": "^1.0.2", - "node-fetch": "^2.6.0", - "rxjs": "^7.8.1", - "valid-url": "^1.0.9" - }, - "engines": { - "node": ">=20" - } - }, "node_modules/@adobe/aio-lib-files": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/@adobe/aio-lib-files/-/aio-lib-files-4.1.4.tgz", @@ -606,19 +514,6 @@ "node": ">=18" } }, - "node_modules/@adobe/aio-lib-target": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@adobe/aio-lib-target/-/aio-lib-target-4.0.3.tgz", - "integrity": "sha512-6AyK8llC+LjN7W+ERYZ8zwN21YQjw9bbAzVkgigHiCQPJF0ElmUyv/wsCOyIr6WX2tZd8fRjWlBgSKujV9OZ7w==", - "dependencies": { - "@adobe/aio-lib-core-errors": "^4", - "@adobe/aio-lib-core-logging": "^3", - "swagger-client": "^3.36.2" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/@adobe/aio-lib-telemetry": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@adobe/aio-lib-telemetry/-/aio-lib-telemetry-1.2.0.tgz", @@ -658,39 +553,6 @@ "node": ">=22 <=24" } }, - "node_modules/@adobe/aio-sdk": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@adobe/aio-sdk/-/aio-sdk-6.0.0.tgz", - "integrity": "sha512-PR9it0eHqI9BsNjG0tmkjt27JZ7qGj7JiIDsUbIdmc7fqvu+4uXnC+XjK558h5+Ll7QQN9ETKr56YS/V546Wkw==", - "license": "Apache-2.0", - "dependencies": { - "@adobe/aio-lib-analytics": "^4", - "@adobe/aio-lib-campaign-standard": "^4", - "@adobe/aio-lib-customer-profile": "^3", - "@adobe/aio-lib-events": "^4", - "@adobe/aio-lib-files": "^4", - "@adobe/aio-lib-state": "^5", - "@adobe/aio-lib-target": "^4", - "@adobe/aio-sdk-core": "^3" - } - }, - "node_modules/@adobe/aio-sdk-core": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@adobe/aio-sdk-core/-/aio-sdk-core-3.1.0.tgz", - "integrity": "sha512-e1szymczBPcwNdOfBtOg05NRe6Xh+OGse5OYzuGnH5BgboYokd1W9njg/GoaZHgmT/IxYtOXPpg4ecstwqIXFw==", - "license": "Apache-2.0", - "dependencies": { - "@adobe/aio-lib-core-auth": "^1", - "@adobe/aio-lib-core-config": "^5", - "@adobe/aio-lib-core-errors": "^4", - "@adobe/aio-lib-core-logging": "^3", - "@adobe/aio-lib-core-networking": "^5", - "@adobe/aio-lib-core-tvm": "^4" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/@adobe/exc-app": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/@adobe/exc-app/-/exc-app-1.6.2.tgz", @@ -1224,18 +1086,6 @@ "node": ">=6.0.0" } }, - "node_modules/@babel/runtime-corejs3": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.29.7.tgz", - "integrity": "sha512-ppj9ouYku+RX0ljtgZd+KMO5mkM2bCqg8H2PYAFWnLsHEIKIdRojqbJ2i3eVHrisuxy7nOFCmngTDdWtUCdXUQ==", - "license": "MIT", - "dependencies": { - "core-js-pure": "^3.48.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/template": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", @@ -2102,15 +1952,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/@isaacs/ttlcache": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@isaacs/ttlcache/-/ttlcache-2.1.5.tgz", - "integrity": "sha512-VwGZqqjAWPICTmxUZnbpEfO60LhPWzquik+bmyXGY7pYRn6diEvCI5i6Ca+J6o2y4vS73HrpuMTo2dOvUevH8w==", - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=12" - } - }, "node_modules/@istanbuljs/schema": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", @@ -4670,13 +4511,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@scarf/scarf": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@scarf/scarf/-/scarf-1.4.0.tgz", - "integrity": "sha512-xxeapPiUXdZAE3che6f3xogoJPeZgig6omHEy1rIY5WVsB3H2BHNnZH+gHG6x91SCWyQCzWGsuL2Hh3ClO5/qQ==", - "hasInstallScript": true, - "license": "Apache-2.0" - }, "node_modules/@sideway/address": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.5.tgz", @@ -4693,686 +4527,27 @@ "license": "BSD-3-Clause" }, "node_modules/@sideway/pinpoint": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz", - "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==", - "license": "BSD-3-Clause" - }, - "node_modules/@so-ric/colorspace": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/@so-ric/colorspace/-/colorspace-1.1.6.tgz", - "integrity": "sha512-/KiKkpHNOBgkFJwu9sh48LkHSMYGyuTcSFK/qMBdnOAlrRJzRSXAOFB5qwzaVQuDl8wAvHVMkaASQDReTahxuw==", - "license": "MIT", - "dependencies": { - "color": "^5.0.2", - "text-hex": "1.0.x" - } - }, - "node_modules/@standard-schema/spec": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", - "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", - "license": "MIT" - }, - "node_modules/@swagger-api/apidom-ast": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ast/-/apidom-ast-1.11.3.tgz", - "integrity": "sha512-Nfi/0vy+cIHClX7raXamtHnCMBbwI1PEg+yroIzyy8LcCH7zcS0Xi4ARG3CkDQswOnWO2gLDAUAFjDvkQWdZ+A==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-error": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "unraw": "^3.0.0" - } - }, - "node_modules/@swagger-api/apidom-core": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-core/-/apidom-core-1.11.3.tgz", - "integrity": "sha512-21/PXEqCzsWkiwKWHt0TPJE7GUtog3BhMlvYLUEPbteXOrk+PNazbjYDPl4zfZGRLaoGhTqpFBY5pXafdzaHWQ==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-ast": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@types/ramda": "~0.30.0", - "minim": "~0.23.8", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "short-unique-id": "^5.3.2", - "ts-mixer": "^6.0.3" - } - }, - "node_modules/@swagger-api/apidom-error": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-error/-/apidom-error-1.11.3.tgz", - "integrity": "sha512-Z4mIDyZUF2kDFHBzKsxkYSaHpGSvGDc7gAkdzLKxcQk4849iCUXxs0PpQLxZxfYcmUSwkw7AZmIP/OKGpsR8JA==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.20.7" - } - }, - "node_modules/@swagger-api/apidom-json-pointer": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-json-pointer/-/apidom-json-pointer-1.11.3.tgz", - "integrity": "sha512-z6eEvJ5HIb0aFqVldHyU5Guut+bv/opu28i+rrfDb1LEG3IWk5T3DbW9d/nWpAfNze/bjwiZvPphmkuycijb2w==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@swaggerexpert/json-pointer": "^2.10.1" - } - }, - "node_modules/@swagger-api/apidom-ns-api-design-systems": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-api-design-systems/-/apidom-ns-api-design-systems-1.11.3.tgz", - "integrity": "sha512-HTISScqScdnUc2BKqMaWM+ISU79AlHlr+XHUR9g0R8QiO4KzCkWUi6TncP0gvGoEY+BvfR0OkztfxYrelkksmg==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-1": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.3" - } - }, - "node_modules/@swagger-api/apidom-ns-arazzo-1": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-arazzo-1/-/apidom-ns-arazzo-1-1.11.3.tgz", - "integrity": "sha512-AHRSbuYy5oA8c/7j7nahxMASjt0cuOWyUk4yu+cKG+KS85ho2f2NiFThqQjtIJLisvrp+qNniJ1EwTfcCTivTQ==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-json-schema-2020-12": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.3" - } - }, - "node_modules/@swagger-api/apidom-ns-asyncapi-2": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-asyncapi-2/-/apidom-ns-asyncapi-2-1.11.3.tgz", - "integrity": "sha512-bn/Pf52SCsSGcw7qO3gAje+KjhhpWJxWjjWQe5Jv9oPoXCnvGoSspSXMY3zIrhz9XfrP94AdWBUpOlWBoaaDBQ==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-json-schema-draft-7": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.3" - } - }, - "node_modules/@swagger-api/apidom-ns-asyncapi-3": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-asyncapi-3/-/apidom-ns-asyncapi-3-1.11.3.tgz", - "integrity": "sha512-QhZtf8YeMRVtgVioJj0qKdNG0LEzi9RPSrC9KWfCdwEBlkhNDhHFh6FIJWayYAwR6DPlOXjTYQf97V9QwIuRmQ==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-asyncapi-2": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.3" - } - }, - "node_modules/@swagger-api/apidom-ns-json-schema-2019-09": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-json-schema-2019-09/-/apidom-ns-json-schema-2019-09-1.11.3.tgz", - "integrity": "sha512-zHA4/oin6Fg6VN0bWmMRu1nt4Xnd05mF5T+Od6vEmid1bxDXpfSSMaPpdu+WCBJ5dDX19EeBVTJoAI0U4psxBg==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@swagger-api/apidom-ns-json-schema-draft-7": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.4" - } - }, - "node_modules/@swagger-api/apidom-ns-json-schema-2020-12": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-json-schema-2020-12/-/apidom-ns-json-schema-2020-12-1.11.3.tgz", - "integrity": "sha512-zUWRb5DlvlZXtf2JmiNqUwwgGc4eUAsUQPU59kP140vkPT98HDhNJx9UXoHLgP5F/Zk8f2rzeG237u+JnCT9/g==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@swagger-api/apidom-ns-json-schema-2019-09": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.4" - } - }, - "node_modules/@swagger-api/apidom-ns-json-schema-draft-4": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-json-schema-draft-4/-/apidom-ns-json-schema-draft-4-1.11.3.tgz", - "integrity": "sha512-udOM8ZQT7BzsyT9012R7/VjeazjOlyLwKpmpbgHZDG6uGHqsnWn9lN+F8/5Eox9qqBnQNqDNtDhBEMYjE6RYNQ==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-ast": "^1.11.3", - "@swagger-api/apidom-core": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.4" - } - }, - "node_modules/@swagger-api/apidom-ns-json-schema-draft-6": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-json-schema-draft-6/-/apidom-ns-json-schema-draft-6-1.11.3.tgz", - "integrity": "sha512-ZOgo5OtpQ6e5XQ5R1H8CYTYXEtnD0l+FyN065A6c2O1NxJXFKS2a5SZTvx+udA4mugtkTSmr7hAQe2ae+KAXQw==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@swagger-api/apidom-ns-json-schema-draft-4": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.4" - } - }, - "node_modules/@swagger-api/apidom-ns-json-schema-draft-7": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-json-schema-draft-7/-/apidom-ns-json-schema-draft-7-1.11.3.tgz", - "integrity": "sha512-L5Sc0qMUrUbgVex3fN+tnNHjed/JCAwpwyzdHY8KgUfXHkfM5aLUyyAGirm+ObwZvGDEejsTT2Otp6B5S29eqw==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@swagger-api/apidom-ns-json-schema-draft-6": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.4" - } - }, - "node_modules/@swagger-api/apidom-ns-openapi-2": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-openapi-2/-/apidom-ns-openapi-2-1.11.3.tgz", - "integrity": "sha512-T241UD+1My1hVJHayTCz9f7rznmeM8rxQW4NtUnD8k677SShpnNkrfeoc1elrpJXdTsnEPIOLCK0EEIyEplHgA==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@swagger-api/apidom-ns-json-schema-draft-4": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.3" - } - }, - "node_modules/@swagger-api/apidom-ns-openapi-3-0": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-openapi-3-0/-/apidom-ns-openapi-3-0-1.11.3.tgz", - "integrity": "sha512-FZvBqWpZFciemMgWBGY89RIH5uLl6ZYtmMAhWzDcmEi1JSjmWKkoqZno//KlqSgbI09gbkzipdMjGK825givPA==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@swagger-api/apidom-ns-json-schema-draft-4": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.3" - } - }, - "node_modules/@swagger-api/apidom-ns-openapi-3-1": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-openapi-3-1/-/apidom-ns-openapi-3-1-1.11.3.tgz", - "integrity": "sha512-ObCP+l3/ZhuPaSqXqmSnCpEOIMalQns0c4IZgX6h3o7Jc6K6BcqDMeq4s17dwcQja9fFUtkoIIFuquJBKvK86Q==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-ast": "^1.11.3", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-json-pointer": "^1.11.3", - "@swagger-api/apidom-ns-json-schema-2020-12": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-0": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.3" - } - }, - "node_modules/@swagger-api/apidom-ns-openapi-3-2": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-ns-openapi-3-2/-/apidom-ns-openapi-3-2-1.11.3.tgz", - "integrity": "sha512-Ri7KLrfrpJeteghUdzbozxKve2NG5Z1aPWX91DI14j75+v/xBAu91AIZt7K+LV8JWUNk+VbhUlhgSH1JAIVa0g==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-ast": "^1.11.3", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-json-pointer": "^1.11.3", - "@swagger-api/apidom-ns-json-schema-2020-12": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-0": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-1": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "ts-mixer": "^6.0.3" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-api-design-systems-json": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-api-design-systems-json/-/apidom-parser-adapter-api-design-systems-json-1.11.3.tgz", - "integrity": "sha512-6LcwiY2Ce1qmsq8CSxCoRMJ3q2quFnEsNgI48LpM9/PYK/idjsB/WrnU9xSl9fXm/aTo/bOO0ckc8KadxVykfA==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-api-design-systems": "^1.11.3", - "@swagger-api/apidom-parser-adapter-json": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-api-design-systems-yaml": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-api-design-systems-yaml/-/apidom-parser-adapter-api-design-systems-yaml-1.11.3.tgz", - "integrity": "sha512-zk2NuWAOvjEHYQ3lZ43VhAqJk+9KK452HeFfZFne4a4iALhCQ/wceK7tCG81jBMMoWnR0f1JS/vxz7/Y2CNwLA==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-api-design-systems": "^1.11.3", - "@swagger-api/apidom-parser-adapter-yaml-1-2": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-arazzo-json-1": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-arazzo-json-1/-/apidom-parser-adapter-arazzo-json-1-1.11.3.tgz", - "integrity": "sha512-vXP6lYp6Q5/5nLkMJyBRTWYIZYxL6GnOsJsdnN0KdTHuoPXNZWsv5p2oPYlVE/W7gRAZDylUmYZQ1L9rr7BGRw==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-arazzo-1": "^1.11.3", - "@swagger-api/apidom-parser-adapter-json": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-arazzo-yaml-1": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-arazzo-yaml-1/-/apidom-parser-adapter-arazzo-yaml-1-1.11.3.tgz", - "integrity": "sha512-zI57Q5DIf7TGv1A2gIk3umbPWMEFWYO3tEmfP0xJGDBn6gZRHgJvvVjn0wQrljigEEw1V3hRDUXk6Zzg3oVNvA==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-arazzo-1": "^1.11.3", - "@swagger-api/apidom-parser-adapter-yaml-1-2": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-asyncapi-json-2": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-asyncapi-json-2/-/apidom-parser-adapter-asyncapi-json-2-1.11.3.tgz", - "integrity": "sha512-VGl15mpHaL+SlsXaRvcVaWXir+pCLrj99QN//Kuir3cpPW6P9IdBztj11bjoIG3aX1bOIrU16/uOhV4G5J4Kag==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-asyncapi-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-json": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-asyncapi-json-3": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-asyncapi-json-3/-/apidom-parser-adapter-asyncapi-json-3-1.11.3.tgz", - "integrity": "sha512-37dNwdLAcAd7TZW8YqSbpuBoujfoM2AvXBoT1BUxzbYetwNkxP19Q1VtCEAzMxUEQ/9niBANSzuo0zClUEc2kw==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-asyncapi-3": "^1.11.3", - "@swagger-api/apidom-parser-adapter-json": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-asyncapi-yaml-2": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-asyncapi-yaml-2/-/apidom-parser-adapter-asyncapi-yaml-2-1.11.3.tgz", - "integrity": "sha512-MEZHn+qROKehrXLhDhl7kSQADXjwU2NGSeNuBTr1/nINShpu4Tkxrk7xT0LY8GauKrZR9MyAnueATDQgK8NWhQ==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-asyncapi-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-yaml-1-2": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-asyncapi-yaml-3": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-asyncapi-yaml-3/-/apidom-parser-adapter-asyncapi-yaml-3-1.11.3.tgz", - "integrity": "sha512-qHOK0NXnG7t5Gx0xCIbyfrM5FXLgK6krlZRPlrlT6K853MWWWWmjAieuayPtu72Ak1hd/8U2/oWgbONnPqj76w==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-asyncapi-3": "^1.11.3", - "@swagger-api/apidom-parser-adapter-yaml-1-2": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-json": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-json/-/apidom-parser-adapter-json-1.11.3.tgz", - "integrity": "sha512-Wj/DTb6mblsaxKfye9kXLwS+KmWWLAM2M2oSs4muOclhAOtcffr2H+STtiT3Hwrzb+cW8RpX6Htvey4rvbj/Jg==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-ast": "^1.11.3", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "tree-sitter": "=0.21.1", - "tree-sitter-json": "=0.24.8", - "web-tree-sitter": "=0.24.5" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-openapi-json-2": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-openapi-json-2/-/apidom-parser-adapter-openapi-json-2-1.11.3.tgz", - "integrity": "sha512-aDR5vKSApqQgDkvJNJZqvp8slEWHGByz5bzDbw6ZHRPSIZcA2IEHdJPgWJVS5gNtJ+YAnA7veM39oqeoF2yy8w==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-openapi-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-json": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-openapi-json-3-0": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-openapi-json-3-0/-/apidom-parser-adapter-openapi-json-3-0-1.11.3.tgz", - "integrity": "sha512-hpSBiaVG7qbyJy25/Pl48NCT9uvvsOPAAj+xCAb9TwmIPBcFkVYvj6ZWJbYZsOmzUzcNLOZEOBjRNPN3G31zmQ==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-0": "^1.11.3", - "@swagger-api/apidom-parser-adapter-json": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-openapi-json-3-1": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-openapi-json-3-1/-/apidom-parser-adapter-openapi-json-3-1-1.11.3.tgz", - "integrity": "sha512-EP7U25s5We8Q/2olymVrJL2nKT+skTea6SnR8F3OETsBoef3i1XgQx7AHqUc9S83hp+bOxZ+oPyI6dNwO+J+MA==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-1": "^1.11.3", - "@swagger-api/apidom-parser-adapter-json": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-openapi-json-3-2": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-openapi-json-3-2/-/apidom-parser-adapter-openapi-json-3-2-1.11.3.tgz", - "integrity": "sha512-WLuMb0pwH+5hjosRHGvUFLm9iWP0/XNnEdrwdUio4y0eodjDwrPGb2LSdH3zaR8p7mKrqe007jqpjaLLsStzrQ==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-json": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-openapi-yaml-2": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-openapi-yaml-2/-/apidom-parser-adapter-openapi-yaml-2-1.11.3.tgz", - "integrity": "sha512-PyD0E4fwOhOCcP/Aqa9HlvZYuw825E6N0IRC69dxxt6Fy6w6Fv2KYRnRw8OINoog8I6/8uSZOLdeDla3FCqhFA==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-openapi-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-yaml-1-2": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-openapi-yaml-3-0/-/apidom-parser-adapter-openapi-yaml-3-0-1.11.3.tgz", - "integrity": "sha512-7ULkLaEAAVKRNWT525PdKOaUjrZ7G2ulH9VBsMJ9niaZN/n6hnSW8IR4Iaf0cLZ1MjsZsdWovq5slPz2hpqR4A==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-0": "^1.11.3", - "@swagger-api/apidom-parser-adapter-yaml-1-2": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-openapi-yaml-3-1": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-openapi-yaml-3-1/-/apidom-parser-adapter-openapi-yaml-3-1-1.11.3.tgz", - "integrity": "sha512-2VqxGS0PaNrYeLgGyOl9m4m6EbJjrtxOswzWK2Rk3/M3gEDfnFdyOVffKWlcdEv6XFJ+wgLy5MPlODrzyOOKCA==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-1": "^1.11.3", - "@swagger-api/apidom-parser-adapter-yaml-1-2": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-openapi-yaml-3-2": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-openapi-yaml-3-2/-/apidom-parser-adapter-openapi-yaml-3-2-1.11.3.tgz", - "integrity": "sha512-fRJYMozAyIJP46kKbUPQX2wIzfX9FSC7ZxUn+VWOa587f3zZC3XmydGO46GA/TGuc8cWs7AFD/EfSKWDbsB3Tg==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-yaml-1-2": "^1.11.3", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-yaml-1-2": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-parser-adapter-yaml-1-2/-/apidom-parser-adapter-yaml-1-2-1.11.3.tgz", - "integrity": "sha512-mSPMfVzDkLC+HPDI/6ho8TxI1PEcDJl/Y53gZdmfCU1xYzUdOF4s0iHalHHt0ipxYpt0EQXD+oGBnpp/TTx4IQ==", - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-ast": "^1.11.3", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@tree-sitter-grammars/tree-sitter-yaml": "=0.7.1", - "@types/ramda": "~0.30.0", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0", - "tree-sitter": "=0.22.4", - "web-tree-sitter": "=0.24.5" - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-yaml-1-2/node_modules/@tree-sitter-grammars/tree-sitter-yaml": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@tree-sitter-grammars/tree-sitter-yaml/-/tree-sitter-yaml-0.7.1.tgz", - "integrity": "sha512-AynBwkIoQCTgjDR33bDUp9Mqq+YTco0is3n5hRApMqG9of/6A4eQsfC1/uSEeHSUyMQSYawcAWamsexnVpIP4Q==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "dependencies": { - "node-addon-api": "^8.3.1", - "node-gyp-build": "^4.8.4" - }, - "peerDependencies": { - "tree-sitter": "^0.22.4" - }, - "peerDependenciesMeta": { - "tree-sitter": { - "optional": true - } - } - }, - "node_modules/@swagger-api/apidom-parser-adapter-yaml-1-2/node_modules/tree-sitter": { - "version": "0.22.4", - "resolved": "https://registry.npmjs.org/tree-sitter/-/tree-sitter-0.22.4.tgz", - "integrity": "sha512-usbHZP9/oxNsUY65MQUsduGRqDHQOou1cagUSwjhoSYAmSahjQDAVsh9s+SlZkn8X8+O1FULRGwHu7AFP3kjzg==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "dependencies": { - "node-addon-api": "^8.3.0", - "node-gyp-build": "^4.8.4" - } - }, - "node_modules/@swagger-api/apidom-reference": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@swagger-api/apidom-reference/-/apidom-reference-1.11.3.tgz", - "integrity": "sha512-Y0J+pAru/Est0wQJlFeQq2AsWyboOJP456Zv2wV4m0Ib1QY6N2wWiL6clkHpHA0pughemN6gcjBeNlMeRGqXuw==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.26.10", - "@swagger-api/apidom-core": "^1.11.3", - "@swagger-api/apidom-error": "^1.11.3", - "@types/ramda": "~0.30.0", - "axios": "^1.16.0", - "minimatch": "^10.2.1", - "ramda": "~0.30.0", - "ramda-adjunct": "^5.0.0" - }, - "optionalDependencies": { - "@swagger-api/apidom-json-pointer": "^1.11.3", - "@swagger-api/apidom-ns-arazzo-1": "^1.11.3", - "@swagger-api/apidom-ns-asyncapi-2": "^1.11.3", - "@swagger-api/apidom-ns-openapi-2": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-0": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-1": "^1.11.3", - "@swagger-api/apidom-ns-openapi-3-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-api-design-systems-json": "^1.11.3", - "@swagger-api/apidom-parser-adapter-api-design-systems-yaml": "^1.11.3", - "@swagger-api/apidom-parser-adapter-arazzo-json-1": "^1.11.3", - "@swagger-api/apidom-parser-adapter-arazzo-yaml-1": "^1.11.3", - "@swagger-api/apidom-parser-adapter-asyncapi-json-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-asyncapi-json-3": "^1.11.3", - "@swagger-api/apidom-parser-adapter-asyncapi-yaml-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-asyncapi-yaml-3": "^1.11.3", - "@swagger-api/apidom-parser-adapter-json": "^1.11.3", - "@swagger-api/apidom-parser-adapter-openapi-json-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-openapi-json-3-0": "^1.11.3", - "@swagger-api/apidom-parser-adapter-openapi-json-3-1": "^1.11.3", - "@swagger-api/apidom-parser-adapter-openapi-json-3-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-openapi-yaml-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": "^1.11.3", - "@swagger-api/apidom-parser-adapter-openapi-yaml-3-1": "^1.11.3", - "@swagger-api/apidom-parser-adapter-openapi-yaml-3-2": "^1.11.3", - "@swagger-api/apidom-parser-adapter-yaml-1-2": "^1.11.3" - } - }, - "node_modules/@swaggerexpert/cookie": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@swaggerexpert/cookie/-/cookie-2.0.2.tgz", - "integrity": "sha512-DPI8YJ0Vznk4CT+ekn3rcFNq1uQwvUHZhH6WvTSPD0YKBIlMS9ur2RYKghXuxxOiqOam/i4lHJH4xTIiTgs3Mg==", - "license": "Apache-2.0", - "dependencies": { - "apg-lite": "^1.0.3" - }, - "engines": { - "node": ">=12.20.0" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz", + "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==", + "license": "BSD-3-Clause" }, - "node_modules/@swaggerexpert/json-pointer": { - "version": "2.10.2", - "resolved": "https://registry.npmjs.org/@swaggerexpert/json-pointer/-/json-pointer-2.10.2.tgz", - "integrity": "sha512-qMx1nOrzoB+PF+pzb26Q4Tc2sOlrx9Ba2UBNX9hB31Omrq+QoZ2Gly0KLrQWw4Of1AQ4J9lnD+XOdwOdcdXqqw==", - "license": "Apache-2.0", + "node_modules/@so-ric/colorspace": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@so-ric/colorspace/-/colorspace-1.1.6.tgz", + "integrity": "sha512-/KiKkpHNOBgkFJwu9sh48LkHSMYGyuTcSFK/qMBdnOAlrRJzRSXAOFB5qwzaVQuDl8wAvHVMkaASQDReTahxuw==", + "license": "MIT", "dependencies": { - "apg-lite": "^1.0.4" - }, - "engines": { - "node": ">=12.20.0" + "color": "^5.0.2", + "text-hex": "1.0.x" } }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", + "license": "MIT" + }, "node_modules/@tanstack/history": { "version": "1.162.0", "resolved": "https://registry.npmjs.org/@tanstack/history/-/history-1.162.0.tgz", @@ -5578,15 +4753,6 @@ "@types/pg": "*" } }, - "node_modules/@types/ramda": { - "version": "0.30.2", - "resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.30.2.tgz", - "integrity": "sha512-PyzHvjCalm2BRYjAU6nIB3TprYwMNOUY/7P/N8bSzp9W/yM2YrtGtAnnVtaCNSeOZ8DzKyFDvaqQs7LnWwwmBA==", - "license": "MIT", - "dependencies": { - "types-ramda": "^0.30.1" - } - }, "node_modules/@types/tedious": { "version": "4.0.14", "resolved": "https://registry.npmjs.org/@types/tedious/-/tedious-4.0.14.tgz", @@ -5938,12 +5104,6 @@ ], "license": "MIT" }, - "node_modules/apg-lite": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/apg-lite/-/apg-lite-1.0.5.tgz", - "integrity": "sha512-SlI+nLMQDzCZfS39ihzjGp3JNBQfJXyMi6cg9tkLOCPVErgFsUIAEdO9IezR7kbP5Xd0ozcPNQBkf9TO5cHgWw==", - "license": "BSD-2-Clause" - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -6000,52 +5160,6 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "license": "MIT" }, - "node_modules/axios": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.18.1.tgz", - "integrity": "sha512-3nTvFlvpn9Zu/RkHUqtc7/+al4UpRW5az71ap5zccp6e8RAYEzhMTecX8Dz1wWDYrPpUoB1HAQEGEAEvUr7S9g==", - "license": "MIT", - "dependencies": { - "follow-redirects": "^1.16.0", - "form-data": "^4.0.5", - "https-proxy-agent": "^5.0.1", - "proxy-from-env": "^2.1.0" - } - }, - "node_modules/axios/node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "license": "MIT", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/axios/node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "license": "MIT", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/axios/node_modules/proxy-from-env": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", - "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", - "license": "MIT", - "engines": { - "node": ">=10" - } - }, "node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", @@ -6212,16 +5326,6 @@ "node": ">= 0.4" } }, - "node_modules/camel-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", - "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", - "license": "MIT", - "dependencies": { - "pascal-case": "^3.1.2", - "tslib": "^2.0.3" - } - }, "node_modules/camelcase": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-9.0.0.tgz", @@ -6255,17 +5359,6 @@ ], "license": "CC-BY-4.0" }, - "node_modules/capital-case": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz", - "integrity": "sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==", - "license": "MIT", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, "node_modules/chai": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", @@ -6292,26 +5385,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/change-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz", - "integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==", - "license": "MIT", - "dependencies": { - "camel-case": "^4.1.2", - "capital-case": "^1.0.4", - "constant-case": "^3.0.4", - "dot-case": "^3.0.4", - "header-case": "^2.0.4", - "no-case": "^3.0.4", - "param-case": "^3.0.4", - "pascal-case": "^3.1.2", - "path-case": "^3.0.4", - "sentence-case": "^3.0.4", - "snake-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/ci-info": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.4.0.tgz", @@ -6579,17 +5652,6 @@ "node": "^14.18.0 || >=16.10.0" } }, - "node_modules/constant-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz", - "integrity": "sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==", - "license": "MIT", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case": "^2.0.2" - } - }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -6603,17 +5665,6 @@ "integrity": "sha512-UaXxwISYJPTr9hwQxMFYZ7kNhSXboMXP+Z3TRX6f1/NyaGPfuNUZOWP1pUEb75B2HjfklIYLVRfWiFZJyC6Npg==", "license": "MIT" }, - "node_modules/core-js-pure": { - "version": "3.49.0", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.49.0.tgz", - "integrity": "sha512-XM4RFka59xATyJv/cS3O3Kml72hQXUeGRuuTmMYFxwzc9/7C8OYTaIR/Ji+Yt8DXzsFLNhat15cE/JP15HrCgw==", - "hasInstallScript": true, - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -6649,12 +5700,6 @@ "node": ">= 8" } }, - "node_modules/crypto-js": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", - "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", - "license": "MIT" - }, "node_modules/data-uri-to-buffer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", @@ -6761,16 +5806,6 @@ "node": ">=8" } }, - "node_modules/dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "license": "MIT", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/dotenv": { "version": "17.4.2", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz", @@ -6999,12 +6034,6 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "license": "MIT" }, - "node_modules/fast-json-patch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/fast-json-patch/-/fast-json-patch-3.1.1.tgz", - "integrity": "sha512-vf6IHUX2SBcA+5/+4883dsIjpBTqmfBjmYiWK1savxQmFk4JfBMLa7ynTYOs1Rolp/T1betJxHiGD3g1Mn8lUQ==", - "license": "MIT" - }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -7153,26 +6182,6 @@ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", "license": "MIT" }, - "node_modules/follow-redirects": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", - "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "license": "MIT", - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, "node_modules/foreground-child": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", @@ -7507,16 +6516,6 @@ "node": ">= 0.4" } }, - "node_modules/header-case": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/header-case/-/header-case-2.0.4.tgz", - "integrity": "sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==", - "license": "MIT", - "dependencies": { - "capital-case": "^1.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/hjson": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/hjson/-/hjson-3.2.2.tgz", @@ -7564,15 +6563,6 @@ "dev": true, "license": "MIT" }, - "node_modules/http-link-header": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/http-link-header/-/http-link-header-1.1.4.tgz", - "integrity": "sha512-xT3GPW6/ZbGuw4UvwHqErSCEjNUlwbQJuZn9/q5U4WEKfp2kENVCAlousG1zLxHeaQ/ffOHUNpWamvkbBW0eNw==", - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/http-proxy-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", @@ -8376,12 +7366,6 @@ "url": "https://github.com/sponsors/antfu" } }, - "node_modules/lodash": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", - "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", - "license": "MIT" - }, "node_modules/lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", @@ -8581,15 +7565,6 @@ "loose-envify": "cli.js" } }, - "node_modules/lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "license": "MIT", - "dependencies": { - "tslib": "^2.0.3" - } - }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -8689,18 +7664,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/minim": { - "version": "0.23.8", - "resolved": "https://registry.npmjs.org/minim/-/minim-0.23.8.tgz", - "integrity": "sha512-bjdr2xW1dBCMsMGGsUeqM4eFI60m94+szhxWys+B1ztIt6gWSfeGBdSVCIawezeHYLYn0j6zrsXdQS/JllBzww==", - "license": "MIT", - "dependencies": { - "lodash": "^4.15.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/minimatch": { "version": "10.2.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", @@ -8801,40 +7764,12 @@ "node": ">= 4.4.x" } }, - "node_modules/neotraverse": { - "version": "0.6.18", - "resolved": "https://registry.npmjs.org/neotraverse/-/neotraverse-0.6.18.tgz", - "integrity": "sha512-Z4SmBUweYa09+o6pG+eASabEpP6QkQ70yHj351pQoEXIs8uHbaU2DWVmzBANKgflPa47A50PtB2+NgRpQvr7vA==", - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, - "node_modules/no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "license": "MIT", - "dependencies": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, "node_modules/node-abort-controller": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.1.1.tgz", "integrity": "sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ==", - "license": "MIT" - }, - "node_modules/node-addon-api": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.9.0.tgz", - "integrity": "sha512-ekZMeaaIzSQTSpr7X2X3iJM7lTzgnx8ahAG9pJfT/7+14mlEM8ZYQ9cgCDvSSRbReFK0oHli3WrZdCiRsgAT9Q==", "license": "MIT", - "optional": true, - "engines": { - "node": "^18 || ^20 || >= 21" - } + "peer": true }, "node_modules/node-domexception": { "version": "1.0.0", @@ -8876,18 +7811,6 @@ } } }, - "node_modules/node-gyp-build": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz", - "integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==", - "license": "MIT", - "optional": true, - "bin": { - "node-gyp-build": "bin.js", - "node-gyp-build-optional": "optional.js", - "node-gyp-build-test": "build-test.js" - } - }, "node_modules/node-releases": { "version": "2.0.51", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.51.tgz", @@ -9040,30 +7963,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/openapi-path-templating": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/openapi-path-templating/-/openapi-path-templating-2.2.1.tgz", - "integrity": "sha512-eN14VrDvl/YyGxxrkGOHkVkWEoPyhyeydOUrbvjoz8K5eIGgELASwN1eqFOJ2CTQMGCy2EntOK1KdtJ8ZMekcg==", - "license": "Apache-2.0", - "dependencies": { - "apg-lite": "^1.0.4" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/openapi-server-url-templating": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/openapi-server-url-templating/-/openapi-server-url-templating-1.3.0.tgz", - "integrity": "sha512-DPlCms3KKEbjVQb0spV6Awfn6UWNheuG/+folQPzh/wUaKwuqvj8zt5gagD7qoyxtE03cIiKPgLFS3Q8Bz00uQ==", - "license": "Apache-2.0", - "dependencies": { - "apg-lite": "^1.0.4" - }, - "engines": { - "node": ">=12.20.0" - } - }, "node_modules/openwhisk": { "version": "3.21.9", "resolved": "https://registry.npmjs.org/openwhisk/-/openwhisk-3.21.9.tgz", @@ -9192,36 +8091,6 @@ "integrity": "sha512-xg1eHpwYL/D/HEdWw2goFZP6vV0FH7W+PZ5rFkGjdIDLtxq7EkzBUeT3m+lndYCt8wKbmofUu1MUdMCXkCk9ZQ==", "license": "MIT" }, - "node_modules/param-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", - "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", - "license": "MIT", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/pascal-case": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", - "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", - "license": "MIT", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/path-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz", - "integrity": "sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==", - "license": "MIT", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/path-expression-matcher": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.6.2.tgz", @@ -9495,32 +8364,6 @@ ], "license": "MIT" }, - "node_modules/ramda": { - "version": "0.30.1", - "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.30.1.tgz", - "integrity": "sha512-tEF5I22zJnuclswcZMc8bDIrwRHRzf+NqVEmqg50ShAZMP7MWeR/RGDthfM/p+BlqvF2fXAzpn8i+SJcYD3alw==", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/ramda" - } - }, - "node_modules/ramda-adjunct": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-5.1.0.tgz", - "integrity": "sha512-8qCpl2vZBXEJyNbi4zqcgdfHtcdsWjOGbiNSEnEBrM6Y0OKOT8UxJbIVGm1TIcjaSu2MxaWcgtsNlKlCk7o7qg==", - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/ramda-adjunct" - }, - "peerDependencies": { - "ramda": ">= 0.30.0" - } - }, "node_modules/react": { "version": "19.2.7", "resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz", @@ -9800,15 +8643,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/rxjs": { - "version": "7.8.2", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", - "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", - "license": "Apache-2.0", - "dependencies": { - "tslib": "^2.1.0" - } - }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -9881,17 +8715,6 @@ "node": ">=10" } }, - "node_modules/sentence-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-3.0.4.tgz", - "integrity": "sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==", - "license": "MIT", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, "node_modules/seroval": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/seroval/-/seroval-1.5.5.tgz", @@ -9934,16 +8757,6 @@ "node": ">=8" } }, - "node_modules/short-unique-id": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/short-unique-id/-/short-unique-id-5.3.2.tgz", - "integrity": "sha512-KRT/hufMSxXKEDSQujfVE0Faa/kZ51ihUcZQAcmP04t00DvPj7Ox5anHke1sJYUtzSuiT/Y5uyzg/W7bBEGhCg==", - "license": "Apache-2.0", - "bin": { - "short-unique-id": "bin/short-unique-id", - "suid": "bin/short-unique-id" - } - }, "node_modules/siginfo": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", @@ -10000,16 +8813,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/snake-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", - "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", - "license": "MIT", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -10210,35 +9013,6 @@ "node": ">=8" } }, - "node_modules/swagger-client": { - "version": "3.37.5", - "resolved": "https://registry.npmjs.org/swagger-client/-/swagger-client-3.37.5.tgz", - "integrity": "sha512-MuABJgD8vIsT5GVBTGj3HjmiEhArf58ng+YP4fo23NOJb/mKXOpKW3Rln90fnoi7ROt6IJsJy9d5kg8Yidn0/Q==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "^7.22.15", - "@scarf/scarf": "=1.4.0", - "@swagger-api/apidom-core": "^1.11.0", - "@swagger-api/apidom-error": "^1.11.0", - "@swagger-api/apidom-json-pointer": "^1.11.0", - "@swagger-api/apidom-ns-openapi-3-1": "^1.11.0", - "@swagger-api/apidom-ns-openapi-3-2": "^1.11.0", - "@swagger-api/apidom-reference": "^1.11.0", - "@swaggerexpert/cookie": "^2.0.2", - "deepmerge": "~4.3.0", - "fast-json-patch": "^3.0.0-1", - "js-yaml": "^4.2.0", - "neotraverse": "=0.6.18", - "node-abort-controller": "^3.1.1", - "openapi-path-templating": "^2.2.1", - "openapi-server-url-templating": "^1.3.0", - "ramda": "^0.30.1", - "ramda-adjunct": "^5.1.0" - }, - "engines": { - "node": ">=22" - } - }, "node_modules/symbol-observable": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz", @@ -10317,38 +9091,6 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "license": "MIT" }, - "node_modules/tree-sitter": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/tree-sitter/-/tree-sitter-0.21.1.tgz", - "integrity": "sha512-7dxoA6kYvtgWw80265MyqJlkRl4yawIjO7S5MigytjELkX43fV2WsAXzsNfO7sBpPPCF5Gp0+XzHk0DwLCq3xQ==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "dependencies": { - "node-addon-api": "^8.0.0", - "node-gyp-build": "^4.8.0" - } - }, - "node_modules/tree-sitter-json": { - "version": "0.24.8", - "resolved": "https://registry.npmjs.org/tree-sitter-json/-/tree-sitter-json-0.24.8.tgz", - "integrity": "sha512-Tc9ZZYwHyWZ3Tt1VEw7Pa2scu1YO7/d2BCBbKTx5hXwig3UfdQjsOPkPyLpDJOn/m1UBEWYAtSdGAwCSyagBqQ==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "dependencies": { - "node-addon-api": "^8.2.2", - "node-gyp-build": "^4.8.2" - }, - "peerDependencies": { - "tree-sitter": "^0.21.1" - }, - "peerDependenciesMeta": { - "tree-sitter": { - "optional": true - } - } - }, "node_modules/triple-beam": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz", @@ -10371,18 +9113,6 @@ "node": ">=8" } }, - "node_modules/ts-mixer": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz", - "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==", - "license": "MIT" - }, - "node_modules/ts-toolbelt": { - "version": "9.6.0", - "resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-9.6.0.tgz", - "integrity": "sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==", - "license": "Apache-2.0" - }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", @@ -10404,15 +9134,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/types-ramda": { - "version": "0.30.1", - "resolved": "https://registry.npmjs.org/types-ramda/-/types-ramda-0.30.1.tgz", - "integrity": "sha512-1HTsf5/QVRmLzcGfldPFvkVsAdi1db1BBKzi7iW3KBUlOICg/nKnFS+jGqDJS3YD8VsWbAh7JiHeBvbsw8RPxA==", - "license": "MIT", - "dependencies": { - "ts-toolbelt": "^9.6.0" - } - }, "node_modules/ufo": { "version": "1.6.4", "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.4.tgz", @@ -10474,12 +9195,6 @@ "node": ">= 10.0.0" } }, - "node_modules/unraw": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/unraw/-/unraw-3.0.0.tgz", - "integrity": "sha512-08/DA66UF65OlpUDIQtbJyrqTR0jTAlJ+jsnkQ4jxR7+K5g5YG1APZKQSMCE1vqqmD+2pv6+IdEjmopFatacvg==", - "license": "MIT" - }, "node_modules/upath": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/upath/-/upath-2.0.1.tgz", @@ -10521,24 +9236,6 @@ "browserslist": ">= 4.21.0" } }, - "node_modules/upper-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-2.0.2.tgz", - "integrity": "sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==", - "license": "MIT", - "dependencies": { - "tslib": "^2.0.3" - } - }, - "node_modules/upper-case-first": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", - "integrity": "sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==", - "license": "MIT", - "dependencies": { - "tslib": "^2.0.3" - } - }, "node_modules/use-sync-external-store": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz", @@ -10581,11 +9278,6 @@ } } }, - "node_modules/valid-url": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz", - "integrity": "sha512-QQDsV8OnSf5Uc30CKSwG9lnhMPe6exHtTXLRYX8uMwKENy640pU+2BgBL0LRbDh/eYRahNCS7aewCx0wf3NYVA==" - }, "node_modules/validate-npm-package-name": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-8.0.0.tgz", @@ -10781,13 +9473,6 @@ "node": ">= 8" } }, - "node_modules/web-tree-sitter": { - "version": "0.24.5", - "resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.24.5.tgz", - "integrity": "sha512-+J/2VSHN8J47gQUAvF8KDadrfz6uFYVjxoxbKWDoXVsH2u7yLdarCnIURnrMA6uSRkgX3SdmqM5BOoQjPdSh5w==", - "license": "MIT", - "optional": true - }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/package.json b/package.json index c4746055..8651bfe3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/commerce-integration-starter-kit", - "version": "1.0.2", + "version": "4.0.0", "author": "Adobe Inc.", "license": "Apache-2.0", "description": "To reduce the cost of integrating with Enterprise Resource Planning (ERP) solutions and to improve the reliability of real-time connections, Adobe is introducing an integration starter kit for back-office integrations using Adobe Developer App Builder.", @@ -11,15 +11,15 @@ }, "imports": { "#app.commerce.config": "./src/commerce-extensibility-1/.generated/app.commerce.config.js", - "#telemetry": "./src/commerce-extensibility-1/telemetry.js", - "#lib/*": "./src/commerce-extensibility-1/lib/*.js", + "#telemetry": "./src/telemetry.js", + "#lib/*": "./src/lib/*.js", "#src/*": "./src/commerce-extensibility-1/actions/*.js" }, "dependencies": { "@adobe/aio-commerce-lib-app": "^1.8.0-beta-20260714082406", "@adobe/aio-commerce-sdk": "^1.4.0-beta-20260714082406", + "@adobe/aio-lib-core-logging": "^3.0.2", "@adobe/aio-lib-telemetry": "^1.0.0", - "@adobe/aio-sdk": "^6.0.0", "ajv": "^8.16.0", "graphql-request": "^7.1.2" }, diff --git a/src/commerce-extensibility-1/actions/customer/commerce/created/index.js b/src/commerce-extensibility-1/actions/customer/commerce/created/index.js index 3cb3a79f..494fbef3 100644 --- a/src/commerce-extensibility-1/actions/customer/commerce/created/index.js +++ b/src/commerce-extensibility-1/actions/customer/commerce/created/index.js @@ -1,14 +1,15 @@ +import { + badRequest, + buildErrorResponse, + internalServerError, + isSuccessResponse, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; import { getInstrumentationHelpers, instrumentEntrypoint, } from "@adobe/aio-lib-telemetry"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { - actionErrorResponse, - actionSuccessResponse, - isActionSuccessful, -} from "#lib/responses"; import { checkMissingRequestInputs, stringParameters } from "#lib/utils"; import { telemetryConfig } from "#telemetry"; @@ -36,10 +37,7 @@ async function __main(params) { ); if (errorMessage) { logger.error(`Invalid request parameters: ${errorMessage}`); - return actionErrorResponse( - HTTP_BAD_REQUEST, - `Invalid request parameters: ${errorMessage}`, - ); + return badRequest(`Invalid request parameters: ${errorMessage}`); } // Only handle newly created records; updates are handled by the updated action. @@ -47,7 +45,7 @@ async function __main(params) { const updatedAt = Date.parse(params.data.value.updated_at); if (createdAt !== updatedAt) { logger.info("Customer is not newly created; skipping"); - return actionSuccessResponse("Skipped: customer is not newly created"); + return ok("Skipped: customer is not newly created"); } try { @@ -55,7 +53,7 @@ async function __main(params) { const validation = validateData(params.data); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data)}`); const transformedData = transformData(params.data); @@ -65,19 +63,21 @@ async function __main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer created successfully"); + return ok("Customer created successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } export const main = instrumentEntrypoint(__main, { ...telemetryConfig, - isSuccessful: isActionSuccessful, + isSuccessful: isSuccessResponse, }); diff --git a/src/commerce-extensibility-1/actions/customer/commerce/created/sender.js b/src/commerce-extensibility-1/actions/customer/commerce/created/sender.js index f43cf225..9d81a59f 100644 --- a/src/commerce-extensibility-1/actions/customer/commerce/created/sender.js +++ b/src/commerce-extensibility-1/actions/customer/commerce/created/sender.js @@ -11,7 +11,13 @@ import { isOperationSuccessful } from "#telemetry"; * @param {object} params - include the env params * @param {object} data - Customer data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. */ async function __sendData(params, data, preProcessed) { // @TODO Here add the logic to send the information to 3rd party diff --git a/src/commerce-extensibility-1/actions/customer/commerce/deleted/index.js b/src/commerce-extensibility-1/actions/customer/commerce/deleted/index.js index 368d2298..82f840c9 100644 --- a/src/commerce-extensibility-1/actions/customer/commerce/deleted/index.js +++ b/src/commerce-extensibility-1/actions/customer/commerce/deleted/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("customer-commerce-deleted", { + const logger = AioLogger("customer-commerce-deleted", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params.data); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data)}`); const transformedData = transformData(params.data); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer deleted successfully"); + return ok("Customer deleted successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/customer/commerce/deleted/sender.js b/src/commerce-extensibility-1/actions/customer/commerce/deleted/sender.js index 99ace317..d5a19a13 100644 --- a/src/commerce-extensibility-1/actions/customer/commerce/deleted/sender.js +++ b/src/commerce-extensibility-1/actions/customer/commerce/deleted/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - Customer data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. * @throws {Error} - throws exception in case the process fail. */ async function sendData(params, data, preProcessed) { diff --git a/src/commerce-extensibility-1/actions/customer/commerce/group-deleted/index.js b/src/commerce-extensibility-1/actions/customer/commerce/group-deleted/index.js index 64d68d09..1c16b375 100644 --- a/src/commerce-extensibility-1/actions/customer/commerce/group-deleted/index.js +++ b/src/commerce-extensibility-1/actions/customer/commerce/group-deleted/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("customer-commerce-group-deleted", { + const logger = AioLogger("customer-commerce-group-deleted", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params.data.value); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data.value)}`); const transformedData = transformData(params.data.value); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer group deleted successfully"); + return ok("Customer group deleted successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/customer/commerce/group-deleted/sender.js b/src/commerce-extensibility-1/actions/customer/commerce/group-deleted/sender.js index 03d0bb30..c16ee917 100644 --- a/src/commerce-extensibility-1/actions/customer/commerce/group-deleted/sender.js +++ b/src/commerce-extensibility-1/actions/customer/commerce/group-deleted/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - Customer data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. */ async function sendData(params, data, preProcessed) { // @TODO Here add the logic to send the information to 3rd party diff --git a/src/commerce-extensibility-1/actions/customer/commerce/group-updated/index.js b/src/commerce-extensibility-1/actions/customer/commerce/group-updated/index.js index 4db8e9a2..a80b0321 100644 --- a/src/commerce-extensibility-1/actions/customer/commerce/group-updated/index.js +++ b/src/commerce-extensibility-1/actions/customer/commerce/group-updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("customer-commerce-group-updated", { + const logger = AioLogger("customer-commerce-group-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params.data.value); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data.value)}`); const transformedData = transformData(params.data.value); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer group updated successfully"); + return ok("Customer group updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/customer/commerce/group-updated/sender.js b/src/commerce-extensibility-1/actions/customer/commerce/group-updated/sender.js index cd922d2b..ece4259a 100644 --- a/src/commerce-extensibility-1/actions/customer/commerce/group-updated/sender.js +++ b/src/commerce-extensibility-1/actions/customer/commerce/group-updated/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - Customer data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. */ async function sendData(params, data, preProcessed) { // @TODO Here add the logic to send the information to 3rd party diff --git a/src/commerce-extensibility-1/actions/customer/commerce/updated/index.js b/src/commerce-extensibility-1/actions/customer/commerce/updated/index.js index 4c130af8..c9dddd95 100644 --- a/src/commerce-extensibility-1/actions/customer/commerce/updated/index.js +++ b/src/commerce-extensibility-1/actions/customer/commerce/updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { checkMissingRequestInputs, stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("customer-commerce-updated", { + const logger = AioLogger("customer-commerce-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -30,10 +34,7 @@ async function main(params) { ); if (errorMessage) { logger.error(`Invalid request parameters: ${errorMessage}`); - return actionErrorResponse( - HTTP_BAD_REQUEST, - `Invalid request parameters: ${errorMessage}`, - ); + return badRequest(`Invalid request parameters: ${errorMessage}`); } // Only handle updates; newly created records are handled by the created action. @@ -41,7 +42,7 @@ async function main(params) { const updatedAt = Date.parse(params.data.value.updated_at); if (createdAt === updatedAt) { logger.info("Customer was not updated; skipping"); - return actionSuccessResponse("Skipped: customer was not updated"); + return ok("Skipped: customer was not updated"); } try { @@ -49,7 +50,7 @@ async function main(params) { const validation = validateData(params.data); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data)}`); const transformedData = transformData(params.data); @@ -59,15 +60,17 @@ async function main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer updated successfully"); + return ok("Customer updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/customer/commerce/updated/sender.js b/src/commerce-extensibility-1/actions/customer/commerce/updated/sender.js index b096077b..c1bbbcee 100644 --- a/src/commerce-extensibility-1/actions/customer/commerce/updated/sender.js +++ b/src/commerce-extensibility-1/actions/customer/commerce/updated/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - Customer data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. */ function sendData(params, data, preProcessed) { // @TODO Here add the logic to send the information to 3rd party diff --git a/src/commerce-extensibility-1/actions/customer/external/created/index.js b/src/commerce-extensibility-1/actions/customer/external/created/index.js index 09f35612..5128e232 100644 --- a/src/commerce-extensibility-1/actions/customer/external/created/index.js +++ b/src/commerce-extensibility-1/actions/customer/external/created/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("customer-external-created", { + const logger = AioLogger("customer-external-created", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer created successfully"); + return ok("Customer created successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/customer/external/created/sender.js b/src/commerce-extensibility-1/actions/customer/external/created/sender.js index af020472..da118059 100644 --- a/src/commerce-extensibility-1/actions/customer/external/created/sender.js +++ b/src/commerce-extensibility-1/actions/customer/external/created/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { createCustomer } from "#src/customer/commerce-customer-api-client"; /** * This function send the customer created data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/customer/external/deleted/index.js b/src/commerce-extensibility-1/actions/customer/external/deleted/index.js index cb0e7386..aac37bb6 100644 --- a/src/commerce-extensibility-1/actions/customer/external/deleted/index.js +++ b/src/commerce-extensibility-1/actions/customer/external/deleted/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("customer-external-deleted", { + const logger = AioLogger("customer-external-deleted", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer deleted successfully"); + return ok("Customer deleted successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/customer/external/deleted/sender.js b/src/commerce-extensibility-1/actions/customer/external/deleted/sender.js index 01b33952..bca4718d 100644 --- a/src/commerce-extensibility-1/actions/customer/external/deleted/sender.js +++ b/src/commerce-extensibility-1/actions/customer/external/deleted/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { deleteCustomer } from "#src/customer/commerce-customer-api-client"; /** * This function send the customer deleted data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/customer/external/group-created/index.js b/src/commerce-extensibility-1/actions/customer/external/group-created/index.js index 16ddbfc8..c72b8a8e 100644 --- a/src/commerce-extensibility-1/actions/customer/external/group-created/index.js +++ b/src/commerce-extensibility-1/actions/customer/external/group-created/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("customer-external-group-created", { + const logger = AioLogger("customer-external-group-created", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer group created successfully"); + return ok("Customer group created successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/customer/external/group-created/sender.js b/src/commerce-extensibility-1/actions/customer/external/group-created/sender.js index a671bf90..60647ea2 100644 --- a/src/commerce-extensibility-1/actions/customer/external/group-created/sender.js +++ b/src/commerce-extensibility-1/actions/customer/external/group-created/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { createCustomerGroup } from "#src/customer/commerce-customer-group-api-client"; /** * This function send the customer group created data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/customer/external/group-deleted/index.js b/src/commerce-extensibility-1/actions/customer/external/group-deleted/index.js index 29bbed87..11d0284b 100644 --- a/src/commerce-extensibility-1/actions/customer/external/group-deleted/index.js +++ b/src/commerce-extensibility-1/actions/customer/external/group-deleted/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("customer-external-group-deleted", { + const logger = AioLogger("customer-external-group-deleted", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer group deleted successfully"); + return ok("Customer group deleted successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/customer/external/group-deleted/sender.js b/src/commerce-extensibility-1/actions/customer/external/group-deleted/sender.js index 6b49d4ac..9e7a0152 100644 --- a/src/commerce-extensibility-1/actions/customer/external/group-deleted/sender.js +++ b/src/commerce-extensibility-1/actions/customer/external/group-deleted/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { deleteCustomerGroup } from "#src/customer/commerce-customer-group-api-client"; /** * This function send the customer group deleted data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/customer/external/group-updated/index.js b/src/commerce-extensibility-1/actions/customer/external/group-updated/index.js index 4b75227c..6f27bb7a 100644 --- a/src/commerce-extensibility-1/actions/customer/external/group-updated/index.js +++ b/src/commerce-extensibility-1/actions/customer/external/group-updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("customer-external-group-updated", { + const logger = AioLogger("customer-external-group-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer group updated successfully"); + return ok("Customer group updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/customer/external/group-updated/sender.js b/src/commerce-extensibility-1/actions/customer/external/group-updated/sender.js index 9343eea1..5143037d 100644 --- a/src/commerce-extensibility-1/actions/customer/external/group-updated/sender.js +++ b/src/commerce-extensibility-1/actions/customer/external/group-updated/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { updateCustomerGroup } from "#src/customer/commerce-customer-group-api-client"; /** * This function send the customer group updated data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/customer/external/updated/index.js b/src/commerce-extensibility-1/actions/customer/external/updated/index.js index 4f3dcc27..ab1ca7cf 100644 --- a/src/commerce-extensibility-1/actions/customer/external/updated/index.js +++ b/src/commerce-extensibility-1/actions/customer/external/updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("customer-external-updated", { + const logger = AioLogger("customer-external-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Customer updated successfully"); + return ok("Customer updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/customer/external/updated/sender.js b/src/commerce-extensibility-1/actions/customer/external/updated/sender.js index 4952a4d4..b2eb98ce 100644 --- a/src/commerce-extensibility-1/actions/customer/external/updated/sender.js +++ b/src/commerce-extensibility-1/actions/customer/external/updated/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { updateCustomer } from "#src/customer/commerce-customer-api-client"; /** * This function send the customer updated data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/ingestion/webhook/index.js b/src/commerce-extensibility-1/actions/ingestion/webhook/index.js index 99d6d576..f685a34d 100644 --- a/src/commerce-extensibility-1/actions/ingestion/webhook/index.js +++ b/src/commerce-extensibility-1/actions/ingestion/webhook/index.js @@ -1,22 +1,24 @@ import { publishEvent } from "@adobe/aio-commerce-lib-app"; -import { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error"; -import { createAdobeIoEventsApiClient } from "@adobe/aio-commerce-lib-events/io-events"; import { resolveImsAuthParams } from "@adobe/aio-commerce-sdk/auth"; -import { Core } from "@adobe/aio-sdk"; - +import { CommerceSdkValidationError } from "@adobe/aio-commerce-sdk/core/error"; import { - BACKOFFICE_PROVIDER_KEY, - HTTP_BAD_REQUEST, - HTTP_INTERNAL_ERROR, + badRequest, HTTP_OK, - HTTP_UNAUTHORIZED, -} from "#lib/constants"; -import { errorResponse, successResponse } from "#lib/responses"; + internalServerError, + ok, + unauthorized, +} from "@adobe/aio-commerce-sdk/core/responses"; +import { createAdobeIoEventsApiClient } from "@adobe/aio-commerce-sdk/events/io-events"; +import AioLogger from "@adobe/aio-lib-core-logging"; + +import appConfig from "#app.commerce.config"; import { stringParameters } from "#lib/utils"; import { checkAuthentication } from "./auth.js"; import { validateData } from "./validator.js"; +const BACKOFFICE_PROVIDER_KEY = appConfig.eventing.external[0].provider.key; + /** * This web action allow external back-office application publish event to IO event using custom authentication mechanism. * @@ -24,7 +26,7 @@ import { validateData } from "./validator.js"; * @returns response with success status and result */ async function main(params) { - const logger = Core.Logger("ingestion-webhook", { + const logger = AioLogger("ingestion-webhook", { level: params.LOG_LEVEL || "info", }); try { @@ -35,12 +37,12 @@ async function main(params) { logger.error( `Authentication failed with error: ${authentication.message}`, ); - return errorResponse(HTTP_UNAUTHORIZED, authentication.message); + return unauthorized(authentication.message); } const validationResult = validateData(params); if (!validationResult.success) { logger.error(`Validation failed with error: ${validationResult.message}`); - return errorResponse(HTTP_BAD_REQUEST, validationResult.message); + return badRequest(validationResult.message); } const client = createAdobeIoEventsApiClient({ auth: resolveImsAuthParams(params), @@ -57,16 +59,21 @@ async function main(params) { payload: params.data.value, }); logger.info(`Successful request: ${HTTP_OK}`); - return successResponse(eventType, { - success: true, - message: "Event published successfully", + return ok({ + body: { + type: eventType, + response: { + success: true, + message: "Event published successfully", + }, + }, }); } catch (error) { logger.error(`Server error: ${error.message}`); if (error instanceof CommerceSdkValidationError) { logger.error(error.display()); } - return errorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/order/commerce/created/index.js b/src/commerce-extensibility-1/actions/order/commerce/created/index.js index c80a8e5c..2a871977 100644 --- a/src/commerce-extensibility-1/actions/order/commerce/created/index.js +++ b/src/commerce-extensibility-1/actions/order/commerce/created/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { checkMissingRequestInputs, stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("order-commerce-created", { + const logger = AioLogger("order-commerce-created", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -30,10 +34,7 @@ async function main(params) { ); if (errorMessage) { logger.error(`Invalid request parameters: ${errorMessage}`); - return actionErrorResponse( - HTTP_BAD_REQUEST, - `Invalid request parameters: ${errorMessage}`, - ); + return badRequest(`Invalid request parameters: ${errorMessage}`); } // Only handle newly created records; updates are handled by the updated action. @@ -41,7 +42,7 @@ async function main(params) { const updatedAt = Date.parse(params.data.value.updated_at); if (createdAt !== updatedAt) { logger.info("Order is not newly created; skipping"); - return actionSuccessResponse("Skipped: order is not newly created"); + return ok("Skipped: order is not newly created"); } try { @@ -49,7 +50,7 @@ async function main(params) { const validation = validateData(params.data); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data)}`); const transformedData = transformData(params.data); @@ -59,15 +60,17 @@ async function main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Order created successfully"); + return ok("Order created successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/order/commerce/created/sender.js b/src/commerce-extensibility-1/actions/order/commerce/created/sender.js index f25ec8d8..1d8ad11e 100644 --- a/src/commerce-extensibility-1/actions/order/commerce/created/sender.js +++ b/src/commerce-extensibility-1/actions/order/commerce/created/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - order data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. */ async function sendData(params, data, preProcessed) { // @TODO Here add the logic to send the information to 3rd party diff --git a/src/commerce-extensibility-1/actions/order/commerce/updated/index.js b/src/commerce-extensibility-1/actions/order/commerce/updated/index.js index 24f9229e..77a878f9 100644 --- a/src/commerce-extensibility-1/actions/order/commerce/updated/index.js +++ b/src/commerce-extensibility-1/actions/order/commerce/updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { checkMissingRequestInputs, stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("order-commerce-updated", { + const logger = AioLogger("order-commerce-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -30,10 +34,7 @@ async function main(params) { ); if (errorMessage) { logger.error(`Invalid request parameters: ${errorMessage}`); - return actionErrorResponse( - HTTP_BAD_REQUEST, - `Invalid request parameters: ${errorMessage}`, - ); + return badRequest(`Invalid request parameters: ${errorMessage}`); } // Only handle updates; newly created records are handled by the created action. @@ -41,7 +42,7 @@ async function main(params) { const updatedAt = Date.parse(params.data.value.updated_at); if (createdAt === updatedAt) { logger.info("Order was not updated; skipping"); - return actionSuccessResponse("Skipped: order was not updated"); + return ok("Skipped: order was not updated"); } try { @@ -49,7 +50,7 @@ async function main(params) { const validation = validateData(params.data); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data)}`); const transformedData = transformData(params.data); @@ -59,15 +60,17 @@ async function main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Order updated successfully"); + return ok("Order updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/order/commerce/updated/sender.js b/src/commerce-extensibility-1/actions/order/commerce/updated/sender.js index 2f92e8ba..e2ad2d02 100644 --- a/src/commerce-extensibility-1/actions/order/commerce/updated/sender.js +++ b/src/commerce-extensibility-1/actions/order/commerce/updated/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - order data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. */ async function sendData(params, data, preProcessed) { // @TODO Here add the logic to send the information to 3rd party diff --git a/src/commerce-extensibility-1/actions/order/external/shipment-created/index.js b/src/commerce-extensibility-1/actions/order/external/shipment-created/index.js index 417a8131..d63cb3d0 100644 --- a/src/commerce-extensibility-1/actions/order/external/shipment-created/index.js +++ b/src/commerce-extensibility-1/actions/order/external/shipment-created/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("order-external-shipment-created", { + const logger = AioLogger("order-external-shipment-created", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Shipment created successfully"); + return ok("Shipment created successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/order/external/shipment-created/sender.js b/src/commerce-extensibility-1/actions/order/external/shipment-created/sender.js index 4310d8c4..082c0fa4 100644 --- a/src/commerce-extensibility-1/actions/order/external/shipment-created/sender.js +++ b/src/commerce-extensibility-1/actions/order/external/shipment-created/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { createShipment } from "#src/order/commerce-shipment-api-client"; /** * This function send the shipment created data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -23,7 +29,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/order/external/shipment-updated/index.js b/src/commerce-extensibility-1/actions/order/external/shipment-updated/index.js index 61674b15..f0436ced 100644 --- a/src/commerce-extensibility-1/actions/order/external/shipment-updated/index.js +++ b/src/commerce-extensibility-1/actions/order/external/shipment-updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("order-external-shipment-updated", { + const logger = AioLogger("order-external-shipment-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Shipment updated successfully"); + return ok("Shipment updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/order/external/shipment-updated/sender.js b/src/commerce-extensibility-1/actions/order/external/shipment-updated/sender.js index 362440c0..30e3ed66 100644 --- a/src/commerce-extensibility-1/actions/order/external/shipment-updated/sender.js +++ b/src/commerce-extensibility-1/actions/order/external/shipment-updated/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { updateShipment } from "#src/order/commerce-shipment-api-client"; /** * This function send the shipment updated data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/order/external/updated/index.js b/src/commerce-extensibility-1/actions/order/external/updated/index.js index 25e59f2c..ad460531 100644 --- a/src/commerce-extensibility-1/actions/order/external/updated/index.js +++ b/src/commerce-extensibility-1/actions/order/external/updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("order-external-updated", { + const logger = AioLogger("order-external-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Order updated successfully"); + return ok("Order updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/order/external/updated/sender.js b/src/commerce-extensibility-1/actions/order/external/updated/sender.js index f3bd79f0..9072bc20 100644 --- a/src/commerce-extensibility-1/actions/order/external/updated/sender.js +++ b/src/commerce-extensibility-1/actions/order/external/updated/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { addComment } from "#src/order/commerce-order-api-client"; /** * This function send the order status updated data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/product/commerce/created/index.js b/src/commerce-extensibility-1/actions/product/commerce/created/index.js index 4057bfa5..ab2a26e7 100644 --- a/src/commerce-extensibility-1/actions/product/commerce/created/index.js +++ b/src/commerce-extensibility-1/actions/product/commerce/created/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { checkMissingRequestInputs, stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("product-commerce-created", { + const logger = AioLogger("product-commerce-created", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -30,10 +34,7 @@ async function main(params) { ); if (errorMessage) { logger.error(`Invalid request parameters: ${errorMessage}`); - return actionErrorResponse( - HTTP_BAD_REQUEST, - `Invalid request parameters: ${errorMessage}`, - ); + return badRequest(`Invalid request parameters: ${errorMessage}`); } // Only handle newly created records; updates are handled by the updated action. @@ -41,7 +42,7 @@ async function main(params) { const updatedAt = Date.parse(params.data.value.updated_at); if (createdAt !== updatedAt) { logger.info("Product is not newly created; skipping"); - return actionSuccessResponse("Skipped: product is not newly created"); + return ok("Skipped: product is not newly created"); } try { @@ -49,7 +50,7 @@ async function main(params) { const validation = validateData(params.data); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data)}`); const transformedData = transformData(params.data); @@ -59,15 +60,17 @@ async function main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Product created successfully"); + return ok("Product created successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/product/commerce/created/sender.js b/src/commerce-extensibility-1/actions/product/commerce/created/sender.js index 61bcb53d..354c72fa 100644 --- a/src/commerce-extensibility-1/actions/product/commerce/created/sender.js +++ b/src/commerce-extensibility-1/actions/product/commerce/created/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - Product data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. */ async function sendData(params, data, preProcessed) { // @TODO Here add the logic to send the information to 3rd party diff --git a/src/commerce-extensibility-1/actions/product/commerce/deleted/index.js b/src/commerce-extensibility-1/actions/product/commerce/deleted/index.js index 0baca1a5..094c05e1 100644 --- a/src/commerce-extensibility-1/actions/product/commerce/deleted/index.js +++ b/src/commerce-extensibility-1/actions/product/commerce/deleted/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("product-commerce-deleted", { + const logger = AioLogger("product-commerce-deleted", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params.data); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data)}`); const transformedData = transformData(params.data); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Product deleted successfully"); + return ok("Product deleted successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/product/commerce/deleted/sender.js b/src/commerce-extensibility-1/actions/product/commerce/deleted/sender.js index 52c20396..8f2d90bd 100644 --- a/src/commerce-extensibility-1/actions/product/commerce/deleted/sender.js +++ b/src/commerce-extensibility-1/actions/product/commerce/deleted/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - Product data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. */ async function sendData(params, data, preProcessed) { // @TODO Here add the logic to send the information to 3rd party diff --git a/src/commerce-extensibility-1/actions/product/commerce/full-sync/index.js b/src/commerce-extensibility-1/actions/product/commerce/full-sync/index.js index 2e35ada1..e5d7d114 100644 --- a/src/commerce-extensibility-1/actions/product/commerce/full-sync/index.js +++ b/src/commerce-extensibility-1/actions/product/commerce/full-sync/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { queryProducts } from "#src/product/commerce-product-graphql-client"; @@ -20,7 +24,7 @@ const DEFAULT_PAGE_SIZE = 20; * @returns response object with status code and result */ async function main(params) { - const logger = Core.Logger("product-commerce-full-sync", { + const logger = AioLogger("product-commerce-full-sync", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing product full sync"); @@ -61,10 +65,10 @@ async function main(params) { )}`, ].join("\n"); logger.info("Product sync completed successfully"); - return actionSuccessResponse(message); + return ok(message); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } @@ -119,7 +123,12 @@ async function processPage(params, pageSize, currentPage, logger) { return createResult(currentPage, true, null, null, totalCount); } catch (error) { logger.error(`Error processing page ${currentPage}: ${error.message}`); - return createResult(currentPage, false, error.message, HTTP_INTERNAL_ERROR); + return createResult( + currentPage, + false, + error.message, + HTTP_INTERNAL_SERVER_ERROR, + ); } } diff --git a/src/commerce-extensibility-1/actions/product/commerce/full-sync/sender.js b/src/commerce-extensibility-1/actions/product/commerce/full-sync/sender.js index 61bcb53d..354c72fa 100644 --- a/src/commerce-extensibility-1/actions/product/commerce/full-sync/sender.js +++ b/src/commerce-extensibility-1/actions/product/commerce/full-sync/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - Product data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. */ async function sendData(params, data, preProcessed) { // @TODO Here add the logic to send the information to 3rd party diff --git a/src/commerce-extensibility-1/actions/product/commerce/updated/index.js b/src/commerce-extensibility-1/actions/product/commerce/updated/index.js index e3645aa2..a57a41c9 100644 --- a/src/commerce-extensibility-1/actions/product/commerce/updated/index.js +++ b/src/commerce-extensibility-1/actions/product/commerce/updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { checkMissingRequestInputs, stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("product-commerce-updated", { + const logger = AioLogger("product-commerce-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -30,10 +34,7 @@ async function main(params) { ); if (errorMessage) { logger.error(`Invalid request parameters: ${errorMessage}`); - return actionErrorResponse( - HTTP_BAD_REQUEST, - `Invalid request parameters: ${errorMessage}`, - ); + return badRequest(`Invalid request parameters: ${errorMessage}`); } // Only handle updates; newly created records are handled by the created action. @@ -41,7 +42,7 @@ async function main(params) { const updatedAt = Date.parse(params.data.value.updated_at); if (createdAt === updatedAt) { logger.info("Product was not updated; skipping"); - return actionSuccessResponse("Skipped: product was not updated"); + return ok("Skipped: product was not updated"); } try { @@ -49,7 +50,7 @@ async function main(params) { const validation = validateData(params.data); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data)}`); const transformedData = transformData(params.data); @@ -59,15 +60,17 @@ async function main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Product updated successfully"); + return ok("Product updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/product/commerce/updated/sender.js b/src/commerce-extensibility-1/actions/product/commerce/updated/sender.js index 80d77978..46e58149 100644 --- a/src/commerce-extensibility-1/actions/product/commerce/updated/sender.js +++ b/src/commerce-extensibility-1/actions/product/commerce/updated/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - Product data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. */ async function sendData(params, data, preProcessed) { // @TODO Here add the logic to send the information to 3rd party diff --git a/src/commerce-extensibility-1/actions/product/external/created/index.js b/src/commerce-extensibility-1/actions/product/external/created/index.js index e647fa18..e21cb01f 100644 --- a/src/commerce-extensibility-1/actions/product/external/created/index.js +++ b/src/commerce-extensibility-1/actions/product/external/created/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("product-external-created", { + const logger = AioLogger("product-external-created", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Product created successfully"); + return ok("Product created successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/product/external/created/sender.js b/src/commerce-extensibility-1/actions/product/external/created/sender.js index 4a1c30c9..51f28960 100644 --- a/src/commerce-extensibility-1/actions/product/external/created/sender.js +++ b/src/commerce-extensibility-1/actions/product/external/created/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { createProduct } from "#src/product/commerce-product-api-client"; /** * This function send the product created data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/product/external/deleted/index.js b/src/commerce-extensibility-1/actions/product/external/deleted/index.js index 678ccded..77205dfa 100644 --- a/src/commerce-extensibility-1/actions/product/external/deleted/index.js +++ b/src/commerce-extensibility-1/actions/product/external/deleted/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("product-external-deleted", { + const logger = AioLogger("product-external-deleted", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Product deleted successfully"); + return ok("Product deleted successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/product/external/deleted/sender.js b/src/commerce-extensibility-1/actions/product/external/deleted/sender.js index 7ad8f761..0370a283 100644 --- a/src/commerce-extensibility-1/actions/product/external/deleted/sender.js +++ b/src/commerce-extensibility-1/actions/product/external/deleted/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { deleteProduct } from "#src/product/commerce-product-api-client"; /** * This function send the product deleted data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/product/external/updated/index.js b/src/commerce-extensibility-1/actions/product/external/updated/index.js index 89aa0d3c..cf2b75c5 100644 --- a/src/commerce-extensibility-1/actions/product/external/updated/index.js +++ b/src/commerce-extensibility-1/actions/product/external/updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("product-external-updated", { + const logger = AioLogger("product-external-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Product updated successfully"); + return ok("Product updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/product/external/updated/sender.js b/src/commerce-extensibility-1/actions/product/external/updated/sender.js index 7ae6b4c6..2ad71af8 100644 --- a/src/commerce-extensibility-1/actions/product/external/updated/sender.js +++ b/src/commerce-extensibility-1/actions/product/external/updated/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { updateProduct } from "#src/product/commerce-product-api-client"; /** * This function send the product updated data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/starter-kit/info/index.js b/src/commerce-extensibility-1/actions/starter-kit/info/index.js index 306707dd..efb21a4c 100644 --- a/src/commerce-extensibility-1/actions/starter-kit/info/index.js +++ b/src/commerce-extensibility-1/actions/starter-kit/info/index.js @@ -1,8 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + HTTP_OK, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; import appConfig from "#app.commerce.config"; -import { HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; /** * Please DO NOT DELETE this action; future functionalities planned for upcoming starter kit releases may stop working. @@ -14,25 +17,27 @@ import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; * @param {object} params - includes the env params */ function main(params) { - const logger = Core.Logger("starter-kit-info", { + const logger = AioLogger("starter-kit-info", { level: params.LOG_LEVEL || "info", }); try { logger.info("Calling the starter kit info action"); logger.info(`Successful request: ${HTTP_OK}`); - return actionSuccessResponse({ - starter_kit_version: appConfig.metadata.version, - // Kept for backwards compatibility; the data now lives in `eventing`. - registrations: 'This information now lives in the "eventing" property.', - eventing: appConfig.eventing, + return ok({ + body: { + message: { + starter_kit_version: appConfig.metadata.version, + // Kept for backwards compatibility; the data now lives in `eventing`. + registrations: + 'This information now lives in the "eventing" property.', + eventing: appConfig.eventing, + }, + }, }); } catch (error) { logger.error(error); - return actionErrorResponse( - HTTP_INTERNAL_ERROR, - `Server error: ${error.message}`, - ); + return internalServerError(`Server error: ${error.message}`); } } diff --git a/src/commerce-extensibility-1/actions/stock/commerce/updated/index.js b/src/commerce-extensibility-1/actions/stock/commerce/updated/index.js index 934fba0e..5f800b63 100644 --- a/src/commerce-extensibility-1/actions/stock/commerce/updated/index.js +++ b/src/commerce-extensibility-1/actions/stock/commerce/updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("stock-commerce-updated", { + const logger = AioLogger("stock-commerce-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params.data); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${JSON.stringify(params.data)}`); const transformedData = transformData(params.data); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformedData, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformedData, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Stock updated successfully"); + return ok("Stock updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error.message}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/stock/commerce/updated/sender.js b/src/commerce-extensibility-1/actions/stock/commerce/updated/sender.js index 085f7a9d..34b55617 100644 --- a/src/commerce-extensibility-1/actions/stock/commerce/updated/sender.js +++ b/src/commerce-extensibility-1/actions/stock/commerce/updated/sender.js @@ -4,7 +4,13 @@ * @param {object} params - include the env params * @param {object} data - Customer data * @param {object} preProcessed - result of the pre-process logic if any - * @returns the sending result if needed for post process + * @returns {Promise< + * | { success: true } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`: `success` gates the flow, and on + * failure `statusCode`/`message` are forwarded to the error response. This stub + * only returns the success variant; return the failure variant (see the @TODO + * below) once real send logic is added. * @throws {Error} - throws exception in case the process fail. */ async function sendData(params, data, preProcessed) { diff --git a/src/commerce-extensibility-1/actions/stock/external/updated/index.js b/src/commerce-extensibility-1/actions/stock/external/updated/index.js index 69886ba5..6e8543de 100644 --- a/src/commerce-extensibility-1/actions/stock/external/updated/index.js +++ b/src/commerce-extensibility-1/actions/stock/external/updated/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { + badRequest, + buildErrorResponse, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR } from "#lib/constants"; -import { actionErrorResponse, actionSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { postProcess } from "./post.js"; @@ -17,7 +21,7 @@ import { validateData } from "./validator.js"; * @param {object} params - includes the env params, type and the data of the event */ async function main(params) { - const logger = Core.Logger("stock-external-updated", { + const logger = AioLogger("stock-external-updated", { level: params.LOG_LEVEL || "info", }); logger.info("Start processing request"); @@ -27,7 +31,7 @@ async function main(params) { const validation = validateData(params); if (!validation.success) { logger.error(`Validation failed with error: ${validation.message}`); - return actionErrorResponse(HTTP_BAD_REQUEST, validation.message); + return badRequest(validation.message); } logger.debug(`Transform data: ${stringParameters(params)}`); const transformed = transformData(params); @@ -37,15 +41,17 @@ async function main(params) { const result = await sendData(params, transformed, preProcessed); if (!result.success) { logger.error(`Send data failed: ${result.message}`); - return actionErrorResponse(result.statusCode, result.message); + return buildErrorResponse(result.statusCode, { + body: { message: result.message }, + }); } logger.debug(`Postprocess data: ${stringParameters(params)}`); postProcess(params, transformed, preProcessed, result); logger.debug("Process finished successfully"); - return actionSuccessResponse("Stock updated successfully"); + return ok("Stock updated successfully"); } catch (error) { logger.error(`Error processing the request: ${error}`); - return actionErrorResponse(HTTP_INTERNAL_ERROR, error.message); + return internalServerError(error.message); } } diff --git a/src/commerce-extensibility-1/actions/stock/external/updated/sender.js b/src/commerce-extensibility-1/actions/stock/external/updated/sender.js index 707ac9ae..37780601 100644 --- a/src/commerce-extensibility-1/actions/stock/external/updated/sender.js +++ b/src/commerce-extensibility-1/actions/stock/external/updated/sender.js @@ -1,10 +1,16 @@ -import { HTTP_INTERNAL_ERROR } from "#lib/constants"; +import { HTTP_INTERNAL_SERVER_ERROR } from "@adobe/aio-commerce-sdk/core/responses"; + import { updateStock } from "#src/stock/commerce-stock-api-client"; /** * This function send the stock updated data to the Adobe commerce REST API * - * @returns the result data of sending information to Adobe commerce + * @returns {Promise< + * | { success: true, message: unknown } + * | { success: false, statusCode: number, message: string } + * >} Result consumed by the action's `main`. On success, `message` carries the + * Adobe Commerce API response; on failure, `statusCode` (from the API error, or + * HTTP_INTERNAL_SERVER_ERROR) and `message` are forwarded to the error response. * @param {object} params - include the env params * @param {object} transformed - transformed received data * @param {object} preProcessed - preprocessed result data @@ -19,7 +25,7 @@ async function sendData(params, transformed, preProcessed) { } catch (error) { return { success: false, - statusCode: error.response?.statusCode || HTTP_INTERNAL_ERROR, + statusCode: error.response?.statusCode || HTTP_INTERNAL_SERVER_ERROR, message: error.message, }; } diff --git a/src/commerce-extensibility-1/actions/webhook/check-stock/index.js b/src/commerce-extensibility-1/actions/webhook/check-stock/index.js index 730a14eb..cd996bea 100644 --- a/src/commerce-extensibility-1/actions/webhook/check-stock/index.js +++ b/src/commerce-extensibility-1/actions/webhook/check-stock/index.js @@ -1,7 +1,11 @@ -import { Core } from "@adobe/aio-sdk"; +import { HTTP_OK } from "@adobe/aio-commerce-sdk/core/responses"; +import { + exceptionOperation, + ok, + successOperation, +} from "@adobe/aio-commerce-sdk/webhooks/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; -import { HTTP_OK } from "#lib/constants"; -import { webhookErrorResponse, webhookSuccessResponse } from "#lib/responses"; import { stringParameters } from "#lib/utils"; import { checkAvailableStock } from "./stock.js"; @@ -14,7 +18,7 @@ import { validateData } from "./validator.js"; * @returns - response with success status and result */ async function main(params) { - const logger = Core.Logger("webhook-check-stock", { + const logger = AioLogger("webhook-check-stock", { level: params.LOG_LEVEL || "info", }); try { @@ -23,18 +27,18 @@ async function main(params) { const validationResult = validateData(params); if (!validationResult.success) { logger.error(`Validation failed with error: ${validationResult.message}`); - return webhookErrorResponse(validationResult.message); + return ok(exceptionOperation(validationResult.message)); } const checkAvailableStockResult = await checkAvailableStock(params.data); if (!checkAvailableStockResult.success) { logger.error(`Stock check failed: ${checkAvailableStockResult.message}`); - return webhookErrorResponse(checkAvailableStockResult.message); + return ok(exceptionOperation(checkAvailableStockResult.message)); } logger.info(`Successful request: ${HTTP_OK}`); - return webhookSuccessResponse(); + return ok(successOperation()); } catch (error) { logger.error(`Server error: ${error.message}`, error); - return webhookErrorResponse(error.message); + return ok(exceptionOperation(error.message)); } } diff --git a/src/commerce-extensibility-1/lib/constants.js b/src/commerce-extensibility-1/lib/constants.js deleted file mode 100644 index caf162ea..00000000 --- a/src/commerce-extensibility-1/lib/constants.js +++ /dev/null @@ -1,17 +0,0 @@ -const HTTP_OK = 200; -const HTTP_BAD_REQUEST = 400; -const HTTP_UNAUTHORIZED = 401; -const HTTP_NOT_FOUND = 404; -const HTTP_INTERNAL_ERROR = 500; -const BACKOFFICE_PROVIDER_KEY = "backoffice"; -const PUBLISH_EVENT_SUCCESS = "OK"; - -export { - BACKOFFICE_PROVIDER_KEY, - HTTP_BAD_REQUEST, - HTTP_INTERNAL_ERROR, - HTTP_NOT_FOUND, - HTTP_OK, - HTTP_UNAUTHORIZED, - PUBLISH_EVENT_SUCCESS, -}; diff --git a/src/commerce-extensibility-1/lib/responses.js b/src/commerce-extensibility-1/lib/responses.js deleted file mode 100644 index c8d52c58..00000000 --- a/src/commerce-extensibility-1/lib/responses.js +++ /dev/null @@ -1,169 +0,0 @@ -import { HTTP_OK } from "./constants.js"; - -/** - * - * Returns a success response object, this method should be called on the handlers actions - * - * @param {string} message a descriptive message of the result - * e.g. 'missing xyz parameter' - * @returns the response object, ready to be returned from the action main's function. - */ -function actionSuccessResponse(message) { - return { - statusCode: HTTP_OK, - body: { - success: true, - message, - }, - }; -} - -/** - * - * Returns a success response object, this method should be called on the handlers actions - * - * @param {number} statusCode the status code. - * e.g. 400 - * @param {string} error a descriptive message of the result - * e.g. 'missing xyz parameter' - * @returns the response object, ready to be returned from the action main's function. - */ -function actionErrorResponse(statusCode, error) { - return { - statusCode, - body: { - success: false, - error, - }, - }; -} - -/** - * Helper function used to determine if an action was successful. - * @param {unknown} result - The result of the instrumented action. - * @returns - True if the action is successful, false otherwise. - */ -function isActionSuccessful(result) { - if (result && typeof result === "object") { - return "body" in result && "success" in result.body && result.body.success; - } - - // Not an object, we assume it's successful if it has a truthy value. - return !!result; -} - -/** - * - * Returns an error response object, this method should be called on the consumers and public webhooks - * - * @param {number} statusCode the error status code. - * e.g. 400 - * @param {string} message the error message. - * e.g. 'missing xyz parameter' - * @returns the error object, ready to be returned from the action main's function. - */ -function errorResponse(statusCode, message) { - return { - error: { - statusCode, - body: { - error: message, - }, - }, - }; -} - -/** - * - * Returns a success response object, this method should be called on the consumers - * - * @param {string} type the event type received by consumer - * e.g. 'adobe.commerce.observer.catalog_product_save_commit_after' - * @param {object} response the response object returned from the event handler - * e.g. '{ success: true, message: 'Product created successfully'}' - * @returns the response object, ready to be returned from the action main's function. - */ -function successResponse(type, response) { - return { - statusCode: HTTP_OK, - body: { - type, - response, - }, - }; -} - -/** - * Helper function used to determine if a consumer was successful. - * @param {unknown} result - The result of the instrumented consumer. - * @returns - True if the consumer is successful, false otherwise. - */ -function isConsumerSuccessful(result) { - if (result && typeof result === "object") { - if ("error" in result) { - return false; - } - return "statusCode" in result && result.statusCode === HTTP_OK; - } - - // Not an object, we assume it's successful if it has a truthy value. - return !!result; -} - -/** - * Returns response error adapted to ingestion webhooks module - * - * @param {string} message the error message. - * e.g. 'missing xyz parameter' - * @returns the response object, ready to be returned from the action main's function. - */ -function webhookErrorResponse(message) { - return { - statusCode: HTTP_OK, - body: { - op: "exception", - message, - }, - }; -} - -/** - * - * Returns a success response object, this method should be called on the sync webhooks - * - * @returns the response object, ready to be returned from the action main's function. - */ -function webhookSuccessResponse() { - return { - statusCode: HTTP_OK, - body: { - op: "success", - }, - }; -} - -/** - * Helper function used to determine if a webhook was successful. - * @param {unknown} result - The result of the instrumented webhook. - * @returns - True if the webhook is successful, false otherwise. - */ -function isWebhookSuccessful(result) { - if (result && typeof result === "object") { - return "op" in result && result.op === "success"; - } - - // Not an object, we assume it's successful if it has a truthy value. - return !!result; -} - -export { - actionErrorResponse, - actionSuccessResponse, - errorResponse, - isActionSuccessful, - isConsumerSuccessful, - isWebhookSuccessful, - successResponse, - webhookErrorResponse, - webhookSuccessResponse, -}; diff --git a/src/commerce-extensibility-1/lib/utils.js b/src/lib/utils.js similarity index 100% rename from src/commerce-extensibility-1/lib/utils.js rename to src/lib/utils.js diff --git a/src/commerce-extensibility-1/telemetry.js b/src/telemetry.js similarity index 100% rename from src/commerce-extensibility-1/telemetry.js rename to src/telemetry.js diff --git a/test/commerce-extensibility-1/actions/customer/commerce/created/created.test.js b/test/commerce-extensibility-1/actions/customer/commerce/created/created.test.js index 1b0ddae8..0f53ef7b 100644 --- a/test/commerce-extensibility-1/actions/customer/commerce/created/created.test.js +++ b/test/commerce-extensibility-1/actions/customer/commerce/created/created.test.js @@ -37,10 +37,8 @@ describe("Given customer commerce created action", () => { expect(response).toEqual({ statusCode: 200, - body: { - success: true, - message: "Skipped: customer is not newly created", - }, + type: "success", + body: { message: "Skipped: customer is not newly created" }, }); expect(validateData).not.toHaveBeenCalled(); }); @@ -61,11 +59,8 @@ describe("Given customer commerce created action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/customer/commerce/deleted/deleted.test.js b/test/commerce-extensibility-1/actions/customer/commerce/deleted/deleted.test.js index f30c44d8..bac3cf33 100644 --- a/test/commerce-extensibility-1/actions/customer/commerce/deleted/deleted.test.js +++ b/test/commerce-extensibility-1/actions/customer/commerce/deleted/deleted.test.js @@ -30,11 +30,8 @@ describe("Given customer commerce deleted action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/customer/commerce/group-deleted/group-deleted.test.js b/test/commerce-extensibility-1/actions/customer/commerce/group-deleted/group-deleted.test.js index a7c130f8..2a1a2d04 100644 --- a/test/commerce-extensibility-1/actions/customer/commerce/group-deleted/group-deleted.test.js +++ b/test/commerce-extensibility-1/actions/customer/commerce/group-deleted/group-deleted.test.js @@ -30,11 +30,8 @@ describe("Given customer group commerce deleted action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/customer/commerce/group-updated/group-updated.test.js b/test/commerce-extensibility-1/actions/customer/commerce/group-updated/group-updated.test.js index b1d34dcf..dcb72463 100644 --- a/test/commerce-extensibility-1/actions/customer/commerce/group-updated/group-updated.test.js +++ b/test/commerce-extensibility-1/actions/customer/commerce/group-updated/group-updated.test.js @@ -30,11 +30,8 @@ describe("Given customer group commerce updated action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/customer/commerce/updated/updated.test.js b/test/commerce-extensibility-1/actions/customer/commerce/updated/updated.test.js index d53a4e00..66253776 100644 --- a/test/commerce-extensibility-1/actions/customer/commerce/updated/updated.test.js +++ b/test/commerce-extensibility-1/actions/customer/commerce/updated/updated.test.js @@ -30,10 +30,8 @@ describe("Given customer commerce updated action", () => { expect(response).toEqual({ statusCode: 200, - body: { - success: true, - message: "Skipped: customer was not updated", - }, + type: "success", + body: { message: "Skipped: customer was not updated" }, }); expect(validateData).not.toHaveBeenCalled(); }); @@ -53,11 +51,8 @@ describe("Given customer commerce updated action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/customer/external/created/created.test.js b/test/commerce-extensibility-1/actions/customer/external/created/created.test.js index 8cf8ee82..551335ff 100644 --- a/test/commerce-extensibility-1/actions/customer/external/created/created.test.js +++ b/test/commerce-extensibility-1/actions/customer/external/created/created.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/customer/external/created/validator"; vi.mock("#src/customer/external/created/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/customer/external/created/index"; import { sendData } from "#src/customer/external/created/sender"; @@ -22,10 +27,10 @@ describe("Given customer external created action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given customer external created action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -61,12 +66,7 @@ describe("Given customer external created action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/customer/external/deleted/deleted.test.js b/test/commerce-extensibility-1/actions/customer/external/deleted/deleted.test.js index 17525044..a449f578 100644 --- a/test/commerce-extensibility-1/actions/customer/external/deleted/deleted.test.js +++ b/test/commerce-extensibility-1/actions/customer/external/deleted/deleted.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/customer/external/deleted/validator"; vi.mock("#src/customer/external/deleted/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/customer/external/deleted/index"; import { sendData } from "#src/customer/external/deleted/sender"; @@ -22,10 +27,10 @@ describe("Given customer external deleted action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given customer external deleted action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -61,12 +66,7 @@ describe("Given customer external deleted action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/customer/external/group-created/group-created.test.js b/test/commerce-extensibility-1/actions/customer/external/group-created/group-created.test.js index 8d31adc9..96d790ac 100644 --- a/test/commerce-extensibility-1/actions/customer/external/group-created/group-created.test.js +++ b/test/commerce-extensibility-1/actions/customer/external/group-created/group-created.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/customer/external/group-created/validator"; vi.mock("#src/customer/external/group-created/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/customer/external/group-created/index"; import { sendData } from "#src/customer/external/group-created/sender"; @@ -22,10 +27,10 @@ describe("Given customer group external created action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given customer group external created action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -61,12 +66,7 @@ describe("Given customer group external created action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/customer/external/group-deleted/group-deleted.test.js b/test/commerce-extensibility-1/actions/customer/external/group-deleted/group-deleted.test.js index b6833358..f7390e75 100644 --- a/test/commerce-extensibility-1/actions/customer/external/group-deleted/group-deleted.test.js +++ b/test/commerce-extensibility-1/actions/customer/external/group-deleted/group-deleted.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/customer/external/group-deleted/validator"; vi.mock("#src/customer/external/group-deleted/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/customer/external/group-deleted/index"; import { sendData } from "#src/customer/external/group-deleted/sender"; @@ -22,10 +27,10 @@ describe("Given customer group external deleted action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given customer group external deleted action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -61,12 +66,7 @@ describe("Given customer group external deleted action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/customer/external/group-updated/group-updated.test.js b/test/commerce-extensibility-1/actions/customer/external/group-updated/group-updated.test.js index eff4a7bc..c762ce30 100644 --- a/test/commerce-extensibility-1/actions/customer/external/group-updated/group-updated.test.js +++ b/test/commerce-extensibility-1/actions/customer/external/group-updated/group-updated.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/customer/external/group-updated/validator"; vi.mock("#src/customer/external/group-updated/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/customer/external/group-updated/index"; import { sendData } from "#src/customer/external/group-updated/sender"; @@ -22,10 +27,10 @@ describe("Given customer group external updated action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given customer group external updated action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -61,12 +66,7 @@ describe("Given customer group external updated action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/customer/external/updated/updated.test.js b/test/commerce-extensibility-1/actions/customer/external/updated/updated.test.js index b8285491..262b47d9 100644 --- a/test/commerce-extensibility-1/actions/customer/external/updated/updated.test.js +++ b/test/commerce-extensibility-1/actions/customer/external/updated/updated.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/customer/external/updated/validator"; vi.mock("#src/customer/external/updated/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/customer/external/updated/index"; import { sendData } from "#src/customer/external/updated/sender"; @@ -22,10 +27,10 @@ describe("Given customer external updated action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given customer external updated action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -61,12 +66,7 @@ describe("Given customer external updated action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/ingestion/webhook/webhook.test.js b/test/commerce-extensibility-1/actions/ingestion/webhook/webhook.test.js index 649799a5..c8db66d2 100644 --- a/test/commerce-extensibility-1/actions/ingestion/webhook/webhook.test.js +++ b/test/commerce-extensibility-1/actions/ingestion/webhook/webhook.test.js @@ -1,20 +1,20 @@ -import { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error"; +import { CommerceSdkValidationError } from "@adobe/aio-commerce-sdk/core/error"; -vi.mock("@adobe/aio-sdk", () => ({ - Core: { Logger: vi.fn() }, +vi.mock("@adobe/aio-lib-core-logging", () => ({ + default: vi.fn(), })); -import { Core } from "@adobe/aio-sdk"; +import AioLogger from "@adobe/aio-lib-core-logging"; vi.mock("@adobe/aio-commerce-lib-app", () => ({ publishEvent: vi.fn() })); import { publishEvent } from "@adobe/aio-commerce-lib-app"; -vi.mock("@adobe/aio-commerce-lib-events/io-events", () => ({ +vi.mock("@adobe/aio-commerce-sdk/events/io-events", () => ({ createAdobeIoEventsApiClient: vi.fn(() => ({ id: "events-client" })), })); -import { createAdobeIoEventsApiClient } from "@adobe/aio-commerce-lib-events/io-events"; +import { createAdobeIoEventsApiClient } from "@adobe/aio-commerce-sdk/events/io-events"; vi.mock("@adobe/aio-commerce-sdk/auth", () => ({ resolveImsAuthParams: vi.fn(() => ({ ims: "auth" })), @@ -29,7 +29,7 @@ const mockLoggerInstance = { debug: vi.fn(), error: vi.fn(), }; -Core.Logger.mockReturnValue(mockLoggerInstance); +AioLogger.mockReturnValue(mockLoggerInstance); afterEach(() => { vi.clearAllMocks(); @@ -71,12 +71,13 @@ describe("Given external backoffice events ingestion webhook", () => { }); expect(response).toEqual({ statusCode: 200, + type: "success", body: { + type: validData.event, response: { success: true, message: "Event published successfully", }, - type: validData.event, }, }); }); @@ -88,10 +89,11 @@ describe("Given external backoffice events ingestion webhook", () => { expect(publishEvent).not.toHaveBeenCalled(); expect(response).toEqual({ + type: "error", error: { statusCode: 400, body: { - error: "missing parameter(s) 'data.uid,data.event,data.value'", + message: "missing parameter(s) 'data.uid,data.event,data.value'", }, }, }); @@ -105,9 +107,10 @@ describe("Given external backoffice events ingestion webhook", () => { const response = await action.main({ data: validData }); expect(response).toEqual({ + type: "error", error: { statusCode: 500, - body: { error: "fake error" }, + body: { message: "fake error" }, }, }); }); @@ -120,9 +123,10 @@ describe("Given external backoffice events ingestion webhook", () => { const response = await action.main({ data: validData }); expect(response).toEqual({ + type: "error", error: { statusCode: 500, - body: { error: "Invalid event data" }, + body: { message: "Invalid event data" }, }, }); expect(mockLoggerInstance.error).toHaveBeenCalledWith( diff --git a/test/commerce-extensibility-1/actions/order/commerce/created/created.test.js b/test/commerce-extensibility-1/actions/order/commerce/created/created.test.js index 68e29f3f..24896b45 100644 --- a/test/commerce-extensibility-1/actions/order/commerce/created/created.test.js +++ b/test/commerce-extensibility-1/actions/order/commerce/created/created.test.js @@ -30,10 +30,8 @@ describe("Given order commerce created action", () => { expect(response).toEqual({ statusCode: 200, - body: { - success: true, - message: "Skipped: order is not newly created", - }, + type: "success", + body: { message: "Skipped: order is not newly created" }, }); expect(validateData).not.toHaveBeenCalled(); }); @@ -53,11 +51,8 @@ describe("Given order commerce created action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/order/commerce/updated/updated.test.js b/test/commerce-extensibility-1/actions/order/commerce/updated/updated.test.js index 0adfc938..59804a2d 100644 --- a/test/commerce-extensibility-1/actions/order/commerce/updated/updated.test.js +++ b/test/commerce-extensibility-1/actions/order/commerce/updated/updated.test.js @@ -30,10 +30,8 @@ describe("Given order commerce updated action", () => { expect(response).toEqual({ statusCode: 200, - body: { - success: true, - message: "Skipped: order was not updated", - }, + type: "success", + body: { message: "Skipped: order was not updated" }, }); expect(validateData).not.toHaveBeenCalled(); }); @@ -53,11 +51,8 @@ describe("Given order commerce updated action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/order/external/shipment-created/shipment-created.test.js b/test/commerce-extensibility-1/actions/order/external/shipment-created/shipment-created.test.js index 78b1c358..064dc3c8 100644 --- a/test/commerce-extensibility-1/actions/order/external/shipment-created/shipment-created.test.js +++ b/test/commerce-extensibility-1/actions/order/external/shipment-created/shipment-created.test.js @@ -6,7 +6,12 @@ vi.mock("#src/order/external/shipment-created/transformer"); vi.mock("#src/order/external/shipment-created/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/order/external/shipment-created/index"; import { sendData } from "#src/order/external/shipment-created/sender"; @@ -24,10 +29,10 @@ describe("Given order external shipment created action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -42,10 +47,10 @@ describe("Given order external shipment created action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -64,12 +69,7 @@ describe("Given order external shipment created action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/order/external/shipment-updated/shipment-updated.test.js b/test/commerce-extensibility-1/actions/order/external/shipment-updated/shipment-updated.test.js index c87012eb..748a23da 100644 --- a/test/commerce-extensibility-1/actions/order/external/shipment-updated/shipment-updated.test.js +++ b/test/commerce-extensibility-1/actions/order/external/shipment-updated/shipment-updated.test.js @@ -6,7 +6,12 @@ vi.mock("#src/order/external/shipment-updated/transformer"); vi.mock("#src/order/external/shipment-updated/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/order/external/shipment-updated/index"; import { sendData } from "#src/order/external/shipment-updated/sender"; @@ -24,10 +29,10 @@ describe("Given order external shipment updated action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -43,10 +48,10 @@ describe("Given order external shipment updated action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -64,12 +69,7 @@ describe("Given order external shipment updated action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/order/external/updated/updated.test.js b/test/commerce-extensibility-1/actions/order/external/updated/updated.test.js index c6aea048..98560275 100644 --- a/test/commerce-extensibility-1/actions/order/external/updated/updated.test.js +++ b/test/commerce-extensibility-1/actions/order/external/updated/updated.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/order/external/updated/validator"; vi.mock("#src/order/external/updated/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/order/external/updated/index"; import { sendData } from "#src/order/external/updated/sender"; @@ -22,10 +27,10 @@ describe("Given order external updated action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given order external updated action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -61,12 +66,7 @@ describe("Given order external updated action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/product/commerce/created/created.test.js b/test/commerce-extensibility-1/actions/product/commerce/created/created.test.js index be57f69e..c3b3e6d3 100644 --- a/test/commerce-extensibility-1/actions/product/commerce/created/created.test.js +++ b/test/commerce-extensibility-1/actions/product/commerce/created/created.test.js @@ -30,10 +30,8 @@ describe("Given product commerce created action", () => { expect(response).toEqual({ statusCode: 200, - body: { - success: true, - message: "Skipped: product is not newly created", - }, + type: "success", + body: { message: "Skipped: product is not newly created" }, }); expect(validateData).not.toHaveBeenCalled(); }); @@ -53,11 +51,8 @@ describe("Given product commerce created action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/product/commerce/deleted/deleted.test.js b/test/commerce-extensibility-1/actions/product/commerce/deleted/deleted.test.js index fc2dd9a7..613c3e27 100644 --- a/test/commerce-extensibility-1/actions/product/commerce/deleted/deleted.test.js +++ b/test/commerce-extensibility-1/actions/product/commerce/deleted/deleted.test.js @@ -30,11 +30,8 @@ describe("Given product commerce deleted action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/product/commerce/full-sync/full-sync.test.js b/test/commerce-extensibility-1/actions/product/commerce/full-sync/full-sync.test.js index 5a10f28c..a2e6fc14 100644 --- a/test/commerce-extensibility-1/actions/product/commerce/full-sync/full-sync.test.js +++ b/test/commerce-extensibility-1/actions/product/commerce/full-sync/full-sync.test.js @@ -54,8 +54,8 @@ describe("Given product commerce full sync action", () => { expect(response).toEqual({ statusCode: 200, + type: "success", body: { - success: true, message: expect.stringContaining("completed with some errors"), }, }); @@ -74,8 +74,8 @@ describe("Given product commerce full sync action", () => { expect(response).toEqual({ statusCode: 200, + type: "success", body: { - success: true, message: expect.stringContaining("completed with some errors"), }, }); @@ -103,8 +103,8 @@ describe("Given product commerce full sync action", () => { expect(response).toEqual({ statusCode: 200, + type: "success", body: { - success: true, message: expect.stringContaining("completed with some errors"), }, }); diff --git a/test/commerce-extensibility-1/actions/product/commerce/updated/updated.test.js b/test/commerce-extensibility-1/actions/product/commerce/updated/updated.test.js index 145c4232..5e76e4cd 100644 --- a/test/commerce-extensibility-1/actions/product/commerce/updated/updated.test.js +++ b/test/commerce-extensibility-1/actions/product/commerce/updated/updated.test.js @@ -30,10 +30,8 @@ describe("Given product commerce updated action", () => { expect(response).toEqual({ statusCode: 200, - body: { - success: true, - message: "Skipped: product was not updated", - }, + type: "success", + body: { message: "Skipped: product was not updated" }, }); expect(validateData).not.toHaveBeenCalled(); }); @@ -53,11 +51,8 @@ describe("Given product commerce updated action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/product/external/created/created.test.js b/test/commerce-extensibility-1/actions/product/external/created/created.test.js index cf20463a..76cfbd97 100644 --- a/test/commerce-extensibility-1/actions/product/external/created/created.test.js +++ b/test/commerce-extensibility-1/actions/product/external/created/created.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/product/external/created/validator"; vi.mock("#src/product/external/created/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/product/external/created/index"; import { sendData } from "#src/product/external/created/sender"; @@ -22,10 +27,10 @@ describe("Given product external created action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given product external created action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -62,12 +67,7 @@ describe("Given product external created action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/product/external/deleted/deleted.test.js b/test/commerce-extensibility-1/actions/product/external/deleted/deleted.test.js index 4faad6f3..f7735043 100644 --- a/test/commerce-extensibility-1/actions/product/external/deleted/deleted.test.js +++ b/test/commerce-extensibility-1/actions/product/external/deleted/deleted.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/product/external/deleted/validator"; vi.mock("#src/product/external/deleted/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/product/external/deleted/index"; import { sendData } from "#src/product/external/deleted/sender"; @@ -22,10 +27,10 @@ describe("Given product external deleted action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given product external deleted action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -61,12 +66,7 @@ describe("Given product external deleted action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/product/external/updated/updated.test.js b/test/commerce-extensibility-1/actions/product/external/updated/updated.test.js index c403526d..acb5c2ff 100644 --- a/test/commerce-extensibility-1/actions/product/external/updated/updated.test.js +++ b/test/commerce-extensibility-1/actions/product/external/updated/updated.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/product/external/updated/validator"; vi.mock("#src/product/external/updated/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/product/external/updated/index"; import { sendData } from "#src/product/external/updated/sender"; @@ -22,10 +27,10 @@ describe("Given product external updated action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given product external updated action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -61,12 +66,7 @@ describe("Given product external updated action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/responses.test.js b/test/commerce-extensibility-1/actions/responses.test.js deleted file mode 100644 index 627514be..00000000 --- a/test/commerce-extensibility-1/actions/responses.test.js +++ /dev/null @@ -1,66 +0,0 @@ -import { HTTP_BAD_REQUEST, HTTP_OK } from "#lib/constants"; -import * as responses from "#lib/responses"; - -describe("Given responses file", () => { - describe("When method errorResponse is called", () => { - test("Then returns error response", () => { - const res = responses.errorResponse(HTTP_BAD_REQUEST, "errorMessage"); - expect(res).toEqual({ - error: { - statusCode: HTTP_BAD_REQUEST, - body: { - error: "errorMessage", - }, - }, - }); - }); - }); - - describe("When method actionErrorResponse is called", () => { - test("Then returns action error response", () => { - const res = responses.actionErrorResponse( - HTTP_BAD_REQUEST, - "errorMessage", - ); - expect(res).toEqual({ - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "errorMessage", - }, - }); - }); - }); - - describe("When method actionSuccessResponse is called", () => { - test("Then returns action success response", () => { - const res = responses.actionSuccessResponse("successMessage"); - expect(res).toEqual({ - statusCode: HTTP_OK, - body: { - success: true, - message: "successMessage", - }, - }); - }); - }); - - describe("When method successResponse is called", () => { - test("Then returns success response", () => { - const res = responses.successResponse("eventType", { - success: true, - message: "successMessage", - }); - expect(res).toEqual({ - statusCode: HTTP_OK, - body: { - type: "eventType", - response: { - success: true, - message: "successMessage", - }, - }, - }); - }); - }); -}); diff --git a/test/commerce-extensibility-1/actions/stock/commerce/updated/updated.test.js b/test/commerce-extensibility-1/actions/stock/commerce/updated/updated.test.js index f7c6efab..153adf9f 100644 --- a/test/commerce-extensibility-1/actions/stock/commerce/updated/updated.test.js +++ b/test/commerce-extensibility-1/actions/stock/commerce/updated/updated.test.js @@ -29,11 +29,8 @@ describe("Given stock item commerce updated action", () => { const response = await action.main(params); expect(response).toEqual({ - statusCode: 400, - body: { - success: false, - error: ERROR_MESSAGE, - }, + type: "error", + error: { statusCode: 400, body: { message: ERROR_MESSAGE } }, }); }); }); diff --git a/test/commerce-extensibility-1/actions/stock/external/updated/updated.test.js b/test/commerce-extensibility-1/actions/stock/external/updated/updated.test.js index a7000fa9..7ac23a63 100644 --- a/test/commerce-extensibility-1/actions/stock/external/updated/updated.test.js +++ b/test/commerce-extensibility-1/actions/stock/external/updated/updated.test.js @@ -4,7 +4,12 @@ import { validateData } from "#src/stock/external/updated/validator"; vi.mock("#src/stock/external/updated/sender"); -import { HTTP_BAD_REQUEST, HTTP_INTERNAL_ERROR, HTTP_OK } from "#lib/constants"; +import { + HTTP_BAD_REQUEST, + HTTP_INTERNAL_SERVER_ERROR, + HTTP_OK, +} from "@adobe/aio-commerce-sdk/core/responses"; + import * as action from "#src/stock/external/updated/index"; import { sendData } from "#src/stock/external/updated/sender"; @@ -22,10 +27,10 @@ describe("Given stock external updated action", () => { message: "Data provided does not validate with the schema", }; const ERROR_RESPONSE = { - statusCode: HTTP_BAD_REQUEST, - body: { - success: false, - error: "Data provided does not validate with the schema", + type: "error", + error: { + statusCode: HTTP_BAD_REQUEST, + body: { message: "Data provided does not validate with the schema" }, }, }; validateData.mockReturnValue(FAILED_VALIDATION_RESPONSE); @@ -40,10 +45,10 @@ describe("Given stock external updated action", () => { }; const ERROR = new Error("generic error"); const ERROR_RESPONSE = { - statusCode: HTTP_INTERNAL_ERROR, - body: { - success: false, - error: ERROR.message, + type: "error", + error: { + statusCode: HTTP_INTERNAL_SERVER_ERROR, + body: { message: ERROR.message }, }, }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); @@ -61,12 +66,7 @@ describe("Given stock external updated action", () => { success: true, response: "anything", }; - const SUCCESS_RESPONSE = { - statusCode: HTTP_OK, - body: { - success: true, - }, - }; + const SUCCESS_RESPONSE = { statusCode: HTTP_OK, type: "success" }; validateData.mockReturnValue(SUCCESSFUL_VALIDATION_RESPONSE); sendData.mockReturnValue(SUCCESSFUL_SEND_DATA_RESPONSE); expect(await action.main(IGNORED_PARAMS)).toMatchObject(SUCCESS_RESPONSE); diff --git a/test/commerce-extensibility-1/actions/webhook/check-stock/check-stock.test.js b/test/commerce-extensibility-1/actions/webhook/check-stock/check-stock.test.js index 972e0e2b..72886ffa 100644 --- a/test/commerce-extensibility-1/actions/webhook/check-stock/check-stock.test.js +++ b/test/commerce-extensibility-1/actions/webhook/check-stock/check-stock.test.js @@ -42,6 +42,7 @@ describe("Given synchronous webhook action to check stock availability", () => { expect(response).toEqual({ statusCode: 200, + type: "success", body: { op: "success", }, @@ -56,6 +57,7 @@ describe("Given synchronous webhook action to check stock availability", () => { expect(response).toEqual({ statusCode: 200, + type: "success", body: { op: "exception", message: "missing parameter(s) 'data.cart_id,data.items'", @@ -89,6 +91,7 @@ describe("Given synchronous webhook action to check stock availability", () => { expect(response).toEqual({ statusCode: 200, + type: "success", body: { op: "exception", message: "no stock found",