szdl-utils-kit 0.0.1
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/index.js +233 -0
- package/dist/index.umd.cjs +1 -0
- package/dist/types/batch.d.ts +61 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +38 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
var tt = (p, t, s) => {
|
|
2
|
+
if (!t.has(p))
|
|
3
|
+
throw TypeError("Cannot " + s);
|
|
4
|
+
};
|
|
5
|
+
var e = (p, t, s) => (tt(p, t, "read from private field"), s ? s.call(p) : t.get(p)), o = (p, t, s) => {
|
|
6
|
+
if (t.has(p))
|
|
7
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
8
|
+
t instanceof WeakSet ? t.add(p) : t.set(p, s);
|
|
9
|
+
}, c = (p, t, s, r) => (tt(p, t, "write to private field"), r ? r.call(p, s) : t.set(p, s), s);
|
|
10
|
+
var h = (p, t, s) => (tt(p, t, "access private method"), s);
|
|
11
|
+
var E, x, A, b, j, P, w, T, g, y, W, C, O, S, k, L, Q, B, st, I, et, K, rt, $, it, v, nt, X, mt, Y, pt, z, ht, F, ot, G, lt, M, U, H, ct, Z, dt, D, _, R, V, J, at;
|
|
12
|
+
class Pt {
|
|
13
|
+
constructor(t, s = {}) {
|
|
14
|
+
o(this, L);
|
|
15
|
+
o(this, B);
|
|
16
|
+
o(this, I);
|
|
17
|
+
o(this, K);
|
|
18
|
+
o(this, $);
|
|
19
|
+
o(this, v);
|
|
20
|
+
o(this, X);
|
|
21
|
+
o(this, Y);
|
|
22
|
+
o(this, z);
|
|
23
|
+
o(this, F);
|
|
24
|
+
o(this, G);
|
|
25
|
+
o(this, M);
|
|
26
|
+
o(this, H);
|
|
27
|
+
o(this, Z);
|
|
28
|
+
o(this, D);
|
|
29
|
+
o(this, R);
|
|
30
|
+
o(this, J);
|
|
31
|
+
o(this, E, null);
|
|
32
|
+
o(this, x, null);
|
|
33
|
+
o(this, A, []);
|
|
34
|
+
o(this, b, {});
|
|
35
|
+
o(this, j, {});
|
|
36
|
+
o(this, P, 50);
|
|
37
|
+
o(this, w, !0);
|
|
38
|
+
o(this, T, null);
|
|
39
|
+
o(this, g, null);
|
|
40
|
+
o(this, y, null);
|
|
41
|
+
o(this, W, 100);
|
|
42
|
+
o(this, C, "no");
|
|
43
|
+
o(this, O, !1);
|
|
44
|
+
o(this, S, !1);
|
|
45
|
+
o(this, k, !1);
|
|
46
|
+
c(this, E, t), c(this, x, s);
|
|
47
|
+
}
|
|
48
|
+
get serial() {
|
|
49
|
+
return e(this, O);
|
|
50
|
+
}
|
|
51
|
+
setSerial() {
|
|
52
|
+
c(this, O, !0), c(this, S, !0), c(this, k, !1);
|
|
53
|
+
}
|
|
54
|
+
setParallel() {
|
|
55
|
+
c(this, O, !1), c(this, S, !1), c(this, k, !0);
|
|
56
|
+
}
|
|
57
|
+
stop() {
|
|
58
|
+
c(this, w, !1);
|
|
59
|
+
}
|
|
60
|
+
async batch(t, s) {
|
|
61
|
+
e(this, y) && h(this, B, st).call(this), s && c(this, T, s), e(this, S) === !1 && c(this, O, !1), Object.keys(t).length > 500 && c(this, O, !0), c(this, w, !0), c(this, A, []), c(this, b, {}), c(this, j, {});
|
|
62
|
+
const r = h(this, K, rt).call(this, t);
|
|
63
|
+
if (Object.keys(t).length < 500) {
|
|
64
|
+
const i = r.map((l, n) => h(this, $, it).call(this, l, r[n]));
|
|
65
|
+
return Promise.allSettled(i).then((l) => {
|
|
66
|
+
let n = {};
|
|
67
|
+
for (let u of l)
|
|
68
|
+
u.status === "fulfilled" && (n = { ...n, ...u.value });
|
|
69
|
+
return n;
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
let i = {}, l = 0, n = 1, u = Object.keys(t).length || 1, a = (f) => {
|
|
73
|
+
l += Object.keys(f).length, n = Math.round(l / u * 100);
|
|
74
|
+
};
|
|
75
|
+
for (let [f, m] of Object.entries(r)) {
|
|
76
|
+
let d = await h(this, $, it).call(this, m, r[f], !0);
|
|
77
|
+
a(m), s && s({ percent: n }), i = { ...i, ...d };
|
|
78
|
+
}
|
|
79
|
+
return i;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async batchTotalCount(t, s) {
|
|
83
|
+
c(this, b, {}), c(this, j, {});
|
|
84
|
+
let r = 1, i = 0, l = Object.keys(t).length || 1, n = (a) => {
|
|
85
|
+
i += Object.keys(a).length, r = Math.round(i / l * 100);
|
|
86
|
+
};
|
|
87
|
+
s && s({ percent: r });
|
|
88
|
+
const u = h(this, K, rt).call(this, t);
|
|
89
|
+
if (e(this, k)) {
|
|
90
|
+
const a = u.map((f) => h(this, v, nt).call(this, f).then((m) => (n(f), s && s({ percent: r }), m)));
|
|
91
|
+
return Promise.allSettled(a).then((f) => {
|
|
92
|
+
let m = {};
|
|
93
|
+
for (let d of f)
|
|
94
|
+
d.status === "fulfilled" && (m = { ...m, ...d.value });
|
|
95
|
+
return m;
|
|
96
|
+
});
|
|
97
|
+
} else {
|
|
98
|
+
let a = {};
|
|
99
|
+
for (let f of u) {
|
|
100
|
+
let m = await h(this, v, nt).call(this, f);
|
|
101
|
+
n(f), s && s({ percent: r }), a = { ...a, ...m };
|
|
102
|
+
}
|
|
103
|
+
return a;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
E = new WeakMap(), x = new WeakMap(), A = new WeakMap(), b = new WeakMap(), j = new WeakMap(), P = new WeakMap(), w = new WeakMap(), T = new WeakMap(), g = new WeakMap(), y = new WeakMap(), W = new WeakMap(), C = new WeakMap(), O = new WeakMap(), S = new WeakMap(), k = new WeakMap(), L = new WeakSet(), Q = function() {
|
|
108
|
+
let t = 0;
|
|
109
|
+
if (!e(this, g))
|
|
110
|
+
return Math.round(t);
|
|
111
|
+
let s = 0, r = 0;
|
|
112
|
+
return Object.values(e(this, g)).forEach((i) => {
|
|
113
|
+
const { total: l, count: n } = i;
|
|
114
|
+
s += l ?? 0, r += n ?? 0;
|
|
115
|
+
}), s ? t = r / s * 100 : t = 100, { percent: Math.round(t), allCount: r, allTotal: s };
|
|
116
|
+
}, B = new WeakSet(), st = function() {
|
|
117
|
+
clearInterval(e(this, y)), c(this, y, ""), c(this, g, ""), c(this, T, ""), c(this, C, "no");
|
|
118
|
+
}, I = new WeakSet(), et = function({ key: t, value: s }) {
|
|
119
|
+
const r = h(this, D, _).call(this, s.data()), i = Array.isArray(r) ? r.length : 0, l = h(this, R, V).call(this, s.total(), i);
|
|
120
|
+
let n = 1;
|
|
121
|
+
r && (n = i), e(this, T) && (e(this, g) || c(this, g, {}), e(this, g)[t] && e(this, g)[t].count && (n += e(this, g)[t].count), e(this, g)[t] = { total: l, count: n }, e(this, y) || c(this, y, setInterval(() => {
|
|
122
|
+
const { percent: u, allCount: a, allTotal: f } = e(this, L, Q);
|
|
123
|
+
(e(this, C) === "no" || e(this, C) < e(this, L, Q).percent) && (e(this, T).call(this, {
|
|
124
|
+
data: e(this, g),
|
|
125
|
+
percent: u,
|
|
126
|
+
allCount: a,
|
|
127
|
+
allTotal: f
|
|
128
|
+
}), c(this, C, e(this, L, Q).percent)), u === 100 && h(this, B, st).call(this);
|
|
129
|
+
}, e(this, W))));
|
|
130
|
+
}, K = new WeakSet(), rt = function(t) {
|
|
131
|
+
const s = [], r = Object.entries(t);
|
|
132
|
+
for (let i = 0; i < r.length; i += e(this, P)) {
|
|
133
|
+
const l = r.slice(i, i + e(this, P));
|
|
134
|
+
s.push(Object.fromEntries(l));
|
|
135
|
+
}
|
|
136
|
+
return s;
|
|
137
|
+
}, $ = new WeakSet(), it = function(t, s, r) {
|
|
138
|
+
return new Promise((i) => {
|
|
139
|
+
const l = h(this, H, ct).call(this, s), n = [];
|
|
140
|
+
let u = 0, a = 0;
|
|
141
|
+
e(this, E).call(this, t, (f) => {
|
|
142
|
+
Object.entries(f).forEach(([m, d]) => {
|
|
143
|
+
const ut = d.error();
|
|
144
|
+
ut && (e(this, j)[m] = ut, u += 1);
|
|
145
|
+
const q = h(this, D, _).call(this, d.data()), ft = Array.isArray(q) ? q.length : 0, N = h(this, R, V).call(this, d.total(), ft);
|
|
146
|
+
if (e(this, b)[m] = q, a += N, r || h(this, I, et).call(this, { key: m, value: d }), N > e(this, P) && N > ft) {
|
|
147
|
+
const gt = Math.ceil(N / e(this, P)) - 1, bt = Array.from({ length: gt });
|
|
148
|
+
n.push([m, l[m], bt]);
|
|
149
|
+
}
|
|
150
|
+
}), a > 5e3 && e(this, S) === !1 && e(this, k) === !1 && c(this, O, !0), u > 0 && h(this, J, at).call(this), n.length ? (h(this, X, mt).call(this, n), h(this, Y, pt).call(this).then(() => i(h(this, M, U).call(this)))) : i(h(this, M, U).call(this));
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}, v = new WeakSet(), nt = function(t) {
|
|
154
|
+
return new Promise((s) => {
|
|
155
|
+
const r = h(this, H, ct).call(this, t);
|
|
156
|
+
let i = 0;
|
|
157
|
+
e(this, E).call(this, r, (l) => {
|
|
158
|
+
Object.entries(l).forEach(([n, u]) => {
|
|
159
|
+
const a = u.error();
|
|
160
|
+
a && (e(this, j)[n] = a, i += 1);
|
|
161
|
+
const f = h(this, D, _).call(this, u.data()), m = Array.isArray(f) ? f.length : 0, d = h(this, R, V).call(this, u.total(), m);
|
|
162
|
+
e(this, b)[n] = d;
|
|
163
|
+
}), i > 0 && h(this, J, at).call(this), s(h(this, M, U).call(this));
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}, X = new WeakSet(), mt = function(t) {
|
|
167
|
+
let s = [];
|
|
168
|
+
t.forEach(([r, i, l]) => {
|
|
169
|
+
l.forEach((n, u) => {
|
|
170
|
+
const a = u + 1, f = e(this, P) * a, d = [[r, a].join("_"), h(this, Z, dt).call(this, i, f)];
|
|
171
|
+
s.length === e(this, P) ? (e(this, A).push(s), s = [d]) : s.push(d);
|
|
172
|
+
});
|
|
173
|
+
}), s.length && e(this, A).push(s);
|
|
174
|
+
}, Y = new WeakSet(), pt = function() {
|
|
175
|
+
const t = [], s = [], r = (i) => {
|
|
176
|
+
Object.entries(i).forEach(([l, n]) => {
|
|
177
|
+
const [u] = l.split("_"), a = h(this, D, _).call(this, n.data());
|
|
178
|
+
Array.isArray(a) && e(this, b)[u].push(...a), h(this, I, et).call(this, { key: u, value: n });
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
return e(this, A).forEach((i, l) => {
|
|
182
|
+
const n = Object.fromEntries(i), u = () => new Promise((a) => e(this, E).call(this, n, (f) => {
|
|
183
|
+
e(this, O) ? r(f) : s[l] = f, a();
|
|
184
|
+
}));
|
|
185
|
+
t.push(u);
|
|
186
|
+
}), e(this, O) ? h(this, F, ot).call(this, t) : h(this, G, lt).call(this, t).then(() => {
|
|
187
|
+
s.forEach(r);
|
|
188
|
+
});
|
|
189
|
+
}, z = new WeakSet(), ht = function() {
|
|
190
|
+
return new Promise((t) => setTimeout(t, 500));
|
|
191
|
+
}, F = new WeakSet(), ot = function(t) {
|
|
192
|
+
if (!t.length)
|
|
193
|
+
return Promise.resolve();
|
|
194
|
+
const s = t.shift();
|
|
195
|
+
return Promise.allSettled([
|
|
196
|
+
s(),
|
|
197
|
+
h(this, z, ht).call(this)
|
|
198
|
+
]).then(() => e(this, w) ? h(this, F, ot).call(this, t) : Promise.resolve());
|
|
199
|
+
}, G = new WeakSet(), lt = function(t) {
|
|
200
|
+
if (!t.length)
|
|
201
|
+
return Promise.resolve();
|
|
202
|
+
const s = t.shift();
|
|
203
|
+
return h(this, z, ht).call(this).then(() => s()).then(() => e(this, w) ? h(this, G, lt).call(this, t) : Promise.resolve());
|
|
204
|
+
}, M = new WeakSet(), U = function() {
|
|
205
|
+
return Object.entries(e(this, x)).forEach(([t, s]) => {
|
|
206
|
+
e(this, b)[t] && (e(this, b)[t] = s(e(this, b)[t]));
|
|
207
|
+
}), e(this, b);
|
|
208
|
+
}, H = new WeakSet(), ct = function(t) {
|
|
209
|
+
return Object.entries(t).reduce((s, [r, i]) => {
|
|
210
|
+
if (Array.isArray(i)) {
|
|
211
|
+
const [l, n = {}] = i;
|
|
212
|
+
s[r] = [l, n];
|
|
213
|
+
} else {
|
|
214
|
+
const { method: l, params: n = {} } = i;
|
|
215
|
+
s[r] = [l, n];
|
|
216
|
+
}
|
|
217
|
+
return s;
|
|
218
|
+
}, {});
|
|
219
|
+
}, Z = new WeakSet(), dt = function(t, s) {
|
|
220
|
+
const [r, i] = t;
|
|
221
|
+
return [r, { start: s, ...i }];
|
|
222
|
+
}, D = new WeakSet(), _ = function(t) {
|
|
223
|
+
return ((t == null ? void 0 : t.items) || (t == null ? void 0 : t.documents)) ?? t;
|
|
224
|
+
}, R = new WeakSet(), V = function(t, s) {
|
|
225
|
+
return t !== t && (t = 0), t === 0 && s === 0 ? 0 : t || s;
|
|
226
|
+
}, J = new WeakSet(), at = function() {
|
|
227
|
+
console.group(`${this.constructor.name}: Ошибки в методах!`), Object.entries(e(this, j)).forEach(([t, s]) => {
|
|
228
|
+
console.info(`[${t}]`, s.toString());
|
|
229
|
+
}), console.groupEnd();
|
|
230
|
+
};
|
|
231
|
+
export {
|
|
232
|
+
Pt as Batch
|
|
233
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var et=(d,m,p)=>{if(!m.has(d))throw TypeError("Cannot "+p)};var s=(d,m,p)=>(et(d,m,"read from private field"),p?p.call(d):m.get(d)),o=(d,m,p)=>{if(m.has(d))throw TypeError("Cannot add the same private member more than once");m instanceof WeakSet?m.add(d):m.set(d,p)},c=(d,m,p,E)=>(et(d,m,"write to private field"),E?E.call(d,p):m.set(d,p),p);var h=(d,m,p)=>(et(d,m,"access private method"),p);(function(d,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(d=typeof globalThis<"u"?globalThis:d||self,m(d["szdl-utils-kit"]={}))})(this,function(d){var p,E,w,j,A,P,S,k,y,T,Q,C,O,M,D,R,Y,_,st,v,it,I,rt,K,nt,$,ht,U,mt,V,pt,z,ot,F,lt,G,ct,x,Z,H,at,W,gt,L,N,B,q,J,ut;"use strict";class m{constructor(t,e={}){o(this,R);o(this,_);o(this,v);o(this,I);o(this,K);o(this,$);o(this,U);o(this,V);o(this,z);o(this,F);o(this,G);o(this,x);o(this,H);o(this,W);o(this,L);o(this,B);o(this,J);o(this,p,null);o(this,E,null);o(this,w,[]);o(this,j,{});o(this,A,{});o(this,P,50);o(this,S,!0);o(this,k,null);o(this,y,null);o(this,T,null);o(this,Q,100);o(this,C,"no");o(this,O,!1);o(this,M,!1);o(this,D,!1);c(this,p,t),c(this,E,e)}get serial(){return s(this,O)}setSerial(){c(this,O,!0),c(this,M,!0),c(this,D,!1)}setParallel(){c(this,O,!1),c(this,M,!1),c(this,D,!0)}stop(){c(this,S,!1)}async batch(t,e){s(this,T)&&h(this,_,st).call(this),e&&c(this,k,e),s(this,M)===!1&&c(this,O,!1),Object.keys(t).length>500&&c(this,O,!0),c(this,S,!0),c(this,w,[]),c(this,j,{}),c(this,A,{});const r=h(this,I,rt).call(this,t);if(Object.keys(t).length<500){const i=r.map((l,n)=>h(this,K,nt).call(this,l,r[n]));return Promise.allSettled(i).then(l=>{let n={};for(let u of l)u.status==="fulfilled"&&(n={...n,...u.value});return n})}else{let i={},l=0,n=1,u=Object.keys(t).length||1,a=f=>{l+=Object.keys(f).length,n=Math.round(l/u*100)};for(let[f,g]of Object.entries(r)){let b=await h(this,K,nt).call(this,g,r[f],!0);a(g),e&&e({percent:n}),i={...i,...b}}return i}}async batchTotalCount(t,e){c(this,j,{}),c(this,A,{});let r=1,i=0,l=Object.keys(t).length||1,n=a=>{i+=Object.keys(a).length,r=Math.round(i/l*100)};e&&e({percent:r});const u=h(this,I,rt).call(this,t);if(s(this,D)){const a=u.map(f=>h(this,$,ht).call(this,f).then(g=>(n(f),e&&e({percent:r}),g)));return Promise.allSettled(a).then(f=>{let g={};for(let b of f)b.status==="fulfilled"&&(g={...g,...b.value});return g})}else{let a={};for(let f of u){let g=await h(this,$,ht).call(this,f);n(f),e&&e({percent:r}),a={...a,...g}}return a}}}p=new WeakMap,E=new WeakMap,w=new WeakMap,j=new WeakMap,A=new WeakMap,P=new WeakMap,S=new WeakMap,k=new WeakMap,y=new WeakMap,T=new WeakMap,Q=new WeakMap,C=new WeakMap,O=new WeakMap,M=new WeakMap,D=new WeakMap,R=new WeakSet,Y=function(){let t=0;if(!s(this,y))return Math.round(t);let e=0,r=0;return Object.values(s(this,y)).forEach(i=>{const{total:l,count:n}=i;e+=l??0,r+=n??0}),e?t=r/e*100:t=100,{percent:Math.round(t),allCount:r,allTotal:e}},_=new WeakSet,st=function(){clearInterval(s(this,T)),c(this,T,""),c(this,y,""),c(this,k,""),c(this,C,"no")},v=new WeakSet,it=function({key:t,value:e}){const r=h(this,L,N).call(this,e.data()),i=Array.isArray(r)?r.length:0,l=h(this,B,q).call(this,e.total(),i);let n=1;r&&(n=i),s(this,k)&&(s(this,y)||c(this,y,{}),s(this,y)[t]&&s(this,y)[t].count&&(n+=s(this,y)[t].count),s(this,y)[t]={total:l,count:n},s(this,T)||c(this,T,setInterval(()=>{const{percent:u,allCount:a,allTotal:f}=s(this,R,Y);(s(this,C)==="no"||s(this,C)<s(this,R,Y).percent)&&(s(this,k).call(this,{data:s(this,y),percent:u,allCount:a,allTotal:f}),c(this,C,s(this,R,Y).percent)),u===100&&h(this,_,st).call(this)},s(this,Q))))},I=new WeakSet,rt=function(t){const e=[],r=Object.entries(t);for(let i=0;i<r.length;i+=s(this,P)){const l=r.slice(i,i+s(this,P));e.push(Object.fromEntries(l))}return e},K=new WeakSet,nt=function(t,e,r){return new Promise(i=>{const l=h(this,H,at).call(this,e),n=[];let u=0,a=0;s(this,p).call(this,t,f=>{Object.entries(f).forEach(([g,b])=>{const ft=b.error();ft&&(s(this,A)[g]=ft,u+=1);const tt=h(this,L,N).call(this,b.data()),dt=Array.isArray(tt)?tt.length:0,X=h(this,B,q).call(this,b.total(),dt);if(s(this,j)[g]=tt,a+=X,r||h(this,v,it).call(this,{key:g,value:b}),X>s(this,P)&&X>dt){const bt=Math.ceil(X/s(this,P))-1,yt=Array.from({length:bt});n.push([g,l[g],yt])}}),a>5e3&&s(this,M)===!1&&s(this,D)===!1&&c(this,O,!0),u>0&&h(this,J,ut).call(this),n.length?(h(this,U,mt).call(this,n),h(this,V,pt).call(this).then(()=>i(h(this,x,Z).call(this)))):i(h(this,x,Z).call(this))})})},$=new WeakSet,ht=function(t){return new Promise(e=>{const r=h(this,H,at).call(this,t);let i=0;s(this,p).call(this,r,l=>{Object.entries(l).forEach(([n,u])=>{const a=u.error();a&&(s(this,A)[n]=a,i+=1);const f=h(this,L,N).call(this,u.data()),g=Array.isArray(f)?f.length:0,b=h(this,B,q).call(this,u.total(),g);s(this,j)[n]=b}),i>0&&h(this,J,ut).call(this),e(h(this,x,Z).call(this))})})},U=new WeakSet,mt=function(t){let e=[];t.forEach(([r,i,l])=>{l.forEach((n,u)=>{const a=u+1,f=s(this,P)*a,b=[[r,a].join("_"),h(this,W,gt).call(this,i,f)];e.length===s(this,P)?(s(this,w).push(e),e=[b]):e.push(b)})}),e.length&&s(this,w).push(e)},V=new WeakSet,pt=function(){const t=[],e=[],r=i=>{Object.entries(i).forEach(([l,n])=>{const[u]=l.split("_"),a=h(this,L,N).call(this,n.data());Array.isArray(a)&&s(this,j)[u].push(...a),h(this,v,it).call(this,{key:u,value:n})})};return s(this,w).forEach((i,l)=>{const n=Object.fromEntries(i),u=()=>new Promise(a=>s(this,p).call(this,n,f=>{s(this,O)?r(f):e[l]=f,a()}));t.push(u)}),s(this,O)?h(this,F,lt).call(this,t):h(this,G,ct).call(this,t).then(()=>{e.forEach(r)})},z=new WeakSet,ot=function(){return new Promise(t=>setTimeout(t,500))},F=new WeakSet,lt=function(t){if(!t.length)return Promise.resolve();const e=t.shift();return Promise.allSettled([e(),h(this,z,ot).call(this)]).then(()=>s(this,S)?h(this,F,lt).call(this,t):Promise.resolve())},G=new WeakSet,ct=function(t){if(!t.length)return Promise.resolve();const e=t.shift();return h(this,z,ot).call(this).then(()=>e()).then(()=>s(this,S)?h(this,G,ct).call(this,t):Promise.resolve())},x=new WeakSet,Z=function(){return Object.entries(s(this,E)).forEach(([t,e])=>{s(this,j)[t]&&(s(this,j)[t]=e(s(this,j)[t]))}),s(this,j)},H=new WeakSet,at=function(t){return Object.entries(t).reduce((e,[r,i])=>{if(Array.isArray(i)){const[l,n={}]=i;e[r]=[l,n]}else{const{method:l,params:n={}}=i;e[r]=[l,n]}return e},{})},W=new WeakSet,gt=function(t,e){const[r,i]=t;return[r,{start:e,...i}]},L=new WeakSet,N=function(t){return((t==null?void 0:t.items)||(t==null?void 0:t.documents))??t},B=new WeakSet,q=function(t,e){return t!==t&&(t=0),t===0&&e===0?0:t||e},J=new WeakSet,ut=function(){console.group(`${this.constructor.name}: Ошибки в методах!`),Object.entries(s(this,A)).forEach(([t,e])=>{console.info(`[${t}]`,e.toString())}),console.groupEnd()},d.Batch=m,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
type TCommand = {
|
|
2
|
+
method: string,
|
|
3
|
+
params: Record<string, unknown> | {
|
|
4
|
+
select?: string[],
|
|
5
|
+
filter?: Record<string, string | string[]>,
|
|
6
|
+
} | {
|
|
7
|
+
id?: string,
|
|
8
|
+
params?: Record<string, string>,
|
|
9
|
+
fields?: Record<string, unknown>,
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class Batch{
|
|
14
|
+
/**
|
|
15
|
+
* @constructor
|
|
16
|
+
* @param {()=>void} callBatch - пробрасываем метод BX24.callBatch
|
|
17
|
+
*/
|
|
18
|
+
constructor(callBatch:()=>void);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Флаг режима передачи
|
|
22
|
+
*/
|
|
23
|
+
serial: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Установить последовательный режим
|
|
27
|
+
*/
|
|
28
|
+
setSerial: ()=> void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Установить параллельный режим режим
|
|
32
|
+
*/
|
|
33
|
+
setParallel: ()=>void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Принудительно остановить выгрузку данных
|
|
37
|
+
*/
|
|
38
|
+
stop: ()=>void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Запрос данных
|
|
42
|
+
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
43
|
+
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
44
|
+
*/
|
|
45
|
+
batch: (
|
|
46
|
+
commandList: Record<string, TCommand>,
|
|
47
|
+
progressCall?: (data:{ percent: number })=>void
|
|
48
|
+
) => Record<string, unknown[]>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Запрос количества элементов по запрощенным сущностям
|
|
52
|
+
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
53
|
+
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
54
|
+
*/
|
|
55
|
+
batchTotalCount: (
|
|
56
|
+
commandList: Record<string, TCommand>,
|
|
57
|
+
progressCall?: (data:{ percent: number })=>void
|
|
58
|
+
) => Record<string, number>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default Batch;
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "szdl-utils-kit",
|
|
3
|
+
"description": "utils-kit library",
|
|
4
|
+
"private": false,
|
|
5
|
+
"version": "0.0.1",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"author": "Stanislav Ovv",
|
|
8
|
+
"license": "BSD",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"main": "./dist/index.umd.cjs",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.umd.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"szdl",
|
|
23
|
+
"utils",
|
|
24
|
+
"szdl-utils-kit"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "vite --host",
|
|
28
|
+
"watch": "vite build --watch",
|
|
29
|
+
"build": "vite build",
|
|
30
|
+
"preview": "vite preview",
|
|
31
|
+
"pub": "npm version patch && npm publish"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"vite": "^4.4.5",
|
|
35
|
+
"vite-plugin-dts": "^3.6.0",
|
|
36
|
+
"vite-plugin-static-copy": "^0.17.0"
|
|
37
|
+
}
|
|
38
|
+
}
|