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
+91
View File
@@ -0,0 +1,91 @@
const BaseXform = require('../base-xform');
const colCache = require('../../../utils/col-cache');
class DefinedNamesXform extends BaseXform {
render(xmlStream, model) {
// <definedNames>
// <definedName name="name">name.ranges.join(',')</definedName>
// <definedName name="_xlnm.Print_Area" localSheetId="0">name.ranges.join(',')</definedName>
// </definedNames>
xmlStream.openNode('definedName', {
name: model.name,
localSheetId: model.localSheetId,
});
xmlStream.writeText(model.ranges.join(','));
xmlStream.closeNode();
}
parseOpen(node) {
switch (node.name) {
case 'definedName':
this._parsedName = node.attributes.name;
this._parsedLocalSheetId = node.attributes.localSheetId;
this._parsedText = [];
return true;
default:
return false;
}
}
parseText(text) {
this._parsedText.push(text);
}
parseClose() {
this.model = {
name: this._parsedName,
ranges: extractRanges(this._parsedText.join('')),
};
if (this._parsedLocalSheetId !== undefined) {
this.model.localSheetId = parseInt(this._parsedLocalSheetId, 10);
}
return false;
}
}
function isValidRange(range) {
try {
colCache.decodeEx(range);
return true;
} catch (err) {
return false;
}
}
function extractRanges(parsedText) {
const ranges = [];
let quotesOpened = false;
let last = '';
parsedText.split(',').forEach(item => {
if (!item) {
return;
}
const quotes = (item.match(/'/g) || []).length;
if (!quotes) {
if (quotesOpened) {
last += `${item},`;
} else if (isValidRange(item)) {
ranges.push(item);
}
return;
}
const quotesEven = quotes % 2 === 0;
if (!quotesOpened && quotesEven && isValidRange(item)) {
ranges.push(item);
} else if (quotesOpened && !quotesEven) {
quotesOpened = false;
if (isValidRange(last + item)) {
ranges.push(last + item);
}
last = '';
} else {
quotesOpened = true;
last += `${item},`;
}
});
return ranges;
}
module.exports = DefinedNamesXform;
+34
View File
@@ -0,0 +1,34 @@
const utils = require('../../../utils/utils');
const BaseXform = require('../base-xform');
class WorksheetXform extends BaseXform {
render(xmlStream, model) {
xmlStream.leafNode('sheet', {
sheetId: model.id,
name: model.name,
state: model.state,
'r:id': model.rId,
});
}
parseOpen(node) {
if (node.name === 'sheet') {
this.model = {
name: utils.xmlDecode(node.attributes.name),
id: parseInt(node.attributes.sheetId, 10),
state: node.attributes.state,
rId: node.attributes['r:id'],
};
return true;
}
return false;
}
parseText() {}
parseClose() {
return false;
}
}
module.exports = WorksheetXform;
@@ -0,0 +1,26 @@
const BaseXform = require('../base-xform');
class WorkbookCalcPropertiesXform extends BaseXform {
render(xmlStream, model) {
xmlStream.leafNode('calcPr', {
calcId: 171027,
fullCalcOnLoad: model.fullCalcOnLoad ? 1 : undefined,
});
}
parseOpen(node) {
if (node.name === 'calcPr') {
this.model = {};
return true;
}
return false;
}
parseText() {}
parseClose() {
return false;
}
}
module.exports = WorkbookCalcPropertiesXform;
+29
View File
@@ -0,0 +1,29 @@
const BaseXform = require('../base-xform');
class WorksheetPropertiesXform extends BaseXform {
render(xmlStream, model) {
xmlStream.leafNode('workbookPr', {
date1904: model.date1904 ? 1 : undefined,
defaultThemeVersion: 164011,
filterPrivacy: 1,
});
}
parseOpen(node) {
if (node.name === 'workbookPr') {
this.model = {
date1904: node.attributes.date1904 === '1',
};
return true;
}
return false;
}
parseText() {}
parseClose() {
return false;
}
}
module.exports = WorksheetPropertiesXform;
+53
View File
@@ -0,0 +1,53 @@
const BaseXform = require('../base-xform');
class WorkbookViewXform extends BaseXform {
render(xmlStream, model) {
const attributes = {
xWindow: model.x || 0,
yWindow: model.y || 0,
windowWidth: model.width || 12000,
windowHeight: model.height || 24000,
firstSheet: model.firstSheet,
activeTab: model.activeTab,
};
if (model.visibility && model.visibility !== 'visible') {
attributes.visibility = model.visibility;
}
xmlStream.leafNode('workbookView', attributes);
}
parseOpen(node) {
if (node.name === 'workbookView') {
const model = (this.model = {});
const addS = function(name, value, dflt) {
const s = value !== undefined ? (model[name] = value) : dflt;
if (s !== undefined) {
model[name] = s;
}
};
const addN = function(name, value, dflt) {
const n = value !== undefined ? (model[name] = parseInt(value, 10)) : dflt;
if (n !== undefined) {
model[name] = n;
}
};
addN('x', node.attributes.xWindow, 0);
addN('y', node.attributes.yWindow, 0);
addN('width', node.attributes.windowWidth, 25000);
addN('height', node.attributes.windowHeight, 10000);
addS('visibility', node.attributes.visibility, 'visible');
addN('activeTab', node.attributes.activeTab, undefined);
addN('firstSheet', node.attributes.firstSheet, undefined);
return true;
}
return false;
}
parseText() {}
parseClose() {
return false;
}
}
module.exports = WorkbookViewXform;
+255
View File
@@ -0,0 +1,255 @@
const _ = require('../../../utils/under-dash');
const colCache = require('../../../utils/col-cache');
const XmlStream = require('../../../utils/xml-stream');
const BaseXform = require('../base-xform');
const StaticXform = require('../static-xform');
const ListXform = require('../list-xform');
const DefinedNameXform = require('./defined-name-xform');
const SheetXform = require('./sheet-xform');
const WorkbookViewXform = require('./workbook-view-xform');
const WorkbookPropertiesXform = require('./workbook-properties-xform');
const WorkbookCalcPropertiesXform = require('./workbook-calc-properties-xform');
class WorkbookXform extends BaseXform {
constructor() {
super();
this.map = {
fileVersion: WorkbookXform.STATIC_XFORMS.fileVersion,
workbookPr: new WorkbookPropertiesXform(),
bookViews: new ListXform({
tag: 'bookViews',
count: false,
childXform: new WorkbookViewXform(),
}),
sheets: new ListXform({tag: 'sheets', count: false, childXform: new SheetXform()}),
definedNames: new ListXform({
tag: 'definedNames',
count: false,
childXform: new DefinedNameXform(),
}),
calcPr: new WorkbookCalcPropertiesXform(),
};
}
prepare(model) {
model.sheets = model.worksheets;
// collate all the print areas from all of the sheets and add them to the defined names
const printAreas = [];
let index = 0; // sheets is sparse array - calc index manually
model.sheets.forEach(sheet => {
if (sheet.pageSetup && sheet.pageSetup.printArea) {
sheet.pageSetup.printArea.split('&&').forEach(printArea => {
const printAreaComponents = printArea.split(':');
const definedName = {
name: '_xlnm.Print_Area',
ranges: [`'${sheet.name}'!$${printAreaComponents[0]}:$${printAreaComponents[1]}`],
localSheetId: index,
};
printAreas.push(definedName);
});
}
if (
sheet.pageSetup &&
(sheet.pageSetup.printTitlesRow || sheet.pageSetup.printTitlesColumn)
) {
const ranges = [];
if (sheet.pageSetup.printTitlesColumn) {
const titlesColumns = sheet.pageSetup.printTitlesColumn.split(':');
ranges.push(`'${sheet.name}'!$${titlesColumns[0]}:$${titlesColumns[1]}`);
}
if (sheet.pageSetup.printTitlesRow) {
const titlesRows = sheet.pageSetup.printTitlesRow.split(':');
ranges.push(`'${sheet.name}'!$${titlesRows[0]}:$${titlesRows[1]}`);
}
const definedName = {
name: '_xlnm.Print_Titles',
ranges,
localSheetId: index,
};
printAreas.push(definedName);
}
index++;
});
if (printAreas.length) {
model.definedNames = model.definedNames.concat(printAreas);
}
(model.media || []).forEach((medium, i) => {
// assign name
medium.name = medium.type + (i + 1);
});
}
render(xmlStream, model) {
xmlStream.openXml(XmlStream.StdDocAttributes);
xmlStream.openNode('workbook', WorkbookXform.WORKBOOK_ATTRIBUTES);
this.map.fileVersion.render(xmlStream);
this.map.workbookPr.render(xmlStream, model.properties);
this.map.bookViews.render(xmlStream, model.views);
this.map.sheets.render(xmlStream, model.sheets);
this.map.definedNames.render(xmlStream, model.definedNames);
this.map.calcPr.render(xmlStream, model.calcProperties);
xmlStream.closeNode();
}
parseOpen(node) {
if (this.parser) {
this.parser.parseOpen(node);
return true;
}
switch (node.name) {
case 'workbook':
return true;
default:
this.parser = this.map[node.name];
if (this.parser) {
this.parser.parseOpen(node);
}
return true;
}
}
parseText(text) {
if (this.parser) {
this.parser.parseText(text);
}
}
parseClose(name) {
if (this.parser) {
if (!this.parser.parseClose(name)) {
this.parser = undefined;
}
return true;
}
switch (name) {
case 'workbook':
this.model = {
sheets: this.map.sheets.model,
properties: this.map.workbookPr.model || {},
views: this.map.bookViews.model,
calcProperties: {},
};
if (this.map.definedNames.model) {
this.model.definedNames = this.map.definedNames.model;
}
return false;
default:
// not quite sure how we get here!
return true;
}
}
reconcile(model) {
const rels = (model.workbookRels || []).reduce((map, rel) => {
map[rel.Id] = rel;
return map;
}, {});
// reconcile sheet ids, rIds and names
const worksheets = [];
let worksheet;
let index = 0;
(model.sheets || []).forEach(sheet => {
const rel = rels[sheet.rId];
if (!rel) {
return;
}
// if rel.Target start with `[space]/xl/` or `/xl/` , then it will be replaced with `''` and spliced behind `xl/`,
// otherwise it will be spliced directly behind `xl/`. i.g.
worksheet = model.worksheetHash[`xl/${rel.Target.replace(/^(\s|\/xl\/)+/, '')}`];
// If there are "chartsheets" in the file, rel.Target will
// come out as chartsheets/sheet1.xml or similar here, and
// that won't be in model.worksheetHash.
// As we don't have the infrastructure to support chartsheets,
// we will ignore them for now:
if (worksheet) {
worksheet.name = sheet.name;
worksheet.id = sheet.id;
worksheet.state = sheet.state;
worksheets[index++] = worksheet;
}
});
// reconcile print areas
const definedNames = [];
_.each(model.definedNames, definedName => {
if (definedName.name === '_xlnm.Print_Area') {
worksheet = worksheets[definedName.localSheetId];
if (worksheet) {
if (!worksheet.pageSetup) {
worksheet.pageSetup = {};
}
const range = colCache.decodeEx(definedName.ranges[0]);
worksheet.pageSetup.printArea = worksheet.pageSetup.printArea
? `${worksheet.pageSetup.printArea}&&${range.dimensions}`
: range.dimensions;
}
} else if (definedName.name === '_xlnm.Print_Titles') {
worksheet = worksheets[definedName.localSheetId];
if (worksheet) {
if (!worksheet.pageSetup) {
worksheet.pageSetup = {};
}
const rangeString = definedName.ranges.join(',');
const dollarRegex = /\$/g;
const rowRangeRegex = /\$\d+:\$\d+/;
const rowRangeMatches = rangeString.match(rowRangeRegex);
if (rowRangeMatches && rowRangeMatches.length) {
const range = rowRangeMatches[0];
worksheet.pageSetup.printTitlesRow = range.replace(dollarRegex, '');
}
const columnRangeRegex = /\$[A-Z]+:\$[A-Z]+/;
const columnRangeMatches = rangeString.match(columnRangeRegex);
if (columnRangeMatches && columnRangeMatches.length) {
const range = columnRangeMatches[0];
worksheet.pageSetup.printTitlesColumn = range.replace(dollarRegex, '');
}
}
} else {
definedNames.push(definedName);
}
});
model.definedNames = definedNames;
// used by sheets to build their image models
model.media.forEach((media, i) => {
media.index = i;
});
}
}
WorkbookXform.WORKBOOK_ATTRIBUTES = {
xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
'mc:Ignorable': 'x15',
'xmlns:x15': 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main',
};
WorkbookXform.STATIC_XFORMS = {
fileVersion: new StaticXform({
tag: 'fileVersion',
$: {appName: 'xl', lastEdited: 5, lowestEdited: 5, rupBuild: 9303},
}),
};
module.exports = WorkbookXform;