diff --git a/README.md b/README.md index 324ea2fb..25ff5ccf 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ _Table of contents_: - [**Prerequisites**](#prerequisites) - [**Starter Kit first deploy \& onboarding**](#starter-kit-first-deploy--onboarding) - [**Development**](#development) + - [**Business Configuration**](#business-configuration) - [**Integrating OpenTelemetry**](#integrating-opentelemetry) - [**Included actions documentation**](#included-actions-documentation) - [**References**](#references) @@ -36,7 +37,7 @@ Go to the [Adobe developer console](https://developer.adobe.com/console) portal - Adobe I/O Events for Adobe Commerce - Adobe Commerce as a Cloud Service. - If upgrading from previous versions without Adobe Commerce as a Cloud Service API: - - Check `.env` to ensure that `commerce.accs` scope has been added to `OAUTH_SCOPES` + - Check `.env` to ensure that `commerce.accs` scope has been added to `AIO_COMMERCE_AUTH_IMS_SCOPES` - Download again workspace configuration as explained below and execute `aio app use` again. - Download the [workspace configuration JSON](https://developer.adobe.com/commerce/extensibility/events/project-setup/#download-the-workspace-configuration-file) file and save it as `workspace.json` in the `./scripts/onboarding/config` starter kit folder because you will use it to configure Adobe IO Events in commerce afterward. @@ -62,7 +63,7 @@ Following the next steps, you will deploy and onboard the starter kit for the fi - Fill in the values following the comments on the env file. > [!NOTE] -> When configuring the `COMMERCE_BASE_URL` environment variable, the format differs between PaaS and SaaS: +> When configuring the `AIO_COMMERCE_API_BASE_URL` environment variable, the format differs between PaaS and SaaS: > > For PaaS (On-Premise/Cloud): > @@ -101,10 +102,10 @@ Configure a new Integration to secure the calls to Commerce from App Builder usi Store the credentials in the `.env` file, these are the minimum required values: ```dotenv -COMMERCE_CONSUMER_KEY= -COMMERCE_CONSUMER_SECRET= -COMMERCE_ACCESS_TOKEN= -COMMERCE_ACCESS_TOKEN_SECRET= +AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY= +AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET= +AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN= +AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET= ``` #### \[SaaS\] IMS OAuth - Add the OAuth Server to Server credentials to the environment @@ -114,9 +115,9 @@ Configure a new IMS OAuth Server to Server following this [documentation](https: Store the credentials in the `.env` file, these are the minimum required values: ```dotenv -OAUTH_CLIENT_ID= # Your client ID -OAUTH_CLIENT_SECRET= # Your client secret -OAUTH_SCOPES= # ['scope1', 'scope2'] +AIO_COMMERCE_AUTH_IMS_CLIENT_ID= # Your client ID +AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS= # ['client-secret'] +AIO_COMMERCE_AUTH_IMS_SCOPES= # ['scope1', 'scope2'] ``` These are optional values that can be provided: @@ -796,6 +797,12 @@ If you want to change an existing event, make the changes in the same places: - Make changes to the operation action invoked by the consumer switch case. - Deploy your changes +## Business Configuration + +The integration starter kit comes pre-integrated with the `@adobe/aio-commerce-lib-config` library, which provides a way to set up configuration management and querying capabilities for your application. You can find more information about the package in the [library documentation](https://github.com/adobe/aio-commerce-sdk/blob/main/packages/aio-commerce-lib-config/docs/usage.md). + +You can configure the `schema` for your integration in the `businessConfig.schema` section of the [`extensibility.config.js`](./extensibility.config.js) file. See the different supported types in the [schema documentation](https://github.com/adobe/aio-commerce-sdk/blob/main/packages/aio-commerce-lib-config/docs/usage.md#schema-validation). + ## Integrating OpenTelemetry > [!NOTE] diff --git a/actions/auth.js b/actions/auth.js index 3493f374..3cefa412 100644 --- a/actions/auth.js +++ b/actions/auth.js @@ -11,6 +11,7 @@ governing permissions and limitations under the License. */ const { Core } = require("@adobe/aio-sdk"); +const { parseArrayParam } = require("./utils"); const logger = Core.Logger("auth", { level: "info" }); /** * @@ -55,21 +56,22 @@ function validateParams(params, expected) { function fromParams(params) { // `aio app dev` compatibility: inputs mapped to undefined env vars come as $ in dev mode, but as '' in prod mode if ( - params.COMMERCE_CONSUMER_KEY && - params.COMMERCE_CONSUMER_KEY !== "$COMMERCE_CONSUMER_KEY" + params.AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY && + params.AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY !== + "$AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY" ) { logger.info("Commerce client is using Commerce OAuth1 authentication"); validateParams(params, [ - "COMMERCE_CONSUMER_KEY", - "COMMERCE_CONSUMER_SECRET", - "COMMERCE_ACCESS_TOKEN", - "COMMERCE_ACCESS_TOKEN_SECRET", + "AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY", + "AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET", + "AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN", + "AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET", ]); const { - COMMERCE_CONSUMER_KEY: consumerKey, - COMMERCE_CONSUMER_SECRET: consumerSecret, - COMMERCE_ACCESS_TOKEN: accessToken, - COMMERCE_ACCESS_TOKEN_SECRET: accessTokenSecret, + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: consumerKey, + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: consumerSecret, + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: accessToken, + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: accessTokenSecret, } = params; return { commerceOAuth1: { @@ -82,22 +84,34 @@ function fromParams(params) { } // `aio app dev` compatibility: inputs mapped to undefined env vars come as $ in dev mode, but as '' in prod mode - if (params.OAUTH_CLIENT_ID && params.OAUTH_CLIENT_ID !== "$OAUTH_CLIENT_ID") { + if ( + params.AIO_COMMERCE_AUTH_IMS_CLIENT_ID && + params.AIO_COMMERCE_AUTH_IMS_CLIENT_ID !== + "$AIO_COMMERCE_AUTH_IMS_CLIENT_ID" + ) { logger.info("Commerce client is using IMS OAuth authentication"); validateParams(params, [ - "OAUTH_CLIENT_ID", - "OAUTH_CLIENT_SECRET", - "OAUTH_SCOPES", + "AIO_COMMERCE_AUTH_IMS_CLIENT_ID", + "AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS", + "AIO_COMMERCE_AUTH_IMS_SCOPES", ]); const { - OAUTH_CLIENT_ID: clientId, - OAUTH_CLIENT_SECRET: clientSecret, - OAUTH_SCOPES: scopes, + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: clientId, + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: clientSecretsRaw, + AIO_COMMERCE_AUTH_IMS_SCOPES: scopesRaw, } = params; + // Parse JSON strings to arrays + const scopes = parseArrayParam(scopesRaw, ["AdobeID", "openid"]); + const clientSecrets = parseArrayParam(clientSecretsRaw, []).filter( + (secret) => secret.trim() !== "", + ); + const imsProps = { clientId, - clientSecret, + clientSecret: Array.isArray(clientSecrets) + ? clientSecrets[0] + : clientSecrets, scopes, }; if (params.OAUTH_HOST) { diff --git a/actions/customer/external/actions.config.yaml b/actions/customer/external/actions.config.yaml index f17a8a5c..d0471c31 100644 --- a/actions/customer/external/actions.config.yaml +++ b/actions/customer/external/actions.config.yaml @@ -13,14 +13,14 @@ created: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true @@ -30,14 +30,14 @@ updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true @@ -47,14 +47,14 @@ deleted: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true @@ -64,14 +64,14 @@ group-created: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true @@ -81,14 +81,14 @@ group-updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true @@ -98,14 +98,14 @@ group-deleted: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true diff --git a/actions/customer/external/created/docs/README.md b/actions/customer/external/created/docs/README.md index c2eaf96d..88f73849 100644 --- a/actions/customer/external/created/docs/README.md +++ b/actions/customer/external/created/docs/README.md @@ -49,11 +49,11 @@ created: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/customer/external/created/sender.js b/actions/customer/external/created/sender.js index 97d11eab..35f3cd10 100644 --- a/actions/customer/external/created/sender.js +++ b/actions/customer/external/created/sender.js @@ -24,7 +24,7 @@ const { HTTP_INTERNAL_ERROR } = require("../../../constants"); async function sendData(params, transformed, preProcessed) { try { const response = await createCustomer( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/customer/external/deleted/docs/README.md b/actions/customer/external/deleted/docs/README.md index bdba98e6..027abaea 100644 --- a/actions/customer/external/deleted/docs/README.md +++ b/actions/customer/external/deleted/docs/README.md @@ -45,11 +45,11 @@ deleted: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/customer/external/deleted/sender.js b/actions/customer/external/deleted/sender.js index ab5eaeb5..980c4a73 100644 --- a/actions/customer/external/deleted/sender.js +++ b/actions/customer/external/deleted/sender.js @@ -24,7 +24,7 @@ const { HTTP_INTERNAL_ERROR } = require("../../../constants"); async function sendData(params, transformed, preProcessed) { try { const response = await deleteCustomer( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/customer/external/group-created/docs/README.md b/actions/customer/external/group-created/docs/README.md index 8ce3dc84..4296c003 100644 --- a/actions/customer/external/group-created/docs/README.md +++ b/actions/customer/external/group-created/docs/README.md @@ -47,11 +47,11 @@ group-created: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/customer/external/group-created/sender.js b/actions/customer/external/group-created/sender.js index cb6378b2..7689671f 100644 --- a/actions/customer/external/group-created/sender.js +++ b/actions/customer/external/group-created/sender.js @@ -26,7 +26,7 @@ const { async function sendData(params, transformed, preProcessed) { try { const response = await createCustomerGroup( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/customer/external/group-deleted/docs/README.md b/actions/customer/external/group-deleted/docs/README.md index 1be56d6a..22972461 100644 --- a/actions/customer/external/group-deleted/docs/README.md +++ b/actions/customer/external/group-deleted/docs/README.md @@ -45,11 +45,11 @@ group-deleted: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/customer/external/group-deleted/sender.js b/actions/customer/external/group-deleted/sender.js index 1a671be8..32b5f29f 100644 --- a/actions/customer/external/group-deleted/sender.js +++ b/actions/customer/external/group-deleted/sender.js @@ -26,7 +26,7 @@ const { async function sendData(params, transformed, preProcessed) { try { const response = await deleteCustomerGroup( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/customer/external/group-updated/docs/README.md b/actions/customer/external/group-updated/docs/README.md index e09e4768..aa44e4a8 100644 --- a/actions/customer/external/group-updated/docs/README.md +++ b/actions/customer/external/group-updated/docs/README.md @@ -50,11 +50,11 @@ group-updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/customer/external/group-updated/sender.js b/actions/customer/external/group-updated/sender.js index 790ac70e..70196d6a 100644 --- a/actions/customer/external/group-updated/sender.js +++ b/actions/customer/external/group-updated/sender.js @@ -26,7 +26,7 @@ const { async function sendData(params, transformed, preProcessed) { try { const response = await updateCustomerGroup( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/customer/external/updated/docs/README.md b/actions/customer/external/updated/docs/README.md index 48212d52..82690317 100644 --- a/actions/customer/external/updated/docs/README.md +++ b/actions/customer/external/updated/docs/README.md @@ -51,11 +51,11 @@ updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/customer/external/updated/sender.js b/actions/customer/external/updated/sender.js index 1fe37c84..d127347d 100644 --- a/actions/customer/external/updated/sender.js +++ b/actions/customer/external/updated/sender.js @@ -24,7 +24,7 @@ const { HTTP_INTERNAL_ERROR } = require("../../../constants"); async function sendData(params, transformed, preProcessed) { try { const response = await updateCustomer( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/ingestion/actions.config.yaml b/actions/ingestion/actions.config.yaml index 33f72847..4e0ba905 100644 --- a/actions/ingestion/actions.config.yaml +++ b/actions/ingestion/actions.config.yaml @@ -4,11 +4,11 @@ webhook: runtime: nodejs:22 inputs: LOG_LEVEL: debug - OAUTH_ORG_ID: $OAUTH_ORG_ID - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_TECHNICAL_ACCOUNT_ID: $OAUTH_TECHNICAL_ACCOUNT_ID - OAUTH_TECHNICAL_ACCOUNT_EMAIL: $OAUTH_TECHNICAL_ACCOUNT_EMAIL + AIO_COMMERCE_AUTH_IMS_ORG_ID: $AIO_COMMERCE_AUTH_IMS_ORG_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: $AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: $AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL IO_MANAGEMENT_BASE_URL: $IO_MANAGEMENT_BASE_URL IO_CONSUMER_ID: $IO_CONSUMER_ID IO_PROJECT_ID: $IO_PROJECT_ID diff --git a/actions/ingestion/webhook/docs/README.md b/actions/ingestion/webhook/docs/README.md index cc9d33f2..4f1f63ba 100644 --- a/actions/ingestion/webhook/docs/README.md +++ b/actions/ingestion/webhook/docs/README.md @@ -49,11 +49,11 @@ webhook: runtime: nodejs:22 inputs: LOG_LEVEL: debug - OAUTH_ORG_ID: $OAUTH_ORG_ID - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_TECHNICAL_ACCOUNT_ID: $OAUTH_TECHNICAL_ACCOUNT_ID - OAUTH_TECHNICAL_ACCOUNT_EMAIL: $OAUTH_TECHNICAL_ACCOUNT_EMAIL + AIO_COMMERCE_AUTH_IMS_ORG_ID: $AIO_COMMERCE_AUTH_IMS_ORG_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: $AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: $AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL IO_MANAGEMENT_BASE_URL: $IO_MANAGEMENT_BASE_URL IO_CONSUMER_ID: $IO_CONSUMER_ID IO_PROJECT_ID: $IO_PROJECT_ID diff --git a/actions/ingestion/webhook/index.js b/actions/ingestion/webhook/index.js index f157fe23..6b30095c 100644 --- a/actions/ingestion/webhook/index.js +++ b/actions/ingestion/webhook/index.js @@ -67,7 +67,7 @@ async function main(params) { const authHeaders = { Authorization: `Bearer ${accessToken}`, - "x-api-key": params.OAUTH_CLIENT_ID, + "x-api-key": params.AIO_COMMERCE_AUTH_IMS_CLIENT_ID, }; logger.debug("Get existing registrations"); @@ -85,8 +85,8 @@ async function main(params) { logger.debug("Initiate events client"); const eventsClient = await Events.init( - params.OAUTH_ORG_ID, - params.OAUTH_CLIENT_ID, + params.AIO_COMMERCE_AUTH_IMS_ORG_ID, + params.AIO_COMMERCE_AUTH_IMS_CLIENT_ID, accessToken, ); diff --git a/actions/order/external/actions.config.yaml b/actions/order/external/actions.config.yaml index b68b0f13..baa10cd0 100644 --- a/actions/order/external/actions.config.yaml +++ b/actions/order/external/actions.config.yaml @@ -13,14 +13,14 @@ updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true @@ -30,14 +30,14 @@ shipment-created: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true @@ -47,14 +47,14 @@ shipment-updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true diff --git a/actions/order/external/shipment-created/docs/README.md b/actions/order/external/shipment-created/docs/README.md index 6fb6b3b7..5a21805c 100644 --- a/actions/order/external/shipment-created/docs/README.md +++ b/actions/order/external/shipment-created/docs/README.md @@ -105,11 +105,11 @@ shipment-created: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/order/external/shipment-created/sender.js b/actions/order/external/shipment-created/sender.js index dc89d3f1..57d17e73 100644 --- a/actions/order/external/shipment-created/sender.js +++ b/actions/order/external/shipment-created/sender.js @@ -24,7 +24,7 @@ const { HTTP_INTERNAL_ERROR } = require("../../../constants"); async function sendData(params, transformed, preProcessed) { try { const response = await createShipment( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, params.data.orderId, transformed, diff --git a/actions/order/external/shipment-updated/docs/README.md b/actions/order/external/shipment-updated/docs/README.md index 84e33e09..ce2d8fa8 100644 --- a/actions/order/external/shipment-updated/docs/README.md +++ b/actions/order/external/shipment-updated/docs/README.md @@ -120,11 +120,11 @@ shipment-updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/order/external/shipment-updated/sender.js b/actions/order/external/shipment-updated/sender.js index 2ad3eda9..01ae0b8e 100644 --- a/actions/order/external/shipment-updated/sender.js +++ b/actions/order/external/shipment-updated/sender.js @@ -24,7 +24,7 @@ const { HTTP_INTERNAL_ERROR } = require("../../../constants"); async function sendData(params, transformed, preProcessed) { try { const response = await updateShipment( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/order/external/updated/docs/README.md b/actions/order/external/updated/docs/README.md index 94c5aac5..7c67e90d 100644 --- a/actions/order/external/updated/docs/README.md +++ b/actions/order/external/updated/docs/README.md @@ -50,11 +50,11 @@ updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/order/external/updated/sender.js b/actions/order/external/updated/sender.js index a98e4fd8..6d82fa93 100644 --- a/actions/order/external/updated/sender.js +++ b/actions/order/external/updated/sender.js @@ -24,7 +24,7 @@ const { HTTP_INTERNAL_ERROR } = require("../../../constants"); async function sendData(params, transformed, preProcessed) { try { const response = await addComment( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, params.data.id, transformed, diff --git a/actions/product/external/actions.config.yaml b/actions/product/external/actions.config.yaml index 2ed7b0a4..73042d49 100644 --- a/actions/product/external/actions.config.yaml +++ b/actions/product/external/actions.config.yaml @@ -13,14 +13,14 @@ created: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true @@ -30,14 +30,14 @@ updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true @@ -47,14 +47,14 @@ deleted: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true diff --git a/actions/product/external/created/docs/README.md b/actions/product/external/created/docs/README.md index f7cfbf12..13407869 100644 --- a/actions/product/external/created/docs/README.md +++ b/actions/product/external/created/docs/README.md @@ -50,11 +50,11 @@ created: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/product/external/created/sender.js b/actions/product/external/created/sender.js index eb838397..8111383f 100644 --- a/actions/product/external/created/sender.js +++ b/actions/product/external/created/sender.js @@ -24,7 +24,7 @@ const { HTTP_INTERNAL_ERROR } = require("../../../constants"); async function sendData(params, transformed, preProcessed) { try { const response = await createProduct( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/product/external/deleted/docs/README.md b/actions/product/external/deleted/docs/README.md index b3ceda8b..540efe9f 100644 --- a/actions/product/external/deleted/docs/README.md +++ b/actions/product/external/deleted/docs/README.md @@ -45,11 +45,11 @@ deleted: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/product/external/deleted/sender.js b/actions/product/external/deleted/sender.js index 45296153..6f36d121 100644 --- a/actions/product/external/deleted/sender.js +++ b/actions/product/external/deleted/sender.js @@ -24,7 +24,7 @@ const { HTTP_INTERNAL_ERROR } = require("../../../constants"); async function sendData(params, transformed, preProcessed) { try { const response = await deleteProduct( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/product/external/updated/docs/README.md b/actions/product/external/updated/docs/README.md index 785debf3..42862533 100644 --- a/actions/product/external/updated/docs/README.md +++ b/actions/product/external/updated/docs/README.md @@ -51,11 +51,11 @@ updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/product/external/updated/sender.js b/actions/product/external/updated/sender.js index 369fb596..5ad20067 100644 --- a/actions/product/external/updated/sender.js +++ b/actions/product/external/updated/sender.js @@ -24,7 +24,7 @@ const { HTTP_INTERNAL_ERROR } = require("../../../constants"); async function sendData(params, transformed, preProcessed) { try { const response = await updateProduct( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/stock/external/actions.config.yaml b/actions/stock/external/actions.config.yaml index 3a3a19c0..22ed18cd 100644 --- a/actions/stock/external/actions.config.yaml +++ b/actions/stock/external/actions.config.yaml @@ -13,14 +13,14 @@ updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET - OAUTH_CLIENT_ID: $OAUTH_CLIENT_ID - OAUTH_CLIENT_SECRET: $OAUTH_CLIENT_SECRET - OAUTH_SCOPES: $OAUTH_SCOPES + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES annotations: require-adobe-auth: true final: true diff --git a/actions/stock/external/updated/docs/README.md b/actions/stock/external/updated/docs/README.md index 4f67ca8b..7abb49b1 100644 --- a/actions/stock/external/updated/docs/README.md +++ b/actions/stock/external/updated/docs/README.md @@ -63,11 +63,11 @@ updated: runtime: nodejs:22 inputs: LOG_LEVEL: debug - COMMERCE_BASE_URL: $COMMERCE_BASE_URL - COMMERCE_CONSUMER_KEY: $COMMERCE_CONSUMER_KEY - COMMERCE_CONSUMER_SECRET: $COMMERCE_CONSUMER_SECRET - COMMERCE_ACCESS_TOKEN: $COMMERCE_ACCESS_TOKEN - COMMERCE_ACCESS_TOKEN_SECRET: $COMMERCE_ACCESS_TOKEN_SECRET + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET annotations: require-adobe-auth: true final: true diff --git a/actions/stock/external/updated/sender.js b/actions/stock/external/updated/sender.js index 1a075b4f..fb54d604 100644 --- a/actions/stock/external/updated/sender.js +++ b/actions/stock/external/updated/sender.js @@ -24,7 +24,7 @@ const { HTTP_INTERNAL_ERROR } = require("../../../constants"); async function sendData(params, transformed, preProcessed) { try { const response = await updateStock( - params.COMMERCE_BASE_URL, + params.AIO_COMMERCE_API_BASE_URL, params, transformed, ); diff --git a/actions/utils.js b/actions/utils.js index a41b99e7..bc5f0b1a 100644 --- a/actions/utils.js +++ b/actions/utils.js @@ -118,8 +118,31 @@ function checkMissingRequestInputs( return errorMessage; } +/** + * Parse JSON string to array, fallback to default if invalid + * @param {string|Array} value - Value to parse (could be JSON string or already an array) + * @param {Array} defaultValue - Default value if parsing fails + * @returns {Array} Parsed array or default value + */ +function parseArrayParam(value, defaultValue = []) { + if (Array.isArray(value)) { + return value; + } + if (typeof value === "string" && value.trim()) { + try { + const parsed = JSON.parse(value); + return Array.isArray(parsed) ? parsed : defaultValue; + } catch { + // If it's not JSON, treat as single value array + return [value]; + } + } + return defaultValue; +} + module.exports = { stringParameters, getMissingKeys, checkMissingRequestInputs, + parseArrayParam, }; diff --git a/app.config.yaml b/app.config.yaml index 0d77b779..2c1a6d77 100644 --- a/app.config.yaml +++ b/app.config.yaml @@ -1,6 +1,6 @@ application: -# hooks: -# post-app-deploy: ./hooks/post-app-deploy.js + # hooks: + # post-app-deploy: ./hooks/post-app-deploy.js runtimeManifest: packages: starter-kit: @@ -56,6 +56,12 @@ application: license: Apache-2.0 actions: $include: ./actions/stock/external/actions.config.yaml + +extensions: + # This extension is required by `@adobe/aio-commerce-lib-config`. + commerce/configuration/1: + $include: src/commerce-configuration-1/ext.config.yaml + productDependencies: - code: COMMC - minVersion: 2.4.4 + minVersion: 2.4.4 \ No newline at end of file diff --git a/biome.jsonc b/biome.jsonc index b4b4869a..0abfd3de 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -77,6 +77,18 @@ } } } + }, + { + "includes": ["src/commerce-configuration-1/.generated/**"], + "linter": { + "enabled": false + }, + "formatter": { + "enabled": false + }, + "assist": { + "enabled": false + } } ], diff --git a/env.dist b/env.dist index 86e2c4e4..5fc97fb2 100644 --- a/env.dist +++ b/env.dist @@ -3,27 +3,27 @@ IO_MANAGEMENT_BASE_URL=https://api.adobe.io/events/ # Commerce endpoints # Commerce base URL should finish with slash '/' -COMMERCE_BASE_URL= +AIO_COMMERCE_API_BASE_URL= COMMERCE_GRAPHQL_ENDPOINT= # Required for SaaS authentication and to authorize access to event management endpoints # Also needed for event provider creation and subscription in Adobe I/O Events # # These values can be copied from the Credential details page in AppBuilder under Organization > Project > Workspace > OAuth Server-to-Server -OAUTH_CLIENT_ID= -OAUTH_CLIENT_SECRET= -OAUTH_TECHNICAL_ACCOUNT_ID= -OAUTH_TECHNICAL_ACCOUNT_EMAIL= -OAUTH_ORG_ID= -OAUTH_SCOPES=AdobeID, openid, read_organizations, additional_info.projectedProductContext, additional_info.roles, adobeio_api, read_client_secret, manage_client_secrets, event_receiver_api, commerce.accs +AIO_COMMERCE_AUTH_IMS_CLIENT_ID= +AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS=[""] +AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID= +AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL= +AIO_COMMERCE_AUTH_IMS_ORG_ID= +AIO_COMMERCE_AUTH_IMS_SCOPES=["AdobeID", "openid", "read_organizations", "additional_info.projectedProductContext", "additional_info.roles", "adobeio_api", "read_client_secret", "manage_client_secrets", "event_receiver_api", "commerce.accs"] #OAUTH_HOST= # PaaS Only. OAuth credentials for Adobe Commerce On-Premise / Cloud # These values can be copied from the Integration Details page in Commerce under System > Integrations -COMMERCE_CONSUMER_KEY= -COMMERCE_CONSUMER_SECRET= -COMMERCE_ACCESS_TOKEN= -COMMERCE_ACCESS_TOKEN_SECRET= +AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY= +AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET= +AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN= +AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET= # Commerce Event Module configs # These values will be used to configure the Adobe I/O Events module automatically @@ -45,3 +45,6 @@ IO_WORKSPACE_ID= # EVENT_PREFIX corresponds to a string that is prepended to an event name. It helps to uniquely identify events when multiple projects use the same event type EVENT_PREFIX= + +# Business Configuration schema path +CONFIG_SCHEMA_PATH=extensibility.config.js diff --git a/extensibility.config.js b/extensibility.config.js new file mode 100644 index 00000000..9b8aa816 --- /dev/null +++ b/extensibility.config.js @@ -0,0 +1,19 @@ +module.exports = { + businessConfig: { + schema: [ + { + name: "exampleList", + type: "list", + label: "Example List", + options: [ + { label: "Option 1", value: "option1" }, + { label: "Option 2", value: "option2" }, + ], + selectionMode: "single", + default: "option1", + description: "This is a description for the example list", + }, + { name: "currency", type: "text", label: "Currency" }, + ], + }, +}; diff --git a/install.yaml b/install.yaml new file mode 100644 index 00000000..44ad98c7 --- /dev/null +++ b/install.yaml @@ -0,0 +1,9 @@ +$schema: http://json-schema.org/draft-07/schema +$id: https://adobe.io/schemas/app-builder-templates/1 + +categories: + - action + +extensions: + # `commerce/configuration/1` is required by `@adobe/aio-commerce-lib-config`. + - extensionPointId: commerce/configuration/1 diff --git a/package-lock.json b/package-lock.json index e11fbc8b..0d26f753 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,8 @@ "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@adobe/aio-commerce-lib-auth": "^0.3.3", - "@adobe/aio-commerce-lib-core": "^0.4.1", + "@adobe/aio-commerce-lib-config": "^0.7.2", + "@adobe/aio-commerce-sdk": "^0.6.2", "@adobe/aio-lib-ims": "^8.0.0", "@adobe/aio-lib-state": "^5.1.0", "@adobe/aio-lib-telemetry": "^1.0.0", @@ -46,13 +46,40 @@ ] } }, + "node_modules/@adobe/aio-commerce-lib-api": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@adobe/aio-commerce-lib-api/-/aio-commerce-lib-api-0.3.2.tgz", + "integrity": "sha512-fkMGf17JSCvVNUzNdCtsV7lk11erNMZV1uCHJWVjwe6V3QT1ER/woSgyLvg7wwdSFOWxoCBXAhtPvxEG9VfP4Q==", + "license": "Apache-2.0", + "dependencies": { + "@adobe/aio-commerce-lib-auth": "0.6.2", + "@adobe/aio-commerce-lib-core": "0.5.1", + "camelcase": "^8.0.0", + "ky": "^1.9.0" + }, + "engines": { + "node": ">=20 <=24" + } + }, + "node_modules/@adobe/aio-commerce-lib-api/node_modules/camelcase": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-8.0.0.tgz", + "integrity": "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==", + "license": "MIT", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@adobe/aio-commerce-lib-auth": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@adobe/aio-commerce-lib-auth/-/aio-commerce-lib-auth-0.3.3.tgz", - "integrity": "sha512-XxS4KYxCVi3I2dT6jJD08UIMvMktzE/coObEHi86ivGbYARfPNXOnQKvNr6MDcuVyDHmJ12dHvqpcqURoAGFEA==", + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/@adobe/aio-commerce-lib-auth/-/aio-commerce-lib-auth-0.6.2.tgz", + "integrity": "sha512-EifzPMVN1yKHJmsniClm9my3xkZLxsn7ed4hsWIWvwTxEsxgyOeeOG6/BGffznaJv54/XlGLR3w4ywV1Mwm06g==", "license": "Apache-2.0", "dependencies": { - "@adobe/aio-commerce-lib-core": "0.4.1", + "@adobe/aio-commerce-lib-core": "0.5.1", "@adobe/aio-lib-ims": "^8.1.0", "ansis": "^4.1.0", "oauth-1.0a": "^2.2.6", @@ -62,10 +89,47 @@ "node": ">=20 <=24" } }, + "node_modules/@adobe/aio-commerce-lib-config": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@adobe/aio-commerce-lib-config/-/aio-commerce-lib-config-0.7.2.tgz", + "integrity": "sha512-WWyiKvJUVezrGSxGzRPyATDvkM+IKGiz3yrNTqW051jA3QImUyoT1g/a7UubG84XJ5ihTRWifSbfuCsCXO3qDg==", + "license": "Apache-2.0", + "dependencies": { + "@adobe/aio-commerce-lib-api": "0.3.2", + "@adobe/aio-commerce-lib-core": "0.5.1", + "@adobe/aio-lib-core-logging": "^3.0.2", + "@adobe/aio-lib-files": "^4.0.0", + "@adobe/aio-lib-state": "^5.0.0", + "find-up": "^8.0.0", + "jiti": "^2.6.1", + "uuid": "^13.0.0", + "valibot": "^1.1.0", + "yaml": "^2.6.1" + }, + "bin": { + "aio-commerce-lib-config": "dist/es/commands/index.js" + }, + "engines": { + "node": ">=20 <=24" + } + }, + "node_modules/@adobe/aio-commerce-lib-config/node_modules/uuid": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-13.0.0.tgz", + "integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist-node/bin/uuid" + } + }, "node_modules/@adobe/aio-commerce-lib-core": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/@adobe/aio-commerce-lib-core/-/aio-commerce-lib-core-0.4.1.tgz", - "integrity": "sha512-gkvHLoSdVHX9ByORVg2F6ITXyFj2HAY2AElvrXJUwXgtywcIs+j0xr4kG1yXQ1zglSRdsvuAH6zDpJGKrfJ6vg==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@adobe/aio-commerce-lib-core/-/aio-commerce-lib-core-0.5.1.tgz", + "integrity": "sha512-Kk4QKxfYGrIpu27HqQ8UPOhbkFG2zy+0Oc17i/X802qPmwmrc7lWoHN9El7FxFGzj3ntvouFe/ctzXI8oYDbmw==", "license": "Apache-2.0", "dependencies": { "ansis": "^4.1.0", @@ -75,6 +139,36 @@ "node": ">=20 <=24" } }, + "node_modules/@adobe/aio-commerce-lib-events": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@adobe/aio-commerce-lib-events/-/aio-commerce-lib-events-0.3.4.tgz", + "integrity": "sha512-56vhu82iAiN3TNmHkmSNGcRUzYritOUMNGHCFW2ZF8j0Qcm2RIFSjmixo0ZpiTxeudaYuRRvQSiL/aAJcPQi5w==", + "license": "Apache-2.0", + "dependencies": { + "@adobe/aio-commerce-lib-api": "0.3.2", + "@adobe/aio-commerce-lib-auth": "0.6.2", + "@adobe/aio-commerce-lib-core": "0.5.1", + "valibot": "^1.1.0" + }, + "engines": { + "node": ">=20 <=24" + } + }, + "node_modules/@adobe/aio-commerce-sdk": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/@adobe/aio-commerce-sdk/-/aio-commerce-sdk-0.6.2.tgz", + "integrity": "sha512-0//3EDpqYMMTbBxHmFfBILZ86MoKAuGWqC0hlZ6IZUHz5B8mtaY5XNezot6YHOcJcAsGEjI3AdNMELaB+MPaww==", + "license": "Apache-2.0", + "dependencies": { + "@adobe/aio-commerce-lib-api": "0.3.2", + "@adobe/aio-commerce-lib-auth": "0.6.2", + "@adobe/aio-commerce-lib-core": "0.5.1", + "@adobe/aio-commerce-lib-events": "0.3.4" + }, + "engines": { + "node": ">=20 <=24" + } + }, "node_modules/@adobe/aio-lib-analytics": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@adobe/aio-lib-analytics/-/aio-lib-analytics-4.0.1.tgz", @@ -8267,6 +8361,22 @@ "node": ">=8" } }, + "node_modules/find-up": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-8.0.0.tgz", + "integrity": "sha512-JGG8pvDi2C+JxidYdIwQDyS/CgcrIdh18cvgxcBge3wSHRQOrooMD3GlFBcmMJAN9M42SAZjDp5zv1dglJjwww==", + "license": "MIT", + "dependencies": { + "locate-path": "^8.0.0", + "unicorn-magic": "^0.3.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/fn.name": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", @@ -10214,6 +10324,15 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/jiti": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.6.1.tgz", + "integrity": "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==", + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, "node_modules/joi": { "version": "17.13.3", "resolved": "https://registry.npmjs.org/joi/-/joi-17.13.3.tgz", @@ -10412,6 +10531,18 @@ "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==", "license": "MIT" }, + "node_modules/ky": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/ky/-/ky-1.14.0.tgz", + "integrity": "sha512-Rczb6FMM6JT0lvrOlP5WUOCB7s9XKxzwgErzhKlKde1bEV90FXplV1o87fpt4PU/asJFiqjYJxAJyzJhcrxOsQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/ky?sponsor=1" + } + }, "node_modules/leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", @@ -10586,6 +10717,21 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/locate-path": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-8.0.0.tgz", + "integrity": "sha512-XT9ewWAC43tiAV7xDAPflMkG0qOPn2QjHqlgX8FOqmWa/rxnyYDulF9T0F7tRy1u+TVTmK/M//6VIOye+2zDXg==", + "license": "MIT", + "dependencies": { + "p-locate": "^6.0.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -11612,6 +11758,48 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/p-locate": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz", + "integrity": "sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==", + "license": "MIT", + "dependencies": { + "p-limit": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", + "license": "MIT", + "dependencies": { + "yocto-queue": "^1.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate/node_modules/yocto-queue": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.2.2.tgz", + "integrity": "sha512-4LCcse/U2MHZ63HAJVE+v71o7yOdIe4cZ70Wpf8D/IyjDKYQLV5GD46B+hSTjJsvV5PztjvHoU580EftxjDZFQ==", + "license": "MIT", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", @@ -13862,6 +14050,18 @@ "integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==", "license": "MIT" }, + "node_modules/unicorn-magic": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.3.0.tgz", + "integrity": "sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/universal-user-agent": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", @@ -14544,7 +14744,6 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", - "dev": true, "license": "ISC", "bin": { "yaml": "bin.mjs" diff --git a/package.json b/package.json index 0beb8062..aaa1a4ef 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "author": "Adobe Inc.", "private": true, "dependencies": { - "@adobe/aio-commerce-lib-auth": "^0.3.3", - "@adobe/aio-commerce-lib-core": "^0.4.1", + "@adobe/aio-commerce-lib-config": "^0.7.2", + "@adobe/aio-commerce-sdk": "^0.6.2", "@adobe/aio-lib-ims": "^8.0.0", "@adobe/aio-lib-state": "^5.1.0", "@adobe/aio-lib-telemetry": "^1.0.0", @@ -40,7 +40,7 @@ }, "scripts": { "prepare": "husky", - "postinstall": "npm run build --if-present --workspaces", + "postinstall": "npm run build --if-present --workspaces && npx @adobe/aio-commerce-lib-config generate all", "test": "jest --passWithNoTests -c ./test/jest.config.js ./test", "onboard": "node --no-warnings -e 'require(\"./scripts/onboarding/index.js\").main()'", "onboard:debug": "node --inspect-brk --no-warnings -e 'require(\"./scripts/onboarding/index.js\").main()'", diff --git a/scripts/lib/configure-eventing.js b/scripts/lib/configure-eventing.js index 915fb83e..8f443cfb 100644 --- a/scripts/lib/configure-eventing.js +++ b/scripts/lib/configure-eventing.js @@ -41,7 +41,7 @@ async function main( try { const eventProviderResult = await getEventProviders( - environment.COMMERCE_BASE_URL, + environment.AIO_COMMERCE_API_BASE_URL, environment, ); const isNonDefaultProviderAdded = eventProviderResult.some( @@ -74,7 +74,7 @@ async function main( const hints = [ 'Ensure your "onboarding/config/workspace.json" file is up to date', "Did you run `aio app deploy`? Your runtime actions should be deployed before running the onboarding script", - "Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL", + "Make sure your authentication environment parameters are correct. Also check the AIO_COMMERCE_API_BASE_URL", ]; if (error?.message?.includes("Response code 404 (Not Found)")) { @@ -116,7 +116,7 @@ async function addCommerceEventProvider( const { label, description } = providersList.find((provider) => provider.key === "commerce") || {}; - await addEventProvider(environment.COMMERCE_BASE_URL, environment, { + await addEventProvider(environment.AIO_COMMERCE_API_BASE_URL, environment, { eventProvider: { provider_id: providerId, instance_id: instanceId, @@ -140,14 +140,18 @@ async function updateCommerceEventingConfiguration( workspaceConfiguration, environment, ) { - await updateConfiguration(environment.COMMERCE_BASE_URL, environment, { - config: { - enabled: true, - merchant_id: environment.COMMERCE_ADOBE_IO_EVENTS_MERCHANT_ID, - environment_id: "Stage", - workspace_configuration: JSON.stringify(workspaceConfiguration), + await updateConfiguration( + environment.AIO_COMMERCE_API_BASE_URL, + environment, + { + config: { + enabled: true, + merchant_id: environment.COMMERCE_ADOBE_IO_EVENTS_MERCHANT_ID, + environment_id: "Stage", + workspace_configuration: JSON.stringify(workspaceConfiguration), + }, }, - }); + ); console.log("\nUpdated the commerce instance with workspace configuration"); } diff --git a/scripts/lib/event-subscribe.js b/scripts/lib/event-subscribe.js index 08a51a0f..fb4ac952 100644 --- a/scripts/lib/event-subscribe.js +++ b/scripts/lib/event-subscribe.js @@ -37,7 +37,11 @@ async function main(eventSpec, environment) { eventSpec.event.name = getEventName(eventSpec.event.name, environment); try { - await eventSubscribe(environment.COMMERCE_BASE_URL, environment, eventSpec); + await eventSubscribe( + environment.AIO_COMMERCE_API_BASE_URL, + environment, + eventSpec, + ); return { success: true, @@ -47,7 +51,7 @@ async function main(eventSpec, environment) { let reason = "Unexpected error occurred while subscribing to an event in the Adobe I/O Events module in Commerce"; const hints = [ - "Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL", + "Make sure your authentication environment parameters are correct. Also check the AIO_COMMERCE_API_BASE_URL", ]; if (error?.message?.includes("Response code 400 (Bad Request)")) { diff --git a/scripts/lib/metadata.js b/scripts/lib/metadata.js index 6e0643ee..6dc0ff68 100644 --- a/scripts/lib/metadata.js +++ b/scripts/lib/metadata.js @@ -287,7 +287,7 @@ async function main(clientRegistrations, providers, environment, authHeaders) { }; } catch (error) { const hints = [ - "Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL", + "Make sure your authentication environment parameters are correct. Also check the AIO_COMMERCE_API_BASE_URL", "Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?", ]; diff --git a/scripts/lib/providers.js b/scripts/lib/providers.js index 471c1c21..7b322021 100644 --- a/scripts/lib/providers.js +++ b/scripts/lib/providers.js @@ -243,7 +243,7 @@ async function main(clientRegistrations, environment, authHeaders) { return response; } catch (error) { const hints = [ - "Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL", + "Make sure your authentication environment parameters are correct. Also check the AIO_COMMERCE_API_BASE_URL", "Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?", ]; diff --git a/scripts/lib/registrations.js b/scripts/lib/registrations.js index 166fc6ef..44b1118e 100644 --- a/scripts/lib/registrations.js +++ b/scripts/lib/registrations.js @@ -21,7 +21,7 @@ const { makeError } = require("./helpers/errors"); * Creates event registrations based on client selections from custom/starter-kit-registrations.json * @param {object} clientRegistrations - Client registrations mapping entity names to provider keys * @param {Array<{id: string, key: string, label: string}>} providers - List of provider objects - * @param {object} environment - Environment configuration containing IO_MANAGEMENT_BASE_URL, IO_CONSUMER_ID, IO_PROJECT_ID, IO_WORKSPACE_ID, OAUTH_CLIENT_ID + * @param {object} environment - Environment configuration containing IO_MANAGEMENT_BASE_URL, IO_CONSUMER_ID, IO_PROJECT_ID, IO_WORKSPACE_ID, AIO_COMMERCE_AUTH_IMS_CLIENT_ID * @param {object} authHeaders - Authentication headers for API requests * @returns Result object with registrations or error */ @@ -95,7 +95,7 @@ async function main(clientRegistrations, providers, environment, authHeaders) { }; } catch (error) { const hints = [ - "Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL", + "Make sure your authentication environment parameters are correct. Also check the AIO_COMMERCE_API_BASE_URL", "Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?", ]; @@ -116,7 +116,7 @@ async function main(clientRegistrations, providers, environment, authHeaders) { * @param {string} entityName - Entity name for the registration * @param {string} providerKey - Provider key identifier * @param {Array<{provider_id: string, event_code: string}>} events - Array of events to register - * @param {object} environment - Environment configuration containing IO_MANAGEMENT_BASE_URL, IO_CONSUMER_ID, IO_PROJECT_ID, IO_WORKSPACE_ID, OAUTH_CLIENT_ID + * @param {object} environment - Environment configuration containing IO_MANAGEMENT_BASE_URL, IO_CONSUMER_ID, IO_PROJECT_ID, IO_WORKSPACE_ID, AIO_COMMERCE_AUTH_IMS_CLIENT_ID * @returns Result object with registration details or error */ async function createRequestRegistration( @@ -127,7 +127,7 @@ async function createRequestRegistration( environment, ) { const body = JSON.stringify({ - client_id: `${environment.OAUTH_CLIENT_ID}`, + client_id: `${environment.AIO_COMMERCE_AUTH_IMS_CLIENT_ID}`, runtime_action: `${entityName}-${providerKey}/consumer`, name: getRegistrationName(providerKey, entityName), description: getRegistrationName(providerKey, entityName), diff --git a/scripts/onboarding/index.js b/scripts/onboarding/index.js index 84370d6e..2c826f50 100644 --- a/scripts/onboarding/index.js +++ b/scripts/onboarding/index.js @@ -26,7 +26,7 @@ const StringSchema = v.pipe( ); const ProcessEnvSchema = v.object({ - COMMERCE_BASE_URL: StringSchema, + AIO_COMMERCE_API_BASE_URL: StringSchema, IO_CONSUMER_ID: StringSchema, IO_PROJECT_ID: StringSchema, IO_WORKSPACE_ID: StringSchema, diff --git a/src/commerce-configuration-1/.generated/actions/app-management/get-config-schema.js b/src/commerce-configuration-1/.generated/actions/app-management/get-config-schema.js new file mode 100644 index 00000000..5f13dbac --- /dev/null +++ b/src/commerce-configuration-1/.generated/actions/app-management/get-config-schema.js @@ -0,0 +1,62 @@ +/* +Copyright 2025 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ + +// This file has been auto-generated by `@adobe/aio-commerce-lib-config` +// Do not modify this file directly + +import util from "node:util"; + +import { init } from "@adobe/aio-commerce-lib-config"; +import { + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; + +// Shorthand to inspect an object. +const inspect = (obj) => util.inspect(obj, { depth: null }); + +/** + * Get the configuration schema. + * @returns The response object containing the configuration schema. + */ +export async function main(params) { + const logger = AioLogger("get-config-schema", { + level: params.LOG_LEVEL || "info", + }); + try { + const config = init(); + + logger.debug("Retrieving configuration schema..."); + const configSchema = await config.getConfigSchema(); + + logger.debug( + `Successfully retrieved configSchema: ${inspect(configSchema)}`, + ); + return ok({ + body: { + configSchema, + }, + }); + } catch (error) { + logger.error( + `Something wen't wrong while retrieving config schema: ${inspect(error)}`, + ); + return internalServerError({ + body: { + code: "INTERNAL_ERROR", + message: "An internal server error occurred", + details: error instanceof Error ? error.message : "Unknown error", + }, + }); + } +} diff --git a/src/commerce-configuration-1/.generated/actions/app-management/get-configuration.js b/src/commerce-configuration-1/.generated/actions/app-management/get-configuration.js new file mode 100644 index 00000000..915c2ea3 --- /dev/null +++ b/src/commerce-configuration-1/.generated/actions/app-management/get-configuration.js @@ -0,0 +1,87 @@ +/* +Copyright 2025 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ + +// This file has been auto-generated by `@adobe/aio-commerce-lib-config` +// Do not modify this file directly + +import util from "node:util"; + +import { init } from "@adobe/aio-commerce-lib-config"; +import { + badRequest, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; + +// Shorthand to inspect an object. +const inspect = (obj) => util.inspect(obj, { depth: null }); + +/** + * Get the configuration. + * @param params - The input parameters. + * @returns The response object containing the configuration data. + */ +export async function main(params) { + const logger = AioLogger("get-configuration", { + level: params.LOG_LEVEL || "info", + }); + try { + const config = init(); + const id = params.id; + const code = params.code; + const level = params.level; + logger.debug( + `Retrieving configuration with params: ${inspect({ id, code, level })}`, + ); + + if (!(id || code)) { + logger.warn("Invalid params: Either id or code query param is required"); + return badRequest({ + body: { + code: "INVALID_PARAMS", + message: "Either id or code query param is required", + }, + }); + } + + let appConfiguration; + if (id) { + logger.debug(`Retrieving configuration by id: ${id}`); + appConfiguration = await config.getConfiguration(id); + } else if (level) { + logger.debug( + `Retrieving configuration by code: ${code}, level: ${level}`, + ); + appConfiguration = await config.getConfiguration(code, level); + } else { + logger.debug(`Retrieving configuration by code: ${code}`); + appConfiguration = await config.getConfiguration(code); + } + + logger.debug( + `Successfully retrieved configuration: ${inspect(appConfiguration)}`, + ); + return ok({ body: appConfiguration }); + } catch (error) { + logger.error( + `Something went wrong while retrieving configuration: ${inspect(error)}`, + ); + return internalServerError({ + body: { + code: "INTERNAL_ERROR", + message: "An internal server error occurred", + details: error instanceof Error ? error.message : "Unknown error", + }, + }); + } +} diff --git a/src/commerce-configuration-1/.generated/actions/app-management/get-scope-tree.js b/src/commerce-configuration-1/.generated/actions/app-management/get-scope-tree.js new file mode 100644 index 00000000..2dd1a992 --- /dev/null +++ b/src/commerce-configuration-1/.generated/actions/app-management/get-scope-tree.js @@ -0,0 +1,68 @@ +/* +Copyright 2025 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ + +// This file has been auto-generated by `@adobe/aio-commerce-lib-config` +// Do not modify this file directly + +import util from "node:util"; + +import { init } from "@adobe/aio-commerce-lib-config"; +import { + internalServerError, + nonAuthoritativeInformation, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; + +// Shorthand to inspect an object. +const inspect = (obj) => util.inspect(obj, { depth: null }); + +/** + * Get scope tree. + * @returns The response object containing persisted scope tree configuration from cache/storage. + */ +export async function main(params) { + const logger = AioLogger("get-scope-tree", { + level: params.LOG_LEVEL || "info", + }); + try { + const config = init(); + logger.debug("Retrieving scope tree..."); + + const result = await config.getScopeTree(); + logger.debug( + `Successfully retrieved scope tree (cached: ${result.isCachedData}): ${inspect(result.scopeTree)}`, + ); + + if (result.isCachedData) { + return nonAuthoritativeInformation({ + headers: { "x-cache": "hit" }, + body: { scopes: result.scopeTree }, + }); + } + + return ok({ + body: { scopes: result.scopeTree }, + }); + } catch (error) { + logger.error( + `Something went wrong while retrieving scope tree: ${inspect(error)}`, + ); + return internalServerError({ + body: { + code: "INTERNAL_ERROR", + message: "An internal server error occurred", + details: error instanceof Error ? error.message : "Unknown error", + }, + }); + } +} diff --git a/src/commerce-configuration-1/.generated/actions/app-management/set-configuration.js b/src/commerce-configuration-1/.generated/actions/app-management/set-configuration.js new file mode 100644 index 00000000..6b2cefc2 --- /dev/null +++ b/src/commerce-configuration-1/.generated/actions/app-management/set-configuration.js @@ -0,0 +1,111 @@ +/* +Copyright 2025 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ + +// This file has been auto-generated by `@adobe/aio-commerce-lib-config` +// Do not modify this file directly + +import util from "node:util"; + +import { init } from "@adobe/aio-commerce-lib-config"; +import { + badRequest, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; + +import AioLogger from "@adobe/aio-lib-core-logging"; + +// Shorthand to inspect an object. +const inspect = (obj) => util.inspect(obj, { depth: null }); + +/** + * Get the configuration. + * @param params - The input parameters. + * @returns The response object containing the updated configuration values. + */ +export async function main(params) { + const logger = AioLogger("set-configuration", { + level: params.LOG_LEVEL || "info", + }); + try { + const lib = init(); + let body; + + if ( + params && + typeof params === "object" && + Object.keys(params).length === 0 + ) { + body = {}; + } + + const id = params.id; + const code = params.code; + const level = params.level; + logger.debug( + `Setting configuration with params: ${inspect({ id, code, level })}`, + ); + + if (!(id || (code && level))) { + logger.warn( + "Invalid params: Either id or both code and level query params are required", + ); + return badRequest({ + body: { + code: "INVALID_PARAMS", + message: "Either id or both code and level query params are required", + }, + }); + } + + const candidateConfig = params.config ?? body?.config; + if (!(candidateConfig && Array.isArray(candidateConfig))) { + logger.warn( + "Invalid body: request must include a config array in params.config or body.config", + ); + return badRequest({ + body: { + code: "INVALID_BODY", + message: + "request must include a config array in params.config or body.config", + }, + }); + } + + const payload = { config: candidateConfig }; + logger.debug(`Setting configuration with payload: ${inspect(payload)}`); + + const libAny = lib; + const result = id + ? await libAny.setConfiguration(payload, id) + : await libAny.setConfiguration(payload, code, level); + + logger.debug(`Successfully set configuration: ${inspect(result)}`); + return ok({ + body: { result }, + headers: { + "Cache-Control": "no-store", + }, + }); + } catch (error) { + logger.error( + `Something went wrong while setting configuration: ${inspect(error)}`, + ); + return internalServerError({ + body: { + code: "INTERNAL_ERROR", + message: "An internal server error occurred", + details: error instanceof Error ? error.message : "Unknown error", + }, + }); + } +} diff --git a/src/commerce-configuration-1/.generated/actions/app-management/set-custom-scope-tree.js b/src/commerce-configuration-1/.generated/actions/app-management/set-custom-scope-tree.js new file mode 100644 index 00000000..1620b299 --- /dev/null +++ b/src/commerce-configuration-1/.generated/actions/app-management/set-custom-scope-tree.js @@ -0,0 +1,81 @@ +/* +Copyright 2025 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ + +// This file has been auto-generated by `@adobe/aio-commerce-lib-config` +// Do not modify this file directly + +import util from "node:util"; + +import { init } from "@adobe/aio-commerce-lib-config"; +import { + badRequest, + internalServerError, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; + +// Shorthand to inspect an object. +const inspect = (obj) => util.inspect(obj, { depth: null }); + +/** + * Set custom scope tree - replace all custom scopes with provided ones + * @param params - The input parameters containing scopes array + * @returns The response object containing updated custom scopes + */ +export async function main(params) { + const logger = AioLogger("set-custom-scope-tree", { + level: params.LOG_LEVEL || "info", + }); + try { + const scopes = params.scopes; + logger.debug( + `Setting custom scope tree with ${scopes?.length || 0} scopes`, + ); + + if (!scopes) { + logger.warn("Invalid request: Request must include scopes parameter"); + return badRequest({ + body: { + code: "INVALID_REQUEST", + message: "Request must include scopes parameter", + details: "Expected: { scopes: [array of scope objects] }", + }, + }); + } + + const request = { scopes }; + logger.debug(`Setting custom scope tree: ${inspect(request)}`); + + const lib = init(); + const result = await lib.setCustomScopeTree(request); + + logger.debug(`Successfully set custom scope tree: ${inspect(result)}`); + return ok({ + body: { result }, + headers: { + "Cache-Control": "no-store", + }, + }); + } catch (error) { + logger.error( + `Something went wrong while updating custom scope tree: ${inspect(error)}`, + ); + return internalServerError({ + body: { + code: "INTERNAL_ERROR", + message: + "An internal server error occurred while updating custom scope tree", + details: error instanceof Error ? error.message : "Unknown error", + }, + }); + } +} diff --git a/src/commerce-configuration-1/.generated/actions/app-management/sync-commerce-scopes.js b/src/commerce-configuration-1/.generated/actions/app-management/sync-commerce-scopes.js new file mode 100644 index 00000000..0afc8ceb --- /dev/null +++ b/src/commerce-configuration-1/.generated/actions/app-management/sync-commerce-scopes.js @@ -0,0 +1,94 @@ +/* +Copyright 2025 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ + +// This file has been auto-generated by `@adobe/aio-commerce-lib-config` +// Do not modify this file directly + +import util from "node:util"; + +import { init } from "@adobe/aio-commerce-lib-config"; +import { resolveCommerceHttpClientParams } from "@adobe/aio-commerce-sdk/api"; +import { + internalServerError, + nonAuthoritativeInformation, + ok, +} from "@adobe/aio-commerce-sdk/core/responses"; +import AioLogger from "@adobe/aio-lib-core-logging"; + +// Shorthand to inspect an object. +const inspect = (obj) => util.inspect(obj, { depth: null }); + +/** + * Sync commerce scopes. + * @param params - The input parameters. + * @returns The response object containing updated scope tree. + */ +export async function main(params) { + const logger = AioLogger("sync-commerce-scopes", { + level: params.LOG_LEVEL || "info", + }); + try { + logger.debug("Syncing commerce scopes..."); + + const commerceConfig = resolveCommerceHttpClientParams(params); + const config = init({ + commerce: commerceConfig, + }); + + const result = await config.syncCommerceScopes(); + + if (result.error) { + logger.error(`Error syncing commerce scopes: ${inspect(result.error)}`); + return internalServerError({ + body: { + code: "INTERNAL_ERROR", + message: "An internal server error occurred", + error: result.error, + }, + }); + } + + if (!result.synced) { + logger.debug( + `Commerce scopes not synced (cached): ${inspect(result.scopeTree)}`, + ); + return nonAuthoritativeInformation({ + headers: { "x-cache": "hit" }, + body: { + scopes: result.scopeTree, + synced: false, + }, + }); + } + + logger.debug( + `Successfully synced commerce scopes: ${inspect(result.scopeTree)}`, + ); + return ok({ + body: { + scopes: result.scopeTree, + synced: true, + }, + }); + } catch (error) { + logger.error( + `Something went wrong while syncing commerce scopes: ${inspect(error)}`, + ); + return internalServerError({ + body: { + code: "INTERNAL_ERROR", + message: "An internal server error occurred", + details: error instanceof Error ? error.message : "Unknown error", + }, + }); + } +} diff --git a/src/commerce-configuration-1/.generated/configuration-schema.json b/src/commerce-configuration-1/.generated/configuration-schema.json new file mode 100644 index 00000000..1a6863a1 --- /dev/null +++ b/src/commerce-configuration-1/.generated/configuration-schema.json @@ -0,0 +1,25 @@ +[ + { + "name": "exampleList", + "type": "list", + "label": "Example List", + "options": [ + { + "label": "Option 1", + "value": "option1" + }, + { + "label": "Option 2", + "value": "option2" + } + ], + "selectionMode": "single", + "default": "option1", + "description": "This is a description for the example list" + }, + { + "name": "currency", + "type": "text", + "label": "Currency" + } +] diff --git a/src/commerce-configuration-1/ext.config.yaml b/src/commerce-configuration-1/ext.config.yaml new file mode 100644 index 00000000..496d6e4f --- /dev/null +++ b/src/commerce-configuration-1/ext.config.yaml @@ -0,0 +1,97 @@ +$schema: http://json-schema.org/draft-07/schema + +# The `pre-app-build` hook is auto-generated by `@adobe/aio-commerce-lib-config`. Do not remove or manually edit. +hooks: + pre-app-build: npx @adobe/aio-commerce-lib-config generate schema + +operations: + # These worker processes definitions are auto-generated by `@adobe/aio-commerce-lib-config`. Do not remove or manually edit. + workerProcess: + - type: action + impl: app-management/get-scope-tree + - type: action + impl: app-management/get-config-schema + - type: action + impl: app-management/get-configuration + - type: action + impl: app-management/set-configuration + - type: action + impl: app-management/set-custom-scope-tree + - type: action + impl: app-management/sync-commerce-scopes + +runtimeManifest: + packages: + # This package definition is auto-generated by `@adobe/aio-commerce-lib-config`. Do not remove or manually edit. + app-management: + license: Apache-2.0 + actions: + get-scope-tree: + function: .generated/actions/app-management/get-scope-tree.js + web: yes + runtime: nodejs:22 + inputs: + LOG_LEVEL: $LOG_LEVEL + annotations: + require-adobe-auth: true + final: true + get-config-schema: + function: .generated/actions/app-management/get-config-schema.js + web: yes + runtime: nodejs:22 + inputs: + LOG_LEVEL: $LOG_LEVEL + annotations: + require-adobe-auth: true + final: true + include: + - [ .generated/configuration-schema.json, app-management/ ] + get-configuration: + function: .generated/actions/app-management/get-configuration.js + web: yes + runtime: nodejs:22 + inputs: + LOG_LEVEL: $LOG_LEVEL + annotations: + require-adobe-auth: true + final: true + include: + - [ .generated/configuration-schema.json, app-management/ ] + set-configuration: + function: .generated/actions/app-management/set-configuration.js + web: yes + runtime: nodejs:22 + inputs: + LOG_LEVEL: $LOG_LEVEL + annotations: + require-adobe-auth: true + final: true + set-custom-scope-tree: + function: .generated/actions/app-management/set-custom-scope-tree.js + web: yes + runtime: nodejs:22 + inputs: + LOG_LEVEL: $LOG_LEVEL + annotations: + require-adobe-auth: true + final: true + sync-commerce-scopes: + function: .generated/actions/app-management/sync-commerce-scopes.js + web: yes + runtime: nodejs:22 + inputs: + LOG_LEVEL: $LOG_LEVEL + AIO_COMMERCE_API_BASE_URL: $AIO_COMMERCE_API_BASE_URL + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: $AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: $AIO_COMMERCE_AUTH_IMS_CLIENT_ID + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: $AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: $AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: $AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL + AIO_COMMERCE_AUTH_IMS_ORG_ID: $AIO_COMMERCE_AUTH_IMS_ORG_ID + AIO_COMMERCE_AUTH_IMS_SCOPES: $AIO_COMMERCE_AUTH_IMS_SCOPES + annotations: + require-adobe-auth: true + final: true diff --git a/test/actions/auth.test.js b/test/actions/auth.test.js index 8bc2e4cd..77c6e097 100644 --- a/test/actions/auth.test.js +++ b/test/actions/auth.test.js @@ -3,26 +3,31 @@ const { validateParams, fromParams } = require("../..//actions/auth"); describe("validateParams", () => { it("should throw error if missing params", () => { const params = { - OAUTH_CLIENT_ID: "client-id", + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: "client-id", }; expect(() => { - validateParams(params, ["OAUTH_CLIENT_ID", "OAUTH_CLIENT_SECRET"]); - }).toThrow("Expected parameters are missing OAUTH_CLIENT_SECRET"); + validateParams(params, [ + "AIO_COMMERCE_AUTH_IMS_CLIENT_ID", + "AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS", + ]); + }).toThrow( + "Expected parameters are missing AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS", + ); }); it("should not throw error if params are not missing", () => { const params = { - OAUTH_CLIENT_ID: "client-id", - OAUTH_CLIENT_SECRET: "client-secret", - OAUTH_SCOPES: ["scope1", "scope2"], + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: "client-id", + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: ["client-secret"], + AIO_COMMERCE_AUTH_IMS_SCOPES: ["scope1", "scope2"], }; expect(() => { validateParams(params, [ - "OAUTH_CLIENT_ID", - "OAUTH_CLIENT_SECRET", - "OAUTH_SCOPES", + "AIO_COMMERCE_AUTH_IMS_CLIENT_ID", + "AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS", + "AIO_COMMERCE_AUTH_IMS_SCOPES", ]); }).not.toThrow(); }); @@ -31,9 +36,9 @@ describe("validateParams", () => { describe("fromParams", () => { it("can extract IMS params", () => { const params = { - OAUTH_CLIENT_ID: "client-id", - OAUTH_CLIENT_SECRET: "client-secret", - OAUTH_SCOPES: ["scope1", "scope2"], + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: "client-id", + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: ["client-secret"], + AIO_COMMERCE_AUTH_IMS_SCOPES: ["scope1", "scope2"], }; expect(fromParams(params)).toEqual({ @@ -47,10 +52,11 @@ describe("fromParams", () => { it("can extract Commerce OAuth1a params", () => { const params = { - COMMERCE_CONSUMER_KEY: "commerce-consumer-key", - COMMERCE_CONSUMER_SECRET: "commerce-consumer-secret", - COMMERCE_ACCESS_TOKEN: "commerce-access-token", - COMMERCE_ACCESS_TOKEN_SECRET: "commerce-access-token-secret", + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: "commerce-consumer-key", + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: "commerce-consumer-secret", + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: "commerce-access-token", + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: + "commerce-access-token-secret", }; expect(fromParams(params)).toEqual({ diff --git a/test/actions/ingestion/webhook/webhook.test.js b/test/actions/ingestion/webhook/webhook.test.js index 4700efef..58e8dfad 100644 --- a/test/actions/ingestion/webhook/webhook.test.js +++ b/test/actions/ingestion/webhook/webhook.test.js @@ -39,8 +39,8 @@ jest.mock("@adobe/aio-lib-ims", () => ({ }, })); -jest.mock("@adobe/aio-commerce-lib-auth", () => { - const originalModule = jest.requireActual("@adobe/aio-commerce-lib-auth"); +jest.mock("@adobe/aio-commerce-sdk/auth", () => { + const originalModule = jest.requireActual("@adobe/aio-commerce-sdk/auth"); return { __esModule: true, ...originalModule, @@ -48,7 +48,7 @@ jest.mock("@adobe/aio-commerce-lib-auth", () => { }; }); -const { getImsAuthProvider } = require("@adobe/aio-commerce-lib-auth"); +const { getImsAuthProvider } = require("@adobe/aio-commerce-sdk/auth"); jest.mock("node-fetch"); const fetch = require("node-fetch"); @@ -63,11 +63,13 @@ afterEach(() => { }); const validEnvParams = { - OAUTH_CLIENT_ID: "OAUTH_CLIENT_ID", - OAUTH_CLIENT_SECRET: "OAUTH_CLIENT_SECRET", - OAUTH_TECHNICAL_ACCOUNT_ID: "example@adobe-ds.com", - OAUTH_TECHNICAL_ACCOUNT_EMAIL: "example2@adobe-ds.com", - OAUTH_ORG_ID: "OAUTH_ORG_ID", + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: "AIO_COMMERCE_AUTH_IMS_CLIENT_ID", + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: [ + "AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS", + ], + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: "example@adobe-ds.com", + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: "example2@adobe-ds.com", + AIO_COMMERCE_AUTH_IMS_ORG_ID: "AIO_COMMERCE_AUTH_IMS_ORG_ID", }; /** @@ -152,8 +154,8 @@ describe("Given external backoffice events ingestion webhook", () => { describe("When received data information is invalid", () => { test("Then returns error response", async () => { const params = { - OAUTH_ORG_ID: "OAUTH_ORG_ID", - OAUTH_CLIENT_ID: "OAUTH_CLIENT_ID", + AIO_COMMERCE_AUTH_IMS_ORG_ID: "AIO_COMMERCE_AUTH_IMS_ORG_ID", + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: "AIO_COMMERCE_AUTH_IMS_CLIENT_ID", AIO_runtime_namespace: "eistarterkitv1", }; @@ -434,8 +436,8 @@ describe("Given external backoffice events ingestion webhook", () => { await action.main(params); expect(Events.init).toHaveBeenCalledWith( - "OAUTH_ORG_ID", - "OAUTH_CLIENT_ID", + "AIO_COMMERCE_AUTH_IMS_ORG_ID", + "AIO_COMMERCE_AUTH_IMS_CLIENT_ID", "access token", ); }); diff --git a/test/actions/oauth1a.test.js b/test/actions/oauth1a.test.js index 9c9fba73..aeccde46 100644 --- a/test/actions/oauth1a.test.js +++ b/test/actions/oauth1a.test.js @@ -8,10 +8,10 @@ describe("getClient", () => { { url: "http://localhost:9000", params: { - COMMERCE_CONSUMER_KEY: "key", - COMMERCE_CONSUMER_SECRET: "secret", - COMMERCE_ACCESS_TOKEN: "secret", - COMMERCE_ACCESS_TOKEN_SECRET: "secret", + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: "key", + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: "secret", + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: "secret", + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: "secret", }, }, console, @@ -39,10 +39,10 @@ describe("getClient", () => { { url: "http://commerce.adobe.io/", params: { - COMMERCE_CONSUMER_KEY: "key", - COMMERCE_CONSUMER_SECRET: "secret", - COMMERCE_ACCESS_TOKEN: "secret", - COMMERCE_ACCESS_TOKEN_SECRET: "secret", + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_KEY: "key", + AIO_COMMERCE_AUTH_INTEGRATION_CONSUMER_SECRET: "secret", + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN: "secret", + AIO_COMMERCE_AUTH_INTEGRATION_ACCESS_TOKEN_SECRET: "secret", }, }, console, @@ -69,9 +69,9 @@ describe("getClient", () => { { url: "http://commerce.adobe.io/", params: { - OAUTH_CLIENT_ID: "client-id", - OAUTH_CLIENT_SECRET: "client-secret", - OAUTH_SCOPES: ["scope1", "scope2"], + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: "client-id", + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: ["client-secret"], + AIO_COMMERCE_AUTH_IMS_SCOPES: ["scope1", "scope2"], }, }, console, diff --git a/test/scripts/lib/onboarding.index.test.js b/test/scripts/lib/onboarding.index.test.js index ea1802b7..b3d81b98 100644 --- a/test/scripts/lib/onboarding.index.test.js +++ b/test/scripts/lib/onboarding.index.test.js @@ -32,7 +32,7 @@ describe("onboarding index", () => { process.env = originalEnv; }); - test("should print an error when COMMERCE_BASE_URL, IO_PROJECT_ID, IO_CONSUMER_ID and IO_WORKSPACE_ID and EVENT_PREFIX are missing", async () => { + test("should print an error when AIO_COMMERCE_API_BASE_URL, IO_PROJECT_ID, IO_CONSUMER_ID and IO_WORKSPACE_ID and EVENT_PREFIX are missing", async () => { // Mock process.env to simulate missing environment variables const mockEnv = {}; jest.replaceProperty(process, "env", mockEnv); @@ -51,7 +51,7 @@ describe("onboarding index", () => { "Missing or invalid environment variables for Onboarding script", ); expect(fullErrorMessage).toContain("Invalid environment variables"); - expect(fullErrorMessage).toContain("COMMERCE_BASE_URL"); + expect(fullErrorMessage).toContain("AIO_COMMERCE_API_BASE_URL"); expect(fullErrorMessage).toContain("IO_PROJECT_ID"); expect(fullErrorMessage).toContain("IO_CONSUMER_ID"); expect(fullErrorMessage).toContain("IO_WORKSPACE_ID"); @@ -61,7 +61,7 @@ describe("onboarding index", () => { test("should print an error when IMS Auth Parameters are missing", async () => { // Mock process.env to simulate missing environment variables const mockEnv = { - COMMERCE_BASE_URL: "https://commerce.test/", + AIO_COMMERCE_API_BASE_URL: "https://commerce.test/", IO_CONSUMER_ID: "test", IO_WORKSPACE_ID: "test", IO_PROJECT_ID: "test", @@ -94,58 +94,16 @@ describe("onboarding index", () => { test("should print an error when IMS Auth clientSecrets is empty", async () => { // Mock process.env to simulate missing environment variables const mockEnv = { - COMMERCE_BASE_URL: "https://commerce.test/", + AIO_COMMERCE_API_BASE_URL: "https://commerce.test/", IO_CONSUMER_ID: "test-consumer-id", IO_WORKSPACE_ID: "test-workspace-id", IO_PROJECT_ID: "test-project-id", EVENT_PREFIX: "test-prefix", IO_MANAGEMENT_BASE_URL: "https://io-management.test/", - OAUTH_CLIENT_ID: "test-client-id", - OAUTH_TECHNICAL_ACCOUNT_ID: "test-tech-account-id", - OAUTH_TECHNICAL_ACCOUNT_EMAIL: "test@example.com", - OAUTH_ORG_ID: "test-org-id", - }; - jest.replaceProperty(process, "env", mockEnv); - const result = await main(); - - expect(result).toBeUndefined(); - expect(consoleErrorSpy).toHaveBeenCalled(); - - const errorCalls = consoleErrorSpy.mock.calls; - const errorMessages = errorCalls.map((call) => call.join(" ")); - const fullErrorMessage = ansis.strip(errorMessages.join(" ")); - - expect(fullErrorMessage).toContain("IMS_AUTH_PARAMS"); - expect(fullErrorMessage).toContain("INVALID_IMS_AUTH_PARAMS"); - expect(fullErrorMessage).toContain( - "Missing or invalid environment variables for Adobe IMS authentication.", - ); - expect(fullErrorMessage).toContain("Invalid ImsAuthProvider configuration"); - expect(fullErrorMessage).toContain("clientSecrets"); - expect(fullErrorMessage).toContain( - "Expected at least one client secret for IMS auth", - ); - expect(fullErrorMessage).not.toContain("clientId"); - expect(fullErrorMessage).not.toContain("technicalAccountId"); - expect(fullErrorMessage).not.toContain("technicalAccountEmail"); - expect(fullErrorMessage).not.toContain("imsOrgId"); - expect(fullErrorMessage).not.toContain("scopes"); - }); - - test("should print an error when IMS Auth clientSecrets.0 is defined but an empty string", async () => { - // Mock process.env to simulate missing environment variables - const mockEnv = { - COMMERCE_BASE_URL: "https://commerce.test/", - IO_CONSUMER_ID: "test-consumer-id", - IO_WORKSPACE_ID: "test-workspace-id", - IO_PROJECT_ID: "test-project-id", - EVENT_PREFIX: "test-prefix", - IO_MANAGEMENT_BASE_URL: "https://io-management.test/", - OAUTH_CLIENT_ID: "test-client-id", - OAUTH_TECHNICAL_ACCOUNT_ID: "test-tech-account-id", - OAUTH_TECHNICAL_ACCOUNT_EMAIL: "test@example.com", - OAUTH_ORG_ID: "test-org-id", - OAUTH_CLIENT_SECRET: "", + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: "test-client-id", + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: "test-tech-account-id", + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: "test@example.com", + AIO_COMMERCE_AUTH_IMS_ORG_ID: "test-org-id", }; jest.replaceProperty(process, "env", mockEnv); const result = await main(); @@ -177,9 +135,9 @@ describe("onboarding index", () => { test("should complete successfully when all required values are provided", async () => { // Mock all required dependencies for this test const { assertImsAuthParams } = jest.requireActual( - "@adobe/aio-commerce-lib-auth", + "@adobe/aio-commerce-sdk/auth", ); - jest.doMock("@adobe/aio-commerce-lib-auth", () => ({ + jest.doMock("@adobe/aio-commerce-sdk/auth", () => ({ __esModule: true, getImsAuthProvider: jest.fn().mockReturnValue({ getHeaders: jest.fn().mockResolvedValue({ @@ -261,17 +219,17 @@ describe("onboarding index", () => { // Set up required environment variables const mockEnv = { - COMMERCE_BASE_URL: "https://commerce.test/", + AIO_COMMERCE_API_BASE_URL: "https://commerce.test/", IO_CONSUMER_ID: "test-consumer-id", IO_WORKSPACE_ID: "test-workspace-id", IO_PROJECT_ID: "test-project-id", EVENT_PREFIX: "test-prefix", IO_MANAGEMENT_BASE_URL: "https://io-management.test/", - OAUTH_CLIENT_ID: "test-client-id", - OAUTH_CLIENT_SECRET: "test-client-secret", - OAUTH_TECHNICAL_ACCOUNT_ID: "test-tech-account-id", - OAUTH_TECHNICAL_ACCOUNT_EMAIL: "test@example.com", - OAUTH_ORG_ID: "test-org-id", + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: "test-client-id", + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: ["test-client-secret"], + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: "test-tech-account-id", + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: "test@example.com", + AIO_COMMERCE_AUTH_IMS_ORG_ID: "test-org-id", }; jest.replaceProperty(process, "env", mockEnv); jest.resetModules(); @@ -337,9 +295,9 @@ describe("onboarding index", () => { test("should print an error when workspace.json file is missing", async () => { // Mock all required dependencies for this test const { assertImsAuthParams } = jest.requireActual( - "@adobe/aio-commerce-lib-auth", + "@adobe/aio-commerce-sdk/auth", ); - jest.doMock("@adobe/aio-commerce-lib-auth", () => ({ + jest.doMock("@adobe/aio-commerce-sdk/auth", () => ({ __esModule: true, getImsAuthProvider: jest.fn().mockReturnValue({ getHeaders: jest.fn().mockResolvedValue({ @@ -425,17 +383,17 @@ describe("onboarding index", () => { // Set up required environment variables const mockEnv = { - COMMERCE_BASE_URL: "https://commerce.test/", + AIO_COMMERCE_API_BASE_URL: "https://commerce.test/", IO_CONSUMER_ID: "test-consumer-id", IO_WORKSPACE_ID: "test-workspace-id", IO_PROJECT_ID: "test-project-id", EVENT_PREFIX: "test-prefix", IO_MANAGEMENT_BASE_URL: "https://io-management.test/", - OAUTH_CLIENT_ID: "test-client-id", - OAUTH_CLIENT_SECRET: "test-client-secret", - OAUTH_TECHNICAL_ACCOUNT_ID: "test-tech-account-id", - OAUTH_TECHNICAL_ACCOUNT_EMAIL: "test@example.com", - OAUTH_ORG_ID: "test-org-id", + AIO_COMMERCE_AUTH_IMS_CLIENT_ID: "test-client-id", + AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: ["test-client-secret"], + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: "test-tech-account-id", + AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: "test@example.com", + AIO_COMMERCE_AUTH_IMS_ORG_ID: "test-org-id", }; jest.replaceProperty(process, "env", mockEnv); jest.resetModules(); diff --git a/test/scripts/lib/onboarding.metadata.test.js b/test/scripts/lib/onboarding.metadata.test.js index 65af6a37..fcb7b8df 100644 --- a/test/scripts/lib/onboarding.metadata.test.js +++ b/test/scripts/lib/onboarding.metadata.test.js @@ -191,7 +191,7 @@ describe("Given on-boarding metadata file", () => { label: "Commerce Provider", }, hints: [ - "Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL", + "Make sure your authentication environment parameters are correct. Also check the AIO_COMMERCE_API_BASE_URL", "Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?", ], }, diff --git a/test/scripts/lib/onboarding.providers.test.js b/test/scripts/lib/onboarding.providers.test.js index 5aff4d97..9de51f85 100644 --- a/test/scripts/lib/onboarding.providers.test.js +++ b/test/scripts/lib/onboarding.providers.test.js @@ -1163,7 +1163,7 @@ describe("Given On-boarding providers file", () => { error: fakeError, provider: undefined, hints: [ - "Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL", + "Make sure your authentication environment parameters are correct. Also check the AIO_COMMERCE_API_BASE_URL", "Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?", ], }, diff --git a/test/scripts/lib/onboarding.registrations.test.js b/test/scripts/lib/onboarding.registrations.test.js index 027f10c6..d27964e4 100644 --- a/test/scripts/lib/onboarding.registrations.test.js +++ b/test/scripts/lib/onboarding.registrations.test.js @@ -877,7 +877,7 @@ describe("Given on-boarding registrations file", () => { payload: { error: fakeError, hints: [ - "Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL", + "Make sure your authentication environment parameters are correct. Also check the AIO_COMMERCE_API_BASE_URL", "Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?", ], }, diff --git a/utils/adobe-auth.js b/utils/adobe-auth.js index d0ef04f1..351cf015 100644 --- a/utils/adobe-auth.js +++ b/utils/adobe-auth.js @@ -13,7 +13,8 @@ governing permissions and limitations under the License. const { assertImsAuthParams, getImsAuthProvider, -} = require("@adobe/aio-commerce-lib-auth"); +} = require("@adobe/aio-commerce-sdk/auth"); +const { parseArrayParam } = require("../actions/utils"); const DEFAULT_IMS_SCOPES = [ "AdobeID", @@ -33,15 +34,21 @@ const DEFAULT_IMS_SCOPES = [ * @returns IMS authentication configuration object */ function resolveImsConfig(params) { + const clientSecrets = parseArrayParam( + params.AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS, + [], + ).filter((secret) => secret.trim() !== ""); + return { - clientId: params.OAUTH_CLIENT_ID, - clientSecrets: params.OAUTH_CLIENT_SECRET - ? [params.OAUTH_CLIENT_SECRET] - : [], - technicalAccountId: params.OAUTH_TECHNICAL_ACCOUNT_ID, - technicalAccountEmail: params.OAUTH_TECHNICAL_ACCOUNT_EMAIL, - imsOrgId: params.OAUTH_ORG_ID, - scopes: DEFAULT_IMS_SCOPES, + clientId: params.AIO_COMMERCE_AUTH_IMS_CLIENT_ID, + clientSecrets, + technicalAccountId: params.AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID, + technicalAccountEmail: params.AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL, + imsOrgId: params.AIO_COMMERCE_AUTH_IMS_ORG_ID, + scopes: parseArrayParam( + params.AIO_COMMERCE_AUTH_IMS_SCOPES, + DEFAULT_IMS_SCOPES, + ), environment: params.AIO_CLI_ENV || "prod", }; }