datafolder 1.0.34 → 1.0.36
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/src/QyAcl.d.ts +10 -14
- package/src/QyAcl.js +166 -129
- package/src/QyAclSaver_Worker.d.ts +4 -3
- package/src/QyAclSaver_Worker.js +7 -10
- package/src/QyAclWriter.js +1 -1
- package/src/QyBatch.d.ts +1 -1
- package/src/QyBatch.js +130 -132
- package/src/QyCache.d.ts +9 -6
- package/src/QyCache.js +60 -79
- package/src/QyDB.d.ts +2 -1
- package/src/QyDB.js +12 -19
- package/src/QyDir.d.ts +8 -0
- package/src/QyDir.js +65 -36
- package/src/QyEmbeddings.d.ts +5 -3
- package/src/QyEmbeddings.js +11 -17
- package/src/QyFile.d.ts +5 -1
- package/src/QyFile.js +53 -44
- package/src/QyFileLogger.d.ts +2 -1
- package/src/QyFileLogger.js +9 -12
- package/src/QyItem.d.ts +8 -15
- package/src/QyItem.js +30 -67
- package/src/QyKVData.d.ts +12 -7
- package/src/QyKVData.js +41 -61
- package/src/QyKVDataCleaner_Worker.js +41 -47
- package/src/QyKVDataLoader.d.ts +3 -7
- package/src/QyKVDataLoader.js +29 -39
- package/src/QyKVDataSaver_Worker.d.ts +2 -2
- package/src/QyKVDataSaver_Worker.js +9 -16
- package/src/QyLogFileSaver_Worker.js +1 -3
- package/src/QyLogger.d.ts +14 -8
- package/src/QyLogger.js +97 -86
- package/src/QyMessager.d.ts +4 -1
- package/src/QyMessager.js +49 -57
- package/src/QyMessager_Run.js +8 -11
- package/src/QySaver.js +12 -15
- package/src/QySnapshotCompactor_Worker.js +23 -27
- package/src/QySnapshotSaver_Worker.d.ts +6 -7
- package/src/QySnapshotSaver_Worker.js +36 -67
- package/src/QySnapshots.d.ts +4 -8
- package/src/QySnapshots.js +22 -31
- package/src/QyTrigger.js +15 -22
- package/src/QyUnionNode.js +1 -4
package/src/QyCache.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import EventEmitter from "node:events";
|
|
2
2
|
import { QyDir } from "./QyDir.ts";
|
|
3
|
+
import { QyFileLogger } from "./QyFileLogger.ts";
|
|
4
|
+
import { QyKVData } from "./QyKVData.ts";
|
|
5
|
+
import { QyEmbeddings } from "./QyEmbeddings.ts";
|
|
3
6
|
import type { QyFile } from "./QyFile.ts";
|
|
4
7
|
export declare class QyCache extends EventEmitter {
|
|
5
8
|
rootFolder: any;
|
|
@@ -16,16 +19,16 @@ export declare class QyCache extends EventEmitter {
|
|
|
16
19
|
infoRootDir: any;
|
|
17
20
|
recycleRootDir: any;
|
|
18
21
|
exclusiveFilePath: any;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
rpcFunMap: any;
|
|
23
|
+
qyKVData: QyKVData | undefined;
|
|
24
|
+
qyFileLogger: QyFileLogger | undefined;
|
|
25
|
+
qyEmbeddings: QyEmbeddings | undefined;
|
|
23
26
|
constructor(rootFolder: string, options?: any, qyDB?: any);
|
|
24
27
|
start(): Promise<this>;
|
|
25
28
|
stop(): Promise<this>;
|
|
26
|
-
increaseChangeId():
|
|
29
|
+
increaseChangeId(): number;
|
|
27
30
|
decreaseChangeId(): void;
|
|
28
|
-
save(changeId: any,
|
|
31
|
+
save(changeId: any, cmdArgAsListArray: any, logText: any, syncList: any, needPromise: any): any;
|
|
29
32
|
getFile(namePath: QyFile | string | string[], parentDir?: any): QyFile | undefined;
|
|
30
33
|
getOrCreateFile(namePath: QyFile | string | string[], parentDir?: any): QyFile;
|
|
31
34
|
getDir(namePath: QyDir | string | string[], parentDir?: any): QyDir | undefined;
|
package/src/QyCache.js
CHANGED
|
@@ -18,19 +18,19 @@ import {
|
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
20
|
QyTriggerNode as R,
|
|
21
|
-
updateTriggerNodes as
|
|
21
|
+
updateTriggerNodes as a
|
|
22
22
|
} from "./QyTrigger.js";
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
25
|
isString as C,
|
|
26
|
-
lockExclusiveFilePath as
|
|
26
|
+
lockExclusiveFilePath as q,
|
|
27
27
|
unlockExclusiveFilePath as o,
|
|
28
|
-
ensureDir as
|
|
28
|
+
ensureDir as x,
|
|
29
29
|
SpecialFilePaths as e
|
|
30
30
|
} from "./QyUtils.js";
|
|
31
31
|
|
|
32
32
|
import {
|
|
33
|
-
dumpStructure as
|
|
33
|
+
dumpStructure as P
|
|
34
34
|
} from "./QyStructure.js";
|
|
35
35
|
|
|
36
36
|
import {
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
} from "./QyUnionNode.js";
|
|
47
47
|
|
|
48
48
|
import {
|
|
49
|
-
QyKVDataLoader as
|
|
49
|
+
QyKVDataLoader as w
|
|
50
50
|
} from "./QyKVDataLoader.js";
|
|
51
51
|
|
|
52
52
|
import {
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
} from "./QyMod.js";
|
|
55
55
|
|
|
56
56
|
import {
|
|
57
|
-
logger as
|
|
57
|
+
logger as O
|
|
58
58
|
} from "./QyLogger.js";
|
|
59
59
|
|
|
60
60
|
import {
|
|
@@ -63,10 +63,10 @@ import {
|
|
|
63
63
|
|
|
64
64
|
let {
|
|
65
65
|
HiddenFolderName: D,
|
|
66
|
-
IndexDirPath:
|
|
67
|
-
TriggerDirPath:
|
|
66
|
+
IndexDirPath: F,
|
|
67
|
+
TriggerDirPath: b,
|
|
68
68
|
RpcDirPath: E,
|
|
69
|
-
ExpireDirPath:
|
|
69
|
+
ExpireDirPath: y,
|
|
70
70
|
MetaFilePath: t,
|
|
71
71
|
HNSWDirPath: m,
|
|
72
72
|
InfoDirPath: f,
|
|
@@ -88,32 +88,27 @@ class i extends r {
|
|
|
88
88
|
infoRootDir;
|
|
89
89
|
recycleRootDir;
|
|
90
90
|
exclusiveFilePath;
|
|
91
|
+
rpcFunMap = {};
|
|
91
92
|
qyKVData;
|
|
92
93
|
qyFileLogger;
|
|
93
94
|
qyEmbeddings;
|
|
94
|
-
rpcFunMap = {};
|
|
95
95
|
constructor(r, e, t) {
|
|
96
96
|
super(), this.rootFolder = r, e = this.options = {
|
|
97
97
|
...d("QyCache"),
|
|
98
98
|
...e
|
|
99
99
|
}, this.qyDB = t;
|
|
100
|
-
var i, o = this, t = o.rootDir = new l("", !0, void 0, o),
|
|
100
|
+
var i, o = this, t = o.rootDir = new l("", !0, void 0, o), s = new l(D, !0, t);
|
|
101
101
|
t._subdirMap = {
|
|
102
|
-
[D]:
|
|
103
|
-
},
|
|
104
|
-
for ([
|
|
105
|
-
var
|
|
106
|
-
|
|
102
|
+
[D]: s
|
|
103
|
+
}, s._subdirMap = {};
|
|
104
|
+
for ([ a, i ] of [ [ F, "indexRootDir" ], [ y, "expireRootDir" ], [ m, "hnswRootDir" ], [ f, "infoRootDir" ], [ Q, "recycleRootDir" ] ]) {
|
|
105
|
+
var a = a.at(-1), n = new l(a, !0, s);
|
|
106
|
+
s._subdirMap[a] = n, o[i] = n;
|
|
107
107
|
}
|
|
108
108
|
t = v(r, "qykv");
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
exclusiveFilePath: v(r, ".opened"),
|
|
113
|
-
qyKVData: new h(t, e, this),
|
|
114
|
-
qyFileLogger: new g(v(r, "qylog"), e),
|
|
115
|
-
qyEmbeddings: new c(this, e)
|
|
116
|
-
});
|
|
109
|
+
this.kvFolder = t, this.rpcFolder = v(r, "rpc"), this.exclusiveFilePath = v(r, ".opened"),
|
|
110
|
+
this.qyKVData = new h(t, e, this), this.qyFileLogger = new g(v(r, "qylog"), e),
|
|
111
|
+
this.qyEmbeddings = new c(this, e);
|
|
117
112
|
}
|
|
118
113
|
async start() {
|
|
119
114
|
var {
|
|
@@ -122,19 +117,14 @@ class i extends r {
|
|
|
122
117
|
options: t,
|
|
123
118
|
qyKVData: i,
|
|
124
119
|
qyFileLogger: o,
|
|
125
|
-
exclusiveFilePath:
|
|
126
|
-
rootDir:
|
|
120
|
+
exclusiveFilePath: s,
|
|
121
|
+
rootDir: a,
|
|
127
122
|
qyEmbeddings: n
|
|
128
123
|
} = this;
|
|
129
|
-
|
|
124
|
+
O.log("Starting at " + r);
|
|
130
125
|
try {
|
|
131
|
-
await
|
|
132
|
-
var [
|
|
133
|
-
maxChangeId: l,
|
|
134
|
-
loadedMaxAclNum: g,
|
|
135
|
-
qySnapshots: h,
|
|
136
|
-
aclKeyValueMap: d
|
|
137
|
-
} ] = await Promise.all([ ((r, e) => (r = new b(r, e)).load())(e, t), x(a) ]);
|
|
126
|
+
await x(e);
|
|
127
|
+
var [ [ l, g, h, d ] ] = await Promise.all([ ((r, e) => (r = new w(r, e)).load())(e, t), q(s) ]);
|
|
138
128
|
o.start(), i.start(l, g, h, d), await n.start();
|
|
139
129
|
} catch (r) {
|
|
140
130
|
throw o.stop(), n.stop(), r;
|
|
@@ -145,51 +135,42 @@ class i extends r {
|
|
|
145
135
|
fileMap: i
|
|
146
136
|
} = e;
|
|
147
137
|
for (var o of t) r(o);
|
|
148
|
-
}(
|
|
138
|
+
}(a);
|
|
149
139
|
var u = this, e = u.rootDir;
|
|
150
140
|
e.triggerNodes = [ new R() ];
|
|
151
|
-
for (p of (e = u.triggerRootDir = e.searchOrCreateSubdir(
|
|
141
|
+
for (p of (e = u.triggerRootDir = e.searchOrCreateSubdir(b)).fileList) {
|
|
152
142
|
var {
|
|
153
143
|
name: p,
|
|
154
144
|
fileContent: c
|
|
155
|
-
} = p, [ c, D,
|
|
156
|
-
u.insertTriggerToTree(p, c, D,
|
|
145
|
+
} = p, [ c, D, F ] = c;
|
|
146
|
+
u.insertTriggerToTree(p, c, D, F);
|
|
157
147
|
}
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
for (m of
|
|
148
|
+
var y = this;
|
|
149
|
+
y.rpcRootDir = y.rootDir.searchOrCreateSubdir(E);
|
|
150
|
+
for (m of y.rpcRootDir.fileList) {
|
|
161
151
|
var {
|
|
162
152
|
name: m,
|
|
163
153
|
fileContent: f
|
|
164
154
|
} = m;
|
|
165
|
-
C(f) &&
|
|
155
|
+
C(f) && y.insertRpc(m, f);
|
|
166
156
|
}
|
|
167
|
-
return t.dumpStructureAtStart && await
|
|
157
|
+
return t.dumpStructureAtStart && await P(v(r, "qystruct"), a), O.log("Started."),
|
|
168
158
|
this;
|
|
169
159
|
}
|
|
170
160
|
async stop() {
|
|
171
|
-
|
|
161
|
+
O.log("Stopping...");
|
|
172
162
|
var {
|
|
173
163
|
qyKVData: r,
|
|
174
164
|
qyEmbeddings: e,
|
|
175
165
|
qyFileLogger: t,
|
|
176
166
|
exclusiveFilePath: i
|
|
177
167
|
} = this;
|
|
178
|
-
return await r.stop(), await e.stop(),
|
|
179
|
-
o(i),
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
rpcRootDir: void 0,
|
|
185
|
-
hnswRootDir: void 0,
|
|
186
|
-
infoRootDir: void 0,
|
|
187
|
-
recycleRootDir: void 0,
|
|
188
|
-
qyKVData: void 0,
|
|
189
|
-
rpcFunMap: void 0,
|
|
190
|
-
qyDB: void 0,
|
|
191
|
-
qyFileLogger: void 0
|
|
192
|
-
}), P.log("Stopped."), this;
|
|
168
|
+
return await r.stop(), await e.stop(), O.log("QyFileLogger stopped."), await t.stop(),
|
|
169
|
+
o(i), this.rootDir = void 0, this.indexRootDir = void 0, this.expireRootDir = void 0,
|
|
170
|
+
this.triggerRootDir = void 0, this.rpcRootDir = void 0, this.hnswRootDir = void 0,
|
|
171
|
+
this.infoRootDir = void 0, this.recycleRootDir = void 0, this.qyKVData = void 0,
|
|
172
|
+
this.rpcFunMap = void 0, this.qyDB = void 0, this.qyFileLogger = void 0,
|
|
173
|
+
O.log("Stopped."), this;
|
|
193
174
|
}
|
|
194
175
|
increaseChangeId() {
|
|
195
176
|
return this.qyKVData.increaseChangeId();
|
|
@@ -199,10 +180,10 @@ class i extends r {
|
|
|
199
180
|
}
|
|
200
181
|
save(r, e, t, i, o) {
|
|
201
182
|
var {
|
|
202
|
-
qyKVData:
|
|
203
|
-
qyFileLogger:
|
|
183
|
+
qyKVData: s,
|
|
184
|
+
qyFileLogger: a
|
|
204
185
|
} = this;
|
|
205
|
-
return t &&
|
|
186
|
+
return t && a.save(r, t), s.save(r, e, i, o);
|
|
206
187
|
}
|
|
207
188
|
getFile(r, e = this.rootDir) {
|
|
208
189
|
return r.isFile ? r : C(r) ? e.getFile(r) : e.searchFile(r);
|
|
@@ -235,13 +216,13 @@ class i extends r {
|
|
|
235
216
|
return this.expireRootDir.searchOrCreateFile(S(r, e));
|
|
236
217
|
}
|
|
237
218
|
getInfoFile(r) {
|
|
238
|
-
return this.infoRootDir.searchFile(
|
|
219
|
+
return this.infoRootDir.searchFile(s(r.fullPathHash));
|
|
239
220
|
}
|
|
240
221
|
getOrCreateInfoFile(r) {
|
|
241
|
-
return this.infoRootDir.searchOrCreateFile(
|
|
222
|
+
return this.infoRootDir.searchOrCreateFile(s(r.fullPathHash));
|
|
242
223
|
}
|
|
243
224
|
hToSrcFile(r) {
|
|
244
|
-
r = this.infoRootDir.searchFile(
|
|
225
|
+
r = this.infoRootDir.searchFile(s(r));
|
|
245
226
|
if (r && r.fileContent) {
|
|
246
227
|
r = r.fileContent.namePath;
|
|
247
228
|
if (r) return this.getOrCreateFile(r);
|
|
@@ -278,13 +259,13 @@ class i extends r {
|
|
|
278
259
|
insertTriggerToTree(r, e, t, i) {
|
|
279
260
|
var {
|
|
280
261
|
rootDir: o,
|
|
281
|
-
qyDB:
|
|
282
|
-
} = this, i = p("trigger", r, i,
|
|
283
|
-
o.triggerNodes[0].insertTrigger(r, e, t, i),
|
|
262
|
+
qyDB: s
|
|
263
|
+
} = this, i = p("trigger", r, i, s);
|
|
264
|
+
o.triggerNodes[0].insertTrigger(r, e, t, i), a(o, e);
|
|
284
265
|
}
|
|
285
266
|
removeTriggerFromTree(r, e) {
|
|
286
267
|
var t = this.rootDir;
|
|
287
|
-
t.triggerNodes[0].removeTrigger(r, e) &&
|
|
268
|
+
t.triggerNodes[0].removeTrigger(r, e) && a(t, e);
|
|
288
269
|
}
|
|
289
270
|
insertRpc(r, e) {
|
|
290
271
|
var {
|
|
@@ -297,21 +278,21 @@ class i extends r {
|
|
|
297
278
|
delete this.rpcFunMap[r];
|
|
298
279
|
}
|
|
299
280
|
queryFiles(r, e, t, i, o = this.rootDir) {
|
|
300
|
-
var
|
|
301
|
-
return L(r, e,
|
|
281
|
+
var s = [], t = (C(e) && !t && (t = 1), new u(t, i)), i = this.options.queryAutoIndex;
|
|
282
|
+
return L(r, e, s, t, o, i), s;
|
|
302
283
|
}
|
|
303
284
|
queryFilesMulti(r, e, t, i = this.rootDir) {
|
|
304
|
-
var o,
|
|
305
|
-
for ([ o,
|
|
306
|
-
return
|
|
285
|
+
var o, s, a = [], n = new u(e, t), l = this.options.queryAutoIndex;
|
|
286
|
+
for ([ o, s ] of r) L(o, s, a, n, i, l);
|
|
287
|
+
return a;
|
|
307
288
|
}
|
|
308
289
|
async callRpc(e, r, t) {
|
|
309
290
|
var i, o = this.rpcFunMap[e];
|
|
310
|
-
if (!o) return
|
|
291
|
+
if (!o) return O.warn(i = `RPC ${e} not implemented.`), new Error(i);
|
|
311
292
|
try {
|
|
312
293
|
return await o(r, t);
|
|
313
294
|
} catch (r) {
|
|
314
|
-
return
|
|
295
|
+
return O.error(`Calling RPC ${e} failed:`, r), r;
|
|
315
296
|
}
|
|
316
297
|
}
|
|
317
298
|
monitorItemExpire(r, e) {
|
|
@@ -328,7 +309,7 @@ class i extends r {
|
|
|
328
309
|
}
|
|
329
310
|
}
|
|
330
311
|
|
|
331
|
-
function
|
|
312
|
+
function s(r) {
|
|
332
313
|
return [ r.substring(0, 2), r ];
|
|
333
314
|
}
|
|
334
315
|
|
|
@@ -340,8 +321,8 @@ function I(r) {
|
|
|
340
321
|
return [ r[0], r ];
|
|
341
322
|
}
|
|
342
323
|
|
|
343
|
-
function L(r, e, t, i, o,
|
|
344
|
-
void 0 !== e && n(r, o,
|
|
324
|
+
function L(r, e, t, i, o, s) {
|
|
325
|
+
void 0 !== e && n(r, o, s, e, t, i);
|
|
345
326
|
}
|
|
346
327
|
|
|
347
328
|
export {
|
package/src/QyDB.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { QyBatch } from "./QyBatch.ts";
|
|
1
2
|
import { QyCD } from "./QyCD.ts";
|
|
2
3
|
import type { QyDir } from "./QyDir.ts";
|
|
3
4
|
import type { QyFile } from "./QyFile.ts";
|
|
@@ -6,7 +7,7 @@ export declare class QyDB extends QyCD {
|
|
|
6
7
|
options: {};
|
|
7
8
|
fetch: any;
|
|
8
9
|
batch: any;
|
|
9
|
-
_immediate:
|
|
10
|
+
_immediate: QyBatch | undefined;
|
|
10
11
|
creationTime: any;
|
|
11
12
|
constructor(rootFolder?: string, options?: {});
|
|
12
13
|
start(options?: {}): Promise<this>;
|
package/src/QyDB.js
CHANGED
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
} from "./QyBatch.js";
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
|
-
QyCache as
|
|
14
|
+
QyCache as o
|
|
15
15
|
} from "./QyCache.js";
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
|
-
getDefaultOptions as
|
|
18
|
+
getDefaultOptions as a
|
|
19
19
|
} from "./QyDefaultOptions.js";
|
|
20
20
|
|
|
21
21
|
import {
|
|
@@ -25,8 +25,8 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
isNotNullObj as s,
|
|
27
27
|
__dirname as n,
|
|
28
|
-
getNowTime as
|
|
29
|
-
getNowRounded as
|
|
28
|
+
getNowTime as h,
|
|
29
|
+
getNowRounded as c
|
|
30
30
|
} from "./QyUtils.js";
|
|
31
31
|
|
|
32
32
|
import {
|
|
@@ -44,7 +44,7 @@ class l extends t {
|
|
|
44
44
|
creationTime;
|
|
45
45
|
constructor(e = d, t) {
|
|
46
46
|
s(e) && (t = e, e = d), super(), this.options = {
|
|
47
|
-
...
|
|
47
|
+
...a("QyDB"),
|
|
48
48
|
...t
|
|
49
49
|
}, this.rootFolder = e;
|
|
50
50
|
for (let t of [ "createIndex", "createIndexFromQuery", "delContent", "delDir", "delEmbedding", "delFile", "delIndex", "expireContent", "expireContentM", "expireDir", "expireDirM", "expireFile", "expireFileM", "insert", "insertEmbedding", "insertRpc", "insertTrigger", "insertWithEmbedding", "removeContentExpire", "removeDirExpire", "removeFileExpire", "removeRpc", "removeTrigger" ]) this[t] = (...e) => this.currentBatch[t](...e).run();
|
|
@@ -54,13 +54,10 @@ class l extends t {
|
|
|
54
54
|
return void 0 === this.qyCache && (e = {
|
|
55
55
|
...this.options,
|
|
56
56
|
...e
|
|
57
|
-
}, t = new
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
_immediate: new r(t, e)
|
|
62
|
-
}), await t.start(), t).metaFile, e.created ? this.creationTime = e.fileContent.creationTime : this.insert(e, {
|
|
63
|
-
creationTime: this.creationTime = h()
|
|
57
|
+
}, t = this.qyCache = new o(this.rootFolder, e, this), e = (this.fetch = new i(t),
|
|
58
|
+
this.batch = new r(t, e), this._immediate = new r(t, e), await t.start(),
|
|
59
|
+
t).metaFile, e.created ? this.creationTime = e.fileContent.creationTime : this.insert(e, {
|
|
60
|
+
creationTime: this.creationTime = c()
|
|
64
61
|
}, !0), m.log("CreationTime:" + new Date(this.creationTime))), this;
|
|
65
62
|
}
|
|
66
63
|
async stop() {
|
|
@@ -71,15 +68,11 @@ class l extends t {
|
|
|
71
68
|
_immediate: r
|
|
72
69
|
} = this;
|
|
73
70
|
e && (await e.stop(), t && (t.qyCache = void 0), i && (i.qyCache = void 0),
|
|
74
|
-
r && (r.qyCache = void 0),
|
|
75
|
-
|
|
76
|
-
fetch: void 0,
|
|
77
|
-
batch: void 0,
|
|
78
|
-
_immediate: void 0
|
|
79
|
-
}));
|
|
71
|
+
r && (r.qyCache = void 0), this.qyCache = void 0, this.fetch = void 0, this.batch = void 0,
|
|
72
|
+
this._immediate = void 0);
|
|
80
73
|
}
|
|
81
74
|
get age() {
|
|
82
|
-
return
|
|
75
|
+
return h() - this.creationTime;
|
|
83
76
|
}
|
|
84
77
|
get ageSecond() {
|
|
85
78
|
return Math.floor(this.age / 1e3);
|
package/src/QyDir.d.ts
CHANGED
|
@@ -21,6 +21,14 @@ export declare class QyDir extends QyItem {
|
|
|
21
21
|
get fileMapKey(): string;
|
|
22
22
|
get subdirMap(): {};
|
|
23
23
|
get fileMap(): {};
|
|
24
|
+
get subdirMapLoaded(): boolean;
|
|
25
|
+
set subdirMapLoaded(val: boolean);
|
|
26
|
+
get fileMapLoaded(): boolean;
|
|
27
|
+
set fileMapLoaded(val: boolean);
|
|
28
|
+
get dExpireChecked(): boolean;
|
|
29
|
+
set dExpireChecked(val: boolean);
|
|
30
|
+
get fExpireChecked(): boolean;
|
|
31
|
+
set fExpireChecked(val: boolean);
|
|
24
32
|
getSubdir(name: string): QyDir | undefined;
|
|
25
33
|
getFile(fileName: string | number): QyFile | undefined;
|
|
26
34
|
getOrCreateSubdir(name: string, created?: boolean): QyDir;
|
package/src/QyDir.js
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Flag_Created as t,
|
|
3
|
+
Flag_DExpireChecked as i,
|
|
4
|
+
Flag_FExpireChecked as r,
|
|
5
|
+
Flag_FileMapLoaded as s,
|
|
6
|
+
Flag_SubdirMapLoaded as a,
|
|
2
7
|
QyItem as e
|
|
3
8
|
} from "./QyItem.js";
|
|
4
9
|
|
|
5
10
|
import {
|
|
6
|
-
getSubdirMapKey as
|
|
7
|
-
getFileMapKey as
|
|
8
|
-
SpecialFilePaths as
|
|
9
|
-
isString as
|
|
10
|
-
getNowTime as
|
|
11
|
+
getSubdirMapKey as d,
|
|
12
|
+
getFileMapKey as l,
|
|
13
|
+
SpecialFilePaths as u,
|
|
14
|
+
isString as n,
|
|
15
|
+
getNowTime as h
|
|
11
16
|
} from "./QyUtils.js";
|
|
12
17
|
|
|
13
18
|
import {
|
|
14
|
-
QyFile as
|
|
19
|
+
QyFile as o
|
|
15
20
|
} from "./QyFile.js";
|
|
16
21
|
|
|
17
22
|
import {
|
|
18
|
-
handleExpiredItem as
|
|
23
|
+
handleExpiredItem as f
|
|
19
24
|
} from "./QyExpire.js";
|
|
20
25
|
|
|
21
|
-
let
|
|
26
|
+
let g = u.HiddenFolderName;
|
|
22
27
|
|
|
23
|
-
class
|
|
28
|
+
class C extends e {
|
|
24
29
|
_subdirCount = 0;
|
|
25
30
|
_fileCount = 0;
|
|
26
31
|
subdirMapChangeCount = 0;
|
|
@@ -29,21 +34,21 @@ class d extends e {
|
|
|
29
34
|
fChangeId = 0;
|
|
30
35
|
valueCache = {};
|
|
31
36
|
constructor(e, i = !1, t = void 0, r = void 0) {
|
|
32
|
-
super(e,
|
|
37
|
+
super(e, t), this.created = i, r && (this._qyCache = r);
|
|
33
38
|
}
|
|
34
39
|
get created() {
|
|
35
|
-
return this.
|
|
40
|
+
return 0 != (this.flagInt & t);
|
|
36
41
|
}
|
|
37
42
|
set created(e) {
|
|
38
43
|
var i;
|
|
39
|
-
this.
|
|
40
|
-
++i.subdirMapChangeCount);
|
|
44
|
+
this.created !== e && (e ? this.flagInt |= t : this.flagInt &= ~t, i = this.parentDir,
|
|
45
|
+
void 0 !== i) && (i._subdirCount += e ? 1 : -1, ++i.subdirMapChangeCount);
|
|
41
46
|
}
|
|
42
47
|
get fileCount() {
|
|
43
|
-
return
|
|
48
|
+
return b(this), this._fileCount;
|
|
44
49
|
}
|
|
45
50
|
get subdirCount() {
|
|
46
|
-
return
|
|
51
|
+
return p(this), this._subdirCount;
|
|
47
52
|
}
|
|
48
53
|
get isDir() {
|
|
49
54
|
return !0;
|
|
@@ -52,19 +57,43 @@ class d extends e {
|
|
|
52
57
|
return 0 === this.fileCount && 0 === this.subdirCount;
|
|
53
58
|
}
|
|
54
59
|
get isHiddenFolder() {
|
|
55
|
-
return this.name ===
|
|
60
|
+
return this.name === g;
|
|
56
61
|
}
|
|
57
62
|
get subdirMapKey() {
|
|
58
|
-
return this._subdirMapKey || (this._subdirMapKey =
|
|
63
|
+
return this._subdirMapKey || (this._subdirMapKey = d(this.fullPathHash));
|
|
59
64
|
}
|
|
60
65
|
get fileMapKey() {
|
|
61
|
-
return this._fileMapKey || (this._fileMapKey =
|
|
66
|
+
return this._fileMapKey || (this._fileMapKey = l(this.fullPathHash));
|
|
62
67
|
}
|
|
63
68
|
get subdirMap() {
|
|
64
|
-
return
|
|
69
|
+
return p(this), this._subdirMap;
|
|
65
70
|
}
|
|
66
71
|
get fileMap() {
|
|
67
|
-
return
|
|
72
|
+
return b(this), this._fileMap;
|
|
73
|
+
}
|
|
74
|
+
get subdirMapLoaded() {
|
|
75
|
+
return 0 != (this.flagInt & a);
|
|
76
|
+
}
|
|
77
|
+
set subdirMapLoaded(e) {
|
|
78
|
+
e ? this.flagInt |= a : this.flagInt &= ~a;
|
|
79
|
+
}
|
|
80
|
+
get fileMapLoaded() {
|
|
81
|
+
return 0 != (this.flagInt & s);
|
|
82
|
+
}
|
|
83
|
+
set fileMapLoaded(e) {
|
|
84
|
+
e ? this.flagInt |= s : this.flagInt &= ~s;
|
|
85
|
+
}
|
|
86
|
+
get dExpireChecked() {
|
|
87
|
+
return 0 != (this.flagInt & i);
|
|
88
|
+
}
|
|
89
|
+
set dExpireChecked(e) {
|
|
90
|
+
e ? this.flagInt |= i : this.flagInt &= ~i;
|
|
91
|
+
}
|
|
92
|
+
get fExpireChecked() {
|
|
93
|
+
return 0 != (this.flagInt & r);
|
|
94
|
+
}
|
|
95
|
+
set fExpireChecked(e) {
|
|
96
|
+
e ? this.flagInt |= r : this.flagInt &= ~r;
|
|
68
97
|
}
|
|
69
98
|
getSubdir(e) {
|
|
70
99
|
var i;
|
|
@@ -84,13 +113,13 @@ class d extends e {
|
|
|
84
113
|
if ("/" === e) return this.qyCache?.rootDir || this;
|
|
85
114
|
let t = this.subdirMap;
|
|
86
115
|
var r = (t = void 0 === t ? this._subdirMap = {} : t)[e];
|
|
87
|
-
return r || (r = t[e] = new
|
|
116
|
+
return r || (r = t[e] = new C(e, i, this), this.setChildTriggerNodes(r)),
|
|
88
117
|
r;
|
|
89
118
|
}
|
|
90
119
|
getOrCreateFile(e, i = !1) {
|
|
91
120
|
let t = this.fileMap;
|
|
92
121
|
var r = (t = void 0 === t ? this._fileMap = {} : t)[e];
|
|
93
|
-
return r || (r = t[e] = new
|
|
122
|
+
return r || (r = t[e] = new o(e, i, this), this.setChildTriggerNodes(r)),
|
|
94
123
|
r;
|
|
95
124
|
}
|
|
96
125
|
searchSubdir(i, t = i.length) {
|
|
@@ -252,10 +281,10 @@ class d extends e {
|
|
|
252
281
|
let s = !1;
|
|
253
282
|
var a = r.length;
|
|
254
283
|
for (let e = t ? a - 1 : 0; t ? 0 <= e : e < a; t ? --e : ++e) {
|
|
255
|
-
var d = r[e],
|
|
256
|
-
if (l
|
|
284
|
+
var d = r[e], l = d.nameNum;
|
|
285
|
+
if (n(l)) {
|
|
257
286
|
if (s) return;
|
|
258
|
-
} else if (i(
|
|
287
|
+
} else if (i(l)) yield d, s = !0; else if (s) return;
|
|
259
288
|
}
|
|
260
289
|
}
|
|
261
290
|
ensureAllLoaded() {
|
|
@@ -264,7 +293,7 @@ class d extends e {
|
|
|
264
293
|
}
|
|
265
294
|
}
|
|
266
295
|
|
|
267
|
-
function
|
|
296
|
+
function p(e) {
|
|
268
297
|
if (e.created && !e.subdirMapLoaded) {
|
|
269
298
|
e.subdirMapLoaded = !0;
|
|
270
299
|
var i = e.qyCache;
|
|
@@ -272,14 +301,14 @@ function u(e) {
|
|
|
272
301
|
var t = i.qyKVData.getValueSync(e.subdirMapKey);
|
|
273
302
|
if (t) {
|
|
274
303
|
var r, s = e._subdirMap || (e._subdirMap = {});
|
|
275
|
-
for (r in t) r in s || (s[r] = new
|
|
276
|
-
e.underHiddenFolder ||
|
|
304
|
+
for (r in t) r in s || (s[r] = new C(r, !0, e));
|
|
305
|
+
e.underHiddenFolder || v(e, i, "d");
|
|
277
306
|
}
|
|
278
307
|
}
|
|
279
308
|
}
|
|
280
309
|
}
|
|
281
310
|
|
|
282
|
-
function
|
|
311
|
+
function b(e) {
|
|
283
312
|
if (e.created && !e._fileMap && !e.fileMapLoaded) {
|
|
284
313
|
e.fileMapLoaded = !0;
|
|
285
314
|
var i = e.qyCache;
|
|
@@ -287,14 +316,14 @@ function n(e) {
|
|
|
287
316
|
var t = i.qyKVData.getValueSync(e.fileMapKey);
|
|
288
317
|
if (t) {
|
|
289
318
|
var r, s = e._fileMap = {};
|
|
290
|
-
for (r in t) s[r] = new
|
|
291
|
-
e.underHiddenFolder ||
|
|
319
|
+
for (r in t) s[r] = new o(r, !0, e);
|
|
320
|
+
e.underHiddenFolder || v(e, i, "f");
|
|
292
321
|
}
|
|
293
322
|
}
|
|
294
323
|
}
|
|
295
324
|
}
|
|
296
325
|
|
|
297
|
-
function
|
|
326
|
+
function v(e, i, t) {
|
|
298
327
|
if ("d" === t) {
|
|
299
328
|
if (e.dExpireChecked) return;
|
|
300
329
|
e.dExpireChecked = !0;
|
|
@@ -304,14 +333,14 @@ function f(e, i, t) {
|
|
|
304
333
|
}
|
|
305
334
|
var r = i.getExpireInfoFile(e.fullPathHash, t);
|
|
306
335
|
if (void 0 !== r) {
|
|
307
|
-
var s, a = r.fileContent, d =
|
|
336
|
+
var s, a = r.fileContent, d = h(), l = i.qyDB;
|
|
308
337
|
for (s in a) {
|
|
309
|
-
var
|
|
310
|
-
n <= d ?
|
|
338
|
+
var u = "d" === t ? e.getOrCreateSubdir(s) : e.getOrCreateFile(s), n = a[s];
|
|
339
|
+
n <= d ? f(l, u) : i.monitorItemExpire(u, n);
|
|
311
340
|
}
|
|
312
341
|
}
|
|
313
342
|
}
|
|
314
343
|
|
|
315
344
|
export {
|
|
316
|
-
|
|
345
|
+
C as QyDir
|
|
317
346
|
};
|
package/src/QyEmbeddings.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import type { QyCache } from "./QyCache.ts";
|
|
2
|
+
import type { QyDB } from "./QyDB.ts";
|
|
1
3
|
export declare class QyEmbeddings {
|
|
2
|
-
qyCache: any;
|
|
3
4
|
embeddingFolder: any;
|
|
4
5
|
options: any;
|
|
5
|
-
qyDB: any;
|
|
6
6
|
qyEmbeddingWriters: any;
|
|
7
7
|
hashToEmbeddingMap: {};
|
|
8
|
-
|
|
8
|
+
qyCache: QyCache;
|
|
9
|
+
qyDB: QyDB;
|
|
10
|
+
constructor(qyCache: QyCache, options?: any);
|
|
9
11
|
start(): Promise<void>;
|
|
10
12
|
stop(): Promise<void>;
|
|
11
13
|
addEmbedding(fullPathHash: any, embedding: any): any;
|