@adobe-commerce/aio-toolkit 1.0.2 → 1.0.3

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,52 @@ 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.3] - 2025-10-23
9
+
10
+ ### 🎨 New Experience Module & Enhanced Framework Components
11
+
12
+ This patch release introduces a comprehensive new Experience module with AdminUiSdk for Adobe Commerce Admin UI extensions, enhanced IMS token caching with State library integration, Adobe I/O event publishing capabilities with CloudEvents compliance, and critical bug fixes for authentication endpoints. All changes maintain backward compatibility while adding powerful new functionality.
13
+
14
+ #### 🎨 Experience Components
15
+
16
+ - **AdminUiSdk** `[New]` - Adobe Commerce Admin UI extension management
17
+ - Create and manage menu items, sections, and page configurations programmatically
18
+ - Full namespaced ID support (e.g., `dataMappingTool::appBuilderApplication`)
19
+ - Parent-child menu relationships with external references (`Magento_Backend::system`)
20
+ - Comprehensive validation and error handling with detailed error messages
21
+ - Type-safe TypeScript interfaces for MenuItem, Page, and AdminUiSdkRegistration
22
+ - **BREAKING CHANGE**: Accepts full IDs without automatic prefixing for real-world usage patterns
23
+
24
+ #### 🔧 Framework Components
25
+
26
+ - **CustomLogger** `[New]` - Centralized null-safe logging utility
27
+ - Consistent logging interface with debug, info, and error methods across all components
28
+ - Graceful handling of missing or null logger instances without throwing errors
29
+ - Seamless integration with Adobe I/O Runtime logger
30
+
31
+ - **PublishEvent** `[New]` - Adobe I/O Event Publishing with CloudEvents compliance
32
+ - CloudEvents specification compliance with proper event structure
33
+ - UUID generation for unique event tracking and correlation
34
+ - Comprehensive validation for IMS organization ID, API keys, and access tokens
35
+ - Integration with CustomLogger for consistent error handling and debugging
36
+ - Support for custom event subjects and structured payload data
37
+
38
+ #### 🛠️ Commerce Components
39
+
40
+ - **GenerateImsToken** `[Enhanced]` - IMS token caching using Adobe I/O State library
41
+ - Automatic token caching and refresh using Adobe I/O State library for performance optimization
42
+ - Token validation and automatic renewal before expiration
43
+ - Enhanced error handling and logging for token operations
44
+ - **BREAKING CHANGE**: ImsConnection constructor simplified - no longer requires currentContext parameter
45
+
46
+ #### 🐛 Critical Bug Fixes
47
+
48
+ - **BasicAuthConnection Token Endpoint Construction** `[Resolved]`
49
+ - **Problem**: Duplicate `/rest/rest/` segments in token endpoints for base URLs ending with '/rest'
50
+ - **Root Cause**: Improper URL concatenation when base URL already contained REST endpoint path
51
+ - **Solution**: Enhanced createTokenEndpoint() method with intelligent URL parsing and construction
52
+ - **Impact**: Correct token endpoint generation for all base URL formats, maintaining backward compatibility
53
+
8
54
  ## [1.0.2] - 2025-09-30
9
55
 
10
56
  ### 🛠️ Framework Component Enhancements & Critical Bug Fixes
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- A comprehensive TypeScript toolkit for Adobe App Builder applications providing standardized Adobe Commerce integrations, I/O Events orchestration, file storage utilities, authentication helpers, and robust backend development tools with 100% test coverage.
5
+ A comprehensive TypeScript toolkit for Adobe App Builder applications providing standardized Adobe Commerce integrations, I/O Events orchestration, file storage utilities, authentication helpers, and robust backend development tools with 100% test coverage and enterprise-grade reliability.
6
6
 
7
7
  ## Installation
8
8
 
@@ -12,7 +12,7 @@ npm install @adobe-commerce/aio-toolkit
12
12
 
13
13
  ## Usage
14
14
 
15
- The toolkit is organized into four main modules:
15
+ The toolkit is organized into five main modules:
16
16
 
17
17
  ### 🛠️ Framework Components
18
18
 
@@ -91,6 +91,55 @@ const myEventConsumer = EventConsumerAction.execute(
91
91
  exports.main = myEventConsumer;
92
92
  ```
93
93
 
94
+ #### `PublishEvent`
95
+ Event publishing component for Adobe I/O Events with CloudEvents support.
96
+
97
+ ```typescript
98
+ const { PublishEvent } = require('@adobe-commerce/aio-toolkit');
99
+
100
+ // Initialize the publisher
101
+ const publishEvent = new PublishEvent(
102
+ 'your-ims-org-id@AdobeOrg',
103
+ 'your-api-key',
104
+ 'your-access-token',
105
+ logger // Optional custom logger
106
+ );
107
+
108
+ // Publish a simple event
109
+ const result = await publishEvent.execute(
110
+ 'your-provider-id',
111
+ 'commerce.order.created',
112
+ {
113
+ orderId: 'ORD-123456',
114
+ customerId: 'CUST-789',
115
+ amount: 199.99,
116
+ currency: 'USD'
117
+ }
118
+ );
119
+
120
+ console.log(`Event published: ${result.eventId}, Status: ${result.status}`);
121
+
122
+ // Publish an event with subject
123
+ const orderResult = await publishEvent.execute(
124
+ 'commerce-provider',
125
+ 'com.adobe.commerce.order.shipped',
126
+ {
127
+ orderId: 'ORD-123456',
128
+ trackingNumber: 'TRK-789',
129
+ carrier: 'UPS',
130
+ estimatedDelivery: '2023-12-05T18:00:00Z'
131
+ },
132
+ 'orders/ORD-123456'
133
+ );
134
+
135
+ // Handle publishing results
136
+ if (orderResult.status === 'published') {
137
+ console.log(`Order shipped event published successfully: ${orderResult.eventId}`);
138
+ } else {
139
+ console.error(`Failed to publish event: ${orderResult.error}`);
140
+ }
141
+ ```
142
+
94
143
  #### `GraphQlAction`
95
144
  GraphQL server implementation with schema validation and introspection control.
96
145
 
@@ -336,24 +385,110 @@ console.log('Authentication token:', token);
336
385
  #### `AdobeCommerceClient`
337
386
  HTTP client for Adobe Commerce API integration with multiple authentication methods.
338
387
 
388
+ **OAuth 1.0a Authentication**
339
389
  ```typescript
340
- const { AdobeCommerceClient } = require('@adobe-commerce/aio-toolkit');
341
- const { Oauth1aConnection } = require('@adobe-commerce/aio-toolkit');
390
+ const { AdobeCommerceClient, Oauth1aConnection } = require('@adobe-commerce/aio-toolkit');
342
391
 
343
392
  const connection = new Oauth1aConnection(
344
393
  'consumer-key',
345
394
  'consumer-secret',
346
395
  'access-token',
347
396
  'access-token-secret',
348
- logger? // Optional custom logger
397
+ logger // Optional custom logger
349
398
  );
350
399
 
351
400
  // Create client
401
+ const client = new AdobeCommerceClient('https://your-commerce-store.com/rest', connection);
402
+
403
+ // Make API calls
404
+ const products = await client.get('V1/products');
405
+ const newProduct = await client.post('V1/products', {}, productData);
406
+ ```
407
+
408
+ **IMS (Identity Management System) Authentication**
409
+ ```typescript
410
+ const { AdobeCommerceClient, ImsConnection } = require('@adobe-commerce/aio-toolkit');
411
+
412
+ const connection = new ImsConnection(
413
+ 'client-id',
414
+ 'client-secret',
415
+ 'technical-account-id',
416
+ 'technical-account-email',
417
+ 'ims-org-id',
418
+ ['AdobeID', 'openid', 'adobeio_api'], // Scopes array
419
+ logger // Optional custom logger
420
+ );
421
+
422
+ // Create client with IMS authentication
352
423
  const client = new AdobeCommerceClient('https://your-commerce-store.com', connection);
353
424
 
425
+ // Make API calls - tokens are automatically cached and refreshed
426
+ const products = await client.get('V1/products');
427
+ const newProduct = await client.post('V1/products', {}, productData);
428
+ ```
429
+
430
+ **Enhanced IMS Token Caching**
431
+
432
+ ```typescript
433
+ const { GenerateImsToken } = require('@adobe-commerce/aio-toolkit');
434
+
435
+ const tokenGenerator = new GenerateImsToken(
436
+ 'client-id', 'client-secret', 'technical-account-id',
437
+ 'technical-account-email', 'ims-org-id',
438
+ ['AdobeID', 'openid', 'adobeio_api'], logger
439
+ );
440
+
441
+ const token = await tokenGenerator.execute();
442
+ ```
443
+
444
+ **Basic Authentication**
445
+ ```typescript
446
+ const { AdobeCommerceClient, BasicAuthConnection } = require('@adobe-commerce/aio-toolkit');
447
+
448
+ const connection = new BasicAuthConnection(
449
+ 'username',
450
+ 'password',
451
+ logger // Optional custom logger
452
+ );
453
+
454
+ // Create client
455
+ const client = new AdobeCommerceClient('https://your-commerce-store.com/rest', connection);
456
+
354
457
  // Make API calls
355
- const products = await client.get('rest/V1/products');
356
- const newProduct = await client.post('rest/V1/products', {}, productData);
458
+ const products = await client.get('V1/products');
459
+ ```
460
+
461
+ ### 🎨 Experience Components
462
+
463
+ **Adobe Commerce Admin UI extension and user experience tools**
464
+
465
+ #### `AdminUiSdk`
466
+ Create and manage Adobe Commerce Admin UI extensions with menu items, sections, and page configurations.
467
+
468
+ ```typescript
469
+ const { AdminUiSdk } = require('@adobe-commerce/aio-toolkit');
470
+
471
+ const sdk = new AdminUiSdk('dataMappingTool');
472
+
473
+ // Add menu section with external parent
474
+ sdk.addMenuSection(
475
+ 'dataMappingTool::checkout_integration',
476
+ 'Checkout Integration',
477
+ 100,
478
+ 'Magento_Backend::system'
479
+ );
480
+
481
+ // Add menu item
482
+ sdk.addMenuItem(
483
+ 'dataMappingTool::application',
484
+ 'Application',
485
+ 1,
486
+ 'dataMappingTool::checkout_integration'
487
+ );
488
+
489
+ // Set page title and get registration
490
+ sdk.addPage('Data Mapping Tool Dashboard');
491
+ const registration = sdk.getRegistration();
357
492
  ```
358
493
 
359
494
  ### 🔗 Integration Components
package/dist/index.d.mts CHANGED
@@ -139,6 +139,27 @@ declare class FileRepository {
139
139
  private getFiles;
140
140
  }
141
141
 
142
+ interface EventData {
143
+ type: string;
144
+ data: any;
145
+ subject?: string;
146
+ }
147
+ interface PublishEventResult {
148
+ eventId: string;
149
+ status: 'published' | 'failed';
150
+ publishedAt: string;
151
+ error?: string;
152
+ }
153
+
154
+ declare class PublishEvent {
155
+ private readonly imsOrgId;
156
+ private readonly apiKey;
157
+ private readonly accessToken;
158
+ private readonly customLogger;
159
+ constructor(imsOrgId: string, apiKey: string, accessToken: string, logger?: any);
160
+ execute(providerId: string, eventCode: string, payload: any, subject?: string): Promise<PublishEventResult>;
161
+ }
162
+
142
163
  interface BearerTokenInfo {
143
164
  token: string | null;
144
165
  tokenLength: number;
@@ -402,9 +423,8 @@ declare class ImsConnection implements Connection {
402
423
  private technicalAccountEmail;
403
424
  private imsOrgId;
404
425
  private scopes;
405
- private logger;
406
- private currentContext;
407
- constructor(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: Array<string>, logger?: any, currentContext?: string);
426
+ private customLogger;
427
+ constructor(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: Array<string>, logger?: any);
408
428
  extend(commerceGot: any): Promise<any>;
409
429
  }
410
430
 
@@ -423,6 +443,7 @@ declare class GenerateBasicAuthToken {
423
443
  constructor(baseUrl: string, username: string, password: string, logger?: any);
424
444
  execute(): Promise<string | null>;
425
445
  getCommerceToken(): Promise<TokenResult | null>;
446
+ createTokenEndpoint(): string;
426
447
  createEndpoint(endpoint: string): string;
427
448
  setValue(result: TokenResult): Promise<boolean>;
428
449
  getValue(): Promise<string | null>;
@@ -632,4 +653,34 @@ interface GetRegistrationQueryParams {
632
653
  registrationId: string;
633
654
  }
634
655
 
635
- export { AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, BasicAuthConnection, BearerToken, type BearerTokenInfo, type Connection, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, 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, Oauth1aConnection, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, Openwhisk, OpenwhiskAction, Parameters, type Provider, type ProviderInputModel, ProviderManager, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, type SuccessResponse, type TokenResult, Validator };
656
+ interface MenuItem {
657
+ id: string;
658
+ title: string;
659
+ sortOrder: number;
660
+ parent?: string;
661
+ isSection?: boolean;
662
+ }
663
+ interface Page {
664
+ title: string;
665
+ }
666
+ interface AdminUiSdkRegistration {
667
+ registration: {
668
+ menuItems?: MenuItem[];
669
+ page?: Page;
670
+ };
671
+ }
672
+
673
+ declare class AdminUiSdk {
674
+ private extensionId;
675
+ private menuItems;
676
+ private pageTitle?;
677
+ constructor(extensionId: string);
678
+ private isValidExtensionId;
679
+ private isValidMenuId;
680
+ addMenuItem(id: string, title: string, sortOrder: number, parent?: string): void;
681
+ addMenuSection(id: string, title: string, sortOrder: number, parent?: string): void;
682
+ addPage(title: string): void;
683
+ getRegistration(): AdminUiSdkRegistration;
684
+ }
685
+
686
+ 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 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, type SuccessResponse, type TokenResult, Validator };
package/dist/index.d.ts CHANGED
@@ -139,6 +139,27 @@ declare class FileRepository {
139
139
  private getFiles;
140
140
  }
141
141
 
142
+ interface EventData {
143
+ type: string;
144
+ data: any;
145
+ subject?: string;
146
+ }
147
+ interface PublishEventResult {
148
+ eventId: string;
149
+ status: 'published' | 'failed';
150
+ publishedAt: string;
151
+ error?: string;
152
+ }
153
+
154
+ declare class PublishEvent {
155
+ private readonly imsOrgId;
156
+ private readonly apiKey;
157
+ private readonly accessToken;
158
+ private readonly customLogger;
159
+ constructor(imsOrgId: string, apiKey: string, accessToken: string, logger?: any);
160
+ execute(providerId: string, eventCode: string, payload: any, subject?: string): Promise<PublishEventResult>;
161
+ }
162
+
142
163
  interface BearerTokenInfo {
143
164
  token: string | null;
144
165
  tokenLength: number;
@@ -402,9 +423,8 @@ declare class ImsConnection implements Connection {
402
423
  private technicalAccountEmail;
403
424
  private imsOrgId;
404
425
  private scopes;
405
- private logger;
406
- private currentContext;
407
- constructor(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: Array<string>, logger?: any, currentContext?: string);
426
+ private customLogger;
427
+ constructor(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: Array<string>, logger?: any);
408
428
  extend(commerceGot: any): Promise<any>;
409
429
  }
410
430
 
@@ -423,6 +443,7 @@ declare class GenerateBasicAuthToken {
423
443
  constructor(baseUrl: string, username: string, password: string, logger?: any);
424
444
  execute(): Promise<string | null>;
425
445
  getCommerceToken(): Promise<TokenResult | null>;
446
+ createTokenEndpoint(): string;
426
447
  createEndpoint(endpoint: string): string;
427
448
  setValue(result: TokenResult): Promise<boolean>;
428
449
  getValue(): Promise<string | null>;
@@ -632,4 +653,34 @@ interface GetRegistrationQueryParams {
632
653
  registrationId: string;
633
654
  }
634
655
 
635
- export { AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, BasicAuthConnection, BearerToken, type BearerTokenInfo, type Connection, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, 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, Oauth1aConnection, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, Openwhisk, OpenwhiskAction, Parameters, type Provider, type ProviderInputModel, ProviderManager, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, type SuccessResponse, type TokenResult, Validator };
656
+ interface MenuItem {
657
+ id: string;
658
+ title: string;
659
+ sortOrder: number;
660
+ parent?: string;
661
+ isSection?: boolean;
662
+ }
663
+ interface Page {
664
+ title: string;
665
+ }
666
+ interface AdminUiSdkRegistration {
667
+ registration: {
668
+ menuItems?: MenuItem[];
669
+ page?: Page;
670
+ };
671
+ }
672
+
673
+ declare class AdminUiSdk {
674
+ private extensionId;
675
+ private menuItems;
676
+ private pageTitle?;
677
+ constructor(extensionId: string);
678
+ private isValidExtensionId;
679
+ private isValidMenuId;
680
+ addMenuItem(id: string, title: string, sortOrder: number, parent?: string): void;
681
+ addMenuSection(id: string, title: string, sortOrder: number, parent?: string): void;
682
+ addPage(title: string): void;
683
+ getRegistration(): AdminUiSdkRegistration;
684
+ }
685
+
686
+ 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 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, type SuccessResponse, type TokenResult, Validator };