@vendure/core
Version:
A modern, headless ecommerce framework
130 lines (129 loc) • 3.54 kB
TypeScript
import { GlobalFlag, LanguageCode } from '@vendure/common/lib/generated-types';
import { Stream } from 'stream';
import { ConfigService } from '../../../config/config.service';
/**
* @description
* The intermediate representation of an OptionGroup after it has been parsed
* by the {@link ImportParser}.
*
* @docsCategory import-export
* @docsPage ImportParser
*/
export interface ParsedOptionGroup {
translations: Array<{
languageCode: LanguageCode;
name: string;
values: string[];
}>;
}
/**
* @description
* The intermediate representation of a Facet after it has been parsed
* by the {@link ImportParser}.
*
* @docsCategory import-export
* @docsPage ImportParser
*/
export interface ParsedFacet {
translations: Array<{
languageCode: LanguageCode;
facet: string;
value: string;
}>;
}
/**
* @description
* The intermediate representation of a ProductVariant after it has been parsed
* by the {@link ImportParser}.
*
* @docsCategory import-export
* @docsPage ImportParser
*/
export interface ParsedProductVariant {
sku: string;
price: number;
taxCategory: string;
stockOnHand: number;
trackInventory: GlobalFlag;
assetPaths: string[];
facets: ParsedFacet[];
translations: Array<{
languageCode: LanguageCode;
optionValues: string[];
customFields: {
[name: string]: string;
};
}>;
}
/**
* @description
* The intermediate representation of a Product after it has been parsed
* by the {@link ImportParser}.
*
* @docsCategory import-export
* @docsPage ImportParser
*/
export interface ParsedProduct {
assetPaths: string[];
optionGroups: ParsedOptionGroup[];
facets: ParsedFacet[];
translations: Array<{
languageCode: LanguageCode;
name: string;
slug: string;
description: string;
customFields: {
[name: string]: string;
};
}>;
}
/**
* @description
* The data structure into which an import CSV file is parsed by the
* {@link ImportParser} `parseProducts()` method.
*
* @docsCategory import-export
* @docsPage ImportParser
*/
export interface ParsedProductWithVariants {
product: ParsedProduct;
variants: ParsedProductVariant[];
}
/**
* @description
* The result returned by the {@link ImportParser} `parseProducts()` method.
*
* @docsCategory import-export
* @docsPage ImportParser
*/
export interface ParseResult<T> {
results: T[];
errors: string[];
processed: number;
}
/**
* @description
* Validates and parses CSV files into a data structure which can then be used to created new entities.
* This is used internally by the {@link Importer}.
*
* @docsCategory import-export
* @docsPage ImportParser
* @docsWeight 0
*/
export declare class ImportParser {
private configService;
/** @internal */
constructor(configService: ConfigService);
/**
* @description
* Parses the contents of the [product import CSV file](/guides/developer-guide/importing-data/#product-import-format) and
* returns a data structure which can then be used to populate Vendure using the {@link FastImporterService}.
*/
parseProducts(input: string | Stream, mainLanguage?: LanguageCode): Promise<ParseResult<ParsedProductWithVariants>>;
private processRawRecords;
private validateCustomFields;
private isTranslatable;
private validateHeaderTranslations;
private parseProductFromRecord;
private parseVariantFromRecord;
}