@datapos/datapos-tool-csv-parse 0.0.90 → 0.0.91
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.
|
@@ -74,7 +74,7 @@ function u(t, e, r) {
|
|
|
74
74
|
throw new Error(
|
|
75
75
|
"If encoding is specified then the first argument must be a string"
|
|
76
76
|
);
|
|
77
|
-
return
|
|
77
|
+
return Ve(this, t);
|
|
78
78
|
}
|
|
79
79
|
return pt(this, t, e, r);
|
|
80
80
|
}
|
|
@@ -103,17 +103,17 @@ function rr(t, e, r, n) {
|
|
|
103
103
|
u.alloc = function(t, e, r) {
|
|
104
104
|
return rr(null, t, e, r);
|
|
105
105
|
};
|
|
106
|
-
function
|
|
107
|
-
if (mt(e), t = q(t, e < 0 ? 0 :
|
|
106
|
+
function Ve(t, e) {
|
|
107
|
+
if (mt(e), t = q(t, e < 0 ? 0 : ze(e) | 0), !u.TYPED_ARRAY_SUPPORT)
|
|
108
108
|
for (var r = 0; r < e; ++r)
|
|
109
109
|
t[r] = 0;
|
|
110
110
|
return t;
|
|
111
111
|
}
|
|
112
112
|
u.allocUnsafe = function(t) {
|
|
113
|
-
return
|
|
113
|
+
return Ve(null, t);
|
|
114
114
|
};
|
|
115
115
|
u.allocUnsafeSlow = function(t) {
|
|
116
|
-
return
|
|
116
|
+
return Ve(null, t);
|
|
117
117
|
};
|
|
118
118
|
function nr(t, e, r) {
|
|
119
119
|
if ((typeof r != "string" || r === "") && (r = "utf8"), !u.isEncoding(r))
|
|
@@ -124,7 +124,7 @@ function nr(t, e, r) {
|
|
|
124
124
|
return i !== n && (t = t.slice(0, i)), t;
|
|
125
125
|
}
|
|
126
126
|
function Ue(t, e) {
|
|
127
|
-
var r = e.length < 0 ? 0 :
|
|
127
|
+
var r = e.length < 0 ? 0 : ze(e.length) | 0;
|
|
128
128
|
t = q(t, r);
|
|
129
129
|
for (var n = 0; n < r; n += 1)
|
|
130
130
|
t[n] = e[n] & 255;
|
|
@@ -139,7 +139,7 @@ function ir(t, e, r, n) {
|
|
|
139
139
|
}
|
|
140
140
|
function or(t, e) {
|
|
141
141
|
if ($(e)) {
|
|
142
|
-
var r =
|
|
142
|
+
var r = ze(e.length) | 0;
|
|
143
143
|
return t = q(t, r), t.length === 0 || e.copy(t, 0, 0, r), t;
|
|
144
144
|
}
|
|
145
145
|
if (e) {
|
|
@@ -150,7 +150,7 @@ function or(t, e) {
|
|
|
150
150
|
}
|
|
151
151
|
throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function ze(t) {
|
|
154
154
|
if (t >= _e())
|
|
155
155
|
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + _e().toString(16) + " bytes");
|
|
156
156
|
return t | 0;
|
|
@@ -1126,18 +1126,18 @@ function Fr(t) {
|
|
|
1126
1126
|
}
|
|
1127
1127
|
}
|
|
1128
1128
|
}
|
|
1129
|
-
var
|
|
1129
|
+
var V = [], ne = !1, ee, me = -1;
|
|
1130
1130
|
function Mr() {
|
|
1131
|
-
!ne || !ee || (ne = !1, ee.length ?
|
|
1131
|
+
!ne || !ee || (ne = !1, ee.length ? V = ee.concat(V) : me = -1, V.length && Dt());
|
|
1132
1132
|
}
|
|
1133
1133
|
function Dt() {
|
|
1134
1134
|
if (!ne) {
|
|
1135
1135
|
var t = Lt(Mr);
|
|
1136
1136
|
ne = !0;
|
|
1137
|
-
for (var e =
|
|
1138
|
-
for (ee =
|
|
1137
|
+
for (var e = V.length; e; ) {
|
|
1138
|
+
for (ee = V, V = []; ++me < e; )
|
|
1139
1139
|
ee && ee[me].run();
|
|
1140
|
-
me = -1, e =
|
|
1140
|
+
me = -1, e = V.length;
|
|
1141
1141
|
}
|
|
1142
1142
|
ee = null, ne = !1, Fr(t);
|
|
1143
1143
|
}
|
|
@@ -1147,7 +1147,7 @@ function U(t) {
|
|
|
1147
1147
|
if (arguments.length > 1)
|
|
1148
1148
|
for (var r = 1; r < arguments.length; r++)
|
|
1149
1149
|
e[r - 1] = arguments[r];
|
|
1150
|
-
|
|
1150
|
+
V.push(new Nt(t, e)), V.length === 1 && !ne && Lt(Dt);
|
|
1151
1151
|
}
|
|
1152
1152
|
function Nt(t, e) {
|
|
1153
1153
|
this.fun = t, this.array = e;
|
|
@@ -1288,7 +1288,7 @@ function ye(t, e, r) {
|
|
|
1288
1288
|
var n = e.inspect(r, t);
|
|
1289
1289
|
return Ye(n) || (n = ye(t, n, r)), n;
|
|
1290
1290
|
}
|
|
1291
|
-
var i =
|
|
1291
|
+
var i = Vr(t, e);
|
|
1292
1292
|
if (i)
|
|
1293
1293
|
return i;
|
|
1294
1294
|
var o = Object.keys(e), s = qr(o);
|
|
@@ -1317,11 +1317,11 @@ function ye(t, e, r) {
|
|
|
1317
1317
|
return Te(e) ? t.stylize(RegExp.prototype.toString.call(e), "regexp") : t.stylize("[Object]", "special");
|
|
1318
1318
|
t.seen.push(e);
|
|
1319
1319
|
var p;
|
|
1320
|
-
return l ? p =
|
|
1320
|
+
return l ? p = zr(t, e, r, s, o) : p = o.map(function(m) {
|
|
1321
1321
|
return Pe(t, e, r, s, m, l);
|
|
1322
1322
|
}), t.seen.pop(), Jr(p, a, c);
|
|
1323
1323
|
}
|
|
1324
|
-
function
|
|
1324
|
+
function Vr(t, e) {
|
|
1325
1325
|
if (Q(e))
|
|
1326
1326
|
return t.stylize("undefined", "undefined");
|
|
1327
1327
|
if (Ye(e)) {
|
|
@@ -1338,7 +1338,7 @@ function zr(t, e) {
|
|
|
1338
1338
|
function Ae(t) {
|
|
1339
1339
|
return "[" + Error.prototype.toString.call(t) + "]";
|
|
1340
1340
|
}
|
|
1341
|
-
function
|
|
1341
|
+
function zr(t, e, r, n, i) {
|
|
1342
1342
|
for (var o = [], s = 0, f = e.length; s < f; ++s)
|
|
1343
1343
|
Bt(e, String(s)) ? o.push(Pe(
|
|
1344
1344
|
t,
|
|
@@ -1873,7 +1873,7 @@ function He(t, e) {
|
|
|
1873
1873
|
var i = t.decodeStrings === !1;
|
|
1874
1874
|
this.decodeStrings = !i, this.defaultEncoding = t.defaultEncoding || "utf8", this.length = 0, this.writing = !1, this.corked = 0, this.sync = !0, this.bufferProcessing = !1, this.onwrite = function(o) {
|
|
1875
1875
|
In(e, o);
|
|
1876
|
-
}, this.writecb = null, this.writelen = 0, this.bufferedRequest = null, this.lastBufferedRequest = null, this.pendingcb = 0, this.prefinished = !1, this.errorEmitted = !1, this.bufferedRequestCount = 0, this.corkedRequestsFree = new
|
|
1876
|
+
}, this.writecb = null, this.writelen = 0, this.bufferedRequest = null, this.lastBufferedRequest = null, this.pendingcb = 0, this.prefinished = !1, this.errorEmitted = !1, this.bufferedRequestCount = 0, this.corkedRequestsFree = new zt(this);
|
|
1877
1877
|
}
|
|
1878
1878
|
He.prototype.getBuffer = function() {
|
|
1879
1879
|
for (var e = this.bufferedRequest, r = []; e; )
|
|
@@ -1944,7 +1944,7 @@ function In(t, e) {
|
|
|
1944
1944
|
}
|
|
1945
1945
|
}
|
|
1946
1946
|
function it(t, e, r, n) {
|
|
1947
|
-
r || Cn(t, e), e.pendingcb--, n(),
|
|
1947
|
+
r || Cn(t, e), e.pendingcb--, n(), Vt(t, e);
|
|
1948
1948
|
}
|
|
1949
1949
|
function Cn(t, e) {
|
|
1950
1950
|
e.length === 0 && e.needDrain && (e.needDrain = !1, t.emit("drain"));
|
|
@@ -1957,7 +1957,7 @@ function jt(t, e) {
|
|
|
1957
1957
|
o.entry = r;
|
|
1958
1958
|
for (var s = 0; r; )
|
|
1959
1959
|
i[s] = r, r = r.next, s += 1;
|
|
1960
|
-
$e(t, e, !0, e.length, i, "", o.finish), e.pendingcb++, e.lastBufferedRequest = null, o.next ? (e.corkedRequestsFree = o.next, o.next = null) : e.corkedRequestsFree = new
|
|
1960
|
+
$e(t, e, !0, e.length, i, "", o.finish), e.pendingcb++, e.lastBufferedRequest = null, o.next ? (e.corkedRequestsFree = o.next, o.next = null) : e.corkedRequestsFree = new zt(e);
|
|
1961
1961
|
} else {
|
|
1962
1962
|
for (; r; ) {
|
|
1963
1963
|
var f = r.chunk, a = r.encoding, l = r.callback, c = e.objectMode ? 1 : f.length;
|
|
@@ -1982,14 +1982,14 @@ function qt(t) {
|
|
|
1982
1982
|
function ot(t, e) {
|
|
1983
1983
|
e.prefinished || (e.prefinished = !0, t.emit("prefinish"));
|
|
1984
1984
|
}
|
|
1985
|
-
function
|
|
1985
|
+
function Vt(t, e) {
|
|
1986
1986
|
var r = qt(e);
|
|
1987
1987
|
return r && (e.pendingcb === 0 ? (ot(t, e), e.finished = !0, t.emit("finish")) : ot(t, e)), r;
|
|
1988
1988
|
}
|
|
1989
1989
|
function On(t, e, r) {
|
|
1990
|
-
e.ending = !0,
|
|
1990
|
+
e.ending = !0, Vt(t, e), r && (e.finished ? U(r) : t.once("finish", r)), e.ended = !0, t.writable = !1;
|
|
1991
1991
|
}
|
|
1992
|
-
function
|
|
1992
|
+
function zt(t) {
|
|
1993
1993
|
var e = this;
|
|
1994
1994
|
this.next = null, this.entry = null, this.finish = function(r) {
|
|
1995
1995
|
var n = e.entry;
|
|
@@ -2073,17 +2073,17 @@ function fe(t) {
|
|
|
2073
2073
|
fe.prototype._transform = function(t, e, r) {
|
|
2074
2074
|
r(null, t);
|
|
2075
2075
|
};
|
|
2076
|
-
oe(
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
function
|
|
2076
|
+
oe(z, g);
|
|
2077
|
+
z.Readable = C;
|
|
2078
|
+
z.Writable = L;
|
|
2079
|
+
z.Duplex = B;
|
|
2080
|
+
z.Transform = k;
|
|
2081
|
+
z.PassThrough = fe;
|
|
2082
|
+
z.Stream = z;
|
|
2083
|
+
function z() {
|
|
2084
2084
|
g.call(this);
|
|
2085
2085
|
}
|
|
2086
|
-
|
|
2086
|
+
z.prototype.pipe = function(t, e) {
|
|
2087
2087
|
var r = this;
|
|
2088
2088
|
function n(c) {
|
|
2089
2089
|
t.writable && t.write(c) === !1 && r.pause && r.pause();
|
|
@@ -3250,7 +3250,7 @@ const Nn = 12, Fn = 13, Mn = 10, Bn = 32, Un = 9, kn = function(t) {
|
|
|
3250
3250
|
}
|
|
3251
3251
|
};
|
|
3252
3252
|
};
|
|
3253
|
-
class
|
|
3253
|
+
class Vn extends k {
|
|
3254
3254
|
constructor(e = {}) {
|
|
3255
3255
|
super({ readableObjectMode: !0, ...e, encoding: null }), this.api = qn({
|
|
3256
3256
|
on_skip: (r, n) => {
|
|
@@ -3309,7 +3309,7 @@ const je = function() {
|
|
|
3309
3309
|
e || {}
|
|
3310
3310
|
);
|
|
3311
3311
|
}
|
|
3312
|
-
const n = new
|
|
3312
|
+
const n = new Vn(e);
|
|
3313
3313
|
if (r) {
|
|
3314
3314
|
const i = e === void 0 || e.objname === void 0 ? [] : {};
|
|
3315
3315
|
n.on("readable", function() {
|
|
@@ -3330,14 +3330,14 @@ const je = function() {
|
|
|
3330
3330
|
}
|
|
3331
3331
|
return n;
|
|
3332
3332
|
};
|
|
3333
|
-
class
|
|
3333
|
+
class zn extends Error {
|
|
3334
3334
|
locator;
|
|
3335
3335
|
/** Logical source of the error. */
|
|
3336
3336
|
constructor(e, r, n) {
|
|
3337
3337
|
super(e, n), this.name = new.target.name, this.locator = r;
|
|
3338
3338
|
}
|
|
3339
3339
|
}
|
|
3340
|
-
class Jn extends
|
|
3340
|
+
class Jn extends zn {
|
|
3341
3341
|
}
|
|
3342
3342
|
class Yn extends Jn {
|
|
3343
3343
|
body;
|
|
@@ -3386,17 +3386,15 @@ class ri {
|
|
|
3386
3386
|
return je(e);
|
|
3387
3387
|
}
|
|
3388
3388
|
/**
|
|
3389
|
-
*
|
|
3389
|
+
* Infer schema.
|
|
3390
3390
|
*/
|
|
3391
|
-
async
|
|
3392
|
-
const i = Xn(r), {
|
|
3393
|
-
console.log("records", o);
|
|
3394
|
-
const f = [], a = [];
|
|
3391
|
+
async inferSchema(e, r, n) {
|
|
3392
|
+
const i = Xn(r), { parsingRecords: o, valueDelimiterId: s } = await Kn(r, n), f = [], a = [];
|
|
3395
3393
|
for (const l of o) {
|
|
3396
3394
|
const c = e.parseRecord(a, l, !0);
|
|
3397
3395
|
f.push(c);
|
|
3398
3396
|
}
|
|
3399
|
-
return console.log("
|
|
3397
|
+
return console.log("inferenceRecords", f), { recordDelimiterId: i, valueDelimiterId: s, parsingRecords: o, inferenceRecords: f, columnConfigs: a };
|
|
3400
3398
|
}
|
|
3401
3399
|
/**
|
|
3402
3400
|
* Parse stream.
|
|
@@ -3490,7 +3488,7 @@ async function Kn(t, e) {
|
|
|
3490
3488
|
});
|
|
3491
3489
|
} catch {
|
|
3492
3490
|
}
|
|
3493
|
-
return {
|
|
3491
|
+
return { parsingRecords: o, valueDelimiterId: r ?? "," };
|
|
3494
3492
|
}
|
|
3495
3493
|
function ei(t) {
|
|
3496
3494
|
const e = Math.max(1, Math.floor(t.chunkSize)), r = [];
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import { Options as ParseOptions, Parser } from 'csv-parse/browser/esm';
|
|
2
2
|
import { EngineUtilities } from '@datapos/datapos-shared/engine';
|
|
3
|
-
import { RetrieveRecordsOptions, RetrieveRecordsSummary } from '@datapos/datapos-shared/component/connector';
|
|
4
|
-
import {
|
|
3
|
+
import { ConnectionColumnConfig, RetrieveRecordsOptions, RetrieveRecordsSummary } from '@datapos/datapos-shared/component/connector';
|
|
4
|
+
import { InferenceRecord, ParsingRecord, RecordDelimiterId, ValueDelimiterId } from '@datapos/datapos-shared/component/dataView';
|
|
5
|
+
/**
|
|
6
|
+
* Schema configuration.
|
|
7
|
+
*/
|
|
8
|
+
interface SchemaConfig {
|
|
9
|
+
recordDelimiterId: RecordDelimiterId;
|
|
10
|
+
valueDelimiterId: ValueDelimiterId;
|
|
11
|
+
parsingRecords: ParsingRecord[];
|
|
12
|
+
inferenceRecords: InferenceRecord[];
|
|
13
|
+
columnConfigs: ConnectionColumnConfig[];
|
|
14
|
+
}
|
|
5
15
|
/** Tool. */
|
|
6
16
|
declare class Tool {
|
|
7
17
|
/** Build parser. */
|
|
8
18
|
buildParser(options: ParseOptions): Parser;
|
|
9
19
|
/**
|
|
10
|
-
*
|
|
20
|
+
* Infer schema.
|
|
11
21
|
*/
|
|
12
|
-
|
|
22
|
+
inferSchema(engineUtilities: EngineUtilities, text: string, delimiters: ValueDelimiterId[]): Promise<SchemaConfig>;
|
|
13
23
|
/**
|
|
14
24
|
* Parse stream.
|
|
15
25
|
*/
|
|
16
|
-
parseStream(retrieveRecordsOptions: RetrieveRecordsOptions, parseOptions: ParseOptions, url: string, abortController: AbortController, chunk: (records:
|
|
26
|
+
parseStream(retrieveRecordsOptions: RetrieveRecordsOptions, parseOptions: ParseOptions, url: string, abortController: AbortController, chunk: (records: ParsingRecord[]) => void): Promise<RetrieveRecordsSummary>;
|
|
17
27
|
}
|
|
18
28
|
export type { Options as ParseOptions, Parser } from 'csv-parse/browser/esm';
|
|
19
29
|
export { Tool };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-tool-csv-parse",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.91",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"prettier": "@datapos/datapos-development/prettierrc",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@datapos/datapos-shared": "^0.3.
|
|
29
|
+
"@datapos/datapos-shared": "^0.3.473",
|
|
30
30
|
"csv-parse": "^6.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|