@miniaxolotl/grove-server 1.11.23 → 1.11.28

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/migrate.js CHANGED
@@ -31,6 +31,31 @@ var dailyNotes = {
31
31
  }
32
32
  };
33
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
+
34
59
  // lib/database/src/writing-allowance-migration.ts
35
60
  var writingAllowance = {
36
61
  name: "20261107_041_writing_allowance",
@@ -2229,6 +2254,32 @@ var aiPreferences = {
2229
2254
  }
2230
2255
  };
2231
2256
 
2257
+ // lib/database/src/proofing-migration.ts
2258
+ var proofingConsents = {
2259
+ name: "20261118_044_proofing_consent",
2260
+ async up(db2) {
2261
+ await db2.raw(`CREATE TABLE proofing_consents (
2262
+ account_id uuid NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
2263
+ scope text NOT NULL CHECK(scope='grove-note-editor'),
2264
+ version integer NOT NULL CHECK(version>0),
2265
+ generation uuid NOT NULL,
2266
+ automatic boolean NOT NULL,
2267
+ updated_at timestamptz NOT NULL DEFAULT now(),
2268
+ revoked_at timestamptz,
2269
+ CHECK(revoked_at IS NULL OR NOT automatic),
2270
+ PRIMARY KEY(account_id,scope)
2271
+ );
2272
+ ALTER TABLE proofing_consents ENABLE ROW LEVEL SECURITY;
2273
+ ALTER TABLE proofing_consents FORCE ROW LEVEL SECURITY;
2274
+ CREATE POLICY tenant ON proofing_consents USING(account_id=nullif(current_setting('grove.account_id',true),'')::uuid);
2275
+ GRANT SELECT, INSERT, UPDATE ON proofing_consents TO grove_runtime;
2276
+ GRANT SELECT, DELETE ON proofing_consents TO grove_worker;`);
2277
+ },
2278
+ async down() {
2279
+ throw new Error("Use a forward migration");
2280
+ }
2281
+ };
2282
+
2232
2283
  // lib/database/src/soft-deletion.ts
2233
2284
  async function softDeletion(db2) {
2234
2285
  for (const table of [
@@ -3727,7 +3778,9 @@ var migrations = [
3727
3778
  nativeSharing,
3728
3779
  billingTrial,
3729
3780
  writingAllowance,
3730
- dailyNotes
3781
+ dailyNotes,
3782
+ cacheRetention,
3783
+ proofingConsents
3731
3784
  ];
3732
3785
  var migrationSource = {
3733
3786
  getMigrations: async () => migrations,