@miniaxolotl/grove-server 1.11.21 → 1.11.24
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/bootstrap.js +55 -1
- package/dist/bootstrap.js.map +4 -4
- package/dist/migrate.js +55 -1
- package/dist/migrate.js.map +4 -4
- package/dist/server.js +154 -18
- package/dist/server.js.map +4 -4
- package/dist/telemetry-build.json +1 -1
- package/dist/worker.js +136 -18
- package/dist/worker.js.map +4 -4
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -4,6 +4,58 @@ import { createRequire as __groveCreateRequire } from "node:module"; const requi
|
|
|
4
4
|
import knex from "knex";
|
|
5
5
|
import { Model, knexSnakeCaseMappers } from "objection";
|
|
6
6
|
|
|
7
|
+
// lib/database/src/daily-note-migration.ts
|
|
8
|
+
var dailyNotes = {
|
|
9
|
+
name: "20261117_042_daily_notes",
|
|
10
|
+
async up(db2) {
|
|
11
|
+
await db2.raw(`
|
|
12
|
+
CREATE TABLE daily_notes (
|
|
13
|
+
account_id uuid NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
|
|
14
|
+
local_date date NOT NULL,
|
|
15
|
+
memory_id uuid,
|
|
16
|
+
PRIMARY KEY (account_id, local_date),
|
|
17
|
+
UNIQUE (account_id, memory_id),
|
|
18
|
+
FOREIGN KEY (account_id, memory_id) REFERENCES memories(account_id,id)
|
|
19
|
+
ON DELETE SET NULL (memory_id)
|
|
20
|
+
);
|
|
21
|
+
ALTER TABLE daily_notes ENABLE ROW LEVEL SECURITY;
|
|
22
|
+
ALTER TABLE daily_notes FORCE ROW LEVEL SECURITY;
|
|
23
|
+
CREATE POLICY daily_notes_tenant ON daily_notes
|
|
24
|
+
USING (account_id=nullif(current_setting('grove.account_id',true),'')::uuid);
|
|
25
|
+
GRANT SELECT, INSERT ON daily_notes TO grove_runtime;
|
|
26
|
+
GRANT SELECT, DELETE ON daily_notes TO grove_worker;
|
|
27
|
+
`);
|
|
28
|
+
},
|
|
29
|
+
async down() {
|
|
30
|
+
throw new Error("Use a forward migration; retain daily note identities");
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// lib/database/src/cache-retention-migration.ts
|
|
35
|
+
var cacheRetention = {
|
|
36
|
+
name: "20261118_043_cache_retention",
|
|
37
|
+
async up(db2) {
|
|
38
|
+
const { rows } = await db2.raw(
|
|
39
|
+
"SELECT pg_get_functiondef('grove_schedule_cleanup()'::regprocedure) AS definition"
|
|
40
|
+
);
|
|
41
|
+
const definition = rows[0].definition;
|
|
42
|
+
const anchor = "OR EXISTS(SELECT 1 FROM rate_buckets r";
|
|
43
|
+
if (definition.split(anchor).length !== 2)
|
|
44
|
+
throw new Error("Unsupported retention scheduler baseline");
|
|
45
|
+
await db2.raw(
|
|
46
|
+
definition.replace(
|
|
47
|
+
anchor,
|
|
48
|
+
`OR EXISTS(SELECT 1 FROM ai_cache c WHERE c.account_id=a.id AND c.expires_at<=now())
|
|
49
|
+
OR EXISTS(SELECT 1 FROM ai_provider_backoff b WHERE b.account_id=a.id AND b.retry_at<now()-interval '1 day')
|
|
50
|
+
${anchor}`
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
async down() {
|
|
55
|
+
throw new Error("Use a forward migration");
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
7
59
|
// lib/database/src/writing-allowance-migration.ts
|
|
8
60
|
var writingAllowance = {
|
|
9
61
|
name: "20261107_041_writing_allowance",
|
|
@@ -3699,7 +3751,9 @@ var migrations = [
|
|
|
3699
3751
|
writingTools,
|
|
3700
3752
|
nativeSharing,
|
|
3701
3753
|
billingTrial,
|
|
3702
|
-
writingAllowance
|
|
3754
|
+
writingAllowance,
|
|
3755
|
+
dailyNotes,
|
|
3756
|
+
cacheRetention
|
|
3703
3757
|
];
|
|
3704
3758
|
var migrationSource = {
|
|
3705
3759
|
getMigrations: async () => migrations,
|