first commit
SAP-ERP Portal CI/CD / build (push) Failing after 5m20s

This commit is contained in:
John
2026-09-23 17:31:02 +05:30
commit 69b4e68baf
51657 changed files with 3864077 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
import { FormatterOptions } from '../FormatterOptions';
import { Row } from '../types';
export declare class FieldFormatter<I extends Row, O extends Row> {
private readonly formatterOptions;
private _headers;
private readonly REPLACE_REGEXP;
private readonly ESCAPE_REGEXP;
constructor(formatterOptions: FormatterOptions<I, O>);
set headers(headers: string[]);
private shouldQuote;
format(field: string, fieldIndex: number, isHeader: boolean): string;
private quoteField;
}
+58
View File
@@ -0,0 +1,58 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldFormatter = void 0;
const lodash_isboolean_1 = __importDefault(require("lodash.isboolean"));
const lodash_isnil_1 = __importDefault(require("lodash.isnil"));
const lodash_escaperegexp_1 = __importDefault(require("lodash.escaperegexp"));
class FieldFormatter {
constructor(formatterOptions) {
this._headers = null;
this.formatterOptions = formatterOptions;
if (formatterOptions.headers !== null) {
this.headers = formatterOptions.headers;
}
this.REPLACE_REGEXP = new RegExp(formatterOptions.quote, 'g');
const escapePattern = `[${formatterOptions.delimiter}${lodash_escaperegexp_1.default(formatterOptions.rowDelimiter)}|\r|\n]`;
this.ESCAPE_REGEXP = new RegExp(escapePattern);
}
set headers(headers) {
this._headers = headers;
}
shouldQuote(fieldIndex, isHeader) {
const quoteConfig = isHeader ? this.formatterOptions.quoteHeaders : this.formatterOptions.quoteColumns;
if (lodash_isboolean_1.default(quoteConfig)) {
return quoteConfig;
}
if (Array.isArray(quoteConfig)) {
return quoteConfig[fieldIndex];
}
if (this._headers !== null) {
return quoteConfig[this._headers[fieldIndex]];
}
return false;
}
format(field, fieldIndex, isHeader) {
const preparedField = `${lodash_isnil_1.default(field) ? '' : field}`.replace(/\0/g, '');
const { formatterOptions } = this;
if (formatterOptions.quote !== '') {
const shouldEscape = preparedField.indexOf(formatterOptions.quote) !== -1;
if (shouldEscape) {
return this.quoteField(preparedField.replace(this.REPLACE_REGEXP, formatterOptions.escapedQuote));
}
}
const hasEscapeCharacters = preparedField.search(this.ESCAPE_REGEXP) !== -1;
if (hasEscapeCharacters || this.shouldQuote(fieldIndex, isHeader)) {
return this.quoteField(preparedField);
}
return preparedField;
}
quoteField(field) {
const { quote } = this.formatterOptions;
return `${quote}${field}${quote}`;
}
}
exports.FieldFormatter = FieldFormatter;
//# sourceMappingURL=FieldFormatter.js.map
@@ -0,0 +1 @@
{"version":3,"file":"FieldFormatter.js","sourceRoot":"","sources":["../../../src/formatter/FieldFormatter.ts"],"names":[],"mappings":";;;;;;AAAA,wEAAyC;AACzC,gEAAiC;AACjC,8EAA+C;AAI/C,MAAa,cAAc;IASvB,YAAmB,gBAAwC;QANnD,aAAQ,GAAoB,IAAI,CAAC;QAOrC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,gBAAgB,CAAC,OAAO,KAAK,IAAI,EAAE;YACnC,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;SAC3C;QACD,IAAI,CAAC,cAAc,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9D,MAAM,aAAa,GAAG,IAAI,gBAAgB,CAAC,SAAS,GAAG,6BAAY,CAAC,gBAAgB,CAAC,YAAY,CAAC,SAAS,CAAC;QAC5G,IAAI,CAAC,aAAa,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC;IAED,IAAW,OAAO,CAAC,OAAiB;QAChC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAEO,WAAW,CAAC,UAAkB,EAAE,QAAiB;QACrD,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC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AAC;IAEO,UAAU,CAAC,KAAa;QAC5B,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACxC,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC;IACtC,CAAC;CACJ;AAzDD,wCAyDC"}
+25
View File
@@ -0,0 +1,25 @@
import { FormatterOptions } from '../FormatterOptions';
import { Row, RowArray, RowTransformFunction } from '../types';
declare type RowFormatterCallback = (error: Error | null, data?: RowArray) => void;
export declare class RowFormatter<I extends Row, O extends Row> {
private static isRowHashArray;
private static isRowArray;
private static gatherHeaders;
private static createTransform;
private readonly formatterOptions;
private readonly fieldFormatter;
private readonly shouldWriteHeaders;
private _rowTransform?;
private headers;
private hasWrittenHeaders;
private rowCount;
constructor(formatterOptions: FormatterOptions<I, O>);
set rowTransform(transformFunction: RowTransformFunction<I, O>);
format(row: I, cb: RowFormatterCallback): void;
finish(cb: RowFormatterCallback): void;
private checkHeaders;
private gatherColumns;
private callTransformer;
private formatColumns;
}
export {};
+168
View File
@@ -0,0 +1,168 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RowFormatter = void 0;
const lodash_isfunction_1 = __importDefault(require("lodash.isfunction"));
const lodash_isequal_1 = __importDefault(require("lodash.isequal"));
const FieldFormatter_1 = require("./FieldFormatter");
const types_1 = require("../types");
class RowFormatter {
constructor(formatterOptions) {
this.rowCount = 0;
this.formatterOptions = formatterOptions;
this.fieldFormatter = new FieldFormatter_1.FieldFormatter(formatterOptions);
this.headers = formatterOptions.headers;
this.shouldWriteHeaders = formatterOptions.shouldWriteHeaders;
this.hasWrittenHeaders = false;
if (this.headers !== null) {
this.fieldFormatter.headers = this.headers;
}
if (formatterOptions.transform) {
this.rowTransform = formatterOptions.transform;
}
}
static isRowHashArray(row) {
if (Array.isArray(row)) {
return Array.isArray(row[0]) && row[0].length === 2;
}
return false;
}
static isRowArray(row) {
return Array.isArray(row) && !this.isRowHashArray(row);
}
// get headers from a row item
static gatherHeaders(row) {
if (RowFormatter.isRowHashArray(row)) {
// lets assume a multi-dimesional array with item 0 being the header
return row.map((it) => it[0]);
}
if (Array.isArray(row)) {
return row;
}
return Object.keys(row);
}
// eslint-disable-next-line @typescript-eslint/no-shadow
static createTransform(transformFunction) {
if (types_1.isSyncTransform(transformFunction)) {
return (row, cb) => {
let transformedRow = null;
try {
transformedRow = transformFunction(row);
}
catch (e) {
return cb(e);
}
return cb(null, transformedRow);
};
}
return (row, cb) => {
transformFunction(row, cb);
};
}
set rowTransform(transformFunction) {
if (!lodash_isfunction_1.default(transformFunction)) {
throw new TypeError('The transform should be a function');
}
this._rowTransform = RowFormatter.createTransform(transformFunction);
}
format(row, cb) {
this.callTransformer(row, (err, transformedRow) => {
if (err) {
return cb(err);
}
if (!row) {
return cb(null);
}
const rows = [];
if (transformedRow) {
const { shouldFormatColumns, headers } = this.checkHeaders(transformedRow);
if (this.shouldWriteHeaders && headers && !this.hasWrittenHeaders) {
rows.push(this.formatColumns(headers, true));
this.hasWrittenHeaders = true;
}
if (shouldFormatColumns) {
const columns = this.gatherColumns(transformedRow);
rows.push(this.formatColumns(columns, false));
}
}
return cb(null, rows);
});
}
finish(cb) {
const rows = [];
// check if we should write headers and we didnt get any rows
if (this.formatterOptions.alwaysWriteHeaders && this.rowCount === 0) {
if (!this.headers) {
return cb(new Error('`alwaysWriteHeaders` option is set to true but `headers` option not provided.'));
}
rows.push(this.formatColumns(this.headers, true));
}
if (this.formatterOptions.includeEndRowDelimiter) {
rows.push(this.formatterOptions.rowDelimiter);
}
return cb(null, rows);
}
// check if we need to write header return true if we should also write a row
// could be false if headers is true and the header row(first item) is passed in
checkHeaders(row) {
if (this.headers) {
// either the headers were provided by the user or we have already gathered them.
return { shouldFormatColumns: true, headers: this.headers };
}
const headers = RowFormatter.gatherHeaders(row);
this.headers = headers;
this.fieldFormatter.headers = headers;
if (!this.shouldWriteHeaders) {
// if we are not supposed to write the headers then
// always format the columns
return { shouldFormatColumns: true, headers: null };
}
// if the row is equal to headers dont format
return { shouldFormatColumns: !lodash_isequal_1.default(headers, row), headers };
}
// todo change this method to unknown[]
gatherColumns(row) {
if (this.headers === null) {
throw new Error('Headers is currently null');
}
if (!Array.isArray(row)) {
return this.headers.map((header) => row[header]);
}
if (RowFormatter.isRowHashArray(row)) {
return this.headers.map((header, i) => {
const col = row[i];
if (col) {
return col[1];
}
return '';
});
}
// if its a one dimensional array and headers were not provided
// then just return the row
if (RowFormatter.isRowArray(row) && !this.shouldWriteHeaders) {
return row;
}
return this.headers.map((header, i) => row[i]);
}
callTransformer(row, cb) {
if (!this._rowTransform) {
return cb(null, row);
}
return this._rowTransform(row, cb);
}
formatColumns(columns, isHeadersRow) {
const formattedCols = columns
.map((field, i) => this.fieldFormatter.format(field, i, isHeadersRow))
.join(this.formatterOptions.delimiter);
const { rowCount } = this;
this.rowCount += 1;
if (rowCount) {
return [this.formatterOptions.rowDelimiter, formattedCols].join('');
}
return formattedCols;
}
}
exports.RowFormatter = RowFormatter;
//# sourceMappingURL=RowFormatter.js.map
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
export { RowFormatter } from './RowFormatter';
export { FieldFormatter } from './FieldFormatter';
+8
View File
@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldFormatter = exports.RowFormatter = void 0;
var RowFormatter_1 = require("./RowFormatter");
Object.defineProperty(exports, "RowFormatter", { enumerable: true, get: function () { return RowFormatter_1.RowFormatter; } });
var FieldFormatter_1 = require("./FieldFormatter");
Object.defineProperty(exports, "FieldFormatter", { enumerable: true, get: function () { return FieldFormatter_1.FieldFormatter; } });
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA"}