@adobe-commerce/aio-toolkit 1.0.5 → 1.0.6

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 CHANGED
@@ -5,6 +5,77 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.0.6] - 2025-11-11
9
+
10
+ ### 🚀 New Integration Module & API Enhancements
11
+
12
+ This release introduces the comprehensive OnboardCommerce integration module for Adobe Commerce I/O Events configuration, a new RuntimeApiGatewayService for flexible Runtime API endpoint management, structured logging system with prefixed messages, and the OnboardIOEvents alias with OnboardEvents deprecation for improved naming clarity. All changes maintain backward compatibility while adding powerful new functionality for Adobe Commerce integrations.
13
+
14
+ #### 🛍️ Commerce Integration Components
15
+
16
+ - **OnboardCommerce** `[New]` - Complete Adobe Commerce I/O Events configuration orchestration
17
+ - Automated provider configuration and validation
18
+ - Event subscription management with conflict detection
19
+ - Support for multiple commerce events with custom configurations
20
+ - Intelligent event metadata validation against supported events
21
+ - Skip duplicate subscriptions automatically
22
+ - Structured logging with visual indicators (`[START]`, `[CREATE]`, `[SKIP]`, `[ERROR]`)
23
+ - Comprehensive summary reporting with provider and event statistics
24
+ - Full TypeScript support with detailed type definitions
25
+ - 100% test coverage with 1,158+ test cases
26
+ - Integration with existing Adobe I/O Events infrastructure
27
+
28
+ #### 🔧 Framework Components
29
+
30
+ - **RuntimeApiGatewayService** `[New]` - Flexible Adobe I/O Runtime API Gateway client
31
+ - Centralized service for Runtime API Gateway endpoint management
32
+ - Automatic IMS token generation and authentication
33
+ - Built-in authentication headers with organization ID
34
+ - Support for all HTTP methods (GET, POST, PUT, DELETE)
35
+ - Flexible endpoint configuration without hardcoded paths
36
+ - Comprehensive error handling with detailed logging
37
+ - Integration with ImsToken for token management
38
+ - CustomLogger integration for consistent logging
39
+ - Type-safe TypeScript interfaces
40
+
41
+ - **ImsToken** `[Enhanced]` - Context-specific token management
42
+ - New `tokenKey` and `tokenContext` constructor parameters
43
+ - Allows multiple ImsToken instances with different contexts
44
+ - Prevents token collision for different service integrations
45
+ - Enhanced caching strategy for multi-service applications
46
+ - Full backward compatibility maintained
47
+
48
+ #### 🔗 Integration Components
49
+
50
+ - **OnboardIOEvents** `[New]` - Renamed alias for OnboardEvents
51
+ - New recommended export name for improved clarity
52
+ - Better naming alignment with Adobe I/O Events terminology
53
+ - Full backward compatibility with OnboardEvents
54
+ - Identical functionality and API surface
55
+
56
+ - **OnboardEvents** `[Deprecated]` - Original export marked for future removal
57
+ - **DEPRECATED**: Use OnboardIOEvents instead
58
+ - JSDoc `@deprecated` tag added for IDE warnings
59
+ - Will be removed in a future major version
60
+ - Migration path documented in README
61
+ - No breaking changes - both exports work identically
62
+
63
+ ---
64
+
65
+ ### 📚 **Migration Guide**
66
+
67
+ #### OnboardEvents → OnboardIOEvents
68
+
69
+ Update your imports to use the new OnboardIOEvents export:
70
+
71
+ ```typescript
72
+ // ❌ Deprecated (will show IDE warning)
73
+ import { OnboardEvents } from '@adobe-commerce/aio-toolkit';
74
+
75
+ // ✅ Recommended
76
+ import { OnboardIOEvents } from '@adobe-commerce/aio-toolkit';
77
+ ```
78
+
8
79
  ## [1.0.5] - 2025-11-03
9
80
 
10
81
  ### 🚀 API Enhancements, Security & Developer Experience Improvements
