@ingestro/importer-react 4.9.2 → 4.9.3
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/{chunk-QXD6LKS7.js → chunk-F2V7OQWG.js} +1 -1
- package/chunk-FRFILSYE.js +1 -0
- package/{chunk-WKADKRGH.js → chunk-FVCICCC3.js} +42 -42
- package/chunk-NPXJPUQJ.js +1 -0
- package/index.d.ts +35 -1
- package/index.js +606 -492
- package/package.json +1 -1
- package/workers/matchValues/index.js +1 -1
- package/workers/parseData/index.js +1 -1
- package/workers/searchAndReplace/index.js +1 -1
- package/chunk-JORVN4P2.js +0 -1
- package/chunk-WOBUOLP3.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as he,i as re,j as S,r as U}from"./chunk-FRFILSYE.js";import{G as Q,H as ee,I as k,K as te,L as J,M as K,b as pe,c as ce,d as y,k as fe,l as p,m as x,n as H,u as ge,v as Se,w as $,x as De}from"./chunk-FVCICCC3.js";import{b as D}from"./chunk-REPANPD5.js";import{isEmpty as ze,uniq as Xe}from"lodash";var Ce=0,oe=class{constructor({sheet:e,columnKey:t,rows:r,id:n,label:a,refJoinSheetColum:s,parserDateFormat:i}){this.removed=!1;this.label="";this.dateInputFormatSamples=null;this.parsedDateSamplesByInputFormat=new Map;this.getColumnKey=()=>this.columnKey;this.getId=()=>this.id;this.getSheet=()=>this.sheet;this.getRows=()=>this.rows;this.getUniqueRows=()=>(this.uniques===void 0&&(this.uniques=Xe(this.getRows())),this.uniques);this.remove=()=>{this.removed=!0};this.unRemove=()=>{this.removed=!1};this.isRemoved=()=>this.removed;this.getType=()=>0;this.getFileName=()=>this.sheet.getSheetFileName();this.toJSON=()=>({columnKey:this.columnKey,id:this.id,rows:this.rows,type:this.getType()});this.equal=e=>this.getId()===e.getId();this.keyEqual=e=>this.columnKey===e.columnKey;this.setIndex=e=>{this.index=e};this.getIndex=()=>this.index;this.normalizeInputFormatKey=e=>{let t=typeof e=="string"?e.trim():"";return t!==""?t:null};this.dateInputFormatCacheKey=e=>this.normalizeInputFormatKey(e)??"\0auto";this.needsDateFormatParse=e=>!this.parsedDateSamplesByInputFormat.has(this.dateInputFormatCacheKey(e));this.hasParsedDateForInputFormat=e=>!this.needsDateFormatParse(e);this.getParsedDateSamplesForInputFormat=e=>this.parsedDateSamplesByInputFormat.get(this.dateInputFormatCacheKey(e));this.getDateInputFormatSamples=()=>this.dateInputFormatSamples??this.rows;this.getParserDateFormat=()=>this.parserDateFormat;this.applyDateInputFormatParse=(e,t)=>{let r=this.getDateInputFormatSamples();if(e.length!==r.length)throw new Error(`SheetColumn.applyDateInputFormatParse: parsed sample count (${e.length}) must match source sample count (${r.length}) for column "${this.columnKey}".`);this.parsedDateSamplesByInputFormat.set(this.dateInputFormatCacheKey(t),e)};this.getRefJoinSheetColum=()=>this.refJoinSheetColum;this.columnKey=t.trim(),this.sheet=e,Object.defineProperty(this,"sheet",{value:e,enumerable:!1,writable:!0,configurable:!0}),this.rows=ze(r)?[""]:r,this.dateInputFormatSamples=[...this.rows],typeof n>"u"?(Ce++,this.id=`${t}-${Ce}`):this.id=n,a&&(this.label=a),i&&(this.parserDateFormat=i),Object.defineProperty(this,"refJoinSheetColum",{value:s,enumerable:!1,writable:!0,configurable:!0})}setRows(e){this.rows=e,this.uniques=void 0}},M=oe;var ae=class extends M{constructor({sheet:t,sheetColumns:r,rows:n,id:a,columnKey:s}){super({columnKey:s,rows:n,sheet:t,id:a});this.getType=()=>1;this.getJoinedSheetColumns=()=>this.sheetColumns;this.toJSON=()=>({columnKey:this.columnKey,id:this.id,rows:this.rows,sheetColumns:this.sheetColumns.map(t=>t.toJSON()),type:this.getType()});this.sheetColumns=r}},Fe=ae;var ye=["?",",","@"];import{isNaN as qe,minBy as Ge,isString as Ze,isEqual as Qe,isEmpty as we,isNil as et}from"lodash";var se=class{constructor({sheets:e,filename:t,type:r,fileSize:n}){this.globalNumberFormat="eu";this.columnsNumberFormat=[];this.needsConfiguration=!1;this.pendingXmlConfigKey=null;this.pendingXmlConfig=null;this.sourceXml=null;this.sourcePdfFile=null;this.pdfDocument=null;this.selectedPdfTableIds=null;this.keepSheetSelection=!1;this.addSheet=e=>{this.sheets.push(e)};this.setNeedsConfiguration=e=>{this.needsConfiguration=e};this.getNeedsConfiguration=()=>this.needsConfiguration;this.setPendingXmlConfigKey=e=>{this.pendingXmlConfigKey=e};this.getPendingXmlConfigKey=()=>this.pendingXmlConfigKey;this.setPendingXmlConfig=e=>{this.pendingXmlConfig=e};this.getPendingXmlConfig=()=>this.pendingXmlConfig;this.setSourceXml=e=>{this.sourceXml=e};this.getSourceXml=()=>this.sourceXml;this.setSourcePdfFile=e=>{this.sourcePdfFile=e};this.getSourcePdfFile=()=>this.sourcePdfFile;this.setPdfDocument=e=>{this.pdfDocument=e};this.getPdfDocument=()=>this.pdfDocument;this.setSelectedPdfTableIds=e=>{this.selectedPdfTableIds=e};this.getSelectedPdfTableIds=()=>this.selectedPdfTableIds;this.setKeepSheetSelection=e=>{this.keepSheetSelection=e};this.getKeepSheetSelection=()=>this.keepSheetSelection;this.replaceSheets=e=>{let t=this.needsConfiguration||!!this.pendingXmlConfigKey||!!this.pendingXmlConfig||!!this.sourceXml,r=!!this.sourcePdfFile||!!this.pdfDocument;this.sheets=e,this.sheets.forEach(n=>{n.setSpreadSheet(this)}),this.needsConfiguration=!1,this.pendingXmlConfigKey=null,t?this.keepSheetSelection=!0:r||(this.pendingXmlConfig=null,this.sourceXml=null),r&&(this.keepSheetSelection=!0)};this.isSelected=()=>{for(let e=0;e<this.sheets.length;e++)if(this.sheets[e].isSelected())return!0;return!1};this.getSheets=()=>this.sheets;this.getSelectedSheets=()=>this.sheets.filter(e=>e.isSelected());this.getFilename=()=>this.filename;this.selectAllSheet=e=>this.sheets.forEach(t=>{t.setSelected(e)});this.getType=()=>this.type;this.setType=e=>{this.type=e};this.getFileSize=()=>{let e=this.fileSize/1e6;return Number(parseFloat(`${e}`).toFixed(4))};this.sheets=e,this.filename=t,this.type=r,this.fileSize=n??0,this.sheets.forEach(a=>{a.setSpreadSheet(this)})}setNumberFormat(e){this.globalNumberFormat=e.global,this.columnsNumberFormat=e.columns}getNumberFormat(){return{global:this.globalNumberFormat,columns:this.columnsNumberFormat}}},Ie=se;var je={dmy:"D/M/YYYY",us:"M/D/YY",de:"DD.MM.YYYY"},xe=(o,e)=>o?Se(o,$(e)):void 0,Te=o=>{let e=$(o);return e==="os"?ge():je[e]},$t=({data:o,excelDateCells:e,columnDateFormats:t,maxRow:r=50,maxCol:n=300})=>{let a=Math.min(o.length,r),s=o.slice(0,a).map(i=>i.slice(0,n));return De(s,e,i=>$(t?.[i]))};var be=0,ie=class{constructor({data:e,name:t,isNotSetColumn:r,id:n,columnDateFormats:a,excelDateCells:s}){this.selected=!1;this.isManualSelectHeader=!1;this.columns=[];this.columnsInitialized=!1;this.headerRowIndex=0;this.transposed=!1;this.headerRowIndexes=[];this.addedColumns=[];this.usedSourceCells=new Set;this.mergedHeadersActive=!1;this.mergedRowsBackup=null;this.availableRows=null;this.spreadSheet=new Ie({filename:"",sheets:[],type:"xlsx",fileSize:0});this.getId=()=>this.id;this.setSpreadSheet=e=>{this.spreadSheet=e};this.getSpreadSheet=()=>this.spreadSheet;this.setSelected=e=>{this.selected=e};this.isSelected=()=>this.selected;this.setHeaderRowIndex=e=>{this.headerRowIndex=e,this.columnsInitialized=!1,this.mergedHeadersActive||(this.headerRowIndexes=[e])};this.setTransposed=e=>{this.transposed=e};this.getTransposed=()=>this.transposed;this.setHeaderRowIndexes=e=>{this.headerRowIndexes=[...e]};this.getHeaderRowIndexes=()=>this.headerRowIndexes.length>0?this.headerRowIndexes:[this.headerRowIndex];this.addAddedColumn=e=>{if(this.addedColumns.push(e),e.sourceCell){let n=`${e.sourceCell.row},${e.sourceCell.col}`;this.usedSourceCells.add(n)}let t=this.data[this.headerRowIndex],r=this.data.length>0?Math.max(...this.data.map(n=>n.length)):0;t&&t.push(e.columnName);for(let n=0;n<this.data.length;n++)if(n!==this.headerRowIndex){for(;this.data[n].length<r;)this.data[n].push("");n<this.headerRowIndex?this.data[n].push(""):this.data[n].push(e.value)}this.setColumns()};this.removeAddedColumn=e=>{let r=(this.data[this.headerRowIndex]?.length||0)-this.addedColumns.length,n=e-r;if(n<0||n>=this.addedColumns.length)return;let a=this.addedColumns[n];if(a?.sourceCell){let s=`${a.sourceCell.row},${a.sourceCell.col}`;this.usedSourceCells.delete(s)}for(let s=0;s<this.data.length;s++)this.data[s].splice(e,1);this.addedColumns.splice(n,1),this.setColumns()};this.removeColumnFromData=e=>{if(!(e<0)){for(let t=0;t<this.data.length;t++)this.data[t].length>e&&this.data[t].splice(e,1);this.columnDateFormats=void 0,this.excelDateCells=void 0}};this.clearAddedColumns=()=>{if(this.addedColumns.length>0){let t=(this.data[this.headerRowIndex]?.length||0)-this.addedColumns.length;for(let r=this.addedColumns.length-1;r>=0;r--){let n=t+r;for(let a=0;a<this.data.length;a++)this.data[a].length>n&&this.data[a].splice(n,1)}}this.addedColumns=[],this.usedSourceCells.clear(),this.setColumns()};this.isSourceCellUsed=(e,t)=>{let r=`${e},${t}`;return this.usedSourceCells.has(r)};this.getAddedColumnBySourceCell=(e,t)=>this.addedColumns.find(r=>r.sourceCell&&r.sourceCell.row===e&&r.sourceCell.col===t);this.getAddedColumns=()=>this.addedColumns;this.setMergedHeadersActive=e=>{this.mergedHeadersActive=e};this.isMergedHeadersActive=()=>this.mergedHeadersActive;this.setMergedRowsBackup=e=>{this.mergedRowsBackup=e};this.getMergedRowsBackup=()=>this.mergedRowsBackup;this.setAvailableRows=e=>{this.availableRows=e};this.getAvailableRows=()=>this.availableRows;this.isLoneWhitelistCharacter=e=>{let t=e.toString()?.trim()??"";return ye.some(r=>t===r)};this.isSignificantCell=e=>!we(e)&&!this.isLoneWhitelistCharacter(e);this.collapseAdjacentDuplicates=e=>e.filter((t,r)=>r===0||`${t}`!=`${e[r-1]}`);this.getSignificantCells=e=>{let t=(e??[]).filter(this.isSignificantCell);return this.collapseAdjacentDuplicates(t)};this.getDataTransform=()=>this.data.map((e,t)=>({data:e,index:t,length:this.getSignificantCells(e).length}));this.getMaxLengthColumns=()=>this.getDataTransform().reduce((t,r)=>Math.max(t,r.length),0);this.isHeaderLikeCell=e=>!he.includes(Ze(e)?e.toLowerCase():e)&&qe(Number(e));this.countHeaderLikeCells=e=>this.getSignificantCells(e).filter(this.isHeaderLikeCell).length;this.setHeaderByAutoDetection=()=>{let t=this.getMaxLengthColumns(),r=this.getDataTransform().slice(0,50).filter(a=>a.length===t&&this.countHeaderLikeCells(a.data)===t),n=r.length===1?r[0].index:Ge(r,a=>a.length)?.index??0;this.setHeaderRowIndex(n)};this.getHeaderRowIndex=()=>this.headerRowIndex;this.getHeaderRow=()=>this.data[this.headerRowIndex]?.filter(e=>!!e);this.getColumns=()=>(this.ensureColumnsBuilt(),this.columns.filter(e=>!e.isRemoved()));this.getSortedColumns=()=>[...this.getColumns()].sort((e,t)=>D(e.getColumnKey())<D(t.getColumnKey())?-1:D(e.getColumnKey())>D(t.getColumnKey())?1:0);this.getColumnsWithRemoved=()=>(this.ensureColumnsBuilt(),this.columns.filter(e=>e.getType()!==1));this.getColumn=(e,t)=>(this.ensureColumnsBuilt(),this.columns.find(r=>t?D(r.getColumnKey())===D(`${e}`):r.getColumnKey()===e));this.getColumnsByKey=(e,t)=>(this.ensureColumnsBuilt(),this.columns.filter(r=>t?D(r.getColumnKey())===D(`${e}`):r.getColumnKey()===e));this.getValues=()=>{let e=this.data.filter((r,n)=>n>this.headerRowIndex);if(we(e))return[[]];let t=[];for(let r=0;r<e.length;r++){let n=[];for(let a=0;a<this.data[this.headerRowIndex].length;a++)et(this.data[this.headerRowIndex][a])||n.push(this.parseValue(e[r][a]));t.push(n)}return t};this.getData=()=>this.data;this.getExcelDateCells=()=>this.excelDateCells;this.getColumnDateFormats=()=>this.columnDateFormats;this.getName=()=>this.name;this.getDisplayName=({t:e})=>{if(this.getName()?.length>0)return this.getName();switch(this.spreadSheet.getType()){case"json":return`${e("txt_default_sheet_prefix_name")} 1`;case"csv":return`${e("txt_default_sheet_prefix_name")} 1`;default:return""}};this.getSheetFileName=()=>`${this.spreadSheet.getFilename()}`;this.getIsManualSelectHeader=()=>this.isManualSelectHeader;this.setIsManualSelectHeader=()=>{this.isManualSelectHeader=!0};this.clearIsManualSelectHeader=()=>{this.isManualSelectHeader=!1};this.addColumn=e=>{this.ensureColumnsBuilt(),this.columns.push(new M({columnKey:`${e}`,sheet:this,rows:this.getRowsByColumnIndex(this.getColumnIndex(e))}))};this.removeColumn=e=>{this.ensureColumnsBuilt(),this.columns.find(t=>t.getColumnKey()===e)?.remove()};this.removeColumnByIndex=e=>{this.ensureColumnsBuilt(),this.columns.find((t,r)=>r===e)?.remove()};this.setData=e=>{this.data=e,this.columnDateFormats=void 0,this.excelDateCells=void 0};this.toJSON=()=>({name:this.name,id:this.id,type:this.getType(),values:this.getValues(),headerRow:this.getHeaderRow()});this.equal=e=>this.id===e.getId();this.getType=()=>0;this.getRowsByColumnIndex=e=>{if(e===-1)return[];let t=[],r=this.columnDateFormats?.[e];for(let n=0;n<this.data.length;n++){let a=this.data[n];if(n>this.headerRowIndex){let s=a[e]??"",i=xe(this.excelDateCells?.[`${n},${e}`],r);t.push(i??this.parseValue(s))}}return t};this.getExcelDisplayInputFormat=e=>{if(!this.excelDateCells)return;let t=!1;for(let r=this.headerRowIndex+1;r<this.data.length;r++)if((this.data[r]?.[e]??"")!==""){if(!this.excelDateCells[`${r},${e}`])return;t=!0}return t?Te(this.columnDateFormats?.[e]):void 0};this.ensureColumnsBuilt=()=>{this.columnsInitialized||this.setColumns()};this.setColumns=()=>{let e=this.data[this.headerRowIndex];if(e){let t=[];for(let r=0;r<e.length;++r){let n=e[r];n&&t.push(new M({columnKey:`${n}`,sheet:this,rows:this.getRowsByColumnIndex(r),parserDateFormat:this.columnDateFormats?.[r]??this.getExcelDisplayInputFormat(r)}))}this.columns=t}else this.columns=[];this.columnsInitialized=!0};this.getColumnIndex=e=>this.data[this.headerRowIndex].findIndex(n=>Qe(`${n}`,`${e}`));this.parseValue=e=>typeof e=="string"?e.trim():e;this.data=e,this.name=t,this.columnDateFormats=a,this.excelDateCells=s,typeof n>"u"?(be++,this.id=`${t}-${be}`):this.id=n,this.columnsInitialized=!!r}},Re=ie;var le=class extends Re{constructor({joinedData:t,sheets:r,mappings:n,mappingIndexes:a}){super({data:t.data,name:"join-sheet",isNotSetColumn:!0});this.sheets=[];this.joinHistory=[];this.findRefJoinSheetColumn=t=>{let r=this.sheets.length===2?this.sheets[0]:this,n=this.sheets[this.sheets.length-1];if(t<r.getColumns().length)return r.getColumns()[t];let a=t-r.getColumns().length;return n.getColumns().filter((s,i)=>this.joinHistory[this.joinHistory.length-1].mappingIndexes.every(l=>l.target!==i))[a]};this.setJoinColumns=(t,r)=>{let n=this.data[this.headerRowIndex];if(!n){this.columns=[];return}let a=[];for(let s=0;s<n.length;++s){let i=n[s],l=r.findIndex(u=>u.source===s),d=this.columns[s]&&this.columns[s].getType()===1;if(l>=0||d){let u=t[l],m;d&&l>=0?m=[...this.columns[s].getJoinedSheetColumns(),u.target]:d?m=this.columns[s].getJoinedSheetColumns():m=[u.source.getRefJoinSheetColum()??u.source,u.target],a.push(new Fe({columnKey:`${i}`,sheetColumns:m,sheet:this,rows:this.getRowsByColumnIndex(s)}))}else{let u=this.columns[s]?this.columns[s].getRefJoinSheetColum()??this.columns[s]:this.findRefJoinSheetColumn(s);a.push(new M({columnKey:`${i}`,sheet:u.getSheet(),rows:this.getRowsByColumnIndex(s),refJoinSheetColum:u}))}}this.columns=a};this.getJoinedSheets=()=>this.sheets;this.getType=()=>1;this.joinSheet=(t,r,n,a)=>{this.setData(t.data),this.sheets.push(r),this.joinHistory.push({mappingIndexes:a,type:t.type,row:t.data.length,col:this.data[this.headerRowIndex]?.length??0}),this.setJoinColumns(n,a)};this.getJoinColumns=()=>this.columns.filter(t=>t.getType()===1);this.getJoinHistory=()=>this.joinHistory;this.headerRowIndex=0,this.joinHistory.push({mappingIndexes:a,type:t.type,row:t.data.length,col:this.data[this.headerRowIndex]?.length??0}),this.sheets=r,this.setJoinColumns(n,a)}},tr=le;var Ne=({rowA:o,rowB:e},t)=>t.every(r=>{let n=`${o[r.source]??""}`,a=`${e[r.target]??""}`;return n===a&&n!==""&&a!==""}),tt=(o,e,t)=>{let r=[],n=o.headerRow,a=e.headerRow;for(let s=0;s<n.length;++s)r.push(n[s]);for(let s=0;s<a.length;++s)t.every(i=>i.target!==s)&&r.push(a[s]);return r},sr=async(o,e)=>{let t=o.values,r=e.values,n=o.headerRow,a=e.headerRow,s=[...n,...a],i=[];i.push(s);for(let l=0;l<t.length;++l)i.push([...t[l],...r[0]]);return{data:i,type:"ADD_TO_ALL_ROWS"}},ir=async(o,e)=>{let t=o.values,r=e.values,n=o.headerRow,a=e.headerRow,s=[...n,...a],i=[];i.push(s);for(let l=0;l<t.length;++l)i.push([...t[l],...a.map(()=>"")]);for(let l=0;l<r.length;++l)i.push([...n.map(()=>""),...r[l]]);return{data:i,type:"JOIN_WITHOUT_COLUMNS"}},lr=async(o,e,t)=>{let r=o.values,n=e.values,a=[],s=[],i={},l=tt(o,e,t);a.push(l);for(let d=0;d<r.length;++d){let u=!1,m=r[d];for(let h=0;h<n.length;++h){let c=n[h];Ne({rowA:m,rowB:c},t)&&(i[h]=!0,u=!0,a.push([...m,...c.filter((f,g)=>t.every(F=>F.target!==g))]))}u||s.push([...m,...e.headerRow.filter((h,c)=>t.every(f=>f.target!==c)).map(()=>"")])}for(let d=0;d<n.length;++d){if(i[d])continue;let u=n[d],m=o.headerRow.map(()=>"");t.forEach(h=>{m[h.source]=u[h.target]}),s.push([...m,...u.filter((h,c)=>t.every(f=>f.target!==c))])}return s.forEach(d=>{a.push(d)}),{data:a,type:"JOIN_ON_COLUMNS"}},ur=async(o,e,t)=>{let r=e.headerRow.filter((i,l)=>t.every(d=>d.target!==l)),a=[[...o.headerRow,...r]];for(let i=0;i<o.values.length;++i){let l=[...o.values[i],...r.map(()=>"")];a.push(l)}let s=e.values;for(let i=0;i<s.length;++i){let l=o.headerRow.map(()=>""),d=[];for(let u=0;u<e.headerRow.length;++u){let m=t.find(h=>h.target===u);m?l[m.source]=s[i][u]:d.push(s[i][u])}a.push([...l,...d])}return{data:a,type:"APPEND_TO_COLUMNS"}},mr=async(o,e,t)=>{let r=o.values,n=e.values,a=r.length+n.length,s=0,i={};for(let l=0;l<r.length;l++){let d=r[l],u=null,m=0;for(let h=0;h<n.length;h++){let c=n[h];if(Ne({rowA:d,rowB:c},t)&&(u=h,m++,m===2))break}m===1&&u!==null&&(s+=1,i[u]=!0)}for(let l=0;l<n.length;l++)i[l]&&(s+=1);return{count:s,total:a}};import{isNil as It}from"lodash";var Ve=o=>o.some(e=>typeof e=="string"&&p(e)&&!y(e.trim())),T=o=>!Ve(o)&&!o.some(e=>typeof e=="boolean"),w=o=>o.filter(e=>typeof e=="string"&&p(e)&&!y(e.trim())),rt=(o,e)=>{let t=e?.trim();return t||(T(o),"")};var b=/T\d{1,2}:\d{2}(:\d{2})?(\.\d+)?/i,B=/\b\d{1,2}:\d{2}(:\d{2})?(\.\d+)?(\s*[AaPp][Mm])?\b/,ot=/\s+\d{1,2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:\s*[AaPp][Mm])?(?:Z|[+-](?:[01]\d|2[0-3])(?::?[0-5]\d)?)?\s*$/i,L=/\b[AaPp][Mm]\b/,nt=/\d{1,2}:\d{2}:\d{2}\.(\d+)/,z=/^(\d{4})([/.\- ])(\d{1,2})\2(\d{1,2})$/,X=/^(\d{1,2})([/.\- ])(\d{1,2})\2(?:\d{2}|\d{4})$/;var j=o=>o.match(nt)?.[1]?.length??0,ve=o=>o<=0||o>9?"":`.${"S".repeat(o)}`,C=o=>{let e=o.trim();return b.test(e)?e.split(/T/i)[0]??"":e.replace(ot,"")};var at=/^(?:\d{4}([/.\- ])\d{1,2}\1\d{1,2}|\d{1,2}([/.\- ])\d{1,2}\2\d{4})$/,st=/^\d{1,2}([/.\- ])\d{1,2}\1\d{2}$/,it=/^\d{4}([/.\- ])\d{1,2}\1\d{1,2}$/,lt=/^\d{1,2}([/.\- ])\d{1,2}\1(?:\d{2}|\d{4})$/,R=o=>{let e=!1,t=!1;for(let r of o){if(typeof r!="string"||!p(r))continue;let n=C(r);if(at.test(n)){e=!0;continue}st.test(n)&&(t=!0)}return e&&t?null:e?"YYYY":t?"YY":null},Ae=o=>{let e=!1,t=!1;for(let r of o){if(typeof r!="string"||!p(r))continue;let n=C(r);if(it.test(n)){e=!0;continue}lt.test(n)&&(t=!0)}return{sawYearFirst:e,sawDayOrMonthFirst:t}},N=o=>{let{sawYearFirst:e,sawDayOrMonthFirst:t}=Ae(o);return e&&!t},Oe=o=>{let{sawYearFirst:e,sawDayOrMonthFirst:t}=Ae(o);return e&&t};var W=o=>o?"D":"DD",q=o=>o?"M":"MM",G=o=>{let e=!1,t=!1;for(let r of o){if(typeof r!="string"||!p(r))continue;let n=C(r),a=n.match(z);if(a){a[3].length===1&&(e=!0),a[4].length===1&&(t=!0);continue}let s=n.match(X);s&&(s[1].length===1&&(e=!0),s[3].length===1&&(t=!0))}return{firstUnpadded:e,secondUnpadded:t}};var Pe=o=>o.length===1?"unpadded":o.length===2&&o[0]==="0"?"padded":"wide",mt=o=>{let e=j(o),t=e>0||/\d{1,2}:\d{2}:\d{2}/.test(o),r=o.match(/(?:[T\s]|^)(\d{1,2}):\d{2}/i)?.[1]??"";return{isoT:b.test(o),seconds:t,fractionDigits:e,timezone:k(o),meridiem:L.test(o),unpaddedHour:r.length===1,paddedHour:r.length===2&&r.startsWith("0")}},dt=(o,e)=>o.isoT===e.isoT&&o.seconds===e.seconds&&o.fractionDigits===e.fractionDigits&&o.timezone===e.timezone&&o.meridiem===e.meridiem,_e=o=>{let e=null;for(let t of o){if(typeof t!="string"||!p(t))continue;let r=Q(C(t));if(r){if(e===null){e=r;continue}if(r!==e)return!0}}return!1},ht=o=>{let e=[];for(let t of o){if(typeof t!="string"||!p(t))continue;let r=Q(C(t));r&&(e.includes(r)||e.push(r))}return e},I=o=>{if(_e(o))return!0;let e=!1,t=!1,r=null,n=!1,a=!1,s=!1,i=!1,l=!1,d=!1;for(let u of o){if(typeof u!="string"||!p(u))continue;let m=u.trim(),h=C(m),c=h.match(z),f=h.match(X),g=c?.[3]??f?.[1],F=c?.[4]??f?.[3];if(g){let A=Pe(g);A==="unpadded"&&(s=!0),A==="padded"&&(i=!0)}if(F){let A=Pe(F);A==="unpadded"&&(l=!0),A==="padded"&&(d=!0)}if(!(b.test(m)||B.test(m))){if(e=!0,t)return!0;continue}if(t=!0,e)return!0;let v=mt(m);if(v.fractionDigits>9)return!0;if(v.unpaddedHour&&(n=!0),v.paddedHour&&(a=!0),!r){r=v;continue}if(!dt(r,v))return!0}return!!(s&&i||l&&d||n&&a)};var O=o=>{if(I(o))return"";let e=!1,t=!1,r=!1,n=!1,a=0,s=!1,i=!1;for(let c of o){if(typeof c!="string"||!p(c))continue;let f=c.trim(),g=b.test(f);if(!g&&!B.test(f))continue;e=!0,g&&(t=!0),L.test(f)&&(r=!0);let F=j(f);F>0?(n=!0,a=F):/\d{1,2}:\d{2}:\d{2}/.test(f)&&(n=!0),k(f)&&(s=!0),(f.match(/(?:[T\s]|^)(\d{1,2}):\d{2}/i)?.[1]??"").length===1&&(i=!0)}if(!e)return"";let l=t?"[T]":" ",d=r?i?"h":"hh":i?"H":"HH",u=r?" A":"",m=ve(a),h=s?"Z":"";return n?`${l}${d}:mm:ss${m}${u}${h}`:`${l}${d}:mm${u}${h}`},V=(o,e)=>{let t=o.trim();if(!t||/[Hh]/.test(t))return t;let r=O(e);return r?`${t}${r}`:t};var Z=(o,e="",t={firstUnpadded:!1,secondUnpadded:!1})=>`YYYY${o}${q(t.firstUnpadded)}${o}${W(t.secondUnpadded)}${e}`,P=(o,e,t="",r="YYYY",n={firstUnpadded:!1,secondUnpadded:!1})=>`${o==="dM"?[W(n.firstUnpadded),q(n.secondUnpadded),r].join(e):[q(n.firstUnpadded),W(n.secondUnpadded),r].join(e)}${t}`,Ee=(o,e="",t="YYYY",r={firstUnpadded:!1,secondUnpadded:!1})=>({dayFirst:P("dM",o,e,t,r),monthFirst:P("Md",o,e,t,r)}),Ye=["/","-","."],pt=(o="",e="YYYY",t={firstUnpadded:!1,secondUnpadded:!1},r=Ye)=>{let n=[];for(let a of r){let{dayFirst:s,monthFirst:i}=Ee(a,o,e,t);n.push(s,i)}return n};var ct=o=>o.every(e=>typeof e!="number"&&(typeof e!="string"||!p(e))),_=({colType:o,inputFormat:e,samples:t,parserDateFormat:r})=>{if(!H(o))return null;if(x(e))return"configured";if(r?.trim())return"detected";if(T(t))return ct(t)?"detected":"undetected";let n=w(t);return I(n)||Oe(n)?"undetected":N(n)?"detected":J(n)===null||R(n)===null?"undetected":"detected"},ft=o=>o.getDateFormatPromptResolved?.()??o.getDeclaredInputFormat?.(),ue=o=>o.getDateFormatPromptResolved?.()??(typeof o.getDeclaredInputFormat=="function"?o.getDeclaredInputFormat():o.getInputFormat()),gt=o=>o.some(e=>{let t=e.matchedDataModel?.dataModel;return!t||!e.sheetColumn?!1:_({colType:t.getType(),inputFormat:ue(t),samples:e.sheetColumn.getDateInputFormatSamples(),parserDateFormat:e.sheetColumn.getParserDateFormat?.()})==="undetected"});var He=({colType:o,inputFormat:e,samples:t,parserDateFormat:r})=>{let n=_({colType:o,inputFormat:e,samples:t,parserDateFormat:r}),a=w(t);if(n==="configured")return V((e??"").trim(),a);if(n!=="detected")return"";let s=r?.trim();if(s)return s;let i=O(a),l=ee(a),d=G(a);if(N(a))return Z(l,i,d);let u=J(a);if(u!=="dM"&&u!=="Md")return"";let m=R(a);return m?P(u,l,i,m,d):""},St=(o,e)=>{o.forEach(t=>{let r=t.matchedDataModel?.dataModel;if(!r?.setInputFormat||!t.sheetColumn)return;let n=r.getType(),a=ue(r),s=t.sheetColumn.getDateInputFormatSamples(),i=t.sheetColumn.getParserDateFormat?.(),l=w(s),d=_({colType:n,inputFormat:a,samples:s,parserDateFormat:i});if(!d)return;let u=e?.getChosenFormat?.(t)?.trim()||"",m=u||He({colType:n,inputFormat:a,samples:s,parserDateFormat:i});if(!m&&d==="undetected"&&e?.fallbackUndetected&&!I(l)){let h=R(l);if(h){let c=ee(l),f=O(l),g=G(l);m=N(l)?Z(c,f,g):P("dM",c,f,h,g)}}!u&&!x(a)&&T(s)&&!m||m&&r.setInputFormat(V(m,l))})};var Dt=o=>{if(o==null)return"";if(typeof o=="object"&&!Array.isArray(o)&&"value"in o){let e=o.value;return typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:""}return typeof o=="string"||typeof o=="number"||typeof o=="boolean"?o:""},Ct=(o,e)=>o.map(t=>({sheetColumn:{getDateInputFormatSamples:()=>e.map(r=>Dt(r?.[t.getKey()]))},matchedDataModel:{dataModel:t}}));import $e from"moment";var Ft=5,ke=o=>{let e=$e(o,pe,!0);if(e.isValid())return e;let t=$e.parseZone(o,ce,!0);return t.isValid()?t:null},yt=(o,e)=>{if(!p(o))return null;let t=K([o],e)[0];if(typeof t!="string")return null;if(t===o||t===o.trim()){if(!y(t.trim()))return null;let n=ke(t.trim());return n?{original:o,parsedMoment:n}:null}let r=ke(t);return r?{original:o,parsedMoment:r}:null},Mt=({samples:o,inputFormat:e,outputFormat:t,maxRows:r=Ft})=>o.filter(a=>p(a)).slice(0,r).map(a=>{let s=yt(a,e);return s?{original:a,formatted:s.parsedMoment.format(t)}:{original:a,formatted:null}});var Je=(o,e)=>{if(!H(e.getType()))return S.parse(o,{dataModel:e});if(fe(o))return null;let t=`${o}`,r=e.getInputFormat();if(x(r)){if(y(t))return S.parse(t,{dataModel:e});let n=r;if(!te(t,n)){let a=V(n,[t]);if(a!==n&&te(t,a))n=a;else return t}return S.parse(K([t],n)[0],{dataModel:e})}return S.parse(t,{dataModel:e})};var me=class{constructor({sheetColumn:e,matchedDataModel:t,detectedNumberFormats:r}){this.parseSheetValue=(e,t)=>t.dataModel.getType()==="date"?Je(e,t.dataModel):S.parse(e,t);this.getOptionValue=(e,t)=>{if(!t)if(this.matchedDataModel.dataModel){let r=this.sheetColumn.columnKey,a=this.detectedNumberFormats.columns.find(s=>s.column===r)?.numberFormat||this.detectedNumberFormats.global;return this.parseSheetValue(e,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0,numberFormat:a})}else return e;for(let r=0;r<t.length;r++)if(`${t[r]?.sheetOption}`==`${e}`){let n=!It(t[r]?.dataModelOptions)&&(t[r]?.dataModelOptions?.length??0)>0;if(t[r]?.autoPreserved===!0&&t[r]?.dataModelOption==null&&!n){if(this.matchedDataModel.dataModel instanceof U){let a=`${e}`,s=this.matchedDataModel.dataModel.getOptions().find(i=>i.label===a||i.value===a);if(s)return S.parse(s.value,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0})}return e}return this.matchedDataModel.dataModel&&this.matchedDataModel.dataModel.getIsMultiSelection()?S.parse(t[r]?.dataModelOptions,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0}):this.matchedDataModel.dataModel?S.parse(t[r]?.dataModelOption,{dataModel:this.matchedDataModel.dataModel,isParseFromSheet:!0}):t[r]?.dataModelOption}};this.getValues=()=>{let e=this.sheetColumn.rows,t=[];for(let r=0;r<e.length;r++){let n=e[r],a=this.getOptionValue(n,this.matchedOptions);t.push(a)}return t};if(this.sheetColumn=e,this.matchedDataModel=t,this.matchedOptions=void 0,this.detectedNumberFormats=r||{global:"eu",columns:[]},this.matchedDataModel.matchedOptions){this.matchedOptions=[];for(let n=0;n<(this.matchedDataModel.matchedOptions?.length??0);n++){let a=this.matchedDataModel.matchedOptions[n];this.matchedDataModel.dataModel?.getIsMultiSelection()?a.dataModelOptions&&this.matchedOptions.push(a):a.dataModelOption!==void 0&&a.dataModelOption!==null?this.matchedOptions.push(a):a.autoPreserved===!0&&!a.userCleared&&this.matchedOptions.push(a)}}}},Ke=me;var de=class{constructor(e){this.matchedColumns=[];this.parseValues=()=>{let e=[];this.matchedColumns.forEach(t=>{let r=t.matchedDataModel,a=new Ke({sheetColumn:t.sheetColumn,matchedDataModel:r,detectedNumberFormats:this.detectedNumberFormats}).getValues(),s=r.dataModel.getKey();a.forEach((i,l)=>{e[l]?e[l][s]=i:e[l]={[s]:i}})});for(let t=0;t<e.length;++t)for(let r=0;r<this.columns.length;++r){let a=this.columns[r].key;e[t][a]===void 0&&(e[t][a]=null)}return e};this.getValues=()=>(this.matchedColumns=[],this.matching.filter(t=>t.matchedDataModel?.dataModel).forEach(t=>{this.matchedColumns.push({sheetColumn:t.sheetColumn,matchedDataModel:t.matchedDataModel})}),this.parseValues());let{matching:t,detectedNumberFormats:r}=e;this.matching=t,this.detectedNumberFormats=r||{global:"eu",columns:[]},this.columns=e.columns??[]}},Ue=de;var $o=({matching:o,detectedNumberFormats:e,columns:t})=>new Ue({matching:o,detectedNumberFormats:e,columns:t}).getValues();import*as Be from"comlink";var E=class{static{this.serialize=e=>e.serialize()}static{this.deSerialize=e=>re.isTypeCategory(e.type)?new U({description:e.description,example:e.example,key:e.key,label:e.label,type:e.type,options:e.options,validators:[],alternativeMatches:e.alternativeMatches,columnSize:e.columnSize,isMultiSelection:e.isMultiSelection??!1,allowCustomOptions:e.allowCustomOptions,allowedCustomOptionTypes:e.allowedCustomOptionTypes,hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:e.optionMappingConfiguration}):new re({description:e.description,example:e.example,key:e.key,label:e.label,type:e.type,validators:[],alternativeMatches:e.alternativeMatches,columnSize:e.columnSize,outputFormat:e.outputFormat,inputFormat:e.inputFormat,numberFormat:e.numberFormat,hidden:e.hidden,disabled:e.disabled,optionMappingConfiguration:e.optionMappingConfiguration})}};var Y=class{static{this.serialize=e=>{let t={matching:[],detectedNumberFormats:e.detectedNumberFormats,columns:e.columns};return t.matching=e.matching.map(r=>({sheetColumn:r.sheetColumn,matchedDataModel:r.matchedDataModel?{dataModel:r.matchedDataModel.dataModel?E.serialize(r.matchedDataModel.dataModel):r.matchedDataModel.dataModel,matchedOptions:r.matchedDataModel.matchedOptions}:r.matchedDataModel})),[t,[]]}}static{this.deserialize=e=>({matching:e.matching.map(t=>({sheetColumn:t.sheetColumn,matchedDataModel:t.matchedDataModel?{dataModel:t.matchedDataModel.dataModel?E.deSerialize(t.matchedDataModel.dataModel):t.matchedDataModel.dataModel,matchedOptions:t.matchedDataModel.matchedOptions}:t.matchedDataModel})),detectedNumberFormats:e.detectedNumberFormats,columns:e.columns})}};Be.transferHandlers.set("Matching",{canHandle:o=>!!(o!==null&&typeof o=="object"&&o.matching),serialize:o=>Y.serialize(o),deserialize:o=>Y.deserialize(o)});export{M as a,Ie as b,$t as c,Re as d,w as e,rt as f,R as g,N as h,G as i,ht as j,I as k,O as l,Z as m,Ee as n,Ye as o,pt as p,_ as q,ft as r,gt as s,He as t,St as u,Ct as v,Mt as w,tr as x,sr as y,ir as z,lr as A,ur as B,mr as C,$o as D,E};
|
package/index.d.ts
CHANGED
|
@@ -574,6 +574,8 @@ export type ColumnAPI = {
|
|
|
574
574
|
|
|
575
575
|
export type I18nOverrides =
|
|
576
576
|
| {
|
|
577
|
+
ar?: Record<string, string>;
|
|
578
|
+
he?: Record<string, string>;
|
|
577
579
|
en?: Record<string, string>;
|
|
578
580
|
de?: Record<string, string>;
|
|
579
581
|
es?: Record<string, string>;
|
|
@@ -686,6 +688,7 @@ export type SettingsAPI = {
|
|
|
686
688
|
cleaningAssistant?: boolean;
|
|
687
689
|
contextualEngine?: `${ContextualEngineType}`;
|
|
688
690
|
columnMappingConfiguration?: IMappingConfiguration;
|
|
691
|
+
pdfConfiguration?: IPdfConfiguration;
|
|
689
692
|
baseUrl?: string;
|
|
690
693
|
completeImportLogging?: boolean;
|
|
691
694
|
submitModalConfiguration?: ISubmitModalConfiguration;
|
|
@@ -786,6 +789,18 @@ export type EntryChangeRow = {
|
|
|
786
789
|
info: RowInfo;
|
|
787
790
|
};
|
|
788
791
|
|
|
792
|
+
export type DatasetRow = {
|
|
793
|
+
rowIndex: number;
|
|
794
|
+
data: Row;
|
|
795
|
+
info: RowInfo;
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
export type EntryChangeDataset = {
|
|
799
|
+
readonly rowCount: number;
|
|
800
|
+
getRow: (index: number) => DatasetRow | undefined;
|
|
801
|
+
forEachRow: (cb: (row: DatasetRow, index: number) => void) => void;
|
|
802
|
+
};
|
|
803
|
+
|
|
789
804
|
export type RowResult = Record<string, HookedRecordResult | FieldValue>;
|
|
790
805
|
|
|
791
806
|
export type EntryChangeResult = {
|
|
@@ -802,7 +817,8 @@ export type ResultOnEntryChange =
|
|
|
802
817
|
|
|
803
818
|
export type OnEntryChange = (
|
|
804
819
|
rows: EntryChangeRow[],
|
|
805
|
-
logs: OnEntryChangeLogs
|
|
820
|
+
logs: OnEntryChangeLogs,
|
|
821
|
+
dataset: EntryChangeDataset
|
|
806
822
|
) => ResultOnEntryChange;
|
|
807
823
|
|
|
808
824
|
export type HookedRecordRowResult = [HookedRecordResult, number];
|
|
@@ -1352,6 +1368,7 @@ type DialogCreateCustomOption = {
|
|
|
1352
1368
|
|
|
1353
1369
|
type ColumnMatchThemeAPI = {
|
|
1354
1370
|
root?: CSSInterpolation;
|
|
1371
|
+
rootError?: CSSInterpolation;
|
|
1355
1372
|
pageHeader?: HeaderThemeAPI;
|
|
1356
1373
|
borderColor?: CSSInterpolation;
|
|
1357
1374
|
matchingTitle?: {
|
|
@@ -1981,6 +1998,8 @@ export type ContextualEngineThemeAPI = {
|
|
|
1981
1998
|
};
|
|
1982
1999
|
|
|
1983
2000
|
export type LanguageType =
|
|
2001
|
+
| 'ar'
|
|
2002
|
+
| 'he'
|
|
1984
2003
|
| 'de'
|
|
1985
2004
|
| 'en'
|
|
1986
2005
|
| 'es'
|
|
@@ -2039,6 +2058,13 @@ export type IParseFileXmlConfiguration = {
|
|
|
2039
2058
|
};
|
|
2040
2059
|
};
|
|
2041
2060
|
|
|
2061
|
+
export type IParseFilePdfConfiguration = {
|
|
2062
|
+
sourcePdfFile?: File;
|
|
2063
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2064
|
+
pdfDocument?: any;
|
|
2065
|
+
selectedPdfTableIds?: string[];
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2042
2068
|
export type SheetSelectionUploadFile = {
|
|
2043
2069
|
fileName: string;
|
|
2044
2070
|
sheets: {
|
|
@@ -2047,6 +2073,7 @@ export type SheetSelectionUploadFile = {
|
|
|
2047
2073
|
visibility?: SheetVisibility;
|
|
2048
2074
|
}[];
|
|
2049
2075
|
xmlConfiguration?: IParseFileXmlConfiguration;
|
|
2076
|
+
pdfConfiguration?: IParseFilePdfConfiguration;
|
|
2050
2077
|
};
|
|
2051
2078
|
|
|
2052
2079
|
export type SheetSelectionUploadData = SheetSelectionUploadFile[];
|
|
@@ -2069,6 +2096,7 @@ export type IParseFile = {
|
|
|
2069
2096
|
fileName: string;
|
|
2070
2097
|
sheets: IParseSheet[];
|
|
2071
2098
|
xmlConfiguration?: IParseFileXmlConfiguration;
|
|
2099
|
+
pdfConfiguration?: IParseFilePdfConfiguration;
|
|
2072
2100
|
};
|
|
2073
2101
|
|
|
2074
2102
|
export type OnEntryChangeLogs = {
|
|
@@ -2095,6 +2123,12 @@ export type IMappingConfiguration = {
|
|
|
2095
2123
|
processingMode?: ProcessingMode;
|
|
2096
2124
|
};
|
|
2097
2125
|
|
|
2126
|
+
export type PdfParsingMode = 'node' | 'browser';
|
|
2127
|
+
|
|
2128
|
+
export type IPdfConfiguration = {
|
|
2129
|
+
mode?: PdfParsingMode;
|
|
2130
|
+
};
|
|
2131
|
+
|
|
2098
2132
|
export type ISubmitModalConfiguration = {
|
|
2099
2133
|
exportButton?: boolean;
|
|
2100
2134
|
importSummary?: boolean;
|