datafolder 1.0.17 → 1.0.18
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/README.md +7 -0
- package/package.json +17 -17
- package/sample.js +3 -0
- package/src/QyAcl.js +109 -87
- package/src/QyBatch.d.ts +4 -0
- package/src/QyBatch.js +150 -107
- package/src/QyBinaryHeap.d.ts +10 -0
- package/src/QyBinaryHeap.js +55 -0
- package/src/QyCD.d.ts +3 -0
- package/src/QyCD.js +68 -57
- package/src/QyCache.d.ts +8 -0
- package/src/QyCache.js +108 -70
- package/src/QyDB.js +4 -4
- package/src/QyFile.js +8 -7
- package/src/QyFileContentUtils.d.ts +0 -1
- package/src/QyFileContentUtils.js +123 -124
- package/src/QyHNSW.d.ts +10 -0
- package/src/QyHNSW.js +57 -0
- package/src/QyIndex.js +28 -27
- package/src/QyIndexPropTree.js +3 -1
- package/src/QySnapshots.js +209 -206
- package/src/QyTrigger.js +5 -6
- package/src/QyUtils.d.ts +5 -0
- package/src/QyUtils.js +108 -98
- package/static/codemirror.bundle/editor.bundle.js +17 -3
- package/test/testQyDocumentDB.js +38 -0
package/src/QySnapshots.js
CHANGED
|
@@ -6,47 +6,49 @@ import {
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
readdir as l,
|
|
9
|
-
readFile as
|
|
9
|
+
readFile as n
|
|
10
10
|
} from "node:fs/promises";
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
-
join as
|
|
13
|
+
join as s
|
|
14
14
|
} from "node:path";
|
|
15
15
|
|
|
16
|
-
import
|
|
16
|
+
import m from "node:zlib";
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
|
-
getDefaultOptions as
|
|
19
|
+
getDefaultOptions as r
|
|
20
20
|
} from "./QyDefaultOptions.js";
|
|
21
21
|
|
|
22
22
|
import {
|
|
23
|
-
Hash_Key_Length as
|
|
24
|
-
folderOrFileExists as
|
|
25
|
-
listToMap as
|
|
23
|
+
Hash_Key_Length as f,
|
|
24
|
+
folderOrFileExists as d,
|
|
25
|
+
listToMap as u,
|
|
26
26
|
isEmptyObj as h,
|
|
27
|
-
isString as v
|
|
27
|
+
isString as v,
|
|
28
|
+
isArray as M,
|
|
29
|
+
isFloat32Array as y
|
|
28
30
|
} from "./QyUtils.js";
|
|
29
31
|
|
|
30
32
|
import {
|
|
31
|
-
QyBinWriter as
|
|
33
|
+
QyBinWriter as g
|
|
32
34
|
} from "./QyBinWriter.js";
|
|
33
35
|
|
|
34
36
|
import {
|
|
35
|
-
bufferToNums as
|
|
36
|
-
numsToBuffer as
|
|
37
|
-
applyAclChange as
|
|
38
|
-
iterCmdKeys as
|
|
37
|
+
bufferToNums as c,
|
|
38
|
+
numsToBuffer as S,
|
|
39
|
+
applyAclChange as C,
|
|
40
|
+
iterCmdKeys as P
|
|
39
41
|
} from "./QyAcl.js";
|
|
40
42
|
|
|
41
43
|
import {
|
|
42
|
-
QyJsonSaver as
|
|
44
|
+
QyJsonSaver as x
|
|
43
45
|
} from "./QyJsonSaver.js";
|
|
44
46
|
|
|
45
47
|
import {
|
|
46
|
-
logger as
|
|
48
|
+
logger as F
|
|
47
49
|
} from "./QyLogger.js";
|
|
48
50
|
|
|
49
|
-
let
|
|
51
|
+
let D = Buffer.from("\n"), L = Buffer.from("'"), O = Buffer.from("z"), b = Buffer.from("vect"), E = L[0], J = O[0], K = b[0];
|
|
50
52
|
|
|
51
53
|
class t {
|
|
52
54
|
snapshotFolder;
|
|
@@ -60,329 +62,330 @@ class t {
|
|
|
60
62
|
snapshotMaxChangeId = 0;
|
|
61
63
|
maxSnapshotNum = 0;
|
|
62
64
|
snapshotCount = 0;
|
|
63
|
-
constructor(t,
|
|
64
|
-
(
|
|
65
|
-
...
|
|
66
|
-
...
|
|
67
|
-
}).vLOutdatedPercent = 2 *
|
|
68
|
-
var
|
|
65
|
+
constructor(t, a = void 0) {
|
|
66
|
+
(a = {
|
|
67
|
+
...r("QySnapshots"),
|
|
68
|
+
...a
|
|
69
|
+
}).vLOutdatedPercent = 2 * a.pMOutdatedPercent;
|
|
70
|
+
var o = s(t, "info");
|
|
69
71
|
Object.assign(this, {
|
|
70
72
|
snapshotFolder: t,
|
|
71
|
-
snapshotInfoFolder:
|
|
72
|
-
options:
|
|
73
|
-
qyJsonSaver: new
|
|
73
|
+
snapshotInfoFolder: o,
|
|
74
|
+
options: a,
|
|
75
|
+
qyJsonSaver: new x(o, a)
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
78
|
async loadSnapshotInfos() {
|
|
77
79
|
let {
|
|
78
80
|
snapshotInfoFolder: t,
|
|
79
|
-
qyJsonSaver:
|
|
80
|
-
numToSnapshotMap:
|
|
81
|
+
qyJsonSaver: r,
|
|
82
|
+
numToSnapshotMap: n
|
|
81
83
|
} = this;
|
|
82
|
-
if (await
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
for (
|
|
86
|
-
var e,
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
if (await d(t)) {
|
|
85
|
+
var a = await (async (t, a) => {
|
|
86
|
+
var o = {};
|
|
87
|
+
for (r of await l(a)) {
|
|
88
|
+
var e, s, r = /^([1-9][0-9]*)(_([0-9]+))*\.json/.exec(r);
|
|
89
|
+
r && (e = +r[1], r = r[3], r = r ? +r : 2, null == (s = o[e]) ? o[e] = r : (t.removeFile(_(e, Math.min(s, r))),
|
|
90
|
+
o[e] = Math.max(s, r)));
|
|
89
91
|
}
|
|
90
|
-
return Object.entries(
|
|
91
|
-
})(
|
|
92
|
-
let e = 0,
|
|
93
|
-
await Promise.all(
|
|
94
|
-
var
|
|
92
|
+
return Object.entries(o).map(([ t, a ]) => [ +t, a ]).sort((t, a) => t[0] - a[0]);
|
|
93
|
+
})(r, t);
|
|
94
|
+
let e = 0, s = 0;
|
|
95
|
+
await Promise.all(a.map(async ([ t, a ]) => {
|
|
96
|
+
var o = await r.loadFromFile(_(t, a)), a = (o.verList = [ a ], n[t] = {
|
|
95
97
|
snapshotNum: t,
|
|
96
|
-
info:
|
|
98
|
+
info: o,
|
|
97
99
|
posMap: {},
|
|
98
100
|
outdatedCount: 0
|
|
99
|
-
}), t = (++this.snapshotCount, t > e && (e = t,
|
|
100
|
-
this),
|
|
101
|
-
t = N(t,
|
|
101
|
+
}), t = (++this.snapshotCount, t > e && (e = t, s = o.maxChangeId),
|
|
102
|
+
this), o = a;
|
|
103
|
+
t = N(t, o), F.info("Loading " + t), o.prefixPM = await V(t);
|
|
102
104
|
})), Object.assign(this, {
|
|
103
105
|
maxSnapshotNum: e,
|
|
104
|
-
snapshotMaxChangeId:
|
|
106
|
+
snapshotMaxChangeId: s
|
|
105
107
|
});
|
|
106
108
|
var {
|
|
107
|
-
numToSnapshotMap:
|
|
109
|
+
numToSnapshotMap: o,
|
|
108
110
|
prefixMap: i
|
|
109
111
|
} = this;
|
|
110
|
-
for ([
|
|
111
|
-
var p,
|
|
112
|
-
for (p in
|
|
112
|
+
for ([ u ] of a) {
|
|
113
|
+
var p, f = o[u], u = f.prefixPM;
|
|
114
|
+
for (p in u) {
|
|
113
115
|
var h = i[p];
|
|
114
|
-
h ? h.push(
|
|
116
|
+
h ? h.push(f) : i[p] = [ f ];
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
}
|
|
119
121
|
closeAllFDs() {
|
|
120
|
-
var t,
|
|
121
|
-
for (t in
|
|
122
|
+
var t, a = this.fDMap;
|
|
123
|
+
for (t in a) e(a[t]), delete a[t];
|
|
122
124
|
}
|
|
123
125
|
saveKeyValueMap(t) {
|
|
124
|
-
var
|
|
126
|
+
var a, o = this.options.minLenToCompress, {
|
|
125
127
|
keyValueMap: e,
|
|
126
|
-
info:
|
|
127
|
-
} = t,
|
|
128
|
+
info: s
|
|
129
|
+
} = t, r = (++s.vLVersion, new g()), n = (r.start(this.getVLFilePath(t)),
|
|
128
130
|
Object.keys(e).sort()), i = {};
|
|
129
|
-
let p = 0,
|
|
130
|
-
for (
|
|
131
|
-
var l = e[
|
|
131
|
+
let p = 0, f = 0, u, h;
|
|
132
|
+
for (a of n) {
|
|
133
|
+
var l = e[a];
|
|
132
134
|
let t;
|
|
133
|
-
null == l ? t =
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
null == l ? t = A : (h = Buffer.isBuffer(l) ? (u = l, 0) : v(l) ? (u = l.length >= o ? (r.save(O),
|
|
136
|
+
m.zstdCompressSync(l)) : (r.save(L), Buffer.from(l)), 1) : y(l) ? (r.save(b),
|
|
137
|
+
u = Buffer.from(l.buffer, l.byteOffset, l.byteLength), 4) : (u = Buffer.from(JSON.stringify(I(a) && !M(l) ? Object.keys(l) : l)),
|
|
138
|
+
0), r.save([ u, D ]), l = h + u.length, t = [ p, l ], p += l + 1), i[a] = t,
|
|
139
|
+
++f;
|
|
137
140
|
}
|
|
138
141
|
return Object.assign(t, {
|
|
139
142
|
posMap: i,
|
|
140
143
|
outdatedCount: 0
|
|
141
|
-
}), Object.assign(
|
|
142
|
-
totalCount:
|
|
144
|
+
}), Object.assign(s, {
|
|
145
|
+
totalCount: f,
|
|
143
146
|
outdatedCount: 0
|
|
144
|
-
}), Promise.all([ this.savePosMap(t,
|
|
147
|
+
}), Promise.all([ this.savePosMap(t, n), r.stop() ]);
|
|
145
148
|
}
|
|
146
149
|
addMaxSnapshot(t) {
|
|
147
|
-
var
|
|
148
|
-
numToSnapshotMap:
|
|
150
|
+
var a, {
|
|
151
|
+
numToSnapshotMap: o,
|
|
149
152
|
keyToSnapshotMap: e
|
|
150
153
|
} = this, {
|
|
151
|
-
posMap:
|
|
152
|
-
keyValueMap:
|
|
153
|
-
snapshotNum:
|
|
154
|
+
posMap: s,
|
|
155
|
+
keyValueMap: r,
|
|
156
|
+
snapshotNum: n,
|
|
154
157
|
info: i
|
|
155
158
|
} = t, i = i.maxChangeId, i = (Object.assign(this, {
|
|
156
|
-
maxSnapshotNum:
|
|
159
|
+
maxSnapshotNum: n,
|
|
157
160
|
snapshotMaxChangeId: i
|
|
158
|
-
}),
|
|
159
|
-
for (
|
|
160
|
-
|
|
161
|
+
}), r || s);
|
|
162
|
+
for (a in i) e[a] = t;
|
|
163
|
+
o[n] = t, ++this.snapshotCount;
|
|
161
164
|
}
|
|
162
165
|
removeKey(t) {
|
|
163
|
-
var
|
|
164
|
-
if (
|
|
166
|
+
var a = this.keyToSnapshotMap, o = a[t];
|
|
167
|
+
if (o) return this.removeKeyFromSnapshot(o, t), delete a[t], !0;
|
|
165
168
|
}
|
|
166
|
-
applyCmdObj(t,
|
|
167
|
-
if (null !=
|
|
168
|
-
var e =
|
|
169
|
+
applyCmdObj(t, a, o) {
|
|
170
|
+
if (null != o) {
|
|
171
|
+
var e = o.length;
|
|
169
172
|
for (let t = 0; t < e; t += 2) {
|
|
170
|
-
var
|
|
171
|
-
|
|
173
|
+
var s = o[t], r = o[t + 1];
|
|
174
|
+
a[s] = null != r && I(s) ? u(r) : r;
|
|
172
175
|
}
|
|
173
176
|
}
|
|
174
|
-
|
|
175
|
-
t in
|
|
176
|
-
}),
|
|
177
|
+
P(t, t => {
|
|
178
|
+
t in a || (a[t] = this.getValueSync(t)), this.removeKey(t);
|
|
179
|
+
}), C(a, t);
|
|
177
180
|
}
|
|
178
181
|
getValueSync(t) {
|
|
179
|
-
var
|
|
182
|
+
var a = ((t, a) => {
|
|
180
183
|
let {
|
|
181
|
-
keyToSnapshotMap:
|
|
184
|
+
keyToSnapshotMap: o,
|
|
182
185
|
prefixMap: e
|
|
183
|
-
} = t,
|
|
184
|
-
if (
|
|
185
|
-
var
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
var i = ((t,
|
|
186
|
+
} = t, s = o[a];
|
|
187
|
+
if (s) return s;
|
|
188
|
+
var r = k(a), n = e[r];
|
|
189
|
+
if (n) for (;0 < n.length; ) {
|
|
190
|
+
s = n.pop();
|
|
191
|
+
var i = ((t, a, o) => {
|
|
189
192
|
var e, {
|
|
190
|
-
posMap:
|
|
191
|
-
prefixPM:
|
|
192
|
-
} =
|
|
193
|
-
if (
|
|
194
|
-
t.loadPartialPosMapBuffer(
|
|
195
|
-
})(t,
|
|
196
|
-
if (i &&
|
|
193
|
+
posMap: s,
|
|
194
|
+
prefixPM: r
|
|
195
|
+
} = a;
|
|
196
|
+
if (r = r[o]) return [ r, e ] = r, r = B(t, t.getPMFilePath(a), r, e),
|
|
197
|
+
t.loadPartialPosMapBuffer(a, o, r), s;
|
|
198
|
+
})(t, s, r);
|
|
199
|
+
if (i && a in i) return s;
|
|
197
200
|
}
|
|
198
201
|
})(this, t);
|
|
199
|
-
if (
|
|
202
|
+
if (a) {
|
|
200
203
|
var {
|
|
201
|
-
keyValueMap:
|
|
204
|
+
keyValueMap: o,
|
|
202
205
|
posMap: e
|
|
203
|
-
} =
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
if (
|
|
207
|
-
var [ e,
|
|
208
|
-
if (0 !=
|
|
209
|
-
var
|
|
210
|
-
if (
|
|
211
|
-
I(t) ?
|
|
206
|
+
} = a;
|
|
207
|
+
if (o) return o[t];
|
|
208
|
+
o = e[t];
|
|
209
|
+
if (o) {
|
|
210
|
+
var [ e, o ] = o;
|
|
211
|
+
if (0 != o) {
|
|
212
|
+
var s = this;
|
|
213
|
+
if (a = s.getVLFilePath(a), s = B(s, a, e, o)) return (a = s[0]) == E ? s.toString("utf8", 1) : a == J ? m.zstdDecompressSync(s.subarray(1)).toString() : a == K ? new Float32Array(s.buffer, s.byteOffset + 4, s.byteLength / Float32Array.BYTES_PER_ELEMENT - 1) : (e = JSON.parse(s),
|
|
214
|
+
I(t) ? u(e) : e);
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
|
-
loadPartialPosMapBuffer(
|
|
219
|
+
loadPartialPosMapBuffer(o, t, a) {
|
|
217
220
|
let {
|
|
218
221
|
posMap: e,
|
|
219
|
-
prefixPM:
|
|
220
|
-
} =
|
|
221
|
-
|
|
222
|
-
t in
|
|
222
|
+
prefixPM: s
|
|
223
|
+
} = o, r = (delete s[t], this).keyToSnapshotMap;
|
|
224
|
+
j(a, (t, a) => {
|
|
225
|
+
t in r ? ++o.outdatedCount : (e[t] = a, r[t] = o);
|
|
223
226
|
});
|
|
224
227
|
}
|
|
225
228
|
delSnapshot(t) {
|
|
226
|
-
delete this.numToSnapshotMap[t.snapshotNum], --this.snapshotCount,
|
|
227
|
-
|
|
229
|
+
delete this.numToSnapshotMap[t.snapshotNum], --this.snapshotCount, a(this, this.getVLFilePath(t)),
|
|
230
|
+
a(this, this.getPMFilePath(t));
|
|
228
231
|
}
|
|
229
232
|
calOutdates() {
|
|
230
|
-
var t,
|
|
233
|
+
var t, a, o, e = [], s = [], r = [], n = [], {
|
|
231
234
|
options: i,
|
|
232
235
|
numToSnapshotMap: p
|
|
233
236
|
} = this, {
|
|
234
|
-
pMOutdatedPercent:
|
|
235
|
-
vLOutdatedPercent:
|
|
237
|
+
pMOutdatedPercent: f,
|
|
238
|
+
vLOutdatedPercent: u
|
|
236
239
|
} = i;
|
|
237
240
|
for (t in p) {
|
|
238
241
|
var h, l = p[t];
|
|
239
|
-
l.isOut || (100 == (h = Q(l)) ? (this.delSnapshot(l), e.push([ t, l.info.verList[0] ])) :
|
|
240
|
-
l.info.totalCount < h.options.minSnapshotKeyCount &&
|
|
242
|
+
l.isOut || (100 == (h = Q(l)) ? (this.delSnapshot(l), e.push([ t, l.info.verList[0] ])) : u < h ? (T(l) ? s : n).push(l) : Math.floor(l.outdatedCount / l.info.totalCount * 100) > f ? r.push(l) : (h = this,
|
|
243
|
+
l.info.totalCount < h.options.minSnapshotKeyCount && T(l) && s.push(l)));
|
|
241
244
|
}
|
|
242
|
-
1 ==
|
|
243
|
-
for ([
|
|
245
|
+
1 == s.length && Q(s[0]) < u && (s.length = 0);
|
|
246
|
+
for ([ a, o ] of [ [ "pMCompacts", r ], [ "vLCompacts", n ], [ "combiningSnapshots", s ] ]) 0 < o.length && F.log(a + ":" + o.map(t => t.snapshotNum + "." + t.info.verList[0]));
|
|
244
247
|
return {
|
|
245
248
|
emptySnapshotNumVerList: e,
|
|
246
|
-
combiningSnapshotList:
|
|
247
|
-
pMCompactSnapshotList:
|
|
248
|
-
vLCompactSnapshotList:
|
|
249
|
+
combiningSnapshotList: s,
|
|
250
|
+
pMCompactSnapshotList: r,
|
|
251
|
+
vLCompactSnapshotList: n
|
|
249
252
|
};
|
|
250
253
|
}
|
|
251
254
|
getMaxCombinedSnapshot(t) {
|
|
252
|
-
let
|
|
255
|
+
let a, o;
|
|
253
256
|
for (var e of t) {
|
|
254
|
-
var
|
|
255
|
-
(!
|
|
257
|
+
var s = e.snapshotNum;
|
|
258
|
+
(!o || o < s) && (a = e, o = s);
|
|
256
259
|
}
|
|
257
|
-
return
|
|
260
|
+
return a;
|
|
258
261
|
}
|
|
259
262
|
getPMFilePath(t) {
|
|
260
263
|
var {
|
|
261
264
|
snapshotNum: t,
|
|
262
|
-
info:
|
|
265
|
+
info: a
|
|
263
266
|
} = t;
|
|
264
|
-
return
|
|
267
|
+
return s(this.snapshotFolder, "" + t, a.pMVersion + "_pM.txt");
|
|
265
268
|
}
|
|
266
269
|
getVLFilePath(t) {
|
|
267
270
|
var {
|
|
268
271
|
snapshotNum: t,
|
|
269
|
-
info:
|
|
272
|
+
info: a
|
|
270
273
|
} = t;
|
|
271
|
-
return
|
|
274
|
+
return s(this.snapshotFolder, "" + t, a.vLVersion + "_vL.txt");
|
|
272
275
|
}
|
|
273
|
-
async saveSnapshotInfo(t,
|
|
274
|
-
var
|
|
276
|
+
async saveSnapshotInfo(t, a) {
|
|
277
|
+
var o = this.qyJsonSaver, {
|
|
275
278
|
pMVersion: e,
|
|
276
|
-
vLVersion:
|
|
277
|
-
verList:
|
|
278
|
-
outdatedCount:
|
|
279
|
+
vLVersion: s,
|
|
280
|
+
verList: r,
|
|
281
|
+
outdatedCount: n,
|
|
279
282
|
totalCount: i
|
|
280
|
-
} =
|
|
281
|
-
return
|
|
282
|
-
!!await
|
|
283
|
-
...
|
|
283
|
+
} = a, p = r[0], r = r[0] = e + s;
|
|
284
|
+
return a.outdated = Math.floor(100 * n / i) + "%", F.log(`Saving snapshotInfo:${p ? t + `.${p}->` : ""}${t}.` + r),
|
|
285
|
+
!!await o.saveToFile({
|
|
286
|
+
...a,
|
|
284
287
|
verList: void 0
|
|
285
|
-
},
|
|
288
|
+
}, _(t, r), !0) && (null != p && o.removeFile(_(t, p)), !0);
|
|
286
289
|
}
|
|
287
|
-
savePosMap(t,
|
|
288
|
-
var
|
|
290
|
+
savePosMap(t, a) {
|
|
291
|
+
var o, {
|
|
289
292
|
outdatedCount: e,
|
|
290
|
-
info:
|
|
291
|
-
posMap:
|
|
292
|
-
} = t,
|
|
293
|
+
info: s,
|
|
294
|
+
posMap: r
|
|
295
|
+
} = t, n = (s.outdatedCount += e, t.outdatedCount = 0, ++s.pMVersion, new g()), i = (n.start(this.getPMFilePath(t)),
|
|
293
296
|
t.prefixPM = {});
|
|
294
|
-
let p = 0,
|
|
295
|
-
for (
|
|
296
|
-
null ==
|
|
297
|
-
p +=
|
|
298
|
-
var h = Buffer.from(
|
|
299
|
-
|
|
297
|
+
let p = 0, f = 0, u;
|
|
298
|
+
for (o of a = a || Object.keys(r).sort()) {
|
|
299
|
+
null == u ? u = k(o) : o.startsWith(u) || (i[u] = [ p, f ], u = k(o),
|
|
300
|
+
p += f, f = 0);
|
|
301
|
+
var h = Buffer.from(o), l = S(r[o]);
|
|
302
|
+
n.save([ h, l ]), f += h.length + l.length;
|
|
300
303
|
}
|
|
301
|
-
return null !=
|
|
302
|
-
var
|
|
303
|
-
for (
|
|
304
|
+
return null != u && (i[u] = [ p, f ]), Promise.all([ n.stop(), ((t, a) => {
|
|
305
|
+
var o, e = new g(), s = (e.start(N(t, a)), a).prefixPM;
|
|
306
|
+
for (o in s) e.save([ Buffer.from(o), S(s[o]) ]);
|
|
304
307
|
return e.stop();
|
|
305
308
|
})(this, t) ]);
|
|
306
309
|
}
|
|
307
310
|
isEmptySnapshot(t) {
|
|
308
311
|
var {
|
|
309
312
|
info: t,
|
|
310
|
-
outdatedCount:
|
|
313
|
+
outdatedCount: a
|
|
311
314
|
} = t;
|
|
312
|
-
return
|
|
315
|
+
return a + t.outdatedCount == t.totalCount;
|
|
313
316
|
}
|
|
314
|
-
removeKeyFromSnapshot(t,
|
|
317
|
+
removeKeyFromSnapshot(t, a) {
|
|
315
318
|
var {
|
|
316
|
-
posMap:
|
|
319
|
+
posMap: o,
|
|
317
320
|
keyValueMap: e
|
|
318
321
|
} = t;
|
|
319
|
-
e && delete e[
|
|
322
|
+
e && delete e[a], o && delete o[a], ++t.outdatedCount;
|
|
320
323
|
}
|
|
321
324
|
}
|
|
322
325
|
|
|
323
|
-
function
|
|
324
|
-
var e =
|
|
326
|
+
function j(a, o) {
|
|
327
|
+
var e = a.length;
|
|
325
328
|
for (let t = 0; t < e; ) {
|
|
326
|
-
var
|
|
327
|
-
t =
|
|
329
|
+
var s = t + f, r = a.toString("latin1", t, s), n = [];
|
|
330
|
+
t = c(a, s, n), o(r, n);
|
|
328
331
|
}
|
|
329
332
|
}
|
|
330
333
|
|
|
331
|
-
async function
|
|
332
|
-
var
|
|
333
|
-
for (let t = 0; t <
|
|
334
|
-
var
|
|
335
|
-
t =
|
|
334
|
+
async function V(t) {
|
|
335
|
+
var a = await n(t), o = a.length, e = {};
|
|
336
|
+
for (let t = 0; t < o; ) {
|
|
337
|
+
var s = t + w, r = e[a.toString("latin1", t, s)] = [];
|
|
338
|
+
t = c(a, s, r);
|
|
336
339
|
}
|
|
337
340
|
return e;
|
|
338
341
|
}
|
|
339
342
|
|
|
340
|
-
function
|
|
341
|
-
var
|
|
342
|
-
let
|
|
343
|
+
function B(t, a, o, e) {
|
|
344
|
+
var s = ((t, a) => {
|
|
345
|
+
let o = t.fDMap, e = o[a];
|
|
343
346
|
if (!e) {
|
|
344
|
-
|
|
347
|
+
F.info("Opening " + a);
|
|
345
348
|
try {
|
|
346
|
-
e = a
|
|
349
|
+
e = o[a] = p(a, "r");
|
|
347
350
|
} catch (t) {
|
|
348
|
-
throw
|
|
351
|
+
throw F.error(`Opening ${a} failed:`, t), t;
|
|
349
352
|
}
|
|
350
353
|
}
|
|
351
354
|
return e;
|
|
352
|
-
})(t,
|
|
355
|
+
})(t, a), r = Buffer.allocUnsafe(e);
|
|
353
356
|
for (let t = 0; t < e; ) {
|
|
354
|
-
var
|
|
355
|
-
if (0 ==
|
|
356
|
-
t +=
|
|
357
|
+
var n = i(s, r, t, e - t, o + t);
|
|
358
|
+
if (0 == n) return void F.error(`readSync ${a} at ${o + t} returning 0 byte`);
|
|
359
|
+
t += n;
|
|
357
360
|
}
|
|
358
|
-
return
|
|
361
|
+
return r;
|
|
359
362
|
}
|
|
360
363
|
|
|
361
|
-
function
|
|
364
|
+
function T(t) {
|
|
362
365
|
var {
|
|
363
|
-
keyValueMap:
|
|
364
|
-
prefixPM:
|
|
366
|
+
keyValueMap: a,
|
|
367
|
+
prefixPM: o
|
|
365
368
|
} = t;
|
|
366
|
-
return
|
|
369
|
+
return a || null == o || h(t.prefixPM);
|
|
367
370
|
}
|
|
368
371
|
|
|
369
|
-
function N(t,
|
|
372
|
+
function N(t, a) {
|
|
370
373
|
var {
|
|
371
|
-
snapshotNum:
|
|
372
|
-
info:
|
|
373
|
-
} =
|
|
374
|
-
return
|
|
374
|
+
snapshotNum: a,
|
|
375
|
+
info: o
|
|
376
|
+
} = a;
|
|
377
|
+
return s(t.snapshotFolder, "" + a, o.pMVersion + "_prefixPM.txt");
|
|
375
378
|
}
|
|
376
379
|
|
|
377
|
-
function
|
|
378
|
-
var t = t.fDMap,
|
|
379
|
-
null !=
|
|
380
|
+
function a(t, a) {
|
|
381
|
+
var t = t.fDMap, o = t[a];
|
|
382
|
+
null != o && (e(o), delete t[a]);
|
|
380
383
|
}
|
|
381
384
|
|
|
382
|
-
let
|
|
385
|
+
let A = [ 0, 0 ], w = 3;
|
|
383
386
|
|
|
384
|
-
function
|
|
385
|
-
return t.substring(0,
|
|
387
|
+
function k(t) {
|
|
388
|
+
return t.substring(0, w);
|
|
386
389
|
}
|
|
387
390
|
|
|
388
391
|
function I(t) {
|
|
@@ -392,18 +395,18 @@ function I(t) {
|
|
|
392
395
|
function Q(t) {
|
|
393
396
|
var {
|
|
394
397
|
outdatedCount: t,
|
|
395
|
-
info:
|
|
396
|
-
} = t,
|
|
397
|
-
return t ==
|
|
398
|
+
info: a
|
|
399
|
+
} = t, o = a.totalCount, t = t + a.outdatedCount;
|
|
400
|
+
return t == o ? 100 : Math.floor(t / o * 100);
|
|
398
401
|
}
|
|
399
402
|
|
|
400
|
-
function
|
|
401
|
-
return t + (2 <
|
|
403
|
+
function _(t, a) {
|
|
404
|
+
return t + (2 < a ? "_" + a : "") + ".json";
|
|
402
405
|
}
|
|
403
406
|
|
|
404
407
|
export {
|
|
405
408
|
t as QySnapshots,
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
+
j as iterPMBuffer,
|
|
410
|
+
V as loadPrefixPMFile,
|
|
411
|
+
_ as getInfoFileName
|
|
409
412
|
};
|
package/src/QyTrigger.js
CHANGED
|
@@ -11,15 +11,14 @@ import {
|
|
|
11
11
|
isEmptyObj as e,
|
|
12
12
|
isMatchName as l,
|
|
13
13
|
getMatchParam as d,
|
|
14
|
-
propNameJoin as v
|
|
14
|
+
propNameJoin as v,
|
|
15
|
+
isArray as N
|
|
15
16
|
} from "./QyUtils.js";
|
|
16
17
|
|
|
17
18
|
import {
|
|
18
|
-
logger as
|
|
19
|
+
logger as y
|
|
19
20
|
} from "./QyLogger.js";
|
|
20
21
|
|
|
21
|
-
let y = Array.isArray;
|
|
22
|
-
|
|
23
22
|
class f {
|
|
24
23
|
name;
|
|
25
24
|
parent;
|
|
@@ -99,7 +98,7 @@ class h {
|
|
|
99
98
|
p(l, f) || (l = {
|
|
100
99
|
oldValue: l,
|
|
101
100
|
newValue: f
|
|
102
|
-
}, (
|
|
101
|
+
}, (N(f) || N(c(n, t))) && (l.isArrayDelta = !0), (g = g || {
|
|
103
102
|
_file: e,
|
|
104
103
|
_fileContent: n
|
|
105
104
|
})[v(t)] = l, u(g, t, l));
|
|
@@ -116,7 +115,7 @@ class h {
|
|
|
116
115
|
try {
|
|
117
116
|
s && s(g), o.emit(a, g);
|
|
118
117
|
} catch (e) {
|
|
119
|
-
|
|
118
|
+
y.error(`Running trigger ${a} failed:`, g, e);
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
}
|