package/README.md CHANGED
@@ -282,6 +282,53 @@ const helloWorldAction = OpenwhiskAction.execute('hello-world', async (params, c
282
282
  exports.main = helloWorldAction;
283
283
  ```
284
284
 
285
+ #### `RuntimeApiGatewayService`
286
+ Flexible Adobe I/O Runtime API Gateway client with automatic IMS token management and authentication.
287
+
288
+ ```typescript
289
+ const { RuntimeApiGatewayService } = require('@adobe-commerce/aio-toolkit');
290
+
291
+ // Initialize the service
292
+ const apiGatewayService = new RuntimeApiGatewayService(
293
+ 'your-client-id',
294
+ 'your-client-secret',
295
+ 'your-technical-account-id',
296
+ 'your-technical-account-email@example.com',
297
+ 'your-ims-org-id@AdobeOrg',
298
+ ['openid', 'AdobeID', 'adobeio_api'],
299
+ 'your-namespace-12345',
300
+ logger // Optional custom logger
301
+ );
302
+
303
+ // GET request
304
+ const data = await apiGatewayService.get('v1/web/my-package/my-action');
305
+ console.log('Action response:', data);
306
+
307
+ // POST request with payload
308
+ const result = await apiGatewayService.post('v1/web/my-package/process', {
309
+ orderId: 'ORD-123',
310
+ action: 'process'
311
+ });
312
+
313
+ // PUT request
314
+ const updateResult = await apiGatewayService.put('v1/web/my-package/update', {
315
+ id: '123',
316
+ status: 'completed'
317
+ });
318
+
319
+ // DELETE request
320
+ const deleteResult = await apiGatewayService.delete('v1/web/my-package/remove/123');
321
+ ```
322
+
323
+ **Key Features:**
324
+ - Automatic IMS token generation and caching
325
+ - Built-in authentication headers
326
+ - Support for GET, POST, PUT, DELETE methods
327
+ - Flexible endpoint configuration
328
+ - Comprehensive error handling
329
+ - Integration with ImsToken for token management
330
+ - CustomLogger integration
331
+
285
332
  #### `FileRepository`
286
333
  File-based storage with CRUD operations for Adobe I/O Runtime applications.
287
334
 
@@ -669,6 +716,110 @@ const newCarrier = new ShippingCarrier('ups', (c) => {
669
716
  - Empty or whitespace-only codes throw errors
670
717
  - Code property cannot be changed after initialization
671
718
 
719
+ #### `OnboardCommerce`
720
+ Complete Adobe Commerce I/O Events configuration orchestration with automated provider setup and event subscription management.
721
+
722
+ ```typescript
723
+ const {
724
+ OnboardCommerce,
725
+ AdobeCommerceClient,
726
+ ImsConnection
727
+ } = require('@adobe-commerce/aio-toolkit');
728
+ const Core = require('@adobe/aio-sdk').Core;
729
+
730
+ // Initialize Adobe Commerce client
731
+ const connection = new ImsConnection(
732
+ 'client-id',
733
+ 'client-secret',
734
+ 'technical-account-id',
735
+ 'technical-account-email',
736
+ 'ims-org-id',
737
+ ['AdobeID', 'openid', 'adobeio_api'],
738
+ logger
739
+ );
740
+ const adobeCommerceClient = new AdobeCommerceClient(
741
+ 'https://your-commerce-store.com',
742
+ connection
743
+ );
744
+
745
+ // Initialize logger
746
+ const logger = Core.Logger('onboard-client', {
747
+ level: 'debug'
748
+ });
749
+
750
+ // Initialize OnboardCommerce
751
+ const onboardCommerce = new OnboardCommerce(
752
+ adobeCommerceClient,
753
+ process.env.COMMERCE_ADOBE_IO_EVENTS_MERCHANT_ID || '',
754
+ process.env.COMMERCE_ADOBE_IO_EVENTS_ENVIRONMENT_ID || '',
755
+ logger
756
+ );
757
+
758
+ // Define commerce provider
759
+ const commerceProvider = {
760
+ raw: {
761
+ id: 'commerce-provider-id',
762
+ label: 'Commerce Events Provider',
763
+ description: 'Provider for Adobe Commerce events',
764
+ docsUrl: 'https://developer.adobe.com/commerce/events'
765
+ }
766
+ };
767
+
768
+ // Define workspace configuration
769
+ const workspaceConfig = {
770
+ project: {
771
+ id: process.env.ADOBE_PROJECT_ID,
772
+ name: 'My Commerce Project',
773
+ title: 'Commerce Integration'
774
+ },
775
+ workspace: {
776
+ id: process.env.ADOBE_WORKSPACE_ID,
777
+ name: 'Production'
778
+ }
779
+ };
780
+
781
+ // Define commerce events configuration
782
+ const commerceEventsConfig = [
783
+ {
784
+ event: {
785
+ name: 'com.adobe.commerce.observer.catalog_product_save_after',
786
+ label: 'Product Saved',
787
+ description: 'Triggered when a product is saved'
788
+ }
789
+ },
790
+ {
791
+ event: {
792
+ name: 'com.adobe.commerce.observer.sales_order_save_after',
793
+ label: 'Order Saved',
794
+ description: 'Triggered when an order is saved'
795
+ }
796
+ }
797
+ ];
798
+
799
+ // Execute configuration
800
+ const result = await onboardCommerce.process(
801
+ commerceProvider.raw,
802
+ workspaceConfig,
803
+ commerceEventsConfig
804
+ );
805
+
806
+ if (result.success) {
807
+ console.log('✅ Commerce events configured successfully');
808
+ console.log(`Provider: ${result.provider?.label}`);
809
+ } else {
810
+ console.error('❌ Configuration failed:', result.error);
811
+ }
812
+ ```
813
+
814
+ **Key Features:**
815
+ - Automated provider configuration with validation
816
+ - Event subscription management with duplicate detection
817
+ - Intelligent event metadata validation against supported Commerce events
818
+ - Structured logging with prefixes: `[START]`, `[CREATE]`, `[SKIP]`, `[ERROR]`
819
+ - Comprehensive summary reporting with event subscription statistics
820
+ - Integration with Adobe Commerce API for event discovery
821
+ - 100% test coverage
822
+
672
823
  ### 🎨 Experience Components
673
824
 
674
825
  **Adobe Commerce Admin UI extension and user experience tools**
@@ -837,13 +988,16 @@ await InfiniteLoopBreaker.storeFingerPrint(
837
988
  );
838
989
  ```
839
990
 
840
- #### `OnboardEvents`
991
+ #### `OnboardIOEvents` (formerly `OnboardEvents`)
841
992
  Complete onboarding orchestration for Adobe I/O Events (providers, metadata, and registrations).
842
993
 
994
+ > **Note**: `OnboardEvents` is deprecated and will be removed in v2.0.0. Please use `OnboardIOEvents` instead.
995
+
843
996
  ```typescript
844
- const { OnboardEvents } = require('@adobe-commerce/aio-toolkit');
997
+ const { OnboardIOEvents } = require('@adobe-commerce/aio-toolkit');
845
998
 
846
- const onboardEvents = new OnboardEvents(
999
+ // Recommended - Use OnboardIOEvents
1000
+ const onboardEvents = new OnboardIOEvents(
847
1001
  'My E-commerce Store',
848
1002
  process.env.ADOBE_CONSUMER_ID!,
849
1003
  process.env.ADOBE_PROJECT_ID!,
package/dist/index.d.mts CHANGED
@@ -231,6 +231,46 @@ declare class WebhookActionResponse {
231
231
  static remove(path: string): WebhookActionRemoveResponse;
232
232
  }
233
233
 
234
+ interface ImsTokenResult {
235
+ token: string | null;
236
+ expire_in: number;
237
+ }
238
+
239
+ declare class ImsToken {
240
+ private readonly clientId;
241
+ private readonly clientSecret;
242
+ private readonly technicalAccountId;
243
+ private readonly technicalAccountEmail;
244
+ private readonly imsOrgId;
245
+ private readonly scopes;
246
+ private readonly customLogger;
247
+ private state;
248
+ private readonly tokenContext;
249
+ private readonly key;
250
+ constructor(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: Array<string>, logger?: any, cacheKey?: string, tokenContext?: string);
251
+ execute(): Promise<string | null>;
252
+ getImsToken(): Promise<ImsTokenResult | null>;
253
+ setValue(result: ImsTokenResult): Promise<boolean>;
254
+ getValue(): Promise<string | null>;
255
+ getState(): Promise<any>;
256
+ }
257
+
258
+ declare class RuntimeApiGatewayService {
259
+ private static readonly BASE_URL;
260
+ private readonly namespace;
261
+ private readonly imsOrgId;
262
+ private readonly imsToken;
263
+ private readonly restClient;
264
+ private readonly customLogger;
265
+ constructor(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: Array<string>, namespace: string, logger?: any);
266
+ private buildEndpoint;
267
+ private getAuthenticatedHeaders;
268
+ get(endpoint: string, additionalHeaders?: Record<string, string>): Promise<any>;
269
+ post(endpoint: string, payload: any, additionalHeaders?: Record<string, string>): Promise<any>;
270
+ put(endpoint: string, payload: any, additionalHeaders?: Record<string, string>): Promise<any>;
271
+ delete(endpoint: string, additionalHeaders?: Record<string, string>): Promise<any>;
272
+ }
273
+
234
274
  interface BearerTokenInfo {
235
275
  token: string | null;
236
276
  tokenLength: number;
@@ -443,10 +483,6 @@ declare class InfiniteLoopBreaker {
443
483
  private static fingerPrint;
444
484
  }
445
485
 
446
- declare class AdobeAuth {
447
- static getToken(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: string[], currentContext?: string): Promise<string>;
448
- }
449
-
450
486
  interface Connection {
451
487
  extend: (client: Got) => Promise<Got>;
452
488
  }
@@ -472,6 +508,120 @@ declare class AdobeCommerceClient {
472
508
  private getHttpClient;
473
509
  }
474
510
 
511
+ declare const IoEventsGlobals: {
512
+ readonly BASE_URL: "https://api.adobe.io";
513
+ readonly STATUS_CODES: {
514
+ readonly OK: 200;
515
+ readonly BAD_REQUEST: 400;
516
+ readonly UNAUTHORIZED: 401;
517
+ readonly FORBIDDEN: 403;
518
+ readonly NOT_FOUND: 404;
519
+ readonly REQUEST_TIMEOUT: 408;
520
+ readonly TIMEOUT: 408;
521
+ readonly CONFLICT: 409;
522
+ readonly INTERNAL_SERVER_ERROR: 500;
523
+ };
524
+ readonly HEADERS: {
525
+ readonly CONFLICTING_ID: "x-conflicting-id";
526
+ };
527
+ };
528
+ interface HALLink {
529
+ href: string;
530
+ templated?: boolean;
531
+ type?: string;
532
+ title?: string;
533
+ }
534
+ interface IOEventsError {
535
+ error?: string;
536
+ message?: string;
537
+ error_code?: string;
538
+ details?: string;
539
+ }
540
+ declare class IOEventsApiError extends Error {
541
+ readonly statusCode: number;
542
+ readonly errorCode: string | undefined;
543
+ readonly details: string | undefined;
544
+ constructor(message: string, statusCode: number, errorCode?: string, details?: string);
545
+ }
546
+
547
+ interface Provider {
548
+ id: string;
549
+ label: string;
550
+ description: string;
551
+ source: string;
552
+ docs_url?: string;
553
+ provider_metadata: string;
554
+ instance_id?: string;
555
+ event_delivery_format: string;
556
+ publisher: string;
557
+ _links?: {
558
+ 'rel:eventmetadata'?: HALLink;
559
+ 'rel:update'?: HALLink;
560
+ self?: HALLink;
561
+ };
562
+ }
563
+
564
+ interface OnboardCommerceConfig {
565
+ adobeCommerceClient: AdobeCommerceClient;
566
+ merchantId: string;
567
+ environmentId: string;
568
+ logger?: any;
569
+ }
570
+ interface CommerceEventField {
571
+ name: string;
572
+ }
573
+ interface CommerceEvent {
574
+ name: string;
575
+ fields: CommerceEventField[];
576
+ }
577
+ interface CommerceEventConfig {
578
+ event: CommerceEvent;
579
+ }
580
+ interface WorkspaceConfig {
581
+ project: {
582
+ id: string;
583
+ name: string;
584
+ title: string;
585
+ org: {
586
+ id: string;
587
+ name: string;
588
+ ims_org_id: string;
589
+ };
590
+ workspace: {
591
+ id: string;
592
+ name: string;
593
+ title: string;
594
+ action_url: string;
595
+ app_url: string;
596
+ details?: any;
597
+ };
598
+ };
599
+ }
600
+ interface OnboardCommerceResult {
601
+ success: boolean;
602
+ message: string;
603
+ error?: string;
604
+ }
605
+
606
+ declare class OnboardCommerce {
607
+ private readonly adobeCommerceClient;
608
+ private readonly merchantId;
609
+ private readonly environmentId;
610
+ private readonly customLogger;
611
+ private readonly configureProvider;
612
+ private readonly eventSubscriptionService;
613
+ private readonly eventService;
614
+ constructor(adobeCommerceClient: AdobeCommerceClient, merchantId: string, environmentId: string, logger?: any);
615
+ process(provider: Provider, workspaceConfig: WorkspaceConfig, commerceEventsConfig?: CommerceEventConfig[]): Promise<any>;
616
+ private filterEventsBySubscriptionStatus;
617
+ private prepareEventPayload;
618
+ private logEventSubscriptionSummary;
619
+ }
620
+
621
+ declare class AdobeAuth {
622
+ static getToken(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: string[], currentContext?: string): Promise<string>;
623
+ }
624
+
475
625
  declare class BasicAuthConnection implements Connection {
476
626
  private baseUrl;
477
627
  private username;
@@ -597,59 +747,6 @@ interface AdobeIMSConfig {
597
747
  scopes: string[];
598
748
  }
599
749
 
600
- declare const IoEventsGlobals: {
601
- readonly BASE_URL: "https://api.adobe.io";
602
- readonly STATUS_CODES: {
603
- readonly OK: 200;
604
- readonly BAD_REQUEST: 400;
605
- readonly UNAUTHORIZED: 401;
606
- readonly FORBIDDEN: 403;
607
- readonly NOT_FOUND: 404;
608
- readonly REQUEST_TIMEOUT: 408;
609
- readonly TIMEOUT: 408;
610
- readonly CONFLICT: 409;
611
- readonly INTERNAL_SERVER_ERROR: 500;
612
- };
613
- readonly HEADERS: {
614
- readonly CONFLICTING_ID: "x-conflicting-id";
615
- };
616
- };
617
- interface HALLink {
618
- href: string;
619
- templated?: boolean;
620
- type?: string;
621
- title?: string;
622
- }
623
- interface IOEventsError {
624
- error?: string;
625
- message?: string;
626
- error_code?: string;
627
- details?: string;
628
- }
629
- declare class IOEventsApiError extends Error {
630
- readonly statusCode: number;
631
- readonly errorCode: string | undefined;
632
- readonly details: string | undefined;
633
- constructor(message: string, statusCode: number, errorCode?: string, details?: string);
634
- }
635
-
636
- interface Provider {
637
- id: string;
638
- label: string;
639
- description: string;
640
- source: string;
641
- docs_url?: string;
642
- provider_metadata: string;
643
- instance_id?: string;
644
- event_delivery_format: string;
645
- publisher: string;
646
- _links?: {
647
- 'rel:eventmetadata'?: HALLink;
648
- 'rel:update'?: HALLink;
649
- self?: HALLink;
650
- };
651
- }
652
-
653
750
  interface GetProviderQueryParams {
654
751
  eventmetadata?: boolean;
655
752
  }
@@ -821,4 +918,4 @@ declare class AdminUiSdk {
821
918
  getRegistration(): AdminUiSdkRegistration;
822
919
  }
823
920
 
824
- export { AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, BasicAuthConnection, BearerToken, type BearerTokenInfo, type Connection, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, Oauth1aConnection, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, Openwhisk, OpenwhiskAction, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, type SuccessResponse, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse };
921
+ export { AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, type SuccessResponse, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };