datafolder 1.0.50 → 1.0.52

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.
Files changed (70) hide show
  1. package/ChangeLog.md +4 -0
  2. package/package.json +1 -1
  3. package/scripts/airbnb1.js +80 -0
  4. package/scripts/convertBinFiles.js +3 -1
  5. package/scripts/flights2.js +1 -1
  6. package/src/QyAcl.d.ts +1 -1
  7. package/src/QyAcl.js +31 -33
  8. package/src/QyAclSaver.js +3 -3
  9. package/src/QyAclWriter.d.ts +2 -1
  10. package/src/QyAclWriter.js +22 -11
  11. package/src/QyBatch.d.ts +20 -20
  12. package/src/QyBatch.js +237 -237
  13. package/src/QyBinWriter.d.ts +5 -3
  14. package/src/QyBinWriter.js +84 -72
  15. package/src/QyBinaryHeap.js +2 -2
  16. package/src/QyCD.js +2 -2
  17. package/src/QyCache.d.ts +5 -3
  18. package/src/QyCache.js +136 -135
  19. package/src/QyDB.js +2 -2
  20. package/src/QyDefaultOptions.js +5 -4
  21. package/src/QyDir.js +14 -14
  22. package/src/QyEmbeddingWriter.js +3 -3
  23. package/src/QyEmbeddings.js +2 -2
  24. package/src/QyExpireInfo.js +4 -4
  25. package/src/QyExpireMonitor.js +2 -2
  26. package/src/QyExpireProcessor.js +3 -3
  27. package/src/QyFetch.js +2 -2
  28. package/src/QyFile.js +10 -10
  29. package/src/QyFileLogger.d.ts +1 -1
  30. package/src/QyFileLogger.js +12 -12
  31. package/src/QyHNSW.js +6 -6
  32. package/src/QyIndexPropTree.js +2 -2
  33. package/src/QyIntersectNode.js +3 -3
  34. package/src/QyItem.js +2 -2
  35. package/src/QyJsonSaver.js +2 -2
  36. package/src/QyKVData.d.ts +3 -1
  37. package/src/QyKVData.js +72 -57
  38. package/src/QyKVDataCleaner.js +9 -12
  39. package/src/QyKVDataCleaner_Worker.d.ts +1 -4
  40. package/src/QyKVDataCleaner_Worker.js +1 -4
  41. package/src/QyKVDataLoader.js +2 -2
  42. package/src/QyKVDataSaver.js +7 -10
  43. package/src/QyKVDataSaver_Worker.d.ts +1 -4
  44. package/src/QyKVDataSaver_Worker.js +4 -7
  45. package/src/QyLogFileSaver.js +3 -3
  46. package/src/QyLogFileSaver_Worker.d.ts +1 -3
  47. package/src/QyLogFileSaver_Worker.js +7 -13
  48. package/src/QyMessageWorker.js +2 -2
  49. package/src/QyMessager.d.ts +2 -2
  50. package/src/QyMessager.js +6 -6
  51. package/src/QyMessager_Run.js +1 -1
  52. package/src/QyOpRunner.js +11 -8
  53. package/src/QyQueue.js +2 -2
  54. package/src/QySaver.js +27 -27
  55. package/src/QySnapshotCompactor.js +3 -6
  56. package/src/QySnapshotCompactor_Worker.d.ts +1 -4
  57. package/src/QySnapshotCompactor_Worker.js +71 -66
  58. package/src/QySnapshotMapSaver.d.ts +1 -1
  59. package/src/QySnapshotMapSaver.js +7 -10
  60. package/src/QySnapshotMapSaver_Worker.d.ts +2 -6
  61. package/src/QySnapshotMapSaver_Worker.js +26 -33
  62. package/src/QySnapshotSaver.js +8 -11
  63. package/src/QySnapshotSaver_Worker.d.ts +1 -4
  64. package/src/QySnapshotSaver_Worker.js +20 -22
  65. package/src/QySnapshots.d.ts +6 -3
  66. package/src/QySnapshots.js +193 -157
  67. package/src/QyTrigger.js +5 -5
  68. package/src/QyUnionNode.js +3 -3
  69. package/static/datafolderui/QyStyledElement.js +2 -2
  70. package/static/datafolderui/QyUIFolderViewer.js +2 -2
