@adobe-commerce/aio-toolkit 1.0.7 → 1.0.9

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,194 @@ 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.9] - 2025-12-23
9
+
10
+ ### ⚠️ Deprecations
11
+
12
+ - **ImsToken** `[Deprecated]` - Class deprecated due to built-in caching mechanism issues
13
+ - Internal caching relies on Adobe I/O Runtime State API which has reliability issues
14
+ - State API may not be available in all runtime environments
15
+ - Hard-coded TTL buffers (10-minute) and minimum TTL (60-minute) are inflexible
16
+ - Limited control over caching strategy and error handling
17
+ - Complex testing requirements due to State API dependencies
18
+ - **Migration:** Use `AdobeAuth.getToken()` directly and implement application-level caching (Redis, Memcached, in-memory, etc.)
19
+ - **Token Validation:** Use `BearerToken.info()` for token validation and expiry checking
20
+ - All existing functionality remains working but shows deprecation warnings
21
+
22
+ ### 💥 Breaking Changes
23
+
24
+ - **RuntimeApiGatewayService** `[Breaking]` - Simplified to accept bearer tokens directly
25
+ - Constructor changed from 8 parameters (IMS credentials) to 4 parameters: `(namespace, imsOrgId, token, logger)`
26
+ - No longer generates tokens internally - accepts pre-generated token string
27
+ - `getAuthenticatedHeaders()` changed from async to synchronous method
28
+ - **Migration Example:**
29
+ ```typescript
30
+ // OLD - Built-in token generation (no longer supported)
31
+ const service = new RuntimeApiGatewayService(
32
+ clientId, clientSecret, techAccountId, techEmail,
33
+ imsOrgId, scopes, namespace, logger
34
+ );
35
+
36
+ // NEW - Accept token directly
37
+ const token = await AdobeAuth.getToken(
38
+ clientId, clientSecret, techAccountId,
39
+ techEmail, imsOrgId, scopes
40
+ );
41
+ const service = new RuntimeApiGatewayService(
42
+ namespace, imsOrgId, token, logger
43
+ );
44
+ ```
45
+
46
+ - **ImsConnection** `[Breaking]` - Simplified to accept bearer tokens directly
47
+ - Constructor changed from 7 parameters (IMS credentials) to 2 parameters: `(token, logger)`
48
+ - No longer generates tokens internally using deprecated `ImsToken` class
49
+ - Accepts pre-generated token string from `AdobeAuth`
50
+ - Token caching must be implemented at application level (Redis, Memcached, in-memory, etc.)
51
+ - **Migration Example:**
52
+ ```typescript
53
+ // OLD - Built-in token generation (no longer supported)
54
+ const connection = new ImsConnection(
55
+ clientId, clientSecret, techAccountId,
56
+ techEmail, imsOrgId, scopes, logger
57
+ );
58
+
59
+ // NEW - Accept token directly
60
+ const token = await AdobeAuth.getToken(
61
+ clientId, clientSecret, techAccountId,
62
+ techEmail, imsOrgId, scopes
63
+ );
64
+ const connection = new ImsConnection(token, logger);
65
+ ```
66
+
67
+ ### 🚀 Major New Features
68
+
69
+ #### 📊 OpenTelemetry Integration with New Relic Support
70
+
71
+ This release introduces comprehensive OpenTelemetry instrumentation for enterprise-grade observability, enabling distributed tracing, metrics collection, and structured logging with automatic request correlation.
72
+
73
+ - **Telemetry** `[New Feature]` - OpenTelemetry integration with multi-provider support
74
+ - Added `Telemetry` class for initializing OpenTelemetry instrumentation
75
+ - Integrated New Relic as the first telemetry provider with full OTLP support
76
+ - Multi-provider chain architecture with graceful fallback mechanism
77
+ - Automatic instrumentation for traces, metrics, and logs via OTLP exporters
78
+ - Configuration via environment variables for easy deployment
79
+ - Backwards compatible - telemetry is completely opt-in via feature flags
80
+ - Zero impact when disabled - no performance overhead for existing deployments
81
+
82
+ #### 🔍 Automatic Request ID Tracking
83
+
84
+ - **Logger Wrapper** `[New Feature]` - Automatic request correlation across all log messages
85
+ - Extracts `x-adobe-commerce-request-id` from webhook headers automatically
86
+ - Injects request ID into all log messages without manual intervention
87
+ - Enables distributed tracing and request correlation in New Relic
88
+ - Works seamlessly with `RuntimeAction`, `EventConsumerAction`, `WebhookAction`, and `OpenwhiskAction`
89
+ - Supports both object-based and string log messages
90
+ - Request ID automatically appears in New Relic log queries for filtering
91
+
92
+ #### 🏷️ Action Type Metadata
93
+
94
+ - **Action Classification** `[New Feature]` - Automatic action type identification in logs
95
+ - Adds `action.type` field to all log messages for better filtering
96
+ - Supported types: `runtime-action`, `webhook-action`, `event-consumer-action`, `openwhisk-action`
97
+ - Extracted from `params.action_type` with automatic fallbacks
98
+ - Enables filtering and grouping by action type in observability platforms
99
+ - Helps identify performance patterns and issues by action category
100
+
101
+ #### 🔄 Updated Action Classes with Telemetry Support
102
+
103
+ - **RuntimeAction** `[Enhanced]` - Full telemetry integration
104
+ - Structured logging for action lifecycle (start, parameters, completion, errors)
105
+ - Automatic request ID and action type injection
106
+ - OpenTelemetry span creation for distributed tracing
107
+ - Comprehensive error logging with stack traces
108
+ - JSDoc documentation for all telemetry features
109
+
110
+ - **EventConsumerAction** `[Enhanced]` - Telemetry support added
111
+ - Structured logging matching RuntimeAction patterns
112
+ - Automatic request ID tracking from event parameters
113
+ - OpenTelemetry instrumentation for event processing
114
+ - Action type always set to `event-consumer-action`
115
+
116
+ - **WebhookAction** `[Enhanced]` - Correct action type handling
117
+ - Sets action type to `webhook-action` via `RuntimeAction.setActionType()`
118
+ - Ensures proper action type appears in all log messages
119
+ - Maintains webhook-specific context in telemetry data
120
+
121
+ - **OpenwhiskAction** `[Enhanced]` - Complete telemetry integration
122
+ - Full structured logging implementation
123
+ - Automatic request ID and action type tracking
124
+ - OpenTelemetry instrumentation for OpenWhisk invocations
125
+ - Action type always set to `openwhisk-action`
126
+ - Comprehensive JSDoc documentation
127
+
128
+ ### 📦 Dependencies
129
+
130
+ - **Added** `@adobe/aio-lib-telemetry@^1.1.2` - Official Adobe OpenTelemetry library
131
+
132
+ ### 📊 Statistics
133
+
134
+ - **New Classes**: 5 (Telemetry, TelemetryInputError, SuccessChecker, ResourceFactory, JsonMessageProcessor)
135
+ - **New Files**: 14 source files, 9 test files
136
+ - **Test Coverage**: 100% maintained (1897 tests passing, +218 new tests)
137
+ - **Lines Added**: 7,172 insertions across 32 files
138
+ - **Dependencies**: +1 (`@adobe/aio-lib-telemetry`)
139
+
140
+ ### 🔮 Future Enhancements
141
+
142
+ - Additional telemetry provider support (Grafana, Datadog, etc.)
143
+ - Custom metric collection APIs
144
+ - Advanced trace sampling strategies
145
+ - Performance monitoring dashboards
146
+
147
+ ---
148
+
149
+ ## [1.0.8] - 2025-11-18
150
+
151
+ ### 🔒 Security Fixes
152
+
153
+ - **OnboardCommerce & OnboardEvents** `[Security]` - Removed sensitive payload logging (#94)
154
+ - Eliminated all sensitive data exposure in debug logs across onboarding components
155
+ - Modified `OnboardCommerce.subscribeToEvents()` to log only event names instead of full payloads
156
+ - Updated `ConfigureProvider` to log only provider/merchant IDs instead of complete configuration objects
157
+ - Changed `CreateRegistrations` to log only registration names instead of input payloads
158
+ - Modified `CreateProviders` to log only provider labels instead of full input data
159
+ - Prevents exposure of API keys, access tokens, client secrets, and merchant credentials
160
+ - Reduces security risks in console output, CI/CD logs, and debug sessions
161
+ - Maintains useful debugging context while protecting sensitive information
162
+ - 100% test coverage maintained
163
+
164
+ ### 🐛 Bug Fixes
165
+
166
+ - **FileRepository** `[Fixed]` - Preserve file timestamps in save() method (#93)
167
+ - Fixed `save()` method to preserve `createdAt` timestamp when updating existing files
168
+ - Removed unnecessary `filesLib.delete()` call that was resetting file creation timestamp
169
+ - Now relies on `filesLib.write()` to overwrite content while preserving file metadata
170
+ - Applies to both merge mode (default) and overwrite mode (`overwrite=true`)
171
+ - File system's native `createdAt` timestamp is now correctly maintained across updates
172
+ - Updated tests to verify `delete` is never called in either mode
173
+ - 100% test coverage maintained
174
+
175
+ ### ✨ Enhancements
176
+
177
+ - **GitHub Issue Templates** `[Enhanced]` - Updated with comprehensive component list (#95)
178
+ - Added 32+ components organized by category across all three issue templates
179
+ - New category headers: Commerce, Integration, Framework, I/O Events, Experience, Other
180
+ - Added missing components:
181
+ - Commerce: BasicAuthConnection, Oauth1aConnection, ImsConnection, GenerateBasicAuthToken, ShippingCarrierMethod, ShippingCarrierResponse
182
+ - Integration: CreateEvents, CreateRegistrations, OnboardCommerce
183
+ - Framework: RuntimeActionResponse, WebhookAction, WebhookActionResponse, ImsToken, RuntimeApiGatewayService, Parameters/Validator
184
+ - I/O Events: EventMetadataManager, ProviderManager, RegistrationManager
185
+ - Experience: AdminUiSdk
186
+ - Improved user experience with visual category separation in dropdowns
187
+ - Better issue triaging and component-level tracking for maintainers
188
+ - All templates (bug_report.yml, feature_request.yml, question.yml) updated consistently
189
+
190
+ ### 📊 Statistics
191
+
192
+ - **Total Components**: 32+ selectable options across 5 categories
193
+ - **Test Coverage**: 100% maintained (1679 tests passing)
194
+ - **Files Changed**: 7 files across 3 PRs
195
+
8
196
  ## [1.0.7] - 2025-11-12
9
197
 
10
198
  ### 🚀 PaaS Support for Adobe Commerce Event Subscriptions
package/README.md CHANGED
@@ -282,22 +282,137 @@ const helloWorldAction = OpenwhiskAction.execute('hello-world', async (params, c
282
282
  exports.main = helloWorldAction;
283
283
  ```
284
284
 
285
+ #### `Telemetry`
286
+ OpenTelemetry integration for enterprise-grade observability with distributed tracing, metrics collection, and structured logging.
287
+
288
+ **Features:**
289
+ - Automatic telemetry instrumentation for all framework action classes
290
+ - Request ID correlation across all log messages (`x-adobe-commerce-request-id`)
291
+ - Action type identification for better filtering (`action.type`)
292
+ - Multi-provider support (New Relic implemented, Grafana ready)
293
+ - Graceful fallback when telemetry is not configured
294
+ - Zero performance impact when disabled (opt-in via feature flags)
295
+
296
+ **Configuration:**
297
+
298
+ Configure telemetry in your `app.config.yaml`:
299
+
300
+ ```yaml
301
+ runtime-action:
302
+ function: actions/runtime-action/index.js
303
+ web: 'yes'
304
+ runtime: nodejs:22
305
+ inputs:
306
+ LOG_LEVEL: debug
307
+ ENVIRONMENT: $ENVIRONMENT
308
+ ENABLE_TELEMETRY: true
309
+ NEW_RELIC_TELEMETRY: true
310
+ NEW_RELIC_SERVICE_NAME: $NEW_RELIC_SERVICE_NAME
311
+ NEW_RELIC_LICENSE_KEY: $NEW_RELIC_LICENSE_KEY
312
+ annotations:
313
+ require-adobe-auth: true
314
+ final: true
315
+ ```
316
+
317
+ Set environment variables in your `.env` file:
318
+
319
+ ```bash
320
+ # Telemetry configuration
321
+ ENVIRONMENT=production
322
+ NEW_RELIC_SERVICE_NAME=my-app-builder-app
323
+ NEW_RELIC_LICENSE_KEY=your-license-key-here
324
+ NEW_RELIC_URL=https://otlp.nr-data.net:4318 # Optional
325
+ ```
326
+
327
+ **Usage Example:**
328
+
329
+ Telemetry is automatically initialized when you use framework action classes:
330
+
331
+ ```javascript
332
+ /*
333
+ * <license header>
334
+ */
335
+
336
+ const { RuntimeAction, RuntimeActionResponse, HttpMethod } = require("@adobe-commerce/aio-toolkit");
337
+ const name = 'runtime-action';
338
+
339
+ exports.main = RuntimeAction.execute(
340
+ name,
341
+ [HttpMethod.POST],
342
+ [],
343
+ ['Authorization'],
344
+ async (params, ctx) => {
345
+ const { logger } = ctx;
346
+
347
+ // Logger automatically includes x-adobe-commerce-request-id and action.type
348
+ logger.info({
349
+ message: `${name}-log`,
350
+ params: JSON.stringify(params),
351
+ });
352
+
353
+ return RuntimeActionResponse.success("Hello World");
354
+ }
355
+ );
356
+ ```
357
+
358
+ **What Gets Logged Automatically:**
359
+
360
+ All log messages automatically include:
361
+ - `x-adobe-commerce-request-id` - Extracted from webhook headers for request correlation
362
+ - `action.type` - Identifies the action type (runtime-action, webhook-action, event-consumer-action, openwhisk-action)
363
+ - Action lifecycle events (start, parameters, completion, errors)
364
+ - Full stack traces for errors
365
+
366
+ **Viewing in New Relic:**
367
+
368
+ Once configured, you can query your logs in New Relic using these attributes:
369
+
370
+ ```sql
371
+ -- Filter by request ID
372
+ SELECT * FROM Log WHERE `x-adobe-commerce-request-id` = 'request-123'
373
+
374
+ -- Filter by action type
375
+ SELECT * FROM Log WHERE `action.type` = 'webhook-action'
376
+
377
+ -- Find errors for a specific request
378
+ SELECT * FROM Log WHERE `x-adobe-commerce-request-id` = 'request-123' AND level = 'error'
379
+
380
+ -- Group by action type
381
+ SELECT count(*) FROM Log FACET `action.type` SINCE 1 hour ago
382
+ ```
383
+
384
+ **Supported Action Classes:**
385
+
386
+ Telemetry is automatically integrated with all framework action classes:
387
+ - `RuntimeAction` - HTTP request handling with telemetry
388
+ - `WebhookAction` - Webhook processing with telemetry
389
+ - `EventConsumerAction` - Event-driven processing with telemetry
390
+ - `OpenwhiskAction` - OpenWhisk action handling with telemetry
391
+
392
+ All action classes provide structured logging with automatic request ID and action type tracking.
393
+
285
394
  #### `RuntimeApiGatewayService`
286
- Flexible Adobe I/O Runtime API Gateway client with automatic IMS token management and authentication.
395
+ Flexible Adobe I/O Runtime API Gateway client that accepts bearer tokens for authenticated requests.
287
396
 
288
397
  ```typescript
289
- const { RuntimeApiGatewayService } = require('@adobe-commerce/aio-toolkit');
398
+ const { RuntimeApiGatewayService, AdobeAuth } = require('@adobe-commerce/aio-toolkit');
290
399
 
291
- // Initialize the service
292
- const apiGatewayService = new RuntimeApiGatewayService(
400
+ // Step 1: Generate token using AdobeAuth (implement caching in your application)
401
+ const token = await AdobeAuth.getToken(
293
402
  'your-client-id',
294
403
  'your-client-secret',
295
404
  'your-technical-account-id',
296
405
  'your-technical-account-email@example.com',
297
406
  'your-ims-org-id@AdobeOrg',
298
- ['openid', 'AdobeID', 'adobeio_api'],
299
- 'your-namespace-12345',
300
- logger // Optional custom logger
407
+ ['openid', 'AdobeID', 'adobeio_api']
408
+ );
409
+
410
+ // Step 2: Initialize the service with the token
411
+ const apiGatewayService = new RuntimeApiGatewayService(
412
+ 'your-namespace-12345', // Runtime namespace
413
+ 'your-ims-org-id@AdobeOrg', // IMS Org ID
414
+ token, // Bearer token
415
+ logger // Optional custom logger
301
416
  );
302
417
 
303
418
  // GET request
@@ -321,14 +436,15 @@ const deleteResult = await apiGatewayService.delete('v1/web/my-package/remove/12
321
436
  ```
322
437
 
323
438
  **Key Features:**
324
- - Automatic IMS token generation and caching
325
439
  - Built-in authentication headers
326
440
  - Support for GET, POST, PUT, DELETE methods
327
441
  - Flexible endpoint configuration
328
442
  - Comprehensive error handling
329
- - Integration with ImsToken for token management
443
+ - Accepts pre-generated bearer tokens (implement your own caching strategy)
330
444
  - CustomLogger integration
331
445
 
446
+ **💡 Best Practice:** Implement token caching at the application level (Redis, Memcached, in-memory) and validate tokens with `BearerToken.info()` before use to avoid unnecessary token generation calls.
447
+
332
448
  #### `FileRepository`
333
449
  File-based storage with CRUD operations for Adobe I/O Runtime applications.
334
450
 
@@ -579,40 +695,109 @@ const newProduct = await client.post('V1/products', {}, productData);
579
695
 
580
696
  **IMS (Identity Management System) Authentication**
581
697
  ```typescript
582
- const { AdobeCommerceClient, ImsConnection } = require('@adobe-commerce/aio-toolkit');
698
+ const { AdobeCommerceClient, ImsConnection, AdobeAuth, BearerToken } = require('@adobe-commerce/aio-toolkit');
699
+
700
+ // Step 1: Generate token using AdobeAuth (implement caching in your application)
701
+ // Check your application cache first
702
+ let token = await yourAppCache.get('commerce_ims_token');
703
+
704
+ if (!token || !BearerToken.info(token).isValid) {
705
+ // Generate new token
706
+ token = await AdobeAuth.getToken(
707
+ 'client-id',
708
+ 'client-secret',
709
+ 'technical-account-id',
710
+ 'technical-account-email',
711
+ 'ims-org-id@AdobeOrg',
712
+ ['AdobeID', 'openid', 'adobeio_api']
713
+ );
714
+
715
+ // Store in your application cache with appropriate TTL
716
+ const tokenInfo = BearerToken.info(token);
717
+ if (tokenInfo.isValid && tokenInfo.timeUntilExpiry) {
718
+ const ttl = Math.floor(tokenInfo.timeUntilExpiry / 1000) - 600; // 10-min buffer
719
+ await yourAppCache.set('commerce_ims_token', token, ttl);
720
+ }
721
+ }
583
722
 
584
- const connection = new ImsConnection(
585
- 'client-id',
586
- 'client-secret',
587
- 'technical-account-id',
588
- 'technical-account-email',
589
- 'ims-org-id',
590
- ['AdobeID', 'openid', 'adobeio_api'], // Scopes array
591
- logger // Optional custom logger
592
- );
723
+ // Step 2: Create connection with token
724
+ const connection = new ImsConnection(token, logger); // Optional logger
593
725
 
594
- // Create client with IMS authentication
726
+ // Step 3: Create client with IMS authentication
595
727
  const client = new AdobeCommerceClient('https://your-commerce-store.com', connection);
596
728
 
597
- // Make API calls - tokens are automatically cached and refreshed
729
+ // Make API calls
598
730
  const products = await client.get('V1/products');
599
731
  const newProduct = await client.post('V1/products', {}, productData);
600
732
  ```
601
733
 
602
- **Enhanced IMS Token Caching**
734
+ > **💡 Best Practice:** Implement token caching at the application level (Redis, Memcached, in-memory) to avoid unnecessary token generation calls.
735
+
736
+ **⚠️ DEPRECATED: ImsToken Class**
737
+
738
+ > **This class is deprecated due to built-in caching mechanism issues:**
739
+ > - Relies on Adobe I/O Runtime State API which has reliability issues
740
+ > - State API may not be available in all runtime environments
741
+ > - Hard-coded TTL buffers and minimum TTL are inflexible
742
+ > - Limited control over caching strategy
743
+ >
744
+ > **Migration Required:** Use `AdobeAuth` directly and implement caching at the application level.
603
745
 
604
746
  ```typescript
605
- const { GenerateImsToken } = require('@adobe-commerce/aio-toolkit');
747
+ // OLD (Deprecated) - ImsToken with built-in caching
748
+ const { ImsToken } = require('@adobe-commerce/aio-toolkit');
606
749
 
607
- const tokenGenerator = new GenerateImsToken(
608
- 'client-id', 'client-secret', 'technical-account-id',
609
- 'technical-account-email', 'ims-org-id',
610
- ['AdobeID', 'openid', 'adobeio_api'], logger
750
+ const imsToken = new ImsToken(
751
+ 'client-id',
752
+ 'client-secret',
753
+ 'technical-account-id',
754
+ 'technical-account-email',
755
+ 'ims-org-id@AdobeOrg',
756
+ ['AdobeID', 'openid', 'adobeio_api'],
757
+ logger // optional
611
758
  );
612
759
 
613
- const token = await tokenGenerator.execute();
760
+ const token = await imsToken.execute();
614
761
  ```
615
762
 
763
+ ```typescript
764
+ // ✅ NEW (Recommended) - AdobeAuth with application-level caching
765
+ const { AdobeAuth, BearerToken } = require('@adobe-commerce/aio-toolkit');
766
+
767
+ // Check your application cache first (Redis, Memcached, in-memory, etc.)
768
+ let token = await yourAppCache.get('ims_token');
769
+
770
+ // Validate cached token
771
+ if (!token || !BearerToken.info(token).isValid) {
772
+ // Generate new token using AdobeAuth
773
+ token = await AdobeAuth.getToken(
774
+ 'client-id',
775
+ 'client-secret',
776
+ 'technical-account-id',
777
+ 'technical-account-email',
778
+ 'ims-org-id@AdobeOrg',
779
+ ['AdobeID', 'openid', 'adobeio_api']
780
+ );
781
+
782
+ // Store in your application cache with appropriate TTL
783
+ const tokenInfo = BearerToken.info(token);
784
+ if (tokenInfo.isValid && tokenInfo.timeUntilExpiry) {
785
+ const ttl = Math.floor(tokenInfo.timeUntilExpiry / 1000) - 600; // 10-min buffer
786
+ await yourAppCache.set('ims_token', token, ttl);
787
+ }
788
+ }
789
+
790
+ // Use the token
791
+ console.log('Token:', token);
792
+ ```
793
+
794
+ **Why Migrate?**
795
+ - ✅ Full control over caching strategy (Redis, Memcached, in-memory, etc.)
796
+ - ✅ Better error handling and retry logic
797
+ - ✅ Works in any environment (not just Adobe I/O Runtime)
798
+ - ✅ Easier to test and mock
799
+ - ✅ Flexible TTL management based on your needs
800
+
616
801
  **Basic Authentication**
617
802
  ```typescript
618
803
  const { AdobeCommerceClient, BasicAuthConnection } = require('@adobe-commerce/aio-toolkit');
@@ -727,16 +912,18 @@ const {
727
912
  } = require('@adobe-commerce/aio-toolkit');
728
913
  const Core = require('@adobe/aio-sdk').Core;
729
914
 
730
- // Initialize Adobe Commerce client
731
- const connection = new ImsConnection(
915
+ // Generate token using AdobeAuth (implement caching in your application)
916
+ const token = await AdobeAuth.getToken(
732
917
  'client-id',
733
918
  'client-secret',
734
919
  'technical-account-id',
735
920
  'technical-account-email',
736
- 'ims-org-id',
737
- ['AdobeID', 'openid', 'adobeio_api'],
738
- logger
921
+ 'ims-org-id@AdobeOrg',
922
+ ['AdobeID', 'openid', 'adobeio_api']
739
923
  );
924
+
925
+ // Initialize Adobe Commerce client
926
+ const connection = new ImsConnection(token, logger);
740
927
  const adobeCommerceClient = new AdobeCommerceClient(
741
928
  'https://your-commerce-store.com',
742
929
  connection
package/dist/index.d.mts CHANGED
@@ -1,4 +1,7 @@
1
1
  import openwhisk, { Dict, Activation } from 'openwhisk';
2
+ import { EntrypointInstrumentationConfig } from '@adobe/aio-lib-telemetry';
3
+ import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
4
+ import { SdkLogRecord } from '@adobe/aio-lib-telemetry/otel';
2
5
  import { Response } from 'node-fetch';
3
6
  import { Logger } from '@adobe/aio-sdk';
4
7
  import { Got, RequestError } from 'got';
@@ -39,6 +42,9 @@ interface ErrorResponse {
39
42
  type RuntimeActionResponseType = SuccessResponse | ErrorResponse;
40
43
 
41
44
  declare class RuntimeAction {
45
+ private static actionType;
46
+ static setActionType(type: string): void;
47
+ static getActionType(): string;
42
48
  static execute(name?: string, httpMethods?: HttpMethod[], requiredParams?: string[], requiredHeaders?: string[], action?: (params: {
43
49
  [key: string]: any;
44
50
  }, ctx: {
@@ -262,7 +268,7 @@ declare class RuntimeApiGatewayService {
262
268
  private readonly imsToken;
263
269
  private readonly restClient;
264
270
  private readonly customLogger;
265
- constructor(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: Array<string>, namespace: string, logger?: any);
271
+ constructor(namespace: string, imsOrgId: string, imsToken: string, logger?: any);
266
272
  private buildEndpoint;
267
273
  private getAuthenticatedHeaders;
268
274
  get(endpoint: string, additionalHeaders?: Record<string, string>): Promise<any>;
@@ -271,6 +277,41 @@ declare class RuntimeApiGatewayService {
271
277
  delete(endpoint: string, additionalHeaders?: Record<string, string>): Promise<any>;
272
278
  }
273
279
 
280
+ interface BaseTelemetryValidator {
281
+ isConfigured(params: Record<string, unknown>): boolean;
282
+ validateConfiguration(params: Record<string, unknown>): void;
283
+ }
284
+ interface BaseTelemetry {
285
+ canInitialize(params: Record<string, unknown>): boolean;
286
+ getConfig(): EntrypointInstrumentationConfig;
287
+ initialize(action: (params: Record<string, unknown>) => any): (params: Record<string, unknown>) => any;
288
+ }
289
+
290
+ declare class Telemetry {
291
+ static createLogger(name: string, params: Record<string, unknown>): any;
292
+ static formatError(error: unknown): Record<string, unknown>;
293
+ static initialize(action: (params: Record<string, unknown>) => any): (params: Record<string, unknown>) => any;
294
+ }
295
+
296
+ declare class TelemetryInputError extends Error {
297
+ constructor(message: string);
298
+ }
299
+
300
+ declare class SuccessChecker {
301
+ execute(result: unknown): boolean;
302
+ }
303
+
304
+ declare class JsonMessageProcessor implements LogRecordProcessor {
305
+ private readonly wrappedProcessor;
306
+ constructor(wrappedProcessor: LogRecordProcessor);
307
+ private parseJavaScriptObjectNotation;
308
+ private flattenObject;
309
+ onEmit(logRecord: SdkLogRecord): void;
310
+ private mapSeverityNumberToLevel;
311
+ forceFlush(): Promise<void>;
312
+ shutdown(): Promise<void>;
313
+ }
314
+
274
315
  interface BearerTokenInfo {
275
316
  token: string | null;
276
317
  tokenLength: number;
@@ -644,14 +685,9 @@ declare class Oauth1aConnection implements Connection {
644
685
  }
645
686
 
646
687
  declare class ImsConnection implements Connection {
647
- private clientId;
648
- private clientSecret;
649
- private technicalAccountId;
650
- private technicalAccountEmail;
651
- private imsOrgId;
652
- private scopes;
653
- private customLogger;
654
- constructor(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: Array<string>, logger?: any);
688
+ private readonly imsToken;
689
+ private readonly customLogger;
690
+ constructor(imsToken: string, logger?: any);
655
691
  extend(commerceGot: any): Promise<any>;
656
692
  }
657
693
 
@@ -919,4 +955,4 @@ declare class AdminUiSdk {
919
955
  getRegistration(): AdminUiSdkRegistration;
920
956
  }
921
957
 
922
- 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 };
958
+ export { AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, type BaseTelemetry, type BaseTelemetryValidator, 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, JsonMessageProcessor, 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, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };