@mbc-cqrs-serverless/import 1.0.20 → 1.0.22
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/dist/event/zip-import.sfn.event.handler.d.ts +8 -1
- package/dist/event/zip-import.sfn.event.handler.js +44 -2
- package/dist/event/zip-import.sfn.event.handler.js.map +1 -1
- package/dist/import.module-definition.d.ts +8 -2
- package/dist/import.module-definition.js +2 -1
- package/dist/import.module-definition.js.map +1 -1
- package/dist/import.module.js +20 -1
- package/dist/import.module.js.map +1 -1
- package/dist/interface/index.d.ts +1 -0
- package/dist/interface/index.js +1 -0
- package/dist/interface/index.js.map +1 -1
- package/dist/interface/zip-finalization-hook.interface.d.ts +59 -0
- package/dist/interface/zip-finalization-hook.interface.js +3 -0
- package/dist/interface/zip-finalization-hook.interface.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { IEventHandler } from '@mbc-cqrs-serverless/core';
|
|
2
2
|
import { ImportService } from '../import.service';
|
|
3
|
+
import { IZipFinalizationHook } from '../interface/zip-finalization-hook.interface';
|
|
3
4
|
import { ZipImportSfnEvent } from './zip-import.sfn.event';
|
|
4
5
|
export declare class ZipImportSfnEventHandler implements IEventHandler<ZipImportSfnEvent> {
|
|
5
6
|
private readonly importService;
|
|
7
|
+
private readonly finalizationHooks;
|
|
6
8
|
private readonly logger;
|
|
7
|
-
constructor(importService: ImportService);
|
|
9
|
+
constructor(importService: ImportService, finalizationHooks: IZipFinalizationHook[]);
|
|
8
10
|
execute(event: ZipImportSfnEvent): Promise<any>;
|
|
9
11
|
/**
|
|
10
12
|
* Handles the trigger_single_csv_and_wait state from the orchestrator.
|
|
@@ -18,4 +20,9 @@ export declare class ZipImportSfnEventHandler implements IEventHandler<ZipImport
|
|
|
18
20
|
* status on the original ZIP_MASTER_JOB.
|
|
19
21
|
*/
|
|
20
22
|
private finalizeZipMasterJob;
|
|
23
|
+
/**
|
|
24
|
+
* Executes all registered ZIP finalization hooks in parallel.
|
|
25
|
+
* Errors are logged but do not affect job completion status.
|
|
26
|
+
*/
|
|
27
|
+
private executeFinalizationHooks;
|
|
21
28
|
}
|
|
@@ -8,17 +8,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
var ZipImportSfnEventHandler_1;
|
|
12
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
16
|
exports.ZipImportSfnEventHandler = void 0;
|
|
14
17
|
const core_1 = require("@mbc-cqrs-serverless/core");
|
|
15
18
|
const common_1 = require("@nestjs/common");
|
|
16
19
|
const enum_1 = require("../enum");
|
|
20
|
+
const import_module_definition_1 = require("../import.module-definition");
|
|
17
21
|
const import_service_1 = require("../import.service");
|
|
18
22
|
const zip_import_sfn_event_1 = require("./zip-import.sfn.event");
|
|
19
23
|
let ZipImportSfnEventHandler = ZipImportSfnEventHandler_1 = class ZipImportSfnEventHandler {
|
|
20
|
-
constructor(importService) {
|
|
24
|
+
constructor(importService, finalizationHooks) {
|
|
21
25
|
this.importService = importService;
|
|
26
|
+
this.finalizationHooks = finalizationHooks;
|
|
22
27
|
this.logger = new common_1.Logger(ZipImportSfnEventHandler_1.name);
|
|
23
28
|
}
|
|
24
29
|
async execute(event) {
|
|
@@ -82,16 +87,53 @@ let ZipImportSfnEventHandler = ZipImportSfnEventHandler_1 = class ZipImportSfnEv
|
|
|
82
87
|
return acc;
|
|
83
88
|
}, { totalRows: 0, processedRows: 0, failedRows: 0 });
|
|
84
89
|
const finalStatus = enum_1.ImportStatusEnum.COMPLETED;
|
|
90
|
+
// Execute finalization hooks in parallel
|
|
91
|
+
await this.executeFinalizationHooks(event, masterJobKey, finalSummary, finalStatus);
|
|
85
92
|
await this.importService.updateStatus(masterJobKey, finalStatus, {
|
|
86
93
|
result: finalSummary,
|
|
87
94
|
});
|
|
88
95
|
this.logger.log(`Successfully finalized ZIP master job ${masterJobKey.pk}#${masterJobKey.sk} with status ${finalStatus}`);
|
|
89
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Executes all registered ZIP finalization hooks in parallel.
|
|
99
|
+
* Errors are logged but do not affect job completion status.
|
|
100
|
+
*/
|
|
101
|
+
async executeFinalizationHooks(event, masterJobKey, results, status) {
|
|
102
|
+
if (!this.finalizationHooks || this.finalizationHooks.length === 0) {
|
|
103
|
+
this.logger.debug('No ZIP finalization hooks registered');
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.logger.log(`Executing ${this.finalizationHooks.length} ZIP finalization hook(s)`);
|
|
107
|
+
const context = {
|
|
108
|
+
event,
|
|
109
|
+
masterJobKey,
|
|
110
|
+
results,
|
|
111
|
+
status,
|
|
112
|
+
executionInput: event.context.Execution.Input,
|
|
113
|
+
};
|
|
114
|
+
// Execute all hooks in parallel with error isolation
|
|
115
|
+
const hookPromises = this.finalizationHooks.map(async (hook, index) => {
|
|
116
|
+
try {
|
|
117
|
+
this.logger.log(`Executing ZIP finalization hook ${index + 1}/${this.finalizationHooks.length}`);
|
|
118
|
+
await hook.execute(context);
|
|
119
|
+
this.logger.log(`ZIP finalization hook ${index + 1} completed successfully`);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
123
|
+
const errorStack = error instanceof Error ? error.stack : undefined;
|
|
124
|
+
this.logger.error(`ZIP finalization hook ${index + 1} failed: ${errorMessage}`, errorStack);
|
|
125
|
+
// Continue execution - don't propagate error
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
await Promise.allSettled(hookPromises);
|
|
129
|
+
this.logger.log(`All ZIP finalization hooks completed`);
|
|
130
|
+
}
|
|
90
131
|
};
|
|
91
132
|
exports.ZipImportSfnEventHandler = ZipImportSfnEventHandler;
|
|
92
133
|
exports.ZipImportSfnEventHandler = ZipImportSfnEventHandler = ZipImportSfnEventHandler_1 = __decorate([
|
|
93
134
|
(0, common_1.Injectable)(),
|
|
94
135
|
(0, core_1.EventHandler)(zip_import_sfn_event_1.ZipImportSfnEvent),
|
|
95
|
-
|
|
136
|
+
__param(1, (0, common_1.Inject)(import_module_definition_1.ZIP_FINALIZATION_HOOKS)),
|
|
137
|
+
__metadata("design:paramtypes", [import_service_1.ImportService, Array])
|
|
96
138
|
], ZipImportSfnEventHandler);
|
|
97
139
|
//# sourceMappingURL=zip-import.sfn.event.handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-import.sfn.event.handler.js","sourceRoot":"","sources":["../../src/event/zip-import.sfn.event.handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zip-import.sfn.event.handler.js","sourceRoot":"","sources":["../../src/event/zip-import.sfn.event.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAIkC;AAClC,2CAA2D;AAG3D,kCAA0D;AAC1D,0EAAoE;AACpE,sDAAiD;AAKjD,iEAA0D;AAInD,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAKnC,YACmB,aAA4B,EAE7C,iBAA0D;QAFzC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAwB;QAL3C,WAAM,GAAW,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAA;IAMxE,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,KAAwB;QACpC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA;QAC1C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,SAAS,cAAc,CAAC,CAAA;QAE5D,IAAI,SAA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b,yBAAyB,KAAK,GAAG,CAAC,yBAAyB,CAC5D,CAAA;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;gBACxD,MAAM,UAAU,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;gBACnE,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,yBAAyB,KAAK,GAAG,CAAC,YAAY,YAAY,EAAE,EAC5D,UAAU,CACX,CAAA;gBACD,6CAA6C;YAC/C,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,MAAM,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;QACtC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAA;IACzD,CAAC;CACF,CAAA;AA1KY,4DAAwB;mCAAxB,wBAAwB;IAFpC,IAAA,mBAAU,GAAE;IACZ,IAAA,mBAAY,EAAC,wCAAiB,CAAC;IAQ3B,WAAA,IAAA,eAAM,EAAC,iDAAsB,CAAC,CAAA;qCADC,8BAAa;GANpC,wBAAwB,CA0KpC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description Defines the configuration for the dynamic ImportModule using ConfigurableModuleBuilder.
|
|
3
3
|
*/
|
|
4
|
-
import { ModuleMetadata } from '@nestjs/common';
|
|
5
|
-
import { ImportEntityProfile } from './interface';
|
|
4
|
+
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
5
|
+
import { ImportEntityProfile, IZipFinalizationHook } from './interface';
|
|
6
6
|
export declare const IMPORT_STRATEGY_MAP = "ImportStrategyMapInjectToken";
|
|
7
7
|
export declare const PROCESS_STRATEGY_MAP = "ProcessStrategyMapInjectToken";
|
|
8
|
+
export declare const ZIP_FINALIZATION_HOOKS = "ZipFinalizationHooksInjectToken";
|
|
8
9
|
/**
|
|
9
10
|
* The main options object for the ImportModule's `register` method.
|
|
10
11
|
*/
|
|
@@ -23,6 +24,11 @@ export interface ImportModuleOptions {
|
|
|
23
24
|
* (Optional) Enables the built-in `/import` and `/import/csv` endpoints.
|
|
24
25
|
*/
|
|
25
26
|
enableController?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* (Optional) Array of ZIP finalization hooks that execute after ZIP import completes.
|
|
29
|
+
* Hooks run in parallel and errors are logged without failing the job.
|
|
30
|
+
*/
|
|
31
|
+
zipFinalizationHooks?: Type<IZipFinalizationHook>[];
|
|
26
32
|
}
|
|
27
33
|
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<ImportModuleOptions, "register", "create", {
|
|
28
34
|
profiles: ImportEntityProfile[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.OPTIONS_TYPE = exports.MODULE_OPTIONS_TOKEN = exports.ConfigurableModuleClass = exports.PROCESS_STRATEGY_MAP = exports.IMPORT_STRATEGY_MAP = void 0;
|
|
4
|
+
exports.OPTIONS_TYPE = exports.MODULE_OPTIONS_TOKEN = exports.ConfigurableModuleClass = exports.ZIP_FINALIZATION_HOOKS = exports.PROCESS_STRATEGY_MAP = exports.IMPORT_STRATEGY_MAP = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* @description Defines the configuration for the dynamic ImportModule using ConfigurableModuleBuilder.
|
|
7
7
|
*/
|
|
@@ -9,6 +9,7 @@ const common_1 = require("@nestjs/common");
|
|
|
9
9
|
// --- Injection Tokens for our internal provider maps ---
|
|
10
10
|
exports.IMPORT_STRATEGY_MAP = 'ImportStrategyMapInjectToken';
|
|
11
11
|
exports.PROCESS_STRATEGY_MAP = 'ProcessStrategyMapInjectToken';
|
|
12
|
+
exports.ZIP_FINALIZATION_HOOKS = 'ZipFinalizationHooksInjectToken';
|
|
12
13
|
// --- Configurable Module Setup ---
|
|
13
14
|
_a = new common_1.ConfigurableModuleBuilder()
|
|
14
15
|
// The module will always be configured with the profiles array.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.module-definition.js","sourceRoot":"","sources":["../src/import.module-definition.ts"],"names":[],"mappings":";;;;AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"import.module-definition.js","sourceRoot":"","sources":["../src/import.module-definition.ts"],"names":[],"mappings":";;;;AAAA;;GAEG;AACH,2CAAgF;AAIhF,0DAA0D;AAC7C,QAAA,mBAAmB,GAAG,8BAA8B,CAAA;AACpD,QAAA,oBAAoB,GAAG,+BAA+B,CAAA;AACtD,QAAA,sBAAsB,GAAG,iCAAiC,CAAA;AA8BvE,oCAAoC;AACvB,KACX,IAAI,kCAAyB,EAAuB;IAClD,gEAAgE;KAC/D,SAAS,CACR,EAAE,QAAQ,EAAE,EAAE,EAAE,EAChB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACvB,GAAG,UAAU;IACb,QAAQ,EAAE,MAAM,CAAC,QAAQ;CAC1B,CAAC,CACH;KACA,KAAK,EAAE,EAVG,+BAAuB,+BAAE,4BAAoB,4BAAE,oBAAY,mBAU9D"}
|
package/dist/import.module.js
CHANGED
|
@@ -23,12 +23,31 @@ const import_service_1 = require("./import.service");
|
|
|
23
23
|
let ImportModule = class ImportModule extends import_module_definition_1.ConfigurableModuleClass {
|
|
24
24
|
static register(options) {
|
|
25
25
|
const module = super.register(options);
|
|
26
|
-
const { enableController, profiles, imports } = options;
|
|
26
|
+
const { enableController, profiles, imports, zipFinalizationHooks } = options;
|
|
27
27
|
module.imports = [...(module.imports || []), ...(imports || [])];
|
|
28
28
|
const dynamicProviders = [
|
|
29
29
|
this.createStrategyMapFactory(import_module_definition_1.IMPORT_STRATEGY_MAP, profiles, (p) => p.importStrategy),
|
|
30
30
|
this.createStrategyMapFactory(import_module_definition_1.PROCESS_STRATEGY_MAP, profiles, (p) => p.processStrategy),
|
|
31
31
|
];
|
|
32
|
+
// Add hooks provider
|
|
33
|
+
if (zipFinalizationHooks && zipFinalizationHooks.length > 0) {
|
|
34
|
+
// Add hook classes as providers so they can be injected
|
|
35
|
+
zipFinalizationHooks.forEach((hookClass) => {
|
|
36
|
+
dynamicProviders.push(hookClass);
|
|
37
|
+
});
|
|
38
|
+
// Add the array provider that collects all hook instances
|
|
39
|
+
dynamicProviders.push({
|
|
40
|
+
provide: import_module_definition_1.ZIP_FINALIZATION_HOOKS,
|
|
41
|
+
useFactory: (...instances) => instances,
|
|
42
|
+
inject: zipFinalizationHooks,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
dynamicProviders.push({
|
|
47
|
+
provide: import_module_definition_1.ZIP_FINALIZATION_HOOKS,
|
|
48
|
+
useValue: [],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
32
51
|
module.providers = [...(module.providers || []), ...dynamicProviders];
|
|
33
52
|
if (enableController) {
|
|
34
53
|
module.controllers = [...(module.controllers || []), import_controller_1.ImportController];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.module.js","sourceRoot":"","sources":["../src/import.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAwE;AACxE,2CAAsE;AAEtE,uGAAqF;AACrF,2FAAmF;AACnF,uFAA+E;AAC/E,uEAAiE;AACjE,mFAA4E;AAC5E,iGAA+E;AAC/E,2FAAmF;AACnF,uFAA+E;AAC/E,2DAAsD;AACtD,
|
|
1
|
+
{"version":3,"file":"import.module.js","sourceRoot":"","sources":["../src/import.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAwE;AACxE,2CAAsE;AAEtE,uGAAqF;AACrF,2FAAmF;AACnF,uFAA+E;AAC/E,uEAAiE;AACjE,mFAA4E;AAC5E,iGAA+E;AAC/E,2FAAmF;AACnF,uFAA+E;A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index.js
CHANGED
|
@@ -18,4 +18,5 @@ __exportStar(require("./csv-mapping-strategy.interface"), exports);
|
|
|
18
18
|
__exportStar(require("./import-entity-profile.interface"), exports);
|
|
19
19
|
__exportStar(require("./import-strategy.interface"), exports);
|
|
20
20
|
__exportStar(require("./processing-strategy.interface"), exports);
|
|
21
|
+
__exportStar(require("./zip-finalization-hook.interface"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interface/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAgD;AAChD,oEAAiD;AACjD,8DAA2C;AAC3C,kEAA+C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interface/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAgD;AAChD,oEAAiD;AACjD,8DAA2C;AAC3C,kEAA+C;AAC/C,oEAAiD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DetailKey } from '@mbc-cqrs-serverless/core';
|
|
2
|
+
import { ImportStatusEnum } from '../enum';
|
|
3
|
+
import { ZipImportSfnEvent } from '../event/zip-import.sfn.event';
|
|
4
|
+
/**
|
|
5
|
+
* Context passed to ZIP finalization hooks containing all relevant job information.
|
|
6
|
+
*/
|
|
7
|
+
export interface ZipFinalizationContext {
|
|
8
|
+
/** The original Step Function event */
|
|
9
|
+
event: ZipImportSfnEvent;
|
|
10
|
+
/** The key of the master ZIP job */
|
|
11
|
+
masterJobKey: DetailKey;
|
|
12
|
+
/** Aggregated results from all CSV files */
|
|
13
|
+
results: {
|
|
14
|
+
totalRows: number;
|
|
15
|
+
processedRows: number;
|
|
16
|
+
failedRows: number;
|
|
17
|
+
};
|
|
18
|
+
/** Final status of the job */
|
|
19
|
+
status: ImportStatusEnum;
|
|
20
|
+
/** The original execution input from Step Functions */
|
|
21
|
+
executionInput: any;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interface for custom hooks that execute after ZIP import processing completes.
|
|
25
|
+
* Implementations can perform post-processing tasks like moving files to backup,
|
|
26
|
+
* sending notifications, or updating external systems.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* @Injectable()
|
|
31
|
+
* export class BackupToS3Hook implements IZipFinalizationHook {
|
|
32
|
+
* constructor(private readonly s3Service: S3Service) {}
|
|
33
|
+
*
|
|
34
|
+
* async execute(context: ZipFinalizationContext): Promise<void> {
|
|
35
|
+
* const { executionInput } = context
|
|
36
|
+
* const { bucket, key } = executionInput.parameters
|
|
37
|
+
*
|
|
38
|
+
* // Move file to backup location
|
|
39
|
+
* const backupKey = `backup/${key}`
|
|
40
|
+
* await this.s3Service.copyObject({
|
|
41
|
+
* sourceBucket: bucket,
|
|
42
|
+
* sourceKey: key,
|
|
43
|
+
* destinationBucket: bucket,
|
|
44
|
+
* destinationKey: backupKey,
|
|
45
|
+
* })
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export interface IZipFinalizationHook {
|
|
51
|
+
/**
|
|
52
|
+
* Executes custom logic after ZIP import completes.
|
|
53
|
+
* Hooks run in parallel and errors are logged without failing the job.
|
|
54
|
+
*
|
|
55
|
+
* @param context - Contains event data, masterJobKey, and aggregated results
|
|
56
|
+
* @returns Promise that resolves when hook completes
|
|
57
|
+
*/
|
|
58
|
+
execute(context: ZipFinalizationContext): Promise<void>;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip-finalization-hook.interface.js","sourceRoot":"","sources":["../../src/interface/zip-finalization-hook.interface.ts"],"names":[],"mappings":""}
|
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.22",
|
|
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.22",
|
|
45
45
|
"csv-parser": "^3.2.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "7d77028acefcce1a4a5b0fbeee2524d2dc264e64"
|
|
48
48
|
}
|