s3db.js 13.0.0 → 13.1.0
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/dist/s3db.cjs.js +2681 -43
- package/dist/s3db.cjs.js.map +1 -1
- package/dist/s3db.es.js +2681 -43
- package/dist/s3db.es.js.map +1 -1
- package/package.json +1 -1
- package/src/plugins/api/index.js +1 -7
- package/src/plugins/api/routes/resource-routes.js +3 -3
- package/src/plugins/api/server.js +29 -9
- package/src/plugins/audit.plugin.js +2 -4
- package/src/plugins/backup.plugin.js +2 -4
- package/src/plugins/cache.plugin.js +1 -3
- package/src/plugins/costs.plugin.js +0 -2
- package/src/plugins/eventual-consistency/index.js +1 -3
- package/src/plugins/fulltext.plugin.js +2 -4
- package/src/plugins/geo.plugin.js +1 -3
- package/src/plugins/importer/index.js +0 -2
- package/src/plugins/index.js +0 -1
- package/src/plugins/metrics.plugin.js +2 -4
- package/src/plugins/ml.plugin.js +794 -32
- package/src/plugins/plugin.class.js +1 -3
- package/src/plugins/queue-consumer.plugin.js +1 -3
- package/src/plugins/relation.plugin.js +1 -3
- package/src/plugins/replicator.plugin.js +2 -4
- package/src/plugins/s3-queue.plugin.js +1 -3
- package/src/plugins/scheduler.plugin.js +2 -4
- package/src/plugins/state-machine.plugin.js +2 -4
- package/src/plugins/tfstate/index.js +0 -2
- package/src/plugins/ttl.plugin.js +36 -21
- package/src/plugins/vector.plugin.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Plugin from "./plugin.class.js";
|
|
1
|
+
import { Plugin } from "./plugin.class.js";
|
|
2
2
|
import tryFn from "../concerns/try-fn.js";
|
|
3
3
|
import {
|
|
4
4
|
RelationError,
|
|
@@ -1373,5 +1373,3 @@ export class RelationPlugin extends Plugin {
|
|
|
1373
1373
|
this.clearCache();
|
|
1374
1374
|
}
|
|
1375
1375
|
}
|
|
1376
|
-
|
|
1377
|
-
export default RelationPlugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Plugin from "./plugin.class.js";
|
|
1
|
+
import { Plugin } from "./plugin.class.js";
|
|
2
2
|
import tryFn from "../concerns/try-fn.js";
|
|
3
3
|
import { createReplicator, validateReplicatorConfig } from "./replicators/index.js";
|
|
4
4
|
import { ReplicationError } from "./replicator.errors.js";
|
|
@@ -777,6 +777,4 @@ export class ReplicatorPlugin extends Plugin {
|
|
|
777
777
|
});
|
|
778
778
|
}
|
|
779
779
|
}
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
export default ReplicatorPlugin;
|
|
780
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Plugin from "./plugin.class.js";
|
|
1
|
+
import { Plugin } from "./plugin.class.js";
|
|
2
2
|
import tryFn from "../concerns/try-fn.js";
|
|
3
3
|
import { idGenerator } from "../concerns/id.js";
|
|
4
4
|
|
|
@@ -673,5 +673,3 @@ export class S3QueuePlugin extends Plugin {
|
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
}
|
|
676
|
-
|
|
677
|
-
export default S3QueuePlugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Plugin from "./plugin.class.js";
|
|
1
|
+
import { Plugin } from "./plugin.class.js";
|
|
2
2
|
import tryFn from "../concerns/try-fn.js";
|
|
3
3
|
import { idGenerator } from "../concerns/id.js";
|
|
4
4
|
import { SchedulerError } from "./scheduler.errors.js";
|
|
@@ -921,6 +921,4 @@ export class SchedulerPlugin extends Plugin {
|
|
|
921
921
|
this.activeJobs.clear();
|
|
922
922
|
this.removeAllListeners();
|
|
923
923
|
}
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
export default SchedulerPlugin;
|
|
924
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Plugin from "./plugin.class.js";
|
|
1
|
+
import { Plugin } from "./plugin.class.js";
|
|
2
2
|
import tryFn from "../concerns/try-fn.js";
|
|
3
3
|
import { StateMachineError } from "./state-machine.errors.js";
|
|
4
4
|
|
|
@@ -684,6 +684,4 @@ export class StateMachinePlugin extends Plugin {
|
|
|
684
684
|
this.machines.clear();
|
|
685
685
|
this.removeAllListeners();
|
|
686
686
|
}
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
export default StateMachinePlugin;
|
|
687
|
+
}
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import Plugin from "./plugin.class.js";
|
|
1
|
+
import { Plugin } from "./plugin.class.js";
|
|
2
2
|
import tryFn from "../concerns/try-fn.js";
|
|
3
3
|
import { idGenerator } from "../concerns/id.js";
|
|
4
4
|
|
|
5
|
+
// Time constants (in seconds)
|
|
6
|
+
const ONE_MINUTE_SEC = 60;
|
|
7
|
+
const ONE_HOUR_SEC = 3600;
|
|
8
|
+
const ONE_DAY_SEC = 86400;
|
|
9
|
+
const THIRTY_DAYS_SEC = 2592000;
|
|
10
|
+
|
|
11
|
+
// Time constants (in milliseconds)
|
|
12
|
+
const TEN_SECONDS_MS = 10000;
|
|
13
|
+
const ONE_MINUTE_MS = 60000;
|
|
14
|
+
const TEN_MINUTES_MS = 600000;
|
|
15
|
+
const ONE_HOUR_MS = 3600000;
|
|
16
|
+
const ONE_DAY_MS = 86400000;
|
|
17
|
+
const ONE_WEEK_MS = 604800000;
|
|
18
|
+
|
|
19
|
+
// Conversion factor
|
|
20
|
+
const SECONDS_TO_MS = 1000;
|
|
21
|
+
|
|
5
22
|
/**
|
|
6
23
|
* TTLPlugin - Time-To-Live Auto-Cleanup System v2
|
|
7
24
|
*
|
|
@@ -45,27 +62,27 @@ import { idGenerator } from "../concerns/id.js";
|
|
|
45
62
|
// Granularity configurations
|
|
46
63
|
const GRANULARITIES = {
|
|
47
64
|
minute: {
|
|
48
|
-
threshold:
|
|
49
|
-
interval:
|
|
50
|
-
cohortsToCheck: 3,
|
|
65
|
+
threshold: ONE_HOUR_SEC, // TTL < 1 hour
|
|
66
|
+
interval: TEN_SECONDS_MS, // Check every 10 seconds
|
|
67
|
+
cohortsToCheck: 3, // Check last 3 minutes
|
|
51
68
|
cohortFormat: (date) => date.toISOString().substring(0, 16) // '2024-10-25T14:30'
|
|
52
69
|
},
|
|
53
70
|
hour: {
|
|
54
|
-
threshold:
|
|
55
|
-
interval:
|
|
56
|
-
cohortsToCheck: 2,
|
|
71
|
+
threshold: ONE_DAY_SEC, // TTL < 24 hours
|
|
72
|
+
interval: TEN_MINUTES_MS, // Check every 10 minutes
|
|
73
|
+
cohortsToCheck: 2, // Check last 2 hours
|
|
57
74
|
cohortFormat: (date) => date.toISOString().substring(0, 13) // '2024-10-25T14'
|
|
58
75
|
},
|
|
59
76
|
day: {
|
|
60
|
-
threshold:
|
|
61
|
-
interval:
|
|
62
|
-
cohortsToCheck: 2,
|
|
77
|
+
threshold: THIRTY_DAYS_SEC, // TTL < 30 days
|
|
78
|
+
interval: ONE_HOUR_MS, // Check every 1 hour
|
|
79
|
+
cohortsToCheck: 2, // Check last 2 days
|
|
63
80
|
cohortFormat: (date) => date.toISOString().substring(0, 10) // '2024-10-25'
|
|
64
81
|
},
|
|
65
82
|
week: {
|
|
66
|
-
threshold: Infinity,
|
|
67
|
-
interval:
|
|
68
|
-
cohortsToCheck: 2,
|
|
83
|
+
threshold: Infinity, // TTL >= 30 days
|
|
84
|
+
interval: ONE_DAY_MS, // Check every 24 hours
|
|
85
|
+
cohortsToCheck: 2, // Check last 2 weeks
|
|
69
86
|
cohortFormat: (date) => {
|
|
70
87
|
const year = date.getUTCFullYear();
|
|
71
88
|
const week = getWeekNumber(date);
|
|
@@ -82,7 +99,7 @@ function getWeekNumber(date) {
|
|
|
82
99
|
const dayNum = d.getUTCDay() || 7;
|
|
83
100
|
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
|
84
101
|
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
85
|
-
return Math.ceil((((d - yearStart) /
|
|
102
|
+
return Math.ceil((((d - yearStart) / ONE_DAY_MS) + 1) / 7);
|
|
86
103
|
}
|
|
87
104
|
|
|
88
105
|
/**
|
|
@@ -109,16 +126,16 @@ function getExpiredCohorts(granularity, count) {
|
|
|
109
126
|
|
|
110
127
|
switch(granularity) {
|
|
111
128
|
case 'minute':
|
|
112
|
-
checkDate = new Date(now.getTime() - (i *
|
|
129
|
+
checkDate = new Date(now.getTime() - (i * ONE_MINUTE_MS));
|
|
113
130
|
break;
|
|
114
131
|
case 'hour':
|
|
115
|
-
checkDate = new Date(now.getTime() - (i *
|
|
132
|
+
checkDate = new Date(now.getTime() - (i * ONE_HOUR_MS));
|
|
116
133
|
break;
|
|
117
134
|
case 'day':
|
|
118
|
-
checkDate = new Date(now.getTime() - (i *
|
|
135
|
+
checkDate = new Date(now.getTime() - (i * ONE_DAY_MS));
|
|
119
136
|
break;
|
|
120
137
|
case 'week':
|
|
121
|
-
checkDate = new Date(now.getTime() - (i *
|
|
138
|
+
checkDate = new Date(now.getTime() - (i * ONE_WEEK_MS));
|
|
122
139
|
break;
|
|
123
140
|
}
|
|
124
141
|
|
|
@@ -340,7 +357,7 @@ export class TTLPlugin extends Plugin {
|
|
|
340
357
|
// Calculate expiration timestamp
|
|
341
358
|
const baseTimestamp = typeof baseTime === 'number' ? baseTime : new Date(baseTime).getTime();
|
|
342
359
|
const expiresAt = config.ttl
|
|
343
|
-
? new Date(baseTimestamp + config.ttl *
|
|
360
|
+
? new Date(baseTimestamp + config.ttl * SECONDS_TO_MS)
|
|
344
361
|
: new Date(baseTimestamp);
|
|
345
362
|
|
|
346
363
|
// Calculate cohort
|
|
@@ -707,5 +724,3 @@ export class TTLPlugin extends Plugin {
|
|
|
707
724
|
}
|
|
708
725
|
}
|
|
709
726
|
}
|
|
710
|
-
|
|
711
|
-
export default TTLPlugin;
|