@mbc-cqrs-serverless/import 1.0.16 → 1.0.18
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/README.md
CHANGED
|
@@ -1,55 +1,373 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
+
# @mbc-cqrs-serverless/import
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@mbc-cqrs-serverless/import)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
Flexible data import module for the MBC CQRS Serverless framework. Import data from REST APIs, CSV files, and ZIP archives with validation, transformation, and async processing.
|
|
7
9
|
|
|
8
|
-
##
|
|
10
|
+
## Features
|
|
9
11
|
|
|
10
|
-
- **
|
|
12
|
+
- **Multi-Source Import**: Support for REST API, CSV files, and ZIP archives
|
|
13
|
+
- **Strategy Pattern**: Customizable validation and transformation per entity type
|
|
14
|
+
- **Two-Phase Processing**: Separate ingestion and business logic phases
|
|
15
|
+
- **Dual Processing Modes**: DIRECT mode for small files, STEP_FUNCTION for large-scale imports
|
|
16
|
+
- **Progress Tracking**: Real-time status updates via SNS notifications
|
|
17
|
+
- **Error Handling**: Built-in alarm notifications and row-level error tracking
|
|
11
18
|
|
|
12
|
-
|
|
19
|
+
## Installation
|
|
13
20
|
|
|
14
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npm install @mbc-cqrs-serverless/import
|
|
23
|
+
```
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
## Quick Start
|
|
17
26
|
|
|
18
|
-
|
|
27
|
+
### 1. Register the Module
|
|
19
28
|
|
|
20
|
-
|
|
29
|
+
```typescript
|
|
30
|
+
import { Module } from '@nestjs/common';
|
|
31
|
+
import { ImportModule } from '@mbc-cqrs-serverless/import';
|
|
32
|
+
import { ProductImportStrategy } from './strategies/product-import.strategy';
|
|
33
|
+
import { ProductProcessStrategy } from './strategies/product-process.strategy';
|
|
34
|
+
import { ProductModule } from './product/product.module';
|
|
21
35
|
|
|
22
|
-
|
|
23
|
-
|
|
36
|
+
@Module({
|
|
37
|
+
imports: [
|
|
38
|
+
ImportModule.register({
|
|
39
|
+
profiles: [
|
|
40
|
+
{
|
|
41
|
+
tableName: 'product',
|
|
42
|
+
importStrategy: ProductImportStrategy,
|
|
43
|
+
processStrategy: ProductProcessStrategy,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
imports: [ProductModule], // Optional: modules that provide strategy dependencies
|
|
47
|
+
enableController: true, // Optional: enable REST endpoints
|
|
48
|
+
}),
|
|
49
|
+
],
|
|
50
|
+
})
|
|
51
|
+
export class AppModule {}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Implement Import Strategy
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { Injectable } from '@nestjs/common';
|
|
58
|
+
import { IImportStrategy } from '@mbc-cqrs-serverless/import';
|
|
59
|
+
|
|
60
|
+
@Injectable()
|
|
61
|
+
export class ProductImportStrategy implements IImportStrategy<RawProductInput, ProductDto> {
|
|
62
|
+
async transform(input: RawProductInput): Promise<ProductDto> {
|
|
63
|
+
return {
|
|
64
|
+
code: input.product_code?.trim(),
|
|
65
|
+
name: input.product_name?.trim(),
|
|
66
|
+
price: parseFloat(input.price),
|
|
67
|
+
category: input.category?.toUpperCase(),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async validate(dto: ProductDto): Promise<void> {
|
|
72
|
+
if (!dto.code) throw new Error('Product code is required');
|
|
73
|
+
if (!dto.name) throw new Error('Product name is required');
|
|
74
|
+
if (isNaN(dto.price) || dto.price < 0) throw new Error('Invalid price');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
24
77
|
```
|
|
25
|
-
## Architecture Overview
|
|
26
78
|
|
|
27
|
-
|
|
79
|
+
### 3. Implement Process Strategy
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { Injectable } from '@nestjs/common';
|
|
83
|
+
import {
|
|
84
|
+
IProcessStrategy,
|
|
85
|
+
ComparisonStatus,
|
|
86
|
+
ComparisonResult,
|
|
87
|
+
} from '@mbc-cqrs-serverless/import';
|
|
88
|
+
import { CommandService, DataModel, CommandInputModel } from '@mbc-cqrs-serverless/core';
|
|
89
|
+
|
|
90
|
+
// Define your entity model
|
|
91
|
+
interface ProductModel extends DataModel {
|
|
92
|
+
code: string;
|
|
93
|
+
name: string;
|
|
94
|
+
price: number;
|
|
95
|
+
}
|
|
28
96
|
|
|
29
|
-
|
|
97
|
+
@Injectable()
|
|
98
|
+
export class ProductProcessStrategy implements IProcessStrategy<ProductModel, ProductDto> {
|
|
99
|
+
constructor(
|
|
100
|
+
private readonly productService: ProductService,
|
|
101
|
+
private readonly commandService: CommandService,
|
|
102
|
+
) {}
|
|
103
|
+
|
|
104
|
+
async compare(dto: ProductDto, tenantCode: string): Promise<ComparisonResult<ProductModel>> {
|
|
105
|
+
const existing = await this.productService.findByCode(dto.code, tenantCode);
|
|
106
|
+
if (!existing) {
|
|
107
|
+
return { status: ComparisonStatus.NOT_EXIST };
|
|
108
|
+
}
|
|
109
|
+
if (this.hasChanges(existing, dto)) {
|
|
110
|
+
return { status: ComparisonStatus.CHANGED, existingData: existing };
|
|
111
|
+
}
|
|
112
|
+
return { status: ComparisonStatus.EQUAL };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async map(
|
|
116
|
+
status: ComparisonStatus.NOT_EXIST | ComparisonStatus.CHANGED,
|
|
117
|
+
dto: ProductDto,
|
|
118
|
+
tenantCode: string,
|
|
119
|
+
existingData?: ProductModel,
|
|
120
|
+
): Promise<CommandInputModel> {
|
|
121
|
+
return {
|
|
122
|
+
pk: `PRODUCT#${tenantCode}`,
|
|
123
|
+
sk: `PRODUCT#${dto.code}`,
|
|
124
|
+
code: dto.code,
|
|
125
|
+
name: dto.name,
|
|
126
|
+
attributes: { price: dto.price },
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
getCommandService(): CommandService {
|
|
131
|
+
return this.commandService;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
30
135
|
|
|
31
|
-
|
|
136
|
+
## Architecture
|
|
137
|
+
|
|
138
|
+
The import module uses a two-phase architecture:
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
142
|
+
│ Import Architecture │
|
|
143
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
144
|
+
│ │
|
|
145
|
+
│ Phase 1: Ingestion │
|
|
146
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
147
|
+
│ │ REST API / │────▶│ ImportStrategy│────▶│ Temp Table │ │
|
|
148
|
+
│ │ CSV / ZIP │ │ transform() │ │ (CREATED) │ │
|
|
149
|
+
│ └──────────────┘ │ validate() │ └──────────────┘ │
|
|
150
|
+
│ └──────────────┘ │ │
|
|
151
|
+
│ ▼ DynamoDB │
|
|
152
|
+
│ Phase 2: Processing │ Streams │
|
|
153
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌─────┴────────┐ │
|
|
154
|
+
│ │ ProcessStrategy│◀───│ SNS/SQS │◀────│ Lambda │ │
|
|
155
|
+
│ │ compare() │ │ Event │ │ Trigger │ │
|
|
156
|
+
│ │ map() │ └──────────────┘ └──────────────┘ │
|
|
157
|
+
│ └──────────────┘ │
|
|
158
|
+
│ │ │
|
|
159
|
+
│ ▼ │
|
|
160
|
+
│ ┌──────────────┐ ┌──────────────┐ │
|
|
161
|
+
│ │ CommandService│────▶│ Final Table │ │
|
|
162
|
+
│ │ publish() │ │ (Data Store) │ │
|
|
163
|
+
│ └──────────────┘ └──────────────┘ │
|
|
164
|
+
│ │
|
|
165
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## API Reference
|
|
169
|
+
|
|
170
|
+
### ImportService
|
|
171
|
+
|
|
172
|
+
| Method | Description |
|
|
173
|
+
|--------|-------------|
|
|
174
|
+
| `createWithApi(dto, options)` | Import single record from REST API |
|
|
175
|
+
| `handleCsvImport(dto, options)` | Import from CSV file (DIRECT or STEP_FUNCTION) |
|
|
176
|
+
| `createCsvJob(dto, options)` | Create CSV import job for Step Functions |
|
|
177
|
+
| `createZipJob(dto, options)` | Create ZIP import job for Step Functions |
|
|
178
|
+
| `createImport(dto, options)` | Create import record in temp table |
|
|
179
|
+
| `updateStatus(key, status, payload?, attributes?, notifyId?)` | Update import status |
|
|
180
|
+
| `getImportByKey(key)` | Get import record by key |
|
|
181
|
+
| `incrementParentJobCounters(parentKey, childSucceeded)` | Update parent job progress |
|
|
182
|
+
|
|
183
|
+
### IImportStrategy Interface
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
interface IImportStrategy<TInput extends object, TAttributesDto extends object> {
|
|
187
|
+
transform(input: TInput): Promise<TAttributesDto>;
|
|
188
|
+
validate(data: TAttributesDto): Promise<void>;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### IProcessStrategy Interface
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
interface IProcessStrategy<TEntity extends DataModel, TAttributesDto extends object> {
|
|
196
|
+
compare(importAttributes: TAttributesDto, tenantCode: string): Promise<ComparisonResult<TEntity>>;
|
|
197
|
+
map(status: ComparisonStatus, importAttributes: TAttributesDto, tenantCode: string, existingData?: TEntity): Promise<CommandInputModel | CommandPartialInputModel>;
|
|
198
|
+
getCommandService(): CommandService;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
interface ComparisonResult<TEntity> {
|
|
202
|
+
status: ComparisonStatus;
|
|
203
|
+
existingData?: TEntity; // Provided when status is CHANGED
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
enum ComparisonStatus {
|
|
207
|
+
NOT_EXIST = 'NOT_EXIST',
|
|
208
|
+
CHANGED = 'CHANGED',
|
|
209
|
+
EQUAL = 'EQUAL',
|
|
210
|
+
}
|
|
211
|
+
```
|
|
32
212
|
|
|
33
|
-
|
|
213
|
+
### ImportStatusEnum
|
|
34
214
|
|
|
35
|
-
|
|
215
|
+
| Status | Description |
|
|
216
|
+
|--------|-------------|
|
|
217
|
+
| `CREATED` | Import record created |
|
|
218
|
+
| `PROCESSING` | Being processed |
|
|
219
|
+
| `COMPLETED` | Successfully completed |
|
|
220
|
+
| `FAILED` | Processing failed |
|
|
221
|
+
|
|
222
|
+
### ImportStatusHandler
|
|
223
|
+
|
|
224
|
+
The `ImportStatusHandler` is an internal event handler that manages Step Functions callbacks for import jobs. When using Step Functions orchestration (ZIP imports or STEP_FUNCTION mode CSV imports), this handler ensures proper communication with the state machine.
|
|
225
|
+
|
|
226
|
+
#### Behavior
|
|
227
|
+
|
|
228
|
+
| Import Status | Action | Step Functions Command |
|
|
229
|
+
|---------------|--------|----------------------|
|
|
230
|
+
| `COMPLETED` | Send success callback | `SendTaskSuccessCommand` |
|
|
231
|
+
| `FAILED` | Send failure callback | `SendTaskFailureCommand` |
|
|
232
|
+
| Other statuses | Ignored | None |
|
|
233
|
+
|
|
234
|
+
#### Methods
|
|
235
|
+
|
|
236
|
+
| Method | Description |
|
|
237
|
+
|--------|-------------|
|
|
238
|
+
| `sendTaskSuccess(taskToken, output)` | Sends success signal to Step Functions with the import result |
|
|
239
|
+
| `sendTaskFailure(taskToken, error, cause)` | Sends failure signal to Step Functions with error details |
|
|
240
|
+
|
|
241
|
+
#### Step Functions Integration
|
|
242
|
+
|
|
243
|
+
When an import job is created as part of a Step Functions workflow (e.g., ZIP import), a `taskToken` is stored in the job's attributes. The `ImportStatusHandler` listens for status change notifications and:
|
|
244
|
+
|
|
245
|
+
1. Retrieves the import job from DynamoDB
|
|
246
|
+
2. Checks if a `taskToken` exists in the job's attributes
|
|
247
|
+
3. Sends the appropriate callback based on the final status:
|
|
248
|
+
- `COMPLETED` → `SendTaskSuccessCommand` with result data
|
|
249
|
+
- `FAILED` → `SendTaskFailureCommand` with error details
|
|
250
|
+
|
|
251
|
+
This ensures Step Functions workflows properly handle both success and failure cases without hanging indefinitely.
|
|
252
|
+
|
|
253
|
+
## Usage Examples
|
|
254
|
+
|
|
255
|
+
### REST API Import
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
@Controller('import')
|
|
259
|
+
export class ImportController {
|
|
260
|
+
constructor(private readonly importService: ImportService) {}
|
|
261
|
+
|
|
262
|
+
@Post('product')
|
|
263
|
+
async importProduct(
|
|
264
|
+
@Body() dto: ImportProductDto,
|
|
265
|
+
@InvokeContext() ctx: IInvoke,
|
|
266
|
+
) {
|
|
267
|
+
return this.importService.createWithApi(
|
|
268
|
+
{
|
|
269
|
+
tableName: 'product',
|
|
270
|
+
tenantCode: dto.tenantCode,
|
|
271
|
+
attributes: dto,
|
|
272
|
+
},
|
|
273
|
+
{ invokeContext: ctx },
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### CSV Import (Direct Mode)
|
|
280
|
+
|
|
281
|
+
Process small CSV files immediately:
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
async importSmallCsv(bucket: string, key: string, opts: { invokeContext: IInvoke }) {
|
|
285
|
+
return this.importService.handleCsvImport(
|
|
286
|
+
{
|
|
287
|
+
tenantCode: 'MBC',
|
|
288
|
+
tableName: 'product',
|
|
289
|
+
bucket,
|
|
290
|
+
key,
|
|
291
|
+
processingMode: 'DIRECT',
|
|
292
|
+
},
|
|
293
|
+
opts,
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### CSV Import (Step Functions Mode)
|
|
299
|
+
|
|
300
|
+
Process large CSV files with Step Functions orchestration:
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
async importLargeCsv(bucket: string, key: string, opts: { invokeContext: IInvoke }) {
|
|
304
|
+
return this.importService.handleCsvImport(
|
|
305
|
+
{
|
|
306
|
+
tenantCode: 'MBC',
|
|
307
|
+
tableName: 'product',
|
|
308
|
+
bucket,
|
|
309
|
+
key,
|
|
310
|
+
processingMode: 'STEP_FUNCTION',
|
|
311
|
+
},
|
|
312
|
+
opts,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### ZIP Import
|
|
318
|
+
|
|
319
|
+
Import multiple CSV files from a ZIP archive:
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
async importZip(bucket: string, key: string, opts: { invokeContext: IInvoke }) {
|
|
323
|
+
return this.importService.createZipJob(
|
|
324
|
+
{
|
|
325
|
+
tenantCode: 'MBC',
|
|
326
|
+
bucket,
|
|
327
|
+
key,
|
|
328
|
+
},
|
|
329
|
+
opts,
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Check Import Status
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
async checkStatus(pk: string, sk: string) {
|
|
338
|
+
const importJob = await this.importService.getImportByKey({ pk, sk });
|
|
339
|
+
return {
|
|
340
|
+
status: importJob.status,
|
|
341
|
+
totalRows: importJob.totalRows,
|
|
342
|
+
processedRows: importJob.processedRows,
|
|
343
|
+
succeededRows: importJob.succeededRows,
|
|
344
|
+
failedRows: importJob.failedRows,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
```
|
|
36
348
|
|
|
37
|
-
|
|
349
|
+
## Processing Modes
|
|
38
350
|
|
|
39
|
-
|
|
351
|
+
| Mode | Use Case | Processing |
|
|
352
|
+
|------|----------|------------|
|
|
353
|
+
| `DIRECT` | Small files (< 1000 rows) | Immediate, synchronous |
|
|
354
|
+
| `STEP_FUNCTION` | Large files, mission-critical | Async, resilient, tracked |
|
|
40
355
|
|
|
41
|
-
|
|
356
|
+
## Related Packages
|
|
42
357
|
|
|
43
|
-
|
|
358
|
+
| Package | Description |
|
|
359
|
+
|---------|-------------|
|
|
360
|
+
| [@mbc-cqrs-serverless/core](https://www.npmjs.com/package/@mbc-cqrs-serverless/core) | Core CQRS framework |
|
|
361
|
+
| [@mbc-cqrs-serverless/task](https://www.npmjs.com/package/@mbc-cqrs-serverless/task) | Task processing for async jobs |
|
|
44
362
|
|
|
45
|
-
|
|
363
|
+
## Documentation
|
|
46
364
|
|
|
47
|
-
|
|
365
|
+
Full documentation available at [https://mbc-cqrs-serverless.mbc-net.com/](https://mbc-cqrs-serverless.mbc-net.com/)
|
|
48
366
|
|
|
49
|
-
|
|
367
|
+
- [Import Service Guide](https://mbc-cqrs-serverless.mbc-net.com/docs/import-service)
|
|
50
368
|
|
|
51
369
|
## License
|
|
52
370
|
|
|
53
|
-
Copyright © 2024, Murakami Business Consulting, Inc. https://www.mbc-net.com/
|
|
371
|
+
Copyright © 2024-2025, Murakami Business Consulting, Inc. [https://www.mbc-net.com/](https://www.mbc-net.com/)
|
|
54
372
|
|
|
55
|
-
This project
|
|
373
|
+
This project is under the [MIT License](../../LICENSE.txt).
|
|
@@ -13,4 +13,11 @@ export declare class ImportStatusHandler implements IEventHandler<ImportStatusQu
|
|
|
13
13
|
* @param output The JSON output to send back to the state machine.
|
|
14
14
|
*/
|
|
15
15
|
sendTaskSuccess(taskToken: string, output: any): Promise<import("@aws-sdk/client-sfn").SendTaskSuccessCommandOutput>;
|
|
16
|
+
/**
|
|
17
|
+
* Sends a failure signal to a waiting Step Function task.
|
|
18
|
+
* @param taskToken The unique token of the paused task.
|
|
19
|
+
* @param error The error code to send back to the state machine.
|
|
20
|
+
* @param cause The detailed cause of the failure (will be JSON stringified).
|
|
21
|
+
*/
|
|
22
|
+
sendTaskFailure(taskToken: string, error: string, cause: any): Promise<import("@aws-sdk/client-sfn").SendTaskFailureCommandOutput>;
|
|
16
23
|
}
|
|
@@ -26,14 +26,17 @@ let ImportStatusHandler = ImportStatusHandler_1 = class ImportStatusHandler {
|
|
|
26
26
|
}
|
|
27
27
|
async execute(event) {
|
|
28
28
|
const notification = JSON.parse(event.body);
|
|
29
|
-
// 1. Filter for
|
|
29
|
+
// 1. Filter for specific events: completed or failed master CSV jobs.
|
|
30
30
|
const pk = notification.pk;
|
|
31
31
|
const status = notification.content?.status;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// Only process COMPLETED or FAILED status for CSV_IMPORT jobs
|
|
33
|
+
const isTerminalStatus = status === enum_1.ImportStatusEnum.COMPLETED ||
|
|
34
|
+
status === enum_1.ImportStatusEnum.FAILED;
|
|
35
|
+
const isCsvImportJob = pk?.startsWith(`${constant_1.CSV_IMPORT_PK_PREFIX}${core_1.KEY_SEPARATOR}`);
|
|
36
|
+
if (!isTerminalStatus || !isCsvImportJob) {
|
|
34
37
|
return;
|
|
35
38
|
}
|
|
36
|
-
this.logger.log(`Received
|
|
39
|
+
this.logger.log(`Received ${status} master CSV job event for: ${notification.id}`);
|
|
37
40
|
try {
|
|
38
41
|
// 2. Get the full import job entity from DynamoDB.
|
|
39
42
|
const importKey = { pk: notification.pk, sk: notification.sk };
|
|
@@ -45,10 +48,14 @@ let ImportStatusHandler = ImportStatusHandler_1 = class ImportStatusHandler {
|
|
|
45
48
|
// 3. Check if a taskToken was saved in its attributes.
|
|
46
49
|
const taskToken = importJob.attributes?.taskToken;
|
|
47
50
|
if (taskToken) {
|
|
48
|
-
this.logger.log(`Found task token.
|
|
49
|
-
// 4. Send the
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
this.logger.log(`Found task token. Sending ${status} signal to Step Function.`);
|
|
52
|
+
// 4. Send the appropriate signal based on status.
|
|
53
|
+
if (status === enum_1.ImportStatusEnum.COMPLETED) {
|
|
54
|
+
await this.sendTaskSuccess(taskToken, importJob.result);
|
|
55
|
+
}
|
|
56
|
+
else if (status === enum_1.ImportStatusEnum.FAILED) {
|
|
57
|
+
await this.sendTaskFailure(taskToken, 'ImportFailed', importJob.result);
|
|
58
|
+
}
|
|
52
59
|
}
|
|
53
60
|
else {
|
|
54
61
|
this.logger.log('No task token found in import job attributes. Nothing to do.');
|
|
@@ -71,6 +78,20 @@ let ImportStatusHandler = ImportStatusHandler_1 = class ImportStatusHandler {
|
|
|
71
78
|
output: JSON.stringify(output),
|
|
72
79
|
}));
|
|
73
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Sends a failure signal to a waiting Step Function task.
|
|
83
|
+
* @param taskToken The unique token of the paused task.
|
|
84
|
+
* @param error The error code to send back to the state machine.
|
|
85
|
+
* @param cause The detailed cause of the failure (will be JSON stringified).
|
|
86
|
+
*/
|
|
87
|
+
async sendTaskFailure(taskToken, error, cause) {
|
|
88
|
+
this.logger.log(`Sending task failure for token: ${taskToken}`);
|
|
89
|
+
return this.sfnService.client.send(new client_sfn_1.SendTaskFailureCommand({
|
|
90
|
+
taskToken: taskToken,
|
|
91
|
+
error: error,
|
|
92
|
+
cause: JSON.stringify(cause),
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
74
95
|
};
|
|
75
96
|
exports.ImportStatusHandler = ImportStatusHandler;
|
|
76
97
|
exports.ImportStatusHandler = ImportStatusHandler = ImportStatusHandler_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-status.queue.event.handler.js","sourceRoot":"","sources":["../../src/event/import-status.queue.event.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"import-status.queue.event.handler.js","sourceRoot":"","sources":["../../src/event/import-status.queue.event.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,oDAG4B;AAC5B,oDAMkC;AAClC,2CAAmD;AAEnD,0CAAkD;AAClD,sDAAiD;AACjD,2EAAoE;AACpE,kCAA0C;AAInC,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAK9B,YACmB,aAA4B,EAC5B,UAA+B;QAD/B,kBAAa,GAAb,aAAa,CAAe;QAC5B,eAAU,GAAV,UAAU,CAAqB;QAJjC,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAA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;IACH,CAAC;CACF,CAAA;AAtGY,kDAAmB;8BAAnB,mBAAmB;IAF/B,IAAA,mBAAU,GAAE;IACZ,IAAA,mBAAY,EAAC,kDAAsB,CAAC;qCAOD,8BAAa;QAChB,0BAAmB;GAPvC,mBAAmB,CAsG/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbc-cqrs-serverless/import",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Import module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mbc",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@mbc-cqrs-serverless/core": "1.0.
|
|
44
|
+
"@mbc-cqrs-serverless/core": "1.0.18",
|
|
45
45
|
"csv-parser": "^3.2.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "f94a747c55ac4b09a643a5201dc89e4edda19c76"
|
|
48
48
|
}
|