@@ -5,13 +5,15 @@ export declare class QyBinWriter extends QyOpRunner {
5
5
  totalSavedSize: number;
6
6
  fileHandle: FileHandle | undefined;
7
7
  constructor(options?: any, filePath?: any);
8
- save(changeId: any, data?: any, needPromise?: any): any;
8
+ save(data: any, needPromise?: any): any;
9
+ savev(data: Buffer[], needPromise?: any): any;
9
10
  truncate(): any;
10
11
  switch(newFilePath: any): any;
11
- getBinData(dataQueue: any[], changeId?: undefined): any[] | undefined;
12
12
  _op_start(filePath?: any): Promise<this>;
13
13
  _op_stop(): Promise<void>;
14
- _op_save(changeId: any, dataQueue: any): Promise<void> | undefined;
14
+ _op_save(dataQueue: any): Promise<void> | undefined;
15
15
  _op_truncate(): Promise<void>;
16
16
  _op_switch(newFilePath: any): Promise<void>;
17
+ _saveBinData(binDataList: any[]): Promise<void>;
18
+ _getLastSaveOp(needPromise: any): any;
17
19
  }
@@ -4,137 +4,149 @@ import {
4
4
 
5
5
  import {
6
6
  ArgList_Idx as s,
7
- OpFun_Idx as f,
8
- Promise_Idx as o,
7
+ OpFun_Idx as d,
8
+ Promise_Idx as r,
9
9
  QyOpRunner as t,
10
- setOpPromise as l
10
+ setOpPromise as e
11
11
  } from "./QyOpRunner.js";
12
12
 
13
13
  import {
14
- ensureParentDir as d,
15
- getSize as h,
16
- sleep as p,
17
- toBuffer as e,
18
- folderOrFileExists as v,
19
- isString as a
14
+ ensureParentDir as h,
15
+ getSize as l,
16
+ sleep as v,
17
+ toBuffer as o,
18
+ folderOrFileExists as p,
19
+ isString as i
20
20
  } from "./QyUtils.js";
21
21
 
22
22
  import {
23
- getDefaultOptions as r
23
+ getDefaultOptions as f
24
24
  } from "./QyDefaultOptions.js";
25
25
 
26
26
  import {
27
- logger as c
27
+ logger as u
28
28
  } from "./QyLogger.js";
29
29
 
30
- class QyBinWriter extends t {
30
+ class a extends t {
31
31
  filePath;
32
32
  totalSavedSize = 0;
33
33
  fileHandle;
34
- constructor(t = void 0, i = void 0) {
35
- a(t) && ([ i, t ] = [ t, void 0 ]), super({
36
- ...r("QyBinWriter"),
34
+ constructor(t = void 0, a = void 0) {
35
+ i(t) && ([ a, t ] = [ t, void 0 ]), super({
36
+ ...f("QyBinWriter"),
37
37
  ...t
38
- }), this.filePath = i;
38
+ }), this.filePath = a;
39
39
  }
40
- save(t, i = void 0, a = !1) {
41
- void 0 === i && (i = t, t = 0);
42
- var e, r = this.lastOp;
43
- return void 0 === r || r[f] !== this._op_save ? (e = [ this._op_save, [ t, [ i ] ] ],
44
- a ? this.pushAndRunWithPromise(e) : this.pushAndRun(e)) : ((e = r[s])[0] = t,
45
- e[1].push(i), a ? (l(r), r[o]) : void 0);
40
+ save(t, a = !1) {
41
+ t = o(t);
42
+ var i, e = this._getLastSaveOp(a);
43
+ return void 0 === e ? (i = [ this._op_save, [ [ t ] ] ], a ? this.pushAndRunWithPromise(i) : this.pushAndRun(i)) : ([ i ] = e[s],
44
+ i.push(t), a ? e[r] : void 0);
45
+ }
46
+ savev(t, a = !1) {
47
+ var i, e = this._getLastSaveOp(a);
48
+ return void 0 === e ? (i = [ this._op_save, [ t ] ], a ? this.pushAndRunWithPromise(i) : this.pushAndRun(i)) : ([ i ] = e[s],
49
+ i.push(...t), a ? e[r] : void 0);
46
50
  }
47
51
  truncate() {
48
- var t = this.lastOp;
49
- return void 0 !== t && t[f] === this._op_truncate ? t[o] : this.pushAndRunWithPromise([ this._op_truncate ]);
52
+ var {
53
+ lastOp: t,
54
+ _op_truncate: a
55
+ } = this;
56
+ return void 0 !== t && t[d] === a ? t[r] : this.pushAndRunWithPromise([ a ]);
50
57
  }
51
58
  switch(t) {
52
- var i = this.lastOp;
53
- return void 0 !== i && i[f] === this._op_switch ? (i[s][0] = t, i[o]) : this.pushAndRunWithPromise([ this._op_switch, [ t ] ]);
54
- }
55
- getBinData(i, t = 0) {
56
- var a = i.length;
57
- if (0 !== a) {
58
- if (!Buffer.isBuffer(i[0])) for (let t = 0; t < a; ++t) i[t] = e(i[t]);
59
- return i;
60
- }
59
+ var {
60
+ lastOp: a,
61
+ _op_switch: i
62
+ } = this;
63
+ return void 0 !== a && a[d] === i ? (a[s][0] = t, a[r]) : this.pushAndRunWithPromise([ i, [ t ] ]);
61
64
  }
62
65
  async _op_start(t = void 0) {
63
- return await u(this, t = void 0 === t ? this.filePath : t), this;
66
+ return await c(this, t = void 0 === t ? this.filePath : t), this;
64
67
  }
65
68
  async _op_stop() {
66
69
  var {
67
70
  fileHandle: t,
68
- filePath: i
71
+ filePath: a
69
72
  } = this;
70
73
  if (t) try {
71
74
  await t.close(), this.fileHandle = void 0;
72
75
  } catch (t) {
73
- c.error(`Close ${i} failed:`, t);
76
+ u.error(`Close ${a} failed:`, t);
74
77
  }
75
78
  this.totalSavedSize = 0;
76
79
  }
77
- _op_save(t, i) {
78
- i = this.getBinData(i, t);
79
- if (void 0 !== i) return (async (t, i, a) => {
80
- let {
81
- fileHandle: e,
82
- totalSavedSize: r,
83
- filePath: s,
84
- options: o
85
- } = t, {
86
- maxRetryInterval: n,
87
- retryIntervalFactor: l
88
- } = o, d = 0;
89
- for (;void 0 === t.firstOp || t.firstOp[f] !== t._op_truncate; ) try {
90
- var h = (await e.writev(a, r)).bytesWritten;
91
- return void (t.totalSavedSize += h);
92
- } catch (t) {
93
- c.error(`Saving (changeId:${i}) to ${s} failed:`, t, "Truncated back to " + r),
94
- await e.truncate(r), d = 0 === d ? 1 : Math.min(n, d * l), c.log(`Retry in ${d} seconds`),
95
- await p(d);
96
- }
97
- })(this, t, i);
80
+ _op_save(t) {
81
+ if (0 < t.length) return this._saveBinData(t);
98
82
  }
99
83
  async _op_truncate() {
100
84
  var {
101
85
  fileHandle: t,
102
- filePath: i
86
+ filePath: a
103
87
  } = this;
104
88
  if (t) try {
105
- await t.truncate(0), c.info("Truncated " + i);
89
+ await t.truncate(0), u.info("Truncated " + a);
106
90
  } catch (t) {
107
- c.error(`Truncate ${i} failed:`, t);
91
+ u.error(`Truncate ${a} failed:`, t);
108
92
  }
109
93
  this.totalSavedSize = 0;
110
94
  }
111
95
  async _op_switch(t) {
112
96
  var {
113
- fileHandle: i,
114
- filePath: a
97
+ fileHandle: a,
98
+ filePath: i
99
+ } = this;
100
+ void 0 !== a && i === t || (await c(this, t), u.info(`Switched from ${i} to ` + t));
101
+ }
102
+ async _saveBinData(t) {
103
+ var {
104
+ fileHandle: a,
105
+ totalSavedSize: i,
106
+ filePath: e,
107
+ options: s,
108
+ _op_truncate: r
109
+ } = this, {
110
+ maxRetryInterval: o,
111
+ retryIntervalFactor: n
112
+ } = s;
113
+ let h = 0;
114
+ for (;void 0 === this.firstOp || this.firstOp[d] !== r; ) try {
115
+ var l = (await a.writev(t, i)).bytesWritten;
116
+ return void (this.totalSavedSize += l);
117
+ } catch (t) {
118
+ u.error(`Saving to ${e} failed:`, t, "Truncated back to " + i), await a.truncate(i),
119
+ h = 0 === h ? 1 : Math.min(o, h * n), u.log(`Retry in ${h} seconds`),
120
+ await v(h);
121
+ }
122
+ }
123
+ _getLastSaveOp(t) {
124
+ var {
125
+ lastOp: a,
126
+ _op_save: i
115
127
  } = this;
116
- void 0 !== i && a === t || (await u(this, t), c.info(`Switched from ${a} to ` + t));
128
+ if (void 0 !== a && a[d] === i) return t && e(a), a;
117
129
  }
118
130
  }
119
131
 
120
- async function u(t, i) {
132
+ async function c(t, a) {
121
133
  var {
122
- fileHandle: a,
134
+ fileHandle: i,
123
135
  options: e
124
136
  } = t;
125
137
  t.totalSavedSize = 0;
126
138
  try {
127
- a && (a.close(), t.fileHandle = void 0), await d(i), t.filePath = i;
139
+ i && (i.close(), t.fileHandle = void 0), await h(a), t.filePath = a;
128
140
  var {
129
- append: r,
130
- read: s
131
- } = e, o = r && await v(i) ? "r+" : s ? "w+" : "w";
132
- t.fileHandle = await n(i, o), r && (t.totalSavedSize = await h(i));
141
+ append: s,
142
+ read: r
143
+ } = e, o = s && await p(a) ? "r+" : r ? "w+" : "w";
144
+ t.fileHandle = await n(a, o), s && (t.totalSavedSize = await l(a));
133
145
  } catch (t) {
134
- c.error(`Open ${i} failed:`, t);
146
+ u.error(`Open ${a} failed:`, t);
135
147
  }
136
148
  }
137
149
 
138
150
  export {
139
- QyBinWriter
151
+ a as QyBinWriter
140
152
  };
@@ -1,4 +1,4 @@
1
- class QyBinaryHeap {
1
+ class t {
2
2
  items = [];
3
3
  cmpFun;
4
4
  constructor(t = (t, e) => t - e) {
@@ -51,5 +51,5 @@ function i(t, e = t.items.length - 1) {
51
51
  }
52
52
 
53
53
  export {
54
- QyBinaryHeap
54
+ t as QyBinaryHeap
55
55
  };
package/src/QyCD.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  pathSplit as n
4
4
  } from "./QyUtils.js";
5
5
 
6
- class QyCD {
6
+ class e {
7
7
  qyCache;
8
8
  currentDir;
9
9
  constructor(e) {
@@ -120,5 +120,5 @@ function h(e, t) {
120
120
  }
121
121
 
122
122
  export {
123
- QyCD
123
+ e as QyCD
124
124
  };
package/src/QyCache.d.ts CHANGED
@@ -22,14 +22,16 @@ export declare class QyCache extends EventEmitter {
22
22
  hnswRootDir: any;
23
23
  exclusiveFilePath: any;
24
24
  rpcFunMap: Map<string, Function>;
25
- qyKVData: QyKVData | undefined;
26
- qyFileLogger: QyFileLogger | undefined;
27
- qyEmbeddings: QyEmbeddings | undefined;
25
+ qyKVData: QyKVData;
26
+ qyFileLogger: QyFileLogger;
27
+ qyEmbeddings: QyEmbeddings;
28
28
  constructor(rootFolder: string, options?: any, qyDB?: any);
29
29
  start(): Promise<this>;
30
30
  stop(): Promise<this>;
31
31
  increaseChangeId(): number;
32
32
  decreaseChangeId(): void;
33
+ removeKey(key: any): true | undefined;
34
+ getValueSync(key: any): any;
33
35
  save(changeId: any, cmdArgAsListArray: any, logText: any, syncList: any, needPromise: any): any;
34
36
  getFile(namePath: QyFile | string | string[], parentDir?: any): QyFile | undefined;
35
37
  getOrCreateFile(namePath: QyFile | string | string[], parentDir?: any): QyFile;