datafolder 1.0.12 → 1.0.13

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/src/QyBatch.js CHANGED
@@ -3,38 +3,39 @@ import {
3
3
  } from "node:util";
4
4
 
5
5
  import {
6
- mergeContentAndGenDelta as c,
6
+ mergeContentAndGenDelta as l,
7
7
  objToDelMarks as r
8
8
  } from "./QyFileContentUtils.js";
9
9
 
10
10
  import {
11
- pathSplit as n,
12
- ensurePropNamePathList as a,
13
- isString as o,
11
+ pathSplit as o,
12
+ ensurePropNamePathList as n,
13
+ isString as c,
14
14
  SpecialOperators as e,
15
15
  getSuffix as g,
16
16
  SpecialFilePaths as t,
17
17
  toSingleName as C,
18
- isSimpleType as l,
19
- getNowSeconds as h,
20
- isEmptyObj as d
18
+ isSimpleType as h,
19
+ isEmptyObj as d,
20
+ isNumber as a,
21
+ getNowRounded as m
21
22
  } from "./QyUtils.js";
22
23
 
23
24
  import {
24
25
  QyAclCmdGenerator as i,
25
- CmdNames as m
26
+ CmdNames as u
26
27
  } from "./QyAcl.js";
27
28
 
28
29
  import {
29
- calDifferenceList as u
30
+ calDifferenceList as f
30
31
  } from "./QyIndex.js";
31
32
 
32
33
  import {
33
- getDefaultOptions as f
34
+ getDefaultOptions as p
34
35
  } from "./QyDefaultOptions.js";
35
36
 
36
37
  import {
37
- QyCD as p
38
+ QyCD as v
38
39
  } from "./QyCD.js";
39
40
 
