@adobe-commerce/aio-toolkit 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/README.md +58 -2
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +37 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5551,6 +5551,7 @@ var _OnboardCommerce = class _OnboardCommerce {
|
|
|
5551
5551
|
* @param merchantId - Merchant ID for Adobe Commerce
|
|
5552
5552
|
* @param environmentId - Environment ID for Adobe Commerce
|
|
5553
5553
|
* @param logger - Optional logger instance for logging operations
|
|
5554
|
+
* @param isPaaS - Flag to indicate if the Commerce instance is PaaS (defaults to false)
|
|
5554
5555
|
* @throws {Error} When required parameters are missing or invalid
|
|
5555
5556
|
* @example
|
|
5556
5557
|
* ```typescript
|
|
@@ -5563,7 +5564,7 @@ var _OnboardCommerce = class _OnboardCommerce {
|
|
|
5563
5564
|
* );
|
|
5564
5565
|
* ```
|
|
5565
5566
|
*/
|
|
5566
|
-
constructor(adobeCommerceClient, merchantId, environmentId, logger = null) {
|
|
5567
|
+
constructor(adobeCommerceClient, merchantId, environmentId, logger = null, isPaaS = false) {
|
|
5567
5568
|
if (!adobeCommerceClient) {
|
|
5568
5569
|
throw new Error("Adobe Commerce client is required");
|
|
5569
5570
|
}
|
|
@@ -5576,6 +5577,7 @@ var _OnboardCommerce = class _OnboardCommerce {
|
|
|
5576
5577
|
this.adobeCommerceClient = adobeCommerceClient;
|
|
5577
5578
|
this.merchantId = merchantId;
|
|
5578
5579
|
this.environmentId = environmentId;
|
|
5580
|
+
this.isPaaS = isPaaS;
|
|
5579
5581
|
this.customLogger = new custom_logger_default(logger);
|
|
5580
5582
|
this.configureProvider = new configure_provider_default(
|
|
5581
5583
|
adobeCommerceClient,
|
|
@@ -5632,16 +5634,22 @@ var _OnboardCommerce = class _OnboardCommerce {
|
|
|
5632
5634
|
`[FETCH] Retrieved ${existingSubscriptions.length} existing event subscription(s)`
|
|
5633
5635
|
);
|
|
5634
5636
|
}
|
|
5635
|
-
this.customLogger.debug("[FETCH] Fetching supported events list...");
|
|
5636
|
-
const supportedEventsResult = await this.eventService.supportedList();
|
|
5637
5637
|
let supportedEvents = [];
|
|
5638
|
-
if (!
|
|
5639
|
-
this.customLogger.
|
|
5640
|
-
|
|
5641
|
-
)
|
|
5638
|
+
if (!this.isPaaS) {
|
|
5639
|
+
this.customLogger.debug("[FETCH] Fetching supported events list...");
|
|
5640
|
+
const supportedEventsResult = await this.eventService.supportedList();
|
|
5641
|
+
if (!supportedEventsResult.success) {
|
|
5642
|
+
this.customLogger.error(
|
|
5643
|
+
`[ERROR] Failed to fetch supported events: ${supportedEventsResult.error}`
|
|
5644
|
+
);
|
|
5645
|
+
} else {
|
|
5646
|
+
supportedEvents = Array.isArray(supportedEventsResult.data) ? supportedEventsResult.data : [];
|
|
5647
|
+
this.customLogger.debug(
|
|
5648
|
+
`[FETCH] Retrieved ${supportedEvents.length} supported event(s)`
|
|
5649
|
+
);
|
|
5650
|
+
}
|
|
5642
5651
|
} else {
|
|
5643
|
-
|
|
5644
|
-
this.customLogger.debug(`[FETCH] Retrieved ${supportedEvents.length} supported event(s)`);
|
|
5652
|
+
this.customLogger.debug("[SKIP] Skipping supported events validation for PaaS instance");
|
|
5645
5653
|
}
|
|
5646
5654
|
const { alreadySubscribed, needsSubscription, unsupported } = this.filterEventsBySubscriptionStatus(
|
|
5647
5655
|
commerceEventsConfig,
|
|
@@ -5684,6 +5692,15 @@ ${JSON.stringify(preparedEvent.event, null, 2)}`
|
|
|
5684
5692
|
}
|
|
5685
5693
|
}
|
|
5686
5694
|
this.logEventSubscriptionSummary(result, provider.label);
|
|
5695
|
+
if (this.isPaaS) {
|
|
5696
|
+
this.customLogger.info("[IMPORTANT] \u26A0\uFE0F Post-Subscription Steps for PaaS:");
|
|
5697
|
+
this.customLogger.info(
|
|
5698
|
+
"[IMPORTANT] 1. Run: bin/magento events:generate:module to generate module after successful event subscription"
|
|
5699
|
+
);
|
|
5700
|
+
this.customLogger.info(
|
|
5701
|
+
"[IMPORTANT] 2. Run: bin/magento setup:upgrade && bin/magento setup:di:compile && bin/magento cache:flush to install the generated module"
|
|
5702
|
+
);
|
|
5703
|
+
}
|
|
5687
5704
|
}
|
|
5688
5705
|
return {
|
|
5689
5706
|
success: true,
|
|
@@ -5741,6 +5758,10 @@ ${JSON.stringify(preparedEvent.event, null, 2)}`
|
|
|
5741
5758
|
/**
|
|
5742
5759
|
* Prepares event payload by transforming event names and adding provider information
|
|
5743
5760
|
*
|
|
5761
|
+
* For PaaS instances, the parent field is omitted to support native events (observer.*, plugin.*)
|
|
5762
|
+
* which would be rejected by Adobe Commerce as invalid aliases if parent is set to the same name.
|
|
5763
|
+
* For non-PaaS instances, the parent field is set to the event name as usual.
|
|
5764
|
+
*
|
|
5744
5765
|
* @param eventSpec - Event specification object containing event details
|
|
5745
5766
|
* @param providerId - Provider ID to assign to the event
|
|
5746
5767
|
* @returns Modified event specification with updated event properties
|
|
@@ -5757,12 +5778,18 @@ ${JSON.stringify(preparedEvent.event, null, 2)}`
|
|
|
5757
5778
|
throw new Error("Valid provider ID is required");
|
|
5758
5779
|
}
|
|
5759
5780
|
const modifiedEventSpec = JSON.parse(JSON.stringify(eventSpec));
|
|
5760
|
-
|
|
5781
|
+
const eventName = modifiedEventSpec.event.name;
|
|
5782
|
+
if (!this.isPaaS) {
|
|
5783
|
+
modifiedEventSpec.event.parent = eventName;
|
|
5784
|
+
}
|
|
5761
5785
|
modifiedEventSpec.event.provider_id = providerId;
|
|
5762
5786
|
modifiedEventSpec.event.destination = "default";
|
|
5763
5787
|
modifiedEventSpec.event.provider_id = providerId;
|
|
5764
5788
|
modifiedEventSpec.event.priority = true;
|
|
5765
5789
|
modifiedEventSpec.event.hipaa_audit_required = false;
|
|
5790
|
+
if (!modifiedEventSpec.event.rules) {
|
|
5791
|
+
modifiedEventSpec.event.rules = [];
|
|
5792
|
+
}
|
|
5766
5793
|
return modifiedEventSpec;
|
|
5767
5794
|
}
|
|
5768
5795
|
/**
|