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