@constructor-io/catalog-ingestor
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -1,2 +0,2 @@ | ||
import { type CatalogIngestionType, type CatalogIngestionPayload } from "../catalog-ingestor/types"; | ||
import { type CatalogIngestionType, type CatalogIngestionPayload, type EntityType } from "../catalog-ingestor/types"; | ||
import { type FileHelper } from "../utils/file-helper"; | ||
@@ -19,3 +19,3 @@ import { type CsvPayload } from "../ingest-catalog-csv/ingest-catalog-csv"; | ||
*/ | ||
export declare function buildCsvRow<T = TObject>(columns: string[], header: boolean, object: T): string; | ||
export declare function buildCsvRow<T = TObject>(columns: string[], header: boolean, object: T, instance: CatalogIngestor<any>, type: EntityType): string; | ||
type TObject = Record<PropertyKey, unknown>; | ||
@@ -22,0 +22,0 @@ interface Args { |
@@ -77,3 +77,2 @@ "use strict"; | ||
var logger_1 = require("../utils/logger"); | ||
var is_json_metadata_1 = require("./is-json-metadata"); | ||
var NEW_LINE_TOKEN = "\r\n"; | ||
@@ -173,3 +172,3 @@ /** | ||
: object; | ||
csvRow = buildCsvRow(columns, first, parsedObject); | ||
csvRow = buildCsvRow(columns, first, parsedObject, instance, type); | ||
if (!first) { | ||
@@ -216,4 +215,4 @@ csvRow = "".concat(NEW_LINE_TOKEN).concat(csvRow); | ||
*/ | ||
function buildCsvRow(columns, header, object) { | ||
var proxyObject = toCsvProxyObject(object); | ||
function buildCsvRow(columns, header, object, instance, type) { | ||
var proxyObject = toCsvProxyObject(object, instance, type); | ||
var csv = papaparse_1.default.unparse([proxyObject], { | ||
@@ -232,3 +231,3 @@ newline: "\n", | ||
*/ | ||
function toCsvProxyObject(object) { | ||
function toCsvProxyObject(object, instance, type) { | ||
var result = R.reduce(R.keys(object), function (acc, key) { | ||
@@ -246,3 +245,3 @@ var value = object[key]; | ||
return acc; | ||
return expandNestedArray(acc, key, value); | ||
return expandNestedArray(acc, key, value, instance, type); | ||
} | ||
@@ -276,6 +275,7 @@ /** | ||
*/ | ||
function expandNestedArray(acc, key, pairs) { | ||
function expandNestedArray(acc, key, pairs, instance, type) { | ||
var result = R.reduce(pairs, function (acc, pair) { | ||
// JSON metadata should be prefixed with "json:" | ||
if ((0, is_json_metadata_1.isJSONMetadata)(pair, key)) { | ||
var isJson = instance.columns[type].metadataJSON.has(pair.key); | ||
if (isJson) { | ||
acc[getNestedFieldTransformedName(key, "json:".concat(pair.key))] = | ||
@@ -282,0 +282,0 @@ JSON.stringify(pair.value); |
{ | ||
"name": "@constructor-io/catalog-ingestor", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Package to help ingesting catalog data into Constructor.io ☕️", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
94987