40
41
  import {
@@ -42,12 +43,10 @@ import {
42
43
  } from "./QyIndexPropTree.js";
43
44
 
44
45
  import {
45
- logger as v
46
+ logger as _
46
47
  } from "./QyLogger.js";
47
48
 
48
- import {
49
- flatObj as _
50
- } from "./QyExpire.js";
49
+ import "node:process";
51
50
 
52
51
  let D = Array.isArray, x = e.$del, O = t.IndexPropPathsFileName, F = {
53
52
  none: 0,
@@ -56,7 +55,7 @@ let D = Array.isArray, x = e.$del, O = t.IndexPropPathsFileName, F = {
56
55
  all: 3
57
56
  };
58
57
 
59
- class L extends p {
58
+ class L extends v {
60
59
  fileLogLevel;
61
60
  actionQueue;
62
61
  changeId;
@@ -67,7 +66,7 @@ class L extends p {
67
66
  running;
68
67
  constructor(e, t) {
69
68
  super(e), t = {
70
- ...f("QyBatch"),
69
+ ...p("QyBatch"),
71
70
  ...t
72
71
  };
73
72
  e = F[t.fileLogLevel.toLowerCase()];
@@ -82,81 +81,100 @@ class L extends p {
82
81
  });
83
82
  }
84
83
  createDir(e, t = this.currentDir) {
85
- return o(e) && (e = n(e)), q(this, "createDir", this.qyCache?.getOrCreateDir(e, t));
84
+ return c(e) && (e = o(e)), N(this, "createDir", this.qyCache.getOrCreateDir(e, t));
86
85
  }
87
86
  delDir(e, t = this.currentDir) {
88
- return o(e) && (e = n(e)), q(this, "delDir", this.qyCache.getOrCreateDir(e, t));
87
+ return c(e) && (e = o(e)), N(this, "delDir", this.qyCache.getOrCreateDir(e, t).ensureAllLoaded());
89
88
  }
90
89
  createFile(e, t = this.currentDir) {
91
- return o(e) && (e = n(e)), q(this, "createFile", this.qyCache.getOrCreateFile(e, t));
90
+ return c(e) && (e = o(e)), N(this, "createFile", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
92
91
  }
93
92
  delFile(e, t = this.currentDir) {
94
- return o(e) && (e = n(e)), q(this, "delFile", this.qyCache.getOrCreateFile(e, t));
93
+ return c(e) && (e = o(e)), N(this, "delFile", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
95
94
  }
96
95
  expireFile(e, t, i = this.currentDir) {
97
- return o(e) && (e = n(e)), this.expireContent(e, {
98
- "": t
99
- }, i);
96
+ return this.expireFileM(e, 1e3 * t, i);
97
+ }
98
+ expireFileM(e, t, i = this.currentDir) {
99
+ return M(this, e, t, "f", i);
100
+ }
101
+ expireDir(e, t, i = this.currentDir) {
102
+ return this.expireDirM(e, 1e3 * t, i);
103
+ }
104
+ expireDirM(e, t, i = this.currentDir) {
105
+ return M(this, e, t, "d", i);
100
106
  }
101
- expireContent(e, t, i = this.currentDir) {
102
- return o(e) && (e = n(e)), q(this, "expireContent", this.qyCache.getOrCreateFile(e, i), {
103
- expireInfoObj: t
107
+ expireContent(e, t, i, r = this.currentDir) {
108
+ c(e) && (e = o(e));
109
+ e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
110
+ return N(this, "expireContent", e, {
111
+ expireInfoObj: t,
112
+ isMilliSecond: i
104
113
  });
105
114
  }
106
- removeFileExpire(e, t = this.currentDir) {
107
- return this.removeContentExpire(e, {
108
- "": 1
109
- }, !1, t);
115
+ expireContentM(e, t, i = this.currentDir) {
116
+ return this.expireContent(e, t, !0, i);
117
+ }
118
+ removeFileExpire(e, t = !1, i = this.currentDir) {
119
+ return E(this, e, "f", t, i);
120
+ }
121
+ removeDirExpire(e, t = !1, i = this.currentDir) {
122
+ return E(this, e, "d", t, i);
110
123
  }
111
124
  removeContentExpire(e, t, i = !1, r = this.currentDir) {
112
- return o(e) && (e = n(e)), q(this, "removeContentExpire", this.qyCache.getOrCreateFile(e, r), {
125
+ c(e) && (e = o(e));
126
+ e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
127
+ return N(this, "removeContentExpire", e, {
113
128
  expireInfoObj: t,
114
129
  infoFileOnly: i
115
130
  });
116
131
  }
117
132
  createIndex(e, t, i = this.currentDir) {
118
- return o(e) && (e = n(e)), D(t) || (t = [ t ]), q(this, "createIndex", this.qyCache?.getOrCreateDir(e, i), {
133
+ return c(e) && (e = o(e)), D(t) || (t = [ t ]), N(this, "createIndex", this.qyCache.getOrCreateDir(e, i), {
119
134
  indexPropPathList: t
120
135
  });
121
136
  }
122
137
  delIndex(e, t, i = this.currentDir) {
123
- return o(e) && (e = n(e)), q(this, "delIndex", this.qyCache.getOrCreateDir(e, i), {
138
+ return c(e) && (e = o(e)), N(this, "delIndex", this.qyCache.getOrCreateDir(e, i), {
124
139
  indexPropPath: t
125
140
  });
126
141
  }
127
- insert(e, t, i = !1, r = this.currentDir) {
128
- return o(e) && (e = n(e)), q(this, "insert", this.qyCache.getOrCreateFile(e, r), {
129
- content: i || l(t) ? t : structuredClone(t)
142
+ insert(e, t, i = !1, r = !1, n = this.currentDir) {
143
+ c(e) && (e = o(e));
144
+ e = this.qyCache.getOrCreateFile(e, n).ensureLoaded();
145
+ return N(this, "insert", e, {
146
+ content: i || h(t) ? t : structuredClone(t),
147
+ noCreate: r
130
148
  });
131
149
  }
132
150
  remove(e, t, i = this.currentDir) {
133
- return this.insert(e, r(t), !0, i);
151
+ return this.insert(e, r(t), !0, !0, i);
134
152
  }
135
- replace(e, t, i = this.currentDir) {
153
+ put(e, t, i = !1, r = this.currentDir) {
136
154
  return this.insert(e, {
137
155
  $rpl: t
138
- }, !0, i);
156
+ }, i, !1, r);
139
157
  }
140
158
  delContent(e, t = this.currentDir) {
141
- return o(e) && (e = n(e)), q(this, "delContent", this.qyCache.getOrCreateFile(e, t));
159
+ return c(e) && (e = o(e)), N(this, "delContent", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
142
160
  }
143
161
  insertTrigger(e, t, i, r) {
144
- return o(t) && (t = n(t)), i = a(i), q(this, "insertTrigger", this.qyCache.getOrCreateTriggerFile(e), {
162
+ return c(t) && (t = o(t)), i = n(i), N(this, "insertTrigger", this.qyCache.getOrCreateTriggerFile(e), {
145
163
  fileNamePath: t,
146
164
  propNamePathList: i,
147
165
  modCode: r
148
166
  });
149
167
  }
150
168
  removeTrigger(e) {
151
- return q(this, "removeTrigger", this.qyCache.getOrCreateTriggerFile(e));
169
+ return N(this, "removeTrigger", this.qyCache.getOrCreateTriggerFile(e));
152
170
  }
153
171
  insertRpc(e, t) {
154
- return q(this, "insertRpc", this.qyCache.getOrCreateRpcFile(e), {
172
+ return N(this, "insertRpc", this.qyCache.getOrCreateRpcFile(e), {
155
173
  modCode: t
156
174
  });
157
175
  }
158
176
  removeRpc(e) {
159
- return q(this, "removeRpc", this.qyCache.getOrCreateRpcFile(e));
177
+ return N(this, "removeRpc", this.qyCache.getOrCreateRpcFile(e));
160
178
  }
161
179
  run(e = !1) {
162
180
  var {
@@ -174,17 +192,17 @@ class L extends p {
174
192
  changeList: i,
175
193
  qyAclCmdGenerator: o,
176
194
  qyCmdObjHistory: s,
177
- syncList: c
178
- } = this, l = i.length;
179
- if (0 == l) return n.decreaseChangeId(), 0;
180
- var h = g(l), o = o.takeCmdArgAsListObj();
195
+ syncList: l
196
+ } = this, c = i.length;
197
+ if (0 == c) return n.decreaseChangeId(), 0;
198
+ var h = g(c), o = o.takeCmdArgAsListObj();
181
199
  let d;
182
200
  0 < r && (r = i.map(({
183
201
  logStr: e
184
- }) => e).join("\n"), d = new Date().toISOString() + `: ${l} change${h}:
202
+ }) => e).join("\n"), d = new Date().toISOString() + `: ${c} change${h}:
185
203
  ${r}
186
204
  `);
187
- var m, u, l = n.save(t, o, d, (e => {
205
+ var m, u, c = n.save(t, o, d, (e => {
188
206
  var t = e.syncList, i = t.length;
189
207
  for (let e = 0; e < i; e += 2) {
190
208
  var r, n = e + 1, a = t[e], o = t[n];
@@ -192,7 +210,7 @@ ${r}
192
210
  t[n] = 0 < r.length ? r : void 0) : t[n] = o.fileContent;
193
211
  }
194
212
  if (0 < i) return t;
195
- })(this), e), h = (c.length = 0, s.push(o), i.filter(({
213
+ })(this), e), h = (l.length = 0, s.push(o), i.filter(({
196
214
  item: e,
197
215
  delta: t
198
216
  }) => t && 0 < e.triggerNodes?.length));
@@ -201,7 +219,7 @@ ${r}
201
219
  item: m,
202
220
  delta: u
203
221
  } of h) for (var f of m.triggerNodes) f.checkTrigger(m, u);
204
- return e ? l : t;
222
+ return e ? c : t;
205
223
  }
206
224
  getTopHistoryCmdObj() {
207
225
  return this.qyCmdObjHistory.top();
@@ -261,15 +279,15 @@ ${r}
261
279
  qyIndexPropTree: o
262
280
  } = (n.created || this._action_createFile({
263
281
  item: n
264
- }), n), s = [], c = {};
282
+ }), n), s = [], l = {};
265
283
  for (e of i) {
266
- var l = C(e);
267
- a && a[l] || (s.push(e), c[l] = 1, o.insert(e));
284
+ var c = C(e);
285
+ a && a[c] || (s.push(e), l[c] = 1, o.insert(e));
268
286
  }
269
287
  if (0 != s.length) {
270
- v.log(`Creating index ${JSON.stringify(s)} for ` + t.fullPath), this._action_insert({
288
+ _.log(`Creating index ${JSON.stringify(s)} for ` + t.fullPath), this._action_insert({
271
289
  item: n,
272
- content: c
290
+ content: l
273
291
  });
274
292
  {
275
293
  var h, d = this, m = t, u = r, i = y(s);
@@ -285,7 +303,7 @@ ${r}
285
303
  fileContent: g,
286
304
  name: p
287
305
  } = g;
288
- null != g && I(d, f, h, p, void 0, g);
306
+ null != g && b(d, f, h, p, void 0, g);
289
307
  }
290
308
  }
291
309
  }
@@ -320,7 +338,7 @@ ${r}
320
338
  parentDir: r,
321
339
  name: n
322
340
  } = i;
323
- return i.created = !1, N(this, e), t || P(this, r, m.R, r.fileMapKey, n),
341
+ return i.created = !1, I(this, e), t || q(this, r, u.R, r.fileMapKey, n),
324
342
  !0;
325
343
  }
326
344
  _action_delDir(e) {
@@ -336,66 +354,71 @@ ${r}
336
354
  fileMapKey: s
337
355
  } = t;
338
356
  if (a) {
339
- P(this, t, m.D, s);
340
- for (var c of t.fileList) this._action_delFile({
341
- item: c
357
+ q(this, t, u.D, s);
358
+ for (var l of t.fileList) this._action_delFile({
359
+ item: l
342
360
  }, !0);
343
361
  }
344
362
  if (n) {
345
- P(this, t, m.D, o);
346
- for (var l of t.allSubdirs()) {
363
+ q(this, t, u.D, o);
364
+ for (var c of t.allSubdirs()) {
347
365
  let {
348
366
  subdirMap: e,
349
367
  fileMap: t,
350
368
  subdirMapKey: i,
351
369
  fileMapKey: r
352
- } = l;
353
- if (e && P(this, l, m.D, i), t) {
354
- P(this, l, m.D, r);
355
- for (var h of l.fileList) this._action_delFile({
370
+ } = c;
371
+ if (e && q(this, c, u.D, i), t) {
372
+ q(this, c, u.D, r);
373
+ for (var h of c.fileList) this._action_delFile({
356
374
  item: h
357
375
  }, !0);
358
376
  }
359
- N(this, {
377
+ I(this, {
360
378
  actionName: "delDir",
361
- item: l
362
- }), l.created = !1;
379
+ item: c
380
+ }), c.created = !1;
363
381
  }
364
382
  }
365
- return !!i && (t.created = !1, N(this, e), P(this, i, m.R, i.subdirMapKey, r),
383
+ return !!i && (t.created = !1, I(this, e), q(this, i, u.R, i.subdirMapKey, r),
366
384
  !0);
367
385
  }
368
386
  _action_delContent(e) {
369
387
  e.actionName = "delContent";
370
388
  var t = e.item, i = t.fileContent;
371
- return null != i && (t.setContent(void 0), Object.assign(e, {
389
+ return null != i && (t.fileContent = void 0, Object.assign(e, {
372
390
  content: i,
373
391
  delta: {
374
392
  oldValue: i,
375
393
  newValue: x
376
394
  }
377
- }), N(this, e), P(this, t, m.D, t.fileContentKey), b(this, t, i), !0);
395
+ }), I(this, e), q(this, t, u.D, t.fileContentKey), P(this, t, i), !0);
378
396
  }
379
397
  _action_insert(e) {
380
398
  e.actionName = "insert";
381
399
  var {
382
400
  item: t,
383
- content: i
401
+ content: i,
402
+ noCreate: r
384
403
  } = e;
385
- if (null == i) return v.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
404
+ if (null == i) return _.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
386
405
  !1;
387
- t.created || this._action_createFile({
388
- item: t
389
- });
390
- var r, n, i = c(t.fileContent, i), {
391
- merged: a,
406
+ if (!t.created) {
407
+ if (r) return !1;
408
+ this._action_createFile({
409
+ item: t
410
+ });
411
+ }
412
+ var n, a, r = l(t.fileContent, i), {
413
+ merged: i,
392
414
  delta: o
393
- } = i;
415
+ } = r;
394
416
  return !!o && ({
395
417
  oldValue: o,
396
- newValue: r
397
- } = o, !!r) && (n = t.fileContentKey, null == a ? P(this, t, m.D, n) : P(this, t, m.M, n, r),
398
- Object.assign(e, i), N(this, e), t.setContent(a), b(this, t, o, r, a), !0);
418
+ newValue: n
419
+ } = o, !!n) && (a = t.fileContentKey, null == i ? q(this, t, u.D, a) : q(this, t, u.M, a, n),
420
+ Object.assign(e, r), I(this, e), t.fileContent = i, P(this, t, o, n, i),
421
+ !0);
399
422
  }
400
423
  _action_createFile(e) {
401
424
  e.actionName = "createFile";
@@ -405,7 +428,7 @@ ${r}
405
428
  }), Object.assign(i, {
406
429
  created: !0,
407
430
  fileContentLoaded: !0
408
- }), N(this, e), P(this, t, m.A, t.fileMapKey, i.name), !0);
431
+ }), I(this, e), q(this, t, u.A, t.fileMapKey, i.name), !0);
409
432
  }
410
433
  _action_createDir(e) {
411
434
  e.actionName = "createDir";
@@ -417,52 +440,83 @@ ${r}
417
440
  created: !0,
418
441
  subdirMapLoaded: !0,
419
442
  fileMapLoaded: !0
420
- }), N(this, {
443
+ }), I(this, {
421
444
  actionName: "createDir",
422
445
  item: e
423
446
  });
424
447
  var r = e.parentDir;
425
- P(this, r, m.A, r.subdirMapKey, e.name);
448
+ q(this, r, u.A, r.subdirMapKey, e.name);
426
449
  }
427
450
  return !0;
428
451
  }
429
- _action_expireContent(e) {
430
- e.actionName = "expireContent";
452
+ _action_expireItem(e) {
453
+ e.actionName = "expireItem";
431
454
  var t, {
432
455
  item: e,
433
- expireInfoObj: i
434
- } = e, r = h(), n = _(i);
435
- for (t in n) n[t] += r;
436
- var i = this.qyCache, a = i.getOrCreateExpireInfoFile(e.fullPathHash), a = this._action_insert({
437
- item: a,
456
+ milliSecond: i
457
+ } = e, {
458
+ parentDir: r,
459
+ name: n
460
+ } = e;
461
+ return !!r && null != (i = T(i, !0, m())) && (t = this.qyCache, r = t.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"),
462
+ (r = this._action_insert({
463
+ item: r,
438
464
  content: {
439
- ...n
465
+ [n]: i
440
466
  }
441
- });
442
- return a && i.monitorContentExpire(e, n), a;
467
+ })) && t.monitorItemExpire(e, i), r);
443
468
  }
444
- _action_removeContentExpire(t) {
445
- t.actionName = "removeContentExpire";
446
- var {
469
+ _action_removeItemExpire(e) {
470
+ e.actionName = "removeItemExpire";
471
+ var t, {
472
+ item: e,
473
+ infoFileOnly: i
474
+ } = e, {
475
+ parentDir: r,
476
+ name: n
477
+ } = e;
478
+ return !!r && (t = this.qyCache, !!(r = t.getExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"))) && ((n = this._action_insert({
479
+ item: r,
480
+ content: {
481
+ [n]: x
482
+ }
483
+ })) && (d(r.fileContent) && this._action_delFile({
484
+ item: r
485
+ }), i || t.unmonitorItemExpire(e)), n);
486
+ }
487
+ _action_expireContent(e) {
488
+ e.actionName = "expireContent";
489
+ let {
447
490
  item: t,
448
491
  expireInfoObj: i,
492
+ isMilliSecond: r
493
+ } = e, n = m();
494
+ var e = S(i, e => T(e, r, n)), a = this.qyCache, o = a.getOrCreateExpireInfoFile(t.fullPathHash, "c"), o = this._action_insert({
495
+ item: o,
496
+ content: {
497
+ ...e
498
+ }
499
+ });
500
+ return o && a.monitorContentExpire(t, e), o;
501
+ }
502
+ _action_removeContentExpire(e) {
503
+ e.actionName = "removeContentExpire";
504
+ var t, {
505
+ item: e,
506
+ expireInfoObj: i,
449
507
  infoFileOnly: r
450
- } = t, n = this.qyCache, a = n.getExpireInfoFile(t.fullPathHash);
451
- if (a.created) {
452
- let e;
453
- if (D(i)) e = Object.fromEntries(i.map(e => [ e, x ])); else for (var o in e = _(i)) e[o] ? e[o] = x : delete e[o];
454
- i = this._action_insert({
455
- item: a,
456
- content: e
457
- });
458
- return i && (d(a.fileContent) && this._action_delFile({
459
- item: a
460
- }), r || n.unmonitorContentExpire(t, e)), i;
461
- }
508
+ } = e, n = this.qyCache, a = n.getExpireInfoFile(e.fullPathHash, "c");
509
+ return !!a && (i = D(i) ? Object.fromEntries(i.map(e => [ e, x ])) : S(i, e => e ? x : void 0),
510
+ (t = this._action_insert({
511
+ item: a,
512
+ content: i
513
+ })) && (d(a.fileContent) && this._action_delFile({
514
+ item: a
515
+ }), r || n.unmonitorContentExpire(e, i)), t);
462
516
  }
463
517
  }
464
518
 
465
- function q(e, t, i, r) {
519
+ function N(e, t, i, r) {
466
520
  return e.actionQueue.push({
467
521
  actionName: t,
468
522
  item: i,
@@ -470,7 +524,7 @@ function q(e, t, i, r) {
470
524
  }), e;
471
525
  }
472
526
 
473
- function N(e, t) {
527
+ function I(e, t) {
474
528
  var {
475
529
  changeList: e,
476
530
  fileLogLevel: i
@@ -494,7 +548,7 @@ function N(e, t) {
494
548
  })(t, i)), e.push(t);
495
549
  }
496
550
 
497
- function P(e, t, i, r, n = void 0) {
551
+ function q(e, t, i, r, n = void 0) {
498
552
  var {
499
553
  qyAclCmdGenerator: e,
500
554
  qyCache: a,
@@ -505,7 +559,7 @@ function P(e, t, i, r, n = void 0) {
505
559
  a && a.qyKVData.removeKey(r) && o.push(r, t);
506
560
  }
507
561
 
508
- function b(e, t, i, r = void 0, n = void 0) {
562
+ function P(e, t, i, r = void 0, n = void 0) {
509
563
  var {
510
564
  underHiddenFolder: t,
511
565
  name: a,
@@ -515,26 +569,26 @@ function b(e, t, i, r = void 0, n = void 0) {
515
569
  var s = e.qyCache.getIndexDir(o);
516
570
  if (s) {
517
571
  t = s.getFile(O);
518
- if (t) for (var c of t.qyIndexPropTree.getAllIndexPropPaths()) I(e, s.searchOrCreateSubdir(c), c, a, i, r, n);
572
+ if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths()) b(e, s.searchOrCreateSubdir(l), l, a, i, r, n);
519
573
  }
520
574
  }
521
575
  }
522
576
 
523
- function I(t, e, i, r, n, a, o = void 0) {
524
- e = u(e, i, r, n, a, o);
577
+ function b(t, e, i, r, n, a, o = void 0) {
578
+ e = f(e, i, r, n, a, o);
525
579
  if (e) {
526
- var s, c, l, {
580
+ var s, l, c, {
527
581
  toAddFileList: i,
528
582
  toDelFileList: r
529
583
  } = e;
530
584
  for (s of i) t._action_createFile({
531
585
  item: s
532
586
  });
533
- for (c of r) t._action_delFile({
534
- item: c
587
+ for (l of r) t._action_delFile({
588
+ item: l
535
589
  });
536
- for (l of r) {
537
- let e = l.parentDir;
590
+ for (c of r) {
591
+ let e = c.parentDir;
538
592
  for (;e.created && !e.isHiddenFolder && e.isEmpty; ) t._action_delDir({
539
593
  item: e
540
594
  }), e = e.parentDir;
@@ -570,6 +624,35 @@ class j {
570
624
  }
571
625
  }
572
626
 
627
+ function S(e, t = void 0, i = [], r = {}) {
628
+ if (h(e)) {
629
+ var n = t ? t(e) : e;
630
+ null != n && (r[JSON.stringify(i)] = n);
631
+ } else {
632
+ var a, o = i.length;
633
+ for (a in e) i.push(a), S(e[a], t, i, r), i.length = o;
634
+ }
635
+ return r;
636
+ }
637
+
638
+ function T(e, t, i) {
639
+ return a(e) ? (t ? e : 1e3 * e) + i : c(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !(e instanceof Date) || (t = e.getTime()) <= i ? void 0 : t;
640
+ }
641
+
642
+ function M(e, t, i, r, n) {
643
+ var a = e.qyCache, r = (c(t) && (t = o(t)), "f" == r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
644
+ return N(e, "expireItem", r, {
645
+ milliSecond: i
646
+ });
647
+ }
648
+
649
+ function E(e, t, i, r, n) {
650
+ var a = e.qyCache, i = (c(t) && (t = o(t)), "f" == i ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
651
+ return N(e, "removeItemExpire", i, {
652
+ infoFileOnly: r
653
+ });
654
+ }
655
+
573
656
  export {
574
657
  L as QyBatch
575
658
  };
package/src/QyCache.d.ts CHANGED
@@ -30,12 +30,13 @@ export declare class QyCache extends EventEmitter {
30
30
  getOrCreateIndexDir(indexHostDir: any): any;
31
31
  getTriggerFile(triggerName: any): any;
32
32
  getOrCreateTriggerFile(triggerName: any): any;
33
- getExpireInfoFile(fullPathHash: any, isDir?: boolean): any;
34
- getOrCreateExpireInfoFile(fullPathHash: any, isDir?: boolean): any;
33
+ getExpireInfoFile(fullPathHash: any, type?: string): any;
34
+ getOrCreateExpireInfoFile(fullPathHash: any, type?: string): any;
35
35
  get triggerFileList(): any;
36
36
  getRpcFile(rpcFunName: any): any;
37
37
  getOrCreateRpcFile(rpcFunName: any): any;
38
38
  get rpcFileList(): any;
39
+ get metaFile(): any;
39
40
  insertTriggerToTree(triggerName: any, fileNamePath: any, propNamePathList: any, modCode: any): void;
40
41
  removeTriggerFromTree(triggerName: any, fileNamePath: any): void;
41
42
  insertRpc(rpcFunName: any, modCode: any): void;
@@ -43,6 +44,8 @@ export declare class QyCache extends EventEmitter {
43
44
  queryFiles(indexHostDirNamePath: any, queryObj: any, limit: any, cursor: any, parentDir?: any): never[];
44
45
  queryFilesMulti(indexHostDirNamePathMulti: any, limit: any, cursor: any, parentDir?: any): never[];
45
46
  callRpc(rpcFunName: any, args: any, body: any): Promise<any>;
46
- monitorContentExpire(file: any, flattedAbsSecondObj: any): void;
47
+ monitorItemExpire(item: any, expireTime: any): void;
48
+ unmonitorItemExpire(item: any): void;
49
+ monitorContentExpire(file: any, flattedAbsTimeObj: any): void;
47
50
  unmonitorContentExpire(file: any, flattedDelObj: any): void;
48
51
  }