dbgate-plugin-csv 6.6.12 → 6.7.0
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/backend.js +1 -1
- package/dist/frontend.js +1 -1
- package/package.json +1 -1
package/dist/backend.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={237:(e,t,r)=>{const s=r(514),i=r(370);e.exports={packageName:"dbgate-plugin-csv",shellApi:{reader:s,writer:i},initialize(e){s.initialize(e)}}},514:(e,t,r)=>{const s=r(825),i=r(464),
|
|
1
|
+
(()=>{var e={237:(e,t,r)=>{const s=r(514),i=r(370);e.exports={packageName:"dbgate-plugin-csv",shellApi:{reader:s,writer:i},initialize(e){s.initialize(e)}}},514:(e,t,r)=>{const s=r(825),i=r(464),o=r(896),c=r(203),u=r(994);let a;class n extends c.Transform{constructor({header:e}){super({objectMode:!0}),this.structure=null,this.header=e}_transform(e,t,r){this.structure?(this.push(s.zipObject(this.structure.columns.map((e=>e.columnName)),e)),r()):(this.header?(this.structure={__isStreamHeader:!0,columns:e.map((e=>({columnName:e})))},this.push(this.structure)):(this.structure={__isStreamHeader:!0,columns:e.map(((e,t)=>({columnName:`col${t+1}`})))},this.push(this.structure),this.push(s.zipObject(this.structure.columns.map((e=>e.columnName)),e))),r())}}async function h({fileName:e,encoding:t="utf-8",header:r=!0,delimiter:s,limitRows:c}){console.log(`Reading file ${e}`);const h=await a.download(e);if(!s){const e=await(f=h,new Promise(((e,t)=>{u.open(f,((r,s)=>{r?t(r):s.hasNextLine()?s.nextLine(((r,i)=>{r?s.close((()=>t(r))):s.close((()=>e(i)))})):s.close((()=>e(null)))}))})));if(e){const t={",":e.replace(/[^,]/g,"").length,";":e.replace(/[^;]/g,"").length,"|":e.replace(/[^|]/g,"").length};s=Object.keys(t).reduce(((e,r)=>t[e]>t[r]?e:r),",")}}var f;const l=i.parse({delimiter:s,skip_lines_with_error:!0,to_line:c?c+1:void 0,ltrim:!0});return[o.createReadStream(h,t),l,new n({header:r})]}h.initialize=e=>{a=e.dbgateApi},e.exports=h},370:(e,t,r)=>{const s=r(464),i=r(896),o=r(203),{getLogger:c}=global.DBGATE_PACKAGES["dbgate-tools"],u=c("csvWriter");class a extends o.Transform{constructor(e="utf8"){super({readableObjectMode:!1,writableObjectMode:!1}),this.to=String(e).toLowerCase(),this.decoder=new(global.TextDecoder||r(23).TextDecoder)("utf-8",{fatal:!1})}_encodeString(e){if("utf8"===this.to||"utf-8"===this.to)return Buffer.from(e,"utf8");if("utf16le"===this.to||"ucs2"===this.to||"utf-16le"===this.to)return Buffer.from(e,"utf16le");if("utf16be"===this.to||"utf-16be"===this.to){const t=Buffer.from(e,"utf16le");for(let e=0;e+1<t.length;e+=2){const r=t[e];t[e]=t[e+1],t[e+1]=r}return t}throw new Error(`Unsupported target encoding: ${this.to}`)}_transform(e,t,r){try{Buffer.isBuffer(e)||(e=Buffer.from(e,t));const s=this.decoder.decode(e,{stream:!0});s.length&&this.push(this._encodeString(s)),r()}catch(e){r(e)}}_flush(e){try{const t=this.decoder.decode();t.length&&this.push(this._encodeString(t)),e()}catch(t){e(t)}}}class n extends o.Transform{constructor({header:e}){super({objectMode:!0}),this.columns=null,this.header=e,this.cachedRows=null}_transform(e,t,r){if(this.columns)this.push(this.columns.map((t=>e[t]))),r();else{if(e.__isStreamHeader&&e.columns?.length>0)return this.columns=e.columns.map((e=>e.columnName)),this.header&&this.push(this.columns),void r();if(this.cachedRows||(this.cachedRows=[]),this.cachedRows.push(e),this.cachedRows.length<100)return void r();this.inferStructureFromCachedRows(),r()}}inferStructureFromCachedRows(){const e={};for(const t of this.cachedRows)for(const r of Object.keys(t))e[r]=!0;this.columns=Object.keys(e),this.header&&this.push(this.columns);for(const e of this.cachedRows)this.push(this.columns.map((t=>e[t])));this.cachedRows=null}_final(e){this.cachedRows&&this.inferStructureFromCachedRows(),e()}}e.exports=async function({fileName:e,encoding:t="utf-8",header:r=!0,delimiter:o,quoted:c,writeBom:h,writeSepHeader:f,recordDelimiter:l}){u.info(`DBGM-00133 Writing file ${e}`);const d=new n({header:r}),m=s.stringify({delimiter:o,quoted:c,record_delimiter:l||void 0}),p=i.createWriteStream(e,t);if(h)switch(t.toLowerCase()){case"utf-8":case"utf8":p.write(Buffer.from([239,187,191]));break;case"utf-16":case"utf16":case"utf-16le":case"utf16le":p.write(Buffer.from([255,254]));break;case"utf-16be":case"utf16be":p.write(Buffer.from([254,255]));break;case"utf-32le":case"utf32le":p.write(Buffer.from([255,254,0,0]));break;case"utf-32be":case"utf32be":p.write(Buffer.from([0,0,254,255]))}return f&&p.write(`sep=${o}${l||"\n"}`),d.requireFixedStructure=!0,"utf8"===t.toLowerCase()||"utf-8"===t.toLowerCase()?[d,m,p]:[d,m,new a(t),p]}},464:e=>{"use strict";e.exports=require("csv")},994:e=>{"use strict";e.exports=require("line-reader")},825:e=>{"use strict";e.exports=require("lodash")},896:e=>{"use strict";e.exports=require("fs")},203:e=>{"use strict";e.exports=require("stream")},23:e=>{"use strict";e.exports=require("util")}},t={},r=function r(s){var i=t[s];if(void 0!==i)return i.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,r),o.exports}(237);module.exports=r})();
|
package/dist/frontend.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var plugin;(()=>{"use strict";var e={d:(
|
|
1
|
+
var plugin;(()=>{"use strict";var e={d:(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>r});const r={fileFormats:[{packageName:"dbgate-plugin-csv",storageType:"csv",extension:"csv",name:"CSV",readerFunc:"reader@dbgate-plugin-csv",writerFunc:"writer@dbgate-plugin-csv",args:[{type:"select",name:"delimiter",label:"Delimiter",options:[{name:"Auto-detect",value:""},{name:"Comma (,)",value:","},{name:"Semicolon (;)",value:";"},{name:"Tab",value:"\t"},{name:"Pipe (|)",value:"|"}],apiName:"delimiter"},{type:"checkbox",name:"quoted",label:"Quoted",apiName:"quoted",direction:"target"},{type:"checkbox",name:"header",label:"Has header row",apiName:"header",default:!0},{type:"checkbox",name:"writeBom",label:"Write BOM (Byte Order Mark)",apiName:"writeBom",direction:"target"},{type:"select",name:"recordDelimiter",label:"Record Delimiter",options:[{name:"CR",value:"\r"},{name:"CRLF",value:"\r\n"}],apiName:"recordDelimiter",direction:"target"}]}],quickExports:[{label:"CSV file",extension:"csv",createWriter:e=>({functionName:"writer@dbgate-plugin-csv",props:{fileName:e,delimiter:","}})},{label:"CSV file (semicolon separated)",extension:"csv",createWriter:e=>({functionName:"writer@dbgate-plugin-csv",props:{fileName:e,delimiter:";"}})},{label:"CSV file for MS Excel",extension:"csv",createWriter:e=>({functionName:"writer@dbgate-plugin-csv",props:{fileName:e,delimiter:";",recordDelimiter:"\r\n",encoding:"utf16le",writeSepHeader:!0,writeBom:!0}})},{label:"TSV file (tab separated)",extension:"tsv",createWriter:e=>({functionName:"writer@dbgate-plugin-csv",props:{fileName:e,delimiter:"\t"}})}]};plugin=t})();
|