datafolder 1.0.40 → 1.0.41
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/ChangeLog.md +2 -0
- package/package.json +1 -1
- package/src/QyAcl.d.ts +8 -7
- package/src/QyAcl.js +117 -161
- package/src/QyAclSaver_Worker.d.ts +2 -2
- package/src/QyAclWriter.js +5 -14
- package/src/QyBatch.d.ts +1 -0
- package/src/QyBatch.js +154 -149
- package/src/QyCD.d.ts +3 -3
- package/src/QyDB.d.ts +3 -2
- package/src/QyDefaultOptions.js +0 -3
- package/src/QyKVData.js +1 -1
- package/src/QyKVDataSaver_Worker.d.ts +6 -4
- package/src/QySnapshotSaver_Worker.d.ts +1 -1
- package/src/QySnapshotSaver_Worker.js +12 -12
package/ChangeLog.md
CHANGED
package/package.json
CHANGED
package/src/QyAcl.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
export declare const CmdName_M = 0;
|
|
2
|
-
export declare const CmdName_A = 1;
|
|
3
|
-
export declare const CmdName_R = 2;
|
|
4
|
-
export declare const CmdName_D = 3;
|
|
5
1
|
export declare function applyAclCmdObj(aclKeyValueMap: any, cmdArgAsListArray: any): void;
|
|
6
2
|
export declare function iterCmdKeys(cmdArgAsListArray: any, fun: any): void;
|
|
7
3
|
export declare function applyChange(oldContent: any, newValue: any): any;
|
|
8
4
|
export declare class QyAclCmdGenerator {
|
|
9
5
|
cmdCount: number;
|
|
10
6
|
batchSize: number;
|
|
11
|
-
|
|
7
|
+
mMap: Map<any, any>;
|
|
8
|
+
aRMap: Map<any, any>;
|
|
9
|
+
dSet: Set<unknown>;
|
|
12
10
|
_cmdArgAsListArray: any[];
|
|
13
|
-
|
|
11
|
+
pushMCmd(cmdHashKey: any, value: any): void;
|
|
12
|
+
pushMPropCmd(cmdHashKey: any, prop: any, value: any): void;
|
|
13
|
+
pushACmd(cmdHashKey: any, name: any): void;
|
|
14
|
+
pushRCmd(cmdHashKey: any, name: any): void;
|
|
15
|
+
pushDCmd(cmdHashKey: any): void;
|
|
14
16
|
pushCmdArgAsListArray(cmdArgAsListArray: any): this;
|
|
15
17
|
takeCmdArgAsListArray(): any[];
|
|
16
18
|
toAclBuffer(changeId: any): Buffer<ArrayBuffer> | undefined;
|
|
17
19
|
}
|
|
18
20
|
export declare function numsToBuffer(nums: any): Buffer<ArrayBuffer>;
|
|
19
21
|
export declare function bufferToNums(buffer: any, offset: any, nums: any): any;
|
|
20
|
-
export declare function toAclBuffer(changeId: any, batchSize: any, cmdArgAsListArrayStr: any): Buffer<ArrayBuffer>;
|
|
21
22
|
export declare function readAclBuffer(aclFilePath: any, contentBuffer: any, autoRepairAclFile: any, currentChangeId: any): Promise<any[]>;
|
package/src/QyAcl.js
CHANGED
|
@@ -1,53 +1,47 @@
|
|
|
1
1
|
import h from "node:fs/promises";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
toBuffer as i,
|
|
10
|
-
isSimpleType as f,
|
|
11
|
-
isArray as o,
|
|
12
|
-
trimArrayTail as n
|
|
4
|
+
isEmptyObj as g,
|
|
5
|
+
toBuffer as a,
|
|
6
|
+
isSimpleType as n,
|
|
7
|
+
isArray as s,
|
|
8
|
+
trimArrayTail as f
|
|
13
9
|
} from "./QyUtils.js";
|
|
14
10
|
|
|
15
11
|
import {
|
|
16
|
-
logger as
|
|
12
|
+
logger as d
|
|
17
13
|
} from "./QyLogger.js";
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function l(t, r) {
|
|
15
|
+
function r(t, r) {
|
|
22
16
|
var [ e, a, i, r ] = r;
|
|
23
17
|
if (r) for (var n of r) void 0 !== t[n] && (t[n] = void 0);
|
|
24
18
|
if (a) {
|
|
25
19
|
var s = a.length;
|
|
26
20
|
for (let r = 0; r < s; r += 2) {
|
|
27
|
-
var f, o = a[r],
|
|
28
|
-
for (f of a[r + 1])
|
|
21
|
+
var f, o = a[r], u = t[o] || (t[o] = {});
|
|
22
|
+
for (f of a[r + 1]) u[f] = 1;
|
|
29
23
|
}
|
|
30
24
|
}
|
|
31
25
|
if (i) {
|
|
32
|
-
var
|
|
33
|
-
for (let r = 0; r <
|
|
34
|
-
var h = i[r],
|
|
35
|
-
if (null !=
|
|
36
|
-
for (var
|
|
37
|
-
|
|
26
|
+
var l = i.length;
|
|
27
|
+
for (let r = 0; r < l; r += 2) {
|
|
28
|
+
var h = i[r], d = t[h];
|
|
29
|
+
if (null != d) {
|
|
30
|
+
for (var c of i[r + 1]) delete d[c];
|
|
31
|
+
g(d) && (t[h] = void 0);
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
35
|
if (e) {
|
|
42
|
-
var
|
|
43
|
-
for (let r = 0; r <
|
|
44
|
-
var
|
|
45
|
-
t[
|
|
36
|
+
var v = e.length;
|
|
37
|
+
for (let r = 0; r < v; r += 2) {
|
|
38
|
+
var p = e[r];
|
|
39
|
+
t[p] = m(t[p], e[r + 1]);
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
function
|
|
44
|
+
function t(r, t) {
|
|
51
45
|
var [ e, a, i, r ] = r;
|
|
52
46
|
if (e) {
|
|
53
47
|
var n = e.length;
|
|
@@ -68,170 +62,142 @@ function m(r, t) {
|
|
|
68
62
|
if (null !== t) {
|
|
69
63
|
var e, a = t.$u8;
|
|
70
64
|
if (a) return new Uint8Array(a);
|
|
71
|
-
if (null == r ||
|
|
65
|
+
if (null == r || n(r) || n(t) || s(t) || t.$rpl) return t;
|
|
72
66
|
for (e in t) {
|
|
73
67
|
var i = m(r[e], t[e]);
|
|
74
68
|
void 0 !== i ? r[e] = i : delete r[e];
|
|
75
69
|
}
|
|
76
|
-
return
|
|
70
|
+
return s(r) && f(r), r;
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
73
|
|
|
80
|
-
class
|
|
74
|
+
class e {
|
|
81
75
|
cmdCount = 0;
|
|
82
76
|
batchSize = 0;
|
|
83
|
-
|
|
77
|
+
mMap = new Map();
|
|
78
|
+
aRMap = new Map();
|
|
79
|
+
dSet = new Set();
|
|
84
80
|
_cmdArgAsListArray = [];
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
case 2:
|
|
109
|
-
d(this, [ 2, t, e ]), g(this, [ 1, t, e ]);
|
|
110
|
-
break;
|
|
111
|
-
|
|
112
|
-
case 3:
|
|
113
|
-
var i = this.cmdArgAsMapArray, n = i[3];
|
|
114
|
-
if (n ? n.push(t) : i[3] = [ t ], t.startsWith("c")) g(this, [ 0, t ]); else for (var s of [ 1, 2 ]) g(this, [ s, t ]);
|
|
115
|
-
break;
|
|
116
|
-
|
|
117
|
-
default:
|
|
118
|
-
c.error(`unsupported cmdName:${r}, called with ${t} ` + e), --this.cmdCount;
|
|
119
|
-
}
|
|
81
|
+
pushMCmd(r, t) {
|
|
82
|
+
++this.cmdCount;
|
|
83
|
+
var e = this.mMap;
|
|
84
|
+
e.set(r, function r(t, e) {
|
|
85
|
+
if (null === e) return null;
|
|
86
|
+
if (void 0 === t || n(e) || s(e) || e.$rpl || e.$u8) return e;
|
|
87
|
+
if (null === t || n(t)) return e.$rpl = 1, e;
|
|
88
|
+
for (var a in e) t[a] = r(t[a], e[a]);
|
|
89
|
+
return t;
|
|
90
|
+
}(e.get(r), t));
|
|
91
|
+
}
|
|
92
|
+
pushMPropCmd(r, t, e) {
|
|
93
|
+
++this.cmdCount, this.mMap.getOrInsert(r, {})[t] = e;
|
|
94
|
+
}
|
|
95
|
+
pushACmd(r, t) {
|
|
96
|
+
++this.cmdCount, this.aRMap.getOrInsertComputed(r, () => new Map()).set(t, 1);
|
|
97
|
+
}
|
|
98
|
+
pushRCmd(r, t) {
|
|
99
|
+
++this.cmdCount, this.aRMap.getOrInsertComputed(r, () => new Map()).set(t, 0);
|
|
100
|
+
}
|
|
101
|
+
pushDCmd(r) {
|
|
102
|
+
++this.cmdCount, this.dSet.add(r), (r.startsWith("c") ? this.mMap : this.aRMap).delete(r);
|
|
120
103
|
}
|
|
121
104
|
pushCmdArgAsListArray(r) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
for (s of e[r + 1]) this.pushCmd(1, f, s);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (a) {
|
|
134
|
-
var o = a.length;
|
|
135
|
-
for (let r = 0; r < o; r += 2) {
|
|
136
|
-
var l, u = a[r];
|
|
137
|
-
for (l of a[r + 1]) this.pushCmd(2, u, l);
|
|
138
|
-
}
|
|
105
|
+
++this.batchSize;
|
|
106
|
+
var [ t, e, a, r ] = r;
|
|
107
|
+
if (r) for (var i of r) this.pushDCmd(i);
|
|
108
|
+
if (e) {
|
|
109
|
+
var n = e.length;
|
|
110
|
+
for (let r = 0; r < n; r += 2) {
|
|
111
|
+
var s, f = e[r];
|
|
112
|
+
for (s of e[r + 1]) this.pushACmd(f, s);
|
|
139
113
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
114
|
+
}
|
|
115
|
+
if (a) {
|
|
116
|
+
var o = a.length;
|
|
117
|
+
for (let r = 0; r < o; r += 2) {
|
|
118
|
+
var u, l = a[r];
|
|
119
|
+
for (u of a[r + 1]) this.pushRCmd(l, u);
|
|
143
120
|
}
|
|
144
121
|
}
|
|
122
|
+
if (t) {
|
|
123
|
+
var h = t.length;
|
|
124
|
+
for (let r = 0; r < h; r += 2) this.pushMCmd(t[r], t[r + 1]);
|
|
125
|
+
}
|
|
145
126
|
return this;
|
|
146
127
|
}
|
|
147
128
|
takeCmdArgAsListArray() {
|
|
148
129
|
var {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
130
|
+
mMap: t,
|
|
131
|
+
aRMap: r,
|
|
132
|
+
dSet: e,
|
|
133
|
+
_cmdArgAsListArray: a
|
|
134
|
+
} = this;
|
|
135
|
+
if ((a.length = 0) < e.size && (a[3] = [ ...e.keys() ], e.clear()), 0 < r.size) {
|
|
136
|
+
var i, n, s = [], f = [];
|
|
137
|
+
for ([ i, n ] of r) if (0 < n.size) {
|
|
138
|
+
var o, u, l = [], h = [];
|
|
139
|
+
for ([ o, u ] of n) (1 === u ? l : h).push(o);
|
|
140
|
+
0 < l.length && s.push(i, l), 0 < h.length && f.push(i, h);
|
|
158
141
|
}
|
|
159
|
-
0 < f.length && (
|
|
142
|
+
0 < f.length && (a[2] = f), 0 < s.length && (a[1] = s), r.clear();
|
|
160
143
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
0 < u.length && (t[1] = u);
|
|
144
|
+
e = t.size;
|
|
145
|
+
if (0 < e) {
|
|
146
|
+
var d, c, v = a[0] = new Array(2 * e);
|
|
147
|
+
let r = 0;
|
|
148
|
+
for ([ d, c ] of t) v[r] = d, v[r + 1] = c, r += 2;
|
|
149
|
+
a[0] = v, t.clear();
|
|
168
150
|
}
|
|
169
|
-
|
|
170
|
-
var c, v = [];
|
|
171
|
-
for (c in e) v.push(c, e[c]);
|
|
172
|
-
0 < v.length && (t[0] = v);
|
|
173
|
-
}
|
|
174
|
-
return t;
|
|
151
|
+
return this.cmdCount = this.batchSize = 0, a;
|
|
175
152
|
}
|
|
176
153
|
toAclBuffer(r) {
|
|
177
|
-
var t = this.batchSize;
|
|
178
|
-
if (0 <
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function d(r, t, e = 1) {
|
|
183
|
-
a(r.cmdArgAsMapArray, t, e);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function g(r, t) {
|
|
187
|
-
let e = r.cmdArgAsMapArray;
|
|
188
|
-
if (!(void 0 === e || void 0 === t || t.length <= 1)) {
|
|
189
|
-
for (let r = 0; r < t.length - 1; ++r) if (void 0 === (e = e[t[r]])) return;
|
|
190
|
-
delete e[t.at(-1)];
|
|
154
|
+
var t, e = this.batchSize;
|
|
155
|
+
if (0 < e) return r = r, e = e, t = this.takeCmdArgAsListArray(), t = a(JSON.stringify(t)),
|
|
156
|
+
Buffer.concat([ i([ r, e, t.length ]), t ]);
|
|
191
157
|
}
|
|
192
158
|
}
|
|
193
159
|
|
|
194
|
-
let
|
|
160
|
+
let v = [ 1, 2, 4, 8 ];
|
|
195
161
|
|
|
196
|
-
function
|
|
162
|
+
function i(t) {
|
|
197
163
|
var e = t.length, a = new Array(e), i = new Array(e);
|
|
198
164
|
let n = e << 6, s = 1;
|
|
199
165
|
for (let r = 0; r < e; ++r) {
|
|
200
166
|
var f = a[r] = (f = t[r]) <= 255 ? 0 : f <= 65535 ? 1 : f <= 4294967295 ? 2 : 3, f = (n |= f << (r << 1),
|
|
201
|
-
i[r] =
|
|
167
|
+
i[r] = v[f]);
|
|
202
168
|
s += f;
|
|
203
169
|
}
|
|
204
170
|
var o = Buffer.allocUnsafe(s);
|
|
205
171
|
o.writeUInt8(n);
|
|
206
|
-
let
|
|
172
|
+
let u = 1;
|
|
207
173
|
for (let r = 0; r < e; ++r) {
|
|
208
|
-
|
|
209
|
-
var [
|
|
210
|
-
switch (
|
|
174
|
+
c = d = h = l = void 0;
|
|
175
|
+
var [ l, h, d, c = 0 ] = [ o, t[r], i[r], u ];
|
|
176
|
+
switch (d) {
|
|
211
177
|
case 1:
|
|
212
|
-
|
|
178
|
+
l.writeUInt8(h, c);
|
|
213
179
|
break;
|
|
214
180
|
|
|
215
181
|
case 2:
|
|
216
|
-
|
|
182
|
+
l.writeUInt16BE(h, c);
|
|
217
183
|
break;
|
|
218
184
|
|
|
219
185
|
case 4:
|
|
220
|
-
|
|
186
|
+
l.writeUInt32BE(h, c);
|
|
221
187
|
break;
|
|
222
188
|
|
|
223
189
|
default:
|
|
224
|
-
|
|
190
|
+
l.writeBigUInt64BE(BigInt(h), c);
|
|
225
191
|
}
|
|
226
|
-
|
|
192
|
+
u += i[r];
|
|
227
193
|
}
|
|
228
194
|
return o;
|
|
229
195
|
}
|
|
230
196
|
|
|
231
|
-
function
|
|
197
|
+
function c(t, e, a) {
|
|
232
198
|
var i = t.readUInt8(e), n = (++e, i >> 6 & 3);
|
|
233
199
|
for (let r = 0; r < n; ++r) {
|
|
234
|
-
var s =
|
|
200
|
+
var s = v[i >> (r << 1) & 3];
|
|
235
201
|
a[r] = ((r, t, e = 0) => {
|
|
236
202
|
switch (t) {
|
|
237
203
|
case 1:
|
|
@@ -251,24 +217,19 @@ function b(t, e, a) {
|
|
|
251
217
|
return e;
|
|
252
218
|
}
|
|
253
219
|
|
|
254
|
-
function
|
|
255
|
-
e = i(e);
|
|
256
|
-
return Buffer.concat([ y([ r, t, e.length ]), e ]);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
async function I(e, r, a, i) {
|
|
220
|
+
async function o(e, r, a, i) {
|
|
260
221
|
var n = [];
|
|
261
222
|
for (let t = 0; t < r.length; ) {
|
|
262
|
-
var s = [], f =
|
|
263
|
-
if (s <= i)
|
|
264
|
-
t = f +
|
|
265
|
-
i + o !== s &&
|
|
223
|
+
var s = [], f = c(r, t, s), [ s, o, u ] = s;
|
|
224
|
+
if (s <= i) d.warn(`changeId ${s} <= currentChangeId ${i} at ${e}:${t}. Ignored.`),
|
|
225
|
+
t = f + u; else {
|
|
226
|
+
i + o !== s && d.warn(`currentChangeId ${i} + batchSize ${o} !== changeId ` + s);
|
|
266
227
|
try {
|
|
267
|
-
var
|
|
268
|
-
n.push(s,
|
|
228
|
+
var l = JSON.parse(r.subarray(f, f + u));
|
|
229
|
+
n.push(s, l), i = s, t = f + u;
|
|
269
230
|
} catch (r) {
|
|
270
|
-
if (
|
|
271
|
-
void 0 === (o = await h.truncate(e, t)) ?
|
|
231
|
+
if (d.error(`Parse ${e} failed at ${t}:`, r), a) return d.warn(`Autorepair by truncating ${e} to ` + t),
|
|
232
|
+
void 0 === (o = await h.truncate(e, t)) ? d.log("truncate success") : d.error("truncate failed:", o),
|
|
272
233
|
n;
|
|
273
234
|
throw r;
|
|
274
235
|
}
|
|
@@ -278,16 +239,11 @@ async function I(e, r, a, i) {
|
|
|
278
239
|
}
|
|
279
240
|
|
|
280
241
|
export {
|
|
281
|
-
r as
|
|
282
|
-
t as
|
|
283
|
-
e as CmdName_R,
|
|
284
|
-
s as CmdName_D,
|
|
285
|
-
l as applyAclCmdObj,
|
|
286
|
-
u as iterCmdKeys,
|
|
242
|
+
r as applyAclCmdObj,
|
|
243
|
+
t as iterCmdKeys,
|
|
287
244
|
m as applyChange,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
I as readAclBuffer
|
|
245
|
+
e as QyAclCmdGenerator,
|
|
246
|
+
i as numsToBuffer,
|
|
247
|
+
c as bufferToNums,
|
|
248
|
+
o as readAclBuffer
|
|
293
249
|
};
|
|
@@ -6,6 +6,6 @@ export default class QyAclSaver_Worker extends QyMessageWorker {
|
|
|
6
6
|
_op_start(aclFilePath: any): Promise<void>;
|
|
7
7
|
_op_stop(): Promise<void>;
|
|
8
8
|
switch(aclFilePath: any): void;
|
|
9
|
-
callSave(changeId: any,
|
|
10
|
-
castSave(changeId: any,
|
|
9
|
+
callSave(changeId: any, cmdArgAsListArray: any): Promise<void>;
|
|
10
|
+
castSave(changeId: any, cmdArgAsListArray: any): void;
|
|
11
11
|
}
|
package/src/QyAclWriter.js
CHANGED
|
@@ -3,8 +3,7 @@ import {
|
|
|
3
3
|
} from "./QyBinWriter.js";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
QyAclCmdGenerator as e
|
|
7
|
-
toAclBuffer as f
|
|
6
|
+
QyAclCmdGenerator as e
|
|
8
7
|
} from "./QyAcl.js";
|
|
9
8
|
|
|
10
9
|
import {
|
|
@@ -19,18 +18,10 @@ class t extends r {
|
|
|
19
18
|
...r
|
|
20
19
|
}, t), this.qyAclCmdGenerator = new e();
|
|
21
20
|
}
|
|
22
|
-
getBinData(
|
|
23
|
-
var e,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} = this, a = t.length;
|
|
27
|
-
if (a < s.minBatchSize) {
|
|
28
|
-
var i = new Array(a), n = r - a + 1;
|
|
29
|
-
for (let r = 0; r < a; ++r) i[r] = f(n + r, 1, t[r]);
|
|
30
|
-
return Buffer.concat(i);
|
|
31
|
-
}
|
|
32
|
-
for (e of t) o.pushCmdArgAsListArray(JSON.parse(e));
|
|
33
|
-
return o.toAclBuffer(r);
|
|
21
|
+
getBinData(r, t) {
|
|
22
|
+
var e, o = this.qyAclCmdGenerator;
|
|
23
|
+
for (e of r) o.pushCmdArgAsListArray(e);
|
|
24
|
+
return o.toAclBuffer(t);
|
|
34
25
|
}
|
|
35
26
|
}
|
|
36
27
|
|
package/src/QyBatch.d.ts
CHANGED
package/src/QyBatch.js
CHANGED
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
} from "node:util";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
mergeContentAndGenDelta as
|
|
6
|
+
mergeContentAndGenDelta as h
|
|
7
7
|
} from "./QyFileContentUtils.js";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
pathSplit as
|
|
10
|
+
pathSplit as s,
|
|
11
11
|
ensurePropNamePathList as n,
|
|
12
|
-
isString as
|
|
13
|
-
getSuffix as
|
|
12
|
+
isString as o,
|
|
13
|
+
getSuffix as v,
|
|
14
14
|
SpecialFilePaths as e,
|
|
15
15
|
isSimpleType as l,
|
|
16
16
|
isEmptyObj as f,
|
|
@@ -22,15 +22,11 @@ import {
|
|
|
22
22
|
} from "./QyUtils.js";
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
CmdName_A as _,
|
|
26
|
-
CmdName_D as C,
|
|
27
|
-
CmdName_M as v,
|
|
28
|
-
CmdName_R as p,
|
|
29
25
|
QyAclCmdGenerator as t
|
|
30
26
|
} from "./QyAcl.js";
|
|
31
27
|
|
|
32
28
|
import {
|
|
33
|
-
calDifferenceList as
|
|
29
|
+
calDifferenceList as C
|
|
34
30
|
} from "./QyIndex.js";
|
|
35
31
|
|
|
36
32
|
import {
|
|
@@ -38,23 +34,24 @@ import {
|
|
|
38
34
|
} from "./QyDefaultOptions.js";
|
|
39
35
|
|
|
40
36
|
import {
|
|
41
|
-
QyCD as
|
|
37
|
+
QyCD as _
|
|
42
38
|
} from "./QyCD.js";
|
|
43
39
|
|
|
44
40
|
import {
|
|
45
|
-
logger as
|
|
41
|
+
logger as p
|
|
46
42
|
} from "./QyLogger.js";
|
|
47
43
|
|
|
48
|
-
let
|
|
44
|
+
let m = e.IndexPropPathsFileName, y = {
|
|
49
45
|
none: 0,
|
|
50
46
|
basic: 1,
|
|
51
47
|
delta: 2,
|
|
52
48
|
all: 3
|
|
53
49
|
};
|
|
54
50
|
|
|
55
|
-
class
|
|
51
|
+
class x extends _ {
|
|
56
52
|
fileLogLevel;
|
|
57
53
|
changeId;
|
|
54
|
+
aqIdx = 0;
|
|
58
55
|
actionQueue = [];
|
|
59
56
|
fileDeltaList = [];
|
|
60
57
|
syncList = [];
|
|
@@ -68,135 +65,132 @@ class j extends x {
|
|
|
68
65
|
...i("QyBatch"),
|
|
69
66
|
...t
|
|
70
67
|
};
|
|
71
|
-
e =
|
|
72
|
-
this.options = t, this.fileLogLevel = e ?? 1, this.qyCmdObjHistory = new
|
|
68
|
+
e = y[t.fileLogLevel.toLowerCase()];
|
|
69
|
+
this.options = t, this.fileLogLevel = e ?? 1, this.qyCmdObjHistory = new j(t.maxHistoryCmdObjCount);
|
|
73
70
|
}
|
|
74
71
|
createDir(e) {
|
|
75
|
-
|
|
72
|
+
o(e) && (e = s(e));
|
|
76
73
|
e = this.qyCache.getOrCreateDir(e, this.currentDir);
|
|
77
|
-
return
|
|
74
|
+
return F(this, this._action_createDir, e);
|
|
78
75
|
}
|
|
79
76
|
delDir(e) {
|
|
80
|
-
|
|
77
|
+
o(e) && (e = s(e));
|
|
81
78
|
e = this.qyCache.getOrCreateDir(e, this.currentDir).ensureAllLoaded();
|
|
82
|
-
return
|
|
79
|
+
return F(this, this._action_delDir, e);
|
|
83
80
|
}
|
|
84
81
|
createFile(e) {
|
|
85
|
-
|
|
82
|
+
o(e) && (e = s(e));
|
|
86
83
|
e = this.qyCache.getOrCreateFile(e, this.currentDir).ensureLoaded();
|
|
87
|
-
return
|
|
84
|
+
return F(this, this._action_createFile, e);
|
|
88
85
|
}
|
|
89
86
|
delFile(e) {
|
|
90
|
-
|
|
87
|
+
o(e) && (e = s(e));
|
|
91
88
|
e = this.qyCache.getOrCreateFile(e, this.currentDir).ensureLoaded();
|
|
92
|
-
return
|
|
89
|
+
return F(this, this._action_delFile, e);
|
|
93
90
|
}
|
|
94
91
|
expireFile(e, t) {
|
|
95
92
|
return this.expireFileM(e, 1e3 * t);
|
|
96
93
|
}
|
|
97
94
|
expireFileM(e, t) {
|
|
98
|
-
return
|
|
95
|
+
return N(this, e, t, "f");
|
|
99
96
|
}
|
|
100
97
|
expireDir(e, t) {
|
|
101
98
|
return this.expireDirM(e, 1e3 * t);
|
|
102
99
|
}
|
|
103
100
|
expireDirM(e, t) {
|
|
104
|
-
return
|
|
101
|
+
return N(this, e, t, "d");
|
|
105
102
|
}
|
|
106
103
|
expireContent(e, t, i) {
|
|
107
|
-
|
|
104
|
+
o(e) && (e = s(e));
|
|
108
105
|
e = this.qyCache.getOrCreateFile(e, this.currentDir).ensureLoaded();
|
|
109
|
-
return
|
|
106
|
+
return F(this, this._action_expireContent, e, t, i);
|
|
110
107
|
}
|
|
111
108
|
expireContentM(e, t) {
|
|
112
109
|
return this.expireContent(e, t, !0);
|
|
113
110
|
}
|
|
114
111
|
removeFileExpire(e, t = !1) {
|
|
115
|
-
return
|
|
112
|
+
return A(this, e, "f", t);
|
|
116
113
|
}
|
|
117
114
|
removeDirExpire(e, t = !1) {
|
|
118
|
-
return
|
|
115
|
+
return A(this, e, "d", t);
|
|
119
116
|
}
|
|
120
117
|
removeContentExpire(e, t, i = !1) {
|
|
121
|
-
|
|
118
|
+
o(e) && (e = s(e));
|
|
122
119
|
e = this.qyCache.getOrCreateFile(e, this.currentDir).ensureLoaded();
|
|
123
|
-
return
|
|
120
|
+
return F(this, this._action_removeContentExpire, e, t, i);
|
|
124
121
|
}
|
|
125
122
|
createIndex(e, t) {
|
|
126
|
-
|
|
123
|
+
o(e) && (e = s(e)), u(t) || (t = [ t ]);
|
|
127
124
|
e = this.qyCache.getOrCreateDir(e, this.currentDir);
|
|
128
|
-
return
|
|
125
|
+
return F(this, this._action_createIndex, e, t);
|
|
129
126
|
}
|
|
130
127
|
createIndexByQuery(e, t) {
|
|
131
|
-
|
|
128
|
+
o(e) && (e = s(e));
|
|
132
129
|
e = this.qyCache.getOrCreateDir(e, this.currentDir);
|
|
133
|
-
return
|
|
130
|
+
return F(this, this._action_createIndexByQuery, e, t);
|
|
134
131
|
}
|
|
135
132
|
delIndex(e, t) {
|
|
136
|
-
|
|
133
|
+
o(e) && (e = s(e));
|
|
137
134
|
e = this.qyCache.getOrCreateDir(e, this.currentDir);
|
|
138
|
-
return
|
|
135
|
+
return F(this, this._action_delIndex, e, t);
|
|
139
136
|
}
|
|
140
137
|
insert(e, t) {
|
|
141
|
-
|
|
138
|
+
o(e) && (e = s(e));
|
|
142
139
|
e = this.qyCache.getOrCreateFile(e, this.currentDir).ensureLoaded();
|
|
143
|
-
return
|
|
140
|
+
return F(this, this._action_insert, e, t);
|
|
144
141
|
}
|
|
145
142
|
insertEmbedding(e, t) {
|
|
146
|
-
var i = this.qyCache, i = (g(t) || (t = new Float32Array(t)),
|
|
143
|
+
var i = this.qyCache, i = (g(t) || (t = new Float32Array(t)), o(e) && (e = s(e)),
|
|
147
144
|
i.getOrCreateFile(e, this.currentDir));
|
|
148
|
-
return
|
|
145
|
+
return F(this, this._action_insertEmbedding, i, t);
|
|
149
146
|
}
|
|
150
147
|
delEmbedding(e) {
|
|
151
|
-
var t = this.qyCache, t = (
|
|
152
|
-
return
|
|
148
|
+
var t = this.qyCache, t = (o(e) && (e = s(e)), t.getOrCreateFile(e, this.currentDir));
|
|
149
|
+
return F(this, this._action_delEmbedding, t);
|
|
153
150
|
}
|
|
154
151
|
insertWithEmbedding(e, t, i) {
|
|
155
152
|
return this.insert(e, t), this.insertEmbedding(e, i);
|
|
156
153
|
}
|
|
157
154
|
delContent(e) {
|
|
158
|
-
|
|
155
|
+
o(e) && (e = s(e));
|
|
159
156
|
e = this.qyCache.getOrCreateFile(e, this.currentDir).ensureLoaded();
|
|
160
|
-
return
|
|
157
|
+
return F(this, this._action_delContent, e);
|
|
161
158
|
}
|
|
162
159
|
insertTrigger(e, t, i, r) {
|
|
163
|
-
|
|
160
|
+
o(t) && (t = s(t)), i = n(i);
|
|
164
161
|
e = this.qyCache.getOrCreateTriggerFile(e);
|
|
165
|
-
return
|
|
162
|
+
return F(this, this._action_insertTrigger, e, t, i, r);
|
|
166
163
|
}
|
|
167
164
|
removeTrigger(e) {
|
|
168
|
-
return
|
|
165
|
+
return F(this, this._action_removeTrigger, this.qyCache.getOrCreateTriggerFile(e));
|
|
169
166
|
}
|
|
170
167
|
insertRpc(e, t) {
|
|
171
168
|
e = this.qyCache.getOrCreateRpcFile(e);
|
|
172
|
-
return
|
|
169
|
+
return F(this, this._action_insertRpc, e, t);
|
|
173
170
|
}
|
|
174
171
|
removeRpc(e) {
|
|
175
|
-
return
|
|
172
|
+
return F(this, this._action_removeRpc, this.qyCache.getOrCreateRpcFile(e));
|
|
176
173
|
}
|
|
177
174
|
run(e = !1) {
|
|
178
|
-
|
|
179
|
-
running: t,
|
|
180
|
-
actionQueue: i
|
|
181
|
-
} = this;
|
|
182
|
-
if (t || 0 === i.length) return 0;
|
|
175
|
+
if (this.running || 0 === this.aqIdx) return 0;
|
|
183
176
|
this.running = !0;
|
|
184
|
-
var r, n, {
|
|
185
|
-
qyCache: t,
|
|
186
|
-
qyAclCmdGenerator: a
|
|
187
|
-
} = this, s = this.changeId = t.increaseChangeId();
|
|
188
|
-
for ([ r, n ] of i) r.apply(this, n);
|
|
189
|
-
i.length = 0, this.running = !1, this.resetCurrentDir();
|
|
190
|
-
i = a.cmdCount;
|
|
191
|
-
if (0 === i) return t.decreaseChangeId(), 0;
|
|
192
177
|
var {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
178
|
+
actionQueue: t,
|
|
179
|
+
qyCache: i,
|
|
180
|
+
qyAclCmdGenerator: r
|
|
181
|
+
} = this, n = this.changeId = i.increaseChangeId();
|
|
182
|
+
for (let e = 0; e < this.aqIdx; e += 2) t[e].apply(this, t[e + 1]), t[e] = t[e + 1] = void 0;
|
|
183
|
+
this.aqIdx = 0, this.running = !1, this.resetCurrentDir();
|
|
184
|
+
var a = r.cmdCount;
|
|
185
|
+
if (0 === a) return i.decreaseChangeId(), 0;
|
|
186
|
+
var {
|
|
187
|
+
fileLogLevel: s,
|
|
188
|
+
logList: o,
|
|
189
|
+
qyCmdObjHistory: h,
|
|
190
|
+
syncList: d
|
|
191
|
+
} = this, l = v(a), r = r.takeCmdArgAsListArray(), s = 0 < s ? "" + new Date().toISOString() + `: ${a} change${l}:
|
|
192
|
+
${o.join("\n")}
|
|
193
|
+
` : void 0, a = (o.length = 0, i.save(n, r, s, (e => {
|
|
200
194
|
var t = e.syncList, i = t.length;
|
|
201
195
|
for (let e = 0; e < i; e += 2) {
|
|
202
196
|
var r, n = e + 1, a = t[e], s = t[n];
|
|
@@ -205,20 +199,20 @@ ${h.join("\n")}
|
|
|
205
199
|
}
|
|
206
200
|
if (0 < i) return t;
|
|
207
201
|
})(this), e));
|
|
208
|
-
|
|
209
|
-
var
|
|
210
|
-
if (0 <
|
|
211
|
-
var
|
|
212
|
-
for (let e = 0; e <
|
|
213
|
-
var
|
|
214
|
-
0 <
|
|
202
|
+
d.length = 0, h.push(r);
|
|
203
|
+
var c = this.fileDeltaList, u = c.length;
|
|
204
|
+
if (0 < u) {
|
|
205
|
+
var f = [];
|
|
206
|
+
for (let e = 0; e < u; e += 2) {
|
|
207
|
+
var g = c[e];
|
|
208
|
+
0 < g.triggerNodes?.length && f.push(g, c[e + 1]);
|
|
215
209
|
}
|
|
216
|
-
for (let e =
|
|
217
|
-
var C,
|
|
218
|
-
for (C of
|
|
210
|
+
for (let e = c.length = 0; e < f.length; e += 2) {
|
|
211
|
+
var C, _ = f[e], p = f[e + 1];
|
|
212
|
+
for (C of _.triggerNodes) C.checkTrigger(_, p);
|
|
219
213
|
}
|
|
220
214
|
}
|
|
221
|
-
return e ?
|
|
215
|
+
return e ? a : n;
|
|
222
216
|
}
|
|
223
217
|
getTopHistoryCmdObj() {
|
|
224
218
|
return this.qyCmdObjHistory.top();
|
|
@@ -246,16 +240,16 @@ ${h.join("\n")}
|
|
|
246
240
|
return !!this._action_delFile(e) && (this.qyCache.removeRpc(e.name), !0);
|
|
247
241
|
}
|
|
248
242
|
_action_createIndex(e, t) {
|
|
249
|
-
var i = this.qyCache.getOrCreateIndexDir(e), r =
|
|
250
|
-
0 < t.length &&
|
|
243
|
+
var i = this.qyCache.getOrCreateIndexDir(e), r = D(this, i), t = r.qyIndexPropTree.insertPropPathList(t);
|
|
244
|
+
0 < t.length && q(this, e, 0, r, t);
|
|
251
245
|
}
|
|
252
246
|
_action_createIndexByQuery(e, t) {
|
|
253
|
-
var i = this.qyCache.getOrCreateIndexDir(e), r =
|
|
254
|
-
0 < t.length &&
|
|
247
|
+
var i = this.qyCache.getOrCreateIndexDir(e), r = D(this, i), t = r.qyIndexPropTree.insertQueryObj(t);
|
|
248
|
+
0 < t.length && q(this, e, 0, r, t);
|
|
255
249
|
}
|
|
256
250
|
_action_delIndex(e, t) {
|
|
257
251
|
var i, e = this.qyCache.getIndexDir(e);
|
|
258
|
-
void 0 !== e && (void 0 === (i = e.getFile(
|
|
252
|
+
void 0 !== e && (void 0 === (i = e.getFile(m)) ? this._action_delDir(e) : (e = i.qyIndexPropTree,
|
|
259
253
|
[ i, e, t ] = (this._action_setProp(i, JSON.stringify(t), null), e.removePropPath(t)),
|
|
260
254
|
i && !e && void 0 !== t && (i = t.indexPropDir, void 0 !== i) && this._action_delDir(i)));
|
|
261
255
|
}
|
|
@@ -265,7 +259,7 @@ ${h.join("\n")}
|
|
|
265
259
|
e.created = !1, t || ({
|
|
266
260
|
parentDir: t,
|
|
267
261
|
name: i
|
|
268
|
-
} = e,
|
|
262
|
+
} = e, P(this, t, t.fileMapKey, i)), I(this, "delFile", e), !0);
|
|
269
263
|
}
|
|
270
264
|
_action_delDir(e) {
|
|
271
265
|
if (!e.created) return !1;
|
|
@@ -278,11 +272,11 @@ ${h.join("\n")}
|
|
|
278
272
|
fileMapKey: s
|
|
279
273
|
} = e;
|
|
280
274
|
if (n) {
|
|
281
|
-
b(this, e,
|
|
275
|
+
b(this, e, s);
|
|
282
276
|
for (var o of e.fileList) this._action_delFile(o, !0);
|
|
283
277
|
}
|
|
284
278
|
if (r) {
|
|
285
|
-
b(this, e,
|
|
279
|
+
b(this, e, a);
|
|
286
280
|
for (var h of e.allSubdirs()) {
|
|
287
281
|
let {
|
|
288
282
|
subdirMap: e,
|
|
@@ -290,19 +284,19 @@ ${h.join("\n")}
|
|
|
290
284
|
subdirMapKey: i,
|
|
291
285
|
fileMapKey: r
|
|
292
286
|
} = h;
|
|
293
|
-
if (e && b(this, h,
|
|
294
|
-
b(this, h,
|
|
287
|
+
if (e && b(this, h, i), t) {
|
|
288
|
+
b(this, h, r);
|
|
295
289
|
for (var d of h.fileList) this._action_delFile(d, !0);
|
|
296
290
|
}
|
|
297
291
|
I(this, "delDir", h), h.created = !1;
|
|
298
292
|
}
|
|
299
293
|
}
|
|
300
|
-
return void 0 !== t && (e.created = !1,
|
|
301
|
-
|
|
294
|
+
return void 0 !== t && (e.created = !1, P(this, t, t.subdirMapKey, i), I(this, "delDir", e),
|
|
295
|
+
!0);
|
|
302
296
|
}
|
|
303
297
|
_action_delContent(e) {
|
|
304
298
|
var t = e.fileContent;
|
|
305
|
-
return void 0 !== t && (e.fileContent = void 0, b(this, e,
|
|
299
|
+
return void 0 !== t && (e.fileContent = void 0, b(this, e, e.fileContentKey),
|
|
306
300
|
I(this, "delContent", e, t, [ t, null ]), E(this, e, t), !0);
|
|
307
301
|
}
|
|
308
302
|
_action_insertEmbedding(e, t) {
|
|
@@ -334,23 +328,24 @@ ${h.join("\n")}
|
|
|
334
328
|
} = e, r = (r || this._action_createFile(e), a ? a[t] : void 0);
|
|
335
329
|
return null === i ? void 0 !== a && delete a[t] : void 0 !== a ? a[t] = i : e.fileContent = {
|
|
336
330
|
[t]: i
|
|
337
|
-
},
|
|
331
|
+
}, a = e, e = n, (n = this).qyAclCmdGenerator.pushMPropCmd(e, t, i), L(n, a, e),
|
|
332
|
+
r;
|
|
338
333
|
}
|
|
339
334
|
_action_insert(e, t) {
|
|
340
|
-
if (void 0 === t) return
|
|
335
|
+
if (void 0 === t) return p.warn(`Saving undefined to ${e.fullPath}. Not making any change.`),
|
|
341
336
|
!1;
|
|
342
337
|
e.created || this._action_createFile(e);
|
|
343
|
-
var [ t, i ] =
|
|
338
|
+
var [ t, i ] = h(e.fileContent, t);
|
|
344
339
|
if (void 0 === i) return !1;
|
|
345
340
|
e.fileContent = t;
|
|
346
|
-
var
|
|
347
|
-
return void 0 === t ? b(this, e,
|
|
348
|
-
E(this, e,
|
|
341
|
+
var r, n, [ a, s ] = i, o = e.fileContentKey;
|
|
342
|
+
return void 0 === t ? b(this, e, o) : (n = e, o = o, (r = this).qyAclCmdGenerator.pushMCmd(o, s),
|
|
343
|
+
L(r, n, o)), I(this, "insert", e, t, i), E(this, e, a, s, t), !0;
|
|
349
344
|
}
|
|
350
345
|
_action_createFile(e) {
|
|
351
346
|
var t;
|
|
352
347
|
return !e.created && (t = e.parentDir, t.created || this._action_createDir(t),
|
|
353
|
-
e.created = !0, e.fileContentLoaded = !0,
|
|
348
|
+
e.created = !0, e.fileContentLoaded = !0, O(this, t, t.fileMapKey, e.name),
|
|
354
349
|
I(this, "createFile", e), !0);
|
|
355
350
|
}
|
|
356
351
|
_action_createDir(e) {
|
|
@@ -359,7 +354,7 @@ ${h.join("\n")}
|
|
|
359
354
|
for (let e of t.reverse()) {
|
|
360
355
|
e.created = !0, e.subdirMapLoaded = !0, e.fileMapLoaded = !0;
|
|
361
356
|
var i = e.parentDir;
|
|
362
|
-
|
|
357
|
+
O(this, i, i.subdirMapKey, e.name), I(this, "createDir", e);
|
|
363
358
|
}
|
|
364
359
|
return !0;
|
|
365
360
|
}
|
|
@@ -368,7 +363,7 @@ ${h.join("\n")}
|
|
|
368
363
|
parentDir: r,
|
|
369
364
|
name: n
|
|
370
365
|
} = e;
|
|
371
|
-
return void 0 !== r && void 0 !== (t =
|
|
366
|
+
return void 0 !== r && void 0 !== (t = Q(t, !0, c())) && (i = this.qyCache,
|
|
372
367
|
r = i.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"), (r = this._action_insert(r, {
|
|
373
368
|
[n]: t
|
|
374
369
|
})) && i.monitorItemExpire(e, t), r);
|
|
@@ -385,28 +380,28 @@ ${h.join("\n")}
|
|
|
385
380
|
}
|
|
386
381
|
_action_expireContent(e, t, i) {
|
|
387
382
|
let r = c();
|
|
388
|
-
var t =
|
|
383
|
+
var t = M(t, e => Q(e, i, r)), n = this.qyCache, a = n.getOrCreateExpireInfoFile(e.fullPathHash, "c"), a = this._action_insert(a, {
|
|
389
384
|
...t
|
|
390
385
|
});
|
|
391
386
|
return a && n.monitorContentExpire(e, t), a;
|
|
392
387
|
}
|
|
393
388
|
_action_removeContentExpire(e, t, i) {
|
|
394
389
|
var r, n = this.qyCache, a = n.getExpireInfoFile(e.fullPathHash, "c");
|
|
395
|
-
return void 0 !== a && (t = u(t) ? Object.fromEntries(t.map(e => [ e, null ])) :
|
|
390
|
+
return void 0 !== a && (t = u(t) ? Object.fromEntries(t.map(e => [ e, null ])) : M(t, e => e ? null : void 0),
|
|
396
391
|
(r = this._action_insert(a, t)) && (f(a.fileContent, !0) && this._action_delFile(a),
|
|
397
392
|
i || n.unmonitorContentExpire(e, t)), r);
|
|
398
393
|
}
|
|
399
394
|
}
|
|
400
395
|
|
|
401
|
-
function
|
|
402
|
-
t = t.getOrCreateFile(
|
|
396
|
+
function D(e, t) {
|
|
397
|
+
t = t.getOrCreateFile(m);
|
|
403
398
|
return t.created || e._action_createFile(t), t;
|
|
404
399
|
}
|
|
405
400
|
|
|
406
|
-
function
|
|
401
|
+
function q(t, i, e, r, n) {
|
|
407
402
|
var a, s = {};
|
|
408
403
|
for (a of n) s[JSON.stringify(a.indexPropPath)] = 1;
|
|
409
|
-
|
|
404
|
+
p.log(`Creating index ${n.map(e => e.indexPropPath)} for ` + i.fullPath), t._action_insert(r, s);
|
|
410
405
|
{
|
|
411
406
|
var o = t, h = i, d;
|
|
412
407
|
let e;
|
|
@@ -422,62 +417,76 @@ function L(t, i, e, r, n) {
|
|
|
422
417
|
fileContent: u,
|
|
423
418
|
name: f
|
|
424
419
|
} = u;
|
|
425
|
-
void 0 !== u &&
|
|
420
|
+
void 0 !== u && T(o, c, l, f, void 0, u);
|
|
426
421
|
}
|
|
427
422
|
}
|
|
428
423
|
}
|
|
429
424
|
}
|
|
430
425
|
}
|
|
431
426
|
|
|
432
|
-
function
|
|
433
|
-
|
|
427
|
+
function F(e, t, ...i) {
|
|
428
|
+
var r, n;
|
|
429
|
+
return e.running ? t.apply(e, i) : ({
|
|
430
|
+
aqIdx: r,
|
|
431
|
+
actionQueue: n
|
|
432
|
+
} = e, n[r] = t, n[r + 1] = i, e.aqIdx += 2), e;
|
|
434
433
|
}
|
|
435
434
|
|
|
436
435
|
function I(t, i, r, n = void 0, a = void 0) {
|
|
437
436
|
var {
|
|
438
|
-
fileLogLevel:
|
|
439
|
-
logList: s,
|
|
437
|
+
fileLogLevel: s,
|
|
440
438
|
fileDeltaList: o
|
|
441
439
|
} = t;
|
|
442
|
-
if (void 0 !== a && o.push(r, a), !(
|
|
440
|
+
if (void 0 !== a && o.push(r, a), !(s <= 0)) {
|
|
443
441
|
o = i + ` "${r.fullPath ?? r}"`;
|
|
444
442
|
let e = o;
|
|
445
|
-
"delContent" === i ? 3 ===
|
|
443
|
+
"delContent" === i ? 3 === s && (e = o + " " + JSON.stringify(n)) : "insert" === i && 2 <= s && ([ r, i ] = a,
|
|
446
444
|
a = `${void 0 === r ? "" : "delta:"} ${JSON.stringify(r)} -> ` + JSON.stringify(i),
|
|
447
|
-
2 ===
|
|
448
|
-
e = o + ` ${a}. ` + i),
|
|
445
|
+
2 === s && (e = o + " " + a), i = void 0 !== r ? "new: " + JSON.stringify(n) : "",
|
|
446
|
+
e = o + ` ${a}. ` + i), t.logList.push(e);
|
|
449
447
|
}
|
|
450
448
|
}
|
|
451
449
|
|
|
452
|
-
function
|
|
450
|
+
function L(e, t, i) {
|
|
453
451
|
var {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
changeId: h
|
|
452
|
+
qyCache: e,
|
|
453
|
+
syncList: r,
|
|
454
|
+
changeId: n
|
|
458
455
|
} = e;
|
|
459
|
-
|
|
460
|
-
void 0 !==
|
|
456
|
+
i.startsWith("d") ? t.dChangeId = n : i.startsWith("f") ? t.fChangeId = n : t.cChangeId = n,
|
|
457
|
+
void 0 !== e && e.qyKVData.removeKey(i) && r.push(i, t);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function O(e, t, i, r) {
|
|
461
|
+
e.qyAclCmdGenerator.pushACmd(i, r), L(e, t, i);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function P(e, t, i, r) {
|
|
465
|
+
e.qyAclCmdGenerator.pushRCmd(i, r), L(e, t, i);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function b(e, t, i) {
|
|
469
|
+
e.qyAclCmdGenerator.pushDCmd(i), L(e, t, i);
|
|
461
470
|
}
|
|
462
471
|
|
|
463
472
|
function E(e, t, i, r = void 0, n = void 0) {
|
|
464
473
|
if (!t.underHiddenFolder) {
|
|
465
474
|
var a = e.qyCache.getIndexDir(t.parentDir);
|
|
466
475
|
if (void 0 !== a) {
|
|
467
|
-
a = a.getFile(
|
|
476
|
+
a = a.getFile(m);
|
|
468
477
|
if (void 0 !== a) {
|
|
469
478
|
var s, o, h = t.name;
|
|
470
479
|
for ({
|
|
471
480
|
indexPropDir: s,
|
|
472
481
|
indexPropPath: o
|
|
473
|
-
} of a.qyIndexPropTree.allLeafNodes)
|
|
482
|
+
} of a.qyIndexPropTree.allLeafNodes) T(e, s, o, h, i, r, n);
|
|
474
483
|
}
|
|
475
484
|
}
|
|
476
485
|
}
|
|
477
486
|
}
|
|
478
487
|
|
|
479
|
-
function
|
|
480
|
-
e =
|
|
488
|
+
function T(t, e, i, r, n, a, s = void 0) {
|
|
489
|
+
e = C(e, i, n, a, s);
|
|
481
490
|
if (void 0 !== e) {
|
|
482
491
|
var o, h, [ i, n ] = e;
|
|
483
492
|
for (o of i) {
|
|
@@ -499,9 +508,9 @@ function N(t, e, i, r, n, a, s = void 0) {
|
|
|
499
508
|
}
|
|
500
509
|
}
|
|
501
510
|
|
|
502
|
-
class
|
|
511
|
+
class j {
|
|
503
512
|
maxLength;
|
|
504
|
-
|
|
513
|
+
historyQueue = [];
|
|
505
514
|
nextPos = 0;
|
|
506
515
|
constructor(e) {
|
|
507
516
|
this.maxLength = e;
|
|
@@ -511,49 +520,45 @@ class H {
|
|
|
511
520
|
maxLength: t,
|
|
512
521
|
nextPos: i
|
|
513
522
|
} = this;
|
|
514
|
-
this.
|
|
523
|
+
this.historyQueue[i] = e, this.nextPos = ((e, t) => (t += 1) < e ? t : 0)(t, i);
|
|
515
524
|
}
|
|
516
525
|
top() {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
maxLength: t,
|
|
520
|
-
nextPos: i
|
|
521
|
-
} = this;
|
|
522
|
-
return e[e = t, (0 < (t = i) ? t : e) - 1];
|
|
526
|
+
return this.historyQueue[e = this.maxLength, (0 < (t = this.nextPos) ? t : e) - 1];
|
|
527
|
+
var e, t;
|
|
523
528
|
}
|
|
524
529
|
}
|
|
525
530
|
|
|
526
|
-
function
|
|
531
|
+
function M(e, t = void 0, i = [], r = {}) {
|
|
527
532
|
if (l(e)) {
|
|
528
533
|
var n = t ? t(e) : e;
|
|
529
534
|
void 0 !== n && (r[JSON.stringify(i)] = n);
|
|
530
535
|
} else {
|
|
531
536
|
var a, s = i.length;
|
|
532
|
-
for (a in e) i.push(a),
|
|
537
|
+
for (a in e) i.push(a), M(e[a], t, i, r), i.length = s;
|
|
533
538
|
}
|
|
534
539
|
return r;
|
|
535
540
|
}
|
|
536
541
|
|
|
537
|
-
function
|
|
538
|
-
return r(e) ? (t ? e : 1e3 * e) + i :
|
|
542
|
+
function Q(e, t, i) {
|
|
543
|
+
return r(e) ? (t ? e : 1e3 * e) + i : o(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !a(e) || (t = e.getTime()) <= i ? void 0 : t;
|
|
539
544
|
}
|
|
540
545
|
|
|
541
|
-
function
|
|
546
|
+
function N(e, t, i, r) {
|
|
542
547
|
var {
|
|
543
548
|
qyCache: n,
|
|
544
549
|
currentDir: a
|
|
545
|
-
} = e, r = (
|
|
546
|
-
return
|
|
550
|
+
} = e, r = (o(t) && (t = s(t)), "f" === r ? n.getOrCreateFile(t, a) : n.getOrCreateDir(t, a));
|
|
551
|
+
return F(e, e._action_expireItem, r, i);
|
|
547
552
|
}
|
|
548
553
|
|
|
549
|
-
function
|
|
554
|
+
function A(e, t, i, r) {
|
|
550
555
|
var {
|
|
551
556
|
qyCache: n,
|
|
552
557
|
currentDir: a
|
|
553
|
-
} = e, i = (
|
|
554
|
-
return
|
|
558
|
+
} = e, i = (o(t) && (t = s(t)), "f" === i ? n.getOrCreateFile(t, a) : n.getOrCreateDir(t, a));
|
|
559
|
+
return F(e, e._action_removeItemExpire, i, r);
|
|
555
560
|
}
|
|
556
561
|
|
|
557
562
|
export {
|
|
558
|
-
|
|
563
|
+
x as QyBatch
|
|
559
564
|
};
|
package/src/QyCD.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { QyCache } from "./QyCache.ts";
|
|
|
2
2
|
import type { QyDir } from "./QyDir.ts";
|
|
3
3
|
import type { QyFile } from "./QyFile.ts";
|
|
4
4
|
export declare class QyCD {
|
|
5
|
-
qyCache:
|
|
5
|
+
qyCache: QyCache | undefined;
|
|
6
6
|
currentDir: any;
|
|
7
7
|
constructor(qyCache?: QyCache);
|
|
8
8
|
cd(namePath: string | string[] | QyDir, parentDir?: any): this;
|
|
@@ -22,8 +22,8 @@ export declare class QyCD {
|
|
|
22
22
|
get rpcFileList(): any;
|
|
23
23
|
view(namePath: any, spec?: any, parentDir?: any): any;
|
|
24
24
|
viewP(namePath: any, spec: any, parentDir?: any): any;
|
|
25
|
-
queryFiles(indexHostDirNamePath: any, queryObj: any, limit?: number | undefined, cursor?: number | undefined, parentDir?: any):
|
|
26
|
-
queryFilesMulti(indexHostDirNamePathMulti: any, limit: any, cursor: any, parentDir?: any):
|
|
25
|
+
queryFiles(indexHostDirNamePath: any, queryObj: any, limit?: number | undefined, cursor?: number | undefined, parentDir?: any): never[];
|
|
26
|
+
queryFilesMulti(indexHostDirNamePathMulti: any, limit: any, cursor: any, parentDir?: any): never[];
|
|
27
27
|
queryTree(indexHostDirNamePath: any, queryObj: any, view: any, limit: any, cursor: any, parentDir?: any): {
|
|
28
28
|
tree: any;
|
|
29
29
|
count: any;
|
package/src/QyDB.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { QyBatch } from "./QyBatch.ts";
|
|
2
|
+
import { QyCache } from "./QyCache.ts";
|
|
2
3
|
import { QyCD } from "./QyCD.ts";
|
|
3
4
|
import type { QyDir } from "./QyDir.ts";
|
|
4
5
|
import type { QyFile } from "./QyFile.ts";
|
|
@@ -17,6 +18,6 @@ export declare class QyDB extends QyCD {
|
|
|
17
18
|
get currentBatch(): any;
|
|
18
19
|
createDir(namePath: string | string[]): QyDir;
|
|
19
20
|
createFile(namePath: string | string[]): QyFile;
|
|
20
|
-
on(eventName: any, listener: any):
|
|
21
|
-
callRpc(rpcFunName: any, argList: any, body?: undefined): any
|
|
21
|
+
on(eventName: any, listener: any): QyCache;
|
|
22
|
+
callRpc(rpcFunName: any, argList: any, body?: undefined): Promise<any>;
|
|
22
23
|
}
|
package/src/QyDefaultOptions.js
CHANGED
package/src/QyKVData.js
CHANGED
|
@@ -149,7 +149,7 @@ class t {
|
|
|
149
149
|
o && o.closeAllFDs(), await a.stop(), await s.stop();
|
|
150
150
|
}
|
|
151
151
|
save(t, a, o, e) {
|
|
152
|
-
var n = this.qyKVDataSaver
|
|
152
|
+
var n = this.qyKVDataSaver;
|
|
153
153
|
if (e) return n.callSave(t, a, o);
|
|
154
154
|
n.castSave(t, a, o);
|
|
155
155
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { QyAclSaver } from "./QyAclSaver.ts";
|
|
1
2
|
import { QyMessageWorker } from "./QyMessageWorker.ts";
|
|
3
|
+
import { QySnapshotSaver } from "./QySnapshotSaver.ts";
|
|
2
4
|
export default class QyKVDataSaver_Worker extends QyMessageWorker {
|
|
3
5
|
kvFolder: any;
|
|
4
6
|
aclFolder: any;
|
|
5
|
-
qyAclSaver:
|
|
6
|
-
qySnapshotSaver:
|
|
7
|
+
qyAclSaver: QyAclSaver | undefined;
|
|
8
|
+
qySnapshotSaver: QySnapshotSaver | undefined;
|
|
7
9
|
isStopping: any;
|
|
8
10
|
currentAclNum: any;
|
|
9
11
|
maxChangeId: any;
|
|
@@ -16,8 +18,8 @@ export default class QyKVDataSaver_Worker extends QyMessageWorker {
|
|
|
16
18
|
});
|
|
17
19
|
_op_start(maxChangeId: any, maxSnapshotNum: any, loadedMaxAclNum: any, aclKeyValueMap: any): void;
|
|
18
20
|
_op_stop(): Promise<any>;
|
|
19
|
-
callSave(changeId: any, cmdArgAsListArray: any,
|
|
20
|
-
castSave(changeId: any, cmdArgAsListArray: any,
|
|
21
|
+
callSave(changeId: any, cmdArgAsListArray: any, syncList: any): any;
|
|
22
|
+
castSave(changeId: any, cmdArgAsListArray: any, syncList: any): any;
|
|
21
23
|
releaseSnapshot(snapshotNum: any): void;
|
|
22
24
|
onSnapshotSavedChangeId(snapshotSavedChangeId: any, pMOnlySnapshot: any): void;
|
|
23
25
|
}
|
|
@@ -14,7 +14,7 @@ export default class QySnapshotSaver_Worker extends QyMessageWorker {
|
|
|
14
14
|
options: any;
|
|
15
15
|
});
|
|
16
16
|
_op_start(maxChangeId: any, loadedMaxAclNum: any, aclKeyValueMap: any): void;
|
|
17
|
-
castSave(changeId: any,
|
|
17
|
+
castSave(changeId: any, cmdArgAsListArray: any, syncList: any): void;
|
|
18
18
|
saveSnapshot(maxSnapshotNum: any): Promise<void>;
|
|
19
19
|
releaseSnapshot(snapshotNum: any): void;
|
|
20
20
|
_op_stop(): Promise<number>;
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "./QyKVDataCleaner.js";
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
|
-
logger as
|
|
22
|
+
logger as y
|
|
23
23
|
} from "./QyLogger.js";
|
|
24
24
|
|
|
25
25
|
export default class extends a {
|
|
@@ -50,7 +50,7 @@ export default class extends a {
|
|
|
50
50
|
aclKeyValueMap: t,
|
|
51
51
|
qySnapshots: o
|
|
52
52
|
} = this;
|
|
53
|
-
o.applyCmdObj(
|
|
53
|
+
o.applyCmdObj(s, t, e), this.maxChangeId = a;
|
|
54
54
|
}
|
|
55
55
|
async saveSnapshot(a) {
|
|
56
56
|
var {
|
|
@@ -97,7 +97,7 @@ export default class extends a {
|
|
|
97
97
|
return e;
|
|
98
98
|
})(this)).prefixPM, delete (u = {
|
|
99
99
|
...s
|
|
100
|
-
}).keyValueMap, delete s.posMap, s.isOut = !0,
|
|
100
|
+
}).keyValueMap, delete s.posMap, s.isOut = !0, y.info("Sending snapshot " + s.snapshotNum)),
|
|
101
101
|
this.postParent("onSnapshotSavedChangeId", t, u);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -114,23 +114,23 @@ function h(a, s, e, t) {
|
|
|
114
114
|
...i
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
let u = a.length,
|
|
117
|
+
let u = a.length, y;
|
|
118
118
|
if (0 < u) {
|
|
119
|
-
var
|
|
119
|
+
var d, S = e.keyToSnapshotMap, {
|
|
120
120
|
keyValueMap: v,
|
|
121
121
|
info: o,
|
|
122
122
|
snapshotNum: m
|
|
123
|
-
} =
|
|
124
|
-
for (
|
|
123
|
+
} = y = e.getMaxCombinedSnapshot(a);
|
|
124
|
+
for (d of a) if (y !== d) {
|
|
125
125
|
var g, {
|
|
126
126
|
keyValueMap: f,
|
|
127
127
|
snapshotNum: M,
|
|
128
128
|
info: V
|
|
129
|
-
} =
|
|
130
|
-
for (g in f) v[g] = f[g], S[g] =
|
|
131
|
-
e.delSnapshot(
|
|
129
|
+
} = d;
|
|
130
|
+
for (g in f) v[g] = f[g], S[g] = y;
|
|
131
|
+
e.delSnapshot(d), t.push([ M, V.verList[0] ]);
|
|
132
132
|
}
|
|
133
|
-
p.push(e.saveKeyValueMap(
|
|
133
|
+
p.push(e.saveKeyValueMap(y)), h.push([ m, o.pMVersion ]), r.push(m, o.vLVersion),
|
|
134
134
|
n[m] = {
|
|
135
135
|
...o
|
|
136
136
|
};
|
|
@@ -152,7 +152,7 @@ function h(a, s, e, t) {
|
|
|
152
152
|
snapshotNum: s,
|
|
153
153
|
info: e
|
|
154
154
|
} = s;
|
|
155
|
-
return await a.saveSnapshotInfo(s, e),
|
|
155
|
+
return await a.saveSnapshotInfo(s, e), y.log("Created snapshot " + s), [ s, e.maxChangeId ];
|
|
156
156
|
})(a, s));
|
|
157
157
|
return [ t, o ];
|
|
158
158
|
}
|