@bytebrand/export-cars 1.26.8 → 1.26.9
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/transformers/fb.transformer.js +2 -2
- package/dist/transformers/fb.transformer.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/converter.utils.d.ts +1 -1
- package/dist/utils/converter.utils.js +8 -8
- package/dist/utils/converter.utils.js.map +1 -1
- package/package.json +1 -1
- package/src/transformers/fb.transformer.ts +6 -3
- package/src/utils/converter.utils.ts +13 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function convertToCSV(data: unknown): string;
|
|
2
2
|
export declare const xmlStringReplacer: (str: string) => string;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function normalizeFeedText(text: string): string;
|
|
4
4
|
export declare function parseCsvToObjects<T>(csv: string): T[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCsvToObjects = exports.
|
|
3
|
+
exports.parseCsvToObjects = exports.normalizeFeedText = exports.xmlStringReplacer = exports.convertToCSV = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
function convertToCSV(data) {
|
|
6
6
|
const converted = [];
|
|
@@ -16,16 +16,16 @@ const xmlStringReplacer = (str) => {
|
|
|
16
16
|
return typeof str === 'string' ? str.replace(/&/g, '&').replace(/[<>]/g, '') : '';
|
|
17
17
|
};
|
|
18
18
|
exports.xmlStringReplacer = xmlStringReplacer;
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
function
|
|
22
|
-
return (
|
|
23
|
-
.replace(
|
|
19
|
+
const DISALLOWED_TEXT_CHARS = /[^\p{L}\p{N} .,\-/()%"°]/gu;
|
|
20
|
+
const EDGE_SEPARATORS = /^[\s.,\-/]+|[\s.,\-/]+$/g;
|
|
21
|
+
function normalizeFeedText(text) {
|
|
22
|
+
return (text || '')
|
|
23
|
+
.replace(DISALLOWED_TEXT_CHARS, ' ')
|
|
24
24
|
.replace(/([.,\-/])\1+/g, '$1')
|
|
25
25
|
.replace(/\s+/g, ' ')
|
|
26
|
-
.replace(
|
|
26
|
+
.replace(EDGE_SEPARATORS, '');
|
|
27
27
|
}
|
|
28
|
-
exports.
|
|
28
|
+
exports.normalizeFeedText = normalizeFeedText;
|
|
29
29
|
function parseCsvToObjects(csv) {
|
|
30
30
|
const rows = [];
|
|
31
31
|
let row = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.utils.js","sourceRoot":"","sources":["../../src/utils/converter.utils.ts"],"names":[],"mappings":";;;AAAA,mCAA6B;AAE7B,SAAgB,YAAY,CAAC,IAAa;IACxC,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QAC/B,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAa,CAAC;QAC7B,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;QAChE,IAAA,YAAG,EAAC,SAAS,EAAE,CAAC,EAAE,IAAI,QAAQ,GAAG,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AARD,oCAQC;AAEM,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAU,EAAE;IACvD,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACxF,CAAC,CAAC;AA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AE;QAC9B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAChB;IAED,MAAM,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACnF,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,EAAE,CAAC;KACX;IAED,OAAO,QAAQ,CAAC,GAAG,CACjB,OAAO,CAAC,EAAE,CACR,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QAC9B,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9C,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAA4B,CAAM,CACxC,CAAC;AACJ,CAAC;AAhDD,8CAgDC"}
|
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ import { Description } from '../interfaces/description.interface';
|
|
|
28
28
|
import { FbDescription } from './fb-description.transformer';
|
|
29
29
|
import { ConfigService, ImagesService, MappingService } from '../services';
|
|
30
30
|
import { FbEquipment } from './fb-equipment.transformer';
|
|
31
|
-
import { isValidVin,
|
|
31
|
+
import { isValidVin, normalizeFeedText } from '../utils';
|
|
32
32
|
import { UserService } from 'src/services';
|
|
33
33
|
import { ImageType } from '../enums';
|
|
34
34
|
import {
|
|
@@ -195,11 +195,14 @@ export class FbTransformer {
|
|
|
195
195
|
const subModel = toString(get(car, 'mainData.subModel', ''));
|
|
196
196
|
// No escape() here: FbXmlBuilder writes <title> inside CDATA, so HTML entities are not
|
|
197
197
|
// decoded by the consumer and leak literally ("Monte Carlo & KESSY").
|
|
198
|
-
return
|
|
198
|
+
return normalizeFeedText(join([year, make, model, subModel], ' '));
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
private getTrim(car: DataSchemes.Car): string {
|
|
202
|
-
|
|
202
|
+
// Same subModel source as the title, so it needs the same cleanup. Normalise before
|
|
203
|
+
// truncating: on the raw string the cut could land mid-junk, and lodash's "..." omission
|
|
204
|
+
// marker would then be collapsed by the repeated-separator rule.
|
|
205
|
+
const trim = normalizeFeedText(toString(get(car, 'mainData.subModel', '')));
|
|
203
206
|
return truncate(trim, { length: FB_MAX_TRIM_LENGTH, separator: ' ' });
|
|
204
207
|
}
|
|
205
208
|
|
|
@@ -15,20 +15,22 @@ export const xmlStringReplacer = (str: string): string => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
// Dealer-supplied subModel strings are full of decorative punctuation ("*AHK*Leder*Navi*",
|
|
18
|
-
// "|ACC|PANO/AHK", "#PANO #NAVI #SONY #") which must not reach Meta. Keep
|
|
19
|
-
// the punctuation that carries meaning in German trim names — "." "," "-"
|
|
20
|
-
// "°" (360° Kamera)
|
|
21
|
-
//
|
|
22
|
-
const
|
|
23
|
-
// Leading/trailing separators only; '"' and "%" are legitimate
|
|
24
|
-
const
|
|
18
|
+
// "|ACC|PANO/AHK", "#PANO #NAVI #SONY #", "Head-Up+B&O+ACC") which must not reach Meta. Keep
|
|
19
|
+
// letters, digits and the punctuation that carries meaning in German trim names — "." "," "-"
|
|
20
|
+
// "/" "(" ")" "%", "°" (360° Kamera) and '"' (Zoll). Everything else, "&" included, becomes a
|
|
21
|
+
// space rather than being deleted, so neighbouring words never fuse ("B&O" -> "B O").
|
|
22
|
+
const DISALLOWED_TEXT_CHARS = /[^\p{L}\p{N} .,\-/()%"°]/gu;
|
|
23
|
+
// Leading/trailing separators only; '"' and "%" are legitimate endings (`LM18"`, `-35%`).
|
|
24
|
+
const EDGE_SEPARATORS = /^[\s.,\-/]+|[\s.,\-/]+$/g;
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
// Applies to the free-text feed fields only (title, trim). URLs, dealer_email and dealer_phone
|
|
27
|
+
// carry "/" ":" "@" "+" as load-bearing characters and must never be run through this.
|
|
28
|
+
export function normalizeFeedText(text: string): string {
|
|
29
|
+
return (text || '')
|
|
30
|
+
.replace(DISALLOWED_TEXT_CHARS, ' ')
|
|
29
31
|
.replace(/([.,\-/])\1+/g, '$1') // "L4H2 //Klimaanlage" -> "L4H2 /Klimaanlage"
|
|
30
32
|
.replace(/\s+/g, ' ')
|
|
31
|
-
.replace(
|
|
33
|
+
.replace(EDGE_SEPARATORS, '');
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
// Parses a "Publish to web" Google Sheets CSV export (RFC4180-ish, quoted fields may
|