datafolder 1.0.28 → 1.0.30
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 +4 -0
- package/package.json +1 -1
- package/scripts/airbnb.js +5 -5
- package/scripts/airbnb2.js +4 -4
- package/scripts/airbnb_queries.js +6 -6
- package/scripts/convertBinFiles.js +2 -2
- package/scripts/fastify.js +2 -1
- package/scripts/flights.js +1 -1
- package/scripts/flights2.js +2 -2
- package/scripts/flights2_queries.js +6 -6
- package/scripts/flights_queries.js +6 -6
- package/src/QyAcl.d.ts +1 -1
- package/src/QyAcl.js +85 -87
- package/src/QyBatch.d.ts +1 -1
- package/src/QyBatch.js +188 -212
- package/src/QyBinWriter.js +11 -14
- package/src/QyBinaryHeap.js +2 -2
- package/src/QyCD.js +1 -1
- package/src/QyCache.js +24 -27
- package/src/QyCompressor.js +2 -2
- package/src/QyDB.js +1 -1
- package/src/QyDir.js +9 -9
- package/src/QyEmbeddingWriter.js +1 -1
- package/src/QyEmbeddings.js +45 -48
- package/src/QyExpire.js +20 -28
- package/src/QyExpireInfo.js +32 -32
- package/src/QyExpire_Worker.js +2 -5
- package/src/QyFile.js +67 -67
- package/src/QyFileContentUtils.js +95 -95
- package/src/QyFileLogger.js +1 -1
- package/src/QyIndex.js +113 -113
- package/src/QyIndexPropTree.js +5 -5
- package/src/QyIntersectNode.js +8 -10
- package/src/QyItem.js +28 -28
- package/src/QyKVData.js +40 -45
- package/src/QyKVDataCleaner_Worker.js +1 -1
- package/src/QyKVDataSaver_Worker.js +5 -7
- package/src/QyMessageWorker.js +1 -1
- package/src/QyMessager.js +2 -2
- package/src/QySaver.js +20 -20
- package/src/QySnapshotCompactor_Worker.js +6 -15
- package/src/QySnapshotSaver_Worker.js +1 -1
- package/src/QySnapshots.js +78 -88
- package/src/QyStructure.js +1 -1
- package/src/QyTrigger.js +3 -8
- package/src/QyUtils.d.ts +1 -5
- package/src/QyUtils.js +73 -98
- package/src/hackernews.js +77 -59
- package/src/rpc/getFileContent.js +4 -3
- package/src/rpc/getSubItems.js +6 -4
- package/src/simulate.js +4 -4
- package/src/simulate2.js +3 -3
- package/src/soc_pokec.js +1 -1
- package/static/codemirror.bundle/editor.bundle.js +348 -178
- package/test/testQyAQL.js +23 -23
- package/test/testQyGraphQL.js +1 -1
- package/test/testQyNorthwind.js +4 -4
package/src/QyBatch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isDeepStrictEqual as
|
|
2
|
+
isDeepStrictEqual as c
|
|
3
3
|
} from "node:util";
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -10,17 +10,16 @@ import {
|
|
|
10
10
|
pathSplit as o,
|
|
11
11
|
ensurePropNamePathList as n,
|
|
12
12
|
isString as l,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
isEmptyObj as m,
|
|
13
|
+
getSuffix as g,
|
|
14
|
+
SpecialFilePaths as e,
|
|
15
|
+
toSingleName as p,
|
|
16
|
+
isSimpleType as h,
|
|
17
|
+
isEmptyObj as d,
|
|
19
18
|
isNumber as r,
|
|
20
|
-
getNowRounded as
|
|
19
|
+
getNowRounded as m,
|
|
21
20
|
isDate as a,
|
|
22
21
|
isArray as u,
|
|
23
|
-
isFloat32Array as
|
|
22
|
+
isFloat32Array as f
|
|
24
23
|
} from "./QyUtils.js";
|
|
25
24
|
|
|
26
25
|
import {
|
|
@@ -29,7 +28,7 @@ import {
|
|
|
29
28
|
} from "./QyAcl.js";
|
|
30
29
|
|
|
31
30
|
import {
|
|
32
|
-
calDifferenceList as
|
|
31
|
+
calDifferenceList as _
|
|
33
32
|
} from "./QyIndex.js";
|
|
34
33
|
|
|
35
34
|
import {
|
|
@@ -37,25 +36,25 @@ import {
|
|
|
37
36
|
} from "./QyDefaultOptions.js";
|
|
38
37
|
|
|
39
38
|
import {
|
|
40
|
-
QyCD as
|
|
39
|
+
QyCD as t
|
|
41
40
|
} from "./QyCD.js";
|
|
42
41
|
|
|
43
42
|
import {
|
|
44
|
-
getPrefixPropPaths as
|
|
43
|
+
getPrefixPropPaths as y
|
|
45
44
|
} from "./QyIndexPropTree.js";
|
|
46
45
|
|
|
47
46
|
import {
|
|
48
|
-
logger as
|
|
47
|
+
logger as x
|
|
49
48
|
} from "./QyLogger.js";
|
|
50
49
|
|
|
51
|
-
let
|
|
50
|
+
let D = e.IndexPropPathsFileName, F = {
|
|
52
51
|
none: 0,
|
|
53
52
|
basic: 1,
|
|
54
53
|
delta: 2,
|
|
55
54
|
all: 3
|
|
56
55
|
};
|
|
57
56
|
|
|
58
|
-
class
|
|
57
|
+
class O extends t {
|
|
59
58
|
fileLogLevel;
|
|
60
59
|
actionQueue;
|
|
61
60
|
changeId;
|
|
@@ -69,34 +68,34 @@ class L extends y {
|
|
|
69
68
|
...v("QyBatch"),
|
|
70
69
|
...t
|
|
71
70
|
};
|
|
72
|
-
e =
|
|
71
|
+
e = F[t.fileLogLevel.toLowerCase()];
|
|
73
72
|
Object.assign(this, {
|
|
74
73
|
options: t,
|
|
75
74
|
fileLogLevel: e ?? 1,
|
|
76
75
|
qyAclCmdGenerator: new i(),
|
|
77
|
-
qyCmdObjHistory: new
|
|
76
|
+
qyCmdObjHistory: new I(t.maxHistoryCmdObjCount),
|
|
78
77
|
actionQueue: [],
|
|
79
78
|
changeList: [],
|
|
80
79
|
syncList: []
|
|
81
80
|
});
|
|
82
81
|
}
|
|
83
82
|
createDir(e, t = this.currentDir) {
|
|
84
|
-
return l(e) && (e = o(e)),
|
|
83
|
+
return l(e) && (e = o(e)), P(this, this._action_createDir, {
|
|
85
84
|
item: this.qyCache.getOrCreateDir(e, t)
|
|
86
85
|
});
|
|
87
86
|
}
|
|
88
87
|
delDir(e, t = this.currentDir) {
|
|
89
|
-
return l(e) && (e = o(e)),
|
|
88
|
+
return l(e) && (e = o(e)), P(this, this._action_delDir, {
|
|
90
89
|
item: this.qyCache.getOrCreateDir(e, t).ensureAllLoaded()
|
|
91
90
|
});
|
|
92
91
|
}
|
|
93
92
|
createFile(e, t = this.currentDir) {
|
|
94
|
-
return l(e) && (e = o(e)),
|
|
93
|
+
return l(e) && (e = o(e)), P(this, this._action_createFile, {
|
|
95
94
|
item: this.qyCache.getOrCreateFile(e, t).ensureLoaded()
|
|
96
95
|
});
|
|
97
96
|
}
|
|
98
97
|
delFile(e, t = this.currentDir) {
|
|
99
|
-
return l(e) && (e = o(e)),
|
|
98
|
+
return l(e) && (e = o(e)), P(this, this._action_delFile, {
|
|
100
99
|
item: this.qyCache.getOrCreateFile(e, t).ensureLoaded()
|
|
101
100
|
});
|
|
102
101
|
}
|
|
@@ -115,7 +114,7 @@ class L extends y {
|
|
|
115
114
|
expireContent(e, t, i, r = this.currentDir) {
|
|
116
115
|
l(e) && (e = o(e));
|
|
117
116
|
e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
|
|
118
|
-
return
|
|
117
|
+
return P(this, this._action_expireContent, {
|
|
119
118
|
item: e,
|
|
120
119
|
expireInfoObj: t,
|
|
121
120
|
isMilliSecond: i
|
|
@@ -125,15 +124,15 @@ class L extends y {
|
|
|
125
124
|
return this.expireContent(e, t, !0, i);
|
|
126
125
|
}
|
|
127
126
|
removeFileExpire(e, t = !1, i = this.currentDir) {
|
|
128
|
-
return
|
|
127
|
+
return j(this, e, "f", t, i);
|
|
129
128
|
}
|
|
130
129
|
removeDirExpire(e, t = !1, i = this.currentDir) {
|
|
131
|
-
return
|
|
130
|
+
return j(this, e, "d", t, i);
|
|
132
131
|
}
|
|
133
132
|
removeContentExpire(e, t, i = !1, r = this.currentDir) {
|
|
134
133
|
l(e) && (e = o(e));
|
|
135
134
|
e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
|
|
136
|
-
return
|
|
135
|
+
return P(this, this._action_removeContentExpire, {
|
|
137
136
|
item: e,
|
|
138
137
|
expireInfoObj: t,
|
|
139
138
|
infoFileOnly: i
|
|
@@ -142,7 +141,7 @@ class L extends y {
|
|
|
142
141
|
createIndex(e, t, i = this.currentDir) {
|
|
143
142
|
l(e) && (e = o(e)), u(t) || (t = [ t ]);
|
|
144
143
|
e = this.qyCache.getOrCreateDir(e, i);
|
|
145
|
-
return
|
|
144
|
+
return P(this, this._action_createIndex, {
|
|
146
145
|
item: e,
|
|
147
146
|
indexPropPathList: t
|
|
148
147
|
});
|
|
@@ -150,7 +149,7 @@ class L extends y {
|
|
|
150
149
|
delIndex(e, t, i = this.currentDir) {
|
|
151
150
|
l(e) && (e = o(e));
|
|
152
151
|
e = this.qyCache.getOrCreateDir(e, i);
|
|
153
|
-
return
|
|
152
|
+
return P(this, this._action_delIndex, {
|
|
154
153
|
item: e,
|
|
155
154
|
indexPropPath: t
|
|
156
155
|
});
|
|
@@ -158,48 +157,40 @@ class L extends y {
|
|
|
158
157
|
insert(e, t, i = !0, r = !1, n = this.currentDir) {
|
|
159
158
|
l(e) && (e = o(e));
|
|
160
159
|
e = this.qyCache.getOrCreateFile(e, n).ensureLoaded();
|
|
161
|
-
return t = i ||
|
|
160
|
+
return t = i || h(t) ? t : structuredClone(t), P(this, this._action_insert, {
|
|
162
161
|
item: e,
|
|
163
162
|
content: t,
|
|
164
163
|
noCreate: r
|
|
165
164
|
});
|
|
166
165
|
}
|
|
167
166
|
insertEmbedding(e, t, i = this.currentDir) {
|
|
168
|
-
var r = this.qyCache, r = (
|
|
167
|
+
var r = this.qyCache, r = (f(t) || (t = new Float32Array(t)), l(e) && (e = o(e)),
|
|
169
168
|
r.getOrCreateFile(e, i));
|
|
170
|
-
return
|
|
169
|
+
return P(this, this._action_insertEmbedding, {
|
|
171
170
|
item: r,
|
|
172
171
|
embedding: t
|
|
173
172
|
});
|
|
174
173
|
}
|
|
175
174
|
delEmbedding(e, t = this.currentDir) {
|
|
176
175
|
var i = this.qyCache, i = (l(e) && (e = o(e)), i.getOrCreateFile(e, t));
|
|
177
|
-
return
|
|
176
|
+
return P(this, this._action_delEmbedding, {
|
|
178
177
|
item: i
|
|
179
178
|
});
|
|
180
179
|
}
|
|
181
|
-
insertWithEmbedding(e, t, i, r = !
|
|
180
|
+
insertWithEmbedding(e, t, i, r = !0, n = !1, a = this.currentDir) {
|
|
182
181
|
return this.insert(e, t, r, n, a), this.insertEmbedding(e, i, a);
|
|
183
182
|
}
|
|
184
|
-
put(e, t, i = this.currentDir) {
|
|
185
|
-
l(e) && (e = o(e));
|
|
186
|
-
e = this.qyCache.getOrCreateFile(e, i).ensureLoaded();
|
|
187
|
-
return q(this, this._action_put, {
|
|
188
|
-
item: e,
|
|
189
|
-
content: t
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
183
|
delContent(e, t = this.currentDir) {
|
|
193
184
|
l(e) && (e = o(e));
|
|
194
185
|
e = this.qyCache.getOrCreateFile(e, t).ensureLoaded();
|
|
195
|
-
return
|
|
186
|
+
return P(this, this._action_delContent, {
|
|
196
187
|
item: e
|
|
197
188
|
});
|
|
198
189
|
}
|
|
199
190
|
insertTrigger(e, t, i, r) {
|
|
200
191
|
l(t) && (t = o(t)), i = n(i);
|
|
201
192
|
e = this.qyCache.getOrCreateTriggerFile(e);
|
|
202
|
-
return
|
|
193
|
+
return P(this, this._action_insertTrigger, {
|
|
203
194
|
item: e,
|
|
204
195
|
fileNamePath: t,
|
|
205
196
|
propNamePathList: i,
|
|
@@ -207,19 +198,19 @@ class L extends y {
|
|
|
207
198
|
});
|
|
208
199
|
}
|
|
209
200
|
removeTrigger(e) {
|
|
210
|
-
return
|
|
201
|
+
return P(this, this._action_removeTrigger, {
|
|
211
202
|
item: this.qyCache.getOrCreateTriggerFile(e)
|
|
212
203
|
});
|
|
213
204
|
}
|
|
214
205
|
insertRpc(e, t) {
|
|
215
206
|
e = this.qyCache.getOrCreateRpcFile(e);
|
|
216
|
-
return
|
|
207
|
+
return P(this, this._action_insertRpc, {
|
|
217
208
|
item: e,
|
|
218
209
|
modCode: t
|
|
219
210
|
});
|
|
220
211
|
}
|
|
221
212
|
removeRpc(e) {
|
|
222
|
-
return
|
|
213
|
+
return P(this, this._action_removeRpc, {
|
|
223
214
|
item: this.qyCache.getOrCreateRpcFile(e)
|
|
224
215
|
});
|
|
225
216
|
}
|
|
@@ -230,7 +221,7 @@ class L extends y {
|
|
|
230
221
|
fileLogLevel: r,
|
|
231
222
|
qyCache: n
|
|
232
223
|
} = this;
|
|
233
|
-
if (t || 0
|
|
224
|
+
if (t || 0 === i.length) return 0;
|
|
234
225
|
this.running = !0;
|
|
235
226
|
var a, t = this.changeId = n.increaseChangeId();
|
|
236
227
|
for (a of i) a.actionFun.call(this, a);
|
|
@@ -240,16 +231,16 @@ class L extends y {
|
|
|
240
231
|
qyAclCmdGenerator: o,
|
|
241
232
|
qyCmdObjHistory: s,
|
|
242
233
|
syncList: l
|
|
243
|
-
} = this,
|
|
244
|
-
if (0
|
|
245
|
-
var
|
|
234
|
+
} = this, h = i.length;
|
|
235
|
+
if (0 === h) return n.decreaseChangeId(), 0;
|
|
236
|
+
var c = g(h), o = o.takeCmdArgAsListObj();
|
|
246
237
|
let d;
|
|
247
238
|
0 < r && (r = i.map(({
|
|
248
239
|
logStr: e
|
|
249
|
-
}) => e).join("\n"), d = new Date().toISOString() + `: ${
|
|
240
|
+
}) => e).join("\n"), d = new Date().toISOString() + `: ${h} change${c}:
|
|
250
241
|
${r}
|
|
251
242
|
`);
|
|
252
|
-
var m, u,
|
|
243
|
+
var m, u, h = n.save(t, o, d, (e => {
|
|
253
244
|
var t = e.syncList, i = t.length;
|
|
254
245
|
for (let e = 0; e < i; e += 2) {
|
|
255
246
|
var r, n = e + 1, a = t[e], o = t[n];
|
|
@@ -257,7 +248,7 @@ ${r}
|
|
|
257
248
|
t[n] = 0 < r.length ? r : void 0) : t[n] = o.fileContent;
|
|
258
249
|
}
|
|
259
250
|
if (0 < i) return t;
|
|
260
|
-
})(this), e),
|
|
251
|
+
})(this), e), c = (l.length = 0, s.push(o), i.filter(({
|
|
261
252
|
item: e,
|
|
262
253
|
delta: t
|
|
263
254
|
}) => t && 0 < e.triggerNodes?.length));
|
|
@@ -265,38 +256,38 @@ ${r}
|
|
|
265
256
|
for ({
|
|
266
257
|
item: m,
|
|
267
258
|
delta: u
|
|
268
|
-
} of
|
|
269
|
-
return e ?
|
|
259
|
+
} of c) for (var f of m.triggerNodes) f.checkTrigger(m, u);
|
|
260
|
+
return e ? h : t;
|
|
270
261
|
}
|
|
271
262
|
getTopHistoryCmdObj() {
|
|
272
263
|
return this.qyCmdObjHistory.top();
|
|
273
264
|
}
|
|
274
265
|
_action_insertTrigger(e) {
|
|
275
266
|
e.actionName = "insertTrigger";
|
|
276
|
-
var
|
|
267
|
+
var {
|
|
277
268
|
item: e,
|
|
278
|
-
fileNamePath:
|
|
279
|
-
propNamePathList:
|
|
280
|
-
modCode:
|
|
269
|
+
fileNamePath: t,
|
|
270
|
+
propNamePathList: i,
|
|
271
|
+
modCode: r
|
|
281
272
|
} = e, {
|
|
282
|
-
name:
|
|
283
|
-
fileContent:
|
|
284
|
-
} = e,
|
|
273
|
+
name: n,
|
|
274
|
+
fileContent: a
|
|
275
|
+
} = e, a = a && a[0], o = [ t, i ], e = (r && o.push(r), this._action_insert({
|
|
285
276
|
item: e,
|
|
286
|
-
content:
|
|
287
|
-
});
|
|
288
|
-
return e && (
|
|
289
|
-
|
|
277
|
+
content: o
|
|
278
|
+
}));
|
|
279
|
+
return e && (o = this.qyCache, a && !c(a, t) && o.removeTriggerFromTree(n, a),
|
|
280
|
+
o.insertTriggerToTree(n, t, i, r)), e;
|
|
290
281
|
}
|
|
291
282
|
_action_removeTrigger(e) {
|
|
292
283
|
e.actionName = "removeTrigger";
|
|
293
284
|
var e = e.item, {
|
|
294
285
|
fileContent: t,
|
|
295
286
|
name: i
|
|
296
|
-
} = e
|
|
297
|
-
return !!this._action_delFile({
|
|
287
|
+
} = e, e = this._action_delFile({
|
|
298
288
|
item: e
|
|
299
|
-
})
|
|
289
|
+
});
|
|
290
|
+
return e && this.qyCache.removeTriggerFromTree(i, t[0]), e;
|
|
300
291
|
}
|
|
301
292
|
_action_insertRpc(e) {
|
|
302
293
|
e.actionName = "insertRpc";
|
|
@@ -321,36 +312,36 @@ ${r}
|
|
|
321
312
|
var e, {
|
|
322
313
|
item: t,
|
|
323
314
|
indexPropPathList: i
|
|
324
|
-
} = t, r = this.qyCache.getOrCreateIndexDir(t), n = r.getOrCreateFile(
|
|
315
|
+
} = t, r = this.qyCache.getOrCreateIndexDir(t), n = r.getOrCreateFile(D), {
|
|
325
316
|
fileContent: a,
|
|
326
317
|
qyIndexPropTree: o
|
|
327
318
|
} = (n.created || this._action_createFile({
|
|
328
319
|
item: n
|
|
329
320
|
}), n), s = [], l = {};
|
|
330
321
|
for (e of i) {
|
|
331
|
-
var
|
|
332
|
-
a && a[
|
|
322
|
+
var h = p(e);
|
|
323
|
+
a && a[h] || (s.push(e), l[h] = 1, o.insert(e));
|
|
333
324
|
}
|
|
334
|
-
if (0
|
|
335
|
-
|
|
325
|
+
if (0 !== s.length) {
|
|
326
|
+
x.log(`Creating index ${JSON.stringify(s)} for ` + t.fullPath), this._action_insert({
|
|
336
327
|
item: n,
|
|
337
328
|
content: l
|
|
338
329
|
});
|
|
339
330
|
{
|
|
340
|
-
var
|
|
331
|
+
var c, d = this, m = t, u = r, i = y(s);
|
|
341
332
|
let e;
|
|
342
|
-
for (
|
|
343
|
-
var
|
|
344
|
-
if (!
|
|
333
|
+
for (c of i) {
|
|
334
|
+
var f = u.searchOrCreateSubdir(c);
|
|
335
|
+
if (!f.created) {
|
|
345
336
|
d._action_createDir({
|
|
346
|
-
item:
|
|
337
|
+
item: f
|
|
347
338
|
});
|
|
348
|
-
for (var
|
|
339
|
+
for (var g of e = e || m.fileList) {
|
|
349
340
|
var {
|
|
350
|
-
fileContent:
|
|
341
|
+
fileContent: g,
|
|
351
342
|
name: C
|
|
352
|
-
} =
|
|
353
|
-
|
|
343
|
+
} = g;
|
|
344
|
+
void 0 !== g && N(d, f, c, C, void 0, g);
|
|
354
345
|
}
|
|
355
346
|
}
|
|
356
347
|
}
|
|
@@ -363,12 +354,8 @@ ${r}
|
|
|
363
354
|
item: e,
|
|
364
355
|
indexPropPath: r
|
|
365
356
|
} = e, e = this.qyCache.getIndexDir(e);
|
|
366
|
-
e && ((i = e.getFile(
|
|
367
|
-
|
|
368
|
-
content: {
|
|
369
|
-
[_(r)]: F
|
|
370
|
-
}
|
|
371
|
-
}), t.remove(r).hasPrefix || (i = e.getSubdir(r)) && this._action_delDir({
|
|
357
|
+
e && ((i = e.getFile(D)) ? (t = i.qyIndexPropTree, this._setProp(i, p(r), null),
|
|
358
|
+
t.remove(r).hasPrefix || (i = e.getSubdir(r)) && this._action_delDir({
|
|
372
359
|
item: i
|
|
373
360
|
})) : this._action_delDir({
|
|
374
361
|
item: e
|
|
@@ -378,14 +365,14 @@ ${r}
|
|
|
378
365
|
e.actionName = "delFile";
|
|
379
366
|
var i = e.item;
|
|
380
367
|
if (!i.created) return !1;
|
|
381
|
-
|
|
368
|
+
void 0 !== i.fileContent && this._action_delContent({
|
|
382
369
|
item: i
|
|
383
370
|
});
|
|
384
371
|
var {
|
|
385
372
|
parentDir: r,
|
|
386
373
|
name: n
|
|
387
374
|
} = i;
|
|
388
|
-
return i.created = !1,
|
|
375
|
+
return i.created = !1, L(this, e), t || q(this, r, C.R, r.fileMapKey, n),
|
|
389
376
|
!0;
|
|
390
377
|
}
|
|
391
378
|
_action_delDir(e) {
|
|
@@ -401,45 +388,42 @@ ${r}
|
|
|
401
388
|
fileMapKey: s
|
|
402
389
|
} = t;
|
|
403
390
|
if (a) {
|
|
404
|
-
|
|
391
|
+
q(this, t, C.D, s);
|
|
405
392
|
for (var l of t.fileList) this._action_delFile({
|
|
406
393
|
item: l
|
|
407
394
|
}, !0);
|
|
408
395
|
}
|
|
409
396
|
if (n) {
|
|
410
|
-
|
|
411
|
-
for (var
|
|
397
|
+
q(this, t, C.D, o);
|
|
398
|
+
for (var h of t.allSubdirs()) {
|
|
412
399
|
let {
|
|
413
400
|
subdirMap: e,
|
|
414
401
|
fileMap: t,
|
|
415
402
|
subdirMapKey: i,
|
|
416
403
|
fileMapKey: r
|
|
417
|
-
} =
|
|
418
|
-
if (e &&
|
|
419
|
-
|
|
420
|
-
for (var
|
|
421
|
-
item:
|
|
404
|
+
} = h;
|
|
405
|
+
if (e && q(this, h, C.D, i), t) {
|
|
406
|
+
q(this, h, C.D, r);
|
|
407
|
+
for (var c of h.fileList) this._action_delFile({
|
|
408
|
+
item: c
|
|
422
409
|
}, !0);
|
|
423
410
|
}
|
|
424
|
-
|
|
411
|
+
L(this, {
|
|
425
412
|
actionName: "delDir",
|
|
426
|
-
item:
|
|
427
|
-
}),
|
|
413
|
+
item: h
|
|
414
|
+
}), h.created = !1;
|
|
428
415
|
}
|
|
429
416
|
}
|
|
430
|
-
return !!i && (t.created = !1,
|
|
417
|
+
return !!i && (t.created = !1, L(this, e), q(this, i, C.R, i.subdirMapKey, r),
|
|
431
418
|
!0);
|
|
432
419
|
}
|
|
433
420
|
_action_delContent(e) {
|
|
434
421
|
e.actionName = "delContent";
|
|
435
422
|
var t = e.item, i = t.fileContent;
|
|
436
|
-
return
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
newValue: F
|
|
441
|
-
}
|
|
442
|
-
}), N(this, e), I(this, t, C.D, t.fileContentKey), P(this, t, i), !0);
|
|
423
|
+
return void 0 !== i && (t.fileContent = void 0, e.content = i, e.delta = {
|
|
424
|
+
oldValue: i,
|
|
425
|
+
newValue: null
|
|
426
|
+
}, L(this, e), q(this, t, C.D, t.fileContentKey), b(this, t, i), !0);
|
|
443
427
|
}
|
|
444
428
|
_action_insertEmbedding(e) {
|
|
445
429
|
e.actionName = "insertEmbedding";
|
|
@@ -447,14 +431,10 @@ ${r}
|
|
|
447
431
|
item: a,
|
|
448
432
|
embedding: o
|
|
449
433
|
} = e, s = o.length, r = r.getOrCreateInfoFile(a), l = r.fileContent;
|
|
450
|
-
let
|
|
451
|
-
return r.created && l.length
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
content: {
|
|
455
|
-
idx: i
|
|
456
|
-
}
|
|
457
|
-
}), c = !0)) : ({
|
|
434
|
+
let h = !1;
|
|
435
|
+
return r.created && l.length === s ? (t = a.fullPathHash, l = l.idx, i = n.getEmbedding(t, s, l),
|
|
436
|
+
c(o, i) || ((i = n.updateEmbedding(t, o, l)) !== l && this._setProp(r, "idx", i),
|
|
437
|
+
h = !0)) : ({
|
|
458
438
|
fullPathHash: t,
|
|
459
439
|
namePath: l
|
|
460
440
|
} = a, i = n.addEmbedding(t, o), this._action_insert({
|
|
@@ -464,7 +444,7 @@ ${r}
|
|
|
464
444
|
idx: i,
|
|
465
445
|
namePath: r.created ? void 0 : l
|
|
466
446
|
}
|
|
467
|
-
}),
|
|
447
|
+
}), h = !0), h && L(this, e), h;
|
|
468
448
|
}
|
|
469
449
|
_action_delEmbedding(e) {
|
|
470
450
|
e.actionName = "delEmbedding";
|
|
@@ -474,7 +454,7 @@ ${r}
|
|
|
474
454
|
if (t && (o = t.fileContent, o) && (n = o.length, a = o.idx), i.delEmbedding(r.fullPathHash, n, a),
|
|
475
455
|
t) return this._action_delFile({
|
|
476
456
|
item: t
|
|
477
|
-
}),
|
|
457
|
+
}), L(this, e), !0;
|
|
478
458
|
}
|
|
479
459
|
_action_put(e) {
|
|
480
460
|
e.actionName = "put";
|
|
@@ -482,39 +462,52 @@ ${r}
|
|
|
482
462
|
item: t,
|
|
483
463
|
content: i
|
|
484
464
|
} = e;
|
|
485
|
-
if (
|
|
465
|
+
if (void 0 === i) return x.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
|
|
486
466
|
!1;
|
|
487
467
|
t.created || this._action_createFile({
|
|
488
468
|
item: t
|
|
489
469
|
});
|
|
490
470
|
var r = t.fileContentKey;
|
|
491
|
-
return i.$rpl = 1,
|
|
471
|
+
return i.$rpl = 1, q(this, t, C.M, r, i), L(this, e), t.fileContent = i,
|
|
492
472
|
!0;
|
|
493
473
|
}
|
|
474
|
+
_setProp(e, t, i) {
|
|
475
|
+
var {
|
|
476
|
+
created: r,
|
|
477
|
+
fileContentKey: n,
|
|
478
|
+
fileContent: a
|
|
479
|
+
} = e, r = (r || this._action_createFile({
|
|
480
|
+
item: e
|
|
481
|
+
}), a ? a[t] : void 0);
|
|
482
|
+
return null === i ? void 0 !== a && delete a[t] : void 0 !== a ? a[t] = i : e.fileContent = {
|
|
483
|
+
[t]: i
|
|
484
|
+
}, q(this, e, C.M, n, t, i), r;
|
|
485
|
+
}
|
|
494
486
|
_action_insert(e) {
|
|
495
487
|
e.actionName = "insert";
|
|
496
|
-
var {
|
|
497
|
-
item:
|
|
498
|
-
content:
|
|
499
|
-
noCreate:
|
|
488
|
+
var t, {
|
|
489
|
+
item: i,
|
|
490
|
+
content: r,
|
|
491
|
+
noCreate: n
|
|
492
|
+
} = e;
|
|
493
|
+
let {
|
|
494
|
+
merged: a,
|
|
495
|
+
delta: o
|
|
500
496
|
} = e;
|
|
501
|
-
if (
|
|
497
|
+
if (void 0 === o && void 0 === r) return x.warn(`Saving undefined to ${i.fullPath}. Not making any change.`),
|
|
502
498
|
!1;
|
|
503
|
-
if (!
|
|
504
|
-
if (
|
|
499
|
+
if (!i.created) {
|
|
500
|
+
if (n) return !1;
|
|
505
501
|
this._action_createFile({
|
|
506
|
-
item:
|
|
502
|
+
item: i
|
|
507
503
|
});
|
|
508
504
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
} = r;
|
|
513
|
-
return !!o && ({
|
|
514
|
-
oldValue: o,
|
|
505
|
+
return void 0 === a && void 0 === o && (n = s(i.fileContent, r), a = n.merged,
|
|
506
|
+
o = n.delta), void 0 !== o && ({
|
|
507
|
+
oldValue: r,
|
|
515
508
|
newValue: n
|
|
516
|
-
} = o,
|
|
517
|
-
|
|
509
|
+
} = o, t = i.fileContentKey, void 0 === a ? q(this, i, C.D, t) : q(this, i, C.M, t, n),
|
|
510
|
+
e.merged = a, e.delta = o, L(this, e), i.fileContent = a, b(this, i, r, n, a),
|
|
518
511
|
!0);
|
|
519
512
|
}
|
|
520
513
|
_action_createFile(e) {
|
|
@@ -522,10 +515,8 @@ ${r}
|
|
|
522
515
|
var t, i = e.item;
|
|
523
516
|
return !i.created && (t = i.parentDir, this._action_createDir({
|
|
524
517
|
item: t
|
|
525
|
-
}),
|
|
526
|
-
|
|
527
|
-
fileContentLoaded: !0
|
|
528
|
-
}), N(this, e), I(this, t, C.A, t.fileMapKey, i.name), !0);
|
|
518
|
+
}), i.created = !0, i.fileContentLoaded = !0, L(this, e), q(this, t, C.A, t.fileMapKey, i.name),
|
|
519
|
+
!0);
|
|
529
520
|
}
|
|
530
521
|
_action_createDir(e) {
|
|
531
522
|
e.actionName = "createDir";
|
|
@@ -533,16 +524,12 @@ ${r}
|
|
|
533
524
|
if (t.created) return !1;
|
|
534
525
|
for (var i = []; !t.created; ) i.push(t), t = t.parentDir;
|
|
535
526
|
for (let e of i.reverse()) {
|
|
536
|
-
|
|
537
|
-
created: !0,
|
|
538
|
-
subdirMapLoaded: !0,
|
|
539
|
-
fileMapLoaded: !0
|
|
540
|
-
}), N(this, {
|
|
527
|
+
e.created = !0, e.subdirMapLoaded = !0, e.fileMapLoaded = !0, L(this, {
|
|
541
528
|
actionName: "createDir",
|
|
542
529
|
item: e
|
|
543
530
|
});
|
|
544
531
|
var r = e.parentDir;
|
|
545
|
-
|
|
532
|
+
q(this, r, C.A, r.subdirMapKey, e.name);
|
|
546
533
|
}
|
|
547
534
|
return !0;
|
|
548
535
|
}
|
|
@@ -555,7 +542,7 @@ ${r}
|
|
|
555
542
|
parentDir: r,
|
|
556
543
|
name: n
|
|
557
544
|
} = e;
|
|
558
|
-
return !!r &&
|
|
545
|
+
return !!r && void 0 !== (i = S(i, !0, m())) && (t = this.qyCache, r = t.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"),
|
|
559
546
|
(r = this._action_insert({
|
|
560
547
|
item: r,
|
|
561
548
|
content: {
|
|
@@ -575,9 +562,9 @@ ${r}
|
|
|
575
562
|
return !!r && (t = this.qyCache, !!(r = t.getExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"))) && ((n = this._action_insert({
|
|
576
563
|
item: r,
|
|
577
564
|
content: {
|
|
578
|
-
[n]:
|
|
565
|
+
[n]: null
|
|
579
566
|
}
|
|
580
|
-
})) && (
|
|
567
|
+
})) && (d(r.fileContent) && this._action_delFile({
|
|
581
568
|
item: r
|
|
582
569
|
}), i || t.unmonitorItemExpire(e)), n);
|
|
583
570
|
}
|
|
@@ -587,8 +574,8 @@ ${r}
|
|
|
587
574
|
item: t,
|
|
588
575
|
expireInfoObj: i,
|
|
589
576
|
isMilliSecond: r
|
|
590
|
-
} = e, n =
|
|
591
|
-
var e =
|
|
577
|
+
} = e, n = m();
|
|
578
|
+
var e = E(i, e => S(e, r, n)), a = this.qyCache, o = a.getOrCreateExpireInfoFile(t.fullPathHash, "c"), o = this._action_insert({
|
|
592
579
|
item: o,
|
|
593
580
|
content: {
|
|
594
581
|
...e
|
|
@@ -603,22 +590,22 @@ ${r}
|
|
|
603
590
|
expireInfoObj: i,
|
|
604
591
|
infoFileOnly: r
|
|
605
592
|
} = e, n = this.qyCache, a = n.getExpireInfoFile(e.fullPathHash, "c");
|
|
606
|
-
return !!a && (i = u(i) ? Object.fromEntries(i.map(e => [ e,
|
|
593
|
+
return !!a && (i = u(i) ? Object.fromEntries(i.map(e => [ e, null ])) : E(i, e => e ? null : void 0),
|
|
607
594
|
(t = this._action_insert({
|
|
608
595
|
item: a,
|
|
609
596
|
content: i
|
|
610
|
-
})) && (
|
|
597
|
+
})) && (d(a.fileContent, !0) && this._action_delFile({
|
|
611
598
|
item: a
|
|
612
599
|
}), r || n.unmonitorContentExpire(e, i)), t);
|
|
613
600
|
}
|
|
614
601
|
}
|
|
615
602
|
|
|
616
|
-
function
|
|
603
|
+
function P(e, t, i) {
|
|
617
604
|
return e.running ? t.call(e, i) : (i.actionFun = t, e.actionQueue.push(i)),
|
|
618
605
|
e;
|
|
619
606
|
}
|
|
620
607
|
|
|
621
|
-
function
|
|
608
|
+
function L(e, t) {
|
|
622
609
|
var {
|
|
623
610
|
changeList: e,
|
|
624
611
|
fileLogLevel: i
|
|
@@ -632,76 +619,65 @@ function N(e, t) {
|
|
|
632
619
|
delta: a
|
|
633
620
|
} = e, i = e + ` "${i.fullPath ?? i}"`;
|
|
634
621
|
if ("delContent" === e) {
|
|
635
|
-
if (3
|
|
622
|
+
if (3 === t) return i + " " + JSON.stringify(r);
|
|
636
623
|
} else if ("insert" === e && 2 <= t) return {
|
|
637
624
|
oldValue: r,
|
|
638
625
|
newValue: e
|
|
639
|
-
} = a, a = `${
|
|
640
|
-
2
|
|
626
|
+
} = a, a = `${void 0 === r ? "" : "delta:"} ${JSON.stringify(r)} -> ` + JSON.stringify(e),
|
|
627
|
+
2 === t ? i + " " + a : i + ` ${a}. ` + (void 0 !== r ? "new: " + JSON.stringify(n) : "");
|
|
641
628
|
return i;
|
|
642
629
|
})(t, i)), e.push(t);
|
|
643
630
|
}
|
|
644
631
|
|
|
645
|
-
function
|
|
632
|
+
function q(e, t, i, r, n = void 0, a = void 0) {
|
|
646
633
|
var {
|
|
647
634
|
qyAclCmdGenerator: e,
|
|
648
|
-
qyCache:
|
|
649
|
-
syncList:
|
|
650
|
-
changeId:
|
|
635
|
+
qyCache: o,
|
|
636
|
+
syncList: s,
|
|
637
|
+
changeId: l
|
|
651
638
|
} = e;
|
|
652
|
-
e.pushCmd(i, r, n), r.startsWith("d") ? t.dChangeId =
|
|
653
|
-
|
|
639
|
+
e.pushCmd(i, r, n, a), r.startsWith("d") ? t.dChangeId = l : r.startsWith("f") ? t.fChangeId = l : t.cChangeId = l,
|
|
640
|
+
o && o.qyKVData.removeKey(r) && s.push(r, t);
|
|
654
641
|
}
|
|
655
642
|
|
|
656
|
-
function
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
t = s.getFile(O);
|
|
666
|
-
if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths()) E(e, s.searchOrCreateSubdir(l), l, a, i, r, n);
|
|
643
|
+
function b(e, t, i, r = void 0, n = void 0) {
|
|
644
|
+
if (!t.underHiddenFolder) {
|
|
645
|
+
var a = e.qyCache.getIndexDir(t.parentDir);
|
|
646
|
+
if (a) {
|
|
647
|
+
var o = a.getFile(D);
|
|
648
|
+
if (o) {
|
|
649
|
+
var s, l = t.name;
|
|
650
|
+
for (s of o.qyIndexPropTree.getAllIndexPropPaths()) N(e, a.searchOrCreateSubdir(s), s, l, i, r, n);
|
|
651
|
+
}
|
|
667
652
|
}
|
|
668
653
|
}
|
|
669
654
|
}
|
|
670
655
|
|
|
671
|
-
function
|
|
672
|
-
e =
|
|
656
|
+
function N(t, e, i, r, n, a, o = void 0) {
|
|
657
|
+
e = _(e, i, n, a, o);
|
|
673
658
|
if (e) {
|
|
674
|
-
var s, l,
|
|
659
|
+
var s, l, h, {
|
|
675
660
|
toAddFileList: i,
|
|
676
661
|
toDelFileList: n
|
|
677
662
|
} = e;
|
|
678
|
-
for (s of i)
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
for (c of n) if (m(c.fileContent)) {
|
|
693
|
-
t._action_delFile({
|
|
694
|
-
item: c
|
|
695
|
-
});
|
|
696
|
-
let e = c.parentDir;
|
|
697
|
-
for (;e.created && !e.isHiddenFolder && e.isEmpty; ) t._action_delDir({
|
|
698
|
-
item: e
|
|
699
|
-
}), e = e.parentDir;
|
|
663
|
+
for (s of i) t._setProp(s, r, 1);
|
|
664
|
+
for (l of n) l.created && t._setProp(l, r, null);
|
|
665
|
+
for (h of n) if (h.created) {
|
|
666
|
+
var c = h.fileContent;
|
|
667
|
+
if (void 0 === c || d(c)) {
|
|
668
|
+
t._action_delFile({
|
|
669
|
+
item: h
|
|
670
|
+
});
|
|
671
|
+
let e = h.parentDir;
|
|
672
|
+
for (;e.created && !e.isHiddenFolder && e.isEmpty; ) t._action_delDir({
|
|
673
|
+
item: e
|
|
674
|
+
}), e = e.parentDir;
|
|
675
|
+
}
|
|
700
676
|
}
|
|
701
677
|
}
|
|
702
678
|
}
|
|
703
679
|
|
|
704
|
-
class
|
|
680
|
+
class I {
|
|
705
681
|
maxLength;
|
|
706
682
|
actionQueue;
|
|
707
683
|
nextPos;
|
|
@@ -729,13 +705,13 @@ class Q {
|
|
|
729
705
|
}
|
|
730
706
|
}
|
|
731
707
|
|
|
732
|
-
function
|
|
733
|
-
if (
|
|
708
|
+
function E(e, t = void 0, i = [], r = {}) {
|
|
709
|
+
if (h(e)) {
|
|
734
710
|
var n = t ? t(e) : e;
|
|
735
|
-
|
|
711
|
+
void 0 !== n && (r[JSON.stringify(i)] = n);
|
|
736
712
|
} else {
|
|
737
713
|
var a, o = i.length;
|
|
738
|
-
for (a in e) i.push(a),
|
|
714
|
+
for (a in e) i.push(a), E(e[a], t, i, r), i.length = o;
|
|
739
715
|
}
|
|
740
716
|
return r;
|
|
741
717
|
}
|
|
@@ -745,21 +721,21 @@ function S(e, t, i) {
|
|
|
745
721
|
}
|
|
746
722
|
|
|
747
723
|
function T(e, t, i, r, n) {
|
|
748
|
-
var a = e.qyCache, r = (l(t) && (t = o(t)), "f"
|
|
749
|
-
return
|
|
724
|
+
var a = e.qyCache, r = (l(t) && (t = o(t)), "f" === r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
725
|
+
return P(e, e._action_expireItem, {
|
|
750
726
|
item: r,
|
|
751
727
|
milliSecond: i
|
|
752
728
|
});
|
|
753
729
|
}
|
|
754
730
|
|
|
755
|
-
function
|
|
756
|
-
var a = e.qyCache, i = (l(t) && (t = o(t)), "f"
|
|
757
|
-
return
|
|
731
|
+
function j(e, t, i, r, n) {
|
|
732
|
+
var a = e.qyCache, i = (l(t) && (t = o(t)), "f" === i ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
733
|
+
return P(e, e._action_removeItemExpire, {
|
|
758
734
|
item: i,
|
|
759
735
|
infoFileOnly: r
|
|
760
736
|
});
|
|
761
737
|
}
|
|
762
738
|
|
|
763
739
|
export {
|
|
764
|
-
|
|
740
|
+
O as QyBatch
|
|
765
741
|
};
|