Scan your whole stack
From OX Research Newsroom
Are you using @mbc-cqrs-serverless/import?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v1.8.1
@mbc-cqrs-serverless/import was last scanned on 25 Nov 2026 at version 1.8.1. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 1.8.1 LATEST | 25 Nov 2026 | No rules fired |
| 1.8.0 | 15 Nov 2026 | No rules fired |
| 1.7.0 | 8 Nov 2026 | No rules fired |
| 1.6.0 | 3 Nov 2026 | Not shown |
| 1.5.0 | 24 Sep 2026 | Not shown |
Findings for v1.8.1. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 1.8.1; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
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.
npm install @mbc-cqrs-serverless/import
import { Module } from '@nestjs/common';
import { ImportModule } from '@mbc-cqrs-serverless/import';
import { ProductImportStrategy } from './strategies/product-import.strategy';
import { ProductProcessStrategy } from './strategies/product-process.strategy';
import { ProductModule } from './product/product.module';
@Module({
imports: [
ImportModule.register({
profiles: [
{
tableName: 'product',
importStrategy: ProductImportStrategy,
processStrategy: ProductProcessStrategy,
},
],
imports: [ProductModule], // Optional: modules that provide strategy dependencies
enableController: true, // Optional: enable REST endpoints
}),
],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
import { IImportStrategy } from '@mbc-cqrs-serverless/import';
@Injectable()
export class ProductImportStrategy implements IImportStrategy<RawProductInput, ProductDto> {
async transform(input: RawProductInput): Promise<ProductDto> {
return {
code: input.product_code?.trim(),
name: input.product_name?.trim(),
price: parseFloat(input.price),
category: input.category?.toUpperCase(),
};
}
async validate(dto: ProductDto): Promise<void> {
if (!dto.code) throw new Error('Product code is required');
if (!dto.name) throw new Error('Product name is required');
if (isNaN(dto.price) || dto.price < 0) throw new Error('Invalid price');
}
}
import { Injectable } from '@nestjs/common';
import {
IProcessStrategy,
ComparisonStatus,
ComparisonResult,
} from '@mbc-cqrs-serverless/import';
import { CommandService, DataModel, CommandInputModel } from '@mbc-cqrs-serverless/core';
// Define your entity model
interface ProductModel extends DataModel {
code: string;
name: string;
price: number;
}
@Injectable()
export class ProductProcessStrategy implements IProcessStrategy<ProductModel, ProductDto> {
constructor(
private readonly productService: ProductService,
private readonly commandService: CommandService,
) {}
async compare(dto: ProductDto, tenantCode: string): Promise<ComparisonResult<ProductModel>> {
const existing = await this.productService.findByCode(dto.code, tenantCode);
if (!existing) {
return { status: ComparisonStatus.NOT_EXIST };
}
if (this.hasChanges(existing, dto)) {
return { status: ComparisonStatus.CHANGED, existingData: existing };
}
return { status: ComparisonStatus.EQUAL };
}
async map(
status: ComparisonStatus.NOT_EXIST | ComparisonStatus.CHANGED,
dto: ProductDto,
tenantCode: string,
existingData?: ProductModel,
): Promise<CommandInputModel> {
return {
pk: `PRODUCT#${tenantCode}`,
sk: `PRODUCT#${dto.code}`,
code: dto.code,
name: dto.name,
attributes: { price: dto.price },
};
}
getCommandService(): CommandService {
return this.commandService;
}
}
The import module uses a two-phase architecture:
┌─────────────────────────────────────────────────────────────────┐
│ Import Architecture │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Phase 1: Ingestion │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ REST API / │────▶│ ImportStrategy│────▶│ Temp Table │ │
│ │ CSV / ZIP │ │ transform() │ │ (CREATED) │ │
│ └──────────────┘ │ validate() │ └──────────────┘ │
│ └──────────────┘ │ │
│ ▼ DynamoDB │
│ Phase 2: Processing │ Streams │
│ ┌──────────────┐ ┌──────────────┐ ┌─────┴────────┐ │
│ │ ProcessStrategy│◀───│ SNS/SQS │◀────│ Lambda │ │
│ │ compare() │ │ Event │ │ Trigger │ │
│ │ map() │ └──────────────┘ └──────────────┘ │
│ └──────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ CommandService│────▶│ Final Table │ │
│ │ publish() │ │ (Data Store) │ │
│ └──────────────┘ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
| Method | Description |
|---|---|
createWithApi(dto, options) |
Import single record from REST API |
handleCsvImport(dto, options) |
Import from CSV file (DIRECT or STEP_FUNCTION) |
createCsvJob(dto, options) |
Create CSV import job for Step Functions |
createZipJob(dto, options) |
Create ZIP import job for Step Functions |
createImport(dto, options) |
Create import record in temp table |
updateStatus(key, status, payload?, attributes?, notifyId?) |
Update import status |
getImportByKey(key) |
Get import record by key |
incrementParentJobCounters(parentKey, childSucceeded) |
Update parent job progress |
interface IImportStrategy<TInput extends object, TAttributesDto extends object> {
transform(input: TInput): Promise<TAttributesDto>;
validate(data: TAttributesDto): Promise<void>;
}
interface IProcessStrategy<TEntity extends DataModel, TAttributesDto extends object> {
compare(importAttributes: TAttributesDto, tenantCode: string): Promise<ComparisonResult<TEntity>>;
map(status: ComparisonStatus, importAttributes: TAttributesDto, tenantCode: string, existingData?: TEntity): Promise<CommandInputModel | CommandPartialInputModel>;
getCommandService(): CommandService;
}
interface ComparisonResult<TEntity> {
status: ComparisonStatus;
existingData?: TEntity; // Provided when status is CHANGED
}
enum ComparisonStatus {
NOT_EXIST = 'NOT_EXIST',
CHANGED = 'CHANGED',
EQUAL = 'EQUAL',
}
| Status | Description |
|---|---|
CREATED |
Import record created |
PROCESSING |
Being processed |
COMPLETED |
Successfully completed |
FAILED |
Processing failed |
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.
| Import Status | Action | Step Functions Command |
|---|---|---|
COMPLETED |
Send success callback | SendTaskSuccessCommand |
FAILED |
Send failure callback | SendTaskFailureCommand |
| Other statuses | Ignored | None |
| Method | Description |
|---|---|
sendTaskSuccess(taskToken, output) |
Sends success signal to Step Functions with the import result |
sendTaskFailure(taskToken, error, cause) |
Sends failure signal to Step Functions with error details |
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:
taskToken exists in the job's attributesCOMPLETED → SendTaskSuccessCommand with result dataFAILED → SendTaskFailureCommand with error detailsThis ensures Step Functions workflows properly handle both success and failure cases without hanging indefinitely.
@Controller('import')
export class ImportController {
constructor(private readonly importService: ImportService) {}
@Post('product')
async importProduct(
@Body() dto: ImportProductDto,
@InvokeContext() ctx: IInvoke,
) {
return this.importService.createWithApi(
{
tableName: 'product',
tenantCode: dto.tenantCode,
attributes: dto,
},
{ invokeContext: ctx },
);
}
}
Process small CSV files immediately:
async importSmallCsv(bucket: string, key: string, opts: { invokeContext: IInvoke }) {
return this.importService.handleCsvImport(
{
tenantCode: 'MBC',
tableName: 'product',
bucket,
key,
processingMode: 'DIRECT',
},
opts,
);
}
Process large CSV files with Step Functions orchestration:
async importLargeCsv(bucket: string, key: string, opts: { invokeContext: IInvoke }) {
return this.importService.handleCsvImport(
{
tenantCode: 'MBC',
tableName: 'product',
bucket,
key,
processingMode: 'STEP_FUNCTION',
},
opts,
);
}
Import multiple CSV files from a ZIP archive:
async importZip(bucket: string, key: string, opts: { invokeContext: IInvoke }) {
return this.importService.createZipJob(
{
tenantCode: 'MBC',
bucket,
key,
},
opts,
);
}
async checkStatus(pk: string, sk: string) {
const importJob = await this.importService.getImportByKey({ pk, sk });
return {
status: importJob.status,
totalRows: importJob.totalRows,
processedRows: importJob.processedRows,
succeededRows: importJob.succeededRows,
failedRows: importJob.failedRows,
};
}
| Mode | Use Case | Processing |
|---|---|---|
DIRECT |
Small files (< 1000 rows) | Immediate, synchronous |
STEP_FUNCTION |
Large files, mission-critical | Async, resilient, tracked |
| Package | Description |
|---|---|
| @mbc-cqrs-serverless/core | Core CQRS framework |
| @mbc-cqrs-serverless/task | Task processing for async jobs |
Full documentation available at https://mbc-cqrs-serverless.mbc-net.com/
Copyright © 2024-2025, Murakami Business Consulting, Inc. https://www.mbc-net.com/
This project is under the MIT License.
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.