@adobe-commerce/aio-toolkit 1.0.3 → 1.0.4
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 +65 -0
- package/README.md +207 -4
- package/dist/index.d.mts +134 -2
- package/dist/index.d.ts +134 -2
- package/dist/index.js +728 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +718 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,71 @@ 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.4] - 2025-10-29
|
|
9
|
+
|
|
10
|
+
### 🚀 Major Feature Release: Webhook Components & Shipping Carrier Builder
|
|
11
|
+
|
|
12
|
+
This minor release introduces powerful new components for Adobe Commerce webhook extensibility, including a comprehensive ShippingCarrier builder and WebhookAction component with signature verification. These additions enable developers to easily create custom shipping carriers and handle webhook requests securely.
|
|
13
|
+
|
|
14
|
+
#### 🎯 Commerce Components
|
|
15
|
+
|
|
16
|
+
- **ShippingCarrier** `[New]` - Fluent builder for custom shipping carrier creation
|
|
17
|
+
- Builder pattern implementation with method chaining support
|
|
18
|
+
- Comprehensive carrier configuration (title, stores, countries, sort order, active status)
|
|
19
|
+
- Shipping method management with add/remove capabilities
|
|
20
|
+
- Validation for carrier and method codes (alphanumeric and underscores only)
|
|
21
|
+
- Integration with WebhookActionResponse for seamless webhook responses
|
|
22
|
+
- Type-safe TypeScript interfaces for all data structures
|
|
23
|
+
- 100% test coverage with 67 comprehensive tests
|
|
24
|
+
|
|
25
|
+
- **ShippingCarrierMethod** `[New]` - Builder for individual shipping methods
|
|
26
|
+
- Configure method title, price, cost, and additional data
|
|
27
|
+
- Flexible additional data structure for custom metadata
|
|
28
|
+
- Returns structured method data via `getData()`
|
|
29
|
+
- Full TypeScript support with `ShippingCarrierMethodData` interface
|
|
30
|
+
|
|
31
|
+
- **ShippingCarrierResponse** `[New]` - Webhook response generator
|
|
32
|
+
- Generates WebhookActionResponse operations from ShippingCarrier instances
|
|
33
|
+
- Handles both added and removed shipping methods
|
|
34
|
+
- Creates proper operation structures for Adobe Commerce webhook extensibility
|
|
35
|
+
|
|
36
|
+
#### 🔧 Framework Components
|
|
37
|
+
|
|
38
|
+
- **WebhookAction** `[New]` - Secure webhook request handler with signature verification
|
|
39
|
+
- Built-in Adobe Commerce webhook signature verification
|
|
40
|
+
- Configurable signature verification (enabled/disabled)
|
|
41
|
+
- Wrapper around RuntimeAction for consistent request handling
|
|
42
|
+
- Support for required parameters and headers validation
|
|
43
|
+
- Integration with WebhookActionResponse for structured responses
|
|
44
|
+
- Comprehensive error handling and logging
|
|
45
|
+
|
|
46
|
+
- **WebhookActionResponse** `[New]` - Structured webhook response builder
|
|
47
|
+
- Success, exception, add, replace, and remove operations
|
|
48
|
+
- Type-safe response structures with TypeScript interfaces
|
|
49
|
+
- Compatible with Adobe Commerce webhook extensibility model
|
|
50
|
+
- Clean API for building complex webhook responses
|
|
51
|
+
|
|
52
|
+
#### 🛠️ Repository Components
|
|
53
|
+
|
|
54
|
+
- **FileRepository** `[Enhanced]` - File system timestamp integration
|
|
55
|
+
- Use file system properties for `createdAt` and `updatedAt` timestamps
|
|
56
|
+
- Retrieve timestamps using `files.getProperties()` method
|
|
57
|
+
- Timestamps reflect actual file system state
|
|
58
|
+
- Removed timestamps from file content for cleaner data storage
|
|
59
|
+
- Enhanced `metadata()` method for lightweight file listing without content
|
|
60
|
+
|
|
61
|
+
- **FileRepository** `[Enhanced]` - Metadata method for efficient file listing
|
|
62
|
+
- New `metadata()` method for retrieving file properties without reading content
|
|
63
|
+
- Significantly faster than `list()` for large file sets
|
|
64
|
+
- Returns file size, creation time, and modification time
|
|
65
|
+
- Supports both single file and batch metadata retrieval
|
|
66
|
+
|
|
67
|
+
- **FileRepository** `[Enhanced]` - Overwrite flag for controlled file writes
|
|
68
|
+
- New `overwrite` parameter in `save()` method
|
|
69
|
+
- Default behavior: merge with existing file (overwrite: false)
|
|
70
|
+
- Explicit overwrite: replace entire file (overwrite: true)
|
|
71
|
+
- Enhanced control over file update strategies
|
|
72
|
+
|
|
8
73
|
## [1.0.3] - 2025-10-23
|
|
9
74
|
|
|
10
75
|
### 🎨 New Experience Module & Enhanced Framework Components
|
package/README.md
CHANGED
|
@@ -91,6 +91,63 @@ const myEventConsumer = EventConsumerAction.execute(
|
|
|
91
91
|
exports.main = myEventConsumer;
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
+
#### `WebhookAction`
|
|
95
|
+
Secure webhook request handler with built-in Adobe Commerce signature verification.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const {
|
|
99
|
+
WebhookAction,
|
|
100
|
+
WebhookActionResponse,
|
|
101
|
+
SignatureVerification
|
|
102
|
+
} = require('@adobe-commerce/aio-toolkit');
|
|
103
|
+
|
|
104
|
+
// Create a webhook action with signature verification enabled
|
|
105
|
+
const myWebhook = WebhookAction.execute(
|
|
106
|
+
'order-webhook',
|
|
107
|
+
['orderId'], // Required parameters
|
|
108
|
+
['x-adobe-commerce-webhook-id'], // Required headers
|
|
109
|
+
SignatureVerification.ENABLED, // Enable signature verification
|
|
110
|
+
async (params, ctx) => {
|
|
111
|
+
const { orderId } = params;
|
|
112
|
+
const { logger } = ctx;
|
|
113
|
+
|
|
114
|
+
logger.info(`Processing order webhook: ${orderId}`);
|
|
115
|
+
|
|
116
|
+
// Your webhook logic here
|
|
117
|
+
// Return structured webhook response
|
|
118
|
+
return [
|
|
119
|
+
WebhookActionResponse.add('result', {
|
|
120
|
+
orderId: orderId,
|
|
121
|
+
status: 'processed',
|
|
122
|
+
timestamp: new Date().toISOString()
|
|
123
|
+
}),
|
|
124
|
+
WebhookActionResponse.success()
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// Export for Adobe I/O Runtime
|
|
130
|
+
exports.main = myWebhook;
|
|
131
|
+
|
|
132
|
+
// Disable signature verification for testing
|
|
133
|
+
const testWebhook = WebhookAction.execute(
|
|
134
|
+
'test-webhook',
|
|
135
|
+
['data'],
|
|
136
|
+
[],
|
|
137
|
+
SignatureVerification.DISABLED,
|
|
138
|
+
async (params, ctx) => {
|
|
139
|
+
return WebhookActionResponse.success();
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**WebhookActionResponse Operations:**
|
|
145
|
+
- `success()`: Indicates successful webhook processing
|
|
146
|
+
- `exception(message?, exceptionClass?)`: Returns error response
|
|
147
|
+
- `add(path, value, instance?)`: Adds data to response
|
|
148
|
+
- `replace(path, value, instance?)`: Replaces data in response
|
|
149
|
+
- `remove(path)`: Removes data from response
|
|
150
|
+
|
|
94
151
|
#### `PublishEvent`
|
|
95
152
|
Event publishing component for Adobe I/O Events with CloudEvents support.
|
|
96
153
|
|
|
@@ -229,11 +286,17 @@ exports.main = helloWorldAction;
|
|
|
229
286
|
File-based storage with CRUD operations for Adobe I/O Runtime applications.
|
|
230
287
|
|
|
231
288
|
**Key Methods:**
|
|
232
|
-
- `save(payload, id?)`: Saves data with optional ID parameter. The `id` parameter takes precedence over `payload.id`. IDs are automatically sanitized to alphanumeric + underscore characters.
|
|
233
|
-
- `load(id)`: Loads data by ID
|
|
234
|
-
- `list()`: Lists all stored records
|
|
289
|
+
- `save(payload, id?, overwrite?)`: Saves data with optional ID parameter and overwrite flag. The `id` parameter takes precedence over `payload.id`. IDs are automatically sanitized to alphanumeric + underscore characters. Set `overwrite: true` to replace entire file, or `false` (default) to merge with existing data.
|
|
290
|
+
- `load(id)`: Loads data by ID with file system timestamps (`createdAt`, `updatedAt`)
|
|
291
|
+
- `list()`: Lists all stored records with file system timestamps
|
|
292
|
+
- `metadata(id?)`: Retrieves file metadata (size, timestamps) without reading content - faster than `list()` for large datasets
|
|
235
293
|
- `delete(ids)`: Deletes records by ID array
|
|
236
294
|
|
|
295
|
+
**New in v1.0.4:**
|
|
296
|
+
- **File System Timestamps**: `createdAt` and `updatedAt` are now retrieved from actual file system properties instead of being stored in file content
|
|
297
|
+
- **Metadata Method**: New `metadata()` method for efficient file property retrieval without reading file content
|
|
298
|
+
- **Overwrite Flag**: Control file update strategy with `save(payload, id, overwrite)` - merge (default) or replace entire file
|
|
299
|
+
|
|
237
300
|
**Best Practice:** Create custom repository classes that extend FileRepository for specific entities.
|
|
238
301
|
|
|
239
302
|
##### **1. Define Entity Repository**
|
|
@@ -332,7 +395,69 @@ exports.main = RuntimeAction.execute(
|
|
|
332
395
|
);
|
|
333
396
|
```
|
|
334
397
|
|
|
335
|
-
##### **5.
|
|
398
|
+
##### **5. Save with Overwrite Flag**
|
|
399
|
+
Control file update strategy with the overwrite parameter:
|
|
400
|
+
|
|
401
|
+
```javascript
|
|
402
|
+
const { HttpMethod, RuntimeAction, RuntimeActionResponse } = require("@adobe-commerce/aio-toolkit");
|
|
403
|
+
const EntityRepository = require("@lib/EntityRepository");
|
|
404
|
+
|
|
405
|
+
exports.main = RuntimeAction.execute(
|
|
406
|
+
"entity-save-overwrite",
|
|
407
|
+
[HttpMethod.POST],
|
|
408
|
+
['name', 'status'],
|
|
409
|
+
['Authorization'],
|
|
410
|
+
async (params) => {
|
|
411
|
+
const entityRepository = new EntityRepository();
|
|
412
|
+
|
|
413
|
+
const payload = {
|
|
414
|
+
name: params.name,
|
|
415
|
+
status: params.status
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
// Replace entire file instead of merging
|
|
419
|
+
const savedId = await entityRepository.save(payload, params.id, true);
|
|
420
|
+
|
|
421
|
+
return RuntimeActionResponse.success({
|
|
422
|
+
id: savedId,
|
|
423
|
+
message: 'Entity replaced successfully'
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
);
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
##### **6. Metadata Action**
|
|
430
|
+
Retrieve file metadata without reading content (faster for large datasets):
|
|
431
|
+
|
|
432
|
+
```javascript
|
|
433
|
+
const { HttpMethod, RuntimeAction, RuntimeActionResponse } = require("@adobe-commerce/aio-toolkit");
|
|
434
|
+
const EntityRepository = require("@lib/EntityRepository");
|
|
435
|
+
|
|
436
|
+
exports.main = RuntimeAction.execute(
|
|
437
|
+
"entity-metadata",
|
|
438
|
+
[HttpMethod.POST],
|
|
439
|
+
[],
|
|
440
|
+
['Authorization'],
|
|
441
|
+
async (params) => {
|
|
442
|
+
const entityRepository = new EntityRepository();
|
|
443
|
+
|
|
444
|
+
// Get metadata for all files
|
|
445
|
+
const allMetadata = await entityRepository.metadata();
|
|
446
|
+
|
|
447
|
+
// Or get metadata for specific file
|
|
448
|
+
const singleMetadata = params.id
|
|
449
|
+
? await entityRepository.metadata(params.id)
|
|
450
|
+
: null;
|
|
451
|
+
|
|
452
|
+
return RuntimeActionResponse.success({
|
|
453
|
+
all: allMetadata,
|
|
454
|
+
single: singleMetadata
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
##### **7. Delete Action**
|
|
336
461
|
Delete entities by providing an array of IDs:
|
|
337
462
|
|
|
338
463
|
```javascript
|
|
@@ -458,6 +583,84 @@ const client = new AdobeCommerceClient('https://your-commerce-store.com/rest', c
|
|
|
458
583
|
const products = await client.get('V1/products');
|
|
459
584
|
```
|
|
460
585
|
|
|
586
|
+
#### `ShippingCarrier`
|
|
587
|
+
Fluent builder for creating custom shipping carriers for Adobe Commerce webhook extensibility.
|
|
588
|
+
|
|
589
|
+
```typescript
|
|
590
|
+
const {
|
|
591
|
+
ShippingCarrier,
|
|
592
|
+
ShippingCarrierResponse
|
|
593
|
+
} = require('@adobe-commerce/aio-toolkit');
|
|
594
|
+
|
|
595
|
+
// Create a custom shipping carrier with methods
|
|
596
|
+
const carrier = new ShippingCarrier('fedex', (carrier) => {
|
|
597
|
+
carrier
|
|
598
|
+
.setTitle('FedEx Express')
|
|
599
|
+
.setStores(['default', 'store1'])
|
|
600
|
+
.setCountries(['US', 'CA', 'MX'])
|
|
601
|
+
.setSortOrder(10)
|
|
602
|
+
.setActive(true)
|
|
603
|
+
.setTrackingAvailable(true)
|
|
604
|
+
.setShippingLabelsAvailable(true)
|
|
605
|
+
.addMethod('standard', (method) => {
|
|
606
|
+
method
|
|
607
|
+
.setMethodTitle('Standard Shipping')
|
|
608
|
+
.setPrice(9.99)
|
|
609
|
+
.setCost(5.00)
|
|
610
|
+
.addAdditionalData('delivery_time', '3-5 business days')
|
|
611
|
+
.addAdditionalData('tracking_available', true);
|
|
612
|
+
})
|
|
613
|
+
.addMethod('express', (method) => {
|
|
614
|
+
method
|
|
615
|
+
.setMethodTitle('Express Shipping')
|
|
616
|
+
.setPrice(19.99)
|
|
617
|
+
.setCost(12.00)
|
|
618
|
+
.addAdditionalData('delivery_time', '1-2 business days');
|
|
619
|
+
})
|
|
620
|
+
.removeMethod('overnight'); // Remove a method
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
// Get carrier configuration
|
|
624
|
+
const carrierData = carrier.getData();
|
|
625
|
+
console.log(carrierData);
|
|
626
|
+
|
|
627
|
+
// Generate webhook response operations
|
|
628
|
+
const response = new ShippingCarrierResponse(carrier);
|
|
629
|
+
const operations = response.generate();
|
|
630
|
+
return operations; // Use in webhook action
|
|
631
|
+
|
|
632
|
+
carrier.setData({
|
|
633
|
+
code: 'dps',
|
|
634
|
+
title: 'Demo Postal Service',
|
|
635
|
+
stores: ['default'],
|
|
636
|
+
countries: ['US', 'CA'],
|
|
637
|
+
sort_order: 10,
|
|
638
|
+
active: true,
|
|
639
|
+
tracking_available: true,
|
|
640
|
+
shipping_labels_available: true
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
// Reset carrier with new code
|
|
644
|
+
carrier.reset('ups', (c) => {
|
|
645
|
+
c.addMethod('ground', (m) => {
|
|
646
|
+
m.setMethodTitle('UPS Ground').setPrice(12.99);
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
**Key Features:**
|
|
652
|
+
- Builder pattern with method chaining
|
|
653
|
+
- Validation for carrier and method codes (alphanumeric and underscores only)
|
|
654
|
+
- Add and remove shipping methods dynamically
|
|
655
|
+
- Configure carrier properties (title, stores, countries, sort order, etc.)
|
|
656
|
+
- Generate webhook response operations
|
|
657
|
+
- Type-safe TypeScript interfaces
|
|
658
|
+
|
|
659
|
+
**Validation Rules:**
|
|
660
|
+
- Carrier and method codes must contain only alphanumeric characters and underscores
|
|
661
|
+
- No spaces, hyphens, dots, or special characters allowed
|
|
662
|
+
- Empty or whitespace-only codes throw errors
|
|
663
|
+
|
|
461
664
|
### 🎨 Experience Components
|
|
462
665
|
|
|
463
666
|
**Adobe Commerce Admin UI extension and user experience tools**
|
package/dist/index.d.mts
CHANGED
|
@@ -126,14 +126,26 @@ interface FileRecord {
|
|
|
126
126
|
updatedAt: string;
|
|
127
127
|
[key: string]: any;
|
|
128
128
|
}
|
|
129
|
+
interface FileMetadata {
|
|
130
|
+
name: string;
|
|
131
|
+
creationTime: Date;
|
|
132
|
+
lastModified: Date;
|
|
133
|
+
etag: string;
|
|
134
|
+
contentLength: number;
|
|
135
|
+
contentType: string;
|
|
136
|
+
isDirectory: boolean;
|
|
137
|
+
isPublic: boolean;
|
|
138
|
+
url: string;
|
|
139
|
+
}
|
|
129
140
|
|
|
130
141
|
declare class FileRepository {
|
|
131
142
|
private readonly filepath;
|
|
132
143
|
private files;
|
|
133
144
|
constructor(filepath: string);
|
|
134
145
|
list(): Promise<FileRecord[]>;
|
|
146
|
+
metadata(id?: string): Promise<FileMetadata | FileMetadata[]>;
|
|
135
147
|
load(id?: string): Promise<FileRecord>;
|
|
136
|
-
save(payload?: Partial<FileRecord>, id?: string | null): Promise<string | null>;
|
|
148
|
+
save(payload?: Partial<FileRecord>, id?: string | null, overwrite?: boolean): Promise<string | null>;
|
|
137
149
|
delete(ids?: string[]): Promise<FileRecord[]>;
|
|
138
150
|
private sanitizeFileId;
|
|
139
151
|
private getFiles;
|
|
@@ -160,6 +172,65 @@ declare class PublishEvent {
|
|
|
160
172
|
execute(providerId: string, eventCode: string, payload: any, subject?: string): Promise<PublishEventResult>;
|
|
161
173
|
}
|
|
162
174
|
|
|
175
|
+
declare enum WebhookActionOperation {
|
|
176
|
+
SUCCESS = "success",
|
|
177
|
+
EXCEPTION = "exception",
|
|
178
|
+
ADD = "add",
|
|
179
|
+
REPLACE = "replace",
|
|
180
|
+
REMOVE = "remove"
|
|
181
|
+
}
|
|
182
|
+
interface WebhookActionSuccessResponse {
|
|
183
|
+
op: typeof WebhookActionOperation.SUCCESS;
|
|
184
|
+
}
|
|
185
|
+
interface WebhookActionExceptionResponse {
|
|
186
|
+
op: typeof WebhookActionOperation.EXCEPTION;
|
|
187
|
+
class?: string;
|
|
188
|
+
message?: string;
|
|
189
|
+
}
|
|
190
|
+
interface WebhookActionAddResponse {
|
|
191
|
+
op: typeof WebhookActionOperation.ADD;
|
|
192
|
+
path: string;
|
|
193
|
+
value: any;
|
|
194
|
+
instance?: string;
|
|
195
|
+
}
|
|
196
|
+
interface WebhookActionReplaceResponse {
|
|
197
|
+
op: typeof WebhookActionOperation.REPLACE;
|
|
198
|
+
path: string;
|
|
199
|
+
value: any;
|
|
200
|
+
instance?: string;
|
|
201
|
+
}
|
|
202
|
+
interface WebhookActionRemoveResponse {
|
|
203
|
+
op: typeof WebhookActionOperation.REMOVE;
|
|
204
|
+
path: string;
|
|
205
|
+
}
|
|
206
|
+
type WebhookActionResponseType = WebhookActionSuccessResponse | WebhookActionExceptionResponse | WebhookActionAddResponse | WebhookActionReplaceResponse | WebhookActionRemoveResponse;
|
|
207
|
+
|
|
208
|
+
declare enum SignatureVerification {
|
|
209
|
+
ENABLED = "enabled",
|
|
210
|
+
DISABLED = "disabled"
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare class WebhookAction {
|
|
214
|
+
static execute(name?: string, requiredParams?: string[], requiredHeaders?: string[], signatureVerification?: SignatureVerification, action?: (params: {
|
|
215
|
+
[key: string]: any;
|
|
216
|
+
}, ctx: {
|
|
217
|
+
logger: any;
|
|
218
|
+
headers: {
|
|
219
|
+
[key: string]: any;
|
|
220
|
+
};
|
|
221
|
+
}) => Promise<WebhookActionResponseType | WebhookActionResponseType[]>): (params: {
|
|
222
|
+
[key: string]: any;
|
|
223
|
+
}) => Promise<RuntimeActionResponseType>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare class WebhookActionResponse {
|
|
227
|
+
static success(): WebhookActionSuccessResponse;
|
|
228
|
+
static exception(message?: string, exceptionClass?: string): WebhookActionExceptionResponse;
|
|
229
|
+
static add(path: string, value: any, instance?: string): WebhookActionAddResponse;
|
|
230
|
+
static replace(path: string, value: any, instance?: string): WebhookActionReplaceResponse;
|
|
231
|
+
static remove(path: string): WebhookActionRemoveResponse;
|
|
232
|
+
}
|
|
233
|
+
|
|
163
234
|
interface BearerTokenInfo {
|
|
164
235
|
token: string | null;
|
|
165
236
|
tokenLength: number;
|
|
@@ -450,6 +521,67 @@ declare class GenerateBasicAuthToken {
|
|
|
450
521
|
getState(): Promise<any>;
|
|
451
522
|
}
|
|
452
523
|
|
|
524
|
+
interface ShippingCarrierData {
|
|
525
|
+
code: string;
|
|
526
|
+
title?: string;
|
|
527
|
+
stores?: string[];
|
|
528
|
+
countries?: string[];
|
|
529
|
+
sort_order?: number;
|
|
530
|
+
active?: boolean;
|
|
531
|
+
tracking_available?: boolean;
|
|
532
|
+
shipping_labels_available?: boolean;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
interface ShippingCarrierMethodAdditionalData {
|
|
536
|
+
key: string;
|
|
537
|
+
value: any;
|
|
538
|
+
}
|
|
539
|
+
interface ShippingCarrierMethodData {
|
|
540
|
+
carrier_code: string;
|
|
541
|
+
method: string;
|
|
542
|
+
method_title: string;
|
|
543
|
+
price: number;
|
|
544
|
+
cost: number;
|
|
545
|
+
additional_data: ShippingCarrierMethodAdditionalData[];
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
declare class ShippingCarrierMethod {
|
|
549
|
+
private methodData;
|
|
550
|
+
constructor(carrierCode: string, method: string);
|
|
551
|
+
setMethodTitle(methodTitle: string): this;
|
|
552
|
+
setPrice(price: number): this;
|
|
553
|
+
setCost(cost: number): this;
|
|
554
|
+
addAdditionalData(key: string, value: any): this;
|
|
555
|
+
getData(): ShippingCarrierMethodData;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
declare class ShippingCarrier {
|
|
559
|
+
private carrierData;
|
|
560
|
+
private addedMethods;
|
|
561
|
+
private removedMethods;
|
|
562
|
+
constructor(code: string, callback?: (builder: ShippingCarrier) => void);
|
|
563
|
+
private validateCarrierCode;
|
|
564
|
+
private validateMethodCode;
|
|
565
|
+
setTitle(title: string): this;
|
|
566
|
+
setStores(stores: string[]): this;
|
|
567
|
+
setCountries(countries: string[]): this;
|
|
568
|
+
setSortOrder(sortOrder: number): this;
|
|
569
|
+
setActive(active: boolean): this;
|
|
570
|
+
setTrackingAvailable(trackingAvailable: boolean): this;
|
|
571
|
+
setShippingLabelsAvailable(shippingLabelsAvailable: boolean): this;
|
|
572
|
+
setData(carrierData: ShippingCarrierData): this;
|
|
573
|
+
addMethod(method: string, callback?: (builder: ShippingCarrierMethod) => void): this;
|
|
574
|
+
removeMethod(method: string): this;
|
|
575
|
+
reset(code: string, callback?: (builder: ShippingCarrier) => void): this;
|
|
576
|
+
getData(): ShippingCarrierData;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
declare class ShippingCarrierResponse {
|
|
580
|
+
private carrier;
|
|
581
|
+
constructor(carrier: ShippingCarrier);
|
|
582
|
+
generate(): WebhookActionResponseType[];
|
|
583
|
+
}
|
|
584
|
+
|
|
453
585
|
interface AdobeIMSConfig {
|
|
454
586
|
client_id: string;
|
|
455
587
|
client_secrets: string[];
|
|
@@ -683,4 +815,4 @@ declare class AdminUiSdk {
|
|
|
683
815
|
getRegistration(): AdminUiSdkRegistration;
|
|
684
816
|
}
|
|
685
817
|
|
|
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 };
|
|
818
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -126,14 +126,26 @@ interface FileRecord {
|
|
|
126
126
|
updatedAt: string;
|
|
127
127
|
[key: string]: any;
|
|
128
128
|
}
|
|
129
|
+
interface FileMetadata {
|
|
130
|
+
name: string;
|
|
131
|
+
creationTime: Date;
|
|
132
|
+
lastModified: Date;
|
|
133
|
+
etag: string;
|
|
134
|
+
contentLength: number;
|
|
135
|
+
contentType: string;
|
|
136
|
+
isDirectory: boolean;
|
|
137
|
+
isPublic: boolean;
|
|
138
|
+
url: string;
|
|
139
|
+
}
|
|
129
140
|
|
|
130
141
|
declare class FileRepository {
|
|
131
142
|
private readonly filepath;
|
|
132
143
|
private files;
|
|
133
144
|
constructor(filepath: string);
|
|
134
145
|
list(): Promise<FileRecord[]>;
|
|
146
|
+
metadata(id?: string): Promise<FileMetadata | FileMetadata[]>;
|
|
135
147
|
load(id?: string): Promise<FileRecord>;
|
|
136
|
-
save(payload?: Partial<FileRecord>, id?: string | null): Promise<string | null>;
|
|
148
|
+
save(payload?: Partial<FileRecord>, id?: string | null, overwrite?: boolean): Promise<string | null>;
|
|
137
149
|
delete(ids?: string[]): Promise<FileRecord[]>;
|
|
138
150
|
private sanitizeFileId;
|
|
139
151
|
private getFiles;
|
|
@@ -160,6 +172,65 @@ declare class PublishEvent {
|
|
|
160
172
|
execute(providerId: string, eventCode: string, payload: any, subject?: string): Promise<PublishEventResult>;
|
|
161
173
|
}
|
|
162
174
|
|
|
175
|
+
declare enum WebhookActionOperation {
|
|
176
|
+
SUCCESS = "success",
|
|
177
|
+
EXCEPTION = "exception",
|
|
178
|
+
ADD = "add",
|
|
179
|
+
REPLACE = "replace",
|
|
180
|
+
REMOVE = "remove"
|
|
181
|
+
}
|
|
182
|
+
interface WebhookActionSuccessResponse {
|
|
183
|
+
op: typeof WebhookActionOperation.SUCCESS;
|
|
184
|
+
}
|
|
185
|
+
interface WebhookActionExceptionResponse {
|
|
186
|
+
op: typeof WebhookActionOperation.EXCEPTION;
|
|
187
|
+
class?: string;
|
|
188
|
+
message?: string;
|
|
189
|
+
}
|
|
190
|
+
interface WebhookActionAddResponse {
|
|
191
|
+
op: typeof WebhookActionOperation.ADD;
|
|
192
|
+
path: string;
|
|
193
|
+
value: any;
|
|
194
|
+
instance?: string;
|
|
195
|
+
}
|
|
196
|
+
interface WebhookActionReplaceResponse {
|
|
197
|
+
op: typeof WebhookActionOperation.REPLACE;
|
|
198
|
+
path: string;
|
|
199
|
+
value: any;
|
|
200
|
+
instance?: string;
|
|
201
|
+
}
|
|
202
|
+
interface WebhookActionRemoveResponse {
|
|
203
|
+
op: typeof WebhookActionOperation.REMOVE;
|
|
204
|
+
path: string;
|
|
205
|
+
}
|
|
206
|
+
type WebhookActionResponseType = WebhookActionSuccessResponse | WebhookActionExceptionResponse | WebhookActionAddResponse | WebhookActionReplaceResponse | WebhookActionRemoveResponse;
|
|
207
|
+
|
|
208
|
+
declare enum SignatureVerification {
|
|
209
|
+
ENABLED = "enabled",
|
|
210
|
+
DISABLED = "disabled"
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare class WebhookAction {
|
|
214
|
+
static execute(name?: string, requiredParams?: string[], requiredHeaders?: string[], signatureVerification?: SignatureVerification, action?: (params: {
|
|
215
|
+
[key: string]: any;
|
|
216
|
+
}, ctx: {
|
|
217
|
+
logger: any;
|
|
218
|
+
headers: {
|
|
219
|
+
[key: string]: any;
|
|
220
|
+
};
|
|
221
|
+
}) => Promise<WebhookActionResponseType | WebhookActionResponseType[]>): (params: {
|
|
222
|
+
[key: string]: any;
|
|
223
|
+
}) => Promise<RuntimeActionResponseType>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare class WebhookActionResponse {
|
|
227
|
+
static success(): WebhookActionSuccessResponse;
|
|
228
|
+
static exception(message?: string, exceptionClass?: string): WebhookActionExceptionResponse;
|
|
229
|
+
static add(path: string, value: any, instance?: string): WebhookActionAddResponse;
|
|
230
|
+
static replace(path: string, value: any, instance?: string): WebhookActionReplaceResponse;
|
|
231
|
+
static remove(path: string): WebhookActionRemoveResponse;
|
|
232
|
+
}
|
|
233
|
+
|
|
163
234
|
interface BearerTokenInfo {
|
|
164
235
|
token: string | null;
|
|
165
236
|
tokenLength: number;
|
|
@@ -450,6 +521,67 @@ declare class GenerateBasicAuthToken {
|
|
|
450
521
|
getState(): Promise<any>;
|
|
451
522
|
}
|
|
452
523
|
|
|
524
|
+
interface ShippingCarrierData {
|
|
525
|
+
code: string;
|
|
526
|
+
title?: string;
|
|
527
|
+
stores?: string[];
|
|
528
|
+
countries?: string[];
|
|
529
|
+
sort_order?: number;
|
|
530
|
+
active?: boolean;
|
|
531
|
+
tracking_available?: boolean;
|
|
532
|
+
shipping_labels_available?: boolean;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
interface ShippingCarrierMethodAdditionalData {
|
|
536
|
+
key: string;
|
|
537
|
+
value: any;
|
|
538
|
+
}
|
|
539
|
+
interface ShippingCarrierMethodData {
|
|
540
|
+
carrier_code: string;
|
|
541
|
+
method: string;
|
|
542
|
+
method_title: string;
|
|
543
|
+
price: number;
|
|
544
|
+
cost: number;
|
|
545
|
+
additional_data: ShippingCarrierMethodAdditionalData[];
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
declare class ShippingCarrierMethod {
|
|
549
|
+
private methodData;
|
|
550
|
+
constructor(carrierCode: string, method: string);
|
|
551
|
+
setMethodTitle(methodTitle: string): this;
|
|
552
|
+
setPrice(price: number): this;
|
|
553
|
+
setCost(cost: number): this;
|
|
554
|
+
addAdditionalData(key: string, value: any): this;
|
|
555
|
+
getData(): ShippingCarrierMethodData;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
declare class ShippingCarrier {
|
|
559
|
+
private carrierData;
|
|
560
|
+
private addedMethods;
|
|
561
|
+
private removedMethods;
|
|
562
|
+
constructor(code: string, callback?: (builder: ShippingCarrier) => void);
|
|
563
|
+
private validateCarrierCode;
|
|
564
|
+
private validateMethodCode;
|
|
565
|
+
setTitle(title: string): this;
|
|
566
|
+
setStores(stores: string[]): this;
|
|
567
|
+
setCountries(countries: string[]): this;
|
|
568
|
+
setSortOrder(sortOrder: number): this;
|
|
569
|
+
setActive(active: boolean): this;
|
|
570
|
+
setTrackingAvailable(trackingAvailable: boolean): this;
|
|
571
|
+
setShippingLabelsAvailable(shippingLabelsAvailable: boolean): this;
|
|
572
|
+
setData(carrierData: ShippingCarrierData): this;
|
|
573
|
+
addMethod(method: string, callback?: (builder: ShippingCarrierMethod) => void): this;
|
|
574
|
+
removeMethod(method: string): this;
|
|
575
|
+
reset(code: string, callback?: (builder: ShippingCarrier) => void): this;
|
|
576
|
+
getData(): ShippingCarrierData;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
declare class ShippingCarrierResponse {
|
|
580
|
+
private carrier;
|
|
581
|
+
constructor(carrier: ShippingCarrier);
|
|
582
|
+
generate(): WebhookActionResponseType[];
|
|
583
|
+
}
|
|
584
|
+
|
|
453
585
|
interface AdobeIMSConfig {
|
|
454
586
|
client_id: string;
|
|
455
587
|
client_secrets: string[];
|
|
@@ -683,4 +815,4 @@ declare class AdminUiSdk {
|
|
|
683
815
|
getRegistration(): AdminUiSdkRegistration;
|
|
684
816
|
}
|
|
685
817
|
|
|
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 };
|
|
818
|
+
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 };
|