datafolder 1.0.16 → 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 +9 -0
- package/data/northwind.json +31945 -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 +1 -2
- package/src/QyFileContentUtils.js +126 -129
- 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/test/testQyNorthwind.js +206 -0
package/src/QyCD.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ export declare class QyCD {
|
|
|
13
13
|
indexDirP(indexHostDirNamePath: string | string[] | QyDir, namePath: string | string[], parentDir?: any): QyDir | undefined;
|
|
14
14
|
file(namePath: string | string[], parentDir?: any): QyFile | undefined;
|
|
15
15
|
fileP(namePath: string | string[], parentDir?: any): QyFile | undefined;
|
|
16
|
+
fileContent(namePath: string | string[], parentDir?: any): any;
|
|
17
|
+
embeddingFile(namePath: string | string[], parentDir?: any): any;
|
|
18
|
+
embedding(namePath: string | string[], parentDir?: any): any;
|
|
16
19
|
triggerFile(triggerName: any): any;
|
|
17
20
|
get triggerFileList(): any;
|
|
18
21
|
rpcFile(rpcName: any): any;
|
package/src/QyCD.js
CHANGED
|
@@ -1,107 +1,118 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isString as t,
|
|
3
|
-
pathSplit as
|
|
3
|
+
pathSplit as n
|
|
4
4
|
} from "./QyUtils.js";
|
|
5
5
|
|
|
6
|
-
class
|
|
6
|
+
class e {
|
|
7
7
|
qyCache;
|
|
8
8
|
currentDir;
|
|
9
|
-
constructor(
|
|
10
|
-
this.qyCache =
|
|
9
|
+
constructor(e) {
|
|
10
|
+
this.qyCache = e;
|
|
11
11
|
}
|
|
12
|
-
cd(
|
|
13
|
-
return t(
|
|
12
|
+
cd(e, r = this.currentDir) {
|
|
13
|
+
return t(e) && (e = n(e)), this.cdP(e, r);
|
|
14
14
|
}
|
|
15
|
-
cdP(
|
|
16
|
-
return this.currentDir = this.qyCache
|
|
15
|
+
cdP(e, r = this.currentDir) {
|
|
16
|
+
return this.currentDir = this.qyCache.getOrCreateDir(e, r), this;
|
|
17
17
|
}
|
|
18
|
-
dir(
|
|
19
|
-
return t(
|
|
18
|
+
dir(e, r = this.currentDir) {
|
|
19
|
+
return t(e) && (e = n(e)), this.dirP(e, r);
|
|
20
20
|
}
|
|
21
|
-
dirP(
|
|
22
|
-
return this.qyCache
|
|
21
|
+
dirP(e, r = this.currentDir) {
|
|
22
|
+
return this.qyCache.getDir(e, r);
|
|
23
23
|
}
|
|
24
|
-
indexDir(
|
|
25
|
-
return t(
|
|
24
|
+
indexDir(e, r, i = this.currentDir) {
|
|
25
|
+
return t(e) && (e = n(e)), t(r) && (r = n(r)), this.indexDirP(e, r, i);
|
|
26
26
|
}
|
|
27
|
-
indexDirP(
|
|
28
|
-
var t = this.qyCache,
|
|
29
|
-
if (
|
|
30
|
-
i = t
|
|
31
|
-
if (i) return
|
|
27
|
+
indexDirP(e, r, i = this.currentDir) {
|
|
28
|
+
var t = this.qyCache, e = t.getDir(e, i);
|
|
29
|
+
if (e) {
|
|
30
|
+
i = t.getIndexDir(e);
|
|
31
|
+
if (i) return r && 0 != r.length ? t.getDir(r, i) : i;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
file(
|
|
35
|
-
return t(
|
|
34
|
+
file(e, r = this.currentDir) {
|
|
35
|
+
return t(e) && (e = n(e)), this.fileP(e, r);
|
|
36
36
|
}
|
|
37
|
-
fileP(
|
|
38
|
-
return this.qyCache
|
|
37
|
+
fileP(e, r = this.currentDir) {
|
|
38
|
+
return this.qyCache.getFile(e, r);
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
return this.
|
|
40
|
+
fileContent(e, r = this.currentDir) {
|
|
41
|
+
return this.file(e, r)?.fileContent;
|
|
42
|
+
}
|
|
43
|
+
embeddingFile(e, r = this.currentDir) {
|
|
44
|
+
t(e) && (e = n(e));
|
|
45
|
+
var i = this.qyCache;
|
|
46
|
+
return i.getEmbeddingFile(i.getOrCreateFile(e, r).fullPathHash);
|
|
47
|
+
}
|
|
48
|
+
embedding(e, r = this.currentDir) {
|
|
49
|
+
return this.embeddingFile(e, r)?.fileContent;
|
|
50
|
+
}
|
|
51
|
+
triggerFile(e) {
|
|
52
|
+
return this.qyCache.getTriggerFile(e);
|
|
42
53
|
}
|
|
43
54
|
get triggerFileList() {
|
|
44
55
|
return this.qyCache.triggerFileList;
|
|
45
56
|
}
|
|
46
|
-
rpcFile(
|
|
47
|
-
return this.qyCache.getRpcFile(
|
|
57
|
+
rpcFile(e) {
|
|
58
|
+
return this.qyCache.getRpcFile(e);
|
|
48
59
|
}
|
|
49
60
|
get rpcFileList() {
|
|
50
61
|
return this.qyCache.rpcFileList;
|
|
51
62
|
}
|
|
52
|
-
view(
|
|
53
|
-
return t(
|
|
63
|
+
view(e, r = void 0, i = this.currentDir) {
|
|
64
|
+
return t(e) && (e = n(e)), this.viewP(e, r, i);
|
|
54
65
|
}
|
|
55
|
-
viewP(
|
|
56
|
-
return this.qyCache.getFile(
|
|
66
|
+
viewP(e, r, i = this.currentDir) {
|
|
67
|
+
return this.qyCache.getFile(e, i)?.view(r);
|
|
57
68
|
}
|
|
58
|
-
queryFiles(
|
|
59
|
-
return this.qyCache.queryFiles(
|
|
69
|
+
queryFiles(e, r, i = void 0, t = void 0, n = this.currentDir) {
|
|
70
|
+
return this.qyCache.queryFiles(e, r, i, t, n);
|
|
60
71
|
}
|
|
61
|
-
queryFilesMulti(
|
|
62
|
-
return this.qyCache.queryFilesMulti(
|
|
72
|
+
queryFilesMulti(e, r, i, t = this.currentDir) {
|
|
73
|
+
return this.qyCache.queryFilesMulti(e, r, i, t);
|
|
63
74
|
}
|
|
64
|
-
queryTree(
|
|
65
|
-
return
|
|
75
|
+
queryTree(e, r, i, t, n, s = this.currentDir) {
|
|
76
|
+
return h(this.qyCache.queryFiles(e, r, t, n, s), i);
|
|
66
77
|
}
|
|
67
|
-
queryTreeMulti(
|
|
68
|
-
return
|
|
78
|
+
queryTreeMulti(e, r, i, t, n = this.currentDir) {
|
|
79
|
+
return h(this.qyCache.queryFilesMulti(e, i, t, n), r);
|
|
69
80
|
}
|
|
70
81
|
resetCurrentDir() {
|
|
71
82
|
this.currentDir = void 0;
|
|
72
83
|
}
|
|
73
|
-
fileListToTree(
|
|
74
|
-
return
|
|
84
|
+
fileListToTree(e, r) {
|
|
85
|
+
return h(e, r);
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
|
|
78
|
-
function
|
|
79
|
-
var t,
|
|
80
|
-
for (t of
|
|
81
|
-
var
|
|
82
|
-
let
|
|
83
|
-
for (
|
|
89
|
+
function h(e, i) {
|
|
90
|
+
var t, n = {};
|
|
91
|
+
for (t of e) {
|
|
92
|
+
var s, h = t.parentList;
|
|
93
|
+
let r = n;
|
|
94
|
+
for (s of h) {
|
|
84
95
|
var {
|
|
85
96
|
name: u,
|
|
86
|
-
fullPathHash:
|
|
87
|
-
} =
|
|
88
|
-
let
|
|
89
|
-
|
|
90
|
-
fullPathHash:
|
|
97
|
+
fullPathHash: l
|
|
98
|
+
} = s;
|
|
99
|
+
let e = r.subdirMap;
|
|
100
|
+
e = e || (r.subdirMap = {}), r = (r = e[u]) || (e[u] = {
|
|
101
|
+
fullPathHash: l
|
|
91
102
|
});
|
|
92
103
|
}
|
|
93
|
-
let
|
|
94
|
-
(
|
|
104
|
+
let e = r.fileMap;
|
|
105
|
+
(e = e || (r.fileMap = {}))[t.name] = {
|
|
95
106
|
fileContent: t.view(i, !0),
|
|
96
107
|
fileContentKey: t.fileContentKey
|
|
97
108
|
};
|
|
98
109
|
}
|
|
99
110
|
return {
|
|
100
|
-
tree:
|
|
101
|
-
count:
|
|
111
|
+
tree: n,
|
|
112
|
+
count: e.length
|
|
102
113
|
};
|
|
103
114
|
}
|
|
104
115
|
|
|
105
116
|
export {
|
|
106
|
-
|
|
117
|
+
e as QyCD
|
|
107
118
|
};
|
package/src/QyCache.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare class QyCache extends EventEmitter {
|
|
|
12
12
|
rpcRootDir: any;
|
|
13
13
|
indexRootDir: any;
|
|
14
14
|
expireRootDir: any;
|
|
15
|
+
embeddingRootDir: any;
|
|
16
|
+
h2FRootDir: any;
|
|
15
17
|
exclusiveFilePath: any;
|
|
16
18
|
qyKVData: any;
|
|
17
19
|
qyFileLogger: any;
|
|
@@ -32,6 +34,12 @@ export declare class QyCache extends EventEmitter {
|
|
|
32
34
|
getOrCreateTriggerFile(triggerName: any): any;
|
|
33
35
|
getExpireInfoFile(fullPathHash: any, type?: string): any;
|
|
34
36
|
getOrCreateExpireInfoFile(fullPathHash: any, type?: string): any;
|
|
37
|
+
getH2FFile(fullPathHash: any): any;
|
|
38
|
+
getOrCreateH2FFile(fullPathHash: any): any;
|
|
39
|
+
h2F(fullPathHash: any): QyFile | undefined;
|
|
40
|
+
getEmbeddingFile(fullPathHash: any): any;
|
|
41
|
+
getOrCreateEmbeddingFile(fullPathHash: any): any;
|
|
42
|
+
getEmbedding(fullPathHash: any): any;
|
|
35
43
|
get triggerFileList(): any;
|
|
36
44
|
getRpcFile(rpcFunName: any): any;
|
|
37
45
|
getOrCreateRpcFile(rpcFunName: any): any;
|
package/src/QyCache.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import {
|
|
2
|
-
join as
|
|
2
|
+
join as f
|
|
3
3
|
} from "node:path";
|
|
4
4
|
|
|
5
5
|
import r from "node:events";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
QyDir as
|
|
8
|
+
QyDir as D
|
|
9
9
|
} from "./QyDir.js";
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
|
-
QyFileLogger as
|
|
12
|
+
QyFileLogger as c
|
|
13
13
|
} from "./QyFileLogger.js";
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
|
-
QyKVData as
|
|
16
|
+
QyKVData as F
|
|
17
17
|
} from "./QyKVData.js";
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
|
-
QyTriggerNode as
|
|
20
|
+
QyTriggerNode as v,
|
|
21
21
|
updateTriggerNodes as s
|
|
22
22
|
} from "./QyTrigger.js";
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
isString as
|
|
26
|
-
lockExclusiveFilePath as
|
|
25
|
+
isString as C,
|
|
26
|
+
lockExclusiveFilePath as R,
|
|
27
27
|
unlockExclusiveFilePath as i
|
|
28
28
|
} from "./QyUtils.js";
|
|
29
29
|
|
|
30
30
|
import {
|
|
31
|
-
dumpStructure as
|
|
31
|
+
dumpStructure as x
|
|
32
32
|
} from "./QyStructure.js";
|
|
33
33
|
|
|
34
34
|
import {
|
|
@@ -37,11 +37,11 @@ import {
|
|
|
37
37
|
} from "./QyIndex.js";
|
|
38
38
|
|
|
39
39
|
import {
|
|
40
|
-
getDefaultOptions as
|
|
40
|
+
getDefaultOptions as m
|
|
41
41
|
} from "./QyDefaultOptions.js";
|
|
42
42
|
|
|
43
43
|
import {
|
|
44
|
-
ensureDir as
|
|
44
|
+
ensureDir as q,
|
|
45
45
|
SpecialFilePaths as e
|
|
46
46
|
} from "./QyUtils.js";
|
|
47
47
|
|
|
@@ -50,24 +50,26 @@ import {
|
|
|
50
50
|
} from "./QyUnionNode.js";
|
|
51
51
|
|
|
52
52
|
import {
|
|
53
|
-
QyKVDataLoader as
|
|
53
|
+
QyKVDataLoader as b
|
|
54
54
|
} from "./QyKVDataLoader.js";
|
|
55
55
|
|
|
56
56
|
import {
|
|
57
|
-
requireFromModCode as
|
|
57
|
+
requireFromModCode as d
|
|
58
58
|
} from "./QyMod.js";
|
|
59
59
|
|
|
60
60
|
import {
|
|
61
|
-
logger as
|
|
61
|
+
logger as O
|
|
62
62
|
} from "./QyLogger.js";
|
|
63
63
|
|
|
64
64
|
let {
|
|
65
|
-
HiddenFolderName:
|
|
66
|
-
IndexDirPath:
|
|
67
|
-
TriggerDirPath:
|
|
68
|
-
RpcDirPath:
|
|
69
|
-
ExpireDirPath:
|
|
70
|
-
MetaFilePath: t
|
|
65
|
+
HiddenFolderName: y,
|
|
66
|
+
IndexDirPath: P,
|
|
67
|
+
TriggerDirPath: Q,
|
|
68
|
+
RpcDirPath: w,
|
|
69
|
+
ExpireDirPath: S,
|
|
70
|
+
MetaFilePath: t,
|
|
71
|
+
EmbeddingDirPath: L,
|
|
72
|
+
H2FDirPath: E
|
|
71
73
|
} = e;
|
|
72
74
|
|
|
73
75
|
class o extends r {
|
|
@@ -81,35 +83,42 @@ class o extends r {
|
|
|
81
83
|
rpcRootDir;
|
|
82
84
|
indexRootDir;
|
|
83
85
|
expireRootDir;
|
|
86
|
+
embeddingRootDir;
|
|
87
|
+
h2FRootDir;
|
|
84
88
|
exclusiveFilePath;
|
|
85
89
|
qyKVData;
|
|
86
90
|
qyFileLogger;
|
|
87
91
|
rpcFunMap = {};
|
|
88
92
|
constructor(r, e, t) {
|
|
89
93
|
super(), e = {
|
|
90
|
-
...
|
|
94
|
+
...m("QyCache"),
|
|
91
95
|
...e
|
|
92
|
-
}, o = new
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
[
|
|
96
|
+
}, o = new D("", !0, void 0, i = this), a = S.at(-1), s = P.at(-1), n = L.at(-1),
|
|
97
|
+
g = E.at(-1), p = new D(y, !0, o), l = new D(a, !0, p), d = new D(s, !0, p),
|
|
98
|
+
h = new D(n, !0, p), u = new D(g, !0, p), o._subdirMap = {
|
|
99
|
+
[y]: p
|
|
100
|
+
}, p._subdirMap = {
|
|
101
|
+
[a]: l,
|
|
102
|
+
[s]: d,
|
|
103
|
+
[n]: h,
|
|
104
|
+
[g]: u
|
|
98
105
|
}, Object.assign(i, {
|
|
99
106
|
rootDir: o,
|
|
100
|
-
expireRootDir:
|
|
101
|
-
indexRootDir:
|
|
107
|
+
expireRootDir: l,
|
|
108
|
+
indexRootDir: d,
|
|
109
|
+
embeddingRootDir: h,
|
|
110
|
+
h2FRootDir: u
|
|
102
111
|
});
|
|
103
|
-
var i, o, a, s, n, g, l =
|
|
112
|
+
var i, o, a, s, n, g, l, d, h, u, p = f(r, "qykv");
|
|
104
113
|
Object.assign(this, {
|
|
105
114
|
rootFolder: r,
|
|
106
115
|
options: e,
|
|
107
116
|
qyDB: t,
|
|
108
|
-
kvFolder:
|
|
109
|
-
rpcFolder:
|
|
110
|
-
exclusiveFilePath:
|
|
111
|
-
qyKVData: new
|
|
112
|
-
qyFileLogger: new
|
|
117
|
+
kvFolder: p,
|
|
118
|
+
rpcFolder: f(r, "rpc"),
|
|
119
|
+
exclusiveFilePath: f(r, ".opened"),
|
|
120
|
+
qyKVData: new F(p, e, this),
|
|
121
|
+
qyFileLogger: new c(f(r, "qylog"), e)
|
|
113
122
|
});
|
|
114
123
|
}
|
|
115
124
|
async start() {
|
|
@@ -122,16 +131,16 @@ class o extends r {
|
|
|
122
131
|
exclusiveFilePath: a,
|
|
123
132
|
rootDir: s
|
|
124
133
|
} = this;
|
|
125
|
-
|
|
134
|
+
O.log(`Starting at ${r}...`);
|
|
126
135
|
try {
|
|
127
|
-
await
|
|
136
|
+
await q(e), o.start();
|
|
128
137
|
var [ {
|
|
129
138
|
maxChangeId: n,
|
|
130
139
|
loadedMaxAclNum: g,
|
|
131
140
|
qySnapshots: l,
|
|
132
|
-
aclKeyValueMap:
|
|
133
|
-
} ] = await Promise.all([ ((r, e) => (r = new
|
|
134
|
-
i.start(n, g, l,
|
|
141
|
+
aclKeyValueMap: d
|
|
142
|
+
} ] = await Promise.all([ ((r, e) => (r = new b(r, e)).load())(e, t), R(a) ]);
|
|
143
|
+
i.start(n, g, l, d);
|
|
135
144
|
} catch (r) {
|
|
136
145
|
throw o.stop(), r;
|
|
137
146
|
}
|
|
@@ -142,46 +151,48 @@ class o extends r {
|
|
|
142
151
|
} = e;
|
|
143
152
|
for (var o of t) r(o);
|
|
144
153
|
}(s);
|
|
145
|
-
var
|
|
146
|
-
e.triggerNodes = [ new
|
|
147
|
-
for (
|
|
154
|
+
var h = this, e = h.rootDir;
|
|
155
|
+
e.triggerNodes = [ new v() ];
|
|
156
|
+
for (u of (e = h.triggerRootDir = e.searchOrCreateSubdir(Q)).fileList) {
|
|
148
157
|
var {
|
|
149
|
-
name:
|
|
150
|
-
fileContent:
|
|
151
|
-
} =
|
|
152
|
-
|
|
158
|
+
name: u,
|
|
159
|
+
fileContent: p
|
|
160
|
+
} = u, [ p, D, c ] = p;
|
|
161
|
+
h.insertTriggerToTree(u, p, D, c);
|
|
153
162
|
}
|
|
154
163
|
var F = this;
|
|
155
|
-
F.rpcRootDir = F.rootDir.searchOrCreateSubdir(
|
|
164
|
+
F.rpcRootDir = F.rootDir.searchOrCreateSubdir(w);
|
|
156
165
|
for (m of F.rpcRootDir.fileList) {
|
|
157
166
|
var {
|
|
158
167
|
name: m,
|
|
159
168
|
fileContent: y
|
|
160
169
|
} = m;
|
|
161
|
-
|
|
170
|
+
C(y) && F.insertRpc(m, y);
|
|
162
171
|
}
|
|
163
|
-
return t.dumpStructureAtStart && await
|
|
172
|
+
return t.dumpStructureAtStart && await x(f(r, "qystruct"), s), O.log("Started."),
|
|
164
173
|
this;
|
|
165
174
|
}
|
|
166
175
|
async stop() {
|
|
167
|
-
|
|
176
|
+
O.log("Stopping...");
|
|
168
177
|
var {
|
|
169
178
|
qyKVData: r,
|
|
170
179
|
qyFileLogger: e,
|
|
171
180
|
exclusiveFilePath: t
|
|
172
181
|
} = this;
|
|
173
|
-
return await r.stop(),
|
|
182
|
+
return await r.stop(), O.log("QyFileLogger stopped."), await e.stop(), i(t),
|
|
174
183
|
Object.assign(this, {
|
|
175
184
|
rootDir: void 0,
|
|
176
185
|
indexRootDir: void 0,
|
|
177
186
|
expireRootDir: void 0,
|
|
178
187
|
triggerRootDir: void 0,
|
|
179
188
|
rpcRootDir: void 0,
|
|
189
|
+
embeddingRootDir: void 0,
|
|
190
|
+
h2FRootDir: void 0,
|
|
180
191
|
qyKVData: void 0,
|
|
181
192
|
rpcFunMap: void 0,
|
|
182
193
|
qyDB: void 0,
|
|
183
194
|
qyFileLogger: void 0
|
|
184
|
-
}),
|
|
195
|
+
}), O.log("Stopped."), this;
|
|
185
196
|
}
|
|
186
197
|
increaseChangeId() {
|
|
187
198
|
return this.qyKVData.increaseChangeId();
|
|
@@ -197,22 +208,22 @@ class o extends r {
|
|
|
197
208
|
return t && s.save(r, t), a.save(r, e, i, o);
|
|
198
209
|
}
|
|
199
210
|
getFile(r, e = this.rootDir) {
|
|
200
|
-
return r.isFile ? r :
|
|
211
|
+
return r.isFile ? r : C(r) ? e.getFile(r) : e.searchFile(r);
|
|
201
212
|
}
|
|
202
213
|
getDir(r, e = this.rootDir) {
|
|
203
|
-
return r.isDir ? r :
|
|
214
|
+
return r.isDir ? r : C(r) ? e.getSubdir(r) : e.searchSubdir(r);
|
|
204
215
|
}
|
|
205
216
|
getOrCreateFile(r, e = this.rootDir) {
|
|
206
|
-
return r.isFile ? r :
|
|
217
|
+
return r.isFile ? r : C(r) ? e.getOrCreateFile(r) : e.searchOrCreateFile(r);
|
|
207
218
|
}
|
|
208
219
|
getOrCreateDir(r, e = this.rootDir) {
|
|
209
|
-
return r.isDir ? r :
|
|
220
|
+
return r.isDir ? r : C(r) ? e.getOrCreateSubdir(r) : e.searchOrCreateSubdir(r);
|
|
210
221
|
}
|
|
211
222
|
getIndexDir(r) {
|
|
212
|
-
return this.indexRootDir.searchSubdir(
|
|
223
|
+
return this.indexRootDir.searchSubdir(p(r.fullPathHash));
|
|
213
224
|
}
|
|
214
225
|
getOrCreateIndexDir(r) {
|
|
215
|
-
return this.indexRootDir.searchOrCreateSubdir(
|
|
226
|
+
return this.indexRootDir.searchOrCreateSubdir(p(r.fullPathHash));
|
|
216
227
|
}
|
|
217
228
|
getTriggerFile(r) {
|
|
218
229
|
return this.triggerRootDir.getFile(r);
|
|
@@ -221,10 +232,29 @@ class o extends r {
|
|
|
221
232
|
return this.triggerRootDir.getOrCreateFile(r);
|
|
222
233
|
}
|
|
223
234
|
getExpireInfoFile(r, e = "c") {
|
|
224
|
-
return this.expireRootDir.searchFile(
|
|
235
|
+
return this.expireRootDir.searchFile(u(r, e));
|
|
225
236
|
}
|
|
226
237
|
getOrCreateExpireInfoFile(r, e = "c") {
|
|
227
|
-
return this.expireRootDir.searchOrCreateFile(
|
|
238
|
+
return this.expireRootDir.searchOrCreateFile(u(r, e));
|
|
239
|
+
}
|
|
240
|
+
getH2FFile(r) {
|
|
241
|
+
return this.h2FRootDir.searchFile(a(r));
|
|
242
|
+
}
|
|
243
|
+
getOrCreateH2FFile(r) {
|
|
244
|
+
return this.h2FRootDir.searchOrCreateFile(a(r));
|
|
245
|
+
}
|
|
246
|
+
h2F(r) {
|
|
247
|
+
r = this.getH2FFile(r);
|
|
248
|
+
if (r) return this.getOrCreateFile(r.fileContent);
|
|
249
|
+
}
|
|
250
|
+
getEmbeddingFile(r) {
|
|
251
|
+
return this.embeddingRootDir.searchFile(h(r));
|
|
252
|
+
}
|
|
253
|
+
getOrCreateEmbeddingFile(r) {
|
|
254
|
+
return this.embeddingRootDir.searchOrCreateFile(h(r));
|
|
255
|
+
}
|
|
256
|
+
getEmbedding(r) {
|
|
257
|
+
return this.embeddingRootDir.searchFile(h(r))?.fileContent;
|
|
228
258
|
}
|
|
229
259
|
get triggerFileList() {
|
|
230
260
|
return this.triggerRootDir.fileList;
|
|
@@ -245,7 +275,7 @@ class o extends r {
|
|
|
245
275
|
var {
|
|
246
276
|
rootDir: o,
|
|
247
277
|
qyDB: a
|
|
248
|
-
} = this, i =
|
|
278
|
+
} = this, i = d("trigger", r, i, a);
|
|
249
279
|
o.triggerNodes[0].insertTrigger(r, e, t, i), s(o, e);
|
|
250
280
|
}
|
|
251
281
|
removeTriggerFromTree(r, e) {
|
|
@@ -256,28 +286,28 @@ class o extends r {
|
|
|
256
286
|
var {
|
|
257
287
|
rpcFunMap: t,
|
|
258
288
|
qyDB: i
|
|
259
|
-
} = this, e =
|
|
289
|
+
} = this, e = d("rpc", r, e, i);
|
|
260
290
|
e && (t[r] = e);
|
|
261
291
|
}
|
|
262
292
|
removeRpc(r) {
|
|
263
293
|
delete this.rpcFunMap[r];
|
|
264
294
|
}
|
|
265
295
|
queryFiles(r, e, t, i, o = this.rootDir) {
|
|
266
|
-
var a = [], t = (
|
|
267
|
-
return
|
|
296
|
+
var a = [], t = (C(e) && !t && (t = 1), new l(t, i)), i = this.options.queryAutoCreateIndex;
|
|
297
|
+
return I(r, e, a, t, o, i), a;
|
|
268
298
|
}
|
|
269
299
|
queryFilesMulti(r, e, t, i = this.rootDir) {
|
|
270
300
|
var o, a, s = [], n = new l(e, t), g = this.options.queryAutoCreateIndex;
|
|
271
|
-
for ([ o, a ] of r)
|
|
301
|
+
for ([ o, a ] of r) I(o, a, s, n, i, g);
|
|
272
302
|
return s;
|
|
273
303
|
}
|
|
274
304
|
async callRpc(e, r, t) {
|
|
275
305
|
var i, o = this.rpcFunMap[e];
|
|
276
|
-
if (!o) return
|
|
306
|
+
if (!o) return O.warn(i = `RPC ${e} not implemented.`), new Error(i);
|
|
277
307
|
try {
|
|
278
308
|
return await o(r, t);
|
|
279
309
|
} catch (r) {
|
|
280
|
-
return
|
|
310
|
+
return O.error(`Calling RPC ${e} failed:`, r), r;
|
|
281
311
|
}
|
|
282
312
|
}
|
|
283
313
|
monitorItemExpire(r, e) {
|
|
@@ -294,15 +324,23 @@ class o extends r {
|
|
|
294
324
|
}
|
|
295
325
|
}
|
|
296
326
|
|
|
297
|
-
function a(r
|
|
327
|
+
function a(r) {
|
|
328
|
+
return [ r.substring(0, 2), r ];
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function h(r) {
|
|
332
|
+
return [ r.substring(0, 2), r ];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function u(r, e) {
|
|
298
336
|
return [ e, r.substring(0, 2), r ];
|
|
299
337
|
}
|
|
300
338
|
|
|
301
|
-
function
|
|
339
|
+
function p(r) {
|
|
302
340
|
return [ r[0], r ];
|
|
303
341
|
}
|
|
304
342
|
|
|
305
|
-
function
|
|
343
|
+
function I(r, e, t, i, o, a) {
|
|
306
344
|
e && (a = a ? n(e) : void 0, g(r, o, a, e, t, i));
|
|
307
345
|
}
|
|
308
346
|
|
package/src/QyDB.js
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
logger as m
|
|
34
34
|
} from "./QyLogger.js";
|
|
35
35
|
|
|
36
|
-
let
|
|
36
|
+
let d = e(n, "../data/sampleDataFolder");
|
|
37
37
|
|
|
38
38
|
class l extends t {
|
|
39
39
|
rootFolder;
|
|
@@ -42,12 +42,12 @@ class l extends t {
|
|
|
42
42
|
batch;
|
|
43
43
|
_immediate;
|
|
44
44
|
creationTime;
|
|
45
|
-
constructor(e =
|
|
46
|
-
s(e) && (t = e, e =
|
|
45
|
+
constructor(e = d, t) {
|
|
46
|
+
s(e) && (t = e, e = d), super(), this.options = {
|
|
47
47
|
...o("QyDB"),
|
|
48
48
|
...t
|
|
49
49
|
}, this.rootFolder = e;
|
|
50
|
-
for (let i of [ "createIndex", "delIndex", "insert", "put", "remove", "delDir", "delFile", "delContent", "insertTrigger", "removeTrigger", "insertRpc", "removeRpc", "expireFile", "expireDir", "expireContent", "expireFileM", "expireDirM", "expireContentM", "removeFileExpire", "removeDirExpire", "removeContentExpire" ]) this[i] = (...e) => {
|
|
50
|
+
for (let i of [ "createIndex", "delIndex", "insert", "put", "remove", "delDir", "delFile", "delContent", "insertTrigger", "removeTrigger", "insertRpc", "removeRpc", "insertEmbedding", "delEmbedding", "expireFile", "expireDir", "expireContent", "expireFileM", "expireDirM", "expireContentM", "removeFileExpire", "removeDirExpire", "removeContentExpire" ]) this[i] = (...e) => {
|
|
51
51
|
var t = this.currentBatch;
|
|
52
52
|
return t[i].apply(t, e).run();
|
|
53
53
|
};
|
package/src/QyFile.js
CHANGED
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
isSimpleType as h,
|
|
11
11
|
fromSingleName as s,
|
|
12
12
|
isEmptyObj as r,
|
|
13
|
-
getNowTime as l
|
|
13
|
+
getNowTime as l,
|
|
14
|
+
isArray as d
|
|
14
15
|
} from "./QyUtils.js";
|
|
15
16
|
|
|
16
17
|
import {
|
|
@@ -25,13 +26,13 @@ import {
|
|
|
25
26
|
handleExpiredProps as u
|
|
26
27
|
} from "./QyExpire.js";
|
|
27
28
|
|
|
28
|
-
let
|
|
29
|
+
let C = n.IndexPropPathsFileName, {
|
|
29
30
|
$spec: p,
|
|
30
31
|
$raw: c,
|
|
31
|
-
$clone:
|
|
32
|
+
$clone: m
|
|
32
33
|
} = t;
|
|
33
34
|
|
|
34
|
-
class
|
|
35
|
+
class y extends e {
|
|
35
36
|
_fileContentKey;
|
|
36
37
|
_fileContent;
|
|
37
38
|
cChangeId = 0;
|
|
@@ -80,7 +81,7 @@ class m extends e {
|
|
|
80
81
|
get clonedContent() {
|
|
81
82
|
return structuredClone(this.fileContent);
|
|
82
83
|
}
|
|
83
|
-
view(e =
|
|
84
|
+
view(e = m, t) {
|
|
84
85
|
var n = this.fileContent;
|
|
85
86
|
return null == n || h(n) ? n : function t(n, i, r, o) {
|
|
86
87
|
if (r === c) return i;
|
|
@@ -105,7 +106,7 @@ class m extends e {
|
|
|
105
106
|
return s;
|
|
106
107
|
}(this, n, e, t);
|
|
107
108
|
}
|
|
108
|
-
prop(e, t =
|
|
109
|
+
prop(e, t = m, n) {
|
|
109
110
|
var i;
|
|
110
111
|
if (t) return e = o(this.fileContent, d(e) ? e : [ e ]), i = t.$link, null != i ? v(this, e, i, t[p], n) : n || t === c ? e : structuredClone(e);
|
|
111
112
|
}
|
|
@@ -161,5 +162,5 @@ function v(e, t, n, i, r = !1) {
|
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
export {
|
|
164
|
-
|
|
165
|
+
y as QyFile
|
|
165
166
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare function mergeContent(oldContent: any, newContent: any): any;
|
|
2
|
-
export declare function mergeContentChanges(oldChanges: any, newChanges: any): any;
|
|
3
2
|
export declare function mergeContentAndGenDelta(oldContent: any, newContent: any): {
|
|
4
3
|
merged: any;
|
|
5
4
|
delta: any;
|
|
@@ -7,5 +6,5 @@ export declare function mergeContentAndGenDelta(oldContent: any, newContent: any
|
|
|
7
6
|
export declare function setValByNamePath(rootObj: any, namePath: any, value: any): any;
|
|
8
7
|
export declare function getValByNamePath(obj: any, namePath: any): any;
|
|
9
8
|
export declare function delValByNamePath(obj: any, propPath: any, keepEmptyObj?: boolean, idx?: number): any;
|
|
10
|
-
export declare function cleanContent(obj: any, shouldCleanMark?: boolean
|
|
9
|
+
export declare function cleanContent(obj: any, shouldCleanMark?: boolean): any;
|
|
11
10
|
export declare function objToDelMarks(obj: any): any;
|