@adobe-commerce/aio-toolkit 1.0.6 → 1.0.8
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 +105 -0
- package/README.md +58 -2
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +42 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -479,7 +479,6 @@ var _FileRepository = class _FileRepository {
|
|
|
479
479
|
const existingData = JSON.parse(buffer.toString());
|
|
480
480
|
payload = { ...existingData, ...payload };
|
|
481
481
|
}
|
|
482
|
-
await filesLib.delete(filepath);
|
|
483
482
|
} else {
|
|
484
483
|
payload = {
|
|
485
484
|
id: fileId,
|
|
@@ -4360,9 +4359,7 @@ var _CreateProviders = class _CreateProviders {
|
|
|
4360
4359
|
}
|
|
4361
4360
|
try {
|
|
4362
4361
|
const providerInput = this.preparePayload(providerData, enhancedLabel);
|
|
4363
|
-
this.logger.debug(
|
|
4364
|
-
`[NEW] Creating new provider with payload: ${JSON.stringify(providerInput)}`
|
|
4365
|
-
);
|
|
4362
|
+
this.logger.debug(`[NEW] Creating new provider: ${enhancedLabel}`);
|
|
4366
4363
|
const createdProvider = await this.getProviderManager().create(providerInput);
|
|
4367
4364
|
this.logger.debug(
|
|
4368
4365
|
`[INFO] Provider created successfully! ID: ${createdProvider.id}, Instance ID: ${createdProvider.instance_id}`
|
|
@@ -4881,7 +4878,7 @@ var _CreateRegistrations = class _CreateRegistrations {
|
|
|
4881
4878
|
registrationName,
|
|
4882
4879
|
firstEvent
|
|
4883
4880
|
);
|
|
4884
|
-
this.logger.debug(`[INFO]
|
|
4881
|
+
this.logger.debug(`[INFO] Creating registration: ${registrationName}`);
|
|
4885
4882
|
const registrationSDK = this.getRegistrationManager();
|
|
4886
4883
|
const createdRegistration = await registrationSDK.create(registrationInput);
|
|
4887
4884
|
this.logger.debug("[SUCCESS] Registration created successfully!");
|
|
@@ -5447,10 +5444,7 @@ var _ConfigureProvider = class _ConfigureProvider {
|
|
|
5447
5444
|
description: provider.description,
|
|
5448
5445
|
workspace_configuration: JSON.stringify(workspaceConfig)
|
|
5449
5446
|
};
|
|
5450
|
-
this.customLogger.debug(
|
|
5451
|
-
`[DEBUG] Creating event provider:
|
|
5452
|
-
${JSON.stringify(providerData, null, 2)}`
|
|
5453
|
-
);
|
|
5447
|
+
this.customLogger.debug(`[DEBUG] Creating event provider: ${provider.label} (${provider.id})`);
|
|
5454
5448
|
const createResult = await this.eventProviderService.create(providerData);
|
|
5455
5449
|
if (!createResult.success) {
|
|
5456
5450
|
const errorMsg = `Failed to create event provider: ${createResult.error}`;
|
|
@@ -5488,8 +5482,7 @@ ${JSON.stringify(providerData, null, 2)}`
|
|
|
5488
5482
|
workspace_configuration: JSON.stringify(workspaceConfig)
|
|
5489
5483
|
};
|
|
5490
5484
|
this.customLogger.debug(
|
|
5491
|
-
`[DEBUG] Updating configuration
|
|
5492
|
-
${JSON.stringify(updateConfigPayload, null, 2)}`
|
|
5485
|
+
`[DEBUG] Updating workspace configuration for merchant: ${this.merchantId}`
|
|
5493
5486
|
);
|
|
5494
5487
|
const updateResult = await this.eventConfigurationService.update(updateConfigPayload);
|
|
5495
5488
|
if (!updateResult.success) {
|
|
@@ -5551,6 +5544,7 @@ var _OnboardCommerce = class _OnboardCommerce {
|
|
|
5551
5544
|
* @param merchantId - Merchant ID for Adobe Commerce
|
|
5552
5545
|
* @param environmentId - Environment ID for Adobe Commerce
|
|
5553
5546
|
* @param logger - Optional logger instance for logging operations
|
|
5547
|
+
* @param isPaaS - Flag to indicate if the Commerce instance is PaaS (defaults to false)
|
|
5554
5548
|
* @throws {Error} When required parameters are missing or invalid
|
|
5555
5549
|
* @example
|
|
5556
5550
|
* ```typescript
|
|
@@ -5563,7 +5557,7 @@ var _OnboardCommerce = class _OnboardCommerce {
|
|
|
5563
5557
|
* );
|
|
5564
5558
|
* ```
|
|
5565
5559
|
*/
|
|
5566
|
-
constructor(adobeCommerceClient, merchantId, environmentId, logger = null) {
|
|
5560
|
+
constructor(adobeCommerceClient, merchantId, environmentId, logger = null, isPaaS = false) {
|
|
5567
5561
|
if (!adobeCommerceClient) {
|
|
5568
5562
|
throw new Error("Adobe Commerce client is required");
|
|
5569
5563
|
}
|
|
@@ -5576,6 +5570,7 @@ var _OnboardCommerce = class _OnboardCommerce {
|
|
|
5576
5570
|
this.adobeCommerceClient = adobeCommerceClient;
|
|
5577
5571
|
this.merchantId = merchantId;
|
|
5578
5572
|
this.environmentId = environmentId;
|
|
5573
|
+
this.isPaaS = isPaaS;
|
|
5579
5574
|
this.customLogger = new custom_logger_default(logger);
|
|
5580
5575
|
this.configureProvider = new configure_provider_default(
|
|
5581
5576
|
adobeCommerceClient,
|
|
@@ -5632,16 +5627,22 @@ var _OnboardCommerce = class _OnboardCommerce {
|
|
|
5632
5627
|
`[FETCH] Retrieved ${existingSubscriptions.length} existing event subscription(s)`
|
|
5633
5628
|
);
|
|
5634
5629
|
}
|
|
5635
|
-
this.customLogger.debug("[FETCH] Fetching supported events list...");
|
|
5636
|
-
const supportedEventsResult = await this.eventService.supportedList();
|
|
5637
5630
|
let supportedEvents = [];
|
|
5638
|
-
if (!
|
|
5639
|
-
this.customLogger.
|
|
5640
|
-
|
|
5641
|
-
)
|
|
5631
|
+
if (!this.isPaaS) {
|
|
5632
|
+
this.customLogger.debug("[FETCH] Fetching supported events list...");
|
|
5633
|
+
const supportedEventsResult = await this.eventService.supportedList();
|
|
5634
|
+
if (!supportedEventsResult.success) {
|
|
5635
|
+
this.customLogger.error(
|
|
5636
|
+
`[ERROR] Failed to fetch supported events: ${supportedEventsResult.error}`
|
|
5637
|
+
);
|
|
5638
|
+
} else {
|
|
5639
|
+
supportedEvents = Array.isArray(supportedEventsResult.data) ? supportedEventsResult.data : [];
|
|
5640
|
+
this.customLogger.debug(
|
|
5641
|
+
`[FETCH] Retrieved ${supportedEvents.length} supported event(s)`
|
|
5642
|
+
);
|
|
5643
|
+
}
|
|
5642
5644
|
} else {
|
|
5643
|
-
|
|
5644
|
-
this.customLogger.debug(`[FETCH] Retrieved ${supportedEvents.length} supported event(s)`);
|
|
5645
|
+
this.customLogger.debug("[SKIP] Skipping supported events validation for PaaS instance");
|
|
5645
5646
|
}
|
|
5646
5647
|
const { alreadySubscribed, needsSubscription, unsupported } = this.filterEventsBySubscriptionStatus(
|
|
5647
5648
|
commerceEventsConfig,
|
|
@@ -5659,10 +5660,7 @@ var _OnboardCommerce = class _OnboardCommerce {
|
|
|
5659
5660
|
for (const commerceEvent of needsSubscription) {
|
|
5660
5661
|
try {
|
|
5661
5662
|
const preparedEvent = this.prepareEventPayload(commerceEvent, provider.id);
|
|
5662
|
-
this.customLogger.debug(
|
|
5663
|
-
`[DEBUG] Subscribing to event with payload:
|
|
5664
|
-
${JSON.stringify(preparedEvent.event, null, 2)}`
|
|
5665
|
-
);
|
|
5663
|
+
this.customLogger.debug(`[DEBUG] Subscribing to event: ${commerceEvent.event.name}`);
|
|
5666
5664
|
const eventSubscribeResult = await this.eventSubscriptionService.create(
|
|
5667
5665
|
preparedEvent.event
|
|
5668
5666
|
);
|
|
@@ -5684,6 +5682,15 @@ ${JSON.stringify(preparedEvent.event, null, 2)}`
|
|
|
5684
5682
|
}
|
|
5685
5683
|
}
|
|
5686
5684
|
this.logEventSubscriptionSummary(result, provider.label);
|
|
5685
|
+
if (this.isPaaS) {
|
|
5686
|
+
this.customLogger.info("[IMPORTANT] \u26A0\uFE0F Post-Subscription Steps for PaaS:");
|
|
5687
|
+
this.customLogger.info(
|
|
5688
|
+
"[IMPORTANT] 1. Run: bin/magento events:generate:module to generate module after successful event subscription"
|
|
5689
|
+
);
|
|
5690
|
+
this.customLogger.info(
|
|
5691
|
+
"[IMPORTANT] 2. Run: bin/magento setup:upgrade && bin/magento setup:di:compile && bin/magento cache:flush to install the generated module"
|
|
5692
|
+
);
|
|
5693
|
+
}
|
|
5687
5694
|
}
|
|
5688
5695
|
return {
|
|
5689
5696
|
success: true,
|
|
@@ -5741,6 +5748,10 @@ ${JSON.stringify(preparedEvent.event, null, 2)}`
|
|
|
5741
5748
|
/**
|
|
5742
5749
|
* Prepares event payload by transforming event names and adding provider information
|
|
5743
5750
|
*
|
|
5751
|
+
* For PaaS instances, the parent field is omitted to support native events (observer.*, plugin.*)
|
|
5752
|
+
* which would be rejected by Adobe Commerce as invalid aliases if parent is set to the same name.
|
|
5753
|
+
* For non-PaaS instances, the parent field is set to the event name as usual.
|
|
5754
|
+
*
|
|
5744
5755
|
* @param eventSpec - Event specification object containing event details
|
|
5745
5756
|
* @param providerId - Provider ID to assign to the event
|
|
5746
5757
|
* @returns Modified event specification with updated event properties
|
|
@@ -5757,12 +5768,18 @@ ${JSON.stringify(preparedEvent.event, null, 2)}`
|
|
|
5757
5768
|
throw new Error("Valid provider ID is required");
|
|
5758
5769
|
}
|
|
5759
5770
|
const modifiedEventSpec = JSON.parse(JSON.stringify(eventSpec));
|
|
5760
|
-
|
|
5771
|
+
const eventName = modifiedEventSpec.event.name;
|
|
5772
|
+
if (!this.isPaaS) {
|
|
5773
|
+
modifiedEventSpec.event.parent = eventName;
|
|
5774
|
+
}
|
|
5761
5775
|
modifiedEventSpec.event.provider_id = providerId;
|
|
5762
5776
|
modifiedEventSpec.event.destination = "default";
|
|
5763
5777
|
modifiedEventSpec.event.provider_id = providerId;
|
|
5764
5778
|
modifiedEventSpec.event.priority = true;
|
|
5765
5779
|
modifiedEventSpec.event.hipaa_audit_required = false;
|
|
5780
|
+
if (!modifiedEventSpec.event.rules) {
|
|
5781
|
+
modifiedEventSpec.event.rules = [];
|
|
5782
|
+
}
|
|
5766
5783
|
return modifiedEventSpec;
|
|
5767
5784
|
}
|
|
5768
5785
|
/**
|